Merge "ASoC: msm: qdsp6v2: add support for AMR_WB_PLUS offload"
diff --git a/Documentation/devicetree/bindings/altek/al6100.txt b/Documentation/devicetree/bindings/altek/al6100.txt
new file mode 100644
index 0000000..01f6b29
--- /dev/null
+++ b/Documentation/devicetree/bindings/altek/al6100.txt
@@ -0,0 +1,65 @@
+Altek al6100 depth chip driver(spi/I2c)
+
+Description:
+
+The al6100 is a mini isp chip which is to process
+the dual IR raw images from IR camera sensor to be
+depth data. It has own firmware. It can connect to
+two IR camera sensors via internal mipi port(Rx0/Rx1).
+The input of this chip is the IR raw image from
+the two IR camera sensors. The Tx0/Tx1 on chip can
+connect to AP side and output depth data and IR images
+to AP.
+
+Required properties:
+ - compatible: Should be "altek,isp"(with spi)/
+ "altek,i2c_slave"(with i2c)/"altek,i2c_top"(with i2c)
+ for al6100 depth chip driver
+ - irq-gpios: a gpio for spi/I2c interrupt
+
+Optional properties:
+ - vcc1-gpios: If present, specifies a gpio for power on
+ al6100 depth chip
+ - wp-gpios: If present, specifies a gpio for control
+ eeprom write protected pin
+ - reset-gpios: If present, specifies a gpio for reset
+ al6100 depth chip
+
+Example:
+ (spi)
+ &spi_8 {
+ mini_isp@0 {
+ compatible = "altek,isp";
+ reg = <0>;
+ spi-max-frequency = <50000000>;
+ spi-cpol;
+ spi-cpha;
+ vcc-supply = <&pm8953_s3>;
+ reset-gpios = <&tlmm 33 0x00>;
+ irq-gpios = <&tlmm 35 0x00>;
+ vcc1-gpios = <&tlmm 38 0x00>;
+ wp-gpios = <&tlmm 52 0x00>;
+ vcc2-gpios = <&tlmm 63 0x00>;
+ status = "ok";
+ };
+ };
+
+ (I2c)
+ i2c_slave@11 {
+ compatible = "altek,i2c_slave";
+ reg = <0x4b>; /* for Pure Bypass */
+ reg = <0x11>;
+ status = "disabled"; /* use SPI instead */
+ };
+
+ i2c_top@77 {
+ compatible = "altek,i2c_top";
+ reg = <0x77>;
+ vcc-supply = <&pm8953_s3>;
+ reset-gpios = <&tlmm 33 0x00>;
+ irq-gpios = <&tlmm 35 0x00>;
+ vcc1-gpios = <&tlmm 38 0x00>;
+ wp-gpios = <&tlmm 52 0x00>;
+ vcc2-gpios = <&tlmm 63 0x00>;
+ status = "disabled"; /* use SPI instead */
+ };
diff --git a/arch/arm/boot/dts/qcom/sa415m-ccard.dtsi b/arch/arm/boot/dts/qcom/sa415m-ccard.dtsi
index d2e597d..42676f0 100644
--- a/arch/arm/boot/dts/qcom/sa415m-ccard.dtsi
+++ b/arch/arm/boot/dts/qcom/sa415m-ccard.dtsi
@@ -151,6 +151,7 @@
/delete-property/ vreg_rgmii-supply;
pinctrl-names = "default";
pinctrl-0 = <&vreg_rgmii_off_default>;
+ qcom,phy-reset-delay-msecs = <10>;
};
&vreg_rgmii_io_pads {
diff --git a/arch/arm/configs/sdxpoorwills-auto-perf_defconfig b/arch/arm/configs/sa415m-perf_defconfig
similarity index 99%
rename from arch/arm/configs/sdxpoorwills-auto-perf_defconfig
rename to arch/arm/configs/sa415m-perf_defconfig
index b04fd97..a517020 100644
--- a/arch/arm/configs/sdxpoorwills-auto-perf_defconfig
+++ b/arch/arm/configs/sa415m-perf_defconfig
@@ -372,6 +372,7 @@
CONFIG_IOMMU_TESTS=y
CONFIG_QCOM_SCM=y
CONFIG_MSM_BOOT_STATS=y
+CONFIG_MSM_BOOT_TIME_MARKER=y
CONFIG_QCOM_WATCHDOG_V2=y
CONFIG_QCOM_MEMORY_DUMP_V2=y
CONFIG_QCOM_BUS_SCALING=y
diff --git a/arch/arm/configs/sdxpoorwills-auto_defconfig b/arch/arm/configs/sa415m_defconfig
similarity index 99%
rename from arch/arm/configs/sdxpoorwills-auto_defconfig
rename to arch/arm/configs/sa415m_defconfig
index 3d0cca3..e10d4ef 100644
--- a/arch/arm/configs/sdxpoorwills-auto_defconfig
+++ b/arch/arm/configs/sa415m_defconfig
@@ -402,6 +402,7 @@
CONFIG_IOMMU_TESTS=y
CONFIG_QCOM_SCM=y
CONFIG_MSM_BOOT_STATS=y
+CONFIG_MSM_BOOT_TIME_MARKER=y
CONFIG_QCOM_WATCHDOG_V2=y
CONFIG_QCOM_MEMORY_DUMP_V2=y
CONFIG_QCOM_BUS_SCALING=y
diff --git a/arch/arm64/boot/dts/qcom/Makefile b/arch/arm64/boot/dts/qcom/Makefile
index b0c6499..5157889 100644
--- a/arch/arm64/boot/dts/qcom/Makefile
+++ b/arch/arm64/boot/dts/qcom/Makefile
@@ -393,7 +393,9 @@
dtbo-$(CONFIG_ARCH_SDM429) += sdm429-mtp-overlay.dtbo \
sdm429-cdp-overlay.dtbo \
sdm429-qrd-overlay.dtbo \
- sdm429-qrd-spyro-evt-overlay.dtbo
+ sdm429-spyro-qrd-evt-overlay.dtbo \
+ sdm429-spyro-qrd-dvt-overlay.dtbo \
+ sdm429-spyro-qrd-wdp-overlay.dtbo
msm8940-mtp-overlay.dtbo-base := msm8940-pmi8950.dtb \
msm8940-pmi8937.dtb \
@@ -512,8 +514,9 @@
msm8937-interposer-sdm429.dtb
sdm429-qrd-overlay.dtbo-base := sdm429.dtb \
msm8937-interposer-sdm429.dtb
-sdm429-qrd-spyro-evt-overlay.dtbo-base := sdm429.dtb \
- msm8937-interposer-sdm429.dtb
+sdm429-spyro-qrd-evt-overlay.dtbo-base := sdm429-spyro.dtb
+sdm429-spyro-qrd-dvt-overlay.dtbo-base := sdm429-spyro-dvt.dtb
+sdm429-spyro-qrd-wdp-overlay.dtbo-base := sdm429-spyro-wdp.dtb
else
dtb-$(CONFIG_ARCH_MSM8953) += msm8953-cdp.dtb \
msm8953-mtp.dtb \
@@ -644,7 +647,10 @@
sdm429-cdp.dtb \
sdm429-qrd.dtb \
sda429-mtp.dtb \
- sda429-cdp.dtb
+ sda429-cdp.dtb \
+ sdm429-spyro.dtb \
+ sdm429-spyro-dvt.dtb \
+ sdm429-spyro-wdp.dtb
endif
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro-dvt.dts b/arch/arm64/boot/dts/qcom/sdm429-spyro-dvt.dts
new file mode 100644
index 0000000..385ae4f
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro-dvt.dts
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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 "sdm429-spyro.dtsi"
+
+/ {
+ model = "Qualcomm Technologies, Inc. SDM429 QRD DVT Spyro";
+ compatible = "qcom,sdm429w-qrd", "qcom,sdm429w", "qcom,qrd";
+ qcom,msm-id = <416 0x0>;
+ qcom,board-id = <0x00010b 6>;
+ qcom,pmic-id = <0x0002001b 0x0 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-dvt-overlay.dts b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-dvt-overlay.dts
new file mode 100644
index 0000000..98b42ee
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-dvt-overlay.dts
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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/;
+/plugin/;
+
+#include "sdm429-spyro-qrd-evt.dtsi"
+
+/ {
+ model = "Qualcomm Technologies, Inc. SDM429 QRD Spyro DVT Overlay";
+ compatible = "qcom,sdm429w-qrd", "qcom,sdm429w", "qcom,qrd";
+ qcom,msm-id = <416 0x0>;
+ qcom,board-id = <0x00010b 6>;
+ qcom,pmic-id = <0x0002001b 0x0 0x0 0x0>;
+};
+
+&usb_otg {
+ HSUSB_3p3-supply = <&L16A>;
+};
+
+&msm_dig_codec {
+ cdc-vdd-digital-supply = <&pm660_l11>;
+};
+
+&ext_smart_pa {
+ dvdd-supply = <&pm660_l11>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt-audio.dtsi b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt-audio.dtsi
new file mode 100644
index 0000000..0c61f71
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt-audio.dtsi
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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_codec {
+ compatible = "qcom,msm8952-dig-asoc-snd";
+ status = "okay";
+ qcom,model = "sdm429-qrd-snd-card";
+ qcom,msm-ext-pa = "quaternary";
+ /delete-property/ qcom,split-a2dp;
+ asoc-wsa-codec-names;
+ asoc-wsa-codec-prefixes;
+ ext_pa_aw8896;
+ qcom,audio-routing =
+ "CDC_CONN", "MCLK",
+ "QUAT_MI2S_RX", "DIGITAL_REGULATOR",
+ "TX_I2S_CLK", "DIGITAL_REGULATOR",
+ "DMIC1", "Digital Mic1",
+ "DMIC2", "Digital Mic2";
+ qcom,cdc-dmic-gpios = <&cdc_dmic_gpios>;
+ qcom,quat-mi2s-gpios = <&cdc_quat_mi2s_gpios>;
+ qcom,msm-gpios =
+ "quat_i2s",
+ "dmic";
+ qcom,pinctrl-names =
+ "all_off",
+ "quat_i2s_act",
+ "dmic_act",
+ "quat_i2s_dmic_act";
+ pinctrl-names =
+ "all_off",
+ "quat_i2s_act",
+ "dmic_act",
+ "quat_i2s_dmic_act";
+ pinctrl-0 = <&quat_mi2s_sleep &quat_mi2s_din_sleep
+ &cdc_dmic0_clk_sus &cdc_dmic0_data_sus>;
+ pinctrl-1 = <&quat_mi2s_active &quat_mi2s_din_active
+ &cdc_dmic0_clk_sus &cdc_dmic0_data_sus>;
+ pinctrl-2 = <&quat_mi2s_sleep &quat_mi2s_din_sleep
+ &cdc_dmic0_clk_act &cdc_dmic0_data_act>;
+ pinctrl-3 = <&quat_mi2s_active &quat_mi2s_din_active
+ &cdc_dmic0_clk_act &cdc_dmic0_data_act>;
+ /delete-property/qcom,cdc-us-euro-gpios;
+ /delete-property/qcom,pri-mi2s-gpios;
+ /delete-property/qcom,cdc-us-eu-gpios;
+
+ asoc-codec = <&stub_codec>, <&msm_dig_codec>, <&ext_smart_pa>;
+ asoc-codec-names = "msm-stub-codec.1", "msm-dig-codec", "ext-smart-pa";
+};
+
+&soc {
+ msm_dig_codec: msm_dig_codec {
+ compatible = "qcom,msm-digital-codec";
+ reg = <0xc0f0000 0x0>;
+ qcom,no-analog-codec;
+ cdc-vdd-digital-supply = <&pm660_l9>;
+ qcom,cdc-vdd-digital-voltage = <1800000 1800000>;
+ qcom,cdc-vdd-digital-current = <10000>;
+ qcom,cdc-on-demand-supplies = "cdc-vdd-digital";
+ };
+
+ cdc_dmic_gpios: cdc_dmic_pinctrl {
+ compatible = "qcom,msm-cdc-pinctrl";
+ pinctrl-names = "aud_active", "aud_sleep";
+ pinctrl-0 = <&cdc_dmic0_clk_act &cdc_dmic0_data_act>;
+ pinctrl-1 = <&cdc_dmic0_clk_sus &cdc_dmic0_data_sus>;
+ };
+
+ cdc_quat_mi2s_gpios: msm_cdc_pinctrl_quat {
+ compatible = "qcom,msm-cdc-pinctrl";
+ pinctrl-names = "aud_active", "aud_sleep";
+ pinctrl-0 = <&quat_mi2s_active &quat_mi2s_din_active>;
+ pinctrl-1 = <&quat_mi2s_sleep &quat_mi2s_din_sleep>;
+ };
+};
+
+&tlmm {
+ smart_pa_int {
+ pa_int_default: pa_int_default {
+ mux {
+ pins = "gpio73", "gpio73";
+ function = "gpio";
+ };
+
+ config {
+ pins = "gpio73", "gpio73";
+ drive-strength = <4>;
+ bias-disable;
+ };
+ };
+ };
+
+ smart_pa_rst {
+ pa_rst_default: pa_rst_default {
+ mux {
+ pins = "gpio68", "gpio68";
+ function = "gpio";
+ };
+
+ config {
+ pins = "gpio68", "gpio68";
+ drive-strength = <4>;
+ bias-disable;
+ };
+ };
+ };
+};
+
+&wsa881x_i2c_f {
+ status = "disabled";
+};
+
+&wsa881x_i2c_45 {
+ status = "disabled";
+};
+
+&wsa881x_analog_vi_gpio {
+ status = "disabled";
+};
+
+&wsa881x_analog_clk_gpio {
+ status = "disabled";
+};
+
+&wsa881x_analog_reset_gpio {
+ status = "disabled";
+};
+
+&cdc_us_euro_sw {
+ status = "disabled";
+};
+
+&cdc_pri_mi2s_gpios {
+ status = "disabled";
+};
+
+&cdc_quin_mi2s_gpios {
+ status = "disabled";
+};
+
+&i2c_2 {
+ ext_smart_pa: aw8896_smartpa@34 {
+ status = "okay";
+ compatible = "awinic,aw8896_smartpa";
+ reg = <0x34>;
+ reset-gpio = <&tlmm 68 0>;
+ irq-gpio = <&tlmm 73 0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pa_int_default &pa_rst_default>;
+ dvdd-supply = <&pm660_l9>;
+ dvdd-voltage = <1800000 1800000>;
+ dvdd-current = <15000>;
+ };
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt-camera.dtsi b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt-camera.dtsi
new file mode 100644
index 0000000..5c15948
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt-camera.dtsi
@@ -0,0 +1,417 @@
+/*
+ * Copyright (c) 2019 The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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 <dt-bindings/clock/msm-clocks-8952.h>
+
+&cam_sensor_rear_standby {
+ /* STANDBY */
+ mux {
+ /delete-property/ pins;
+ pins = "gpio92";
+ function = "gpio";
+ };
+
+ config {
+ /delete-property/ pins;
+ pins = "gpio92";
+ bias-disable; /* No PULL */
+ drive-strength = <2>; /* 2 MA */
+ };
+};
+
+&cam_sensor_rear_standby_sleep {
+ /* STANDBY */
+ mux {
+ /delete-property/ pins;
+ pins = "gpio92";
+ function = "gpio";
+ };
+
+ config {
+ /delete-property/ pins;
+ pins = "gpio92";
+ bias-disable; /* No PULL */
+ drive-strength = <2>; /* 2 MA */
+ };
+};
+
+&cam_sensor_rear_vana {
+ /* VANA */
+ mux {
+ /delete-property/ pins;
+ pins = "gpio58";
+ function = "gpio";
+ };
+
+ config {
+ /delete-property/ pins;
+ pins = "gpio58";
+ bias-disable; /* No PULL */
+ drive-strength = <2>; /* 2 MA */
+ };
+};
+
+&cam_sensor_rear_vana_sleep {
+ /* VANA */
+ mux {
+ /delete-property/ pins;
+ pins = "gpio58";
+ function = "gpio";
+ };
+
+ config {
+ /delete-property/ pins;
+ pins = "gpio58";
+ bias-disable; /* No PULL */
+ drive-strength = <2>; /* 2 MA */
+ };
+};
+
+&soc {
+ /delete-node/ qcom,cci@1b0c000;
+ cci: qcom,cci@1b0c000 {
+ status = "ok";
+ cell-index = <0>;
+ compatible = "qcom,cci";
+ reg = <0x1b0c000 0x4000>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg-names = "cci";
+ interrupts = <0 50 0>;
+ interrupt-names = "cci";
+ clocks = <&clock_gcc clk_gcc_camss_ispif_ahb_clk>,
+ <&clock_gcc clk_cci_clk_src>,
+ <&clock_gcc clk_gcc_camss_cci_ahb_clk>,
+ <&clock_gcc clk_gcc_camss_cci_clk>,
+ <&clock_gcc clk_gcc_camss_ahb_clk>,
+ <&clock_gcc clk_gcc_camss_top_ahb_clk>;
+ clock-names = "ispif_ahb_clk", "cci_src_clk",
+ "cci_ahb_clk", "camss_cci_clk",
+ "camss_ahb_clk", "camss_top_ahb_clk";
+ qcom,clock-rates = <61540000 19200000 0 0 0 0>,
+ <61540000 37500000 0 0 0 0>;
+ pinctrl-names = "cci_default", "cci_suspend";
+ pinctrl-0 = <&cci0_active &cci1_active>;
+ pinctrl-1 = <&cci0_suspend &cci1_suspend>;
+ gpios = <&tlmm 29 0>,
+ <&tlmm 30 0>,
+ <&tlmm 31 0>,
+ <&tlmm 32 0>;
+ qcom,gpio-tbl-num = <0 1 2 3>;
+ qcom,gpio-tbl-flags = <1 1 1 1>;
+ qcom,gpio-tbl-label = "CCI_I2C_DATA0",
+ "CCI_I2C_CLK0",
+ "CCI_I2C_DATA1",
+ "CCI_I2C_CLK1";
+ i2c_freq_100Khz: qcom,i2c_standard_mode {
+ status = "disabled";
+ };
+ i2c_freq_400Khz: qcom,i2c_fast_mode {
+ status = "disabled";
+ };
+ i2c_freq_custom: qcom,i2c_custom_mode {
+ status = "disabled";
+ };
+
+ i2c_freq_1Mhz: qcom,i2c_fast_plus_mode {
+ status = "disabled";
+ };
+ };
+};
+
+&cci {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ actuator_spyro0: qcom,actuator@0 {
+ cell-index = <0>;
+ reg = <0x0>;
+ compatible = "qcom,actuator";
+ qcom,cci-master = <0>;
+ cam_vaf-supply = <&pm660_l19>;
+ qcom,cam-vreg-name = "cam_vaf";
+ qcom,cam-vreg-min-voltage = <2850000>;
+ qcom,cam-vreg-max-voltage = <3200000>;
+ qcom,cam-vreg-op-mode = <80000>;
+ };
+
+ actuator_spyro1: qcom,actuator@1 {
+ cell-index = <1>;
+ reg = <0x1>;
+ compatible = "qcom,actuator";
+ qcom,cci-master = <0>;
+ cam_vaf-supply = <&pm660_l19>;
+ qcom,cam-vreg-name = "cam_vaf";
+ qcom,cam-vreg-min-voltage = <2850000>;
+ qcom,cam-vreg-max-voltage = <3200000>;
+ qcom,cam-vreg-op-mode = <80000>;
+ };
+
+ eeprom_spyro0: qcom,eeprom@0 {
+ cell-index = <0>;
+ compatible = "qcom,eeprom";
+ qcom,cci-master = <0>;
+ reg = <0x0>;
+ cam_vana-supply = <&pm660_l6>;
+ cam_vio-supply = <&pm660_l14>;
+ cam_vaf-supply = <&pm660_l19>;
+ cam_vdig-supply = <&pm660_l2>;
+ qcom,cam-vreg-name = "cam_vana", "cam_vio",
+ "cam_vdig", "cam_vaf";
+ qcom,cam-vreg-min-voltage = <2800000 1800000 1050000 2850000>;
+ qcom,cam-vreg-max-voltage = <2800000 1800000 1050000 3200000>;
+ qcom,cam-vreg-op-mode = <80000 0 200000 100000>;
+ pinctrl-names = "cam_default", "cam_suspend";
+ pinctrl-0 = <&cam_sensor_mclk0_default
+ &cam_sensor_rear_reset
+ &cam_sensor_rear_vana
+ &cam_sensor_rear_standby>;
+ pinctrl-1 = <&cam_sensor_mclk0_sleep
+ &cam_sensor_rear_reset_sleep
+ &cam_sensor_rear_vana_sleep
+ &cam_sensor_rear_standby_sleep>;
+ gpios = <&tlmm 26 0>,
+ <&tlmm 36 0>,
+ <&tlmm 58 0>,
+ <&tlmm 92 0>;
+ qcom,gpio-reset = <1>;
+ qcom,gpio-vana = <2>;
+ qcom,gpio-standby = <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_MCLK0",
+ "CAM_RESET0",
+ "CAM_VANA",
+ "CAM_STANDBY";
+ status = "ok";
+ clocks = <&clock_gcc clk_mclk0_clk_src>,
+ <&clock_gcc clk_gcc_camss_mclk0_clk>;
+ clock-names = "cam_src_clk", "cam_clk";
+ qcom,clock-rates = <19200000 0>;
+ };
+
+ eeprom_spyro1: qcom,eeprom@1 {
+ cell-index = <1>;
+ reg = <0x1>;
+ qcom,eeprom-name = "sunny_8865";
+ compatible = "qcom,eeprom";
+ qcom,slave-addr = <0x6c>;
+ qcom,cci-master = <0>;
+ qcom,num-blocks = <8>;
+
+ qcom,page0 = <1 0x0100 2 0x01 1 1>;
+ qcom,poll0 = <0 0x0 2 0x0 1 0>;
+ qcom,mem0 = <0 0x0 2 0x0 1 0>;
+
+ qcom,page1 = <1 0x5002 2 0x00 1 0>;
+ qcom,poll1 = <0 0x0 2 0x0 1 0>;
+ qcom,mem1 = <0 0x0 2 0x0 1 0>;
+
+ qcom,page2 = <1 0x3d84 2 0xc0 1 0>;
+ qcom,poll2 = <0 0x0 2 0x0 1 0>;
+ qcom,mem2 = <0 0x0 2 0x0 1 0>;
+
+ qcom,page3 = <1 0x3d88 2 0x70 1 0>;
+ qcom,poll3 = <0 0x0 2 0x0 1 0>;
+ qcom,mem3 = <0 0x0 2 0x0 1 0>;
+
+ qcom,page4 = <1 0x3d89 2 0x10 1 0>;
+ qcom,poll4 = <0 0x0 2 0x0 1 0>;
+ qcom,mem4 = <0 0x0 2 0x0 1 0>;
+
+ qcom,page5 = <1 0x3d8a 2 0x70 1 0>;
+ qcom,poll5 = <0 0x0 2 0x0 1 0>;
+ qcom,mem5 = <0 0x0 2 0x0 1 0>;
+
+ qcom,page6 = <1 0x3d8b 2 0xf4 1 0>;
+ qcom,poll6 = <0 0x0 2 0x0 1 0>;
+ qcom,mem6 = <0 0x0 2 0x0 1 0>;
+
+ qcom,page7 = <1 0x3d81 2 0x01 1 10>;
+ qcom,poll7 = <0 0x0 2 0x0 1 1>;
+ qcom,mem7 = <1536 0x7010 2 0 1 0>;
+
+ cam_vdig-supply = <&pm660_l3>;
+ cam_vana-supply = <&pm660_l7>;
+ cam_vio-supply = <&pm660_l6>;
+ cam_vaf-supply = <&pm660_l17>;
+ qcom,cam-vreg-name = "cam_vdig", "cam_vio",
+ "cam_vana", "cam_vaf";
+ qcom,cam-vreg-min-voltage = <1200000 0 2800000 2850000>;
+ qcom,cam-vreg-max-voltage = <1200000 0 2800000 3200000>;
+ qcom,cam-vreg-op-mode = <105000 0 80000 100000>;
+ qcom,gpio-no-mux = <0>;
+ pinctrl-names = "cam_default", "cam_suspend";
+ pinctrl-0 = <&cam_sensor_mclk2_default
+ &cam_sensor_front1_default>;
+ pinctrl-1 = <&cam_sensor_mclk2_sleep
+ &cam_sensor_front1_sleep>;
+ gpios = <&tlmm 28 0>,
+ <&tlmm 40 0>,
+ <&tlmm 39 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_MCLK2",
+ "CAM_RESET2",
+ "CAM_STANDBY2";
+ qcom,cam-power-seq-type = "sensor_vreg", "sensor_vreg",
+ "sensor_vreg",
+ "sensor_gpio", "sensor_gpio" , "sensor_clk";
+ qcom,cam-power-seq-val = "cam_vdig", "cam_vana", "cam_vio",
+ "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 1 30 30 5>;
+ status = "disabled";
+ clocks = <&clock_gcc clk_mclk2_clk_src>,
+ <&clock_gcc clk_gcc_camss_mclk2_clk>;
+ clock-names = "cam_src_clk", "cam_clk";
+ qcom,clock-rates = <19200000 0>;
+ };
+
+ qcom,camera@0 {
+ cell-index = <0>;
+ compatible = "qcom,camera";
+ reg = <0x0>;
+ qcom,csiphy-sd-index = <0>;
+ qcom,csid-sd-index = <0>;
+ qcom,mount-angle = <90>;
+ qcom,eeprom-src = <&eeprom_spyro0>;
+ qcom,actuator-src = <&actuator_spyro0>;
+ cam_vio-supply = <&pm660_l14>;
+ cam_vaf-supply = <&L19A>;
+ cam_vdig-supply = <&pm660_l2>;
+ qcom,cam-vreg-name = "cam_vana", "cam_vio",
+ "cam_vdig", "cam_vaf";
+ qcom,cam-vreg-min-voltage = <2800000 1800000 1050000 2850000>;
+ qcom,cam-vreg-max-voltage = <2800000 1800000 1050000 3200000>;
+ qcom,cam-vreg-op-mode = <80000 0 200000 100000>;
+ pinctrl-names = "cam_default", "cam_suspend";
+ pinctrl-0 = <&cam_sensor_mclk0_default
+ &cam_sensor_rear_reset
+ &cam_sensor_rear_vana
+ &cam_sensor_rear_standby>;
+ pinctrl-1 = <&cam_sensor_mclk0_sleep
+ &cam_sensor_rear_reset_sleep
+ &cam_sensor_rear_vana_sleep
+ &cam_sensor_rear_standby_sleep>;
+ gpios = <&tlmm 26 0>,
+ <&tlmm 36 0>,
+ <&tlmm 58 0>,
+ <&tlmm 92 0>;
+ qcom,gpio-reset = <1>;
+ qcom,gpio-vana = <2>;
+ qcom,gpio-standby = <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_MCLK0",
+ "CAM_RESET0",
+ "CAM_VANA",
+ "CAM_STANDBY";
+ qcom,sensor-position = <0>;
+ qcom,sensor-mode = <0>;
+ qcom,cci-master = <0>;
+ status = "ok";
+ clocks = <&clock_gcc clk_mclk0_clk_src>,
+ <&clock_gcc clk_gcc_camss_mclk0_clk>;
+ clock-names = "cam_src_clk", "cam_clk";
+ qcom,clock-rates = <24000000 0>;
+ };
+
+ qcom,camera@1 {
+ cell-index = <1>;
+ compatible = "qcom,camera";
+ reg = <0x1>;
+ qcom,csiphy-sd-index = <1>;
+ qcom,csid-sd-index = <1>;
+ qcom,mount-angle = <270>;
+ cam_vdig-supply = <&pm660_l3>;
+ cam_vio-supply = <&pm660_l14>;
+ cam_vana-supply = <&pm660_s5>;
+ qcom,cam-vreg-name = "cam_vdig", "cam_vio", "cam_vana";
+ qcom,cam-vreg-min-voltage = <1200000 1800000 1420000>;
+ qcom,cam-vreg-max-voltage = <1200000 1800000 1420000>;
+ qcom,cam-vreg-op-mode = <200000 80000 80000>;
+ pinctrl-names = "cam_default", "cam_suspend";
+ pinctrl-0 = <&cam_sensor_mclk1_default
+ &cam_sensor_front_default>;
+ pinctrl-1 = <&cam_sensor_mclk1_sleep
+ &cam_sensor_front_sleep>;
+ gpios = <&tlmm 27 0>,
+ <&tlmm 33 0>,
+ <&tlmm 66 0>,
+ <&tlmm 38 0>;
+ qcom,gpio-vana= <1>;
+ qcom,gpio-vdig= <2>;
+ qcom,gpio-reset = <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_MCLK1",
+ "CAM_AVDD1",
+ "CAM_DVDD1",
+ "CAM_RESET1";
+ qcom,sensor-position = <0x1>;
+ qcom,sensor-mode = <0>;
+ qcom,cci-master = <1>;
+ clocks = <&clock_gcc clk_mclk1_clk_src>,
+ <&clock_gcc clk_gcc_camss_mclk1_clk>;
+ clock-names = "cam_src_clk", "cam_clk";
+ qcom,clock-rates = <24000000 0>;
+ };
+
+ qcom,camera@2 {
+ cell-index = <2>;
+ compatible = "qcom,camera";
+ reg = <0x02>;
+ qcom,csiphy-sd-index = <1>;
+ qcom,csid-sd-index = <1>;
+ qcom,mount-angle = <270>;
+ qcom,eeprom-src = <&eeprom_spyro1>;
+ qcom,actuator-src = <&actuator_spyro1>;
+ cam_vdig-supply = <&pm660_l3>;
+ cam_vana-supply = <&pm660_l7>;
+ cam_vio-supply = <&pm660_l6>;
+ cam_vaf-supply = <&pm660_l19>;
+ qcom,cam-vreg-name = "cam_vdig", "cam_vio", "cam_vana",
+ "cam_vaf";
+ qcom,cam-vreg-min-voltage = <1200000 0 2800000 2850000>;
+ qcom,cam-vreg-max-voltage = <1200000 0 2800000 3200000>;
+ qcom,cam-vreg-op-mode = <105000 0 80000 100000>;
+ qcom,gpio-no-mux = <0>;
+ pinctrl-names = "cam_default", "cam_suspend";
+ pinctrl-0 = <&cam_sensor_mclk2_default
+ &cam_sensor_front1_default>;
+ pinctrl-1 = <&cam_sensor_mclk2_sleep
+ &cam_sensor_front1_sleep>;
+ gpios = <&tlmm 27 0>,
+ <&tlmm 38 0>,
+ <&tlmm 39 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_MCLK2",
+ "CAM_RESET2",
+ "CAM_STANDBY2";
+ qcom,sensor-position = <1>;
+ qcom,sensor-mode = <0>;
+ qcom,cci-master = <0>;
+ status = "disabled";
+ clocks = <&clock_gcc clk_mclk2_clk_src>,
+ <&clock_gcc clk_gcc_camss_mclk2_clk>;
+ clock-names = "cam_src_clk", "cam_clk";
+ qcom,clock-rates = <24000000 0>;
+ };
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt-overlay.dts b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt-overlay.dts
new file mode 100644
index 0000000..f33fd0e
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt-overlay.dts
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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/;
+/plugin/;
+
+#include "sdm429-spyro-qrd-evt.dtsi"
+
+/ {
+ model = "Qualcomm Technologies, Inc. SDM429 QRD Spyro Overlay";
+ qcom,board-id = <0xb 6>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt.dtsi b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt.dtsi
new file mode 100644
index 0000000..dda1f84
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-evt.dtsi
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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 "sdm429-spyro-qrd-mdss-panels.dtsi"
+#include "sdm429-spyro-qrd-evt-camera.dtsi"
+#include "sdm429-spyro-qrd-evt-audio.dtsi"
+
+&gpio_key_active {
+ mux {
+ pins = "gpio91", "gpio127", "gpio128", "gpio35", "gpio126";
+ function = "gpio";
+ };
+
+ config {
+ pins = "gpio91", "gpio127", "gpio128", "gpio35", "gpio126";
+ drive-strength = <2>;
+ bias-pull-up;
+ };
+};
+
+&gpio_key_suspend {
+ mux {
+ pins = "gpio91", "gpio127", "gpio128", "gpio35", "gpio126";
+ function = "gpio";
+ };
+
+ config {
+ pins = "gpio91", "gpio127", "gpio128", "gpio35", "gpio126";
+ drive-strength = <2>;
+ bias-pull-up;
+ };
+};
+
+&soc {
+ gpio_keys: gpio_keys {
+ compatible = "gpio-keys";
+ label = "gpio-keys";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio_key_active>;
+ pinctrl-1 = <&gpio_key_suspend>;
+
+ vol_up: vol_up {
+ label = "volume_up";
+ gpios = <&tlmm 35 0x1>;
+ linux,input-type = <1>;
+ linux,code = <115>;
+ debounce-interval = <15>;
+ linux,can-disable;
+ gpio-key,wakeup;
+ };
+
+ function_1: function_1 {
+ label = "function_1";
+ gpios = <&tlmm 127 0x1>;
+ linux,input-type = <1>;
+ linux,code = <116>;
+ debounce-interval = <15>;
+ linux,can-disable;
+ gpio-key,wakeup;
+ };
+
+ function_2: function_2 {
+ label = "function_2";
+ gpios = <&tlmm 126 0x1>;
+ linux,input-type = <1>;
+ linux,code = <117>;
+ debounce-interval = <15>;
+ linux,can-disable;
+ gpio-key,wakeup;
+ };
+ };
+};
+
+&blsp1_uart2 {
+ status = "ok";
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart_console_active>;
+};
+
+&sdhc_1 {
+ /* device core power supply */
+ vdd-supply = <&L19A>;
+ qcom,vdd-voltage-level = <2900000 3200000>;
+ qcom,vdd-current-level = <200 570000>;
+
+ /* device communication power supply */
+ vdd-io-supply = <&L13A>;
+ qcom,vdd-io-always-on;
+ qcom,vdd-io-lpm-sup;
+ qcom,vdd-io-voltage-level = <1800000 1800000>;
+ qcom,vdd-io-current-level = <0 60000>;
+
+ pinctrl-names = "active", "sleep";
+ pinctrl-0 = <&sdc1_clk_on &sdc1_cmd_on &sdc1_data_on &sdc1_rclk_on>;
+ pinctrl-1 = <&sdc1_clk_off &sdc1_cmd_off &sdc1_data_off &sdc1_rclk_off>;
+
+ qcom,clk-rates = <400000 20000000 25000000 50000000 100000000 192000000
+ 384000000>;
+ qcom,nonremovable;
+ qcom,bus-speed-mode = "HS400_1p8v", "HS200_1p8v", "DDR_1p8v";
+
+ status = "ok";
+};
+
+&sdhc_2 {
+ /* device core power supply for sd card*/
+ vdd-supply = <&vreg_sd_vdd>;
+ qcom,vdd-voltage-level = <2950000 2950000>;
+ qcom,vdd-current-level = <15000 800000>;
+
+ /* device communication power supply for msm_io*/
+ vdd-io-supply = <&vreg_sd_pad>;
+ qcom,vdd-io-voltage-level = <1800000 2950000>;
+ qcom,vdd-io-current-level = <200 22000>;
+
+ pinctrl-names = "active", "sleep";
+ pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on &sdc2_cd_on>;
+ pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off>;
+
+ cd-gpios = <&tlmm 67 0x0>;
+
+ qcom,clk-rates = <400000 20000000 25000000 50000000 100000000
+ 200000000>;
+
+ qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";
+
+ status = "ok";
+};
+
+&firmware {
+ android {
+ compatible = "android,firmware";
+ vbmeta {
+ compatible = "android,vbmeta";
+ parts = "vbmeta,boot,system,vendor,dtbo,recovery";
+ };
+ fstab {
+ compatible = "android,fstab";
+ vendor {
+ compatible = "android,vendor";
+ dev =
+ "/dev/block/platform/soc/7824900.sdhci/by-name/vendor";
+ type = "ext4";
+ mnt_flags = "ro,barrier=1,discard";
+ fsmgr_flags = "wait,avb";
+ status = "ok";
+ };
+ system {
+ compatible = "android,system";
+ dev =
+ "/dev/block/platform/soc/7824900.sdhci/by-name/system";
+ type = "ext4";
+ mnt_flags = "ro,barrier=1,discard";
+ fsmgr_flags = "wait,avb";
+ status = "ok";
+ };
+ };
+ };
+};
+
+&modem_mem {
+ reg = <0x0 0x86800000 0x0 0x5000000>;
+};
+
+&adsp_fw_mem {
+ reg = <0x0 0x8b800000 0x0 0x1400000>;
+};
+
+&wcnss_fw_mem {
+ reg = <0x0 0x8cc00000 0x0 0x700000>;
+};
+
+&i2c_4 {
+ status = "ok";
+
+ tsc@24 {
+ compatible = "cy,cyttsp5_i2c_adapter";
+ reg = <0x24>;
+
+ interrupt-parent = <&tlmm>;
+ interrupts = <65 0x2008>;
+ cy,adapter_id = "cyttsp5_i2c_adapter";
+ vcc_i2c-supply = <&L13A>;
+ vdd-supply = <&L15A>;
+ pinctrl-names = "pmx_ts_active", "pmx_ts_suspend",
+ "pmx_ts_release";
+ pinctrl-0 = <&ts_int_active &ts_reset_active>;
+ pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;
+ pinctrl-2 = <&ts_release>;
+
+ cy,core {
+ cy,name = "cyttsp5_core";
+ cy,irq_gpio = <65>;
+ cy,rst_gpio = <64>;
+ cy,hid_desc_register = <1>;
+ cy,flags = <4>;
+ cy,easy_wakeup_gesture = <1>;
+ cy,btn_keys = <172 139 158 217 114 115 212 116>;
+ cy,btn_keys-tag = <0>;
+
+ cy,mt {
+ cy,name = "cyttsp5_mt";
+
+ cy,inp_dev_name = "cyttsp5_mt";
+ cy,flags = <0x28>;
+ cy,abs =
+ <0x35 0 320 0 0
+ 0x36 0 360 0 0
+ 0x3a 0 255 0 0
+ 0xffff 0 255 0 0
+ 0x39 0 15 0 0
+ 0x30 0 255 0 0
+ 0x31 0 255 0 0
+ 0x34 0xffffff81 127 0 0
+ 0x37 0 1 0 0
+ 0x3b 0 255 0 0>;
+
+ cy,vkeys_x = <320>;
+ cy,vkeys_y = <360>;
+
+ cy,virtual_keys =
+ <158 1360 90 160 180
+ 139 1360 270 160 180
+ 172 1360 450 160 180
+ 217 1360 630 160 180>;
+ };
+
+ cy,btn {
+ cy,name = "cyttsp5_btn";
+
+ cy,inp_dev_name = "cyttsp5_btn";
+ };
+
+ cy,proximity {
+ cy,name = "cyttsp5_proximity";
+
+ cy,inp_dev_name = "cyttsp5_proximity";
+ cy,abs = <0x19 0 1 0 0>;
+ };
+ };
+ };
+
+};
+
+&pm660_gpios {
+ nfc_clk {
+ nfc_clk_default: nfc_clk_default {
+ pins = "gpio4";
+ function = "normal";
+ input-enable;
+ power-source = <1>;
+ };
+ };
+};
+
+&i2c_5 { /* BLSP2 QUP1 (NFC) */
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ status = "ok";
+ nq@28 {
+ compatible = "qcom,nq-nci";
+ reg = <0x28>;
+ qcom,nq-irq = <&tlmm 17 0x00>;
+ qcom,nq-ven = <&tlmm 16 0x00>;
+ qcom,nq-firm = <&tlmm 130 0x00>;
+ qcom,nq-clkreq = <&pm660_gpios 4 0x00>;
+ qcom,nq-esepwr = <&tlmm 93 0x00>;
+ interrupt-parent = <&tlmm>;
+ qcom,clk-src = "BBCLK2";
+ interrupts = <17 0>;
+ interrupt-names = "nfc_irq";
+ pinctrl-names = "nfc_active", "nfc_suspend";
+ pinctrl-0 = <&nfc_int_active &nfc_disable_active
+ &nfc_clk_default>;
+ pinctrl-1 = <&nfc_int_suspend &nfc_disable_suspend>;
+ clocks = <&clock_gcc clk_bb_clk2_pin>;
+ clock-names = "ref_clk";
+ };
+};
+
+&tlmm {
+ pmx_ts_int_active {
+ ts_int_active: ts_int_active {
+ mux {
+ pins = "gpio65";
+ function = "gpio";
+ };
+
+ config {
+ pins = "gpio65";
+ drive-strength = <8>;
+ bias-pull-up;
+ };
+ };
+ };
+
+ pmx_ts_int_suspend {
+ ts_int_suspend: ts_int_suspend {
+ mux {
+ pins = "gpio65";
+ function = "gpio";
+ };
+
+ config {
+ pins = "gpio65";
+ drive-strength = <2>;
+ bias-pull-down;
+ };
+ };
+ };
+
+ pmx_ts_reset_active {
+ ts_reset_active: ts_reset_active {
+ mux {
+ pins = "gpio64";
+ function = "gpio";
+ };
+
+ config {
+ pins = "gpio64";
+ drive-strength = <8>;
+ bias-pull-up;
+ };
+ };
+ };
+
+ pmx_ts_reset_suspend {
+ ts_reset_suspend: ts_reset_suspend {
+ mux {
+ pins = "gpio64";
+ function = "gpio";
+ };
+
+ config {
+ pins = "gpio64";
+ drive-strength = <2>;
+ bias-pull-down;
+ };
+ };
+ };
+
+ pmx_ts_release {
+ ts_release: ts_release {
+ mux {
+ pins = "gpio65", "gpio64";
+ function = "gpio";
+ };
+
+ config {
+ pins = "gpio65", "gpio64";
+ drive-strength = <2>;
+ bias-pull-down;
+ };
+ };
+ };
+
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-mdss-panels.dtsi b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-mdss-panels.dtsi
new file mode 100644
index 0000000..247d312
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-mdss-panels.dtsi
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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 "dsi-panel-edo-rm67162-qvga-cmd.dtsi"
+
+&soc {
+ dsi_pm660_panel_pwr_supply: dsi_pm660_panel_pwr_supply {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ qcom,panel-supply-entry@0 {
+ reg = <0>;
+ qcom,supply-name = "vdd";
+ qcom,supply-min-voltage = <2800000>;
+ qcom,supply-max-voltage = <2800000>;
+ qcom,supply-enable-load = <100000>;
+ qcom,supply-disable-load = <100>;
+ };
+
+ qcom,panel-supply-entry@1 {
+ reg = <1>;
+ qcom,supply-name = "vddio";
+ qcom,supply-min-voltage = <1800000>;
+ qcom,supply-max-voltage = <1800000>;
+ qcom,supply-enable-load = <100000>;
+ qcom,supply-disable-load = <100>;
+ };
+ };
+};
+
+&cdc_pdm_lines_act {
+ mux {
+ pins = "gpio68", "gpio73", "gpio74";
+ function = "cdc_pdm0";
+ };
+
+ config {
+ pins = "gpio68", "gpio73", "gpio74";
+ drive-strength = <8>;
+ };
+};
+
+&cdc_pdm_lines_sus {
+ mux {
+ pins = "gpio68", "gpio73", "gpio74";
+ function = "cdc_pdm0";
+ };
+
+ config {
+ pins = "gpio68", "gpio73", "gpio74";
+ drive-strength = <2>;
+ bias-disable;
+ };
+};
+
+&mdss_dsi0 {
+ qcom,dsi-pref-prim-pan = <&dsi_edo_rm67162_qvga_cmd>;
+ pinctrl-names = "mdss_default", "mdss_sleep";
+ pinctrl-0 = <&mdss_dsi_active &mdss_te_active>;
+ pinctrl-1 = <&mdss_dsi_suspend &mdss_te_suspend>;
+ qcom,platform-te-gpio = <&tlmm 24 0>;
+ qcom,platform-reset-gpio = <&tlmm 60 0>;
+ qcom,platform-enable-gpio = <&tlmm 69 0>;
+};
+
+&dsi_edo_rm67162_qvga_cmd {
+ /delete-property/ qcom,mdss-dsi-panel-timings;
+ qcom,mdss-dsi-panel-timings-phy-12nm = [06 05 01 0A 00 03 01 0F];
+ qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_dcs";
+ qcom,panel-supply-entries = <&dsi_pm660_panel_pwr_supply>;
+ qcom,esd-check-enabled;
+ qcom,mdss-dsi-panel-status-check-mode = "te_signal_check";
+ qcom,partial-update-enabled;
+ qcom,panel-roi-alignment = <2 2 4 2 320 2>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-wdp-overlay.dts b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-wdp-overlay.dts
new file mode 100644
index 0000000..f70c458
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro-qrd-wdp-overlay.dts
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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/;
+/plugin/;
+
+#include "sdm429-spyro-qrd-evt.dtsi"
+
+/ {
+ model = "Qualcomm Technologies, Inc. SDM429 QRD Spyro WDP Overlay";
+ compatible = "qcom,sdm429w-qrd", "qcom,sdm429w", "qcom,qrd";
+ qcom,msm-id = <416 0x0>;
+ qcom,board-id = <0x01000b 6>;
+ qcom,pmic-id = <0x0002001b 0x0 0x0 0x0>;
+};
+
+&usb_otg {
+ HSUSB_3p3-supply = <&L16A>;
+};
+
+&msm_dig_codec {
+ cdc-vdd-digital-supply = <&pm660_l11>;
+};
+
+&ext_smart_pa {
+ dvdd-supply = <&pm660_l11>;
+};
+
+&sdhc_2 {
+ cd-gpios = <&tlmm 67 0x1>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro-wdp.dts b/arch/arm64/boot/dts/qcom/sdm429-spyro-wdp.dts
new file mode 100644
index 0000000..dd12d18
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro-wdp.dts
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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 "sdm429-spyro.dtsi"
+
+/ {
+ model = "Qualcomm Technologies, Inc. SDM429 QRD Spyro WDP";
+ compatible = "qcom,sdm429w-qrd", "qcom,sdm429w", "qcom,qrd";
+ qcom,msm-id = <416 0x0>;
+ qcom,board-id = <0x01000b 6>;
+ qcom,pmic-id = <0x0002001b 0x0 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro.dts b/arch/arm64/boot/dts/qcom/sdm429-spyro.dts
new file mode 100644
index 0000000..a869792
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro.dts
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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 "sdm429-spyro.dtsi"
+
+/ {
+ model = "Qualcomm Technologies, Inc. SDM429 QRD Spyro";
+ compatible = "qcom,sdm429-qrd", "qcom,sdm429", "qcom,qrd";
+ qcom,board-id = <0xb 6>;
+ qcom,pmic-id = <0x0002001b 0x0 0x0 0x0>;
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm429-spyro.dtsi b/arch/arm64/boot/dts/qcom/sdm429-spyro.dtsi
new file mode 100644
index 0000000..80f89d9
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sdm429-spyro.dtsi
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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 "sdm429.dtsi"
+#include "sdm429w-pm660.dtsi"
diff --git a/arch/arm64/boot/dts/qcom/sdm429w-pm660.dtsi b/arch/arm64/boot/dts/qcom/sdm429w-pm660.dtsi
index 450691b..caab464 100644
--- a/arch/arm64/boot/dts/qcom/sdm429w-pm660.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm429w-pm660.dtsi
@@ -339,14 +339,6 @@
/delete-node/ qcom,pmi632@3;
};
-&dsi_hx8399c_truly_vid {
- /delete-property/ qcom,mdss-dsi-pwm-gpio;
-};
-
-&dsi_hx8399c_hd_vid {
- /delete-property/ qcom,mdss-dsi-pwm-gpio;
-};
-
&tlmm {
/delete-node/ smb_int_default;
};
diff --git a/arch/arm64/boot/dts/qcom/sdm429w-regulator.dtsi b/arch/arm64/boot/dts/qcom/sdm429w-regulator.dtsi
index b4dd41e..4b521b2 100644
--- a/arch/arm64/boot/dts/qcom/sdm429w-regulator.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm429w-regulator.dtsi
@@ -338,6 +338,7 @@
&soc {
regulator@b018000 {
vdd-apc-supply = <&pm660_s3>;
+ qcom,cpr-apc-volt-step = <4000>;
};
vreg_sd_pad: vreg_sd_pad {
diff --git a/arch/arm64/boot/dts/qcom/sdm439-regulator.dtsi b/arch/arm64/boot/dts/qcom/sdm439-regulator.dtsi
index 750cedb..c04017a 100644
--- a/arch/arm64/boot/dts/qcom/sdm439-regulator.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm439-regulator.dtsi
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -467,7 +467,8 @@
qcom,cpr-speed-bin-max-corners =
<0 (-1) 1 2 5>,
<1 (-1) 1 2 5>,
- <4 (-1) 1 2 6>;
+ <4 (-1) 1 2 6>,
+ <5 (-1) 1 2 6>;
qcom,cpr-fuse-revision = <69 39 3 0>;
qcom,cpr-quot-adjust-scaling-factor-max = <0 1400 1400>;
qcom,cpr-voltage-scaling-factor-max = <0 2000 2000>;
diff --git a/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi b/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi
index a7a234a..86320c3 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi
@@ -893,6 +893,21 @@
};
};
+ ext_bridge_mux {
+ lt9611_pins: lt9611_pins {
+ mux {
+ pins = "gpio84", "gpio128", "gpio89";
+ function = "gpio";
+ };
+
+ config {
+ pins = "gpio84", "gpio128", "gpio89";
+ bias-disable = <0>; /* no pull */
+ drive-strength = <8>;
+ };
+ };
+ };
+
sec_aux_pcm {
sec_aux_pcm_sleep: sec_aux_pcm_sleep {
mux {
diff --git a/arch/arm64/boot/dts/qcom/sdm845-sde-display.dtsi b/arch/arm64/boot/dts/qcom/sdm845-sde-display.dtsi
index 7735237..aa3976d 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-sde-display.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-sde-display.dtsi
@@ -527,6 +527,29 @@
ibb-supply = <&ibb_regulator>;
};
+ ext_dsi_bridge_display: qcom,dsi-display@19 {
+ compatible = "qcom,dsi-display";
+ label = "ext_dsi_bridge_display";
+ qcom,display-type = "primary";
+
+ qcom,dsi-ctrl = <&mdss_dsi0>;
+ qcom,dsi-phy = <&mdss_dsi_phy0>;
+ clocks = <&mdss_dsi0_pll BYTECLK_MUX_0_CLK>,
+ <&mdss_dsi0_pll PCLK_MUX_0_CLK>;
+ clock-names = "mux_byte_clk", "mux_pixel_clk";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+ ext_dsi_out: endpoint {
+ };
+ };
+ };
+ };
+
sde_wb: qcom,wb-display@0 {
compatible = "qcom,wb-display";
cell-index = <0>;
diff --git a/arch/arm64/boot/dts/qcom/sdm845-v2.1-rb3.dtsi b/arch/arm64/boot/dts/qcom/sdm845-v2.1-rb3.dtsi
index e1159d3..cf84ecf 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-v2.1-rb3.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-v2.1-rb3.dtsi
@@ -204,3 +204,96 @@
&ipa_hw {
status="disabled";
};
+
+&dsi_nt35597_truly_dsc_cmd_display {
+ /delete-property/ qcom,dsi-display-active;
+};
+
+&mdss_mdp {
+ bridges = <<9611>;
+};
+
+&soc {
+ lt9611_vcc_eldo: lt9611-gpio-regulator@0 {
+ compatible = "regulator-fixed";
+ regulator-name = "lt9611_vcc_eldo";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-enable-ramp-delay = <233>;
+ gpio = <&tlmm 89 0>;
+ enable-active-high;
+ };
+};
+
+&qupv3_se10_i2c {
+ status = "ok";
+ lt9611: lt,lt9611@3b {
+ compatible = "lt,lt9611";
+ reg = <0x3b>;
+ interrupt-parent = <&tlmm>;
+ interrupts = <84 0>;
+ interrupt-names = "lt_irq";
+ lt,irq-gpio = <&tlmm 84 0x0>;
+ lt,reset-gpio = <&tlmm 128 0x0>;
+ lt,non-pluggable;
+ lt,preferred-mode = "1920x1080";
+
+ pinctrl-names = "default";
+ pinctrl-0 = <<9611_pins>;
+
+ vdd-supply = <<9611_vcc_eldo>;
+ lt,supply-entries {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ lt,supply-entry@0 {
+ reg = <0>;
+ lt,supply-name = "vdd";
+ lt,supply-min-voltage = <1800000>;
+ lt,supply-max-voltage = <1800000>;
+ lt,supply-enable-load = <200000>;
+ lt,supply-post-on-sleep = <150>;
+ };
+ };
+
+ lt,customize-modes {
+ lt,customize-mode-id@0 {
+ lt,mode-h-active = <1920>;
+ lt,mode-h-front-porch = <88>;
+ lt,mode-h-pulse-width = <44>;
+ lt,mode-h-back-porch = <148>;
+ lt,mode-h-active-high;
+ lt,mode-v-active = <1080>;
+ lt,mode-v-front-porch = <4>;
+ lt,mode-v-pulse-width = <5>;
+ lt,mode-v-back-porch = <36>;
+ lt,mode-v-active-high;
+ lt,mode-refresh-rate = <60>;
+ lt,mode-clock-in-khz = <148500>;
+ };
+ };
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+ lt9611_in: endpoint {
+ remote-endpoint = <&ext_dsi_out>;
+ };
+ };
+ };
+ };
+};
+
+&ext_dsi_bridge_display {
+ qcom,dsi-display-active;
+ ports {
+ port@0 {
+ ext_dsi_out: endpoint {
+ remote-endpoint = <<9611_in>;
+ };
+ };
+ };
+};
diff --git a/arch/arm64/configs/sdm845-perf_defconfig b/arch/arm64/configs/sdm845-perf_defconfig
index f62a85a..e58defd 100755
--- a/arch/arm64/configs/sdm845-perf_defconfig
+++ b/arch/arm64/configs/sdm845-perf_defconfig
@@ -388,10 +388,12 @@
CONFIG_DVB_MPQ_DEMUX=m
CONFIG_DVB_MPQ_TSPP1=y
CONFIG_TSPP=m
+CONFIG_VIDEO_ALTEK_ISP=y
CONFIG_QCOM_KGSL=y
CONFIG_DRM=y
CONFIG_DRM_SDE_EVTLOG_DEBUG=y
CONFIG_DRM_SDE_RSC=y
+CONFIG_DRM_LT_LT9611=y
CONFIG_FB_VIRTUAL=y
CONFIG_BACKLIGHT_LCD_SUPPORT=y
CONFIG_BACKLIGHT_CLASS_DEVICE=y
diff --git a/arch/arm64/configs/sdm845_defconfig b/arch/arm64/configs/sdm845_defconfig
index 9f6dba1..352689f 100644
--- a/arch/arm64/configs/sdm845_defconfig
+++ b/arch/arm64/configs/sdm845_defconfig
@@ -393,10 +393,12 @@
CONFIG_DVB_MPQ_DEMUX=m
CONFIG_DVB_MPQ_TSPP1=y
CONFIG_TSPP=m
+CONFIG_VIDEO_ALTEK_ISP=y
CONFIG_QCOM_KGSL=y
CONFIG_DRM=y
CONFIG_DRM_SDE_EVTLOG_DEBUG=y
CONFIG_DRM_SDE_RSC=y
+CONFIG_DRM_LT_LT9611=y
CONFIG_FB_VIRTUAL=y
CONFIG_BACKLIGHT_LCD_SUPPORT=y
CONFIG_BACKLIGHT_CLASS_DEVICE=y
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 493035b..92ee790 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -379,3 +379,4 @@
endif #DVB_PLATFORM_DRIVERS
source "drivers/media/platform/msm/Kconfig"
+source "drivers/media/platform/altek/Kconfig"
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 0929cd1..cb648c0 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -67,4 +67,6 @@
obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec/
+obj-$(CONFIG_VIDEO_ALTEK_ISP) += altek/
+
obj-y += msm/
diff --git a/drivers/media/platform/altek/Kconfig b/drivers/media/platform/altek/Kconfig
new file mode 100644
index 0000000..3c013d0
--- /dev/null
+++ b/drivers/media/platform/altek/Kconfig
@@ -0,0 +1,8 @@
+config VIDEO_ALTEK_ISP
+ tristate "Altek mini isp support"
+ depends on I2C && SPI
+ ---help---
+ This is a camera driver for Altek mini isp which is to process
+ depth data from dual IR camera sensors.
+ Say Y here to enable Altek mini isp support.
+
diff --git a/drivers/media/platform/altek/Makefile b/drivers/media/platform/altek/Makefile
new file mode 100755
index 0000000..e31405c
--- /dev/null
+++ b/drivers/media/platform/altek/Makefile
@@ -0,0 +1,16 @@
+# Makefile for Altek mini isp driver
+
+ccflags-y += -DNEW_ABS
+
+# add obj to linux kernel
+altek_isp-objs := \
+ basic_setting_cmd.o bulk_data_cmd.o \
+ camera_profile_cmd.o miniisp_intf_i2c.o \
+ miniisp_intf_spi.o miniisp_isp.o \
+ ispctrl_if_master.o miniisp_customer_define.o \
+ miniisp_top.o miniisp_ctrl.o \
+ operation_cmd.o sys_manage_cmd.o \
+ miniisp_utility.o miniisp_debug_if.o \
+ miniisp_chip_base_define.o miniisp_ctrl_intf.o
+
+obj-$(CONFIG_VIDEO_ALTEK_ISP) += altek_isp.o
diff --git a/drivers/media/platform/altek/basic_setting_cmd.c b/drivers/media/platform/altek/basic_setting_cmd.c
new file mode 100755
index 0000000..9c18ec8
--- /dev/null
+++ b/drivers/media/platform/altek/basic_setting_cmd.c
@@ -0,0 +1,182 @@
+/*
+ * File: basic_setting_cmd.c
+ * Description: Mini ISP sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/10/14; Aaron Chuang; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+/******Include File******/
+#include "include/isp_camera_cmd.h"
+#include "include/ispctrl_if_master.h"
+#include "include/error/ispctrl_if_master_err.h"
+#include "include/miniisp.h"
+#include "include/ispctrl_if_master_local.h"
+
+/******Private Constant Definition******/
+#define MINI_ISP_LOG_TAG "[[miniisp]Basic_setting_cmd]"
+
+/******Private Type Declaration******/
+
+/******Private Function Prototype******/
+
+/******Private Global Variable******/
+
+/******Public Global Variable******/
+
+/******Public Function******/
+
+/*
+ *\brief Set Depth 3A Info
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_depth_3a_info(void *devdata,
+ u16 opcode, u8 *param)
+{
+ /*Error Code */
+ errcode err = ERR_SUCCESS;
+ u32 para_size = sizeof(struct isp_cmd_depth_3a_info);
+
+ /*Send command to slave */
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set Depth auto interleave mode
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode
+mast_basic_setting_cmd_set_depth_auto_interleave_mode(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /*Error Code */
+ errcode err = ERR_SUCCESS;
+ u32 para_size = sizeof(struct isp_cmd_depth_auto_interleave_param);
+ struct isp_cmd_depth_auto_interleave_param *depth_auto_interleave_param;
+
+ depth_auto_interleave_param =
+ (struct isp_cmd_depth_auto_interleave_param *)param;
+
+ misp_info("%s - enter", __func__);
+ misp_info("[onoff]: %d, [skip_frame]: %d, ",
+ depth_auto_interleave_param->depth_interleave_mode_on_off,
+ depth_auto_interleave_param->skip_frame_num_after_illuminator_pulse);
+
+ misp_info("[projector_Lv]: %d, [flood_Lv]: %d",
+ depth_auto_interleave_param->projector_power_level,
+ depth_auto_interleave_param->illuminator_power_level);
+
+ /*Send command to slave */
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set projector interleave mode with depth type
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode
+mast_basic_setting_cmd_set_interleave_mode_depth_type(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /*Error Code */
+ errcode err = ERR_SUCCESS;
+ u32 para_size = sizeof(struct isp_cmd_interleave_mode_depth_type);
+
+ /*Send command to slave */
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set depth polish level
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_depth_polish_level(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /*Error Code */
+ errcode err = ERR_SUCCESS;
+ u32 para_size = sizeof(struct isp_cmd_depth_polish_level);
+
+ /*Send command to slave */
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set exposure param
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_exposure_param(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /*Error Code */
+ errcode err = ERR_SUCCESS;
+ u32 para_size = sizeof(struct isp_cmd_exposure_param);
+
+ /*Send command to slave */
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set depth stream size
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_depth_stream_size(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /*Error Code */
+ errcode err = ERR_SUCCESS;
+ u32 para_size = sizeof(struct isp_cmd_depth_stream_size);
+
+ /*Send command to slave */
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+/******End Of File******/
diff --git a/drivers/media/platform/altek/bulk_data_cmd.c b/drivers/media/platform/altek/bulk_data_cmd.c
new file mode 100644
index 0000000..d70fca4
--- /dev/null
+++ b/drivers/media/platform/altek/bulk_data_cmd.c
@@ -0,0 +1,2176 @@
+/*
+ * File: bulk_data_cmd.c
+ * Description: Mini ISP sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/10/14; Bruce Chung; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ * 2016/05/05; Louis Wang; Linux Coding Style
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/******Include File******/
+#include <linux/buffer_head.h>
+#include <linux/delay.h>
+#include <linux/vmalloc.h>
+#include <linux/firmware.h>
+#include "include/isp_camera_cmd.h"
+#include "include/ispctrl_if_master.h"
+#include "include/error/ispctrl_if_master_err.h"
+#include "include/miniisp.h"
+#include "include/ispctrl_if_master_local.h"
+#include "include/miniisp_customer_define.h"
+/******Private Constant Definition******/
+#define LOGSIZE (4*1024)
+#define RAWBLOCKSIZE SPI_TX_BULK_SIZE_BOOT
+#define MINI_ISP_LOG_TAG "[[miniisp]bulk_data_cmd]"
+#define MID_PJ_EXEBIN_BUF (1024*1024)
+#define MAX_BUFFER_SIZE (10 * 1024 * 1024)
+
+/*Private Type Declaration*/
+#if (!ENABLE_LINUX_FW_LOADER)
+/*Basic code buffer address*/
+static u8 *basic_code_buf_addr;
+#endif
+/*Calibration data buffer address*/
+static u8 *calibration_data_buf_addr;
+
+u16 fw_version_before_point;
+u16 fw_version_after_point;
+char fw_build_by[9];
+char fw_project_name[17];
+u32 sc_build_date;
+/******Private Function Prototype******/
+static u16
+calculate_check_sum(const u8 *input_buffer_addr, u32 input_buffer_size);
+
+/******Private Global Variable******/
+
+
+/******Public Global Variable*******/
+
+/******Public Function******/
+
+#if ENABLE_LINUX_FW_LOADER
+const u8 *fw_data;
+/**
+ *\brief Write Boot Code
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], boot code file pointer
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_boot_code(void *devdata,
+ u8 *param)
+{
+ errcode err = ERR_SUCCESS;
+ u32 total_size;
+ u32 curpos;
+ const struct firmware *fw = NULL;
+ struct device *mini_isp_device;
+ u32 ProductId_val = 0;
+ u16 miniboot_version_before_point = 0;
+ u16 miniboot_version_after_point = 0;
+ u8 ProductId[4];
+ u8 miniboot_ver_major[2];
+ u8 miniboot_ver_minor[2];
+ char miniboot_build_by[9];
+ char *fw_name = NULL;
+
+ /* load boot fw file */
+ mini_isp_device = mini_isp_getdev();
+ if (mini_isp_device != NULL) {
+ fw_name = strrchr((BOOT_FILE_LOCATION ?
+ BOOT_FILE_LOCATION : ""), '/');
+
+ /* skip char '/' */
+ if (fw_name != NULL)
+ fw_name = fw_name + 1;
+
+ misp_info("%s, fw name: %s", __func__, fw_name);
+ err = request_firmware(&fw,
+ fw_name, mini_isp_device);
+ if (err) {
+ misp_info("%s, L: %d, err: %d",
+ __func__, __LINE__, err);
+ goto mast_bulk_data_cmd_write_boot_code_end;
+ }
+ }
+
+ if (fw == NULL) {
+ misp_info("%s, fw is NULL.", __func__);
+ return -EINVAL;
+ }
+
+ total_size = fw->size;
+ fw_data = fw->data;
+
+ /*Transfer boot code*/
+ /* boot code & main code can only be sent by SPI */
+ err = ispctrl_if_mast_send_bulk(devdata,
+ fw_data, total_size, RAWBLOCKSIZE, true);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_boot_code_end;
+
+ misp_info("%s send boot code success", __func__);
+
+ /* Get miniboot version */
+ curpos = total_size - 16;
+ memcpy(ProductId, &fw_data[curpos], 4);
+ curpos += 4;
+ memcpy(miniboot_ver_major, &fw_data[curpos], 2);
+ curpos += 2;
+ memcpy(miniboot_ver_minor, &fw_data[curpos], 2);
+ curpos += 2;
+ memcpy(miniboot_build_by, &fw_data[curpos], 8);
+
+ if (err == -1) {
+ misp_info("%s - Read file failed.", __func__);
+ } else {
+ err = 0;
+ ProductId_val = (ProductId[3]<<24) + (ProductId[2]<<16) +
+ (ProductId[1] << 8) + ProductId[0];
+ miniboot_version_before_point = miniboot_ver_major[1]*256 +
+ miniboot_ver_major[0];
+ miniboot_version_after_point = miniboot_ver_minor[1]*256 +
+ miniboot_ver_minor[0];
+ miniboot_build_by[8] = '\0';
+ misp_info("%s - miniboot version: %d.%d.%d, build by %s",
+ __func__, ProductId_val, miniboot_version_before_point,
+ miniboot_version_after_point, miniboot_build_by);
+ }
+
+mast_bulk_data_cmd_write_boot_code_end:
+ if (fw != NULL)
+ release_firmware(fw);
+
+ return err;
+}
+
+/**
+ *\brief Write Boot Code (Short SPI Len)
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], boot code file pointer
+ *\return Error code
+ */
+errcode
+mast_bulk_data_cmd_write_boot_code_shortlen(void *devdata,
+ u8 *param)
+{
+ errcode err = ERR_SUCCESS;
+ u32 total_size;
+ u32 block_size;
+ u32 curpos;
+ const struct firmware *fw = NULL;
+ struct device *mini_isp_device;
+ u32 ProductId_val = 0;
+ u16 miniboot_version_before_point = 0;
+ u16 miniboot_version_after_point = 0;
+ u8 ProductId[4];
+ u8 miniboot_ver_major[2];
+ u8 miniboot_ver_minor[2];
+ char miniboot_build_by[9];
+ char *fw_name = NULL;
+
+ /* load boot fw file */
+ mini_isp_device = mini_isp_getdev();
+ if (mini_isp_device != NULL) {
+ fw_name = strrchr((BOOT_FILE_LOCATION ?
+ BOOT_FILE_LOCATION : ""), '/');
+
+ /* skip char '/' */
+ if (fw_name != NULL)
+ fw_name = fw_name + 1;
+
+ misp_info("%s, fw name: %s", __func__, fw_name);
+ err = request_firmware(&fw,
+ fw_name, mini_isp_device);
+ if (err) {
+ misp_info("%s, err: %d", __func__, err);
+ goto mast_bulk_data_cmd_write_boot_code_end;
+ }
+ }
+
+ if (fw == NULL) {
+ misp_info("%s, fw is NULL.", __func__);
+ return -EINVAL;
+ }
+
+ block_size = SPI_BLOCK_LEN;
+ total_size = fw->size;
+ fw_data = fw->data;
+ /*misp_info("%s filesize : %d", __func__, total_size);*/
+ /*misp_info("block_size %d", RAWBLOCKSIZE);*/
+
+ /*Transfer boot code*/
+ /* boot code & main code can only be sent by SPI */
+ err = ispctrl_if_mast_send_bulk(devdata,
+ fw_data, total_size, block_size, true);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_boot_code_end;
+
+ misp_info("%s send boot code success", __func__);
+
+ /* Get miniboot version */
+ curpos = total_size - 16;
+ memcpy(ProductId, &fw_data[curpos], 4);
+ curpos += 4;
+ memcpy(miniboot_ver_major, &fw_data[curpos], 2);
+ curpos += 2;
+ memcpy(miniboot_ver_minor, &fw_data[curpos], 2);
+ curpos += 2;
+ memcpy(miniboot_build_by, &fw_data[curpos], 8);
+
+ if (err == -1) {
+ misp_info("%s - Read file failed.", __func__);
+ } else {
+ err = 0;
+ ProductId_val = (ProductId[3]<<24) + (ProductId[2]<<16) +
+ (ProductId[1] << 8) + ProductId[0];
+ miniboot_version_before_point = miniboot_ver_major[1]*256 +
+ miniboot_ver_major[0];
+ miniboot_version_after_point = miniboot_ver_minor[1]*256 +
+ miniboot_ver_minor[0];
+ miniboot_build_by[8] = '\0';
+ misp_info("%s - miniboot version: %d.%d.%d, build by %s",
+ __func__, ProductId_val, miniboot_version_before_point,
+ miniboot_version_after_point, miniboot_build_by);
+ }
+ /* Get miniboot version */
+
+mast_bulk_data_cmd_write_boot_code_end:
+ if (fw != NULL)
+ release_firmware(fw);
+
+ return err;
+}
+
+/**
+ *\brief Write Basic Code
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], basic code file pointer
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_basic_code(void *devdata,
+ u8 *param)
+{
+ errcode err = ERR_SUCCESS;
+ u8 fw_version[4];
+ u32 para_size = ISPCMD_EXEBIN_INFOBYTES;
+ u32 *total_size = (u32 *)¶m[ISPCMD_EXEBIN_ADDRBYTES];
+ u32 file_total_size;
+ u32 block_size;
+ u32 currpos;
+ const struct firmware *fw = NULL;
+ struct device *mini_isp_device;
+ char *fw_name = NULL;
+
+ block_size = ((struct misp_data *)devdata)->bulk_cmd_blocksize;
+
+ /* load boot fw file */
+ mini_isp_device = mini_isp_getdev();
+ if (mini_isp_device != NULL) {
+ fw_name = strrchr((BASIC_FILE_LOCATION ?
+ BASIC_FILE_LOCATION : ""), '/');
+
+ /* skip char '/' */
+ if (fw_name != NULL)
+ fw_name = fw_name + 1;
+
+ misp_info("%s, fw name: %s", __func__, fw_name);
+ err = request_firmware(&fw,
+ fw_name, mini_isp_device);
+ if (err) {
+ misp_info("%s, L: %d, err: %d",
+ __func__, __LINE__, err);
+ goto mast_bulk_data_cmd_write_basic_code_end;
+ }
+ }
+
+ if (fw == NULL) {
+ misp_info("%s, fw is NULL.", __func__);
+ return -EINVAL;
+ }
+
+ file_total_size = fw->size;
+ fw_data = fw->data;
+
+ /*read the header info (first 16 bytes in the basic code)*/
+ memcpy(param, fw_data, ISPCMD_EXEBIN_INFOBYTES);
+
+ /*To copy checksum value to correct header point*/
+ memcpy((u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES + ISPCMD_EXEBIN_BLOCKSIZEBYTES),
+ (u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES), sizeof(u32));
+ /*Assign block size to correct header point*/
+ memcpy((u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES), &block_size, sizeof(u32));
+ /*
+ * misp_info("%s param[0][1][2][3]: %02x %02x %02x %02x",
+ * __func__, param[0], param[1], param[2], param[3]);
+ * misp_info("%s param[4][5][6][7]: %02x %02x %02x %02x",
+ * __func__, param[4], param[5], param[6], param[7]);
+ * misp_info("%s param[8][9][10][11]: %02x %02x %02x %02x",
+ * __func__, param[8], param[9], param[10], param[11]);
+ * misp_info("%s param[12][13][14][15]: %02x %02x %02x %02x",
+ * __func__, param[12], param[13], param[14], param[15]);
+ */
+
+ misp_info("block size: %d", block_size);
+ misp_info("Total fw size: %zu", fw->size);
+ misp_info("fw size: %d", ((u32 *)param)[1]);
+ misp_info("0x%x, 0x%x, 0x%x, 0x%x",
+ ((u32 *)fw->data)[0], ((u32 *)fw->data)[1],
+ ((u32 *)fw->data)[2], ((u32 *)fw->data)[3]);
+
+ /*Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_WRITE_BASICCODE, param, para_size);
+ if (err != ERR_SUCCESS) {
+ misp_info("%s, L: %d, err: %d", __func__, __LINE__, err);
+ goto mast_bulk_data_cmd_write_basic_code_end;
+ }
+
+ /*misp_info("%s send leaking packet success", __func__);*/
+
+ /*misp_info("block_size %d", BLOCKSIZE);*/
+ misp_info("%s send basic code start", __func__);
+ /*Transfer basic code*/
+ err = ispctrl_if_mast_send_bulk(devdata,
+ fw_data + ISPCMD_EXEBIN_INFOBYTES,
+ *total_size, block_size, false);
+
+ if (err != ERR_SUCCESS) {
+ misp_info("%s, L: %d, err: %d", __func__, __LINE__, err);
+ goto mast_bulk_data_cmd_write_basic_code_end;
+ }
+
+ /*wait for the interrupt*/
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_BULKDATA);
+
+ if (err != ERR_SUCCESS) {
+ misp_info("%s, L: %d, err: %d", __func__, __LINE__, err);
+ goto mast_bulk_data_cmd_write_basic_code_end;
+ }
+
+ misp_info("%s - send basic code success", __func__);
+
+ currpos = file_total_size - 32;
+ memcpy(fw_project_name, &fw_data[currpos], 16);
+ currpos = file_total_size - 12;
+ memcpy(fw_version, &fw_data[currpos], 4);
+ currpos += 4;
+ memcpy(fw_build_by, &fw_data[currpos], 8);
+
+ err = 0;
+ fw_version_before_point = fw_version[1]*256 + fw_version[0];
+ fw_version_after_point = fw_version[3]*256 + fw_version[2];
+ fw_build_by[8] = '\0';
+ fw_project_name[16] = '\0';
+ misp_info("%s project: %s, fw version: %05d.%05d, build by %s",
+ __func__, fw_project_name, fw_version_before_point,
+ fw_version_after_point, fw_build_by);
+
+mast_bulk_data_cmd_write_basic_code_end:
+ if (fw != NULL)
+ release_firmware(fw);
+ return err;
+}
+
+/**
+ *\brief Write Basic Code (Short SPI Len)
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], basic code file pointer
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_basic_code_shortlen(
+ void *devdata, u8 *param)
+{
+ errcode err = ERR_SUCCESS;
+ u8 fw_version[4];
+ /* u32 para_size = ISPCMD_EXEBIN_INFOBYTES; */
+ u32 *total_size = (u32 *)¶m[ISPCMD_EXEBIN_ADDRBYTES];
+ u32 file_total_size;
+ u32 block_size;
+ off_t currpos;
+ const struct firmware *fw = NULL;
+ struct device *mini_isp_device;
+ char *fw_name = NULL;
+
+ /* load boot fw file */
+ mini_isp_device = mini_isp_getdev();
+ if (mini_isp_device != NULL) {
+ fw_name = strrchr((BASIC_FILE_LOCATION ?
+ BASIC_FILE_LOCATION : ""), '/');
+
+ /* skip char '/' */
+ if (fw_name != NULL)
+ fw_name = fw_name + 1;
+
+ misp_info("%s, fw name: %s", __func__, fw_name);
+ err = request_firmware(&fw,
+ fw_name, mini_isp_device);
+ if (err) {
+ misp_info("%s, err: %d", __func__, err);
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+ }
+ }
+
+ if (fw == NULL) {
+ misp_info("%s, fw is NULL.", __func__);
+ return -EINVAL;
+ }
+
+ block_size = SPI_BLOCK_LEN;
+
+ /*get the file size*/
+ file_total_size = fw->size;
+ fw_data = fw->data;
+ /*misp_info("%s filesize : %u", __func__, file_total_size);*/
+
+
+ /*read the header info (first 16 bytes in the basic code)*/
+ memcpy(param, fw_data, ISPCMD_EXEBIN_INFOBYTES);
+
+ /*To copy checksum value to correct header point*/
+ memcpy((u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES + ISPCMD_EXEBIN_BLOCKSIZEBYTES),
+ (u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES), sizeof(u32));
+ /*Assign block size to correct header point*/
+ memcpy((u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES), &block_size, sizeof(u32));
+
+
+ misp_info("%s param[0][1][2][3]: %02x %02x %02x %02x",
+ __func__, param[0], param[1], param[2], param[3]);
+ misp_info("%s param[4][5][6][7]: %02x %02x %02x %02x",
+ __func__, param[4], param[5], param[6], param[7]);
+ misp_info("%s param[8][9][10][11]: %02x %02x %02x %02x",
+ __func__, param[8], param[9], param[10], param[11]);
+ misp_info("%s param[12][13][14][15]: %02x %02x %02x %02x",
+ __func__, param[12], param[13], param[14], param[15]);
+
+
+
+ /* misp_info("%s Main Code Address >>>> param[0]: %04x",
+ * __func__, *(u32 *)¶m[0]);
+ * misp_info("%s Main Code Size >>>> param[4]: %04x",
+ * __func__, *(u32 *)¶m[4]);
+ * misp_info("%s Main Code Checksum >>>> param[12]: %04x",
+ * __func__, *(u32 *)¶m[12]);
+ */
+
+ /*Send command to slave*/
+ /* Step 1: Main Code Address */
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_WRITE_BASICCODE_CODEADDR,
+ ¶m[0], ISPCMD_EXEBIN_ADDRBYTES);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+
+ msleep(20); /*mdelay(1);*/
+
+ /* Step 2: Main Code Size */
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_WRITE_BASICCODE_CODESIZE,
+ ¶m[4], ISPCMD_EXEBIN_TOTALSIZEBYTES);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+
+ msleep(20); /*mdelay(1);*/
+
+ /* Step 3: Main Code Checksum */
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_WRITE_BASICCODE_CODESUM,
+ ¶m[12], ISPCMD_EXEBIN_CKSUMBYTES);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+
+
+ /*misp_info("%s send leaking packet success", __func__);*/
+
+ /*misp_info("block_size %d", BLOCKSIZE);*/
+ misp_info("%s send basic code start", __func__);
+ /*Transfer basic code*/
+ err = ispctrl_if_mast_send_bulk(devdata,
+ fw_data + ISPCMD_EXEBIN_INFOBYTES,
+ *total_size, block_size, false);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+
+ misp_info("%s - send basic code success", __func__);
+
+
+ /* mdelay(1); */
+
+ /* wait for the interrupt */
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_BULKDATA);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+
+ currpos = file_total_size - 32;
+ memcpy(fw_project_name, &fw_data[currpos], 16);
+ currpos = file_total_size - 12;
+ memcpy(fw_version, &fw_data[currpos], 4);
+ currpos += 4;
+ memcpy(fw_build_by, &fw_data[currpos], 8);
+
+ err = 0;
+ fw_version_before_point = fw_version[1]*256 + fw_version[0];
+ fw_version_after_point = fw_version[3]*256 + fw_version[2];
+ fw_build_by[8] = '\0';
+ fw_project_name[16] = '\0';
+ misp_info("%s project: %s, fw version: %05d.%05d, build by %s",
+ __func__, fw_project_name, fw_version_before_point,
+ fw_version_after_point, fw_build_by);
+
+mast_bulk_data_cmd_write_basic_code_shortlen_end:
+ if (fw != NULL)
+ release_firmware(fw);
+ return err;
+}
+
+/**
+ *\brief Write Calibration Data
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], calibration data file pointer
+ *\return Error code
+ */
+errcode
+mast_bulk_data_cmd_write_calibration_data(void *devdata,
+ u8 *param)
+{
+ #define IS_FROM_AP_BUF (infomode == 0 || infomode == 1 || \
+ infomode == 7 || infomode == 9)
+ errcode err = ERR_SUCCESS;
+ u8 infomode;
+ u16 opcode;
+ u16 ckecksum;
+ u32 para_size = 11;
+ u32 filesize = 0;
+ u32 block_size;
+ const char *file_name;
+ const struct firmware *fw = NULL;
+ struct device *mini_isp_device;
+
+ infomode = param[8];
+ block_size = ((struct misp_data *)devdata)->bulk_cmd_blocksize;
+
+ /* Trasfered files have been opened in kernel
+ * when mini_isp_drv_load_fw()
+ */
+
+ /* load boot fw file */
+ if (infomode == 2)
+ file_name = strrchr(
+ (SCENARIO_TABLE_FILE_LOCATION ?
+ SCENARIO_TABLE_FILE_LOCATION : ""), '/');
+ else if (infomode == 3)
+ file_name = strrchr(
+ (HDR_QMERGE_DATA_FILE_LOCATION ?
+ HDR_QMERGE_DATA_FILE_LOCATION : ""), '/');
+ else if (infomode == 4)
+ file_name = strrchr(
+ (IRP0_QMERGE_DATA_FILE_LOCATION ?
+ IRP0_QMERGE_DATA_FILE_LOCATION : ""), '/');
+
+ else if (infomode == 5)
+ file_name = strrchr(
+ (IRP1_QMERGE_DATA_FILE_LOCATION ?
+ IRP1_QMERGE_DATA_FILE_LOCATION : ""), '/');
+
+ else if (infomode == 6)
+ file_name = strrchr(
+ (PP_MAP_FILE_LOCATION ?
+ PP_MAP_FILE_LOCATION : ""), '/');
+
+ else if (infomode == 7)
+ file_name = NULL;
+ else if (infomode == 8)
+ file_name = strrchr(
+ (DPETH_QMERGE_DATA_FILE_LOCATION ?
+ DPETH_QMERGE_DATA_FILE_LOCATION : ""), '/');
+
+ else
+ file_name = NULL;
+
+ /* skip char '/' */
+ if (file_name != NULL)
+ file_name = file_name + 1;
+
+ /* AP provide data buffer */
+ if (IS_FROM_AP_BUF) {
+ misp_info("%s, buf_len: %d", __func__, *(u32 *)¶m[0]);
+ memcpy(&filesize, param, sizeof(u32));
+ if (filesize > T_MEMSIZE) {
+ err = ~ERR_SUCCESS;
+ misp_info("%s, filesize:%d out of bound.", __func__, filesize);
+ return err;
+ }
+ calibration_data_buf_addr = kzalloc(filesize, GFP_KERNEL);
+ if (!calibration_data_buf_addr) {
+ err = ~ERR_SUCCESS;
+ misp_info("%s, L: %d, err: %d",
+ __func__, __LINE__, err);
+ goto cmd_write_calibration_data_end;
+ }
+
+ memcpy(calibration_data_buf_addr,
+ param + T_SPI_CMD_LENGTH, filesize);
+
+ /*
+ * calculate the checksum of calibration data.
+ */
+ ckecksum = calculate_check_sum(calibration_data_buf_addr, filesize);
+
+ fw_data = (const u8 *) calibration_data_buf_addr;
+ } else {
+ /* load bin file flow*/
+ misp_info("%s, fw name: %s", __func__, file_name);
+ mini_isp_device = mini_isp_getdev();
+ if (mini_isp_device != NULL && file_name != NULL) {
+ err = request_firmware(&fw,
+ file_name, mini_isp_device);
+
+ if (err) {
+ misp_info("%s, L: %d, err: %d",
+ __func__, __LINE__, err);
+ goto cmd_write_calibration_data_end;
+ }
+ }
+
+ if (fw == NULL) {
+ misp_info("%s, fw:%s is NULL.", __func__, file_name);
+ return -EINVAL;
+ }
+
+ filesize = fw->size;
+ fw_data = fw->data;
+
+ if (infomode == 2) {
+ sc_build_date =
+ fw_data[16+3]*256*256*256 +
+ fw_data[16+2]*256*256 +
+ fw_data[16+1]*256 +
+ fw_data[16+0];
+ misp_info("%s - SC table build date %d.", __func__,
+ sc_build_date);
+ }
+
+ ckecksum = calculate_check_sum(fw_data, filesize);
+ }
+
+ /*Assign Info ID to correct header point*/
+ memcpy((u8 *)(param + 8), &infomode, sizeof(u8));
+ /*To copy Total Size to correct header point*/
+ memcpy((u8 *)param, &filesize, sizeof(u32));
+ /*Assign block size to correct header point*/
+ memcpy((u8 *)(param + 4), &block_size, sizeof(u32));
+ /*Assign check sum to correct header point*/
+ memcpy((u8 *)(param + 9), &ckecksum, sizeof(u16));
+
+ if (SPI_SHORT_LEN_MODE && SPI_SHORT_LEN_MODE_WRITE_ENABLE) {
+ opcode = ISPCMD_BULK_WRITE_CALIBRATION_NO_BLOCK;
+ /* Total size(4byte) + data id(1byte) + checksum(2byte)*/
+ para_size = 7;
+ /* left shift 4byte */
+ memcpy((u8 *)(param + 4), (u8 *)(param + 8),
+ sizeof(u32) + sizeof(u16));
+ block_size = SPI_BLOCK_LEN;
+ } else
+ opcode = ISPCMD_BULK_WRITE_CALIBRATION_DATA;
+
+ /*Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ opcode, param, para_size);
+
+ if (err != ERR_SUCCESS) {
+ misp_info("%s L:%d err: %d", __func__, __LINE__, err);
+ goto cmd_write_calibration_data_end;
+ }
+
+ /*misp_info("%s send leaking packet success", __func__);*/
+ /*misp_info("block_size %d", BLOCKSIZE);*/
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_CMD_READY);
+ if (err) {
+ misp_info("%s L:%d err: %d", __func__, __LINE__, err);
+ goto cmd_write_calibration_data_end;
+ }
+
+ err = ispctrl_if_mast_send_bulk(devdata,
+ fw_data, filesize, block_size, false);
+
+ if (err != ERR_SUCCESS) {
+ misp_info("%s L:%d err: %d", __func__, __LINE__, err);
+ goto cmd_write_calibration_data_end;
+ }
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_BULKDATA);
+ if (err) {
+ misp_info("%s L:%d err: %d", __func__, __LINE__, err);
+ goto cmd_write_calibration_data_end;
+ }
+
+ if (infomode == 0)
+ misp_info("%s write IQ calibration data success", __func__);
+ else if (infomode == 1)
+ misp_info("%s write depth packet data success", __func__);
+ else if (infomode == 2)
+ misp_info("%s write scenario table success", __func__);
+ else if (infomode == 3)
+ misp_info("%s write HDR Qmerge data success", __func__);
+ else if (infomode == 4)
+ misp_info("%s write IRP0 Qmerge data success", __func__);
+ else if (infomode == 5)
+ misp_info("%s write IRP1 Qmerge data success", __func__);
+ else if (infomode == 6)
+ misp_info("%s write PP map success", __func__);
+ else if (infomode == 7)
+ misp_info("%s write blending table success", __func__);
+ else if (infomode == 8)
+ misp_info("%s write Depth Qmerge data success", __func__);
+
+cmd_write_calibration_data_end:
+ if (IS_FROM_AP_BUF && calibration_data_buf_addr != NULL)
+ kfree(calibration_data_buf_addr);
+ else if (fw != NULL)
+ release_firmware(fw);
+
+ return err;
+
+}
+
+#else
+/**
+ *\brief Write Boot Code
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], boot code file pointer
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_boot_code(void *devdata,
+ u8 *param, struct file *filp)
+{
+ errcode err = ERR_SUCCESS;
+ u32 total_size;
+ off_t currpos;
+ mm_segment_t oldfs;
+ u32 ProductId_val = 0;
+ u16 miniboot_version_before_point = 0;
+ u16 miniboot_version_after_point = 0;
+ u8 ProductId[4];
+ u8 miniboot_ver_major[2];
+ u8 miniboot_ver_minor[2];
+ char miniboot_build_by[9];
+
+ oldfs = get_fs();
+ set_fs(KERNEL_DS);
+
+ if (filp == NULL) {
+ misp_err("%s - file didn't exist.", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_boot_code_end;
+ }
+
+ /*get the file size*/
+ currpos = vfs_llseek(filp, 0L, SEEK_END);
+ if (currpos == -1) {
+ misp_err("%s llseek failed", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_boot_code_end;
+ }
+ total_size = (u32)currpos;
+ /*misp_info("%s filesize : %d", __func__, total_size);*/
+ vfs_llseek(filp, 0L, SEEK_SET);
+
+ /*misp_info("block_size %d", RAWBLOCKSIZE);*/
+
+ /*Transfer boot code*/
+ /* boot code & main code can only be sent by SPI */
+ err = ispctrl_if_mast_send_bulk(devdata,
+ basic_code_buf_addr, filp, total_size, RAWBLOCKSIZE, true);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_boot_code_end;
+
+ misp_info("%s send boot code success", __func__);
+
+ /* Get miniboot version */
+ set_fs(KERNEL_DS);
+ currpos = vfs_llseek(filp, total_size - 16, SEEK_SET);
+ err = vfs_read(filp, ProductId, 4, &filp->f_pos);
+ err = vfs_read(filp, miniboot_ver_major, 2, &filp->f_pos);
+ err = vfs_read(filp, miniboot_ver_minor, 2, &filp->f_pos);
+ err = vfs_read(filp, miniboot_build_by, 8, &filp->f_pos);
+ set_fs(oldfs);
+ if (err == -1) {
+ misp_info("%s - Read file failed.", __func__);
+ } else {
+ err = 0;
+ ProductId_val = (ProductId[3]<<24) + (ProductId[2]<<16) +
+ (ProductId[1] << 8) + ProductId[0];
+ miniboot_version_before_point = miniboot_ver_major[1]*256 +
+ miniboot_ver_major[0];
+ miniboot_version_after_point = miniboot_ver_minor[1]*256 +
+ miniboot_ver_minor[0];
+ miniboot_build_by[8] = '\0';
+ misp_info("%s - miniboot version: %d.%d.%d, build by %s",
+ __func__, ProductId_val, miniboot_version_before_point,
+ miniboot_version_after_point, miniboot_build_by);
+ }
+ /* Get miniboot version */
+
+mast_bulk_data_cmd_write_boot_code_end:
+
+ return err;
+}
+
+
+/**
+ *\brief Write Boot Code (Short SPI Len)
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], boot code file pointer
+ *\return Error code
+ */
+errcode
+mast_bulk_data_cmd_write_boot_code_shortlen(void *devdata,
+ u8 *param, struct file *filp)
+{
+ errcode err = ERR_SUCCESS;
+ u32 total_size;
+ u32 block_size;
+ off_t currpos;
+ mm_segment_t oldfs;
+
+ u32 ProductId_val = 0;
+ u16 miniboot_version_before_point = 0;
+ u16 miniboot_version_after_point = 0;
+ u8 ProductId[4];
+ u8 miniboot_ver_major[2];
+ u8 miniboot_ver_minor[2];
+ char miniboot_build_by[9];
+
+ oldfs = get_fs();
+ set_fs(KERNEL_DS);
+
+
+ block_size = SPI_BLOCK_LEN;
+
+ if (filp == NULL) {
+ misp_err("%s - file didn't exist.", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_boot_code_end;
+ }
+
+ /*get the file size*/
+ currpos = vfs_llseek(filp, 0L, SEEK_END);
+ if (currpos == -1) {
+ misp_err("%s llseek failed", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_boot_code_end;
+ }
+ total_size = (u32)currpos;
+ /*misp_info("%s filesize : %d", __func__, total_size);*/
+ vfs_llseek(filp, 0L, SEEK_SET);
+
+ /*misp_info("block_size %d", RAWBLOCKSIZE);*/
+
+ /*Transfer boot code*/
+ /* boot code & main code can only be sent by SPI */
+ err = ispctrl_if_mast_send_bulk(devdata,
+ basic_code_buf_addr, filp, total_size, block_size, true);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_boot_code_end;
+
+ misp_info("%s send boot code success", __func__);
+
+
+
+ /* Get miniboot version */
+ set_fs(KERNEL_DS);
+ currpos = vfs_llseek(filp, total_size - 16, SEEK_SET);
+ err = vfs_read(filp, ProductId, 4, &filp->f_pos);
+ err = vfs_read(filp, miniboot_ver_major, 2, &filp->f_pos);
+ err = vfs_read(filp, miniboot_ver_minor, 2, &filp->f_pos);
+ err = vfs_read(filp, miniboot_build_by, 8, &filp->f_pos);
+ set_fs(oldfs);
+
+ if (err == -1) {
+ misp_info("%s - Read file failed.", __func__);
+ } else {
+ err = 0;
+ ProductId_val = (ProductId[3]<<24) + (ProductId[2]<<16) +
+ (ProductId[1] << 8) + ProductId[0];
+ miniboot_version_before_point = miniboot_ver_major[1]*256 +
+ miniboot_ver_major[0];
+ miniboot_version_after_point = miniboot_ver_minor[1]*256 +
+ miniboot_ver_minor[0];
+ miniboot_build_by[8] = '\0';
+ misp_info("%s - miniboot version: %d.%d.%d, build by %s",
+ __func__, ProductId_val, miniboot_version_before_point,
+ miniboot_version_after_point, miniboot_build_by);
+ }
+ /* Get miniboot version */
+
+
+mast_bulk_data_cmd_write_boot_code_end:
+
+ return err;
+}
+
+
+
+/**
+ *\brief Write Basic Code
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], basic code file pointer
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_basic_code(void *devdata,
+ u8 *param, struct file *filp)
+{
+ errcode err = ERR_SUCCESS;
+ u8 fw_version[4];
+ u32 para_size = ISPCMD_EXEBIN_INFOBYTES;
+ u32 *total_size = (u32 *)¶m[ISPCMD_EXEBIN_ADDRBYTES];
+ u32 file_total_size;
+ u32 block_size;
+ off_t currpos;
+ loff_t offset;
+ mm_segment_t oldfs;
+
+ if (filp == NULL) {
+ misp_err("%s - file didn't exist.", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_basic_code_end;
+ }
+
+ block_size = ((struct misp_data *)devdata)->bulk_cmd_blocksize;
+
+ oldfs = get_fs();
+ set_fs(KERNEL_DS);
+
+
+ /*get the file size*/
+ currpos = vfs_llseek(filp, 0L, SEEK_END);
+ if (currpos == -1) {
+ set_fs(oldfs);
+ misp_err("%s - llseek end failed", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_basic_code_end;
+ }
+
+ file_total_size = (u32)currpos;
+ /*misp_info("%s filesize : %u", __func__, file_total_size);*/
+
+ currpos = vfs_llseek(filp, 0L, SEEK_SET);
+ if (currpos == -1) {
+ set_fs(oldfs);
+ misp_err("%s - llseek set failed", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_basic_code_end;
+ }
+
+
+ /*read the header info (first 16 bytes in the basic code)*/
+ offset = filp->f_pos;
+ err = vfs_read(filp, param, ISPCMD_EXEBIN_INFOBYTES, &offset);
+ set_fs(oldfs);
+ if (err == -1) {
+ misp_err("%s - Read file failed.", __func__);
+ /*close the file*/
+ filp_close(filp, NULL);
+ goto mast_bulk_data_cmd_write_basic_code_end;
+ }
+ filp->f_pos = offset;
+
+ /*To copy checksum value to correct header point*/
+ memcpy((u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES + ISPCMD_EXEBIN_BLOCKSIZEBYTES),
+ (u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES), sizeof(u32));
+ /*Assign block size to correct header point*/
+ memcpy((u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES), &block_size, sizeof(u32));
+
+ /*misp_info("%s param[0][1][2][3]: %02x %02x %02x %02x",
+ *__func__, param[0], param[1], param[2], param[3]);
+ *misp_info("%s param[4][5][6][7]: %02x %02x %02x %02x",
+ *__func__, param[4], param[5], param[6], param[7]);
+ *misp_info("%s param[8][9][10][11]: %02x %02x %02x %02x",
+ *__func__, param[8], param[9], param[10], param[11]);
+ *misp_info("%s param[12][13][14][15]: %02x %02x %02x %02x",
+ *__func__, param[12], param[13], param[14], param[15]);
+ */
+
+ /*Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_WRITE_BASICCODE, param, para_size);
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_end;
+
+ /*misp_info("%s send leaking packet success", __func__);*/
+
+ /*misp_info("block_size %d", BLOCKSIZE);*/
+ misp_info("%s send basic code start", __func__);
+ /*Transfer basic code*/
+ err = ispctrl_if_mast_send_bulk(devdata,
+ basic_code_buf_addr, filp, *total_size, block_size, false);
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_end;
+
+ misp_info("%s - send basic code success", __func__);
+
+ /*wait for the interrupt*/
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_BULKDATA);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_end;
+
+ set_fs(KERNEL_DS);
+ offset = filp->f_pos;
+ currpos = vfs_llseek(filp, file_total_size - 32, SEEK_SET);
+ err = vfs_read(filp, fw_project_name, 16, &filp->f_pos);
+
+ currpos = vfs_llseek(filp, file_total_size - 12, SEEK_SET);
+ err = vfs_read(filp, fw_version, 4, &filp->f_pos);
+ err = vfs_read(filp, fw_build_by, 8, &filp->f_pos);
+ set_fs(oldfs);
+
+ if (err == -1) {
+ misp_info("%s - Read file failed.", __func__);
+ } else {
+ err = 0;
+ fw_version_before_point = fw_version[1]*256 + fw_version[0];
+ fw_version_after_point = fw_version[3]*256 + fw_version[2];
+ fw_build_by[8] = '\0';
+ fw_project_name[16] = '\0';
+ misp_info("%s project: %s, fw version: %05d.%05d, build by %s",
+ __func__, fw_project_name, fw_version_before_point,
+ fw_version_after_point, fw_build_by);
+}
+mast_bulk_data_cmd_write_basic_code_end:
+
+ return err;
+}
+
+/**
+ *\brief Write Basic Code (Short SPI Len)
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], basic code file pointer
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_basic_code_shortlen(
+ void *devdata, u8 *param, struct file *filp)
+{
+ errcode err = ERR_SUCCESS;
+ u8 fw_version[4];
+ /* u32 para_size = ISPCMD_EXEBIN_INFOBYTES; */
+ u32 *total_size = (u32 *)¶m[ISPCMD_EXEBIN_ADDRBYTES];
+ u32 file_total_size;
+ u32 block_size;
+ off_t currpos;
+ loff_t offset;
+ mm_segment_t oldfs;
+
+ if (filp == NULL) {
+ misp_err("%s - file didn't exist.", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+ }
+
+ block_size = SPI_BLOCK_LEN;
+
+ oldfs = get_fs();
+ set_fs(KERNEL_DS);
+
+
+ /*get the file size*/
+ currpos = vfs_llseek(filp, 0L, SEEK_END);
+ if (currpos == -1) {
+ set_fs(oldfs);
+ misp_err("%s - llseek end failed", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+ }
+
+ file_total_size = (u32)currpos;
+ /*misp_info("%s filesize : %u", __func__, file_total_size);*/
+
+ currpos = vfs_llseek(filp, 0L, SEEK_SET);
+ if (currpos == -1) {
+ set_fs(oldfs);
+ misp_err("%s - llseek set failed", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+ }
+
+
+ /*read the header info (first 16 bytes in the basic code)*/
+ offset = filp->f_pos;
+ err = vfs_read(filp, param, ISPCMD_EXEBIN_INFOBYTES, &offset);
+ set_fs(oldfs);
+ if (err == -1) {
+ misp_err("%s - Read file failed.", __func__);
+ /*close the file*/
+ filp_close(filp, NULL);
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+ }
+ filp->f_pos = offset;
+
+ /*To copy checksum value to correct header point*/
+ memcpy((u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES + ISPCMD_EXEBIN_BLOCKSIZEBYTES),
+ (u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES), sizeof(u32));
+ /*Assign block size to correct header point*/
+ memcpy((u8 *)(param + ISPCMD_EXEBIN_ADDRBYTES +
+ ISPCMD_EXEBIN_TOTALSIZEBYTES), &block_size, sizeof(u32));
+
+
+ /*misp_info("%s param[0][1][2][3]: %02x %02x %02x %02x",
+ *__func__, param[0], param[1], param[2], param[3]);
+ *misp_info("%s param[4][5][6][7]: %02x %02x %02x %02x",
+ *__func__, param[4], param[5], param[6], param[7]);
+ *misp_info("%s param[8][9][10][11]: %02x %02x %02x %02x",
+ *__func__, param[8], param[9], param[10], param[11]);
+ *misp_info("%s param[12][13][14][15]: %02x %02x %02x %02x",
+ *__func__, param[12], param[13], param[14], param[15]);
+ */
+
+
+ /* misp_info("%s Main Code Address >>>> param[0]: %04x",
+ * __func__, *(u32 *)¶m[0]);
+ * misp_info("%s Main Code Size >>>> param[4]: %04x",
+ * __func__, *(u32 *)¶m[4]);
+ * misp_info("%s Main Code Checksum >>>> param[12]: %04x",
+ * __func__, *(u32 *)¶m[12]);
+ */
+
+ /*Send command to slave*/
+ /* Step 1: Main Code Address */
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_WRITE_BASICCODE_CODEADDR,
+ ¶m[0], ISPCMD_EXEBIN_ADDRBYTES);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+
+ msleep(20); /*mdelay(1);*/
+
+ /* Step 2: Main Code Size */
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_WRITE_BASICCODE_CODESIZE,
+ ¶m[4], ISPCMD_EXEBIN_TOTALSIZEBYTES);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+
+ msleep(20); /*mdelay(1);*/
+
+ /* Step 3: Main Code Checksum */
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_WRITE_BASICCODE_CODESUM,
+ ¶m[12], ISPCMD_EXEBIN_CKSUMBYTES);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+
+
+ /*misp_info("%s send leaking packet success", __func__);*/
+
+ /*misp_info("block_size %d", BLOCKSIZE);*/
+ misp_info("%s send basic code start", __func__);
+ /*Transfer basic code*/
+ err = ispctrl_if_mast_send_bulk(devdata,
+ basic_code_buf_addr, filp, *total_size, block_size, false);
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+
+ misp_info("%s - send basic code success", __func__);
+
+
+ /* mdelay(1); */
+
+ /* wait for the interrupt */
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_BULKDATA);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_basic_code_shortlen_end;
+
+ set_fs(KERNEL_DS);
+ offset = filp->f_pos;
+ currpos = vfs_llseek(filp, file_total_size - 12, SEEK_SET);
+ err = vfs_read(filp, fw_version, 4, &filp->f_pos);
+ err = vfs_read(filp, fw_build_by, 8, &filp->f_pos);
+ set_fs(oldfs);
+
+ if (err == -1) {
+ misp_info("%s - Read file failed.", __func__);
+ } else {
+ err = 0;
+ fw_version_before_point = fw_version[1]*256 + fw_version[0];
+ fw_version_after_point = fw_version[3]*256 + fw_version[2];
+ fw_build_by[8] = '\0';
+ misp_info("%s - fw version: %05d.%05d, build by %s",
+ __func__, fw_version_before_point,
+ fw_version_after_point, fw_build_by);
+}
+mast_bulk_data_cmd_write_basic_code_shortlen_end:
+
+ return err;
+}
+
+/**
+ *\brief Write Calibration Data
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], calibration data file pointer
+ *\return Error code
+ */
+errcode
+mast_bulk_data_cmd_write_calibration_data(void *devdata,
+ u8 *param, struct file *filp)
+{
+ errcode err = ERR_SUCCESS;
+ u8 infomode;
+ u16 opcode;
+ u16 ckecksum;
+ u32 para_size = 11;
+ u32 filesize;
+ u32 block_size;
+ off_t currpos;
+ loff_t offset;
+ mm_segment_t oldfs;
+
+ infomode = param[8];
+ block_size = ((struct misp_data *)devdata)->bulk_cmd_blocksize;
+
+ /* Trasfered files have been opened in kernel
+ * when mini_isp_drv_load_fw()
+ */
+ if (((infomode >= 2) && (infomode < 7)) || (infomode == 8)) {
+ if (filp == NULL) {
+ misp_err("%s - file didn't exist.", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_calibration_data_end;
+ }
+
+ oldfs = get_fs();
+ set_fs(KERNEL_DS);
+
+ /*get the file size*/
+ currpos = vfs_llseek(filp, 0L, SEEK_END);
+ if (currpos == -1) {
+ set_fs(oldfs);
+ misp_err("%s llseek end failed", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_calibration_data_end;
+ }
+
+ filesize = (u32)currpos;
+ /*misp_info("%s filesize : %u", __func__, filesize);*/
+
+ currpos = vfs_llseek(filp, 0L, SEEK_SET);
+ if (currpos == -1) {
+ set_fs(oldfs);
+ misp_err("%s llseek set failed", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_calibration_data_end;
+ }
+
+ /*Request memory*/
+ calibration_data_buf_addr = kzalloc(filesize, GFP_KERNEL);
+ if (!calibration_data_buf_addr) {
+ err = ~ERR_SUCCESS;
+ kfree(calibration_data_buf_addr);
+ goto mast_bulk_data_cmd_write_calibration_data_fail;
+ }
+
+ /* if the file is SC table, print the SC table built day */
+ if (infomode == 2) {
+ vfs_llseek(filp, 16, SEEK_SET);
+ vfs_read(filp, calibration_data_buf_addr, 4,
+ &filp->f_pos);
+ sc_build_date =
+ calibration_data_buf_addr[3]*256*256*256 +
+ calibration_data_buf_addr[2]*256*256 +
+ calibration_data_buf_addr[1]*256 +
+ calibration_data_buf_addr[0];
+ misp_info("%s - SC table build date %d.", __func__,
+ sc_build_date);
+ vfs_llseek(filp, 0L, SEEK_SET);
+ }
+
+ /*read the header info (first 16 bytes in the data)*/
+ offset = filp->f_pos;
+ err = vfs_read(filp, calibration_data_buf_addr, filesize,
+ &offset);
+ set_fs(oldfs);
+ if (err == -1) {
+ misp_err("%s Read file failed.", __func__);
+ /*close the file*/
+ filp_close(filp, NULL);
+ kfree(calibration_data_buf_addr);
+ goto mast_bulk_data_cmd_write_calibration_data_end;
+ }
+ filp->f_pos = offset;
+ vfs_llseek(filp, 0L, SEEK_SET);
+
+ ckecksum = calculate_check_sum((u8 *) calibration_data_buf_addr,
+ filesize);
+
+ /*Assign Info ID to correct header point*/
+ memcpy((u8 *)(param + 8), &infomode, sizeof(u8));
+ /*To copy Total Size to correct header point*/
+ memcpy((u8 *)param, &filesize, sizeof(u32));
+ /*Assign block size to correct header point*/
+ memcpy((u8 *)(param + 4), &block_size, sizeof(u32));
+ /*Assign check sum to correct header point*/
+ memcpy((u8 *)(param + 9), &ckecksum, sizeof(u16));
+ /*
+ * misp_info("%s [0][1][2][3]:%02x %02x %02x %02x",
+ * __func__, param[0], param[1], param[2], param[3]);
+ * misp_info("%s [4][5][6][7]:%02x %02x %02x %02x",
+ * __func__, param[4], param[5], param[6], param[7]);
+ * misp_info("%s [8][9][10]:%02x %02x %02x",
+ * __func__, param[8], param[9], param[10]);
+ */
+
+ /* Trasfered buffer has opened in user space and passed to kernel.*/
+ } else {
+ memcpy(&filesize, param, sizeof(u32));
+ calibration_data_buf_addr = kzalloc(filesize, GFP_KERNEL);
+
+ if (!calibration_data_buf_addr) {
+ err = ~ERR_SUCCESS;
+ kfree(calibration_data_buf_addr);
+ goto mast_bulk_data_cmd_write_calibration_data_fail;
+ }
+ memcpy(calibration_data_buf_addr,
+ param + T_SPI_CMD_LENGTH, filesize);
+ }
+
+ if (SPI_SHORT_LEN_MODE && SPI_SHORT_LEN_MODE_WRITE_ENABLE) {
+ opcode = ISPCMD_BULK_WRITE_CALIBRATION_NO_BLOCK;
+ /* Total size(4byte) + data id(1byte) + checksum(2byte)*/
+ para_size = 7;
+ /* left shift 4byte */
+ memcpy((u8 *)(param + 4), (u8 *)(param + 8),
+ sizeof(u32) + sizeof(u16));
+ block_size = SPI_BLOCK_LEN;
+ } else
+ opcode = ISPCMD_BULK_WRITE_CALIBRATION_DATA;
+
+ /*Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ opcode, param, para_size);
+
+ if (err != ERR_SUCCESS) {
+ kfree(calibration_data_buf_addr);
+ goto mast_bulk_data_cmd_write_calibration_data_end;
+ }
+
+ /*misp_info("%s send leaking packet success", __func__);*/
+ /*misp_info("block_size %d", BLOCKSIZE);*/
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_CMD_READY);
+ if (err)
+ goto mast_bulk_data_cmd_write_calibration_data_fail;
+
+ err = ispctrl_if_mast_send_bulk(devdata,
+ calibration_data_buf_addr, filp, filesize, block_size,
+ false);
+
+ kfree(calibration_data_buf_addr);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_calibration_data_end;
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_BULKDATA);
+ if (err)
+ goto mast_bulk_data_cmd_write_calibration_data_fail;
+
+ if (infomode == 0)
+ misp_info("%s write IQ calibration data success", __func__);
+ else if (infomode == 1)
+ misp_info("%s write depth packet data success", __func__);
+ else if (infomode == 2)
+ misp_info("%s write scenario table success", __func__);
+ else if (infomode == 3)
+ misp_info("%s write HDR Qmerge data success", __func__);
+ else if (infomode == 4)
+ misp_info("%s write IRP0 Qmerge data success", __func__);
+ else if (infomode == 5)
+ misp_info("%s write IRP1 Qmerge data success", __func__);
+ else if (infomode == 6)
+ misp_info("%s write PP map success", __func__);
+ else if (infomode == 7)
+ misp_info("%s write blending table success", __func__);
+ else if (infomode == 8)
+ misp_info("%s write Depth Qmerge data success", __func__);
+
+ goto mast_bulk_data_cmd_write_calibration_data_end;
+
+mast_bulk_data_cmd_write_calibration_data_fail:
+ misp_err("%s mast_bulk_data_cmd_write_calibration_data_fail", __func__);
+
+mast_bulk_data_cmd_write_calibration_data_end:
+ return err;
+
+}
+
+#endif
+
+/*
+ *\brief Read Calibration Data
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_read_calibration_data(void *devdata,
+ u8 *param)
+{
+ /*Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 *allocated_memmory = NULL;
+ u32 read_size = 0;
+ u8 filename[80];
+ /*
+ *Parameter size
+ *4bytes for start addr, 4 bytes for total size, 4 bytes for block size,
+ *4 bytes for memory dump mode
+ */
+ u32 para_size = sizeof(struct memmory_dump_hdr_info);
+ /*Total size*/
+ u32 total_size;
+ struct memmory_dump_hdr_info *memory_dump_hdr_config;
+ struct file *f;
+ mm_segment_t fs;
+
+ read_size = MID_PJ_EXEBIN_BUF;
+
+ /*Request memory*/
+ allocated_memmory = kzalloc(read_size, GFP_KERNEL);
+ if (!allocated_memmory) {
+ err = ~ERR_SUCCESS;
+ misp_err("%s Allocate memory failed.", __func__);
+ goto allocate_memory_fail;
+ }
+
+
+ memory_dump_hdr_config = (struct memmory_dump_hdr_info *)param;
+
+ /*Assign total size*/
+ total_size = memory_dump_hdr_config->total_size;
+ if (total_size > read_size) {
+ err = ERR_MASTERCMDSIZE_MISMATCH;
+ kfree(allocated_memmory);
+ misp_err("%s total_size error.", __func__);
+ goto mast_bulk_data_cmd_read_memory_data_end;
+ }
+
+ /*Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_READ_CALIBRATION_DATA, param, para_size);
+ if (err != ERR_SUCCESS) {
+ kfree(allocated_memmory);
+ misp_err("%s send command fail, 0x%x.", __func__, err);
+ goto mast_bulk_data_cmd_read_memory_data_end;
+ }
+ /*Get memory data from slave*/
+ err = ispctrl_if_mast_recv_memory_data_from_slave(devdata,
+ allocated_memmory,
+ &total_size,
+ memory_dump_hdr_config->block_size,
+ true);
+ if (err != ERR_SUCCESS) {
+ kfree(allocated_memmory);
+ misp_err("%s get bulk fail, 0x%x.", __func__, err);
+ goto mast_bulk_data_cmd_read_memory_data_end;
+ }
+
+ misp_info("%s - Read memory finished.", __func__);
+ /*write out allocated_memmory to file here*/
+ /*** add your codes here ***/
+ snprintf(filename, 80, "%s/READ_OTP_DATA.bin",
+ MINIISP_INFO_DUMPLOCATION);
+#if ENABLE_FILP_OPEN_API
+ /* use file open */
+#else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ goto file_open_fail;
+#endif
+ /*Get current segment descriptor*/
+ fs = get_fs();
+ /*Set segment descriptor associated*/
+ set_fs(get_ds());
+
+ if (IS_ERR(f)) {
+ err = PTR_ERR(f);
+ misp_err("%s open file failed. err: %d", __func__, err);
+ set_fs(fs);
+ goto file_open_fail;
+ }
+
+ /*write the file*/
+ vfs_write(f, (char *)allocated_memmory, total_size,
+ &f->f_pos);
+
+ /*Restore segment descriptor*/
+ set_fs(fs);
+ filp_close(f, NULL);
+ /*** end of the codes ***/
+file_open_fail:
+ kfree(allocated_memmory);
+allocate_memory_fail:
+mast_bulk_data_cmd_read_memory_data_end:
+
+ return err;
+
+
+}
+
+/*
+ *\brief Read Memory Data
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_read_memory_data(void *devdata,
+ u8 *param)
+{
+ /*Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 *allocated_memmory = NULL;
+ u32 read_size = 0;
+ u8 filename[80];
+ /*
+ *Parameter size
+ *4bytes for start addr, 4 bytes for total size, 4 bytes for block size,
+ *4 bytes for memory dump mode
+ */
+ u32 para_size = sizeof(struct memmory_dump_hdr_info);
+ /*Total size*/
+ u32 total_size;
+ struct memmory_dump_hdr_info *memory_dump_hdr_config;
+ struct file *f;
+ mm_segment_t fs;
+
+ read_size = MID_PJ_EXEBIN_BUF;
+
+ /*Request memory*/
+ allocated_memmory = kzalloc(read_size, GFP_KERNEL);
+ if (!allocated_memmory) {
+ err = ~ERR_SUCCESS;
+ misp_err("%s Allocate memory failed.", __func__);
+ goto allocate_memory_fail;
+ }
+
+
+ memory_dump_hdr_config = (struct memmory_dump_hdr_info *)param;
+
+ /*Assign total size*/
+ total_size = memory_dump_hdr_config->total_size;
+ if (total_size > read_size) {
+ kfree(allocated_memmory);
+ err = ERR_MASTERCMDSIZE_MISMATCH;
+ misp_err("%s total_size error.", __func__);
+ goto mast_bulk_data_cmd_read_memory_data_end;
+ }
+
+ /*Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_READ_MEMORY, param, para_size);
+ if (err != ERR_SUCCESS) {
+ kfree(allocated_memmory);
+ misp_err("%s send command fail, 0x%x.", __func__, err);
+ goto mast_bulk_data_cmd_read_memory_data_end;
+ }
+ /*Get memory data from slave*/
+ err = ispctrl_if_mast_recv_memory_data_from_slave(devdata,
+ allocated_memmory,
+ &total_size,
+ memory_dump_hdr_config->block_size,
+ true);
+ if (err != ERR_SUCCESS) {
+ kfree(allocated_memmory);
+ misp_err("%s get bulk fail, 0x%x.", __func__, err);
+ goto mast_bulk_data_cmd_read_memory_data_end;
+ }
+
+ misp_info("%s - Read memory finished.", __func__);
+ /*write out allocated_memmory to file here*/
+ /*** add your codes here ***/
+ snprintf(filename, 80, "%s/miniISP_memory.log",
+ MINIISP_INFO_DUMPLOCATION);
+#if ENABLE_FILP_OPEN_API
+ /* use file open */
+#else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ goto file_open_fail;
+#endif
+ /*Get current segment descriptor*/
+ fs = get_fs();
+ /*Set segment descriptor associated*/
+ set_fs(get_ds());
+
+ if (IS_ERR(f)) {
+ err = PTR_ERR(f);
+ misp_err("%s open file failed. err: %d", __func__, err);
+ set_fs(fs);
+ goto file_open_fail;
+ }
+
+ /*write the file*/
+ vfs_write(f, (char *)allocated_memmory, total_size,
+ &f->f_pos);
+
+ /*Restore segment descriptor*/
+ set_fs(fs);
+ filp_close(f, NULL);
+ /*** end of the codes ***/
+file_open_fail:
+ kfree(allocated_memmory);
+allocate_memory_fail:
+mast_bulk_data_cmd_read_memory_data_end:
+
+ return err;
+}
+
+/*
+ *\brief Read common log data
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode bulk_data_cmd_read_common_log(void *devdata, u8 *param)
+{
+ /*Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 *allocated_memmory = NULL;
+ u32 read_size = LOGSIZE;
+ struct file *f = NULL;
+ mm_segment_t fs;
+ u8 filename[80];
+
+ /*Parameter size : 4 bytes for total size, 4 bytes for block size*/
+ u32 para_size = sizeof(struct common_log_hdr_info);
+ /*Total size*/
+ u32 total_size;
+ struct common_log_hdr_info *common_log_hdr_cfg;
+
+
+ /*Request memory*/
+ allocated_memmory = kzalloc(read_size, GFP_KERNEL);
+ if (!allocated_memmory) {
+ err = ~ERR_SUCCESS;
+ goto allocate_memory_fail;
+ }
+
+
+ common_log_hdr_cfg = (struct common_log_hdr_info *)param;
+
+ /*Assign total size*/
+ total_size = common_log_hdr_cfg->total_size;
+ if (total_size > read_size) {
+ err = ERR_MASTERCMDSIZE_MISMATCH;
+ kfree(allocated_memmory);
+ goto bulk_data_cmd_read_common_log_end;
+ }
+
+ /*Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_READ_COMLOG, param, para_size);
+ if (err != ERR_SUCCESS) {
+ kfree(allocated_memmory);
+ misp_info("%s err - 0x%x.", __func__, err);
+ goto bulk_data_cmd_read_common_log_end;
+ }
+ misp_info("%s - Start to read log.", __func__);
+
+ /*
+ *Get memory data from slave,don't wait INT
+ *and use polling interval to wait
+ */
+ err = ispctrl_if_mast_recv_memory_data_from_slave(devdata,
+ allocated_memmory,
+ &total_size,
+ common_log_hdr_cfg->block_size,
+ true);
+ if (err != ERR_SUCCESS) {
+ kfree(allocated_memmory);
+ goto bulk_data_cmd_read_common_log_end;
+ }
+ misp_info("%s - Read log finished.", __func__);
+ snprintf(filename, 80, "%s/miniISP_Common_Log.log",
+ MINIISP_INFO_DUMPLOCATION);
+#if ENABLE_FILP_OPEN_API
+ /* use file open */
+#else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ kfree(allocated_memmory);
+ goto bulk_data_cmd_read_common_log_end;
+#endif
+ /*Get current segment descriptor*/
+ fs = get_fs();
+
+ /*Set segment descriptor associated*/
+ set_fs(get_ds());
+
+ if (IS_ERR(f)) {
+ err = PTR_ERR(f);
+ misp_err("%s open file failed. err: %d", __func__, err);
+ goto file_open_fail;
+ }
+ /*write the file*/
+ vfs_write(f, (char *)allocated_memmory, strlen(allocated_memmory),
+ &f->f_pos);
+
+file_open_fail:
+ /*Restore segment descriptor*/
+ set_fs(fs);
+ filp_close(f, NULL);
+
+ kfree(allocated_memmory);
+ goto bulk_data_cmd_read_common_log_end;
+allocate_memory_fail:
+
+ misp_err("%s Allocate memory failed.", __func__);
+bulk_data_cmd_read_common_log_end:
+ return err;
+}
+
+
+/*
+ *\brief Get depth Rect A, B, Invrect
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_depth_rectab_invrect(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /*Error Code */
+ errcode err = ERR_SUCCESS;
+ u8 *allocated_memmory = 0;
+ u32 para_size = 0;
+ u32 rect_set_num = 0;
+ u32 send_total_bulk_size = 0;
+ u8 send_cmd[T_SPI_CMD_LENGTH];
+ struct isp_cmd_depth_rectab_invrect_info *depth_rect_info;
+
+ depth_rect_info = (struct isp_cmd_depth_rectab_invrect_info *)param;
+ if (depth_rect_info->trans_mode == 0)
+ rect_set_num = 3;
+ else
+ rect_set_num = 1;
+
+ send_total_bulk_size =
+ rect_set_num*sizeof(struct depth_rectab_invrect_param);
+
+ /* Fill command buffer for send */
+ memcpy(&send_cmd[0], &(depth_rect_info->trans_mode),
+ sizeof(depth_rect_info->trans_mode));
+ para_size = sizeof(depth_rect_info->trans_mode);
+
+ memcpy(&send_cmd[para_size], &(depth_rect_info->block_size),
+ sizeof(depth_rect_info->block_size));
+ para_size += sizeof(depth_rect_info->block_size);
+
+ /*Request memory*/
+ allocated_memmory = kzalloc(send_total_bulk_size, GFP_KERNEL);
+ if (!allocated_memmory) {
+ err = ~ERR_SUCCESS;
+ goto allocate_memory_fail;
+ }
+
+ /*Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ ISPCMD_BULK_WRITE_DEPTH_RECTAB_INVRECT,
+ (u8 *)&send_cmd[0], para_size);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_depth_rectab_invrect_end;
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_CMD_READY);
+ if (err)
+ goto mast_bulk_data_cmd_write_depth_rectab_invrect_end;
+
+#if ENABLE_LINUX_FW_LOADER
+ /* Send bulk data to slave*/
+ err = ispctrl_if_mast_send_bulk(
+ devdata,
+ (u8 *)&depth_rect_info->rect_param[0],
+ send_total_bulk_size,
+ depth_rect_info->block_size, false);
+#else
+ /* Send bulk data to slave*/
+ err = ispctrl_if_mast_send_bulk(
+ devdata,
+ (u8 *)&depth_rect_info->rect_param[0],
+ NULL, send_total_bulk_size,
+ depth_rect_info->block_size, false);
+#endif
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_depth_rectab_invrect_end;
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_BULKDATA);
+ if (err)
+ goto mast_bulk_data_cmd_write_depth_rectab_invrect_end;
+
+mast_bulk_data_cmd_write_depth_rectab_invrect_end:
+ kfree(allocated_memmory);
+ allocated_memmory = NULL;
+
+allocate_memory_fail:
+ misp_err("%s Allocate memory failed.", __func__);
+
+ return err;
+}
+
+#if ENABLE_LINUX_FW_LOADER
+/**
+ *\brief Write Spinor Data
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], the data file pointer
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_spinor_data(void *devdata,
+ u8 *param)
+{
+ errcode err = ERR_SUCCESS;
+ u8 infomode;
+ u16 opcode;
+ u16 ckecksum;
+ u32 para_size = 11;
+ u32 filesize;
+ u32 block_size;
+ const char *file_name;
+ const struct firmware *fw = NULL;
+ struct device *mini_isp_device;
+ const u8 *fw_data;
+
+ infomode = param[8];
+ block_size = ((struct misp_data *)devdata)->bulk_cmd_blocksize;
+
+ if (infomode == 0)
+ file_name = strrchr(
+ BOOT_FILE_LOCATION ?
+ BOOT_FILE_LOCATION : "", '/');
+ else if (infomode == 1)
+ file_name = strrchr(
+ BASIC_FILE_LOCATION ?
+ BASIC_FILE_LOCATION : "", '/');
+ else {
+ misp_err("%s not support infomode: %x", __func__, infomode);
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ }
+
+ mini_isp_device = mini_isp_getdev();
+ if (mini_isp_device != NULL && file_name != NULL) {
+ /* skip char '/' */
+ if (file_name != NULL)
+ file_name = file_name + 1;
+
+ misp_info("%s, fw name: %s", __func__, file_name);
+ err = request_firmware(&fw,
+ file_name, mini_isp_device);
+
+ if (err) {
+ misp_info("%s, L: %d, err: %d",
+ __func__, __LINE__, err);
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ }
+ }
+
+ if (fw == NULL) {
+ misp_info("%s, fw:%s is NULL.", __func__, file_name);
+ return -EINVAL;
+ }
+
+ /*get the file size*/
+ filesize = fw->size;
+ fw_data = fw->data;
+
+ ckecksum = calculate_check_sum(fw_data, filesize);
+ misp_info("ckecksum %d", ckecksum);
+ /*Assign Info ID to correct header point*/
+ memcpy((u8 *)(param + 8), &infomode, sizeof(u8));
+ /*To copy Total Size to correct header point*/
+ memcpy((u8 *)param, &filesize, sizeof(u32));
+ /*Assign block size to correct header point*/
+ memcpy((u8 *)(param + 4), &block_size, sizeof(u32));
+ /*Assign check sum to correct header point*/
+ memcpy((u8 *)(param + 9), &ckecksum, sizeof(u16));
+
+ opcode = ISPCMD_BULK_WRITE_SPINOR_DATA;
+
+ /*Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ opcode, param, para_size);
+ if (err != ERR_SUCCESS) {
+ misp_info("%s, L: %d, err: %d", __func__, __LINE__, err);
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ }
+
+ /*misp_info("%s send leaking packet success", __func__);*/
+
+ /*misp_info("block_size %d", BLOCKSIZE);*/
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_CMD_READY);
+ if (err) {
+ misp_info("%s, L: %d, err: %d", __func__, __LINE__, err);
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ }
+
+ err = ispctrl_if_mast_send_bulk(devdata,
+ fw_data, filesize, block_size, false);
+
+ if (err != ERR_SUCCESS) {
+ misp_info("%s, L: %d, err: %d", __func__, __LINE__, err);
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ }
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_BULKDATA);
+
+ if (err) {
+ misp_info("%s, L: %d, err: %d", __func__, __LINE__, err);
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ }
+
+ if (infomode == 0)
+ misp_info("%s write spinor boot data success", __func__);
+ else if (infomode == 1)
+ misp_info("%s write spinor main data success", __func__);
+
+mast_bulk_data_cmd_write_spinor_data_end:
+ if (fw != NULL)
+ release_firmware(fw);
+
+ return err;
+
+}
+
+#else
+/**
+ *\brief Write Spinor Data
+ *\param devdata [In], misp_data
+ *\param param [In], CMD param
+ *\param filp [In], the data file pointer
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_spinor_data(void *devdata,
+ u8 *param, struct file *filp)
+{
+ errcode err = ERR_SUCCESS;
+ u8 infomode;
+ u16 opcode;
+ u16 ckecksum;
+ u32 para_size = 11;
+ u32 filesize;
+ u32 block_size;
+ off_t currpos;
+ loff_t offset;
+ mm_segment_t oldfs;
+
+ infomode = param[8];
+ block_size = ((struct misp_data *)devdata)->bulk_cmd_blocksize;
+
+ oldfs = get_fs();
+ set_fs(KERNEL_DS);
+
+#if ENABLE_FILP_OPEN_API
+ /* use file open */
+#else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ set_fs(oldfs);
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+#endif
+ if (IS_ERR(filp)) {
+ err = PTR_ERR(filp);
+ misp_err("%s open file failed. err: %x", __func__, err);
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ } else {
+ misp_info("%s open file success!", __func__);
+ }
+
+ /*get the file size*/
+ currpos = vfs_llseek(filp, 0L, SEEK_END);
+ if (currpos == -1) {
+ set_fs(oldfs);
+ misp_err("%s llseek end failed", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ }
+
+ filesize = (u32)currpos;
+ /*misp_info("%s filp: %p, filesize : %u, blocksize : %u"
+ * , __func__, filp, filesize, block_size);
+ */
+
+ currpos = vfs_llseek(filp, 0L, SEEK_SET);
+ if (currpos == -1) {
+ set_fs(oldfs);
+ misp_err("%s llseek set failed", __func__);
+ err = ~ERR_SUCCESS;
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ }
+
+ /*Request memory*/
+ calibration_data_buf_addr = vmalloc(filesize);
+ if (!calibration_data_buf_addr) {
+ err = ~ERR_SUCCESS;
+ vfree(calibration_data_buf_addr);
+ goto mast_bulk_data_cmd_write_spinor_data_fail;
+ }
+
+ offset = filp->f_pos;
+ err = vfs_read(filp, calibration_data_buf_addr, filesize, &offset);
+ filp->f_pos = offset;
+
+ set_fs(oldfs);
+ if (err == -1) {
+ misp_err("%s Read file failed.", __func__);
+ /*close the file*/
+ filp_close(filp, NULL);
+ vfree(calibration_data_buf_addr);
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ }
+ vfs_llseek(filp, 0L, SEEK_SET);
+
+ ckecksum = calculate_check_sum((u8 *) calibration_data_buf_addr,
+ filesize);
+ misp_info("ckecksum %d", ckecksum);
+ /*Assign Info ID to correct header point*/
+ memcpy((u8 *)(param + 8), &infomode, sizeof(u8));
+ /*To copy Total Size to correct header point*/
+ memcpy((u8 *)param, &filesize, sizeof(u32));
+ /*Assign block size to correct header point*/
+ memcpy((u8 *)(param + 4), &block_size, sizeof(u32));
+ /*Assign check sum to correct header point*/
+ memcpy((u8 *)(param + 9), &ckecksum, sizeof(u16));
+
+ opcode = ISPCMD_BULK_WRITE_SPINOR_DATA;
+
+ /*Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata,
+ opcode, param, para_size);
+ if (err != ERR_SUCCESS) {
+ vfree(calibration_data_buf_addr);
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+ }
+
+ /*misp_info("%s send leaking packet success", __func__);*/
+
+ /*misp_info("block_size %d", BLOCKSIZE);*/
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_CMD_READY);
+ if (err)
+ goto mast_bulk_data_cmd_write_spinor_data_fail;
+
+ err = ispctrl_if_mast_send_bulk(devdata,
+ calibration_data_buf_addr, filp, filesize, block_size,
+ false);
+
+ if (err != ERR_SUCCESS)
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_BULKDATA);
+
+ vfree(calibration_data_buf_addr);
+
+ if (err)
+ goto mast_bulk_data_cmd_write_spinor_data_fail;
+
+ if (infomode == 0)
+ misp_info("%s write spinor boot data success", __func__);
+ else if (infomode == 1)
+ misp_info("%s write spinor main data success", __func__);
+
+ goto mast_bulk_data_cmd_write_spinor_data_end;
+
+mast_bulk_data_cmd_write_spinor_data_fail:
+ misp_err("%s mast_bulk_data_cmd_write_spinor_data_fail", __func__);
+
+mast_bulk_data_cmd_write_spinor_data_end:
+
+ /*close the file*/
+ filp_close(filp, NULL);
+
+ return err;
+
+}
+#endif
+
+/******Private Function******/
+static
+u16 calculate_check_sum(const u8 *input_buffer_addr, u32 input_buffer_size)
+{
+ u32 i;
+ u32 sum = 0;
+ u16 sumvalue;
+
+ if (input_buffer_size > MAX_BUFFER_SIZE) {
+ misp_err("%s input buffer size:%d out of bound.",
+ __func__, input_buffer_size);
+ return 0;
+ }
+
+ /*calculating unit is 2 bytes */
+ for (i = 0; i < input_buffer_size; i++) {
+ if (0 == (i%2))
+ sum += input_buffer_addr[i];
+ else
+ sum += (input_buffer_addr[i] << 8);
+ }
+
+ /*Do 2's complement */
+ sumvalue = (u16)(65536 - (sum & 0x0000FFFF));
+
+ return sumvalue;
+}
+
+/******End Of File******/
diff --git a/drivers/media/platform/altek/camera_profile_cmd.c b/drivers/media/platform/altek/camera_profile_cmd.c
new file mode 100755
index 0000000..a1ab39f
--- /dev/null
+++ b/drivers/media/platform/altek/camera_profile_cmd.c
@@ -0,0 +1,716 @@
+/*
+ * File: camera_profile_cmd.c
+ * Description: Mini ISP sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/10/14; Bruce Chung; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/******Include File******/
+
+#include <linux/string.h>
+
+#include "include/mtype.h"
+#include "include/error.h"
+#include "include/miniisp.h"
+#include "include/isp_camera_cmd.h"
+#include "include/ispctrl_if_master.h"
+#include "include/ispctrl_if_master_local.h"
+
+/******Private Constant Definition******/
+#define MINI_ISP_LOG_TAG "[[miniisp]camera_profile_cmd]"
+
+/******Private Type Declaration******/
+
+/******Private Function Prototype******/
+
+/******Private Global Variable******/
+
+static struct isp_cmd_get_sensor_mode mast_sensors_info;
+
+/******Public Function******/
+
+/*
+ *\brief Camera profile parameters init
+ *\return None
+ */
+void isp_mast_camera_profile_para_init(void)
+{
+ /*Reset Camera profile parameters*/
+ memset(&mast_sensors_info, 0x0,
+ sizeof(struct isp_cmd_get_sensor_mode));
+}
+
+/*
+ *\brief Set Sensor Mode
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_sensor_mode(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_set_sensor_mode *set_sensor_mode_param;
+
+ set_sensor_mode_param = (struct isp_cmd_set_sensor_mode *)param;
+ misp_info("%s - enter", __func__);
+ misp_info("[on/off]: %d, [id]:%d, [txskew]: %d",
+ set_sensor_mode_param->sensor_on_off,
+ set_sensor_mode_param->scenario_id,
+ set_sensor_mode_param->mipi_tx_skew);
+
+ misp_info("[w_tbl_idx]: %d, [merge_enable]:%d",
+ set_sensor_mode_param->ae_weighting_table_index,
+ set_sensor_mode_param->merge_mode_enable);
+
+ para_size = sizeof(struct isp_cmd_set_sensor_mode);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+
+
+ if ((((struct isp_cmd_set_sensor_mode *)param)->sensor_on_off)
+ && (err == ERR_SUCCESS))
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_SETSENSORMODE);
+
+ return err;
+}
+
+/*
+ *\brief Get Sensor Mode
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_get_sensor_mode(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+
+ misp_info("%s - enter", __func__);
+
+ para_size = sizeof(struct isp_cmd_get_sensor_mode);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode, NULL, 0);
+ if (err != ERR_SUCCESS)
+ goto mast_camera_profile_cmd_get_sensor_mode_end;
+
+ /* Get data from slave*/
+ err = ispctrl_mast_recv_response_from_slave(devdata,
+ (u8 *)&mast_sensors_info, para_size, true);
+ if (err != ERR_SUCCESS)
+ goto mast_camera_profile_cmd_get_sensor_mode_end;
+
+ /* copy to usr defined target addr*/
+ memcpy(param, &mast_sensors_info, para_size);
+
+mast_camera_profile_cmd_get_sensor_mode_end:
+ return err;
+}
+
+/*
+ *\brief Set Output Format
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_output_format(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_set_output_format *set_output_format_param;
+
+ set_output_format_param = (struct isp_cmd_set_output_format *)param;
+
+ misp_info("%s - enter", __func__);
+ misp_info("[DP_size]: 0x%x, [DP_Type_LV]: 0x%x, [InvRect_bypass]: 0x%x",
+ set_output_format_param->depth_size,
+ set_output_format_param->reserve[0],
+ set_output_format_param->reserve[1]);
+
+ para_size = sizeof(struct isp_cmd_set_output_format);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode, param,
+ para_size);
+ return err;
+}
+
+/*
+ *\brief Set CP Mode
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_cp_mode(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+
+ misp_info("%s - enter", __func__);
+
+ para_size = 0;
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ if (err != ERR_SUCCESS)
+ goto mast_camera_profile_cmd_set_cp_mode_end;
+
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_CPCHANGE);
+
+mast_camera_profile_cmd_set_cp_mode_end:
+ return err;
+}
+
+/*
+ *\brief Set AE statistics
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_ae_statistics(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /*Error Code */
+ errcode err = ERR_SUCCESS;
+ u32 para_size = sizeof(struct isp_cmd_ae_statistics);
+
+ misp_info("%s - enter", __func__);
+ /*Send command to slave */
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Preview stream on off
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_preview_stream_on_off(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_preview_stream_on_off *preview_stream_on_off_param;
+
+ preview_stream_on_off_param =
+ (struct isp_cmd_preview_stream_on_off *)param;
+
+ misp_info("%s - enter", __func__);
+ misp_info("[tx0]: %d, [tx1]: %d",
+ preview_stream_on_off_param->tx0_stream_on_off,
+ preview_stream_on_off_param->tx1_stream_on_off);
+
+ para_size = sizeof(struct isp_cmd_preview_stream_on_off);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief dual PD Y calculation weightings
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode
+mast_camera_profile_cmd_dual_pd_y_cauculation_weightings(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+
+ misp_info("%s - enter", __func__);
+ para_size = sizeof(struct isp_cmd_dual_pd_y_calculation_weightings);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief LED power control
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_led_power_control(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_led_power_control *led_power_control_param;
+
+ led_power_control_param = (struct isp_cmd_led_power_control *)param;
+ misp_info("%s - enter", __func__);
+ misp_info("[led_onoff]: %d, [led_lv]: %d, [led_id]: %d",
+ led_power_control_param->led_on_off,
+ led_power_control_param->led_power_level,
+ led_power_control_param->control_projector_id);
+
+ misp_info("[delay_after_sof]: %d, [pulse_time]: %d",
+ led_power_control_param->delay_after_sof,
+ led_power_control_param->pulse_time);
+
+ misp_info("[control_mode]: %d, [reserved]: %d, [rolling_shutter]: %d",
+ led_power_control_param->control_mode,
+ led_power_control_param->reserved,
+ led_power_control_param->rolling_shutter);
+
+ para_size = sizeof(struct isp_cmd_led_power_control);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Active AE
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_active_ae(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_active_ae *active_ae_param;
+
+ active_ae_param = (struct isp_cmd_active_ae *) param;
+ misp_info("%s - enter", __func__);
+ misp_info("[active ae]: %d, [f_number]: %d",
+ active_ae_param->active_ae, active_ae_param->f_number_x1000);
+
+ para_size = sizeof(struct isp_cmd_active_ae);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Control AE on/off
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_isp_ae_control_on_off(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_isp_ae_control_on_off *ae_control_on_off_param;
+
+ ae_control_on_off_param = (struct isp_cmd_isp_ae_control_on_off *)param;
+ misp_info("%s - enter", __func__);
+ misp_info("[ae control]: %d",
+ ae_control_on_off_param->isp_ae_control_mode_on_off);
+
+ para_size = sizeof(struct isp_cmd_isp_ae_control_on_off);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set Frame Rate Limits
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_frame_rate_limits(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+
+ misp_info("%s - enter", __func__);
+ para_size = sizeof(struct isp_cmd_frame_rate_limits);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set period drop frame
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_period_drop_frame(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_period_drop_frame *period_drop_frame_param;
+
+ period_drop_frame_param = (struct isp_cmd_period_drop_frame *)param;
+ misp_info("%s - enter", __func__);
+ misp_info("[period_drop_type]: %d",
+ period_drop_frame_param->period_drop_type);
+
+ para_size = sizeof(struct isp_cmd_period_drop_frame);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set Max exposure
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_max_exposure(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+
+ misp_info("%s - enter", __func__);
+ para_size = sizeof(struct isp_cmd_exposure_param);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set target mean
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_target_mean(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+
+ misp_info("%s - enter", __func__);
+ para_size = sizeof(struct isp_cmd_target_mean);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Frame sync control
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_frame_sync_control(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_frame_sync_control *frame_sync_control_param;
+
+ frame_sync_control_param = (struct isp_cmd_frame_sync_control *)param;
+ misp_info("%s - enter", __func__);
+ misp_info("[deviceId]: %d, [delay_frame]: %d, [active_frame]: %d,",
+ frame_sync_control_param->control_deviceID,
+ frame_sync_control_param->delay_framephase,
+ frame_sync_control_param->active_framephase);
+
+ misp_info("[deactive_frame]: %d, [active_timeLv]: %d",
+ frame_sync_control_param->deactive_framephase,
+ frame_sync_control_param->active_timelevel);
+
+ para_size = sizeof(struct isp_cmd_frame_sync_control);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set shot mode
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_shot_mode(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_set_shot_mode *set_shot_mode_param;
+
+ set_shot_mode_param = (struct isp_cmd_set_shot_mode *)param;
+ misp_info("%s - enter", __func__);
+ misp_info("[shot_mode]: %d, [frame_rate]: %d",
+ set_shot_mode_param->shot_mode,
+ set_shot_mode_param->frame_rate);
+ para_size = sizeof(struct isp_cmd_set_shot_mode);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Lighting control
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_lighting_ctrl(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size, i;
+ struct isp_cmd_lighting_ctrl *lighting_ctrl_param;
+
+ lighting_ctrl_param = (struct isp_cmd_lighting_ctrl *)param;
+ misp_info("%s - enter", __func__);
+ misp_info("[cycle_len]: %d", lighting_ctrl_param->cycle_len);
+ for (i = 0; i < lighting_ctrl_param->cycle_len; i++) {
+ misp_info("cycle[%d]: 0x%x, 0x%x, %d", i,
+ lighting_ctrl_param->cycle[i].source,
+ lighting_ctrl_param->cycle[i].TxDrop,
+ lighting_ctrl_param->cycle[i].co_frame_rate);
+ }
+ para_size = sizeof(struct isp_cmd_lighting_ctrl);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set Min exposure
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_min_exposure(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+
+ misp_info("%s - enter", __func__);
+ para_size = sizeof(struct isp_cmd_exposure_param);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set Max exposure slope
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_max_exposure_slope(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+
+ misp_info("%s - enter", __func__);
+ para_size = sizeof(struct isp_cmd_max_exposure_slope);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set Depth Compensation
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_depth_compensation(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_depth_compensation_param *depth_compensation_param;
+
+ depth_compensation_param =
+ (struct isp_cmd_depth_compensation_param *)param;
+
+ misp_info("%s - enter", __func__);
+ misp_info("[en_updated]: 0x%x, [short_dist]: %d, [compensation]: %d",
+ depth_compensation_param->en_updated,
+ depth_compensation_param->short_distance_value,
+ depth_compensation_param->compensation);
+
+ para_size = sizeof(struct isp_cmd_depth_compensation_param);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/*
+ *\brief Set cycle trigger depth process
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_cycle_trigger_depth(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+ struct isp_cmd_cycle_trigger_depth_process
+ *cycle_trigger_depth_process_param;
+
+ cycle_trigger_depth_process_param =
+ (struct isp_cmd_cycle_trigger_depth_process *)param;
+
+ misp_info("%s - enter", __func__);
+ misp_info("[Cycle_len]: %d, [DP_trigBitField]: 0x%x",
+ cycle_trigger_depth_process_param->cycleLen,
+ cycle_trigger_depth_process_param->depth_triggerBitField);
+
+ misp_info("[DPOut_trigBitField]: 0x%x",
+ cycle_trigger_depth_process_param->depthoutput_triggerBitField);
+
+ para_size = sizeof(struct isp_cmd_cycle_trigger_depth_process);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+/*
+ *\brief Set led active delay time
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_led_active_delay(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+
+ misp_info("%s - enter", __func__);
+ misp_info("[delay]: %d", *(u32 *)param);
+ para_size = sizeof(u32);
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+/*
+ *\brief Set isp control led level
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_isp_control_led_level(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size;
+
+ misp_info("%s - enter", __func__);
+ misp_info("[isp control led level]: %d", *(u8 *)param);
+ para_size = sizeof(u8);
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+/************************** End Of File *******************************/
diff --git a/drivers/media/platform/altek/include/error.h b/drivers/media/platform/altek/include/error.h
new file mode 100755
index 0000000..c47f5e8
--- /dev/null
+++ b/drivers/media/platform/altek/include/error.h
@@ -0,0 +1,79 @@
+/*
+ * File: error.h
+ * Description: Error code base of modules
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/*
+ *@defgroup ErrorCode Error Code Definition
+ */
+
+/**
+ *@file error.h
+ *@brief TBirdOS 2.0 module error code definition.
+ *Error code definition:
+ *Bits 31~20: Module id
+ *Bits 19~12: Reserved
+ *Bits 11~0: Error code defined in each module
+ *@author Gene Hung
+ *@version 2005/08/22; Gene; Add Doxygen remark
+ *@see ModuleID
+ *@ingroup ErrorCode Error Code Definition
+ */
+
+/**
+ *@defgroup SysCtrlErr System Control Module Error Code
+ *@ingroup ErrorCode
+ */
+
+/**
+ *@defgroup SysMgrErr System Manager Module Error Code
+ *@ingroup ErrorCode
+ */
+
+#ifndef _ERROR_H_
+#define _ERROR_H_
+
+#ifndef _MODULEID_H_
+#include "moduleid.h"
+#endif
+/**
+ *@ingroup ErrorCode
+ *@{
+ */
+#define ERR_MODULEID_SHIFTBITS 20
+#define ERR_MODULEID(ErrorCode) ((ErrorCode) >> ERR_MODULEID_SHIFTBITS)
+#define ERR_BASE(ModuleId) ((ModuleId) << ERR_MODULEID_SHIFTBITS)
+
+/* No error*/
+#define ERR_SUCCESS 0
+
+/* The following constants define the module ID and the error code base*/
+
+#define ERR_BASE_PROJECT ERR_BASE(MODULEID_PROJECT)
+
+/**
+ *@}
+ */
+#endif /*_ERROR_H_*/
+
diff --git a/drivers/media/platform/altek/include/error/altek_state_err.h b/drivers/media/platform/altek/include/error/altek_state_err.h
new file mode 100755
index 0000000..7b43338
--- /dev/null
+++ b/drivers/media/platform/altek/include/error/altek_state_err.h
@@ -0,0 +1,39 @@
+/*
+ * File: altek_state_err.h
+ * Description: miniISPISP error definition
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _ALTEK_STATE_ERR_H_
+#define _ALTEK_STATE_ERR_H_
+
+/******Include File******/
+
+#include "../error_pj.h"
+
+/******Public Define******/
+
+#define ERR_MINIISP_STATE_REDUNDANT_SEQUENCE \
+ (ERR_BASE_PJ_MINIISP_STATE + 0x000)
+#define ERR_MINIISP_STATE_ERROR_SEQUENCE \
+ (ERR_BASE_PJ_MINIISP_STATE + 0x001)
+
+#endif
diff --git a/drivers/media/platform/altek/include/error/ispctrl_if_master_err.h b/drivers/media/platform/altek/include/error/ispctrl_if_master_err.h
new file mode 100755
index 0000000..1f322a0
--- /dev/null
+++ b/drivers/media/platform/altek/include/error/ispctrl_if_master_err.h
@@ -0,0 +1,57 @@
+/**
+ * File: ispctrl_if_master_err.h
+ * Description: ISP Ctrl IF Master error definition
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/10/14; Aaron Chuang; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _ISPCTRLIFMASTER_ERR_H_
+#define _ISPCTRLIFMASTER_ERR_H_
+
+/******Include File******/
+
+
+#include "../error_pj.h"
+
+
+/******Public Define******/
+/* command Size mismatch*/
+#define ERR_MASTERCMDSIZE_MISMATCH (ERR_BASE_PJ_ISPCTRLIF_MASTER + 0x000)
+/* null buffer*/
+#define ERR_MASTERCMDBUF_NULL (ERR_BASE_PJ_ISPCTRLIF_MASTER + 0x001)
+/* command options unsupport*/
+#define ERR_MASTERCMDOPTION_UNSUPPORT (ERR_BASE_PJ_ISPCTRLIF_MASTER + 0x002)
+/* open file error*/
+#define ERR_MASTERCMDCKSM_INVALID (ERR_BASE_PJ_ISPCTRLIF_MASTER + 0x003)
+/* open file error*/
+#define ERR_MASTEROPENFILE_FAILED (ERR_BASE_PJ_ISPCTRLIF_MASTER + 0x004)
+/* open file error*/
+#define ERR_MASTEROPENFILE_FILENAME_INVALID (ERR_BASE_PJ_ISPCTRLIF_MASTER+\
+ 0x005)
+/* event timeout*/
+#define ERR_MASTER_EVENT_TIMEOUT (ERR_BASE_PJ_ISPCTRLIF_MASTER + 0x006)
+
+/* opcode not supported*/
+#define ERR_MASTER_OPCODE_UNSUPPORT (ERR_BASE_PJ_ISPCTRLIF_MASTER + 0x007)
+
+#endif
diff --git a/drivers/media/platform/altek/include/error/miniisp_err.h b/drivers/media/platform/altek/include/error/miniisp_err.h
new file mode 100755
index 0000000..f1fb5ae
--- /dev/null
+++ b/drivers/media/platform/altek/include/error/miniisp_err.h
@@ -0,0 +1,38 @@
+/*
+ * File: miniisp_err.h
+ * Description: miniISPISP error definition
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _MINIISP_ERR_H_
+#define _MINIISP_ERR_H_
+
+/******Include File******/
+
+#include "../error_pj.h"
+
+/******Public Define******/
+
+#define ERR_MINIISP_BUFFERSIZE_OVERFLOW (ERR_BASE_PJ_MINIISP + 0x000)
+#define ERR_MINIISP_REQUESTFIRMWARE_FAILED (ERR_BASE_PJ_MINIISP + 0x001)
+#define ERR_MINIISP_GETDATA_TIMEOUT (ERR_BASE_PJ_MINIISP + 0x002)
+
+#endif
diff --git a/drivers/media/platform/altek/include/error_pj.h b/drivers/media/platform/altek/include/error_pj.h
new file mode 100755
index 0000000..c51781f
--- /dev/null
+++ b/drivers/media/platform/altek/include/error_pj.h
@@ -0,0 +1,45 @@
+/*
+ * File: error_pj.h
+ * Description: Error code base of modules
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+#ifndef _ERROR_PJ_H_
+#define _ERROR_PJ_H_
+
+#include "error.h"
+#include "moduleid_pj.h"
+
+/**
+ *@ingroup ErrorCode
+ *@{
+ */
+
+/* The following constants define the module ID and the error code base*/
+#define ERR_BASE_PJ_MINIISP_STATE ERR_BASE(MODULEID_PJ_MINIISP_STATE)
+#define ERR_BASE_PJ_ISPCTRLIF_SLAVE ERR_BASE(MODULEID_PJ_ISPCTRLIF_SLAVE)
+#define ERR_BASE_PJ_ISPCTRLIF_MASTER ERR_BASE(MODULEID_PJ_ISPCTRLIF_MASTER)
+#define ERR_BASE_PJ_MINIISP ERR_BASE(MODULEID_PJ_MINIISP)
+
+
+
+#endif
diff --git a/drivers/media/platform/altek/include/isp_camera_cmd.h b/drivers/media/platform/altek/include/isp_camera_cmd.h
new file mode 100755
index 0000000..b5de794
--- /dev/null
+++ b/drivers/media/platform/altek/include/isp_camera_cmd.h
@@ -0,0 +1,698 @@
+/*
+ * File: isp_camera_cmd.h
+ * Description: The structure and API definition ISP camera command
+ * It is a header file that define structure and API for ISP camera command
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * History
+ * 2013/09/18; Aaron Chuang; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _ISPCAMERA_CMD_H_
+#define _ISPCAMERA_CMD_H_
+
+/*
+ *@addtogroup ISPCameraCmd
+ *@{
+ */
+
+/******Include File******/
+
+
+#include "mtype.h"
+
+
+/******Public Constant Definition******/
+
+#define T_MEMSIZE (936*1024)
+#define T_SPI_CMD_LENGTH 64
+
+#define ISPCMD_DUMMYBYTES 4
+#define FWVER_INFOSIZE_MAX 34
+
+#define ISPCMD_LENFLDBYTES 2
+#define ISPCMD_OPCODEBYTES 2
+#define ReportRegCount 27
+#define ISPCMD_CKSUMBYTES 2
+
+/*length field size = 2, opcode field size = 2 */
+#define ISPCMD_CMDSIZE ((ISPCMD_LENFLDBYTES) + (ISPCMD_OPCODEBYTES))
+
+/*length field size = 2, opcode field size = 2, dummy bytes = 4*/
+#define ISPCMD_CMDSIZEWDUMMY (ISPCMD_LENFLDBYTES+\
+ ISPCMD_OPCODEBYTES+\
+ ISPCMD_DUMMYBYTES)
+
+#define ISPCMD_FILENAME_SIZE 15
+
+#define ISPCMD_EXEBIN_ADDRBYTES 4
+#define ISPCMD_EXEBIN_TOTALSIZEBYTES 4
+#define ISPCMD_EXEBIN_BLOCKSIZEBYTES 4
+#define ISPCMD_EXEBIN_CKSUMBYTES 4
+#define ISPCMD_EXEBIN_INFOBYTES (ISPCMD_EXEBIN_ADDRBYTES+\
+ ISPCMD_EXEBIN_TOTALSIZEBYTES+\
+ ISPCMD_EXEBIN_BLOCKSIZEBYTES+\
+ ISPCMD_EXEBIN_CKSUMBYTES)
+
+/* Definition for Error code array number*/
+#define MAX_RECERRORCODE_NUM 10
+
+/*log buffer size*/
+#define LEVEL_LOG_BUFFER_SIZE (1024*4)
+
+
+
+/*calibration profile*/
+#define ISPCMD_CAMERA_SET_SENSORMODE 0x300A
+#define ISPCMD_CAMERA_GET_SENSORMODE 0x300B
+#define ISPCMD_CAMERA_SET_OUTPUTFORMAT 0x300D
+#define ISPCMD_CAMERA_SET_CP_MODE 0x300E
+#define ISPCMD_CAMERA_SET_AE_STATISTICS 0x300F
+#define ISPCMD_CAMERA_PREVIEWSTREAMONOFF 0x3010
+#define ISPCMD_CAMERA_DUALPDYCALCULATIONWEIGHT 0x3011
+#define ISPCMD_LED_POWERCONTROL 0x3012
+#define ISPCMD_CAMERA_ACTIVE_AE 0x3013
+#define ISPCMD_ISP_AECONTROLONOFF 0x3014
+#define ISPCMD_CAMERA_SET_FRAMERATELIMITS 0x3015
+#define ISPCMD_CAMERA_SET_PERIODDROPFRAME 0x3016
+#define ISPCMD_CAMERA_SET_MAX_EXPOSURE 0x3017
+#define ISPCMD_CAMERA_SET_AE_TARGET_MEAN 0x3018
+#define ISPCMD_CAMERA_FRAME_SYNC_CONTROL 0x3019
+#define ISPCMD_CAMERA_SET_SHOT_MODE 0x301A
+#define ISPCMD_CAMERA_LIGHTING_CTRL 0x301B
+#define ISPCMD_CAMERA_DEPTH_COMPENSATION 0x301C
+#define ISPCMD_CAMERA_TRIGGER_DEPTH_PROCESS_CTRL 0x301D
+#define ISPCMD_CAMERA_SET_MIN_EXPOSURE 0x301E
+#define ISPCMD_CAMERA_SET_MAX_EXPOSURE_SLOPE 0x301F
+#define ISPCMD_CAMERA_SET_LED_ACTIVE_DELAY 0x3020
+#define ISPCMD_CAMERA_ISPLEDLEVELCONTROLONOFF 0x3021
+
+/* Bulk Data*/
+#define ISPCMD_BULK_WRITE_BASICCODE 0x2002
+#define ISPCMD_BULK_WRITE_BASICCODE_CODEADDR 0x2003
+#define ISPCMD_BULK_WRITE_BASICCODE_CODESIZE 0x2004
+#define ISPCMD_BULK_WRITE_BASICCODE_CODESUM 0x2005
+#define ISPCMD_BULK_READ_CALIBRATION_DATA 0x2007
+#define ISPCMD_BULK_WRITE_BOOTCODE 0x2008
+#define ISPCMD_BULK_WRITE_BOOTCODE_SHORT_LEN 0x2009
+#define ISPCMD_BULK_READ_MEMORY 0x2101
+#define ISPCMD_BULK_READ_COMLOG 0x2102
+#define ISPCMD_BULK_WRITE_CALIBRATION_DATA 0x210B
+#define ISPCMD_BULK_WRITE_DEPTH_RECTAB_INVRECT 0x210C
+#define ISPCMD_BULK_WRITE_CALIBRATION_NO_BLOCK 0x210D
+#define ISPCMD_BULK_WRITE_SPINOR_DATA 0x210E
+
+/*basic setting*/
+#define ISPCMD_BASIC_SET_DEPTH_3A_INFO 0x10B9
+#define ISPCMD_BASIC_SET_DEPTH_AUTO_INTERLEAVE_MODE 0x10BC
+#define ISPCMD_BASIC_SET_INTERLEAVE_MODE_DEPTH_TYPE 0x10BD
+#define ISPCMD_BASIC_SET_DEPTH_POLISH_LEVEL 0x10BE
+#define ISPCMD_BASIC_SET_EXPOSURE_PARAM 0x10BF
+#define ISPCMD_BASIC_SET_DEPTH_STREAM_SIZE 0x10C0
+/*system cmd*/
+#define ISPCMD_SYSTEM_GET_STATUSOFLASTEXECUTEDCOMMAND 0x0015
+#define ISPCMD_SYSTEM_GET_ERRORCODE 0x0016
+#define ISPCMD_SYSTEM_SET_ISPREGISTER 0x0100
+#define ISPCMD_SYSTEM_GET_ISPREGISTER 0x0101
+/*#define ISPCMD_SYSTEM_SET_DEBUGCMD 0x0104*/
+#define ISPCMD_SYSTEM_SET_COMLOGLEVEL 0x0109
+#define ISPCMD_SYSTEM_GET_CHIPTESTREPORT 0x010A
+#define ISPCMD_SYSTEM_GET_CHIP_THERMAL 0x0115
+
+/*operarion code*/
+#define ISPCMD_MINIISPOPEN 0x4000
+
+/* constants for memory dump mode*/
+#define T_MEMDUMP_CPURUN 0
+#define T_MEMDUMP_CPUHALT 1
+
+#define EEPROM_BUFFER_ADDRESS 0x00000000
+#define EEPROM_BUFFER_SIZE 0x4000
+/******Public Type Declaration******/
+/*mode id*/
+/*define for ISP decide mode*/
+enum mini_isp_mode {
+ MINI_ISP_MODE_NORMAL = 0x0000,
+ MINI_ISP_MODE_E2A = 0x0001,
+ MINI_ISP_MODE_A2E = 0x0002,
+ MINI_ISP_MODE_LEAVE_BYPASS = 0x0003,
+ MINI_ISP_MODE_GET_CHIP_ID = 0x0004,
+ MINI_ISP_MODE_SET_CP_MODE = 0x0005,
+ MINI_ISP_MODE_LEAVE_CP_MODE = 0x0006,
+ MINI_ISP_MODE_CHIP_INIT = 0x0007,
+ MINI_ISP_MODE_BYPASS = 0x1000,
+ MINI_ISP_MODE_QUARTER_BYPASS = 0x1001,
+};
+
+#pragma pack(push, 1)
+#pragma pack(1)
+struct transferdata {
+ u16 opcode;
+ void *data;
+};
+
+/*camera profile cmd use structure*/
+/**
+ *@struct isp_cmd_set_sensor_mode(opcode:300A)
+ *@brief ISP master cmd for set sensor mode
+ *\param sensor_on_off [In],sensor on/off
+ *\param scenario_id[In], Scenario ID
+ *\param mipi_tx_skew_enable[In], mipi tx skew on(1)/off(0)
+ *\param ae_weighting_table_index[In]
+ *\param merge_mode_enable[In]
+ *\ bit[0:3] :
+ *\ set 0 for normal mode
+ *\ set 1 for merge mode, only for image samller than 640X480 case
+ *\ set 2 for depth test pattern mode
+ *\ bit[4] :
+ *\ set 0 for turn on sensor by AP.
+ *\ set 1 for turn on sensor by AL6100.
+ *\ bit[5] :
+ *\ set 0 for disable time stamp function.
+ *\ set 1 for enable time stamp function.
+ *\ Time stamp data will be put after ir raw data.
+ *\ Besides, the original metadata will be cancelled.
+ */
+#pragma pack(1)
+struct isp_cmd_set_sensor_mode {
+ u8 sensor_on_off;
+ u8 scenario_id;
+ u8 mipi_tx_skew;
+ u8 ae_weighting_table_index;
+ u8 merge_mode_enable;
+ u8 reserve[2];
+};
+
+/**
+ *@struct isp_cmd_get_sensor_mode(opcode:300B)
+ *@brief ISP master cmd for get sensor mode
+ */
+#pragma pack(1)
+struct isp_cmd_get_sensor_mode {
+ bool on; /* On/off flag*/
+ u8 scenario_id; /* scenario mode*/
+ u8 reserve[4];
+};
+
+/**
+ *@struct isp_cmd_set_output_format(opcode:300D)
+ *@brief ISP master cmd for set depth output format
+
+ depth_size[In]depth_map_setting = resolution | opereation_mode
+ resolution
+ 0: Disable depth function (Depth engine is disable)
+ 1: 180p
+ 2: 360p
+ 3: 720p
+ 4: 480p
+ opereation_mode,
+ 0x00: DEPTH_BIT_DG_ONLY
+ 0x10: DEPTH_BIT_DP
+ 0x40: DEPTH_BIT_HIGH_DISTORTION_RATE
+
+ reserve[0] [In]depth_process_type_and_qlevel = process_type | quality level
+ B[0:2] process_type: value 0x6 as reserve
+ B[3:6] quality level: 0 ~ 15
+
+ reserve[1] [In]
+ B[0:0] InvRect bypass: set 1 for enable InvRect bypass. set 0 disable.
+ return Error code
+ */
+#pragma pack(1)
+struct isp_cmd_set_output_format {
+ u8 depth_size;
+ u8 reserve[2];
+};
+
+/**
+ *@struct isp_cmd_ae_statistics(opcode:300F)
+ *@brief ae statistics
+ *\gr_channel_weight (0~65535)
+ *\gb_channel_weight (0~65535)
+ *\r_channel_weight (0~65535)
+ *\b_channel_weight (0~65535)
+ *\shift_bits (0 ~ 15, 0 means no shift)
+ */
+#pragma pack(1)
+struct isp_cmd_ae_statistics {
+ u16 gr_channel_weight;
+ u16 gb_channel_weight;
+ u16 r_channel_weight;
+ u16 b_channel_weight;
+ u8 shift_bits;
+};
+
+/**
+ *@struct isp_cmd_preview_stream_on_off(opcode:3010)
+ *@briefISP master cmd for control tx stream on or off
+ */
+#pragma pack(1)
+struct isp_cmd_preview_stream_on_off {
+ u8 tx0_stream_on_off;
+ u8 tx1_stream_on_off;
+ u8 reserve;
+};
+
+/**
+ *@struct isp_cmd_dual_pd_y_calculation_weightings(opcode:3011)
+ *@briefISP master cmd for control dual pd y calculation weightings
+ */
+#pragma pack(1)
+struct isp_cmd_dual_pd_y_calculation_weightings {
+ u8 y_weight_gr_short;
+ u8 y_weight_gr_long;
+ u8 y_weight_r_short;
+ u8 y_weight_r_long;
+ u8 y_weight_b_short;
+ u8 y_weight_b_long;
+ u8 y_weight_gb_short;
+ u8 y_weight_gb_long;
+ u8 y_sum_right_shift;
+};
+
+/**
+ *@struct isp_cmd_led_power_control(opcode:3012)
+ *@briefISP master cmd for control led power
+ * u8 led_on_off:
+ * 0: off
+ * 1: always on
+ * 2: AP control pulse mode
+ * 3: AHCC control pulse mode
+ * u8 led_power_level: (0~255)
+ * u8 control_projector_id:
+ * 0: projector
+ * 1:illuminator
+ * u32 delay_after_sof,
+ * when led_on_off = 2, use this param to set delay time
+ * between SOF and start pulse time
+ * u32 pulse_time:
+ * when led_on_off = 2, use this param to set pulse time
+ * u8 control_mode:
+ * when led_on_off = 2,
+ * use this param to decide if pulse time
+ * met next SOF need triggler imediately or not
+ * u8 reserved:
+ * reserved; always set to 0
+ * u8 rolling_shutter:
+ * when led_on_off = 3, use this param to let
+ * projector/illuminator konw hoe exposure deal
+ */
+#pragma pack(1)
+struct isp_cmd_led_power_control {
+ u8 led_on_off;
+ u8 led_power_level;
+ u8 control_projector_id;
+ u32 delay_after_sof;
+ u32 pulse_time;
+ u8 control_mode;
+ u8 reserved;
+ u8 rolling_shutter;
+};
+
+/**
+ *@struct isp_cmd_active_ae(opcode:3013)
+ *@briefISP master cmd for avtive AE
+ */
+#pragma pack(1)
+struct isp_cmd_active_ae {
+ u8 active_ae;
+ u16 f_number_x1000;
+};
+
+/**
+ *@struct isp_cmd_isp_ae_control_on_off(opcode:3014)
+ *@briefISP master cmd for isp AE control on off
+ */
+#pragma pack(1)
+struct isp_cmd_isp_ae_control_on_off {
+ u8 isp_ae_control_mode_on_off;
+};
+
+
+/**
+ *@struct isp_cmd_frame_rate_limits(opcode:3015)
+ *@brief set frame rate limits
+ */
+#pragma pack(1)
+struct isp_cmd_frame_rate_limits {
+ u16 main_min_framerate_x100;
+ u16 main_max_framerate_x100;
+ u16 sub_min_framerate_x100;
+ u16 sub_max_framerate_x100;
+};
+
+/**
+ *@struct isp_cmd_period_drop_frame(opcode:3016)
+ *@brief set period drop frame
+ */
+#pragma pack(1)
+struct isp_cmd_period_drop_frame {
+ u8 period_drop_type;/* 0: no drop, 1: drop active, 2; drop passive */
+};
+
+/**
+ *@struct isp_cmd_target_mean(opcode:3018)
+ *@brief set target mean
+ */
+#pragma pack(1)
+struct isp_cmd_target_mean {
+ u16 target_mean;/* 0~255 */
+ u8 ucActiveDevice;
+};
+
+#pragma pack(1)
+struct isp_cmd_frame_sync_control {
+ u8 control_deviceID; /* bit 0~3: Device ID */
+ /* 0: OutDevice_0, 1: OutDevice_1. */
+ /* Device name is based on project definition */
+ /* bit 4~7: Reference signal source */
+ /* 0: Dual sensor sync, 1: GPI */
+ u8 delay_framephase; /* Unit: frame number */
+ u8 active_framephase; /* Unit: frame number */
+ u8 deactive_framephase; /* Unit: frame number */
+ u8 active_timelevel; /* bit 0~3 : Active time level */
+ /* 0: one frame; others : value*100(us), range (1~10) */
+ /* bit 4~7: mode setting */
+ /* 0: normal mode 1: always off mode 2: always on mode */
+ u8 reserve[3];
+};
+
+
+/*
+Param: shot_mode => value 0: Manual, value 1: Auto + N fps
+Param: frame_rate => Please set frame rate when shot mode is Auto + N fps
+*/
+#pragma pack(1)
+struct isp_cmd_set_shot_mode {
+ u8 shot_mode;
+ u16 frame_rate; /* corresponding frame rate; Ex. 3002 = 30.02 fps */
+ u8 reserve[1];
+};
+
+/*
+*/
+#pragma pack(1)
+struct isp_cmd_lighting_ctrl {
+ u32 cycle_len; /* effective length in cycle[] */
+ struct {
+ u8 source;
+ /* source of lighting (bit-map) */
+ /* 0 means none */
+ /* bit 0 represents an IR Project */
+ /* bit 1 represents a Flood Illuminator */
+ u8 TxDrop;
+ /* mipi tx drop control (bit-map) */
+ /* 0 means mipi tx0 and mipi tx1 output */
+ /* bit 0 represents mipi tx0 drop */
+ /* bit 1 represents mipi tx1 drop */
+ u16 co_frame_rate;
+ /* corresponding frame rate; Ex. 3002 = 30.02 fps */
+ /* 0 means the same as sensor */
+ } cycle[8];
+};
+
+/*basic cmd use structure*/
+
+/**
+ *@struct isp_cmd_depth_3a_info(opcode:10B9)
+ *@brief depth 3A information
+ */
+#pragma pack(1)
+struct isp_cmd_depth_3a_info {
+ u16 hdr_ratio;
+ u32 main_cam_exp_time;
+ u16 main_cam_exp_gain;
+ u16 main_cam_amb_r_gain;
+ u16 main_cam_amb_g_gain;
+ u16 main_cam_amb_b_gain;
+ u16 main_cam_iso;
+ u16 main_cam_bv;
+ s16 main_cam_vcm_position;
+ u8 main_cam_vcm_status;
+ u32 sub_cam_exp_time;
+ u16 sub_cam_exp_gain;
+ u16 sub_cam_amb_r_gain;
+ u16 sub_cam_amb_g_gain;
+ u16 sub_cam_amb_b_gain;
+ u16 sub_cam_iso;
+ u16 sub_cam_bv;
+ s16 sub_cam_vcm_position;
+ u8 sub_cam_vcm_status;
+ u16 main_cam_isp_d_gain;
+ u16 sub_cam_isp_d_gain;
+ s16 hdr_long_exp_ev_x1000;
+ s16 hdr_short_exp_ev_x1000;
+ u16 ghost_prevent_low;
+ u16 ghost_prevent_high;
+ u8 depth_proc_mode;
+};
+
+/**
+ *@struct isp_cmd_depth_auto_interleave_param(opcode:10BC)
+ *@brief depth Interleave mode param
+ */
+#pragma pack(1)
+struct isp_cmd_depth_auto_interleave_param {
+ u8 depth_interleave_mode_on_off;/*1: on, 0: off*/
+ u8 skip_frame_num_after_illuminator_pulse;
+ u8 projector_power_level;/*0~255*/
+ u8 illuminator_power_level;/*0~255*/
+};
+
+/**
+ *@struct isp_cmd_interleave_mode_depth_type(opcode:10BD)
+ *@brief interleave mode projector with depth type
+ */
+#pragma pack(1)
+struct isp_cmd_interleave_mode_depth_type {
+ u8 projector_interleave_mode_with_depth_type;
+ /*1: passive, 0: active, default active*/
+};
+
+/**
+ *@struct isp_cmd_depth_polish_level(opcode:10BE)
+ *@brief set depth polish level
+ */
+#pragma pack(1)
+struct isp_cmd_depth_polish_level {
+ u8 depth_polish_level;/*0~100*/
+};
+
+/**
+ *@struct isp_cmd_exposure_param(opcode:10BF)
+ *@brief set exposure param
+ */
+#pragma pack(1)
+struct isp_cmd_exposure_param {
+ u32 udExpTime;/*unit:us*/
+ u16 uwISO;
+ u8 ucActiveDevice;
+};
+
+/**
+ *@struct isp_cmd_depth_stream_size(opcode:10C0)
+ *@brief set depth stream size
+ */
+#pragma pack(1)
+struct isp_cmd_depth_stream_size {
+ u8 depth_stream_size;/*0 : normal, 1: Binning x2*/
+};
+
+/*system cmd use structure*/
+
+/* ISP operation mode*/
+enum ispctrl_operation_mode {
+ ISPCTRL_TEST_MODE,
+ ISPCTRL_STILLLV_MODE,
+ ISPCTRL_VIDEOLV_MODE,
+ ISPCTRL_CONCURRENT_MODE,
+ ISPCTRL_BYPASS_MODE,
+ ISPCTRL_POWERDOWN_MODE
+};
+
+/**
+ *@struct system_cmd_isp_mode(opcode:0010 and 0011)
+ *@brief depth 3A information
+ */
+#pragma pack(1)
+struct system_cmd_isp_mode {
+ u8 isp_mode; /*ispctrl_operation_mode*/
+};
+
+/**
+ *@struct system_cmd_status_of_last_command(opcode:0015)
+ *@brief last execution command status
+ */
+#pragma pack(1)
+struct system_cmd_status_of_last_command {
+ u16 opcode;
+ u32 execution_status;
+};
+
+/**
+ *@struct system_cmd_isp_register(opcode:0100 and 0101)
+ *@brief use on set/get isp register
+ */
+#pragma pack(1)
+struct system_cmd_isp_register {
+ u32 address;
+ u32 value;
+};
+
+/**
+ *@struct system_cmd_debug_mode(opcode:0104)
+ *@brief use on get irq status
+ */
+#pragma pack(1)
+struct system_cmd_debug_mode {
+ u8 on;
+};
+
+/**
+ *@struct system_cmd_common_log_level(opcode:0109)
+ *@brief use on set common log level
+ */
+#pragma pack(1)
+struct system_cmd_common_log_level {
+ u32 log_level;
+};
+
+
+
+/*bulk cmd use structure*/
+
+/**
+ *@struct memmory_dump_hdr_info
+ *@brief use on isp memory read
+ */
+#pragma pack(1)
+struct memmory_dump_hdr_info {
+ u32 start_addr;
+ u32 total_size;
+ u32 block_size;
+ u32 dump_mode;
+};
+
+
+/**
+ *@struct common_log_hdr_info
+ *@brief Bulk data for memory dump header
+ */
+#pragma pack(1)
+struct common_log_hdr_info {
+ u32 total_size;
+ u32 block_size;
+};
+
+struct depthflowmgrpv_dgmgr_recta_quality_param {
+ u32 recta_quality_rect_core_sel_param;
+ u32 recta_quality_rect_ldc_param[43];
+ u32 recta_quality_rect_hgh_param[9];
+ u32 recta_quality_rect_bilinear_param;
+};
+
+struct depthflowmgrpv_dgmgr_rectb_quality_param {
+ u32 rectb_quality_rect_core_sel_param;
+ u32 rectb_quality_rect_ldc_param[43];
+ u32 rectb_quality_rect_hgh_param[9];
+ u32 rectb_quality_rect_bilinear_param;
+};
+
+struct depthflowmgrpv_invrectmgr_quality_param {
+ u32 recta_quality_irect_core_sel_param;
+ u32 recta_quality_irect_ldc_param[43];
+ u32 recta_quality_irect_hgh_param[9];
+ u32 recta_quality_irect_bilinear_param;
+ u32 rectb_quality_irect_bilinear_param;
+};
+
+/**
+ *@struct depth_rectab_invrect_param(opcode:0x210C)
+ *@brief depth rect A, B, INV rect parameter structure
+ */
+#pragma pack(1)
+struct depth_rectab_invrect_param {
+ struct depthflowmgrpv_dgmgr_recta_quality_param depth_recta_quality;
+ struct depthflowmgrpv_dgmgr_rectb_quality_param depth_rectb_quality;
+ struct depthflowmgrpv_invrectmgr_quality_param depth_invrect_quality;
+};
+
+/**
+ *@struct isp_cmd_depth_rectab_invrect_info(opcode:0x210C)
+ *@brief depth rect A, B, INV rect buffer address
+ */
+#pragma pack(1)
+struct isp_cmd_depth_rectab_invrect_info {
+ struct depth_rectab_invrect_param rect_param[3];
+ u8 trans_mode;
+ u32 block_size;
+};
+
+/**
+ *@struct isp_cmd_depth_compensation_param(opcode:0x301C)
+ *@brief depth compensation param
+ */
+#pragma pack(1)
+struct isp_cmd_depth_compensation_param {
+ u8 en_updated;
+ u16 short_distance_value;
+ s8 compensation;
+ u8 reserve[4];
+};
+
+/**
+@struct isp_cmd_cycle_trigger_depth_process
+@brief cycle trigger depth process
+*/
+#pragma pack(1)
+struct isp_cmd_cycle_trigger_depth_process {
+ u8 cycleLen;
+ /* effective length in cycle[], Range: 1~16 frames one cycle*/
+ u16 depth_triggerBitField;
+ /* bit 0 : 1st frame, bit 1 : 2nd frame, ... */
+ u16 depthoutput_triggerBitField;
+ /* bit 0 : 1st frame, bit 1 : 2nd frame, ... */
+ /* 0 : Not trigger, 1: Trigger */
+ u8 Reserved[3];
+};
+
+/**
+@struct isp_cmd_max_exposure_slope
+@brief set max exposure slope
+*/
+#pragma pack(1)
+struct isp_cmd_max_exposure_slope {
+ u32 max_exposure_slope;
+ u8 ucActiveDevice;
+ u8 Reserved[3];
+};
+
+/******Public Function Prototype******/
+
+#pragma pack(pop)
+/******End of File******/
+
+/**
+ *@}
+ */
+
+#endif /* _ISPCAMERA_CMD_H_*/
diff --git a/drivers/media/platform/altek/include/ispctrl_if_master.h b/drivers/media/platform/altek/include/ispctrl_if_master.h
new file mode 100755
index 0000000..eba22d7
--- /dev/null
+++ b/drivers/media/platform/altek/include/ispctrl_if_master.h
@@ -0,0 +1,194 @@
+/*
+ * File: ispctrl_if_master.h
+ * Description: The structure and API definition ISP Ctrl IF Master
+ * It,s a header file that define structure and API for ISP Ctrl IF Master
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/09/18; Aaron Chuang; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+/**
+ * \file ispctrl_if_master.h
+ * \brief ISP Ctrl IF Master and API define
+ * \version 0.01
+ * \author Aaron Chuang
+ * \date 2013/09/17
+ * \see ispctrl_if_master.h
+ */
+
+#ifndef _ISPCTRLIF_MASTER_H_
+#define _ISPCTRLIF_MASTER_H_
+
+/**
+ *@addtogroup ispctrl_if_master
+ *@{
+ */
+
+/******Include File******/
+#include <linux/interrupt.h>
+
+#include "mtype.h"
+#include "moduleid_pj.h"
+#include "miniisp.h"
+
+/******Public Constant Definition******/
+
+enum firmware_type {
+ BOOT_CODE,
+ BASIC_CODE,
+ ADVANCED_CODE,
+ SCENARIO_CODE,
+ HDR_CODE,
+ IRP0_CODE,
+ IRP1_CODE,
+ PPMAP_CODE,
+ DEPTH_CODE,
+ FIRMWARE_MAX
+};
+
+extern int g_isMiniISP_sendboot;
+
+
+
+/******Public Type Declaration******/
+
+
+/******Public Function Prototype******/
+
+
+/**
+ *\brief Execute master command
+ *\param opcode [In], Op code
+ *\param param [In], CMD param buffer
+ *\return Error code
+ */
+extern errcode ispctrl_if_mast_execute_cmd(u16 opcode, u8 *param);
+
+/**
+ *\brief Send command to slave
+ *\param devdata [In], misp_data
+ *\param opcode [In], Op code
+ *\param param [In], CMD param buffer
+ *\param len [In], CMD param size
+ *\return Error code
+ */
+errcode ispctrl_mast_send_cmd_to_slave(void *devdata,
+ u16 opcode,
+ u8 *param,
+ u32 len);
+
+/**
+ *\brief Receive response from slave
+ *\param devdata [In], misp_data
+ *\param param [Out], Response buffer
+ *\param len [Out], Response size
+ *\return Error code
+ */
+errcode ispctrl_mast_recv_response_from_slave(void *devdata,
+ u8 *param,
+ u32 len,
+ bool wait_int);
+
+/**
+ *\brief Receive Memory data from slave
+ *\param devdata [In], misp_data
+ *\param response_buf [Out], Response buffer
+ *\param response_size [Out], Response size
+ *\param wait_int [In], waiting INT flag
+ *\return Error code
+ */
+errcode ispctrl_if_mast_recv_memory_data_from_slave(
+ void *devdata,
+ u8 *response_buf,
+ u32 *response_size,
+ u32 block_size,
+ bool wait_int);
+
+#if ENABLE_LINUX_FW_LOADER
+/** \brief Master send bulk (large data) to slave
+ *\param devdata [In], misp_data
+ *\param buffer [In], Data buffer to be sent, address 8-byte alignment
+ *\param filp [In], file pointer, used to read the file and send the data
+ *\param total_size [In], file size
+ *\param block_size [In], transfer buffer block size
+ *\param is_raw [In], true: mini boot code false: other files
+ *\return Error code
+ */
+errcode ispctrl_if_mast_send_bulk(void *devdata, const u8 *buffer,
+ u32 total_size,
+ u32 block_size, bool is_raw);
+
+#else
+/** \brief Master send bulk (large data) to slave
+ *\param devdata [In], misp_data
+ *\param buffer [In], Data buffer to be sent, address 8-byte alignment
+ *\param filp [In], file pointer, used to read the file and send the data
+ *\param total_size [In], file size
+ *\param block_size [In], transfer buffer block size
+ *\param is_raw [In], true: mini boot code false: other files
+ *\return Error code
+ */
+errcode ispctrl_if_mast_send_bulk(void *devdata, u8 *buffer,
+ struct file *filp, u32 total_size,
+ u32 block_size, bool is_raw);
+#endif
+/** \brief Master open the firmware
+ *\param filename [In], file name of the firmware
+ *\param firmwaretype [In], firmware type
+ *\return Error code
+ */
+errcode ispctrl_if_mast_request_firmware(u8 *filename, u8 a_firmwaretype);
+
+/** \brief Master get SPI status bytes
+ *\param n/a
+ *\return status bytes(2 bytes)
+ */
+u16 ispctrl_if_mast_read_spi_status(void);
+
+/**
+ *\brief Receive ISP register response from slave
+ *\param devdata [In] misp_data
+ *\param response_buf [Out], Response buffer
+ *\param response_size [Out], Response size
+ *\param total_count [In], Total reg count
+ *\return Error code
+ */
+errcode ispctrl_if_mast_recv_isp_register_response_from_slave(
+ void *devdata,
+ u8 *response_buf,
+ u32 *response_size,
+ u32 total_count);
+
+/**
+ *\brief Initial purpose
+ *\param None
+ *\return Error code
+ */
+void isp_mast_camera_profile_para_init(void);
+
+/****** End of File******/
+
+/**
+ *@}
+ */
+
+#endif /* _ISPCTRLIF_MASTER_H_*/
diff --git a/drivers/media/platform/altek/include/ispctrl_if_master_local.h b/drivers/media/platform/altek/include/ispctrl_if_master_local.h
new file mode 100755
index 0000000..a263114
--- /dev/null
+++ b/drivers/media/platform/altek/include/ispctrl_if_master_local.h
@@ -0,0 +1,668 @@
+/*
+ * File: ispctrl_if_master_local.h
+ * Description: The structure and API definition ISP Ctrl IF Master Local
+ * It,s a header file that define structure and API for ISP Ctrl IF Master Local
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/10/14; Aaron Chuang; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+/**
+ * \file ispctrl_if_master_local.h
+ * \brief ISP Ctrl IF Master Local and API define
+ * \version 0.01
+ * \author Aaron Chuang
+ * \date 2013/09/23
+ * \see ispctrl_if_master_local.h
+ */
+
+#ifndef _ISPCTRLIF_MASTER_LOCAL_H_
+#define _ISPCTRLIF_MASTER_LOCAL_H_
+
+/**
+ *@addtogroup ispctrl_if_master_local
+ *@{
+ */
+
+
+/******Include File******/
+
+#include "mtype.h"
+#include "miniisp.h"
+
+
+/******Public Constant Definition******/
+#define ISP_REGISTER_PARA_SIZE 8
+#define ISP_REGISTER_VALUE 4
+
+
+/******Public Function Prototype******/
+
+/*********************** System manage command ***********************/
+/**
+ *\brief Get status of last executed command
+ *\param devdata [In], misp device data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_get_status_of_last_exec_command(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/**
+ *\brief Get error code CMD
+ *\param devdata [In], misp device data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_get_error_code_command(void *devdata,
+ u16 opcode,
+ u8 *param);
+
+/**
+ *\brief Set ISP register
+ *\param devdata [In], misp device data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_set_isp_register(void *devdata,
+ u16 opcode,
+ u8 *param);
+
+/**
+ *\brief Get ISP register
+ *\param devdata [In], misp device data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_get_isp_register(void *devdata,
+ u16 opcode,
+ u8 *param);
+
+/**
+ *\brief Set common log level
+ *\param devdata [In], misp device data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_set_comomn_log_level(void *devdata,
+ u16 opcode,
+ u8 *param);
+
+/**
+ *\brief Get chip test report
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_get_chip_test_report(void *devdata,
+ u16 opcode,
+ u8 *param);
+
+/**
+ *\brief Get chip isp thermal
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_get_chip_thermal(void *devdata,
+ u16 opcode,
+ u8 *param);
+
+
+/*********************** Camera profile command ***********************/
+/**
+ *\brief Set Sensor Mode
+ *\param devdata [In], misp device data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_sensor_mode(void *devdata,
+ u16 opcode,
+ u8 *param);
+
+/**
+ *\brief Get Sensor Mode
+ *\param devdata [In], misp device data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_get_sensor_mode(void *devdata,
+ u16 opcode,
+ u8 *param);
+
+/**
+ *\brief Set Output Format
+ *\param devdata [In], misp device data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_output_format(void *devdata,
+ u16 opcode,
+ u8 *param);
+
+/*
+ *\brief Set CP Mode
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_cp_mode(void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set AE statistics
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_ae_statistics(void *devdata,
+ u16 opcode, u8 *param);
+
+/**
+ *\brief Preview stream on
+ *\param devdata [In], misp device data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_preview_stream_on_off(
+ void *devdata,
+ u16 opcode,
+ u8 *param);
+
+/*
+ *\brief dual PD Y calculation weightings
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_dual_pd_y_cauculation_weightings(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+
+/*
+ *\brief led power control
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_led_power_control(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+
+/*
+ *\brief Active AE
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_active_ae(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief ISP AE control on off
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_isp_ae_control_on_off(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set Frame Rate Limits
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_frame_rate_limits(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set Period Drop Frame
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_period_drop_frame(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set max exposure
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_max_exposure(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set target mean
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_target_mean(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Frame sync control
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_frame_sync_control(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set shot mode
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_shot_mode(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Lighting control
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_lighting_ctrl(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set min exposure
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_min_exposure(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set Max exposure slope
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_max_exposure_slope(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set depth compensation
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_depth_compensation(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set cycle trigger depth process
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_cycle_trigger_depth(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Set led active delay time
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_set_led_active_delay(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+
+/*
+ *\brief Set isp control led level
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_isp_control_led_level(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+/*
+ *\brief Get isp thermal
+ *\param None
+ *\return Error code
+ */
+errcode mast_camera_profile_cmd_get_chip_thermal(
+ void *devdata,
+ u16 opcode, u8 *param);
+
+
+/* Bulk data command*/
+#if ENABLE_LINUX_FW_LOADER
+/**
+ *\brief Write Boot Code
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], boot file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_boot_code(void *devdata,
+ u8 *param);
+
+
+/**
+ *\brief Write Boot Code (Short SPI CMD)
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], boot file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_boot_code_shortlen(
+ void *devdata, u8 *param);
+
+/**
+ *\brief Write Basic Code
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], basic file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_basic_code(void *devdata,
+ u8 *param);
+
+/**
+ *\brief Write Basic Code
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], basic file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_basic_code_shortlen(void *devdata,
+ u8 *param);
+
+/**
+ *\brief Write Calibration Data
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], sc table file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_calibration_data(void *devdata,
+ u8 *param);
+
+#else
+/**
+ *\brief Write Boot Code
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], boot file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_boot_code(void *devdata,
+ u8 *param,
+ struct file *filp);
+
+
+/**
+ *\brief Write Boot Code (Short SPI CMD)
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], boot file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_boot_code_shortlen(void *devdata,
+ u8 *param,
+ struct file *filp);
+
+/**
+ *\brief Write Basic Code
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], basic file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_basic_code(void *devdata,
+ u8 *param,
+ struct file *filp);
+
+/**
+ *\brief Write Basic Code
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], basic file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_basic_code_shortlen(void *devdata,
+ u8 *param,
+ struct file *filp);
+
+/**
+ *\brief Write Calibration Data
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], sc table file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_calibration_data(void *devdata,
+ u8 *param,
+ struct file *filp);
+#endif
+
+/**
+ *\brief Write Qmerge Data
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], sc table file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_qmerge_data(void *devdata,
+ u8 *param,
+ struct file *filp);
+
+/**
+ *\brief Read Calibration Data
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_read_calibration_data(void *devdata,
+ u8 *param);
+
+/**
+ *\brief Read Memory Data
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_read_memory_data(void *devdata,
+ u8 *param);
+
+/**
+ *\brief Read common log data
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode bulk_data_cmd_read_common_log(void *devdata,
+ u8 *param);
+
+/*
+ *\brief Read depth Rect A, B, Invrect
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_depth_rectab_invrect(
+ void *devdata, u16 opcode, u8 *param);
+
+#if ENABLE_LINUX_FW_LOADER
+/**
+ *\brief Write Spinor Data
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], source file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_spinor_data(void *devdata,
+ u8 *param);
+
+#else
+/**
+ *\brief Write Spinor Data
+ *\param devdata [In], misp device data
+ *\param param [In], CMD param
+ *\param filp [In], source file
+ *\return Error code
+ */
+errcode mast_bulk_data_cmd_write_spinor_data(void *devdata,
+ u8 *param, struct file *filp);
+#endif
+/*********************** Basic setting command ************************/
+/**
+ *\brief Set Depth 3A Info
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_depth_3a_info(void *devdata,
+ u16 opcode,
+ u8 *param);
+
+
+/*
+ *\brief Set Depth auto interleave mode
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_depth_auto_interleave_mode(
+ void *devdata, u16 opcode, u8 *param);
+
+
+/*
+ *\brief Set projector interleave mode with depth type
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_interleave_mode_depth_type(
+ void *devdata, u16 opcode, u8 *param);
+
+/*
+ *\brief Set depth polish level
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_depth_polish_level(
+ void *devdata, u16 opcode, u8 *param);
+
+/*
+ *\brief Set exposure param
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_exposure_param(
+ void *devdata, u16 opcode, u8 *param);
+
+/*
+ *\brief Set depth stream size
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_basic_setting_cmd_set_depth_stream_size(
+ void *devdata, u16 opcode, u8 *param);
+/*********************** operation command ***********************/
+/**
+ *\brief Mini ISP open
+ *\param devdata [In], misp device data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_operation_cmd_miniisp_open(
+ void *devdata, u16 opcode, char *FileNametbl[]);
+
+
+/****************************** End of File *********************************/
+
+/**
+ *@}
+ */
+
+#endif /* _ISPCTRLIF_MASTER_LOCAL_H_*/
diff --git a/drivers/media/platform/altek/include/miniisp.h b/drivers/media/platform/altek/include/miniisp.h
new file mode 100755
index 0000000..8f8e661
--- /dev/null
+++ b/drivers/media/platform/altek/include/miniisp.h
@@ -0,0 +1,348 @@
+/*
+ * File: miniisp.h
+ * Description: Mini ISP sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/11/01; Bruce Chung; Initial version
+ * 2017/03/30; LouisWang; 2rd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _MINI_ISP_H_
+#define _MINI_ISP_H_
+
+/******Include File******/
+#include <linux/mutex.h>
+#include <linux/semaphore.h>
+#include <linux/spi/spi.h>
+#include <linux/types.h>
+#include <linux/clk.h>
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+
+#include "mtype.h"
+/******Public Constant Definition******/
+
+#define MINIISP_DRIVER_VERSION "v1.48.A4"
+
+/* SPI_E_AND_I2C_SLAVE_RELATED */
+#define CTRL_BYTE_REGRD (0x19)
+#define CTRL_BYTE_REGWR (0x09)
+#define CTRL_BYTE_MEMRD (0x15)
+#define CTRL_BYTE_MEMWR (0x05)
+/* SPI_E CMD */
+#define CTRL_BYTE_REGRD_W (0x81)
+#define CTRL_BYTE_MEMRD_W (0x82)
+#define CTRL_BYTE_GETDATA_W (0x83)
+
+#define EMODE_TXCMD_LEN (5) /*1byte ctrl byte + 4 bytes address*/
+
+#define EN_SPIE_REG_DUMMY_BYTE 1
+#if EN_SPIE_REG_DUMMY_BYTE
+ #define SPIE_RX_REG_DUMMY_LEN (16)
+ #define SPIE_RX_MEM_DUMMY_LEN (70)
+#else
+ #define SPIE_RX_DUMMY_LEN (32)
+#endif
+
+/*SPI_A_MODE_RELATED*/
+#define CTRL_BYTE_A2E 0x20
+#define SPI_TX_BULK_SIZE (64 * 1024)
+#define SPI_TX_BULK_SIZE_BOOT (8 * 1024)
+
+/*I2C_TOP_RELATED*/
+/*#define I2C_BULK_SIZE (4 * 1024) *//* AQ360 can work */
+#define I2C_TX_BULK_SIZE (1024) /*AL6100 can work*/
+#define I2C_RX_DUMMY_LEN (0)
+
+#define TX_BUF_SIZE 64
+#define RX_BUF_SIZE 64
+
+#define MINIISP_I2C_SLAVE 0
+#define MINIISP_I2C_TOP 1
+
+#define INTF_SPI_READY (1 << 0)
+#define INTF_I2C_READY (1 << 1)
+#define INTF_CCI_READY (1 << 2)
+
+#define DEBUG_ALERT 1
+#define DEBUG_TURNON 1
+
+/* Enable for use Linux Firmware API "request_firmware" to load fw or bin file
+ * The file search path is be defined at below array
+ * drivers/base/firmware_class.c: const fw_path[]
+ * User need to add required search path into this array
+ */
+#define ENABLE_LINUX_FW_LOADER 1
+
+/* Enable below function
+ * 1. mast_bulk_data_cmd_read_calibration_data
+ * 2. mast_bulk_data_cmd_read_memory_data
+ */
+
+#define ENABLE_FILP_OPEN_API 0
+
+#define ENABLE_FSM 0
+
+/*#define ALTEK_TEST*/
+
+#ifdef DEBUG_TURNON
+
+ #ifdef DEBUG_ALERT
+ #define misp_info(fmt, ...) \
+ pr_err(MINI_ISP_LOG_TAG ": " fmt "\n",\
+ ##__VA_ARGS__)
+
+ #define misp_warn(fmt, ...) \
+ pr_warn(MINI_ISP_LOG_TAG ": " fmt "\n",\
+ ##__VA_ARGS__)
+
+ #define misp_err(fmt, ...) \
+ pr_err(MINI_ISP_LOG_TAG ": " fmt "\n",\
+ ##__VA_ARGS__)
+ #else
+ #define misp_info(fmt, ...) \
+ pr_err(MINI_ISP_LOG_TAG ": " fmt "\n",\
+ ##__VA_ARGS__)
+
+ #define misp_warn(fmt, ...) \
+ pr_debug(MINI_ISP_LOG_TAG ": " fmt "\n",\
+ ##__VA_ARGS__)
+
+ #define misp_err(fmt, ...) \
+ pr_debug(MINI_ISP_LOG_TAG ": " fmt "\n",\
+ ##__VA_ARGS__)
+ #endif
+
+#else
+ #define misp_info(fmt, ...)
+ #define misp_err(fmt, ...)
+ #define misp_warn(fmt, ...)
+
+#endif
+
+/*ALTEK SPI MODE*/
+/*define Altek SPI mode*/
+enum ALTEK_SPI_MODE {
+ ALTEK_SPI_MODE_E = 0,
+ ALTEK_SPI_MODE_A,
+};
+
+/*
+ *@typedef USPICTRL_MS_CB_ID
+ *@brief USPI control byte definition (for master control)
+ */
+enum {
+ /*!< Ctrl-Byte, original command */
+ USPICTRL_MS_CB_ORG = (0x00<<6),
+ /*!< Ctrl-Byte, polling status */
+ USPICTRL_MS_CB_STS = (0x01<<6),
+ /*!< Ctrl-Byte, get response */
+ USPICTRL_MS_CB_RSP = (0x02<<6),
+ /*!< Ctrl-Byte, disable Ctrl-Byte mode */
+ USPICTRL_MS_CB_DIS = (0x03<<6),
+};
+
+/*Event Bit define*/
+/*define ISP control Master event Bit*/
+enum MINI_ISP_EVENT {
+ MINI_ISP_RCV_WAITING = 0, /* 0x00000000*/
+ MINI_ISP_RCV_CMD_READY = (1L << 0), /* 0x00000001*/
+ MINI_ISP_RCV_BULKDATA = (1L << 1), /* 0x00000002*/
+ MINI_ISP_RCV_CPCHANGE = (1L << 2), /* 0x00000004*/
+ MINI_ISP_RCV_SETSENSORMODE = (1L << 3),/* 0x00000008*/
+ MINI_ISP_RCV_ERROR = (1L << 4),/* 0x00000010*/
+ MINI_ISP_RCV_ERROR2 = (1L << 5),/* 0x00000020*/
+ MINI_ISP_RCV_STRMOFF = (1L << 6),/* 0x00000040*/
+};
+
+/* Definition for IRQ status*/
+#define COMMAND_COMPLETE 0x0001/*cmd deal complete by altek chip*/
+#define BULK_DATA_COMPLETE 0x0002/*bulk data deal complete by altek chip*/
+#define CP_STATUS_CHANGE_DONE 0x0004/*code persistence mode change finish*/
+#define SET_SENSOR_MODE_READY 0x0008
+#define SYSTEM_ERROR_LEVEL1 0x0010/*(Get Report)*/
+#define SYSTEM_ERROR_LEVEL2 0x0020/*(Dump Register)*/
+#define STRMOFF_READY 0x0040/*default not use*/
+
+enum MINI_ISP_STATE {
+ MINI_ISP_POWER_OFF = 0,
+ MINI_ISP_POWER_ON = 1,
+ MINI_ISP_STANDBY = 3,
+ MINI_ISP_SENSOR_MODE = 4,
+ MINI_ISP_CP_MODE = 5,
+};
+
+enum MINI_CALIB_ID {
+ CALIBRATION_ID_OTP = 0,
+ CALIBRATION_ID_DEPTH = 1,
+ CALIBRATION_ID_SCID = 2,
+ CALIBRATION_ID_HDR = 3,
+ CALIBRATION_ID_IRP0 = 4,
+ CALIBRATION_ID_IRP1 = 5,
+ CALIBRATION_ID_PPMAP = 6,
+ CALIBRATION_ID_BLENDINGTABLE = 7,
+ CALIBRATION_ID_QMERGE = 8,
+ CALIBRATION_ID_EEPROM = 9,
+ CALIBRATION_ID_ALTEK = 10,
+ CALIBRATION_ID_MAX,
+};
+/******Public Type Declaration******/
+struct misp_intf_fn_t {
+ int (*send)(void *devdata, u32 len);
+ int (*recv)(void *devdata, u32 len, bool waitINT);
+ int (*read)(void *devdata, u8 *tx_buf, u32 tx_len, u8 *rx_buf,
+ u32 rx_len);
+ int (*write)(void *devdata, u8 *tx_buf, u8 *rx_buf, u32 len);
+#if ENABLE_LINUX_FW_LOADER
+ int (*send_bulk)(void *devdata, u32 total_size, u32 block_size,
+ bool is_raw, const u8 *Sendbulkbuffer);
+#else
+ int (*send_bulk)(void *devdata, struct file *filp, u32 total_size,
+ u32 block_size, bool is_raw, u8 *Sendbulkbuffer);
+#endif
+};
+
+struct misp_data {
+ union {
+ struct spi_device *spi;
+ struct i2c_client *i2c;
+ /*struct msm_camera_i2c_client *cci;*/
+ } __packed cfg;
+
+ struct misp_intf_fn_t *intf_fn;
+ int bulk_cmd_blocksize;
+ u8 tx_buf[TX_BUF_SIZE];
+ u8 rx_buf[RX_BUF_SIZE];
+};
+
+struct misp_global_variable {
+ int vcc1_gpio;
+ int vcc2_gpio;
+ int vcc3_gpio;
+ int irq_gpio;
+ int wp_gpio;
+ int irq_num;
+ int reset_gpio;
+ int intf_status;
+ int before_booting;
+ int i2c_enable;
+ int altek_spi_mode;
+ int be_set_to_bypass;
+ int now_state;
+ int spi_low_speed_mode;
+ bool en_cmd_send;
+ struct clk *isp_clk;
+ struct mutex busy_lock;
+};
+
+
+struct irp_and_depth_information {
+ u32 irp_image_address;
+ u32 irp_width;
+ u32 irp_height;
+ u8 irp_format;/*Y_only:0 YUV:1*/
+ u32 depth_image_address;
+ u32 depth_width;
+ u32 depth_height;
+ u8 fov_mode;
+} __packed;
+
+/******Public Function Prototype******/
+extern irqreturn_t mini_isp_irq(int irq, void *handle);
+
+/*miniisp_spi.c*/
+extern struct misp_data *get_mini_isp_data(void);
+extern void set_mini_isp_data(struct misp_data *data, int intf_type);
+extern struct misp_data *get_mini_isp_intf(int i2c_type);
+extern struct misp_global_variable *get_mini_isp_global_variable(void);
+extern int mini_isp_get_bulk(struct misp_data *devdata, u8 *response_buf,
+ u32 total_size, u32 block_size);
+/*extern u16 mini_isp_get_status(void); //currently not use*/
+
+/*miniisp_top.c*/
+extern void mini_isp_e_to_a(void);
+extern void mini_isp_a_to_e(void);
+extern void mini_isp_chip_init(void);
+extern void mini_isp_cp_mode_suspend_flow(void);
+extern void mini_isp_cp_mode_resume_flow(void);
+extern void mini_isp_check_and_leave_bypass_mode(void);
+extern int mini_isp_pure_bypass(u16 mini_isp_mode);
+extern void mini_isp_pure_bypass_debug(u16 mini_isp_mode);
+extern int mini_isp_get_chip_id(void);
+extern u32 mini_isp_register_read_then_write_file(u32 start_reg_addr,
+ u32 end_reg_addr, char *dest_path, char *module_name);
+extern u32 mini_isp_register_read(u32 reg_addr, u32 *reg_value);
+extern errcode mini_isp_debug_dump(void);
+extern errcode mini_isp_memory_read_then_write_file(u32 start_addr, u32 len,
+ char *dest_path, char *file_name);
+extern u32 mini_isp_woi_memory_read_then_write_file(
+ u32 start_addr, u32 lineoffset,
+ u32 width, u32 height, char *dest_path, char *file_name);
+extern u32 mini_isp_memory_read_shortlen(u32 start_addr, u32 *read_buffer);
+extern u32 mini_isp_memory_read(u32 start_addr, u8 *read_buffer, u32 len);
+extern int mini_isp_get_altek_status(void *devdata, u32 *altek_status);
+extern int mini_isp_wait_for_event(u32 MINI_ISP_EVENT);
+extern u32 mini_isp_get_currentevent(void);
+extern void mini_isp_register_write(u32 reg_addr, u32 reg_new_value);
+extern void mini_isp_memory_write(u32 memory_addr, u8 *write_buffer,
+ u32 write_len);
+
+/*miniisp_utility.c*/
+extern int mini_isp_debug_dump_img(void);
+extern int mini_isp_debug_depth_rect_combo_dump(u8 is_ground_mode);
+extern errcode mini_isp_debug_packdata_dump(void);
+extern errcode mini_isp_debug_IQCalib_dump(void);
+extern errcode mini_isp_debug_metadata_dump(void);
+extern errcode mini_isp_utility_read_reg_e_mode_for_bypass_use(void);
+extern errcode mini_isp_utility_read_reg_e_mode(void);
+
+
+extern errcode mini_isp_debug_depth_info(void);
+extern errcode mini_isp_debug_metadata_info(void);
+extern errcode mini_isp_debug_sensor_info(bool a_IsLog2File);
+extern errcode mini_isp_debug_led_info(bool a_IsLog2File);
+extern int mini_isp_debug_mipi_rx_fps_start(bool a_IsLog2File);
+extern void mini_isp_debug_mipi_rx_fps_stop(void);
+extern errcode mini_isp_debug_GPIO_Status(bool a_IsLog2File);
+extern errcode mini_isp_utility_get_irp_and_depth_information(
+ struct irp_and_depth_information *info);
+extern u32 mini_isp_check_rx_dummy(u8 **recv_buffer, u32 rx_dummy_len);
+extern errcode mini_isp_create_directory(char *dir_name);
+extern u32 mini_isp_get_rx_dummy_byte(u8 spie_rx_mode);
+extern void mini_isp_set_spie_dummy_byte(u32 dummy_lens);
+
+/*miniisp_customer_define.c*/
+extern void mini_isp_poweron(void);
+extern void mini_isp_poweroff(void);
+extern void mini_isp_eeprom_wpon(void);
+extern void mini_isp_eeprom_wpoff(void);
+extern int mini_isp_gpio_init(struct device *spi,
+ struct misp_data *drv_data,
+ struct misp_global_variable *drv_global_variable);
+/* AL6100 debug tool */
+extern int mini_isp_setup_resource(struct device *dev,
+ struct misp_data *drv_data);
+extern struct device *miniisp_chdev_create(struct class *mini_isp_class);
+extern struct device *mini_isp_getdev(void);
+extern struct misp_data *get_mini_isp_intf_spi(void);
+extern struct misp_data *get_mini_isp_intf_i2c(int i2c_type);
+#endif
+
diff --git a/drivers/media/platform/altek/include/miniisp_chip_base_define.h b/drivers/media/platform/altek/include/miniisp_chip_base_define.h
new file mode 100755
index 0000000..89c949e
--- /dev/null
+++ b/drivers/media/platform/altek/include/miniisp_chip_base_define.h
@@ -0,0 +1,1035 @@
+/*
+ * File: miniisp_chip_base_define.c.h
+ * Description: Mini ISP ChipBase Define Code
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2017/10/18; Louis Wang; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _MINIISP_CHIP_BASE_DEFINE_H_
+#define _MINIISP_CHIP_BASE_DEFINE_H_
+
+/******Include File******/
+
+
+/******Public Constant Definition******/
+#define CHIP_ID_ADDR 0xffef0020
+#define SPIE_DUMMY_BYTE_ADDR 0xFFF82000
+
+#define INTERRUPT_STATUS_REGISTER_ADDR 0xffef00b4
+#define INTERRUPT_ENABLE_BIT_REGISTER_ADDR 0xffef00b0
+
+#define clk_gen_dump_field \
+{\
+0xFFE80040, 0xFFE8004C,\
+0xFFE80060, 0xFFE80064,\
+0xFFE80080, 0xFFE80084,\
+0xFFE800A0, 0xFFE800A4,\
+0xFFE800C0, 0xFFE800C4,\
+0xFFE800E0, 0xFFE800E4,\
+0xFFE80100, 0xFFE80104,\
+0xFFE80120, 0xFFE80124,\
+0xFFE80140, 0xFFE80144,\
+0xFFE80160, 0xFFE80164,\
+0xFFE80180, 0xFFE80184,\
+0xFFE801A0, 0xFFE801A8,\
+0xFFE801C8, 0xFFE801C8,\
+0xFFE80200, 0xFFE80204,\
+0xFFE80240, 0xFFE80244,\
+0xFFE80280, 0xFFE80284,\
+0xFFE80340, 0xFFE80344,\
+0xFFE80380, 0xFFE80384,\
+0xFFE80400, 0xFFE80404,\
+0xFFE80440, 0xFFE80444,\
+0xFFE80460, 0xFFE80464,\
+0xFFE80484, 0xFFE80484,\
+0xFFE804A4, 0xFFE804A4,\
+0xFFE804C4, 0xFFE804C4,\
+0xFFE804E4, 0xFFE804E4,\
+0xFFE80500, 0xFFE80504,\
+0xFFE80540, 0xFFE80548,\
+0xFFE80580, 0xFFE80588,\
+0xFFE805C0, 0xFFE805C8,\
+0xFFE80620, 0xFFE80630,\
+0xFFE80680, 0xFFE80684,\
+0xFFE806E0, 0xFFE806E4,\
+0xFFE80720, 0xFFE80724,\
+0xFFE807C0, 0xFFE807C4,\
+0xFFE80804, 0xFFE80804,\
+0xFFE80814, 0xFFE80814,\
+0xFFE80824, 0xFFE80824,\
+0xFFE80840, 0xFFE80844,\
+0xFFE80884, 0xFFE80884,\
+0xFFE80900, 0xFFE80904,\
+0xFFE80944, 0xFFE80944,\
+0xFFE80B00, 0xFFE80B04,\
+0xFFE80C00, 0xFFE80C04,\
+0xFFE80C40, 0xFFE80C44,\
+0xFFE81000, 0xFFE81004,\
+0xFFE81080, 0xFFE81080,\
+0xFFE81100, 0xFFE81114,\
+0xFFE81120, 0xFFE81134,\
+0xFFE81140, 0xFFE81154,\
+0xFFE81200, 0xFFE8122C,\
+0xFFE8F000, 0xFFE8F000,\
+}
+
+#define mipi_tx_phy_if_0_dump_field \
+{\
+0xFFED1000, 0xFFED1048,\
+0xFFED1100, 0xFFED1104,\
+}
+
+#define mipi_tx_phy_if_1_dump_field \
+{\
+0xFFED6000, 0xFFED6048,\
+0xFFED6100, 0xFFED6104,\
+}
+
+#define gen_reg_dump_field \
+{\
+0xffef0000, 0xffef0008,\
+0xffef0020, 0xffef0044,\
+0xffef0054, 0xffef005C,\
+0xffef0070, 0xffef00a8,\
+0xffef00b0, 0xffef00b4,\
+0xffef00f0, 0xffef00f8,\
+0xffef0100, 0xffef0100,\
+0xffef0208, 0xffef0208,\
+0xffef0240, 0xffef0240,\
+0xffef0248, 0xffef0248,\
+0xffef0250, 0xffef0258,\
+0xffef0280, 0xffef0284,\
+0xffef0410, 0xffef0414,\
+0xffef0500, 0xffef0500,\
+0xffef0f00, 0xffef0f00,\
+}
+
+#define mipi_slvds_rx_phy_if_0_dump_field \
+{\
+0xfff91000, 0xfff91008,\
+0xfff91010, 0xfff91040,\
+0xfff9104c, 0xfff9104c,\
+0xfff91068, 0xfff91078,\
+0xfff91084, 0xfff91084,\
+0xfff9108c, 0xfff9108c,\
+0xfff91094, 0xfff910c8,\
+0xfff91100, 0xfff9114c,\
+}
+
+#define mipi_slvds_rx_phy_if_1_dump_field \
+{\
+0xfff94000, 0xfff94008,\
+0xfff94010, 0xfff94040,\
+0xfff9404c, 0xfff9404c,\
+0xfff94068, 0xfff94078,\
+0xfff94084, 0xfff94084,\
+0xfff9408c, 0xfff9408c,\
+0xfff94094, 0xfff940c8,\
+0xfff94100, 0xfff9414c,\
+}
+
+#define ppi_bridge_a_0_dump_field \
+{\
+0xfff97000, 0xfff97040,\
+0xfff970a0, 0xfff970ac,\
+0xfff970f0, 0xfff970fc,\
+0xfff97110, 0xfff9716c,\
+0xfff972a0, 0xfff972a4,\
+0xfff97300, 0xfff97314,\
+}
+
+#define ppi_bridge_a_1_dump_field \
+{\
+0xfff98000, 0xfff98040,\
+0xfff980a0, 0xfff980ac,\
+0xfff980f0, 0xfff980fc,\
+0xfff98110, 0xfff9816c,\
+0xfff982a0, 0xfff982a4,\
+0xfff98300, 0xfff98314,\
+}
+
+#define ppi_bridge_a_1_dump_field \
+{\
+0xfff98000, 0xfff98040,\
+0xfff980a0, 0xfff980ac,\
+0xfff980f0, 0xfff980fc,\
+0xfff98110, 0xfff9816c,\
+0xfff982a0, 0xfff982a4,\
+0xfff98300, 0xfff98314,\
+}
+
+#define tx_top_out_mux_a_0_dump_field \
+{\
+0xffecb000, 0xffecb004,\
+0xffecb010, 0xffecb014,\
+0xffecb020, 0xffecb050,\
+0xffecb100, 0xffecb13c,\
+0xffecb200, 0xffecb220,\
+0xffecb300, 0xffecb32c,\
+0xffecbf00, 0xffecbf00,\
+}
+
+#define tx_top_out_mux_a_1_dump_field \
+{\
+0xffecc000, 0xffecc004,\
+0xffecc010, 0xffecc014,\
+0xffecc020, 0xffecc050,\
+0xffecc100, 0xffecc13c,\
+0xffecc200, 0xffecc220,\
+0xffecc300, 0xffecc32c,\
+0xffeccf00, 0xffeccf00,\
+}
+
+#define tx_line_merge_21_a_0_dump_field \
+{\
+0xffec1000, 0xffec1010,\
+0xffec1020, 0xffec1024,\
+0xffec1030, 0xffec1034,\
+0xffec1040, 0xffec1044,\
+0xffec104c, 0xffec105c,\
+0xffec1070, 0xffec1074,\
+0xffec108c, 0xffec108c,\
+0xffec1100, 0xffec1124,\
+0xffec1140, 0xffec1144,\
+0xffec1150, 0xffec1174,\
+0xffec1180, 0xffec1184,\
+0xffec1300, 0xffec1300,\
+0xffec1310, 0xffec1320,\
+0xffec1330, 0xffec135c,\
+0xffec1400, 0xffec1404,\
+0xffec1410, 0xffec145c,\
+0xffec1470, 0xffec1484,\
+0xffec1490, 0xffec14b0,\
+0xffec1a00, 0xffec1a00,\
+0xffec1a10, 0xffec1a34,\
+0xffec1a40, 0xffec1a84,\
+0xffec1a90, 0xffec1aac,\
+0xffec1ac0, 0xffec1ac4,\
+0xffec1ad0, 0xffec1adc,\
+0xffec1b00, 0xffec1b08,\
+0xffec1b10, 0xffec1b14,\
+0xffec1b20, 0xffec1b54,\
+0xffec1b68, 0xffec1b98,\
+0xffec1f00, 0xffec1f00,\
+}
+
+#define tx_line_merge_21_b_0_dump_field \
+{\
+0xffec2000, 0xffec2010,\
+0xffec2020, 0xffec2024,\
+0xffec2030, 0xffec2034,\
+0xffec2040, 0xffec2044,\
+0xffec204c, 0xffec205c,\
+0xffec2070, 0xffec2074,\
+0xffec208c, 0xffec208c,\
+0xffec2100, 0xffec2124,\
+0xffec2140, 0xffec2144,\
+0xffec2150, 0xffec2174,\
+0xffec2180, 0xffec2184,\
+0xffec2300, 0xffec2300,\
+0xffec2310, 0xffec2320,\
+0xffec2330, 0xffec235c,\
+0xffec2400, 0xffec2404,\
+0xffec2410, 0xffec245c,\
+0xffec2470, 0xffec2484,\
+0xffec2490, 0xffec24b0,\
+0xffec2a00, 0xffec2a00,\
+0xffec2a10, 0xffec2a34,\
+0xffec2a40, 0xffec2a84,\
+0xffec2a90, 0xffec2aac,\
+0xffec2ac0, 0xffec2ac4,\
+0xffec2ad0, 0xffec2adc,\
+0xffec2b00, 0xffec2b08,\
+0xffec2b10, 0xffec2b14,\
+0xffec2b20, 0xffec2b54,\
+0xffec2b68, 0xffec2b98,\
+0xffec2f00, 0xffec2f00,\
+}
+
+#define tx_line_merge_21_c_0_dump_field \
+{\
+0xffec5000, 0xffec5010,\
+0xffec5020, 0xffec5024,\
+0xffec5030, 0xffec5034,\
+0xffec5040, 0xffec5044,\
+0xffec504c, 0xffec505c,\
+0xffec5070, 0xffec5074,\
+0xffec508c, 0xffec508c,\
+0xffec5100, 0xffec5124,\
+0xffec5140, 0xffec5144,\
+0xffec5150, 0xffec5174,\
+0xffec5180, 0xffec5184,\
+0xffec5300, 0xffec5300,\
+0xffec5310, 0xffec5320,\
+0xffec5330, 0xffec535c,\
+0xffec5400, 0xffec5404,\
+0xffec5410, 0xffec545c,\
+0xffec5470, 0xffec5484,\
+0xffec5490, 0xffec54b0,\
+0xffec5a00, 0xffec5a00,\
+0xffec5a10, 0xffec5a34,\
+0xffec5a40, 0xffec5a84,\
+0xffec5a90, 0xffec5aac,\
+0xffec5ac0, 0xffec5ac4,\
+0xffec5ad0, 0xffec5adc,\
+0xffec5b00, 0xffec5b08,\
+0xffec5b10, 0xffec5b14,\
+0xffec5b20, 0xffec5b54,\
+0xffec5b68, 0xffec5b98,\
+0xffec5f00, 0xffec5f00,\
+}
+
+#define tx_line_merge_21_d_0_dump_field \
+{\
+0xffec6000, 0xffec6010,\
+0xffec6020, 0xffec6024,\
+0xffec6030, 0xffec6034,\
+0xffec6040, 0xffec6044,\
+0xffec604c, 0xffec605c,\
+0xffec6070, 0xffec6074,\
+0xffec608c, 0xffec608c,\
+0xffec6100, 0xffec6124,\
+0xffec6140, 0xffec6144,\
+0xffec6150, 0xffec6174,\
+0xffec6180, 0xffec6184,\
+0xffec6300, 0xffec6300,\
+0xffec6310, 0xffec6320,\
+0xffec6330, 0xffec635c,\
+0xffec6400, 0xffec6404,\
+0xffec6410, 0xffec645c,\
+0xffec6470, 0xffec6484,\
+0xffec6490, 0xffec64b0,\
+0xffec6a00, 0xffec6a00,\
+0xffec6a10, 0xffec6a34,\
+0xffec6a40, 0xffec6a84,\
+0xffec6a90, 0xffec6aac,\
+0xffec6ac0, 0xffec6ac4,\
+0xffec6ad0, 0xffec6adc,\
+0xffec6b00, 0xffec6b08,\
+0xffec6b10, 0xffec6b14,\
+0xffec6b20, 0xffec6b54,\
+0xffec6b68, 0xffec6b98,\
+0xffec6f00, 0xffec6f00,\
+}
+
+#define mipi_csi2_tx_0_dump_field \
+{\
+0xFFED0000, 0xFFED0008,\
+0xFFED0044, 0xFFED0044,\
+0xFFED0058, 0xFFED0068,\
+0xFFED0090, 0xFFED00AC,\
+0xFFED00BC, 0xFFED00C8,\
+0xFFED00D4, 0xFFED00EC,\
+0xFFED0100, 0xFFED0138,\
+0xFFED0300, 0xFFED0358,\
+0xFFED038C, 0xFFED038C,\
+0xFFED0360, 0xFFED03B4,\
+0xFFED03BC, 0xFFED03D0,\
+0xFFED0FF0, 0xFFED0FF0,\
+}
+
+#define mipi_csi2_tx_1_dump_field \
+{\
+0xFFED5000, 0xFFED5008,\
+0xFFED5044, 0xFFED5044,\
+0xFFED5058, 0xFFED5068,\
+0xFFED5090, 0xFFED50AC,\
+0xFFED50BC, 0xFFED50C8,\
+0xFFED50D4, 0xFFED50EC,\
+0xFFED5100, 0xFFED5138,\
+0xFFED5300, 0xFFED5358,\
+0xFFED538C, 0xFFED538C,\
+0xFFED5360, 0xFFED53B4,\
+0xFFED53BC, 0xFFED53D0,\
+0xFFED5FF0, 0xFFED5FF0,\
+}
+
+#define gen_reg_depth_top_dump_field \
+{\
+0xfffa0000, 0xfffa0004,\
+0xfffa0050, 0xfffa0050,\
+0xfffa0100, 0xfffa0104,\
+0xfffa0128, 0xfffa0128,\
+0xfffa0200, 0xfffa0234,\
+0xfffa0f00, 0xfffa0f00,\
+}
+
+#define gen_reg_dpc_top_dump_field \
+{\
+0xfff00000, 0xfff00004,\
+0xfff00010, 0xfff00010,\
+0xfff00100, 0xfff00104,\
+0xfff00128, 0xfff00128,\
+0xfff00f00, 0xfff00f00,\
+}
+
+#define gen_reg_hdr_top_dump_field \
+{\
+0xfff50000, 0xfff50004,\
+0xfff50100, 0xfff50104,\
+0xfff50128, 0xfff50128,\
+0xfff50f00, 0xfff50f00,\
+}
+
+#define gen_reg_irp_top_dump_field \
+{\
+0xffec3000, 0xffec3004,\
+0xffec3010, 0xffec3018,\
+0xffec3100, 0xffec3104,\
+0xffec3128, 0xffec312c,\
+0xffec3f00, 0xffec3f00,\
+}
+
+#define gen_reg_standby_top_dump_field \
+{\
+0xffec4000, 0xffec4004,\
+0xffec4010, 0xffec4020,\
+0xffec4030, 0xffec4044,\
+0xffec4100, 0xffec4104,\
+0xffec4128, 0xffec4128,\
+0xffec4f00, 0xffec4f00,\
+}
+
+#define gen_reg_tx_top_dump_field \
+{\
+0xffec0000, 0xffec0008,\
+0xffec0010, 0xffec0018,\
+0xffec0310, 0xffec0318,\
+0xffec0f00, 0xffec0f00,\
+}
+
+#define id_det_a_0_dump_field \
+{\
+0xfff01000, 0xfff01038,\
+0xfff01050, 0xfff0110c,\
+0xfff01150, 0xfff01158,\
+0xfff0117c, 0xfff011c8,\
+0xfff011f4, 0xfff01208,\
+0xfff012a0, 0xfff012b0,\
+0xfff012dc, 0xfff012e4,\
+}
+
+#define id_det_a_1_dump_field \
+{\
+0xfff02000, 0xfff02038,\
+0xfff02050, 0xfff0210c,\
+0xfff02150, 0xfff02158,\
+0xfff0217c, 0xfff021c8,\
+0xfff021f4, 0xfff02208,\
+0xfff022a0, 0xfff022b0,\
+0xfff022dc, 0xfff022e4,\
+}
+
+#define bayer_binning_a_0_dump_field \
+{\
+0xfff54000, 0xfff54008,\
+0xfff5401c, 0xfff54068,\
+0xfff54070, 0xfff54094,\
+}
+
+#define bayer_binning_a_1_dump_field \
+{\
+0xfff55000, 0xfff55008,\
+0xfff5501c, 0xfff55068,\
+0xfff55070, 0xfff55094,\
+}
+
+#define bayer_scl_a_0_dump_field \
+{\
+0xfffa7000, 0xfffa70d0,\
+0xfffa7100, 0xfffa7108,\
+0xfffa7110, 0xfffa7118,\
+0xfffa7200, 0xfffa7200,\
+}
+
+#define bayer_scl_a_1_dump_field \
+{\
+0xfffa8000, 0xfffa80d0,\
+0xfffa8100, 0xfffa8108,\
+0xfffa8110, 0xfffa8118,\
+0xfffa8200, 0xfffa8200,\
+}
+
+#define rlb_a_0_dump_field \
+{\
+0xfff05000, 0xfff0500c,\
+0xfff05018, 0xfff0501c,\
+0xfff05028, 0xfff0502c,\
+0xfff05058, 0xfff05098,\
+0xfff050b0, 0xfff050b0,\
+0xfff050b8, 0xfff050c8,\
+0xfff050d4, 0xfff050e0,\
+0xfff050f0, 0xfff050f0,\
+0xfff05100, 0xfff05108,\
+0xfff05110, 0xfff05110,\
+0xfff05120, 0xfff05138,\
+}
+
+#define rlb_b_0_dump_field \
+{\
+0xfff06000, 0xfff0600c,\
+0xfff06018, 0xfff0601c,\
+0xfff06028, 0xfff0602c,\
+0xfff06058, 0xfff06098,\
+0xfff060b0, 0xfff060b0,\
+0xfff060b8, 0xfff060c8,\
+0xfff060d4, 0xfff060e0,\
+0xfff060f0, 0xfff060f0,\
+0xfff06100, 0xfff06108,\
+0xfff06110, 0xfff06110,\
+0xfff06120, 0xfff06138,\
+}
+
+
+#define mipi_csi2_rx_0_dump_field \
+{\
+0xfff92000, 0xfff92004,\
+0xfff9200c, 0xfff9208c,\
+0xfff92100, 0xfff92148,\
+0xfff9215c, 0xfff9217c,\
+0xfff92188, 0xfff9218c,\
+0xfff92198, 0xfff921dc,\
+0xfff921f8, 0xfff922d4,\
+}
+
+#define mipi_csi2_rx_1_dump_field \
+{\
+0xfff95000, 0xfff95004,\
+0xfff9500c, 0xfff9508c,\
+0xfff95100, 0xfff95148,\
+0xfff9515c, 0xfff9517c,\
+0xfff95188, 0xfff9518c,\
+0xfff95198, 0xfff951dc,\
+0xfff951f8, 0xfff952d4,\
+}
+
+#define dg_ca_a_0_dump_field \
+{\
+0xfff8b000, 0xfff8b074,\
+}
+
+#define dg_mcc_a_0_dump_field \
+{\
+0xfff8a000, 0xfff8a024,\
+0xfff8a0b0, 0xfff8a170,\
+}
+
+#define dp_top_a_0_dump_field \
+{\
+0xfff88000, 0xfff88090,\
+0xfff88100, 0xfff88104,\
+0xfff88200, 0xfff88240,\
+0xfff88280, 0xfff88280,\
+0xfff88300, 0xfff88300,\
+}
+
+#define lvhwirp_top_a_0_dump_field \
+{\
+0xfff30000, 0xfff30018,\
+0xfff30100, 0xfff30110,\
+0xfff30200, 0xfff30238,\
+0xfff30400, 0xfff30418,\
+0xfff31000, 0xfff311ec,\
+0xfff31300, 0xfff31310,\
+0xfff32000, 0xfff32ffc,\
+0xfff33000, 0xfff33004,\
+0xfff33100, 0xfff33188,\
+0xfff33200, 0xfff34204,\
+0xfff34300, 0xfff35ddc,\
+0xfff36000, 0xfff37000,\
+}
+
+#define lvhwirp_top_b_0_dump_field \
+{\
+0xfff20000, 0xfff20018,\
+0xfff20100, 0xfff20110,\
+0xfff20200, 0xfff20238,\
+0xfff20400, 0xfff20418,\
+0xfff21000, 0xfff211ec,\
+0xfff21300, 0xfff21310,\
+0xfff22000, 0xfff22ffc,\
+0xfff23000, 0xfff23004,\
+0xfff23100, 0xfff23188,\
+0xfff23200, 0xfff24204,\
+0xfff24300, 0xfff25ddc,\
+0xfff26000, 0xfff27000,\
+}
+
+#define lvlumanr_a_0_dump_field \
+{\
+0xfffa1000, 0xfffa1018,\
+0xfffa1040, 0xfffa1098,\
+0xfffa10A4, 0xfffa10C8,\
+}
+
+#define lvlumanr_a_1_dump_field \
+{\
+0xfffa2000, 0xfffa2018,\
+0xfffa2040, 0xfffa2098,\
+0xfffa20A4, 0xfffa20C8,\
+}
+
+#define lvsharp_a_0_dump_field \
+{\
+0xfffa5000, 0xfffa5028,\
+0xfffa5034, 0xfffa5034,\
+0xfffa5044, 0xfffa5060,\
+0xfffa5070, 0xfffa5070,\
+0xfffa50fc, 0xfffa51b0,\
+0xfffa5208, 0xfffa521c,\
+0xfffa5250, 0xfffa5264,\
+0xfffa5270, 0xfffa5270,\
+0xfffa5300, 0xfffa5308,\
+}
+
+#define lvsharp_a_1_dump_field \
+{\
+0xfffa6000, 0xfffa6028,\
+0xfffa6034, 0xfffa6034,\
+0xfffa6044, 0xfffa6060,\
+0xfffa6070, 0xfffa6070,\
+0xfffa60fc, 0xfffa61b0,\
+0xfffa6208, 0xfffa621c,\
+0xfffa6250, 0xfffa6264,\
+0xfffa6270, 0xfffa6270,\
+0xfffa6300, 0xfffa6308,\
+}
+
+#define rectify_a_0_dump_field \
+{\
+0xFFF8C000, 0xFFF8C008,\
+0xFFF8C010, 0xFFF8C010,\
+0xFFF8C024, 0xFFF8C024,\
+0xFFF8C040, 0xFFF8C040,\
+0xFFF8C050, 0xFFF8C050,\
+0xFFF8C060, 0xFFF8C060,\
+0xFFF8C080, 0xFFF8C084,\
+0xFFF8C100, 0xFFF8C108,\
+0xFFF8C110, 0xFFF8C110,\
+0xFFF8C17C, 0xFFF8C1A8,\
+0xFFF8C380, 0xFFF8C3A0,\
+0xFFF8C400, 0xFFF8C408,\
+0xFFF8C480, 0xFFF8C480,\
+0xFFF8C50C, 0xFFF8C518,\
+0xFFF8C540, 0xFFF8C540,\
+0xFFF8C550, 0xFFF8C550,\
+0xFFF8C5F0, 0xFFF8C5F0,\
+0xFFF8C900, 0xFFF8C908,\
+0xFFF8C910, 0xFFF8C910,\
+0xFFF8C97C, 0xFFF8C9A8,\
+0xFFF8CB80, 0xFFF8CBA0,\
+0xFFF8CC00, 0xFFF8CC00,\
+0xFFF8CC08, 0xFFF8CC08,\
+0xFFF8CC80, 0xFFF8CC80,\
+0xFFF8CD0C, 0xFFF8CD18,\
+0xFFF8CD40, 0xFFF8CD40,\
+0xFFF8CD50, 0xFFF8CD50,\
+0xFFF8CDF0, 0xFFF8CDF0,\
+0xFFF8CE04, 0xFFF8CE38,\
+0xFFF8CE40, 0xFFF8CE48,\
+0xFFF8CF00, 0xFFF8CFFC,\
+}
+
+#define rectify_b_0_dump_field \
+{\
+0xFFF8D000, 0xFFF8D008,\
+0xFFF8D010, 0xFFF8D010,\
+0xFFF8D024, 0xFFF8D024,\
+0xFFF8D040, 0xFFF8D040,\
+0xFFF8D050, 0xFFF8D050,\
+0xFFF8D060, 0xFFF8D060,\
+0xFFF8D080, 0xFFF8D084,\
+0xFFF8D100, 0xFFF8D108,\
+0xFFF8D110, 0xFFF8D110,\
+0xFFF8D17C, 0xFFF8D1A8,\
+0xFFF8D380, 0xFFF8D3A0,\
+0xFFF8D400, 0xFFF8D408,\
+0xFFF8D480, 0xFFF8D480,\
+0xFFF8D50C, 0xFFF8D518,\
+0xFFF8D540, 0xFFF8D540,\
+0xFFF8D550, 0xFFF8D550,\
+0xFFF8D5F0, 0xFFF8D5F0,\
+0xFFF8D900, 0xFFF8D908,\
+0xFFF8D910, 0xFFF8D910,\
+0xFFF8D97C, 0xFFF8D9A8,\
+0xFFF8DB80, 0xFFF8DBA0,\
+0xFFF8DC00, 0xFFF8DC00,\
+0xFFF8DC08, 0xFFF8DC08,\
+0xFFF8DC80, 0xFFF8DC80,\
+0xFFF8DD0C, 0xFFF8DD18,\
+0xFFF8DD40, 0xFFF8DD40,\
+0xFFF8DD50, 0xFFF8DD50,\
+0xFFF8DDF0, 0xFFF8DDF0,\
+0xFFF8DE04, 0xFFF8DE38,\
+0xFFF8DE40, 0xFFF8DE48,\
+0xFFF8DF00, 0xFFF8DFFC,\
+}
+
+#define hdr_ae_a_0_dump_field \
+{\
+ 0xFFF59000, 0xFFF59450,\
+}
+
+#define hdr_ae_a_1_dump_field \
+{\
+ 0xFFF5A000, 0xFFF5A450,\
+}
+
+#define DEPTH_FLOWMGR_INFO_VER 0xc
+/* V11 */
+typedef struct {
+ /* General info */
+ u8 ValidFlag;
+ u8 Ver;
+ u8 ALDU_MainVer;
+ u8 ALDU_SubVer;
+
+ struct {
+ u8 ValidDepthFlowDebugInfo;
+ u8 DepthFlowModeId;
+ u16 refImg1_Width;
+ u16 refImg1_Height;
+ u16 refImg2_Width;
+ u16 refImg2_Height;
+ u16 refImg3_Width;
+ u16 refImg3_Height;
+ u16 DepthImgKernelSizeRatio;
+ u16 DepthType;
+ u16 DepthGroundType;
+ u32 DephtProcTime;
+ u32 BlendingProcTime;
+ u32 DepthProcCnt;
+ u8 FeatureFlag;
+ u8 InvRECT_BypassLDC;
+ u8 PerformanceFlag;
+ u8 NormalKernalSizeMatch;
+ u8 GroundKernalSizeMatch;
+ u8 NormalKernelSizeIdx;
+ u8 GroundKernelSizeIdx;
+ } tDepthFlowDebugInfo;
+
+ /* Packdata */
+ struct {
+ u8 ValidDepthPacadataDebugInfo;
+ u8 ValidPackdata;
+ u8 ValidDisparityToDistanceTable;
+ u8 HighDistortionRate;
+ u8 PackdataNormalIdx;
+ u8 PackdataGroundIdx;
+ u8 PackdataRGBIdx;
+ u8 AbsoluteGlobalVal;
+ u8 HwCoefficient;
+ u16 HighDistortionIdx;
+ u8 PackdataSource;
+ u16 WOIMainXBase;
+ u16 WOIMainYBase;
+ u16 WOIMainXLength;
+ u16 WOIMainYLength;
+ u16 WOISubXBase;
+ u16 WOISubYBase;
+ u16 WOISubXLength;
+ u16 WOISubYLength;
+ s16 SubCamRectShift;
+ u32 PackdataAddr;
+ u32 PackdataChkSum;
+ u32 IntrinsicK_Main[9];
+ u32 AlDUErrCode;
+ u8 reserve;
+ u8 ConvertMatch;
+ u8 ConvertCount;
+ u8 NormalRectQPReadPingPongIdx;
+ } tDepthPackdataDebugInfo;
+
+ /* Detph utility */
+ struct {
+ u8 ValidDepthUtiDebugInfo;
+ u8 ValidBlendingTable;
+ u16 DistanceVal[3];
+ u8 BlendingTableSource;
+ u16 BlendingTableSize;
+ u16 BlendingStartLine;
+ u8 ValidQmerge;
+ u8 QmergeBinCameraID;
+ u8 DWUpdated;
+ } tDepthUtiDebugInfo;
+} DEPTHFLOWMGR_DEBUG_INFO;
+
+enum {
+ RESOLUTION_16_9 = 0,
+ RESOLUTION_16_10 = 1,
+ RESOLUTION_4_3 = 2,
+ RESOLUTION_OTHER = 3
+};
+
+typedef enum {
+ DEPTHPACKDATA_SRC_NULL,
+ DEPTHPACKDATA_SRC_CMD, /* receive packdata via command */
+ DEPTHPACKDATA_SRC_OTP, /* receive packdata from OTP, EEPROM (ISP read via I2C) */
+} DEPTHPACKDATA_SRC;
+
+typedef enum {
+ DEPTHBLENDING_SRC_NULL,
+ DEPTHBLENDING_SRC_CMD, /* AP send blending table */
+ DEPTHBLENDING_SRC_ISP, /* ISP calculate blending table */
+} DEPTHBLENDING_SRC;
+
+typedef struct {
+ u16 MetaDataVer;
+ u16 SCID;
+ u8 RxSwap;
+ u8 TxSwap;
+ u8 SensorType;
+ u8 HDRPPPipeIdx;
+ u16 LPPWidth;
+ u16 LPPHeight;
+ u16 RPPWidth;
+ u16 RPPHeight;
+} CAPFLOWMGR_META_COMMON;
+
+/**
+@struct CAPFLOWMGR_META_PIPE
+@brief Pipe paramters
+*/
+typedef struct {
+ u32 FrameIndex;
+ u16 SrcImgWidth;
+ u16 SrcImgHeight;
+ u32 ColorOrder;
+ u32 ExpTime;
+ s16 BV;
+ u16 ISO;
+ u16 AD_Gain;
+ u16 AWB_RGain;
+ u16 AWB_GGain;
+ u16 AWB_BGain;
+
+ u16 BlackOffset_R;
+ u16 BlackOffset_G;
+ u16 BlackOffset_B;
+ u16 Crop_X;
+ u16 Crop_Y;
+ u16 Crop_Width;
+ u16 Crop_Height;
+ u16 ScalarWidth;
+ u16 ScalarHeight;
+
+ s16 VCM_macro;
+ s16 VCM_infinity;
+ s16 VCM_CurStep;
+ u32 Depth_VCMStatus;
+} CAPFLOWMGR_META_PIPE; /* For MetaData */
+
+/**
+@struct CAPFLOWMGR_META_DEPTH
+@brief Depth paramters
+*/
+typedef struct {
+ u32 DepthIndex;
+ u32 ReferenceFrameIndex;
+ u16 DepthWidth;
+ u16 DepthHeight;
+ u16 DepthType;
+ s16 awDepth_VCMStep[2];
+ u8 aucMediaData[34];
+} CAPFLOWMGR_META_DEPTH; /* For MetaData */
+
+/**
+@struct CAPFLOWMGR_META_HDR
+@brief Depth paramters
+*/
+typedef struct {
+ u8 HDR_Type;
+ u8 HDR_OutputMode;
+ u8 ZZ_ColorOrder_R;
+ u8 ZZ_ColorOrder_Gr;
+ u8 ZZ_ColorOrder_B;
+ u8 ExpRatio;
+ u16 RDN_AdapParam;
+ u8 Block_Operation_Mode;
+ u8 PPInfo;
+ u16 uw0EV_gain;
+ s16 LongImage_0EV_Target;
+ s16 ShortImage_0EV_Target;
+ u16 GhostPrevent_low;
+ u16 GhostPrevent_high;
+ u16 HDR_AE_weighting_table_ID;
+ u16 HDR_Compress_tone_ID;
+} CAPFLOWMGR_META_HDR; /* For MetaData */
+
+typedef struct {
+ u16 SHDTableW;
+ u16 SHDTableH;
+ u16 SHDNoWOIOutWidth;
+ u16 SHDNoWOIOutHeight;
+ u16 SHD_WOI_X;
+ u16 SHD_WOI_Y;
+ u16 SHD_WOI_Width;
+ u16 SHD_WOI_Height;
+} CAPFLOWMGR_SHADING_DEBUG_INFO; /* For Metadata, check if it will be used in SK1 */
+
+/**
+@struct CAPFLOWMGR_PROJECTOR_STATUS
+@brief Depth paramters
+*/
+typedef struct {
+ u8 TurnOn;
+ u8 Level;
+} CAPFLOWMGR_PROJECTOR_STATUS;
+
+typedef struct {
+ u16 XBase;
+ u16 YBase;
+ u16 XLength;
+ u16 YLength;
+} DEPTHPACKDATA_WOI_INFO;
+
+/**
+@struct CAPFLOWMGR_PROJECTOR_STATUS
+@brief Depth paramters
+*/
+typedef struct {
+ u8 TurnOn;
+} CAPFLOWMGR_GPIO_DEV;
+
+/**
+@struct CAPFLOWMGR_META_SWDEBUG
+@brief Depth paramters
+*/
+typedef struct {
+ u8 aucModuleByPass[12]; /* 12 */
+ u16 DepthInWidth; /* 2 */
+ u16 DepthInHeight; /* 2 */
+ CAPFLOWMGR_SHADING_DEBUG_INFO tPipeSHDInfo[2]; /* 32 */
+ DEPTHPACKDATA_WOI_INFO tPipeDepthCaliWOI[2]; /* 16 */
+ u64 SysTimeus; /* 8 */
+ CAPFLOWMGR_PROJECTOR_STATUS tProjectorStatus[8]; /* 16 */
+ CAPFLOWMGR_GPIO_DEV tGPIO_Device[2]; /* 2 */
+ u8 Resv1[6];
+ u64 IDD0_ISRTimeus;
+ u64 IDD1_ISRTimeus;
+ u8 aucResv2[16];
+} CAPFLOWMGR_META_SWDEBUG; /* For MetaData */
+
+/**
+@struct CAPFLOWMGR_DEPTH
+@brief Depth paramters
+*/
+typedef struct {
+ u16 OriginalWidth;
+ u16 OriginalHeight;
+ u16 WOIWidth; /* Sensor Crop */
+ u16 WOIHeight; /* Sensor Crop */
+ u16 WOI_X; /* Sensor Crop */
+ u16 WOI_Y; /* Sensor Crop */
+ u16 uw2ndWOIWidth; /* Internal Module Crop */
+ u16 uw2ndWOIHeight; /* Internal Module Crop */
+ u16 uw2ndWOI_X; /* Internal Module Crop */
+ u16 uw2ndWOI_Y; /* Internal Module Crop */
+ u16 OutputWidth;
+ u16 OutputHeight;
+ u16 Output_X;
+ u16 Output_Y;
+} CAPFLOWMGR_DEPTH_WOI_INFO;
+
+typedef struct {
+ u32 Qmerge_Ver;
+ u32 audTool_Ver[3];
+ u32 audTuning_Ver[3];
+ u8 aucVerifyDebug[2];
+ u16 uw2PD_Info;
+ u8 aucEngineEnable[8];
+ s16 awCCM[2][9];
+ u32 ExpRatio;
+ u32 audParaAddr[2][80];
+ u8 aucResv[32];
+} CAPFLOWMGR_META_IQDEBUG; /* For Metadata, check if it will be used in SK1 */
+
+/**
+@struct CAPFLOWMGR_METADATA
+@brief scenario paramters
+*/
+typedef struct {
+ CAPFLOWMGR_META_COMMON tCommonInfo;
+ CAPFLOWMGR_META_PIPE tPipe0Info;
+ CAPFLOWMGR_META_PIPE tPipe1Info;
+ CAPFLOWMGR_META_DEPTH tDpethInfo;
+ CAPFLOWMGR_META_HDR tHDRInfo;
+ u8 aucMetaData_reserved_0[12];
+ CAPFLOWMGR_META_SWDEBUG tSWDebugInfo;
+ CAPFLOWMGR_META_IQDEBUG tIQDebugInfo;
+ u8 aucMetaData_reserved_1[920];
+ u32 audHDRAEHistogram_Short[260];
+ u32 audHDRAEHistogram_Long[260];
+} CAPFLOWMGR_METADATA;
+
+typedef enum {
+ E_FEC_SENSOR_MODE_NORMAL,
+ E_FEC_SENSOR_MODE_MASTER,
+ E_FEC_SENSOR_MODE_SLAVE,
+ E_FEC_SENSOR_MODE_MAX
+} E_FEC_SENSOR_MODE;
+
+typedef struct {
+ u16 VTS; /* line_length_pck */
+ u16 HTS; /* frame_length_line */
+ u16 ImageWidth; /* image width */
+ u16 ImageHeight; /* image height */
+ u32 FrameTime; /* frame time (us) */
+ u32 FrameRate; /* frame rate (3003 = 30.03fps) */
+ u32 ExpTime; /* expousre time (us) */
+ u32 Gain; /* gain (150 = 1.5x) */
+ E_FEC_SENSOR_MODE SensorMode; /* see E_FEC_SENSOR_MODE */
+} FEC_SENSOR_REAL_INFO;
+
+typedef enum {
+ E_LED_PROJECTOR = 0,
+ E_LED_FLOOD,
+} E_LED_TYPE;
+
+
+typedef struct{
+ u8 Type; /* 0 for projector, 1 for flood */
+ u16 Level; /* current sw level (0~255) */
+ u16 Current; /* sw level mapping to current (mA) */
+ u16 MaxCurrent; /* support maximum current (mA) */
+ u16 ErrStatus; /* driver IC status (if support) */
+ u16 Temperature; /* error occurs, and record temperature from thermal sensor */
+ u32 errCode; /* errCode, see ProjectorCtrl_Err.h */
+} PROJECTOR_INFO;
+
+typedef struct {
+ char name[32];
+ u32 addr;
+ char mapping[32];
+} GPIO;
+
+
+/******Public Function Prototype******/
+extern void mini_isp_chip_base_define_module_reg_dump(
+ char *dest_path, char *module_name);
+
+extern errcode mini_isp_chip_base_dump_bypass_mode_register(char *dest_path);
+
+extern errcode mini_isp_chip_base_dump_normal_mode_register(char *dest_path);
+
+extern errcode mini_isp_chip_base_dump_irp_and_depth_based_register(void);
+#endif
diff --git a/drivers/media/platform/altek/include/miniisp_ctrl.h b/drivers/media/platform/altek/include/miniisp_ctrl.h
new file mode 100755
index 0000000..b2287da
--- /dev/null
+++ b/drivers/media/platform/altek/include/miniisp_ctrl.h
@@ -0,0 +1,441 @@
+/*
+ * File: miniisp_ctrl.h
+ * Description: The structure and API definition mini ISP Ctrl
+ * It is a header file that define structure and API for mini ISP Ctrl
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/10/14; Aaron Chuang; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _MINIISP_CTRL_H_
+#define _MINIISP_CTRL_H_
+
+/**
+ *@addtogroup MiniISPCtrl
+ *@{
+ */
+
+/******Include File******/
+
+#include "mtype.h"
+#include "isp_camera_cmd.h"
+#include "error.h"
+#include "moduleid_pj.h"
+
+/******Global define******/
+#define DEPTH_NONE 0x0 /*No depth*/
+#define DEPTH_BIT_RES_180 0x1 /*180p*/
+#define DEPTH_BIT_RES_360 0x2 /*360p*/
+#define DEPTH_BIT_RES_720 0x3 /*720p*/
+#define DEPTH_BIT_RES_480 0x4 /*480p*/
+
+#define DEPTH_BIT_DG_ONLY 0x00
+#define DEPTH_BIT_DP_SPARSE_1 0x10
+#define DEPTH_BIT_DP_SPARSE_2 0x20
+#define DEPTH_BIT_DP_SPARSE_3 0x30
+#define DEPTH_BIT_DP_DENSE 0x40
+#define DEPTH_BIT_MASK_TYPE 0x70
+#define DEPTH_BIT_RESV 0x80
+
+/******Public Function Prototype******/
+
+/**
+ *\brief Mini ISP open
+ *\param boot_code_file_name [In], Boot code filename
+ *\param basic_code_file_name [In], Basic code filename
+ *\param advanced_code_file_name [In], Advanced code filename
+ *\param scenario_table_file_name [In], Sc table filename
+ *\param hdr_qmerge_file_name [In], hdr qmerge filename
+ *\param irp0_qmerge_file_name [In], irp0 qmerge filename
+ *\param irp1_qmerge_file_name [In], irp1 qmerge filename
+ *\param pp_map_file_name [In], PP map filename
+ *\param depth_qmerge_file_name [In], depth qmerge filename
+ *\return Error code
+ *\image html BootSeq.jpg
+ */
+extern errcode mini_isp_drv_open(char *boot_code_file_name,
+ char *basic_code_file_name,
+ char *advanced_code_file_name,
+ char *scenario_table_file_name,
+ char *hdr_qmerge_file_name,
+ char *irp0_qmerge_file_name,
+ char *irp1_qmerge_file_name,
+ char *pp_map_file_name,
+ char *depth_qmerge_file_name
+ );
+
+/**
+ *\brief Mini ISP write boot code
+ *\param n/a
+ *\return Error code
+ */
+extern errcode mini_isp_drv_write_boot_code(void);
+
+/**
+ *\brief Mini ISP write boot code (short SPI Len)
+ *\param n/a
+ *\return Error code
+ */
+extern errcode mini_isp_drv_write_boot_code_shortlen(void);
+
+/**
+ *\brief Mini ISP write basic code
+ *\param n/a
+ *\return Error code
+ */
+extern errcode mini_isp_drv_write_basic_code(void);
+
+/**
+ *\brief Mini ISP write basic code (short SPI Len)
+ *\param n/a
+ *\return Error code
+ */
+extern errcode mini_isp_drv_write_basic_code_shortlen(void);
+
+/**
+ *\brief Mini ISP write spinor code
+ *\param info_id [In], 0 : boot data
+ * 1 : main data
+ *\return Error code
+ */
+extern errcode mini_isp_drv_write_spinor_data(u8 info_id);
+
+/**
+ *\brief Mini ISP Write Calibration Data 0x210B
+ *\param info_id [In], 0 : IQ data
+ * 1 : packet data
+ * 2 : scenario table
+ * 3 : hdr
+ * 4 : irp0
+ * 5 : irp1
+ * 6 : PP map
+ * 7 : blending table
+ * 8 : depth qmerge
+ * 9 : OTP data
+ *\param buf_addr [In], otp/packet data buffer start address
+ *\param buf_len [In], otp/packet data buffer len
+ *\return Error code
+ */
+extern errcode mini_isp_drv_write_calibration_data(u8 info_id,
+ u8 *buf_addr, u32 buf_len);
+
+
+/**
+ *\brief Set Sensor Mode 0x300A
+ *\param sensor_on_off [In],sensor on/off
+ *\param scenario_id[In], Scenario ID
+ *\param mipi_tx_skew_enable[In], mipi tx skew on(1)/off(0)
+ *\param ae_weighting_table_index[In]
+ *\param merge_mode_enable[In]
+ *\ bit[0:3] :
+ *\ set 0 for normal mode
+ *\ set 1 for merge mode, only for image samller than 640X480 case
+ *\ set 2 for depth test pattern mode
+ *\ bit[4] :
+ *\ set 0 for turn on sensor by AP.
+ *\ set 1 for turn on sensor by AL6100.
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_sensor_mode(u8 sensor_on_off,
+ u8 scenario_id,
+ u8 mipi_tx_skew_enable,
+ u8 ae_weighting_table_index,
+ u8 merge_mode_enable);
+
+/**
+ *\brief Set Output Format 0x300D
+ *\param depth_map_setting [In]
+ *\param depth_process_type[In] value 0x6 as reserve
+ *\param function on/off[In]
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_output_format(
+ struct isp_cmd_set_output_format *output_format);
+
+/**
+ *\brief Set CP Mode 0x300E
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_cp_mode(void);
+
+/**
+ *\brief Leave CP Mode
+ *\using set sensor mode opcode :0x300A
+ *\param sensor_on_off [In],sensor on/off
+ *\param scenario_id[In], Scenario ID
+ *\param mipi_tx_skew_enable[In], mipi tx skew on(1)/off(0)
+ *\param ae_weighting_table_index[In]
+ *\param merge_mode_enable[In]
+ *\return Error code
+ */
+extern errcode mini_isp_drv_leave_cp_mode(u8 sensor_on_off, u8 scenario_id,
+ u8 mipi_tx_skew_enable, u8 ae_weighting_table_index,
+ u8 merge_mode_enable);
+
+/**
+ *\brief Set AE statistics 0x300F
+ *\param gr_channel_weight [In],
+ *\param gb_channel_weight [In],
+ *\param r_channel_weight [In],
+ *\param b_channel_weight [In],
+ *\param shift_bits [In],
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_ae_statistics(
+ struct isp_cmd_ae_statistics *ae_statistics);
+
+/**
+ *\brief Preview stream on/off 0x3010
+ *\param tx0_stream_on_off [In], Tx0 stream on/off
+ *\param tx1_stream_on_off [In], Tx1 stream on/off
+ *\return Error code
+ */
+errcode mini_isp_drv_preview_stream_on_off(u8 tx0_stream_on_off,
+ u8 tx1_stream_on_off);
+
+/**
+ *\brief Dual PD Y Calcualtion Weighting 0x3011
+ *\param isp_cmd_dual_pd_y_calculation_weightings [In],
+ dual PD Y calculation weightings
+ *\return Error code
+ */
+errcode mini_isp_drv_dual_pd_y_calculation_weighting(
+ struct isp_cmd_dual_pd_y_calculation_weightings *calculation_weighting);
+
+/**
+ *\brief LED power control 0x3012
+ *\param projector_control_param,
+ *\return Error code
+ */
+errcode mini_isp_drv_led_power_control(
+ struct isp_cmd_led_power_control *projector_control_param);
+
+/**
+ *\brief Active AE 0x3013
+ *\param active_ae [In],
+ *\return Error code
+ */
+extern errcode mini_isp_drv_active_ae(
+ struct isp_cmd_active_ae *active_ae_param);
+
+/**
+ *\brief ISP AE control mode on off 0x3014
+ *\param isp_ae_control_mode_on_off [In], 0:off 1:on
+ *\return Error code
+ */
+extern errcode mini_isp_drv_isp_ae_control_mode_on_off(
+ u8 isp_ae_control_mode_on_off);
+
+/**
+ *\brief Set Frame Rate Limite 0x3015
+ *\param set_frame_rate_param [In],
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_frame_rate_limits(
+ struct isp_cmd_frame_rate_limits *set_frame_rate_param);
+
+extern errcode mini_isp_drv_get_sensor_mode(void);
+
+extern errcode mini_isp_drv_get_last_exec_cmd(void);
+
+extern errcode mini_isp_drv_get_err_code_cmd(void);
+
+extern errcode mini_isp_drv_get_err_code_cmd_in_irq(void);
+
+extern u16 mini_isp_drv_read_spi_status(void);
+
+
+/**
+ *\brief Set ISP register 0x0100
+ *\param reg_start_addr [In], Reg start addr
+ *\param reg_value [In], Reg value
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_isp_register(u32 reg_start_addr,
+ u32 reg_value);
+
+
+/**
+ *\brief Get ISP register
+ *\param reg_start_addr [In], Reg start addr
+ *\param reg_count [In], Reg count
+ *\return Error code
+ */
+extern errcode mini_isp_drv_get_isp_register(u32 reg_start_addr,
+ u32 reg_count);
+
+/**
+ *\brief Get Chip test Report 0x010A
+ *\return Error code
+ */
+extern errcode mini_isp_drv_get_chip_test_report(void);
+
+/**
+ *\brief Set Depth 3A Information 0x10B9
+ *\param depth_3a_info [In], Depth 3A parameter
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_depth_3a_info(
+ struct isp_cmd_depth_3a_info *depth_3a_info);
+
+/**
+ *\brief Set Depth auto interleave mode 0x10BC
+ *\param depth_auto_interleave_param [In], ISP Depth auto interleave parameter
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_depth_auto_interleave_mode(
+ struct isp_cmd_depth_auto_interleave_param
+ *depth_auto_interleave_param);
+
+/**
+ *\brief Set Projector Interleave Mode with Depth Type 0x10BD
+ *\param mini_isp_drv_projector_interleave_mode_depth_type [In],
+ *\ 0: depth active, 1: depth passive
+ *\return Error code
+ */
+extern errcode mini_isp_drv_projector_interleave_mode_depth_type(
+ u8 projector_interleave_mode_with_depth_type);
+
+/**
+ *\brief Set Depth Polish LEVEL 0x10BE
+ *\param depth_polish_level [In], 0~100
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_depth_polish_level(
+ u8 depth_polish_level);
+
+/**
+ *\brief Set Exposure Parameter 0x10BF
+ *\param exposure_param [In], ISP Exposure parameter
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_exposure_param(
+ struct isp_cmd_exposure_param *exposure_param);
+
+/**
+ *\brief Set depth stream size 0x10C0
+ *\param depth_stream_size [In], ISP depth stream size
+ *\return Error code
+ */
+extern errcode mini_isp_drv_set_depth_stream_size(
+ struct isp_cmd_depth_stream_size *depth_stream_size);
+
+/**
+ *\brief Reading Common Log
+ *\param stop [In], Stop to log flag
+ *\return Error code
+ */
+extern errcode mini_isp_drv_read_com_log(bool stop);
+
+/**
+ *\brief Read memory
+ *\param start_addr [In]starting address
+ *\param read_size [In]TotalReadSize
+ *\return Error code
+ */
+extern errcode mini_isp_drv_read_memory(u32 start_addr, u32 read_size);
+
+/**
+ *\brief Read Calibration Data
+ *\param info_param [In],
+ *\return Error code
+ */
+extern errcode mini_isp_drv_read_calibration_data(void);
+
+/**
+ *\brief Get Depth rect A, B, invrect parameter
+ *\param 0 : depth rect A, B InvRect parameter structure array buffer
+ *\param 1 : transfer mode. (Default set to 0)
+ *\param 2 : bluk block size
+ *\return Error code
+ */
+extern errcode mini_isp_drv_write_depth_rectab_invrect(
+ struct depth_rectab_invrect_param *rect_param,
+ u8 trans_mode,
+ u32 block_size);
+
+extern errcode mini_isp_drv_set_com_log_level(u32 log_level);
+
+/**
+ *\brief Master boot miniISP
+ *\param e [In], MINI_ISP_EVENT
+ *\return Errorcode
+ */
+extern int mini_isp_drv_wait_for_event(u16 e);
+
+extern errcode mini_isp_drv_setting(u16 mini_isp_mode);
+
+extern errcode mini_isp_drv_set_bypass_mode(u16 bypass_mode);
+
+extern errcode mini_isp_drv_set_max_exposure(
+ struct isp_cmd_exposure_param *max_exposure_info);
+
+extern errcode mini_isp_drv_set_target_mean(
+ struct isp_cmd_target_mean *target_mean_info);
+
+extern errcode mini_isp_drv_frame_sync_control(
+ struct isp_cmd_frame_sync_control *frame_sync_control_param);
+
+extern errcode mini_isp_drv_set_shot_mode(
+ struct isp_cmd_set_shot_mode *set_shot_mode_param);
+
+extern errcode mini_isp_drv_lighting_ctrl(
+ struct isp_cmd_lighting_ctrl *lighting_ctrl);
+
+extern errcode mini_isp_drv_depth_compensation(
+ struct isp_cmd_depth_compensation_param *depth_compensation_param);
+
+extern errcode mini_isp_drv_cycle_trigger_depth_process(
+ struct isp_cmd_cycle_trigger_depth_process *param);
+
+extern errcode mini_isp_drv_led_active_delay(u32 delay_ms);
+
+extern errcode mini_isp_drv_set_min_exposure(
+ struct isp_cmd_exposure_param *min_exposure_info);
+
+extern errcode mini_isp_drv_set_max_exposure_slope(
+ struct isp_cmd_max_exposure_slope *max_exposure_slope_info);
+
+extern errcode mini_isp_drv_isp_control_led_level(u8 on);
+
+extern errcode mini_isp_drv_get_chip_thermal(u16 *thermal_val);
+
+extern void mini_isp_drv_altek_i2c_mode_change(void);
+
+extern errcode mini_isp_drv_load_fw(void);
+
+extern void mini_isp_reset(void);
+
+
+/** \brief Master boot miniISP
+ *\param None
+ *\return None
+ */
+extern int mini_isp_drv_boot_mini_isp(void);
+
+/******End of File******/
+
+/**
+ *@}
+ */
+
+#endif /* _MINIISP_CTRL_H_*/
diff --git a/drivers/media/platform/altek/include/miniisp_ctrl_intf.h b/drivers/media/platform/altek/include/miniisp_ctrl_intf.h
new file mode 100755
index 0000000..d9532e0
--- /dev/null
+++ b/drivers/media/platform/altek/include/miniisp_ctrl_intf.h
@@ -0,0 +1,46 @@
+/*
+ * File: miniisp_ctrl_intf.h
+ * Description: mini ISP control cmd interface.
+ * use for handling the control cmds instead of debug cmds
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2018/08/28; PhenixChen; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _MINIISP_CTRL_INTF_H_
+#define _MINIISP_CTRL_INTF_H_
+
+#define P_F_INTERLEAVE
+
+extern int handle_ControlFlowCmd_II(u16 miniisp_op_code, u8 *param);
+extern long handle_ControlFlowCmd(unsigned int cmd, unsigned long arg);
+/*AL6100 Kernel Base Solution */
+enum miniisp_firmware {
+ ECHO_IQ_CODE,
+ ECHO_DEPTH_CODE,
+ ECHO_OTHER_MAX
+};
+
+extern long handle_ControlFlowCmd_Kernel(unsigned int cmd, unsigned long arg);
+extern void mini_isp_other_drv_open(char *file_name, u8 type);
+extern void mini_isp_other_drv_read(struct file *filp, u8 type);
+/*AL6100 Kernel Base Solution */
+#endif
diff --git a/drivers/media/platform/altek/include/miniisp_customer_define.h b/drivers/media/platform/altek/include/miniisp_customer_define.h
new file mode 100755
index 0000000..be37808
--- /dev/null
+++ b/drivers/media/platform/altek/include/miniisp_customer_define.h
@@ -0,0 +1,114 @@
+/*
+ * File: miniisp_customer_define.h
+ * Description: miniISP customer define
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _MINIISP_CUSTOMER_DEFINE_H_
+#define _MINIISP_CUSTOMER_DEFINE_H_
+
+#include <linux/spi/spi.h>
+/******Public Define******/
+
+/*SPI MODE*/
+#define SPI_MODE (SPI_MODE_3) /*SPI_MODE_3 | SPI_CS_HIGH*/
+
+/* SPI SPEED */
+/* SPI speed for generally using. */
+/* Note: QCOM605 need to configure beyond 32000000Hz*/
+/* ,otherwise it may happen SPI timeout*/
+#define SPI_BUS_SPEED 32000000
+#define SPI_BUS_SPEED_BOOT 2000000 /* SPI Speed before boot code ready phase */
+#define SPI_BUS_SPEED_LOW 3000000 /* For code persistence mode */
+
+/*boot file location*/
+#define BOOT_FILE_LOCATION "/data/firmware/miniBoot.bin"
+/*basic code location*/
+#define BASIC_FILE_LOCATION "/data/firmware/TBM_SK1.bin"
+/*advanced code location*/
+#define ADVANCED_FILE_LOCATION NULL
+/*scenario table location*/
+#define SCENARIO_TABLE_FILE_LOCATION "/data/firmware/SCTable.asb"
+
+/*hdr qmerge data location*/
+#define HDR_QMERGE_DATA_FILE_LOCATION "/data/firmware/HDR.bin"
+/*irp0 qmerge data location*/
+#define IRP0_QMERGE_DATA_FILE_LOCATION "/data/firmware/IRP0.bin"
+/*irp1 qmerge data location*/
+#define IRP1_QMERGE_DATA_FILE_LOCATION "/data/firmware/IRP1.bin"
+/*pp map location*/
+#define PP_MAP_FILE_LOCATION NULL/*"/system/etc/firmware/PPmap.bin"*/
+/*depth qmerge data location*/
+#define DPETH_QMERGE_DATA_FILE_LOCATION "/data/firmware/Depth.bin"
+
+/*iq calibaration data location*/
+#define IQCALIBRATIONDATA_FILE_LOCATION \
+ "/data/misc/camera_otp/IQCalibrationData_Decrypt.bin"
+ /*"/system/etc/firmware/PPmap.bin"*/
+/*depth pack data location*/
+#define DEPTHPACKDATA_FILE_LOCATION \
+ "/data/misc/camera_otp/DepthPackData_Decrypt.bin"
+ /*"/system/etc/firmware/PPmap.bin"*/
+
+/*miniISP dump info save location*/
+/*Add location folder where you let Altek debug info saving in your device*/
+#define MINIISP_INFO_DUMPLOCATION "/data/local/tmp/"
+
+/*miniISP bypass setting file location*/
+/*Add location folder where you let Altek debug info saving in your device*/
+#define MINIISP_BYPASS_SETTING_FILE_PATH "/data/firmware/"
+
+/*define for gpio*/
+/*vcc1 : if no use, set NULL*/
+#define VCC1_GPIO NULL /*"vcc1-gpios"*/
+
+/*vcc2 : if no use, set NULL*/
+#define VCC2_GPIO NULL/*"vcc2-gpios"*/
+
+/*vcc3 : if no use, set NULL*/
+#define VCC3_GPIO NULL/*"vcc3-gpios"*/
+
+/*reset*/
+#define RESET_GPIO NULL /*"reset-gpios"*/
+
+/*irq*/
+#define IRQ_GPIO "irq-gpios"
+
+/*wp*/
+#define WP_GPIO NULL /*"wp-gpios"*/
+
+/*isp_clk : if no use, set NULL*/
+#define ISP_CLK NULL /*"al6100_clk"*/
+
+/*Enable SPI short length mode*/
+#define SPI_SHORT_LEN_MODE (false)
+#define SPI_BLOCK_LEN (14)
+#define SPI_SHORT_LEN_MODE_WRITE_ENABLE (false)
+#define SPI_SHORT_LEN_MODE_READ_ENABLE (true)
+
+#define INTERRUPT_METHOD 0
+#define POLLING_METHOD 1
+/* choose INT or polling mechanism to get AL6100 status */
+#define ISR_MECHANISM INTERRUPT_METHOD
+
+#define EN_605_IOCTRL_INTF 1
+/******Public Function Prototype******/
+#endif
diff --git a/drivers/media/platform/altek/include/miniisp_debug_if.h b/drivers/media/platform/altek/include/miniisp_debug_if.h
new file mode 100755
index 0000000..1cf1af5
--- /dev/null
+++ b/drivers/media/platform/altek/include/miniisp_debug_if.h
@@ -0,0 +1,68 @@
+/*
+ * File: miniisp_debug_if.h
+ * Description: mini ISP debug daemon interface
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2017/04/20; PhenixChen; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _ISPDBG_IOCTL_H
+#define _ISPDBG_IOCTL_H
+
+#include <asm-generic/ioctl.h> /*_IOW(), _IOR()*/
+#include <linux/types.h>
+
+struct ioctl_regRW_cmd {
+ u32 RegAddr;
+ u32 RegVal;
+};
+
+struct ioctl_regBulkRW_cmd {
+ u32 StartAddr;
+ u32 EndAddr;
+};
+
+struct ioctl_memRW_cmd {
+ u32 MemAddr;
+ u32 len;
+};
+
+#define IOC_REGCMD_MAGIC 'R'
+#define IOC_MEMCMD_MAGIC 'M'
+#define IOC_BULKCMD_MAGIC 'B'
+#define IOC_INFOCMD_MAGIC 'I'
+#define IOC_PREPARECMD_MAGIC 'P'
+
+/*------------------ _IOX(TYPE 8bits, nr 8bits, size 14bits) */
+#define IOCTL_REGREAD _IOR(IOC_REGCMD_MAGIC, 1, struct ioctl_regRW_cmd)
+#define IOCTL_REGWRITE _IOW(IOC_REGCMD_MAGIC, 2, struct ioctl_regRW_cmd)
+#define IOCTL_REGBULKREAD _IOR(IOC_BULKCMD_MAGIC, 3, struct ioctl_regBulkRW_cmd)
+#define IOCTL_REGBULKWRITE _IOR(IOC_BULKCMD_MAGIC, 4,\
+ struct ioctl_regBulkRW_cmd)
+#define IOCTL_MEMREAD _IOR(IOC_MEMCMD_MAGIC, 5, struct ioctl_memRW_cmd)
+#define IOCTL_MEMWRITE _IOW(IOC_MEMCMD_MAGIC, 6, struct ioctl_memRW_cmd)
+#define IOCTL_MUNMAP_DONE _IOW(IOC_MEMCMD_MAGIC, 7, struct ioctl_memRW_cmd)
+#define IOCTL_MEMGET _IOW(IOC_MEMCMD_MAGIC, 8, struct ioctl_memRW_cmd)
+#define IOCTL_IRP_DEPTH_INFO _IOR(IOC_INFOCMD_MAGIC, 9,\
+ struct irp_and_depth_information)
+#define IOCTL_REFRESH_MODULE _IOR(IOC_PREPARECMD_MAGIC, 10, u8)
+
+#endif
diff --git a/drivers/media/platform/altek/include/moduleid.h b/drivers/media/platform/altek/include/moduleid.h
new file mode 100755
index 0000000..0e92ea6
--- /dev/null
+++ b/drivers/media/platform/altek/include/moduleid.h
@@ -0,0 +1,71 @@
+/*
+ * File: moduleid.h
+ * Description: Define module id
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+/**
+ *@file moduleid.h
+ *@author Gene Hung
+ *@version 2005/08/22; Gene; Add Doxygen remark
+ *@defgroup ModuleID Module ID definition
+ *@brief TBirdOS 2.0 and later module ID definition.
+ *code number definition:
+ *Bits 31~20: Module id
+ *Bits 19~12: Reserved
+ *Bits 11~0: Code defined in each module
+ */
+
+#ifndef _MODULEID_H_
+#define _MODULEID_H_
+
+/**
+ *@ingroup ModuleID
+ *@{
+ */
+
+/**
+ *@def MODULEID_SHIFTBITS
+ *@brief Module ID MARCO definition
+ */
+#define MODULEID_SHIFTBITS 20
+/**
+ *@def MODULEID_ModuleID
+ *@brief Get ID number from a CODE
+ */
+#define MODULEID_ModuleID(code) (code >> MODULEID_SHIFTBITS)
+/**
+ *@def MODULEID_ModuleBase
+ *@brief Get CODE BASE from a module ID
+ */
+#define MODULEID_ModuleBase(id) (id << MODULEID_SHIFTBITS)
+
+/* Project-dependent module starts from this ID*/
+#define MODULEID_PROJECT 0x400
+
+
+/* Let Project use MODULEID_PROJECT to extend. */
+/*Don't define module ID 0x401 0x402... here.*/
+
+/**
+ *@}
+ */
+#endif /*_MODULEID_H_*/
diff --git a/drivers/media/platform/altek/include/moduleid_pj.h b/drivers/media/platform/altek/include/moduleid_pj.h
new file mode 100755
index 0000000..d820e24
--- /dev/null
+++ b/drivers/media/platform/altek/include/moduleid_pj.h
@@ -0,0 +1,39 @@
+/*
+ * File: Moduleid_PJ.h
+ * Description: Define module id in project
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _MODULEID_PJ_H_
+#define _MODULEID_PJ_H_
+
+#include "moduleid.h"
+
+/* Project-dependent module starts from MODULEID_PROJECT (0x400)*/
+#define MODULEID_PJ_MINIISP_STATE (MODULEID_PROJECT + 0x2C)
+#define MODULEID_PJ_ISPCTRLIF_SLAVE (MODULEID_PROJECT + 0x2D)
+#define MODULEID_PJ_ISPCTRLIF_MASTER (MODULEID_PROJECT + 0x2E)
+#define MODULEID_PJ_MINIISP (MODULEID_PROJECT + 0x2F)
+#endif
+
+
+
+
diff --git a/drivers/media/platform/altek/include/mtype.h b/drivers/media/platform/altek/include/mtype.h
new file mode 100755
index 0000000..db31741
--- /dev/null
+++ b/drivers/media/platform/altek/include/mtype.h
@@ -0,0 +1,38 @@
+/*
+ * File: mtype.h
+ * Description: Global type definition
+ * Please don't add new definition arbitrarily
+ * Only system-member is allowed to modify this file
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+#ifndef _MTYPE_H_
+#define _MTYPE_H_
+
+#include <linux/types.h>
+#include <linux/stddef.h>
+
+typedef u32 errcode;
+
+/* Other definition*/
+/*#define _Uncached volatile __attribute__ ((section(".ucdata")))*/
+
+#endif
diff --git a/drivers/media/platform/altek/ispctrl_if_master.c b/drivers/media/platform/altek/ispctrl_if_master.c
new file mode 100644
index 0000000..7823cf1
--- /dev/null
+++ b/drivers/media/platform/altek/ispctrl_if_master.c
@@ -0,0 +1,1113 @@
+/*
+ * File: ispctrl_if_master.c
+ * Description: ISP Ctrl IF Master
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/10/14; Aaron Chuang; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/******Include File******/
+/* Linux headers*/
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <linux/delay.h>
+
+#include "include/miniisp.h"
+#include "include/ispctrl_if_master.h"
+#include "include/isp_camera_cmd.h"
+#include "include/error/ispctrl_if_master_err.h"
+#include "include/ispctrl_if_master_local.h"
+#include "include/miniisp_ctrl.h"
+#include "include/miniisp_chip_base_define.h"
+
+
+/*extern struct misp_data *misp_drv_data;*/
+
+/******Private Constant Definition******/
+#define MASTERTX_BLOCK_SIZE SPI_TX_BULK_SIZE
+#define MINI_ISP_LOG_TAG "[_mini_ispctrl_if_master]"
+
+
+/******Private Type Definition******/
+struct file *g_filp[FIRMWARE_MAX];
+struct spi_device *spictrl;
+/******Private Function Prototype******/
+
+
+static errcode execute_system_manage_cmd(void *devdata, u16 opcode,
+ u8 *param);
+static errcode execute_basic_setting_cmd(void *devdata, u16 opcode,
+ u8 *param);
+static errcode execute_bulk_data_cmd(void *devdata, u16 opcode,
+ u8 *param);
+static errcode execute_camera_profile_cmd(void *devdata, u16 opcode,
+ u8 *param);
+static errcode execute_operation_cmd(void *devdata, u16 opcode,
+ char *param);
+static u16 isp_mast_calculate_check_sum(u8 *input_buffer_addr,
+ u16 input_buffer_size, bool b2sCom);
+
+/******Private Global Variable******/
+
+
+/******Private Global Variable******/
+
+
+
+
+/******Public Function******/
+
+/*
+ *\brief Execute SPI master command
+ *\param opcode [In], Op code
+ *\param param [In], CMD param buffer
+ *\return Error code
+ */
+errcode ispctrl_if_mast_execute_cmd(u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ struct misp_global_variable *devdata_global_variable;
+ void *devdata;
+
+ misp_info("%s opcode: %#04x >>>",
+ __func__, opcode);
+
+ devdata_global_variable = get_mini_isp_global_variable();
+ devdata = (void *)get_mini_isp_intf(MINIISP_I2C_TOP);
+
+ if (!devdata)
+ return -ENODEV;
+
+ if (!devdata_global_variable->en_cmd_send && opcode != 0x210B) {
+ misp_info("%s, disable cmd send!", __func__);
+ return err;
+ }
+
+
+ mutex_lock(&devdata_global_variable->busy_lock);
+
+ /* System Management 0x0000~0x0FFF*/
+ if (opcode <= 0x0FFF)
+ err = execute_system_manage_cmd(devdata, opcode, param);
+ /* Basic Setting 0x1000~0x1FFF*/
+ else if (opcode <= 0x1FFF)
+ err = execute_basic_setting_cmd(devdata, opcode, param);
+ /* Bulk Data 0x2000~0x2FFF*/
+ else if (opcode <= 0x2FFF)
+ err = execute_bulk_data_cmd(devdata, opcode, param);
+ /* Camera Profile 0x3000~0x3FFF*/
+ else if (opcode <= 0x3FFF)
+ err = execute_camera_profile_cmd(devdata, opcode, param);
+ /*Operation 0x4000~0x4FFF*/
+ else if (opcode <= 0x4FFF)
+ err = execute_operation_cmd(devdata, opcode, param);
+ else
+ err = ERR_MASTER_OPCODE_UNSUPPORT;
+
+ /* delay 2ms */
+ msleep(20);
+
+ mutex_unlock(&devdata_global_variable->busy_lock);
+
+ misp_info("%s opcode: %#04x <<<",
+ __func__, opcode);
+
+ return err;
+}
+EXPORT_SYMBOL(ispctrl_if_mast_execute_cmd);
+
+/*
+ *\brief Send command to slave
+ *\param devdata [In], misp_data
+ *\param opcode [In], Op code
+ *\param param [In], CMD param buffer
+ *\param len [In], CMD param size
+ *\return Error code
+ */
+errcode ispctrl_mast_send_cmd_to_slave(void *devdata,
+ u16 opcode, u8 *param, u32 len)
+{
+ u16 *send_len, *send_opcode, total_len;
+ errcode err = ERR_SUCCESS;
+ u16 chksum;
+ u8 *tx_buf;
+ struct misp_global_variable *devdata_global_variable;
+
+ devdata_global_variable = get_mini_isp_global_variable();
+ tx_buf = ((struct misp_data *)devdata)->tx_buf;
+
+ memset(tx_buf, 0, TX_BUF_SIZE);
+
+ send_len = (u16 *)&tx_buf[0];
+ send_opcode = (u16 *)&tx_buf[ISPCMD_LENFLDBYTES];
+
+ /*[2-byte len field] + [2-byte opcode field] + (params len)*/
+ total_len = ISPCMD_CMDSIZE + len;
+ /* totoal - 2-byte length field*/
+ *send_len = total_len - ISPCMD_LENFLDBYTES;
+
+ *send_opcode = opcode;
+ if (len > 0)
+ memcpy(&tx_buf[ISPCMD_CMDSIZE], param, len);
+
+ /*calculate checksum*/
+ chksum = isp_mast_calculate_check_sum(tx_buf, total_len, true);
+ memcpy(&tx_buf[total_len], &chksum, ISPCMD_CKSUMBYTES);
+
+ /*add bytes for checksum*/
+ total_len += ISPCMD_CKSUMBYTES;
+
+ /**
+ * tx_buf:
+ * |--len_field(2)--|
+ * |--opcode(2)--|--param(len)--|
+ * |--cksum(2)--|
+ * len_field size: ISPCMD_LENFLDBYTES (2 bytes)
+ * opcode size: ISPCMD_OPCODEBYTES (2 bytes)
+ * param size: (len bytes)
+ * ISP_CMD_HDR_SIZE = ISPCMD_LENFLDBYTES + ISPCMD_OPCODEBYTES (4 bytes)
+ *
+ * total_len: (len_field_size + opcode_size + param_size + cksum_size)
+ * len(param_len) = (opcode_size + param_size), excluding cksum
+ */
+
+ /* Send command to slave*/
+ err = ((struct misp_data *)devdata)->intf_fn->send(devdata, total_len);
+
+
+ return err;
+}
+
+/*
+ *\brief Receive response from slave
+ *\param devdata [In], misp_data
+ *\param param [Out], Respons e buffer
+ *\param len [Out], Response size
+ *\return Error code
+ */
+errcode ispctrl_mast_recv_response_from_slave(void *devdata,
+ u8 *param, u32 len, bool wait_int)
+{
+ errcode err = ERR_SUCCESS;
+ u32 total_len;
+ u16 org_chk_sum;
+ u8 *rx_buf;
+ struct misp_global_variable *devdata_global_variable;
+
+ devdata_global_variable = get_mini_isp_global_variable();
+ rx_buf = ((struct misp_data *)devdata)->rx_buf;
+
+ memset(rx_buf, 0, RX_BUF_SIZE);
+ total_len = len + ISPCMD_CMDSIZEWDUMMY + ISPCMD_CKSUMBYTES;
+
+ /*Receive command from slave*/
+ err = ((struct misp_data *)devdata)->intf_fn->
+ recv(devdata, total_len, wait_int);
+ if (err != ERR_SUCCESS)
+ goto ispctrl_mast_recv_response_from_slave_end;
+
+
+ /*checksum*/
+ memcpy(&org_chk_sum, &rx_buf[(total_len - ISPCMD_CKSUMBYTES)],
+ ISPCMD_CKSUMBYTES);
+ if (org_chk_sum != isp_mast_calculate_check_sum(rx_buf,
+ (total_len - ISPCMD_CKSUMBYTES), true)) {
+ misp_err("%s - checksum error", __func__);
+ err = ERR_MASTERCMDCKSM_INVALID;
+ goto ispctrl_mast_recv_response_from_slave_end;
+ }
+
+
+ /* Copy param data*/
+ memcpy(param, &rx_buf[ISPCMD_CMDSIZEWDUMMY], len);
+
+ispctrl_mast_recv_response_from_slave_end:
+
+ return err;
+
+}
+
+/*
+ *\brief Receive Memory data from slave
+ *\param devdata [In], misp_data
+ *\param response_buf [Out], Response buffer
+ *\param response_size [Out], Response size
+ *\param wait_int [In], waiting INT flag
+ *\return Error code
+ */
+errcode ispctrl_if_mast_recv_memory_data_from_slave(
+ void *devdata,
+ u8 *response_buf,
+ u32 *response_size,
+ u32 block_size,
+ bool wait_int)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 expect_size;
+ u32 altek_event_state;
+ u16 i;
+
+ expect_size = *response_size;
+
+ misp_info("%s - Start.", __func__);
+
+ if (wait_int) {
+ err = mini_isp_wait_for_event(MINI_ISP_RCV_CMD_READY);
+ if (err) {
+ misp_err("%s - irq error: status=%d",
+ __func__, err);
+ goto ispctrl_if_mast_recv_memory_data_from_slave_end;
+ }
+ } else {
+ for (i = 0; i < 200; i++) {
+ err = mini_isp_get_altek_status(devdata,
+ &altek_event_state);
+ if (altek_event_state & COMMAND_COMPLETE) {
+ altek_event_state = (altek_event_state &
+ ~((~0) << 1));
+ break;
+ }
+ /* delay 5ms */
+ msleep(20);
+ }
+ if (i >= 200) {
+ misp_err("%s time out.", __func__);
+ err = ERR_MASTER_EVENT_TIMEOUT;
+ goto ispctrl_if_mast_recv_memory_data_from_slave_end;
+ }
+
+ }
+
+ err = mini_isp_get_bulk((struct misp_data *)devdata,
+ response_buf, expect_size, block_size);
+
+ispctrl_if_mast_recv_memory_data_from_slave_end:
+
+ return err;
+}
+
+#if ENABLE_LINUX_FW_LOADER
+/*
+ * \brief Master send bulk (large data) to slave
+ * \param devdata [In], misp_data
+ * \param buffer [In], Data buffer to be sent, address 8-byte alignment
+ * \param filp [In], file pointer, used to read the file and send the data
+ * \param total_size [In], file size
+ * \param block_size [In], transfer buffer block size
+ * \param is_raw [In], true: mini boot code false: other files
+ * \return Error code
+ */
+errcode ispctrl_if_mast_send_bulk(void *devdata, const u8 *buffer,
+ u32 total_size, u32 block_size, bool is_raw)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+
+ if (buffer == NULL)
+ return -ENOENT;
+
+ misp_info("ispctrl_if_master_send_bulk Start ============");
+ /* Transfer basic code*/
+ err = ((struct misp_data *)devdata)->intf_fn->send_bulk(devdata,
+ total_size, block_size, is_raw, buffer);
+
+ if (err != ERR_SUCCESS)
+ misp_err("ispctrl_if_master_send_bulk failed!!");
+
+ misp_info("ispctrl_if_master_send_bulk End ============");
+ return err;
+
+}
+
+#else
+/*
+ * \brief Master send bulk (large data) to slave
+ * \param devdata [In], misp_data
+ * \param buffer [In], Data buffer to be sent, address 8-byte alignment
+ * \param filp [In], file pointer, used to read the file and send the data
+ * \param total_size [In], file size
+ * \param block_size [In], transfer buffer block size
+ * \param is_raw [In], true: mini boot code false: other files
+ * \return Error code
+ */
+errcode ispctrl_if_mast_send_bulk(void *devdata, u8 *buffer,
+ struct file *filp, u32 total_size, u32 block_size, bool is_raw)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+
+
+ if ((!filp) && (buffer == NULL))
+ return -ENOENT;
+
+ misp_info("ispctrl_if_master_send_bulk Start ============");
+ /* Transfer basic code*/
+ err = ((struct misp_data *)devdata)->intf_fn->send_bulk(devdata,
+ filp, total_size, block_size, is_raw, buffer);
+
+ if (err != ERR_SUCCESS)
+ misp_err("ispctrl_if_master_send_bulk failed!!");
+ misp_info("ispctrl_if_master_send_bulk End ============");
+
+
+ /*close the file*/
+ if (filp && (buffer == NULL))
+ filp_close(filp, NULL);
+ return err;
+
+}
+#endif
+
+
+/* open boot / basic / advanced / sc table file*/
+errcode ispctrl_if_mast_request_firmware(u8 *filepath, u8 firmwaretype)
+{
+ errcode err = ERR_SUCCESS;
+
+ misp_info("%s filepath : %s", __func__, filepath);
+#if ENABLE_FILP_OPEN_API
+ /* use file open */
+#else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ return err;
+#endif
+ if (IS_ERR(g_filp[firmwaretype])) {
+ err = PTR_ERR(g_filp[firmwaretype]);
+ misp_err("%s open file failed. err: %x", __func__, err);
+ } else {
+ misp_info("%s open file success!", __func__);
+ }
+
+ return err;
+}
+
+
+/* current no use
+u16 ispctrl_if_mast_read_spi_status(void)
+{
+ return mini_isp_get_status();
+}
+*/
+
+/*
+ *\brief Receive ISP register response from slave
+ *\param devdata [In], misp_data
+ *\param response_buf [Out], Response buffer
+ *\param response_size [Out], Response size
+ *\param total_count [In], Total reg count
+ *\return Error code
+ */
+errcode ispctrl_if_mast_recv_isp_register_response_from_slave(
+ void *devdata, u8 *response_buf,
+ u32 *response_size, u32 total_count)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 total_len;
+ u16 org_chk_sum;
+
+ /* Last packet flag*/
+ bool last_packet = false;
+ /* Get Reg count*/
+ u8 reg_count = 0;
+ /* Total count*/
+ u32 use_total_count = total_count;
+ /* Total return size*/
+ u32 total_ret_size = 0;
+ /* Max count*/
+ u8 max_reg_count = 12;
+ /* Checksum*/
+ u16 check_sum = 0;
+ bool wait_int = true;
+ u8 *rx_buf;
+ struct misp_global_variable *devdata_global_variable;
+
+ devdata_global_variable = get_mini_isp_global_variable();
+ rx_buf = ((struct misp_data *)devdata)->rx_buf;
+
+ /* Update expect size*/
+ total_len = ISPCMD_CMDSIZEWDUMMY + ISP_REGISTER_PARA_SIZE;
+
+ /* Multi SPI Tx transfer*/
+ /*if One SPI Rx recv*/
+ while (last_packet == false) {
+ /* One SPI Rx recv*/
+ if (use_total_count <= max_reg_count) {
+ /* Set reg count*/
+ reg_count = use_total_count;
+ /* Set last packet*/
+ last_packet = true;
+ } else {
+ /*Multi SPI Rx recv*/
+ reg_count = max_reg_count;
+ }
+ /* Update expect size*/
+ total_len += reg_count*ISP_REGISTER_VALUE;
+
+ /* Add bytes for checksum*/
+ if (last_packet == true)
+ total_len += ISPCMD_CKSUMBYTES;
+
+
+ /* Receive command from slave*/
+ err = ((struct misp_data *)devdata)->intf_fn->recv(
+ devdata, total_len, wait_int);
+ if (err != ERR_SUCCESS)
+ break;
+
+ /* Last packet*/
+ if (last_packet == true) {
+ /* Get checksum*/
+ memcpy(&org_chk_sum,
+ &rx_buf[(total_len - ISPCMD_CKSUMBYTES)],
+ ISPCMD_CKSUMBYTES);
+
+ /* Count checksum*/
+ check_sum += isp_mast_calculate_check_sum(
+ &rx_buf[total_ret_size],
+ total_len - ISPCMD_CKSUMBYTES, false);
+ /* Do 2's complement*/
+ check_sum = 65536 - check_sum;
+
+ /* Checksum error*/
+ if (org_chk_sum != check_sum) {
+ /* Set error code*/
+ err = ERR_MASTERCMDCKSM_INVALID;
+ break;
+ }
+ } else {
+ /* Normal packet*/
+ /* checksum is valid or not*/
+ check_sum += isp_mast_calculate_check_sum(
+ &rx_buf[total_ret_size], total_len,
+ false);
+ }
+
+ /* Update total count*/
+ use_total_count -= reg_count;
+ /* Update total ret size*/
+ total_ret_size += total_len;
+
+ /* Reset expect size*/
+ total_len = 0;
+ /* Update max reg count*/
+ max_reg_count = 16;
+
+ }
+
+
+ #ifdef OUTPUT_ISP_REGISTER
+ /*write out the buffer to .arw file here*/
+ #endif
+
+
+ return err;
+
+}
+
+/******Private Function******/
+
+
+/**
+ *\brief Execute system manage command
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+static errcode execute_system_manage_cmd(void *devdata, u16 opcode,
+ u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+
+ /* Get status of Last Executed Command*/
+ if (opcode == ISPCMD_SYSTEM_GET_STATUSOFLASTEXECUTEDCOMMAND)
+ err = mast_sys_manage_cmd_get_status_of_last_exec_command(
+ devdata, opcode, param);
+ else if (opcode == ISPCMD_SYSTEM_GET_ERRORCODE)
+ err = mast_sys_manage_cmd_get_error_code_command(devdata,
+ opcode, param);
+ /* Set ISP register*/
+ else if (opcode == ISPCMD_SYSTEM_SET_ISPREGISTER)
+ err = mast_sys_manage_cmd_set_isp_register(devdata,
+ opcode, param);
+ /* Get ISP register*/
+ else if (opcode == ISPCMD_SYSTEM_GET_ISPREGISTER)
+ err = mast_sys_manage_cmd_get_isp_register(devdata,
+ opcode, param);
+ /* Set common log level*/
+ else if (opcode == ISPCMD_SYSTEM_SET_COMLOGLEVEL)
+ err = mast_sys_manage_cmd_set_comomn_log_level(devdata,
+ opcode, param);
+ /*Get chip test report*/
+ else if (opcode == ISPCMD_SYSTEM_GET_CHIPTESTREPORT)
+ err = mast_sys_manage_cmd_get_chip_test_report(devdata,
+ opcode, param);
+ /*Get chip thermal*/
+ else if (opcode == ISPCMD_SYSTEM_GET_CHIP_THERMAL)
+ err = mast_sys_manage_cmd_get_chip_thermal(devdata,
+ opcode, param);
+ return err;
+
+}
+
+/**
+ *\brief Execute basic setting command
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+static errcode execute_basic_setting_cmd(void *devdata, u16 opcode,
+ u8 *param)
+{
+ /*Error Code*/
+ errcode err = ERR_SUCCESS;
+
+
+ /* Set Depth 3A info*/
+ if (opcode == ISPCMD_BASIC_SET_DEPTH_3A_INFO)
+ err = mast_basic_setting_cmd_set_depth_3a_info(devdata,
+ opcode, param);
+ /* Set Depth Auto interleave mode*/
+ else if (opcode == ISPCMD_BASIC_SET_DEPTH_AUTO_INTERLEAVE_MODE)
+ err = mast_basic_setting_cmd_set_depth_auto_interleave_mode(
+ devdata, opcode, param);
+ /* Set Depth Auto interleave mode*/
+ else if (opcode == ISPCMD_BASIC_SET_INTERLEAVE_MODE_DEPTH_TYPE)
+ err = mast_basic_setting_cmd_set_interleave_mode_depth_type(
+ devdata, opcode, param);
+ /* Set Depth polish level*/
+ else if (opcode == ISPCMD_BASIC_SET_DEPTH_POLISH_LEVEL)
+ err = mast_basic_setting_cmd_set_depth_polish_level(
+ devdata, opcode, param);
+ /* Set exposure param*/
+ else if (opcode == ISPCMD_BASIC_SET_EXPOSURE_PARAM)
+ err = mast_basic_setting_cmd_set_exposure_param(
+ devdata, opcode, param);
+ /* Set exposure param*/
+ else if (opcode == ISPCMD_BASIC_SET_DEPTH_STREAM_SIZE)
+ err = mast_basic_setting_cmd_set_depth_stream_size(
+ devdata, opcode, param);
+
+ return err;
+
+}
+#if ENABLE_LINUX_FW_LOADER
+/**
+ *\brief Execute bulk data command
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+static errcode execute_bulk_data_cmd(void *devdata,
+ u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 *block_size;
+ char filename[ISPCMD_FILENAME_SIZE];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ memcpy(filename, param, ISPCMD_FILENAME_SIZE);
+
+
+ misp_info("%s Start", __func__);
+
+ /*set the size*/
+ block_size = (u32 *)¶m[8];
+
+ if (opcode == ISPCMD_BULK_WRITE_BOOTCODE) {
+ /* Write Boot Code*/
+ misp_info("%s : write BOOT_CODE", __func__);
+
+ dev_global_variable->before_booting = 1;
+ *block_size = MASTERTX_BLOCK_SIZE;
+
+#ifndef AL6100_SPI_NOR
+ err = mast_bulk_data_cmd_write_boot_code(devdata, param);
+#endif
+ dev_global_variable->before_booting = 0;
+ } else if (opcode == ISPCMD_BULK_WRITE_BOOTCODE_SHORT_LEN) {
+ /* Write Boot Code (short SPI len)*/
+ misp_info("%s : write BOOT_CODE", __func__);
+ dev_global_variable->before_booting = 1;
+ *block_size = MASTERTX_BLOCK_SIZE;
+#ifndef AL6100_SPI_NOR
+ err = mast_bulk_data_cmd_write_boot_code_shortlen(
+ devdata, param);
+#endif
+ dev_global_variable->before_booting = 0;
+ } else if (opcode == ISPCMD_BULK_WRITE_BASICCODE) {
+ /* Write Basic Code*/
+ misp_info("%s : write BASIC_CODE", __func__);
+
+#ifndef AL6100_SPI_NOR
+ err = mast_bulk_data_cmd_write_basic_code(
+ devdata, param);
+#endif
+ } else if (opcode == ISPCMD_BULK_WRITE_BASICCODE_CODESUM) {
+ /* Write Basic Code (short SPI len)*/
+ misp_info("%s : write BASIC_CODE", __func__);
+#ifndef AL6100_SPI_NOR
+ err = mast_bulk_data_cmd_write_basic_code_shortlen(
+ devdata, param);
+#endif
+
+ } else if (opcode == ISPCMD_BULK_WRITE_CALIBRATION_DATA) {
+ /*Write Calibration Data*/
+ if (param[8] == 0) {
+ misp_info("%s : write IQ_CALIBRATION_DATA", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param);
+ } else if (param[8] == 1) {
+ misp_info("%s : write DEPTH_CALIBRATION_DATA",
+ __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param);
+ } else if (param[8] == 2) {
+ misp_info("%s : write SCENARIO_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param);
+ } else if (param[8] == 3) {
+ misp_info("%s : write HDR_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param);
+ } else if (param[8] == 4) {
+ misp_info("%s : write IRP0_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param);
+ } else if (param[8] == 5) {
+ misp_info("%s : write IRP1_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param);
+ } else if (param[8] == 6) {
+ misp_info("%s : write PPMAP_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param);
+ } else if (param[8] == 7) {
+ misp_info("%s : write BLENDING_TABLE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param);
+ } else if (param[8] == 8) {
+ misp_info("%s : write DEPTH_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param);
+ } else if (param[8] == 9) {
+ misp_info("%s : write OTP DATA", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param);
+ }
+ }
+ /* Read Calibration Data*/
+ else if (opcode == ISPCMD_BULK_READ_CALIBRATION_DATA)
+ err = mast_bulk_data_cmd_read_calibration_data(devdata, param);
+
+ /* Read memory Data*/
+ else if (opcode == ISPCMD_BULK_READ_MEMORY)
+ err = mast_bulk_data_cmd_read_memory_data(devdata, param);
+ /* Read Common Log Data*/
+ else if (opcode == ISPCMD_BULK_READ_COMLOG)
+ err = bulk_data_cmd_read_common_log(devdata, param);
+ /* Read Depth RectA, B, Invrect*/
+ else if (opcode == ISPCMD_BULK_WRITE_DEPTH_RECTAB_INVRECT) {
+ err = mast_bulk_data_cmd_write_depth_rectab_invrect(
+ devdata, opcode, param);
+ } else if (opcode == ISPCMD_BULK_WRITE_SPINOR_DATA) {
+ /*Write SPINOR Data*/
+ if (param[8] == 0) {
+ misp_info("%s : write SPINOR BOOT DATA ", __func__);
+ err = mast_bulk_data_cmd_write_spinor_data(
+ devdata, param);
+ } else if (param[8] == 1) {
+ misp_info("%s : write SPINOR MAIN DATA", __func__);
+ err = mast_bulk_data_cmd_write_spinor_data(
+ devdata, param);
+ }
+ }
+ misp_info("execute_bulk_data_cmd - end Errcode: %d ======",
+ (int)err);
+
+ return err;
+
+}
+
+#else
+/**
+ *\brief Execute bulk data command
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+static errcode execute_bulk_data_cmd(void *devdata,
+ u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 *block_size;
+ char filename[ISPCMD_FILENAME_SIZE];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ memcpy(filename, param, ISPCMD_FILENAME_SIZE);
+
+
+ misp_info("%s Start", __func__);
+
+ /*set the size*/
+ block_size = (u32 *)¶m[8];
+
+ if (opcode == ISPCMD_BULK_WRITE_BOOTCODE) {
+ /* Write Boot Code*/
+ misp_info("%s : write BOOT_CODE", __func__);
+
+ dev_global_variable->before_booting = 1;
+ *block_size = MASTERTX_BLOCK_SIZE;
+
+#ifndef AL6100_SPI_NOR
+ err = mast_bulk_data_cmd_write_boot_code(devdata, param,
+ g_filp[BOOT_CODE]);
+
+ if (g_filp[BOOT_CODE] != NULL) {
+ filp_close(g_filp[BOOT_CODE], NULL);
+ g_filp[BOOT_CODE] = NULL;
+ }
+#endif
+
+ dev_global_variable->before_booting = 0;
+ } else if (opcode == ISPCMD_BULK_WRITE_BOOTCODE_SHORT_LEN) {
+ /* Write Boot Code (short SPI len)*/
+ misp_info("%s : write BOOT_CODE", __func__);
+ dev_global_variable->before_booting = 1;
+ *block_size = MASTERTX_BLOCK_SIZE;
+#ifndef AL6100_SPI_NOR
+ err = mast_bulk_data_cmd_write_boot_code_shortlen(
+ devdata, param, g_filp[BOOT_CODE]);
+
+ if (g_filp[BOOT_CODE] != NULL) {
+ filp_close(g_filp[BOOT_CODE], NULL);
+ g_filp[BOOT_CODE] = NULL;
+ }
+#endif
+ dev_global_variable->before_booting = 0;
+ } else if (opcode == ISPCMD_BULK_WRITE_BASICCODE) {
+ /* Write Basic Code*/
+ misp_info("%s : write BASIC_CODE", __func__);
+
+#ifndef AL6100_SPI_NOR
+ err = mast_bulk_data_cmd_write_basic_code(devdata, param,
+ g_filp[BASIC_CODE]);
+
+ if (g_filp[BASIC_CODE] != NULL) {
+ filp_close(g_filp[BASIC_CODE], NULL);
+ g_filp[BASIC_CODE] = NULL;
+ }
+#endif
+ } else if (opcode == ISPCMD_BULK_WRITE_BASICCODE_CODESUM) {
+ /* Write Basic Code (short SPI len)*/
+ misp_info("%s : write BASIC_CODE", __func__);
+#ifndef AL6100_SPI_NOR
+ err = mast_bulk_data_cmd_write_basic_code_shortlen(
+ devdata, param, g_filp[BASIC_CODE]);
+
+ if (g_filp[BASIC_CODE] != NULL) {
+ filp_close(g_filp[BASIC_CODE], NULL);
+ g_filp[BASIC_CODE] = NULL;
+ }
+#endif
+
+ } else if (opcode == ISPCMD_BULK_WRITE_CALIBRATION_DATA) {
+ /*Write Calibration Data*/
+ if (param[8] == 0) {
+ misp_info("%s : write IQ_CALIBRATION_DATA", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param, NULL);
+ } else if (param[8] == 1) {
+ misp_info("%s : write DEPTH_CALIBRATION_DATA",
+ __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param, NULL);
+ } else if (param[8] == 2) {
+ misp_info("%s : write SCENARIO_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param, g_filp[SCENARIO_CODE]);
+
+ if (g_filp[SCENARIO_CODE] != NULL) {
+ filp_close(g_filp[SCENARIO_CODE], NULL);
+ g_filp[SCENARIO_CODE] = NULL;
+ }
+
+ } else if (param[8] == 3) {
+ misp_info("%s : write HDR_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param, g_filp[HDR_CODE]);
+
+ if (g_filp[HDR_CODE] != NULL) {
+ filp_close(g_filp[HDR_CODE], NULL);
+ g_filp[HDR_CODE] = NULL;
+ }
+ } else if (param[8] == 4) {
+ misp_info("%s : write IRP0_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param, g_filp[IRP0_CODE]);
+
+ if (g_filp[IRP0_CODE] != NULL) {
+ filp_close(g_filp[IRP0_CODE], NULL);
+ g_filp[IRP0_CODE] = NULL;
+ }
+ } else if (param[8] == 5) {
+ misp_info("%s : write IRP1_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param, g_filp[IRP1_CODE]);
+
+ if (g_filp[IRP1_CODE] != NULL) {
+ filp_close(g_filp[IRP1_CODE], NULL);
+ g_filp[IRP1_CODE] = NULL;
+ }
+ } else if (param[8] == 6) {
+ misp_info("%s : write PPMAP_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param, g_filp[PPMAP_CODE]);
+
+ if (g_filp[PPMAP_CODE] != NULL) {
+ filp_close(g_filp[PPMAP_CODE], NULL);
+ g_filp[PPMAP_CODE] = NULL;
+ }
+ } else if (param[8] == 7) {
+ misp_info("%s : write BLENDING_TABLE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param, NULL);
+ } else if (param[8] == 8) {
+ misp_info("%s : write DEPTH_CODE", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param, g_filp[DEPTH_CODE]);
+
+ if (g_filp[DEPTH_CODE] != NULL) {
+ filp_close(g_filp[DEPTH_CODE], NULL);
+ g_filp[DEPTH_CODE] = NULL;
+ }
+ } else if (param[8] == 9) {
+ misp_info("%s : write OTP DATA", __func__);
+ err = mast_bulk_data_cmd_write_calibration_data(
+ devdata, param, NULL);
+ }
+ }
+ /* Read Calibration Data*/
+ else if (opcode == ISPCMD_BULK_READ_CALIBRATION_DATA)
+ err = mast_bulk_data_cmd_read_calibration_data(devdata, param);
+ /* Read memory Data*/
+ else if (opcode == ISPCMD_BULK_READ_MEMORY)
+ err = mast_bulk_data_cmd_read_memory_data(devdata, param);
+ /* Read Common Log Data*/
+ else if (opcode == ISPCMD_BULK_READ_COMLOG)
+ err = bulk_data_cmd_read_common_log(devdata, param);
+ /* Read Depth RectA, B, Invrect*/
+ else if (opcode == ISPCMD_BULK_WRITE_DEPTH_RECTAB_INVRECT) {
+ err = mast_bulk_data_cmd_write_depth_rectab_invrect(
+ devdata, opcode, param);
+ } else if (opcode == ISPCMD_BULK_WRITE_SPINOR_DATA) {
+ /*Write SPINOR Data*/
+ if (param[8] == 0) {
+ misp_info("%s : write SPINOR BOOT DATA ", __func__);
+ err = mast_bulk_data_cmd_write_spinor_data(
+ devdata, param, g_filp[BOOT_CODE]);
+ } else if (param[8] == 1) {
+ misp_info("%s : write SPINOR MAIN DATA", __func__);
+ err = mast_bulk_data_cmd_write_spinor_data(
+ devdata, param, g_filp[BASIC_CODE]);
+ }
+ }
+ misp_info("execute_bulk_data_cmd - end Errcode: %d ======", (int)err);
+
+ return err;
+
+}
+#endif
+/**
+ *\brief Execute camera profile command
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+static errcode execute_camera_profile_cmd(void *devdata, u16 opcode,
+ u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+
+ /* Set Sensor Mode*/
+ if (opcode == ISPCMD_CAMERA_SET_SENSORMODE)
+ err = mast_camera_profile_cmd_set_sensor_mode(devdata,
+ opcode, param);
+ /* Get Sensor Mode*/
+ else if (opcode == ISPCMD_CAMERA_GET_SENSORMODE)
+ err = mast_camera_profile_cmd_get_sensor_mode(devdata,
+ opcode, param);
+ /*Set Output format*/
+ else if (opcode == ISPCMD_CAMERA_SET_OUTPUTFORMAT)
+ err = mast_camera_profile_cmd_set_output_format(devdata,
+ opcode, param);
+ /*Set CP Mode*/
+ else if (opcode == ISPCMD_CAMERA_SET_CP_MODE)
+ err = mast_camera_profile_cmd_set_cp_mode(devdata,
+ opcode, param);
+ /* Preview stream on*/
+ else if (opcode == ISPCMD_CAMERA_PREVIEWSTREAMONOFF)
+ err = mast_camera_profile_cmd_preview_stream_on_off(
+ devdata, opcode, param);
+ /* Set AE statistic*/
+ else if (opcode == ISPCMD_CAMERA_SET_AE_STATISTICS)
+ err = mast_basic_setting_cmd_set_ae_statistics(
+ devdata, opcode, param);
+ /* Dual PD Y calculation weightings*/
+ else if (opcode == ISPCMD_CAMERA_DUALPDYCALCULATIONWEIGHT)
+ err = mast_camera_profile_cmd_dual_pd_y_cauculation_weightings(
+ devdata, opcode, param);
+ /* LED power control*/
+ else if (opcode == ISPCMD_LED_POWERCONTROL)
+ err = mast_camera_profile_cmd_led_power_control(
+ devdata, opcode, param);
+ /* Active AE*/
+ else if (opcode == ISPCMD_CAMERA_ACTIVE_AE)
+ err = mast_camera_profile_cmd_active_ae(
+ devdata, opcode, param);
+ /* ISP AE Control*/
+ else if (opcode == ISPCMD_ISP_AECONTROLONOFF)
+ err = mast_camera_profile_cmd_isp_ae_control_on_off(
+ devdata, opcode, param);
+ /* Set Frame Rate Limits*/
+ else if (opcode == ISPCMD_CAMERA_SET_FRAMERATELIMITS)
+ err = mast_camera_profile_cmd_set_frame_rate_limits(
+ devdata, opcode, param);
+ /* Set Period Drop Frame*/
+ else if (opcode == ISPCMD_CAMERA_SET_PERIODDROPFRAME)
+ err = mast_camera_profile_cmd_set_period_drop_frame(
+ devdata, opcode, param);
+ /* Set Max exposure*/
+ else if (opcode == ISPCMD_CAMERA_SET_MAX_EXPOSURE)
+ err = mast_camera_profile_cmd_set_max_exposure(
+ devdata, opcode, param);
+ /* Set AE Target Mean*/
+ else if (opcode == ISPCMD_CAMERA_SET_AE_TARGET_MEAN)
+ err = mast_camera_profile_cmd_set_target_mean(
+ devdata, opcode, param);
+ /* Frame Sync Control*/
+ else if (opcode == ISPCMD_CAMERA_FRAME_SYNC_CONTROL)
+ err = mast_camera_profile_cmd_frame_sync_control(
+ devdata, opcode, param);
+ /* Set Shot Mode */
+ else if (opcode == ISPCMD_CAMERA_SET_SHOT_MODE)
+ err = mast_camera_profile_cmd_set_shot_mode(
+ devdata, opcode, param);
+ /* Lighting Control*/
+ else if (opcode == ISPCMD_CAMERA_LIGHTING_CTRL)
+ err = mast_camera_profile_cmd_lighting_ctrl(
+ devdata, opcode, param);
+ /* Set Depth shift */
+ else if (opcode == ISPCMD_CAMERA_DEPTH_COMPENSATION)
+ err = mast_camera_profile_cmd_set_depth_compensation(
+ devdata, opcode, param);
+ /* set cycle trigger depth process */
+ else if (opcode == ISPCMD_CAMERA_TRIGGER_DEPTH_PROCESS_CTRL)
+ err = mast_camera_profile_cmd_set_cycle_trigger_depth(
+ devdata, opcode, param);
+ /* Set Min exposure*/
+ else if (opcode == ISPCMD_CAMERA_SET_MIN_EXPOSURE)
+ err = mast_camera_profile_cmd_set_min_exposure(
+ devdata, opcode, param);
+ /* Set Max exposure slope*/
+ else if (opcode == ISPCMD_CAMERA_SET_MAX_EXPOSURE_SLOPE)
+ err = mast_camera_profile_cmd_set_max_exposure_slope(
+ devdata, opcode, param);
+ /* Set led active delay time */
+ else if (opcode == ISPCMD_CAMERA_SET_LED_ACTIVE_DELAY)
+ err = mast_camera_profile_cmd_set_led_active_delay(
+ devdata, opcode, param);
+ /* Set ISP control led level */
+ else if (opcode == ISPCMD_CAMERA_ISPLEDLEVELCONTROLONOFF)
+ err = mast_camera_profile_cmd_isp_control_led_level(
+ devdata, opcode, param);
+ else
+ misp_err("%s : unknown opcode: %#04x", __func__, opcode);
+ return err;
+
+}
+
+
+/**
+ *\brief Execute operation command
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+static errcode execute_operation_cmd(void *devdata,
+ u16 opcode, char *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+
+ /* mini_isp_drv_open*/
+ if (opcode == ISPCMD_MINIISPOPEN)
+ err = mast_operation_cmd_miniisp_open(devdata,
+ opcode, (char **)param);
+
+ return err;
+}
+
+
+static u16 isp_mast_calculate_check_sum(u8 *input_buffer_addr,
+ u16 input_buffer_size, bool b2sCom)
+{
+ u16 i;
+ u32 sum = 0;
+ u16 sumvalue;
+
+ for (i = 0; i < input_buffer_size; i++) {
+ if (0 == (i%2))
+ sum += input_buffer_addr[i];
+ else
+ sum += (input_buffer_addr[i] << 8);
+ }
+
+ /* Do 2's complement*/
+ if (b2sCom == true)
+ sumvalue = (u16) (65536 - (sum & 0x0000FFFF));
+ /* Update total sum*/
+ else
+ sumvalue = sum;
+
+ return sumvalue;
+}
+
+
+/******End Of File******/
diff --git a/drivers/media/platform/altek/miniisp_chip_base_define.c b/drivers/media/platform/altek/miniisp_chip_base_define.c
new file mode 100755
index 0000000..ec995ea
--- /dev/null
+++ b/drivers/media/platform/altek/miniisp_chip_base_define.c
@@ -0,0 +1,756 @@
+/*
+ * File: miniisp_chip_base_define.c.c
+ * Description: Mini ISP ChipBase Define Code
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2017/10/18; Louis Wang; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+ /******Include File******/
+#include "linux/init.h"
+#include "linux/module.h"
+
+#include "include/miniisp.h"
+#include "include/error.h"
+#include "include/miniisp_chip_base_define.h"
+#include "include/miniisp_customer_define.h"
+
+#define MINI_ISP_LOG_TAG "[miniisp_chip_base_define]"
+
+/******Private Variable******/
+static u32 clk_gen_array[] = clk_gen_dump_field;
+static u32 mipi_tx_phy_if_0_array[] = mipi_tx_phy_if_0_dump_field;
+static u32 mipi_tx_phy_if_1_array[] = mipi_tx_phy_if_1_dump_field;
+static u32 gen_reg_array[] = gen_reg_dump_field;
+static u32 mipi_slvds_rx_phy_if_0_array[] = mipi_slvds_rx_phy_if_0_dump_field;
+static u32 mipi_slvds_rx_phy_if_1_array[] = mipi_slvds_rx_phy_if_1_dump_field;
+static u32 ppi_bridge_a_0_array[] = ppi_bridge_a_0_dump_field;
+static u32 ppi_bridge_a_1_array[] = ppi_bridge_a_1_dump_field;
+static u32 tx_top_out_mux_a_0_array[] = tx_top_out_mux_a_0_dump_field;
+static u32 tx_top_out_mux_a_1_array[] = tx_top_out_mux_a_1_dump_field;
+static u32 tx_line_merge_21_a_0_array[] = tx_line_merge_21_a_0_dump_field;
+static u32 tx_line_merge_21_b_0_array[] = tx_line_merge_21_b_0_dump_field;
+static u32 tx_line_merge_21_c_0_array[] = tx_line_merge_21_c_0_dump_field;
+static u32 tx_line_merge_21_d_0_array[] = tx_line_merge_21_d_0_dump_field;
+static u32 mipi_csi2_tx_0_array[] = mipi_csi2_tx_0_dump_field;
+static u32 mipi_csi2_tx_1_array[] = mipi_csi2_tx_1_dump_field;
+static u32 gen_reg_depth_top_array[] = gen_reg_depth_top_dump_field;
+static u32 gen_reg_dpc_top_array[] = gen_reg_dpc_top_dump_field;
+static u32 gen_reg_hdr_top_array[] = gen_reg_hdr_top_dump_field;
+static u32 gen_reg_irp_top_array[] = gen_reg_irp_top_dump_field;
+static u32 gen_reg_standby_top_array[] = gen_reg_standby_top_dump_field;
+static u32 gen_reg_tx_top_array[] = gen_reg_tx_top_dump_field;
+static u32 id_det_a_0_array[] = id_det_a_0_dump_field;
+static u32 id_det_a_1_array[] = id_det_a_1_dump_field;
+static u32 bayer_binning_a_0_array[] = bayer_binning_a_0_dump_field;
+static u32 bayer_binning_a_1_array[] = bayer_binning_a_1_dump_field;
+static u32 bayer_scl_a_0_array[] = bayer_scl_a_0_dump_field;
+static u32 bayer_scl_a_1_array[] = bayer_scl_a_1_dump_field;
+static u32 rlb_a_0_array[] = rlb_a_0_dump_field;
+static u32 rlb_b_0_array[] = rlb_b_0_dump_field;
+static u32 mipi_csi2_rx_0_array[] = mipi_csi2_rx_0_dump_field;
+static u32 mipi_csi2_rx_1_array[] = mipi_csi2_rx_1_dump_field;
+static u32 dg_ca_a_0_array[] = dg_ca_a_0_dump_field;
+static u32 dg_mcc_a_0_array[] = dg_mcc_a_0_dump_field;
+static u32 dp_top_a_0_array[] = dp_top_a_0_dump_field;
+static u32 lvhwirp_top_a_0_array[] = lvhwirp_top_a_0_dump_field;
+static u32 lvhwirp_top_b_0_array[] = lvhwirp_top_b_0_dump_field;
+static u32 lvlumanr_a_0_array[] = lvlumanr_a_0_dump_field;
+static u32 lvlumanr_a_1_array[] = lvlumanr_a_1_dump_field;
+static u32 lvsharp_a_0_array[] = lvsharp_a_0_dump_field;
+static u32 lvsharp_a_1_array[] = lvsharp_a_1_dump_field;
+static u32 rectify_a_0_array[] = rectify_a_0_dump_field;
+static u32 rectify_b_0_array[] = rectify_b_0_dump_field;
+static u32 hdr_ae_a_0_array[] = hdr_ae_a_0_dump_field;
+static u32 hdr_ae_a_1_array[] = hdr_ae_a_1_dump_field;
+
+/******Public Function******/
+
+void mini_isp_chip_base_define_module_reg_dump(
+ char *dest_path, char *module_name)
+{
+ int i = 0;
+
+ /*clk_gen*/
+ if (strcmp(module_name, "clk_gen") == 0)
+ for (i = 0; i < sizeof(clk_gen_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ clk_gen_array[i],
+ clk_gen_array[i+1],
+ dest_path,
+ module_name);
+ /*mipi_tx_phy_if_0*/
+ else if (strcmp(module_name, "mipi_tx_phy_if_0") == 0)
+ for (i = 0; i < sizeof(mipi_tx_phy_if_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ mipi_tx_phy_if_0_array[i],
+ mipi_tx_phy_if_0_array[i+1],
+ dest_path,
+ module_name);
+ /*mipi_tx_phy_if_1*/
+ else if (strcmp(module_name, "mipi_tx_phy_if_1") == 0)
+ for (i = 0; i < sizeof(mipi_tx_phy_if_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ mipi_tx_phy_if_1_array[i],
+ mipi_tx_phy_if_1_array[i+1],
+ dest_path,
+ module_name);
+ /*gen_reg*/
+ else if (strcmp(module_name, "gen_reg") == 0)
+ for (i = 0; i < sizeof(gen_reg_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ gen_reg_array[i],
+ gen_reg_array[i+1],
+ dest_path,
+ module_name);
+ /*mipi_slvds_rx_phy_if_0*/
+ else if (strcmp(module_name, "mipi_slvds_rx_phy_if_0") == 0)
+ for (i = 0;
+ i < sizeof(mipi_slvds_rx_phy_if_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ mipi_slvds_rx_phy_if_0_array[i],
+ mipi_slvds_rx_phy_if_0_array[i+1],
+ dest_path,
+ module_name);
+ /*mipi_slvds_rx_phy_if_1*/
+ else if (strcmp(module_name, "mipi_slvds_rx_phy_if_1") == 0)
+ for (i = 0;
+ i < sizeof(mipi_slvds_rx_phy_if_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ mipi_slvds_rx_phy_if_1_array[i],
+ mipi_slvds_rx_phy_if_1_array[i+1],
+ dest_path,
+ module_name);
+ /*ppi_bridge_a_0*/
+ else if (strcmp(module_name, "ppi_bridge_a_0") == 0)
+ for (i = 0; i < sizeof(ppi_bridge_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ ppi_bridge_a_0_array[i],
+ ppi_bridge_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*ppi_bridge_a_1*/
+ else if (strcmp(module_name, "ppi_bridge_a_1") == 0)
+ for (i = 0; i < sizeof(ppi_bridge_a_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ ppi_bridge_a_1_array[i],
+ ppi_bridge_a_1_array[i+1],
+ dest_path,
+ module_name);
+ /*tx_top_out_mux_a_0*/
+ else if (strcmp(module_name, "tx_top_out_mux_a_0") == 0)
+ for (i = 0; i < sizeof(tx_top_out_mux_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ tx_top_out_mux_a_0_array[i],
+ tx_top_out_mux_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*tx_top_out_mux_a_1*/
+ else if (strcmp(module_name, "tx_top_out_mux_a_1") == 0)
+ for (i = 0; i < sizeof(tx_top_out_mux_a_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ tx_top_out_mux_a_1_array[i],
+ tx_top_out_mux_a_1_array[i+1],
+ dest_path,
+ module_name);
+ /*tx_line_merge_21_a_0*/
+ else if (strcmp(module_name, "tx_line_merge_21_a_0") == 0)
+ for (i = 0;
+ i < sizeof(tx_line_merge_21_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ tx_line_merge_21_a_0_array[i],
+ tx_line_merge_21_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*tx_line_merge_21_b_0*/
+ else if (strcmp(module_name, "tx_line_merge_21_b_0") == 0)
+ for (i = 0;
+ i < sizeof(tx_line_merge_21_b_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ tx_line_merge_21_b_0_array[i],
+ tx_line_merge_21_b_0_array[i+1],
+ dest_path,
+ module_name);
+ /*tx_line_merge_21_c_0*/
+ else if (strcmp(module_name, "tx_line_merge_21_c_0") == 0)
+ for (i = 0;
+ i < sizeof(tx_line_merge_21_c_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ tx_line_merge_21_c_0_array[i],
+ tx_line_merge_21_c_0_array[i+1],
+ dest_path,
+ module_name);
+ /*tx_line_merge_21_d_0*/
+ else if (strcmp(module_name, "tx_line_merge_21_d_0") == 0)
+ for (i = 0;
+ i < sizeof(tx_line_merge_21_d_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ tx_line_merge_21_d_0_array[i],
+ tx_line_merge_21_d_0_array[i+1],
+ dest_path,
+ module_name);
+ /*mipi_csi2_tx_0*/
+ else if (strcmp(module_name, "mipi_csi2_tx_0") == 0)
+ for (i = 0; i < sizeof(mipi_csi2_tx_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ mipi_csi2_tx_0_array[i],
+ mipi_csi2_tx_0_array[i+1],
+ dest_path,
+ module_name);
+ /*mipi_csi2_tx_1*/
+ else if (strcmp(module_name, "mipi_csi2_tx_1") == 0)
+ for (i = 0; i < sizeof(mipi_csi2_tx_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ mipi_csi2_tx_1_array[i],
+ mipi_csi2_tx_1_array[i+1],
+ dest_path,
+ module_name);
+ /*gen_reg_depth_top*/
+ else if (strcmp(module_name, "gen_reg_depth_top") == 0)
+ for (i = 0; i < sizeof(gen_reg_depth_top_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ gen_reg_depth_top_array[i],
+ gen_reg_depth_top_array[i+1],
+ dest_path,
+ module_name);
+ /*gen_reg_dpc_top*/
+ else if (strcmp(module_name, "gen_reg_dpc_top") == 0)
+ for (i = 0; i < sizeof(gen_reg_dpc_top_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ gen_reg_dpc_top_array[i],
+ gen_reg_dpc_top_array[i+1],
+ dest_path,
+ module_name);
+ /*gen_reg_hdr_top*/
+ else if (strcmp(module_name, "gen_reg_hdr_top") == 0)
+ for (i = 0; i < sizeof(gen_reg_hdr_top_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ gen_reg_hdr_top_array[i],
+ gen_reg_hdr_top_array[i+1],
+ dest_path,
+ module_name);
+ /*gen_reg_irp_top*/
+ else if (strcmp(module_name, "gen_reg_irp_top") == 0)
+ for (i = 0; i < sizeof(gen_reg_irp_top_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ gen_reg_irp_top_array[i],
+ gen_reg_irp_top_array[i+1],
+ dest_path,
+ module_name);
+ /*gen_reg_standby_top*/
+ else if (strcmp(module_name, "gen_reg_standby_top") == 0)
+ for (i = 0; i < sizeof(gen_reg_standby_top_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ gen_reg_standby_top_array[i],
+ gen_reg_standby_top_array[i+1],
+ dest_path,
+ module_name);
+ /*gen_reg_tx_top*/
+ else if (strcmp(module_name, "gen_reg_tx_top") == 0)
+ for (i = 0; i < sizeof(gen_reg_tx_top_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ gen_reg_tx_top_array[i],
+ gen_reg_tx_top_array[i+1],
+ dest_path,
+ module_name);
+ /*id_det_a_0*/
+ else if (strcmp(module_name, "id_det_a_0") == 0)
+ for (i = 0; i < sizeof(id_det_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ id_det_a_0_array[i],
+ id_det_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*id_det_a_1*/
+ else if (strcmp(module_name, "id_det_a_1") == 0)
+ for (i = 0; i < sizeof(id_det_a_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ id_det_a_1_array[i],
+ id_det_a_1_array[i+1],
+ dest_path,
+ module_name);
+ /*bayer_binning_a_0*/
+ else if (strcmp(module_name, "bayer_binning_a_0") == 0)
+ for (i = 0; i < sizeof(bayer_binning_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ bayer_binning_a_0_array[i],
+ bayer_binning_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*bayer_binning_a_1*/
+ else if (strcmp(module_name, "bayer_binning_a_1") == 0)
+ for (i = 0; i < sizeof(bayer_binning_a_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ bayer_binning_a_1_array[i],
+ bayer_binning_a_1_array[i+1],
+ dest_path,
+ module_name);
+ /*bayer_scl_a_0*/
+ else if (strcmp(module_name, "bayer_scl_a_0") == 0)
+ for (i = 0; i < sizeof(bayer_scl_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ bayer_scl_a_0_array[i],
+ bayer_scl_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*bayer_scl_a_1*/
+ else if (strcmp(module_name, "bayer_scl_a_1") == 0)
+ for (i = 0; i < sizeof(bayer_scl_a_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ bayer_scl_a_1_array[i],
+ bayer_scl_a_1_array[i+1],
+ dest_path,
+ module_name);
+ /*rlb_a_0*/
+ else if (strcmp(module_name, "rlb_a_0") == 0)
+ for (i = 0; i < sizeof(rlb_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ rlb_a_0_array[i],
+ rlb_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*rlb_b_0*/
+ else if (strcmp(module_name, "rlb_b_0") == 0)
+ for (i = 0; i < sizeof(rlb_b_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ rlb_b_0_array[i],
+ rlb_b_0_array[i+1],
+ dest_path,
+ module_name);
+ /*mipi_csi2_rx_0*/
+ else if (strcmp(module_name, "mipi_csi2_rx_0") == 0)
+ for (i = 0; i < sizeof(mipi_csi2_rx_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ mipi_csi2_rx_0_array[i],
+ mipi_csi2_rx_0_array[i+1],
+ dest_path,
+ module_name);
+ /*mipi_csi2_rx_1*/
+ else if (strcmp(module_name, "mipi_csi2_rx_1") == 0)
+ for (i = 0; i < sizeof(mipi_csi2_rx_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ mipi_csi2_rx_1_array[i],
+ mipi_csi2_rx_1_array[i+1],
+ dest_path,
+ module_name);
+ /*dg_ca_a_0*/
+ else if (strcmp(module_name, "dg_ca_a_0") == 0)
+ for (i = 0; i < sizeof(dg_ca_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ dg_ca_a_0_array[i],
+ dg_ca_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*dg_mcc_a_0*/
+ else if (strcmp(module_name, "dg_mcc_a_0") == 0)
+ for (i = 0; i < sizeof(dg_mcc_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ dg_mcc_a_0_array[i],
+ dg_mcc_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*dp_top_a_0*/
+ else if (strcmp(module_name, "dp_top_a_0") == 0)
+ for (i = 0; i < sizeof(dp_top_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ dp_top_a_0_array[i],
+ dp_top_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*lvhwirp_top_a_0*/
+ else if (strcmp(module_name, "lvhwirp_top_a_0") == 0)
+ for (i = 0; i < sizeof(lvhwirp_top_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ lvhwirp_top_a_0_array[i],
+ lvhwirp_top_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*lvhwirp_top_b_0*/
+ else if (strcmp(module_name, "lvhwirp_top_b_0") == 0)
+ for (i = 0; i < sizeof(lvhwirp_top_b_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ lvhwirp_top_b_0_array[i],
+ lvhwirp_top_b_0_array[i+1],
+ dest_path,
+ module_name);
+ /*lvlumanr_a_0*/
+ else if (strcmp(module_name, "lvlumanr_a_0") == 0)
+ for (i = 0; i < sizeof(lvlumanr_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ lvlumanr_a_0_array[i],
+ lvlumanr_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*lvlumanr_a_1*/
+ else if (strcmp(module_name, "lvlumanr_a_1") == 0)
+ for (i = 0; i < sizeof(lvlumanr_a_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ lvlumanr_a_1_array[i],
+ lvlumanr_a_1_array[i+1],
+ dest_path,
+ module_name);
+ /*lvsharp_a_0*/
+ else if (strcmp(module_name, "lvsharp_a_0") == 0)
+ for (i = 0; i < sizeof(lvsharp_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ lvsharp_a_0_array[i],
+ lvsharp_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*lvsharp_a_1*/
+ else if (strcmp(module_name, "lvsharp_a_1") == 0)
+ for (i = 0; i < sizeof(lvsharp_a_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ lvsharp_a_1_array[i],
+ lvsharp_a_1_array[i+1],
+ dest_path,
+ module_name);
+ /*rectify_a_0*/
+ else if (strcmp(module_name, "rectify_a_0") == 0)
+ for (i = 0; i < sizeof(rectify_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ rectify_a_0_array[i],
+ rectify_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*rectify_b_0*/
+ else if (strcmp(module_name, "rectify_b_0") == 0)
+ for (i = 0; i < sizeof(rectify_b_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ rectify_b_0_array[i],
+ rectify_b_0_array[i+1],
+ dest_path,
+ module_name);
+ /*hdr_ae_a_0*/
+ else if (strcmp(module_name, "hdr_ae_a_0") == 0)
+ for (i = 0; i < sizeof(hdr_ae_a_0_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ hdr_ae_a_0_array[i],
+ hdr_ae_a_0_array[i+1],
+ dest_path,
+ module_name);
+ /*hdr_ae_a_1*/
+ else if (strcmp(module_name, "hdr_ae_a_1") == 0)
+ for (i = 0; i < sizeof(hdr_ae_a_1_array)/(sizeof(u32));
+ i = i + 2)
+ mini_isp_register_read_then_write_file(
+ hdr_ae_a_1_array[i],
+ hdr_ae_a_1_array[i+1],
+ dest_path,
+ module_name);
+ else
+ misp_err("%s %s dump field not exit, please add",
+ __func__, module_name);
+}
+
+/**
+ *\brief dump bypass mode reg
+ *\descript should use SPI e mode or I2C slave
+ *\return Error code
+ */
+errcode mini_isp_chip_base_dump_bypass_mode_register(char *dest_path)
+{
+ errcode err = ERR_SUCCESS;
+
+ /*clk_gen*/
+ misp_info("%s clk_gen", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "clk_gen");
+ /*mipi_tx_phy_if_0*/
+ misp_info("%s mipi_tx_phy_if_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_tx_phy_if_0");
+ /*mipi_tx_phy_if_1*/
+ misp_info("%s mipi_tx_phy_if_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_tx_phy_if_1");
+ /*gen_reg*/
+ misp_info("%s gen_reg", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "gen_reg");
+ /*mipi_slvds_rx_phy_if_0*/
+ misp_info("%s mipi_slvds_rx_phy_if_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_slvds_rx_phy_if_0");
+ /*mipi_slvds_rx_phy_if_1*/
+ misp_info("%s mipi_slvds_rx_phy_if_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_slvds_rx_phy_if_1");
+ /*ppi_bridge_a_0*/
+ misp_info("%s ppi_bridge_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "ppi_bridge_a_0");
+ /*ppi_bridge_a_1*/
+ misp_info("%s ppi_bridge_a_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "ppi_bridge_a_1");
+ return err;
+}
+
+
+/**
+ *\brief dump normal mode reg
+ *\descript should use SPI e mode or I2C slave
+ *\return Error code
+ */
+errcode mini_isp_chip_base_dump_normal_mode_register(char *dest_path)
+{
+ errcode err = ERR_SUCCESS;
+
+ /*clk_gen*/
+ misp_info("%s clk_gen", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "clk_gen");
+ /*tx_top_out_mux_a_0*/
+ misp_info("%s tx_top_out_mux_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "tx_top_out_mux_a_0");
+ /*tx_top_out_mux_a_1*/
+ misp_info("%s tx_top_out_mux_a_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "tx_top_out_mux_a_1");
+ /*tx_line_merge_21_a_0*/
+ misp_info("%s tx_line_merge_21_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "tx_line_merge_21_a_0");
+ /*tx_line_merge_21_b_0*/
+ misp_info("%s tx_line_merge_21_b_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "tx_line_merge_21_b_0");
+ /*tx_line_merge_21_c_0*/
+ misp_info("%s tx_line_merge_21_c_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "tx_line_merge_21_c_0");
+ /*tx_line_merge_21_d_0*/
+ misp_info("%s tx_line_merge_21_d_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "tx_line_merge_21_d_0");
+ /*mipi_csi2_tx_0*/
+ misp_info("%s mipi_csi2_tx_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_csi2_tx_0");
+ /*mipi_tx_phy_if_0*/
+ misp_info("%s mipi_tx_phy_if_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_tx_phy_if_0");
+ /*mipi_csi2_tx_1*/
+ misp_info("%s mipi_csi2_tx_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_csi2_tx_1");
+ /*mipi_tx_phy_if_1*/
+ misp_info("%s mipi_tx_phy_if_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_tx_phy_if_1");
+ /*gen_reg_depth_top*/
+ misp_info("%s gen_reg_depth_top", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "gen_reg_depth_top");
+ /*gen_reg_dpc_top*/
+ misp_info("%s gen_reg_dpc_top", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "gen_reg_dpc_top");
+ /*gen_reg_hdr_top*/
+ misp_info("%s gen_reg_hdr_top", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "gen_reg_hdr_top");
+ /*gen_reg_irp_top*/
+ misp_info("%s gen_reg_irp_top", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "gen_reg_irp_top");
+ /*gen_reg_standby_top*/
+ misp_info("%s gen_reg_standby_top", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "gen_reg_standby_top");
+ /*gen_reg_tx_top*/
+ misp_info("%s gen_reg_tx_top", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "gen_reg_tx_top");
+ /*id_det_a_0*/
+ misp_info("%s id_det_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "id_det_a_0");
+ /*id_det_a_1*/
+ misp_info("%s id_det_a_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "id_det_a_1");
+ /*bayer_binning_a_0*/
+ misp_info("%s bayer_binning_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "bayer_binning_a_0");
+ /*bayer_binning_a_1*/
+ misp_info("%s bayer_binning_a_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "bayer_binning_a_1");
+ /*bayer_scl_a_0*/
+ misp_info("%s bayer_scl_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "bayer_scl_a_0");
+ /*bayer_scl_a_1*/
+ misp_info("%s bayer_scl_a_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "bayer_scl_a_1");
+ /*rlb_a_0*/
+ misp_info("%s rlb_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "rlb_a_0");
+ /*rlb_b_0*/
+ misp_info("%s rlb_b_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "rlb_b_0");
+ /*mipi_slvds_rx_phy_if_0*/
+ misp_info("%s mipi_slvds_rx_phy_if_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_slvds_rx_phy_if_0");
+ /*mipi_csi2_rx_0*/
+ misp_info("%s mipi_csi2_rx_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_csi2_rx_0");
+ /*mipi_slvds_rx_phy_if_1*/
+ misp_info("%s mipi_slvds_rx_phy_if_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_slvds_rx_phy_if_1");
+ /*mipi_csi2_rx_1*/
+ misp_info("%s mipi_csi2_rx_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "mipi_csi2_rx_1");
+ /*ppi_bridge_a_0*/
+ misp_info("%s ppi_bridge_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "ppi_bridge_a_0");
+ /*ppi_bridge_a_1*/
+ misp_info("%s ppi_bridge_a_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "ppi_bridge_a_1");
+ /*hdr_ae_a_0*/
+ misp_info("%s hdr_ae_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "hdr_ae_a_0");
+ /*hdr_ae_a_1*/
+ misp_info("%s hdr_ae_a_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "hdr_ae_a_1");
+ /*gen_reg*/
+ misp_info("%s gen_reg", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ dest_path, "gen_reg");
+ return err;
+}
+
+/**
+ *\brief dump irp and depth based reg
+ *\descript should use SPI e mode or I2C slave
+ *\return Error code
+ */
+errcode mini_isp_chip_base_dump_irp_and_depth_based_register(void)
+{
+ errcode err = ERR_SUCCESS;
+
+ /*dg_ca_a_0*/
+ misp_info("%s dg_ca_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "dg_ca_a_0");
+ /*dg_mcc_a_0*/
+ misp_info("%s dg_mcc_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "dg_mcc_a_0");
+ /*dp_top_a_0*/
+ misp_info("%s dp_top_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "dp_top_a_0");
+ /*lvhwirp_top_a_0*/
+ misp_info("%s lvhwirp_top_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "lvhwirp_top_a_0");
+ /*lvhwirp_top_b_0*/
+ misp_info("%s lvhwirp_top_b_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "lvhwirp_top_b_0");
+ /*lvlumanr_a_0*/
+ misp_info("%s lvlumanr_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "lvlumanr_a_0");
+ /*lvlumanr_a_1*/
+ misp_info("%s lvlumanr_a_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "lvlumanr_a_1");
+ /*lvsharp_a_0*/
+ misp_info("%s lvsharp_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "lvsharp_a_0");
+ /*lvsharp_a_1*/
+ misp_info("%s lvsharp_a_1", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "lvsharp_a_1");
+ /*rectify_a_0*/
+ misp_info("%s rectify_a_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "rectify_a_0");
+ /*rectify_b_0*/
+ misp_info("%s rectify_b_0", __func__);
+ mini_isp_chip_base_define_module_reg_dump(
+ MINIISP_INFO_DUMPLOCATION, "rectify_b_0");
+ return err;
+}
diff --git a/drivers/media/platform/altek/miniisp_ctrl.c b/drivers/media/platform/altek/miniisp_ctrl.c
new file mode 100755
index 0000000..63e82bb
--- /dev/null
+++ b/drivers/media/platform/altek/miniisp_ctrl.c
@@ -0,0 +1,1901 @@
+/*
+ * File: miniisp_ctrl.c
+ * Description: Mini ISP Ctrl sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/10/14; Aaron Chuang; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/******Include File******/
+#include <linux/delay.h>
+
+#include "include/miniisp_customer_define.h"
+#include "include/ispctrl_if_master.h"
+#include "include/miniisp_ctrl.h"
+#include "include/error/altek_state_err.h"
+#include "include/miniisp_chip_base_define.h"
+/******Private Constant Definition******/
+#define MINI_ISP_LOG_TAG "[miniisp_ctrl]"
+
+/******Private Function Prototype******/
+
+static int load_code_task(void *data);
+#if (!ENABLE_LINUX_FW_LOADER)
+static u16 calibration_check_sum(u8 *input_buffer_addr, u16 input_buffer_size);
+#endif
+/******Private Type Declaration******/
+
+
+/******Private Global Variable******/
+
+static struct memmory_dump_hdr_info mem_dum_hdr_cfg = {0};
+static struct common_log_hdr_info com_log_hdr_cfg = {0};
+static bool stop_to_log;
+
+/*Command parameter buffer*/
+/*static u8 cmd_param_buf[T_SPI_CMD_LENGTH];*/
+static u8 rcv_cmd_param_buf[T_SPI_CMD_LENGTH];
+
+
+bool load_code_ready;
+
+/******Public Global Variable******/
+
+
+/******Public Function******/
+
+/*************************************************************************/
+/*operation cmd*/
+
+/**
+ *\brief Mini ISP open 0x4000
+ *\param boot_code_file_name [In], Boot code filename
+ *\param basic_code_file_name [In], Basic code filename
+ *\param advanced_code_file_name [In], Advanced code filename
+ *\param scenario_table_file_name [In], SC table filename
+ *\param hdr_qmerge_data_file_name [In], HDR Qmerge data filename
+ *\param irp0_qmerge_data_file_name [In], IRP0 Qmerge data filename
+ *\param irp1_qmerge_data_file_name [In], IRP1 Qmerge data filename
+ *\param pp_map_file_name [In], pp map filename
+ *\return Error code
+ */
+errcode mini_isp_drv_open(char *pBoot_code_file_name,
+ char *pBasic_code_file_name,
+ char *pAdvanced_code_file_name,
+ char *pScenario_table_file_name,
+ char *pHdr_qmerge_data_file_name,
+ char *pIrp0_qmerge_data_file_name,
+ char *pIrp1_qmerge_data_file_name,
+ char *pPP_map_file_name,
+ char *pDepth_qmerge_file_name)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_MINIISPOPEN; /*0x4000*/
+ char *cmd_param_buf[9];
+
+ /* Command parameter buffer*/
+ memset(cmd_param_buf, 0, sizeof(cmd_param_buf));
+ misp_info("%s - start", __func__);
+ /* Parameter 0 boot code filename*/
+ cmd_param_buf[0] = pBoot_code_file_name;
+ /* Parameter 1 basic code filename*/
+ cmd_param_buf[1] = pBasic_code_file_name;
+ /* Parameter 2 advanced code filename*/
+ cmd_param_buf[2] = pAdvanced_code_file_name;
+ /* Parameter 3 calibration filename(sc atable)*/
+ cmd_param_buf[3] = pScenario_table_file_name;
+ /* Parameter 4 hdr qmerge data filename*/
+ cmd_param_buf[4] = pHdr_qmerge_data_file_name;
+ /* Parameter 5 irp0 qmerge data filename*/
+ cmd_param_buf[5] = pIrp0_qmerge_data_file_name;
+ /* Parameter 6 irp1 qmerge data filename*/
+ cmd_param_buf[6] = pIrp1_qmerge_data_file_name;
+ /* Parameter 7 PP map filename*/
+ cmd_param_buf[7] = pPP_map_file_name;
+ /* Parameter 8 depth qmerge filename*/
+ cmd_param_buf[8] = pDepth_qmerge_file_name;
+
+ /* mini ISP open*/
+ err = ispctrl_if_mast_execute_cmd(opcode, (u8 *)cmd_param_buf);
+
+ if (err != ERR_SUCCESS)
+ misp_err("%s open file failed. err: 0x%x", __func__, err);
+ else
+ misp_info("%s - open files success", __func__);
+
+ return err;
+
+}
+
+/*************************************************************************/
+/*bulk cmd*/
+
+/**
+ *\brief Mini ISP write boot code 0x2008
+ *\return Error code
+ */
+errcode mini_isp_drv_write_boot_code(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ u16 opcode = ISPCMD_BULK_WRITE_BOOTCODE; /*0x2008*/
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+ misp_info("%s write boot code state: %d", __func__, err);
+
+ return err;
+}
+
+/**
+ *\brief Mini ISP write boot code (short SPI Len) 0x2009
+ *\return Error code
+ */
+errcode mini_isp_drv_write_boot_code_shortlen(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ u16 opcode = ISPCMD_BULK_WRITE_BOOTCODE_SHORT_LEN; /*0x2009*/
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+ misp_info("%s write boot code state: %d", __func__, err);
+ return err;
+}
+/**
+ *\brief Mini ISP write basic code 0x2002
+ *\return Error code
+ */
+errcode mini_isp_drv_write_basic_code(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ u16 opcode = ISPCMD_BULK_WRITE_BASICCODE; /*0x2002*/
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ misp_info("%s write basic code state: %d", __func__, err);
+
+ return err;
+}
+
+/**
+ *\brief Mini ISP write basic code (short SPI Len) 0x2003/0x2004/0x2005
+ *\return Error code
+ */
+errcode mini_isp_drv_write_basic_code_shortlen(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ u16 opcode = ISPCMD_BULK_WRITE_BASICCODE_CODESUM; /*0x2005*/
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ misp_info("%s write basic code state: %d", __func__, err);
+ return err;
+}
+
+/**
+ *\brief MiniISP Write Calibration Data 0x210B
+ *\param info_id [In], 0 : boot data
+ * 1 : basic data
+ *\return Error code
+ */
+errcode mini_isp_drv_write_spinor_data(u8 info_id)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u16 opcode = ISPCMD_BULK_WRITE_SPINOR_DATA; /*0x210E*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ /* Parameter 8 Info ID*/
+ cmd_param_buf[8] = info_id;
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+ misp_info("%s write calibration data state: %d", __func__, err);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_write_spinor_data);
+
+#if ENABLE_LINUX_FW_LOADER
+/**
+ *\brief MiniISP Write Calibration Data 0x210B
+ *\param info_id [In], 0 : IQ data
+ * 1 : packet data
+ * 2 : scenario table
+ * 3 : qmerge hdr
+ * 4 : qmerge irp0
+ * 5 : qmerge irp1
+ * 6 : PP map
+ * 7 : blending table
+ * 8 : qmerge depth
+ * 9 : OTP data
+ *\param buf_addr [In], otp/packet data buffer start address
+ *\param buf_len [In], otp/packet data buffer len
+ *\return Error code
+ */
+errcode mini_isp_drv_write_calibration_data(u8 info_id, u8 *buf_addr,
+ u32 buf_len)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u16 opcode = ISPCMD_BULK_WRITE_CALIBRATION_DATA; /*0x210B*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ u8 *allocated_memmory = 0;
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ /*
+ *misp_info("%s info_id %d buf_addr %p buf_len %d",
+ * __func__, info_id, buf_addr, buf_len);
+ */
+ /* Parameter 0 Info ID*/
+ cmd_param_buf[8] = info_id;
+ if (((info_id >= 2) && (info_id < 7)) || (info_id == 8)) {
+ err = ispctrl_if_mast_execute_cmd(opcode,
+ cmd_param_buf);
+ } else {
+ /* Request memory*/
+ allocated_memmory = kzalloc(buf_len+T_SPI_CMD_LENGTH,
+ GFP_KERNEL);
+ if (!allocated_memmory) {
+ err = ~ERR_SUCCESS;
+ goto allocate_memory_fail;
+ }
+
+ /* fill checksum and block size at
+ * mast_bulk_data_cmd_write_calibration_data api
+ */
+ memcpy(allocated_memmory + T_SPI_CMD_LENGTH,
+ buf_addr, buf_len);
+ memcpy(allocated_memmory, &buf_len, sizeof(u32));
+ memcpy(allocated_memmory + 8, &info_id, sizeof(u8));
+
+ /*
+ *misp_info("%s Cal_param[0][1][2][3]:%02x %02x %02x %02x",
+ * __func__, allocated_memmory[0],
+ * allocated_memmory[1],
+ * allocated_memmory[2],
+ * allocated_memmory[3]);
+ *misp_info("%s Cal_param[4][5][6][7]:%02x %02x %02x %02x",
+ * __func__, allocated_memmory[4],
+ * allocated_memmory[5],
+ * allocated_memmory[6],
+ * allocated_memmory[7]);
+ *misp_info("%s Cal_param[8][9][10]:%02x %02x %02x",
+ * __func__, allocated_memmory[8],
+ * allocated_memmory[9],
+ * allocated_memmory[10]);
+ */
+ err = ispctrl_if_mast_execute_cmd(opcode,
+ allocated_memmory);
+ kfree(allocated_memmory);
+ }
+ misp_info("%s write calibration data state: %d", __func__, err);
+
+
+ goto miniisp_drv_write_calibration_data_end;
+allocate_memory_fail:
+ misp_err("%s Allocate memory failed.", __func__);
+ kfree(allocated_memmory);
+miniisp_drv_write_calibration_data_end:
+
+ return err;
+
+}
+EXPORT_SYMBOL(mini_isp_drv_write_calibration_data);
+
+#else
+/**
+ *\brief MiniISP Write Calibration Data 0x210B
+ *\param info_id [In], 0 : IQ data
+ * 1 : packet data
+ * 2 : scenario table
+ * 3 : qmerge hdr
+ * 4 : qmerge irp0
+ * 5 : qmerge irp1
+ * 6 : PP map
+ * 7 : blending table
+ * 8 : qmerge depth
+ * 9 : OTP data
+ *\param buf_addr [In], otp/packet data buffer start address
+ *\param buf_len [In], otp/packet data buffer len
+ *\return Error code
+ */
+errcode mini_isp_drv_write_calibration_data(u8 info_id, u8 *buf_addr,
+ u32 buf_len)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u16 opcode = ISPCMD_BULK_WRITE_CALIBRATION_DATA; /*0x210B*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ u16 chk_sum;
+ u32 block_size = 384*1024;
+ u8 *allocated_memmory = 0;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ if ((dev_global_variable->now_state != MINI_ISP_STANDBY) &&
+ (dev_global_variable->now_state != MINI_ISP_SENSOR_MODE))
+ return ERR_MINIISP_STATE_ERROR_SEQUENCE;
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ /*
+ *misp_info("%s info_id %d buf_addr %p buf_len %d",
+ * __func__, info_id, buf_addr, buf_len);
+ */
+ /* Parameter 0 Info ID*/
+ cmd_param_buf[8] = info_id;
+ if (((info_id >= 2) && (info_id < 7)) || (info_id == 8)) {
+ err = ispctrl_if_mast_execute_cmd(opcode,
+ cmd_param_buf);
+ } else {
+ /* Request memory*/
+ allocated_memmory = kzalloc(buf_len+T_SPI_CMD_LENGTH,
+ GFP_KERNEL);
+ if (!allocated_memmory) {
+ err = ~ERR_SUCCESS;
+ goto allocate_memory_fail;
+ }
+ memcpy(allocated_memmory + T_SPI_CMD_LENGTH, buf_addr,
+ buf_len);
+ memcpy(allocated_memmory, &buf_len, sizeof(u32));
+ memcpy(allocated_memmory + 4, &block_size, sizeof(u32));
+ memcpy(allocated_memmory + 8, &info_id, sizeof(u8));
+ chk_sum = calibration_check_sum(
+ allocated_memmory + T_SPI_CMD_LENGTH,
+ buf_len);
+ memcpy(allocated_memmory+9, &chk_sum, sizeof(u16));
+ /*
+ *misp_info("%s Cal_param[0][1][2][3]:%02x %02x %02x %02x",
+ * __func__, allocated_memmory[0],
+ * allocated_memmory[1],
+ * allocated_memmory[2],
+ * allocated_memmory[3]);
+ *misp_info("%s Cal_param[4][5][6][7]:%02x %02x %02x %02x",
+ * __func__, allocated_memmory[4],
+ * allocated_memmory[5],
+ * allocated_memmory[6],
+ * allocated_memmory[7]);
+ *misp_info("%s Cal_param[8][9][10]:%02x %02x %02x",
+ * __func__, allocated_memmory[8],
+ * allocated_memmory[9],
+ * allocated_memmory[10]);
+ */
+ err = ispctrl_if_mast_execute_cmd(opcode,
+ allocated_memmory);
+ kfree(allocated_memmory);
+ }
+ misp_info("%s write calibration data state: %d", __func__, err);
+
+
+ goto miniisp_drv_write_calibration_data_end;
+allocate_memory_fail:
+ misp_err("%s Allocate memory failed.", __func__);
+ kfree(allocated_memmory);
+miniisp_drv_write_calibration_data_end:
+
+ return err;
+
+}
+EXPORT_SYMBOL(mini_isp_drv_write_calibration_data);
+#endif
+
+/**
+ *\brief Read Calibration Data
+ *\param info_param [In],
+ *\return Error code
+ */
+errcode mini_isp_drv_read_calibration_data(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_BULK_READ_CALIBRATION_DATA;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ mem_dum_hdr_cfg.start_addr = EEPROM_BUFFER_ADDRESS;
+ mem_dum_hdr_cfg.total_size = EEPROM_BUFFER_SIZE;
+ if (SPI_SHORT_LEN_MODE_READ_ENABLE)
+ mem_dum_hdr_cfg.block_size = SPI_BLOCK_LEN;
+ else
+ mem_dum_hdr_cfg.block_size = SPI_TX_BULK_SIZE;
+ mem_dum_hdr_cfg.dump_mode = T_MEMDUMP_CPURUN;
+
+ /*Copy it to transmission header*/
+ memcpy(&cmd_param_buf[0], (u8 *)&mem_dum_hdr_cfg,
+ sizeof(struct memmory_dump_hdr_info));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_read_calibration_data);
+
+/**
+ *\brief Read memory
+ *\param start_addr [In]starting address
+ *\param read_size [In]TotalReadSize
+ *\return Error code
+ */
+errcode mini_isp_drv_read_memory(u32 start_addr, u32 read_size)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_BULK_READ_MEMORY;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ mem_dum_hdr_cfg.start_addr = start_addr;/*0x0;//0x9DC00;*/
+ mem_dum_hdr_cfg.total_size = read_size;/*T_MEMSIZE;*/
+ mem_dum_hdr_cfg.block_size = SPI_TX_BULK_SIZE;
+ mem_dum_hdr_cfg.dump_mode = T_MEMDUMP_CPURUN;
+
+ /*Copy it to transmission header*/
+ memcpy(&cmd_param_buf[0], (u8 *)&mem_dum_hdr_cfg,
+ sizeof(struct memmory_dump_hdr_info));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_read_memory);
+
+/**
+ *\brief Get Depth rect A, B, invrect parameter
+ *\param 0 : depth rect A, B InvRect parameter structure array buffer
+ *\param 1 : transfer mode. (Default set to 0)
+ *\param 2 : bluk block size
+ *\return Error code
+ */
+errcode mini_isp_drv_write_depth_rectab_invrect(
+ struct depth_rectab_invrect_param *rect_param,
+ u8 trans_mode,
+ u32 block_size)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_BULK_WRITE_DEPTH_RECTAB_INVRECT; /*0x210C*/
+ u32 rect_set_num = 0;
+ u32 rectinfo_total_size = 0;
+ static struct isp_cmd_depth_rectab_invrect_info rect_info;
+
+ if (trans_mode == 0)
+ rect_set_num = 3;
+ else
+ rect_set_num = 1;
+
+ rectinfo_total_size
+ = rect_set_num*sizeof(struct depth_rectab_invrect_param);
+ /* copy to local static structure */
+ memcpy(&(rect_info.rect_param[0]), rect_param,
+ rectinfo_total_size);
+
+ rect_info.trans_mode = trans_mode;
+ rect_info.block_size = block_size;
+
+ err = ispctrl_if_mast_execute_cmd(opcode, (u8 *)&rect_info);
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_write_depth_rectab_invrect);
+
+/**
+ *\brief Reading Common Log
+ *\param stop [In], Stop to log flag
+ *\return Error code
+ */
+errcode mini_isp_drv_read_com_log(bool stop)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_BULK_READ_COMLOG;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ /* Wait semaphore*/
+ /*SEMAPHORE_LW_Wait( ISPCTRLIFMASTER_SEMAPHORE_LOGDUMP,*/
+ /* SEMAPHORE_WAITFOREVER );*/
+
+ /* Force to stop log*/
+ /*To inform isp to set log level as 0 for stoping log reight away*/
+ if (stop)
+ mini_isp_drv_set_com_log_level(0);
+
+ if (!stop_to_log) {
+ com_log_hdr_cfg.total_size = LEVEL_LOG_BUFFER_SIZE;
+ com_log_hdr_cfg.block_size = SPI_TX_BULK_SIZE;
+
+ /*Copy it to transmission header*/
+ memcpy(&cmd_param_buf[0], (u8 *)&com_log_hdr_cfg,
+ sizeof(struct common_log_hdr_info));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ /* Force to stop log*/
+ if (stop)
+ stop_to_log = true;
+ }
+
+ /* Post semaphore*/
+ /*SEMAPHORE_LW_Post( ISPCTRLIFMASTER_SEMAPHORE_LOGDUMP );*/
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_read_com_log);
+
+/*************************************************************************/
+/*camera profile cmd*/
+
+/**
+ *\brief Set Sensor Mode 0x300A
+ *\param sensor_on_off [In],sensor on/off
+ *\param scenario_id[In], Scenario ID
+ *\param mipi_tx_skew_enable[In], mipi tx skew on(1)/off(0)
+ *\param ae_weighting_table_index[In]
+ *\param merge_mode_enable[In]
+ *\ bit[0:3] :
+ *\ set 0 for normal mode
+ *\ set 1 for merge mode, only for image samller than 640X480 case
+ *\ set 2 for depth test pattern mode
+ *\ bit[4] :
+ *\ set 0 for turn on sensor by AP.
+ *\ set 1 for turn on sensor by AL6100.
+ *\return Error code
+ */
+errcode mini_isp_drv_set_sensor_mode(u8 sensor_on_off, u8 scenario_id,
+ u8 mipi_tx_skew_enable, u8 ae_weighting_table_index,
+ u8 merge_mode_enable)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ misp_info("%s no FSM", __func__);
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ /* Parameter 0 sensor on/off*/
+ cmd_param_buf[0] = sensor_on_off;
+ /* Parameter 1 Scenario ID*/
+ cmd_param_buf[1] = scenario_id;
+ /* Parameter 2 mipi tx skew on/off*/
+ cmd_param_buf[2] = mipi_tx_skew_enable;
+ /* Parameter 3 ae weighting table index*/
+ cmd_param_buf[3] = ae_weighting_table_index;
+ /* Parameter 4 merge_mode_enable*/
+ cmd_param_buf[4] = merge_mode_enable;
+ /* Parameter 5 reserve*/
+ cmd_param_buf[5] = 0;
+ /* Parameter 6 reserve*/
+ cmd_param_buf[6] = 0;
+
+ if (sensor_on_off == 0) {
+ /* Set Sensor Mode*/
+ err = ispctrl_if_mast_execute_cmd(ISPCMD_CAMERA_SET_SENSORMODE,
+ cmd_param_buf);
+
+ if (err != 0) {
+ misp_err("%s err, error code = %x",
+ __func__, err);
+ return err;
+ }
+ } else {
+ /* Set Sensor Mode*/
+ err = ispctrl_if_mast_execute_cmd(ISPCMD_CAMERA_SET_SENSORMODE,
+ cmd_param_buf);
+ if (err != 0) {
+ misp_err("%s err, error code = %x",
+ __func__, err);
+ return err;
+ }
+ }
+ return err;
+
+}
+EXPORT_SYMBOL(mini_isp_drv_set_sensor_mode);
+
+/*0x300B*/
+errcode mini_isp_drv_get_sensor_mode(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_GET_SENSORMODE; /*0x300B*/
+ err = ispctrl_if_mast_execute_cmd(opcode, rcv_cmd_param_buf);
+
+ return err;
+
+}
+EXPORT_SYMBOL(mini_isp_drv_get_sensor_mode);
+
+/*
+brief Set Output format 0x300D
+param1[In]depth_map_setting = resolution | opereation_mode
+resolution
+ 0: Disable depth function (Depth engine is disable)
+ 1: 180p
+ 2: 360p
+ 3: 720p
+ 4: 480p
+ 5: 400p
+opereation_mode,
+ 0x00: DEPTH_BIT_DG_ONLY
+ 0x10: DEPTH_BIT_DP
+ 0x40: DEPTH_BIT_HIGH_DISTORTION_RATE
+*/
+/*
+ param2 [In]depth_process_type_and_qlevel = process_type | quality level
+ B[0:2] process_type: value 0x6 as reserve
+ B[3:6] quality level: 0 ~ 15
+
+ param3 [In]
+ B[0:0] InvRect bypass: set 1 for enable InvRect bypass. set 0 disable.
+ (This function is incompatible with
+ mini_isp_drv_write_depth_rectab_invrect,
+ Do not configure this bit if set
+ mini_isp_drv_write_depth_rectab_invrect before)
+ return Error code
+*/
+errcode mini_isp_drv_set_output_format(
+ struct isp_cmd_set_output_format *output_format)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_SET_OUTPUTFORMAT; /*0x300D*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ memcpy(cmd_param_buf, output_format,
+ sizeof(struct isp_cmd_set_output_format));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+
+}
+EXPORT_SYMBOL(mini_isp_drv_set_output_format);
+
+/**
+ *\brief Set CP mode 0x300E
+ *\return Error code
+ */
+errcode mini_isp_drv_set_cp_mode(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ misp_info("%s no FSM", __func__);
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E))
+ mini_isp_e_to_a();
+
+ dev_global_variable->spi_low_speed_mode = 1;
+
+ err = ispctrl_if_mast_execute_cmd(ISPCMD_CAMERA_SET_CP_MODE,
+ NULL);
+ if (err != 0) {
+ dev_global_variable->spi_low_speed_mode = 0;
+ return err;
+ }
+
+ if (dev_global_variable->intf_status & INTF_SPI_READY)
+ mini_isp_a_to_e();
+ /*enter code here*/
+ mini_isp_cp_mode_suspend_flow();
+
+ if (err != 0) {
+ misp_err("%s err, error code = %x", __func__, err);
+ return err;
+ }
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_cp_mode);
+
+/**
+ *\brief Set AE statistics 0x300F
+ *\param ae_statistics [In], ae statistics
+ *\return Error code
+ */
+errcode mini_isp_drv_set_ae_statistics(
+ struct isp_cmd_ae_statistics *ae_statistics)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ misp_info("%s no FSM", __func__);
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, ae_statistics,
+ sizeof(struct isp_cmd_ae_statistics));
+ err = ispctrl_if_mast_execute_cmd(ISPCMD_CAMERA_SET_AE_STATISTICS,
+ cmd_param_buf);
+
+ if (err != 0)
+ misp_err("%s err, error code = %x", __func__, err);
+
+ return err;
+
+}
+EXPORT_SYMBOL(mini_isp_drv_set_ae_statistics);
+
+/**
+ *\brief Preview stream on/off 0x3010
+ *\param tx0_stream_on_off [In], Tx0 stream on/off
+ *\param tx1_stream_on_off [In], Tx1 stream on/off
+ *\return Error code
+ */
+errcode mini_isp_drv_preview_stream_on_off(u8 tx0_stream_on_off,
+ u8 tx1_stream_on_off)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ misp_info("%s no FSM", __func__);
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ /* Parameter 0 Tx0 stream on/off*/
+ cmd_param_buf[0] = tx0_stream_on_off;
+ /* Parameter 1 Tx1 stream on/off*/
+ cmd_param_buf[1] = tx1_stream_on_off;
+
+ err = ispctrl_if_mast_execute_cmd(ISPCMD_CAMERA_PREVIEWSTREAMONOFF,
+ cmd_param_buf);
+
+ if (err != 0)
+ misp_err("%s err, error code = %x", __func__, err);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_preview_stream_on_off);
+
+/**
+ *\brief Dual PD Y Calcualtion Weighting 0x3011
+ *\param isp_cmd_dual_pd_y_calculation_weightings [In],
+ dual PD Y calculation weightings
+ *\return Error code
+ */
+errcode mini_isp_drv_dual_pd_y_calculation_weighting(
+ struct isp_cmd_dual_pd_y_calculation_weightings *calculation_weighting)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_DUALPDYCALCULATIONWEIGHT; /*0x3010*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, calculation_weighting,
+ sizeof(struct isp_cmd_dual_pd_y_calculation_weightings));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_dual_pd_y_calculation_weighting);
+
+
+/**
+ *\brief LED power control 0x3012
+ *\param projector_control_param [In],
+ *\return Error code
+ */
+errcode mini_isp_drv_led_power_control(
+ struct isp_cmd_led_power_control *projector_control_param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_LED_POWERCONTROL; /*0x3012*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, projector_control_param,
+ sizeof(struct isp_cmd_led_power_control));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_led_power_control);
+
+/**
+ *\brief Active AE 0x3013
+ *\param active_ae_param [In],
+ *\return Error code
+ */
+errcode mini_isp_drv_active_ae(
+ struct isp_cmd_active_ae *active_ae_param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_ACTIVE_AE; /*0x3013*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, active_ae_param,
+ sizeof(struct isp_cmd_active_ae));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_active_ae);
+
+
+/**
+ *\brief ISP AE control mode on off 0x3014
+ *\param isp_ae_control_mode_on_off [In], 0:off 1:on
+ *\return Error code
+ */
+errcode mini_isp_drv_isp_ae_control_mode_on_off(u8 isp_ae_control_mode_on_off)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_ISP_AECONTROLONOFF; /*0x3014*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ /* Parameter 0 isp_ae_control_mode_on_off*/
+ cmd_param_buf[0] = isp_ae_control_mode_on_off;
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_isp_ae_control_mode_on_off);
+
+/**
+ *\brief Set Frame Rate Limite 0x3015
+ *\param set_frame_rate_param [In],
+ *\return Error code
+ */
+errcode mini_isp_drv_set_frame_rate_limits(
+ struct isp_cmd_frame_rate_limits *set_frame_rate_param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_SET_FRAMERATELIMITS; /*0x3015*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, set_frame_rate_param,
+ sizeof(struct isp_cmd_frame_rate_limits));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_frame_rate_limits);
+
+/**
+ *\brief Set period drop frame 0x3016
+ *\param set_period_drop_fram_param [In],
+ *\return Error code
+ */
+errcode mini_isp_drv_set_period_drop_frame(
+ struct isp_cmd_period_drop_frame *set_period_drop_fram_param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_SET_PERIODDROPFRAME; /*0x3016*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, set_period_drop_fram_param,
+ sizeof(struct isp_cmd_period_drop_frame));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_period_drop_frame);
+
+/**
+ *\brief Leave CP Mode
+ *\using set sensor mode opcode :0x300A
+ *\param sensor_on_off [In],sensor on/off
+ *\param scenario_id[In], Scenario ID
+ *\param mipi_tx_skew_enable[In], mipi tx skew on(1)/off(0)
+ *\param ae_weighting_table_index[In]
+ *\return Error code
+ */
+errcode mini_isp_drv_leave_cp_mode(u8 sensor_on_off, u8 scenario_id,
+ u8 mipi_tx_skew_enable, u8 ae_weighting_table_index,
+ u8 merge_mode_enable)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ int original_altek_spi_mode;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ original_altek_spi_mode = dev_global_variable->altek_spi_mode;
+
+ misp_info("%s no FSM", __func__);
+ /* Parameter 0 sensor on/off*/
+ cmd_param_buf[0] = sensor_on_off;
+ /* Parameter 1 Scenario ID*/
+ cmd_param_buf[1] = scenario_id;
+ /* Parameter 2 mipi tx skew on/off*/
+ cmd_param_buf[2] = mipi_tx_skew_enable;
+ /* Parameter 3 ae_weighting_table_index*/
+ cmd_param_buf[3] = ae_weighting_table_index;
+ /* Parameter 4 merge_mode_enable*/
+ cmd_param_buf[4] = merge_mode_enable;
+ /* Parameter 5 reserve*/
+ cmd_param_buf[5] = 0;
+ /* Parameter 6 reserve*/
+ cmd_param_buf[6] = 0;
+
+ if (sensor_on_off) {
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (original_altek_spi_mode == ALTEK_SPI_MODE_A))
+ mini_isp_a_to_e();
+ mini_isp_cp_mode_resume_flow();
+
+ dev_global_variable->spi_low_speed_mode = 0;
+
+ if (dev_global_variable->intf_status & INTF_SPI_READY)
+ mini_isp_e_to_a();
+
+ /* Set Sensor Mode*/
+ err = ispctrl_if_mast_execute_cmd(ISPCMD_CAMERA_SET_SENSORMODE,
+ cmd_param_buf);
+
+ if (err != 0) {
+ misp_err("mini_isp_drv_leave_cp_mode err, errcode = %x",
+ err);
+ return err;
+ }
+ } else {
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A))
+ mini_isp_a_to_e();
+
+ mini_isp_cp_mode_resume_flow();
+ dev_global_variable->spi_low_speed_mode = 0;
+
+ if (dev_global_variable->intf_status & INTF_SPI_READY)
+ mini_isp_e_to_a();
+ }
+
+ return err;
+
+}
+EXPORT_SYMBOL(mini_isp_drv_leave_cp_mode);
+
+/*************************************************************************/
+/*system cmd*/
+
+/**
+ *\brief Set ISP register 0x0100
+ *\param a_udStartAddr [In], Reg start addr
+ *\param reg_value [In], Reg value
+ *\return Error code
+ */
+errcode mini_isp_drv_set_isp_register(u32 reg_start_addr, u32 reg_value)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_SYSTEM_SET_ISPREGISTER; /*0x0100*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ /* Reg start addr*/
+ memcpy(&cmd_param_buf[0], ®_start_addr, 4);
+ /* Reg count*/
+ memcpy(&cmd_param_buf[4], ®_value, 4);
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_isp_register);
+
+
+/**
+ *\brief Set ISP register 0x0101
+ *\param a_udStartAddr [In], Reg start addr
+ *\param reg_count [In], Reg count
+ *\return Error code
+ */
+errcode mini_isp_drv_get_isp_register(u32 reg_start_addr, u32 reg_count)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_SYSTEM_GET_ISPREGISTER; /*0x0101*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ /* Reg start addr*/
+ memcpy(&cmd_param_buf[0], ®_start_addr, 4);
+ /* Reg count*/
+ memcpy(&cmd_param_buf[4], ®_count, 4);
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_get_isp_register);
+
+
+errcode mini_isp_drv_set_com_log_level(u32 log_level)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_SYSTEM_SET_COMLOGLEVEL;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ memcpy(cmd_param_buf, &log_level, sizeof(u32));
+
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_com_log_level);
+
+/*0x0015*/
+errcode mini_isp_drv_get_last_exec_cmd(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_SYSTEM_GET_STATUSOFLASTEXECUTEDCOMMAND; /*0x0015*/
+ err = ispctrl_if_mast_execute_cmd(opcode, rcv_cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_get_last_exec_cmd);
+
+/*0x0016*/
+errcode mini_isp_drv_get_err_code_cmd(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_SYSTEM_GET_ERRORCODE; /*0x0016*/
+ err = ispctrl_if_mast_execute_cmd(opcode, rcv_cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_get_err_code_cmd);
+
+/*0x0016*/
+errcode mini_isp_drv_get_err_code_cmd_in_irq(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ void *devdata = (void *)get_mini_isp_intf(MINIISP_I2C_TOP);
+ u8 param[64];
+ u32 al6100_errcode = 0;
+ /* Parameter size*/
+ /*get last ten error code and error status*/
+ u32 para_size = (sizeof(errcode))*10;
+
+ misp_err("%s - enter + + + + +", __func__);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(
+ devdata, ISPCMD_SYSTEM_GET_ERRORCODE, param, 0);
+ if (err != ERR_SUCCESS)
+ goto mast_sys_manage_cmd_get_error_code_command_end;
+
+ /* Get data from slave*/
+ err = ispctrl_mast_recv_response_from_slave(devdata, param,
+ para_size, false);
+ if (err != ERR_SUCCESS)
+ goto mast_sys_manage_cmd_get_error_code_command_end;
+
+ al6100_errcode = *(u32 *)param;
+ misp_err("%s last error code %#x", __func__, al6100_errcode);
+
+mast_sys_manage_cmd_get_error_code_command_end:
+
+ misp_err("%s - leave - - - - -", __func__);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_get_err_code_cmd_in_irq);
+
+
+/**
+ *\brief Get Chip test Report 0x010A
+ *\return Error code
+ */
+errcode mini_isp_drv_get_chip_test_report(void)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_SYSTEM_GET_CHIPTESTREPORT; /*0x010A*/
+ err = ispctrl_if_mast_execute_cmd(opcode, rcv_cmd_param_buf);
+
+ misp_info("%s chip test report: %x %x %x %x", __func__,
+ rcv_cmd_param_buf[0], rcv_cmd_param_buf[1],
+ rcv_cmd_param_buf[2], rcv_cmd_param_buf[3]);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_get_chip_test_report);
+
+/*************************************************************************/
+/*basic cmd*/
+
+/**
+ *\brief Set Depth 3A Information 0x10B9
+ *\param depth_3a_info [In], ISP Depth 3A parameter
+ *\return Error code
+ */
+errcode mini_isp_drv_set_depth_3a_info(
+ struct isp_cmd_depth_3a_info *depth_3a_info)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 *param;
+
+ misp_info("%s no FSM", __func__);
+ param = kzalloc(sizeof(struct isp_cmd_depth_3a_info), GFP_KERNEL);
+ if (param != NULL) {
+ /* Copy ISP Depth 3A Info*/
+ memcpy(param, depth_3a_info,
+ sizeof(struct isp_cmd_depth_3a_info));
+ } else {
+ misp_info("%s buf alloc fail!", __func__);
+ return err;
+ }
+
+ err = ispctrl_if_mast_execute_cmd(
+ ISPCMD_BASIC_SET_DEPTH_3A_INFO, param);
+
+ kfree(param);
+
+ if (err != 0)
+ misp_err("%s err, error code = %x", __func__, err);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_depth_3a_info);
+
+
+/**
+ *\brief Set Depth auto interleave mode 0x10BC
+ *\param depth_auto_interleave_param [In], ISP Depth auto interleave parameter
+ *\return Error code
+ */
+errcode mini_isp_drv_set_depth_auto_interleave_mode(
+ struct isp_cmd_depth_auto_interleave_param *depth_auto_interleave_param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_BASIC_SET_DEPTH_AUTO_INTERLEAVE_MODE; /*0x10BC*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, depth_auto_interleave_param,
+ sizeof(struct isp_cmd_depth_auto_interleave_param));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_depth_auto_interleave_mode);
+
+/**
+ *\brief Set Projector Interleave Mode with Depth Type 0x10BD
+ *\param projector_interleave_mode_with_depth_type [In],
+ *\ 0: depth active, 1: depth passive
+ *\return Error code
+ */
+errcode mini_isp_drv_projector_interleave_mode_depth_type(
+ u8 projector_interleave_mode_with_depth_type)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_BASIC_SET_INTERLEAVE_MODE_DEPTH_TYPE; /*0x10BD*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ cmd_param_buf[0] = projector_interleave_mode_with_depth_type;
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_projector_interleave_mode_depth_type);
+
+/**
+ *\brief Set Depth Polish LEVEL 0x10BE
+ *\param depth_polish_level [In], 0~100
+ *\return Error code
+ */
+errcode mini_isp_drv_set_depth_polish_level(u8 depth_polish_level)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_BASIC_SET_DEPTH_POLISH_LEVEL; /*0x10BE*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ cmd_param_buf[0] = depth_polish_level;
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_depth_polish_level);
+
+/**
+ *\brief Set Exposure Parameter 0x10BF
+ *\param exposure_param [In], ISP Exposure parameter
+ *\return Error code
+ */
+errcode mini_isp_drv_set_exposure_param(
+ struct isp_cmd_exposure_param *exposure_param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_BASIC_SET_EXPOSURE_PARAM; /*0x10BF*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, exposure_param,
+ sizeof(struct isp_cmd_exposure_param));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_exposure_param);
+
+/**
+ *\brief Set Exposure Parameter 0x10BF
+ *\param exposure_param [In], ISP Exposure parameter
+ *\return Error code
+ */
+errcode mini_isp_drv_set_depth_stream_size(
+ struct isp_cmd_depth_stream_size *depth_stream_size)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_BASIC_SET_DEPTH_STREAM_SIZE; /*0x10C0*/
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, depth_stream_size,
+ sizeof(struct isp_cmd_depth_stream_size));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_depth_stream_size);
+
+/*************************************************************************/
+/* cuurent no use
+u16 mini_isp_drv_read_spi_status(void)
+{
+ return ispctrl_if_mast_read_spi_status();
+}
+EXPORT_SYMBOL(mini_isp_drv_read_spi_status);
+*/
+/**
+ *\brief Write boot code and basic code
+ *\param None
+ *\return None
+ */
+int mini_isp_drv_boot_mini_isp(void)
+{
+ errcode err = ERR_SUCCESS;
+
+
+ /* Write boot code*/
+ err = mini_isp_drv_write_boot_code();
+ if (err != ERR_SUCCESS)
+ goto mini_isp_drv_boot_mini_isp_end;
+
+ udelay(500);
+
+ /* Write basic code*/
+ err = mini_isp_drv_write_basic_code();
+
+mini_isp_drv_boot_mini_isp_end:
+
+ return err;
+
+}
+EXPORT_SYMBOL(mini_isp_drv_boot_mini_isp);
+
+/**
+ *\brief Write boot code and basic code (short SPI Len)
+ *\param None
+ *\return None
+ */
+int mini_isp_drv_boot_mini_isp_shortlen(void)
+{
+ errcode err = ERR_SUCCESS;
+
+
+ /* Write boot code*/
+ err = mini_isp_drv_write_boot_code_shortlen();
+ if (err != ERR_SUCCESS)
+ goto mini_isp_drv_boot_mini_isp_shortlen_end;
+
+ udelay(500);
+
+ /* Write basic code*/
+ err = mini_isp_drv_write_basic_code_shortlen();
+
+mini_isp_drv_boot_mini_isp_shortlen_end:
+
+ return err;
+
+}
+EXPORT_SYMBOL(mini_isp_drv_boot_mini_isp_shortlen);
+
+/**
+ *\brief Open boot and FW file then write boot code and FW code
+ *\param None
+ *\return Error code
+ */
+errcode mini_isp_drv_load_fw(void)
+{
+ errcode err = ERR_SUCCESS;
+
+ misp_info("mini_isp_drv_setting(0) mini_isp_drv_load_fw start");
+ /* Clear load code ready flag;*/
+ load_code_ready = false;
+ /*spi isr task*/
+ /*g_ptload_code_task = kthread_run(load_code_task, NULL, */
+ /* "miniISP_loadcode_thread");*/
+
+ load_code_task(NULL);
+
+ misp_info("mini_isp_drv_setting(0) mini_isp_drv_load_fw X");
+ return err;
+
+}
+EXPORT_SYMBOL(mini_isp_drv_load_fw);
+
+/**
+ *\brief Wait miniISP event
+ *\param e [In], MINI_ISP_EVENT
+ *\return Errorcode
+ */
+int mini_isp_drv_wait_for_event(u16 e)
+{
+ return mini_isp_wait_for_event(e);
+}
+EXPORT_SYMBOL(mini_isp_drv_wait_for_event);
+
+
+/**
+ *\brief Set mode to miniISP
+ *\param mini_isp_mode [In], Select ISP MODE,
+ *0:(isp already in state A)normal case load FW directly,
+ *1 :(isp state inital in state E)set state E to state A
+ *2 :(isp already in state A)set state A to state E for debug ,
+ *3 :leave HW bypass
+ *4 :Get Chip ID
+ *else : None Support
+ *\return Errorcode
+ */
+errcode mini_isp_drv_setting(u16 mini_isp_mode)
+{
+ errcode err = ERR_SUCCESS;
+ struct misp_global_variable *dev_global_variable;
+
+ misp_info("%s no FSM", __func__);
+ dev_global_variable = get_mini_isp_global_variable();
+
+ if (mini_isp_mode == MINI_ISP_MODE_NORMAL) {
+ /*check bypass mode be set or not*/
+ /*if yes, leave bypass mode*/
+ mini_isp_check_and_leave_bypass_mode();
+ /*normal case load FW*/
+ err = mini_isp_drv_load_fw();
+
+ if (err != 0)
+ goto mini_isp_drv_setting_err;
+ } else if (mini_isp_mode == MINI_ISP_MODE_E2A) {
+ /*isp, inital in E,*/
+ mini_isp_e_to_a();
+ } else if (mini_isp_mode == MINI_ISP_MODE_A2E) {
+ mini_isp_a_to_e();
+ } else if (mini_isp_mode == MINI_ISP_MODE_LEAVE_BYPASS) {
+ /*check bypass mode be set or not*/
+ /*if yes, leave bypass mode*/
+ mini_isp_check_and_leave_bypass_mode();
+ if (err != 0)
+ goto mini_isp_drv_setting_err;
+ } else if (mini_isp_mode == MINI_ISP_MODE_GET_CHIP_ID) {
+ mini_isp_get_chip_id();
+ } else if (mini_isp_mode == MINI_ISP_MODE_CHIP_INIT) {
+ /*set some reg value to let it know should chang to A*/
+ /* For SPI_Nor, do not call this */
+ mini_isp_chip_init();
+ } else {
+ misp_err("%s err, none support setting", __func__);
+ }
+ return err;
+mini_isp_drv_setting_err:
+ misp_err("%s err, mini_isp_mode = %d, error code = %x", __func__,
+ mini_isp_mode, err);
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_setting);
+
+void mini_isp_drv_altek_i2c_mode_change(void)
+{
+ mini_isp_register_write(0xffea0100, 0x3201);
+ mini_isp_register_write(0xffea0104, 0x3201);
+}
+EXPORT_SYMBOL(mini_isp_drv_altek_i2c_mode_change);
+
+/**
+ *\brief set bypass mode
+ *\param bypass_mode [In], Select bypass MODE,
+ *\return Errorcode
+ */
+errcode mini_isp_drv_set_bypass_mode(u16 bypass_mode)
+{
+ errcode err = ERR_SUCCESS;
+ misp_info("%s no FSM", __func__);
+ /*check bypass mode be set or not*/
+ /*if yes, leave bypass mode*/
+ mini_isp_check_and_leave_bypass_mode();
+ /*Pure bypass by sensor*/
+ err = mini_isp_pure_bypass(bypass_mode);
+
+ if (err != 0)
+ goto mini_isp_drv_setting_err;
+
+ return err;
+mini_isp_drv_setting_err:
+ misp_err("%s err, bypass_mode = %d, error code = %x", __func__,
+ bypass_mode, err);
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_bypass_mode);
+
+/**
+ *\brief set Max exposure
+ *\param paramlength [In], Select bypass MODE,
+ *\return Errorcode
+ */
+errcode mini_isp_drv_set_max_exposure(
+ struct isp_cmd_exposure_param *max_exposure_info)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_SET_MAX_EXPOSURE;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ memcpy(cmd_param_buf, max_exposure_info,
+ sizeof(struct isp_cmd_exposure_param));
+
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_max_exposure);
+
+/**
+ *\brief set target mean
+ *\param paramlength [In], Select bypass MODE,
+ *\return Errorcode
+ */
+errcode mini_isp_drv_set_target_mean(
+ struct isp_cmd_target_mean *target_mean_info)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_SET_AE_TARGET_MEAN;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ memcpy(cmd_param_buf, target_mean_info,
+ sizeof(struct isp_cmd_target_mean));
+
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_target_mean);
+
+errcode mini_isp_drv_frame_sync_control(
+ struct isp_cmd_frame_sync_control *frame_sync_control_param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_FRAME_SYNC_CONTROL;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ memcpy(cmd_param_buf, frame_sync_control_param,
+ sizeof(struct isp_cmd_frame_sync_control));
+
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_frame_sync_control);
+
+errcode mini_isp_drv_set_shot_mode(
+ struct isp_cmd_set_shot_mode *set_shot_mode_param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_SET_SHOT_MODE;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ memcpy(cmd_param_buf, set_shot_mode_param,
+ sizeof(struct isp_cmd_set_shot_mode));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_shot_mode);
+
+errcode mini_isp_drv_lighting_ctrl(
+ struct isp_cmd_lighting_ctrl *lighting_ctrl)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_LIGHTING_CTRL;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ memcpy(cmd_param_buf, lighting_ctrl,
+ sizeof(struct isp_cmd_lighting_ctrl));
+
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_lighting_ctrl);
+
+errcode mini_isp_drv_set_min_exposure(
+ struct isp_cmd_exposure_param *min_exposure_info)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_SET_MIN_EXPOSURE;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ memcpy(cmd_param_buf, min_exposure_info,
+ sizeof(struct isp_cmd_exposure_param));
+
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_min_exposure);
+
+errcode mini_isp_drv_set_max_exposure_slope(
+ struct isp_cmd_max_exposure_slope *max_exposure_slope_info)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_SET_MAX_EXPOSURE_SLOPE;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+
+ memcpy(cmd_param_buf, max_exposure_slope_info,
+ sizeof(struct isp_cmd_max_exposure_slope));
+
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_set_max_exposure_slope);
+
+/**
+ *\brief Set Sensor Mode 0x301C
+ *\param en_update
+ *\ [In], en_update = update short distance | update compensation
+ *\bit[0:3] = update compensation
+ *\bit[4:7] = update short distance
+ *\param short_distance [In], short distance
+ *\param compensation [In], compensation value, Ground mode only
+ *\return Error code
+ */
+
+errcode mini_isp_drv_depth_compensation(
+ struct isp_cmd_depth_compensation_param *depth_compensation_param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_DEPTH_COMPENSATION;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, depth_compensation_param,
+ sizeof(struct isp_cmd_depth_compensation_param));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_depth_compensation);
+
+/**
+ *\brief Set Sensor Mode 0x301D
+ *\param cycleLen
+ *\ [In], en_update = update short distance | update global shift
+ *\param depth_triggerBitField
+ *\ [In], bit 0 : 1st frame, bit 1 : 2nd frame
+ *\param depthoutput_triggerBitField
+ *\ [In], bit 0 : 1st frame, bit 1 : 2nd frame
+ *\return Error code
+ */
+errcode mini_isp_drv_cycle_trigger_depth_process(
+ struct isp_cmd_cycle_trigger_depth_process *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_TRIGGER_DEPTH_PROCESS_CTRL;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, param, sizeof(
+ struct isp_cmd_cycle_trigger_depth_process));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_cycle_trigger_depth_process);
+
+/**
+ *\brief Set led first power on delay time 0x3020
+ *\param delay_ms [In], delay time (mini second)
+ *\return Error code
+ */
+errcode mini_isp_drv_led_active_delay(u32 delay_ms)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_SET_LED_ACTIVE_DELAY;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, &delay_ms, sizeof(u32));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_led_active_delay);
+
+
+/**
+ *\brief Set isp control led level 0x3021
+ *\param AL6100 control Led Level [In], 1: on, 0: off
+ *\return Error code
+ */
+errcode mini_isp_drv_isp_control_led_level(u8 on)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Op code*/
+ u16 opcode = ISPCMD_CAMERA_ISPLEDLEVELCONTROLONOFF;
+ u8 cmd_param_buf[T_SPI_CMD_LENGTH];
+
+ memset(cmd_param_buf, 0, T_SPI_CMD_LENGTH);
+ memcpy(cmd_param_buf, &on, sizeof(u8));
+
+ err = ispctrl_if_mast_execute_cmd(opcode, cmd_param_buf);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_isp_control_led_level);
+
+/**
+ *\brief Get isp thermal 0x0115
+ *\param None
+ *\return Error code
+ */
+errcode mini_isp_drv_get_chip_thermal(u16 *thermal_val)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u8 recv_buf[T_SPI_CMD_LENGTH];
+
+ /* Op code*/
+ u16 opcode = ISPCMD_SYSTEM_GET_CHIP_THERMAL;
+
+ memset(recv_buf, 0, T_SPI_CMD_LENGTH);
+
+ /* recv buffer must use local buffer, can not be global or static. */
+ err = ispctrl_if_mast_execute_cmd(opcode, recv_buf);
+ misp_info("%s - 0x%x", __func__, *(u16 *)recv_buf);
+
+ memcpy((u8 *)thermal_val, recv_buf, 2);
+
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_drv_get_chip_thermal);
+
+/******Private Function******/
+
+static int load_code_task(void *data)
+{
+ /* Error code*/
+ errcode err = ERR_SUCCESS;
+
+ misp_info("misp_load_fw start");
+
+ /* Reset mini-isp low for at least 200us, release to high for 20ms*/
+ /*mini_isp_reset();*/
+
+#if ENABLE_LINUX_FW_LOADER
+ /* Write boot code and basic code*/
+ if (!SPI_SHORT_LEN_MODE)
+ err = mini_isp_drv_boot_mini_isp();
+ /* SPI "Write" NO short Len limitation */
+ else if (!SPI_SHORT_LEN_MODE_WRITE_ENABLE)
+ err = mini_isp_drv_boot_mini_isp();
+ else
+ err = mini_isp_drv_boot_mini_isp_shortlen(); /* short SPI Len */
+ if (err != ERR_SUCCESS)
+ goto load_code_task_end;
+#else
+ /* Open boot file and FW file*/
+ err = mini_isp_drv_open(BOOT_FILE_LOCATION,
+ BASIC_FILE_LOCATION,
+ ADVANCED_FILE_LOCATION,
+ SCENARIO_TABLE_FILE_LOCATION,
+ HDR_QMERGE_DATA_FILE_LOCATION,
+ IRP0_QMERGE_DATA_FILE_LOCATION,
+ IRP1_QMERGE_DATA_FILE_LOCATION,
+ PP_MAP_FILE_LOCATION,
+ DPETH_QMERGE_DATA_FILE_LOCATION);
+ if (err != ERR_SUCCESS)
+ goto load_code_task_end;
+
+ /* Write boot code and basic code*/
+ if (!SPI_SHORT_LEN_MODE)
+ err = mini_isp_drv_boot_mini_isp();
+ /* SPI "Write" NO short Len limitation*/
+ else if (!SPI_SHORT_LEN_MODE_WRITE_ENABLE)
+ err = mini_isp_drv_boot_mini_isp();
+ else
+ err = mini_isp_drv_boot_mini_isp_shortlen(); /* short SPI Len*/
+ if (err != ERR_SUCCESS)
+ goto load_code_task_end;
+#endif
+ /* Set load code ready flag*/
+ load_code_ready = true;
+
+load_code_task_end:
+
+ return (int)err;
+}
+
+#if (!ENABLE_LINUX_FW_LOADER)
+static u16 calibration_check_sum(u8 *input_buffer_addr, u16 input_buffer_size)
+{
+ u16 i;
+ u32 sum = 0;
+ u16 sumvalue;
+
+ /* calculating unit is 2 bytes*/
+ for (i = 0; i < input_buffer_size; i++) {
+ if (0 == (i % 2))
+ sum += input_buffer_addr[i];
+ else
+ sum += (input_buffer_addr[i] << 8);
+ }
+
+ /* Do 2's complement*/
+ sumvalue = (u16)(65536 - (sum & 0x0000FFFF)); /*get 2's complement*/
+
+ return sumvalue;
+}
+#endif
+
+
+
+
+
+/******End Of File******/
diff --git a/drivers/media/platform/altek/miniisp_ctrl_intf.c b/drivers/media/platform/altek/miniisp_ctrl_intf.c
new file mode 100755
index 0000000..4c00055
--- /dev/null
+++ b/drivers/media/platform/altek/miniisp_ctrl_intf.c
@@ -0,0 +1,129 @@
+/*
+ * File: miniisp_ctrl_intf.c
+ * Description: mini ISP control cmd interface.
+ * use for handling the control cmds instead of debug cmds
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 018/08/28 PhenixChen; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/******Include File******/
+#include <miniISP/miniISP_ioctl.h>
+#include <linux/uaccess.h> /* copy_*_user() */
+#include "include/miniisp.h"
+#include "include/miniisp_ctrl.h" /* mini_isp_drv_setting() */
+#include "include/isp_camera_cmd.h"
+#include "include/ispctrl_if_master.h" /* ispctrl_if_mast_execute_cmd() */
+#include "include/miniisp_customer_define.h"
+#include "include/miniisp_ctrl_intf.h"
+
+/******Private Constant Definition******/
+#define MINI_ISP_LOG_TAG "[miniisp_ctrl_intf]"
+#define MAX_DATA_SIZE (64 * 1024)
+
+/******Private Function Prototype******/
+
+/******Public Function Prototype******/
+
+/******Private Global Variable******/
+
+
+
+long handle_ControlFlowCmd(unsigned int cmd, unsigned long arg)
+{
+ long retval = 0;
+ struct miniISP_cmd_config *config = NULL;
+ u8 *param = NULL;
+
+ misp_info("%s - enter", __func__);
+
+ /* step1: allocate & receive cmd struct from user space */
+ config = kzalloc(sizeof(struct miniISP_cmd_config), GFP_KERNEL);
+ if (NULL == config) {
+ retval = -ENOMEM;
+ goto done;
+ }
+ if (copy_from_user(config, (void __user *)arg,
+ sizeof(struct miniISP_cmd_config))) {
+ retval = -EFAULT;
+ goto done;
+ }
+
+ /* step2: allocate & receive cmd parameter from user space if needed*/
+ if ((config->size > 0) && (config->size < MAX_DATA_SIZE)) {
+ param = kzalloc(config->size, GFP_KERNEL);
+ if (NULL == param) {
+ retval = -ENOMEM;
+ goto done;
+ }
+ if (copy_from_user((void *)param,
+ (void __user *)(config->param), config->size)) {
+ retval = -EFAULT;
+ goto done;
+ }
+ }
+
+ switch (cmd) {
+ case IOCTL_ISP_LOAD_FW:
+ misp_info("%s - IOCTL_ISP_LOAD_FW", __func__);
+ /* open boot and FW file then write boot code and FW code */
+ mini_isp_poweron();
+ mini_isp_drv_setting(MINI_ISP_MODE_GET_CHIP_ID);
+#ifndef AL6100_SPI_NOR
+ /* if boot form SPI NOR, do not call this */
+ mini_isp_drv_setting(MINI_ISP_MODE_CHIP_INIT);
+#endif
+ mini_isp_drv_setting(MINI_ISP_MODE_E2A);
+ mini_isp_drv_setting(MINI_ISP_MODE_NORMAL);
+ break;
+ case IOCTL_ISP_PURE_BYPASS:
+ misp_info("%s - IOCTL_ISP_PURE_BYPASS", __func__);
+ mini_isp_poweron();
+ mini_isp_drv_setting(MINI_ISP_MODE_GET_CHIP_ID);
+ mini_isp_drv_set_bypass_mode(1);
+ break;
+ case IOCTL_ISP_CTRL_CMD:
+ if (param == NULL) {
+ misp_info("%s - cmd parameter is NULL", __func__);
+ break;
+ }
+ retval = ispctrl_if_mast_execute_cmd(config->opcode, param);
+ break;
+ case IOCTL_ISP_DEINIT:
+ misp_info("%s - IOCTL_ISP_DEINIT", __func__);
+ mini_isp_poweroff();
+ break;
+ default:
+ misp_info("%s - UNKNOWN CMD[0x%x]", __func__, cmd);
+ retval = -ENOTTY;
+ break;
+ }
+
+done:
+ if (param != NULL)
+ kfree(param);
+ if (config != NULL)
+ kfree(config);
+
+ misp_info("%s - leave", __func__);
+ return retval;
+}
diff --git a/drivers/media/platform/altek/miniisp_customer_define.c b/drivers/media/platform/altek/miniisp_customer_define.c
new file mode 100755
index 0000000..04e3055
--- /dev/null
+++ b/drivers/media/platform/altek/miniisp_customer_define.c
@@ -0,0 +1,399 @@
+/*
+ * File: miniisp_customer_define.c
+ * Description: Mini ISP sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2017/03/14 LouisWang; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/******Include File******/
+/* Linux headers*/
+#include <linux/delay.h>
+#include <linux/of_gpio.h>
+
+#include "include/miniisp_customer_define.h"
+#include "include/miniisp.h"
+#include "include/miniisp_ctrl.h"
+
+#define MINI_ISP_LOG_TAG "[miniisp_customer_define]"
+
+
+extern void mini_isp_poweron(void)
+{
+ errcode ret = 0;
+ void *devdata;
+ struct misp_global_variable *dev_global_variable;
+
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+ dev_global_variable = get_mini_isp_global_variable();
+ misp_info("%s no FSM", __func__);
+ misp_err("[miniISP]mini_isp_poweron");
+
+#if (ISR_MECHANISM == INTERRUPT_METHOD)
+ if (IRQ_GPIO != NULL) {
+ ret = request_threaded_irq(
+ gpio_to_irq(dev_global_variable->irq_gpio),
+ NULL, mini_isp_irq,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ "mini_isp", devdata);
+ }
+
+ if (ret != 0) {
+ misp_err("%s err, %x", __func__, ret);
+ return;
+ }
+
+ misp_info("%s request_threaded_irq succeed, irq_gpio: %d, irg_num %d"
+ , __func__, dev_global_variable->irq_gpio,
+ gpio_to_irq(dev_global_variable->irq_gpio));
+#endif
+
+ if (RESET_GPIO != NULL) {
+ gpio_direction_output(dev_global_variable->reset_gpio, 0);
+ gpio_set_value(dev_global_variable->reset_gpio, 0);
+ msleep(20);
+ }
+ if (VCC1_GPIO != NULL)
+ gpio_set_value(dev_global_variable->vcc1_gpio, 0);
+ if (VCC2_GPIO != NULL)
+ gpio_set_value(dev_global_variable->vcc2_gpio, 0);
+ if (VCC3_GPIO != NULL)
+ gpio_set_value(dev_global_variable->vcc3_gpio, 0);
+
+ msleep(20);
+
+ if (VCC1_GPIO != NULL)
+ gpio_set_value(dev_global_variable->vcc1_gpio, 1);
+ if (VCC2_GPIO != NULL)
+ gpio_set_value(dev_global_variable->vcc2_gpio, 1);
+ if (VCC3_GPIO != NULL)
+ gpio_set_value(dev_global_variable->vcc3_gpio, 1);
+
+ msleep(20);
+ if (ISP_CLK != NULL)
+ if (clk_prepare_enable(dev_global_variable->isp_clk) < 0)
+ misp_err("mini_isp_poweron clk_prepare_enable failed");
+
+ if (RESET_GPIO != NULL) {
+ gpio_direction_output(dev_global_variable->reset_gpio, 1);
+ gpio_set_value(dev_global_variable->reset_gpio, 1);
+ msleep(20);
+ }
+
+ if (RESET_GPIO != NULL)
+ misp_err("%s -reset_gpio gpio_get_value = %d", __func__,
+ gpio_get_value(dev_global_variable->reset_gpio));
+ if (VCC1_GPIO != NULL)
+ misp_err("%s -vcc1_gpio gpio_get_value = %d", __func__,
+ gpio_get_value(dev_global_variable->vcc1_gpio));
+ if (VCC2_GPIO != NULL)
+ misp_err("%s -vcc2_gpio gpio_get_value = %d", __func__,
+ gpio_get_value(dev_global_variable->vcc2_gpio));
+ if (VCC3_GPIO != NULL)
+ misp_err("%s -vcc3_gpio gpio_get_value = %d", __func__,
+ gpio_get_value(dev_global_variable->vcc3_gpio));
+
+ misp_err("%s - leave", __func__);
+
+ if (ret != 0) {
+ misp_err("%s err, %x", __func__, ret);
+ return;
+ }
+
+ dev_global_variable->before_booting = 1;
+ dev_global_variable->be_set_to_bypass = 0;
+}
+EXPORT_SYMBOL(mini_isp_poweron);
+
+extern void mini_isp_poweroff(void)
+{
+ int ret = 0;
+ struct misp_global_variable *dev_global_variable;
+ void *devdata;
+
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+ dev_global_variable = get_mini_isp_global_variable();
+
+ misp_info("%s no FSM", __func__);
+ misp_err("[miniISP]mini_isp_poweroff");
+
+ if (RESET_GPIO != NULL)
+ gpio_set_value(dev_global_variable->reset_gpio, 0);
+ msleep(20);
+ if (VCC1_GPIO != NULL)
+ gpio_set_value(dev_global_variable->vcc1_gpio, 0);
+ if (VCC2_GPIO != NULL)
+ gpio_set_value(dev_global_variable->vcc2_gpio, 0);
+ if (VCC3_GPIO != NULL)
+ gpio_set_value(dev_global_variable->vcc3_gpio, 0);
+ if (ISP_CLK != NULL)
+ clk_disable_unprepare(dev_global_variable->isp_clk);
+ msleep(20);
+
+#if (ISR_MECHANISM == INTERRUPT_METHOD)
+ if (IRQ_GPIO != NULL)
+ free_irq(gpio_to_irq(dev_global_variable->irq_gpio), devdata);
+
+#endif
+
+ if (ret != 0) {
+ misp_err("%s err, %x", __func__, ret);
+ return;
+ }
+
+ dev_global_variable->be_set_to_bypass = 0;
+ dev_global_variable->before_booting = 1;
+
+ misp_info("%s - X", __func__);
+}
+EXPORT_SYMBOL(mini_isp_poweroff);
+
+extern void mini_isp_eeprom_wpon(void)
+{
+ struct misp_global_variable *dev_global_variable;
+
+ misp_err("[miniISP]mini_isp_eeprom_wpon");
+ if (WP_GPIO != NULL) {
+ dev_global_variable = get_mini_isp_global_variable();
+ gpio_set_value(dev_global_variable->wp_gpio, 1);
+ }
+ misp_info("%s - X", __func__);
+}
+EXPORT_SYMBOL(mini_isp_eeprom_wpon);
+
+extern void mini_isp_eeprom_wpoff(void)
+{
+ struct misp_global_variable *dev_global_variable;
+
+ misp_err("[miniISP]mini_isp_eeprom_wpoff");
+ if (WP_GPIO != NULL) {
+ dev_global_variable = get_mini_isp_global_variable();
+ gpio_set_value(dev_global_variable->wp_gpio, 0);
+ }
+ misp_info("%s - X", __func__);
+}
+EXPORT_SYMBOL(mini_isp_eeprom_wpoff);
+
+extern int mini_isp_gpio_init(struct device *dev,
+ struct misp_data *drv_data,
+ struct misp_global_variable *drv_global_variable)
+{
+ int ret = 0;
+
+ if (VCC1_GPIO != NULL) {
+ drv_global_variable->vcc1_gpio =
+ of_get_named_gpio(dev->of_node, VCC1_GPIO, 0);
+ misp_info("%s - probe vcc1-gpios = %d", __func__,
+ drv_global_variable->vcc1_gpio);
+
+ ret = devm_gpio_request(dev,
+ drv_global_variable->vcc1_gpio, VCC1_GPIO);
+ if (ret) {
+ misp_err("%s -step 4. request vcc1-gpio error",
+ __func__);
+ goto err_gpio1_config;
+ }
+
+ gpio_direction_output(drv_global_variable->vcc1_gpio, 1);
+ msleep(20);
+ gpio_set_value(drv_global_variable->vcc1_gpio, 1);
+ msleep(20);
+ }
+
+ if (VCC2_GPIO != NULL) {
+ drv_global_variable->vcc2_gpio = of_get_named_gpio(
+ dev->of_node, VCC2_GPIO, 0);
+ misp_info("%s - probe vcc2-gpios = %d", __func__,
+ drv_global_variable->vcc2_gpio);
+
+ ret = devm_gpio_request(dev,
+ drv_global_variable->vcc2_gpio, VCC2_GPIO);
+ if (ret) {
+ misp_err("%s -step 4. request vcc2-gpios error",
+ __func__);
+ goto err_gpio2_config;
+ }
+
+ gpio_direction_output(drv_global_variable->vcc2_gpio, 1);
+ msleep(20);
+ gpio_set_value(drv_global_variable->vcc2_gpio, 1);
+ msleep(20);
+ }
+
+ if (VCC3_GPIO != NULL) {
+ drv_global_variable->vcc3_gpio = of_get_named_gpio(
+ dev->of_node, VCC3_GPIO, 0);
+ misp_err("%s - probe vcc3-gpios = %d", __func__,
+ drv_global_variable->vcc3_gpio);
+
+ ret = devm_gpio_request(dev,
+ drv_global_variable->vcc3_gpio, VCC3_GPIO);
+ if (ret) {
+ misp_err("%s -step 4. request vcc3-gpio error",
+ __func__);
+ goto err_gpio_config;
+ }
+
+ gpio_direction_output(drv_global_variable->vcc3_gpio, 1);
+ gpio_set_value(drv_global_variable->vcc3_gpio, 1);
+ msleep(20);
+
+ }
+
+ if (WP_GPIO != NULL) {
+ drv_global_variable->wp_gpio = of_get_named_gpio(
+ dev->of_node, WP_GPIO, 0);
+ misp_info("%s - probe wp-gpios = %d", __func__,
+ drv_global_variable->wp_gpio);
+
+ ret = devm_gpio_request(dev,
+ drv_global_variable->wp_gpio, WP_GPIO);
+ if (ret) {
+ misp_err("%s -step 4. request wp-gpio error",
+ __func__);
+ goto err_gpio_config;
+ }
+
+ gpio_direction_output(drv_global_variable->wp_gpio, 1);
+ gpio_set_value(drv_global_variable->wp_gpio, 1);
+ msleep(20);
+
+ }
+
+ if (ISP_CLK != NULL) {
+ drv_global_variable->isp_clk = devm_clk_get(dev,
+ ISP_CLK);
+ misp_err("clk_ptr = %p", drv_global_variable->isp_clk);
+ ret = clk_set_rate(drv_global_variable->isp_clk, 19200000L);
+ if (ret < 0)
+ misp_err("clk_set_rate failed, not fatal\n");
+
+ misp_err("clk_get_rate %ld\n", clk_get_rate(
+ drv_global_variable->isp_clk));
+ ret = clk_prepare_enable(drv_global_variable->isp_clk);
+ if (ret < 0) {
+ misp_err("clk_prepare_enable failed\n");
+ goto err_clk_config;
+ }
+ msleep(20);
+ }
+
+ if (RESET_GPIO != NULL) {
+ drv_global_variable->reset_gpio =
+ of_get_named_gpio(dev->of_node, RESET_GPIO, 0);
+ misp_info("%s - probe reset_gpio = %d", __func__,
+ drv_global_variable->reset_gpio);
+
+ ret = devm_gpio_request(dev,
+ drv_global_variable->reset_gpio, RESET_GPIO);
+ if (ret) {
+ misp_err("%s -step 4. request reset gpio error",
+ __func__);
+ goto err_reset_config;
+ }
+
+ gpio_direction_output(drv_global_variable->reset_gpio, 0);
+ gpio_set_value(drv_global_variable->reset_gpio, 0);
+ msleep(20);
+
+ }
+
+#if (ISR_MECHANISM == INTERRUPT_METHOD)
+ if (IRQ_GPIO != NULL) {
+
+ drv_global_variable->irq_gpio =
+ of_get_named_gpio(dev->of_node, IRQ_GPIO, 0);
+
+ misp_info("%s - probe irq_gpio = %d",
+ __func__, drv_global_variable->irq_gpio);
+
+ ret = gpio_request(drv_global_variable->irq_gpio, IRQ_GPIO);
+ if (ret) {
+ misp_err("%s -step 4. request irq gpio error",
+ __func__);
+ goto err_irq_config;
+ }
+ gpio_direction_input(drv_global_variable->irq_gpio);
+
+ drv_global_variable->irq_num =
+ gpio_to_irq(drv_global_variable->irq_gpio);
+
+ misp_err("%s - probe spi->irq = %d %d ",
+ __func__, drv_global_variable->irq_num,
+ gpio_to_irq(drv_global_variable->irq_gpio));
+
+ ret = request_threaded_irq(
+ drv_global_variable->irq_num, NULL, mini_isp_irq,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT, "mini_isp", drv_data);
+
+ if (ret) {
+ misp_err("%s - step4. probe - request irq error",
+ __func__);
+ goto err_dev_attr;
+ }
+ misp_info("%s - step4 done. irq number:%d", __func__,
+ drv_global_variable->irq_num);
+
+ free_irq(drv_global_variable->irq_num, drv_data);
+ }
+#endif
+
+ /*step 5:other additional config*/
+
+ misp_info("%s - step5 done", __func__);
+
+ if (RESET_GPIO != NULL) {
+ gpio_direction_output(drv_global_variable->reset_gpio, 1);
+ gpio_set_value(drv_global_variable->reset_gpio, 1);
+ msleep(20);
+ }
+
+ return ret;
+
+#if (ISR_MECHANISM == INTERRUPT_METHOD)
+err_dev_attr:
+ free_irq(drv_global_variable->irq_num, drv_data);
+
+err_irq_config:
+ if (IRQ_GPIO != NULL)
+ gpio_free(drv_global_variable->irq_gpio);
+#endif
+
+err_reset_config:
+ if (RESET_GPIO != NULL)
+ gpio_free(drv_global_variable->reset_gpio);
+
+err_clk_config:
+ if (ISP_CLK != NULL)
+ clk_disable_unprepare(drv_global_variable->isp_clk);
+
+err_gpio_config:
+ if (VCC2_GPIO != NULL)
+ gpio_free(drv_global_variable->vcc2_gpio);
+err_gpio2_config:
+ if (VCC1_GPIO != NULL)
+ gpio_free(drv_global_variable->vcc1_gpio);
+
+err_gpio1_config:
+
+ return ret;
+}
diff --git a/drivers/media/platform/altek/miniisp_debug_if.c b/drivers/media/platform/altek/miniisp_debug_if.c
new file mode 100755
index 0000000..7d7363c
--- /dev/null
+++ b/drivers/media/platform/altek/miniisp_debug_if.c
@@ -0,0 +1,647 @@
+/*
+ * File: miniisp_debug_if.c
+ * Description: mini ISP debug daemon interface
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2017/04/20; PhenixChen; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/******Include File******/
+#include "include/miniisp.h"
+#include "include/miniisp_debug_if.h"
+#include "include/miniisp_customer_define.h"
+
+#include <linux/uaccess.h> /* copy_*_user() */
+#include <linux/fs.h> /* chrdev, struct file_operations */
+#include <linux/cdev.h> /* cdev_add()/cdev_del() */
+#include <linux/mm.h>
+#include <linux/delay.h> /*msleep()*/
+
+#if EN_605_IOCTRL_INTF
+#include "include/miniisp_ctrl_intf.h"
+#include <miniISP/miniISP_ioctl.h>
+#endif
+
+/******Private Constant Definition******/
+#define MINI_ISP_LOG_TAG "[miniisp_debug_if]"
+#define MAX_RW_SIZE (64 * 1024)
+
+/******Private Function Prototype******/
+static int miniisp_dev_open(struct inode*, struct file*);
+static int miniisp_dev_release(struct inode *inode, struct file *filp);
+static long miniisp_dev_ioctl(struct file *filp,
+ unsigned int cmd, unsigned long arg);
+static int miniisp_dev_map(struct file *filp, struct vm_area_struct *vma);
+static u32 miniisp_debugif_memory_read(u32 start_addr, u32 len);
+static u32 miniisp_debugif_RegBulk_read(u32 start_addr, u32 end_reg_addr);
+static long miniisp_debugif_get_mem(u32 len);
+static long miniisp_debugif_munmap_done(void);
+static long handle_RegCmd(unsigned int cmd, unsigned long arg);
+static long handle_MemCmd(unsigned int cmd, unsigned long arg);
+static long handle_BulkCmd(unsigned int cmd, unsigned long arg);
+
+/******Public Function Prototype******/
+struct device *miniisp_chdev_create(struct class *mini_isp_class);
+
+/******Private Global Variable******/
+static int miniisp_dev_major;
+static int miniisp_dev_minor;
+static struct cdev *miniisp_dev_cdev;
+static unsigned long *allocated_memmory_align;
+static unsigned long *allocated_memmory;
+static unsigned long allocated_size;
+static u8 During_Refresh_Module;
+
+struct dbg_drvdata {
+ /* u32 val; */
+ u32 reg_tbl[4]; /* for Test */
+ /* unsigned char mem[16]; */
+ rwlock_t lock;
+};
+
+static const struct file_operations miniisp_dev_fops = {
+ .owner = THIS_MODULE,
+ .open = miniisp_dev_open,
+ .release = miniisp_dev_release,
+ .mmap = miniisp_dev_map,
+ /* .read = dev_read, */
+ /* .write = dev_write, */
+
+ .unlocked_ioctl = miniisp_dev_ioctl,
+#if EN_605_IOCTRL_INTF
+ .compat_ioctl = miniisp_dev_ioctl,
+#endif
+};
+
+static long miniisp_debugif_munmap_done(void)
+{
+ unsigned long virt_addr;
+
+ misp_err("%s:called", __func__);
+ if (allocated_memmory_align) {
+ for (virt_addr = (unsigned long)allocated_memmory_align;
+ virt_addr < (unsigned long)allocated_memmory_align
+ + allocated_size; virt_addr += PAGE_SIZE)
+ ClearPageReserved(virt_to_page(virt_addr));
+ kfree(allocated_memmory);
+ allocated_memmory = NULL;
+ allocated_memmory_align = NULL;
+ allocated_size = 0;
+ }
+ return 0;
+}
+
+static long miniisp_debugif_get_mem(u32 len)
+{
+ long retval = 0;
+ unsigned long virt_addr;
+ unsigned long mask = ~(PAGE_SIZE - 1);
+
+ /* page-aligned memory size */
+ allocated_size = (len + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+ misp_err("%s:memory length = %u, page-aligned memory size = %lu",
+ __func__, len, allocated_size);
+
+ /* allocate page-aligned memory */
+ allocated_memmory = kzalloc(allocated_size + PAGE_SIZE - 1, GFP_KERNEL);
+ if (!allocated_memmory) {
+ retval = -ENOMEM;
+ misp_err("%s:kzalloc failed", __func__);
+ goto done;
+ }
+ /* printf指標的位址通常使用%x,但它的寬度是 32-bit,
+ 無法在 64-bit 環境下顯示正確結果,需改用%p */
+ misp_err("%s:allocated_memmory before align = %p",
+ __func__, allocated_memmory);
+ allocated_memmory_align = (unsigned long *)
+ (((unsigned long)allocated_memmory + PAGE_SIZE - 1) & mask);
+ misp_err("%s:allocated_memmory after align = %p",
+ __func__, allocated_memmory_align);
+ misp_err("%s:kzalloc succeed, total allocated_size = %lu",
+ __func__, allocated_size + PAGE_SIZE - 1);
+
+ /* reserve all pages to make them remapable */
+ for (virt_addr = (unsigned long)allocated_memmory_align;
+ virt_addr < ((unsigned long)allocated_memmory_align
+ + allocated_size);
+ virt_addr += PAGE_SIZE)
+ SetPageReserved(virt_to_page(virt_addr));
+done:
+ return retval;
+}
+
+
+static int miniisp_dev_map(struct file *filp, struct vm_area_struct *vma)
+{
+ unsigned long page, pos;
+ unsigned long start = (unsigned long)vma->vm_start;
+ unsigned long size = (unsigned long)(vma->vm_end - vma->vm_start);
+
+ misp_err("%s:called", __func__);
+
+ if (size > (unsigned long)allocated_size) {
+ misp_err("%s:ERROR1 mapsz = %lu, allocated_size = %lu",
+ __func__, size, (unsigned long)allocated_size);
+ return -EINVAL;
+ }
+ pos = (unsigned long)allocated_memmory_align;
+ page = virt_to_phys((void *)pos);
+
+ if (remap_pfn_range(vma,
+ start, page >> PAGE_SHIFT, size, PAGE_SHARED)) {
+ misp_err("%s:ERROR2", __func__);
+ return -EAGAIN;
+ }
+ return 0;
+}
+
+static u32 miniisp_debugif_RegBulk_read(u32 start_reg_addr, u32 end_reg_addr)
+{
+ struct misp_data *devdata;
+ struct misp_global_variable *dev_global_variable;
+ u32 count;
+ u32 rx_dummy_len;
+ u8 *send_buffer;
+ u8 *recv_buffer;
+ u8 *io_buffer = NULL;
+ u32 io_size;
+ u8 *dump_memory = NULL;
+ u8 *keep_dump_memory = NULL;
+ u32 ouput_size;
+ u8 ctrlbyte = CTRL_BYTE_REGRD;
+
+ /* prepare for mmap >>>*/
+ long retval = 0;
+ u8 *mmap_addr;
+
+ /*how many registers(4 bytes) do you want to read?*/
+ count = ((end_reg_addr - start_reg_addr) / 4) + 1;
+ ouput_size = (count + 2) * 4; /* read 4 bytes register value */
+
+ retval = miniisp_debugif_get_mem(ouput_size);
+ if (retval)
+ goto mini_isp_register_read_end;
+ mmap_addr = (u8 *)allocated_memmory_align;
+ /* prepare for mmap <<<*/
+
+ dev_global_variable = get_mini_isp_global_variable();
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+
+
+ rx_dummy_len = mini_isp_get_rx_dummy_byte(ctrlbyte);
+
+#if EN_SPIE_REG_DUMMY_BYTE
+ mini_isp_set_spie_dummy_byte(rx_dummy_len-1); /* 0 base */
+#endif
+
+ /* read 4 bytes register value at a time */
+ io_size = EMODE_TXCMD_LEN + rx_dummy_len + 4;
+
+ io_buffer = kzalloc(io_size, GFP_KERNEL);
+ if (!io_buffer) {
+ retval = -ENOMEM;
+ misp_err("%s Allocate memory failed.", __func__);
+ goto allocate_memory_fail;
+ }
+
+ dump_memory = kzalloc(ouput_size, GFP_KERNEL);
+ if (!dump_memory) {
+ retval = -ENOMEM;
+ misp_err("%s Allocate memory failed.", __func__);
+ goto allocate_memory_fail;
+ }
+ keep_dump_memory = dump_memory;
+
+ send_buffer = io_buffer;
+ recv_buffer = io_buffer + EMODE_TXCMD_LEN;
+
+ memcpy(dump_memory, &start_reg_addr, 4);
+ dump_memory = dump_memory + 4;
+ memcpy(dump_memory, &count, 4);
+ dump_memory = dump_memory + 4;
+
+ while (start_reg_addr <= end_reg_addr) {
+
+ memset(io_buffer, 0, io_size);
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &start_reg_addr, 4);
+
+ retval = devdata->intf_fn->read((void *)devdata,
+ send_buffer, EMODE_TXCMD_LEN,
+ recv_buffer, rx_dummy_len + 4);
+
+ if (retval)
+ goto mini_isp_register_read_get_fail;
+
+ if (dev_global_variable->intf_status & INTF_SPI_READY) {
+ /* check if send len + recv len > 32. if yes then
+ rx_dummy_len need + EMODE_TXCMD_LEN */
+ if (EMODE_TXCMD_LEN + rx_dummy_len + 4 > 32)
+ retval = mini_isp_check_rx_dummy(
+ &recv_buffer, rx_dummy_len+EMODE_TXCMD_LEN);
+ else
+ retval = mini_isp_check_rx_dummy(
+ &recv_buffer, rx_dummy_len);
+
+ if (retval)
+ goto mini_isp_register_read_get_fail;
+ }
+
+ memcpy(dump_memory, recv_buffer, 4);
+ start_reg_addr = start_reg_addr + 4;
+ dump_memory = dump_memory + 4;
+ }
+ memcpy(mmap_addr, keep_dump_memory, ouput_size);
+ kfree(io_buffer);
+ kfree(keep_dump_memory);
+ goto mini_isp_register_read_end;
+
+mini_isp_register_read_get_fail:
+ misp_err("%s read failed.", __func__);
+allocate_memory_fail:
+ misp_err("%s Allocate memory failed.", __func__);
+ kfree(io_buffer);
+ kfree(keep_dump_memory);
+ miniisp_debugif_munmap_done();
+mini_isp_register_read_end:
+ return retval;
+}
+
+static u32 miniisp_debugif_memory_read(u32 start_addr, u32 len)
+{
+ /* prepare for mmap >>>*/
+ long retval = 0;
+ u8 *mmap_addr;
+
+ retval = miniisp_debugif_get_mem(len);
+ if (retval) {
+ misp_err("%s alloc fail", __func__);
+ goto mini_isp_memory_read_fail;
+ }
+ mmap_addr = (u8 *)allocated_memmory_align;
+ /* prepare for mmap <<<*/
+
+ retval = mini_isp_memory_read(start_addr, mmap_addr, len);
+ if (retval) {
+ misp_err("%s read fail", __func__);
+ miniisp_debugif_munmap_done();
+ goto mini_isp_memory_read_fail;
+ }
+ misp_err("%s dump_finish", __func__);
+
+mini_isp_memory_read_fail:
+ return retval;
+}
+
+static long handle_PrepareCmd(unsigned int cmd, unsigned long arg)
+{
+ long retval = 0;
+ u8 state; /* 1:start, 0:done */
+
+ if (copy_from_user(&state, (int __user *)arg, sizeof(state))) {
+ retval = -EFAULT;
+ goto done;
+ }
+ switch (cmd) {
+ case IOCTL_REFRESH_MODULE:
+ if (state == 1) {
+ During_Refresh_Module = 1;
+ mini_isp_a_to_e();
+ } else if (state == 0) {
+ mini_isp_e_to_a();
+ During_Refresh_Module = 0;
+ }
+ break;
+ default:
+ retval = -ENOTTY;
+ break;
+ }
+done:
+ return retval;
+}
+
+static long handle_InfoCmd(unsigned int cmd, unsigned long arg)
+{
+ long retval = 0;
+ struct irp_and_depth_information data;
+
+ memset(&data, 0, sizeof(data));
+ if (copy_from_user(&data, (int __user *)arg, sizeof(data))) {
+ retval = -EFAULT;
+ goto done;
+ }
+
+ mini_isp_a_to_e();
+
+ switch (cmd) {
+ case IOCTL_IRP_DEPTH_INFO:
+ misp_err("%s:IOCTL_IRP_DEPTH_INFO", __func__);
+ retval = mini_isp_utility_get_irp_and_depth_information(&data);
+ if (retval) {
+ misp_err("%s:miniisp driver spi error, retval = %u",
+ __func__, (u32)retval);
+ retval = -EIO;
+ break;
+ }
+ if (copy_to_user((int __user *)arg, &data, sizeof(data)))
+ retval = -EFAULT;
+ break;
+ default:
+ retval = -ENOTTY;
+ break;
+ }
+
+ mini_isp_e_to_a();
+done:
+ return retval;
+}
+
+static long handle_RegCmd(unsigned int cmd, unsigned long arg)
+{
+ long retval = 0;
+ u32 val = 0xFFFFFFFF;
+ struct ioctl_regRW_cmd data;
+
+ memset(&data, 0, sizeof(data));
+ if (copy_from_user(&data, (int __user *)arg, sizeof(data))) {
+ retval = -EFAULT;
+ goto done;
+ }
+
+ if (!During_Refresh_Module)
+ mini_isp_a_to_e();
+
+ switch (cmd) {
+ case IOCTL_REGREAD:
+ misp_err("%s:IOCTL_REGREAD RegAddr = %#04x",
+ __func__, data.RegAddr);
+ retval = mini_isp_register_read(data.RegAddr, &val);
+ if (val == 0xFFFFFFFF) {
+ if (retval < 0)
+ misp_err("%s:miniisp driver sync_error, retval = %u",
+ __func__, (u32)retval);
+ else
+ misp_err("%s:miniisp driver can't get register.",
+ __func__);
+ retval = -EIO;
+ break;
+ }
+ data.RegVal = val;
+ if (copy_to_user((int __user *)arg, &data, sizeof(data)))
+ retval = -EFAULT;
+ break;
+ case IOCTL_REGWRITE:
+ misp_err("%s:IOCTL_REGWRITE RegAddr = %#04x; val = %#04x",
+ __func__, data.RegAddr, data.RegVal);
+ mini_isp_register_write(data.RegAddr, data.RegVal);
+ break;
+ default:
+ retval = -ENOTTY;
+ break;
+ }
+
+ if (!During_Refresh_Module)
+ mini_isp_e_to_a();
+
+done:
+ return retval;
+}
+
+
+static long handle_MemCmd(unsigned int cmd, unsigned long arg)
+{
+ long retval = 0;
+ struct ioctl_memRW_cmd data;
+
+ memset(&data, 0, sizeof(data));
+ if (copy_from_user(&data, (int __user *)arg, sizeof(data))) {
+ retval = -EFAULT;
+ goto done;
+ }
+
+ if (data.len > MAX_RW_SIZE) {
+ misp_err("%s:Invalid length, MemAddr = %#04x len = %u",
+ __func__, data.MemAddr, data.len);
+ retval = -EFAULT;
+ goto done;
+ }
+
+ if (!During_Refresh_Module)
+ mini_isp_a_to_e();
+
+ switch (cmd) {
+ case IOCTL_MEMREAD:
+ misp_err("%s:IOCTL_MEMREAD MemAddr = %#04x len = %u",
+ __func__, data.MemAddr, data.len);
+ retval = miniisp_debugif_memory_read(data.MemAddr, data.len);
+ break;
+ case IOCTL_MUNMAP_DONE:
+ misp_err("%s:IOCTL_MMAPDONE", __func__);
+ retval = miniisp_debugif_munmap_done();
+ break;
+ case IOCTL_MEMGET:
+ misp_err("%s:IOCTL_MEMGET len = %u", __func__, data.len);
+ retval = miniisp_debugif_get_mem(data.len);
+ break;
+ case IOCTL_MEMWRITE:
+ misp_err("%s:IOCTL_MEMWRITE MemAddr = %#04x len = %u",
+ __func__, data.MemAddr, data.len);
+ mini_isp_memory_write(data.MemAddr,
+ (u8 *)allocated_memmory_align, data.len);
+ break;
+ default:
+ retval = -ENOTTY;
+ break;
+ }
+
+ if (!During_Refresh_Module)
+ mini_isp_e_to_a();
+
+done:
+ return retval;
+}
+
+static long handle_BulkCmd(unsigned int cmd, unsigned long arg)
+{
+ long retval = 0;
+ struct ioctl_regBulkRW_cmd data;
+
+ memset(&data, 0, sizeof(data));
+ if (copy_from_user(&data, (int __user *)arg, sizeof(data))) {
+ retval = -EFAULT;
+ goto done;
+ }
+
+ if ((data.StartAddr > data.EndAddr) ||
+ ((data.EndAddr - data.StartAddr) > MAX_RW_SIZE)) {
+ misp_err("%s:Invalid address, StartAddr = %#04x EndAddr = %#04x",
+ __func__, data.StartAddr, data.EndAddr);
+ retval = -EFAULT;
+ goto done;
+ }
+
+ if (!During_Refresh_Module)
+ mini_isp_a_to_e();
+
+ switch (cmd) {
+ case IOCTL_REGBULKREAD:
+ misp_err("%s:IOCTL_REGBULKREAD StartAddr = %#04x EndAddr = %#04x",
+ __func__, data.StartAddr, data.EndAddr);
+ retval = miniisp_debugif_RegBulk_read(
+ data.StartAddr, data.EndAddr);
+ misp_err("%s:IOCTL_REGBULKREAD end", __func__);
+ break;
+ default:
+ retval = -ENOTTY;
+ break;
+ }
+ if (!During_Refresh_Module)
+ mini_isp_e_to_a();
+
+done:
+ return retval;
+}
+
+
+static long miniisp_dev_ioctl(
+ struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ long retval = 0;
+
+ misp_err("%s: IOCTL cmd:0x%08x", __func__, cmd);
+ /*
+ if (!access_ok(VERIFY_READ, (void __user *)arg, _IOC_SIZE(cmd))) {
+ retval = -EFAULT;
+ goto done;
+ }
+ */
+ switch (_IOC_TYPE(cmd)) {
+ case IOC_REGCMD_MAGIC:
+ retval = handle_RegCmd(cmd, arg);
+ break;
+ case IOC_MEMCMD_MAGIC:
+ retval = handle_MemCmd(cmd, arg);
+ break;
+ case IOC_BULKCMD_MAGIC:
+ retval = handle_BulkCmd(cmd, arg);
+ break;
+ case IOC_INFOCMD_MAGIC:
+ retval = handle_InfoCmd(cmd, arg);
+ break;
+ case IOC_PREPARECMD_MAGIC:
+ retval = handle_PrepareCmd(cmd, arg);
+ break;
+#if EN_605_IOCTRL_INTF
+ case IOC_ISP_CTRL_FLOW_MAGIC:
+ retval = handle_ControlFlowCmd(cmd, arg);
+ break;
+#endif
+ default:
+ retval = -ENOTTY;
+ break;
+ }
+ return retval;
+}
+
+static int miniisp_dev_open(struct inode *inode, struct file *filp)
+{
+ struct dbg_drvdata *p;
+
+ misp_err("%s:major %d minor %d (pid %d)", __func__,
+ imajor(inode), iminor(inode), current->pid);
+ inode->i_private = inode;
+
+ p = kmalloc(sizeof(struct dbg_drvdata), GFP_KERNEL);
+ if (p == NULL) {
+ /* misp_err("%s:No memory", __func__); */
+ return -ENOMEM;
+ }
+
+ memset(p, 0, sizeof(*p));
+
+ rwlock_init(&p->lock);
+ filp->private_data = p;
+
+ misp_err("%s:inode->i_private = %p, filp->private_data = %p",
+ __func__, inode->i_private, filp->private_data);
+ return 0;
+}
+
+static int miniisp_dev_release(struct inode *inode, struct file *filp)
+{
+ misp_err("%s:major %d, minor %d, pid %d",
+ __func__, imajor(inode), iminor(inode), current->pid);
+ misp_err("%s:inode->i_private = %p, filp->private_data = %p",
+ __func__, inode->i_private, filp->private_data);
+ kfree(filp->private_data);
+ return 0;
+}
+
+struct device *miniisp_chdev_create(struct class *mini_isp_class)
+{
+ dev_t miniisp_dev_nr; /* device number */
+ int ret = 0;
+ struct device *mini_isp_dev;
+
+ /* alloc major number */
+ if (alloc_chrdev_region(
+ &miniisp_dev_nr, 0, 1, "mini_isp_device") != 0) {
+ misp_err("%s:Allocate major number failed", __func__);
+ mini_isp_dev = device_create(
+ mini_isp_class, NULL, 0, NULL, "mini_isp_device");
+ } else {
+ misp_err("%s:Allocate major number succeed", __func__);
+ mini_isp_dev = device_create(mini_isp_class, NULL,
+ miniisp_dev_nr, NULL, "mini_isp_device");
+
+ miniisp_dev_major = MAJOR(miniisp_dev_nr);
+ miniisp_dev_minor = MINOR(miniisp_dev_nr);
+ misp_err("%s:register chrdev(%d,%d)", __func__,
+ miniisp_dev_major, miniisp_dev_minor);
+ /* alloc struct cdev */
+ /* kmalloc(sizeof(struct cdev), GFP_KERNEL);
+ //alloc struct cdev */
+ miniisp_dev_cdev = cdev_alloc();
+ if (miniisp_dev_cdev == NULL) {
+ misp_err("%s:kmalloc dev_cdev failed", __func__);
+ return mini_isp_dev;
+ } else {
+ misp_err("%s:kmalloc dev_cdev succeed", __func__);
+ }
+ /* register handler to struct cdev */
+ /* cdev_init(miniisp_dev_cdev, &miniisp_dev_fops); */
+ miniisp_dev_cdev->ops = &miniisp_dev_fops;
+ miniisp_dev_cdev->owner = THIS_MODULE;
+ /* register driver (struct cdev with file handler) to kernel */
+ ret = cdev_add(miniisp_dev_cdev,
+ MKDEV(miniisp_dev_major, miniisp_dev_minor), 1);
+ if (ret < 0) {
+ misp_err("%s:Add character device failed", __func__);
+
+ kfree(miniisp_dev_cdev);
+ miniisp_dev_cdev = NULL;
+ } else {
+ misp_err("%s:Add character device succeed", __func__);
+ }
+ }
+ return mini_isp_dev;
+}
diff --git a/drivers/media/platform/altek/miniisp_intf_i2c.c b/drivers/media/platform/altek/miniisp_intf_i2c.c
new file mode 100755
index 0000000..0021ef8
--- /dev/null
+++ b/drivers/media/platform/altek/miniisp_intf_i2c.c
@@ -0,0 +1,487 @@
+/*
+ * File: miniisp_intf_i2c.c
+ * Description: Mini ISP i2c sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2017/03/30; Max Tseng; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/****************************************************************************
+* Include File *
+****************************************************************************/
+/* Linux headers*/
+#include <linux/module.h>
+#include <linux/buffer_head.h>
+
+#include "include/miniisp.h"
+#include "include/miniisp_ctrl.h"
+#include "include/error/miniisp_err.h"
+
+/****************************************************************************
+* Private Constant Definition *
+****************************************************************************/
+#define MINI_ISP_LOG_TAG "[miniisp_intf_i2c]"
+#define MINIISP_SLAVE_ADDR 0x11
+#define MINIISP_TOP_ADDR 0x77
+
+/****************************************************************************
+* Private Global Variable *
+****************************************************************************/
+static struct misp_data *misp_intf_i2c_slave_data;
+static struct misp_data *misp_intf_i2c_top_data;
+static u8 *i2c_bulkbuffer;
+
+/****************************************************************************
+* Private Function Prototype *
+****************************************************************************/
+
+/**********************************************************************
+* Public Function *
+**********************************************************************/
+
+static const struct i2c_device_id mini_isp_intf_i2c_id[] = {
+ { "altek_i2c_slave", MINIISP_I2C_SLAVE},
+ { "altek_i2c_top", MINIISP_I2C_TOP},
+ {} /* NULL terminated*/
+};
+MODULE_DEVICE_TABLE(i2c, mini_isp_intf_i2c_id);
+
+/*
+ *get mini isp data
+ *return mini isp i2c data
+ */
+struct misp_data *get_mini_isp_intf_i2c_top_data(void)
+{
+ if (!misp_intf_i2c_top_data) {
+ misp_err("%s - get pdata error", __func__);
+ return NULL;
+ } else {
+ return misp_intf_i2c_top_data;
+ }
+}
+
+struct misp_data *get_mini_isp_intf_i2c_slave_data(void)
+{
+ if (!misp_intf_i2c_slave_data) {
+ misp_err("%s - get pdata error", __func__);
+ return NULL;
+ } else {
+ return misp_intf_i2c_slave_data;
+ }
+}
+struct misp_data *get_mini_isp_intf_i2c(int i2c_type)
+{
+ if (i2c_type == MINIISP_I2C_SLAVE) {
+ return get_mini_isp_intf_i2c_slave_data();
+ } else if (i2c_type == MINIISP_I2C_TOP) {
+ return get_mini_isp_intf_i2c_top_data();
+ } else {
+ misp_err("%s - error i2c type %d", __func__, i2c_type);
+ return NULL;
+ }
+}
+
+
+/****************************************************************************
+* Private Function *
+****************************************************************************/
+/*write command to miniISP through i2c,this function will block.
+ *return 0 successful
+ *others fail
+*/
+static int mini_isp_intf_i2c_write(void *dev, u8 *tx_buf, u8 *rx_buf, u32 len)
+{
+ int status = 0;
+ struct misp_data *devdata = (struct misp_data *)dev;
+
+ if (!devdata) {
+ misp_err("%s - invalid arg devdata = %p", __func__, devdata);
+ return -EINVAL;
+ }
+
+ status = i2c_master_send(devdata->cfg.i2c, tx_buf, len);
+
+ if (status < 0)
+ misp_err("%s - sync error: status=%d", __func__, status);
+ else
+ status = 0;
+
+ return status;
+}
+
+/*read command from device ,this function will block.
+ *return 0 successful
+ *others fail
+ */
+static int mini_isp_intf_i2c_read(
+ void *dev, u8 *tx_buf, u32 tx_len, u8 *rx_buf, u32 rx_len)
+{
+ int status = 0;
+ struct misp_data *devdata = (struct misp_data *)dev;
+
+ if (!devdata) {
+ misp_err("%s - invalid arg devdata = %p", __func__, devdata);
+ return -EINVAL;
+ }
+
+ misp_info("%s - i2c_master_send start.", __func__);
+ if (tx_len > 0) {
+ status = i2c_master_send(devdata->cfg.i2c, tx_buf, tx_len);
+ if (status != tx_len)
+ return status;
+ }
+
+ misp_info("%s - i2c_master_recv start.", __func__);
+ /* read data from device through i2c */
+ status = i2c_master_recv(devdata->cfg.i2c, rx_buf, rx_len);
+
+ if (status < 0)
+ misp_err("%s - sync error: status=%d", __func__, status);
+ else
+ status = 0;
+
+ return status;
+}
+
+/*
+ *write command data to miniISP through i2c
+ *return 0 successful
+ *others fail
+*/
+static int mini_isp_intf_i2c_send(void *dev, u32 len)
+{
+ int status = 0;
+ struct misp_data *devdata = (struct misp_data *)dev;
+
+ misp_info("%s - enter", __func__);
+
+ if (!devdata) {
+ misp_err("%s - invalid arg devdata = %p, len= %d",
+ __func__, devdata, len);
+ return -EINVAL;
+ }
+
+ misp_info("%s - i2c_master_send start.", __func__);
+ /* send data to miniISP through i2c */
+ status = mini_isp_intf_i2c_write(
+ devdata, devdata->tx_buf, devdata->rx_buf, len);
+
+ misp_info("%s - devdata->cfg.i2c->addr = %x",
+ __func__, devdata->cfg.i2c->addr);
+ if (status < 0)
+ misp_err("%s - sync error: status=%d", __func__, status);
+ else
+ status = 0;
+
+ return status;
+}
+
+/* read miniISP using i2c ,this function will block.
+ *return 0 successful
+ *others fail
+ */
+static int mini_isp_intf_i2c_recv(void *dev, u32 len, bool waitINT)
+{
+ int status = 0;
+ struct misp_data *devdata = (struct misp_data *)dev;
+
+ misp_info("%s - enter", __func__);
+
+ if (!devdata) {
+ misp_err("%s - invalid arg devdata=%p,len=%d", __func__,
+ devdata, len);
+ return -EINVAL;
+ }
+
+ if (waitINT)
+ /*wait for the interrupt*/
+ status = mini_isp_wait_for_event(MINI_ISP_RCV_CMD_READY);
+
+ if (status) {
+ misp_err("%s - irq error: status=%d", __func__, status);
+ return status;
+ }
+
+ /* receive the data through i2c */
+ status = mini_isp_intf_i2c_read(
+ devdata, devdata->tx_buf, 0, devdata->rx_buf, len);
+
+ if (status) {
+ misp_err("%s - sync error: status=%d", __func__, status);
+ return status;
+ }
+
+ misp_info("%s - recv buf len=%d:", __func__, len);
+ return status;
+}
+
+#if ENABLE_LINUX_FW_LOADER
+/*used to send the firmware*/
+static int mini_isp_intf_i2c_send_bulk(void *devdata,
+ u32 total_size, u32 block_size, bool is_raw,
+ const u8 *i2c_Sendbulkbuffer)
+{
+ int status = 0, count = 0;
+ int remain_size, one_size;
+ int shift = 0;
+
+ misp_info("%s - enter", __func__);
+
+ if (i2c_Sendbulkbuffer != NULL) {
+ misp_info("%s start. Total size: %d. block_size: %d",
+ __func__, total_size, block_size);
+
+ if (total_size > I2C_TX_BULK_SIZE)
+ i2c_bulkbuffer = kzalloc(I2C_TX_BULK_SIZE, GFP_DMA);
+ /* Allocate boot code bulk buffer*/
+ else
+ i2c_bulkbuffer = kzalloc(total_size, GFP_DMA);
+
+ if (!i2c_bulkbuffer) {
+ status = -EINVAL;
+ goto T_EXIT;
+ }
+
+ for (remain_size = total_size; remain_size > 0; remain_size -= one_size) {
+ one_size = (remain_size > block_size) ? block_size : remain_size;
+
+ misp_info("remain size: %d one_size: %d.", remain_size, one_size);
+
+ memcpy(i2c_bulkbuffer, i2c_Sendbulkbuffer + shift, one_size);
+ shift += one_size;
+
+ /*send the data*/
+ status = mini_isp_intf_i2c_write(devdata,
+ i2c_bulkbuffer, NULL, one_size);
+
+ if (status != 0) {
+ misp_err("%s failed! block:%d status:%d", __func__, count, status);
+ break;
+ }
+ misp_info("%s write block %d success", __func__, count);
+ count++;
+ }
+ }
+
+T_EXIT:
+
+ if (i2c_bulkbuffer != NULL) {
+ kfree(i2c_bulkbuffer);
+ i2c_bulkbuffer = NULL;
+ }
+
+ if (status != ERR_SUCCESS)
+ misp_err("%s error: %d", __func__, status);
+ else
+ misp_info("%s success", __func__);
+
+ return status;
+}
+
+struct misp_intf_fn_t intf_i2c_fn = {
+ .send = mini_isp_intf_i2c_send,
+ .recv = mini_isp_intf_i2c_recv,
+ .read = mini_isp_intf_i2c_read,
+ .write = mini_isp_intf_i2c_write,
+ .send_bulk = mini_isp_intf_i2c_send_bulk,
+};
+
+#else
+/*used to send the firmware*/
+static int mini_isp_intf_i2c_send_bulk(void *devdata, struct file *filp,
+ u32 total_size, u32 block_size, bool is_raw, u8 *i2c_Sendbulkbuffer)
+{
+ int status = 0, count = 0;
+ int remain_size, one_size;
+ int shift = 0;
+
+ misp_info("%s - enter", __func__);
+
+ if (i2c_Sendbulkbuffer != NULL) {
+ misp_info("%s start. Total size: %d. block_size: %d", __func__, total_size, block_size);
+
+ if (total_size > I2C_TX_BULK_SIZE)
+ i2c_bulkbuffer = kzalloc(I2C_TX_BULK_SIZE, GFP_DMA);
+ /* Allocate boot code bulk buffer*/
+ else
+ i2c_bulkbuffer = kzalloc(total_size, GFP_DMA);
+
+ if (!i2c_bulkbuffer) {
+ status = -EINVAL;
+ goto T_EXIT;
+ }
+
+ for (remain_size = total_size; remain_size > 0; remain_size -= one_size) {
+ one_size = (remain_size > block_size) ? block_size : remain_size;
+
+ misp_info("remain size: %d one_size: %d.", remain_size, one_size);
+
+ memcpy(i2c_bulkbuffer, i2c_Sendbulkbuffer + shift, one_size);
+ shift += one_size;
+
+ /*send the data*/
+ status = mini_isp_intf_i2c_write(devdata,
+ i2c_bulkbuffer, NULL, one_size);
+
+ if (status != 0) {
+ misp_err("%s failed! block:%d status:%d", __func__, count, status);
+ break;
+ }
+ misp_info("%s write block %d success", __func__, count);
+ count++;
+ }
+ }
+
+T_EXIT:
+
+ if (i2c_bulkbuffer != NULL) {
+ kfree(i2c_bulkbuffer);
+ i2c_bulkbuffer = NULL;
+ }
+
+ if (status != ERR_SUCCESS)
+ misp_err("%s error: %d", __func__, status);
+ else
+ misp_info("%s success", __func__);
+
+ return status;
+}
+
+struct misp_intf_fn_t intf_i2c_fn = {
+ .send = mini_isp_intf_i2c_send,
+ .recv = mini_isp_intf_i2c_recv,
+ .read = mini_isp_intf_i2c_read,
+ .write = mini_isp_intf_i2c_write,
+ .send_bulk = mini_isp_intf_i2c_send_bulk,
+};
+#endif
+
+static int mini_isp_intf_i2c_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ int status = 0;
+ struct misp_data *drv_data = NULL;
+
+ misp_info("%s - start, addr[0x%x].", __func__, client->addr);
+
+ /* step 0: Check if the adapter supports the needed features */
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+ misp_err("%s - i2c_check_functionality err.", __func__);
+ return -EIO;
+ }
+ /*step 1: alloc driver data struct*/
+ drv_data = kmalloc(sizeof(struct misp_data), GFP_KERNEL);
+ if (!drv_data) {
+ status = -ENOMEM;
+ goto alloc_misp_data_fail;
+ }
+ misp_info("%s - step1 done.", __func__);
+
+ /*step 2: init driver data*/
+ drv_data->cfg.i2c = client;
+ drv_data->intf_fn = &intf_i2c_fn;
+ drv_data->bulk_cmd_blocksize = I2C_TX_BULK_SIZE;
+ misp_info("%s - step2 done.", __func__);
+
+ /*step 3: setup recource : gpio, sem*/
+ if (id->driver_data == MINIISP_I2C_SLAVE) {
+ misp_intf_i2c_slave_data = drv_data;
+ i2c_set_clientdata(client, misp_intf_i2c_slave_data);
+ misp_info("%s - misp_intf_i2c_slave_data set done.", __func__);
+ } else if (id->driver_data == MINIISP_I2C_TOP) {
+ misp_intf_i2c_top_data = drv_data;
+ i2c_set_clientdata(client, misp_intf_i2c_top_data);
+ status = mini_isp_setup_resource(&client->dev, drv_data);
+ if (status < 0) {
+ misp_err("%s step3. probe - setup resource error", __func__);
+ goto setup_i2c_error;
+ }
+ misp_info("%s - misp_intf_i2c_top_data set done.", __func__);
+ } else {
+ misp_err("%s - probe fail.", __func__);
+ kfree(drv_data);
+ return -ENODEV;
+ }
+
+ set_mini_isp_data(drv_data, INTF_I2C_READY);
+ goto done;
+
+setup_i2c_error:
+ kfree(misp_intf_i2c_top_data);
+ misp_intf_i2c_top_data = NULL;
+
+alloc_misp_data_fail:
+
+done:
+ return status;
+
+}
+static int mini_isp_intf_i2c_remove(struct i2c_client *client)
+{
+ struct misp_data *misp_intf_i2c = i2c_get_clientdata(client);
+
+ if (!misp_intf_i2c) {
+ misp_err("%s: i2c data is NULL\n", __func__);
+ return 0;
+ }
+
+ kfree(misp_intf_i2c);
+
+ return 0;
+}
+static const struct of_device_id mini_isp_dt_i2c_slave_match[] = {
+ { .compatible = "altek,i2c_slave",},
+ /*Compatible node must match dts*/
+ { },
+ };
+
+MODULE_DEVICE_TABLE(of, mini_isp_dt_i2c_slave_match);
+
+static const struct of_device_id mini_isp_dt_i2c_top_match[] = {
+ { .compatible = "altek,i2c_top",},
+ /*Compatible node must match dts*/
+ { },
+ };
+
+MODULE_DEVICE_TABLE(of, mini_isp_dt_i2c_top_match);
+
+struct i2c_driver mini_isp_intf_i2c_slave = {
+ .driver = {
+ .name = "altek_i2c_slave",
+ .owner = THIS_MODULE,
+ .of_match_table = mini_isp_dt_i2c_slave_match,
+ },
+ .probe = mini_isp_intf_i2c_probe,
+ .remove = mini_isp_intf_i2c_remove,
+ .id_table = mini_isp_intf_i2c_id,
+};
+
+struct i2c_driver mini_isp_intf_i2c_top = {
+ .driver = {
+ .name = "altek_i2c_top",
+ .owner = THIS_MODULE,
+ .of_match_table = mini_isp_dt_i2c_top_match,
+ },
+ .probe = mini_isp_intf_i2c_probe,
+ .remove = mini_isp_intf_i2c_remove,
+ .id_table = mini_isp_intf_i2c_id,
+};
diff --git a/drivers/media/platform/altek/miniisp_intf_spi.c b/drivers/media/platform/altek/miniisp_intf_spi.c
new file mode 100755
index 0000000..5eac2ca
--- /dev/null
+++ b/drivers/media/platform/altek/miniisp_intf_spi.c
@@ -0,0 +1,727 @@
+/*
+ * File: miniisp_spi.c
+ * Description: Mini ISP sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2017/04/11; LouisWang; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/******Include File******/
+/* Linux headers*/
+#include <linux/module.h>
+#include <linux/dma-mapping.h>
+#include <linux/delay.h>
+#include <linux/buffer_head.h>
+#include <linux/of_gpio.h>
+
+
+#include "include/miniisp.h"
+#include "include/miniisp_ctrl.h"
+#include "include/miniisp_customer_define.h"
+#include "include/miniisp_chip_base_define.h"
+
+#include "include/error/miniisp_err.h"
+
+#ifdef ALTEK_TEST
+#include "include/altek_test.h"
+#endif
+
+/******Private Constant Definition******/
+#define DEBUG_NODE 0
+
+/*#define DEBUG_ALERT*/
+#define MINI_ISP_LOG_TAG "[miniisp_intf_spi]"
+
+/*drv debug defination*/
+#define _SPI_DEBUG
+
+
+/****************************************************************************
+* Private Global Variable *
+****************************************************************************/
+static struct misp_data *misp_intf_spi_data;
+struct file *filp[4];
+static u8 *spi_bulkbuffer;
+/****************************************************************************
+* Private Function Prototype *
+****************************************************************************/
+
+#if DEBUG_NODE
+static ssize_t
+mini_isp_config_show(struct device *dev, struct device_attribute *attr,
+ char *buf);
+static ssize_t
+mini_isp_config_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count);
+static DEVICE_ATTR(mini_isp_config, S_IRUGO|S_IWUSR, mini_isp_config_show,
+ mini_isp_config_store);
+#endif
+
+/**********************************************************************
+* Public Function *
+**********************************************************************/
+
+
+/******Public Function******/
+struct misp_data *get_mini_isp_intf_spi(void)
+{
+ if (!misp_intf_spi_data) {
+ misp_err("%s - get pdata error", __func__);
+ return NULL;
+ } else {
+ return misp_intf_spi_data;
+ }
+}
+
+#ifdef _SPI_DEBUG
+void spi_data_debug(const void *buf, int data_len, int dbg_len)
+{
+ int len = 0, pos = 0;
+ unsigned char *char_buf = (unsigned char *)buf;
+ unsigned char string[100], temp[4];
+
+ memset(string, 0, sizeof(string));
+
+ len = (dbg_len > data_len) ? data_len : dbg_len;
+
+ pos = 0;
+ while (len > 0) {
+ if (len > 7) {
+ misp_info("%02x %02x %02x %02x %02x %02x %02x %02x",
+ char_buf[pos], char_buf[pos+1], char_buf[pos+2],
+ char_buf[pos+3], char_buf[pos+4], char_buf[pos+5],
+ char_buf[pos+6], char_buf[pos+7]);
+
+ len -= 8;
+ pos += 8;
+ } else {
+ for ( ; len > 0; len--) {
+ snprintf(temp, 4, "%02x ", char_buf[pos++]);
+ strlcat(string, temp, 24);
+ }
+ misp_info("%s", string);
+ }
+ }
+}
+#else
+#define spi_data_debug(buf, data_len, dbg_len)
+#endif
+
+int mini_isp_dma_write(struct spi_device *spi, u8 *tx_buf, u32 len)
+{
+ int state;
+ dma_addr_t bus_addr;
+
+ struct spi_transfer t = {
+ .tx_buf = tx_buf,
+ .len = len,
+ };
+ struct spi_message m;
+
+ misp_info("%s - entering ", __func__);
+
+ spi_message_init(&m);
+
+ bus_addr = dma_map_single(&spi->dev, tx_buf, len, DMA_TO_DEVICE);
+
+ if (!bus_addr) {
+ misp_err("%s dma mapping failed.", __func__);
+ state = -ENOMEM;
+ goto mini_isp_dma_write_end;
+ }
+
+ t.tx_dma = bus_addr;
+ m.is_dma_mapped = 1;
+
+ spi_message_add_tail(&t, &m);
+
+ state = spi_sync(spi, &m);
+
+ dma_unmap_single(&spi->dev, bus_addr, len, DMA_TO_DEVICE);
+
+ misp_info("%s - leave ", __func__);
+
+mini_isp_dma_write_end:
+
+ return state;
+}
+
+/****************************************************************************
+* Private Function *
+****************************************************************************/
+
+/*read command from device ,this function will block.
+ *return 0 successful
+ *others fail
+ */
+static int mini_isp_intf_spi_read(void *dev, u8 *tx_buf,
+ u32 tx_len, u8 *rx_buf, u32 rx_len)
+{
+ struct spi_transfer t = {
+ .tx_buf = tx_buf,
+ .rx_buf = rx_buf,
+ .len = tx_len + rx_len,
+ .delay_usecs = 1,
+ .speed_hz = SPI_BUS_SPEED,
+ };
+ struct spi_message m;
+ struct misp_global_variable *misp_drv_global;
+ struct misp_data *devdata = (struct misp_data *)dev;
+ int status;
+
+ misp_drv_global = get_mini_isp_global_variable();
+
+ if (!devdata) {
+ misp_err("%s - invalid arg devdata = %p, len = %d",
+ __func__, devdata, tx_len + rx_len);
+ return -EINVAL;
+ }
+
+ if (misp_drv_global->before_booting) {
+ devdata->cfg.spi->max_speed_hz = SPI_BUS_SPEED_BOOT;
+ t.speed_hz = SPI_BUS_SPEED_BOOT;
+ } else if (misp_drv_global->spi_low_speed_mode) {
+ devdata->cfg.spi->max_speed_hz = SPI_BUS_SPEED_LOW;
+ t.speed_hz = SPI_BUS_SPEED_LOW;
+ } else {
+ /* Set to SPI high speed after booting */
+ devdata->cfg.spi->max_speed_hz = SPI_BUS_SPEED;
+ }
+
+ status = spi_setup(devdata->cfg.spi);
+ if (status < 0)
+ misp_err("%s : setup spi error", __func__);
+
+ if (tx_len + rx_len <= 32)
+ return spi_write_then_read(devdata->cfg.spi,
+ tx_buf, tx_len, rx_buf, rx_len);
+
+
+ spi_message_init(&m);
+ spi_message_add_tail(&t, &m);
+
+ return spi_sync(devdata->cfg.spi, &m);
+}
+
+
+/*write commadn to device ,this fucntion will block.
+ *return 0 successful
+ *others fail
+ */
+static int mini_isp_intf_spi_write(void *dev, u8 *tx_buf,
+ u8 *rx_buf, u32 len)
+{
+ struct spi_transfer t = {
+ .tx_buf = tx_buf,
+ .rx_buf = rx_buf,
+ .len = len,
+ .delay_usecs = 1,
+ .speed_hz = SPI_BUS_SPEED,
+ };
+ struct spi_message m;
+ struct misp_global_variable *misp_drv_global;
+ struct misp_data *devdata = (struct misp_data *)dev;
+
+ misp_drv_global = get_mini_isp_global_variable();
+ if (!devdata) {
+ misp_err("%s - invalid arg devdata = %p, len = %d",
+ __func__, devdata, len);
+ return -EINVAL;
+ }
+
+ if (misp_drv_global->before_booting)
+ t.speed_hz = SPI_BUS_SPEED_BOOT;
+ else if (misp_drv_global->spi_low_speed_mode)
+ t.speed_hz = SPI_BUS_SPEED_LOW;
+
+ spi_message_init(&m);
+ spi_message_add_tail(&t, &m);
+
+ return spi_sync(devdata->cfg.spi, &m);
+}
+
+/*
+ *write command data to spi
+ *return 0 successful
+ *others fail
+ */
+static int mini_isp_intf_spi_send(void *dev, u32 len)
+{
+ int status;
+ u8 check = USPICTRL_MS_CB_ORG;
+ u8 spi_databuffer[TX_BUF_SIZE + 1] = {0};
+ struct misp_data *devdata = (struct misp_data *)dev;
+
+ if ((!devdata) || (len > TX_BUF_SIZE)) {
+ misp_err("%s - invalid arg devdata = %p, len = %d", __func__,
+ devdata, len);
+ return -EINVAL;
+ }
+
+ /*put the ctrl byte in the first byte, then put the following data.*/
+ spi_databuffer[0] = check;
+
+ memcpy(spi_databuffer + 1, devdata->tx_buf, len);
+
+ status = mini_isp_intf_spi_write(devdata, spi_databuffer,
+ NULL, len + 1);
+ if (status) {
+ misp_err("%s - sync error: status = %d", __func__, status);
+ return status;
+ }
+
+ return status;
+}
+
+/* read miniISP using spi ,this fucntion will block.
+ *return 0 successful
+ *others fail
+ */
+static int mini_isp_intf_spi_recv(void *dev, u32 len, bool waitINT)
+{
+ int status;
+ u8 ctrlbyte = USPICTRL_MS_CB_RSP;
+ int i = 0;
+ int original_altek_spi_mode;
+ u32 altek_event_state;
+ u8 spi_databuffer[TX_BUF_SIZE + 1] = {0};
+ u8 *spi_txbuf = NULL;
+ u8 *spi_rxbuf = NULL;
+ struct misp_global_variable *dev_global_variable;
+ struct misp_data *devdata = (struct misp_data *)dev;
+
+ misp_err("%s - enter", __func__);
+
+ dev_global_variable = get_mini_isp_global_variable();
+ original_altek_spi_mode = dev_global_variable->altek_spi_mode;
+ if ((!devdata) || (len > RX_BUF_SIZE)) {
+ misp_err("%s - invalid arg devdata = %p, len = %d",
+ __func__, devdata, len);
+ status = -EINVAL;
+ goto mini_isp_intf_spi_recv_end;
+ }
+ spi_txbuf = &spi_databuffer[0];
+ spi_rxbuf = &spi_databuffer[1];
+
+ memset(spi_databuffer, 0, RX_BUF_SIZE + 1);
+
+ if (waitINT) {
+ /*wait for the interrupt*/
+ status = mini_isp_wait_for_event(MINI_ISP_RCV_CMD_READY);
+ } else {
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (original_altek_spi_mode == ALTEK_SPI_MODE_A))
+ mini_isp_a_to_e();
+ for (i = 0; i < 200; i++) {
+ status = mini_isp_get_altek_status(devdata,
+ &altek_event_state);
+ if (altek_event_state & COMMAND_COMPLETE) {
+ altek_event_state = (altek_event_state &
+ ~((~0) << 1));
+ mini_isp_register_write(
+ INTERRUPT_STATUS_REGISTER_ADDR,
+ altek_event_state);
+ break;
+ }
+ msleep(20); /* mdelay(5); */
+ }
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (original_altek_spi_mode !=
+ dev_global_variable->altek_spi_mode))
+ mini_isp_e_to_a();
+ if (i >= 200) {
+ misp_err("%s time out.", __func__);
+ status = ERR_MINIISP_GETDATA_TIMEOUT;
+ goto mini_isp_intf_spi_recv_end;
+ }
+ }
+
+ if (status) {
+ misp_err("%s - irq error: status = %d", __func__, status);
+ goto mini_isp_intf_spi_recv_end;
+ }
+
+ /*send the ctrl byte and get the data in full duplex mode*/
+ /*the data is stored from the 2nd byte*/
+ *spi_txbuf = ctrlbyte;
+ status = mini_isp_intf_spi_read(devdata, spi_txbuf, 1, spi_rxbuf, len);
+ if (status) {
+ misp_err("%s - sync error: status = %d", __func__, status);
+ goto mini_isp_intf_spi_recv_end;
+ }
+
+ /* full duplex mode, skip tx_len */
+ if (len+1 > 32) {
+ if (len > RX_BUF_SIZE - 1)
+ misp_err("%s - invalid len = %d",
+ __func__, len);
+ else
+ memcpy(devdata->rx_buf, spi_rxbuf + 1, len);
+ } else {
+ /* half duplex mode, no need skip tx_len */
+ memcpy(devdata->rx_buf, spi_rxbuf, len);
+ }
+
+ misp_info("%s - recv buf len = %d:", __func__, len);
+ spi_data_debug(devdata->rx_buf, RX_BUF_SIZE, len);
+
+mini_isp_intf_spi_recv_end:
+ return status;
+}
+
+#if ENABLE_LINUX_FW_LOADER
+/*used to send the firmware*/
+static int mini_isp_intf_spi_send_bulk(void *dev,
+ u32 total_size, u32 block_size, bool is_raw,
+ const u8 *spi_Sendbulkbuffer)
+{
+ int status = 0, count = 0;
+ int remain_size, one_size;
+ u8 ctrlbyte = USPICTRL_MS_CB_DIS, ack[2];
+ int shift = 0;
+ struct misp_data *devdata = (struct misp_data *)dev;
+
+ misp_info("%s - entering", __func__);
+
+ if (spi_Sendbulkbuffer != NULL) {
+ misp_info("%s start. Total size: %d.", __func__, total_size);
+ if (!is_raw) {
+ /*send the ctrl byte*/
+ status = mini_isp_intf_spi_read(devdata, &ctrlbyte,
+ 1, ack, 2);
+ if (status) {
+ misp_err("%s send ctrlbyte fail status: %d",
+ __func__, status);
+ status = -EINVAL;
+ goto T_EXIT;
+ }
+ }
+
+ /* Allocate basic code bulk buffer*/
+ if (total_size > SPI_TX_BULK_SIZE)
+ spi_bulkbuffer = kzalloc(SPI_TX_BULK_SIZE, GFP_DMA);
+ /* Allocate boot code bulk buffer*/
+ else
+ spi_bulkbuffer = kzalloc(total_size, GFP_DMA);
+
+ if (!spi_bulkbuffer) {
+ status = -EINVAL;
+ misp_err("%s - Can not alloc SPI bulk buffer",
+ __func__);
+ goto T_EXIT;
+ }
+
+ for (remain_size = total_size; remain_size > 0;
+ remain_size -= one_size) {
+
+ one_size = (remain_size > block_size) ?
+ block_size : remain_size;
+
+ misp_info("remain size: %d one_size: %d.",
+ remain_size, one_size);
+
+ memcpy(spi_bulkbuffer, (spi_Sendbulkbuffer + shift),
+ one_size);
+ shift += one_size;
+
+ /*send the data*/
+ status = mini_isp_intf_spi_write(devdata,
+ spi_bulkbuffer, NULL, one_size);
+
+ if (status != 0) {
+ misp_err(
+ "%s failed! block:%d status:%d",
+ __func__, count, status);
+ break;
+ }
+
+ count++;
+ }
+
+ }
+T_EXIT:
+
+ /* Free SPI bulk buffer*/
+ if (spi_bulkbuffer != NULL) {
+ kfree(spi_bulkbuffer);
+ spi_bulkbuffer = NULL;
+ }
+
+ if (status != ERR_SUCCESS)
+ misp_err("%s error: %d", __func__, status);
+ else
+ misp_info("%s success", __func__);
+
+ return status;
+}
+
+#else
+/*used to send the firmware*/
+static int mini_isp_intf_spi_send_bulk(void *dev, struct file *filp,
+ u32 total_size, u32 block_size, bool is_raw, u8 *spi_Sendbulkbuffer)
+{
+ int status = 0, count = 0;
+ int remain_size, one_size;
+ u8 ctrlbyte = USPICTRL_MS_CB_DIS, ack[2];
+ mm_segment_t oldfs;
+ loff_t offset;
+ int shift = 0;
+ struct misp_data *devdata = (struct misp_data *)dev;
+
+ misp_info("%s - entering", __func__);
+
+ if (spi_Sendbulkbuffer != NULL) {
+ misp_info("%s start. Total size: %d.", __func__, total_size);
+ if (!is_raw) {
+ /*send the ctrl byte*/
+ status = mini_isp_intf_spi_read(devdata, &ctrlbyte,
+ 1, ack, 2);
+ if (status) {
+ misp_err("%s send ctrlbyte fail status: %d",
+ __func__, status);
+ status = -EINVAL;
+ goto T_EXIT;
+ }
+ }
+
+ /* Allocate basic code bulk buffer*/
+ if (total_size > SPI_TX_BULK_SIZE)
+ spi_bulkbuffer = kzalloc(SPI_TX_BULK_SIZE, GFP_DMA);
+ /* Allocate boot code bulk buffer*/
+ else
+ spi_bulkbuffer = kzalloc(total_size, GFP_DMA);
+
+ if (!spi_bulkbuffer) {
+ status = -EINVAL;
+ misp_err("%s - Can not alloc SPI bulk buffer",
+ __func__);
+ goto T_EXIT;
+ }
+
+ for (remain_size = total_size; remain_size > 0;
+ remain_size -= one_size) {
+ one_size = (remain_size > block_size) ?
+ block_size : remain_size;
+
+
+ /* misp_info("remain size: %d one_size: %d.", */
+ /* remain_size, one_size); */
+
+ memcpy(spi_bulkbuffer, (spi_Sendbulkbuffer + shift),
+ one_size);
+ shift += one_size;
+
+ /*send the data*/
+ status = mini_isp_intf_spi_write(devdata,
+ spi_bulkbuffer, NULL, one_size);
+
+ if (status != 0) {
+ misp_err(
+ "%s failed! block:%d status:%d",
+ __func__, count, status);
+ break;
+ }
+
+ /* misp_info("%s write block %d success", */
+ /* __func__, count); */
+
+ count++;
+ }
+
+ } else {
+ oldfs = get_fs();
+
+ set_fs(get_ds());
+
+ misp_info("%s start. Total size: %d", __func__, total_size);
+
+ if (!is_raw) {
+ /*send the ctrl byte*/
+ status = mini_isp_intf_spi_read(devdata, &ctrlbyte,
+ 1, ack, 2);
+ misp_info("%s is not raw", __func__);
+ if (status) {
+ misp_err("%s ctrl byte fail status: %d",
+ __func__, status);
+ status = -EINVAL;
+ goto T_EXIT;
+ }
+ }
+
+ /* Allocate basic code bulk buffer*/
+ if (total_size > SPI_TX_BULK_SIZE_BOOT)
+ spi_bulkbuffer = kzalloc(SPI_TX_BULK_SIZE, GFP_DMA);
+ /* Allocate boot code bulk buffer*/
+ else
+ spi_bulkbuffer = kzalloc(SPI_TX_BULK_SIZE_BOOT,
+ GFP_DMA);
+
+
+ if (!spi_bulkbuffer) {
+ misp_err("%s - Can not alloc SPI bulk buffer",
+ __func__);
+ status = -EINVAL;
+ goto T_EXIT;
+ }
+
+ for (remain_size = total_size; remain_size > 0;
+ remain_size -= one_size) {
+ one_size = (remain_size > block_size) ?
+ block_size : remain_size;
+
+ /* misp_info("remain size: %d one_size: %d", */
+ /* remain_size, one_size); */
+
+ /*copy the firmware to the buffer*/
+ offset = filp->f_pos;
+ status = vfs_read(filp, spi_bulkbuffer, one_size,
+ &offset);
+
+ if (status == -1) {
+ misp_info("%s Read file failed.", __func__);
+ break;
+ }
+
+ filp->f_pos = offset;
+
+ /*send the data*/
+ status = mini_isp_intf_spi_write(devdata,
+ spi_bulkbuffer, NULL, one_size);
+ if (status != 0) {
+ misp_err("%s send fail, block:%d status: %d",
+ __func__, count, status);
+ break;
+ }
+
+ /* misp_info("%s write block %d success", */
+ /* __func__, count); */
+
+ count++;
+ }
+ }
+T_EXIT:
+ if (filp && (spi_Sendbulkbuffer == NULL))
+ set_fs(oldfs);
+ /* Free SPI bulk buffer*/
+ if (spi_bulkbuffer != NULL) {
+ kfree(spi_bulkbuffer);
+ spi_bulkbuffer = NULL;
+ }
+
+ if (status != ERR_SUCCESS)
+ misp_err("%s error: %d", __func__, status);
+ else
+ misp_info("%s success", __func__);
+
+ return status;
+}
+#endif
+
+static struct misp_intf_fn_t intf_spi_fn = {
+ .send = mini_isp_intf_spi_send,
+ .recv = mini_isp_intf_spi_recv,
+ .read = mini_isp_intf_spi_read,
+ .write = mini_isp_intf_spi_write,
+ .send_bulk = mini_isp_intf_spi_send_bulk,
+};
+
+static int mini_isp_intf_spi_probe(struct spi_device *spi)
+{
+ int status = 0;
+
+ misp_info("%s - start", __func__);
+
+ /*step 1: alloc driver data struct*/
+ misp_intf_spi_data = kzalloc(sizeof(struct misp_data), GFP_KERNEL);
+ if (!misp_intf_spi_data) {
+ status = -EINVAL;
+ misp_err("%s step1. probe - alloc misp_intf_spi_data error",
+ __func__);
+ return -ENOMEM;
+ }
+ misp_info("%s - step1 done.", __func__);
+
+ /*step 2: init driver data*/
+ misp_intf_spi_data->cfg.spi = spi;
+ misp_intf_spi_data->intf_fn = &intf_spi_fn;
+ misp_intf_spi_data->bulk_cmd_blocksize = SPI_TX_BULK_SIZE;
+
+ misp_info("%s - step2 done.", __func__);
+
+ /*step 3: setup spi*/
+ spi->mode = SPI_MODE;
+ spi->max_speed_hz = SPI_BUS_SPEED_BOOT;
+ spi->bits_per_word = 8;
+ status = spi_setup(spi);
+ if (status < 0) {
+ misp_err("%s step3. probe - setup spi error", __func__);
+ goto setup_spi_error;
+ }
+ misp_info("%s - step3 done.", __func__);
+
+ /*step 3: setup recource : gpio, sem*/
+ status = mini_isp_setup_resource(&spi->dev, misp_intf_spi_data);
+ if (status < 0) {
+ misp_err("%s step4. probe - setup resource error", __func__);
+ goto setup_spi_error;
+ }
+ misp_info("%s - step4 done.", __func__);
+
+ /*setp last: set driver_data to device*/
+ spi_set_drvdata(spi, misp_intf_spi_data);
+ set_mini_isp_data(misp_intf_spi_data, INTF_SPI_READY);
+
+ misp_info("%s -success", __func__);
+ mini_isp_get_chip_id();
+ goto probe_done;
+
+setup_spi_error:
+ kfree(misp_intf_spi_data);
+ misp_intf_spi_data = NULL;
+
+probe_done:
+ return status;
+}
+
+static int mini_isp_intf_spi_remove(struct spi_device *spi)
+{
+ kfree(misp_intf_spi_data);
+ return 0;
+}
+
+/*Compatible node must match dts*/
+static const struct of_device_id mini_isp_dt_spi_match[] = {
+ { .compatible = "altek,isp",},
+ { },
+};
+MODULE_DEVICE_TABLE(of, mini_isp_dt_spi_match);
+
+
+struct spi_driver mini_isp_intf_spi = {
+ .driver = {
+ .name = "altek_isp",
+ .owner = THIS_MODULE,
+ .of_match_table = mini_isp_dt_spi_match,
+ },
+ .probe = mini_isp_intf_spi_probe,
+ .remove = mini_isp_intf_spi_remove,
+};
diff --git a/drivers/media/platform/altek/miniisp_isp.c b/drivers/media/platform/altek/miniisp_isp.c
new file mode 100644
index 0000000..4e0226a
--- /dev/null
+++ b/drivers/media/platform/altek/miniisp_isp.c
@@ -0,0 +1,2038 @@
+/*
+ * File: miniisp_spi.c
+ * Description: Mini ISP sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2017/04/11; LouisWang; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/************************************************************
+* Include File *
+*************************************************************/
+/* Linux headers*/
+#include <linux/module.h>
+#include <linux/dma-mapping.h>
+#include <linux/delay.h>
+#include <linux/buffer_head.h>
+#include <linux/of_gpio.h>
+
+
+#include "include/miniisp.h"
+#include "include/miniisp_ctrl.h"
+#include "include/miniisp_customer_define.h"
+#include "include/miniisp_chip_base_define.h"
+#include "include/ispctrl_if_master.h"
+#include "include/isp_camera_cmd.h"
+#include "include/error/miniisp_err.h"
+
+#if EN_605_IOCTRL_INTF
+/* ALTEK_AL6100_ECHO >>> */
+#include "include/miniisp_ctrl_intf.h"
+/* ALTEK_AL6100_ECHO <<< */
+#endif
+
+#ifdef ALTEK_TEST
+#include "include/altek_test.h"
+#endif
+
+/****************************************************************************
+* Private Constant Definition *
+****************************************************************************/
+#define DEBUG_NODE 0
+/*#define DEBUG_ALERT*/
+#define MINI_ISP_LOG_TAG "[miniisp_isp]"
+/*drv debug defination*/
+#define _SPI_DEBUG
+
+/****************************************************************************
+* Private Global Variable *
+****************************************************************************/
+static struct misp_global_variable *misp_drv_global_variable;
+static struct class *mini_isp_class;
+static struct device *mini_isp_dev;
+
+#if EN_605_IOCTRL_INTF
+/* ALTEK_AL6100_ECHO >>> */
+struct file *l_internal_file[ECHO_OTHER_MAX];
+/* ALTEK_AL6100_ECHO <<< */
+#endif
+
+extern u16 fw_version_before_point;
+extern u16 fw_version_after_point;
+extern char fw_build_by[];
+extern char fw_project_name[];
+extern u32 sc_build_date;
+/************************************************************
+ * Public Global Variable
+ *************************************************************/
+
+/************************************************************
+ * Private Macro Definition
+ *************************************************************/
+
+/************************************************************
+ * Public Function Prototype
+ *************************************************************/
+
+
+/************************************************************
+ * Private Function
+ *************************************************************/
+#if EN_605_IOCTRL_INTF
+void mini_isp_other_drv_open_l(char *file_name, u8 type)
+{
+
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+
+ misp_info("%s filepath : %s", __func__, file_name);
+
+#if ENABLE_FILP_OPEN_API
+ /* use file open */
+#else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ return;
+#endif
+ if (IS_ERR(l_internal_file[type])) {
+ err = PTR_ERR(l_internal_file[type]);
+ misp_err("%s open file failed. err: %x", __func__, err);
+ } else {
+ misp_info("%s open file success!", __func__);
+ }
+
+}
+#endif
+static ssize_t mini_isp_mode_config_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ /*misp_info("%s - mini_isp_spi_send return %d", __func__, ret);*/
+ return snprintf(buf, 32, "load fw:0 e_to_a:1 a_to_e:2\n");
+}
+
+static ssize_t mini_isp_mode_config_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t size)
+{
+ u8 buf_chip_id_use[4];
+
+ if ('0' == buf[0]) {
+ mini_isp_chip_init();
+ mini_isp_e_to_a();
+ mini_isp_drv_load_fw();
+ } else if ('1' == buf[0]) {
+ mini_isp_chip_init();
+ mini_isp_e_to_a();
+ } else if ('2' == buf[0]) {
+ mini_isp_a_to_e();
+ } else if ('4' == buf[0]) {
+ mini_isp_get_chip_id();
+ } else if ('7' == buf[0]) {
+ buf_chip_id_use[0] = 0;
+ mini_isp_debug_dump_img();
+ mini_isp_a_to_e();
+ mini_isp_chip_base_dump_irp_and_depth_based_register();
+ mini_isp_memory_write(0x10, buf_chip_id_use, 1);
+ mini_isp_e_to_a();
+ } else {
+ mini_isp_poweron();
+ mini_isp_drv_set_bypass_mode(1);
+ }
+ return size;
+}
+
+static DEVICE_ATTR(mini_isp_mode_config, 0660, mini_isp_mode_config_show,
+ mini_isp_mode_config_store);
+
+static ssize_t mini_isp_reset_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ int ret = -EINVAL;
+
+ ret = gpio_get_value(misp_drv_global_variable->reset_gpio);
+ misp_info("%s - reset_gpio is %d", __func__, ret);
+
+ return snprintf(buf, 32, "%d", ret);
+}
+
+static ssize_t mini_isp_reset_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t size)
+{
+ if ('0' == buf[0])
+ gpio_set_value(misp_drv_global_variable->reset_gpio, 0);
+ else
+ gpio_set_value(misp_drv_global_variable->reset_gpio, 1);
+
+ misp_info("%s - ", __func__);
+
+ return size;
+}
+
+static DEVICE_ATTR(mini_isp_reset, 0660,
+ mini_isp_reset_show,
+ mini_isp_reset_store);
+
+
+static ssize_t mini_isp_rectab_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return snprintf(buf, 32, "Set rectab Param!!\n");
+}
+
+static ssize_t mini_isp_rectab_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t size)
+{
+ u8 trans_mode;
+ u32 block_size;
+ struct depth_rectab_invrect_param rect_param[3];
+
+ misp_info("Set rectab start!!");
+
+ /* fill test pattern */
+ memset((u8 *)&rect_param[0], 0xa,
+ 3*sizeof(struct depth_rectab_invrect_param));
+
+ trans_mode = 0;
+ block_size = 64;
+
+ mini_isp_drv_write_depth_rectab_invrect(
+ &rect_param[0], trans_mode, block_size);
+
+ misp_info("Set rectab end!!");
+ return size;
+}
+
+static DEVICE_ATTR(mini_isp_rectab, 0660,
+ mini_isp_rectab_show,
+ mini_isp_rectab_store);
+
+ssize_t echo_mini_isp_drv_set_depth_3a_info(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ struct isp_cmd_depth_3a_info depth_3a_info;
+
+ memset(&depth_3a_info, 0, sizeof(struct isp_cmd_depth_3a_info));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %hu %u %hu %hu %hu %hu %hu %hu %hd %hhu\
+ %u %hu %hu %hu %hu %hu %hu %hd %hhu\
+ %hu %hu %hd %hd %hu %hu %hhu",
+ cmd_name,
+ &depth_3a_info.hdr_ratio,
+ &depth_3a_info.main_cam_exp_time,
+ &depth_3a_info.main_cam_exp_gain,
+ &depth_3a_info.main_cam_amb_r_gain,
+ &depth_3a_info.main_cam_amb_g_gain,
+ &depth_3a_info.main_cam_amb_b_gain,
+ &depth_3a_info.main_cam_iso,
+ &depth_3a_info.main_cam_bv,
+ &depth_3a_info.main_cam_vcm_position,
+ &depth_3a_info.main_cam_vcm_status,
+ &depth_3a_info.sub_cam_exp_time,
+ &depth_3a_info.sub_cam_exp_gain,
+ &depth_3a_info.sub_cam_amb_r_gain,
+ &depth_3a_info.sub_cam_amb_g_gain,
+ &depth_3a_info.sub_cam_amb_b_gain,
+ &depth_3a_info.sub_cam_iso,
+ &depth_3a_info.sub_cam_bv,
+ &depth_3a_info.sub_cam_vcm_position,
+ &depth_3a_info.sub_cam_vcm_status,
+ &depth_3a_info.main_cam_isp_d_gain,
+ &depth_3a_info.sub_cam_isp_d_gain,
+ &depth_3a_info.hdr_long_exp_ev_x1000,
+ &depth_3a_info.hdr_short_exp_ev_x1000,
+ &depth_3a_info.ghost_prevent_low,
+ &depth_3a_info.ghost_prevent_high,
+ &depth_3a_info.depth_proc_mode);
+
+ if (ret != 27) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("%hu %u %hu %hu %hu %hu %hu %hu %hd %hhu\
+ %u %hu %hu %hu %hu %hu %hu %hd %hhu\
+ %hu %hu %hd %hd %hu %hu %hhu",
+ depth_3a_info.hdr_ratio,
+ depth_3a_info.main_cam_exp_time,
+ depth_3a_info.main_cam_exp_gain,
+ depth_3a_info.main_cam_amb_r_gain,
+ depth_3a_info.main_cam_amb_g_gain,
+ depth_3a_info.main_cam_amb_b_gain,
+ depth_3a_info.main_cam_iso,
+ depth_3a_info.main_cam_bv,
+ depth_3a_info.main_cam_vcm_position,
+ depth_3a_info.main_cam_vcm_status,
+ depth_3a_info.sub_cam_exp_time,
+ depth_3a_info.sub_cam_exp_gain,
+ depth_3a_info.sub_cam_amb_r_gain,
+ depth_3a_info.sub_cam_amb_g_gain,
+ depth_3a_info.sub_cam_amb_b_gain,
+ depth_3a_info.sub_cam_iso,
+ depth_3a_info.sub_cam_bv,
+ depth_3a_info.sub_cam_vcm_position,
+ depth_3a_info.sub_cam_vcm_status,
+ depth_3a_info.main_cam_isp_d_gain,
+ depth_3a_info.sub_cam_isp_d_gain,
+ depth_3a_info.hdr_long_exp_ev_x1000,
+ depth_3a_info.hdr_short_exp_ev_x1000,
+ depth_3a_info.ghost_prevent_low,
+ depth_3a_info.ghost_prevent_high,
+ depth_3a_info.depth_proc_mode);
+
+ mini_isp_drv_set_depth_3a_info(&depth_3a_info);
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_depth_auto_interleave_mode(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[4];
+ struct isp_cmd_depth_auto_interleave_param depth_auto_interleave_param;
+
+ memset(&depth_auto_interleave_param, 0,
+ sizeof(struct isp_cmd_depth_auto_interleave_param));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u %u", cmd_name,
+ ¶m[0], ¶m[1], ¶m[2], ¶m[3]);
+ depth_auto_interleave_param.depth_interleave_mode_on_off = (u8) param[0];
+ depth_auto_interleave_param.skip_frame_num_after_illuminator_pulse = (u8) param[1];
+ depth_auto_interleave_param.projector_power_level = (u8) param[2];
+ depth_auto_interleave_param.illuminator_power_level = (u8) param[3];
+
+ if (ret != 5) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("%d, %d, %d, %d",
+ depth_auto_interleave_param.depth_interleave_mode_on_off,
+ depth_auto_interleave_param.skip_frame_num_after_illuminator_pulse,
+ depth_auto_interleave_param.projector_power_level,
+ depth_auto_interleave_param.illuminator_power_level);
+
+ mini_isp_drv_set_depth_auto_interleave_mode(&depth_auto_interleave_param);
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_exposure_param(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[3];
+
+ struct isp_cmd_exposure_param set_exposure_param;
+
+ memset(&set_exposure_param, 0, sizeof(struct isp_cmd_exposure_param));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u", cmd_name, ¶m[0], ¶m[1], ¶m[2]);
+ if (ret != 4) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ set_exposure_param.udExpTime = (u32)param[0];
+ set_exposure_param.uwISO = (u16)param[1];
+ set_exposure_param.ucActiveDevice = (u8)param[2];
+
+ misp_info("menu exposure param: %d %d %d",
+ set_exposure_param.udExpTime,
+ set_exposure_param.uwISO,
+ set_exposure_param.ucActiveDevice);
+
+ mini_isp_drv_set_exposure_param(&set_exposure_param);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_depth_stream_size(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[1];
+
+ struct isp_cmd_depth_stream_size depth_stream_size_param;
+
+ memset(&depth_stream_size_param, 0, sizeof(struct isp_cmd_depth_stream_size));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u", cmd_name, ¶m[0]);
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ depth_stream_size_param.depth_stream_size = (u8)param[0];
+
+ misp_info("depth stream size: %d",
+ depth_stream_size_param.depth_stream_size);
+
+ mini_isp_drv_set_depth_stream_size(&depth_stream_size_param);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_sensor_mode(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u8 sensor_on_off = 0;
+ u8 scenario_id = 0;
+ u8 mipi_tx_skew_enable = 0;
+ u8 ae_weighting_table_index = 0;
+ u8 merge_mode_enable = 0;
+
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %hhu %hhu %hhu %hhu %hhu",
+ cmd_name, &sensor_on_off, &scenario_id, &mipi_tx_skew_enable,
+ &ae_weighting_table_index, &merge_mode_enable);
+
+ if (ret != 6) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("0x%x, 0x%x, 0x%x, 0x%x, 0x%x", sensor_on_off, scenario_id, mipi_tx_skew_enable,
+ ae_weighting_table_index, merge_mode_enable);
+
+ mini_isp_drv_set_sensor_mode(sensor_on_off, scenario_id,
+ mipi_tx_skew_enable, ae_weighting_table_index, merge_mode_enable);
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+
+ssize_t echo_mini_isp_drv_set_output_format(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[3];
+ struct isp_cmd_set_output_format output_format_param;
+
+ memset(&output_format_param, 0, sizeof(struct isp_cmd_set_output_format));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u", cmd_name, ¶m[0], ¶m[1], ¶m[2]);
+ if (ret != 4) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("0x%x, 0x%x, 0x%x", param[0], param[1], param[2]);
+ output_format_param.depth_size = (u8)param[0];
+ output_format_param.reserve[0] = (u8)param[1];
+ output_format_param.reserve[1] = (u8)param[2];
+
+ errcode = mini_isp_drv_set_output_format(&output_format_param);
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_cp_mode(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S!!", __func__);
+ errcode = mini_isp_drv_set_cp_mode();
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_leave_cp_mode(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u8 param[5];
+
+ misp_info("%s S!!", __func__);
+ ret = sscanf(cmd_buf, "%19s %hhu %hhu %hhu %hhu %hhu",
+ cmd_name, ¶m[0], ¶m[1],
+ ¶m[2], ¶m[3], ¶m[4]);
+ if (ret != 6) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+
+ misp_info("0x%x, 0x%x, 0x%x, 0x%x, 0x%x",
+ param[0], param[1], param[2], param[3], param[4]);
+
+ errcode = mini_isp_drv_leave_cp_mode(param[0], param[1], param[2], param[3], param[4]);
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+ssize_t echo_mini_isp_drv_preview_stream_on_off(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u8 tx0_stream_on_off;
+ u8 tx1_stream_on_off;
+
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %hhu %hhu", cmd_name,
+ &tx0_stream_on_off, &tx1_stream_on_off);
+
+ if (ret != 3) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("0x%x, 0x%x",
+ tx0_stream_on_off, tx1_stream_on_off);
+ errcode = mini_isp_drv_preview_stream_on_off(
+ tx0_stream_on_off, tx1_stream_on_off);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_led_power_control(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[8];
+ struct isp_cmd_led_power_control projector_control_param;
+
+ memset(&projector_control_param, 0, sizeof(struct isp_cmd_led_power_control));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u %u %u %u %u %u",
+ cmd_name, ¶m[0], ¶m[1], ¶m[2],
+ ¶m[3], ¶m[4], ¶m[5],
+ ¶m[6], ¶m[7]);
+
+ if (ret != 9) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ projector_control_param.led_on_off = (u8)param[0];
+ projector_control_param.led_power_level = (u8)param[1];
+ projector_control_param.control_projector_id = (u8)param[2];
+ projector_control_param.delay_after_sof = param[3];
+ projector_control_param.pulse_time = param[4];
+ projector_control_param.control_mode = (u8)param[5];
+ projector_control_param.reserved = (u8)param[6];
+ projector_control_param.rolling_shutter = (u8)param[7];
+
+ misp_info("%d, %d, %d, %d, %d, %d, %d, %d",
+ projector_control_param.led_on_off,
+ projector_control_param.led_power_level,
+ projector_control_param.control_projector_id,
+ projector_control_param.delay_after_sof,
+ projector_control_param.pulse_time,
+ projector_control_param.control_mode,
+ projector_control_param.reserved,
+ projector_control_param.rolling_shutter);
+
+ errcode = mini_isp_drv_led_power_control(&projector_control_param);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_active_ae(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[2];
+ struct isp_cmd_active_ae active_ae_param;
+
+ memset(&active_ae_param, 0,
+ sizeof(struct isp_cmd_active_ae));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u",
+ cmd_name, ¶m[0], ¶m[1]);
+
+ if (ret != 3) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+
+ active_ae_param.active_ae = (u8)param[0];
+ active_ae_param.f_number_x1000 = param[1];
+
+ misp_info("%d, %d",
+ active_ae_param.active_ae,
+ active_ae_param.f_number_x1000);
+
+ errcode = mini_isp_drv_active_ae(&active_ae_param);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_isp_ae_control_mode_on_off(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param;
+
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u", cmd_name, ¶m);
+
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("%d", param);
+
+ errcode = mini_isp_drv_isp_ae_control_mode_on_off(param);
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_frame_rate_limits(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[4];
+ struct isp_cmd_frame_rate_limits frame_rate_param;
+
+ memset(&frame_rate_param, 0,
+ sizeof(struct isp_cmd_frame_rate_limits));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u %u", cmd_name,
+ ¶m[0], ¶m[1], ¶m[2], ¶m[3]);
+
+ if (ret != 5) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ frame_rate_param.main_min_framerate_x100 = param[0];
+ frame_rate_param.main_max_framerate_x100 = param[1];
+ frame_rate_param.sub_min_framerate_x100 = param[2];
+ frame_rate_param.sub_max_framerate_x100 = param[3];
+
+ misp_info("%d %d %d %d",
+ frame_rate_param.main_min_framerate_x100,
+ frame_rate_param.main_max_framerate_x100,
+ frame_rate_param.sub_min_framerate_x100,
+ frame_rate_param.sub_max_framerate_x100);
+
+ errcode = mini_isp_drv_set_frame_rate_limits(&frame_rate_param);
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_max_exposure(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[3];
+
+ struct isp_cmd_exposure_param set_max_exposure;
+
+ memset(&set_max_exposure, 0, sizeof(struct isp_cmd_exposure_param));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u",
+ cmd_name, ¶m[0], ¶m[1], ¶m[2]);
+
+ if (ret != 4) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ set_max_exposure.udExpTime = (u32)param[0];
+ set_max_exposure.uwISO = (u16)param[1];
+ set_max_exposure.ucActiveDevice = (u8)param[2];
+
+ misp_info("max exposure param: %d %d %d",
+ set_max_exposure.udExpTime,
+ set_max_exposure.uwISO,
+ set_max_exposure.ucActiveDevice);
+
+ mini_isp_drv_set_max_exposure(&set_max_exposure);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_frame_sync_control(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[5];
+ struct isp_cmd_frame_sync_control frame_sync_control_param;
+
+ memset(&frame_sync_control_param, 0, sizeof(struct isp_cmd_frame_sync_control));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u %u %u", cmd_name,
+ ¶m[0], ¶m[1], ¶m[2], ¶m[3], ¶m[4]);
+
+ if (ret != 6) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ frame_sync_control_param.control_deviceID = (u8) param[0];
+ frame_sync_control_param.delay_framephase = (u8) param[1];
+ frame_sync_control_param.active_framephase = (u8) param[2];
+ frame_sync_control_param.deactive_framephase = (u8)param[3];
+ frame_sync_control_param.active_timelevel = (u8) param[4];
+
+ misp_info("%d %d %d %d %d",
+ frame_sync_control_param.control_deviceID,
+ frame_sync_control_param.delay_framephase,
+ frame_sync_control_param.active_framephase,
+ frame_sync_control_param.deactive_framephase,
+ frame_sync_control_param.active_timelevel);
+
+ errcode = mini_isp_drv_frame_sync_control(&frame_sync_control_param);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_shot_mode(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[2];
+ struct isp_cmd_set_shot_mode set_shot_mode_param;
+
+ memset(&set_shot_mode_param, 0, sizeof(struct isp_cmd_set_shot_mode));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u", cmd_name, ¶m[0], ¶m[1]);
+
+ if (ret != 3) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ set_shot_mode_param.shot_mode = (u8) param[0];
+ set_shot_mode_param.frame_rate = (u16) param[1];
+
+ misp_info("%d %d",
+ set_shot_mode_param.shot_mode,
+ set_shot_mode_param.frame_rate);
+
+ errcode = mini_isp_drv_set_shot_mode(&set_shot_mode_param);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_lighting_ctrl(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u8 i = 0;
+ u32 param[25];
+ struct isp_cmd_lighting_ctrl lighting_ctrl;
+
+ memset(&lighting_ctrl, 0, sizeof(struct isp_cmd_lighting_ctrl));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u\
+ %u %u %u %u %u",
+ cmd_name, ¶m[0], ¶m[1], ¶m[2],
+ ¶m[3], ¶m[4], ¶m[5], ¶m[6],
+ ¶m[7], ¶m[8], ¶m[9], ¶m[10],
+ ¶m[11], ¶m[12], ¶m[13], ¶m[14],
+ ¶m[15], ¶m[16], ¶m[17], ¶m[18],
+ ¶m[19], ¶m[20], ¶m[21], ¶m[22],
+ ¶m[23], ¶m[24]);
+
+ if (ret != 26) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ lighting_ctrl.cycle_len = param[0];
+ for (i = 0; i < lighting_ctrl.cycle_len; i++) {
+ lighting_ctrl.cycle[i].source = (u8)param[i*3+1];
+ lighting_ctrl.cycle[i].TxDrop = (u8)param[i*3+2];
+ lighting_ctrl.cycle[i].co_frame_rate = (u16)param[i*3+3];
+ }
+
+ misp_info("cycle_len: %d", lighting_ctrl.cycle_len);
+ for (i = 0; i < lighting_ctrl.cycle_len; i++) {
+ misp_info("cycle[%d]: %d, %d, %d", i,
+ lighting_ctrl.cycle[i].source,
+ lighting_ctrl.cycle[i].TxDrop,
+ lighting_ctrl.cycle[i].co_frame_rate);
+ }
+
+ errcode = mini_isp_drv_lighting_ctrl(&lighting_ctrl);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_depth_compensation(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[4];
+ u8 en_update = 0;
+ struct isp_cmd_depth_compensation_param depth_compensation_param;
+
+ memset(&depth_compensation_param, 0,
+ sizeof(struct isp_cmd_depth_compensation_param));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u %u", cmd_name,
+ ¶m[0], ¶m[1], ¶m[2], ¶m[3]);
+
+ if (ret != 5) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ en_update = (param[0] << 4) | param[1];
+ depth_compensation_param.en_updated = (u8)en_update;
+ depth_compensation_param.short_distance_value = (u16)param[2];
+ depth_compensation_param.compensation = (s8)param[3];
+
+ misp_info("0x%x %d %d",
+ depth_compensation_param.en_updated,
+ depth_compensation_param.short_distance_value,
+ depth_compensation_param.compensation);
+
+ mini_isp_drv_depth_compensation(&depth_compensation_param);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_cycle_trigger_depth_process(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[3];
+
+ struct isp_cmd_cycle_trigger_depth_process depth_cycle_param;
+
+ memset(&depth_cycle_param, 0,
+ sizeof(struct isp_cmd_cycle_trigger_depth_process));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u", cmd_name,
+ ¶m[0], ¶m[1], ¶m[2]);
+
+ if (ret != 4) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ depth_cycle_param.cycleLen = (u8)param[0];
+ depth_cycle_param.depth_triggerBitField = (u16)param[1];
+ depth_cycle_param.depthoutput_triggerBitField = (u16)param[2];
+
+ misp_info("depth cycle len: 0%d %d %d",
+ depth_cycle_param.cycleLen,
+ depth_cycle_param.depth_triggerBitField,
+ depth_cycle_param.depthoutput_triggerBitField);
+
+ mini_isp_drv_cycle_trigger_depth_process(&depth_cycle_param);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_min_exposure(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[3];
+
+ struct isp_cmd_exposure_param set_min_exposure;
+
+ memset(&set_min_exposure, 0,
+ sizeof(struct isp_cmd_exposure_param));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u %u", cmd_name,
+ ¶m[0], ¶m[1], ¶m[2]);
+
+ if (ret != 4) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ set_min_exposure.udExpTime = (u32)param[0];
+ set_min_exposure.uwISO = (u16)param[1];
+ set_min_exposure.ucActiveDevice = (u8)param[2];
+
+ misp_info("min exposure param: %d %d %d",
+ set_min_exposure.udExpTime,
+ set_min_exposure.uwISO,
+ set_min_exposure.ucActiveDevice);
+
+ mini_isp_drv_set_min_exposure(&set_min_exposure);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_max_exposure_slope(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[2];
+
+ struct isp_cmd_max_exposure_slope max_exposure_slope;
+
+ memset(&max_exposure_slope, 0,
+ sizeof(struct isp_cmd_max_exposure_slope));
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u %u", cmd_name,
+ ¶m[0], ¶m[1]);
+
+ if (ret != 3) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ max_exposure_slope.max_exposure_slope = (u32)param[0];
+ max_exposure_slope.ucActiveDevice = (u8)param[1];
+
+ misp_info("max exposure slope: %d %d",
+ max_exposure_slope.max_exposure_slope,
+ max_exposure_slope.ucActiveDevice);
+
+ mini_isp_drv_set_max_exposure_slope(&max_exposure_slope);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_led_active_delay(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 delay_ms = 0;
+
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u", cmd_name, &delay_ms);
+
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("[delay]: %d", delay_ms);
+
+ mini_isp_drv_led_active_delay(delay_ms);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_isp_control_led_level(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 on = 0;
+
+ misp_info("%s S!!", __func__);
+
+ ret = sscanf(cmd_buf, "%19s %u", cmd_name, &on);
+
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("[isp control led level]: %d", on);
+
+ mini_isp_drv_isp_control_led_level((u8)on);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_get_chip_thermal(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ u16 thermal_val;
+
+ misp_info("%s S!!", __func__);
+
+ mini_isp_drv_get_chip_thermal(&thermal_val);
+ misp_info("0x%x", thermal_val);
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_poweron(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S!!", __func__);
+ mini_isp_poweron();
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_poweroff(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S!!", __func__);
+ mini_isp_poweroff();
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_load_fw(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S!!", __func__);
+ misp_info("%s no FSM", __func__);
+ /*check bypass mode be set or not*/
+ /*if yes, leave bypass mode*/
+ mini_isp_check_and_leave_bypass_mode();
+ /*normal case load FW*/
+ errcode = mini_isp_drv_load_fw();
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_write_calibration_data(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param;
+
+ misp_info("%s S!!", __func__);
+ ret = sscanf(cmd_buf, "%19s %u", cmd_name, ¶m);
+
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("%d", param);
+ if (param == 0 || param == 1) {
+ misp_info("Currently echo mode not support"
+ " IQ calibration and packdata!");
+ goto ERR;
+ }
+ errcode = mini_isp_drv_write_calibration_data(param, NULL, 0);
+ERR:
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_write_spinor_data(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param;
+
+ misp_info("%s S!!", __func__);
+ ret = sscanf(cmd_buf, "%19s %u", cmd_name, ¶m);
+
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("%d", param);
+ if (param > 1)
+ goto ERR;
+
+ errcode = mini_isp_drv_write_spinor_data(param);
+ERR:
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_get_chip_id(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S!!", __func__);
+ errcode = mini_isp_get_chip_id();
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_get_comlog(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ struct common_log_hdr_info info;
+
+ memset(&info, 0, sizeof(struct common_log_hdr_info));
+ misp_info("%s S!!", __func__);
+
+ info.block_size = SPI_TX_BULK_SIZE;
+ info.total_size = LEVEL_LOG_BUFFER_SIZE;
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_set_register(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param[2];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ misp_info("%s S", __func__);
+ /* switch to E mode */
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ ret = sscanf(cmd_buf, "%19s 0x%x 0x%x", cmd_name, ¶m[0], ¶m[1]);
+ if (ret != 3) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ mini_isp_register_write(param[0], param[1]);
+ misp_info("set register 0x%x, 0x%x", param[0], param[1]);
+
+ /* switch to A mode */
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_get_register(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ u32 param;
+ u32 reg_val;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ misp_info("%s S", __func__);
+ /* switch to E mode */
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ ret = sscanf(cmd_buf, "%19s 0x%x", cmd_name, ¶m);
+
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ mini_isp_register_read(param, ®_val);
+ misp_info("get register 0x%x, 0x%x", param, reg_val);
+
+ /* switch to A mode */
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_memdump(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ char cmd_name[20];
+ char filename[80];
+ u32 param[2];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ misp_info("%s S", __func__);
+ /* switch to E mode */
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ ret = sscanf(cmd_buf, "%19s 0x%x %u", cmd_name, ¶m[0], ¶m[1]);
+
+ if (ret != 3) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("Get mem 0x%x, %d\n", param[0], param[1]);
+
+ snprintf(filename, 80, "memdump_0x%x_%d", param[0], param[1]);
+ mini_isp_memory_read_then_write_file(param[0], param[1],
+ MINIISP_INFO_DUMPLOCATION, filename);
+
+ /* switch to A mode */
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_show_version(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ misp_info("MINIISP_DRIVER_VERSION: %s", MINIISP_DRIVER_VERSION);
+ misp_info("AL6100 project: %s, fw ver: %05d.%05d, build by %s",
+ fw_project_name, fw_version_before_point, fw_version_after_point, fw_build_by);
+ misp_info("SC table build data: %d", sc_build_date);
+ misp_info("set fsm status: %d", dev_global_variable->now_state);
+ return errcode;
+}
+
+ssize_t echo_set_fsm_status(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ u32 param;
+ char cmd_name[20];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ ret = sscanf(cmd_buf, "%19s %u", cmd_name, ¶m);
+
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ dev_global_variable->now_state = param;
+ misp_info("set fsm status: %d", dev_global_variable->now_state);
+ return errcode;
+}
+
+ssize_t echo_cfg_cmd_send(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ u32 param;
+ char cmd_name[20];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ ret = sscanf(cmd_buf, "%19s %u", cmd_name, ¶m);
+
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ dev_global_variable->en_cmd_send = param;
+ misp_info("set en_cmd_send: %d", dev_global_variable->en_cmd_send);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_a_to_e(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s, S", __func__);
+ mini_isp_a_to_e();
+ misp_info("%s, E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_e_to_a(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s, S", __func__);
+ mini_isp_e_to_a();
+ misp_info("%s, E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_chip_init(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s, S", __func__);
+ mini_isp_chip_init();
+ misp_info("%s, E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_debug_dump_img(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s, S", __func__);
+ errcode = mini_isp_debug_dump_img();
+ misp_info("%s, E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_drv_set_bypass_mode(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ u16 param;
+ char cmd_name[20];
+
+ misp_info("%s S", __func__);
+ ret = sscanf(cmd_buf, "%19s %hu", cmd_name, ¶m);
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+ if (param == 0)
+ param = 1;
+/* errcode = mini_isp_drv_set_bypass_mode(param); */
+ errcode = mini_isp_pure_bypass(param);
+
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_utility_read_reg_e_mode_for_bypass_use(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S", __func__);
+ errcode = mini_isp_utility_read_reg_e_mode_for_bypass_use();
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_utility_read_reg_e_mode(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S", __func__);
+ errcode = mini_isp_utility_read_reg_e_mode();
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_debug_packdata_dump(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S", __func__);
+ errcode = mini_isp_debug_packdata_dump();
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_debug_IQCalib_dump(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S", __func__);
+ errcode = mini_isp_debug_IQCalib_dump();
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_debug_metadata_dump(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S", __func__);
+ errcode = mini_isp_debug_metadata_dump();
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+
+
+ssize_t echo_mini_isp_debug_rect_combo_dump(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ u8 param;
+ char cmd_name[20];
+
+ misp_info("%s S", __func__);
+ ret = sscanf(cmd_buf, "%19s %hhu", cmd_name, ¶m);
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ misp_info("dump mode %hhu", param);
+ errcode = mini_isp_debug_depth_rect_combo_dump(param);
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_debug_depth_info(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S", __func__);
+ errcode = mini_isp_debug_depth_info();
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+
+ssize_t echo_mini_isp_debug_metadata_info(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S", __func__);
+ errcode = mini_isp_debug_metadata_info();
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_debug_sensor_info(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ u8 param;
+ char cmd_name[20];
+
+ misp_info("%s S", __func__);
+ ret = sscanf(cmd_buf, "%19s %hhu", cmd_name, ¶m);
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ errcode = mini_isp_debug_sensor_info(param);
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_debug_led_info(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ u8 param;
+ char cmd_name[20];
+
+ misp_info("%s S", __func__);
+ ret = sscanf(cmd_buf, "%19s %hhu", cmd_name, ¶m);
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ errcode = mini_isp_debug_led_info(param);
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_debug_rx_fps_info(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ u8 param[2];
+ char cmd_name[20];
+
+ misp_info("%s S", __func__);
+ ret = sscanf(cmd_buf, "%19s %hhu %hhu", cmd_name, ¶m[0], ¶m[1]);
+ if (ret != 3) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ if (param[0] == 0) {
+ misp_info("rx_fps_info initial!");
+ errcode = mini_isp_debug_mipi_rx_fps_start(param[1]);
+ } else if (param[0] == 1) {
+ misp_info("rx_fps_info exit!");
+ mini_isp_debug_mipi_rx_fps_stop();
+ }
+
+ misp_info("%s E", __func__);
+ return errcode;
+}
+ssize_t echo_mini_isp_debug_GPIO_Status(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ u8 param;
+ char cmd_name[20];
+
+ misp_info("%s S", __func__);
+ ret = sscanf(cmd_buf, "%19s %hhu", cmd_name, ¶m);
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ errcode = mini_isp_debug_GPIO_Status(param);
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_eeprom_wp(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ struct misp_global_variable *dev_global_variable;
+ u8 param;
+ char cmd_name[20];
+
+ misp_info("%s S", __func__);
+ ret = sscanf(cmd_buf, "%19s %hhu", cmd_name, ¶m);
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ if (WP_GPIO != NULL) {
+ dev_global_variable = get_mini_isp_global_variable();
+ if (param)
+ gpio_set_value(dev_global_variable->wp_gpio, 1);
+ else
+ gpio_set_value(dev_global_variable->wp_gpio, 0);
+ }
+ misp_info("%s E", __func__);
+ return errcode;
+}
+
+ssize_t echo_mini_isp_eeprom_op(const char *cmd_buf)
+{
+ errcode errcode = ERR_SUCCESS;
+ int ret;
+ struct misp_global_variable *dev_global_variable;
+ u8 filename[80];
+ struct file *filp = NULL;
+ mm_segment_t oldfs;
+ off_t currpos;
+ u8 *data_buf_addr;
+ u32 total_size;
+ u8 param;
+ char cmd_name[20];
+
+ misp_info("%s S", __func__);
+ ret = sscanf(cmd_buf, "%19s %hhu", cmd_name, ¶m);
+ if (ret != 2) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+
+ if (param == 1) {
+ dev_global_variable = get_mini_isp_global_variable();
+
+ snprintf(filename, 80, "%s/WRITE_OTP_DATA.bin",
+ MINIISP_INFO_DUMPLOCATION);
+
+ oldfs = get_fs();
+ set_fs(KERNEL_DS);
+
+ /*open the file*/
+ #if ENABLE_FILP_OPEN_API
+ /* use file open */
+ #else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ goto code_end;
+ #endif
+ /*get the file size*/
+ currpos = vfs_llseek(filp, 0L, SEEK_END);
+ if (currpos == -1) {
+ misp_err("%s llseek failed", __func__);
+ errcode = ~ERR_SUCCESS;
+ goto code_end;
+ }
+ total_size = (u32)currpos;
+ misp_info("%s filesize : %d", __func__, total_size);
+ vfs_llseek(filp, 0L, SEEK_SET);
+
+ if (total_size) {
+ data_buf_addr = kzalloc(total_size, GFP_KERNEL);
+ if (data_buf_addr == NULL) {
+ misp_err("%s - Kzalloc data buf fail ", __func__);
+ goto code_end;
+ }
+ errcode = vfs_read(filp, data_buf_addr, total_size,
+ &filp->f_pos);
+
+ if (errcode == -1) {
+ misp_err("%s - Read file failed.", __func__);
+ } else {
+ if (WP_GPIO != NULL)
+ gpio_set_value(dev_global_variable->wp_gpio, 0);
+
+ errcode = mini_isp_drv_write_calibration_data(9,
+ data_buf_addr, total_size);
+ misp_info("%s write otp data = %x", __func__, errcode);
+
+ if (WP_GPIO != NULL)
+ gpio_set_value(dev_global_variable->wp_gpio, 1);
+ }
+ kfree(data_buf_addr);
+ }
+code_end:
+ set_fs(oldfs);
+ /*close the file*/
+ filp_close(filp, NULL);
+ } else if (param == 2)
+ errcode = mini_isp_drv_read_calibration_data();
+ else
+ misp_err("%s - Not Support ", __func__);
+
+ misp_info("%s E!!", __func__);
+ return errcode;
+}
+
+ssize_t echo_test(const char *cmd_buf)
+{
+ size_t errcode = ERR_SUCCESS;
+
+ misp_info("%s S", __func__);
+
+ misp_info("%s, E", __func__);
+ return errcode;
+}
+
+struct echo_cmd_format {
+ u32 opcode;
+ char cmd_name[30];
+ ssize_t (*pfunc)(const char *cmd_buf);
+};
+
+struct echo_cmd_format echo_cmd_list[] = {
+ {.opcode = 0x10B9, .cmd_name = "depth_3a_info",
+ .pfunc = echo_mini_isp_drv_set_depth_3a_info},
+ {.opcode = 0x10BC, .cmd_name = "interleave",
+ .pfunc = echo_mini_isp_drv_set_depth_auto_interleave_mode},
+ {.opcode = 0x10BF, .cmd_name = "set_menu_exposure",
+ .pfunc = echo_mini_isp_drv_set_exposure_param},
+ {.opcode = 0x10C0, .cmd_name = "set_depth_stream_size",
+ .pfunc = echo_mini_isp_drv_set_depth_stream_size},
+ {.opcode = 0x300A, .cmd_name = "set_sensor",
+ .pfunc = echo_mini_isp_drv_set_sensor_mode},
+ {.opcode = 0x300D, .cmd_name = "output_format",
+ .pfunc = echo_mini_isp_drv_set_output_format},
+ {.opcode = 0x300E, .cmd_name = "enter_cp",
+ .pfunc = echo_mini_isp_drv_set_cp_mode},
+ {.opcode = 0x3010, .cmd_name = "streamon",
+ .pfunc = echo_mini_isp_drv_preview_stream_on_off},
+ {.opcode = 0x3012, .cmd_name = "led_power",
+ .pfunc = echo_mini_isp_drv_led_power_control},
+ {.opcode = 0x3013, .cmd_name = "active_ae",
+ .pfunc = echo_mini_isp_drv_active_ae},
+ {.opcode = 0x3014, .cmd_name = "ae_onoff",
+ .pfunc = echo_mini_isp_drv_isp_ae_control_mode_on_off},
+ {.opcode = 0x3015, .cmd_name = "framerate",
+ .pfunc = echo_mini_isp_drv_set_frame_rate_limits},
+ {.opcode = 0x3017, .cmd_name = "set_max_exposure",
+ .pfunc = echo_mini_isp_drv_set_max_exposure},
+ {.opcode = 0x3019, .cmd_name = "frame_sync",
+ .pfunc = echo_mini_isp_drv_frame_sync_control},
+ {.opcode = 0x301A, .cmd_name = "shot_mode",
+ .pfunc = echo_mini_isp_drv_set_shot_mode},
+ {.opcode = 0x301B, .cmd_name = "lighting_ctrl",
+ .pfunc = echo_mini_isp_drv_lighting_ctrl},
+ {.opcode = 0x301C, .cmd_name = "depth_compensation",
+ .pfunc = echo_mini_isp_drv_depth_compensation},
+ {.opcode = 0x301D, .cmd_name = "cycle_trigger_depth",
+ .pfunc = echo_mini_isp_drv_cycle_trigger_depth_process},
+ {.opcode = 0x301E, .cmd_name = "set_min_exposure",
+ .pfunc = echo_mini_isp_drv_set_min_exposure},
+ {.opcode = 0x301F, .cmd_name = "set_max_exposure_slop",
+ .pfunc = echo_mini_isp_drv_set_max_exposure_slope},
+ {.opcode = 0x3020, .cmd_name = "led_active_delay",
+ .pfunc = echo_mini_isp_drv_led_active_delay},
+ {.opcode = 0x3021, .cmd_name = "isp_control_led_level",
+ .pfunc = echo_mini_isp_drv_isp_control_led_level},
+ {.opcode = 0x3022, .cmd_name = "get_chip_thermal",
+ .pfunc = echo_mini_isp_drv_get_chip_thermal},
+ {.opcode = 0xFFFF, .cmd_name = "power_on",
+ .pfunc = echo_mini_isp_poweron},
+ {.opcode = 0xFFFF, .cmd_name = "power_off",
+ .pfunc = echo_mini_isp_poweroff},
+ {.opcode = 0xFFFF, .cmd_name = "load_fw",
+ .pfunc = echo_mini_isp_drv_load_fw},
+ {.opcode = 0xFFFF, .cmd_name = "load_cali",
+ .pfunc = echo_mini_isp_drv_write_calibration_data},
+ {.opcode = 0xFFFF, .cmd_name = "load_spinor",
+ .pfunc = echo_mini_isp_drv_write_spinor_data},
+ {.opcode = 0xFFFF, .cmd_name = "get_chip_id",
+ .pfunc = echo_mini_isp_get_chip_id},
+ {.opcode = 0xFFFF, .cmd_name = "leave_cp",
+ .pfunc = echo_mini_isp_drv_leave_cp_mode},
+ {.opcode = 0xFFFF, .cmd_name = "comlog",
+ .pfunc = echo_get_comlog},
+ {.opcode = 0xFFFF, .cmd_name = "setreg",
+ .pfunc = echo_set_register},
+ {.opcode = 0xFFFF, .cmd_name = "getreg",
+ .pfunc = echo_get_register},
+ {.opcode = 0xFFFF, .cmd_name = "memdump",
+ .pfunc = echo_memdump},
+ {.opcode = 0xFFFF, .cmd_name = "version",
+ .pfunc = echo_show_version},
+ {.opcode = 0xFFFF, .cmd_name = "set_fsm_status",
+ .pfunc = echo_set_fsm_status},
+ {.opcode = 0xFFFF, .cmd_name = "cfg_cmd_send",
+ .pfunc = echo_cfg_cmd_send},
+ {.opcode = 0xFFFF, .cmd_name = "a2e",
+ .pfunc = echo_mini_isp_a_to_e},
+ {.opcode = 0xFFFF, .cmd_name = "e2a",
+ .pfunc = echo_mini_isp_e_to_a},
+ {.opcode = 0xFFFF, .cmd_name = "chip_init",
+ .pfunc = echo_mini_isp_chip_init},
+ {.opcode = 0xFFFF, .cmd_name = "pure_bypass",
+ .pfunc = echo_mini_isp_drv_set_bypass_mode},
+ {.opcode = 0xFFFF, .cmd_name = "dump_bypass_reg",
+ .pfunc = echo_mini_isp_utility_read_reg_e_mode_for_bypass_use},
+ {.opcode = 0xFFFF, .cmd_name = "dump_normal_reg",
+ .pfunc = echo_mini_isp_utility_read_reg_e_mode},
+ {.opcode = 0xFFFF, .cmd_name = "dump_packdata",
+ .pfunc = echo_mini_isp_debug_packdata_dump},
+ {.opcode = 0xFFFF, .cmd_name = "dump_IQCalib",
+ .pfunc = echo_mini_isp_debug_IQCalib_dump},
+ {.opcode = 0xFFFF, .cmd_name = "dump_Meta",
+ .pfunc = echo_mini_isp_debug_metadata_dump},
+ {.opcode = 0xFFFF, .cmd_name = "dump_irp_img",
+ .pfunc = echo_mini_isp_debug_dump_img},
+ {.opcode = 0xFFFF, .cmd_name = "dump_depth_reg",
+ .pfunc = echo_mini_isp_debug_rect_combo_dump},
+ {.opcode = 0xFFFF, .cmd_name = "debug_depth_info",
+ .pfunc = echo_mini_isp_debug_depth_info},
+ {.opcode = 0xFFFF, .cmd_name = "debug_metadata_info",
+ .pfunc = echo_mini_isp_debug_metadata_info},
+ {.opcode = 0xFFFF, .cmd_name = "debug_sensor_info",
+ .pfunc = echo_mini_isp_debug_sensor_info},
+ {.opcode = 0xFFFF, .cmd_name = "debug_led_info",
+ .pfunc = echo_mini_isp_debug_led_info},
+ {.opcode = 0xFFFF, .cmd_name = "debug_rx_fps_info",
+ .pfunc = echo_mini_isp_debug_rx_fps_info},
+ {.opcode = 0xFFFF, .cmd_name = "debug_GPIO_status",
+ .pfunc = echo_mini_isp_debug_GPIO_Status},
+ {.opcode = 0xFFFF, .cmd_name = "eeprom_wp",
+ .pfunc = echo_mini_isp_eeprom_wp},
+ {.opcode = 0xFFFF, .cmd_name = "eeprom_op",
+ .pfunc = echo_mini_isp_eeprom_op},
+ {.opcode = 0xFFFF, .cmd_name = "test",
+ .pfunc = echo_test},
+};
+
+#define echo_cmd_list_len \
+ (sizeof(echo_cmd_list) / sizeof(struct echo_cmd_format))
+
+static ssize_t mini_isp_cmd_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ /* print cmd list */
+ u32 total_len = 0, count = 0;
+ u32 i = 0;
+
+ for (i = 0; i < echo_cmd_list_len; i++) {
+ count = snprintf(buf, 70, "%s\n", echo_cmd_list[i].cmd_name);
+ buf += count; /* move buffer pointer */
+ total_len += count;
+ }
+
+ return total_len;
+}
+
+static ssize_t mini_isp_cmd_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t size)
+{
+ char cmd_name[20];
+ size_t errcode = ERR_SUCCESS;
+ int ret;
+ u32 opcode = 0x0;
+ u32 err = ERR_SUCCESS;
+ u32 loopidx = 0;
+
+ ret = sscanf(buf, "%19s", cmd_name);
+ if (ret != 1) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+ /* check first input is opcode or cmd_name */
+ if (cmd_name[0] == '0' && cmd_name[1] == 'x') {
+ ret = sscanf(cmd_name, "0x%x", &opcode);
+
+ if (ret != 1) {
+ errcode = -EINVAL;
+ return errcode;
+ }
+ }
+
+ for (loopidx = 0; loopidx < echo_cmd_list_len; loopidx++) {
+ if (echo_cmd_list[loopidx].opcode == opcode ||
+ strcmp(echo_cmd_list[loopidx].cmd_name,
+ cmd_name) == 0){
+
+ err = echo_cmd_list[loopidx].pfunc(buf);
+ if (err)
+ misp_info("%s, err: 0x%x", __func__, err);
+
+ return size;
+ }
+ }
+
+ misp_info("command not find!");
+ return size;
+}
+
+static
+DEVICE_ATTR(mini_isp_cmd, 0660, mini_isp_cmd_show, mini_isp_cmd_store);
+
+/************************************************************
+* Public Function *
+*************************************************************/
+
+struct misp_data *get_mini_isp_intf(int i2c_type)
+{
+ if (misp_drv_global_variable->intf_status & INTF_SPI_READY) {
+ return get_mini_isp_intf_spi();
+ } else if (misp_drv_global_variable->intf_status & INTF_I2C_READY) {
+ return get_mini_isp_intf_i2c(i2c_type);
+ /*} else if (misp_drv_global_variable->intf_status & INTF_CCI_READY) {
+ return get_mini_isp_intf_cci(i2c_type);*/
+ } else {
+ misp_err("%s - error i2c type %d", __func__, i2c_type);
+ return NULL;
+ }
+}
+void set_mini_isp_data(struct misp_data *data, int intf_type)
+{
+ if (!misp_drv_global_variable)
+ misp_err("%s - set global_variable error", __func__);
+ else
+ misp_drv_global_variable->intf_status |= intf_type;
+}
+
+struct misp_global_variable *get_mini_isp_global_variable(void)
+{
+ if (!misp_drv_global_variable) {
+ misp_err("%s - get global_variable error", __func__);
+ return NULL;
+ } else {
+ return misp_drv_global_variable;
+ }
+}
+
+int mini_isp_setup_resource(struct device *dev, struct misp_data *drv_data)
+{
+ int status = 0;
+
+ misp_info("%s - start", __func__);
+ if (misp_drv_global_variable != NULL) {
+ misp_err("%s - resource already been setupped", __func__);
+ goto setup_done;
+ }
+
+ /*step 1: alloc misp_drv_global_variable*/
+ misp_drv_global_variable =
+ kzalloc(sizeof(*misp_drv_global_variable), GFP_KERNEL);
+
+ if (!misp_drv_global_variable) {
+ misp_info("%s - Out of memory", __func__);
+ status = -ENOMEM;
+ goto alloc_fail;
+ }
+ misp_info("%s - step1 done.", __func__);
+
+ /*step 2: init mutex and gpio resource*/
+ mutex_init(&misp_drv_global_variable->busy_lock);
+ status = mini_isp_gpio_init(dev, drv_data, misp_drv_global_variable);
+ if (status < 0) {
+ misp_info("%s - gpio init fail", __func__);
+ goto setup_fail;
+ }
+ misp_info("%s - step2 done.", __func__);
+
+ misp_drv_global_variable->before_booting = 1;
+ misp_drv_global_variable->en_cmd_send = 1;
+
+ /*step 3: register to VFS as character device*/
+ mini_isp_class = class_create(THIS_MODULE, "mini_isp");
+ if (IS_ERR(mini_isp_class))
+ misp_err("Failed to create class(mini_isp_class)!");
+ mini_isp_dev = miniisp_chdev_create(mini_isp_class);
+
+ if (IS_ERR(mini_isp_dev))
+ misp_err("Failed to create device(mini_isp_dev)!");
+
+ status = device_create_file(mini_isp_dev,
+ &dev_attr_mini_isp_mode_config);
+
+ if (status < 0)
+ misp_err("Failed to create device file(%s)!",
+ dev_attr_mini_isp_mode_config.attr.name);
+
+ if (RESET_GPIO != NULL) {
+ status = device_create_file(mini_isp_dev,
+ &dev_attr_mini_isp_reset);
+
+ if (status < 0)
+ misp_err("Failed to create device file(%s)!",
+ dev_attr_mini_isp_reset.attr.name);
+ }
+
+ status = device_create_file(mini_isp_dev,
+ &dev_attr_mini_isp_rectab);
+ if (status < 0)
+ misp_err("Failed to create device file(%s)!",
+ dev_attr_mini_isp_rectab.attr.name);
+
+ status = device_create_file(mini_isp_dev,
+ &dev_attr_mini_isp_cmd);
+ if (status < 0)
+ misp_err("Failed to create device file(%s)!",
+ dev_attr_mini_isp_cmd.attr.name);
+
+ misp_info("%s - step3 done.", __func__);
+
+ misp_info("%s - success.", __func__);
+ goto setup_done;
+
+setup_fail:
+ mutex_destroy(&misp_drv_global_variable->busy_lock);
+ kfree(misp_drv_global_variable);
+
+alloc_fail:
+ misp_drv_global_variable = NULL;
+
+setup_done:
+ return status;
+}
+
+struct device *mini_isp_getdev(void)
+{
+ return mini_isp_dev;
+}
+
+static int __init mini_isp_init(void)
+{
+ int ret = 0;
+ extern struct spi_driver mini_isp_intf_spi;
+ extern struct i2c_driver mini_isp_intf_i2c_slave;
+ extern struct i2c_driver mini_isp_intf_i2c_top;
+
+ misp_info("%s - start", __func__);
+ isp_mast_camera_profile_para_init();
+
+ /* register SPI driver */
+ ret = spi_register_driver(&mini_isp_intf_spi);
+ if (ret) {
+ misp_err("%s - regsiter failed. Errorcode:%d",
+ __func__, ret);
+ }
+
+ /* register I2C driver */
+ ret = i2c_add_driver(&mini_isp_intf_i2c_slave);
+ if (ret)
+ misp_info("%s - failed. Error:%d", __func__, ret);
+
+ ret = i2c_add_driver(&mini_isp_intf_i2c_top);
+ if (ret)
+ misp_info("%s - failed. Error:%d", __func__, ret);
+
+ misp_info("MINIISP_DRIVER_VERSION: %s", MINIISP_DRIVER_VERSION);
+ misp_info("%s - success", __func__);
+
+ return ret;
+}
+
+static void __exit mini_isp_exit(void)
+{
+ extern struct spi_driver mini_isp_intf_spi;
+ extern struct i2c_driver mini_isp_intf_i2c_slave;
+ extern struct i2c_driver mini_isp_intf_i2c_top;
+
+ misp_info("%s", __func__);
+
+ if (misp_drv_global_variable->irq_gpio)
+ gpio_free(misp_drv_global_variable->irq_gpio);
+
+ /*if (misp_drv_global_variable)*/
+ kfree(misp_drv_global_variable);
+
+ /* unregister all driver */
+ spi_unregister_driver(&mini_isp_intf_spi);
+ i2c_del_driver(&mini_isp_intf_i2c_slave);
+ i2c_del_driver(&mini_isp_intf_i2c_top);
+}
+
+module_init(mini_isp_init);
+module_exit(mini_isp_exit);
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/media/platform/altek/miniisp_top.c b/drivers/media/platform/altek/miniisp_top.c
new file mode 100644
index 0000000..82f1961
--- /dev/null
+++ b/drivers/media/platform/altek/miniisp_top.c
@@ -0,0 +1,1934 @@
+/*
+ * File: miniisp_top.c
+ * Description: Mini ISP sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2017/04/11; LouisWang; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+ /******Include File******/
+ /* Linux headers*/
+#include <linux/delay.h>
+#include <linux/buffer_head.h>
+#include <linux/namei.h>
+#include <linux/fcntl.h>
+#include <linux/firmware.h>
+#include "include/miniisp.h"
+#include "include/miniisp_ctrl.h"
+#include "include/miniisp_customer_define.h"
+#include "include/miniisp_chip_base_define.h"
+
+#include "include/error/miniisp_err.h"
+
+/****************************************************************************
+* Private Constant Definition *
+****************************************************************************/
+#define EN_SPIE_DEBUG 0
+#define MINI_ISP_LOG_TAG "[miniisp_top]"
+#define ALIGN_CEIL(x, N) (((x) + ((N) - 1)) / (N) * (N))
+static bool irqflag;
+static u32 event = MINI_ISP_RCV_WAITING;
+static u32 current_event = MINI_ISP_RCV_WAITING;
+static DECLARE_WAIT_QUEUE_HEAD(WAITQ);
+/**********************************************************************
+* Public Function *
+**********************************************************************/
+int mini_isp_get_chip_id(void)
+{
+ int status = ERR_SUCCESS;
+ u32 buff_id = 0;
+
+ misp_info("%s - enter", __func__);
+
+ mini_isp_register_read(CHIP_ID_ADDR, &buff_id);
+
+ misp_err("[miniISP]Get Chip ID 0x%x", buff_id);
+
+ return status;
+}
+
+
+void mini_isp_register_write(u32 reg_addr, u32 reg_new_value)
+{
+ u8 *send_buffer;
+ u8 ctrlbyte = CTRL_BYTE_REGWR;
+ u32 address = reg_addr, value = reg_new_value;
+ struct misp_data *devdata;
+ struct misp_global_variable *dev_global_variable;
+
+ /* misp_info("%s - enter, reg_addr[%#08x], write_value[%#08x]",
+ __func__, reg_addr, reg_new_value); */
+
+ dev_global_variable = get_mini_isp_global_variable();
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+
+ send_buffer = devdata->tx_buf;
+
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &address, 4);
+ memcpy(send_buffer + 5, &value, 4);
+ /* dev_global_variable->before_booting = 1; */
+ devdata->intf_fn->write(devdata, devdata->tx_buf, devdata->rx_buf, 9);
+ /* dev_global_variable->before_booting = 0; */
+}
+
+void mini_isp_register_write_one_bit(u32 reg_addr,
+ u8 bit_offset, u8 bit_value)
+{
+ u8 *send_buffer;
+ u32 reg_value;
+ u8 ctrlbyte = CTRL_BYTE_REGWR;
+ u32 address = reg_addr;
+ struct misp_data *devdata;
+ struct misp_global_variable *dev_global_variable;
+
+ misp_info("%s - enter", __func__);
+
+ dev_global_variable = get_mini_isp_global_variable();
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+ send_buffer = devdata->tx_buf;
+
+ mini_isp_register_read(reg_addr, ®_value);
+
+ if (bit_value)
+ reg_value |= 1UL << bit_offset;
+ else
+ reg_value &= ~(1UL << bit_offset);
+
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &address, 4);
+ memcpy(send_buffer + 5, ®_value, 4);
+ /* dev_global_variable->before_booting = 1; */
+ devdata->intf_fn->write(devdata, devdata->tx_buf, devdata->rx_buf, 9);
+ /* dev_global_variable->before_booting = 0; */
+}
+
+
+void mini_isp_register_write_bit_field(u32 reg_addr, u32 mask, u32 mask_value)
+{
+ u8 *send_buffer;
+ u32 reg_value;
+ u8 ctrlbyte = CTRL_BYTE_REGWR;
+ u32 address = reg_addr, value;
+ struct misp_data *devdata;
+ struct misp_global_variable *dev_global_variable;
+
+ misp_info("%s - enter", __func__);
+
+ dev_global_variable = get_mini_isp_global_variable();
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+ send_buffer = devdata->tx_buf;
+
+ mini_isp_register_read(reg_addr, ®_value);
+ value = (reg_value & ~mask) | mask_value;
+
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &address, 4);
+ memcpy(send_buffer + 5, &value, 4);
+ /* dev_global_variable->before_booting = 1; */
+ devdata->intf_fn->write(devdata, devdata->tx_buf, devdata->rx_buf, 9);
+ /* dev_global_variable->before_booting = 0; */
+}
+
+void mini_isp_e_to_a(void)
+{
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ misp_info("mini_isp_drv_setting(1) mini_isp_e_to_a");
+ mini_isp_register_write(0xffef0240, 0x0);
+ /*mdelay(1);*/
+ msleep(20);
+ dev_global_variable->altek_spi_mode = ALTEK_SPI_MODE_A;
+}
+
+
+void mini_isp_a_to_e(void)
+{
+ u8 *send_buffer;
+ u8 ctrlbyte = CTRL_BYTE_A2E;
+ struct misp_data *devdata;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+ send_buffer = devdata->tx_buf;
+
+ memcpy(send_buffer, &ctrlbyte, 1);
+ devdata->intf_fn->write(devdata, devdata->tx_buf, devdata->rx_buf, 1);
+ dev_global_variable->altek_spi_mode = ALTEK_SPI_MODE_E;
+ misp_info("mini_isp_drv_setting(2) mini_isp_a_to_e");
+}
+
+void mini_isp_chip_init(void)
+{
+ misp_info("%s - enter", __func__);
+ mini_isp_register_write(0xffe40050, 0x1);
+ mini_isp_register_write(0xffef00a4, 0xe);
+ udelay(70);
+ mini_isp_register_write(0xffef00a0, 0xe);
+ mini_isp_register_write(0xffe81080, 0x8);
+ mini_isp_register_write(0xffef0090, 0x30079241);
+ mini_isp_register_write(0xffe800c4, 0x0);
+ udelay(100);
+ misp_info("%s - leave", __func__);
+}
+
+void mini_isp_cp_mode_suspend_flow(void)
+{
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ misp_info("%s - enter", __func__);
+
+ /*# AP disable OCRAM0*/
+ mini_isp_register_write_one_bit(0xffe609f4, 0, 1);/* # ocr0_disable*/
+
+ /*# 2.AP reset ARC5*/
+ mini_isp_register_write_one_bit(0xffe800c4, 1, 1);/* # base_ck_in*/
+
+ /*# 3.AP reset modules(including arbiter bus)*/
+ mini_isp_register_write_one_bit(0xffe801a4, 1, 1);/* # standby_top*/
+ mini_isp_register_write_one_bit(0xffe80104, 1, 1);/* # arb_bus_stdby_0*/
+
+ /*# 4.AP stop clock of modules(including arbiter bus, OCRAM0) and ARC5*/
+ mini_isp_register_write_one_bit(0xffe800c4, 0, 1);/* # base_ck_in*/
+ mini_isp_register_write_one_bit(0xffe801a4, 0, 1);/* # standby_top*/
+ mini_isp_register_write_one_bit(0xffe80104, 0, 1);/* # arb_bus_stdby_0*/
+ mini_isp_register_write_one_bit(0xffe80104, 2, 1);/* # ocram_0*/
+
+ /*# 5.AP isolate standby power domain*/
+ mini_isp_register_write_one_bit(0xffef00a0, 0, 1);/* # iso_pd_standby*/
+
+ /*# 6.AP power down standby power domain*/
+ mini_isp_register_write_one_bit(0xffef00a4, 0, 1);/* # psw_pd_standby*/
+
+ /*# AP issue global reset of standby power domain*/
+ /* # pd_rstn_standby_top*/
+ mini_isp_register_write_one_bit(0xffe81080, 3, 0);
+ /*# 7.AP keep PLL factor then disable PLLs (Keep PLL_fix)
+ *# ClkGen have kept PLL factor so don't keep here
+ *#pll_var_ext_dat = []
+ *# address of PLL factor
+ *#pll_var_ext_addr = [0xffe81120, 0xffe81124, 0xffe81128,
+ *# 0xffe8112c, 0xffe81130, 0xffe81134,
+ *# 0xffe81140, 0xffe81144, 0xffe81148,
+ *# 0xffe8114c, 0xffe81150, 0xffe81154 ]
+ *#for addr in pll_var_ext_addr:
+ *# (retsts, retdat) = altek_get_register(interface,
+ *# handle, I2C_SLAVE_ID, addr)
+ *# pll_var_ext_dat.append(retdat)
+ *# bit 11: reset_pll_ext,
+ *# bit 10: reset_pll_var,
+ *# bit 3: disable_pll_ext,
+ *# bit 2: disable_pll_var
+ */
+ /*# 7.AP keep PLL factor then disable PLLs
+ *(disable PLL_fix, PLL_ext and PLL_var)
+ */
+ mini_isp_register_write_bit_field(0xffe81004, 0x0e0e, 0x0e0e);
+ /*# AP do something*/
+ /*mdelay(10);*/
+ msleep(20);
+ misp_info("%s - leave", __func__);
+}
+
+void mini_isp_cp_mode_resume_flow(void)
+{
+ u32 magic_number;
+ struct misp_global_variable *dev_global_variable;
+ errcode status = ERR_SUCCESS;
+
+ misp_info("%s - enter", __func__);
+ dev_global_variable = get_mini_isp_global_variable();
+ /*# 1.AP check magic number*/
+ mini_isp_register_read(0xffef0008, &magic_number);/* # magic_number*/
+
+ /*
+ *# 2.AP check if magic number is equal to RESUME (0x19961224)
+ *then jump to step 4
+ */
+ if (magic_number != 0x19961224) {
+ /*
+ *# 3.Else exit resume flow
+ *(Note: AP can decide what to do.
+ *Ex: Toggle system reset of SK1 to reboot SK1)
+ */
+ misp_err("%s-resume fail!,magic number not equal!", __func__);
+ return;
+ }
+
+ /*# 4.AP power up standby power domain*/
+ mini_isp_register_write_one_bit(0xffef00a4, 0, 0);/* # psw_pd_standby*/
+ udelay(70);/* # 70us, TO-DO: depend on backend spec*/
+
+ /*# 5.AP release isolation of standby power domain*/
+ mini_isp_register_write_one_bit(0xffef00a0, 0, 0);/* # iso_pd_standby*/
+
+ /*# AP release global reset of standby power domain*/
+ /*# pd_rstn_standby_top*/
+ mini_isp_register_write_one_bit(0xffe81080, 3, 1);
+
+ /*# AP power up SRAM of ARC5*/
+ mini_isp_register_write_one_bit(0xffef0090, 22, 0);/*# srampd_base_arc*/
+
+ /*
+ *# 6.AP enable clock of modules(including arbiter bus, OCRAM0)
+ *and ARC5
+ */
+ mini_isp_register_write_one_bit(0xffe800c4, 0, 0);/* # base_ck_in*/
+ mini_isp_register_write_one_bit(0xffe801a4, 0, 0);/* # standby_top*/
+ mini_isp_register_write_one_bit(0xffe80104, 0, 0);/* # arb_bus_stdby_0*/
+ mini_isp_register_write_one_bit(0xffe80104, 2, 0);/* # ocram_0*/
+
+ /*# 7.AP release reset of modules(including arbiter bus)*/
+ mini_isp_register_write_one_bit(0xffe801a4, 1, 0);/* # standby_top*/
+ mini_isp_register_write_one_bit(0xffe80104, 1, 0);/* # arb_bus_stdby_0*/
+
+ /*# AP restore OCRAM0 setting*/
+ mini_isp_register_write(0xffe609f8, 0xdbfc0);
+ mini_isp_register_write(0xffe609f4, 0);
+ mini_isp_register_write(0xffe60800, 0);
+ mini_isp_register_write(0xffe60900, 0);
+
+ /*# 8. AP release reset of ARC5*/
+ mini_isp_register_write_one_bit(0xffe800c4, 1, 0);/* # base_ck_in*/
+
+ /*# 9. AP wait interrupt then clean interrupt status*/
+ status = mini_isp_wait_for_event(MINI_ISP_RCV_CPCHANGE);
+ misp_info("%s - leave", __func__);
+}
+
+void mini_isp_check_and_leave_bypass_mode(void)
+{
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ if (dev_global_variable->be_set_to_bypass) {
+ /*Add code here*/
+ mini_isp_register_write(0xffe80b04, 0x2a2a);/*mipidphy exc*/
+ mini_isp_register_write(0xffe80944, 0x2);/*mipi tx phy 1*/
+ mini_isp_register_write(0xffe80884, 0x2);/*mipi tx phy 0*/
+ mini_isp_register_write(0xffe804e4, 0x2);/*ppibridge 1 exc*/
+ mini_isp_register_write(0xffe804c4, 0x2);/*ppibridge 1*/
+ mini_isp_register_write(0xffe804a4, 0x2);/*ppibridge 0 exc*/
+ mini_isp_register_write(0xffe80484, 0x2);/*ppibridge 0*/
+ mini_isp_register_write(0xffe80444, 0xa);/*mipi rx phy 1*/
+ mini_isp_register_write(0xffe80404, 0xa);/*mipi rx phy 0*/
+
+ dev_global_variable->be_set_to_bypass = 0;
+ } else {
+ /*do nothing*/
+ misp_info("not running bypass mode yet");
+ }
+}
+
+
+#if ENABLE_LINUX_FW_LOADER
+int mini_isp_pure_bypass(u16 mini_isp_mode)
+{
+ struct misp_global_variable *dev_global_variable;
+ errcode err = ERR_SUCCESS;
+ u32 idx = 0;
+ u32 CurBufPos = 0;
+ u32 reg_addr;
+ u32 reg_new_value;
+ u32 sleepTime;
+ u32 file_total_size;
+ u8 byass_setting_file_location[80];
+ u8 linebuf[64];
+ u32 copylens;
+ const struct firmware *fw = NULL;
+ const u8 *fw_data;
+ struct device *mini_isp_device;
+ char *file_name = NULL;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ snprintf(byass_setting_file_location, 64,
+ "altek_bypass_setting_%d.log", mini_isp_mode);
+ misp_info("altek bypass mode %d", mini_isp_mode);
+
+ /* load boot fw file */
+ mini_isp_device = mini_isp_getdev();
+ if (mini_isp_device != NULL && byass_setting_file_location != NULL) {
+ file_name = byass_setting_file_location;
+ misp_info("%s, fw name: %s", __func__, file_name);
+
+ err = request_firmware(&fw,
+ file_name, mini_isp_device);
+
+ if (err) {
+ misp_info("%s, L: %d, err: %d",
+ __func__, __LINE__, err);
+ goto EXIT;
+ }
+ }
+
+ if (fw == NULL) {
+ misp_info("%s, fw:%s is NULL.", __func__, file_name);
+ return -EINVAL;
+ }
+
+ file_total_size = fw->size;
+ fw_data = fw->data;
+
+#ifndef AL6100_SPI_NOR
+ mini_isp_chip_init();
+#endif
+ misp_info("%s file_total_size = %d", __func__, file_total_size);
+ CurBufPos = idx = 0;
+ while (CurBufPos < file_total_size) {
+ /* Get line form fw_data */
+ for (idx = CurBufPos; idx < file_total_size; idx++) {
+ if (fw_data[idx] == '\n') {
+ copylens = (idx-CurBufPos > 64) ?
+ 64 : (idx-CurBufPos);
+ memcpy(linebuf, &(fw_data[CurBufPos]),
+ copylens);
+ break;
+ } else if (idx == file_total_size - 1) {
+ /* buf tail */
+ copylens = (idx-CurBufPos > 64) ?
+ 64 : (idx-CurBufPos);
+ memcpy(linebuf, &(fw_data[CurBufPos]),
+ copylens);
+ break;
+ }
+ }
+
+ /* analyze line buffer */
+ if (sscanf(linebuf, "ml 0x%x 0x%x",
+ ®_addr, ®_new_value) == 2) {
+
+ misp_info("ml 0x%x 0x%x", reg_addr, reg_new_value);
+ mini_isp_register_write(reg_addr, reg_new_value);
+ } else if (sscanf(linebuf, "sl %u", &sleepTime) == 1) {
+ misp_info("sl %d", sleepTime);
+ msleep(sleepTime);
+ } else {
+ misp_info("file format error! CurPos:%d", CurBufPos);
+ break;
+ }
+
+ /* skip '\n' char */
+ CurBufPos = idx + 1;
+ }
+
+ /*Restore segment descriptor*/
+ misp_info("miniisp bypass setting send finish");
+ dev_global_variable->be_set_to_bypass = 1;
+EXIT:
+ if (fw != NULL)
+ release_firmware(fw);
+
+ return err;
+}
+
+#else
+int mini_isp_pure_bypass(u16 mini_isp_mode)
+{
+ struct misp_global_variable *dev_global_variable;
+ errcode err = ERR_SUCCESS;
+ mm_segment_t oldfs;
+ struct file *file_filp;
+ off_t currpos;
+ loff_t offset;
+ char *allocated_memmory;
+ u8 *keep_allocated_memmory;
+ char allocated_memmory_buf[64];
+ u32 reg_addr;
+ u32 reg_new_value;
+ u32 file_total_size;
+ u8 byass_setting_file_location[80];
+ u8 buf[8];
+ int i;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ snprintf(byass_setting_file_location, 64,
+ "%saltek_bypass_setting_%d.log",
+ MINIISP_BYPASS_SETTING_FILE_PATH, mini_isp_mode);
+ misp_info("altek bypass mode %d", mini_isp_mode);
+ misp_info("%s setting filepath : %s", __func__,
+ byass_setting_file_location);
+
+ allocated_memmory = allocated_memmory_buf;
+ keep_allocated_memmory = allocated_memmory;
+ oldfs = get_fs();
+ set_fs(KERNEL_DS);
+#if ENABLE_FILP_OPEN_API
+ /* use file open */
+#else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ set_fs(oldfs);
+ return 0;
+#endif
+ if (IS_ERR(file_filp)) {
+ err = PTR_ERR(file_filp);
+ misp_err("%s open file failed. err: %d", __func__, err);
+ set_fs(oldfs);
+ return err;
+ }
+ misp_info("%s open file success!", __func__);
+
+#ifndef AL6100_SPI_NOR
+ mini_isp_chip_init();
+#endif
+ /*get bin filie size*/
+ currpos = vfs_llseek(file_filp, 0L, SEEK_END);
+ file_total_size = currpos;
+ currpos = vfs_llseek(file_filp, 0L, SEEK_SET);
+
+ misp_info("%s file_total_size = %d", __func__, file_total_size);
+ offset = file_filp->f_pos;
+ while (file_total_size > 0) {
+
+ vfs_read(file_filp, (char *)allocated_memmory_buf,
+ 1, &offset);
+
+ file_filp->f_pos = offset;
+ file_total_size--;
+ if (allocated_memmory_buf[0] == '0') {
+ vfs_read(file_filp, (char *)allocated_memmory,
+ 1, &offset);
+ file_filp->f_pos = offset;
+ file_total_size--;
+ if (allocated_memmory_buf[0] == 'x') {
+ vfs_read(file_filp, (char *)allocated_memmory,
+ 8, &offset);
+ file_filp->f_pos = offset;
+ file_total_size = file_total_size - 8;
+
+ for (i = 0; i < 4; i++)
+ err = hex2bin(buf+3-i,
+ allocated_memmory+2*i, 1);
+
+ while (1) {
+ vfs_read(file_filp,
+ (char *)allocated_memmory,
+ 1, &offset);
+ file_filp->f_pos = offset;
+ file_total_size = file_total_size - 1;
+
+ if (allocated_memmory[0] == '0')
+ break;
+ }
+
+ if (file_total_size < 0)
+ break;
+
+ vfs_read(file_filp, (char *)allocated_memmory,
+ 1, &offset);
+ file_filp->f_pos = offset;
+ file_total_size = file_total_size - 1;
+ if ((allocated_memmory[0] == 'x')) {
+ vfs_read(file_filp,
+ (char *)allocated_memmory,
+ 8, &offset);
+ file_filp->f_pos = offset;
+ file_total_size = file_total_size - 8;
+
+ for (i = 0; i < 4; i++)
+ err = hex2bin(buf+4+3-i,
+ allocated_memmory+2*i,
+ 1);
+
+ memcpy(®_addr, buf, 4);
+ memcpy(®_new_value, buf+4, 4);
+
+ mini_isp_register_write(
+ reg_addr,
+ reg_new_value);
+
+ }
+ }
+ } else if (allocated_memmory_buf[0] == 's') {
+ while (1) {
+ vfs_read(file_filp, (char *)allocated_memmory,
+ 1, &offset);
+ file_filp->f_pos = offset;
+ file_total_size = file_total_size - 1;
+
+ if (allocated_memmory[0] == 13) {
+ udelay(350);
+ break;
+ }
+ }
+ }
+ }
+ /*Restore segment descriptor*/
+ misp_info("miniisp bypass setting send finish");
+
+ dev_global_variable->be_set_to_bypass = 1;
+ set_fs(oldfs);
+ filp_close(file_filp, NULL);
+
+ return err;
+}
+#endif
+
+void mini_isp_pure_bypass_debug(u16 mini_isp_mode)
+{
+ mini_isp_chip_init();
+ misp_info("mini_isp_pure_bypass_debug(%d) set bypass mode",
+ mini_isp_mode);
+ switch (mini_isp_mode) {
+ case 1:
+ mini_isp_register_write(0xffe40000, 0x00000008);
+ mini_isp_register_write(0xffe40004, 0x00006621);
+ mini_isp_register_write(0xffe40008, 0x00006621);
+ mini_isp_register_write(0xffe4000c, 0x00006621);
+ mini_isp_register_write(0xffe40010, 0x00006621);
+ mini_isp_register_write(0xffe40050, 0x00000001);
+ mini_isp_register_write(0xffe81004, 0x00000200);
+ udelay(0x00000005);
+ mini_isp_register_write(0xffe81100, 0x00000000);
+ mini_isp_register_write(0xffe81104, 0x00000000);
+ mini_isp_register_write(0xffe81108, 0x000000dc);
+ mini_isp_register_write(0xffe8110c, 0x00000000);
+ mini_isp_register_write(0xffe81110, 0x00000001);
+ mini_isp_register_write(0xffe81114, 0x00000000);
+ mini_isp_register_write(0xffe81004, 0x00000000);
+ udelay(0x0000015e);
+ mini_isp_register_write(0xffe800c0, 0x0000000a);
+ mini_isp_register_write(0xffe800e0, 0x0000000a);
+ mini_isp_register_write(0xffe80100, 0x0000000a);
+ mini_isp_register_write(0xffe80120, 0x0000000a);
+ mini_isp_register_write(0xffe81004, 0x00000800);
+ udelay(0x00000005);
+ mini_isp_register_write(0xffe81120, 0x00000000);
+ mini_isp_register_write(0xffe81124, 0x00000000);
+ mini_isp_register_write(0xffe81128, 0x0000017a);
+ mini_isp_register_write(0xffe8112c, 0x00000000);
+ mini_isp_register_write(0xffe81130, 0x00000001);
+ mini_isp_register_write(0xffe81134, 0x00000001);
+ mini_isp_register_write(0xffe81004, 0x00000000);
+ udelay(0x0000015e);
+ mini_isp_register_write(0xffe81004, 0x00000400);
+ udelay(0x00000005);
+ mini_isp_register_write(0xffe81140, 0x00000000);
+ mini_isp_register_write(0xffe81144, 0x00000000);
+ mini_isp_register_write(0xffe81148, 0x0000017a);
+ mini_isp_register_write(0xffe8114c, 0x00000000);
+ mini_isp_register_write(0xffe81150, 0x00000001);
+ mini_isp_register_write(0xffe81154, 0x00000001);
+ mini_isp_register_write(0xffe81004, 0x00000000);
+ udelay(0x0000015e);
+ mini_isp_register_write(0xffe80b00, 0x00000819);
+ mini_isp_register_write(0xffe80880, 0x00000400);
+ mini_isp_register_write(0xffe80380, 0x00000004);
+ mini_isp_register_write(0xffe80400, 0x00000802);
+ mini_isp_register_write(0xffed1008, 0x0000aab0);
+ mini_isp_register_write(0xffed100c, 0x00000306);
+ mini_isp_register_write(0xffed1010, 0x00000147);
+ mini_isp_register_write(0xffed1014, 0x0000aa73);
+ mini_isp_register_write(0xffed1018, 0x00000eaa);
+ mini_isp_register_write(0xffed101c, 0x00008e1a);
+ mini_isp_register_write(0xffed1044, 0x000000b8);
+ mini_isp_register_write(0xffed1044, 0x00000098);
+ udelay(0x00000028);
+ mini_isp_register_write(0xffed1044, 0x00000088);
+ udelay(0x00000028);
+ mini_isp_register_write(0xffed1030, 0x00080000);
+ mini_isp_register_write(0xffed1034, 0x00080000);
+ mini_isp_register_write(0xffed1038, 0x00080000);
+ mini_isp_register_write(0xffed103c, 0x00080000);
+ mini_isp_register_write(0xffed1040, 0x00080000);
+ udelay(0x00000006);
+ mini_isp_register_write(0xffed1030, 0x00080002);
+ mini_isp_register_write(0xffed1034, 0x00080002);
+ mini_isp_register_write(0xffed1038, 0x00080002);
+ mini_isp_register_write(0xffed103c, 0x00080002);
+ mini_isp_register_write(0xffed1040, 0x00080002);
+ mini_isp_register_write(0xffed1000, 0x00000000);
+ mini_isp_register_write(0xfff97000, 0x00000001);
+ mini_isp_register_write(0xfff97004, 0x00003210);
+ mini_isp_register_write(0xfff97008, 0x00003210);
+ mini_isp_register_write(0xfff9700c, 0x145000b4);
+ mini_isp_register_write(0xfff97010, 0x00000000);
+ mini_isp_register_write(0xfff97014, 0x00000000);
+ mini_isp_register_write(0xfff97018, 0x00000000);
+ mini_isp_register_write(0xfff9701c, 0x00000000);
+ mini_isp_register_write(0xfff97020, 0x00000000);
+ mini_isp_register_write(0xfff97024, 0x00000010);
+ mini_isp_register_write(0xfff97028, 0x0000001e);
+ mini_isp_register_write(0xfff9702c, 0x0000000b);
+ mini_isp_register_write(0xfff97030, 0x0f0f0f0f);
+ mini_isp_register_write(0xfff97000, 0x00000000);
+ mini_isp_register_write(0xfff91000, 0x1000000b);
+ mini_isp_register_write(0xfff91024, 0x0000000f);
+ mini_isp_register_write(0xfff91028, 0x00001010);
+ mini_isp_register_write(0xfff9106c, 0x00000c0c);
+ mini_isp_register_write(0xfff91040, 0x00003c02);
+ udelay(0x00000028);
+ mini_isp_register_write(0xfff91004, 0x00000000);
+ mini_isp_register_write(0xfff91008, 0x00003033);
+ mini_isp_register_write(0xfff91010, 0x00003c02);
+ mini_isp_register_write(0xfff91014, 0x00003c02);
+ mini_isp_register_write(0xfff9103c, 0x00000000);
+ mini_isp_register_write(0xfff91098, 0x00444404);
+ mini_isp_register_write(0xfff9104c, 0x000d0011);
+ mini_isp_register_write(0xfff91000, 0x1000000b);
+ mini_isp_register_write(0xfff91024, 0x0000000f);
+ mini_isp_register_write(0xfff91028, 0x0000013f);
+ mini_isp_register_write(0xfff9106c, 0x00000e0e);
+ mini_isp_register_write(0xfff9104c, 0x000d0011);
+ mini_isp_register_write(0xfff91070, 0x01000005);
+ mini_isp_register_write(0xfff910a8, 0x00000000);
+ mini_isp_register_write(0xfff91094, 0x00001021);
+ mini_isp_register_write(0xfff91000, 0x1000000a);
+ break;
+ case 2:
+ mini_isp_register_write(0xffe40000, 0x00000008);
+ mini_isp_register_write(0xffe40004, 0x00006621);
+ mini_isp_register_write(0xffe40008, 0x00006621);
+ mini_isp_register_write(0xffe4000c, 0x00006621);
+ mini_isp_register_write(0xffe40010, 0x00006621);
+ mini_isp_register_write(0xffe40050, 0x00000001);
+ mini_isp_register_write(0xffe81004, 0x00000200);
+ udelay(0x00000005);
+ mini_isp_register_write(0xffe81100, 0x00000000);
+ mini_isp_register_write(0xffe81104, 0x00000000);
+ mini_isp_register_write(0xffe81108, 0x000000dc);
+ mini_isp_register_write(0xffe8110c, 0x00000000);
+ mini_isp_register_write(0xffe81110, 0x00000001);
+ mini_isp_register_write(0xffe81114, 0x00000000);
+ mini_isp_register_write(0xffe81004, 0x00000000);
+ udelay(0x0000015e);
+ mini_isp_register_write(0xffe800c0, 0x0000000a);
+ mini_isp_register_write(0xffe800e0, 0x0000000a);
+ mini_isp_register_write(0xffe80100, 0x0000000a);
+ mini_isp_register_write(0xffe80120, 0x0000000a);
+ mini_isp_register_write(0xffe81004, 0x00000800);
+ udelay(0x00000005);
+ mini_isp_register_write(0xffe81120, 0x00000000);
+ mini_isp_register_write(0xffe81124, 0x00000000);
+ mini_isp_register_write(0xffe81128, 0x0000017a);
+ mini_isp_register_write(0xffe8112c, 0x00000000);
+ mini_isp_register_write(0xffe81130, 0x00000001);
+ mini_isp_register_write(0xffe81134, 0x00000001);
+ mini_isp_register_write(0xffe81004, 0x00000000);
+ udelay(0x0000015e);
+ mini_isp_register_write(0xffe81004, 0x00000400);
+ udelay(0x00000005);
+ mini_isp_register_write(0xffe81140, 0x00000000);
+ mini_isp_register_write(0xffe81144, 0x00000000);
+ mini_isp_register_write(0xffe81148, 0x0000017a);
+ mini_isp_register_write(0xffe8114c, 0x00000000);
+ mini_isp_register_write(0xffe81150, 0x00000001);
+ mini_isp_register_write(0xffe81154, 0x00000001);
+ mini_isp_register_write(0xffe81004, 0x00000000);
+ udelay(0x0000015e);
+ mini_isp_register_write(0xffe80b00, 0x00000819);
+ mini_isp_register_write(0xffe80940, 0x00000800);
+ mini_isp_register_write(0xffe80440, 0x00000004);
+ mini_isp_register_write(0xffe80460, 0x00000802);
+ mini_isp_register_write(0xffed6008, 0x0000aab0);
+ mini_isp_register_write(0xffed600c, 0x00000306);
+ mini_isp_register_write(0xffed6010, 0x00000147);
+ mini_isp_register_write(0xffed6014, 0x0000aa73);
+ mini_isp_register_write(0xffed6018, 0x00000eaa);
+ mini_isp_register_write(0xffed601c, 0x00008e1a);
+ mini_isp_register_write(0xffed6044, 0x000000b8);
+ mini_isp_register_write(0xffed6044, 0x00000098);
+ udelay(0x00000028);
+ mini_isp_register_write(0xffed6044, 0x00000088);
+ udelay(0x00000028);
+ mini_isp_register_write(0xffed6030, 0x00080000);
+ mini_isp_register_write(0xffed6034, 0x00080000);
+ mini_isp_register_write(0xffed6038, 0x00080000);
+ mini_isp_register_write(0xffed603c, 0x00080000);
+ mini_isp_register_write(0xffed6040, 0x00080000);
+ udelay(0x00000006);
+ mini_isp_register_write(0xffed6030, 0x00080002);
+ mini_isp_register_write(0xffed6034, 0x00080002);
+ mini_isp_register_write(0xffed6038, 0x00080002);
+ mini_isp_register_write(0xffed603c, 0x00080002);
+ mini_isp_register_write(0xffed6040, 0x00080002);
+ mini_isp_register_write(0xffed6000, 0x00000000);
+ mini_isp_register_write(0xfff98000, 0x00000001);
+ mini_isp_register_write(0xfff98004, 0x00003210);
+ mini_isp_register_write(0xfff98008, 0x00003210);
+ mini_isp_register_write(0xfff9800c, 0x14500344);
+ mini_isp_register_write(0xfff98010, 0x00000000);
+ mini_isp_register_write(0xfff98014, 0x00000000);
+ mini_isp_register_write(0xfff98018, 0x00000000);
+ mini_isp_register_write(0xfff9801c, 0x00000000);
+ mini_isp_register_write(0xfff98020, 0x00000000);
+ mini_isp_register_write(0xfff98024, 0x000000ec);
+ mini_isp_register_write(0xfff98028, 0x0000001e);
+ mini_isp_register_write(0xfff9802c, 0x000000c3);
+ mini_isp_register_write(0xfff98030, 0x56565656);
+ mini_isp_register_write(0xfff98000, 0x00000000);
+ mini_isp_register_write(0xfff94000, 0x1000000b);
+ mini_isp_register_write(0xfff94024, 0x0000000f);
+ mini_isp_register_write(0xfff94028, 0x00001010);
+ mini_isp_register_write(0xfff9406c, 0x00000c0c);
+ mini_isp_register_write(0xfff94040, 0x00003c02);
+ udelay(0x00000028);
+ mini_isp_register_write(0xfff94004, 0x00000000);
+ mini_isp_register_write(0xfff94008, 0x00003033);
+ mini_isp_register_write(0xfff94010, 0x00003c02);
+ mini_isp_register_write(0xfff94014, 0x00003c02);
+ mini_isp_register_write(0xfff9403c, 0x00000000);
+ mini_isp_register_write(0xfff94098, 0x00444404);
+ mini_isp_register_write(0xfff9404c, 0x000d0011);
+ mini_isp_register_write(0xfff94000, 0x1000000b);
+ mini_isp_register_write(0xfff94024, 0x0000000f);
+ mini_isp_register_write(0xfff94028, 0x00003f01);
+ mini_isp_register_write(0xfff9406c, 0x00000e0e);
+ mini_isp_register_write(0xfff9404c, 0x000d0011);
+ mini_isp_register_write(0xfff94070, 0x01000005);
+ mini_isp_register_write(0xfff940a8, 0x00000000);
+ mini_isp_register_write(0xfff94094, 0x00001021);
+ mini_isp_register_write(0xfff94000, 0x1000000a);
+ break;
+ case 3:
+ mini_isp_register_write(0xffe40000, 0x00000008);
+ mini_isp_register_write(0xffe40004, 0x00006621);
+ mini_isp_register_write(0xffe40008, 0x00006621);
+ mini_isp_register_write(0xffe4000c, 0x00006621);
+ mini_isp_register_write(0xffe40010, 0x00006621);
+ mini_isp_register_write(0xffe40050, 0x00000001);
+ mini_isp_register_write(0xffe81004, 0x00000200);
+ udelay(0x00000005);
+ mini_isp_register_write(0xffe81100, 0x00000000);
+ mini_isp_register_write(0xffe81104, 0x00000000);
+ mini_isp_register_write(0xffe81108, 0x000000dc);
+ mini_isp_register_write(0xffe8110c, 0x00000000);
+ mini_isp_register_write(0xffe81110, 0x00000001);
+ mini_isp_register_write(0xffe81114, 0x00000000);
+ mini_isp_register_write(0xffe81004, 0x00000000);
+ udelay(0x0000015e);
+ mini_isp_register_write(0xffe800c0, 0x0000000a);
+ mini_isp_register_write(0xffe800e0, 0x0000000a);
+ mini_isp_register_write(0xffe80100, 0x0000000a);
+ mini_isp_register_write(0xffe80120, 0x0000000a);
+ mini_isp_register_write(0xffe81004, 0x00000800);
+ udelay(0x00000005);
+ mini_isp_register_write(0xffe81120, 0x00000000);
+ mini_isp_register_write(0xffe81124, 0x00000000);
+ mini_isp_register_write(0xffe81128, 0x0000017a);
+ mini_isp_register_write(0xffe8112c, 0x00000000);
+ mini_isp_register_write(0xffe81130, 0x00000001);
+ mini_isp_register_write(0xffe81134, 0x00000001);
+ mini_isp_register_write(0xffe81004, 0x00000000);
+ udelay(0x0000015e);
+ mini_isp_register_write(0xffe81004, 0x00000400);
+ udelay(0x00000005);
+ mini_isp_register_write(0xffe81140, 0x00000000);
+ mini_isp_register_write(0xffe81144, 0x00000000);
+ mini_isp_register_write(0xffe81148, 0x0000017a);
+ mini_isp_register_write(0xffe8114c, 0x00000000);
+ mini_isp_register_write(0xffe81150, 0x00000001);
+ mini_isp_register_write(0xffe81154, 0x00000001);
+ mini_isp_register_write(0xffe81004, 0x00000000);
+ udelay(0x0000015e);
+ mini_isp_register_write(0xffe80b00, 0x00000819);
+ mini_isp_register_write(0xffe80880, 0x00000400);
+ mini_isp_register_write(0xffe80380, 0x00000004);
+ mini_isp_register_write(0xffe80400, 0x00000802);
+ mini_isp_register_write(0xffe80940, 0x00000800);
+ mini_isp_register_write(0xffe80440, 0x00000004);
+ mini_isp_register_write(0xffe80460, 0x00000802);
+ mini_isp_register_write(0xffed1008, 0x0000aab0);
+ mini_isp_register_write(0xffed100c, 0x00000306);
+ mini_isp_register_write(0xffed1010, 0x00000147);
+ mini_isp_register_write(0xffed1014, 0x0000aa73);
+ mini_isp_register_write(0xffed1018, 0x00000eaa);
+ mini_isp_register_write(0xffed101c, 0x00008e1a);
+ mini_isp_register_write(0xffed1044, 0x000000b8);
+ mini_isp_register_write(0xffed1044, 0x00000098);
+ udelay(0x00000028);
+ mini_isp_register_write(0xffed1044, 0x00000088);
+ udelay(0x00000028);
+ mini_isp_register_write(0xffed1030, 0x00080000);
+ mini_isp_register_write(0xffed1034, 0x00080000);
+ mini_isp_register_write(0xffed1038, 0x00080000);
+ mini_isp_register_write(0xffed103c, 0x00080000);
+ mini_isp_register_write(0xffed1040, 0x00080000);
+ udelay(0x00000006);
+ mini_isp_register_write(0xffed1030, 0x00080002);
+ mini_isp_register_write(0xffed1034, 0x00080002);
+ mini_isp_register_write(0xffed1038, 0x00080002);
+ mini_isp_register_write(0xffed103c, 0x00080002);
+ mini_isp_register_write(0xffed1040, 0x00080002);
+ mini_isp_register_write(0xffed1000, 0x00000000);
+ mini_isp_register_write(0xfff97000, 0x00000001);
+ mini_isp_register_write(0xfff97004, 0x00003210);
+ mini_isp_register_write(0xfff97008, 0x00003210);
+ mini_isp_register_write(0xfff9700c, 0x145000b4);
+ mini_isp_register_write(0xfff97010, 0x00000000);
+ mini_isp_register_write(0xfff97014, 0x00000000);
+ mini_isp_register_write(0xfff97018, 0x00000000);
+ mini_isp_register_write(0xfff9701c, 0x00000000);
+ mini_isp_register_write(0xfff97020, 0x00000000);
+ mini_isp_register_write(0xfff97024, 0x00000010);
+ mini_isp_register_write(0xfff97028, 0x0000001e);
+ mini_isp_register_write(0xfff9702c, 0x0000000b);
+ mini_isp_register_write(0xfff97030, 0x0f0f0f0f);
+ mini_isp_register_write(0xfff97000, 0x00000000);
+ mini_isp_register_write(0xfff91000, 0x1000000b);
+ mini_isp_register_write(0xfff91024, 0x0000000f);
+ mini_isp_register_write(0xfff91028, 0x00001010);
+ mini_isp_register_write(0xfff9106c, 0x00000c0c);
+ mini_isp_register_write(0xfff91040, 0x00003c02);
+ udelay(0x00000028);
+ mini_isp_register_write(0xfff91004, 0x00000000);
+ mini_isp_register_write(0xfff91008, 0x00003033);
+ mini_isp_register_write(0xfff91010, 0x00003c02);
+ mini_isp_register_write(0xfff91014, 0x00003c02);
+ mini_isp_register_write(0xfff9103c, 0x00000000);
+ mini_isp_register_write(0xfff91098, 0x00444404);
+ mini_isp_register_write(0xfff9104c, 0x000d0011);
+ mini_isp_register_write(0xfff91000, 0x1000000b);
+ mini_isp_register_write(0xfff91024, 0x0000000f);
+ mini_isp_register_write(0xfff91028, 0x0000013f);
+ mini_isp_register_write(0xfff9106c, 0x00000e0e);
+ mini_isp_register_write(0xfff9104c, 0x000d0011);
+ mini_isp_register_write(0xfff91070, 0x01000005);
+ mini_isp_register_write(0xfff910a8, 0x00000000);
+ mini_isp_register_write(0xfff91094, 0x00001021);
+ mini_isp_register_write(0xfff91000, 0x1000000a);
+ mini_isp_register_write(0xffed6008, 0x0000aab0);
+ mini_isp_register_write(0xffed600c, 0x00000306);
+ mini_isp_register_write(0xffed6010, 0x00000147);
+ mini_isp_register_write(0xffed6014, 0x0000aa73);
+ mini_isp_register_write(0xffed6018, 0x00000eaa);
+ mini_isp_register_write(0xffed601c, 0x00008e1a);
+ mini_isp_register_write(0xffed6044, 0x000000b8);
+ mini_isp_register_write(0xffed6044, 0x00000098);
+ udelay(0x00000028);
+ mini_isp_register_write(0xffed6044, 0x00000088);
+ udelay(0x00000028);
+ mini_isp_register_write(0xffed6030, 0x00080000);
+ mini_isp_register_write(0xffed6034, 0x00080000);
+ mini_isp_register_write(0xffed6038, 0x00080000);
+ mini_isp_register_write(0xffed603c, 0x00080000);
+ mini_isp_register_write(0xffed6040, 0x00080000);
+ udelay(0x00000006);
+ mini_isp_register_write(0xffed6030, 0x00080002);
+ mini_isp_register_write(0xffed6034, 0x00080002);
+ mini_isp_register_write(0xffed6038, 0x00080002);
+ mini_isp_register_write(0xffed603c, 0x00080002);
+ mini_isp_register_write(0xffed6040, 0x00080002);
+ mini_isp_register_write(0xffed6000, 0x00000000);
+ mini_isp_register_write(0xfff98000, 0x00000001);
+ mini_isp_register_write(0xfff98004, 0x00003210);
+ mini_isp_register_write(0xfff98008, 0x00003210);
+ mini_isp_register_write(0xfff9800c, 0x14500344);
+ mini_isp_register_write(0xfff98010, 0x00000000);
+ mini_isp_register_write(0xfff98014, 0x00000000);
+ mini_isp_register_write(0xfff98018, 0x00000000);
+ mini_isp_register_write(0xfff9801c, 0x00000000);
+ mini_isp_register_write(0xfff98020, 0x00000000);
+ mini_isp_register_write(0xfff98024, 0x000000ec);
+ mini_isp_register_write(0xfff98028, 0x0000001e);
+ mini_isp_register_write(0xfff9802c, 0x000000c3);
+ mini_isp_register_write(0xfff98030, 0x56565656);
+ mini_isp_register_write(0xfff98000, 0x00000000);
+ mini_isp_register_write(0xfff94000, 0x1000000b);
+ mini_isp_register_write(0xfff94024, 0x0000000f);
+ mini_isp_register_write(0xfff94028, 0x00001010);
+ mini_isp_register_write(0xfff9406c, 0x00000c0c);
+ mini_isp_register_write(0xfff94040, 0x00003c02);
+ udelay(0x00000028);
+ mini_isp_register_write(0xfff94004, 0x00000000);
+ mini_isp_register_write(0xfff94008, 0x00003033);
+ mini_isp_register_write(0xfff94010, 0x00003c02);
+ mini_isp_register_write(0xfff94014, 0x00003c02);
+ mini_isp_register_write(0xfff9403c, 0x00000000);
+ mini_isp_register_write(0xfff94098, 0x00444404);
+ mini_isp_register_write(0xfff9404c, 0x000d0011);
+ mini_isp_register_write(0xfff94000, 0x1000000b);
+ mini_isp_register_write(0xfff94024, 0x0000000f);
+ mini_isp_register_write(0xfff94028, 0x00003f01);
+ mini_isp_register_write(0xfff9406c, 0x00000e0e);
+ mini_isp_register_write(0xfff9404c, 0x000d0011);
+ mini_isp_register_write(0xfff94070, 0x01000005);
+ mini_isp_register_write(0xfff940a8, 0x00000000);
+ mini_isp_register_write(0xfff94094, 0x00001021);
+ mini_isp_register_write(0xfff94000, 0x1000000a);
+ break;
+ default:
+ break;
+ }
+}
+EXPORT_SYMBOL(mini_isp_pure_bypass_debug);
+
+
+u32 mini_isp_register_read_then_write_file(
+ u32 start_reg_addr, u32 end_reg_addr,
+ char *dest_path, char *module_name)
+{
+ u32 retval = ERR_SUCCESS;
+ u32 count;
+ u8 *dump_memory = NULL;
+ u8 *keep_dump_memory = NULL;
+ u32 ouput_size;
+ u8 filename[128];
+ struct file *f;
+ mm_segment_t fs;
+
+ /* how many registers(4 bytes) do you want to read? */
+ count = ((end_reg_addr - start_reg_addr) / 4) + 1;
+ /* read 4 bytes register value */
+ ouput_size = (count + 2) * 4;
+
+ dump_memory = kzalloc(ouput_size, GFP_KERNEL);
+ if (!dump_memory) {
+ retval = -ENOMEM;
+ misp_err("%s Allocate memory failed.", __func__);
+ goto allocate_memory_fail;
+ }
+ keep_dump_memory = dump_memory;
+
+
+ memcpy(dump_memory, &start_reg_addr, 4);
+ dump_memory = dump_memory + 4;
+ memcpy(dump_memory, &count, 4);
+ dump_memory = dump_memory + 4;
+
+ while (start_reg_addr <= end_reg_addr) {
+
+ mini_isp_register_read(start_reg_addr, (u32 *)dump_memory);
+
+ start_reg_addr = start_reg_addr + 4;
+ dump_memory = dump_memory + 4;
+ }
+
+
+
+ snprintf(filename, 128, "%s/%s_%x.regx",
+ dest_path, module_name, start_reg_addr);
+#if ENABLE_FILP_OPEN_API
+ /* use file open */
+#else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ goto file_open_fail;
+#endif
+ /*Get current segment descriptor*/
+ fs = get_fs();
+ /*Set segment descriptor associated*/
+ set_fs(get_ds());
+
+ if (IS_ERR(f)) {
+ retval = PTR_ERR(f);
+ set_fs(fs);
+ misp_err("%s open file failed. err: %d", __func__, retval);
+ goto file_open_fail;
+ }
+
+ /*write the file*/
+ vfs_write(f, (char *)keep_dump_memory, ouput_size, &f->f_pos);
+
+ /*Restore segment descriptor*/
+ set_fs(fs);
+ filp_close(f, NULL);
+
+file_open_fail:
+allocate_memory_fail:
+ kfree(keep_dump_memory);
+
+ return retval;
+}
+
+u32 mini_isp_register_read(u32 reg_addr, u32 *reg_value)
+{
+ int status = ERR_SUCCESS;
+ u8 *send_buffer;
+ u8 *recv_buffer;
+ u8 ctrlbyte = 0;
+ u32 address = reg_addr;
+ struct misp_data *devdata;
+ struct misp_global_variable *dev_global_variable;
+
+ u8 send_buffer_value[64] = {0};
+ u8 recv_buffer_value[64] = {0};
+ u32 rx_dummy_len;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+ send_buffer = send_buffer_value;
+ recv_buffer = recv_buffer_value;
+ if (SPI_SHORT_LEN_MODE && SPI_SHORT_LEN_MODE_READ_ENABLE) {
+ /* Setp1, Send address: { ctrlbyte[1byte] + addr[4byte] } */
+ ctrlbyte = CTRL_BYTE_REGRD_W;
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &address, 4);
+
+ /* read 4 bytes register value */
+ status = devdata->intf_fn->read(devdata,
+ send_buffer_value,
+ EMODE_TXCMD_LEN,
+ recv_buffer_value,
+ 0);
+
+ if (status) {
+ misp_err("%s - sync error: status = %d",
+ __func__, status);
+ goto mini_isp_register_read_end;
+ }
+
+
+ udelay(50);
+
+ /* Setp2, wait a moment and
+ * get data{ dummy[1byte] + data[4byte] }
+ */
+ ctrlbyte = CTRL_BYTE_GETDATA_W;
+ memcpy(send_buffer, &ctrlbyte, 1);
+
+ status = devdata->intf_fn->read(devdata,
+ send_buffer_value,
+ 1,
+ recv_buffer_value,
+ 5);
+
+ if (status) {
+ misp_err("%s - sync error: status = %d",
+ __func__, status);
+ goto mini_isp_register_read_end;
+ }
+
+ recv_buffer = (u8 *)&recv_buffer_value[1];
+
+ } else {
+ ctrlbyte = CTRL_BYTE_REGRD;
+ rx_dummy_len = mini_isp_get_rx_dummy_byte(ctrlbyte);
+ #if EN_SPIE_REG_DUMMY_BYTE
+ mini_isp_set_spie_dummy_byte(rx_dummy_len-1); /* 0 base */
+ #endif
+
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &address, 4);
+
+ /* read 4 bytes register value */
+ status = devdata->intf_fn->read(devdata,
+ send_buffer_value,
+ EMODE_TXCMD_LEN,
+ recv_buffer_value,
+ rx_dummy_len + 4);
+
+ if (status) {
+ misp_err("%s - sync error: status = %d",
+ __func__, status);
+ goto mini_isp_register_read_end;
+ }
+
+ if (dev_global_variable->intf_status & INTF_SPI_READY) {
+ /* check if send len + recv len > 32. if yes then
+ * rx_dummy_len need + EMODE_TXCMD_LEN
+ */
+ if (EMODE_TXCMD_LEN + rx_dummy_len + 4 > 32)
+ status = mini_isp_check_rx_dummy(&recv_buffer,
+ rx_dummy_len+EMODE_TXCMD_LEN);
+ else
+ status = mini_isp_check_rx_dummy(&recv_buffer,
+ rx_dummy_len);
+
+ if (status) {
+ misp_err("[miniisp]Can't get reg");
+ goto mini_isp_register_read_end;
+ }
+ }
+
+ }
+ memcpy(reg_value, recv_buffer, 4);
+
+mini_isp_register_read_end:
+
+ return status;
+}
+
+void mini_isp_memory_write(u32 memory_addr, u8 *write_buffer, u32 write_len)
+{
+ u8 *send_buffer;
+ u8 ctrlbyte = CTRL_BYTE_MEMWR;
+ u32 address = memory_addr;
+ u32 start_mem_addr = memory_addr;
+ u32 end_mem_addr = memory_addr + write_len;
+ struct misp_data *devdata;
+ u8 send_buffer_value[EMODE_TXCMD_LEN + write_len];
+ struct misp_global_variable *dev_global_variable;
+ u32 wt_len = write_len;
+ u8 *wt_buffer;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+ send_buffer = send_buffer_value;
+
+ /* dev_global_variable->before_booting = 1; */
+
+
+ if (SPI_SHORT_LEN_MODE && SPI_SHORT_LEN_MODE_WRITE_ENABLE) {
+ wt_buffer = write_buffer;
+
+ while (start_mem_addr < end_mem_addr) {
+
+ wt_len = end_mem_addr - start_mem_addr;
+
+ if (wt_len >= 4) {
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &start_mem_addr, 4);
+ memcpy(send_buffer + 5, wt_buffer, 4);
+ devdata->intf_fn->write(
+ devdata,
+ send_buffer,
+ NULL,
+ EMODE_TXCMD_LEN + 4);
+ } else {
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &start_mem_addr, 4);
+ memcpy(send_buffer + 5, wt_buffer, wt_len);
+ devdata->intf_fn->write(
+ devdata,
+ send_buffer,
+ NULL,
+ EMODE_TXCMD_LEN + wt_len);
+ }
+
+ wt_buffer = wt_buffer + 4;
+ start_mem_addr = start_mem_addr + 4;
+ }
+ } else {
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &address, 4);
+ memcpy(send_buffer + 5, write_buffer, write_len);
+ devdata->intf_fn->write(
+ devdata,
+ send_buffer,
+ NULL,
+ EMODE_TXCMD_LEN + write_len);
+ }
+ /* dev_global_variable->before_booting = 0; */
+}
+
+u32 mini_isp_memory_read_then_write_file(u32 start_addr, u32 len,
+ char *dest_path, char *file_name)
+{
+ u32 retval = ERR_SUCCESS;
+ u8 *dump_memory = NULL;
+ u8 filename[128];
+ struct file *f;
+ mm_segment_t fs;
+
+ /* misp_err("%s - entering", __func__); */
+
+ dump_memory = kzalloc(len, GFP_KERNEL);
+ if (!dump_memory) {
+ retval = -ENOMEM;
+ misp_err("%s Allocate memory failed.", __func__);
+ goto allocate_memory_fail;
+ }
+
+ mini_isp_memory_read(start_addr, dump_memory, len);
+
+
+ snprintf(filename, 128, "%s/%s.raw", dest_path, file_name);
+#if ENABLE_FILP_OPEN_API
+ /* use file open */
+#else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ goto file_open_fail;
+#endif
+ /*Get current segment descriptor*/
+ fs = get_fs();
+ /*Set segment descriptor associated*/
+ set_fs(get_ds());
+
+ if (IS_ERR(f)) {
+ retval = PTR_ERR(f);
+ set_fs(fs);
+ misp_err("%s open file failed. err: %d", __func__, retval);
+ goto file_open_fail;
+ }
+ /*write the file*/
+ vfs_write(f, (char *)dump_memory, len, &f->f_pos);
+
+ /*Restore segment descriptor*/
+ set_fs(fs);
+ filp_close(f, NULL);
+file_open_fail:
+allocate_memory_fail:
+ kfree(dump_memory);
+
+ return retval;
+}
+EXPORT_SYMBOL(mini_isp_memory_read_then_write_file);
+/**
+ *\brief Get woi image and save as file.
+ *\param start_addr [In], start address
+ *\param lineoffset [In], line offset (byte)
+ *\param width [In], image width (byte), it can't exceed 60000bytes.
+ *\param height [In], image height(byte)
+ *\param dest_path [In], save path
+ *\param file_name [In], save file name
+ *\return
+ */
+u32 mini_isp_woi_memory_read_then_write_file(u32 start_addr,
+ u32 lineoffset, u32 width, u32 height,
+ char *dest_path, char *file_name)
+{
+ u32 retval = ERR_SUCCESS;
+ u8 *dump_memory = NULL;
+ u8 *keep_dump_memory = NULL;
+ u32 dump_addr = start_addr;
+ u32 ouput_size;
+ u32 one_size;
+ u32 loopidx = 0;
+ s32 remain_size;
+ u8 filename[128];
+ struct file *f;
+ mm_segment_t fs;
+
+ misp_info("%s, lineoffset: %d, width: %d, height: %d, filename: %s",
+ __func__, lineoffset, width, height, file_name);
+
+ ouput_size = width * height;
+ dump_memory = kzalloc(ouput_size, GFP_KERNEL);
+ if (!dump_memory) {
+ misp_err("%s Allocate memory failed.", __func__);
+ goto allocate_dump_memory_fail;
+ }
+ keep_dump_memory = dump_memory;
+
+
+ /* memory read */
+ for (loopidx = 0, remain_size = ouput_size; remain_size > 0;
+ remain_size -= width, loopidx++) {
+ /* update read memory size and address */
+ one_size = (remain_size > width) ? width : remain_size;
+ dump_addr = start_addr + loopidx*lineoffset;
+
+ retval = mini_isp_memory_read(dump_addr, dump_memory, one_size);
+ if (retval) {
+ misp_err("%s get failed.", __func__);
+ goto mini_isp_memory_read_get_fail;
+ }
+
+ misp_info("%s dump_addr = 0x%x one_size = %d",
+ __func__, dump_addr, one_size);
+
+ dump_memory += one_size;
+ dump_addr += one_size;
+ }
+
+ misp_info("%s read_finish", __func__);
+
+ snprintf(filename, 128, "%s/%s.raw", dest_path, file_name);
+#if ENABLE_FILP_OPEN_API
+ /* use file open */
+#else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ goto file_open_fail;
+#endif
+ /*Get current segment descriptor*/
+ fs = get_fs();
+ /*Set segment descriptor associated*/
+ set_fs(get_ds());
+
+ if (IS_ERR(f)) {
+ retval = PTR_ERR(f);
+ set_fs(fs);
+ misp_err("%s open file failed. err: %d", __func__, retval);
+ goto file_open_fail;
+ }
+ /*write the file*/
+ vfs_write(f, (char *)keep_dump_memory, ouput_size, &f->f_pos);
+
+ /*Restore segment descriptor*/
+ set_fs(fs);
+ filp_close(f, NULL);
+file_open_fail:
+mini_isp_memory_read_get_fail:
+allocate_dump_memory_fail:
+ kfree(keep_dump_memory);
+
+ return retval;
+}
+EXPORT_SYMBOL(mini_isp_woi_memory_read_then_write_file);
+u32 mini_isp_memory_read_shortlen(u32 start_addr, u32 *read_buffer)
+{
+ int status = ERR_SUCCESS;
+ u8 *send_buffer;
+ u8 *recv_buffer;
+ u8 ctrlbyte = 0;
+ u32 address = start_addr;
+ struct misp_data *devdata;
+ u8 send_buffer_value[64] = {0};
+ u8 recv_buffer_value[64] = {0};
+
+
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+ send_buffer = send_buffer_value;
+ recv_buffer = recv_buffer_value;
+
+
+ /* misp_err("%s - entering", __func__); */
+
+ /* Setp1, Send memory address: { ctrlbyte[1byte] + addr[4byte] } */
+ ctrlbyte = CTRL_BYTE_MEMRD_W;
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &address, 4);
+
+ /* read 4 bytes memory value */
+ status = devdata->intf_fn->read(
+ devdata,
+ send_buffer_value,
+ EMODE_TXCMD_LEN,
+ recv_buffer_value,
+ 0);
+
+ if (status) {
+ misp_err("%s - sync error: status = %d", __func__, status);
+ goto mini_isp_memory_read_shortlen_end;
+ }
+
+ udelay(500);
+
+ /* Setp2, wait a moment and get data{ dummy[1byte] + data[4byte] } */
+ ctrlbyte = CTRL_BYTE_GETDATA_W;
+ memcpy(send_buffer, &ctrlbyte, 1);
+
+ status = devdata->intf_fn->read(devdata,
+ send_buffer_value,
+ 1,
+ recv_buffer_value,
+ 5);
+
+ if (status) {
+ misp_err("%s - sync error: status = %d", __func__, status);
+ goto mini_isp_memory_read_shortlen_end;
+ }
+
+ recv_buffer = (u8 *)&recv_buffer_value[1];
+
+
+
+ memcpy(read_buffer, recv_buffer, 4);
+
+mini_isp_memory_read_shortlen_end:
+
+ return status;
+
+}
+
+
+u32 mini_isp_memory_read(u32 start_addr, u8 *read_buffer, u32 len)
+{
+ struct misp_data *devdata;
+ struct misp_global_variable *dev_global_variable;
+ u32 retval = ERR_SUCCESS;
+ u8 *io_buffer = NULL;
+ u8 *send_buffer;
+ u8 *recv_buffer;
+ u8 *dump_memory = NULL;
+ u8 *keep_dump_memory = NULL;
+ u32 dump_addr = start_addr;
+ u32 start_mem_addr = start_addr;
+ u32 ouput_size;
+ u32 io_size, remain_size, one_size, recv_buffer_size, send_buffer_size;
+ u32 rx_dummy_len;
+ u8 ctrlbyte = CTRL_BYTE_MEMRD;
+ u32 len_align;
+
+ misp_err("%s - entering", __func__);
+
+ /* 4byte alignment for 'mini_isp_memory_read_shortlen()' */
+ len_align = ALIGN_CEIL(len, 4);
+
+ dump_memory = kzalloc(len_align, GFP_KERNEL);
+ if (!dump_memory) {
+ retval = -ENOMEM;
+ misp_err("%s Allocate memory failed.", __func__);
+ goto allocate_memory_fail;
+ }
+ keep_dump_memory = dump_memory;
+ ouput_size = len;
+
+
+ if (SPI_SHORT_LEN_MODE && SPI_SHORT_LEN_MODE_READ_ENABLE) {
+ while (start_mem_addr < start_addr + len) {
+ mini_isp_memory_read_shortlen(start_mem_addr,
+ (u32 *)dump_memory);
+
+ start_mem_addr = start_mem_addr + 4;
+ dump_memory = dump_memory + 4;
+ }
+ } else {
+ dev_global_variable = get_mini_isp_global_variable();
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+
+ rx_dummy_len = mini_isp_get_rx_dummy_byte(ctrlbyte);
+
+ #if EN_SPIE_REG_DUMMY_BYTE
+ mini_isp_set_spie_dummy_byte(rx_dummy_len-1); /* 0 base */
+ #endif
+
+ send_buffer_size = EMODE_TXCMD_LEN;
+ recv_buffer_size = EMODE_TXCMD_LEN + rx_dummy_len + 60000;
+
+ /* read 60000 bytes at a time;*/
+ io_size = send_buffer_size + recv_buffer_size;
+ io_buffer = kzalloc(io_size, GFP_KERNEL);
+ if (!io_buffer) {
+ misp_err("%s Allocate memory failed.", __func__);
+ goto allocate_memory_fail;
+ }
+
+ /* memory read */
+ for (remain_size = ouput_size; remain_size > 0;
+ remain_size -= one_size) {
+
+ one_size = (remain_size > 60000) ?
+ 60000 : remain_size;
+
+ memset(io_buffer, 0, io_size);
+ send_buffer = io_buffer;
+ recv_buffer = io_buffer + EMODE_TXCMD_LEN;
+
+ memcpy(send_buffer, &ctrlbyte, 1);
+ memcpy(send_buffer + 1, &dump_addr, 4);
+
+ retval = devdata->intf_fn->read((void *)devdata,
+ send_buffer,
+ EMODE_TXCMD_LEN,
+ recv_buffer,
+ one_size + rx_dummy_len);
+ if (retval) {
+ misp_err("%s get failed.", __func__);
+ goto mini_isp_memory_read_get_fail;
+ }
+
+ if (dev_global_variable->intf_status & INTF_SPI_READY) {
+ /* check if send len + recv len > 32. if yes then
+ * rx_dummy_len need + EMODE_TXCMD_LEN
+ */
+ if (EMODE_TXCMD_LEN + rx_dummy_len + one_size > 32)
+ retval = mini_isp_check_rx_dummy(
+ &recv_buffer,
+ rx_dummy_len+EMODE_TXCMD_LEN);
+ else
+ retval = mini_isp_check_rx_dummy(
+ &recv_buffer,
+ rx_dummy_len);
+
+ if (retval) {
+ misp_err("%s get failed.", __func__);
+ goto mini_isp_memory_read_get_fail;
+ }
+ }
+
+ memcpy(dump_memory, recv_buffer, one_size);
+ misp_info("%s dump_addr = 0x%x one_size = %d",
+ __func__, dump_addr, one_size);
+ dump_memory += one_size;
+ dump_addr += one_size;
+ }
+
+ }
+
+ misp_info("%s read_finish", __func__);
+
+ memcpy(read_buffer, keep_dump_memory, ouput_size);
+
+mini_isp_memory_read_get_fail:
+allocate_memory_fail:
+ kfree(keep_dump_memory);
+ kfree(io_buffer);
+
+ return retval;
+}
+EXPORT_SYMBOL(mini_isp_memory_read);
+
+
+int mini_isp_get_bulk(struct misp_data *devdata, u8 *response_buf,
+ u32 total_size, u32 block_size)
+{
+ int status = ERR_SUCCESS, count = 0;
+ int remain_size, one_size;
+ /* 1byte ctrlbyte, 2bytes recv */
+ u8 io_buffer[3] = {0};
+ u8 *send_buffer;
+ u8 *recv_buffer;
+ u8 ctrlbyte = USPICTRL_MS_CB_DIS;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ send_buffer = io_buffer;
+ send_buffer[0] = ctrlbyte;
+ recv_buffer = io_buffer + 1;
+
+ misp_info("%s started.", __func__);
+
+ status = devdata->intf_fn->read(
+ (void *)devdata,
+ send_buffer,
+ 1,
+ recv_buffer,
+ 2);
+ if (status) {
+ misp_err(
+ "mini_isp_send_bulk send ctrl byte failed. status:%d",
+ status);
+ status = -EINVAL;
+ goto G_EXIT;
+ }
+
+ for (remain_size = total_size;
+ remain_size > 0;
+ remain_size -= one_size) {
+
+ one_size = (remain_size > block_size) ?
+ block_size : remain_size;
+ /*get the data*/
+ misp_info("%s dump start", __func__);
+ status = devdata->intf_fn->read(
+ (void *)devdata,
+ response_buf,
+ 0,
+ response_buf,
+ one_size);
+
+ if (status != 0) {
+ misp_err("%s failed!! block:%d status: %d", __func__,
+ count, status);
+ break;
+ }
+
+ response_buf += one_size;
+ count++;
+ }
+
+G_EXIT:
+
+ if (status != ERR_SUCCESS)
+ misp_info("%s - error: %d", __func__, status);
+ else
+ misp_info("%s - success.", __func__);
+
+ return status;
+}
+EXPORT_SYMBOL_GPL(mini_isp_get_bulk);
+
+
+
+int mini_isp_get_altek_status(void *devdata, u32 *altek_status)
+{
+ int status = ERR_SUCCESS;
+
+ misp_info("%s - entering", __func__);
+
+ mini_isp_register_read(INTERRUPT_STATUS_REGISTER_ADDR, altek_status);
+
+ misp_info("%s - altek_status = %#x", __func__, *altek_status);
+
+ return status;
+}
+
+/*interrupt handler function */
+extern irqreturn_t mini_isp_irq(int irq, void *handle)
+{
+ struct misp_data *devdata = NULL;
+ struct misp_global_variable *dev_global_variable;
+ int errcode = ERR_SUCCESS;
+ int original_altek_spi_mode;
+ u32 altek_event_state = 0;
+
+ misp_info("%s - enter", __func__);
+
+ irqflag = true;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+ if (!devdata || !dev_global_variable)
+ return -IRQ_NONE;
+
+ original_altek_spi_mode = dev_global_variable->altek_spi_mode;
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ mini_isp_a_to_e();
+ }
+ errcode = mini_isp_get_altek_status(devdata,
+ &altek_event_state);
+ misp_info("%s - read spi register: %#x",
+ __func__, altek_event_state);
+
+ event = MINI_ISP_RCV_WAITING;
+
+ if (errcode == ERR_SUCCESS) {
+ /*error event*/
+ if (altek_event_state & SYSTEM_ERROR_LEVEL1) {
+ event = event | MINI_ISP_RCV_ERROR;
+ if (dev_global_variable->intf_status & INTF_SPI_READY)
+ mini_isp_e_to_a();
+ /* need to port out of this ISR */
+ mini_isp_drv_get_err_code_cmd_in_irq();
+ if (dev_global_variable->intf_status & INTF_SPI_READY)
+ mini_isp_a_to_e();
+ }
+ if (altek_event_state & SYSTEM_ERROR_LEVEL2) {
+ event = event | MINI_ISP_RCV_ERROR2;
+ mini_isp_utility_read_reg_e_mode();
+ }
+ /*set sensor mode event*/
+ if (altek_event_state & SET_SENSOR_MODE_READY)
+ event = event | MINI_ISP_RCV_SETSENSORMODE;
+ /*change cp mode event*/
+ if (altek_event_state & CP_STATUS_CHANGE_DONE)
+ event = event | MINI_ISP_RCV_CPCHANGE;
+ /*ready event*/
+ /*CMD*/
+ if (altek_event_state & COMMAND_COMPLETE)
+ event = event | MINI_ISP_RCV_CMD_READY;
+ /*Bulk Data*/
+ if (altek_event_state & BULK_DATA_COMPLETE)
+ event = event | MINI_ISP_RCV_BULKDATA;
+ /* streamoff event*/
+ if (altek_event_state & STRMOFF_READY)
+ event = event | MINI_ISP_RCV_STRMOFF;
+
+ mini_isp_register_write(
+ INTERRUPT_STATUS_REGISTER_ADDR,
+ altek_event_state);
+ } else {
+ misp_err("%s - err: %d", __func__, errcode);
+ }
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ original_altek_spi_mode !=
+ dev_global_variable->altek_spi_mode)
+ mini_isp_e_to_a();
+
+ wake_up_interruptible(&WAITQ);
+
+ misp_info("%s - leave", __func__);
+
+ return IRQ_HANDLED;
+}
+
+int mini_isp_wait_for_event(u32 e)
+{
+ int state = 0;
+
+#if (ISR_MECHANISM == INTERRUPT_METHOD)
+ misp_info("%s - entering. event: %#x", __func__, e);
+ do {
+ state = wait_event_interruptible(WAITQ, event & e);
+ } while (state == (-ERESTARTSYS));
+
+ current_event = event;
+
+ event = (~e) & event;/*MINI_ISP_RCV_WAITING;*/
+
+ if (state)
+ misp_err("%s - irq error. err: %d", __func__, state);
+
+#else /* ISR_MECHANISM == POLLING_METHOD */
+
+ struct misp_data *devdata = NULL;
+ struct misp_global_variable *dev_global_variable;
+ u32 altek_event_state = 0;
+ int original_altek_spi_mode;
+
+ devdata = get_mini_isp_intf(MINIISP_I2C_SLAVE);
+ dev_global_variable = get_mini_isp_global_variable();
+ original_altek_spi_mode = dev_global_variable->altek_spi_mode;
+
+ msleep(100);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ mini_isp_a_to_e();
+ }
+
+ misp_info("%s - entering. event: %#x", __func__, e);
+ do {
+ misp_info("%s - polling...", __func__);
+
+ mini_isp_get_altek_status(devdata, &altek_event_state);
+
+ if (altek_event_state & SYSTEM_ERROR_LEVEL1) {
+ if (dev_global_variable->intf_status & INTF_SPI_READY)
+ mini_isp_e_to_a();
+ /* need to port out of this ISR */
+ mini_isp_drv_get_err_code_cmd_in_irq();
+ if (dev_global_variable->intf_status & INTF_SPI_READY)
+ mini_isp_a_to_e();
+ } else if (altek_event_state & SYSTEM_ERROR_LEVEL2) {
+ mini_isp_utility_read_reg_e_mode();
+ } else if (altek_event_state & e) {
+ /* find target, clear status */
+ mini_isp_register_write(0xffef00b4, e);
+ break;
+ }
+ msleep(50);
+ } while ((altek_event_state & e) == 0);
+
+ current_event = e;
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (original_altek_spi_mode !=
+ dev_global_variable->altek_spi_mode))
+ mini_isp_e_to_a();
+#endif
+ misp_info("%s - leaving. event: %#x", __func__, e);
+
+ return state;
+}
+
+u32 mini_isp_get_currentevent(void)
+{
+ return current_event;
+}
+
+u32 mini_isp_check_rx_dummy(u8 **recv_buffer, u32 rx_dummy_len)
+{
+ u32 ret = 0;
+#if (EN_SPIE_REG_DUMMY_BYTE == 0)
+ u32 get_count = 0;
+#endif
+
+#if EN_SPIE_DEBUG
+ /*u8 idx = 0;*/
+ u8 col_idx = 0;
+ u8 row_idx = 0;
+ u8 *ptest = NULL;
+
+ misp_info("%s, dummy byte: %d", __func__, rx_dummy_len);
+ ptest = *recv_buffer;
+
+ misp_info(" 0 1 2 3 4 5 6 7 8 9 A B C D E F");
+ for (col_idx = 0; col_idx < ((rx_dummy_len+1)/16); col_idx++) {
+ misp_info(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",
+ (u32)*(ptest), (u32)*(ptest+1), (u32)*(ptest+2), (u32)*(ptest+3),
+ (u32)*(ptest+4), (u32)*(ptest+5), (u32)*(ptest+6), (u32)*(ptest+7),
+ (u32)*(ptest+8), (u32)*(ptest+9), (u32)*(ptest+10), (u32)*(ptest+11),
+ (u32)*(ptest+12), (u32)*(ptest+13), (u32)*(ptest+14), (u32)*(ptest+15));
+
+ ptest = ptest + 16;
+ }
+
+ /* remain less 16 byte data */
+ col_idx -= 1;
+ for (row_idx = 0; row_idx < (rx_dummy_len+1)-(col_idx*16); row_idx++) {
+ misp_info(" %02X", (u32)*(ptest));
+ ptest++;
+ }
+ #endif
+
+#if EN_SPIE_REG_DUMMY_BYTE
+ (*recv_buffer) = (*recv_buffer) + rx_dummy_len;
+#else
+ /* find first 0xa5 */
+ while (**recv_buffer != 0xa5) {
+ (*recv_buffer)++;
+ get_count++;
+ if (get_count >= rx_dummy_len) {
+ misp_info("%s, dummy byte excess 32!", __func__);
+ return -EIO;
+ }
+ }
+
+ /* check last 0xa5*/
+ while (*(*recv_buffer+1) == 0xa5) {
+ (*recv_buffer)++;
+ get_count++;
+ if (get_count >= rx_dummy_len) {
+ misp_info("%s, dummy byte excess 32!", __func__);
+ return -EIO;
+ }
+ }
+
+ /* find available data */
+ (*recv_buffer)++;
+#endif
+
+#if EN_SPIE_DEBUG
+ misp_info("%s, available byte: 0x%x", __func__, (u32)(**recv_buffer));
+#endif
+ return ret;
+}
+
+
+errcode mini_isp_create_directory(char *dir_name)
+{
+ size_t errcode = ERR_SUCCESS;
+ struct dentry *dentry;
+ struct path path;
+
+ dentry = kern_path_create(AT_FDCWD, dir_name,
+ &path, LOOKUP_DIRECTORY);
+ if (IS_ERR(dentry)) {
+ misp_info("%s, fail %d", __func__, IS_ERR(dentry));
+ return PTR_ERR(dentry);
+ }
+
+ errcode = vfs_mkdir(path.dentry->d_inode, dentry, 0777);
+
+ done_path_create(&path, dentry);
+
+ misp_info("%s, create directory %s", __func__, dir_name);
+ return errcode;
+}
+
+/**
+ *\brief Get rx dummy byte.
+ *\param spie_rx_mode [In], spie rx mode. memory read or register read.
+ *\ If it's not spie mode, set 0 for default.
+ *\return dummy byte lens
+ */
+
+u32 mini_isp_get_rx_dummy_byte(u8 spie_rx_mode)
+{
+ u32 rx_dummy_byte = 0;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ /* only spi-e need configure rx dummy byte */
+ if (dev_global_variable->intf_status & INTF_SPI_READY) {
+#if EN_SPIE_REG_DUMMY_BYTE
+ if (spie_rx_mode == CTRL_BYTE_REGRD)
+ rx_dummy_byte = SPIE_RX_REG_DUMMY_LEN;
+ else if (spie_rx_mode == CTRL_BYTE_MEMRD)
+ rx_dummy_byte = SPIE_RX_MEM_DUMMY_LEN;
+#else
+ rx_dummy_byte = SPIE_RX_DUMMY_LEN;
+#endif
+ } else if (dev_global_variable->intf_status & INTF_I2C_READY)
+ rx_dummy_byte = 0;
+ else
+ rx_dummy_byte = 0;
+
+ return rx_dummy_byte;
+}
+
+void mini_isp_set_spie_dummy_byte(u32 dummy_lens)
+{
+ mini_isp_register_write(SPIE_DUMMY_BYTE_ADDR, dummy_lens);
+}
diff --git a/drivers/media/platform/altek/miniisp_utility.c b/drivers/media/platform/altek/miniisp_utility.c
new file mode 100644
index 0000000..d28f093
--- /dev/null
+++ b/drivers/media/platform/altek/miniisp_utility.c
@@ -0,0 +1,2376 @@
+/*
+ * File: miniisp_utility.c
+ * Description: Mini ISP Utility sample codes
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2017/03/29; Louis Wang; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+ /******Include File******/
+#include "linux/init.h"
+#include "linux/module.h"
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/timekeeping.h>
+#include <linux/wait.h>
+#include <linux/fcntl.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+
+#ifdef NEW_CLOCK_HEADER
+#include <linux/sched/clock.h>
+#endif
+
+#include "include/miniisp.h"
+#include "include/error.h"
+#include "include/miniisp_chip_base_define.h"
+#include "include/miniisp_customer_define.h"
+
+
+#define MINI_ISP_LOG_TAG "[miniisp_utility]"
+
+#define DEBUG_INFO_DEPTH_FLOW_INFO_ADDR (0x28)
+#define DEBUG_INFO_METADATA_ADDR (0x14)
+#define DEBUG_INFO_FEC_DEBUG_MODE_ADDR (0x40)
+#define DEBUG_INFO_SENSOR_REAL_INFO_ADDR (0x44)
+#define DEBUG_INFO_LED_INFO_ADDR (0x48)
+
+#define ADV_LOG_LIGHTING_PROJECTOR (0x5)
+#define ADV_LOG_LIGHTING_FLOOD (0x6)
+
+#define PACKDATA_SIZE (1824)
+#define PACKDATA_OFFSET (0x4C)
+
+#define LOG_BUF_SIZE (200*1024)
+
+GPIO g_atGPIO[] = {
+
+ { "GPIO0", 0xFFEA0200, "NoUse" },
+ { "GPIO1", 0xFFEA0204, "NoUse" },
+ { "GPIO2", 0xFFEA0208, "NoUse" },
+ { "GPIO3", 0xFFEA020c, "NoUse" },
+ { "GPIO4", 0xFFEA0210, "NoUse" },
+ { "GPIO5", 0xFFEA0214, "NoUse" },
+ { "GPIO6", 0xFFEA0218, "NoUse" },
+ { "GPIO7", 0xFFEA021C, "NoUse" },
+ { "GPIO8", 0xFFEA0220, "NoUse" },
+ { "GPIO9", 0xFFEA0224, "NoUse" },
+ { "GPIO10", 0xFFEA0228, "NoUse" }
+};
+#define GPIO_NUMBER (sizeof(g_atGPIO)/sizeof(GPIO))
+
+ /******Private Global Variable******/
+
+
+ /******Public Function******/
+/**
+ *\brief dump AL6100 register for debug bypass mode
+ *\return Error code
+*/
+errcode mini_isp_utility_read_reg_e_mode_for_bypass_use(void)
+{
+ errcode err = ERR_SUCCESS;
+ u8 filepath[80];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ /* switch to E mode */
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ snprintf(filepath, 80, "%s/dump_bypass_reg/",
+ MINIISP_INFO_DUMPLOCATION);
+ err = mini_isp_create_directory(filepath);
+ err = mini_isp_chip_base_dump_bypass_mode_register(filepath);
+
+ /* switch to A mode */
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_utility_read_reg_e_mode_for_bypass_use);
+
+
+/**
+ *\brief dump AL6100 register for debug
+ *\return Error code
+*/
+errcode mini_isp_utility_read_reg_e_mode(void)
+{
+ errcode err = ERR_SUCCESS;
+ u8 filepath[80];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ /* switch to E mode */
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ snprintf(filepath, 80, "%s/dump_normal_reg/",
+ MINIISP_INFO_DUMPLOCATION);
+ err = mini_isp_create_directory(filepath);
+ err = mini_isp_chip_base_dump_normal_mode_register(filepath);
+
+ /* switch to A mode */
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_utility_read_reg_e_mode);
+
+/**
+ *\brief Read irp and depth image based information
+ *\return Error code
+*/
+errcode mini_isp_utility_get_irp_and_depth_information(
+ struct irp_and_depth_information *info)
+{
+ errcode err = ERR_SUCCESS;
+ u32 rg_img_in_size;
+ u32 rg_depth_in_size;
+ u32 crop_src;
+ u8 fov_mode;
+
+ mini_isp_register_read(0xfff8401c, &rg_img_in_size);
+ info->irp_width = ((rg_img_in_size & 0x00001fff)+1);
+ info->irp_height = (((rg_img_in_size & 0x1fff0000)>>16)+1);
+
+ mini_isp_register_read(0xfffa7020, &crop_src);
+
+ if (crop_src)
+ info->irp_format = 1;
+ else
+ info->irp_format = 0;
+
+ mini_isp_register_read(0xfff5601c, &rg_depth_in_size);
+ info->depth_width = ((rg_depth_in_size & 0x00001fff)+1);
+ info->depth_height = (((rg_depth_in_size & 0x1fff0000)>>16)+1);
+
+ info->depth_image_address = 0x20715400;
+
+ mini_isp_memory_read(0x24, &fov_mode, 1);
+
+ info->fov_mode = fov_mode;
+ if (fov_mode == 1)
+ info->irp_image_address = 0x20500000 + 288000 -
+ ((rg_img_in_size & 0x00001fff) + 1) *
+ (((rg_img_in_size & 0x1fff0000)>>16) + 1);
+ else
+ info->irp_image_address = 0x20500000;
+ misp_info("%s:depth_image_address:%u, depth_width:%u, depth_height:%u, \
+ irp_format:%u, irp_image_address:%u, irp_width:%u, \
+ irp_height:%u, fov_mode:%u\n", __func__,
+ info->depth_image_address, info->depth_width,
+ info->depth_height, info->irp_format,
+ info->irp_image_address, info->irp_width,
+ info->irp_height, info->fov_mode);
+ return err;
+}
+EXPORT_SYMBOL(mini_isp_utility_get_irp_and_depth_information);
+
+/**
+ *\brief dump compress irp img and rectify depth
+ *\return Error code
+ */
+int mini_isp_debug_dump_img(void)
+{
+ #define left_rotate_val 1
+ #define right_rotate_val 2
+
+ int errcode = ERR_SUCCESS;
+ u8 write_buffer[4];
+ u32 rg_img_in_size;
+ u32 rotate_mode = 0;
+ u32 img_width = 0, img_height = 0;
+ u32 HighDistRateFlag = 0;
+ u32 YUVFlag = 0;
+ u32 img_size_mul = 100, img_size_div = 100;
+ u32 img_addr = 0;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+ mini_isp_register_read(0xfff8401c, &rg_img_in_size);
+ mini_isp_register_read(0xfff84014, &rotate_mode);
+ rotate_mode &= 0x3;
+
+ /* Step 1 */
+ write_buffer[0] = 1;
+ mini_isp_memory_write(0x10, write_buffer, 1);
+
+ msleep(2000); /* delay 2 sec */
+ /* IRP image rotate */
+ if (rotate_mode == right_rotate_val || rotate_mode == left_rotate_val) {
+ img_height = (rg_img_in_size & 0x1fff) + 1; /* 0 base */
+ img_width = ((rg_img_in_size >> 16) & 0x1fff) + 1; /* 0 base */
+ } else {
+ img_width = (rg_img_in_size & 0x1fff) + 1; /* 0 base */
+ img_height = ((rg_img_in_size >> 16) & 0x1fff) + 1; /* 0 base */
+ }
+
+ mini_isp_register_read(0xffe80064, &YUVFlag);
+ YUVFlag = !YUVFlag;
+ mini_isp_register_read(0x24, &HighDistRateFlag);
+ HighDistRateFlag &= 0xFF;
+
+ if (HighDistRateFlag) {
+ img_addr = 0x20500000 + 288000 - (img_width * img_height);
+ img_size_mul = 100;
+ img_size_div = 100;
+ } else {
+ img_addr = 0x20500000;
+ img_size_mul = 125;
+ img_size_div = 100;
+ }
+
+ misp_info("%s - [W,H]: [%d, %d], rotate_mode: %d, YUV: %d, HighDistRateFlag: %d",
+ __func__, img_width, img_height,
+ rotate_mode, YUVFlag, HighDistRateFlag);
+
+ mini_isp_memory_read_then_write_file(img_addr,
+ (img_width * img_height * img_size_mul / img_size_div),
+ MINIISP_INFO_DUMPLOCATION, "compress_irp");
+
+ /* Step 2 */
+ write_buffer[0] = 2;
+ mini_isp_memory_write(0x10, write_buffer, 1);
+ msleep(100); /* image will broken if no delay time */
+
+ mini_isp_register_read(0xfff5601C, &rg_img_in_size);
+ img_width = (rg_img_in_size & 0x1fff) + 1;
+ img_height = ((rg_img_in_size >> 16) & 0x1fff) + 1;
+
+ mini_isp_memory_read_then_write_file(0x20715400,
+ (img_width * img_height * 10/8),
+ MINIISP_INFO_DUMPLOCATION, "rect_depth");
+
+ /* step 3, restore */
+ write_buffer[0] = 0;
+ mini_isp_memory_write(0x10, write_buffer, 1);
+ msleep(100);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return errcode;
+}
+EXPORT_SYMBOL(mini_isp_debug_dump_img);
+
+/**
+ *\brief dump every phase of depth module info, and save as file
+ *\param is_ground_mode [in] 0: For depth normal mdoe.
+ *\ 1: For depth ground mode
+ *\return Error code
+ */
+int mini_isp_debug_depth_rect_combo_dump(u8 is_ground_mode)
+{
+ int errcode = ERR_SUCCESS;
+ u8 write_buffer[4];
+ u8 filepath[80];
+ u8 filename[80];
+ u8 loopNum = 1, loopIdx = 0;
+ u32 rg_img_in_size;
+ u32 ref_img_width = 0, ref_img_height = 0;
+ u32 start_x = 0, start_y = 0;
+ u32 imgAddr, ref_imgLinePixelOffset;
+ u32 tmp;
+
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ if (is_ground_mode)
+ loopNum = 2;
+ else
+ loopNum = 1;
+
+ /* create base folder */
+ snprintf(filepath, 80, "%s/depth_combo_dump/",
+ MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+
+ /* First loop for Normal, second loop for gound */
+ for (loopIdx = 0; loopIdx < loopNum; loopIdx++) {
+ /* step 1 */
+ write_buffer[0] = 1;
+ mini_isp_memory_write(0x10, write_buffer, 1);
+ msleep(100);
+
+ /* step 2 */
+ write_buffer[0] = 1;
+ mini_isp_memory_write(0x20, write_buffer, 1);
+ msleep(100);
+
+ /* step 3 */
+ write_buffer[0] = 2;
+ mini_isp_memory_write(0x10, write_buffer, 1);
+ msleep(100);
+
+ /* dump reg */
+ snprintf(filepath, 80,
+ "%s/depth_combo_dump/%s_step3_rectify_a_0/",
+ MINIISP_INFO_DUMPLOCATION, (loopIdx == 0)?"n":"g");
+ errcode = mini_isp_create_directory(filepath);
+ mini_isp_chip_base_define_module_reg_dump(filepath, "rectify_a_0");
+
+ mini_isp_register_read(0xFFF8C104, &tmp);
+ start_x = (tmp & 0x00001fff)+1;
+ start_y = ((tmp & 0x1fff0000) >> 16)+1;
+
+ mini_isp_register_read(0xFFF8C108, &tmp);
+ ref_img_width = (tmp & 0x00001fff)+1;
+ ref_img_height = ((tmp & 0x1fff0000) >> 16)+1;
+
+ ref_img_width = ref_img_width - start_x + 1;
+ ref_img_height = ref_img_height - start_y + 1;
+
+ misp_info("step3 m [ref_w,ref_h]: %d ,%d", ref_img_width, ref_img_height);
+
+ mini_isp_register_read(0xFFF8C510, &imgAddr);
+ mini_isp_register_read(0xFFF8C518, &ref_imgLinePixelOffset);
+ ref_imgLinePixelOffset *= 8;
+
+ /* step 4 */
+ write_buffer[0] = 2;
+ mini_isp_memory_write(0x20, write_buffer, 1);
+ msleep(100);
+
+ /* dump reg */
+ snprintf(filepath, 80,
+ "%s/depth_combo_dump/%s_step4_rectify_a_0/",
+ MINIISP_INFO_DUMPLOCATION, (loopIdx == 0)?"n":"g");
+ errcode = mini_isp_create_directory(filepath);
+ mini_isp_chip_base_define_module_reg_dump(filepath, "rectify_a_0");
+
+ /* dump img */
+ misp_info("[Step4] %s Main W,H: %d, %d", (loopIdx == 0)?"n":"g",
+ ref_img_width, ref_img_height);
+ snprintf(filepath, 80, "%s/depth_combo_dump/",
+ MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+ snprintf(filename, 80, "%s_%s", (loopIdx == 0)?"n":"g", "step4_mainRect_img_8bit.raw");
+ errcode = mini_isp_woi_memory_read_then_write_file(imgAddr,
+ ref_imgLinePixelOffset, ref_img_width, ref_img_height, filepath, filename);
+
+ mini_isp_register_read(0xFFF8C104, &tmp);
+ start_x = (tmp & 0x00001fff)+1;
+ start_y = ((tmp & 0x1fff0000) >> 16)+1;
+
+ mini_isp_register_read(0xFFF8C108, &tmp);
+ ref_img_width = (tmp & 0x00001fff)+1;
+ ref_img_height = ((tmp & 0x1fff0000) >> 16)+1;
+
+ ref_img_width = ref_img_width - start_x + 1;
+ ref_img_height = ref_img_height - start_y + 1;
+
+ mini_isp_register_read(0xFFF8C510, &imgAddr);
+ mini_isp_register_read(0xFFF8C518, &ref_imgLinePixelOffset);
+ ref_imgLinePixelOffset *= 8;
+
+ /* dump img */
+ misp_info("[Step4] %s Sub W,H: %d, %d",
+ (loopIdx == 0)?"n":"g",
+ ref_img_width, ref_img_height);
+ snprintf(filepath, 80, "%s/depth_combo_dump/",
+ MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+ snprintf(filename, 80, "%s_%s", (loopIdx == 0)?"n":"g",
+ "step4_subRect_img_8bit.raw");
+ errcode = mini_isp_woi_memory_read_then_write_file(imgAddr,
+ ref_imgLinePixelOffset, ref_img_width,
+ ref_img_height, filepath, filename);
+
+ /* step 5 */
+ write_buffer[0] = 3;
+ mini_isp_memory_write(0x20, write_buffer, 1);
+ msleep(100);
+
+ /* dump reg */
+ snprintf(filepath, 80,
+ "%s/depth_combo_dump/%s_step5_rectify_a_0/",
+ MINIISP_INFO_DUMPLOCATION, (loopIdx == 0)?"n":"g");
+ errcode = mini_isp_create_directory(filepath);
+ mini_isp_chip_base_define_module_reg_dump(
+ filepath, "rectify_a_0");
+
+ snprintf(filepath, 80,
+ "%s/depth_combo_dump/%s_step5_rectify_b_0/",
+ MINIISP_INFO_DUMPLOCATION, (loopIdx == 0)?"n":"g");
+ errcode = mini_isp_create_directory(filepath);
+ mini_isp_chip_base_define_module_reg_dump(
+ filepath, "rectify_b_0");
+
+ snprintf(filepath, 80,
+ "%s/depth_combo_dump/%s_step5_dg_ca_a_0/",
+ MINIISP_INFO_DUMPLOCATION, (loopIdx == 0)?"n":"g");
+ errcode = mini_isp_create_directory(filepath);
+ mini_isp_chip_base_define_module_reg_dump(
+ filepath, "dg_ca_a_0");
+
+ snprintf(filepath, 80,
+ "%s/depth_combo_dump/%s_step5_dg_mcc_a_0/",
+ MINIISP_INFO_DUMPLOCATION, (loopIdx == 0)?"n":"g");
+ errcode = mini_isp_create_directory(filepath);
+ mini_isp_chip_base_define_module_reg_dump(
+ filepath, "dg_mcc_a_0");
+
+ /* dump img */
+ misp_info("[Step5] %s dg W,H: %d, %d",
+ (loopIdx == 0)?"n":"g", 1024,
+ ref_img_height);
+ snprintf(filepath, 80, "%s/depth_combo_dump/",
+ MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+ snprintf(filename, 80, "%s_%s",
+ (loopIdx == 0)?"n":"g",
+ "step5_dg_img_10unpack.raw");
+ errcode = mini_isp_woi_memory_read_then_write_file(0x20100000,
+ 1024*2, ref_img_width*2, ref_img_height, filepath, filename);
+
+ /* step 6 */
+ write_buffer[0] = 4;
+ mini_isp_memory_write(0x20, write_buffer, 1);
+ msleep(100);
+
+ /* dump reg */
+ snprintf(filepath, 80, "%s/depth_combo_dump/%s_step6_dp_top_a_0/",
+ MINIISP_INFO_DUMPLOCATION, (loopIdx == 0)?"n":"g");
+ errcode = mini_isp_create_directory(filepath);
+ mini_isp_chip_base_define_module_reg_dump(filepath, "dp_top_a_0");
+
+ /* dump img */
+ misp_info("[Step6] %s dg_top W,H: %d, %d",
+ (loopIdx == 0)?"n":"g", 1024,
+ ref_img_height);
+ snprintf(filepath, 80, "%s/depth_combo_dump/",
+ MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+ snprintf(filename, 80, "%s_%s", (loopIdx == 0)?"n":"g",
+ "step6_dp_img_10unpack.raw");
+ errcode = mini_isp_woi_memory_read_then_write_file(0x20100000,
+ 1024*2, ref_img_width*2,
+ ref_img_height, filepath, filename);
+
+ /* step 7 */
+ write_buffer[0] = 5;
+ mini_isp_memory_write(0x20, write_buffer, 1);
+ msleep(100);
+
+ /* dump reg */
+ snprintf(filepath, 80, "%s/depth_combo_dump/%s_step7_rectify_b_0/",
+ MINIISP_INFO_DUMPLOCATION, (loopIdx == 0)?"n":"g");
+ errcode = mini_isp_create_directory(filepath);
+ mini_isp_chip_base_define_module_reg_dump(filepath, "rectify_b_0");
+
+ /* dump img */
+ if (is_ground_mode) {
+ mini_isp_register_read(0xFFF8C104, &tmp);
+ start_x = (tmp & 0x00001fff)+1;
+ start_y = ((tmp & 0x1fff0000) >> 16)+1;
+
+ mini_isp_register_read(0xFFF8C108, &tmp);
+ ref_img_width = (tmp & 0x00001fff)+1;
+ ref_img_height = ((tmp & 0x1fff0000) >> 16)+1;
+
+ ref_img_width = ref_img_width - start_x + 1;
+ ref_img_height = ref_img_height - start_y + 1;
+ } else {
+ mini_isp_register_read(0xfff5601c, &rg_img_in_size);
+ ref_img_width = (rg_img_in_size & 0x00001fff) + 1;
+ ref_img_height = ((rg_img_in_size & 0x1fff0000)>>16) + 1;
+ }
+
+ misp_info("[Step7] %s InvRect W,H: %d, %d",
+ (loopIdx == 0)?"n":"g",
+ ref_img_width, ref_img_height);
+ snprintf(filepath, 80, "%s/depth_combo_dump/",
+ MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+
+ imgAddr = (loopIdx == 0) ? 0x20715400 : 0x20669AC0;
+ snprintf(filename, 80, "%s_%s",
+ (loopIdx == 0)?"n":"g",
+ "step7_InvRect_img_10pack.raw");
+
+ errcode = mini_isp_memory_read_then_write_file(imgAddr,
+ (ref_img_width * ref_img_height * 10 / 8), filepath, filename);
+
+ }
+
+ if (is_ground_mode) {
+ write_buffer[0] = 6;
+ mini_isp_memory_write(0x20, write_buffer, 1);
+ msleep(300);
+
+ /* dump reg */
+ snprintf(filepath, 80, "%s/depth_combo_dump/step9_rectify_b_0/",
+ MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+ mini_isp_chip_base_define_module_reg_dump(filepath, "rectify_b_0");
+
+ /* dump img */
+ misp_info("[Step9] blending W,H: %d, %d", 1024, ref_img_height);
+ snprintf(filepath, 80, "%s/depth_combo_dump/", MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+ errcode = mini_isp_woi_memory_read_then_write_file(0x20100000,
+ 1024*2, ref_img_width*2, ref_img_height, filepath, "g_step9_blending_img_10unpack.raw");
+
+ misp_info("[Step9] InvRect W,H: %d, %d", ref_img_width, ref_img_height);
+ snprintf(filepath, 80, "%s/depth_combo_dump/", MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+
+ mini_isp_register_read(0xfff5601c, &rg_img_in_size);
+ ref_img_width = (rg_img_in_size & 0x00001fff) + 1;
+ ref_img_height = ((rg_img_in_size & 0x1fff0000)>>16) + 1;
+ errcode = mini_isp_memory_read_then_write_file(0x20715400,
+ (ref_img_width * ref_img_height * 10 / 8), filepath, "g_step9_InvRect_img_10pack.raw");
+ }
+
+ /* step final restore */
+ write_buffer[0] = 0;
+ mini_isp_memory_write(0x20, write_buffer, 1);
+ msleep(300);
+
+ write_buffer[0] = 0;
+ mini_isp_memory_write(0x10, write_buffer, 1);
+ msleep(300);
+
+ if (dev_global_variable->intf_status & INTF_SPI_READY &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return errcode;
+}
+EXPORT_SYMBOL(mini_isp_debug_depth_rect_combo_dump);
+
+errcode mini_isp_debug_packdata_dump(void)
+{
+ errcode errcode = ERR_SUCCESS;
+ u32 packdebuginfo_addr = 0;
+ u32 packdata_addr = 0;
+ char filepath[80];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ mini_isp_memory_read(DEBUG_INFO_DEPTH_FLOW_INFO_ADDR, (u8 *)&packdebuginfo_addr, 4);
+ if (packdebuginfo_addr != 0) {
+ mini_isp_memory_read(packdebuginfo_addr+PACKDATA_OFFSET, (u8 *)&packdata_addr, 4);
+ } else{
+ misp_info("%s, addr err", __func__);
+ goto EXIT;
+ }
+
+ if (packdata_addr != 0) {
+ misp_info("%s dump 1824 bytes", __func__);
+ snprintf(filepath, 80, "%s", MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+ errcode = mini_isp_memory_read_then_write_file(packdata_addr,
+ PACKDATA_SIZE, filepath, "Dump_packdata.bin");
+ } else{
+ misp_info("%s, addr err", __func__);
+ goto EXIT;
+ }
+
+EXIT:
+ if (dev_global_variable->intf_status & INTF_SPI_READY &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return errcode;
+}
+EXPORT_SYMBOL(mini_isp_debug_packdata_dump);
+
+/**
+ *\brief save IQCalibration data as a file
+ *\return Error code
+ */
+errcode mini_isp_debug_IQCalib_dump(void)
+{
+ errcode errcode = ERR_SUCCESS;
+ u32 IQCalib_addr = 0;
+ char filepath[80];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ mini_isp_memory_read(0x30, (u8 *)&IQCalib_addr, 4);
+ if (IQCalib_addr != 0) {
+ misp_info("%s dump", __func__);
+ snprintf(filepath, 80, "%s", MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+ errcode = mini_isp_memory_read_then_write_file(IQCalib_addr,
+ 16556, filepath, "Dump_IQCalibration.bin");
+ } else
+ misp_info("%s, addr err", __func__);
+
+ if (dev_global_variable->intf_status & INTF_SPI_READY &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return errcode;
+}
+EXPORT_SYMBOL(mini_isp_debug_IQCalib_dump);
+
+/**
+ *\brief save metadata as a file
+ *\return Error code
+ */
+errcode mini_isp_debug_metadata_dump(void)
+{
+ errcode errcode = ERR_SUCCESS;
+ u32 metadata_addr = 0;
+ char filepath[80];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ mini_isp_memory_read(0x14, (u8 *)&metadata_addr, 4);
+ if (metadata_addr != 0) {
+ misp_info("%s dump", __func__);
+ snprintf(filepath, 80, "%s", MINIISP_INFO_DUMPLOCATION);
+ errcode = mini_isp_create_directory(filepath);
+ errcode = mini_isp_memory_read_then_write_file(metadata_addr,
+ 4*1024, filepath, "Dump_MetaData.bin");
+ } else
+ misp_info("%s, addr err", __func__);
+
+ if (dev_global_variable->intf_status & INTF_SPI_READY &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return errcode;
+}
+EXPORT_SYMBOL(mini_isp_debug_metadata_dump);
+
+static u32 CalculatePackdataCheckSum(u8 *PackdataBuf)
+{
+ u32 *PackdataBuf4B = (u32 *)PackdataBuf;
+ u32 CheckSum = 0;
+ u32 ii = 0;
+
+ for (ii = 0; ii < PACKDATA_SIZE/4; ii++) {
+ CheckSum += *PackdataBuf4B;
+ PackdataBuf4B++;
+ }
+
+ return CheckSum;
+}
+
+static void mini_isp_debug_depth_info_parser(DEPTHFLOWMGR_DEBUG_INFO *ptDepthFlowInfo)
+{
+ u32 modeid;
+ u32 refImg1_w, refImg1_h, refImg2_w, refImg2_h, refImg3_w, refImg3_h;
+ u32 refImg1_Idx, refImg2_Idx, refImg3_Idx;
+ u32 KernelSizeRatio;
+ u32 DepthType;
+ u32 GroundMode;
+ u32 ValidPackdata;
+ u32 ValidDisparityToDistanceTable;
+ u32 HighDistortionRateFlag;
+ u32 PackdataIdxNormal, PackdataIdxGround, PackdataIdxRGB;
+ u32 GlobalCompensation;
+ u32 HwCoefficient;
+ u32 HighDistortionIdx;
+ u32 PackdataSrc;
+ u32 WOI_x, WOI_y, WOI_w, WOI_h, Full_w, Full_h;
+ u32 ValidBlendingTable;
+ u32 BlendingSrc;
+ u32 ValidQmerge;
+ u32 dist[] = { 0, 0, 0 };
+ u32 tmp;
+
+ const u32 modeid_min = 0;
+ const u32 modeid_max = 8;
+ const u32 KernelSizeRatio_min = 0;
+ const u32 KernelSizeRatio_max = 15;
+ const u32 GlobalCompensation_21 = 21;
+ const u32 GlobalCompensation_36 = 36;
+ const u32 HwCoefficient_16 = 16;
+ const u32 uwHighDistortionIdx_max = 5;
+ const char ResStr[4][64] = {"16:9", "16:10", "4:3", "@:@"};
+
+ if (ptDepthFlowInfo == NULL) {
+ misp_info("%s fail!", __func__);
+ return;
+ }
+ if (!ptDepthFlowInfo->ValidFlag) {
+ misp_info("depth info ValidFlag err! L:%d", __LINE__);
+ return;
+ }
+
+ if (ptDepthFlowInfo->Ver != DEPTH_FLOWMGR_INFO_VER) {
+ misp_info("depth info version err! L:%d", __LINE__);
+ misp_info("Depth debug version: 0x%X", ptDepthFlowInfo->Ver);
+ misp_info("Linux depth debug ver: 0x%X", DEPTH_FLOWMGR_INFO_VER);
+ return;
+ }
+
+ misp_info("====== Depth Debug Info ======");
+ misp_info("=== Check Depth Debug Info Version ===");
+ misp_info("Depth debug version: 0x%X", ptDepthFlowInfo->Ver);
+ misp_info("alDU ver: %d.%d", ptDepthFlowInfo->ALDU_MainVer, ptDepthFlowInfo->ALDU_SubVer);
+ misp_info("=== DepthFlowInfo: General ===");
+
+
+ if (ptDepthFlowInfo->tDepthFlowDebugInfo.ValidDepthFlowDebugInfo == false) {
+ misp_info("General information all invalid.");
+ goto DepthFlowDebugInfoEnd;
+ } else{
+ modeid = ptDepthFlowInfo->tDepthFlowDebugInfo.DepthFlowModeId;
+ if (modeid > modeid_max) {
+ misp_info("Depth Flow Mode ID: %d. (error! mode id out of range %d~%d)",
+ modeid, modeid_min, modeid_max);
+ goto DepthFlowDebugInfoEnd;
+ } else
+ misp_info("Depth Flow Mode ID: %d. (valid range %d~%d)",
+ modeid, modeid_min, modeid_max);
+ }
+
+ /* ref img1 w/h */
+ refImg1_w = ptDepthFlowInfo->tDepthFlowDebugInfo.refImg1_Width;
+ refImg1_h = ptDepthFlowInfo->tDepthFlowDebugInfo.refImg1_Height;
+ switch (16 * refImg1_h / refImg1_w) {
+ case 9:
+ refImg1_Idx = RESOLUTION_16_9;
+ break;
+ case 10:
+ refImg1_Idx = RESOLUTION_16_10;
+ break;
+ case 12:
+ refImg1_Idx = RESOLUTION_4_3;
+ break;
+ default:
+ refImg1_Idx = RESOLUTION_OTHER;
+ break;
+ }
+
+ if (refImg1_Idx != RESOLUTION_OTHER)
+ misp_info("ref1 Img Resolution: %dx%d. (%s)",
+ refImg1_w, refImg1_h, ResStr[refImg1_Idx]);
+ else {
+ /* mutiple 100 for division */
+ tmp = refImg1_h * 16 * 100 / refImg1_w;
+ misp_info("ref1 Img Resolution: %dx%d. (16:%d.%d)",
+ refImg1_w, refImg1_h, tmp/100, tmp%100);
+ }
+
+ /* ref img2 w/h */
+ refImg2_w = ptDepthFlowInfo->tDepthFlowDebugInfo.refImg2_Width;
+ refImg2_h = ptDepthFlowInfo->tDepthFlowDebugInfo.refImg2_Height;
+
+ /* check resolution index */
+ switch (16 * refImg2_h / refImg2_w) {
+ case 9:
+ refImg2_Idx = RESOLUTION_16_9;
+ break;
+ case 10:
+ refImg2_Idx = RESOLUTION_16_10;
+ break;
+ case 12:
+ refImg2_Idx = RESOLUTION_4_3;
+ break;
+ default:
+ refImg2_Idx = RESOLUTION_OTHER;
+ break;
+ }
+
+ /* display solution */
+ if (refImg2_Idx != RESOLUTION_OTHER)
+ misp_info("ref2 Img Resolution: %dx%d. (%s)",
+ refImg2_w, refImg2_h, ResStr[refImg2_Idx]);
+ else {
+ /* mutiple 100 for division */
+ tmp = refImg2_h * 16 * 100 / refImg2_w;
+ misp_info("ref2 Img Resolution: %dx%d. (16:%d.%d)",
+ refImg2_w, refImg2_h, tmp/100, tmp%100);
+ }
+ /* display warning */
+ if (refImg2_Idx != refImg1_Idx)
+ misp_info("(Warning!. ref1 Img resolution is %s, but ref2 Img resolution is %s.", ResStr[refImg1_Idx], ResStr[refImg2_Idx]);
+
+ if (refImg2_w > refImg1_w)
+ misp_info("(Warning!. ref2 Img width %d > ref1 Img width %d.", refImg2_w, refImg1_w);
+
+ if (refImg2_h > refImg1_h)
+ misp_info("(Warning!. ref2 Img height %d > ref1 Img height %d.", refImg2_h, refImg1_h);
+
+
+ /* ref img3 w/h */
+ refImg3_w = ptDepthFlowInfo->tDepthFlowDebugInfo.refImg3_Width;
+ refImg3_h = ptDepthFlowInfo->tDepthFlowDebugInfo.refImg3_Height;
+ switch (16 * refImg3_h / refImg3_w) {
+ case 9:
+ refImg3_Idx = RESOLUTION_16_9;
+ break;
+ case 10:
+ refImg3_Idx = RESOLUTION_16_10;
+ break;
+ case 12:
+ refImg3_Idx = RESOLUTION_4_3;
+ break;
+ default:
+ refImg3_Idx = RESOLUTION_OTHER;
+ break;
+ }
+
+ if (refImg3_Idx != RESOLUTION_OTHER)
+ misp_info("ref3 Img Resolution: %dx%d. (%s)", refImg3_w, refImg3_h, ResStr[refImg3_Idx]);
+ else {
+ tmp = refImg3_h * 16 * 100 / refImg3_w ; /* mutiple 100 for division */
+ misp_info("ref3 Img Resolution: %dx%d. (16:%d.%d)", refImg3_w, refImg3_h,
+ tmp/100, tmp%100);
+ }
+
+ /* kernel size ratio */
+ KernelSizeRatio = ptDepthFlowInfo->tDepthFlowDebugInfo.DepthImgKernelSizeRatio;
+ if (KernelSizeRatio > KernelSizeRatio_max)
+ misp_info("Kernel Size Ratio: %d. (error! ration output of range %d~%d).", KernelSizeRatio, KernelSizeRatio_min, KernelSizeRatio_max);
+ else
+ misp_info("Kernel Size Ratio: %d. (valid range %d~%d).", KernelSizeRatio, KernelSizeRatio_min, KernelSizeRatio_max);
+
+ /* Depth type */
+ DepthType = ptDepthFlowInfo->tDepthFlowDebugInfo.DepthType;
+ misp_info("Depth Type: %d. (%s)", DepthType, (DepthType > 0) ? "Active" : "Passive");
+
+ /* Ground mode */
+ GroundMode = ptDepthFlowInfo->tDepthFlowDebugInfo.DepthGroundType;
+ switch (GroundMode) {
+ case 0:
+ misp_info("Ground Type: 0 (Normal mode only).");
+ break;
+ case 0x10:
+ misp_info("Ground Type: 0x%X. (Ground Enhance).",
+ GroundMode);
+ break;
+ case 0x30:
+ misp_info("Ground Type: 0x%X. (Ground Enhance + Advance Hold Fill).", GroundMode);
+ break;
+ case 0x50:
+ misp_info("Ground Type: 0x%X. (Ground Enhance + Anti-Cliff).", GroundMode);
+ break;
+ case 0x70:
+ misp_info("Ground Type: 0x%X. (Ground Enhance + Advance Hold Fill + Anti-Cliff).", GroundMode);
+ break;
+ default:
+ misp_info("Ground Type: 0x%X. (Unkown feature).", GroundMode);
+ break;
+ }
+
+ /* Processing time */
+ if (0 != ptDepthFlowInfo->tDepthFlowDebugInfo.DephtProcTime) {
+ tmp = ptDepthFlowInfo->tDepthFlowDebugInfo.DephtProcTime*100/1000;
+ misp_info("Processing Time: %d.%d ms.", tmp/100, tmp%100);
+ tmp = 1000000*100/ptDepthFlowInfo->tDepthFlowDebugInfo.DephtProcTime;
+ misp_info("Processing max fps: %d.%d", tmp/100, tmp%100);
+ } else
+ misp_info("Processing Time: 0.");
+
+ /* Blending process time */
+ tmp = ptDepthFlowInfo->tDepthFlowDebugInfo.BlendingProcTime*100 / 1000;
+ misp_info("Blending processing time: %d.%d ms.", tmp/100, tmp%100);
+
+ /* Frame count */
+ misp_info("Frame Count: %d.", ptDepthFlowInfo->tDepthFlowDebugInfo.DepthProcCnt);
+
+ /* Feature flag: InvRec LDC bypass */
+ misp_info("Feature flag: %d.", ptDepthFlowInfo->tDepthFlowDebugInfo.FeatureFlag);
+
+ /* InvRECT_BypassLDC */
+ misp_info("InvRect bypass LDC: %d.", ptDepthFlowInfo->tDepthFlowDebugInfo.InvRECT_BypassLDC);
+
+ /* check feature flag */
+ if ((ptDepthFlowInfo->tDepthFlowDebugInfo.FeatureFlag & 0x1) !=
+ ptDepthFlowInfo->tDepthFlowDebugInfo.InvRECT_BypassLDC)
+ misp_info("InvRect bypass flag is not eqaual feature flag.");
+
+ /* PerformanceFlag */
+ /* [Debug] FALSE: DEPTH_PERFORMANCE_FLAG disable, TRUE: DEPTH_PERFORMANCE_FLAG enable */
+ misp_info("Performance flag: %d.", ptDepthFlowInfo->tDepthFlowDebugInfo.PerformanceFlag);
+
+ /* NormalKernalSizeMatch */
+ /* [Debug] Valid when DEPTH_PERFORMANCE_FLAG enable, TRUE: Kernel size of normal mode can be extimated by clock and Frame rate */
+ misp_info("Normal kernel size match flag: %d.", ptDepthFlowInfo->tDepthFlowDebugInfo.NormalKernalSizeMatch);
+
+ /* GroundKernalSizeMatch */
+ /* [Debug] Valid when DEPTH_PERFORMANCE_FLAG enable, TRUE: Kernel size of ground mode can be extimated by clock and Frame rate */
+ misp_info("Ground kernel size match flag: %d.", ptDepthFlowInfo->tDepthFlowDebugInfo.GroundKernalSizeMatch);
+
+ /* NormalKernelSizeIdx */
+ /* [Debug] Kernel size idx of normal mode, if NormalKernalSizeMatch is False,
+ then it means the kernel size could not be extimated by clock and frame rate */
+ misp_info("Normal kernel size index: %d. (0~15)", ptDepthFlowInfo->tDepthFlowDebugInfo.NormalKernelSizeIdx);
+
+ /* GroundKernelSizeIdx */
+ /* [Debug] Kernel size idx of ground mode, if GroundKernalSizeMatch is False,
+ then it means the kernel size could not be extimated by clock and frame rate */
+ misp_info("Ground kernel size index: %d. (0~15)", ptDepthFlowInfo->tDepthFlowDebugInfo.GroundKernelSizeIdx);
+DepthFlowDebugInfoEnd:
+
+ misp_info("=== DepthFlowInfo: Utility ===");
+ if (ptDepthFlowInfo->tDepthUtiDebugInfo.ValidDepthUtiDebugInfo == false) {
+ misp_info("Utility information all invalid.");
+ goto UtilityEnd;
+ }
+
+ /* ValidBlendingTable */
+ ValidBlendingTable = ptDepthFlowInfo->tDepthUtiDebugInfo.ValidBlendingTable;
+ if (ValidBlendingTable) {
+ /* Set blending table source */
+ BlendingSrc = ptDepthFlowInfo->tDepthUtiDebugInfo.BlendingTableSource;
+ if (BlendingSrc == DEPTHBLENDING_SRC_CMD)
+ misp_info("Blending table is available: %d. (AP send to ISP).", BlendingSrc);
+ else if (BlendingSrc == DEPTHBLENDING_SRC_ISP)
+ misp_info("Blending table is available: %d. (ISP calculated done).", BlendingSrc);
+ else
+ misp_info("Warning!! Blending table source from nowhere: %d. (ground mode may fail).", BlendingSrc);
+ }
+
+
+ /* Distance */
+ dist[0] = ptDepthFlowInfo->tDepthUtiDebugInfo.DistanceVal[0];
+ dist[1] = ptDepthFlowInfo->tDepthUtiDebugInfo.DistanceVal[1];
+ dist[2] = ptDepthFlowInfo->tDepthUtiDebugInfo.DistanceVal[2];
+
+ misp_info("Distance: (upper, middle, lower) = (%d, %d, %d)mm. (after v764 change cm to mm)",
+ dist[0], dist[1], dist[2]);
+
+ /* Blending table source and size */
+ misp_info("Blending table source: %d. (0:None 1:AP 2:ISP)", ptDepthFlowInfo->tDepthUtiDebugInfo.BlendingTableSource);
+ misp_info("Blending table size: %d.", ptDepthFlowInfo->tDepthUtiDebugInfo.BlendingTableSize);
+
+ /* Blending start line */
+ misp_info("Blending start line: %d.", ptDepthFlowInfo->tDepthUtiDebugInfo.BlendingStartLine);
+
+ /* Valid QMerge */
+ ValidQmerge = ptDepthFlowInfo->tDepthUtiDebugInfo.ValidQmerge;
+ if (ValidQmerge)
+ misp_info("QMerge table updated by AP: %d. (Received)", ValidQmerge);
+ else
+ misp_info("QMerge table updated by AP: %d. (No updated)", ValidQmerge);
+
+ /* Dynamic warping */
+ misp_info("Dynamic warping updated or not: %d.",
+ ptDepthFlowInfo->tDepthUtiDebugInfo.DWUpdated);
+UtilityEnd:
+
+ misp_info("=== DepthFlowInfo: Packdata ===");
+ if (ptDepthFlowInfo->tDepthPackdataDebugInfo.ValidDepthPacadataDebugInfo == false) {
+ misp_info("Packdata information all invalid.");
+ goto PackdataDebugInfoEnd;
+ }
+
+ /* check AP download packdata to ISP or not */
+ ValidPackdata = ptDepthFlowInfo->tDepthPackdataDebugInfo.ValidPackdata;
+ if (ValidPackdata)
+ misp_info("Valid Packdata=%d. (Packdata download completed.).", ValidPackdata);
+ else{
+ misp_info("Valid Packdata=%d.", ValidPackdata);
+ misp_info("(Packdata doesn't be downloaded, depth qulity and flow may fail.)");
+ }
+
+ /* Disparity to distance table convert. */
+ ValidDisparityToDistanceTable = ptDepthFlowInfo->tDepthPackdataDebugInfo.ValidDisparityToDistanceTable;
+ if (ValidDisparityToDistanceTable)
+ misp_info("Valid Disparity to Distance Table = %d. (Valid.).", ValidDisparityToDistanceTable);
+ else
+ misp_info("Valid Disparity to Distance Table = %d. (Table not ready, convet may fail).",
+ ValidDisparityToDistanceTable);
+
+ /* High distortion rate flag */
+ HighDistortionRateFlag = ptDepthFlowInfo->tDepthPackdataDebugInfo.HighDistortionRate;
+ if (HighDistortionRateFlag)
+ misp_info("High distortion rate flag: %d. (High distortion)", HighDistortionRateFlag);
+ else {
+ misp_info("High distortion rate flag: %d. (Low distortion)", HighDistortionRateFlag);
+ misp_info("(Warning! in current lib, high distortion rate flag should be 1.");
+ }
+
+ /* Packdata usage index */
+ PackdataIdxNormal = ptDepthFlowInfo->tDepthPackdataDebugInfo.PackdataNormalIdx;
+ PackdataIdxGround = ptDepthFlowInfo->tDepthPackdataDebugInfo.PackdataGroundIdx;
+ PackdataIdxRGB = ptDepthFlowInfo->tDepthPackdataDebugInfo.PackdataRGBIdx;
+ if ((PackdataIdxNormal <= 2) && (PackdataIdxNormal <= 2) && (PackdataIdxNormal <= 2))
+ misp_info("Packdata index:(normal, ground, RGB) = (%d, %d, %d). (generally, it is (0,0,2))",
+ PackdataIdxNormal, PackdataIdxGround, PackdataIdxRGB);
+ else
+ misp_info("Packdata index:(normal, ground, RGB) = (%d, %d, %d). (error! valid value should 0~2)",
+ PackdataIdxNormal, PackdataIdxGround, PackdataIdxRGB);
+
+ /* Global compensation */
+ GlobalCompensation = ptDepthFlowInfo->tDepthPackdataDebugInfo.AbsoluteGlobalVal;
+ if (GlobalCompensation == GlobalCompensation_21 || GlobalCompensation == GlobalCompensation_36)
+ misp_info("Global Compensation value: %d. (valid value is %d or %d)",
+ GlobalCompensation, GlobalCompensation_21, GlobalCompensation_36);
+ else
+ misp_info("Global Compensation value: %d. (error! it should be %d or %d)",
+ GlobalCompensation, GlobalCompensation_21, GlobalCompensation_36);
+
+ /* HwCoefficient */
+ HwCoefficient = ptDepthFlowInfo->tDepthPackdataDebugInfo.HwCoefficient;
+ if (HwCoefficient == HwCoefficient_16)
+ misp_info("HW coefficient: %d. (valid value is %d)", HwCoefficient, HwCoefficient_16);
+ else
+ misp_info("HW coefficient: %d. (error! it should be %d)", HwCoefficient, HwCoefficient_16);
+
+ /* index of high distrotion rate */
+ HighDistortionIdx = ptDepthFlowInfo->tDepthPackdataDebugInfo.HighDistortionIdx;
+ if (HighDistortionIdx <= uwHighDistortionIdx_max)
+ misp_info("High distortion index: %d. (valid range 0~5)", HighDistortionIdx);
+ else
+ misp_info("High distortion index: %d. (error! if should be 0~5)", HighDistortionIdx);
+
+ /* Packdata source */
+ PackdataSrc = ptDepthFlowInfo->tDepthPackdataDebugInfo.PackdataSource;
+ if (PackdataSrc == DEPTHPACKDATA_SRC_CMD)
+ misp_info("Packdata source from AP: %d. (Received)", PackdataSrc);
+ else if (PackdataSrc == DEPTHPACKDATA_SRC_OTP)
+ misp_info("Packdata source from ISP reading OTP: %d.", PackdataSrc);
+ else
+ misp_info("Warning! packdata source from nowhere: %d. (Depth may fail)", PackdataSrc);
+
+ /* WOI */
+ WOI_x = ptDepthFlowInfo->tDepthPackdataDebugInfo.WOIMainXBase;
+ WOI_y = ptDepthFlowInfo->tDepthPackdataDebugInfo.WOIMainYBase;
+ WOI_w = ptDepthFlowInfo->tDepthPackdataDebugInfo.WOIMainXLength;
+ WOI_h = ptDepthFlowInfo->tDepthPackdataDebugInfo.WOIMainYLength;
+ Full_w = WOI_w + (WOI_x) * 2;
+ Full_h = WOI_h + (WOI_y) * 2;
+ misp_info("Main Camera WOI (x,y,w,h) = (%d, %d, %d, %d). (FullSize WxH = %dx%d)",
+ WOI_x, WOI_y, WOI_w, WOI_h, Full_w, Full_h);
+
+ WOI_x = ptDepthFlowInfo->tDepthPackdataDebugInfo.WOISubXBase;
+ WOI_y = ptDepthFlowInfo->tDepthPackdataDebugInfo.WOISubYBase;
+ WOI_w = ptDepthFlowInfo->tDepthPackdataDebugInfo.WOISubXLength;
+ WOI_h = ptDepthFlowInfo->tDepthPackdataDebugInfo.WOISubYLength;
+ Full_w = WOI_w + (WOI_x) * 2;
+ Full_h = WOI_h + (WOI_y) * 2;
+ misp_info("Sub Camera WOI (x,y,w,h) = (%d, %d, %d, %d). (FullSize WxH = %dx%d)",
+ WOI_x, WOI_y, WOI_w, WOI_h, Full_w, Full_h);
+
+ /* Sub can rectify left shift */
+ misp_info("Short distance(cm): %d. (For sub-cam retify left shift)",
+ ptDepthFlowInfo->tDepthPackdataDebugInfo.SubCamRectShift);
+
+ misp_info("IntrinsicK_Main[9] = %d, %d, %d, %d, %d, %d, %d, %d, %d.",
+ ptDepthFlowInfo->tDepthPackdataDebugInfo.IntrinsicK_Main[0], ptDepthFlowInfo->tDepthPackdataDebugInfo.IntrinsicK_Main[1],
+ ptDepthFlowInfo->tDepthPackdataDebugInfo.IntrinsicK_Main[2], ptDepthFlowInfo->tDepthPackdataDebugInfo.IntrinsicK_Main[3],
+ ptDepthFlowInfo->tDepthPackdataDebugInfo.IntrinsicK_Main[4], ptDepthFlowInfo->tDepthPackdataDebugInfo.IntrinsicK_Main[5],
+ ptDepthFlowInfo->tDepthPackdataDebugInfo.IntrinsicK_Main[6], ptDepthFlowInfo->tDepthPackdataDebugInfo.IntrinsicK_Main[7],
+ ptDepthFlowInfo->tDepthPackdataDebugInfo.IntrinsicK_Main[8]);
+
+ /* check ALDU errcode */
+ if (0 == ptDepthFlowInfo->tDepthPackdataDebugInfo.AlDUErrCode)
+ misp_info("alDU operation error code: 0x%X. (success)", ptDepthFlowInfo->tDepthPackdataDebugInfo.AlDUErrCode);
+ else {
+ misp_info("alDU operation fail, error code: 0x%X.", ptDepthFlowInfo->tDepthPackdataDebugInfo.AlDUErrCode);
+ switch (ptDepthFlowInfo->tDepthPackdataDebugInfo.AlDUErrCode) {
+ case 0x9001:
+ misp_info("alDU Buffer size too small.");
+ break;
+ case 0x9002:
+ misp_info("alDU Buffer is null.");
+ break;
+ case 0x9003:
+ misp_info("alDU Rse size too small.");
+ break;
+ case 0x9004:
+ misp_info("alDU Rse packdata invalid.");
+ break;
+ default:
+ misp_info("alDU Unkown error code.");
+ break;
+ }
+ }
+
+ if (0 == ptDepthFlowInfo->tDepthPackdataDebugInfo.ConvertMatch)
+ misp_info("Packdata convert task process time doen't match alDU convert process time: %d.",
+ ptDepthFlowInfo->tDepthPackdataDebugInfo.ConvertMatch);
+ else
+ misp_info("Packdata convert task process time match alDU convert process time: %d.",
+ ptDepthFlowInfo->tDepthPackdataDebugInfo.ConvertMatch);
+
+ misp_info("Packdata convert count: %d.", ptDepthFlowInfo->tDepthPackdataDebugInfo.ConvertCount);
+ misp_info("Normal mode rectify QP pingpong index: %d.", ptDepthFlowInfo->tDepthPackdataDebugInfo.NormalRectQPReadPingPongIdx);
+
+ if (0 == ptDepthFlowInfo->tDepthFlowDebugInfo.DepthGroundType) {
+ if (ptDepthFlowInfo->tDepthPackdataDebugInfo.NormalRectQPReadPingPongIdx !=
+ ((ptDepthFlowInfo->tDepthPackdataDebugInfo.ConvertCount + 1) % 2))
+ misp_info("Normal QP buffer index invalid.");
+ else
+ misp_info("Normal QP buffer index valid.");
+ }
+PackdataDebugInfoEnd:
+
+ return;
+}
+
+/**
+ *\brief log depth module debug info
+ *\param a_IsLog2File [In] 0: print to dmesg. 1: log to file.
+ *\return Error code
+ */
+errcode mini_isp_debug_depth_info(void)
+{
+ errcode errcode = ERR_SUCCESS;
+ u32 depthinfo_addr = 0;
+ u32 packdata_addr = 0;
+ u32 PackdataCheckSum = 0;
+ u8 *packdata_buffer = NULL;
+ DEPTHFLOWMGR_DEBUG_INFO tDepthFlowInfo = {0};
+
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ /* 1. read depth flow info structure addr */
+ mini_isp_memory_read(DEBUG_INFO_DEPTH_FLOW_INFO_ADDR, (u8 *)&depthinfo_addr, 4);
+ if (depthinfo_addr == 0) {
+ misp_info("read depth info addr fail! L:%d", __LINE__);
+ goto EXIT;
+ }
+
+ /* 2. read depth flow info structure context */
+ mini_isp_memory_read(depthinfo_addr, (u8 *)&tDepthFlowInfo,
+ sizeof(DEPTHFLOWMGR_DEBUG_INFO));
+
+ /* 3. show depth flow info */
+ mini_isp_debug_depth_info_parser(&tDepthFlowInfo);
+
+ /* 4. check packdata checksum */
+ packdata_addr = tDepthFlowInfo.tDepthPackdataDebugInfo.PackdataAddr;
+ misp_info("Packdata address: 0x%X.", packdata_addr);
+
+ packdata_buffer = kzalloc(PACKDATA_SIZE, GFP_KERNEL);
+ if (packdata_buffer != NULL) {
+ mini_isp_memory_read(packdata_addr, packdata_buffer, PACKDATA_SIZE);
+ PackdataCheckSum = CalculatePackdataCheckSum(packdata_buffer);
+ if (PackdataCheckSum == tDepthFlowInfo.tDepthPackdataDebugInfo.PackdataChkSum)
+ misp_info("Packdata check sum: 0x%X. (equal tool).", tDepthFlowInfo.tDepthPackdataDebugInfo.PackdataChkSum);
+ else
+ misp_info("Packdata check fail: ISP:0x%X. Tool:0x%X.", tDepthFlowInfo.tDepthPackdataDebugInfo.PackdataChkSum, PackdataCheckSum);
+
+ kfree(packdata_buffer);
+ } else{
+ misp_info("allocate packdata buffer fail!");
+ }
+
+EXIT:
+ if (dev_global_variable->intf_status & INTF_SPI_READY &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return errcode;
+}
+EXPORT_SYMBOL(mini_isp_debug_depth_info);
+
+static void mini_isp_debug_metadata_parser(CAPFLOWMGR_METADATA *ptMetadata)
+{
+ u64 DualPathFrameSyncTimeDiff = 0;
+
+ if (ptMetadata == NULL) {
+ misp_info("%s fail!", __func__);
+ return;
+ }
+ misp_info("=============== Metadata ===============");
+ misp_info("---=== Metadata:Common ===----");
+ misp_info("Metadata version: %d.", ptMetadata->tCommonInfo.MetaDataVer);
+ misp_info("SCID: %d.", ptMetadata->tCommonInfo.SCID);
+ misp_info("Swap(Rx,Tx): (%d,%d).", ptMetadata->tCommonInfo.RxSwap, ptMetadata->tCommonInfo.TxSwap);
+ misp_info("SensorType: %d.", ptMetadata->tCommonInfo.SensorType);
+ misp_info("HDR (PPIdx, LPPw, LPPh, RPPw, RPPh): (%d,%d,%d,%d,%d).",
+ ptMetadata->tCommonInfo.HDRPPPipeIdx, ptMetadata->tCommonInfo.LPPWidth,
+ ptMetadata->tCommonInfo.LPPHeight, ptMetadata->tCommonInfo.RPPWidth,
+ ptMetadata->tCommonInfo.RPPHeight);
+
+ misp_info("---=== Metadata:PIPE0 Info ===----");
+
+ misp_info("Frame Index: %d.", ptMetadata->tPipe0Info.FrameIndex);
+ misp_info("SrcImg (width, height, ColorOrder): (%d, %d, %d).",
+ ptMetadata->tPipe0Info.SrcImgWidth, ptMetadata->tPipe0Info.SrcImgHeight,
+ ptMetadata->tPipe0Info.ColorOrder);
+ misp_info("(ExpTime, wBV): (%d, %d).", ptMetadata->tPipe0Info.ExpTime, ptMetadata->tPipe0Info.BV);
+ misp_info("(ISO, ADGain): (%d, %d).", ptMetadata->tPipe0Info.ISO, ptMetadata->tPipe0Info.AD_Gain);
+ misp_info("AWBGain(R,G,B): (%d, %d, %d).", ptMetadata->tPipe0Info.AWB_RGain,
+ ptMetadata->tPipe0Info.AWB_GGain, ptMetadata->tPipe0Info.AWB_BGain);
+ misp_info("BlkOst(R,G,B): (%d, %d, %d).", ptMetadata->tPipe0Info.BlackOffset_R,
+ ptMetadata->tPipe0Info.BlackOffset_G, ptMetadata->tPipe0Info.BlackOffset_B);
+ misp_info("Crop(x,y,w,h): (%d, %d, %d, %d).", ptMetadata->tPipe0Info.Crop_X,
+ ptMetadata->tPipe0Info.Crop_Y, ptMetadata->tPipe0Info.Crop_Width,
+ ptMetadata->tPipe0Info.Crop_Height);
+ misp_info("Scalar(w,h): (%d, %d).", ptMetadata->tPipe0Info.ScalarWidth,
+ ptMetadata->tPipe0Info.ScalarHeight);
+ misp_info("VCM(macro,infinity,curStep,status): (%d, %d, %d, %d).",
+ ptMetadata->tPipe0Info.VCM_macro, ptMetadata->tPipe0Info.VCM_infinity,
+ ptMetadata->tPipe0Info.VCM_CurStep, ptMetadata->tPipe0Info.Depth_VCMStatus);
+
+ misp_info("---=== Metadata:PIPE1 Info ===----");
+ misp_info("Frame Index: %d.", ptMetadata->tPipe1Info.FrameIndex);
+ misp_info("SrcImg (width, height, ColorOrder): (%d, %d, %d).", ptMetadata->tPipe1Info.SrcImgWidth,
+ ptMetadata->tPipe1Info.SrcImgHeight, ptMetadata->tPipe1Info.ColorOrder);
+ misp_info("(ExpTime, wBV): (%d, %d).", ptMetadata->tPipe1Info.ExpTime, ptMetadata->tPipe1Info.BV);
+ misp_info("(ISO, ADGain): (%d, %d).", ptMetadata->tPipe1Info.ISO, ptMetadata->tPipe1Info.AD_Gain);
+ misp_info("AWBGain(R,G,B): (%d, %d, %d).", ptMetadata->tPipe1Info.AWB_RGain,
+ ptMetadata->tPipe1Info.AWB_GGain, ptMetadata->tPipe1Info.AWB_BGain);
+ misp_info("BlkOst(R,G,B): (%d, %d, %d).", ptMetadata->tPipe1Info.BlackOffset_R,
+ ptMetadata->tPipe1Info.BlackOffset_G, ptMetadata->tPipe1Info.BlackOffset_B);
+ misp_info("Crop(x,y,w,h): (%d, %d, %d, %d).", ptMetadata->tPipe1Info.Crop_X,
+ ptMetadata->tPipe1Info.Crop_Y, ptMetadata->tPipe1Info.Crop_Width,
+ ptMetadata->tPipe1Info.Crop_Height);
+ misp_info("Scalar(w,h): (%d, %d).", ptMetadata->tPipe1Info.ScalarWidth,
+ ptMetadata->tPipe1Info.ScalarHeight);
+ misp_info("VCM(macro,infinity,curStep,status): (%d, %d, %d, %d).",
+ ptMetadata->tPipe1Info.VCM_macro, ptMetadata->tPipe1Info.VCM_infinity,
+ ptMetadata->tPipe1Info.VCM_CurStep, ptMetadata->tPipe1Info.Depth_VCMStatus);
+
+ misp_info("---=== Metadata:Depth Info ===----");
+ misp_info("Depth index: %d.", ptMetadata->tDpethInfo.DepthIndex);
+ misp_info("Reference Frame Index: %d.", ptMetadata->tDpethInfo.ReferenceFrameIndex);
+ misp_info("Depth(w,h,type) = (%d, %d, %d).", ptMetadata->tDpethInfo.DepthWidth,
+ ptMetadata->tDpethInfo.DepthHeight, ptMetadata->tDpethInfo.DepthType);
+ misp_info("VCM Step = (%d, %d).", ptMetadata->tDpethInfo.awDepth_VCMStep[0],
+ ptMetadata->tDpethInfo.awDepth_VCMStep[1]);
+
+ misp_info("---=== Metadata:SWDebug ===----");
+ misp_info("ModuleBypass[0~ 5]: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X.",
+ ptMetadata->tSWDebugInfo.aucModuleByPass[0], ptMetadata->tSWDebugInfo.aucModuleByPass[1],
+ ptMetadata->tSWDebugInfo.aucModuleByPass[2], ptMetadata->tSWDebugInfo.aucModuleByPass[3],
+ ptMetadata->tSWDebugInfo.aucModuleByPass[4], ptMetadata->tSWDebugInfo.aucModuleByPass[5]);
+ misp_info("ModuleBypass[6~12]: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X.",
+ ptMetadata->tSWDebugInfo.aucModuleByPass[6], ptMetadata->tSWDebugInfo.aucModuleByPass[7],
+ ptMetadata->tSWDebugInfo.aucModuleByPass[8], ptMetadata->tSWDebugInfo.aucModuleByPass[9],
+ ptMetadata->tSWDebugInfo.aucModuleByPass[10], ptMetadata->tSWDebugInfo.aucModuleByPass[11]);
+ misp_info("DepthInSize: %dx%d.", ptMetadata->tSWDebugInfo.DepthInWidth,
+ ptMetadata->tSWDebugInfo.DepthInHeight);
+ misp_info("Pipe0Shading (w,h,inw,inh,woix,woiy,woiw,woih): (%d, %d, %d, %d, %d, %d, %d, %d).",
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[0].SHDTableW,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[0].SHDTableH,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[0].SHDNoWOIOutWidth,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[0].SHDNoWOIOutHeight,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[0].SHD_WOI_X,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[0].SHD_WOI_Y,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[0].SHD_WOI_Width,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[0].SHD_WOI_Height);
+ misp_info("Pipe1Shading (w,h,inw,inh,woix,woiy,woiw,woih): (%d, %d, %d, %d, %d, %d, %d, %d).",
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[1].SHDTableW,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[1].SHDTableH,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[1].SHDNoWOIOutWidth,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[1].SHDNoWOIOutHeight,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[1].SHD_WOI_X,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[1].SHD_WOI_Y,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[1].SHD_WOI_Width,
+ ptMetadata->tSWDebugInfo.tPipeSHDInfo[1].SHD_WOI_Height);
+ misp_info("Pipe0DepthCalibWOI (x,y,w,h): (%d, %d, %d, %d).",
+ ptMetadata->tSWDebugInfo.tPipeDepthCaliWOI[0].XBase,
+ ptMetadata->tSWDebugInfo.tPipeDepthCaliWOI[0].YBase,
+ ptMetadata->tSWDebugInfo.tPipeDepthCaliWOI[0].XLength,
+ ptMetadata->tSWDebugInfo.tPipeDepthCaliWOI[0].YLength);
+ misp_info("Pipe1DepthCalibWOI (x,y,w,h): (%d, %d, %d, %d).",
+ ptMetadata->tSWDebugInfo.tPipeDepthCaliWOI[1].XBase,
+ ptMetadata->tSWDebugInfo.tPipeDepthCaliWOI[1].YBase,
+ ptMetadata->tSWDebugInfo.tPipeDepthCaliWOI[1].XLength,
+ ptMetadata->tSWDebugInfo.tPipeDepthCaliWOI[1].YLength);
+ misp_info("SysTime(us): %llu us.", ptMetadata->tSWDebugInfo.SysTimeus);
+ misp_info("ProjectorStatus[0] (on/off, level): (%d, %d).",
+ ptMetadata->tSWDebugInfo.tProjectorStatus[0].TurnOn,
+ ptMetadata->tSWDebugInfo.tProjectorStatus[0].Level);
+ misp_info("ProjectorStatus[1] (on/off, level): (%d, %d).",
+ ptMetadata->tSWDebugInfo.tProjectorStatus[1].TurnOn,
+ ptMetadata->tSWDebugInfo.tProjectorStatus[1].Level);
+ misp_info("ProjectorStatus[2] (on/off, level): (%d, %d).",
+ ptMetadata->tSWDebugInfo.tProjectorStatus[2].TurnOn,
+ ptMetadata->tSWDebugInfo.tProjectorStatus[2].Level);
+ misp_info("ProjectorStatus[3] (on/off, level): (%d, %d).",
+ ptMetadata->tSWDebugInfo.tProjectorStatus[3].TurnOn,
+ ptMetadata->tSWDebugInfo.tProjectorStatus[3].Level);
+ misp_info("ProjectorStatus[4] (on/off, level): (%d, %d).",
+ ptMetadata->tSWDebugInfo.tProjectorStatus[4].TurnOn,
+ ptMetadata->tSWDebugInfo.tProjectorStatus[4].Level);
+ misp_info("ProjectorStatus[5] (on/off, level): (%d, %d).",
+ ptMetadata->tSWDebugInfo.tProjectorStatus[5].TurnOn,
+ ptMetadata->tSWDebugInfo.tProjectorStatus[5].Level);
+ misp_info("ProjectorStatus[6] (on/off, level): (%d, %d).",
+ ptMetadata->tSWDebugInfo.tProjectorStatus[6].TurnOn,
+ ptMetadata->tSWDebugInfo.tProjectorStatus[6].Level);
+ misp_info("ProjectorStatus[7] (on/off, level): (%d, %d).",
+ ptMetadata->tSWDebugInfo.tProjectorStatus[7].TurnOn,
+ ptMetadata->tSWDebugInfo.tProjectorStatus[7].Level);
+ misp_info("GPIO_Dev on/off: (Dev0, Dev1) = (%d, %d).",
+ ptMetadata->tSWDebugInfo.tGPIO_Device[0].TurnOn,
+ ptMetadata->tSWDebugInfo.tGPIO_Device[1].TurnOn);
+ misp_info("IDD0_ISRTimeus: %llu us.", ptMetadata->tSWDebugInfo.IDD0_ISRTimeus);
+ misp_info("IDD1_ISRTimeus: %llu us.", ptMetadata->tSWDebugInfo.IDD1_ISRTimeus);
+
+#ifdef NEW_ABS
+ DualPathFrameSyncTimeDiff =
+ abs((s64)(ptMetadata->tSWDebugInfo.IDD1_ISRTimeus - ptMetadata->tSWDebugInfo.IDD0_ISRTimeus));
+#else
+ DualPathFrameSyncTimeDiff =
+ abs64((s64)(ptMetadata->tSWDebugInfo.IDD1_ISRTimeus - ptMetadata->tSWDebugInfo.IDD0_ISRTimeus));
+#endif
+
+ misp_info("DualPathFrameSyncTimeDiff: %llu us.", DualPathFrameSyncTimeDiff);
+
+ misp_info("---=== Metadata:IQDebug ===----");
+ misp_info("QMerge_Ver: %d.", ptMetadata->tIQDebugInfo.Qmerge_Ver);
+ misp_info("Tool_Ver: %d. %d .%d.", ptMetadata->tIQDebugInfo.audTool_Ver[0],
+ ptMetadata->tIQDebugInfo.audTool_Ver[1], ptMetadata->tIQDebugInfo.audTool_Ver[2]);
+ misp_info("audTuning_Ver: %d. %d .%d.", ptMetadata->tIQDebugInfo.audTuning_Ver[0],
+ ptMetadata->tIQDebugInfo.audTuning_Ver[1], ptMetadata->tIQDebugInfo.audTuning_Ver[2]);
+ misp_info("Verify Debug: %d. %d.", ptMetadata->tIQDebugInfo.aucVerifyDebug[0],
+ ptMetadata->tIQDebugInfo.aucVerifyDebug[1]);
+ misp_info("2PDInfo: %d.", ptMetadata->tIQDebugInfo.uw2PD_Info);
+ misp_info("EngineEnable: %d. %d. %d. %d. %d. %d. %d. %d.",
+ ptMetadata->tIQDebugInfo.aucEngineEnable[0], ptMetadata->tIQDebugInfo.aucEngineEnable[1],
+ ptMetadata->tIQDebugInfo.aucEngineEnable[2], ptMetadata->tIQDebugInfo.aucEngineEnable[3],
+ ptMetadata->tIQDebugInfo.aucEngineEnable[4], ptMetadata->tIQDebugInfo.aucEngineEnable[5],
+ ptMetadata->tIQDebugInfo.aucEngineEnable[6], ptMetadata->tIQDebugInfo.aucEngineEnable[7]);
+ misp_info("CCM[0]: %d. %d. %d. %d. %d. %d. %d. %d. %d.", ptMetadata->tIQDebugInfo.awCCM[0][0],
+ ptMetadata->tIQDebugInfo.awCCM[0][1], ptMetadata->tIQDebugInfo.awCCM[0][2],
+ ptMetadata->tIQDebugInfo.awCCM[0][3], ptMetadata->tIQDebugInfo.awCCM[0][4],
+ ptMetadata->tIQDebugInfo.awCCM[0][5], ptMetadata->tIQDebugInfo.awCCM[0][6],
+ ptMetadata->tIQDebugInfo.awCCM[0][7], ptMetadata->tIQDebugInfo.awCCM[0][8]);
+ misp_info("CCM[1]: %d. %d. %d .%d. %d. %d. %d. %d. %d.", ptMetadata->tIQDebugInfo.awCCM[1][0],
+ ptMetadata->tIQDebugInfo.awCCM[1][1], ptMetadata->tIQDebugInfo.awCCM[1][2],
+ ptMetadata->tIQDebugInfo.awCCM[1][3], ptMetadata->tIQDebugInfo.awCCM[1][4],
+ ptMetadata->tIQDebugInfo.awCCM[1][5], ptMetadata->tIQDebugInfo.awCCM[1][6],
+ ptMetadata->tIQDebugInfo.awCCM[1][7], ptMetadata->tIQDebugInfo.awCCM[1][8]);
+ misp_info("ExpRatio: %d.", ptMetadata->tIQDebugInfo.ExpRatio);
+ misp_info("ParaAddr[0][ 0~ 9]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[0][0], ptMetadata->tIQDebugInfo.audParaAddr[0][1],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][2], ptMetadata->tIQDebugInfo.audParaAddr[0][3],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][4], ptMetadata->tIQDebugInfo.audParaAddr[0][5],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][6], ptMetadata->tIQDebugInfo.audParaAddr[0][7],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][8], ptMetadata->tIQDebugInfo.audParaAddr[0][9]);
+ misp_info("ParaAddr[0][10~19]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[0][10], ptMetadata->tIQDebugInfo.audParaAddr[0][11],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][12], ptMetadata->tIQDebugInfo.audParaAddr[0][13],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][14], ptMetadata->tIQDebugInfo.audParaAddr[0][15],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][16], ptMetadata->tIQDebugInfo.audParaAddr[0][17],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][18], ptMetadata->tIQDebugInfo.audParaAddr[0][19]);
+ misp_info("ParaAddr[0][20~29]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[0][20], ptMetadata->tIQDebugInfo.audParaAddr[0][21],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][22], ptMetadata->tIQDebugInfo.audParaAddr[0][23],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][24], ptMetadata->tIQDebugInfo.audParaAddr[0][25],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][26], ptMetadata->tIQDebugInfo.audParaAddr[0][27],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][28], ptMetadata->tIQDebugInfo.audParaAddr[0][29]);
+ misp_info("ParaAddr[0][30~39]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[0][30], ptMetadata->tIQDebugInfo.audParaAddr[0][31],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][32], ptMetadata->tIQDebugInfo.audParaAddr[0][33],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][34], ptMetadata->tIQDebugInfo.audParaAddr[0][35],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][36], ptMetadata->tIQDebugInfo.audParaAddr[0][37],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][38], ptMetadata->tIQDebugInfo.audParaAddr[0][39]);
+ misp_info("ParaAddr[0][40~49]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[0][40], ptMetadata->tIQDebugInfo.audParaAddr[0][41],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][42], ptMetadata->tIQDebugInfo.audParaAddr[0][43],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][44], ptMetadata->tIQDebugInfo.audParaAddr[0][45],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][46], ptMetadata->tIQDebugInfo.audParaAddr[0][47],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][48], ptMetadata->tIQDebugInfo.audParaAddr[0][49]);
+ misp_info("ParaAddr[0][50~59]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[0][50], ptMetadata->tIQDebugInfo.audParaAddr[0][51],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][52], ptMetadata->tIQDebugInfo.audParaAddr[0][53],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][54], ptMetadata->tIQDebugInfo.audParaAddr[0][55],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][56], ptMetadata->tIQDebugInfo.audParaAddr[0][57],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][58], ptMetadata->tIQDebugInfo.audParaAddr[0][59]);
+ misp_info("ParaAddr[0][60~69]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[0][60], ptMetadata->tIQDebugInfo.audParaAddr[0][61],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][62], ptMetadata->tIQDebugInfo.audParaAddr[0][63],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][64], ptMetadata->tIQDebugInfo.audParaAddr[0][65],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][66], ptMetadata->tIQDebugInfo.audParaAddr[0][67],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][68], ptMetadata->tIQDebugInfo.audParaAddr[0][69]);
+ misp_info("ParaAddr[0][70~79]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[0][70], ptMetadata->tIQDebugInfo.audParaAddr[0][71],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][72], ptMetadata->tIQDebugInfo.audParaAddr[0][73],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][74], ptMetadata->tIQDebugInfo.audParaAddr[0][75],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][76], ptMetadata->tIQDebugInfo.audParaAddr[0][77],
+ ptMetadata->tIQDebugInfo.audParaAddr[0][78], ptMetadata->tIQDebugInfo.audParaAddr[0][79]);
+ misp_info("ParaAddr[1][ 0~ 9]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[1][0], ptMetadata->tIQDebugInfo.audParaAddr[1][1],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][2], ptMetadata->tIQDebugInfo.audParaAddr[1][3],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][4], ptMetadata->tIQDebugInfo.audParaAddr[1][5],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][6], ptMetadata->tIQDebugInfo.audParaAddr[1][7],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][8], ptMetadata->tIQDebugInfo.audParaAddr[1][9]);
+ misp_info("ParaAddr[1][10~19]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[1][10], ptMetadata->tIQDebugInfo.audParaAddr[1][11],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][12], ptMetadata->tIQDebugInfo.audParaAddr[1][13],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][14], ptMetadata->tIQDebugInfo.audParaAddr[1][15],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][16], ptMetadata->tIQDebugInfo.audParaAddr[1][17],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][18], ptMetadata->tIQDebugInfo.audParaAddr[1][19]);
+ misp_info("ParaAddr[1][20~29]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[1][20], ptMetadata->tIQDebugInfo.audParaAddr[1][21],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][22], ptMetadata->tIQDebugInfo.audParaAddr[1][23],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][24], ptMetadata->tIQDebugInfo.audParaAddr[1][25],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][26], ptMetadata->tIQDebugInfo.audParaAddr[1][27],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][28], ptMetadata->tIQDebugInfo.audParaAddr[1][29]);
+ misp_info("ParaAddr[1][30~39]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[1][30], ptMetadata->tIQDebugInfo.audParaAddr[1][31],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][32], ptMetadata->tIQDebugInfo.audParaAddr[1][33],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][34], ptMetadata->tIQDebugInfo.audParaAddr[1][35],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][36], ptMetadata->tIQDebugInfo.audParaAddr[1][37],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][38], ptMetadata->tIQDebugInfo.audParaAddr[1][39]);
+ misp_info("ParaAddr[1][40~49]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[1][40], ptMetadata->tIQDebugInfo.audParaAddr[1][41],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][42], ptMetadata->tIQDebugInfo.audParaAddr[1][43],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][44], ptMetadata->tIQDebugInfo.audParaAddr[1][45],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][46], ptMetadata->tIQDebugInfo.audParaAddr[1][47],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][48], ptMetadata->tIQDebugInfo.audParaAddr[1][49]);
+ misp_info("ParaAddr[1][50~59]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[1][50], ptMetadata->tIQDebugInfo.audParaAddr[1][51],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][52], ptMetadata->tIQDebugInfo.audParaAddr[1][53],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][54], ptMetadata->tIQDebugInfo.audParaAddr[1][55],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][56], ptMetadata->tIQDebugInfo.audParaAddr[1][57],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][58], ptMetadata->tIQDebugInfo.audParaAddr[1][59]);
+ misp_info("ParaAddr[1][60~69]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[1][60], ptMetadata->tIQDebugInfo.audParaAddr[1][61],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][62], ptMetadata->tIQDebugInfo.audParaAddr[1][63],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][64], ptMetadata->tIQDebugInfo.audParaAddr[1][65],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][66], ptMetadata->tIQDebugInfo.audParaAddr[1][67],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][68], ptMetadata->tIQDebugInfo.audParaAddr[1][69]);
+ misp_info("ParaAddr[1][70~79]: 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x. 0x%x.",
+ ptMetadata->tIQDebugInfo.audParaAddr[1][70], ptMetadata->tIQDebugInfo.audParaAddr[1][71],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][72], ptMetadata->tIQDebugInfo.audParaAddr[1][73],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][74], ptMetadata->tIQDebugInfo.audParaAddr[1][75],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][76], ptMetadata->tIQDebugInfo.audParaAddr[1][77],
+ ptMetadata->tIQDebugInfo.audParaAddr[1][78], ptMetadata->tIQDebugInfo.audParaAddr[1][79]);
+
+ misp_info("---=== Metadata:Histogram ===----");
+ misp_info("Hist_S[256~259]: [%d. %d. %d. %d].",
+ ptMetadata->audHDRAEHistogram_Short[256], ptMetadata->audHDRAEHistogram_Short[257],
+ ptMetadata->audHDRAEHistogram_Short[258], ptMetadata->audHDRAEHistogram_Short[259]);
+ misp_info("Hist_L[256~259]: [%d. %d. %d. %d].", ptMetadata->audHDRAEHistogram_Long[256],
+ ptMetadata->audHDRAEHistogram_Long[257], ptMetadata->audHDRAEHistogram_Long[258],
+ ptMetadata->audHDRAEHistogram_Long[259]);
+
+}
+
+/**
+ *\brief log metadata status
+ *\param a_IsLog2File [In] 0: print to dmesg. 1: log to file.
+ *\return Error code
+ */
+errcode mini_isp_debug_metadata_info(void)
+{
+ errcode errcode = ERR_SUCCESS;
+ u32 metadata_addr;
+ CAPFLOWMGR_METADATA *ptMetadata = NULL;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ /* 1. read metadata structure addr */
+ mini_isp_memory_read(DEBUG_INFO_METADATA_ADDR, (u8 *)&metadata_addr, 4);
+ if (metadata_addr == 0) {
+ misp_info("read meta data addr fail! L:%d", __LINE__);
+ goto EXIT;
+ }
+
+ /* 2. allocate metadata buffer */
+ ptMetadata = kzalloc(sizeof(CAPFLOWMGR_METADATA), GFP_KERNEL);
+ if (ptMetadata == NULL) {
+ errcode = -ENOMEM;
+ misp_info("allocate metadata buffer fail!");
+ goto EXIT;
+ }
+ /* 3. read metadata structure context */
+ mini_isp_memory_read(metadata_addr, (u8 *)ptMetadata,
+ sizeof(CAPFLOWMGR_METADATA));
+
+ /* 4. show metadata context */
+ mini_isp_debug_metadata_parser(ptMetadata);
+
+ /* 5. free metadata buffer */
+ kfree(ptMetadata);
+EXIT:
+ if (dev_global_variable->intf_status & INTF_SPI_READY &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return errcode;
+}
+EXPORT_SYMBOL(mini_isp_debug_metadata_info);
+
+static void mini_isp_debug_sensor_info_parser(
+ FEC_SENSOR_REAL_INFO atRealSensorInfo[],
+ u8 sensor_info_num, bool a_IsLog2File)
+{
+ u8 i = 0;
+ u32 ret = 0;
+ char *LogBuffer = NULL;
+ char filename[128];
+ struct file *fp = NULL;
+ mm_segment_t fs = {0};
+ u32 CurLogSize = 0;
+
+ u64 SysTimeNow_ns, SysTimeNow_sec, Temp_u64;
+
+ if (atRealSensorInfo == NULL) {
+ misp_info("%s fail!", __func__);
+ goto EXIT;
+ }
+
+ if (a_IsLog2File) {
+ /* 200KB enougth for two hours */
+ LogBuffer = kzalloc(LOG_BUF_SIZE, GFP_KERNEL);
+ if (LogBuffer == NULL) {
+ ret = -ENOMEM;
+ misp_err("%s, LogBuffer allocate fail", __func__);
+ goto EXIT;
+ }
+
+ ret = mini_isp_create_directory(MINIISP_INFO_DUMPLOCATION);
+
+ snprintf(filename, 128, "%s/sensor_info_log",
+ MINIISP_INFO_DUMPLOCATION);
+ #if ENABLE_FILP_OPEN_API
+ /* use file open */
+ #else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ goto EXIT;
+ #endif
+ /*Get current segment descriptor*/
+ fs = get_fs();
+
+ /*Set segment descriptor associated*/
+ set_fs(get_ds());
+
+ if (IS_ERR(fp)) {
+ ret = PTR_ERR(fp);
+ set_fs(fs);
+ misp_err("%s open file failed. err: %d", __func__, ret);
+ goto EXIT;
+ }
+
+ /* get linux system time */
+ SysTimeNow_ns = local_clock();
+ SysTimeNow_sec = SysTimeNow_ns;
+ SysTimeNow_ns = do_div(SysTimeNow_sec, 1000000000);
+ Temp_u64 = SysTimeNow_ns;
+ do_div(Temp_u64, 1000);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "SysTime: [%5lld.%06lld]\n",
+ SysTimeNow_sec, Temp_u64);
+
+ for (i = 0; i < sensor_info_num; i++) {
+ /* LogBuffer full, write the file */
+ if (CurLogSize + 512 > LOG_BUF_SIZE) {
+ vfs_write(fp, (char *)LogBuffer, CurLogSize, &fp->f_pos);
+ CurLogSize = 0;
+ }
+
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "=============== Sensor Real Info ===============\n");
+
+ for (i = 0; i < sensor_info_num; i++) {
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128, "---=== Sensor %d ===----\n", i);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128, "VTS: %d\n", atRealSensorInfo[i].VTS);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128, "HTS: %d\n", atRealSensorInfo[i].HTS);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "ImageWidth: %d\n", atRealSensorInfo[i].ImageWidth);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "ImageHeight: %d\n", atRealSensorInfo[i].ImageHeight);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "FrameTime: %d us\n", atRealSensorInfo[i].FrameTime);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "FrameRate: %d.%d fps\n",
+ atRealSensorInfo[i].FrameRate/100, atRealSensorInfo[i].FrameRate % 100);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "ExpTime: %d us\n", atRealSensorInfo[i].ExpTime);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "Gain: %d.%dx\n", atRealSensorInfo[i].Gain/100, atRealSensorInfo[i].Gain % 100);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "Mode: %d. (0~2: normal, master, slave)\n", atRealSensorInfo[i].SensorMode);
+ }
+ }
+
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128, "\n");
+
+ /* save final Log */
+ vfs_write(fp, (char *)LogBuffer, CurLogSize, &fp->f_pos);
+
+ /*Restore segment descriptor*/
+ set_fs(fs);
+ filp_close(fp, NULL);
+
+ } else {
+ /* print to dmesg */
+ misp_info("=============== Sensor Real Info ===============");
+ for (i = 0; i < sensor_info_num; i++) {
+ misp_info("---=== Sensor %d ===----", i);
+ misp_info("VTS: %d.", atRealSensorInfo[i].VTS);
+ misp_info("HTS: %d.", atRealSensorInfo[i].HTS);
+ misp_info("ImageWidth: %d.", atRealSensorInfo[i].ImageWidth);
+ misp_info("ImageHeight: %d.", atRealSensorInfo[i].ImageHeight);
+ misp_info("FrameTime: %d us.", atRealSensorInfo[i].FrameTime);
+
+ misp_info("FrameRate: %d.%d fps.", atRealSensorInfo[i].FrameRate/100,
+ atRealSensorInfo[i].FrameRate % 100);
+ misp_info("ExpTime: %d us.", atRealSensorInfo[i].ExpTime);
+ misp_info("Gain: %d.%dx.", atRealSensorInfo[i].Gain/100, atRealSensorInfo[i].Gain % 100);
+ misp_info("Mode: %d. (0~2: normal, master, slave)", atRealSensorInfo[i].SensorMode);
+ }
+ }
+
+EXIT:
+ if (LogBuffer != NULL)
+ kfree(LogBuffer);
+ return;
+}
+
+/**
+ *\brief log sensor status
+ *\param a_IsLog2File [In] 0: print to dmesg. 1: log to file.
+ *\return Error code
+ */
+errcode mini_isp_debug_sensor_info(bool a_IsLog2File)
+{
+ errcode errcode = ERR_SUCCESS;
+ u32 SensorInfo_addr = 0;
+ FEC_SENSOR_REAL_INFO atRealSensorInfo[2];
+ u8 write_buffer[4];
+ u8 sensor_info_num = 1;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ sensor_info_num = sizeof(atRealSensorInfo) / sizeof(FEC_SENSOR_REAL_INFO);
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ /* 1. active ISP front-end debug mode. AL6100 stop AEC control */
+ write_buffer[0] = 1;
+ mini_isp_memory_write(DEBUG_INFO_FEC_DEBUG_MODE_ADDR, write_buffer, 1);
+ msleep(300);
+
+ /* 2. read Sensor Info addr */
+ mini_isp_memory_read(DEBUG_INFO_SENSOR_REAL_INFO_ADDR, (u8 *)&SensorInfo_addr, 4);
+ if (SensorInfo_addr == 0) {
+ misp_info("read SensorInfo addr fail! L:%d", __LINE__);
+ goto EXIT;
+ }
+
+ /* 3. read sensor info context */
+ mini_isp_memory_read(SensorInfo_addr, (u8 *)atRealSensorInfo, sizeof(atRealSensorInfo));
+
+
+ /* 4. close ISP front-end debug mode. */
+ write_buffer[0] = 0;
+ mini_isp_memory_write(DEBUG_INFO_FEC_DEBUG_MODE_ADDR, write_buffer, 1);
+
+ /* 5. show sensor info context */
+ mini_isp_debug_sensor_info_parser(atRealSensorInfo, sensor_info_num, a_IsLog2File);
+
+EXIT:
+ if (dev_global_variable->intf_status & INTF_SPI_READY &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return errcode;
+}
+EXPORT_SYMBOL(mini_isp_debug_sensor_info);
+
+static void mini_isp_debug_led_info_parser(
+ PROJECTOR_INFO atLED_INFO[], u8 led_info_num, bool a_IsLog2File)
+{
+ u8 i = 0;
+ u32 ret = 0;
+ char *LogBuffer = NULL;
+ char filename[128];
+ struct file *fp = NULL;
+ mm_segment_t fs = {0};
+
+ u32 CurLogSize = 0;
+ u64 SysTimeNow_ns, SysTimeNow_sec, Temp_u64;
+
+ if (atLED_INFO == NULL) {
+ misp_info("%s fail!", __func__);
+ goto EXIT;
+ }
+
+ if (a_IsLog2File) {
+ /* 200KB enougth for two hours */
+ LogBuffer = kzalloc(LOG_BUF_SIZE, GFP_KERNEL);
+ if (LogBuffer == NULL) {
+ ret = -ENOMEM;
+ misp_err("%s, LogBuffer allocate fail", __func__);
+ goto EXIT;
+ }
+
+ ret = mini_isp_create_directory(MINIISP_INFO_DUMPLOCATION);
+
+ snprintf(filename, 128, "%s/led_info_log", MINIISP_INFO_DUMPLOCATION);
+ #if ENABLE_FILP_OPEN_API
+ /* use file open */
+ #else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ kfree(LogBuffer);
+ goto EXIT;
+ #endif
+ /*Get current segment descriptor*/
+ fs = get_fs();
+
+ /*Set segment descriptor associated*/
+ set_fs(get_ds());
+
+ if (IS_ERR(fp)) {
+ ret = PTR_ERR(fp);
+ set_fs(fs);
+ kfree(LogBuffer);
+ misp_err("%s open file failed. err: %d", __func__, ret);
+ goto EXIT;
+ }
+
+ /* get linux system time */
+ SysTimeNow_ns = local_clock();
+ SysTimeNow_sec = SysTimeNow_ns;
+ SysTimeNow_ns = do_div(SysTimeNow_sec, 1000000000);
+ Temp_u64 = SysTimeNow_ns;
+ do_div(Temp_u64, 1000);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "SysTime: [%5lld.%06lld]\n", SysTimeNow_sec, Temp_u64);
+ for (i = 0; i < led_info_num; i++) {
+ /* LogBuffer full, write the file */
+ if (CurLogSize + 256 > LOG_BUF_SIZE) {
+ vfs_write(fp, (char *)LogBuffer, CurLogSize, &fp->f_pos);
+ CurLogSize = 0;
+ }
+
+ if (atLED_INFO[i].Type == E_LED_PROJECTOR)
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128, "Projector ID: %d\n", i);
+ else if (atLED_INFO[i].Type == E_LED_FLOOD)
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128, "Flood ID: %d\n", i);
+ else {
+ kfree(LogBuffer);
+ misp_info("%s parser err", __func__);
+ goto EXIT;
+ }
+
+ /* one line 128 byte at most */
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "level: %d, current: %d(mA), MaxCurrent: %d(mA)\n",
+ atLED_INFO[i].Level, atLED_INFO[i].Current, atLED_INFO[i].MaxCurrent);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "err: 0x%x, ErrStatus: 0x%x, ErrTemperature: %d\n",
+ atLED_INFO[i].errCode, atLED_INFO[i].ErrStatus, atLED_INFO[i].Temperature);
+ }
+
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128, "\n");
+
+ /* save final Log */
+ vfs_write(fp, (char *)LogBuffer, CurLogSize, &fp->f_pos);
+
+ /*Restore segment descriptor*/
+ set_fs(fs);
+ filp_close(fp, NULL);
+
+ if (LogBuffer)
+ kfree(LogBuffer);
+ } else {
+ /* printf to dmesg */
+ for (i = 0; i < led_info_num; i++) {
+ if (atLED_INFO[i].Type == E_LED_PROJECTOR)
+ misp_info("Projector ID: %d", i);
+ else if (atLED_INFO[i].Type == E_LED_FLOOD)
+ misp_info("Flood ID: %d", i);
+ else {
+ misp_info("%s parser err", __func__);
+ goto EXIT;
+ }
+
+ misp_info("level: %d, current: %d(mA), MaxCurrent: %d(mA)",
+ atLED_INFO[i].Level, atLED_INFO[i].Current, atLED_INFO[i].MaxCurrent);
+ misp_info("err: 0x%x, ErrStatus: 0x%x, ErrTemperature: %d",
+ atLED_INFO[i].errCode, atLED_INFO[i].ErrStatus, atLED_INFO[i].Temperature);
+ }
+ }
+
+
+EXIT:
+ return;
+}
+
+/**
+ *\brief log projector & flood status
+ *\param a_IsLog2File [In] 0: print to dmesg. 1: log to file.
+ *\return Error code
+ */
+errcode mini_isp_debug_led_info(bool a_IsLog2File)
+{
+ errcode errcode = ERR_SUCCESS;
+ const u32 maxWaitNum = 180;
+ u8 LED_INFO_NUM = 1;
+ u8 write_buffer[4];
+ u32 FEC_DEBUG_FLAG = 0;
+ u32 led_info_addr = 0;
+ u32 i = 0;
+ PROJECTOR_INFO atLED_INFO[5];
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+ LED_INFO_NUM = sizeof(atLED_INFO)/sizeof(PROJECTOR_INFO);
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+
+ /* 1. Set Projector debug mode. AL6100 stop AEC control */
+ write_buffer[0] = ADV_LOG_LIGHTING_PROJECTOR;
+ mini_isp_memory_write(DEBUG_INFO_FEC_DEBUG_MODE_ADDR, write_buffer, 1);
+
+ /* 2. wait projector log collect */
+ for (i = 0; i < maxWaitNum; i++) {
+ msleep(100);
+ mini_isp_memory_read(DEBUG_INFO_FEC_DEBUG_MODE_ADDR, (u8 *)&FEC_DEBUG_FLAG, 4);
+ if (FEC_DEBUG_FLAG == 0)
+ break;
+
+ if (i == maxWaitNum-1) {
+ misp_info("wait projector log fail!");
+ goto EXIT;
+ } else
+ misp_info("wait projector log..");
+ }
+
+ /* 3. Set flood debug mode. AL6100 stop AEC control */
+ write_buffer[0] = ADV_LOG_LIGHTING_FLOOD;
+ mini_isp_memory_write(DEBUG_INFO_FEC_DEBUG_MODE_ADDR, write_buffer, 1);
+
+ /* 4. wait flood log collect */
+ for (i = 0; i < maxWaitNum; i++) {
+ msleep(100);
+ mini_isp_memory_read(DEBUG_INFO_FEC_DEBUG_MODE_ADDR, (u8 *)&FEC_DEBUG_FLAG, 4);
+ if (FEC_DEBUG_FLAG == 0)
+ break;
+
+ if (i == maxWaitNum-1) {
+ misp_info("wait flood log fail!");
+ goto EXIT;
+ } else
+ misp_info("wait flood log..");
+ }
+
+ /* 5. read led info addr */
+ mini_isp_memory_read(DEBUG_INFO_LED_INFO_ADDR, (u8 *)&led_info_addr, 4);
+
+ /* 6. read led info context */
+ mini_isp_memory_read(led_info_addr, (u8 *)atLED_INFO, sizeof(atLED_INFO));
+
+ /* 7. show led info context */
+ mini_isp_debug_led_info_parser(atLED_INFO, LED_INFO_NUM, a_IsLog2File);
+EXIT:
+ if (dev_global_variable->intf_status & INTF_SPI_READY &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+ return errcode;
+}
+EXPORT_SYMBOL(mini_isp_debug_led_info);
+
+bool mipi_rx_fps_first_run = true;
+bool mipi_rx_fps_task_active = false;
+static struct task_struct *mipi_rx_fps_task;
+
+static void mipi_rx_get_frame_count(u32 *rx0_count, u32 *rx1_count)
+{
+ #define RX0_FRAME_COUNT_REG 0xfff92010
+ #define RX1_FRAME_COUNT_REG 0xfff95010
+
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ if (rx0_count == NULL && rx1_count == NULL) {
+ misp_info("%s input err", __func__);
+ return;
+ }
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ if (rx0_count != NULL) {
+ mini_isp_register_read(RX0_FRAME_COUNT_REG, rx0_count);
+ *rx0_count = *rx0_count & 0xFFFF; /* only use 0~15 bit*/
+ }
+
+ if (rx1_count != NULL) {
+ mini_isp_register_read(RX1_FRAME_COUNT_REG, rx1_count);
+ *rx1_count = *rx1_count & 0xFFFF; /* only use 0~15 bit*/
+ }
+
+ if (dev_global_variable->intf_status & INTF_SPI_READY &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+}
+
+int mipi_rx_fps_body(void *arg)
+{
+ u32 ret;
+ struct timeval TimeNow = {0};
+ struct timeval TimePrev = {0};
+ u32 Rx0_count_Now = 0, Rx0_count_Prev = 0;
+ u32 Rx1_count_Now = 0, Rx1_count_Prev = 0;
+ u32 Rx0_fps_d, Rx0_fps_f, Rx1_fps_d, Rx1_fps_f;
+ u32 Rx0_count_diff, Rx1_count_diff;
+ u32 tmp;
+ u32 Timediff_ms = 0;
+ u64 TimeNow_ms, TimePrev_ms, Temp_u64;
+ u64 SysTimeNow_sec;
+ u64 SysTimeNow_ns;
+
+ char filename[128];
+ struct file *fp = NULL;
+ mm_segment_t fs = {0};
+ u32 CurLogSize = 0;
+ char *LogBuffer = NULL;
+ bool IsLog2File = *(bool *)arg;
+
+ misp_info("%s S", __func__);
+
+ if (IsLog2File) {
+ LogBuffer = kzalloc(LOG_BUF_SIZE, GFP_KERNEL); /* 200KB enougth for two hours */
+ if (LogBuffer == NULL) {
+ misp_err("%s, LogBuffer allocate fail", __func__);
+ goto EXIT;
+ }
+
+ ret = mini_isp_create_directory(MINIISP_INFO_DUMPLOCATION);
+
+ snprintf(filename, 128, "%s/rx_fps_log", MINIISP_INFO_DUMPLOCATION);
+ #if ENABLE_FILP_OPEN_API
+ /* use file open */
+ #else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ goto EXIT;
+ #endif
+ /*Get current segment descriptor*/
+ fs = get_fs();
+
+ /*Set segment descriptor associated*/
+ set_fs(get_ds());
+
+ if (IS_ERR(fp)) {
+ ret = PTR_ERR(fp);
+ set_fs(fs);
+ misp_err("%s open file failed. err: %d", __func__, ret);
+ goto EXIT;
+ }
+
+ }
+
+ while (!kthread_should_stop()) {
+ do_gettimeofday(&TimeNow);
+ mipi_rx_get_frame_count(&Rx0_count_Now, &Rx1_count_Now);
+
+ if (mipi_rx_fps_first_run) {
+ mipi_rx_fps_first_run = false;
+
+ /* keep previous time record */
+ memcpy(&TimePrev, &TimeNow, sizeof(struct timespec));
+ Rx0_count_Prev = Rx0_count_Now;
+ Rx1_count_Prev = Rx1_count_Now;
+
+ msleep(2000);
+ continue;
+ }
+
+ /* Calc rx frame count fps */
+ TimeNow_ms = (TimeNow.tv_sec * 1000) + (TimeNow.tv_usec / 1000);
+ TimePrev_ms = (TimePrev.tv_sec * 1000) + (TimePrev.tv_usec / 1000);
+ Timediff_ms = (u32) (TimeNow_ms - TimePrev_ms);
+
+ /* X1000 for ms precision, X100 for the two digit after the decimal point*/
+ Rx0_count_diff = Rx0_count_Now - Rx0_count_Prev;
+ tmp = (Rx0_count_diff * 100 * 1000) / Timediff_ms;
+ Rx0_fps_d = tmp / 100;
+ Rx0_fps_f = tmp % 100;
+
+ Rx1_count_diff = Rx1_count_Now - Rx1_count_Prev;
+ tmp = (Rx1_count_diff * 100 * 1000) / Timediff_ms;
+ Rx1_fps_d = tmp / 100;
+ Rx1_fps_f = tmp % 100;
+
+ /* get linux system time */
+ SysTimeNow_ns = local_clock();
+ SysTimeNow_sec = SysTimeNow_ns;
+ SysTimeNow_ns = do_div(SysTimeNow_sec, 1000000000);
+ if (IsLog2File) {
+ /* LogBuffer full, write the file */
+ if (CurLogSize + 128 > LOG_BUF_SIZE) {
+ vfs_write(fp, (char *)LogBuffer, CurLogSize, &fp->f_pos);
+ CurLogSize = 0;
+ }
+
+ /* one line 128 byte at most */
+ Temp_u64 = SysTimeNow_ns;
+ do_div(Temp_u64, 1000);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "[%5lld.%06lld]: Rx0 fps %d.%02d, Rx1 fps %d.%02d\n",
+ SysTimeNow_sec, Temp_u64,
+ Rx0_fps_d, Rx0_fps_f, Rx1_fps_d, Rx1_fps_f);
+ } else{
+ Temp_u64 = SysTimeNow_ns;
+ do_div(Temp_u64, 1000);
+ misp_info("%s test", __func__);
+ misp_info("[%5lld.%06lld]: Rx0 fps %d.%02d, Rx1 fps %d.%02d",
+ SysTimeNow_sec, Temp_u64,
+ Rx0_fps_d, Rx0_fps_f, Rx1_fps_d, Rx1_fps_f);
+ }
+
+ /* keep previous time record */
+ memcpy(&TimePrev, &TimeNow, sizeof(struct timeval));
+ Rx0_count_Prev = Rx0_count_Now;
+ Rx1_count_Prev = Rx1_count_Now;
+
+ msleep(2000);
+ }
+
+ if (IsLog2File) {
+ /* save final Log */
+ vfs_write(fp, (char *)LogBuffer, CurLogSize, &fp->f_pos);
+
+ /*Restore segment descriptor*/
+ set_fs(fs);
+ filp_close(fp, NULL);
+ }
+
+EXIT:
+ misp_info("%s E", __func__);
+ if (LogBuffer != NULL)
+ kfree(LogBuffer);
+
+ return 0;
+}
+
+/**
+ *\brief start log mini rx frame count fps
+ *\param a_IsLog2File [In] 0: print to dmesg. 1: log to file.
+ *\return Error code
+ */
+int mini_isp_debug_mipi_rx_fps_start(bool a_IsLog2File)
+{
+ u32 ret = 0;
+ static bool IsLog2File;
+
+ IsLog2File = a_IsLog2File;
+
+ /* create mipi_rx_fps_task */
+ if (!mipi_rx_fps_task_active) {
+ mipi_rx_fps_task = kthread_create(mipi_rx_fps_body, &IsLog2File, "mipi_rx_fps_task");
+ if (IS_ERR(mipi_rx_fps_task)) {
+ ret = PTR_ERR(mipi_rx_fps_task);
+ mipi_rx_fps_task = NULL;
+ misp_info("%s, mipi_rx_fps_task initial fail, 0x%x", __func__, ret);
+ goto EXIT;
+ }
+ wake_up_process(mipi_rx_fps_task);
+
+ mipi_rx_fps_task_active = true;
+ mipi_rx_fps_first_run = true;
+ misp_info("%s task create success!", __func__);
+ } else {
+ misp_info("%s already initial", __func__);
+ }
+
+EXIT:
+ return ret;
+}
+EXPORT_SYMBOL(mini_isp_debug_mipi_rx_fps_start);
+
+/**
+ *\brief stop log mini rx frame count fps
+ *\return none
+ */
+void mini_isp_debug_mipi_rx_fps_stop(void)
+{
+ /* delete mipi_rx_fps_task.
+ Can't delete task if this task is done. otherwise, it will busy waiting */
+ if (mipi_rx_fps_task_active) {
+ if (mipi_rx_fps_task != NULL) {
+ kthread_stop(mipi_rx_fps_task);
+ mipi_rx_fps_task = NULL;
+ }
+ mipi_rx_fps_task_active = false;
+ misp_info("%s kill task success", __func__);
+ } else
+ misp_info("%s no task to kill", __func__);
+}
+EXPORT_SYMBOL(mini_isp_debug_mipi_rx_fps_stop);
+
+/**
+ *\brief list GPIO status
+ *\return none
+ */
+errcode mini_isp_debug_GPIO_Status(bool a_IsLog2File)
+{
+ errcode errcode = ERR_SUCCESS;
+ u32 aGPIO_RegVal[GPIO_NUMBER] = {0};
+ u32 aGPIO_mode[GPIO_NUMBER] = {0};
+ u32 aGPIO_IO[GPIO_NUMBER] = {0};
+ u32 aGPIO_data[GPIO_NUMBER] = {0};
+ u32 i = 0;
+ char filename[128];
+ struct file *fp = NULL;
+ mm_segment_t fs = {0};
+
+ u32 CurLogSize = 0;
+ char *LogBuffer = NULL;
+ u64 SysTimeNow_ns, SysTimeNow_sec, Temp_u64;
+ struct misp_global_variable *dev_global_variable;
+
+ dev_global_variable = get_mini_isp_global_variable();
+
+ mutex_lock(&dev_global_variable->busy_lock);
+
+ if ((dev_global_variable->intf_status & INTF_SPI_READY) &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_A)) {
+ misp_info("%s a_to_e", __func__);
+ mini_isp_a_to_e();
+ }
+
+ if (a_IsLog2File) {
+ LogBuffer = kzalloc(LOG_BUF_SIZE, GFP_KERNEL);
+ if (LogBuffer == NULL) {
+ misp_err("%s, LogBuffer allocate fail", __func__);
+ goto EXIT;
+ }
+
+ errcode = mini_isp_create_directory(MINIISP_INFO_DUMPLOCATION);
+
+ snprintf(filename, 128, "%s/GPIO_Status_log", MINIISP_INFO_DUMPLOCATION);
+
+ #if ENABLE_FILP_OPEN_API
+ /* use file open */
+ #else
+ misp_info("Error! Currently not support file open api");
+ misp_info("See define ENABLE_FILP_OPEN_API");
+ goto EXIT;
+ #endif
+ /*Get current segment descriptor*/
+ fs = get_fs();
+
+ /*Set segment descriptor associated*/
+ set_fs(get_ds());
+
+ if (IS_ERR(fp)) {
+ errcode = PTR_ERR(fp);
+ set_fs(fs);
+ misp_err("%s open file failed. err: %d", __func__, errcode);
+ goto EXIT;
+ }
+
+ /* get linux system time */
+ SysTimeNow_ns = local_clock();
+ SysTimeNow_sec = SysTimeNow_ns;
+ SysTimeNow_ns = do_div(SysTimeNow_sec, 1000000000);
+ Temp_u64 = SysTimeNow_ns;
+ do_div(Temp_u64, 1000);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "SysTime: [%5lld.%06lld]\n", SysTimeNow_sec, Temp_u64);
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128, "=== Check GPIO status ===\n");
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "SK1 pin\tMapping\t\tmode\t\tI/O\tHigh/Low\n");
+
+ for (i = 0; i < GPIO_NUMBER; i++) {
+ /* read GPIO status */
+ mini_isp_register_read(g_atGPIO[i].addr, &aGPIO_RegVal[i]);
+ aGPIO_mode[i] = aGPIO_RegVal[i] & 0x1F;
+ if (aGPIO_mode[i] > 1)
+ aGPIO_mode[i] = 1;
+ aGPIO_IO[i] = (aGPIO_RegVal[i] >> 6) & 0x1;
+ aGPIO_data[i] = (aGPIO_RegVal[i] >> 5) & 0x1;
+
+ /* one line 128 byte at most */
+ CurLogSize += snprintf(&LogBuffer[CurLogSize], 128,
+ "%s\t%s \t%s\t\t%s\t%s\n",
+ g_atGPIO[i].name, g_atGPIO[i].mapping,
+ aGPIO_mode[i] ? "Function" : "GPIO",
+ aGPIO_IO[i] ? "GPO" : "GPI",
+ aGPIO_data[i] ? "High" : "Low");
+
+ }
+
+ /* save final Log */
+ vfs_write(fp, (char *)LogBuffer, CurLogSize, &fp->f_pos);
+
+ /*Restore segment descriptor*/
+ set_fs(fs);
+ filp_close(fp, NULL);
+ } else {
+ misp_info("=== Check GPIO status ===");
+ misp_info("SK1 pin\tMapping\t\tmode\t\tI/O\tHigh/Low");
+ for (i = 0; i < GPIO_NUMBER; i++) {
+ /* read GPIO status */
+ mini_isp_register_read(g_atGPIO[i].addr, &aGPIO_RegVal[i]);
+ aGPIO_mode[i] = aGPIO_RegVal[i] & 0x1F;
+ if (aGPIO_mode[i] > 1)
+ aGPIO_mode[i] = 1;
+ aGPIO_IO[i] = (aGPIO_RegVal[i] >> 6) & 0x1;
+ aGPIO_data[i] = (aGPIO_RegVal[i] >> 5) & 0x1;
+
+ misp_info("%s\t%s \t%s\t\t%s\t%s",
+ g_atGPIO[i].name, g_atGPIO[i].mapping,
+ aGPIO_mode[i] ? "Function" : "GPIO",
+ aGPIO_IO[i] ? "GPO" : "GPI",
+ aGPIO_data[i] ? "High" : "Low");
+ }
+ }
+
+EXIT:
+ if (dev_global_variable->intf_status & INTF_SPI_READY &&
+ (dev_global_variable->altek_spi_mode == ALTEK_SPI_MODE_E)) {
+ misp_info("%s e_to_a", __func__);
+ mini_isp_e_to_a();
+ }
+
+ mutex_unlock(&dev_global_variable->busy_lock);
+
+ if (LogBuffer != NULL)
+ kfree(LogBuffer);
+
+ return errcode;
+}
+EXPORT_SYMBOL(mini_isp_debug_GPIO_Status);
diff --git a/drivers/media/platform/altek/operation_cmd.c b/drivers/media/platform/altek/operation_cmd.c
new file mode 100755
index 0000000..3821241
--- /dev/null
+++ b/drivers/media/platform/altek/operation_cmd.c
@@ -0,0 +1,214 @@
+/*
+ * File: operation_cmd.c
+ * Description: operation command
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/10/14; Aaron Chuang; Initial version
+ * 2013/12/05; Bruce Chung; 2nd version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/******Include File******/
+
+
+#include <linux/string.h>
+#include <uapi/asm-generic/errno-base.h>
+
+#include "include/error.h"
+#include "include/mtype.h"
+#include "include/error.h"
+#include "include/isp_camera_cmd.h"
+#include "include/miniisp.h"
+#include "include/ispctrl_if_master.h"
+
+
+/******Private Constant Definition******/
+
+
+#define MINI_ISP_LOG_TAG "[operation_cmd]"
+
+extern struct file *g_filp[FIRMWARE_MAX];
+
+/******Public Function******/
+
+/**
+ *\brief Mini ISP open
+ *\param devdata [In], CMD param
+ *\param opcode [In], CMD param
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_operation_cmd_miniisp_open(void *devdata,
+ u16 opcode, u8 *FileNametbl[])
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ char *pBootpath, /*boot code*/
+ *pBasicpath, /*basic code*/
+ *pAdvancedpath, /*advanced code*/
+ *pScenariopath, /*scenario data*/
+ *pHdrpath, /*hdr qmerge data*/
+ *pIrp0path, /*irp0 qmerge data*/
+ *pIrp1path, /*irp1 qmerge data*/
+ *pPPmappath, /*pp map*/
+ *pDepthpath; /*depth qmerge data*/
+
+ pBootpath = FileNametbl[0];
+ pBasicpath = FileNametbl[1];
+ pAdvancedpath = FileNametbl[2];
+ pScenariopath = FileNametbl[3];
+ pHdrpath = FileNametbl[4];
+ pIrp0path = FileNametbl[5];
+ pIrp1path = FileNametbl[6];
+ pPPmappath = FileNametbl[7];
+ pDepthpath = FileNametbl[8];
+
+ misp_info("%s - start", __func__);
+
+ /*open boot code*/
+ if (pBootpath) {
+ /*
+ *misp_info("%s - boot code, path: %s",
+ * __func__, pBootpath);
+ */
+ err = ispctrl_if_mast_request_firmware(pBootpath,
+ BOOT_CODE);
+ if (err != ERR_SUCCESS) {
+ misp_err("%s - open boot code failed", __func__);
+ goto mast_operation_cmd_miniisp_open_end;
+ }
+ }
+
+ /*open basic code*/
+ if (pBasicpath) {
+ /*
+ *misp_info("%s - basic code, path: %s",
+ * __func__, pBasicpath);
+ */
+ err = ispctrl_if_mast_request_firmware(pBasicpath,
+ BASIC_CODE);
+ if (err != ERR_SUCCESS) {
+ misp_err("%s - open basic code failed", __func__);
+ goto mast_operation_cmd_miniisp_open_end;
+ }
+ }
+
+ /*open advanced code*/
+ if (pAdvancedpath) {
+ /*
+ *misp_info("%s - advanced code, path: %s",
+ * __func__, pAdvancedpath);
+ */
+ err = ispctrl_if_mast_request_firmware(pAdvancedpath,
+ ADVANCED_CODE);
+ if (err != ERR_SUCCESS) {
+ misp_err("%s - open advanced code failed", __func__);
+ goto mast_operation_cmd_miniisp_open_end;
+ }
+ }
+
+
+ /*open scenario data*/
+ if (pScenariopath) {
+ /*
+ *misp_info("%s - scenario data, path: %s",
+ * __func__, pScenariopath);
+ */
+ err = ispctrl_if_mast_request_firmware(pScenariopath,
+ SCENARIO_CODE);
+ if (err != ERR_SUCCESS) {
+ misp_err("%s - open scenario data failed", __func__);
+ goto mast_operation_cmd_miniisp_open_end;
+ }
+ }
+
+ /*open hdr qmerge data*/
+ if (pHdrpath) {
+
+ err = ispctrl_if_mast_request_firmware(pHdrpath,
+ HDR_CODE);
+ if (err != ERR_SUCCESS) {
+ misp_err("%s - open hdr qmerge data failed", __func__);
+ goto mast_operation_cmd_miniisp_open_end;
+ }
+ }
+ /*open irp0 qmerge data*/
+ if (pIrp0path) {
+
+ err = ispctrl_if_mast_request_firmware(pIrp0path,
+ IRP0_CODE);
+ if (err != ERR_SUCCESS) {
+ misp_err("%s - open irp0 qmerge data failed", __func__);
+ goto mast_operation_cmd_miniisp_open_end;
+ }
+ }
+ /*open irp1 qmerge data*/
+ if (pIrp1path) {
+
+ err = ispctrl_if_mast_request_firmware(pIrp1path,
+ IRP1_CODE);
+ if (err != ERR_SUCCESS) {
+ misp_err("%s - open irp1 qmerge data failed", __func__);
+ goto mast_operation_cmd_miniisp_open_end;
+ }
+ }
+
+ /*open pp map*/
+ if (pPPmappath) {
+
+ err = ispctrl_if_mast_request_firmware(pPPmappath,
+ PPMAP_CODE);
+ if (err != ERR_SUCCESS) {
+ misp_err("%s - open PP map failed", __func__);
+ goto mast_operation_cmd_miniisp_open_end;
+ }
+ }
+
+ /*open depth qmerge data*/
+ if (pDepthpath) {
+
+ err = ispctrl_if_mast_request_firmware(pDepthpath,
+ DEPTH_CODE);
+ if (err != ERR_SUCCESS) {
+ /* Ignored error for 'No such file or directory' */
+ if ((ENOENT + err) == 0) {
+ g_filp[DEPTH_CODE] = NULL;
+ err = ERR_SUCCESS;
+ }
+ misp_info("%s - open depth qmerge data failed", __func__);
+ /* goto mast_operation_cmd_miniisp_open_end; */
+ }
+ }
+
+ misp_info("%s end", __func__);
+
+mast_operation_cmd_miniisp_open_end:
+
+ return err;
+}
+
+/******Private Function******/
+
+
+
+
+
+/****** End Of File******/
diff --git a/drivers/media/platform/altek/sys_manage_cmd.c b/drivers/media/platform/altek/sys_manage_cmd.c
new file mode 100755
index 0000000..509019b
--- /dev/null
+++ b/drivers/media/platform/altek/sys_manage_cmd.c
@@ -0,0 +1,281 @@
+/*
+ * File: sys_managec_md.c
+ * Description: System manage command
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ * 2013/10/14; Aaron Chuang; Initial version
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+
+
+/* Standard C*/
+
+/* Global Header Files*/
+/*#include <osshell.h>*/
+
+#include "include/isp_camera_cmd.h"
+/* ISP Ctrl IF slave*/
+#include "include/ispctrl_if_master.h"
+/* ISP Ctrl IF slave error*/
+#include "include/error/ispctrl_if_master_err.h"
+
+/* Local Header Files*/
+#include "include/ispctrl_if_master_local.h"
+
+
+
+/******Include File******/
+
+
+
+/******Private Constant Definition******/
+
+
+#define MINI_ISP_LOG_TAG "[sys_manage_cmd]"
+
+
+/******Private Type Declaration******/
+
+
+
+/******Private Function Prototype******/
+
+/******Private Global Variable******/
+
+
+
+/******Public Global Variable******/
+
+/******Public Function******/
+
+/**
+ *\brief Get Status of Last Executed Command
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_get_status_of_last_exec_command(
+ void *devdata, u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Parameter size*/
+ u32 para_size = sizeof(struct system_cmd_status_of_last_command);
+
+
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode, param, 0);
+ if (err != ERR_SUCCESS)
+ goto mast_sys_manage_cmd_get_status_of_last_exec_command_end;
+
+ /* Get data from slave*/
+ err = ispctrl_mast_recv_response_from_slave(devdata, param,
+ para_size, true);
+mast_sys_manage_cmd_get_status_of_last_exec_command_end:
+
+ return err;
+
+
+}
+
+/**
+ *\brief Get Error Code Command
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_get_error_code_command(void *devdata,
+ u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Parameter size*/
+ /*get last ten error code and error status*/
+ u32 para_size = (sizeof(errcode))*10;
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode, param, 0);
+ if (err != ERR_SUCCESS)
+ goto mast_sys_manage_cmd_get_error_code_command_end;
+
+ /* Get data from slave*/
+ err = ispctrl_mast_recv_response_from_slave(devdata, param,
+ para_size, false);
+ if (err != ERR_SUCCESS)
+ goto mast_sys_manage_cmd_get_error_code_command_end;
+
+ misp_err("%s last error code %x %x %x %x", __func__, *(param),
+ *(param+1), *(param+2), *(param+3));
+mast_sys_manage_cmd_get_error_code_command_end:
+
+ return err;
+}
+
+/**
+ *\brief Set ISP register
+ *\param devdata [In], misp_data
+ *\param opCode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_set_isp_register(void *devdata,
+ u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Parameter size*/
+ u32 para_size = sizeof(struct system_cmd_isp_register);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/**
+ *\brief Get ISP register
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_get_isp_register(void *devdata,
+ u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ /* Parameter size*/
+ u32 para_size = sizeof(struct system_cmd_isp_register);
+ /* Response size*/
+ u32 *reg_count = (u32 *)¶m[4];
+
+
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ if (err != ERR_SUCCESS)
+ goto mast_sys_manage_cmd_get_isp_register_end;
+
+ /* Update response size*/
+ para_size = sizeof(struct system_cmd_isp_register) + *reg_count*4;
+
+ /* Get data from slave*/
+ err = ispctrl_if_mast_recv_isp_register_response_from_slave(
+ devdata,
+ param,
+ ¶_size,
+ *reg_count);
+mast_sys_manage_cmd_get_isp_register_end:
+
+ return err;
+}
+
+/**
+ *\brief Set common log level
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_set_comomn_log_level(void *devdata,
+ u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size = sizeof(struct system_cmd_common_log_level);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ return err;
+}
+
+/**
+ *\brief Get chip test report
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_get_chip_test_report(void *devdata,
+ u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size = 0;
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode,
+ param, para_size);
+ if (err != ERR_SUCCESS)
+ goto mast_sys_manage_cmd_get_chip_test_report_end;
+
+ /* Update response size*/
+ para_size = ReportRegCount;
+
+ /* Get data from slave*/
+ err = ispctrl_mast_recv_response_from_slave(devdata, param,
+ para_size, true);
+mast_sys_manage_cmd_get_chip_test_report_end:
+
+ return err;
+}
+
+/*
+ *\brief Get isp thermal
+ *\param devdata [In], misp_data
+ *\param opcode [In], Operation code
+ *\param param [In], CMD param
+ *\return Error code
+ */
+errcode mast_sys_manage_cmd_get_chip_thermal(
+ void *devdata,
+ u16 opcode, u8 *param)
+{
+ /* Error Code*/
+ errcode err = ERR_SUCCESS;
+ u32 para_size = sizeof(u16);
+
+ misp_info("%s - enter", __func__);
+
+ /* Send command to slave*/
+ err = ispctrl_mast_send_cmd_to_slave(devdata, opcode, NULL, 0);
+ if (err != ERR_SUCCESS)
+ goto mast_camera_profile_cmd_get_isp_thermal_end;
+
+ /* Get data from slave*/
+ err = ispctrl_mast_recv_response_from_slave(devdata,
+ param, para_size, true);
+ if (err != ERR_SUCCESS) {
+ misp_info("%s - err 0x%x", __func__, err);
+ goto mast_camera_profile_cmd_get_isp_thermal_end;
+ }
+
+ misp_info("Get thermal value 0x%x", *(u16 *)param);
+
+mast_camera_profile_cmd_get_isp_thermal_end:
+ return err;
+}
+
+/******End Of File******/
diff --git a/drivers/media/platform/msm/vidc_3x/hfi_response_handler.c b/drivers/media/platform/msm/vidc_3x/hfi_response_handler.c
index 5dfb442..abf2ef1 100644
--- a/drivers/media/platform/msm/vidc_3x/hfi_response_handler.c
+++ b/drivers/media/platform/msm/vidc_3x/hfi_response_handler.c
@@ -843,6 +843,20 @@
{
enum vidc_status status = VIDC_ERR_NONE;
u32 prop_id, next_offset;
+#define VALIDATE_PROPERTY_STRUCTURE_SIZE(pkt_size, property_size) ({\
+ if (pkt_size < property_size) { \
+ status = VIDC_ERR_BAD_PARAM; \
+ break; \
+ } \
+})
+
+#define VALIDATE_PROPERTY_PAYLOAD_SIZE(pkt_size, payload_size, \
+ property_count) ({\
+ if (pkt_size/payload_size < property_count) { \
+ status = VIDC_ERR_BAD_PARAM; \
+ break; \
+ } \
+})
while (status == VIDC_ERR_NONE && num_properties &&
rem_bytes >= sizeof(u32)) {
@@ -856,6 +870,9 @@
struct hfi_codec_mask_supported *prop =
(struct hfi_codec_mask_supported *)
(data_ptr + next_offset);
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(*prop));
codecs = prop->codecs;
domain = prop->video_domains;
@@ -869,11 +886,14 @@
(struct hfi_capability_supported_info *)
(data_ptr + next_offset);
- if ((rem_bytes - next_offset) < prop->num_capabilities *
- sizeof(struct hfi_capability_supported)) {
- status = VIDC_ERR_BAD_PARAM;
- break;
- }
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(*prop));
+ VALIDATE_PROPERTY_PAYLOAD_SIZE(rem_bytes -
+ next_offset - sizeof(u32),
+ sizeof(struct hfi_capability_supported),
+ prop->num_capabilities);
+
next_offset += sizeof(u32) +
prop->num_capabilities *
sizeof(struct hfi_capability_supported);
@@ -894,10 +914,10 @@
char *fmt_ptr;
struct hfi_uncompressed_plane_info *plane_info;
- if ((rem_bytes - next_offset) < sizeof(*prop)) {
- status = VIDC_ERR_BAD_PARAM;
- break;
- }
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(*prop));
+
num_format_entries = prop->format_entries;
next_offset = sizeof(*prop);
fmt_ptr = (char *)&prop->rg_format_info[0];
@@ -908,17 +928,19 @@
plane_info =
(struct hfi_uncompressed_plane_info *) fmt_ptr;
- if ((rem_bytes - next_offset) <
- sizeof(*plane_info)) {
- status = VIDC_ERR_BAD_PARAM;
- break;
- }
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(*plane_info));
+
bytes_to_skip = sizeof(*plane_info) -
sizeof(struct
hfi_uncompressed_plane_constraints) +
plane_info->num_planes *
sizeof(struct
hfi_uncompressed_plane_constraints);
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ bytes_to_skip);
fmt_ptr += bytes_to_skip;
next_offset += bytes_to_skip;
@@ -932,6 +954,13 @@
struct hfi_properties_supported *prop =
(struct hfi_properties_supported *)
(data_ptr + next_offset);
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(*prop));
+ VALIDATE_PROPERTY_PAYLOAD_SIZE(rem_bytes -
+ next_offset - sizeof(*prop) +
+ sizeof(u32), sizeof(u32),
+ prop->num_properties);
next_offset += sizeof(*prop) - sizeof(u32)
+ prop->num_properties * sizeof(u32);
num_properties--;
@@ -948,6 +977,9 @@
(struct hfi_profile_level_supported *)
(data_ptr + next_offset);
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(*prop));
ptr = (char *) &prop->rg_profile_level[0];
prof_count = prop->profile_count;
next_offset += sizeof(u32);
@@ -960,6 +992,9 @@
}
while (prof_count) {
prof_level = (struct hfi_profile_level *)ptr;
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(*prof_level));
capability.
profile_level.profile_level[count].profile
= prof_level->profile;
@@ -976,6 +1011,9 @@
}
case HFI_PROPERTY_PARAM_INTERLACE_FORMAT_SUPPORTED:
{
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(struct hfi_interlace_format_supported));
next_offset +=
sizeof(struct hfi_interlace_format_supported);
num_properties--;
@@ -983,6 +1021,9 @@
}
case HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SUPPORTED:
{
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(struct hfi_nal_stream_format_supported));
next_offset +=
sizeof(struct hfi_nal_stream_format_supported);
num_properties--;
@@ -990,18 +1031,27 @@
}
case HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SELECT:
{
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(u32));
next_offset += sizeof(u32);
num_properties--;
break;
}
case HFI_PROPERTY_PARAM_MAX_SEQUENCE_HEADER_SIZE:
{
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(u32));
next_offset += sizeof(u32);
num_properties--;
break;
}
case HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH:
{
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(struct hfi_intra_refresh));
next_offset +=
sizeof(struct hfi_intra_refresh);
num_properties--;
@@ -1012,13 +1062,21 @@
struct hfi_buffer_alloc_mode_supported *prop =
(struct hfi_buffer_alloc_mode_supported *)
(data_ptr + next_offset);
-
+ VALIDATE_PROPERTY_STRUCTURE_SIZE(rem_bytes -
+ next_offset,
+ sizeof(*prop));
if (prop->num_entries >= 32) {
dprintk(VIDC_ERR,
"%s - num_entries: %d from f/w seems suspect\n",
__func__, prop->num_entries);
break;
}
+ VALIDATE_PROPERTY_PAYLOAD_SIZE(rem_bytes -
+ next_offset -
+ sizeof(struct hfi_buffer_alloc_mode_supported) +
+ sizeof(u32),
+ sizeof(u32),
+ prop->num_entries);
next_offset +=
sizeof(struct hfi_buffer_alloc_mode_supported) -
sizeof(u32) + prop->num_entries * sizeof(u32);
@@ -1036,8 +1094,12 @@
__func__, data_ptr, prop_id);
break;
}
- rem_bytes -= next_offset;
- data_ptr += next_offset;
+ if (rem_bytes > next_offset) {
+ rem_bytes -= next_offset;
+ data_ptr += next_offset;
+ } else {
+ rem_bytes = 0;
+ }
}
return status;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
index 62d10bf..c9c6281 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
@@ -1936,6 +1936,9 @@
dma_unmap_single(ipa3_ctx->pdev, rx_pkt->data.dma_addr,
sys->rx_buff_sz, DMA_FROM_DEVICE);
fail_dma_mapping:
+ /* Recycle skb before adding to recycle list if dma mapping failed */
+ rx_pkt->data.dma_addr = 0;
+ ipa3_skb_recycle(rx_pkt->data.skb);
spin_lock_bh(&sys->spinlock);
list_add_tail(&rx_pkt->link, &sys->rcycl_list);
INIT_LIST_HEAD(&rx_pkt->link);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 80386d2..fc61099 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -44,6 +44,7 @@
#define DWC3_EP0_BOUNCE_SIZE 512
#define DWC3_ENDPOINTS_NUM 32
#define DWC3_XHCI_RESOURCES_NUM 2
+#define MAX_ERROR_RECOVERY_TRIES 3
#define DWC3_SCRATCHBUF_SIZE 4096 /* each buffer is assumed to be 4KiB */
#define DWC3_EVENT_BUFFERS_SIZE 4096
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
index 37c4e7e..a2a4438 100644
--- a/drivers/usb/dwc3/dwc3-msm.c
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -2022,8 +2022,13 @@
reg |= DWC3_GCTL_CORESOFTRESET;
dwc3_msm_write_reg(mdwc->base, DWC3_GCTL, reg);
- /* restart USB which performs full reset and reconnect */
- schedule_work(&mdwc->restart_usb_work);
+ /*
+ * If the core could not recover after MAX_ERROR_RECOVERY_TRIES,
+ * skip the restart USB work and keep the core in softreset
+ * state.
+ */
+ if (dwc->retries_on_error < MAX_ERROR_RECOVERY_TRIES)
+ schedule_work(&mdwc->restart_usb_work);
break;
case DWC3_CONTROLLER_RESET_EVENT:
dev_dbg(mdwc->dev, "DWC3_CONTROLLER_RESET_EVENT received\n");
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index d0391b4..1235287 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -37,8 +37,6 @@
#include "gadget.h"
#include "io.h"
-#define MAX_ERROR_RECOVERY_TRIES 3
-
static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc, bool remote_wakeup);
static int dwc3_gadget_wakeup_int(struct dwc3 *dwc);
static void dwc3_stop_active_transfers(struct dwc3 *dwc);
@@ -1954,6 +1952,11 @@
reg1 |= DWC3_GEVNTSIZ_INTMASK;
dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg1);
+ /*
+ * Reset the err_evt_seen so that the interrupts on
+ * next connect/session is processed correctly.
+ */
+ dwc->err_evt_seen = false;
dwc->pullups_connected = false;
__dwc3_gadget_ep_disable(dwc->eps[0]);
@@ -3666,12 +3669,10 @@
evt->lpos = (evt->lpos + left) %
DWC3_EVENT_BUFFERS_SIZE;
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), left);
- if (dwc->retries_on_error < MAX_ERROR_RECOVERY_TRIES) {
- if (dwc3_notify_event(dwc,
+ if (dwc3_notify_event(dwc,
DWC3_CONTROLLER_ERROR_EVENT, 0))
- dwc->err_evt_seen = 0;
- dwc->retries_on_error++;
- }
+ dwc->err_evt_seen = 0;
+ dwc->retries_on_error++;
break;
}
diff --git a/drivers/usb/gadget/function/f_ccid.c b/drivers/usb/gadget/function/f_ccid.c
index 631597e..33490a8 100644
--- a/drivers/usb/gadget/function/f_ccid.c
+++ b/drivers/usb/gadget/function/f_ccid.c
@@ -857,9 +857,9 @@
&bulk_dev->tx_idle)))
ccid_request_free(req, ccid_dev->in);
r = -ENODEV;
+ goto done;
}
spin_unlock_irqrestore(&ccid_dev->lock, flags);
- goto done;
}
done:
pr_debug("ccid_bulk_write returning %d\n", r);
diff --git a/include/uapi/Kbuild b/include/uapi/Kbuild
index aeb3366..96815bd 100644
--- a/include/uapi/Kbuild
+++ b/include/uapi/Kbuild
@@ -14,3 +14,4 @@
header-y += scsi/
header-y += misc/
header-y += media/
+header-y += miniISP/
diff --git a/include/uapi/miniISP/Kbuild b/include/uapi/miniISP/Kbuild
new file mode 100644
index 0000000..0e318e6
--- /dev/null
+++ b/include/uapi/miniISP/Kbuild
@@ -0,0 +1,3 @@
+# ///ALTEK_TAG_HwMiniISP>>>
+header-y += miniISP_ioctl.h
+# ///ALTEK_TAG_HwMiniISP<<<
\ No newline at end of file
diff --git a/include/uapi/miniISP/miniISP_ioctl.h b/include/uapi/miniISP/miniISP_ioctl.h
new file mode 100644
index 0000000..a087e91
--- /dev/null
+++ b/include/uapi/miniISP/miniISP_ioctl.h
@@ -0,0 +1,164 @@
+/*
+ * File: miniISP_ioctl.h
+ * Description: miniISP ioctl
+ *
+ * Copyright 2019-2030 Altek Semiconductor Corporation
+ *
+ */
+
+/*
+ * This file is part of al6100.
+ *
+ * al6100 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.
+ *
+ * al6100 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTIBILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details.
+ *
+ * You should have received a copy of the General Public License version 2
+ * along with al6100. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+/* /ALTEK_TAG_HwMiniISP>>> */
+
+#ifndef _MINI_ISP_IOCTL_H_
+#define _MINI_ISP_IOCTL_H_
+
+#include <linux/types.h>
+#include <linux/ioctl.h> /* _IOW(), _IOR() */
+
+#define SPIBULK_BLOCKSIZE 8192 /* 8k bytes */
+#define SPI_CMD_LENGTH 64
+
+#define ISPCMD_LOAD_FW 0x0001
+#define ISPCMD_PURE_BYPASS 0x0010
+#define ISPCMD_POWER_OFF 0x0100
+#define ISPCMD_ENTER_CP_MODE 0x0200
+#define ISPCMD_LEAVE_CP_MODE_STANDBY 0x0002
+#define ISPCMD_NONE 0x0000
+
+
+/*Calibration Profile*/
+#define ISPCMD_CAMERA_SET_SENSORMODE 0x300A
+#define ISPCMD_CAMERA_GET_SENSORMODE 0x300B
+#define ISPCMD_CAMERA_SET_OUTPUTFORMAT 0x300D
+#define ISPCMD_CAMERA_SET_CP_MODE 0x300E
+#define ISPCMD_CAMERA_SET_AE_STATISTICS 0x300F
+#define ISPCMD_CAMERA_PREVIEWSTREAMONOFF 0x3010
+#define ISPCMD_CAMERA_DUALPDYCALCULATIONWEIGHT 0x3011
+#define ISPCMD_LED_POWERCONTROL 0x3012
+#define ISPCMD_CAMERA_ACTIVE_AE 0x3013
+#define ISPCMD_ISP_AECONTROLONOFF 0x3014
+#define ISPCMD_CAMERA_SET_FRAMERATELIMITS 0x3015
+#define ISPCMD_CAMERA_SET_PERIODDROPFRAME 0x3016
+#define ISPCMD_CAMERA_SET_MAX_EXPOSURE 0x3017
+#define ISPCMD_CAMERA_SET_AE_TARGET_MEAN 0x3018
+#define ISPCMD_CAMERA_FRAME_SYNC_CONTROL 0x3019
+#define ISPCMD_CAMERA_SET_SHOT_MODE 0x301A
+#define ISPCMD_CAMERA_LIGHTING_CTRL 0x301B
+#define ISPCMD_CAMERA_DEPTH_COMPENSATION 0x301C
+#define ISPCMD_CAMERA_TRIGGER_DEPTH_PROCESS_CTRL 0x301D
+#define ISPCMD_CAMERA_SET_MIN_EXPOSURE 0x301E
+#define ISPCMD_CAMERA_SET_MAX_EXPOSURE_SLOPE 0x301F
+
+
+
+/* Bulk Data*/
+#define ISPCMD_BULK_WRITE_BASICCODE 0x2002
+#define ISPCMD_BULK_WRITE_BOOTCODE 0x2008
+#define ISPCMD_BULK_READ_MEMORY 0x2101
+#define ISPCMD_BULK_READ_COMLOG 0x2102
+#define ISPCMD_BULK_WRITE_CALIBRATION_DATA 0x210B
+
+/*Basic Setting*/
+#define ISPCMD_BASIC_SET_DEPTH_3A_INFO 0x10B9
+#define ISPCMD_BASIC_SET_DEPTH_AUTO_INTERLEAVE_MODE 0x10BC
+#define ISPCMD_BASIC_SET_INTERLEAVE_MODE_DEPTH_TYPE 0x10BD
+#define ISPCMD_BASIC_SET_DEPTH_POLISH_LEVEL 0x10BE
+
+/*System Cmd*/
+#define ISPCMD_SYSTEM_GET_STATUSOFLASTEXECUTEDCOMMAND 0x0015
+#define ISPCMD_SYSTEM_GET_ERRORCODE 0x0016
+#define ISPCMD_SYSTEM_SET_ISPREGISTER 0x0100
+#define ISPCMD_SYSTEM_GET_ISPREGISTER 0x0101
+/*#define ISPCMD_SYSTEM_SET_DEBUGCMD 0x0104*/
+#define ISPCMD_SYSTEM_SET_COMLOGLEVEL 0x0109
+#define ISPCMD_SYSTEM_GET_CHIPTESTREPORT 0x010A
+
+/*Operarion Code*/
+#define ISPCMD_MINIISPOPEN 0x4000
+
+
+
+/* ALTEK_AL6100_KERNEL >>> */
+#define IOC_ISP_CTRL_FLOW_KERNEL_MAGIC 'D'
+
+#define IOCTL_ISP_RUN_TASK_INIT \
+ _IOWR(IOC_ISP_CTRL_FLOW_KERNEL_MAGIC, BASE_MINIISP_CONTROL, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_RUN_TASK_START \
+ _IOWR(IOC_ISP_CTRL_FLOW_KERNEL_MAGIC, BASE_MINIISP_CONTROL + 1, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_RUN_TASK_STOP \
+ _IOWR(IOC_ISP_CTRL_FLOW_KERNEL_MAGIC, BASE_MINIISP_CONTROL + 2, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_RUN_TASK_DEINIT \
+ _IOWR(IOC_ISP_CTRL_FLOW_KERNEL_MAGIC, BASE_MINIISP_CONTROL + 3, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_RUN_TASK_QUERY \
+ _IOWR(IOC_ISP_CTRL_FLOW_KERNEL_MAGIC, BASE_MINIISP_CONTROL + 4, struct miniISP_cmd_config)
+
+struct miniISP_chi_param {
+ /* uint8_t board_power_always_on; //1: power is always on */
+ uint8_t scid;
+ uint8_t irflood_mode;
+ uint8_t merge_mode;
+} __attribute__ ((packed));
+
+
+/* ALTEK_AL6100_KERNEL <<< */
+
+
+
+
+/* TODO: Need to solve the kernel panic >>> */
+struct miniISP_cmd_config {
+ uint16_t opcode;
+ uint32_t size;
+ uint64_t param;
+} __attribute__ ((packed));
+
+#define BASE_MINIISP_CONTROL 100
+
+#define IOC_ISP_CTRL_FLOW_MAGIC 'C'
+
+#define IOCTL_ISP_LOAD_FW \
+ _IOWR(IOC_ISP_CTRL_FLOW_MAGIC, BASE_MINIISP_CONTROL, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_PURE_BYPASS \
+ _IOWR(IOC_ISP_CTRL_FLOW_MAGIC, BASE_MINIISP_CONTROL + 1, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_POWER_OFF \
+ _IOWR(IOC_ISP_CTRL_FLOW_MAGIC, BASE_MINIISP_CONTROL + 2, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_ENTER_CP_MODE \
+ _IOWR(IOC_ISP_CTRL_FLOW_MAGIC, BASE_MINIISP_CONTROL + 3, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_LEAVE_CP_MODE \
+ _IOWR(IOC_ISP_CTRL_FLOW_MAGIC, BASE_MINIISP_CONTROL + 4, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_CTRL_CMD \
+ _IOWR(IOC_ISP_CTRL_FLOW_MAGIC, BASE_MINIISP_CONTROL + 5, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_POWER_ON \
+ _IOWR(IOC_ISP_CTRL_FLOW_MAGIC, BASE_MINIISP_CONTROL + 6, struct miniISP_cmd_config)
+
+#define IOCTL_ISP_DEINIT \
+ _IOWR(IOC_ISP_CTRL_FLOW_MAGIC, BASE_MINIISP_CONTROL + 7, struct miniISP_cmd_config)
+
+/* /ALTEK_TAG_HwMiniISP<<< */
+#endif
+