Merge "mm: add preempt points into __purge_vmap_area_lazy()"
diff --git a/Documentation/devicetree/bindings/crypto/msm/qcedev.txt b/Documentation/devicetree/bindings/crypto/msm/qcedev.txt
index c8077cb..051b315 100644
--- a/Documentation/devicetree/bindings/crypto/msm/qcedev.txt
+++ b/Documentation/devicetree/bindings/crypto/msm/qcedev.txt
@@ -20,6 +20,8 @@
- qcom,ce-hw-key : optional, indicates if the hardware supports use of HW KEY.
- qcom,support-core-clk-only : optional, indicates if the HW supports single crypto core clk.
- qcom,bsm-ee : optional, indicate the BAM EE value, changes from target to target. Default value is 1 if not specified.
+ - qcom,smmu-s1-bypass : Boolean flag to bypass SMMU stage 1 translation.
+ - iommus : A list of phandle and IOMMU specifier pairs that describe the IOMMU master interfaces of the device.
Example:
diff --git a/Documentation/devicetree/bindings/crypto/msm/qcrypto.txt b/Documentation/devicetree/bindings/crypto/msm/qcrypto.txt
index 3c8a79a..fa27198 100644
--- a/Documentation/devicetree/bindings/crypto/msm/qcrypto.txt
+++ b/Documentation/devicetree/bindings/crypto/msm/qcrypto.txt
@@ -40,6 +40,9 @@
required. For other targets such as fsm, they do not perform
bus scaling. It is not required for those targets.
+ - qcom,smmu-s1-bypass : Boolean flag to bypass SMMU stage 1 translation.
+ - iommus : A list of phandle and IOMMU specifier pairs that describe the IOMMU master interfaces of the device.
+
Example:
qcom,qcrypto@fd444000 {
diff --git a/Documentation/devicetree/bindings/media/video/msm-cam-eeprom.txt b/Documentation/devicetree/bindings/media/video/msm-cam-eeprom.txt
new file mode 100644
index 0000000..933ad85
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/video/msm-cam-eeprom.txt
@@ -0,0 +1,438 @@
+* Qualcomm Technologies, Inc. MSM EEPROM
+
+EEPROM is an one time programmed(OTP) device that stores the calibration data
+use for camera sensor. It may either be integrated in the sensor module or in
+the sensor itself. As a result, the power, clock and GPIOs may be the same as
+the camera sensor. The following describes the page block map, power supply,
+clock, GPIO and power on sequence properties of the EEPROM device.
+
+=======================================================
+Required Node Structure if probe happens from userspace
+=======================================================
+The EEPROM device is described in one level of the device node.
+
+======================================
+First Level Node - CAM EEPROM device
+======================================
+- compatible
+ Usage: required
+ Value type: <string>
+ Definition: Should be "qcom,eeprom".
+
+- cell-index
+ Usage: required
+ Value type: <u32>
+ Definition: Should specify the hardware index id.
+
+- reg
+ Usage: required
+ Value type: <u32>
+ Definition: Register values.
+
+- regulator-names
+ Usage: required
+ Value type: <string>
+ Definition: Name of the regulator resources for EEPROM HW.
+
+- xxxx-supply
+ Usage: required
+ Value type: <phandle>
+ Definition: Regulator reference corresponding to the names listed in
+ "regulator-names".
+
+- rgltr-cntrl-support
+ Usage: required
+ Value type: <bool>
+ Definition: This property specifies if the regulator control is supported
+ e.g. rgltr-min-voltage.
+
+- rgltr-min-voltage
+ Usage: required
+ Value type: <u32>
+ Definition: should contain minimum voltage level for regulators
+ mentioned in regulator-names property.
+
+- rgltr-max-voltage
+ Usage: required
+ Value type: <u32>
+ Definition: should contain maximum voltage level for regulators
+ mentioned in regulator-names property.
+
+- rgltr-load-current
+ Usage: required
+ Value type: <u32>
+ Definition: should contain the maximum current in microamps required for
+ the regulators mentioned in regulator-names property.
+
+- gpio-no-mux
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the gpio mux type.
+
+- gpios
+ Usage: required
+ Value type: <phandle>
+ Definition: should specify the gpios to be used for the eeprom.
+
+- gpio-reset
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the reset gpio index.
+
+- gpio-standby
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the standby gpio index.
+
+- gpio-req-tbl-num
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the gpio table index.
+
+- gpio-req-tbl-flags
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the gpio functions.
+
+- gpio-req-tbl-label
+ Usage: required
+ Value type: <string>
+ Definition: should specify the gpio labels.
+
+- sensor-position
+ Usage: required
+ Value type: <u32>
+ Definition: should contain the mount angle of the camera sensor.
+
+- cci-master
+ Usage: required
+ Value type: <u32>
+ Definition: should contain i2c master id to be used for this camera
+ sensor.
+
+- sensor-mode
+ Usage: required
+ Value type: <u32>
+ Definition: should contain sensor mode supported.
+
+- clock-names
+ Usage: required
+ Value type: <string>
+ Definition: List of clock names required for EEPROM HW.
+
+- clocks
+ Usage: required
+ Value type: <phandle>
+ Definition: List of clocks used for EEPROM HW.
+
+- clock-cntl-level
+ Usage: required
+ Value type: <string>
+ Definition: says what all different clock levels eeprom node has.
+
+- clock-rates
+ Usage: required
+ Value type: <u32>
+ Definition: List of clocks rates.
+
+Example:
+
+ eprom0: qcom,eeprom@0 {
+ cell-index = <0>;
+ reg = <0x0>;
+ compatible = "qcom,eeprom";
+ cam_vdig-supply = <&pm8998_l5>;
+ cam_vio-supply = <&pm8998_lvs1>;
+ regulator-names = "cam_vdig", "cam_vio";
+ rgltr-cntrl-support;
+ rgltr-min-voltage = <1200000 0>;
+ rgltr-max-voltage = <1200000 0>;
+ rgltr-load-current = <0 80000 105000 0>;
+ gpio-no-mux = <0>;
+ gpios = <&msmgpio 26 0>,
+ <&msmgpio 37 0>,
+ <&msmgpio 36 0>;
+ gpio-reset = <1>;
+ gpio-standby = <2>;
+ gpio-req-tbl-num = <0 1 2>;
+ gpio-req-tbl-flags = <1 0 0>;
+ gpio-req-tbl-label = "CAMIF_MCLK",
+ "CAM_RESET1",
+ "CAM_STANDBY";
+ sensor-position = <0>;
+ sensor-mode = <0>;
+ cci-master = <0>;
+ status = "ok";
+ clocks = <&clock_camcc CAM_CC_MCLK0_CLK>;
+ clock-names = "cam_clk";
+ clock-cntl-level = "turbo";
+ clock-rates = <24000000>;
+ };
+
+=======================================================
+Required Node Structure if probe happens from kernel
+=======================================================
+The EEPROM device is described in one level of the device node.
+
+======================================
+First Level Node - CAM EEPROM device
+======================================
+- compatible
+ Usage: required
+ Value type: <string>
+ Definition: Should be "qcom,eeprom".
+
+- cell-index
+ Usage: required
+ Value type: <u32>
+ Definition: Should specify the hardware index id.
+
+- reg
+ Usage: required
+ Value type: <u32>
+ Definition: Register values.
+
+- qcom,eeprom-name
+ Usage: required
+ Value type: <string>
+ Definition: Name of the EEPROM HW.
+
+- qcom,slave-addr
+ Usage: required
+ Value type: <u32>
+ Definition: Slave address of the EEPROM HW.
+
+- qcom,num-blocks
+ Usage: required
+ Value type: <u32>
+ Definition: Total block number that eeprom contains.
+
+- qcom,pageX
+ Usage: required
+ Value type: <u32>
+ Definition: List of values specifying page size, start address,
+ address type, data, data type, delay in ms.
+ size 0 stand for non-paged.
+
+- qcom,pollX
+ Usage: required
+ Value type: <u32>
+ Definition: List of values specifying poll size, poll reg address,
+ address type, data, data type, delay in ms.
+ size 0 stand for not used.
+
+- qcom,memX
+ Usage: required
+ Value type: <u32>
+ Definition: List of values specifying memory size, start address,
+ address type, data, data type, delay in ms.
+ size 0 stand for not used.
+
+- qcom,saddrX
+ Usage: required
+ Value type: <u32>
+ Definition: property should specify the slave address for block (%d).
+
+- regulator-names
+ Usage: required
+ Value type: <string>
+ Definition: Name of the regulator resources for EEPROM HW.
+
+- qcom,cmm-data-support
+ Usage: required
+ Value type: <u32>
+ Definition: Camera MultiModule data capability flag..
+
+- qcom,cmm-data-compressed
+ Usage: required
+ Value type: <u32>
+ Definition: Camera MultiModule data compression flag.
+
+- qcom,cmm-data-offset
+ Usage: required
+ Value type: <u32>
+ Definition: Camera MultiModule data start offset.
+
+- qcom,cmm-data-size
+ Usage: required
+ Value type: <u32>
+ Definition: Camera MultiModule data size.
+
+- qcom,cam-power-seq-type
+ Usage: required
+ Value type: <string>
+ Definition: should specify the power on sequence types.
+
+- qcom,cam-power-seq-val
+ Usage: required
+ Value type: <string>
+ Definition: should specify the power on sequence values.
+
+- qcom,cam-power-seq-cfg-val
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the power on sequence config values.
+
+- qcom,cam-power-seq-delay
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the power on sequence delay time in ms.
+
+- xxxx-supply
+ Usage: required
+ Value type: <phandle>
+ Definition: Regulator reference corresponding to the names listed in
+ "regulator-names".
+
+- rgltr-cntrl-support
+ Usage: required
+ Value type: <bool>
+ Definition: This property specifies if the regulator control is supported
+ e.g. rgltr-min-voltage.
+
+- rgltr-min-voltage
+ Usage: required
+ Value type: <u32>
+ Definition: should contain minimum voltage level for regulators
+ mentioned in regulator-names property.
+
+- rgltr-max-voltage
+ Usage: required
+ Value type: <u32>
+ Definition: should contain maximum voltage level for regulators
+ mentioned in regulator-names property.
+
+- rgltr-load-current
+ Usage: required
+ Value type: <u32>
+ Definition: should contain the maximum current in microamps required for
+ the regulators mentioned in regulator-names property.
+
+- gpio-no-mux
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the gpio mux type.
+
+- gpios
+ Usage: required
+ Value type: <phandle>
+ Definition: should specify the gpios to be used for the eeprom.
+
+- gpio-reset
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the reset gpio index.
+
+- gpio-standby
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the standby gpio index.
+
+- gpio-req-tbl-num
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the gpio table index.
+
+- gpio-req-tbl-flags
+ Usage: required
+ Value type: <u32>
+ Definition: should specify the gpio functions.
+
+- gpio-req-tbl-label
+ Usage: required
+ Value type: <string>
+ Definition: should specify the gpio labels.
+
+- sensor-position
+ Usage: required
+ Value type: <u32>
+ Definition: should contain the mount angle of the camera sensor.
+
+- cci-master
+ Usage: required
+ Value type: <u32>
+ Definition: should contain i2c master id to be used for this camera
+ sensor.
+
+- sensor-mode
+ Usage: required
+ Value type: <u32>
+ Definition: should contain sensor mode supported.
+
+- clock-cntl-level
+ Usage: required
+ Value type: <string>
+ Definition: says what all different clock levels eeprom node has.
+
+- clock-names
+ Usage: required
+ Value type: <string>
+ Definition: List of clock names required for EEPROM HW.
+
+- clocks
+ Usage: required
+ Value type: <phandle>
+ Definition: List of clocks used for EEPROM HW.
+
+- clock-rates
+ Usage: required
+ Value type: <u32>
+ Definition: List of clocks rates.
+
+Example:
+
+ eeprom0: qcom,eeprom@0 {
+ cell-index = <0>;
+ reg = <0x0>;
+ qcom,eeprom-name = "msm_eeprom";
+ compatible = "qcom,eeprom";
+ qcom,slave-addr = <0x60>;
+ qcom,num-blocks = <2>;
+ qcom,page0 = <1 0x100 2 0x01 1 1>;
+ qcom,poll0 = <0 0x0 2 0 1 1>;
+ qcom,mem0 = <0 0x0 2 0 1 0>;
+ qcom,page1 = <1 0x0200 2 0x8 1 1>;
+ qcom,pageen1 = <1 0x0202 2 0x01 1 10>;
+ qcom,poll1 = <0 0x0 2 0 1 1>;
+ qcom,mem1 = <32 0x3000 2 0 1 0>;
+ qcom,saddr1 = <0x62>;
+ qcom,cmm-data-support;
+ qcom,cmm-data-compressed;
+ qcom,cmm-data-offset = <0>;
+ qcom,cmm-data-size = <0>;
+ qcom,cam-power-seq-type = "sensor_vreg",
+ "sensor_vreg", "sensor_clk",
+ "sensor_gpio", "sensor_gpio";
+ qcom,cam-power-seq-val = "cam_vdig",
+ "cam_vio", "sensor_cam_mclk",
+ "sensor_gpio_reset",
+ "sensor_gpio_standby";
+ qcom,cam-power-seq-cfg-val = <1 1 24000000 1 1>;
+ qcom,cam-power-seq-delay = <1 1 5 5 10>;
+ cam_vdig-supply = <&pm8998_l5>;
+ cam_vio-supply = <&pm8998_lvs1>;
+ regulator-names = "cam_vdig", "cam_vio";
+ rgltr-cntrl-support;
+ rgltr-min-voltage = <1200000 0>;
+ rgltr-max-voltage = <1200000 0>;
+ rgltr-load-current = <0 80000 105000 0>;
+ qcom,gpio-no-mux = <0>;
+ gpios = <&msmgpio 26 0>,
+ <&msmgpio 37 0>,
+ <&msmgpio 36 0>;
+ gpio-reset = <1>;
+ gpio-standby = <2>;
+ gpio-req-tbl-num = <0 1 2>;
+ gpio-req-tbl-flags = <1 0 0>;
+ gpio-req-tbl-label = "CAMIF_MCLK",
+ "CAM_RESET1",
+ "CAM_STANDBY";
+ sensor-position = <0>;
+ sensor-mode = <0>;
+ cci-master = <0>;
+ status = "ok";
+ clocks = <&clock_camcc CAM_CC_MCLK0_CLK>;
+ clock-cntl-level = "turbo";
+ clock-names = "cam_clk";
+ clock-rates = <24000000>;
+ };
diff --git a/Documentation/devicetree/bindings/media/video/msm-camera-flash.txt b/Documentation/devicetree/bindings/media/video/msm-camera-flash.txt
new file mode 100644
index 0000000..d24314a
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/video/msm-camera-flash.txt
@@ -0,0 +1,126 @@
+* Qualcomm Technologies, Inc. MSM FLASH
+
+The MSM camera Flash driver provides the definitions for
+enabling and disabling LED Torch/Flash by requesting it to
+PMIC/I2C/GPIO based hardware. It provides the functions for
+the Client to control the Flash hardware.
+
+=======================================================
+Required Node Structure
+=======================================================
+The Flash device is described in one level of the device node.
+
+======================================
+First Level Node - CAM FLASH device
+======================================
+- compatible
+ Usage: required
+ Value type: <string>
+ Definition: Should be "qcom,camera-flash".
+
+- cell-index
+ Usage: required
+ Value type: <u32>
+ Definition: Should specify the hardware index id.
+
+- reg
+ Usage: required
+ Value type: <u32>
+ Definition: Register values.
+
+- flash-source
+ Usage: required
+ Value type: <phandle>
+ Definition: Should contain array of phandles to Flash source nodes.
+
+- torch-source
+ Usage: required
+ Value type: <phandle>
+ Definition: Should contain array of phandles to torch source nodes.
+
+- switch-source
+ Usage: Optional
+ Value type: <phandle>
+ Definition: Should contain phandle to switch source nodes.
+
+- slave-id
+ Usage: optional
+ Value type: <u32>
+ Definition: should contain i2c slave address, device id address
+ and expected id read value.
+
+- cci-master
+ Usage: optional
+ Value type: <u32>
+ Definition: should contain i2c master id to be used for this camera
+ flash.
+
+- max-current
+ Usage: optional
+ Value type: <u32>
+ Definition: Max current in mA supported by flash
+
+- max-duration
+ Usage: optional
+ Value type: <u32>
+ Definition: Max duration in ms flash can glow.
+
+- gpios
+ Usage: optional
+ Value type: <u32>
+ Definition: should specify the gpios to be used for the flash.
+
+- gpio-req-tbl-num
+ Usage: optional
+ Value type: <u32>
+ Definition: should specify the gpio table index.
+
+- gpio-req-tbl-flags
+ Usage: optional
+ Value type: <u32>
+ Definition: should specify the gpio functions.
+
+- gpio-req-tbl-label
+ Usage: optional
+ Value type: <u32>
+ Definition: should specify the gpio labels.
+
+- gpio-flash-reset
+ Usage: optional
+ Value type: <u32>
+ Definition: should contain index to gpio used by flash's "flash reset" pin.
+
+- gpio-flash-en
+ Usage: optional
+ Value type: <u32>
+ Definition: should contain index to gpio used by flash's "flash enable" pin.
+
+- gpio-flash-now
+ Usage: optional
+ Value type: <u32>
+ Definition: should contain index to gpio used by flash's "flash now" pin.
+
+Example:
+
+led_flash_rear: qcom,camera-flash@0 {
+ reg = <0x00 0x00>;
+ cell-index = <0>;
+ compatible = "qcom,camera-flash";
+ flash-source = <&pmi8998_flash0 &pmi8998_flash1>;
+ torch-source = <&pmi8998_torch0 &pmi8998_torch1>;
+ switch-source = <&pmi8998_switch0>;
+ qcom,slave-id = <0x00 0x00 0x0011>;
+ qcom,cci-master = <0>;
+ gpios = <&msmgpio 23 0>,
+ <&msmgpio 24 0>;
+ <&msmgpio 25 0>;
+ qcom,gpio-flash-reset = <0>;
+ qcom,gpio-flash-en = <0>;
+ qcom,gpio-flash-now = <1>;
+ qcom,gpio-req-tbl-num = <0 1>;
+ qcom,gpio-req-tbl-flags = <0 0>;
+ qcom,gpio-req-tbl-label = "FLASH_EN",
+ "FLASH_NOW";
+ qcom,max-current = <1500>;
+ qcom,max-duration = <1200>;
+ };
diff --git a/Documentation/devicetree/bindings/platform/msm/msm_tspp.txt b/Documentation/devicetree/bindings/platform/msm/msm_tspp.txt
index 072f920..b4ce7cb 100644
--- a/Documentation/devicetree/bindings/platform/msm/msm_tspp.txt
+++ b/Documentation/devicetree/bindings/platform/msm/msm_tspp.txt
@@ -23,6 +23,8 @@
- qcom, msm_bus,num_paths: The paths for source and destination ports
- qcom, msm_bus,vectors: Vectors for bus topology.
- pinctrl-names: Names for the TSIF mode configuration to specify which TSIF interface is active.
+- qcom,smmu-s1-bypass : Boolean flag to bypass SMMU stage 1 translation.
+- iommus : A list of phandle and IOMMU specifier pairs that describe the IOMMU master interfaces of the device.
Example:
@@ -75,4 +77,7 @@
&tsif0_sync_active
&tsif1_signals_active
&tsif1_sync_active>; /* dual-tsif-mode2 */
+
+ qcom,smmu-s1-bypass;
+ iommus = <&apps_smmu 0x20 0x0f>;
};
diff --git a/Makefile b/Makefile
index 04b3557..c11421f 100644
--- a/Makefile
+++ b/Makefile
@@ -565,7 +565,7 @@
# Objects we will link into vmlinux / subdirs we need to visit
init-y := init/
-drivers-y := drivers/ sound/ firmware/
+drivers-y := drivers/ sound/ firmware/ techpack/
net-y := net/
libs-y := lib/
core-y := usr/
@@ -1152,6 +1152,7 @@
$(error Headers not exportable for the $(SRCARCH) architecture))
$(Q)$(MAKE) $(hdr-inst)=include/uapi
$(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst)
+ $(Q)$(MAKE) $(hdr-inst)=techpack
PHONY += headers_check_all
headers_check_all: headers_install_all
@@ -1161,6 +1162,7 @@
headers_check: headers_install
$(Q)$(MAKE) $(hdr-inst)=include/uapi HDRCHECK=1
$(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) HDRCHECK=1
+ $(Q)$(MAKE) $(hdr-inst)=techpack HDRCHECK=1
# ---------------------------------------------------------------------------
# Kernel selftest
diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile
index 92dc1e6..b97f1de 100644
--- a/arch/arm64/boot/Makefile
+++ b/arch/arm64/boot/Makefile
@@ -28,6 +28,17 @@
DTB_OBJS := $(shell find $(obj)/dts/ -name \*.dtb)
endif
+# Add RTIC DTB to the DTB list if RTIC MPGen is enabled
+ifdef RTIC_MPGEN
+DTB_OBJS += rtic_mp.dtb
+endif
+
+rtic_mp.dtb: vmlinux FORCE
+ $(RTIC_MPGEN) --objcopy="${OBJCOPY}" --objdump="${OBJDUMP}" \
+ --binpath="" --vmlinux="vmlinux" --config=${KCONFIG_CONFIG} \
+ --cc="${CC}" --dts=rtic_mp.dts && \
+ $(DTC) -O dtb -o rtic_mp.dtb -b 0 $(DTC_FLAGS) rtic_mp.dts
+
$(obj)/Image: vmlinux FORCE
$(call if_changed,objcopy)
diff --git a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-cmd.dtsi b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-cmd.dtsi
index 44b817e..436a05d 100644
--- a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-cmd.dtsi
+++ b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dsc-wqxga-cmd.dtsi
@@ -40,6 +40,7 @@
17000 15500 30000 8000 3000>;
qcom,mdss-dsi-panel-peak-brightness = <4200000>;
qcom,mdss-dsi-panel-blackness-level = <3230>;
+ qcom,mdss-dsi-panel-jitter = <0x1 0x1>;
qcom,mdss-dsi-on-command = [
/* CMD2_P0 */
15 01 00 00 00 00 02 ff 20
diff --git a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-cmd.dtsi b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-cmd.dtsi
index 647ea4e..64e4d27 100644
--- a/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-cmd.dtsi
+++ b/arch/arm64/boot/dts/qcom/dsi-panel-nt35597-truly-dualmipi-wqxga-cmd.dtsi
@@ -35,6 +35,7 @@
qcom,mdss-dsi-color-order = "rgb_swap_rgb";
qcom,mdss-dsi-underflow-color = <0xff>;
qcom,mdss-dsi-border-color = <0>;
+ qcom,mdss-dsi-panel-jitter = <0x1 0x1>;
qcom,mdss-dsi-h-sync-pulse = <0>;
qcom,mdss-dsi-traffic-mode = "non_burst_sync_event";
qcom,mdss-dsi-bllp-eof-power-mode;
diff --git a/arch/arm64/boot/dts/qcom/dsi-panel-sharp-dsc-4k-cmd.dtsi b/arch/arm64/boot/dts/qcom/dsi-panel-sharp-dsc-4k-cmd.dtsi
index 6534cdc..744bd2c 100644
--- a/arch/arm64/boot/dts/qcom/dsi-panel-sharp-dsc-4k-cmd.dtsi
+++ b/arch/arm64/boot/dts/qcom/dsi-panel-sharp-dsc-4k-cmd.dtsi
@@ -49,6 +49,7 @@
qcom,mdss-dsi-te-using-te-pin;
qcom,dcs-cmd-by-left;
qcom,mdss-dsi-tx-eot-append;
+ qcom,mdss-dsi-panel-jitter = <0x8 0xa>;
qcom,adjust-timer-wakeup-ms = <1>;
qcom,mdss-dsi-on-command = [
diff --git a/arch/arm64/boot/dts/qcom/pm660l.dtsi b/arch/arm64/boot/dts/qcom/pm660l.dtsi
index 0f18ba5..9cd117c 100644
--- a/arch/arm64/boot/dts/qcom/pm660l.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm660l.dtsi
@@ -250,9 +250,8 @@
<0xd900 0x100>;
reg-names = "qpnp-wled-ctrl-base",
"qpnp-wled-sink-base";
- interrupts = <0x3 0xd8 0x1 IRQ_TYPE_EDGE_RISING>,
- <0x3 0xd8 0x2 IRQ_TYPE_EDGE_RISING>;
- interrupt-names = "ovp-irq", "sc-irq";
+ interrupts = <0x3 0xd8 0x1 IRQ_TYPE_EDGE_RISING>;
+ interrupt-names = "ovp-irq";
linux,name = "wled";
linux,default-trigger = "bkl-trigger";
qcom,fdbk-output = "auto";
@@ -268,7 +267,6 @@
qcom,fs-curr-ua = <25000>;
qcom,cons-sync-write-delay-us = <1000>;
qcom,led-strings-list = [00 01 02];
- qcom,en-ext-pfet-sc-pro;
qcom,loop-auto-gm-en;
qcom,pmic-revid = <&pm660l_revid>;
status = "ok";
diff --git a/arch/arm64/boot/dts/qcom/sdm670-smp2p.dtsi b/arch/arm64/boot/dts/qcom/sdm670-smp2p.dtsi
index 6dd1b749..f3e5ddb 100644
--- a/arch/arm64/boot/dts/qcom/sdm670-smp2p.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm670-smp2p.dtsi
@@ -25,8 +25,8 @@
compatible = "qcom,smp2p";
reg = <0x1799000c 0x4>;
qcom,remote-pid = <2>;
- qcom,irq-bitmask = <0x200>;
- interrupts = <GIC_SPI 157 IRQ_TYPE_EDGE_RISING>;
+ qcom,irq-bitmask = <0x4000000>;
+ interrupts = <GIC_SPI 172 IRQ_TYPE_EDGE_RISING>;
};
qcom,smp2p-cdsp@1799000c {
@@ -245,4 +245,27 @@
interrupt-controller;
#interrupt-cells = <2>;
};
+
+ /* ssr - inbound entry from cdsp */
+ smp2pgpio_ssr_smp2p_5_in: qcom,smp2pgpio-ssr-smp2p-5-in {
+ compatible = "qcom,smp2pgpio";
+ qcom,entry-name = "slave-kernel";
+ qcom,remote-pid = <5>;
+ qcom,is-inbound;
+ gpio-controller;
+ #gpio-cells = <2>;
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
+
+ /* ssr - outbound entry to cdsp */
+ smp2pgpio_ssr_smp2p_5_out: qcom,smp2pgpio-ssr-smp2p-5-out {
+ compatible = "qcom,smp2pgpio";
+ qcom,entry-name = "master-kernel";
+ qcom,remote-pid = <5>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ interrupt-controller;
+ #interrupt-cells = <2>;
+ };
};
diff --git a/arch/arm64/boot/dts/qcom/sdm670.dtsi b/arch/arm64/boot/dts/qcom/sdm670.dtsi
index 21c40fc..7d9702e 100644
--- a/arch/arm64/boot/dts/qcom/sdm670.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm670.dtsi
@@ -825,6 +825,12 @@
reg-names = "pshold-base", "tcsr-boot-misc-detect";
};
+ aop-msg-client {
+ compatible = "qcom,debugfs-qmp-client";
+ mboxes = <&qmp_aop 0>;
+ mbox-names = "aop";
+ };
+
clock_rpmh: qcom,rpmhclk {
compatible = "qcom,dummycc";
clock-output-names = "rpmh_clocks";
@@ -1113,8 +1119,8 @@
reg = <0x86000000 0x200000>,
<0x1799000c 0x4>;
reg-names = "smem", "irq-reg-base";
- qcom,irq-mask = <0x100>;
- interrupts = <GIC_SPI 156 IRQ_TYPE_EDGE_RISING>;
+ qcom,irq-mask = <0x1000000>;
+ interrupts = <GIC_SPI 170 IRQ_TYPE_EDGE_RISING>;
label = "lpass";
qcom,qos-config = <&glink_qos_adsp>;
qcom,ramp-time = <0xaf>;
@@ -1368,6 +1374,19 @@
<CONTROL_TCS 1>;
};
+ disp_rsc: mailbox@af20000 {
+ compatible = "qcom,tcs-drv";
+ label = "display_rsc";
+ reg = <0xaf20000 0x100>, <0xaf21c00 0x3000>;
+ interrupts = <0 129 0>;
+ #mbox-cells = <1>;
+ qcom,drv-id = <0>;
+ qcom,tcs-config = <SLEEP_TCS 1>,
+ <WAKE_TCS 1>,
+ <ACTIVE_TCS 0>,
+ <CONTROL_TCS 1>;
+ };
+
system_pm {
compatible = "qcom,system-pm";
mboxes = <&apps_rsc 0>;
@@ -1715,6 +1734,64 @@
memory-region = <&pil_mba_mem>;
};
};
+
+ qcom,venus@aae0000 {
+ compatible = "qcom,pil-tz-generic";
+ reg = <0xaae0000 0x4000>;
+
+ vdd-supply = <&venus_gdsc>;
+ qcom,proxy-reg-names = "vdd";
+
+ clocks = <&clock_videocc VIDEO_CC_VENUS_CTL_CORE_CLK>,
+ <&clock_videocc VIDEO_CC_VENUS_AHB_CLK>,
+ <&clock_videocc VIDEO_CC_VENUS_CTL_AXI_CLK>;
+ clock-names = "core_clk", "iface_clk", "bus_clk";
+ qcom,proxy-clock-names = "core_clk", "iface_clk", "bus_clk";
+
+ qcom,pas-id = <9>;
+ qcom,msm-bus,name = "pil-venus";
+ qcom,msm-bus,num-cases = <2>;
+ qcom,msm-bus,num-paths = <1>;
+ qcom,msm-bus,vectors-KBps =
+ <63 512 0 0>,
+ <63 512 0 304000>;
+ qcom,proxy-timeout-ms = <100>;
+ qcom,firmware-name = "venus";
+ memory-region = <&pil_video_mem>;
+ status = "ok";
+ };
+
+ qcom,turing@8300000 {
+ compatible = "qcom,pil-tz-generic";
+ reg = <0x8300000 0x100000>;
+ interrupts = <0 578 1>;
+
+ vdd_cx-supply = <&pm660l_s3_level>;
+ qcom,proxy-reg-names = "vdd_cx";
+ qcom,vdd_cx-uV-uA = <RPMH_REGULATOR_LEVEL_TURBO 100000>;
+
+ clocks = <&clock_rpmh RPMH_CXO_CLK>;
+ clock-names = "xo";
+ qcom,proxy-clock-names = "xo";
+
+ qcom,pas-id = <18>;
+ qcom,proxy-timeout-ms = <10000>;
+ qcom,smem-id = <601>;
+ qcom,sysmon-id = <7>;
+ qcom,ssctl-instance-id = <0x17>;
+ qcom,firmware-name = "cdsp";
+ memory-region = <&pil_cdsp_mem>;
+
+ /* GPIO inputs from turing */
+ qcom,gpio-err-fatal = <&smp2pgpio_ssr_smp2p_5_in 0 0>;
+ qcom,gpio-proxy-unvote = <&smp2pgpio_ssr_smp2p_5_in 2 0>;
+ qcom,gpio-err-ready = <&smp2pgpio_ssr_smp2p_5_in 1 0>;
+ qcom,gpio-stop-ack = <&smp2pgpio_ssr_smp2p_5_in 3 0>;
+
+ /* GPIO output to turing*/
+ qcom,gpio-force-stop = <&smp2pgpio_ssr_smp2p_5_out 0 0>;
+ status = "ok";
+ };
};
#include "sdm670-pinctrl.dtsi"
diff --git a/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-mtp.dtsi b/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-mtp.dtsi
index ab6ba18..f18137c 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-mtp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-camera-sensor-mtp.dtsi
@@ -245,7 +245,7 @@
compatible = "qcom,cam-sensor";
reg = <0x0>;
csiphy-sd-index = <0>;
- sensor-position-roll = <90>;
+ sensor-position-roll = <270>;
sensor-position-pitch = <0>;
sensor-position-yaw = <180>;
led-flash-src = <&led_flash_rear>;
diff --git a/arch/arm64/boot/dts/qcom/sdm845-camera.dtsi b/arch/arm64/boot/dts/qcom/sdm845-camera.dtsi
index cbd495a..3f19890 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-camera.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-camera.dtsi
@@ -36,9 +36,7 @@
<&clock_camcc CAM_CC_CPHY_RX_CLK_SRC>,
<&clock_camcc CAM_CC_CSIPHY0_CLK>,
<&clock_camcc CAM_CC_CSI0PHYTIMER_CLK_SRC>,
- <&clock_camcc CAM_CC_CSI0PHYTIMER_CLK>,
- <&clock_camcc CAM_CC_IFE_0_CSID_CLK>,
- <&clock_camcc CAM_CC_IFE_0_CSID_CLK_SRC>;
+ <&clock_camcc CAM_CC_CSI0PHYTIMER_CLK>;
clock-names = "camnoc_axi_clk",
"soc_ahb_clk",
"slow_ahb_src_clk",
@@ -46,12 +44,10 @@
"cphy_rx_clk_src",
"csiphy0_clk",
"csi0phytimer_clk_src",
- "csi0phytimer_clk",
- "ife_0_csid_clk",
- "ife_0_csid_clk_src";
+ "csi0phytimer_clk";
clock-cntl-level = "turbo";
clock-rates =
- <0 0 0 0 320000000 0 269333333 0 0 384000000>;
+ <0 0 0 0 320000000 0 269333333 0>;
status = "ok";
};
@@ -74,9 +70,7 @@
<&clock_camcc CAM_CC_CPHY_RX_CLK_SRC>,
<&clock_camcc CAM_CC_CSIPHY1_CLK>,
<&clock_camcc CAM_CC_CSI1PHYTIMER_CLK_SRC>,
- <&clock_camcc CAM_CC_CSI1PHYTIMER_CLK>,
- <&clock_camcc CAM_CC_IFE_1_CSID_CLK>,
- <&clock_camcc CAM_CC_IFE_1_CSID_CLK_SRC>;
+ <&clock_camcc CAM_CC_CSI1PHYTIMER_CLK>;
clock-names = "camnoc_axi_clk",
"soc_ahb_clk",
"slow_ahb_src_clk",
@@ -84,12 +78,10 @@
"cphy_rx_clk_src",
"csiphy1_clk",
"csi1phytimer_clk_src",
- "csi1phytimer_clk",
- "ife_1_csid_clk",
- "ife_1_csid_clk_src";
+ "csi1phytimer_clk";
clock-cntl-level = "turbo";
clock-rates =
- <0 0 0 0 320000000 0 269333333 0 0 384000000>;
+ <0 0 0 0 320000000 0 269333333 0>;
status = "ok";
};
@@ -113,9 +105,7 @@
<&clock_camcc CAM_CC_CPHY_RX_CLK_SRC>,
<&clock_camcc CAM_CC_CSIPHY2_CLK>,
<&clock_camcc CAM_CC_CSI2PHYTIMER_CLK_SRC>,
- <&clock_camcc CAM_CC_CSI2PHYTIMER_CLK>,
- <&clock_camcc CAM_CC_IFE_LITE_CSID_CLK>,
- <&clock_camcc CAM_CC_IFE_LITE_CSID_CLK_SRC>;
+ <&clock_camcc CAM_CC_CSI2PHYTIMER_CLK>;
clock-names = "camnoc_axi_clk",
"soc_ahb_clk",
"slow_ahb_src_clk",
@@ -123,12 +113,10 @@
"cphy_rx_clk_src",
"csiphy2_clk",
"csi2phytimer_clk_src",
- "csi2phytimer_clk",
- "ife_lite_csid_clk",
- "ife_lite_csid_clk_src";
+ "csi2phytimer_clk";
clock-cntl-level = "turbo";
clock-rates =
- <0 0 0 0 320000000 0 269333333 0 0 384000000>;
+ <0 0 0 0 320000000 0 269333333 0>;
status = "ok";
};
diff --git a/arch/arm64/boot/dts/qcom/sdm845-cdp.dtsi b/arch/arm64/boot/dts/qcom/sdm845-cdp.dtsi
index c4ec012..8fca29c 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-cdp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-cdp.dtsi
@@ -169,10 +169,6 @@
pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on>;
pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off>;
- qcom,clk-rates = <400000 20000000 25000000
- 50000000 100000000 200000000>;
- qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";
-
extcon = <&extcon_storage_cd>;
status = "ok";
diff --git a/arch/arm64/boot/dts/qcom/sdm845-mtp.dtsi b/arch/arm64/boot/dts/qcom/sdm845-mtp.dtsi
index 1453975..29d80a7 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-mtp.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-mtp.dtsi
@@ -245,10 +245,6 @@
pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on>;
pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off>;
- qcom,clk-rates = <400000 20000000 25000000
- 50000000 100000000 200000000>;
- qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";
-
extcon = <&extcon_storage_cd>;
status = "ok";
diff --git a/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi b/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi
index 2a7b6d1..04f67cd 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-pinctrl.dtsi
@@ -2667,7 +2667,7 @@
config {
pins = "gpio80","gpio79";
- bias-disable; /* No PULL */
+ bias-pull-down; /* PULL DOWN */
drive-strength = <2>; /* 2 MA */
};
};
@@ -2723,7 +2723,7 @@
config {
pins = "gpio28";
- bias-disable; /* No PULL */
+ bias-pull-down; /* PULL DOWN */
drive-strength = <2>; /* 2 MA */
};
};
@@ -2780,7 +2780,7 @@
};
config {
pins = "gpio9","gpio8";
- bias-disable; /* No PULL */
+ bias-pull-down; /* PULL DOWN */
drive-strength = <2>; /* 2 MA */
};
};
diff --git a/arch/arm64/boot/dts/qcom/sdm845-qrd.dtsi b/arch/arm64/boot/dts/qcom/sdm845-qrd.dtsi
index 9cf18b7..6bdc149 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-qrd.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-qrd.dtsi
@@ -170,10 +170,6 @@
pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on>;
pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off>;
- qcom,clk-rates = <400000 20000000 25000000
- 50000000 100000000 200000000>;
- qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";
-
extcon = <&extcon_storage_cd>;
status = "ok";
diff --git a/arch/arm64/boot/dts/qcom/sdm845-v2.dtsi b/arch/arm64/boot/dts/qcom/sdm845-v2.dtsi
index f5848c1..c20999b 100644
--- a/arch/arm64/boot/dts/qcom/sdm845-v2.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845-v2.dtsi
@@ -17,6 +17,14 @@
qcom,msm-id = <321 0x20000>;
};
+&sdhc_2 {
+ qcom,bus-bw-vectors-bps = <0 400000 20000000 25000000 50000000
+ 100000000 200000000 4294967295>;
+ qcom,clk-rates = <400000 20000000 25000000 50000000
+ 100000000 200000000>;
+ qcom,devfreq,freq-table = <50000000 200000000>;
+};
+
&clock_gcc {
compatible = "qcom,gcc-sdm845-v2";
};
diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index 11d553d..202df95 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -1676,13 +1676,18 @@
<81 512 1338562 4096000>,
<1 608 1338562 4096000>;
qcom,bus-bw-vectors-bps = <0 400000 20000000 25000000 50000000
- 100000000 200000000 4294967295>;
+ 100750000 200000000 4294967295>;
qcom,sdr104-wa;
qcom,restore-after-cx-collapse;
- qcom,devfreq,freq-table = <50000000 200000000>;
+ qcom,clk-rates = <400000 20000000 25000000
+ 50000000 100000000 201500000>;
+ qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50",
+ "SDR104";
+
+ qcom,devfreq,freq-table = <50000000 201500000>;
clocks = <&clock_gcc GCC_SDCC2_AHB_CLK>,
<&clock_gcc GCC_SDCC2_APPS_CLK>;
clock-names = "iface_clk", "core_clk";
@@ -2700,6 +2705,9 @@
<&clock_gcc GCC_CE1_AXI_CLK>;
qcom,ce-opp-freq = <171430000>;
qcom,request-bw-before-clk;
+ qcom,smmu-s1-bypass;
+ iommus = <&apps_smmu 0x702 0x1>,
+ <&apps_smmu 0x712 0x1>;
};
qcom_crypto: qcrypto@1de0000 {
@@ -2734,6 +2742,9 @@
qcom,use-sw-ahash-algo;
qcom,use-sw-aead-algo;
qcom,use-sw-hmac-algo;
+ qcom,smmu-s1-bypass;
+ iommus = <&apps_smmu 0x704 0x3>,
+ <&apps_smmu 0x714 0x3>;
};
qcom,msm_gsi {
@@ -3614,6 +3625,9 @@
&tsif0_sync_active
&tsif1_signals_active
&tsif1_sync_active>; /* dual-tsif-mode2 */
+
+ qcom,smmu-s1-bypass;
+ iommus = <&apps_smmu 0x20 0x0f>;
};
};
diff --git a/arch/arm64/configs/sdm670_defconfig b/arch/arm64/configs/sdm670_defconfig
index b8f115b..f5c62aa 100644
--- a/arch/arm64/configs/sdm670_defconfig
+++ b/arch/arm64/configs/sdm670_defconfig
@@ -512,6 +512,7 @@
CONFIG_QCOM_DCC_V2=y
CONFIG_QTI_RPM_STATS_LOG=y
CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
+CONFIG_QMP_DEBUGFS_CLIENT=y
CONFIG_QCOM_BIMC_BWMON=y
CONFIG_ARM_MEMLAT_MON=y
CONFIG_QCOMCCI_HWMON=y
diff --git a/arch/arm64/configs/sdm845-perf_defconfig b/arch/arm64/configs/sdm845-perf_defconfig
index 5872f88..f1dcb9d 100644
--- a/arch/arm64/configs/sdm845-perf_defconfig
+++ b/arch/arm64/configs/sdm845-perf_defconfig
@@ -403,6 +403,7 @@
CONFIG_USB_PD_POLICY=y
CONFIG_QPNP_USB_PDPHY=y
CONFIG_USB_EHSET_TEST_FIXTURE=y
+CONFIG_USB_LINK_LAYER_TEST=y
CONFIG_NOP_USB_XCEIV=y
CONFIG_DUAL_ROLE_USB_INTF=y
CONFIG_USB_MSM_SSPHY_QMP=y
@@ -513,6 +514,7 @@
CONFIG_MSM_GLINK_PKT=y
CONFIG_MSM_SUBSYSTEM_RESTART=y
CONFIG_MSM_PIL=y
+CONFIG_MSM_SYSMON_GLINK_COMM=y
CONFIG_MSM_PIL_SSR_GENERIC=y
CONFIG_MSM_PIL_MSS_QDSP6V5=y
CONFIG_ICNSS=y
@@ -528,6 +530,7 @@
CONFIG_APSS_CORE_EA=y
CONFIG_QTI_RPM_STATS_LOG=y
CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
+CONFIG_QMP_DEBUGFS_CLIENT=y
CONFIG_QCOM_BIMC_BWMON=y
CONFIG_ARM_MEMLAT_MON=y
CONFIG_QCOMCCI_HWMON=y
diff --git a/arch/arm64/configs/sdm845_defconfig b/arch/arm64/configs/sdm845_defconfig
index 82455e5..3aefe13 100644
--- a/arch/arm64/configs/sdm845_defconfig
+++ b/arch/arm64/configs/sdm845_defconfig
@@ -407,6 +407,7 @@
CONFIG_USB_PD_POLICY=y
CONFIG_QPNP_USB_PDPHY=y
CONFIG_USB_EHSET_TEST_FIXTURE=y
+CONFIG_USB_LINK_LAYER_TEST=y
CONFIG_NOP_USB_XCEIV=y
CONFIG_DUAL_ROLE_USB_INTF=y
CONFIG_USB_MSM_SSPHY_QMP=y
@@ -530,6 +531,7 @@
CONFIG_MSM_GLINK_PKT=y
CONFIG_MSM_SUBSYSTEM_RESTART=y
CONFIG_MSM_PIL=y
+CONFIG_MSM_SYSMON_GLINK_COMM=y
CONFIG_MSM_PIL_SSR_GENERIC=y
CONFIG_MSM_PIL_MSS_QDSP6V5=y
CONFIG_ICNSS=y
@@ -547,6 +549,7 @@
CONFIG_QCOM_DCC_V2=y
CONFIG_QTI_RPM_STATS_LOG=y
CONFIG_QCOM_FORCE_WDOG_BITE_ON_PANIC=y
+CONFIG_QMP_DEBUGFS_CLIENT=y
CONFIG_QCOM_BIMC_BWMON=y
CONFIG_ARM_MEMLAT_MON=y
CONFIG_QCOMCCI_HWMON=y
diff --git a/drivers/char/diag/diagchar.h b/drivers/char/diag/diagchar.h
index 26e91f9..8051d5d 100644
--- a/drivers/char/diag/diagchar.h
+++ b/drivers/char/diag/diagchar.h
@@ -580,6 +580,7 @@ struct diagchar_dev {
unsigned char *buf_feature_mask_update;
uint8_t hdlc_disabled;
struct mutex hdlc_disable_mutex;
+ struct mutex hdlc_recovery_mutex;
struct timer_list hdlc_reset_timer;
struct mutex diag_hdlc_mutex;
unsigned char *hdlc_buf;
diff --git a/drivers/char/diag/diagchar_core.c b/drivers/char/diag/diagchar_core.c
index 5b507df..e4397c5 100644
--- a/drivers/char/diag/diagchar_core.c
+++ b/drivers/char/diag/diagchar_core.c
@@ -975,14 +975,34 @@ static int diag_send_raw_data_remote(int proc, void *buf, int len,
else
hdlc_disabled = driver->hdlc_disabled;
if (hdlc_disabled) {
+ if (len < 4) {
+ pr_err("diag: In %s, invalid len: %d of non_hdlc pkt",
+ __func__, len);
+ return -EBADMSG;
+ }
payload = *(uint16_t *)(buf + 2);
+ if (payload > DIAG_MAX_HDLC_BUF_SIZE) {
+ pr_err("diag: Dropping packet, payload size is %d\n",
+ payload);
+ return -EBADMSG;
+ }
driver->hdlc_encode_buf_len = payload;
/*
- * Adding 4 bytes for start (1 byte), version (1 byte) and
- * payload (2 bytes)
+ * Adding 5 bytes for start (1 byte), version (1 byte),
+ * payload (2 bytes) and end (1 byte)
*/
- memcpy(driver->hdlc_encode_buf, buf + 4, payload);
- goto send_data;
+ if (len == (payload + 5)) {
+ /*
+ * Adding 4 bytes for start (1 byte), version (1 byte)
+ * and payload (2 bytes)
+ */
+ memcpy(driver->hdlc_encode_buf, buf + 4, payload);
+ goto send_data;
+ } else {
+ pr_err("diag: In %s, invalid len: %d of non_hdlc pkt",
+ __func__, len);
+ return -EBADMSG;
+ }
}
if (hdlc_flag) {
@@ -3468,6 +3488,7 @@ static int __init diagchar_init(void)
mutex_init(&driver->delayed_rsp_mutex);
mutex_init(&apps_data_mutex);
mutex_init(&driver->msg_mask_lock);
+ mutex_init(&driver->hdlc_recovery_mutex);
for (i = 0; i < NUM_PERIPHERALS; i++)
mutex_init(&driver->diagfwd_channel_mutex[i]);
init_waitqueue_head(&driver->wait_q);
diff --git a/drivers/char/diag/diagfwd.c b/drivers/char/diag/diagfwd.c
index cd49f00..3f00a7e 100644
--- a/drivers/char/diag/diagfwd.c
+++ b/drivers/char/diag/diagfwd.c
@@ -1443,7 +1443,9 @@ static void diag_hdlc_start_recovery(unsigned char *buf, int len,
if (start_ptr) {
/* Discard any partial packet reads */
+ mutex_lock(&driver->hdlc_recovery_mutex);
driver->incoming_pkt.processing = 0;
+ mutex_unlock(&driver->hdlc_recovery_mutex);
diag_process_non_hdlc_pkt(start_ptr, len - i, info);
}
}
@@ -1457,18 +1459,24 @@ void diag_process_non_hdlc_pkt(unsigned char *buf, int len,
const uint32_t header_len = sizeof(struct diag_pkt_frame_t);
struct diag_pkt_frame_t *actual_pkt = NULL;
unsigned char *data_ptr = NULL;
- struct diag_partial_pkt_t *partial_pkt = &driver->incoming_pkt;
+ struct diag_partial_pkt_t *partial_pkt = NULL;
- if (!buf || len <= 0)
+ mutex_lock(&driver->hdlc_recovery_mutex);
+ if (!buf || len <= 0) {
+ mutex_unlock(&driver->hdlc_recovery_mutex);
return;
-
- if (!partial_pkt->processing)
+ }
+ partial_pkt = &driver->incoming_pkt;
+ if (!partial_pkt->processing) {
+ mutex_unlock(&driver->hdlc_recovery_mutex);
goto start;
+ }
if (partial_pkt->remaining > len) {
if ((partial_pkt->read_len + len) > partial_pkt->capacity) {
pr_err("diag: Invalid length %d, %d received in %s\n",
partial_pkt->read_len, len, __func__);
+ mutex_unlock(&driver->hdlc_recovery_mutex);
goto end;
}
memcpy(partial_pkt->data + partial_pkt->read_len, buf, len);
@@ -1482,6 +1490,7 @@ void diag_process_non_hdlc_pkt(unsigned char *buf, int len,
pr_err("diag: Invalid length during partial read %d, %d received in %s\n",
partial_pkt->read_len,
partial_pkt->remaining, __func__);
+ mutex_unlock(&driver->hdlc_recovery_mutex);
goto end;
}
memcpy(partial_pkt->data + partial_pkt->read_len, buf,
@@ -1495,20 +1504,27 @@ void diag_process_non_hdlc_pkt(unsigned char *buf, int len,
if (partial_pkt->remaining == 0) {
actual_pkt = (struct diag_pkt_frame_t *)(partial_pkt->data);
data_ptr = partial_pkt->data + header_len;
- if (*(uint8_t *)(data_ptr + actual_pkt->length) != CONTROL_CHAR)
+ if (*(uint8_t *)(data_ptr + actual_pkt->length) !=
+ CONTROL_CHAR) {
+ mutex_unlock(&driver->hdlc_recovery_mutex);
diag_hdlc_start_recovery(buf, len, info);
+ mutex_lock(&driver->hdlc_recovery_mutex);
+ }
err = diag_process_apps_pkt(data_ptr,
actual_pkt->length, info);
if (err) {
pr_err("diag: In %s, unable to process incoming data packet, err: %d\n",
__func__, err);
+ mutex_unlock(&driver->hdlc_recovery_mutex);
goto end;
}
partial_pkt->read_len = 0;
partial_pkt->total_len = 0;
partial_pkt->processing = 0;
+ mutex_unlock(&driver->hdlc_recovery_mutex);
goto start;
}
+ mutex_unlock(&driver->hdlc_recovery_mutex);
goto end;
start:
@@ -1521,14 +1537,14 @@ void diag_process_non_hdlc_pkt(unsigned char *buf, int len,
diag_send_error_rsp(buf, len);
goto end;
}
-
+ mutex_lock(&driver->hdlc_recovery_mutex);
if (pkt_len + header_len > partial_pkt->capacity) {
pr_err("diag: In %s, incoming data is too large for the request buffer %d\n",
__func__, pkt_len);
+ mutex_unlock(&driver->hdlc_recovery_mutex);
diag_hdlc_start_recovery(buf, len, info);
break;
}
-
if ((pkt_len + header_len) > (len - read_bytes)) {
partial_pkt->read_len = len - read_bytes;
partial_pkt->total_len = pkt_len + header_len;
@@ -1536,19 +1552,27 @@ void diag_process_non_hdlc_pkt(unsigned char *buf, int len,
partial_pkt->read_len;
partial_pkt->processing = 1;
memcpy(partial_pkt->data, buf, partial_pkt->read_len);
+ mutex_unlock(&driver->hdlc_recovery_mutex);
break;
}
data_ptr = buf + header_len;
- if (*(uint8_t *)(data_ptr + actual_pkt->length) != CONTROL_CHAR)
+ if (*(uint8_t *)(data_ptr + actual_pkt->length) !=
+ CONTROL_CHAR) {
+ mutex_unlock(&driver->hdlc_recovery_mutex);
diag_hdlc_start_recovery(buf, len, info);
+ mutex_lock(&driver->hdlc_recovery_mutex);
+ }
else
hdlc_reset = 0;
err = diag_process_apps_pkt(data_ptr,
actual_pkt->length, info);
- if (err)
+ if (err) {
+ mutex_unlock(&driver->hdlc_recovery_mutex);
break;
+ }
read_bytes += header_len + pkt_len + 1;
buf += header_len + pkt_len + 1; /* advance to next pkt */
+ mutex_unlock(&driver->hdlc_recovery_mutex);
}
end:
return;
diff --git a/drivers/char/diag/diagfwd_cntl.c b/drivers/char/diag/diagfwd_cntl.c
index c975654..5282e02 100644
--- a/drivers/char/diag/diagfwd_cntl.c
+++ b/drivers/char/diag/diagfwd_cntl.c
@@ -68,7 +68,6 @@ void diag_cntl_channel_close(struct diagfwd_info *p_info)
driver->feature[peripheral].sent_feature_mask = 0;
driver->feature[peripheral].rcvd_feature_mask = 0;
- flush_workqueue(driver->cntl_wq);
reg_dirty |= PERIPHERAL_MASK(peripheral);
diag_cmd_remove_reg_by_proc(peripheral);
driver->feature[peripheral].stm_support = DISABLE_STM;
diff --git a/drivers/char/diag/diagfwd_glink.c b/drivers/char/diag/diagfwd_glink.c
index 6476684..e9683e0 100644
--- a/drivers/char/diag/diagfwd_glink.c
+++ b/drivers/char/diag/diagfwd_glink.c
@@ -375,8 +375,10 @@ static void diag_glink_notify_rx_work_fn(struct work_struct *work)
struct diag_glink_read_work, work);
struct diag_glink_info *glink_info = read_work->glink_info;
- if (!glink_info || !glink_info->hdl)
+ if (!glink_info || !glink_info->hdl) {
+ kfree(read_work);
return;
+ }
diagfwd_channel_read_done(glink_info->fwd_ctxt,
(unsigned char *)(read_work->ptr_read_done),
@@ -388,6 +390,7 @@ static void diag_glink_notify_rx_work_fn(struct work_struct *work)
"diag: Rx done for packet %pK of len: %d periph: %d ch: %d\n",
read_work->ptr_rx_done, (int)read_work->ptr_read_size,
glink_info->peripheral, glink_info->type);
+ kfree(read_work);
}
static void diag_glink_notify_rx(void *hdl, const void *priv,
@@ -411,6 +414,7 @@ static void diag_glink_notify_rx(void *hdl, const void *priv,
if (!read_work) {
DIAG_LOG(DIAG_DEBUG_PERIPHERALS,
"diag: Could not allocate read_work\n");
+ glink_rx_done(glink_info->hdl, ptr, true);
return;
}
diff --git a/drivers/char/diag/diagfwd_peripheral.c b/drivers/char/diag/diagfwd_peripheral.c
index 3b8203f..dd5a552 100644
--- a/drivers/char/diag/diagfwd_peripheral.c
+++ b/drivers/char/diag/diagfwd_peripheral.c
@@ -897,6 +897,9 @@ int diagfwd_channel_close(struct diagfwd_info *fwd_info)
if (!fwd_info)
return -EIO;
+ if (fwd_info->type == TYPE_CNTL)
+ flush_workqueue(driver->cntl_wq);
+
mutex_lock(&driver->diagfwd_channel_mutex[fwd_info->peripheral]);
fwd_info->ch_open = 0;
if (fwd_info && fwd_info->c_ops && fwd_info->c_ops->close)
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index bb7c862..3e13186 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -283,10 +283,14 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
const struct clk_div_table *table, u8 width,
unsigned long flags)
{
+ struct clk_hw *parent = clk_hw_get_parent(hw);
int i, bestdiv = 0;
unsigned long parent_rate, best = 0, now, maxdiv;
unsigned long parent_rate_saved = *best_parent_rate;
+ if (!parent)
+ return -EINVAL;
+
if (!rate)
rate = 1;
@@ -317,8 +321,7 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
*best_parent_rate = parent_rate_saved;
return i;
}
- parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw),
- rate * i);
+ parent_rate = clk_hw_round_rate(parent, rate * i);
now = DIV_ROUND_UP_ULL((u64)parent_rate, i);
if (_is_best_div(rate, now, best, flags)) {
bestdiv = i;
@@ -329,7 +332,7 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
if (!bestdiv) {
bestdiv = _get_maxdiv(table, width, flags);
- *best_parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw), 1);
+ *best_parent_rate = clk_hw_round_rate(parent, 1);
}
return bestdiv;
diff --git a/drivers/clk/qcom/clk-branch.c b/drivers/clk/qcom/clk-branch.c
index 46ced08..fa0ca36 100644
--- a/drivers/clk/qcom/clk-branch.c
+++ b/drivers/clk/qcom/clk-branch.c
@@ -287,20 +287,30 @@ static int clk_branch2_enable(struct clk_hw *hw)
static int clk_branch2_prepare(struct clk_hw *hw)
{
- struct clk_branch *branch = to_clk_branch(hw);
- struct clk_hw *parent = clk_hw_get_parent(hw);
- unsigned long curr_rate, branch_rate = branch->rate;
+ struct clk_branch *branch;
+ struct clk_hw *parent;
+ unsigned long curr_rate;
int ret = 0;
+ if (!hw)
+ return -EINVAL;
+
+ branch = to_clk_branch(hw);
+ parent = clk_hw_get_parent(hw);
+ if (!branch)
+ return -EINVAL;
+
/*
* Do the rate aggregation and scaling of the RCG in the prepare/
* unprepare functions to avoid potential RPM(/h) communication due to
* votes on the voltage rails.
*/
if (branch->aggr_sibling_rates) {
+ if (!parent)
+ return -EINVAL;
curr_rate = clk_aggregate_rate(hw, parent->core);
- if (branch_rate > curr_rate) {
- ret = clk_set_rate(parent->clk, branch_rate);
+ if (branch->rate > curr_rate) {
+ ret = clk_set_rate(parent->clk, branch->rate);
if (ret)
goto exit;
}
@@ -316,13 +326,23 @@ static void clk_branch2_disable(struct clk_hw *hw)
static void clk_branch2_unprepare(struct clk_hw *hw)
{
- struct clk_branch *branch = to_clk_branch(hw);
- struct clk_hw *parent = clk_hw_get_parent(hw);
- unsigned long curr_rate, new_rate, branch_rate = branch->rate;
+ struct clk_branch *branch;
+ struct clk_hw *parent;
+ unsigned long curr_rate, new_rate;
+
+ if (!hw)
+ return;
+
+ branch = to_clk_branch(hw);
+ parent = clk_hw_get_parent(hw);
+ if (!branch)
+ return;
if (branch->aggr_sibling_rates) {
+ if (!parent)
+ return;
new_rate = clk_aggregate_rate(hw, parent->core);
- curr_rate = max(new_rate, branch_rate);
+ curr_rate = max(new_rate, branch->rate);
if (new_rate < curr_rate)
if (clk_set_rate(parent->clk, new_rate))
pr_err("Failed to scale %s to %lu\n",
diff --git a/drivers/clk/qcom/clk-cpu-osm.c b/drivers/clk/qcom/clk-cpu-osm.c
index 1d63a86..47e9fab 100644
--- a/drivers/clk/qcom/clk-cpu-osm.c
+++ b/drivers/clk/qcom/clk-cpu-osm.c
@@ -518,6 +518,9 @@ static long clk_osm_round_rate(struct clk_hw *hw, unsigned long rate,
int i;
unsigned long rrate = 0;
+ if (!hw)
+ return -EINVAL;
+
/*
* If the rate passed in is 0, return the first frequency in the
* FMAX table.
@@ -3018,6 +3021,14 @@ static int clk_cpu_osm_driver_probe(struct platform_device *pdev)
clk_data->clk_num = num_clks;
+ rc = clk_osm_resources_init(pdev);
+ if (rc) {
+ if (rc != -EPROBE_DEFER)
+ dev_err(&pdev->dev, "OSM resources init failed, rc=%d\n",
+ rc);
+ return rc;
+ }
+
if (l3_clk.vbases[EFUSE_BASE]) {
/* Multiple speed-bins are supported */
pte_efuse = readl_relaxed(l3_clk.vbases[EFUSE_BASE]);
@@ -3089,14 +3100,6 @@ static int clk_cpu_osm_driver_probe(struct platform_device *pdev)
return rc;
}
- rc = clk_osm_resources_init(pdev);
- if (rc) {
- if (rc != -EPROBE_DEFER)
- dev_err(&pdev->dev, "OSM resources init failed, rc=%d\n",
- rc);
- return rc;
- }
-
rc = clk_osm_acd_resources_init(pdev);
if (rc) {
dev_err(&pdev->dev, "ACD resources init failed, rc=%d\n",
diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
index b63c3c3..dd69b31 100644
--- a/drivers/clk/qcom/clk-rcg2.c
+++ b/drivers/clk/qcom/clk-rcg2.c
@@ -934,10 +934,11 @@ const struct clk_ops clk_byte2_ops = {
EXPORT_SYMBOL_GPL(clk_byte2_ops);
static const struct frac_entry frac_table_pixel[] = {
+ { 1, 1 },
+ { 2, 3 },
+ { 4, 9 },
{ 3, 8 },
{ 2, 9 },
- { 4, 9 },
- { 1, 1 },
{ }
};
@@ -1028,6 +1029,7 @@ static int clk_dp_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct clk_rcg2 *rcg = to_clk_rcg2(hw);
+ struct clk_hw *parent = clk_hw_get_parent(hw);
struct freq_tbl f = { 0 };
unsigned long src_rate;
unsigned long num, den;
@@ -1035,7 +1037,12 @@ static int clk_dp_set_rate(struct clk_hw *hw, unsigned long rate,
u32 hid_div, cfg;
int i, num_parents = clk_hw_get_num_parents(hw);
- src_rate = clk_get_rate(clk_hw_get_parent(hw)->clk);
+ if (!parent) {
+ pr_err("RCG parent isn't initialized\n");
+ return -EINVAL;
+ }
+
+ src_rate = clk_get_rate(parent->clk);
if (src_rate <= 0) {
pr_err("Invalid RCG parent rate\n");
return -EINVAL;
@@ -1196,13 +1203,15 @@ static u8 clk_parent_index_pre_div_and_mode(struct clk_hw *hw, u32 offset,
u32 *mode, u32 *pre_div)
{
struct clk_rcg2 *rcg;
- int num_parents = clk_hw_get_num_parents(hw);
+ int num_parents;
u32 cfg, mask;
int i, ret;
if (!hw)
return -EINVAL;
+ num_parents = clk_hw_get_num_parents(hw);
+
rcg = to_clk_rcg2(hw);
ret = regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + offset, &cfg);
diff --git a/drivers/clk/qcom/clk-regmap.c b/drivers/clk/qcom/clk-regmap.c
index 1c856d3..aa024c2d 100644
--- a/drivers/clk/qcom/clk-regmap.c
+++ b/drivers/clk/qcom/clk-regmap.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014, 2017, The Linux Foundation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -103,9 +103,12 @@ EXPORT_SYMBOL_GPL(clk_disable_regmap);
*/
int devm_clk_register_regmap(struct device *dev, struct clk_regmap *rclk)
{
- if (dev && dev_get_regmap(dev, NULL))
+ if (!dev || !rclk)
+ return -EINVAL;
+
+ if (dev_get_regmap(dev, NULL))
rclk->regmap = dev_get_regmap(dev, NULL);
- else if (dev && dev->parent)
+ else if (dev->parent)
rclk->regmap = dev_get_regmap(dev->parent, NULL);
return devm_clk_hw_register(dev, &rclk->hw);
diff --git a/drivers/clk/qcom/gcc-sdm845.c b/drivers/clk/qcom/gcc-sdm845.c
index 1450b91..4e16155 100644
--- a/drivers/clk/qcom/gcc-sdm845.c
+++ b/drivers/clk/qcom/gcc-sdm845.c
@@ -182,6 +182,22 @@ static const char * const gcc_parent_names_9[] = {
"core_bi_pll_test_se",
};
+static const struct parent_map gcc_parent_map_10[] = {
+ { P_BI_TCXO, 0 },
+ { P_GPLL0_OUT_MAIN, 1 },
+ { P_GPLL4_OUT_MAIN, 5 },
+ { P_GPLL0_OUT_EVEN, 6 },
+ { P_CORE_BI_PLL_TEST_SE, 7 },
+};
+
+static const char * const gcc_parent_names_10[] = {
+ "bi_tcxo",
+ "gpll0",
+ "gpll4",
+ "gpll0_out_even",
+ "core_bi_pll_test_se",
+};
+
static struct clk_dummy measure_only_snoc_clk = {
.rrate = 1000,
.hw.init = &(struct clk_init_data){
@@ -241,6 +257,28 @@ static struct clk_alpha_pll gpll0 = {
},
};
+static struct clk_alpha_pll gpll4 = {
+ .offset = 0x76000,
+ .vco_table = fabia_vco,
+ .num_vco = ARRAY_SIZE(fabia_vco),
+ .type = FABIA_PLL,
+ .clkr = {
+ .enable_reg = 0x52000,
+ .enable_mask = BIT(4),
+ .hw.init = &(struct clk_init_data){
+ .name = "gpll4",
+ .parent_names = (const char *[]){ "bi_tcxo" },
+ .num_parents = 1,
+ .ops = &clk_fabia_fixed_pll_ops,
+ VDD_CX_FMAX_MAP4(
+ MIN, 615000000,
+ LOW, 1066000000,
+ LOW_L1, 1600000000,
+ NOMINAL, 2000000000),
+ },
+ },
+};
+
static const struct clk_div_table post_div_table_fabia_even[] = {
{ 0x0, 1 },
{ 0x1, 2 },
@@ -476,6 +514,7 @@ static const struct freq_tbl ftbl_gcc_qupv3_wrap0_s0_clk_src[] = {
F(19200000, P_BI_TCXO, 1, 0, 0),
F(29491200, P_GPLL0_OUT_EVEN, 1, 1536, 15625),
F(32000000, P_GPLL0_OUT_EVEN, 1, 8, 75),
+ F(38400000, P_GPLL0_OUT_EVEN, 1, 16, 125),
F(48000000, P_GPLL0_OUT_EVEN, 1, 4, 25),
F(64000000, P_GPLL0_OUT_EVEN, 1, 16, 75),
F(80000000, P_GPLL0_OUT_EVEN, 1, 4, 15),
@@ -830,6 +869,17 @@ static const struct freq_tbl ftbl_gcc_sdcc2_apps_clk_src[] = {
F(25000000, P_GPLL0_OUT_EVEN, 12, 0, 0),
F(50000000, P_GPLL0_OUT_EVEN, 6, 0, 0),
F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0),
+ F(201500000, P_GPLL4_OUT_MAIN, 4, 0, 0),
+ { }
+};
+
+static const struct freq_tbl ftbl_gcc_sdcc2_apps_clk_src_sdm845_v2[] = {
+ F(400000, P_BI_TCXO, 12, 1, 4),
+ F(9600000, P_BI_TCXO, 2, 0, 0),
+ F(19200000, P_BI_TCXO, 1, 0, 0),
+ F(25000000, P_GPLL0_OUT_EVEN, 12, 0, 0),
+ F(50000000, P_GPLL0_OUT_EVEN, 6, 0, 0),
+ F(100000000, P_GPLL0_OUT_MAIN, 6, 0, 0),
F(200000000, P_GPLL0_OUT_MAIN, 3, 0, 0),
{ }
};
@@ -838,12 +888,12 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = {
.cmd_rcgr = 0x1400c,
.mnd_width = 8,
.hid_width = 5,
- .parent_map = gcc_parent_map_5,
+ .parent_map = gcc_parent_map_10,
.freq_tbl = ftbl_gcc_sdcc2_apps_clk_src,
.enable_safe_config = true,
.clkr.hw.init = &(struct clk_init_data){
.name = "gcc_sdcc2_apps_clk_src",
- .parent_names = gcc_parent_names_5,
+ .parent_names = gcc_parent_names_10,
.num_parents = 5,
.flags = CLK_SET_RATE_PARENT,
.ops = &clk_rcg2_ops,
@@ -851,7 +901,7 @@ static struct clk_rcg2 gcc_sdcc2_apps_clk_src = {
MIN, 9600000,
LOWER, 19200000,
LOW, 100000000,
- LOW_L1, 200000000),
+ LOW_L1, 201500000),
},
};
@@ -3775,6 +3825,7 @@ static struct clk_regmap *gcc_sdm845_clocks[] = {
[GCC_VSENSOR_CLK_SRC] = &gcc_vsensor_clk_src.clkr,
[GPLL0] = &gpll0.clkr,
[GPLL0_OUT_EVEN] = &gpll0_out_even.clkr,
+ [GPLL4] = &gpll4.clkr,
};
static const struct qcom_reset_map gcc_sdm845_resets[] = {
@@ -3952,6 +4003,9 @@ static void gcc_sdm845_fixup_sdm845v2(void)
50000000;
gcc_qupv3_wrap1_s7_clk_src.clkr.hw.init->rate_max[VDD_CX_NOMINAL] =
128000000;
+ gcc_sdcc2_apps_clk_src.freq_tbl = ftbl_gcc_sdcc2_apps_clk_src_sdm845_v2;
+ gcc_sdcc2_apps_clk_src.clkr.hw.init->rate_max[VDD_CX_LOW_L1] =
+ 200000000;
gcc_ufs_card_axi_clk_src.freq_tbl =
ftbl_gcc_ufs_card_axi_clk_src_sdm845_v2;
gcc_ufs_card_axi_clk_src.clkr.hw.init->rate_max[VDD_CX_HIGH] =
diff --git a/drivers/clk/qcom/mdss/mdss-dsi-pll-10nm.c b/drivers/clk/qcom/mdss/mdss-dsi-pll-10nm.c
index 93ad1b0..eb6c658 100644
--- a/drivers/clk/qcom/mdss/mdss-dsi-pll-10nm.c
+++ b/drivers/clk/qcom/mdss/mdss-dsi-pll-10nm.c
@@ -94,7 +94,6 @@ enum {
struct dsi_pll_regs {
u32 pll_prop_gain_rate;
- u32 pll_outdiv_rate;
u32 pll_lockdet_rate;
u32 decimal_div_start;
u32 frac_div_start_low;
@@ -134,6 +133,165 @@ struct dsi_pll_10nm {
struct dsi_pll_regs reg_setup;
};
+static inline int pll_reg_read(void *context, unsigned int reg,
+ unsigned int *val)
+{
+ int rc = 0;
+ struct mdss_pll_resources *rsc = context;
+
+ rc = mdss_pll_resource_enable(rsc, true);
+ if (rc) {
+ pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
+ return rc;
+ }
+
+ *val = MDSS_PLL_REG_R(rsc->pll_base, reg);
+ (void)mdss_pll_resource_enable(rsc, false);
+
+ return rc;
+}
+
+static inline int pll_reg_write(void *context, unsigned int reg,
+ unsigned int val)
+{
+ int rc = 0;
+ struct mdss_pll_resources *rsc = context;
+
+ rc = mdss_pll_resource_enable(rsc, true);
+ if (rc) {
+ pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
+ return rc;
+ }
+
+ MDSS_PLL_REG_W(rsc->pll_base, reg, val);
+ (void)mdss_pll_resource_enable(rsc, false);
+
+ return rc;
+}
+
+static inline int phy_reg_read(void *context, unsigned int reg,
+ unsigned int *val)
+{
+ int rc = 0;
+ struct mdss_pll_resources *rsc = context;
+
+ rc = mdss_pll_resource_enable(rsc, true);
+ if (rc) {
+ pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
+ return rc;
+ }
+
+ *val = MDSS_PLL_REG_R(rsc->phy_base, reg);
+ (void)mdss_pll_resource_enable(rsc, false);
+
+ return rc;
+}
+
+static inline int phy_reg_write(void *context, unsigned int reg,
+ unsigned int val)
+{
+ int rc = 0;
+ struct mdss_pll_resources *rsc = context;
+
+ rc = mdss_pll_resource_enable(rsc, true);
+ if (rc) {
+ pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
+ return rc;
+ }
+
+ MDSS_PLL_REG_W(rsc->phy_base, reg, val);
+ (void)mdss_pll_resource_enable(rsc, false);
+
+ return rc;
+}
+
+static inline int phy_reg_update_bits_sub(struct mdss_pll_resources *rsc,
+ unsigned int reg, unsigned int mask, unsigned int val)
+{
+ u32 reg_val;
+ int rc = 0;
+
+ reg_val = MDSS_PLL_REG_R(rsc->phy_base, reg);
+ reg_val &= ~mask;
+ reg_val |= (val & mask);
+ MDSS_PLL_REG_W(rsc->phy_base, reg, reg_val);
+
+ return rc;
+}
+
+static inline int phy_reg_update_bits(void *context, unsigned int reg,
+ unsigned int mask, unsigned int val)
+{
+ int rc = 0;
+ struct mdss_pll_resources *rsc = context;
+
+ rc = mdss_pll_resource_enable(rsc, true);
+ if (rc) {
+ pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
+ return rc;
+ }
+
+ rc = phy_reg_update_bits_sub(rsc, reg, mask, val);
+ if (!rc && rsc->slave)
+ rc = phy_reg_update_bits_sub(rsc->slave, reg, mask, val);
+ (void)mdss_pll_resource_enable(rsc, false);
+
+ return rc;
+}
+
+static inline int pclk_mux_read_sel(void *context, unsigned int reg,
+ unsigned int *val)
+{
+ int rc = 0;
+ struct mdss_pll_resources *rsc = context;
+
+ rc = mdss_pll_resource_enable(rsc, true);
+ if (rc)
+ pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
+ else
+ *val = (MDSS_PLL_REG_R(rsc->pll_base, reg) & 0x3);
+
+ (void)mdss_pll_resource_enable(rsc, false);
+ return rc;
+}
+
+
+static inline int pclk_mux_write_sel_sub(struct mdss_pll_resources *rsc,
+ unsigned int reg, unsigned int val)
+{
+ u32 reg_val;
+ int rc = 0;
+
+ reg_val = MDSS_PLL_REG_R(rsc->phy_base, reg);
+ reg_val &= ~0x03;
+ reg_val |= val;
+
+ MDSS_PLL_REG_W(rsc->phy_base, reg, reg_val);
+
+ return rc;
+}
+
+static inline int pclk_mux_write_sel(void *context, unsigned int reg,
+ unsigned int val)
+{
+ int rc = 0;
+ struct mdss_pll_resources *rsc = context;
+
+ rc = mdss_pll_resource_enable(rsc, true);
+ if (rc) {
+ pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
+ return rc;
+ }
+
+ rc = pclk_mux_write_sel_sub(rsc, reg, val);
+ if (!rc && rsc->slave)
+ rc = pclk_mux_write_sel_sub(rsc->slave, reg, val);
+
+ (void)mdss_pll_resource_enable(rsc, false);
+
+ return rc;
+}
+
static struct mdss_pll_resources *pll_rsc_db[DSI_PLL_MAX];
static struct dsi_pll_10nm plls[DSI_PLL_MAX];
@@ -203,54 +361,14 @@ static void dsi_pll_calc_dec_frac(struct dsi_pll_10nm *pll,
{
struct dsi_pll_config *config = &pll->pll_configuration;
struct dsi_pll_regs *regs = &pll->reg_setup;
- u64 target_freq;
u64 fref = rsc->vco_ref_clk_rate;
- u32 computed_output_div, div_log = 0;
u64 pll_freq;
u64 divider;
u64 dec, dec_multiple;
u32 frac;
u64 multiplier;
- u32 i;
- target_freq = rsc->vco_current_rate;
- pr_debug("target_freq = %llu\n", target_freq);
-
- if (config->div_override) {
- computed_output_div = config->output_div;
-
- /*
- * Computed_output_div = 2 ^ div_log
- * To get div_log from output div just get the index of the
- * 1 bit in the value.
- * div_log ranges from 0-3. so check the 4 lsbs
- */
-
- for (i = 0; i < 4; i++) {
- if (computed_output_div & (1 << i)) {
- div_log = i;
- break;
- }
- }
-
- } else {
- if (target_freq < MHZ_250) {
- computed_output_div = 8;
- div_log = 3;
- } else if (target_freq < MHZ_500) {
- computed_output_div = 4;
- div_log = 2;
- } else if (target_freq < MHZ_1000) {
- computed_output_div = 2;
- div_log = 1;
- } else {
- computed_output_div = 1;
- div_log = 0;
- }
- }
- pr_debug("computed_output_div = %d\n", computed_output_div);
-
- pll_freq = target_freq * computed_output_div;
+ pll_freq = rsc->vco_current_rate;
if (config->disable_prescaler)
divider = fref;
@@ -274,7 +392,6 @@ static void dsi_pll_calc_dec_frac(struct dsi_pll_10nm *pll,
else
regs->pll_clock_inverters = 0;
- regs->pll_outdiv_rate = div_log;
regs->pll_lockdet_rate = config->lock_timer;
regs->decimal_div_start = dec;
regs->frac_div_start_low = (frac & 0xff);
@@ -394,7 +511,6 @@ static void dsi_pll_commit(struct dsi_pll_10nm *pll,
MDSS_PLL_REG_W(pll_base, PLL_FRAC_DIV_START_HIGH_1,
reg->frac_div_start_high);
MDSS_PLL_REG_W(pll_base, PLL_PLL_LOCKDET_RATE_1, 0x40);
- MDSS_PLL_REG_W(pll_base, PLL_PLL_OUTDIV_RATE, reg->pll_outdiv_rate);
MDSS_PLL_REG_W(pll_base, PLL_PLL_LOCK_DELAY, 0x06);
MDSS_PLL_REG_W(pll_base, PLL_CMODE, 0x10);
MDSS_PLL_REG_W(pll_base, PLL_CLOCK_INVERTERS, reg->pll_clock_inverters);
@@ -605,7 +721,9 @@ static void vco_10nm_unprepare(struct clk_hw *hw)
}
pll->cached_cfg0 = MDSS_PLL_REG_R(pll->phy_base, PHY_CMN_CLK_CFG0);
pll->cached_cfg1 = MDSS_PLL_REG_R(pll->phy_base, PHY_CMN_CLK_CFG1);
- pr_debug("cfg0=%d,cfg1=%d\n", pll->cached_cfg0, pll->cached_cfg1);
+ pll->cached_outdiv = MDSS_PLL_REG_R(pll->pll_base, PLL_PLL_OUTDIV_RATE);
+ pr_debug("cfg0=%d,cfg1=%d, outdiv=%d\n", pll->cached_cfg0,
+ pll->cached_cfg1, pll->cached_outdiv);
pll->vco_cached_rate = clk_hw_get_rate(hw);
dsi_pll_disable(vco);
@@ -646,6 +764,8 @@ static int vco_10nm_prepare(struct clk_hw *hw)
pll->cached_cfg0);
MDSS_PLL_REG_W(pll->phy_base, PHY_CMN_CLK_CFG1,
pll->cached_cfg1);
+ MDSS_PLL_REG_W(pll->pll_base, PLL_PLL_OUTDIV_RATE,
+ pll->cached_outdiv);
}
rc = dsi_pll_enable(vco);
@@ -855,176 +975,6 @@ static int bit_clk_set_div(void *context, unsigned int reg, unsigned int div)
return rc;
}
-static int post_vco_clk_get_div(void *context, unsigned int reg,
- unsigned int *div)
-{
- int rc;
- struct mdss_pll_resources *pll = context;
- u32 reg_val;
-
- rc = mdss_pll_resource_enable(pll, true);
- if (rc) {
- pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
- return rc;
- }
-
- reg_val = MDSS_PLL_REG_R(pll->phy_base, PHY_CMN_CLK_CFG1);
- reg_val &= 0x3;
-
- if (reg_val == 2)
- *div = 1;
- else if (reg_val == 3)
- *div = 4;
- else
- *div = 1;
-
- /**
- *Common clock framework the divider value is interpreted as one less
- * hence we return one less for all dividers except when zero
- */
- if (*div != 0)
- *div -= 1;
-
- (void)mdss_pll_resource_enable(pll, false);
-
- return rc;
-}
-
-static int post_vco_clk_set_div_sub(struct mdss_pll_resources *pll, int div)
-{
- u32 reg_val;
- int rc = 0;
-
- reg_val = MDSS_PLL_REG_R(pll->phy_base, PHY_CMN_CLK_CFG1);
- reg_val &= ~0x03;
- if (div == 1) {
- reg_val |= 0x2;
- } else if (div == 4) {
- reg_val |= 0x3;
- } else {
- rc = -EINVAL;
- pr_err("unsupported divider %d\n", div);
- goto error;
- }
-
- MDSS_PLL_REG_W(pll->phy_base, PHY_CMN_CLK_CFG1, reg_val);
-
-error:
- return rc;
-}
-
-static int post_vco_clk_set_div(void *context, unsigned int reg,
- unsigned int div)
-{
- int rc = 0;
- struct mdss_pll_resources *pll = context;
-
- rc = mdss_pll_resource_enable(pll, true);
- if (rc) {
- pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
- return rc;
- }
-
- /**
- * In common clock framework the divider value provided is one less and
- * and hence adjusting the divider value by one prior to writing it to
- * hardware
- */
- div++;
- rc = post_vco_clk_set_div_sub(pll, div);
- if (!rc && pll->slave)
- rc = post_vco_clk_set_div_sub(pll->slave, div);
-
- (void)mdss_pll_resource_enable(pll, false);
-
- return rc;
-}
-
-static int post_bit_clk_get_div(void *context, unsigned int reg,
- unsigned int *div)
-{
- int rc;
- struct mdss_pll_resources *pll = context;
- u32 reg_val;
-
- rc = mdss_pll_resource_enable(pll, true);
- if (rc) {
- pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
- return rc;
- }
-
- reg_val = MDSS_PLL_REG_R(pll->phy_base, PHY_CMN_CLK_CFG1);
- reg_val &= 0x3;
-
- if (reg_val == 0)
- *div = 1;
- else if (reg_val == 1)
- *div = 2;
- else
- *div = 1;
-
- /**
- *Common clock framework the divider value is interpreted as one less
- * hence we return one less for all dividers except when zero
- */
- if (*div != 0)
- *div -= 1;
-
- (void)mdss_pll_resource_enable(pll, false);
-
- return rc;
-}
-
-static int post_bit_clk_set_div_sub(struct mdss_pll_resources *pll, int div)
-{
- int rc = 0;
- u32 reg_val;
-
- reg_val = MDSS_PLL_REG_R(pll->phy_base, PHY_CMN_CLK_CFG1);
- reg_val &= ~0x03;
- if (div == 1) {
- reg_val |= 0x0;
- } else if (div == 2) {
- reg_val |= 0x1;
- } else {
- rc = -EINVAL;
- pr_err("unsupported divider %d\n", div);
- goto error;
- }
-
- MDSS_PLL_REG_W(pll->phy_base, PHY_CMN_CLK_CFG1, reg_val);
-
-error:
- return rc;
-}
-
-static int post_bit_clk_set_div(void *context, unsigned int reg,
- unsigned int div)
-{
- int rc = 0;
- struct mdss_pll_resources *pll = context;
-
- rc = mdss_pll_resource_enable(pll, true);
- if (rc) {
- pr_err("Failed to enable dsi pll resources, rc=%d\n", rc);
- return rc;
- }
-
- /**
- * In common clock framework the divider value provided is one less and
- * and hence adjusting the divider value by one prior to writing it to
- * hardware
- */
- div++;
- rc = post_bit_clk_set_div_sub(pll, div);
- if (!rc && pll->slave)
- rc = post_bit_clk_set_div_sub(pll->slave, div);
-
- (void)mdss_pll_resource_enable(pll, false);
-
- return rc;
-}
-
static struct regmap_config dsi_pll_10nm_config = {
.reg_bits = 32,
.reg_stride = 4,
@@ -1032,14 +982,14 @@ static struct regmap_config dsi_pll_10nm_config = {
.max_register = 0x7c0,
};
-static struct regmap_bus post_vco_regmap_bus = {
- .reg_write = post_vco_clk_set_div,
- .reg_read = post_vco_clk_get_div,
+static struct regmap_bus pll_regmap_bus = {
+ .reg_write = pll_reg_write,
+ .reg_read = pll_reg_read,
};
-static struct regmap_bus post_bit_regmap_bus = {
- .reg_write = post_bit_clk_set_div,
- .reg_read = post_bit_clk_get_div,
+static struct regmap_bus pclk_mux_regmap_bus = {
+ .reg_read = phy_reg_read,
+ .reg_write = pclk_mux_write_sel,
};
static struct regmap_bus pclk_src_regmap_bus = {
@@ -1073,23 +1023,30 @@ static struct regmap_bus mdss_mux_regmap_bus = {
* | vco_clk |
* +-------+-------+
* |
- * +--------------------------------------+
- * | |
- * +-------v-------+ |
- * | bitclk_src | |
- * | DIV(1..15) | |
- * +-------+-------+ |
- * | |
- * +--------------------+ |
- * Shadow Path | | |
- * + +-------v-------+ +------v------+ +------v-------+
- * | | byteclk_src | |post_bit_div | |post_vco_div |
- * | | DIV(8) | |DIV(1,2) | |DIV(1,4) |
- * | +-------+-------+ +------+------+ +------+-------+
- * | | | |
- * | | +------+ +----+
- * | +--------+ | |
- * | | +----v-----v------+
+ * |
+ * +---------------+
+ * | pll_out_div |
+ * | DIV(1,2,4,8) |
+ * +-------+-------+
+ * |
+ * +-----------------------------+--------+
+ * | | |
+ * +-------v-------+ | |
+ * | bitclk_src | | |
+ * | DIV(1..15) | | |
+ * +-------+-------+ | |
+ * | | |
+ * +----------+---------+ | |
+ * Shadow Path | | | | |
+ * + +-------v-------+ | +------v------+ | +------v-------+
+ * | | byteclk_src | | |post_bit_div | | |post_vco_div |
+ * | | DIV(8) | | |DIV (2) | | |DIV(4) |
+ * | +-------+-------+ | +------+------+ | +------+-------+
+ * | | | | | | |
+ * | | | +------+ | |
+ * | | +-------------+ | | +----+
+ * | +--------+ | | | |
+ * | | +-v--v-v---v------+
* +-v---------v----+ \ pclk_src_mux /
* \ byteclk_mux / \ /
* \ / +-----+-----+
@@ -1140,13 +1097,45 @@ static struct dsi_pll_vco_clk dsi1pll_vco_clk = {
},
};
+static struct clk_regmap_div dsi0pll_pll_out_div = {
+ .reg = PLL_PLL_OUTDIV_RATE,
+ .shift = 0,
+ .width = 2,
+ .flags = CLK_DIVIDER_POWER_OF_TWO,
+ .clkr = {
+ .hw.init = &(struct clk_init_data){
+ .name = "dsi0pll_pll_out_div",
+ .parent_names = (const char *[]){"dsi0pll_vco_clk"},
+ .num_parents = 1,
+ .flags = (CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT),
+ .ops = &clk_regmap_div_ops,
+ },
+ },
+};
+
+static struct clk_regmap_div dsi1pll_pll_out_div = {
+ .reg = PLL_PLL_OUTDIV_RATE,
+ .shift = 0,
+ .width = 2,
+ .flags = CLK_DIVIDER_POWER_OF_TWO,
+ .clkr = {
+ .hw.init = &(struct clk_init_data){
+ .name = "dsi1pll_pll_out_div",
+ .parent_names = (const char *[]){"dsi1pll_vco_clk"},
+ .num_parents = 1,
+ .flags = (CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT),
+ .ops = &clk_regmap_div_ops,
+ },
+ },
+};
+
static struct clk_regmap_div dsi0pll_bitclk_src = {
.shift = 0,
.width = 4,
.clkr = {
.hw.init = &(struct clk_init_data){
.name = "dsi0pll_bitclk_src",
- .parent_names = (const char *[]){"dsi0pll_vco_clk"},
+ .parent_names = (const char *[]){"dsi0pll_pll_out_div"},
.num_parents = 1,
.flags = (CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT),
.ops = &clk_regmap_div_ops,
@@ -1160,7 +1149,7 @@ static struct clk_regmap_div dsi1pll_bitclk_src = {
.clkr = {
.hw.init = &(struct clk_init_data){
.name = "dsi1pll_bitclk_src",
- .parent_names = (const char *[]){"dsi1pll_vco_clk"},
+ .parent_names = (const char *[]){"dsi1pll_pll_out_div"},
.num_parents = 1,
.flags = (CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT),
.ops = &clk_regmap_div_ops,
@@ -1168,31 +1157,27 @@ static struct clk_regmap_div dsi1pll_bitclk_src = {
},
};
-static struct clk_regmap_div dsi0pll_post_vco_div = {
- .shift = 0,
- .width = 2,
- .clkr = {
- .hw.init = &(struct clk_init_data){
- .name = "dsi0pll_post_vco_div",
- .parent_names = (const char *[]){"dsi0pll_vco_clk"},
- .num_parents = 1,
- .flags = CLK_GET_RATE_NOCACHE,
- .ops = &clk_regmap_div_ops,
- },
+static struct clk_fixed_factor dsi0pll_post_vco_div = {
+ .div = 4,
+ .mult = 1,
+ .hw.init = &(struct clk_init_data){
+ .name = "dsi0pll_post_vco_div",
+ .parent_names = (const char *[]){"dsi0pll_pll_out_div"},
+ .num_parents = 1,
+ .flags = (CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT),
+ .ops = &clk_fixed_factor_ops,
},
};
-static struct clk_regmap_div dsi1pll_post_vco_div = {
- .shift = 0,
- .width = 2,
- .clkr = {
- .hw.init = &(struct clk_init_data){
- .name = "dsi1pll_post_vco_div",
- .parent_names = (const char *[]){"dsi1pll_vco_clk"},
- .num_parents = 1,
- .flags = CLK_GET_RATE_NOCACHE,
- .ops = &clk_regmap_div_ops,
- },
+static struct clk_fixed_factor dsi1pll_post_vco_div = {
+ .div = 4,
+ .mult = 1,
+ .hw.init = &(struct clk_init_data){
+ .name = "dsi1pll_post_vco_div",
+ .parent_names = (const char *[]){"dsi1pll_pll_out_div"},
+ .num_parents = 1,
+ .flags = (CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT),
+ .ops = &clk_fixed_factor_ops,
},
};
@@ -1220,31 +1205,27 @@ static struct clk_fixed_factor dsi1pll_byteclk_src = {
},
};
-static struct clk_regmap_div dsi0pll_post_bit_div = {
- .shift = 0,
- .width = 1,
- .clkr = {
- .hw.init = &(struct clk_init_data){
- .name = "dsi0pll_post_bit_div",
- .parent_names = (const char *[]){"dsi0pll_bitclk_src"},
- .num_parents = 1,
- .flags = CLK_GET_RATE_NOCACHE,
- .ops = &clk_regmap_div_ops,
- },
+static struct clk_fixed_factor dsi0pll_post_bit_div = {
+ .div = 2,
+ .mult = 1,
+ .hw.init = &(struct clk_init_data){
+ .name = "dsi0pll_post_bit_div",
+ .parent_names = (const char *[]){"dsi0pll_bitclk_src"},
+ .num_parents = 1,
+ .flags = CLK_GET_RATE_NOCACHE,
+ .ops = &clk_fixed_factor_ops,
},
};
-static struct clk_regmap_div dsi1pll_post_bit_div = {
- .shift = 0,
- .width = 1,
- .clkr = {
- .hw.init = &(struct clk_init_data){
- .name = "dsi1pll_post_bit_div",
- .parent_names = (const char *[]){"dsi1pll_bitclk_src"},
- .num_parents = 1,
- .flags = CLK_GET_RATE_NOCACHE,
- .ops = &clk_regmap_div_ops,
- },
+static struct clk_fixed_factor dsi1pll_post_bit_div = {
+ .div = 2,
+ .mult = 1,
+ .hw.init = &(struct clk_init_data){
+ .name = "dsi1pll_post_bit_div",
+ .parent_names = (const char *[]){"dsi1pll_bitclk_src"},
+ .num_parents = 1,
+ .flags = CLK_GET_RATE_NOCACHE,
+ .ops = &clk_fixed_factor_ops,
},
};
@@ -1277,30 +1258,36 @@ static struct clk_regmap_mux dsi1pll_byteclk_mux = {
};
static struct clk_regmap_mux dsi0pll_pclk_src_mux = {
+ .reg = PHY_CMN_CLK_CFG1,
.shift = 0,
- .width = 1,
+ .width = 2,
.clkr = {
.hw.init = &(struct clk_init_data){
.name = "dsi0pll_pclk_src_mux",
- .parent_names = (const char *[]){"dsi0pll_post_bit_div",
- "dsi0pll_post_vco_div"},
- .num_parents = 2,
- .flags = (CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT),
+ .parent_names = (const char *[]){"dsi0pll_bitclk_src",
+ "dsi0pll_post_bit_div",
+ "dsi0pll_pll_out_div",
+ "dsi0pll_post_vco_div"},
+ .num_parents = 4,
+ .flags = CLK_GET_RATE_NOCACHE,
.ops = &clk_regmap_mux_closest_ops,
},
},
};
static struct clk_regmap_mux dsi1pll_pclk_src_mux = {
+ .reg = PHY_CMN_CLK_CFG1,
.shift = 0,
- .width = 1,
+ .width = 2,
.clkr = {
.hw.init = &(struct clk_init_data){
.name = "dsi1pll_pclk_src_mux",
- .parent_names = (const char *[]){"dsi1pll_post_bit_div",
- "dsi1pll_post_vco_div"},
- .num_parents = 2,
- .flags = (CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT),
+ .parent_names = (const char *[]){"dsi1pll_bitclk_src",
+ "dsi1pll_post_bit_div",
+ "dsi1pll_pll_out_div",
+ "dsi1pll_post_vco_div"},
+ .num_parents = 4,
+ .flags = CLK_GET_RATE_NOCACHE,
.ops = &clk_regmap_mux_closest_ops,
},
},
@@ -1366,24 +1353,25 @@ static struct clk_regmap_mux dsi1pll_pclk_mux = {
static struct clk_hw *mdss_dsi_pllcc_10nm[] = {
[VCO_CLK_0] = &dsi0pll_vco_clk.hw,
+ [PLL_OUT_DIV_0_CLK] = &dsi0pll_pll_out_div.clkr.hw,
[BITCLK_SRC_0_CLK] = &dsi0pll_bitclk_src.clkr.hw,
[BYTECLK_SRC_0_CLK] = &dsi0pll_byteclk_src.hw,
- [POST_BIT_DIV_0_CLK] = &dsi0pll_post_bit_div.clkr.hw,
- [POST_VCO_DIV_0_CLK] = &dsi0pll_post_vco_div.clkr.hw,
+ [POST_BIT_DIV_0_CLK] = &dsi0pll_post_bit_div.hw,
+ [POST_VCO_DIV_0_CLK] = &dsi0pll_post_vco_div.hw,
[BYTECLK_MUX_0_CLK] = &dsi0pll_byteclk_mux.clkr.hw,
[PCLK_SRC_MUX_0_CLK] = &dsi0pll_pclk_src_mux.clkr.hw,
[PCLK_SRC_0_CLK] = &dsi0pll_pclk_src.clkr.hw,
[PCLK_MUX_0_CLK] = &dsi0pll_pclk_mux.clkr.hw,
[VCO_CLK_1] = &dsi1pll_vco_clk.hw,
+ [PLL_OUT_DIV_1_CLK] = &dsi1pll_pll_out_div.clkr.hw,
[BITCLK_SRC_1_CLK] = &dsi1pll_bitclk_src.clkr.hw,
[BYTECLK_SRC_1_CLK] = &dsi1pll_byteclk_src.hw,
- [POST_BIT_DIV_1_CLK] = &dsi1pll_post_bit_div.clkr.hw,
- [POST_VCO_DIV_1_CLK] = &dsi1pll_post_vco_div.clkr.hw,
+ [POST_BIT_DIV_1_CLK] = &dsi1pll_post_bit_div.hw,
+ [POST_VCO_DIV_1_CLK] = &dsi1pll_post_vco_div.hw,
[BYTECLK_MUX_1_CLK] = &dsi1pll_byteclk_mux.clkr.hw,
[PCLK_SRC_MUX_1_CLK] = &dsi1pll_pclk_src_mux.clkr.hw,
[PCLK_SRC_1_CLK] = &dsi1pll_pclk_src.clkr.hw,
[PCLK_MUX_1_CLK] = &dsi1pll_pclk_mux.clkr.hw,
-
};
int dsi_pll_clock_register_10nm(struct platform_device *pdev,
@@ -1428,13 +1416,10 @@ int dsi_pll_clock_register_10nm(struct platform_device *pdev,
/* Establish client data */
if (ndx == 0) {
- rmap = devm_regmap_init(&pdev->dev, &post_vco_regmap_bus,
- pll_res, &dsi_pll_10nm_config);
- dsi0pll_post_vco_div.clkr.regmap = rmap;
- rmap = devm_regmap_init(&pdev->dev, &post_bit_regmap_bus,
+ rmap = devm_regmap_init(&pdev->dev, &pll_regmap_bus,
pll_res, &dsi_pll_10nm_config);
- dsi0pll_post_bit_div.clkr.regmap = rmap;
+ dsi0pll_pll_out_div.clkr.regmap = rmap;
rmap = devm_regmap_init(&pdev->dev, &bitclk_src_regmap_bus,
pll_res, &dsi_pll_10nm_config);
@@ -1448,10 +1433,9 @@ int dsi_pll_clock_register_10nm(struct platform_device *pdev,
pll_res, &dsi_pll_10nm_config);
dsi0pll_pclk_mux.clkr.regmap = rmap;
- rmap = devm_regmap_init(&pdev->dev, &mdss_mux_regmap_bus,
+ rmap = devm_regmap_init(&pdev->dev, &pclk_mux_regmap_bus,
pll_res, &dsi_pll_10nm_config);
dsi0pll_pclk_src_mux.clkr.regmap = rmap;
-
rmap = devm_regmap_init(&pdev->dev, &mdss_mux_regmap_bus,
pll_res, &dsi_pll_10nm_config);
dsi0pll_byteclk_mux.clkr.regmap = rmap;
@@ -1475,13 +1459,9 @@ int dsi_pll_clock_register_10nm(struct platform_device *pdev,
} else {
- rmap = devm_regmap_init(&pdev->dev, &post_vco_regmap_bus,
+ rmap = devm_regmap_init(&pdev->dev, &pll_regmap_bus,
pll_res, &dsi_pll_10nm_config);
- dsi1pll_post_vco_div.clkr.regmap = rmap;
-
- rmap = devm_regmap_init(&pdev->dev, &post_bit_regmap_bus,
- pll_res, &dsi_pll_10nm_config);
- dsi1pll_post_bit_div.clkr.regmap = rmap;
+ dsi1pll_pll_out_div.clkr.regmap = rmap;
rmap = devm_regmap_init(&pdev->dev, &bitclk_src_regmap_bus,
pll_res, &dsi_pll_10nm_config);
@@ -1491,14 +1471,13 @@ int dsi_pll_clock_register_10nm(struct platform_device *pdev,
pll_res, &dsi_pll_10nm_config);
dsi1pll_pclk_src.clkr.regmap = rmap;
- rmap = devm_regmap_init(&pdev->dev, &mdss_mux_regmap_bus,
+ rmap = devm_regmap_init(&pdev->dev, &pclk_mux_regmap_bus,
pll_res, &dsi_pll_10nm_config);
dsi1pll_pclk_mux.clkr.regmap = rmap;
rmap = devm_regmap_init(&pdev->dev, &mdss_mux_regmap_bus,
pll_res, &dsi_pll_10nm_config);
dsi1pll_pclk_src_mux.clkr.regmap = rmap;
-
rmap = devm_regmap_init(&pdev->dev, &mdss_mux_regmap_bus,
pll_res, &dsi_pll_10nm_config);
dsi1pll_byteclk_mux.clkr.regmap = rmap;
diff --git a/drivers/clk/qcom/mdss/mdss-pll.h b/drivers/clk/qcom/mdss/mdss-pll.h
index 033462d..2f92270 100644
--- a/drivers/clk/qcom/mdss/mdss-pll.h
+++ b/drivers/clk/qcom/mdss/mdss-pll.h
@@ -99,6 +99,7 @@ struct mdss_pll_resources {
unsigned long vco_cached_rate;
u32 cached_cfg0;
u32 cached_cfg1;
+ u32 cached_outdiv;
/* dsi/edp/hmdi pll interface type */
u32 pll_interface_type;
diff --git a/drivers/crypto/msm/qce50.c b/drivers/crypto/msm/qce50.c
index d9ebe11..82a316b 100644
--- a/drivers/crypto/msm/qce50.c
+++ b/drivers/crypto/msm/qce50.c
@@ -33,12 +33,17 @@
#include <crypto/hash.h>
#include <crypto/sha.h>
#include <soc/qcom/socinfo.h>
+#include <asm/dma-iommu.h>
+#include <linux/iommu.h>
#include "qce.h"
#include "qce50.h"
#include "qcryptohw_50.h"
#include "qce_ota.h"
+#define CRYPTO_SMMU_IOVA_START 0x10000000
+#define CRYPTO_SMMU_IOVA_SIZE 0x40000000
+
#define CRYPTO_CONFIG_RESET 0xE01EF
#define MAX_SPS_DESC_FIFO_SIZE 0xfff0
#define QCE_MAX_NUM_DSCR 0x200
@@ -156,6 +161,8 @@ struct qce_device {
atomic_t last_intr_seq;
bool cadence_flag;
uint8_t *dummyreq_in_buf;
+ struct dma_iommu_mapping *smmu_mapping;
+ bool bypass_s1_smmu;
};
static void print_notify_debug(struct sps_event_notify *notify);
@@ -5703,6 +5710,10 @@ static int __qce_get_device_tree_data(struct platform_device *pdev,
pr_info("CE operating frequency is not defined, setting to default 100MHZ\n");
pce_dev->ce_opp_freq_hz = CE_CLK_100MHZ;
}
+
+ if (of_property_read_bool((&pdev->dev)->of_node, "qcom,smmu-s1-bypass"))
+ pce_dev->bypass_s1_smmu = true;
+
pce_dev->ce_bam_info.dest_pipe_index =
2 * pce_dev->ce_bam_info.pipe_pair_index;
pce_dev->ce_bam_info.src_pipe_index =
@@ -5936,6 +5947,48 @@ static int setup_dummy_req(struct qce_device *pce_dev)
return 0;
}
+static void qce_iommu_release_iomapping(struct qce_device *pce_dev)
+{
+ if (pce_dev->smmu_mapping)
+ arm_iommu_release_mapping(pce_dev->smmu_mapping);
+
+ pce_dev->smmu_mapping = NULL;
+}
+
+static int qce_smmu_init(struct qce_device *pce_dev)
+{
+ struct dma_iommu_mapping *mapping;
+ int s1_bypass = 1;
+ int ret = 0;
+
+ mapping = arm_iommu_create_mapping(&platform_bus_type,
+ CRYPTO_SMMU_IOVA_START, CRYPTO_SMMU_IOVA_SIZE);
+ if (IS_ERR(mapping)) {
+ ret = PTR_ERR(mapping);
+ pr_err("Create mapping failed, err = %d\n", ret);
+ return ret;
+ }
+
+ ret = iommu_domain_set_attr(mapping->domain,
+ DOMAIN_ATTR_S1_BYPASS, &s1_bypass);
+ if (ret < 0) {
+ pr_err("Set s1_bypass attribute failed, err = %d\n", ret);
+ goto ext_fail_set_attr;
+ }
+
+ ret = arm_iommu_attach_device(pce_dev->pdev, mapping);
+ if (ret < 0) {
+ pr_err("Attach device failed, err = %d\n", ret);
+ goto ext_fail_set_attr;
+ }
+ pce_dev->smmu_mapping = mapping;
+ return ret;
+
+ext_fail_set_attr:
+ qce_iommu_release_iomapping(pce_dev);
+ return ret;
+}
+
/* crypto engine open function. */
void *qce_open(struct platform_device *pdev, int *rc)
{
@@ -5993,6 +6046,13 @@ void *qce_open(struct platform_device *pdev, int *rc)
if (*rc)
goto err_enable_clk;
+ if (pce_dev->bypass_s1_smmu) {
+ if (qce_smmu_init(pce_dev)) {
+ *rc = -EIO;
+ goto err_smmu;
+ }
+ }
+
if (_probe_ce_engine(pce_dev)) {
*rc = -ENXIO;
goto err;
@@ -6019,6 +6079,9 @@ void *qce_open(struct platform_device *pdev, int *rc)
mutex_unlock(&qce_iomap_mutex);
return pce_dev;
err:
+ if (pce_dev->bypass_s1_smmu)
+ qce_iommu_release_iomapping(pce_dev);
+err_smmu:
qce_disable_clk(pce_dev);
err_enable_clk:
@@ -6060,6 +6123,9 @@ int qce_close(void *handle)
kfree(pce_dev->dummyreq_in_buf);
kfree(pce_dev->iovec_vmem);
+ if (pce_dev->bypass_s1_smmu)
+ qce_iommu_release_iomapping(pce_dev);
+
qce_disable_clk(pce_dev);
__qce_deinit_clk(pce_dev);
mutex_unlock(&qce_iomap_mutex);
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.c b/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.c
index 3625ed0..5e76ce7 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.c
@@ -56,6 +56,8 @@ static void dsi_catalog_cmn_init(struct dsi_ctrl_hw *ctrl,
dsi_ctrl_hw_cmn_trigger_cmd_test_pattern;
ctrl->ops.clear_phy0_ln_err = dsi_ctrl_hw_dln0_phy_err;
ctrl->ops.phy_reset_config = dsi_ctrl_hw_cmn_phy_reset_config;
+ ctrl->ops.setup_misr = dsi_ctrl_hw_cmn_setup_misr;
+ ctrl->ops.collect_misr = dsi_ctrl_hw_cmn_collect_misr;
switch (version) {
case DSI_CTRL_VERSION_1_4:
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.h b/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.h
index 2d7b174..e8a6ab4 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_catalog.h
@@ -147,6 +147,12 @@ void dsi_ctrl_hw_cmn_setup_cmd_stream(struct dsi_ctrl_hw *ctrl,
void dsi_ctrl_hw_cmn_phy_sw_reset(struct dsi_ctrl_hw *ctrl);
void dsi_ctrl_hw_cmn_soft_reset(struct dsi_ctrl_hw *ctrl);
+void dsi_ctrl_hw_cmn_setup_misr(struct dsi_ctrl_hw *ctrl,
+ enum dsi_op_mode panel_mode,
+ bool enable, u32 frame_count);
+u32 dsi_ctrl_hw_cmn_collect_misr(struct dsi_ctrl_hw *ctrl,
+ enum dsi_op_mode panel_mode);
+
void dsi_ctrl_hw_cmn_kickoff_command(struct dsi_ctrl_hw *ctrl,
struct dsi_ctrl_cmd_dma_info *cmd,
u32 flags);
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.c b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.c
index b2aef9c..21ef811 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.c
@@ -2258,6 +2258,28 @@ int dsi_ctrl_cmd_tx_trigger(struct dsi_ctrl *dsi_ctrl, u32 flags)
}
/**
+ * _dsi_ctrl_cache_misr - Cache frame MISR value
+ * @dsi_ctrl: Pointer to associated dsi_ctrl structure
+ */
+static void _dsi_ctrl_cache_misr(struct dsi_ctrl *dsi_ctrl)
+{
+ u32 misr;
+
+ if (!dsi_ctrl || !dsi_ctrl->hw.ops.collect_misr)
+ return;
+
+ misr = dsi_ctrl->hw.ops.collect_misr(&dsi_ctrl->hw,
+ dsi_ctrl->host_config.panel_mode);
+
+ if (misr)
+ dsi_ctrl->misr_cache = misr;
+
+ pr_debug("DSI_%d misr_cache = %x\n", dsi_ctrl->cell_index,
+ dsi_ctrl->misr_cache);
+
+}
+
+/**
* dsi_ctrl_set_power_state() - set power state for dsi controller
* @dsi_ctrl: DSI controller handle.
* @state: Power state.
@@ -2295,6 +2317,9 @@ int dsi_ctrl_set_power_state(struct dsi_ctrl *dsi_ctrl,
goto error;
}
} else if (state == DSI_CTRL_POWER_VREG_OFF) {
+ if (dsi_ctrl->misr_enable)
+ _dsi_ctrl_cache_misr(dsi_ctrl);
+
rc = dsi_ctrl_enable_supplies(dsi_ctrl, false);
if (rc) {
pr_err("[%d]failed to disable vreg supplies, rc=%d\n",
@@ -2609,6 +2634,59 @@ int dsi_ctrl_set_clock_source(struct dsi_ctrl *dsi_ctrl,
}
/**
+ * dsi_ctrl_setup_misr() - Setup frame MISR
+ * @dsi_ctrl: DSI controller handle.
+ * @enable: enable/disable MISR.
+ * @frame_count: Number of frames to accumulate MISR.
+ *
+ * Return: error code.
+ */
+int dsi_ctrl_setup_misr(struct dsi_ctrl *dsi_ctrl,
+ bool enable,
+ u32 frame_count)
+{
+ if (!dsi_ctrl) {
+ pr_err("Invalid params\n");
+ return -EINVAL;
+ }
+
+ if (!dsi_ctrl->hw.ops.setup_misr)
+ return 0;
+
+ mutex_lock(&dsi_ctrl->ctrl_lock);
+ dsi_ctrl->misr_enable = enable;
+ dsi_ctrl->hw.ops.setup_misr(&dsi_ctrl->hw,
+ dsi_ctrl->host_config.panel_mode,
+ enable, frame_count);
+ mutex_unlock(&dsi_ctrl->ctrl_lock);
+ return 0;
+}
+
+/**
+ * dsi_ctrl_collect_misr() - Read frame MISR
+ * @dsi_ctrl: DSI controller handle.
+ *
+ * Return: MISR value.
+ */
+u32 dsi_ctrl_collect_misr(struct dsi_ctrl *dsi_ctrl)
+{
+ u32 misr;
+
+ if (!dsi_ctrl || !dsi_ctrl->hw.ops.collect_misr)
+ return 0;
+
+ misr = dsi_ctrl->hw.ops.collect_misr(&dsi_ctrl->hw,
+ dsi_ctrl->host_config.panel_mode);
+ if (!misr)
+ misr = dsi_ctrl->misr_cache;
+
+ pr_debug("DSI_%d cached misr = %x, final = %x\n",
+ dsi_ctrl->cell_index, dsi_ctrl->misr_cache, misr);
+
+ return misr;
+}
+
+/**
* dsi_ctrl_drv_register() - register platform driver for dsi controller
*/
void dsi_ctrl_drv_register(void)
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h
index ec535ce11..95dac1c 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl.h
@@ -188,6 +188,8 @@ struct dsi_ctrl_interrupts {
* @vaddr: CPU virtual address of cmd buffer.
* @cmd_buffer_size: Size of command buffer.
* @debugfs_root: Root for debugfs entries.
+ * @misr_enable: Frame MISR enable/disable
+ * @misr_cache: Cached Frame MISR value
*/
struct dsi_ctrl {
struct platform_device *pdev;
@@ -226,6 +228,10 @@ struct dsi_ctrl {
/* Debug Information */
struct dentry *debugfs_root;
+ /* MISR */
+ bool misr_enable;
+ u32 misr_cache;
+
};
/**
@@ -571,6 +577,26 @@ void dsi_ctrl_disable_status_interrupt(
struct dsi_ctrl *dsi_ctrl, uint32_t intr_idx);
/**
+ * dsi_ctrl_setup_misr() - Setup frame MISR
+ * @dsi_ctrl: DSI controller handle.
+ * @enable: enable/disable MISR.
+ * @frame_count: Number of frames to accumulate MISR.
+ *
+ * Return: error code.
+ */
+int dsi_ctrl_setup_misr(struct dsi_ctrl *dsi_ctrl,
+ bool enable,
+ u32 frame_count);
+
+/**
+ * dsi_ctrl_collect_misr() - Read frame MISR
+ * @dsi_ctrl: DSI controller handle.
+ *
+ * Return: MISR value.
+ */
+u32 dsi_ctrl_collect_misr(struct dsi_ctrl *dsi_ctrl);
+
+/**
* dsi_ctrl_drv_register() - register platform driver for dsi controller
*/
void dsi_ctrl_drv_register(void);
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw.h b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw.h
index 74be279..2130144 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw.h
@@ -675,6 +675,26 @@ struct dsi_ctrl_hw_ops {
ssize_t (*reg_dump_to_buffer)(struct dsi_ctrl_hw *ctrl,
char *buf,
u32 size);
+
+ /**
+ * setup_misr() - Setup frame MISR
+ * @ctrl: Pointer to the controller host hardware.
+ * @panel_mode: CMD or VIDEO mode indicator
+ * @enable: Enable/disable MISR.
+ * @frame_count: Number of frames to accumulate MISR.
+ */
+ void (*setup_misr)(struct dsi_ctrl_hw *ctrl,
+ enum dsi_op_mode panel_mode,
+ bool enable, u32 frame_count);
+
+ /**
+ * collect_misr() - Read frame MISR
+ * @ctrl: Pointer to the controller host hardware.
+ * @panel_mode: CMD or VIDEO mode indicator
+ */
+ u32 (*collect_misr)(struct dsi_ctrl_hw *ctrl,
+ enum dsi_op_mode panel_mode);
+
};
/*
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_2_0.c b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_2_0.c
index c22849a..6421dc2 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_2_0.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_2_0.c
@@ -157,6 +157,10 @@ ssize_t dsi_ctrl_hw_20_reg_dump_to_buffer(struct dsi_ctrl_hw *ctrl,
len += snprintf((buf + len), (size - len),
DUMP_REG_VALUE(DSI_RESET_SW_TRIGGER));
len += snprintf((buf + len), (size - len),
+ DUMP_REG_VALUE(DSI_MISR_CMD_CTRL));
+ len += snprintf((buf + len), (size - len),
+ DUMP_REG_VALUE(DSI_MISR_VIDEO_CTRL));
+ len += snprintf((buf + len), (size - len),
DUMP_REG_VALUE(DSI_LANE_STATUS));
len += snprintf((buf + len), (size - len),
DUMP_REG_VALUE(DSI_LANE_CTRL));
@@ -193,6 +197,12 @@ ssize_t dsi_ctrl_hw_20_reg_dump_to_buffer(struct dsi_ctrl_hw *ctrl,
len += snprintf((buf + len), (size - len),
DUMP_REG_VALUE(DSI_AXI2AHB_CTRL));
len += snprintf((buf + len), (size - len),
+ DUMP_REG_VALUE(DSI_MISR_CMD_MDP0_32BIT));
+ len += snprintf((buf + len), (size - len),
+ DUMP_REG_VALUE(DSI_MISR_CMD_MDP1_32BIT));
+ len += snprintf((buf + len), (size - len),
+ DUMP_REG_VALUE(DSI_MISR_VIDEO_32BIT));
+ len += snprintf((buf + len), (size - len),
DUMP_REG_VALUE(DSI_COMMAND_MODE_MDP_CTRL2));
len += snprintf((buf + len), (size - len),
DUMP_REG_VALUE(DSI_COMMAND_MODE_MDP_STREAM2_CTRL));
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_cmn.c b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_cmn.c
index 0af6f25..8e8e353 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_cmn.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_ctrl_hw_cmn.c
@@ -20,9 +20,12 @@
#include "dsi_ctrl_reg.h"
#include "dsi_hw.h"
#include "dsi_panel.h"
+#include "dsi_catalog.h"
#define MMSS_MISC_CLAMP_REG_OFF 0x0014
#define DSI_CTRL_DYNAMIC_FORCE_ON (0x23F|BIT(8)|BIT(9)|BIT(11)|BIT(21))
+#define DSI_CTRL_CMD_MISR_ENABLE BIT(28)
+#define DSI_CTRL_VIDEO_MISR_ENABLE BIT(16)
/* Unsupported formats default to RGB888 */
static const u8 cmd_mode_format_map[DSI_PIXEL_FORMAT_MAX] = {
@@ -149,6 +152,70 @@ void dsi_ctrl_hw_cmn_soft_reset(struct dsi_ctrl_hw *ctrl)
}
/**
+ * setup_misr() - Setup frame MISR
+ * @ctrl: Pointer to the controller host hardware.
+ * @panel_mode: CMD or VIDEO mode indicator
+ * @enable: Enable/disable MISR.
+ * @frame_count: Number of frames to accumulate MISR.
+ */
+void dsi_ctrl_hw_cmn_setup_misr(struct dsi_ctrl_hw *ctrl,
+ enum dsi_op_mode panel_mode,
+ bool enable,
+ u32 frame_count)
+{
+ u32 addr;
+ u32 config = 0;
+
+ if (panel_mode == DSI_OP_CMD_MODE) {
+ addr = DSI_MISR_CMD_CTRL;
+ if (enable)
+ config = DSI_CTRL_CMD_MISR_ENABLE;
+ } else {
+ addr = DSI_MISR_VIDEO_CTRL;
+ if (enable)
+ config = DSI_CTRL_VIDEO_MISR_ENABLE;
+ if (frame_count > 255)
+ frame_count = 255;
+ config |= frame_count << 8;
+ }
+
+ pr_debug("[DSI_%d] MISR ctrl: 0x%x\n", ctrl->index,
+ config);
+ DSI_W32(ctrl, addr, config);
+ wmb(); /* make sure MISR is configured */
+}
+
+/**
+ * collect_misr() - Read frame MISR
+ * @ctrl: Pointer to the controller host hardware.
+ * @panel_mode: CMD or VIDEO mode indicator
+ */
+u32 dsi_ctrl_hw_cmn_collect_misr(struct dsi_ctrl_hw *ctrl,
+ enum dsi_op_mode panel_mode)
+{
+ u32 addr;
+ u32 enabled;
+ u32 misr = 0;
+
+ if (panel_mode == DSI_OP_CMD_MODE) {
+ addr = DSI_MISR_CMD_MDP0_32BIT;
+ enabled = DSI_R32(ctrl, DSI_MISR_CMD_CTRL) &
+ DSI_CTRL_CMD_MISR_ENABLE;
+ } else {
+ addr = DSI_MISR_VIDEO_32BIT;
+ enabled = DSI_R32(ctrl, DSI_MISR_VIDEO_CTRL) &
+ DSI_CTRL_VIDEO_MISR_ENABLE;
+ }
+
+ if (enabled)
+ misr = DSI_R32(ctrl, addr);
+
+ pr_debug("[DSI_%d] MISR enabled %x value: 0x%x\n", ctrl->index,
+ enabled, misr);
+ return misr;
+}
+
+/**
* set_video_timing() - set up the timing for video frame
* @ctrl: Pointer to controller host hardware.
* @mode: Video mode information.
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_display.c b/drivers/gpu/drm/msm/dsi-staging/dsi_display.c
index a4a9fb5..c0c6698 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_display.c
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_display.c
@@ -32,6 +32,8 @@
#define to_dsi_display(x) container_of(x, struct dsi_display, host)
#define INT_BASE_10 10
+#define MISR_BUFF_SIZE 256
+
static DEFINE_MUTEX(dsi_display_list_lock);
static LIST_HEAD(dsi_display_list);
static char dsi_display_primary[MAX_CMDLINE_PARAM_LEN];
@@ -128,9 +130,20 @@ enum dsi_pixel_format dsi_display_get_dst_format(void *display)
return format;
}
+static void _dsi_display_setup_misr(struct dsi_display *display)
+{
+ int i;
+
+ for (i = 0; i < display->ctrl_count; i++) {
+ dsi_ctrl_setup_misr(display->ctrl[i].ctrl,
+ display->misr_enable,
+ display->misr_frame_count);
+ }
+}
+
static ssize_t debugfs_dump_info_read(struct file *file,
- char __user *buff,
- size_t count,
+ char __user *user_buf,
+ size_t user_len,
loff_t *ppos)
{
struct dsi_display *display = file->private_data;
@@ -168,7 +181,7 @@ static ssize_t debugfs_dump_info_read(struct file *file,
"\tClock master = %s\n",
display->ctrl[display->clk_master_idx].ctrl->name);
- if (copy_to_user(buff, buf, len)) {
+ if (copy_to_user(user_buf, buf, len)) {
kfree(buf);
return -EFAULT;
}
@@ -179,16 +192,151 @@ static ssize_t debugfs_dump_info_read(struct file *file,
return len;
}
+static ssize_t debugfs_misr_setup(struct file *file,
+ const char __user *user_buf,
+ size_t user_len,
+ loff_t *ppos)
+{
+ struct dsi_display *display = file->private_data;
+ char *buf;
+ int rc = 0;
+ size_t len;
+ u32 enable, frame_count;
+
+ if (!display)
+ return -ENODEV;
+
+ if (*ppos)
+ return 0;
+
+ buf = kzalloc(MISR_BUFF_SIZE, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ /* leave room for termination char */
+ len = min_t(size_t, user_len, MISR_BUFF_SIZE - 1);
+ if (copy_from_user(buf, user_buf, len)) {
+ rc = -EINVAL;
+ goto error;
+ }
+
+ buf[len] = '\0'; /* terminate the string */
+
+ if (sscanf(buf, "%u %u", &enable, &frame_count) != 2) {
+ rc = -EINVAL;
+ goto error;
+ }
+
+ display->misr_enable = enable;
+ display->misr_frame_count = frame_count;
+
+ mutex_lock(&display->display_lock);
+ rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
+ DSI_CORE_CLK, DSI_CLK_ON);
+ if (rc) {
+ pr_err("[%s] failed to enable DSI core clocks, rc=%d\n",
+ display->name, rc);
+ goto unlock;
+ }
+
+ _dsi_display_setup_misr(display);
+
+ rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
+ DSI_CORE_CLK, DSI_CLK_OFF);
+ if (rc) {
+ pr_err("[%s] failed to disable DSI core clocks, rc=%d\n",
+ display->name, rc);
+ goto unlock;
+ }
+
+ rc = user_len;
+unlock:
+ mutex_unlock(&display->display_lock);
+error:
+ kfree(buf);
+ return rc;
+}
+
+static ssize_t debugfs_misr_read(struct file *file,
+ char __user *user_buf,
+ size_t user_len,
+ loff_t *ppos)
+{
+ struct dsi_display *display = file->private_data;
+ char *buf;
+ u32 len = 0;
+ int rc = 0;
+ struct dsi_ctrl *dsi_ctrl;
+ int i;
+ u32 misr;
+ size_t max_len = min_t(size_t, user_len, MISR_BUFF_SIZE);
+
+ if (!display)
+ return -ENODEV;
+
+ if (*ppos)
+ return 0;
+
+ buf = kzalloc(max_len, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ mutex_lock(&display->display_lock);
+ rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
+ DSI_CORE_CLK, DSI_CLK_ON);
+ if (rc) {
+ pr_err("[%s] failed to enable DSI core clocks, rc=%d\n",
+ display->name, rc);
+ goto error;
+ }
+
+ for (i = 0; i < display->ctrl_count; i++) {
+ dsi_ctrl = display->ctrl[i].ctrl;
+ misr = dsi_ctrl_collect_misr(display->ctrl[i].ctrl);
+
+ len += snprintf((buf + len), max_len - len,
+ "DSI_%d MISR: 0x%x\n", dsi_ctrl->cell_index, misr);
+
+ if (len >= max_len)
+ break;
+ }
+
+ rc = dsi_display_clk_ctrl(display->dsi_clk_handle,
+ DSI_CORE_CLK, DSI_CLK_OFF);
+ if (rc) {
+ pr_err("[%s] failed to disable DSI core clocks, rc=%d\n",
+ display->name, rc);
+ goto error;
+ }
+
+ if (copy_to_user(user_buf, buf, len)) {
+ rc = -EFAULT;
+ goto error;
+ }
+
+ *ppos += len;
+
+error:
+ mutex_unlock(&display->display_lock);
+ kfree(buf);
+ return len;
+}
static const struct file_operations dump_info_fops = {
.open = simple_open,
.read = debugfs_dump_info_read,
};
+static const struct file_operations misr_data_fops = {
+ .open = simple_open,
+ .read = debugfs_misr_read,
+ .write = debugfs_misr_setup,
+};
+
static int dsi_display_debugfs_init(struct dsi_display *display)
{
int rc = 0;
- struct dentry *dir, *dump_file;
+ struct dentry *dir, *dump_file, *misr_data;
dir = debugfs_create_dir(display->name, NULL);
if (IS_ERR_OR_NULL(dir)) {
@@ -199,13 +347,25 @@ static int dsi_display_debugfs_init(struct dsi_display *display)
}
dump_file = debugfs_create_file("dump_info",
- 0444,
+ 0400,
dir,
display,
&dump_info_fops);
if (IS_ERR_OR_NULL(dump_file)) {
rc = PTR_ERR(dump_file);
- pr_err("[%s] debugfs create file failed, rc=%d\n",
+ pr_err("[%s] debugfs create dump info file failed, rc=%d\n",
+ display->name, rc);
+ goto error_remove_dir;
+ }
+
+ misr_data = debugfs_create_file("misr_data",
+ 0600,
+ dir,
+ display,
+ &misr_data_fops);
+ if (IS_ERR_OR_NULL(misr_data)) {
+ rc = PTR_ERR(misr_data);
+ pr_err("[%s] debugfs create misr datafile failed, rc=%d\n",
display->name, rc);
goto error_remove_dir;
}
@@ -3533,6 +3693,10 @@ int dsi_display_pre_kickoff(struct dsi_display *display,
{
int rc = 0;
+ /* check and setup MISR */
+ if (display->misr_enable)
+ _dsi_display_setup_misr(display);
+
rc = dsi_display_set_roi(display, params->rois);
return rc;
diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_display.h b/drivers/gpu/drm/msm/dsi-staging/dsi_display.h
index b382e4a..359e04f3 100644
--- a/drivers/gpu/drm/msm/dsi-staging/dsi_display.h
+++ b/drivers/gpu/drm/msm/dsi-staging/dsi_display.h
@@ -154,6 +154,8 @@ struct dsi_display_clk_info {
* @dsi_clk_handle: DSI clock handle.
* @mdp_clk_handle: MDP clock handle.
* @root: Debugfs root directory
+ * @misr_enable Frame MISR enable/disable
+ * @misr_frame_count Number of frames to accumulate the MISR value
*/
struct dsi_display {
struct platform_device *pdev;
@@ -201,6 +203,9 @@ struct dsi_display {
/* DEBUG FS */
struct dentry *root;
+
+ bool misr_enable;
+ u32 misr_frame_count;
};
int dsi_display_dev_probe(struct platform_device *pdev);
diff --git a/drivers/gpu/drm/msm/msm_prop.c b/drivers/gpu/drm/msm/msm_prop.c
index f2996dd..d1991a4 100644
--- a/drivers/gpu/drm/msm/msm_prop.c
+++ b/drivers/gpu/drm/msm/msm_prop.c
@@ -21,8 +21,6 @@ void msm_property_init(struct msm_property_info *info,
uint32_t blob_count,
uint32_t state_size)
{
- int i;
-
/* prevent access if any of these are NULL */
if (!base || !dev || !property_array || !property_data) {
property_count = 0;
@@ -60,10 +58,6 @@ void msm_property_init(struct msm_property_info *info,
0,
sizeof(struct msm_property_data) *
property_count);
- INIT_LIST_HEAD(&info->dirty_list);
-
- for (i = 0; i < property_count; ++i)
- INIT_LIST_HEAD(&property_data[i].dirty_node);
}
}
@@ -72,9 +66,6 @@ void msm_property_destroy(struct msm_property_info *info)
if (!info)
return;
- /* reset dirty list */
- INIT_LIST_HEAD(&info->dirty_list);
-
/* free state cache */
while (info->state_cache_size > 0)
kfree(info->state_cache[--(info->state_cache_size)]);
@@ -82,24 +73,25 @@ void msm_property_destroy(struct msm_property_info *info)
mutex_destroy(&info->property_lock);
}
-int msm_property_pop_dirty(struct msm_property_info *info)
+int msm_property_pop_dirty(struct msm_property_info *info,
+ struct msm_property_state *property_state)
{
struct list_head *item;
int rc = 0;
- if (!info) {
- DRM_ERROR("invalid info\n");
+ if (!info || !property_state || !property_state->values) {
+ DRM_ERROR("invalid argument(s)\n");
return -EINVAL;
}
mutex_lock(&info->property_lock);
- if (list_empty(&info->dirty_list)) {
+ if (list_empty(&property_state->dirty_list)) {
rc = -EAGAIN;
} else {
- item = info->dirty_list.next;
+ item = property_state->dirty_list.next;
list_del_init(item);
- rc = container_of(item, struct msm_property_data, dirty_node)
- - info->property_data;
+ rc = container_of(item, struct msm_property_value, dirty_node)
+ - property_state->values;
DRM_DEBUG_KMS("property %d dirty\n", rc);
}
mutex_unlock(&info->property_lock);
@@ -112,26 +104,28 @@ int msm_property_pop_dirty(struct msm_property_info *info)
* This function doesn't mutex protect the
* dirty linked list.
* @info: Pointer to property info container struct
+ * @property_state: Pointer to property state container struct
* @property_idx: Property index
*/
static void _msm_property_set_dirty_no_lock(
struct msm_property_info *info,
+ struct msm_property_state *property_state,
uint32_t property_idx)
{
- if (!info || property_idx >= info->property_count) {
- DRM_ERROR("invalid argument(s), info %pK, idx %u\n",
- info, property_idx);
+ if (!info || !property_state || !property_state->values ||
+ property_idx >= info->property_count) {
+ DRM_ERROR("invalid argument(s), idx %u\n", property_idx);
return;
}
/* avoid re-inserting if already dirty */
- if (!list_empty(&info->property_data[property_idx].dirty_node)) {
+ if (!list_empty(&property_state->values[property_idx].dirty_node)) {
DRM_DEBUG_KMS("property %u already dirty\n", property_idx);
return;
}
- list_add_tail(&info->property_data[property_idx].dirty_node,
- &info->dirty_list);
+ list_add_tail(&property_state->values[property_idx].dirty_node,
+ &property_state->dirty_list);
}
/**
@@ -371,35 +365,36 @@ int msm_property_index(struct msm_property_info *info,
return rc;
}
-int msm_property_set_dirty(struct msm_property_info *info, int property_idx)
+int msm_property_set_dirty(struct msm_property_info *info,
+ struct msm_property_state *property_state,
+ int property_idx)
{
- if (!info) {
- DRM_ERROR("invalid property info\n");
+ if (!info || !property_state || !property_state->values) {
+ DRM_ERROR("invalid argument(s)\n");
return -EINVAL;
}
mutex_lock(&info->property_lock);
- _msm_property_set_dirty_no_lock(info, property_idx);
+ _msm_property_set_dirty_no_lock(info, property_state, property_idx);
mutex_unlock(&info->property_lock);
return 0;
}
int msm_property_atomic_set(struct msm_property_info *info,
- uint64_t *property_values,
- struct drm_property_blob **property_blobs,
+ struct msm_property_state *property_state,
struct drm_property *property, uint64_t val)
{
struct drm_property_blob *blob;
int property_idx, rc = -EINVAL;
property_idx = msm_property_index(info, property);
- if (!info || (property_idx == -EINVAL) || !property_values) {
- DRM_DEBUG("Invalid argument(s)\n");
+ if (!info || !property_state ||
+ (property_idx == -EINVAL) || !property_state->values) {
+ DRM_DEBUG("invalid argument(s)\n");
} else {
/* extra handling for incoming properties */
mutex_lock(&info->property_lock);
if ((property->flags & DRM_MODE_PROP_BLOB) &&
- (property_idx < info->blob_count) &&
- property_blobs) {
+ (property_idx < info->blob_count)) {
/* DRM lookup also takes a reference */
blob = drm_property_lookup_blob(info->dev,
(uint32_t)val);
@@ -411,18 +406,21 @@ int msm_property_atomic_set(struct msm_property_info *info,
val = blob->base.id;
/* save blob - need to clear previous ref */
- if (property_blobs[property_idx])
+ if (property_state->values[property_idx].blob)
drm_property_unreference_blob(
- property_blobs[property_idx]);
- property_blobs[property_idx] = blob;
+ property_state->values[
+ property_idx].blob);
+ property_state->values[property_idx].blob =
+ blob;
}
}
/* update value and flag as dirty */
- if (property_values[property_idx] != val ||
+ if (property_state->values[property_idx].value != val ||
info->property_data[property_idx].force_dirty) {
- property_values[property_idx] = val;
- _msm_property_set_dirty_no_lock(info, property_idx);
+ property_state->values[property_idx].value = val;
+ _msm_property_set_dirty_no_lock(info, property_state,
+ property_idx);
DBG("%s - %lld", property->name, val);
}
@@ -434,18 +432,18 @@ int msm_property_atomic_set(struct msm_property_info *info,
}
int msm_property_atomic_get(struct msm_property_info *info,
- uint64_t *property_values,
- struct drm_property_blob **property_blobs,
+ struct msm_property_state *property_state,
struct drm_property *property, uint64_t *val)
{
int property_idx, rc = -EINVAL;
property_idx = msm_property_index(info, property);
- if (!info || (property_idx == -EINVAL) || !property_values || !val) {
+ if (!info || (property_idx == -EINVAL) ||
+ !property_state->values || !val) {
DRM_DEBUG("Invalid argument(s)\n");
} else {
mutex_lock(&info->property_lock);
- *val = property_values[property_idx];
+ *val = property_state->values[property_idx].value;
mutex_unlock(&info->property_lock);
rc = 0;
}
@@ -495,8 +493,8 @@ static void _msm_property_free_state(struct msm_property_info *info, void *st)
}
void msm_property_reset_state(struct msm_property_info *info, void *state,
- uint64_t *property_values,
- struct drm_property_blob **property_blobs)
+ struct msm_property_state *property_state,
+ struct msm_property_value *property_values)
{
uint32_t i;
@@ -508,24 +506,29 @@ void msm_property_reset_state(struct msm_property_info *info, void *state,
if (state)
memset(state, 0, info->state_size);
+ if (property_state) {
+ property_state->property_count = info->property_count;
+ property_state->values = property_values;
+ INIT_LIST_HEAD(&property_state->dirty_list);
+ }
+
/*
* Assign default property values. This helper is mostly used
* to initialize newly created state objects.
*/
if (property_values)
- for (i = 0; i < info->property_count; ++i)
- property_values[i] =
+ for (i = 0; i < info->property_count; ++i) {
+ property_values[i].value =
info->property_data[i].default_value;
-
- if (property_blobs)
- for (i = 0; i < info->blob_count; ++i)
- property_blobs[i] = 0;
+ property_values[i].blob = NULL;
+ INIT_LIST_HEAD(&property_values[i].dirty_node);
+ }
}
void msm_property_duplicate_state(struct msm_property_info *info,
void *old_state, void *state,
- uint64_t *property_values,
- struct drm_property_blob **property_blobs)
+ struct msm_property_state *property_state,
+ struct msm_property_value *property_values)
{
uint32_t i;
@@ -536,17 +539,24 @@ void msm_property_duplicate_state(struct msm_property_info *info,
memcpy(state, old_state, info->state_size);
- if (property_blobs) {
- /* add ref count for blobs */
- for (i = 0; i < info->blob_count; ++i)
- if (property_blobs[i])
- drm_property_reference_blob(property_blobs[i]);
- }
+ if (!property_state)
+ return;
+
+ INIT_LIST_HEAD(&property_state->dirty_list);
+ property_state->values = property_values;
+
+ if (property_state->values)
+ /* add ref count for blobs and initialize dirty nodes */
+ for (i = 0; i < info->property_count; ++i) {
+ if (property_state->values[i].blob)
+ drm_property_reference_blob(
+ property_state->values[i].blob);
+ INIT_LIST_HEAD(&property_state->values[i].dirty_node);
+ }
}
void msm_property_destroy_state(struct msm_property_info *info, void *state,
- uint64_t *property_values,
- struct drm_property_blob **property_blobs)
+ struct msm_property_state *property_state)
{
uint32_t i;
@@ -554,19 +564,21 @@ void msm_property_destroy_state(struct msm_property_info *info, void *state,
DRM_ERROR("invalid argument(s)\n");
return;
}
- if (property_blobs) {
+ if (property_state && property_state->values) {
/* remove ref count for blobs */
- for (i = 0; i < info->blob_count; ++i)
- if (property_blobs[i])
+ for (i = 0; i < info->property_count; ++i)
+ if (property_state->values[i].blob) {
drm_property_unreference_blob(
- property_blobs[i]);
+ property_state->values[i].blob);
+ property_state->values[i].blob = NULL;
+ }
}
_msm_property_free_state(info, state);
}
void *msm_property_get_blob(struct msm_property_info *info,
- struct drm_property_blob **property_blobs,
+ struct msm_property_state *property_state,
size_t *byte_len,
uint32_t property_idx)
{
@@ -574,10 +586,11 @@ void *msm_property_get_blob(struct msm_property_info *info,
size_t len = 0;
void *rc = 0;
- if (!info || !property_blobs || (property_idx >= info->blob_count)) {
+ if (!info || !property_state || !property_state->values ||
+ (property_idx >= info->blob_count)) {
DRM_ERROR("invalid argument(s)\n");
} else {
- blob = property_blobs[property_idx];
+ blob = property_state->values[property_idx].blob;
if (blob) {
len = blob->length;
rc = &blob->data;
@@ -636,14 +649,15 @@ int msm_property_set_blob(struct msm_property_info *info,
}
int msm_property_set_property(struct msm_property_info *info,
- uint64_t *property_values,
+ struct msm_property_state *property_state,
uint32_t property_idx,
uint64_t val)
{
int rc = -EINVAL;
if (!info || (property_idx >= info->property_count) ||
- property_idx < info->blob_count || !property_values) {
+ property_idx < info->blob_count ||
+ !property_state || !property_state->values) {
DRM_ERROR("invalid argument(s)\n");
} else {
struct drm_property *drm_prop;
@@ -651,8 +665,7 @@ int msm_property_set_property(struct msm_property_info *info,
mutex_lock(&info->property_lock);
/* update cached value */
- if (property_values)
- property_values[property_idx] = val;
+ property_state->values[property_idx].value = val;
/* update the new default value for immutables */
drm_prop = info->property_array[property_idx];
diff --git a/drivers/gpu/drm/msm/msm_prop.h b/drivers/gpu/drm/msm/msm_prop.h
index e54c796..9a53e56 100644
--- a/drivers/gpu/drm/msm/msm_prop.h
+++ b/drivers/gpu/drm/msm/msm_prop.h
@@ -22,17 +22,28 @@
* struct msm_property_data - opaque structure for tracking per
* drm-object per property stuff
* @default_value: Default property value for this drm object
- * @dirty_node: Linked list node to track if property is dirty or not
* @force_dirty: Always dirty property on incoming sets, rather than checking
* for modified values
*/
struct msm_property_data {
uint64_t default_value;
- struct list_head dirty_node;
bool force_dirty;
};
/**
+ * struct msm_property_value - opaque structure for tracking per
+ * drm-object per property stuff
+ * @value: Current property value for this drm object
+ * @blob: Pointer to associated blob data, if available
+ * @dirty_node: Linked list node to track if property is dirty or not
+ */
+struct msm_property_value {
+ uint64_t value;
+ struct drm_property_blob *blob;
+ struct list_head dirty_node;
+};
+
+/**
* struct msm_property_info: Structure for property/state helper functions
* @base: Pointer to base drm object (plane/crtc/etc.)
* @dev: Pointer to drm device object
@@ -43,8 +54,6 @@ struct msm_property_data {
* @install_request: Total number of property 'install' requests
* @install_count: Total number of successful 'install' requests
* @recent_idx: Index of property most recently accessed by set/get
- * @dirty_list: List of all properties that have been 'atomic_set' but not
- * yet cleared with 'msm_property_pop_dirty'
* @is_active: Whether or not drm component properties are 'active'
* @state_cache: Cache of local states, to prevent alloc/free thrashing
* @state_size: Size of local state structures
@@ -64,7 +73,6 @@ struct msm_property_info {
int32_t recent_idx;
- struct list_head dirty_list;
bool is_active;
void *state_cache[MSM_PROP_STATE_CACHE_SIZE];
@@ -74,6 +82,19 @@ struct msm_property_info {
};
/**
+ * struct msm_property_state - Structure for local property state information
+ * @property_count: Total number of properties
+ * @values: Pointer to array of msm_property_value objects
+ * @dirty_list: List of all properties that have been 'atomic_set' but not
+ * yet cleared with 'msm_property_pop_dirty'
+ */
+struct msm_property_state {
+ uint32_t property_count;
+ struct msm_property_value *values;
+ struct list_head dirty_list;
+};
+
+/**
* msm_property_get_default - query default value of a property
* @info: Pointer to property info container struct
* @property_idx: Property index
@@ -134,12 +155,14 @@ bool msm_property_get_is_active(struct msm_property_info *info)
* msm_property_pop_dirty - determine next dirty property and clear
* its dirty flag
* @info: Pointer to property info container struct
+ * @property_state: Pointer to property state container struct
* Returns: Valid msm property index on success,
* -EAGAIN if no dirty properties are available
* Property indicies returned from this function are similar
* to those returned by the msm_property_index function.
*/
-int msm_property_pop_dirty(struct msm_property_info *info);
+int msm_property_pop_dirty(struct msm_property_info *info,
+ struct msm_property_state *property_state);
/**
* msm_property_init - initialize property info structure
@@ -268,38 +291,37 @@ int msm_property_index(struct msm_property_info *info,
/**
* msm_property_set_dirty - forcibly flag a property as dirty
* @info: Pointer to property info container struct
+ * @property_state: Pointer to property state container struct
* @property_idx: Property index
* Returns: Zero on success
*/
-int msm_property_set_dirty(struct msm_property_info *info, int property_idx);
+int msm_property_set_dirty(struct msm_property_info *info,
+ struct msm_property_state *property_state,
+ int property_idx);
/**
* msm_property_atomic_set - helper function for atomic property set callback
* @info: Pointer to property info container struct
- * @property_values: Pointer to property values cache array
- * @property_blobs: Pointer to property blobs cache array
+ * @property_state: Pointer to local state structure
* @property: Incoming property pointer
* @val: Incoming property value
* Returns: Zero on success
*/
int msm_property_atomic_set(struct msm_property_info *info,
- uint64_t *property_values,
- struct drm_property_blob **property_blobs,
+ struct msm_property_state *property_state,
struct drm_property *property,
uint64_t val);
/**
* msm_property_atomic_get - helper function for atomic property get callback
* @info: Pointer to property info container struct
- * @property_values: Pointer to property values cache array
- * @property_blobs: Pointer to property blobs cache array
+ * @property_state: Pointer to local state structure
* @property: Incoming property pointer
* @val: Pointer to variable for receiving property value
* Returns: Zero on success
*/
int msm_property_atomic_get(struct msm_property_info *info,
- uint64_t *property_values,
- struct drm_property_blob **property_blobs,
+ struct msm_property_state *property_state,
struct drm_property *property,
uint64_t *val);
@@ -313,50 +335,47 @@ void *msm_property_alloc_state(struct msm_property_info *info);
* msm_property_reset_state - helper function for state reset callback
* @info: Pointer to property info container struct
* @state: Pointer to local state structure
+ * @property_state: Pointer to property state container struct
* @property_values: Pointer to property values cache array
- * @property_blobs: Pointer to property blobs cache array
*/
-void msm_property_reset_state(struct msm_property_info *info,
- void *state,
- uint64_t *property_values,
- struct drm_property_blob **property_blobs);
+void msm_property_reset_state(struct msm_property_info *info, void *state,
+ struct msm_property_state *property_state,
+ struct msm_property_value *property_values);
/**
* msm_property_duplicate_state - helper function for duplicate state cb
* @info: Pointer to property info container struct
* @old_state: Pointer to original state structure
* @state: Pointer to newly created state structure
+ * @property_state: Pointer to destination property state container struct
* @property_values: Pointer to property values cache array
- * @property_blobs: Pointer to property blobs cache array
*/
void msm_property_duplicate_state(struct msm_property_info *info,
void *old_state,
void *state,
- uint64_t *property_values,
- struct drm_property_blob **property_blobs);
+ struct msm_property_state *property_state,
+ struct msm_property_value *property_values);
/**
* msm_property_destroy_state - helper function for destroy state cb
* @info: Pointer to property info container struct
* @state: Pointer to local state structure
- * @property_values: Pointer to property values cache array
- * @property_blobs: Pointer to property blobs cache array
+ * @property_state: Pointer to property state container struct
*/
void msm_property_destroy_state(struct msm_property_info *info,
void *state,
- uint64_t *property_values,
- struct drm_property_blob **property_blobs);
+ struct msm_property_state *property_state);
/**
* msm_property_get_blob - obtain cached data pointer for drm blob property
* @info: Pointer to property info container struct
- * @property_blobs: Pointer to property blobs cache array
+ * @property_state: Pointer to property state container struct
* @byte_len: Optional pointer to variable for accepting blob size
* @property_idx: Property index
* Returns: Pointer to blob data
*/
void *msm_property_get_blob(struct msm_property_info *info,
- struct drm_property_blob **property_blobs,
+ struct msm_property_state *property_state,
size_t *byte_len,
uint32_t property_idx);
@@ -385,13 +404,13 @@ int msm_property_set_blob(struct msm_property_info *info,
* DRM_MODE_PROP_IMMUTABLE flag set.
* Note: This function cannot be called on a blob.
* @info: Pointer to property info container struct
- * @property_values: Pointer to property values cache array
+ * @property_state: Pointer to property state container struct
* @property_idx: Property index
* @val: value of the property to set
* Returns: Zero on success
*/
int msm_property_set_property(struct msm_property_info *info,
- uint64_t *property_values,
+ struct msm_property_state *property_state,
uint32_t property_idx,
uint64_t val);
diff --git a/drivers/gpu/drm/msm/sde/sde_connector.c b/drivers/gpu/drm/msm/sde/sde_connector.c
index e87058e..f5e2ada 100644
--- a/drivers/gpu/drm/msm/sde/sde_connector.c
+++ b/drivers/gpu/drm/msm/sde/sde_connector.c
@@ -233,8 +233,8 @@ static int _sde_connector_get_default_dither_cfg_v1(
}
if (!c_conn->ops.get_dst_format) {
- SDE_ERROR("get_dst_format is invalid\n");
- return -EINVAL;
+ SDE_DEBUG("get_dst_format is unavailable\n");
+ return 0;
}
dst_format = c_conn->ops.get_dst_format(c_conn->display);
@@ -331,7 +331,7 @@ int sde_connector_get_dither_cfg(struct drm_connector *conn,
/* try to get user config data first */
*cfg = msm_property_get_blob(&c_conn->property_info,
- c_state->property_blobs,
+ &c_state->property_state,
&dither_sz,
CONNECTOR_PROP_PP_DITHER);
/* if user config data doesn't exist, use default dither blob */
@@ -459,13 +459,12 @@ static void _sde_connector_destroy_fb(struct sde_connector *c_conn,
drm_framebuffer_unreference(c_state->out_fb);
c_state->out_fb = NULL;
- if (c_conn) {
- c_state->property_values[CONNECTOR_PROP_OUT_FB] =
+ if (c_conn)
+ c_state->property_values[CONNECTOR_PROP_OUT_FB].value =
msm_property_get_default(&c_conn->property_info,
CONNECTOR_PROP_OUT_FB);
- } else {
- c_state->property_values[CONNECTOR_PROP_OUT_FB] = ~0;
- }
+ else
+ c_state->property_values[CONNECTOR_PROP_OUT_FB].value = ~0;
}
static void sde_connector_atomic_destroy_state(struct drm_connector *connector,
@@ -496,8 +495,7 @@ static void sde_connector_atomic_destroy_state(struct drm_connector *connector,
} else {
/* destroy value helper */
msm_property_destroy_state(&c_conn->property_info, c_state,
- c_state->property_values,
- c_state->property_blobs);
+ &c_state->property_state);
}
}
@@ -526,7 +524,8 @@ static void sde_connector_atomic_reset(struct drm_connector *connector)
/* reset value helper, zero out state structure and reset properties */
msm_property_reset_state(&c_conn->property_info, c_state,
- c_state->property_values, c_state->property_blobs);
+ &c_state->property_state,
+ c_state->property_values);
c_state->base.connector = connector;
connector->state = &c_state->base;
@@ -554,8 +553,8 @@ sde_connector_atomic_duplicate_state(struct drm_connector *connector)
/* duplicate value helper */
msm_property_duplicate_state(&c_conn->property_info,
- c_oldstate, c_state, c_state->property_values,
- c_state->property_blobs);
+ c_oldstate, c_state,
+ &c_state->property_state, c_state->property_values);
/* additional handling for drm framebuffer objects */
if (c_state->out_fb) {
@@ -755,8 +754,7 @@ static int sde_connector_atomic_set_property(struct drm_connector *connector,
/* generic property handling */
rc = msm_property_atomic_set(&c_conn->property_info,
- c_state->property_values, c_state->property_blobs,
- property, val);
+ &c_state->property_state, property, val);
if (rc)
goto end;
@@ -863,8 +861,7 @@ static int sde_connector_atomic_get_property(struct drm_connector *connector,
else
/* get cached property value */
rc = msm_property_atomic_get(&c_conn->property_info,
- c_state->property_values,
- c_state->property_blobs, property, val);
+ &c_state->property_state, property, val);
/* allow for custom override */
if (c_conn->ops.get_property)
diff --git a/drivers/gpu/drm/msm/sde/sde_connector.h b/drivers/gpu/drm/msm/sde/sde_connector.h
index 8796c52..1598968 100644
--- a/drivers/gpu/drm/msm/sde/sde_connector.h
+++ b/drivers/gpu/drm/msm/sde/sde_connector.h
@@ -315,6 +315,7 @@ struct sde_connector {
* @base: Base drm connector structure
* @out_fb: Pointer to output frame buffer, if applicable
* @aspace: Address space for accessing frame buffer objects, if applicable
+ * @property_state: Local storage for msm_prop properties
* @property_values: Local cache of current connector property values
* @rois: Regions of interest structure for mapping CRTC to Connector output
* @property_blobs: blob properties
@@ -323,7 +324,8 @@ struct sde_connector_state {
struct drm_connector_state base;
struct drm_framebuffer *out_fb;
struct msm_gem_address_space *aspace;
- uint64_t property_values[CONNECTOR_PROP_COUNT];
+ struct msm_property_state property_state;
+ struct msm_property_value property_values[CONNECTOR_PROP_COUNT];
struct msm_roi_list rois;
struct drm_property_blob *property_blobs[CONNECTOR_PROP_BLOBCOUNT];
@@ -346,15 +348,15 @@ struct sde_connector_state {
*/
#define sde_connector_get_property(S, X) \
((S) && ((X) < CONNECTOR_PROP_COUNT) ? \
- (to_sde_connector_state((S))->property_values[(X)]) : 0)
+ (to_sde_connector_state((S))->property_values[(X)].value) : 0)
/**
- * sde_connector_get_property_values - retrieve property values cache
+ * sde_connector_get_property_state - retrieve property state cache
* @S: Pointer to drm connector state
- * Returns: Integer value of requested property
+ * Returns: Pointer to local property state structure
*/
-#define sde_connector_get_property_values(S) \
- ((S) ? (to_sde_connector_state((S))->property_values) : 0)
+#define sde_connector_get_property_state(S) \
+ ((S) ? (&to_sde_connector_state((S))->property_state) : NULL)
/**
* sde_connector_get_out_fb - query out_fb value from sde connector state
diff --git a/drivers/gpu/drm/msm/sde/sde_crtc.c b/drivers/gpu/drm/msm/sde/sde_crtc.c
index ff802e6..01e4f93 100644
--- a/drivers/gpu/drm/msm/sde/sde_crtc.c
+++ b/drivers/gpu/drm/msm/sde/sde_crtc.c
@@ -2084,7 +2084,7 @@ static void sde_crtc_destroy_state(struct drm_crtc *crtc,
/* destroy value helper */
msm_property_destroy_state(&sde_crtc->property_info, cstate,
- cstate->property_values, cstate->property_blobs);
+ &cstate->property_state);
}
static int _sde_crtc_wait_for_frame_done(struct drm_crtc *crtc)
@@ -2344,7 +2344,7 @@ static struct drm_crtc_state *sde_crtc_duplicate_state(struct drm_crtc *crtc)
/* duplicate value helper */
msm_property_duplicate_state(&sde_crtc->property_info,
old_cstate, cstate,
- cstate->property_values, cstate->property_blobs);
+ &cstate->property_state, cstate->property_values);
/* duplicate base helper */
__drm_atomic_helper_crtc_duplicate_state(crtc, &cstate->base);
@@ -2389,7 +2389,8 @@ static void sde_crtc_reset(struct drm_crtc *crtc)
/* reset value helper */
msm_property_reset_state(&sde_crtc->property_info, cstate,
- cstate->property_values, cstate->property_blobs);
+ &cstate->property_state,
+ cstate->property_values);
_sde_crtc_set_input_fence_timeout(cstate);
@@ -3196,8 +3197,7 @@ static int sde_crtc_atomic_set_property(struct drm_crtc *crtc,
sde_crtc = to_sde_crtc(crtc);
cstate = to_sde_crtc_state(state);
ret = msm_property_atomic_set(&sde_crtc->property_info,
- cstate->property_values, cstate->property_blobs,
- property, val);
+ &cstate->property_state, property, val);
if (!ret) {
idx = msm_property_index(&sde_crtc->property_info,
property);
@@ -3317,8 +3317,8 @@ static int sde_crtc_atomic_get_property(struct drm_crtc *crtc,
SDE_ERROR("fence create failed\n");
} else {
ret = msm_property_atomic_get(&sde_crtc->property_info,
- cstate->property_values,
- cstate->property_blobs, property, val);
+ &cstate->property_state,
+ property, val);
if (ret)
ret = sde_cp_crtc_get_property(crtc,
property, val);
diff --git a/drivers/gpu/drm/msm/sde/sde_crtc.h b/drivers/gpu/drm/msm/sde/sde_crtc.h
index 86b7855..84f9ce1 100644
--- a/drivers/gpu/drm/msm/sde/sde_crtc.h
+++ b/drivers/gpu/drm/msm/sde/sde_crtc.h
@@ -269,9 +269,9 @@ struct sde_crtc_respool {
* @lm_roi : Current LM ROI, possibly sub-rectangle of mode.
* Origin top left of CRTC.
* @user_roi_list : List of user's requested ROIs as from set property
+ * @property_state: Local storage for msm_prop properties
* @property_values: Current crtc property values
* @input_fence_timeout_ns : Cached input fence timeout, in ns
- * @property_blobs: Reference pointers for blob properties
* @num_dim_layers: Number of dim layers
* @dim_layer: Dim layer configs
* @new_perf: new performance state being requested
@@ -296,9 +296,9 @@ struct sde_crtc_state {
struct sde_rect lm_roi[CRTC_DUAL_MIXERS];
struct msm_roi_list user_roi_list;
- uint64_t property_values[CRTC_PROP_COUNT];
+ struct msm_property_state property_state;
+ struct msm_property_value property_values[CRTC_PROP_COUNT];
uint64_t input_fence_timeout_ns;
- struct drm_property_blob *property_blobs[CRTC_PROP_COUNT];
uint32_t num_dim_layers;
struct sde_hw_dim_layer dim_layer[SDE_MAX_DIM_LAYERS];
@@ -320,7 +320,7 @@ struct sde_crtc_state {
* Returns: Integer value of requested property
*/
#define sde_crtc_get_property(S, X) \
- ((S) && ((X) < CRTC_PROP_COUNT) ? ((S)->property_values[(X)]) : 0)
+ ((S) && ((X) < CRTC_PROP_COUNT) ? ((S)->property_values[(X)].value) : 0)
static inline int sde_crtc_mixer_width(struct sde_crtc *sde_crtc,
struct drm_display_mode *mode)
diff --git a/drivers/gpu/drm/msm/sde/sde_plane.c b/drivers/gpu/drm/msm/sde/sde_plane.c
index 665315d..90e6caf 100644
--- a/drivers/gpu/drm/msm/sde/sde_plane.c
+++ b/drivers/gpu/drm/msm/sde/sde_plane.c
@@ -957,15 +957,15 @@ static int _sde_plane_setup_scaler3_lut(struct sde_plane *psde,
cfg->dir_lut = msm_property_get_blob(
&psde->property_info,
- pstate->property_blobs, &cfg->dir_len,
+ &pstate->property_state, &cfg->dir_len,
PLANE_PROP_SCALER_LUT_ED);
cfg->cir_lut = msm_property_get_blob(
&psde->property_info,
- pstate->property_blobs, &cfg->cir_len,
+ &pstate->property_state, &cfg->cir_len,
PLANE_PROP_SCALER_LUT_CIR);
cfg->sep_lut = msm_property_get_blob(
&psde->property_info,
- pstate->property_blobs, &cfg->sep_len,
+ &pstate->property_state, &cfg->sep_len,
PLANE_PROP_SCALER_LUT_SEP);
if (!cfg->dir_lut || !cfg->cir_lut || !cfg->sep_lut)
ret = -ENODATA;
@@ -1276,7 +1276,7 @@ static void sde_color_process_plane_setup(struct drm_plane *plane)
if (psde->pipe_hw->ops.setup_pa_memcolor) {
/* Skin memory color setup */
memcol = msm_property_get_blob(&psde->property_info,
- pstate->property_blobs,
+ &pstate->property_state,
&memcol_sz,
PLANE_PROP_SKIN_COLOR);
psde->pipe_hw->ops.setup_pa_memcolor(psde->pipe_hw,
@@ -1284,7 +1284,7 @@ static void sde_color_process_plane_setup(struct drm_plane *plane)
/* Sky memory color setup */
memcol = msm_property_get_blob(&psde->property_info,
- pstate->property_blobs,
+ &pstate->property_state,
&memcol_sz,
PLANE_PROP_SKY_COLOR);
psde->pipe_hw->ops.setup_pa_memcolor(psde->pipe_hw,
@@ -1292,7 +1292,7 @@ static void sde_color_process_plane_setup(struct drm_plane *plane)
/* Foliage memory color setup */
memcol = msm_property_get_blob(&psde->property_info,
- pstate->property_blobs,
+ &pstate->property_state,
&memcol_sz,
PLANE_PROP_FOLIAGE_COLOR);
psde->pipe_hw->ops.setup_pa_memcolor(psde->pipe_hw,
@@ -3250,7 +3250,8 @@ static int sde_plane_sspp_atomic_update(struct drm_plane *plane,
}
/* determine what needs to be refreshed */
- while ((idx = msm_property_pop_dirty(&psde->property_info)) >= 0) {
+ while ((idx = msm_property_pop_dirty(&psde->property_info,
+ &pstate->property_state)) >= 0) {
switch (idx) {
case PLANE_PROP_SCALER_V1:
case PLANE_PROP_SCALER_V2:
@@ -3908,7 +3909,8 @@ static inline void _sde_plane_set_scaler_v1(struct sde_plane *psde,
}
/* force property to be dirty, even if the pointer didn't change */
- msm_property_set_dirty(&psde->property_info, PLANE_PROP_SCALER_V1);
+ msm_property_set_dirty(&psde->property_info,
+ &pstate->property_state, PLANE_PROP_SCALER_V1);
/* populate from user space */
pe = &pstate->pixel_ext;
@@ -3974,7 +3976,8 @@ static inline void _sde_plane_set_scaler_v2(struct sde_plane *psde,
}
/* force property to be dirty, even if the pointer didn't change */
- msm_property_set_dirty(&psde->property_info, PLANE_PROP_SCALER_V2);
+ msm_property_set_dirty(&psde->property_info,
+ &pstate->property_state, PLANE_PROP_SCALER_V2);
/* populate from user space */
pe = &pstate->pixel_ext;
@@ -4091,8 +4094,7 @@ static int sde_plane_atomic_set_property(struct drm_plane *plane,
} else {
pstate = to_sde_plane_state(state);
ret = msm_property_atomic_set(&psde->property_info,
- pstate->property_values, pstate->property_blobs,
- property, val);
+ &pstate->property_state, property, val);
if (!ret) {
idx = msm_property_index(&psde->property_info,
property);
@@ -4109,7 +4111,7 @@ static int sde_plane_atomic_set_property(struct drm_plane *plane,
break;
case PLANE_PROP_SCALER_V2:
_sde_plane_set_scaler_v2(psde, pstate,
- (void *)val);
+ (void *)val);
break;
case PLANE_PROP_EXCL_RECT_V1:
_sde_plane_set_excl_rect_v1(psde, pstate,
@@ -4154,8 +4156,7 @@ static int sde_plane_atomic_get_property(struct drm_plane *plane,
pstate = to_sde_plane_state(state);
sde_plane_rot_install_caps(plane);
ret = msm_property_atomic_get(&psde->property_info,
- pstate->property_values, pstate->property_blobs,
- property, val);
+ &pstate->property_state, property, val);
}
return ret;
@@ -4216,7 +4217,7 @@ static void sde_plane_destroy_state(struct drm_plane *plane,
/* destroy value helper */
msm_property_destroy_state(&psde->property_info, pstate,
- pstate->property_values, pstate->property_blobs);
+ &pstate->property_state);
}
static struct drm_plane_state *
@@ -4247,13 +4248,14 @@ sde_plane_duplicate_state(struct drm_plane *plane)
/* duplicate value helper */
msm_property_duplicate_state(&psde->property_info, old_state, pstate,
- pstate->property_values, pstate->property_blobs);
+ &pstate->property_state, pstate->property_values);
/* clear out any input fence */
pstate->input_fence = 0;
input_fence_default = msm_property_get_default(
&psde->property_info, PLANE_PROP_INPUT_FENCE);
- msm_property_set_property(&psde->property_info, pstate->property_values,
+ msm_property_set_property(&psde->property_info,
+ &pstate->property_state,
PLANE_PROP_INPUT_FENCE, input_fence_default);
pstate->dirty = 0x0;
@@ -4293,7 +4295,8 @@ static void sde_plane_reset(struct drm_plane *plane)
/* reset value helper */
msm_property_reset_state(&psde->property_info, pstate,
- pstate->property_values, pstate->property_blobs);
+ &pstate->property_state,
+ pstate->property_values);
pstate->base.plane = plane;
diff --git a/drivers/gpu/drm/msm/sde/sde_plane.h b/drivers/gpu/drm/msm/sde/sde_plane.h
index 2f0068a..a5599a5 100644
--- a/drivers/gpu/drm/msm/sde/sde_plane.h
+++ b/drivers/gpu/drm/msm/sde/sde_plane.h
@@ -119,8 +119,8 @@ enum sde_plane_sclcheck_state {
/**
* struct sde_plane_state: Define sde extension of drm plane state object
* @base: base drm plane state object
+ * @property_state: Local storage for msm_prop properties
* @property_values: cached plane property values
- * @property_blobs: blob properties
* @aspace: pointer to address space for input/output buffers
* @input_fence: dereferenced input fence pointer
* @stage: assigned by crtc blender
@@ -136,8 +136,8 @@ enum sde_plane_sclcheck_state {
*/
struct sde_plane_state {
struct drm_plane_state base;
- uint64_t property_values[PLANE_PROP_COUNT];
- struct drm_property_blob *property_blobs[PLANE_PROP_BLOBCOUNT];
+ struct msm_property_state property_state;
+ struct msm_property_value property_values[PLANE_PROP_COUNT];
struct msm_gem_address_space *aspace;
void *input_fence;
enum sde_stage stage;
@@ -178,8 +178,8 @@ struct sde_multirect_plane_states {
* @X: Property index, from enum msm_mdp_plane_property
* Returns: Integer value of requested property
*/
-#define sde_plane_get_property(S, X) \
- ((S) && ((X) < PLANE_PROP_COUNT) ? ((S)->property_values[(X)]) : 0)
+#define sde_plane_get_property(S, X) ((S) && ((X) < PLANE_PROP_COUNT) ? \
+ ((S)->property_values[(X)].value) : 0)
/**
* sde_plane_pipe - return sspp identifier for the given plane
diff --git a/drivers/gpu/drm/msm/sde/sde_rm.c b/drivers/gpu/drm/msm/sde/sde_rm.c
index 0382ed0..be3a8af 100644
--- a/drivers/gpu/drm/msm/sde/sde_rm.c
+++ b/drivers/gpu/drm/msm/sde/sde_rm.c
@@ -1150,7 +1150,7 @@ void sde_rm_release(struct sde_rm *rm, struct drm_encoder *enc)
(void) msm_property_set_property(
sde_connector_get_propinfo(conn),
- sde_connector_get_property_values(conn->state),
+ sde_connector_get_property_state(conn->state),
CONNECTOR_PROP_TOPOLOGY_NAME,
SDE_RM_TOPOLOGY_NONE);
}
@@ -1170,7 +1170,7 @@ static int _sde_rm_commit_rsvp(
ret = msm_property_set_property(
sde_connector_get_propinfo(conn_state->connector),
- sde_connector_get_property_values(conn_state),
+ sde_connector_get_property_state(conn_state),
CONNECTOR_PROP_TOPOLOGY_NAME,
rsvp->topology);
if (ret) {
@@ -1267,7 +1267,7 @@ int sde_rm_reserve(
(void) msm_property_set_property(
sde_connector_get_propinfo(
conn_state->connector),
- sde_connector_get_property_values(conn_state),
+ sde_connector_get_property_state(conn_state),
CONNECTOR_PROP_TOPOLOGY_NAME,
SDE_RM_TOPOLOGY_NONE);
}
diff --git a/drivers/gpu/drm/msm/sde_edid_parser.c b/drivers/gpu/drm/msm/sde_edid_parser.c
index 130bd1f..3c03b92 100644
--- a/drivers/gpu/drm/msm/sde_edid_parser.c
+++ b/drivers/gpu/drm/msm/sde_edid_parser.c
@@ -228,10 +228,17 @@ u32 video_format)
{
u8 cea_mode = 0;
struct drm_display_mode *mode;
+ u32 mode_fmt_flags = 0;
/* Need to add Y420 support flag to the modes */
list_for_each_entry(mode, &connector->probed_modes, head) {
+ /* Cache the format flags before clearing */
+ mode_fmt_flags = mode->flags;
+ /* Clear the RGB/YUV format flags before calling upstream API */
+ mode->flags &= ~SDE_DRM_MODE_FLAG_FMT_MASK;
cea_mode = drm_match_cea_mode(mode);
+ /* Restore the format flags */
+ mode->flags = mode_fmt_flags;
if ((cea_mode != 0) && (cea_mode == video_format)) {
SDE_EDID_DEBUG("%s found match for %d ", __func__,
video_format);
@@ -245,7 +252,7 @@ struct drm_connector *connector, struct sde_edid_ctrl *edid_ctrl,
const u8 *db)
{
u32 offset = 0;
- u8 len = 0;
+ u8 cmdb_len = 0;
u8 svd_len = 0;
const u8 *svd = NULL;
u32 i = 0, j = 0;
@@ -261,10 +268,8 @@ const u8 *db)
return;
}
SDE_EDID_DEBUG("%s +\n", __func__);
- len = db[0] & 0x1f;
+ cmdb_len = db[0] & 0x1f;
- if (len < 7)
- return;
/* Byte 3 to L+1 contain SVDs */
offset += 2;
@@ -272,20 +277,24 @@ const u8 *db)
if (svd) {
/*moving to the next byte as vic info begins there*/
- ++svd;
svd_len = svd[0] & 0x1f;
+ ++svd;
}
for (i = 0; i < svd_len; i++, j++) {
- video_format = *svd & 0x7F;
- if (db[offset] & (1 << j))
+ video_format = *(svd + i) & 0x7F;
+ if (cmdb_len == 1) {
+ /* If cmdb_len is 1, it means all SVDs support YUV */
+ sde_edid_set_y420_support(connector, video_format);
+ } else if (db[offset] & (1 << j)) {
sde_edid_set_y420_support(connector, video_format);
- if (j & 0x80) {
- j = j/8;
- offset++;
- if (offset >= len)
- break;
+ if (j & 0x80) {
+ j = j/8;
+ offset++;
+ if (offset >= cmdb_len)
+ break;
+ }
}
}
diff --git a/drivers/gpu/drm/msm/sde_edid_parser.h b/drivers/gpu/drm/msm/sde_edid_parser.h
index eb68439..b58b322 100644
--- a/drivers/gpu/drm/msm/sde_edid_parser.h
+++ b/drivers/gpu/drm/msm/sde_edid_parser.h
@@ -33,6 +33,8 @@
#define SDE_CEA_EXT 0x02
#define SDE_EXTENDED_TAG 0x07
+#define SDE_DRM_MODE_FLAG_FMT_MASK (0x3 << 20)
+
enum extended_data_block_types {
VIDEO_CAPABILITY_DATA_BLOCK = 0x0,
VENDOR_SPECIFIC_VIDEO_DATA_BLOCK = 0x01,
diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c
index 6f465aa..6426363 100644
--- a/drivers/gpu/msm/adreno.c
+++ b/drivers/gpu/msm/adreno.c
@@ -2342,6 +2342,11 @@ int adreno_soft_reset(struct kgsl_device *device)
return ret;
}
+ /* Clear the busy_data stats - we're starting over from scratch */
+ adreno_dev->busy_data.gpu_busy = 0;
+ adreno_dev->busy_data.vbif_ram_cycles = 0;
+ adreno_dev->busy_data.vbif_starved_ram = 0;
+
/* Set the page table back to the default page table */
adreno_ringbuffer_set_global(adreno_dev, 0);
kgsl_mmu_set_pt(&device->mmu, device->mmu.defaultpagetable);
diff --git a/drivers/gpu/msm/adreno_dispatch.c b/drivers/gpu/msm/adreno_dispatch.c
index 422c434..0a45d27 100644
--- a/drivers/gpu/msm/adreno_dispatch.c
+++ b/drivers/gpu/msm/adreno_dispatch.c
@@ -983,6 +983,13 @@ static void _adreno_dispatcher_issuecmds(struct adreno_device *adreno_dev)
spin_unlock(&dispatcher->plist_lock);
}
+static inline void _decrement_submit_now(struct kgsl_device *device)
+{
+ spin_lock(&device->submit_lock);
+ device->submit_now--;
+ spin_unlock(&device->submit_lock);
+}
+
/**
* adreno_dispatcher_issuecmds() - Issue commmands from pending contexts
* @adreno_dev: Pointer to the adreno device struct
@@ -992,15 +999,29 @@ static void _adreno_dispatcher_issuecmds(struct adreno_device *adreno_dev)
static void adreno_dispatcher_issuecmds(struct adreno_device *adreno_dev)
{
struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
+ struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
+
+ spin_lock(&device->submit_lock);
+ /* If state transition to SLUMBER, schedule the work for later */
+ if (device->slumber == true) {
+ spin_unlock(&device->submit_lock);
+ goto done;
+ }
+ device->submit_now++;
+ spin_unlock(&device->submit_lock);
/* If the dispatcher is busy then schedule the work for later */
if (!mutex_trylock(&dispatcher->mutex)) {
- adreno_dispatcher_schedule(KGSL_DEVICE(adreno_dev));
- return;
+ _decrement_submit_now(device);
+ goto done;
}
_adreno_dispatcher_issuecmds(adreno_dev);
mutex_unlock(&dispatcher->mutex);
+ _decrement_submit_now(device);
+ return;
+done:
+ adreno_dispatcher_schedule(device);
}
/**
@@ -2452,7 +2473,7 @@ static void _dispatcher_power_down(struct adreno_device *adreno_dev)
mutex_unlock(&device->mutex);
}
-static void adreno_dispatcher_work(struct work_struct *work)
+static void adreno_dispatcher_work(struct kthread_work *work)
{
struct adreno_dispatcher *dispatcher =
container_of(work, struct adreno_dispatcher, work);
@@ -2512,7 +2533,7 @@ void adreno_dispatcher_schedule(struct kgsl_device *device)
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
- kgsl_schedule_work(&dispatcher->work);
+ kthread_queue_work(&kgsl_driver.worker, &dispatcher->work);
}
/**
@@ -2808,7 +2829,7 @@ int adreno_dispatcher_init(struct adreno_device *adreno_dev)
setup_timer(&dispatcher->fault_timer, adreno_dispatcher_fault_timer,
(unsigned long) adreno_dev);
- INIT_WORK(&dispatcher->work, adreno_dispatcher_work);
+ kthread_init_work(&dispatcher->work, adreno_dispatcher_work);
init_completion(&dispatcher->idle_gate);
complete_all(&dispatcher->idle_gate);
diff --git a/drivers/gpu/msm/adreno_dispatch.h b/drivers/gpu/msm/adreno_dispatch.h
index 72545db..48f0cdc 100644
--- a/drivers/gpu/msm/adreno_dispatch.h
+++ b/drivers/gpu/msm/adreno_dispatch.h
@@ -91,7 +91,7 @@ struct adreno_dispatcher {
atomic_t fault;
struct plist_head pending;
spinlock_t plist_lock;
- struct work_struct work;
+ struct kthread_work work;
struct kobject kobj;
struct completion idle_gate;
unsigned int disp_preempt_fair_sched;
diff --git a/drivers/gpu/msm/adreno_drawctxt.c b/drivers/gpu/msm/adreno_drawctxt.c
index c6df7bb..0882447 100644
--- a/drivers/gpu/msm/adreno_drawctxt.c
+++ b/drivers/gpu/msm/adreno_drawctxt.c
@@ -548,6 +548,8 @@ void adreno_drawctxt_detach(struct kgsl_context *context)
mutex_unlock(&device->mutex);
+ debugfs_remove_recursive(drawctxt->debug_root);
+
/* wake threads waiting to submit commands from this context */
wake_up_all(&drawctxt->waiting);
wake_up_all(&drawctxt->wq);
@@ -569,7 +571,6 @@ void adreno_drawctxt_destroy(struct kgsl_context *context)
gpudev->preemption_context_destroy(context);
drawctxt = ADRENO_CONTEXT(context);
- debugfs_remove_recursive(drawctxt->debug_root);
kfree(drawctxt);
}
diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c
index 129e99c..f88132f 100644
--- a/drivers/gpu/msm/kgsl.c
+++ b/drivers/gpu/msm/kgsl.c
@@ -4645,6 +4645,7 @@ int kgsl_device_platform_probe(struct kgsl_device *device)
device->id, device->reg_phys, device->reg_len);
rwlock_init(&device->context_lock);
+ spin_lock_init(&device->submit_lock);
setup_timer(&device->idle_timer, kgsl_timer, (unsigned long) device);
@@ -4788,6 +4789,8 @@ static void kgsl_core_exit(void)
static int __init kgsl_core_init(void)
{
int result = 0;
+ struct sched_param param = { .sched_priority = 2 };
+
/* alloc major and minor device numbers */
result = alloc_chrdev_region(&kgsl_driver.major, 0, KGSL_DEVICE_MAX,
"kgsl");
@@ -4854,6 +4857,18 @@ static int __init kgsl_core_init(void)
kgsl_driver.mem_workqueue = alloc_workqueue("kgsl-mementry",
WQ_UNBOUND | WQ_MEM_RECLAIM, 0);
+ kthread_init_worker(&kgsl_driver.worker);
+
+ kgsl_driver.worker_thread = kthread_run(kthread_worker_fn,
+ &kgsl_driver.worker, "kgsl_worker_thread");
+
+ if (IS_ERR(kgsl_driver.worker_thread)) {
+ pr_err("unable to start kgsl thread\n");
+ goto err;
+ }
+
+ sched_setscheduler(kgsl_driver.worker_thread, SCHED_FIFO, ¶m);
+
kgsl_events_init();
result = kgsl_drawobjs_cache_init();
diff --git a/drivers/gpu/msm/kgsl.h b/drivers/gpu/msm/kgsl.h
index c54e51e..f80da79 100644
--- a/drivers/gpu/msm/kgsl.h
+++ b/drivers/gpu/msm/kgsl.h
@@ -25,6 +25,7 @@
#include <linux/regulator/consumer.h>
#include <linux/mm.h>
#include <linux/uaccess.h>
+#include <linux/kthread.h>
#include <asm/cacheflush.h>
/*
@@ -151,6 +152,8 @@ struct kgsl_driver {
unsigned int full_cache_threshold;
struct workqueue_struct *workqueue;
struct workqueue_struct *mem_workqueue;
+ struct kthread_worker worker;
+ struct task_struct *worker_thread;
};
extern struct kgsl_driver kgsl_driver;
@@ -300,7 +303,7 @@ struct kgsl_event {
void *priv;
struct list_head node;
unsigned int created;
- struct work_struct work;
+ struct kthread_work work;
int result;
struct kgsl_event_group *group;
};
diff --git a/drivers/gpu/msm/kgsl_device.h b/drivers/gpu/msm/kgsl_device.h
index b621ada..4aaea80 100644
--- a/drivers/gpu/msm/kgsl_device.h
+++ b/drivers/gpu/msm/kgsl_device.h
@@ -269,6 +269,11 @@ struct kgsl_device {
struct kgsl_pwrctrl pwrctrl;
int open_count;
+ /* For GPU inline submission */
+ uint32_t submit_now;
+ spinlock_t submit_lock;
+ bool slumber;
+
struct mutex mutex;
uint32_t state;
uint32_t requested_state;
diff --git a/drivers/gpu/msm/kgsl_events.c b/drivers/gpu/msm/kgsl_events.c
index d042f05..759a966 100644
--- a/drivers/gpu/msm/kgsl_events.c
+++ b/drivers/gpu/msm/kgsl_events.c
@@ -32,7 +32,7 @@ static inline void signal_event(struct kgsl_device *device,
{
list_del(&event->node);
event->result = result;
- queue_work(device->events_wq, &event->work);
+ kthread_queue_work(&kgsl_driver.worker, &event->work);
}
/**
@@ -42,7 +42,7 @@ static inline void signal_event(struct kgsl_device *device,
* Each event callback has its own work struct and is run on a event specific
* workqeuue. This is the worker that queues up the event callback function.
*/
-static void _kgsl_event_worker(struct work_struct *work)
+static void _kgsl_event_worker(struct kthread_work *work)
{
struct kgsl_event *event = container_of(work, struct kgsl_event, work);
int id = KGSL_CONTEXT_ID(event->context);
@@ -286,7 +286,7 @@ int kgsl_add_event(struct kgsl_device *device, struct kgsl_event_group *group,
event->created = jiffies;
event->group = group;
- INIT_WORK(&event->work, _kgsl_event_worker);
+ kthread_init_work(&event->work, _kgsl_event_worker);
trace_kgsl_register_event(KGSL_CONTEXT_ID(context), timestamp, func);
@@ -301,7 +301,7 @@ int kgsl_add_event(struct kgsl_device *device, struct kgsl_event_group *group,
if (timestamp_cmp(retired, timestamp) >= 0) {
event->result = KGSL_EVENT_RETIRED;
- queue_work(device->events_wq, &event->work);
+ kthread_queue_work(&kgsl_driver.worker, &event->work);
spin_unlock(&group->lock);
return 0;
}
diff --git a/drivers/gpu/msm/kgsl_pwrctrl.c b/drivers/gpu/msm/kgsl_pwrctrl.c
index 5c53a05c..6710cd2 100644
--- a/drivers/gpu/msm/kgsl_pwrctrl.c
+++ b/drivers/gpu/msm/kgsl_pwrctrl.c
@@ -1049,6 +1049,8 @@ static void __force_on(struct kgsl_device *device, int flag, int on)
if (on) {
switch (flag) {
case KGSL_PWRFLAGS_CLK_ON:
+ /* make sure pwrrail is ON before enabling clocks */
+ kgsl_pwrctrl_pwrrail(device, KGSL_PWRFLAGS_ON);
kgsl_pwrctrl_clk(device, KGSL_PWRFLAGS_ON,
KGSL_STATE_ACTIVE);
break;
@@ -1854,7 +1856,12 @@ static int kgsl_pwrctrl_pwrrail(struct kgsl_device *device, int state)
if (kgsl_gmu_isenabled(device))
return 0;
- if (test_bit(KGSL_PWRFLAGS_POWER_ON, &pwr->ctrl_flags))
+ /*
+ * Disabling the regulator means also disabling dependent clocks.
+ * Hence don't disable it if force clock ON is set.
+ */
+ if (test_bit(KGSL_PWRFLAGS_POWER_ON, &pwr->ctrl_flags) ||
+ test_bit(KGSL_PWRFLAGS_CLK_ON, &pwr->ctrl_flags))
return 0;
if (state == KGSL_PWRFLAGS_OFF) {
@@ -2362,9 +2369,24 @@ void kgsl_idle_check(struct work_struct *work)
|| device->state == KGSL_STATE_NAP) {
if (!atomic_read(&device->active_cnt)) {
+ spin_lock(&device->submit_lock);
+ if (device->submit_now) {
+ spin_unlock(&device->submit_lock);
+ goto done;
+ }
+ /* Don't allow GPU inline submission in SLUMBER */
+ if (requested_state == KGSL_STATE_SLUMBER)
+ device->slumber = true;
+ spin_unlock(&device->submit_lock);
+
ret = kgsl_pwrctrl_change_state(device,
device->requested_state);
if (ret == -EBUSY) {
+ if (requested_state == KGSL_STATE_SLUMBER) {
+ spin_lock(&device->submit_lock);
+ device->slumber = false;
+ spin_unlock(&device->submit_lock);
+ }
/*
* If the GPU is currently busy, restore
* the requested state and reschedule
@@ -2375,7 +2397,7 @@ void kgsl_idle_check(struct work_struct *work)
kgsl_schedule_work(&device->idle_check_ws);
}
}
-
+done:
if (!ret)
kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE);
@@ -2835,6 +2857,13 @@ static void kgsl_pwrctrl_set_state(struct kgsl_device *device,
trace_kgsl_pwr_set_state(device, state);
device->state = state;
device->requested_state = KGSL_STATE_NONE;
+
+ spin_lock(&device->submit_lock);
+ if (state == KGSL_STATE_SLUMBER || state == KGSL_STATE_SUSPEND)
+ device->slumber = true;
+ else
+ device->slumber = false;
+ spin_unlock(&device->submit_lock);
}
static void kgsl_pwrctrl_request_state(struct kgsl_device *device,
diff --git a/drivers/gpu/msm/kgsl_sharedmem.c b/drivers/gpu/msm/kgsl_sharedmem.c
index f0f202b..5061f6a 100644
--- a/drivers/gpu/msm/kgsl_sharedmem.c
+++ b/drivers/gpu/msm/kgsl_sharedmem.c
@@ -741,6 +741,8 @@ kgsl_sharedmem_page_alloc_user(struct kgsl_memdesc *memdesc,
*/
memdesc->pages = kgsl_malloc(len_alloc * sizeof(struct page *));
+ memdesc->page_count = 0;
+ memdesc->size = 0;
if (memdesc->pages == NULL) {
ret = -ENOMEM;
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
index d6941ea..202d867 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
@@ -171,8 +171,11 @@ static int tmc_enable_etf_sink_sysfs(struct coresight_device *csdev, u32 mode)
if (!used)
kfree(buf);
- if (!ret)
+ if (!ret) {
+ coresight_cti_map_trigin(drvdata->cti_reset, 2, 0);
+ coresight_cti_map_trigout(drvdata->cti_flush, 1, 0);
dev_info(drvdata->dev, "TMC-ETB/ETF enabled\n");
+ }
return ret;
}
@@ -244,6 +247,9 @@ static void tmc_disable_etf_sink(struct coresight_device *csdev)
spin_unlock_irqrestore(&drvdata->spinlock, flags);
+ coresight_cti_unmap_trigin(drvdata->cti_reset, 2, 0);
+ coresight_cti_unmap_trigout(drvdata->cti_flush, 1, 0);
+
dev_info(drvdata->dev, "TMC-ETB/ETF disabled\n");
}
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
index 9e6f443..3234928 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
@@ -800,6 +800,8 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev, u32 mode)
mutex_unlock(&drvdata->mem_lock);
return ret;
}
+ coresight_cti_map_trigout(drvdata->cti_flush, 3, 0);
+ coresight_cti_map_trigin(drvdata->cti_reset, 2, 0);
} else {
drvdata->usbch = usb_qdss_open("qdss", drvdata,
usb_notifier);
@@ -891,6 +893,7 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev)
unsigned long flags;
struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+ mutex_lock(&drvdata->mem_lock);
spin_lock_irqsave(&drvdata->spinlock, flags);
if (drvdata->reading) {
spin_unlock_irqrestore(&drvdata->spinlock, flags);
@@ -911,6 +914,11 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev)
spin_unlock_irqrestore(&drvdata->spinlock, flags);
+ if (drvdata->out_mode == TMC_ETR_OUT_MODE_MEM) {
+ coresight_cti_unmap_trigin(drvdata->cti_reset, 2, 0);
+ coresight_cti_unmap_trigout(drvdata->cti_flush, 3, 0);
+ }
+ mutex_unlock(&drvdata->mem_lock);
dev_info(drvdata->dev, "TMC-ETR disabled\n");
}
diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c
index 98fcd01..b97ebb8 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.c
+++ b/drivers/hwtracing/coresight/coresight-tmc.c
@@ -361,6 +361,9 @@ static ssize_t out_mode_store(struct device *dev,
drvdata->out_mode = TMC_ETR_OUT_MODE_MEM;
spin_unlock_irqrestore(&drvdata->spinlock, flags);
+ coresight_cti_map_trigout(drvdata->cti_flush, 3, 0);
+ coresight_cti_map_trigin(drvdata->cti_reset, 2, 0);
+
tmc_etr_bam_disable(drvdata);
usb_qdss_close(drvdata->usbch);
} else if (!strcmp(str, str_tmc_etr_out_mode[TMC_ETR_OUT_MODE_USB])) {
@@ -381,6 +384,9 @@ static ssize_t out_mode_store(struct device *dev,
drvdata->out_mode = TMC_ETR_OUT_MODE_USB;
spin_unlock_irqrestore(&drvdata->spinlock, flags);
+ coresight_cti_unmap_trigout(drvdata->cti_flush, 3, 0);
+ coresight_cti_unmap_trigin(drvdata->cti_reset, 2, 0);
+
drvdata->usbch = usb_qdss_open("qdss", drvdata,
usb_notifier);
if (IS_ERR(drvdata->usbch)) {
@@ -503,6 +509,7 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
struct resource *res = &adev->res;
struct coresight_desc desc = { 0 };
struct device_node *np = adev->dev.of_node;
+ struct coresight_cti_data *ctidata;
pdata = of_get_coresight_platform_data(dev, np);
if (IS_ERR(pdata)) {
@@ -554,6 +561,19 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
pm_runtime_put(&adev->dev);
+ ctidata = of_get_coresight_cti_data(dev, adev->dev.of_node);
+ if (IS_ERR(ctidata)) {
+ dev_err(dev, "invalid cti data\n");
+ } else if (ctidata && ctidata->nr_ctis == 2) {
+ drvdata->cti_flush = coresight_cti_get(ctidata->names[0]);
+ if (IS_ERR(drvdata->cti_flush))
+ dev_err(dev, "failed to get flush cti\n");
+
+ drvdata->cti_reset = coresight_cti_get(ctidata->names[1]);
+ if (IS_ERR(drvdata->cti_reset))
+ dev_err(dev, "failed to get reset cti\n");
+ }
+
desc.pdata = pdata;
desc.dev = dev;
if (drvdata->config_type == TMC_CONFIG_TYPE_ETB) {
diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h
index a9de0e8..6643adc 100644
--- a/drivers/hwtracing/coresight/coresight-tmc.h
+++ b/drivers/hwtracing/coresight/coresight-tmc.h
@@ -25,6 +25,7 @@
#include <linux/amba/bus.h>
#include <linux/usb_bam.h>
#include <linux/usb/usb_qdss.h>
+#include <linux/coresight-cti.h>
#define TMC_RSZ 0x004
#define TMC_STS 0x00c
@@ -184,7 +185,8 @@ struct tmc_drvdata {
struct tmc_etr_bam_data *bamdata;
bool enable_to_bam;
bool sticky_enable;
-
+ struct coresight_cti *cti_flush;
+ struct coresight_cti *cti_reset;
};
/* Generic functions */
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index 2492f90..81bbd78 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, 2016 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012, 2016-2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -23,7 +23,7 @@
#include <linux/coresight.h>
#include <linux/cpumask.h>
#include <asm/smp_plat.h>
-
+#include <linux/coresight-cti.h>
static int of_dev_node_match(struct device *dev, void *data)
{
@@ -196,3 +196,45 @@ struct coresight_platform_data *of_get_coresight_platform_data(
return pdata;
}
EXPORT_SYMBOL_GPL(of_get_coresight_platform_data);
+
+struct coresight_cti_data *of_get_coresight_cti_data(
+ struct device *dev, struct device_node *node)
+{
+ int i, ret;
+ uint32_t ctis_len;
+ struct device_node *child_node;
+ struct coresight_cti_data *ctidata;
+
+ ctidata = devm_kzalloc(dev, sizeof(*ctidata), GFP_KERNEL);
+ if (!ctidata)
+ return ERR_PTR(-ENOMEM);
+
+ if (of_get_property(node, "coresight-ctis", &ctis_len))
+ ctidata->nr_ctis = ctis_len/sizeof(uint32_t);
+ else
+ return ERR_PTR(-EINVAL);
+
+ if (ctidata->nr_ctis) {
+ ctidata->names = devm_kzalloc(dev, ctidata->nr_ctis *
+ sizeof(*ctidata->names),
+ GFP_KERNEL);
+ if (!ctidata->names)
+ return ERR_PTR(-ENOMEM);
+
+ for (i = 0; i < ctidata->nr_ctis; i++) {
+ child_node = of_parse_phandle(node, "coresight-ctis",
+ i);
+ if (!child_node)
+ return ERR_PTR(-EINVAL);
+
+ ret = of_property_read_string(child_node,
+ "coresight-name",
+ &ctidata->names[i]);
+ of_node_put(child_node);
+ if (ret)
+ return ERR_PTR(ret);
+ }
+ }
+ return ctidata;
+}
+EXPORT_SYMBOL(of_get_coresight_cti_data);
diff --git a/drivers/mailbox/qti-tcs.c b/drivers/mailbox/qti-tcs.c
index c50fc0e..a1e0908 100644
--- a/drivers/mailbox/qti-tcs.c
+++ b/drivers/mailbox/qti-tcs.c
@@ -11,12 +11,13 @@
*
*/
-#define pr_fmt(fmt) "%s:%s " fmt, KBUILD_MODNAME, __func__
+#define pr_fmt(fmt) "%s " fmt, KBUILD_MODNAME
#include <linux/atomic.h>
#include <linux/bitmap.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
+#include <linux/ipc_logging.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/list.h>
@@ -40,6 +41,8 @@
#define CREATE_TRACE_POINTS
#include <trace/events/rpmh.h>
+#define TCS_DRV_IPC_LOG_SIZE 2
+
#define MAX_CMDS_PER_TCS 16
#define MAX_TCS_PER_TYPE 3
#define MAX_TCS_SLOTS (MAX_CMDS_PER_TCS * MAX_TCS_PER_TYPE)
@@ -140,8 +143,35 @@ struct tcs_drv {
u64 tcs_last_recv_ts[MAX_POOL_SIZE];
atomic_t tcs_send_count[MAX_POOL_SIZE];
atomic_t tcs_irq_count[MAX_POOL_SIZE];
+ void *ipc_log_ctx;
};
+/* Log to IPC and Ftrace */
+#define log_send_msg(drv, m, n, i, a, d, c, t) do { \
+ trace_rpmh_send_msg(drv->name, m, n, i, a, d, c, t); \
+ ipc_log_string(drv->ipc_log_ctx, \
+ "send msg: m=%d n=%d msgid=0x%x addr=0x%x data=0x%x cmpl=%d trigger=%d", \
+ m, n, i, a, d, c, t); \
+ } while (0)
+
+#define log_rpmh_notify_irq(drv, m, a, e) do { \
+ trace_rpmh_notify_irq(drv->name, m, a, e); \
+ ipc_log_string(drv->ipc_log_ctx, \
+ "irq response: m=%d addr=0x%x err=%d", m, a, e); \
+ } while (0)
+
+#define log_rpmh_control_msg(drv, d) do { \
+ trace_rpmh_control_msg(drv->name, d); \
+ ipc_log_string(drv->ipc_log_ctx, "ctrlr msg: data=0x%x", d); \
+ } while (0)
+
+#define log_rpmh_notify(drv, m, a, e) do { \
+ trace_rpmh_notify(drv->name, m, a, e); \
+ ipc_log_string(drv->ipc_log_ctx, \
+ "tx done: m=%d addr=0x%x err=%d", m, a, e); \
+ } while (0)
+
+
static int tcs_response_pool_init(struct tcs_drv *drv)
{
struct tcs_response_pool *pool;
@@ -223,7 +253,6 @@ static inline struct tcs_response *get_response(struct tcs_drv *drv, u32 m,
break;
}
pos++;
- udelay(1);
} while (1);
spin_unlock_irqrestore(&pool->lock, flags);
@@ -241,7 +270,7 @@ static void print_response(struct tcs_drv *drv, int m)
return;
msg = resp->msg;
- pr_warn("Response object idx=%d:\n\tfor-tcs=%d\tin-use=%d\n",
+ pr_warn("Response object [idx=%d for-tcs=%d in-use=%d]\n",
resp->idx, resp->m, resp->in_use);
pr_warn("Msg: state=%d\n", msg->state);
for (i = 0; i < msg->num_payload; i++)
@@ -425,8 +454,10 @@ static irqreturn_t tcs_irq_handler(int irq, void *p)
sts = read_tcs_reg(base, TCS_DRV_CMD_STATUS, m, i);
if ((!(sts & CMD_STATUS_ISSUED)) ||
((resp->msg->is_complete || cmd->complete) &&
- (!(sts & CMD_STATUS_COMPL))))
+ (!(sts & CMD_STATUS_COMPL)))) {
resp->err = -EIO;
+ break;
+ }
}
/* Check for response if this was a read request */
@@ -437,7 +468,7 @@ static irqreturn_t tcs_irq_handler(int irq, void *p)
mbox_chan_received_data(resp->chan, resp->msg);
}
- trace_rpmh_notify_irq(drv->name, m, resp->msg->payload[0].addr,
+ log_rpmh_notify_irq(drv, m, resp->msg->payload[0].addr,
resp->err);
/* Clear the AMC mode for non-ACTIVE TCSes */
@@ -480,7 +511,7 @@ static inline void mbox_notify_tx_done(struct mbox_chan *chan,
{
struct tcs_drv *drv = container_of(chan->mbox, struct tcs_drv, mbox);
- trace_rpmh_notify(drv->name, m, msg->payload[0].addr, err);
+ log_rpmh_notify(drv, m, msg->payload[0].addr, err);
mbox_chan_txdone(chan, err);
}
@@ -546,7 +577,7 @@ static void __tcs_buffer_write(struct tcs_drv *drv, int d, int m, int n,
write_tcs_reg(base, TCS_DRV_CMD_MSGID, m, n + i, msgid);
write_tcs_reg(base, TCS_DRV_CMD_ADDR, m, n + i, cmd->addr);
write_tcs_reg(base, TCS_DRV_CMD_DATA, m, n + i, cmd->data);
- trace_rpmh_send_msg(drv->name, m, n + i, msgid, cmd->addr,
+ log_send_msg(drv, m, n + i, msgid, cmd->addr,
cmd->data, cmd->complete, trigger);
}
@@ -667,7 +698,8 @@ static int find_slots(struct tcs_mbox *tcs, struct tcs_mbox_msg *msg)
int n = 0;
/* For active requests find the first free AMC. */
- if (tcs->type == ACTIVE_TCS)
+ if (msg->state == RPMH_ACTIVE_ONLY_STATE ||
+ msg->state == RPMH_AWAKE_STATE)
return find_free_tcs(tcs);
/* Find if we already have the msg in our TCS */
@@ -780,6 +812,10 @@ static int tcs_mbox_invalidate(struct mbox_chan *chan)
spin_lock_irqsave(&tcs->tcs_lock, flags);
for (i = 0; i < tcs->num_tcs; i++) {
m = i + tcs->tcs_offset;
+ if (!tcs_is_free(drv, m)) {
+ spin_unlock_irqrestore(&tcs->tcs_lock, flags);
+ return -EBUSY;
+ }
__tcs_buffer_invalidate(drv->reg_base, m);
}
/* Mark the TCS as free */
@@ -795,7 +831,7 @@ static void print_tcs_regs(struct tcs_drv *drv, int m)
int n;
struct tcs_mbox *tcs = get_tcs_from_index(drv, m);
void __iomem *base = drv->reg_base;
- u32 enable, addr, data, msgid;
+ u32 enable, addr, data, msgid, sts, irq_sts;
if (!tcs || tcs_is_free(drv, m))
return;
@@ -804,15 +840,24 @@ static void print_tcs_regs(struct tcs_drv *drv, int m)
if (!enable)
return;
- pr_warn("TCS-%d contents:\n", m);
+ pr_warn("RSC:%s\n", drv->name);
+
+ sts = read_tcs_reg(base, TCS_DRV_STATUS, m, 0);
+ data = read_tcs_reg(base, TCS_DRV_CONTROL, m, 0);
+ irq_sts = read_tcs_reg(base, TCS_DRV_IRQ_STATUS, 0, 0);
+ pr_warn("TCS=%d [ctrlr-sts:%s amc-mode:0x%x irq-sts:%s]\n",
+ m, sts ? "IDLE" : "BUSY", data,
+ (irq_sts & BIT(m)) ? "COMPLETED" : "PENDING");
+
for (n = 0; n < tcs->ncpt; n++) {
if (!(enable & BIT(n)))
continue;
addr = read_tcs_reg(base, TCS_DRV_CMD_ADDR, m, n);
data = read_tcs_reg(base, TCS_DRV_CMD_DATA, m, n);
msgid = read_tcs_reg(base, TCS_DRV_CMD_MSGID, m, n);
- pr_warn("\tn=%d addr=0x%x data=0x%x hdr=0x%x\n",
- n, addr, data, msgid);
+ sts = read_tcs_reg(base, TCS_DRV_CMD_STATUS, m, n);
+ pr_warn("\tCMD=%d [addr=0x%x data=0x%x hdr=0x%x sts=0x%x]\n",
+ n, addr, data, msgid, sts);
}
}
@@ -866,7 +911,8 @@ static int chan_tcs_write(struct mbox_chan *chan, void *data)
goto tx_fail;
}
- if (!msg->payload || msg->num_payload > MAX_RPMH_PAYLOAD) {
+ if (!msg->payload || !msg->num_payload ||
+ msg->num_payload > MAX_RPMH_PAYLOAD) {
dev_err(dev, "Payload error\n");
ret = -EINVAL;
goto tx_fail;
@@ -896,8 +942,11 @@ static int chan_tcs_write(struct mbox_chan *chan, void *data)
* Since we are re-purposing the wake TCS, invalidate previous
* contents to avoid confusion.
*/
- if (msg->state == RPMH_AWAKE_STATE)
- tcs_mbox_invalidate(chan);
+ if (msg->state == RPMH_AWAKE_STATE) {
+ ret = tcs_mbox_invalidate(chan);
+ if (ret)
+ goto tx_fail;
+ }
/* Post the message to the TCS and trigger */
ret = tcs_mbox_write(chan, msg, true);
@@ -909,8 +958,10 @@ static int chan_tcs_write(struct mbox_chan *chan, void *data)
drv, msg, chan, TCS_M_INIT, ret);
dev_err(dev, "Error sending RPMH message %d\n", ret);
- if (resp)
+ if (!IS_ERR(resp))
send_tcs_response(resp);
+ else
+ dev_err(dev, "No response object %ld\n", PTR_ERR(resp));
ret = 0;
}
@@ -932,7 +983,7 @@ static void __tcs_write_hidden(struct tcs_drv *drv, int d,
for (i = 0; i < msg->num_payload; i++) {
/* Only data is write capable */
writel_relaxed(cpu_to_le32(msg->payload[i].data), addr);
- trace_rpmh_control_msg(drv->name, msg->payload[i].data);
+ log_rpmh_control_msg(drv, msg->payload[i].data);
addr += TCS_HIDDEN_CMD_SHIFT;
}
}
@@ -977,7 +1028,8 @@ static int chan_tcs_ctrl_write(struct mbox_chan *chan, void *data)
goto tx_done;
}
- if (msg->num_payload > MAX_RPMH_PAYLOAD) {
+ if (!msg->payload || (!msg->num_payload && !msg->invalidate) ||
+ msg->num_payload > MAX_RPMH_PAYLOAD) {
dev_err(dev, "Payload error\n");
goto tx_done;
}
@@ -1117,7 +1169,8 @@ static int tcs_drv_probe(struct platform_device *pdev)
if (tcs->num_tcs > MAX_TCS_PER_TYPE)
return -EINVAL;
- if (st > max_tcs)
+ if (st + tcs->num_tcs > max_tcs &&
+ st + tcs->num_tcs >= sizeof(tcs->tcs_mask))
return -EINVAL;
tcs->tcs_mask = ((1 << tcs->num_tcs) - 1) << st;
@@ -1139,10 +1192,12 @@ static int tcs_drv_probe(struct platform_device *pdev)
for (j = 0; j < i; j++) {
ret = of_parse_phandle_with_args(np, "mboxes",
"#mbox-cells", j, &p);
- if (!ret && p.np == pdev->dev.of_node)
+ of_node_put(p.np);
+ if (!ret && p.np == pdev->dev.of_node) {
+ num_chans++;
break;
+ }
}
- num_chans++;
}
if (!num_chans) {
@@ -1200,6 +1255,9 @@ static int tcs_drv_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(drv->tcs_in_use); i++)
atomic_set(&drv->tcs_in_use[i], 0);
+ drv->ipc_log_ctx = ipc_log_context_create(TCS_DRV_IPC_LOG_SIZE,
+ drv->name, 0);
+
ret = mbox_controller_register(&drv->mbox);
if (ret)
return ret;
diff --git a/drivers/media/platform/msm/broadcast/tspp.c b/drivers/media/platform/msm/broadcast/tspp.c
index 7717759..44193f5 100644
--- a/drivers/media/platform/msm/broadcast/tspp.c
+++ b/drivers/media/platform/msm/broadcast/tspp.c
@@ -24,6 +24,7 @@
#include <linux/uaccess.h> /* copy_to_user */
#include <linux/slab.h> /* kfree, kzalloc */
#include <linux/ioport.h> /* XXX_ mem_region */
+#include <asm/dma-iommu.h>
#include <linux/dma-mapping.h> /* dma_XXX */
#include <linux/dmapool.h> /* DMA pools */
#include <linux/delay.h> /* msleep */
@@ -59,6 +60,10 @@
#define TSPP_NUM_KEYS 8
#define INVALID_CHANNEL 0xFFFFFFFF
#define TSPP_BAM_DEFAULT_IPC_LOGLVL 2
+
+#define TSPP_SMMU_IOVA_START (0x10000000)
+#define TSPP_SMMU_IOVA_SIZE (0x40000000)
+
/*
* BAM descriptor FIFO size (in number of descriptors).
* Max number of descriptors allowed by SPS which is 8K-1.
@@ -489,6 +494,8 @@ struct tspp_device {
struct mutex mutex;
struct tspp_pinctrl pinctrl;
unsigned int tts_source; /* Time stamp source type LPASS timer/TCR */
+ struct dma_iommu_mapping *iommu_mapping;
+ bool bypass_s1_smmu;
struct dentry *dent;
struct dentry *debugfs_regs[ARRAY_SIZE(debugfs_tspp_regs)];
@@ -1058,6 +1065,42 @@ static void tspp_free_key_entry(int entry)
tspp_key_entry &= ~(1 << entry);
}
+static int tspp_iommu_init(struct tspp_device *device)
+{
+ struct dma_iommu_mapping *iommu_map;
+ int s1_bypass = 1;
+
+ iommu_map = arm_iommu_create_mapping(&platform_bus_type,
+ TSPP_SMMU_IOVA_START,
+ TSPP_SMMU_IOVA_SIZE);
+ if (IS_ERR(iommu_map)) {
+ dev_err(&device->pdev->dev, "iommu_create_mapping failure\n");
+ return PTR_ERR(iommu_map);
+ }
+ if (iommu_domain_set_attr(iommu_map->domain,
+ DOMAIN_ATTR_S1_BYPASS, &s1_bypass)) {
+ dev_err(&device->pdev->dev, "Can't bypass s1 translation\n");
+ arm_iommu_release_mapping(iommu_map);
+ return -EIO;
+ }
+ if (arm_iommu_attach_device(&device->pdev->dev, iommu_map)) {
+ dev_err(&device->pdev->dev, "can't arm_iommu_attach_device\n");
+ arm_iommu_release_mapping(iommu_map);
+ return -EIO;
+ }
+
+ device->iommu_mapping = iommu_map;
+ return 0;
+}
+
+static void tspp_iommu_release_iomapping(struct tspp_device *device)
+{
+ if (device->bypass_s1_smmu && device->iommu_mapping)
+ arm_iommu_release_mapping(device->iommu_mapping);
+
+ device->iommu_mapping = NULL;
+}
+
static int tspp_alloc_buffer(u32 channel_id, struct tspp_data_descriptor *desc,
u32 size, struct dma_pool *dma_pool, tspp_allocator *alloc, void *user)
{
@@ -2959,6 +3002,14 @@ static int msm_tspp_probe(struct platform_device *pdev)
goto err_irq;
device->req_irqs = false;
+ if (of_property_read_bool(pdev->dev.of_node, "qcom,smmu-s1-bypass")) {
+ device->bypass_s1_smmu = true;
+ if (tspp_iommu_init(device)) {
+ dev_err(&pdev->dev, "iommu init failed");
+ goto err_iommu;
+ }
+ }
+
device->tts_source = TSIF_TTS_TCR;
for (i = 0; i < TSPP_TSIF_INSTANCES; i++)
device->tsif[i].tts_source = device->tts_source;
@@ -3029,6 +3080,8 @@ static int msm_tspp_probe(struct platform_device *pdev)
tspp_debugfs_exit(device);
for (i = 0; i < TSPP_TSIF_INSTANCES; i++)
tsif_debugfs_exit(&device->tsif[i]);
+err_iommu:
+ tspp_iommu_release_iomapping(device);
err_irq:
iounmap(device->bam_props.virt_addr);
err_map_bam:
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm.h b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm.h
index 38f13c4..048fe8f 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm.h
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm.h
@@ -27,18 +27,7 @@
#include "cam_cpas_api.h"
#include "cam_hw_intf.h"
#include "cam_hw.h"
-
-#ifdef CONFIG_CAM_CDM_DBG
-#define CDM_CDBG(fmt, args...) pr_err(fmt, ##args)
-#else
-#define CDM_CDBG(fmt, args...) pr_debug(fmt, ##args)
-#endif
-
-#ifdef CONFIG_CAM_CDM_DUMP_DBG
-#define CDM_DUMP_CDBG(fmt, args...) pr_err(fmt, ##args)
-#else
-#define CDM_DUMP_CDBG(fmt, args...) pr_debug(fmt, ##args)
-#endif
+#include "cam_debug_util.h"
#define CAM_MAX_SW_CDM_VERSION_SUPPORTED 1
#define CAM_SW_CDM_INDEX 0
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.c b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.c
index 3604357..6c8bde1 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.c
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CAM-CDM-CORE %s:%d " fmt, __func__, __LINE__
-
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/of.h>
@@ -32,7 +30,7 @@
static void cam_cdm_get_client_refcount(struct cam_cdm_client *client)
{
mutex_lock(&client->lock);
- CDM_CDBG("CDM client get refcount=%d\n",
+ CAM_DBG(CAM_CDM, "CDM client get refcount=%d",
client->refcount);
client->refcount++;
mutex_unlock(&client->lock);
@@ -41,12 +39,12 @@ static void cam_cdm_get_client_refcount(struct cam_cdm_client *client)
static void cam_cdm_put_client_refcount(struct cam_cdm_client *client)
{
mutex_lock(&client->lock);
- CDM_CDBG("CDM client put refcount=%d\n",
+ CAM_DBG(CAM_CDM, "CDM client put refcount=%d",
client->refcount);
if (client->refcount > 0) {
client->refcount--;
} else {
- pr_err("Refcount put when zero\n");
+ CAM_ERR(CAM_CDM, "Refcount put when zero");
WARN_ON(1);
}
mutex_unlock(&client->lock);
@@ -63,16 +61,16 @@ bool cam_cdm_set_cam_hw_version(
cam_version->reserved = 0;
return true;
default:
- pr_err("CDM Version=%x not supported in util\n", ver);
+ CAM_ERR(CAM_CDM, "CDM Version=%x not supported in util", ver);
break;
}
return false;
}
-void cam_cdm_cpas_cb(int32_t client_handle, void *userdata,
+void cam_cdm_cpas_cb(uint32_t client_handle, void *userdata,
enum cam_camnoc_irq_type evt_type, uint32_t evt_data)
{
- pr_err("CPAS error callback type=%d with data=%x\n", evt_type,
+ CAM_ERR(CAM_CDM, "CPAS error callback type=%d with data=%x", evt_type,
evt_data);
}
@@ -84,13 +82,14 @@ struct cam_cdm_utils_ops *cam_cdm_get_ops(
case CAM_CDM170_VERSION:
return &CDM170_ops;
default:
- pr_err("CDM Version=%x not supported in util\n", ver);
+ CAM_ERR(CAM_CDM, "CDM Version=%x not supported in util",
+ ver);
}
} else if (cam_version) {
if ((cam_version->major == 1) && (cam_version->minor == 0) &&
(cam_version->incr == 0))
return &CDM170_ops;
- pr_err("cam_hw_version=%x:%x:%x not supported\n",
+ CAM_ERR(CAM_CDM, "cam_hw_version=%x:%x:%x not supported",
cam_version->major, cam_version->minor,
cam_version->incr);
}
@@ -107,7 +106,7 @@ struct cam_cdm_bl_cb_request_entry *cam_cdm_find_request_by_bl_tag(
if (node->bl_tag == tag)
return node;
}
- pr_err("Could not find the bl request for tag=%x\n", tag);
+ CAM_ERR(CAM_CDM, "Could not find the bl request for tag=%x", tag);
return NULL;
}
@@ -135,11 +134,11 @@ int cam_cdm_find_free_client_slot(struct cam_cdm *hw)
for (i = 0; i < CAM_PER_CDM_MAX_REGISTERED_CLIENTS; i++) {
if (hw->clients[i] == NULL) {
- CDM_CDBG("Found client slot %d\n", i);
+ CAM_DBG(CAM_CDM, "Found client slot %d", i);
return i;
}
}
- pr_err("No more client slots\n");
+ CAM_ERR(CAM_CDM, "No more client slots");
return -EBUSY;
}
@@ -153,7 +152,7 @@ void cam_cdm_notify_clients(struct cam_hw_info *cdm_hw,
struct cam_cdm_client *client = NULL;
if (!cdm_hw) {
- pr_err("CDM Notify called with NULL hw info\n");
+ CAM_ERR(CAM_CDM, "CDM Notify called with NULL hw info");
return;
}
core = (struct cam_cdm *)cdm_hw->core_info;
@@ -166,20 +165,21 @@ void cam_cdm_notify_clients(struct cam_hw_info *cdm_hw,
client_idx = CAM_CDM_GET_CLIENT_IDX(node->client_hdl);
client = core->clients[client_idx];
if ((!client) || (client->handle != node->client_hdl)) {
- pr_err("Invalid client %pK hdl=%x\n", client,
+ CAM_ERR(CAM_CDM, "Invalid client %pK hdl=%x", client,
node->client_hdl);
return;
}
cam_cdm_get_client_refcount(client);
if (client->data.cam_cdm_callback) {
- CDM_CDBG("Calling client=%s cb cookie=%d\n",
+ CAM_DBG(CAM_CDM, "Calling client=%s cb cookie=%d",
client->data.identifier, node->cookie);
client->data.cam_cdm_callback(node->client_hdl,
node->userdata, CAM_CDM_CB_STATUS_BL_SUCCESS,
node->cookie);
- CDM_CDBG("Exit client cb cookie=%d\n", node->cookie);
+ CAM_DBG(CAM_CDM, "Exit client cb cookie=%d",
+ node->cookie);
} else {
- pr_err("No cb registered for client hdl=%x\n",
+ CAM_ERR(CAM_CDM, "No cb registered for client hdl=%x",
node->client_hdl);
}
cam_cdm_put_client_refcount(client);
@@ -190,7 +190,7 @@ void cam_cdm_notify_clients(struct cam_hw_info *cdm_hw,
if (core->clients[i] != NULL) {
client = core->clients[i];
mutex_lock(&client->lock);
- CDM_CDBG("Found client slot %d\n", i);
+ CAM_DBG(CAM_CDM, "Found client slot %d", i);
if (client->data.cam_cdm_callback) {
if (status == CAM_CDM_CB_STATUS_PAGEFAULT) {
unsigned long iova =
@@ -203,7 +203,8 @@ void cam_cdm_notify_clients(struct cam_hw_info *cdm_hw,
(iova & 0xFFFFFFFF));
}
} else {
- pr_err("No cb registered for client hdl=%x\n",
+ CAM_ERR(CAM_CDM,
+ "No cb registered for client hdl=%x",
client->handle);
}
mutex_unlock(&client->lock);
@@ -228,24 +229,26 @@ int cam_cdm_stream_ops_internal(void *hw_priv,
client_idx = CAM_CDM_GET_CLIENT_IDX(*handle);
client = core->clients[client_idx];
if (!client) {
- pr_err("Invalid client %pK hdl=%x\n", client, *handle);
+ CAM_ERR(CAM_CDM, "Invalid client %pK hdl=%x", client, *handle);
return -EINVAL;
}
cam_cdm_get_client_refcount(client);
if (*handle != client->handle) {
- pr_err("client id given handle=%x invalid\n", *handle);
+ CAM_ERR(CAM_CDM, "client id given handle=%x invalid", *handle);
cam_cdm_put_client_refcount(client);
return -EINVAL;
}
if (operation == true) {
if (true == client->stream_on) {
- pr_err("Invalid CDM client is already streamed ON\n");
+ CAM_ERR(CAM_CDM,
+ "Invalid CDM client is already streamed ON");
cam_cdm_put_client_refcount(client);
return rc;
}
} else {
if (client->stream_on == false) {
- pr_err("Invalid CDM client is already streamed Off\n");
+ CAM_ERR(CAM_CDM,
+ "Invalid CDM client is already streamed Off");
cam_cdm_put_client_refcount(client);
return rc;
}
@@ -265,26 +268,28 @@ int cam_cdm_stream_ops_internal(void *hw_priv,
rc = cam_cpas_start(core->cpas_handle,
&ahb_vote, &axi_vote);
if (rc != 0) {
- pr_err("CPAS start failed\n");
+ CAM_ERR(CAM_CDM, "CPAS start failed");
goto end;
}
- CDM_CDBG("CDM init first time\n");
+ CAM_DBG(CAM_CDM, "CDM init first time");
if (core->id == CAM_CDM_VIRTUAL) {
- CDM_CDBG("Virtual CDM HW init first time\n");
+ CAM_DBG(CAM_CDM,
+ "Virtual CDM HW init first time");
rc = 0;
} else {
- CDM_CDBG("CDM HW init first time\n");
+ CAM_DBG(CAM_CDM, "CDM HW init first time");
rc = cam_hw_cdm_init(hw_priv, NULL, 0);
if (rc == 0) {
rc = cam_hw_cdm_alloc_genirq_mem(
hw_priv);
if (rc != 0) {
- pr_err("Genirqalloc failed\n");
+ CAM_ERR(CAM_CDM,
+ "Genirqalloc failed");
cam_hw_cdm_deinit(hw_priv,
NULL, 0);
}
} else {
- pr_err("CDM HW init failed\n");
+ CAM_ERR(CAM_CDM, "CDM HW init failed");
}
}
if (rc == 0) {
@@ -292,11 +297,11 @@ int cam_cdm_stream_ops_internal(void *hw_priv,
client->stream_on = true;
} else {
if (cam_cpas_stop(core->cpas_handle))
- pr_err("CPAS stop failed\n");
+ CAM_ERR(CAM_CDM, "CPAS stop failed");
}
} else {
cdm_hw->open_count++;
- CDM_CDBG("CDM HW already ON count=%d\n",
+ CAM_DBG(CAM_CDM, "CDM HW already ON count=%d",
cdm_hw->open_count);
rc = 0;
client->stream_on = true;
@@ -304,35 +309,41 @@ int cam_cdm_stream_ops_internal(void *hw_priv,
} else {
if (cdm_hw->open_count) {
cdm_hw->open_count--;
- CDM_CDBG("stream OFF CDM %d\n", cdm_hw->open_count);
+ CAM_DBG(CAM_CDM, "stream OFF CDM %d",
+ cdm_hw->open_count);
if (!cdm_hw->open_count) {
- CDM_CDBG("CDM Deinit now\n");
+ CAM_DBG(CAM_CDM, "CDM Deinit now");
if (core->id == CAM_CDM_VIRTUAL) {
- CDM_CDBG("Virtual CDM HW Deinit\n");
+ CAM_DBG(CAM_CDM,
+ "Virtual CDM HW Deinit");
rc = 0;
} else {
- CDM_CDBG("CDM HW Deinit now\n");
+ CAM_DBG(CAM_CDM, "CDM HW Deinit now");
rc = cam_hw_cdm_deinit(
hw_priv, NULL, 0);
if (cam_hw_cdm_release_genirq_mem(
hw_priv))
- pr_err("Genirq release failed\n");
+ CAM_ERR(CAM_CDM,
+ "Genirq release fail");
}
if (rc) {
- pr_err("Deinit failed in streamoff\n");
+ CAM_ERR(CAM_CDM,
+ "Deinit failed in streamoff");
} else {
client->stream_on = false;
rc = cam_cpas_stop(core->cpas_handle);
if (rc)
- pr_err("CPAS stop failed\n");
+ CAM_ERR(CAM_CDM,
+ "CPAS stop failed");
}
} else {
client->stream_on = false;
- CDM_CDBG("Client stream off success =%d\n",
+ CAM_DBG(CAM_CDM,
+ "Client stream off success =%d",
cdm_hw->open_count);
}
} else {
- CDM_CDBG("stream OFF CDM Invalid %d\n",
+ CAM_DBG(CAM_CDM, "stream OFF CDM Invalid %d",
cdm_hw->open_count);
rc = -ENXIO;
}
@@ -390,33 +401,35 @@ int cam_cdm_process_cmd(void *hw_priv,
struct cam_cdm_client *client;
if (sizeof(struct cam_cdm_hw_intf_cmd_submit_bl) != arg_size) {
- pr_err("Invalid CDM cmd %d arg size=%x\n", cmd,
+ CAM_ERR(CAM_CDM, "Invalid CDM cmd %d arg size=%x", cmd,
arg_size);
break;
}
req = (struct cam_cdm_hw_intf_cmd_submit_bl *)cmd_args;
if ((req->data->type < 0) ||
(req->data->type > CAM_CDM_BL_CMD_TYPE_KERNEL_IOVA)) {
- pr_err("Invalid req bl cmd addr type=%d\n",
+ CAM_ERR(CAM_CDM, "Invalid req bl cmd addr type=%d",
req->data->type);
break;
}
idx = CAM_CDM_GET_CLIENT_IDX(req->handle);
client = core->clients[idx];
if ((!client) || (req->handle != client->handle)) {
- pr_err("Invalid client %pK hdl=%x\n", client,
+ CAM_ERR(CAM_CDM, "Invalid client %pK hdl=%x", client,
req->handle);
break;
}
cam_cdm_get_client_refcount(client);
if ((req->data->flag == true) &&
(!client->data.cam_cdm_callback)) {
- pr_err("CDM request cb without registering cb\n");
+ CAM_ERR(CAM_CDM,
+ "CDM request cb without registering cb");
cam_cdm_put_client_refcount(client);
break;
}
if (client->stream_on != true) {
- pr_err("Invalid CDM needs to be streamed ON first\n");
+ CAM_ERR(CAM_CDM,
+ "Invalid CDM needs to be streamed ON first");
cam_cdm_put_client_refcount(client);
break;
}
@@ -434,19 +447,20 @@ int cam_cdm_process_cmd(void *hw_priv,
struct cam_cdm_client *client;
if (sizeof(struct cam_cdm_acquire_data) != arg_size) {
- pr_err("Invalid CDM cmd %d arg size=%x\n", cmd,
+ CAM_ERR(CAM_CDM, "Invalid CDM cmd %d arg size=%x", cmd,
arg_size);
break;
}
mutex_lock(&cdm_hw->hw_mutex);
data = (struct cam_cdm_acquire_data *)cmd_args;
- CDM_CDBG("Trying to acquire client=%s in hw idx=%d\n",
+ CAM_DBG(CAM_CDM, "Trying to acquire client=%s in hw idx=%d",
data->identifier, core->index);
idx = cam_cdm_find_free_client_slot(core);
if ((idx < 0) || (core->clients[idx])) {
mutex_unlock(&cdm_hw->hw_mutex);
- pr_err("Failed to client slots for client=%s in hw idx=%d\n",
+ CAM_ERR(CAM_CDM,
+ "Fail to client slots, client=%s in hw idx=%d",
data->identifier, core->index);
break;
}
@@ -477,7 +491,7 @@ int cam_cdm_process_cmd(void *hw_priv,
mutex_unlock(
&cdm_hw->hw_mutex);
rc = -EPERM;
- pr_err("Invalid ops for virtual cdm\n");
+ CAM_ERR(CAM_CDM, "Invalid ops for virtual cdm");
break;
}
} else {
@@ -493,7 +507,7 @@ int cam_cdm_process_cmd(void *hw_priv,
idx);
client->stream_on = false;
data->handle = client->handle;
- CDM_CDBG("Acquired client=%s in hwidx=%d\n",
+ CAM_DBG(CAM_CDM, "Acquired client=%s in hwidx=%d",
data->identifier, core->index);
mutex_unlock(&client->lock);
rc = 0;
@@ -505,7 +519,8 @@ int cam_cdm_process_cmd(void *hw_priv,
struct cam_cdm_client *client;
if (sizeof(uint32_t) != arg_size) {
- pr_err("Invalid CDM cmd %d size=%x for handle=%x\n",
+ CAM_ERR(CAM_CDM,
+ "Invalid CDM cmd %d size=%x for handle=%x",
cmd, arg_size, *handle);
return -EINVAL;
}
@@ -513,14 +528,15 @@ int cam_cdm_process_cmd(void *hw_priv,
mutex_lock(&cdm_hw->hw_mutex);
client = core->clients[idx];
if ((!client) || (*handle != client->handle)) {
- pr_err("Invalid client %pK hdl=%x\n", client, *handle);
+ CAM_ERR(CAM_CDM, "Invalid client %pK hdl=%x",
+ client, *handle);
mutex_unlock(&cdm_hw->hw_mutex);
break;
}
cam_cdm_put_client_refcount(client);
mutex_lock(&client->lock);
if (client->refcount != 0) {
- pr_err("CDM Client refcount not zero %d",
+ CAM_ERR(CAM_CDM, "CDM Client refcount not zero %d",
client->refcount);
rc = -EPERM;
mutex_unlock(&client->lock);
@@ -536,12 +552,12 @@ int cam_cdm_process_cmd(void *hw_priv,
break;
}
case CAM_CDM_HW_INTF_CMD_RESET_HW: {
- pr_err("CDM HW reset not supported for handle =%x\n",
+ CAM_ERR(CAM_CDM, "CDM HW reset not supported for handle =%x",
*((uint32_t *)cmd_args));
break;
}
default:
- pr_err("CDM HW intf command not valid =%d\n", cmd);
+ CAM_ERR(CAM_CDM, "CDM HW intf command not valid =%d", cmd);
break;
}
return rc;
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.h b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.h
index eb75aaa..fa3ae04 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.h
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_core_common.h
@@ -32,7 +32,7 @@ int cam_cdm_process_cmd(void *hw_priv, uint32_t cmd, void *cmd_args,
uint32_t arg_size);
bool cam_cdm_set_cam_hw_version(
uint32_t ver, struct cam_hw_version *cam_version);
-void cam_cdm_cpas_cb(int32_t client_handle, void *userdata,
+void cam_cdm_cpas_cb(uint32_t client_handle, void *userdata,
enum cam_camnoc_irq_type evt_type, uint32_t evt_data);
struct cam_cdm_utils_ops *cam_cdm_get_ops(
uint32_t ver, struct cam_hw_version *cam_version, bool by_cam_version);
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c
index 5fac7d8..5f6895c 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_hw_core.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CAM-CDM-HW %s:%d " fmt, __func__, __LINE__
-
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/of.h>
@@ -31,7 +29,6 @@
#include "cam_io_util.h"
#include "cam_hw_cdm170_reg.h"
-
#define CAM_HW_CDM_CPAS_0_NAME "qcom,cam170-cpas-cdm0"
#define CAM_HW_CDM_IPE_0_NAME "qcom,cam170-ipe0-cdm"
#define CAM_HW_CDM_IPE_1_NAME "qcom,cam170-ipe1-cdm"
@@ -65,7 +62,7 @@ int cam_hw_cdm_bl_fifo_pending_bl_rb(struct cam_hw_info *cdm_hw,
if (cam_cdm_read_hw_reg(cdm_hw, CDM_BL_FIFO_PENDING_REQ_RB,
pending_bl)) {
- pr_err("Failed to read CDM pending BL's\n");
+ CAM_ERR(CAM_CDM, "Failed to read CDM pending BL's");
rc = -EIO;
}
@@ -81,28 +78,28 @@ static int cam_hw_cdm_enable_bl_done_irq(struct cam_hw_info *cdm_hw,
if (cam_cdm_read_hw_reg(cdm_hw, CDM_IRQ_MASK,
&irq_mask)) {
- pr_err("Failed to read CDM IRQ mask\n");
+ CAM_ERR(CAM_CDM, "Failed to read CDM IRQ mask");
return rc;
}
if (enable == true) {
if (cam_cdm_write_hw_reg(cdm_hw, CDM_IRQ_MASK,
(irq_mask | 0x4))) {
- pr_err("Write failed to enable BL done irq\n");
+ CAM_ERR(CAM_CDM, "Write failed to enable BL done irq");
} else {
atomic_inc(&core->bl_done);
rc = 0;
- CDM_CDBG("BL done irq enabled =%d\n",
+ CAM_DBG(CAM_CDM, "BL done irq enabled =%d",
atomic_read(&core->bl_done));
}
} else {
if (cam_cdm_write_hw_reg(cdm_hw, CDM_IRQ_MASK,
(irq_mask & 0x70003))) {
- pr_err("Write failed to disable BL done irq\n");
+ CAM_ERR(CAM_CDM, "Write failed to disable BL done irq");
} else {
atomic_dec(&core->bl_done);
rc = 0;
- CDM_CDBG("BL done irq disable =%d\n",
+ CAM_DBG(CAM_CDM, "BL done irq disable =%d",
atomic_read(&core->bl_done));
}
}
@@ -115,12 +112,12 @@ static int cam_hw_cdm_enable_core(struct cam_hw_info *cdm_hw, bool enable)
if (enable == true) {
if (cam_cdm_write_hw_reg(cdm_hw, CDM_CFG_CORE_EN, 0x01)) {
- pr_err("Failed to Write CDM HW core enable\n");
+ CAM_ERR(CAM_CDM, "Failed to Write CDM HW core enable");
rc = -EIO;
}
} else {
if (cam_cdm_write_hw_reg(cdm_hw, CDM_CFG_CORE_EN, 0x02)) {
- pr_err("Failed to Write CDM HW core disable\n");
+ CAM_ERR(CAM_CDM, "Failed to Write CDM HW core disable");
rc = -EIO;
}
}
@@ -132,7 +129,7 @@ int cam_hw_cdm_enable_core_dbg(struct cam_hw_info *cdm_hw)
int rc = 0;
if (cam_cdm_write_hw_reg(cdm_hw, CDM_DBG_CORE_DBUG, 0x10100)) {
- pr_err("Failed to Write CDM HW core debug\n");
+ CAM_ERR(CAM_CDM, "Failed to Write CDM HW core debug");
rc = -EIO;
}
@@ -144,7 +141,7 @@ int cam_hw_cdm_disable_core_dbg(struct cam_hw_info *cdm_hw)
int rc = 0;
if (cam_cdm_write_hw_reg(cdm_hw, CDM_DBG_CORE_DBUG, 0)) {
- pr_err("Failed to Write CDM HW core debug\n");
+ CAM_ERR(CAM_CDM, "Failed to Write CDM HW core debug");
rc = -EIO;
}
@@ -156,31 +153,31 @@ void cam_hw_cdm_dump_scratch_registors(struct cam_hw_info *cdm_hw)
uint32_t dump_reg = 0;
cam_cdm_read_hw_reg(cdm_hw, CDM_CFG_CORE_EN, &dump_reg);
- pr_err("dump core en=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "dump core en=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_SCRATCH_0_REG, &dump_reg);
- pr_err("dump scratch0=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "dump scratch0=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_SCRATCH_1_REG, &dump_reg);
- pr_err("dump scratch1=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "dump scratch1=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_SCRATCH_2_REG, &dump_reg);
- pr_err("dump scratch2=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "dump scratch2=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_SCRATCH_3_REG, &dump_reg);
- pr_err("dump scratch3=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "dump scratch3=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_SCRATCH_4_REG, &dump_reg);
- pr_err("dump scratch4=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "dump scratch4=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_SCRATCH_5_REG, &dump_reg);
- pr_err("dump scratch5=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "dump scratch5=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_SCRATCH_6_REG, &dump_reg);
- pr_err("dump scratch6=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "dump scratch6=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_SCRATCH_7_REG, &dump_reg);
- pr_err("dump scratch7=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "dump scratch7=%x", dump_reg);
}
@@ -191,64 +188,65 @@ void cam_hw_cdm_dump_core_debug_registers(
mutex_lock(&cdm_hw->hw_mutex);
cam_cdm_read_hw_reg(cdm_hw, CDM_CFG_CORE_EN, &dump_reg);
- pr_err("CDM HW core status=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "CDM HW core status=%x", dump_reg);
/* First pause CDM, If it fails still proceed to dump debug info */
cam_hw_cdm_enable_core(cdm_hw, false);
cam_hw_cdm_bl_fifo_pending_bl_rb(cdm_hw, &dump_reg);
- pr_err("CDM HW current pending BL=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "CDM HW current pending BL=%x", dump_reg);
loop_cnt = dump_reg;
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_DEBUG_STATUS, &dump_reg);
- pr_err("CDM HW Debug status reg=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "CDM HW Debug status reg=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_CORE_DBUG, &core_dbg);
if (core_dbg & 0x100) {
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_LAST_AHB_ADDR, &dump_reg);
- pr_err("AHB dump reglastaddr=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "AHB dump reglastaddr=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_LAST_AHB_DATA, &dump_reg);
- pr_err("AHB dump reglastdata=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "AHB dump reglastdata=%x", dump_reg);
} else {
- pr_err("CDM HW AHB dump not enable\n");
+ CAM_ERR(CAM_CDM, "CDM HW AHB dump not enable");
}
if (core_dbg & 0x10000) {
int i;
- pr_err("CDM HW BL FIFO dump with loop count=%d\n", loop_cnt);
+ CAM_ERR(CAM_CDM, "CDM HW BL FIFO dump with loop count=%d",
+ loop_cnt);
for (i = 0 ; i < loop_cnt ; i++) {
cam_cdm_write_hw_reg(cdm_hw, CDM_BL_FIFO_RB, i);
cam_cdm_read_hw_reg(cdm_hw, CDM_BL_FIFO_BASE_RB,
&dump_reg);
- pr_err("BL(%d) base addr =%x\n", i, dump_reg);
+ CAM_ERR(CAM_CDM, "BL(%d) base addr =%x", i, dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_BL_FIFO_LEN_RB,
&dump_reg);
- pr_err("BL(%d) len=%d tag=%d\n", i,
+ CAM_ERR(CAM_CDM, "BL(%d) len=%d tag=%d", i,
(dump_reg & 0xFFFFF), (dump_reg & 0xFF000000));
}
} else {
- pr_err("CDM HW BL FIFO readback not enable\n");
+ CAM_ERR(CAM_CDM, "CDM HW BL FIFO readback not enable");
}
- pr_err("CDM HW default dump\n");
+ CAM_ERR(CAM_CDM, "CDM HW default dump");
cam_cdm_read_hw_reg(cdm_hw, CDM_CFG_CORE_CFG, &dump_reg);
- pr_err("CDM HW core cfg=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "CDM HW core cfg=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_IRQ_STATUS, &dump_reg);
- pr_err("CDM HW irq status=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "CDM HW irq status=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_IRQ_SET, &dump_reg);
- pr_err("CDM HW irq set reg=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "CDM HW irq set reg=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_CURRENT_BL_BASE, &dump_reg);
- pr_err("CDM HW current BL base=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "CDM HW current BL base=%x", dump_reg);
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_CURRENT_BL_LEN, &dump_reg);
- pr_err("CDM HW current BL len=%d tag=%d\n", (dump_reg & 0xFFFFF),
- (dump_reg & 0xFF000000));
+ CAM_ERR(CAM_CDM, "CDM HW current BL len=%d tag=%d",
+ (dump_reg & 0xFFFFF), (dump_reg & 0xFF000000));
cam_cdm_read_hw_reg(cdm_hw, CDM_DBG_CURRENT_USED_AHB_BASE, &dump_reg);
- pr_err("CDM HW current AHB base=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "CDM HW current AHB base=%x", dump_reg);
cam_hw_cdm_bl_fifo_pending_bl_rb(cdm_hw, &dump_reg);
- pr_err("CDM HW current pending BL=%x\n", dump_reg);
+ CAM_ERR(CAM_CDM, "CDM HW current pending BL=%x", dump_reg);
/* Enable CDM back */
cam_hw_cdm_enable_core(cdm_hw, true);
@@ -268,43 +266,46 @@ int cam_hw_cdm_wait_for_bl_fifo(struct cam_hw_info *cdm_hw,
do {
if (cam_cdm_read_hw_reg(cdm_hw, CDM_BL_FIFO_PENDING_REQ_RB,
&pending_bl)) {
- pr_err("Failed to read CDM pending BL's\n");
+ CAM_ERR(CAM_CDM, "Failed to read CDM pending BL's");
rc = -EIO;
break;
}
available_bl_slots = CAM_CDM_HWFIFO_SIZE - pending_bl;
if (available_bl_slots < 0) {
- pr_err("Invalid available slots %d:%d:%d\n",
+ CAM_ERR(CAM_CDM, "Invalid available slots %d:%d:%d",
available_bl_slots, CAM_CDM_HWFIFO_SIZE,
pending_bl);
break;
}
if (bl_count < (available_bl_slots - 1)) {
- CDM_CDBG("BL slot available_cnt=%d requested=%d\n",
+ CAM_DBG(CAM_CDM,
+ "BL slot available_cnt=%d requested=%d",
(available_bl_slots - 1), bl_count);
rc = bl_count;
break;
} else if (0 == (available_bl_slots - 1)) {
rc = cam_hw_cdm_enable_bl_done_irq(cdm_hw, true);
if (rc) {
- pr_err("Enable BL done irq failed\n");
+ CAM_ERR(CAM_CDM, "Enable BL done irq failed");
break;
}
time_left = wait_for_completion_timeout(
&core->bl_complete, msecs_to_jiffies(
CAM_CDM_BL_FIFO_WAIT_TIMEOUT));
if (time_left <= 0) {
- pr_err("CDM HW BL Wait timed out failed\n");
+ CAM_ERR(CAM_CDM,
+ "CDM HW BL Wait timed out failed");
if (cam_hw_cdm_enable_bl_done_irq(cdm_hw,
false))
- pr_err("Disable BL done irq failed\n");
+ CAM_ERR(CAM_CDM,
+ "Disable BL done irq failed");
rc = -EIO;
break;
}
if (cam_hw_cdm_enable_bl_done_irq(cdm_hw, false))
- pr_err("Disable BL done irq failed\n");
+ CAM_ERR(CAM_CDM, "Disable BL done irq failed");
rc = 0;
- CDM_CDBG("CDM HW is ready for data\n");
+ CAM_DBG(CAM_CDM, "CDM HW is ready for data");
} else {
rc = (bl_count - (available_bl_slots - 1));
break;
@@ -318,12 +319,12 @@ bool cam_hw_cdm_bl_write(struct cam_hw_info *cdm_hw, uint32_t src,
uint32_t len, uint32_t tag)
{
if (cam_cdm_write_hw_reg(cdm_hw, CDM_BL_FIFO_BASE_REG, src)) {
- pr_err("Failed to write CDM base to BL base\n");
+ CAM_ERR(CAM_CDM, "Failed to write CDM base to BL base");
return true;
}
if (cam_cdm_write_hw_reg(cdm_hw, CDM_BL_FIFO_LEN_REG,
((len & 0xFFFFF) | ((tag & 0xFF) << 20)))) {
- pr_err("Failed to write CDM BL len\n");
+ CAM_ERR(CAM_CDM, "Failed to write CDM BL len");
return true;
}
return false;
@@ -332,7 +333,7 @@ bool cam_hw_cdm_bl_write(struct cam_hw_info *cdm_hw, uint32_t src,
bool cam_hw_cdm_commit_bl_write(struct cam_hw_info *cdm_hw)
{
if (cam_cdm_write_hw_reg(cdm_hw, CDM_BL_FIFO_STORE_REG, 1)) {
- pr_err("Failed to write CDM commit BL\n");
+ CAM_ERR(CAM_CDM, "Failed to write CDM commit BL");
return true;
}
return false;
@@ -347,11 +348,11 @@ int cam_hw_cdm_submit_gen_irq(struct cam_hw_info *cdm_hw,
int rc;
if (core->bl_tag > 63) {
- pr_err("bl_tag invalid =%d\n", core->bl_tag);
+ CAM_ERR(CAM_CDM, "bl_tag invalid =%d", core->bl_tag);
rc = -EINVAL;
goto end;
}
- CDM_CDBG("CDM write BL last cmd tag=%x total=%d cookie=%d\n",
+ CAM_DBG(CAM_CDM, "CDM write BL last cmd tag=%x total=%d cookie=%d",
core->bl_tag, req->data->cmd_arrary_count, req->data->cookie);
node = kzalloc(sizeof(struct cam_cdm_bl_cb_request_entry),
GFP_KERNEL);
@@ -372,7 +373,7 @@ int cam_hw_cdm_submit_gen_irq(struct cam_hw_info *cdm_hw,
((4 * core->ops->cdm_required_size_genirq()) - 1),
core->bl_tag);
if (rc) {
- pr_err("CDM hw bl write failed for gen irq bltag=%d\n",
+ CAM_ERR(CAM_CDM, "CDM hw bl write failed for gen irq bltag=%d",
core->bl_tag);
list_del_init(&node->entry);
kfree(node);
@@ -381,7 +382,7 @@ int cam_hw_cdm_submit_gen_irq(struct cam_hw_info *cdm_hw,
}
if (cam_hw_cdm_commit_bl_write(cdm_hw)) {
- pr_err("Cannot commit the genirq BL with tag tag=%d\n",
+ CAM_ERR(CAM_CDM, "Cannot commit the genirq BL with tag tag=%d",
core->bl_tag);
list_del_init(&node->entry);
kfree(node);
@@ -403,7 +404,7 @@ int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw,
int write_count = 0;
if (req->data->cmd_arrary_count > CAM_CDM_HWFIFO_SIZE) {
- pr_info("requested BL more than max size, cnt=%d max=%d\n",
+ pr_info("requested BL more than max size, cnt=%d max=%d",
req->data->cmd_arrary_count, CAM_CDM_HWFIFO_SIZE);
}
@@ -414,7 +415,7 @@ int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw,
mutex_lock(&client->lock);
rc = cam_hw_cdm_bl_fifo_pending_bl_rb(cdm_hw, &pending_bl);
if (rc) {
- pr_err("Cannot read the current BL depth\n");
+ CAM_ERR(CAM_CDM, "Cannot read the current BL depth");
mutex_unlock(&client->lock);
mutex_unlock(&cdm_hw->hw_mutex);
return rc;
@@ -426,14 +427,16 @@ int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw,
if ((!cdm_cmd->cmd[i].len) &&
(cdm_cmd->cmd[i].len > 0x100000)) {
- pr_err("cmd len(%d) is invalid cnt=%d total cnt=%d\n",
+ CAM_ERR(CAM_CDM,
+ "cmd len(%d) is invalid cnt=%d total cnt=%d",
cdm_cmd->cmd[i].len, i,
req->data->cmd_arrary_count);
rc = -EINVAL;
break;
}
if (atomic_read(&core->error)) {
- pr_err_ratelimited("In error state cnt=%d total cnt=%d\n",
+ CAM_ERR_RATE_LIMIT(CAM_CDM,
+ "In error state cnt=%d total cnt=%d\n",
i, req->data->cmd_arrary_count);
rc = -EIO;
break;
@@ -442,7 +445,8 @@ int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw,
write_count = cam_hw_cdm_wait_for_bl_fifo(cdm_hw,
(req->data->cmd_arrary_count - i));
if (write_count < 0) {
- pr_err("wait for bl fifo failed %d:%d\n",
+ CAM_ERR(CAM_CDM,
+ "wait for bl fifo failed %d:%d",
i, req->data->cmd_arrary_count);
rc = -EIO;
break;
@@ -458,7 +462,8 @@ int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw,
&len);
} else if (req->data->type == CAM_CDM_BL_CMD_TYPE_HW_IOVA) {
if (!cdm_cmd->cmd[i].bl_addr.hw_iova) {
- pr_err("Hw bl hw_iova is invalid %d:%d\n",
+ CAM_ERR(CAM_CDM,
+ "Hw bl hw_iova is invalid %d:%d",
i, req->data->cmd_arrary_count);
rc = -EINVAL;
break;
@@ -468,7 +473,8 @@ int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw,
(uint64_t)cdm_cmd->cmd[i].bl_addr.hw_iova;
len = cdm_cmd->cmd[i].len + cdm_cmd->cmd[i].offset;
} else {
- pr_err("Only mem hdl/hw va type is supported %d\n",
+ CAM_ERR(CAM_CDM,
+ "Only mem hdl/hw va type is supported %d",
req->data->type);
rc = -EINVAL;
break;
@@ -476,7 +482,7 @@ int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw,
if ((!rc) && (hw_vaddr_ptr) && (len) &&
(len >= cdm_cmd->cmd[i].offset)) {
- CDM_CDBG("Got the HW VA\n");
+ CAM_DBG(CAM_CDM, "Got the HW VA");
if (core->bl_tag >=
(CAM_CDM_HWFIFO_SIZE - 1))
core->bl_tag = 0;
@@ -485,33 +491,36 @@ int cam_hw_cdm_submit_bl(struct cam_hw_info *cdm_hw,
cdm_cmd->cmd[i].offset),
(cdm_cmd->cmd[i].len - 1), core->bl_tag);
if (rc) {
- pr_err("Hw bl write failed %d:%d\n",
+ CAM_ERR(CAM_CDM, "Hw bl write failed %d:%d",
i, req->data->cmd_arrary_count);
rc = -EIO;
break;
}
} else {
- pr_err("Sanity check failed for hdl=%x len=%zu:%d\n",
+ CAM_ERR(CAM_CDM,
+ "Sanity check failed for hdl=%x len=%zu:%d",
cdm_cmd->cmd[i].bl_addr.mem_handle, len,
cdm_cmd->cmd[i].offset);
- pr_err("Sanity check failed for %d:%d\n",
+ CAM_ERR(CAM_CDM, "Sanity check failed for %d:%d",
i, req->data->cmd_arrary_count);
rc = -EINVAL;
break;
}
if (!rc) {
- CDM_CDBG("write BL success for cnt=%d with tag=%d\n",
+ CAM_DBG(CAM_CDM,
+ "write BL success for cnt=%d with tag=%d",
i, core->bl_tag);
- CDM_CDBG("Now commit the BL\n");
+ CAM_DBG(CAM_CDM, "Now commit the BL");
if (cam_hw_cdm_commit_bl_write(cdm_hw)) {
- pr_err("Cannot commit the BL %d tag=%d\n",
+ CAM_ERR(CAM_CDM,
+ "Cannot commit the BL %d tag=%d",
i, core->bl_tag);
rc = -EIO;
break;
}
- CDM_CDBG("BL commit success BL %d tag=%d\n", i,
+ CAM_DBG(CAM_CDM, "BL commit success BL %d tag=%d", i,
core->bl_tag);
core->bl_tag++;
if ((req->data->flag == true) &&
@@ -541,12 +550,12 @@ static void cam_hw_cdm_work(struct work_struct *work)
cdm_hw = payload->hw;
core = (struct cam_cdm *)cdm_hw->core_info;
- CDM_CDBG("IRQ status=%x\n", payload->irq_status);
+ CAM_DBG(CAM_CDM, "IRQ status=%x", payload->irq_status);
if (payload->irq_status &
CAM_CDM_IRQ_STATUS_INFO_INLINE_IRQ_MASK) {
struct cam_cdm_bl_cb_request_entry *node;
- CDM_CDBG("inline IRQ data=%x\n",
+ CAM_DBG(CAM_CDM, "inline IRQ data=%x",
payload->irq_data);
mutex_lock(&cdm_hw->hw_mutex);
node = cam_cdm_find_request_by_bl_tag(
@@ -560,13 +569,15 @@ static void cam_hw_cdm_work(struct work_struct *work)
(void *)node);
} else if (node->request_type ==
CAM_HW_CDM_BL_CB_INTERNAL) {
- pr_err("Invalid node=%pK %d\n", node,
+ CAM_ERR(CAM_CDM,
+ "Invalid node=%pK %d", node,
node->request_type);
}
list_del_init(&node->entry);
kfree(node);
} else {
- pr_err("Invalid node for inline irq status=%x data=%x\n",
+ CAM_ERR(CAM_CDM,
+ "Inval node, inline_irq st=%x data=%x",
payload->irq_status, payload->irq_data);
}
mutex_unlock(&cdm_hw->hw_mutex);
@@ -574,39 +585,40 @@ static void cam_hw_cdm_work(struct work_struct *work)
if (payload->irq_status &
CAM_CDM_IRQ_STATUS_INFO_RST_DONE_MASK) {
- CDM_CDBG("CDM HW reset done IRQ\n");
+ CAM_DBG(CAM_CDM, "CDM HW reset done IRQ");
complete(&core->reset_complete);
}
if (payload->irq_status &
CAM_CDM_IRQ_STATUS_INFO_BL_DONE_MASK) {
if (atomic_read(&core->bl_done)) {
- CDM_CDBG("CDM HW BL done IRQ\n");
+ CAM_DBG(CAM_CDM, "CDM HW BL done IRQ");
complete(&core->bl_complete);
}
}
if (payload->irq_status &
CAM_CDM_IRQ_STATUS_ERROR_INV_CMD_MASK) {
- pr_err_ratelimited("Invalid command IRQ, Need HW reset\n");
+ CAM_ERR_RATE_LIMIT(CAM_CDM,
+ "Invalid command IRQ, Need HW reset\n");
atomic_inc(&core->error);
cam_hw_cdm_dump_core_debug_registers(cdm_hw);
}
if (payload->irq_status &
CAM_CDM_IRQ_STATUS_ERROR_AHB_BUS_MASK) {
- pr_err_ratelimited("AHB Error IRQ\n");
+ CAM_ERR_RATE_LIMIT(CAM_CDM, "AHB Error IRQ\n");
atomic_inc(&core->error);
cam_hw_cdm_dump_core_debug_registers(cdm_hw);
atomic_dec(&core->error);
}
if (payload->irq_status &
CAM_CDM_IRQ_STATUS_ERROR_OVER_FLOW_MASK) {
- pr_err_ratelimited("Overflow Error IRQ\n");
+ CAM_ERR_RATE_LIMIT(CAM_CDM, "Overflow Error IRQ\n");
atomic_inc(&core->error);
cam_hw_cdm_dump_core_debug_registers(cdm_hw);
atomic_dec(&core->error);
}
kfree(payload);
} else {
- pr_err("NULL payload\n");
+ CAM_ERR(CAM_CDM, "NULL payload");
}
}
@@ -622,12 +634,13 @@ static void cam_hw_cdm_iommu_fault_handler(struct iommu_domain *domain,
core = (struct cam_cdm *)cdm_hw->core_info;
atomic_inc(&core->error);
cam_hw_cdm_dump_core_debug_registers(cdm_hw);
- pr_err_ratelimited("Page fault iova addr %pK\n", (void *)iova);
+ CAM_ERR_RATE_LIMIT(CAM_CDM, "Page fault iova addr %pK\n",
+ (void *)iova);
cam_cdm_notify_clients(cdm_hw, CAM_CDM_CB_STATUS_PAGEFAULT,
(void *)iova);
atomic_dec(&core->error);
} else {
- pr_err("Invalid token\n");
+ CAM_ERR(CAM_CDM, "Invalid token");
}
}
@@ -639,15 +652,15 @@ irqreturn_t cam_hw_cdm_irq(int irq_num, void *data)
struct cam_cdm_work_payload *payload;
bool work_status;
- CDM_CDBG("Got irq\n");
+ CAM_DBG(CAM_CDM, "Got irq");
payload = kzalloc(sizeof(struct cam_cdm_work_payload), GFP_ATOMIC);
if (payload) {
if (cam_cdm_read_hw_reg(cdm_hw, CDM_IRQ_STATUS,
&payload->irq_status)) {
- pr_err("Failed to read CDM HW IRQ status\n");
+ CAM_ERR(CAM_CDM, "Failed to read CDM HW IRQ status");
}
if (!payload->irq_status) {
- pr_err_ratelimited("Invalid irq received\n");
+ CAM_ERR_RATE_LIMIT(CAM_CDM, "Invalid irq received\n");
kfree(payload);
return IRQ_HANDLED;
}
@@ -655,21 +668,22 @@ irqreturn_t cam_hw_cdm_irq(int irq_num, void *data)
CAM_CDM_IRQ_STATUS_INFO_INLINE_IRQ_MASK) {
if (cam_cdm_read_hw_reg(cdm_hw, CDM_IRQ_USR_DATA,
&payload->irq_data)) {
- pr_err("Failed to read CDM HW IRQ data\n");
+ CAM_ERR(CAM_CDM,
+ "Failed to read CDM HW IRQ data");
}
}
- CDM_CDBG("Got payload=%d\n", payload->irq_status);
+ CAM_DBG(CAM_CDM, "Got payload=%d", payload->irq_status);
payload->hw = cdm_hw;
INIT_WORK((struct work_struct *)&payload->work,
cam_hw_cdm_work);
if (cam_cdm_write_hw_reg(cdm_hw, CDM_IRQ_CLEAR,
payload->irq_status))
- pr_err("Failed to Write CDM HW IRQ Clear\n");
+ CAM_ERR(CAM_CDM, "Failed to Write CDM HW IRQ Clear");
if (cam_cdm_write_hw_reg(cdm_hw, CDM_IRQ_CLEAR_CMD, 0x01))
- pr_err("Failed to Write CDM HW IRQ cmd\n");
+ CAM_ERR(CAM_CDM, "Failed to Write CDM HW IRQ cmd");
work_status = queue_work(cdm_core->work_queue, &payload->work);
if (work_status == false) {
- pr_err("Failed to queue work for irq=%x\n",
+ CAM_ERR(CAM_CDM, "Failed to queue work for irq=%x",
payload->irq_status);
kfree(payload);
}
@@ -697,7 +711,7 @@ int cam_hw_cdm_alloc_genirq_mem(void *hw_priv)
rc = cam_mem_mgr_request_mem(&genirq_alloc_cmd,
&genirq_alloc_out);
if (rc) {
- pr_err("Failed to get genirq cmd space rc=%d\n", rc);
+ CAM_ERR(CAM_CDM, "Failed to get genirq cmd space rc=%d", rc);
goto end;
}
cdm_core->gen_irq.handle = genirq_alloc_out.mem_handle;
@@ -723,7 +737,7 @@ int cam_hw_cdm_release_genirq_mem(void *hw_priv)
genirq_release_cmd.mem_handle = cdm_core->gen_irq.handle;
rc = cam_mem_mgr_release_mem(&genirq_release_cmd);
if (rc)
- pr_err("Failed to put genirq cmd space for hw\n");
+ CAM_ERR(CAM_CDM, "Failed to put genirq cmd space for hw");
return rc;
}
@@ -746,11 +760,11 @@ int cam_hw_cdm_init(void *hw_priv,
rc = cam_soc_util_enable_platform_resource(soc_info, true,
CAM_SVS_VOTE, true);
if (rc) {
- pr_err("Enable platform failed\n");
+ CAM_ERR(CAM_CDM, "Enable platform failed");
goto end;
}
- CDM_CDBG("Enable soc done\n");
+ CAM_DBG(CAM_CDM, "Enable soc done");
/* Before triggering the reset to HW, clear the reset complete */
atomic_set(&cdm_core->error, 0);
@@ -759,15 +773,15 @@ int cam_hw_cdm_init(void *hw_priv,
reinit_completion(&cdm_core->bl_complete);
if (cam_cdm_write_hw_reg(cdm_hw, CDM_IRQ_MASK, 0x70003)) {
- pr_err("Failed to Write CDM HW IRQ mask\n");
+ CAM_ERR(CAM_CDM, "Failed to Write CDM HW IRQ mask");
goto disable_return;
}
if (cam_cdm_write_hw_reg(cdm_hw, CDM_CFG_RST_CMD, 0x9)) {
- pr_err("Failed to Write CDM HW reset\n");
+ CAM_ERR(CAM_CDM, "Failed to Write CDM HW reset");
goto disable_return;
}
- CDM_CDBG("Waiting for CDM HW resetdone\n");
+ CAM_DBG(CAM_CDM, "Waiting for CDM HW resetdone");
time_left = wait_for_completion_timeout(&cdm_core->reset_complete,
msecs_to_jiffies(CAM_CDM_HW_RESET_TIMEOUT));
@@ -778,15 +792,16 @@ int cam_hw_cdm_init(void *hw_priv,
* as a workaround.
*/
if (time_left <= 0) {
- pr_err("CDM HW reset Wait failed time_left=%ld\n", time_left);
+ CAM_ERR(CAM_CDM, "CDM HW reset Wait failed time_left=%ld",
+ time_left);
time_left = 1;
}
if (time_left <= 0) {
- pr_err("CDM HW reset Wait failed rc=%d\n", rc);
+ CAM_ERR(CAM_CDM, "CDM HW reset Wait failed rc=%d", rc);
goto disable_return;
} else {
- CDM_CDBG("CDM Init success\n");
+ CAM_DBG(CAM_CDM, "CDM Init success");
cdm_hw->hw_state = CAM_HW_STATE_POWER_UP;
cam_cdm_write_hw_reg(cdm_hw, CDM_IRQ_MASK, 0x70003);
rc = 0;
@@ -815,9 +830,9 @@ int cam_hw_cdm_deinit(void *hw_priv,
cdm_core = cdm_hw->core_info;
rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
if (rc) {
- pr_err("disable platform failed\n");
+ CAM_ERR(CAM_CDM, "disable platform failed");
} else {
- CDM_CDBG("CDM Deinit success\n");
+ CAM_DBG(CAM_CDM, "CDM Deinit success");
cdm_hw->hw_state = CAM_HW_STATE_POWER_DOWN;
}
@@ -862,7 +877,7 @@ int cam_hw_cdm_probe(struct platform_device *pdev)
rc = cam_hw_cdm_soc_get_dt_properties(cdm_hw, msm_cam_hw_cdm_dt_match);
if (rc) {
- pr_err("Failed to get dt properties\n");
+ CAM_ERR(CAM_CDM, "Failed to get dt properties");
goto release_mem;
}
cdm_hw_intf->hw_idx = cdm_hw->soc_info.index;
@@ -877,7 +892,8 @@ int cam_hw_cdm_probe(struct platform_device *pdev)
cdm_core->bl_tag = 0;
cdm_core->id = cam_hw_cdm_get_id_by_name(cdm_core->name);
if (cdm_core->id >= CAM_CDM_MAX) {
- pr_err("Failed to get CDM HW name for %s\n", cdm_core->name);
+ CAM_ERR(CAM_CDM, "Failed to get CDM HW name for %s",
+ cdm_core->name);
goto release_private_mem;
}
INIT_LIST_HEAD(&cdm_core->bl_request_list);
@@ -894,14 +910,14 @@ int cam_hw_cdm_probe(struct platform_device *pdev)
cdm_hw_intf->hw_ops.process_cmd = cam_cdm_process_cmd;
mutex_lock(&cdm_hw->hw_mutex);
- CDM_CDBG("type %d index %d\n", cdm_hw_intf->hw_type,
+ CAM_DBG(CAM_CDM, "type %d index %d", cdm_hw_intf->hw_type,
cdm_hw_intf->hw_idx);
platform_set_drvdata(pdev, cdm_hw_intf);
rc = cam_smmu_get_handle("cpas-cdm0", &cdm_core->iommu_hdl.non_secure);
if (rc < 0) {
- pr_err("cpas-cdm get iommu handle failed\n");
+ CAM_ERR(CAM_CDM, "cpas-cdm get iommu handle failed");
goto unlock_release_mem;
}
cam_smmu_reg_client_page_fault_handler(cdm_core->iommu_hdl.non_secure,
@@ -909,7 +925,7 @@ int cam_hw_cdm_probe(struct platform_device *pdev)
rc = cam_smmu_ops(cdm_core->iommu_hdl.non_secure, CAM_SMMU_ATTACH);
if (rc < 0) {
- pr_err("Attach iommu non secure handle failed\n");
+ CAM_ERR(CAM_CDM, "Attach iommu non secure handle failed");
goto destroy_non_secure_hdl;
}
cdm_core->iommu_hdl.secure = -1;
@@ -921,7 +937,7 @@ int cam_hw_cdm_probe(struct platform_device *pdev)
rc = cam_soc_util_request_platform_resource(&cdm_hw->soc_info,
cam_hw_cdm_irq, cdm_hw);
if (rc) {
- pr_err("Failed to request platform resource\n");
+ CAM_ERR(CAM_CDM, "Failed to request platform resource");
goto destroy_non_secure_hdl;
}
@@ -932,10 +948,10 @@ int cam_hw_cdm_probe(struct platform_device *pdev)
strlcpy(cpas_parms.identifier, "cpas-cdm", CAM_HW_IDENTIFIER_LENGTH);
rc = cam_cpas_register_client(&cpas_parms);
if (rc) {
- pr_err("Virtual CDM CPAS registration failed\n");
+ CAM_ERR(CAM_CDM, "Virtual CDM CPAS registration failed");
goto release_platform_resource;
}
- CDM_CDBG("CPAS registration successful handle=%d\n",
+ CAM_DBG(CAM_CDM, "CPAS registration successful handle=%d",
cpas_parms.client_handle);
cdm_core->cpas_handle = cpas_parms.client_handle;
@@ -945,54 +961,54 @@ int cam_hw_cdm_probe(struct platform_device *pdev)
axi_vote.uncompressed_bw = CAM_CPAS_DEFAULT_AXI_BW;
rc = cam_cpas_start(cdm_core->cpas_handle, &ahb_vote, &axi_vote);
if (rc) {
- pr_err("CPAS start failed\n");
+ CAM_ERR(CAM_CDM, "CPAS start failed");
goto cpas_unregister;
}
rc = cam_hw_cdm_init(cdm_hw, NULL, 0);
if (rc) {
- pr_err("Failed to Init CDM HW\n");
+ CAM_ERR(CAM_CDM, "Failed to Init CDM HW");
goto cpas_stop;
}
cdm_hw->open_count++;
if (cam_cdm_read_hw_reg(cdm_hw, CDM_CFG_HW_VERSION,
&cdm_core->hw_version)) {
- pr_err("Failed to read CDM HW Version\n");
+ CAM_ERR(CAM_CDM, "Failed to read CDM HW Version");
goto deinit;
}
if (cam_cdm_read_hw_reg(cdm_hw, CDM_CFG_TITAN_VERSION,
&cdm_core->hw_family_version)) {
- pr_err("Failed to read CDM family Version\n");
+ CAM_ERR(CAM_CDM, "Failed to read CDM family Version");
goto deinit;
}
- CDM_CDBG("CDM Hw version read success family =%x hw =%x\n",
+ CAM_DBG(CAM_CDM, "CDM Hw version read success family =%x hw =%x",
cdm_core->hw_family_version, cdm_core->hw_version);
cdm_core->ops = cam_cdm_get_ops(cdm_core->hw_version, NULL,
false);
if (!cdm_core->ops) {
- pr_err("Failed to util ops for hw\n");
+ CAM_ERR(CAM_CDM, "Failed to util ops for hw");
goto deinit;
}
if (!cam_cdm_set_cam_hw_version(cdm_core->hw_version,
&cdm_core->version)) {
- pr_err("Failed to set cam he version for hw\n");
+ CAM_ERR(CAM_CDM, "Failed to set cam he version for hw");
goto deinit;
}
rc = cam_hw_cdm_deinit(cdm_hw, NULL, 0);
if (rc) {
- pr_err("Failed to Deinit CDM HW\n");
+ CAM_ERR(CAM_CDM, "Failed to Deinit CDM HW");
cdm_hw->open_count--;
goto cpas_stop;
}
rc = cam_cpas_stop(cdm_core->cpas_handle);
if (rc) {
- pr_err("CPAS stop failed\n");
+ CAM_ERR(CAM_CDM, "CPAS stop failed");
cdm_hw->open_count--;
goto cpas_unregister;
}
@@ -1000,30 +1016,30 @@ int cam_hw_cdm_probe(struct platform_device *pdev)
rc = cam_cdm_intf_register_hw_cdm(cdm_hw_intf,
soc_private, CAM_HW_CDM, &cdm_core->index);
if (rc) {
- pr_err("HW CDM Interface registration failed\n");
+ CAM_ERR(CAM_CDM, "HW CDM Interface registration failed");
cdm_hw->open_count--;
goto cpas_unregister;
}
cdm_hw->open_count--;
mutex_unlock(&cdm_hw->hw_mutex);
- CDM_CDBG("CDM%d probe successful\n", cdm_hw_intf->hw_idx);
+ CAM_DBG(CAM_CDM, "CDM%d probe successful", cdm_hw_intf->hw_idx);
return rc;
deinit:
if (cam_hw_cdm_deinit(cdm_hw, NULL, 0))
- pr_err("Deinit failed for hw\n");
+ CAM_ERR(CAM_CDM, "Deinit failed for hw");
cdm_hw->open_count--;
cpas_stop:
if (cam_cpas_stop(cdm_core->cpas_handle))
- pr_err("CPAS stop failed\n");
+ CAM_ERR(CAM_CDM, "CPAS stop failed");
cpas_unregister:
if (cam_cpas_unregister_client(cdm_core->cpas_handle))
- pr_err("CPAS unregister failed\n");
+ CAM_ERR(CAM_CDM, "CPAS unregister failed");
release_platform_resource:
if (cam_soc_util_release_platform_resource(&cdm_hw->soc_info))
- pr_err("Release platform resource failed\n");
+ CAM_ERR(CAM_CDM, "Release platform resource failed");
flush_workqueue(cdm_core->work_queue);
destroy_workqueue(cdm_core->work_queue);
@@ -1031,7 +1047,7 @@ int cam_hw_cdm_probe(struct platform_device *pdev)
cam_smmu_reg_client_page_fault_handler(cdm_core->iommu_hdl.non_secure,
NULL, cdm_hw);
if (cam_smmu_destroy_handle(cdm_core->iommu_hdl.non_secure))
- pr_err("Release iommu secure hdl failed\n");
+ CAM_ERR(CAM_CDM, "Release iommu secure hdl failed");
unlock_release_mem:
mutex_unlock(&cdm_hw->hw_mutex);
release_private_mem:
@@ -1053,26 +1069,28 @@ int cam_hw_cdm_remove(struct platform_device *pdev)
cdm_hw_intf = platform_get_drvdata(pdev);
if (!cdm_hw_intf) {
- pr_err("Failed to get dev private data\n");
+ CAM_ERR(CAM_CDM, "Failed to get dev private data");
return rc;
}
cdm_hw = cdm_hw_intf->hw_priv;
if (!cdm_hw) {
- pr_err("Failed to get hw private data for type=%d idx=%d\n",
+ CAM_ERR(CAM_CDM,
+ "Failed to get hw private data for type=%d idx=%d",
cdm_hw_intf->hw_type, cdm_hw_intf->hw_idx);
return rc;
}
cdm_core = cdm_hw->core_info;
if (!cdm_core) {
- pr_err("Failed to get hw core data for type=%d idx=%d\n",
+ CAM_ERR(CAM_CDM,
+ "Failed to get hw core data for type=%d idx=%d",
cdm_hw_intf->hw_type, cdm_hw_intf->hw_idx);
return rc;
}
if (cdm_hw->open_count != 0) {
- pr_err("Hw open count invalid type=%d idx=%d cnt=%d\n",
+ CAM_ERR(CAM_CDM, "Hw open count invalid type=%d idx=%d cnt=%d",
cdm_hw_intf->hw_type, cdm_hw_intf->hw_idx,
cdm_hw->open_count);
return rc;
@@ -1080,24 +1098,24 @@ int cam_hw_cdm_remove(struct platform_device *pdev)
rc = cam_hw_cdm_deinit(cdm_hw, NULL, 0);
if (rc) {
- pr_err("Deinit failed for hw\n");
+ CAM_ERR(CAM_CDM, "Deinit failed for hw");
return rc;
}
rc = cam_cpas_unregister_client(cdm_core->cpas_handle);
if (rc) {
- pr_err("CPAS unregister failed\n");
+ CAM_ERR(CAM_CDM, "CPAS unregister failed");
return rc;
}
if (cam_soc_util_release_platform_resource(&cdm_hw->soc_info))
- pr_err("Release platform resource failed\n");
+ CAM_ERR(CAM_CDM, "Release platform resource failed");
flush_workqueue(cdm_core->work_queue);
destroy_workqueue(cdm_core->work_queue);
if (cam_smmu_destroy_handle(cdm_core->iommu_hdl.non_secure))
- pr_err("Release iommu secure hdl failed\n");
+ CAM_ERR(CAM_CDM, "Release iommu secure hdl failed");
cam_smmu_reg_client_page_fault_handler(cdm_core->iommu_hdl.non_secure,
NULL, cdm_hw);
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_intf.c b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_intf.c
index 59f5b92..fa98be2 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_intf.c
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_intf.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CAM-CDM-INTF %s:%d " fmt, __func__, __LINE__
-
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/of.h>
@@ -41,10 +39,10 @@ static int get_cdm_mgr_refcount(void)
mutex_lock(&cam_cdm_mgr_lock);
if (cdm_mgr.probe_done == false) {
- pr_err("CDM intf mgr not probed yet\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr not probed yet");
rc = -EPERM;
} else {
- CDM_CDBG("CDM intf mgr get refcount=%d\n",
+ CAM_DBG(CAM_CDM, "CDM intf mgr get refcount=%d",
cdm_mgr.refcount);
cdm_mgr.refcount++;
}
@@ -56,14 +54,14 @@ static void put_cdm_mgr_refcount(void)
{
mutex_lock(&cam_cdm_mgr_lock);
if (cdm_mgr.probe_done == false) {
- pr_err("CDM intf mgr not probed yet\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr not probed yet");
} else {
- CDM_CDBG("CDM intf mgr put refcount=%d\n",
+ CAM_DBG(CAM_CDM, "CDM intf mgr put refcount=%d",
cdm_mgr.refcount);
if (cdm_mgr.refcount > 0) {
cdm_mgr.refcount--;
} else {
- pr_err("Refcount put when zero\n");
+ CAM_ERR(CAM_CDM, "Refcount put when zero");
WARN_ON(1);
}
}
@@ -90,20 +88,20 @@ static int get_cdm_index_by_id(char *identifier,
int rc = -EPERM, i, j;
char client_name[128];
- CDM_CDBG("Looking for HW id of =%s and index=%d\n",
+ CAM_DBG(CAM_CDM, "Looking for HW id of =%s and index=%d",
identifier, cell_index);
snprintf(client_name, sizeof(client_name), "%s", identifier);
- CDM_CDBG("Looking for HW id of %s count:%d\n", client_name,
+ CAM_DBG(CAM_CDM, "Looking for HW id of %s count:%d", client_name,
cdm_mgr.cdm_count);
mutex_lock(&cam_cdm_mgr_lock);
for (i = 0; i < cdm_mgr.cdm_count; i++) {
mutex_lock(&cdm_mgr.nodes[i].lock);
- CDM_CDBG("dt_num_supported_clients=%d\n",
+ CAM_DBG(CAM_CDM, "dt_num_supported_clients=%d",
cdm_mgr.nodes[i].data->dt_num_supported_clients);
for (j = 0; j <
cdm_mgr.nodes[i].data->dt_num_supported_clients; j++) {
- CDM_CDBG("client name:%s\n",
+ CAM_DBG(CAM_CDM, "client name:%s",
cdm_mgr.nodes[i].data->dt_cdm_client_name[j]);
if (!strcmp(
cdm_mgr.nodes[i].data->dt_cdm_client_name[j],
@@ -131,10 +129,10 @@ int cam_cdm_get_iommu_handle(char *identifier,
return -EINVAL;
if (get_cdm_mgr_refcount()) {
- pr_err("CDM intf mgr get refcount failed\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
return rc;
}
- CDM_CDBG("Looking for Iommu handle of %s\n", identifier);
+ CAM_DBG(CAM_CDM, "Looking for Iommu handle of %s", identifier);
for (i = 0; i < cdm_mgr.cdm_count; i++) {
mutex_lock(&cdm_mgr.nodes[i].lock);
@@ -173,39 +171,41 @@ int cam_cdm_acquire(struct cam_cdm_acquire_data *data)
return -EINVAL;
if (get_cdm_mgr_refcount()) {
- pr_err("CDM intf mgr get refcount failed\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
return rc;
}
if (data->id > CAM_CDM_HW_ANY) {
- pr_err("only CAM_CDM_VIRTUAL/CAM_CDM_HW_ANY is supported\n");
+ CAM_ERR(CAM_CDM,
+ "only CAM_CDM_VIRTUAL/CAM_CDM_HW_ANY is supported");
rc = -EPERM;
goto end;
}
rc = get_cdm_index_by_id(data->identifier, data->cell_index,
&hw_index);
if ((rc < 0) && (hw_index < CAM_CDM_INTF_MGR_MAX_SUPPORTED_CDM)) {
- pr_err("Failed to identify associated hw id\n");
+ CAM_ERR(CAM_CDM, "Failed to identify associated hw id");
goto end;
} else {
- CDM_CDBG("hw_index:%d\n", hw_index);
+ CAM_DBG(CAM_CDM, "hw_index:%d", hw_index);
hw = cdm_mgr.nodes[hw_index].device;
if (hw && hw->hw_ops.process_cmd) {
rc = hw->hw_ops.process_cmd(hw->hw_priv,
CAM_CDM_HW_INTF_CMD_ACQUIRE, data,
sizeof(struct cam_cdm_acquire_data));
if (rc < 0) {
- pr_err("CDM hw acquire failed\n");
+ CAM_ERR(CAM_CDM, "CDM hw acquire failed");
goto end;
}
} else {
- pr_err("idx %d doesn't have acquire ops\n", hw_index);
+ CAM_ERR(CAM_CDM, "idx %d doesn't have acquire ops",
+ hw_index);
rc = -EPERM;
}
}
end:
if (rc < 0) {
- pr_err("CDM acquire failed for id=%d name=%s, idx=%d\n",
+ CAM_ERR(CAM_CDM, "CDM acquire failed for id=%d name=%s, idx=%d",
data->id, data->identifier, data->cell_index);
put_cdm_mgr_refcount();
}
@@ -220,7 +220,7 @@ int cam_cdm_release(uint32_t handle)
struct cam_hw_intf *hw;
if (get_cdm_mgr_refcount()) {
- pr_err("CDM intf mgr get refcount failed\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
return rc;
}
@@ -232,10 +232,11 @@ int cam_cdm_release(uint32_t handle)
CAM_CDM_HW_INTF_CMD_RELEASE, &handle,
sizeof(handle));
if (rc < 0)
- pr_err("hw release failed for handle=%x\n",
+ CAM_ERR(CAM_CDM,
+ "hw release failed for handle=%x",
handle);
} else
- pr_err("hw idx %d doesn't have release ops\n",
+ CAM_ERR(CAM_CDM, "hw idx %d doesn't have release ops",
hw_index);
}
put_cdm_mgr_refcount();
@@ -257,7 +258,7 @@ int cam_cdm_submit_bls(uint32_t handle, struct cam_cdm_bl_request *data)
return rc;
if (get_cdm_mgr_refcount()) {
- pr_err("CDM intf mgr get refcount failed\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
rc = -EPERM;
return rc;
}
@@ -274,10 +275,11 @@ int cam_cdm_submit_bls(uint32_t handle, struct cam_cdm_bl_request *data)
CAM_CDM_HW_INTF_CMD_SUBMIT_BL, &req,
sizeof(struct cam_cdm_hw_intf_cmd_submit_bl));
if (rc < 0)
- pr_err("hw submit bl failed for handle=%x\n",
+ CAM_ERR(CAM_CDM,
+ "hw submit bl failed for handle=%x",
handle);
} else {
- pr_err("hw idx %d doesn't have submit ops\n",
+ CAM_ERR(CAM_CDM, "hw idx %d doesn't have submit ops",
hw_index);
}
}
@@ -294,7 +296,7 @@ int cam_cdm_stream_on(uint32_t handle)
struct cam_hw_intf *hw;
if (get_cdm_mgr_refcount()) {
- pr_err("CDM intf mgr get refcount failed\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
rc = -EPERM;
return rc;
}
@@ -306,10 +308,12 @@ int cam_cdm_stream_on(uint32_t handle)
rc = hw->hw_ops.start(hw->hw_priv, &handle,
sizeof(uint32_t));
if (rc < 0)
- pr_err("hw start failed handle=%x\n",
+ CAM_ERR(CAM_CDM,
+ "hw start failed handle=%x",
handle);
} else {
- pr_err("hw idx %d doesn't have start ops\n",
+ CAM_ERR(CAM_CDM,
+ "hw idx %d doesn't have start ops",
hw_index);
}
}
@@ -326,7 +330,7 @@ int cam_cdm_stream_off(uint32_t handle)
struct cam_hw_intf *hw;
if (get_cdm_mgr_refcount()) {
- pr_err("CDM intf mgr get refcount failed\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
rc = -EPERM;
return rc;
}
@@ -338,10 +342,10 @@ int cam_cdm_stream_off(uint32_t handle)
rc = hw->hw_ops.stop(hw->hw_priv, &handle,
sizeof(uint32_t));
if (rc < 0)
- pr_err("hw stop failed handle=%x\n",
+ CAM_ERR(CAM_CDM, "hw stop failed handle=%x",
handle);
} else {
- pr_err("hw idx %d doesn't have stop ops\n",
+ CAM_ERR(CAM_CDM, "hw idx %d doesn't have stop ops",
hw_index);
}
}
@@ -358,7 +362,7 @@ int cam_cdm_reset_hw(uint32_t handle)
struct cam_hw_intf *hw;
if (get_cdm_mgr_refcount()) {
- pr_err("CDM intf mgr get refcount failed\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
rc = -EPERM;
return rc;
}
@@ -371,10 +375,11 @@ int cam_cdm_reset_hw(uint32_t handle)
CAM_CDM_HW_INTF_CMD_RESET_HW, &handle,
sizeof(handle));
if (rc < 0)
- pr_err("CDM hw release failed for handle=%x\n",
+ CAM_ERR(CAM_CDM,
+ "CDM hw release failed for handle=%x",
handle);
} else {
- pr_err("hw idx %d doesn't have release ops\n",
+ CAM_ERR(CAM_CDM, "hw idx %d doesn't have release ops",
hw_index);
}
}
@@ -394,7 +399,7 @@ int cam_cdm_intf_register_hw_cdm(struct cam_hw_intf *hw,
return rc;
if (get_cdm_mgr_refcount()) {
- pr_err("CDM intf mgr get refcount failed\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
return rc;
}
@@ -417,7 +422,7 @@ int cam_cdm_intf_register_hw_cdm(struct cam_hw_intf *hw,
cdm_mgr.cdm_count++;
rc = 0;
} else {
- pr_err("CDM registration failed type=%d count=%d\n",
+ CAM_ERR(CAM_CDM, "CDM registration failed type=%d count=%d",
type, cdm_mgr.cdm_count);
}
mutex_unlock(&cam_cdm_mgr_lock);
@@ -436,7 +441,7 @@ int cam_cdm_intf_deregister_hw_cdm(struct cam_hw_intf *hw,
return rc;
if (get_cdm_mgr_refcount()) {
- pr_err("CDM intf mgr get refcount failed\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
rc = -EPERM;
return rc;
}
@@ -459,7 +464,7 @@ int cam_cdm_intf_deregister_hw_cdm(struct cam_hw_intf *hw,
cdm_mgr.cdm_count--;
rc = 0;
} else {
- pr_err("CDM Deregistration failed type=%d index=%d\n",
+ CAM_ERR(CAM_CDM, "CDM Deregistration failed type=%d index=%d",
type, index);
}
mutex_unlock(&cam_cdm_mgr_lock);
@@ -474,7 +479,7 @@ static int cam_cdm_intf_probe(struct platform_device *pdev)
rc = cam_cdm_intf_mgr_soc_get_dt_properties(pdev, &cdm_mgr);
if (rc) {
- pr_err("Failed to get dt properties\n");
+ CAM_ERR(CAM_CDM, "Failed to get dt properties");
return rc;
}
mutex_lock(&cam_cdm_mgr_lock);
@@ -494,7 +499,8 @@ static int cam_cdm_intf_probe(struct platform_device *pdev)
for (i = 0 ; i < CAM_CDM_INTF_MGR_MAX_SUPPORTED_CDM; i++) {
if (cdm_mgr.nodes[i].device || cdm_mgr.nodes[i].data ||
(cdm_mgr.nodes[i].refcount != 0))
- pr_err("Valid node present in index=%d\n", i);
+ CAM_ERR(CAM_CDM,
+ "Valid node present in index=%d", i);
mutex_destroy(&cdm_mgr.nodes[i].lock);
cdm_mgr.nodes[i].device = NULL;
cdm_mgr.nodes[i].data = NULL;
@@ -511,19 +517,19 @@ static int cam_cdm_intf_remove(struct platform_device *pdev)
int i, rc = -EBUSY;
if (get_cdm_mgr_refcount()) {
- pr_err("CDM intf mgr get refcount failed\n");
+ CAM_ERR(CAM_CDM, "CDM intf mgr get refcount failed");
return rc;
}
if (cam_virtual_cdm_remove(pdev)) {
- pr_err("Virtual CDM remove failed\n");
+ CAM_ERR(CAM_CDM, "Virtual CDM remove failed");
goto end;
}
put_cdm_mgr_refcount();
mutex_lock(&cam_cdm_mgr_lock);
if (cdm_mgr.refcount != 0) {
- pr_err("cdm manger refcount not zero %d\n",
+ CAM_ERR(CAM_CDM, "cdm manger refcount not zero %d",
cdm_mgr.refcount);
goto end;
}
@@ -531,7 +537,7 @@ static int cam_cdm_intf_remove(struct platform_device *pdev)
for (i = 0 ; i < CAM_CDM_INTF_MGR_MAX_SUPPORTED_CDM; i++) {
if (cdm_mgr.nodes[i].device || cdm_mgr.nodes[i].data ||
(cdm_mgr.nodes[i].refcount != 0)) {
- pr_err("Valid node present in index=%d\n", i);
+ CAM_ERR(CAM_CDM, "Valid node present in index=%d", i);
mutex_unlock(&cam_cdm_mgr_lock);
goto end;
}
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_soc.c b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_soc.c
index fbf185c..f8b0d3d 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_soc.c
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_soc.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CAM-CDM-SOC %s:%d " fmt, __func__, __LINE__
-
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/of.h>
@@ -40,27 +38,29 @@ bool cam_cdm_read_hw_reg(struct cam_hw_info *cdm_hw,
resource_size_t mem_len =
cdm_hw->soc_info.reg_map[CAM_HW_CDM_BASE_INDEX].size;
- CDM_CDBG("E: b=%pK blen=%d reg=%x off=%x\n", (void *)base,
+ CAM_DBG(CAM_CDM, "E: b=%pK blen=%d reg=%x off=%x", (void __iomem *)base,
(int)mem_len, reg, (CAM_CDM_OFFSET_FROM_REG(cdm->offset_tbl,
reg)));
- CDM_CDBG("E: b=%pK reg=%x off=%x\n", (void *)base,
+ CAM_DBG(CAM_CDM, "E: b=%pK reg=%x off=%x", (void __iomem *)base,
reg, (CAM_CDM_OFFSET_FROM_REG(cdm->offset_tbl, reg)));
if ((reg > cdm->offset_tbl->offset_max_size) ||
(reg > cdm->offset_tbl->last_offset)) {
- pr_err_ratelimited("Invalid reg=%d\n", reg);
+ CAM_ERR_RATE_LIMIT(CAM_CDM, "Invalid reg=%d\n", reg);
goto permission_error;
} else {
reg_addr = (base + (CAM_CDM_OFFSET_FROM_REG(
cdm->offset_tbl, reg)));
if (reg_addr > (base + mem_len)) {
- pr_err_ratelimited("Invalid mapped region %d\n", reg);
+ CAM_ERR_RATE_LIMIT(CAM_CDM,
+ "Invalid mapped region %d", reg);
goto permission_error;
}
*value = cam_io_r_mb(reg_addr);
- CDM_CDBG("X b=%pK reg=%x off=%x val=%x\n",
- (void *)base, reg, (CAM_CDM_OFFSET_FROM_REG(
- cdm->offset_tbl, reg)), *value);
+ CAM_DBG(CAM_CDM, "X b=%pK reg=%x off=%x val=%x",
+ (void __iomem *)base, reg,
+ (CAM_CDM_OFFSET_FROM_REG(cdm->offset_tbl, reg)),
+ *value);
return false;
}
permission_error:
@@ -79,18 +79,20 @@ bool cam_cdm_write_hw_reg(struct cam_hw_info *cdm_hw,
resource_size_t mem_len =
cdm_hw->soc_info.reg_map[CAM_HW_CDM_BASE_INDEX].size;
- CDM_CDBG("E: b=%pK reg=%x off=%x val=%x\n", (void *)base,
+ CAM_DBG(CAM_CDM, "E: b=%pK reg=%x off=%x val=%x", (void __iomem *)base,
reg, (CAM_CDM_OFFSET_FROM_REG(cdm->offset_tbl, reg)), value);
if ((reg > cdm->offset_tbl->offset_max_size) ||
(reg > cdm->offset_tbl->last_offset)) {
- pr_err_ratelimited("CDM accessing invalid reg=%d\n", reg);
+ CAM_ERR_RATE_LIMIT(CAM_CDM, "CDM accessing invalid reg=%d\n",
+ reg);
goto permission_error;
} else {
reg_addr = (base + CAM_CDM_OFFSET_FROM_REG(
cdm->offset_tbl, reg));
if (reg_addr > (base + mem_len)) {
- pr_err_ratelimited("Accessing invalid region %d:%d\n",
+ CAM_ERR_RATE_LIMIT(CAM_CDM,
+ "Accessing invalid region %d:%d\n",
reg, (CAM_CDM_OFFSET_FROM_REG(
cdm->offset_tbl, reg)));
goto permission_error;
@@ -111,17 +113,17 @@ int cam_cdm_soc_load_dt_private(struct platform_device *pdev,
ptr->dt_num_supported_clients = of_property_count_strings(
pdev->dev.of_node,
"cdm-client-names");
- CDM_CDBG("Num supported cdm_client = %d\n",
+ CAM_DBG(CAM_CDM, "Num supported cdm_client = %d",
ptr->dt_num_supported_clients);
if (ptr->dt_num_supported_clients >
CAM_PER_CDM_MAX_REGISTERED_CLIENTS) {
- pr_err("Invalid count of client names count=%d\n",
+ CAM_ERR(CAM_CDM, "Invalid count of client names count=%d",
ptr->dt_num_supported_clients);
rc = -EINVAL;
return rc;
}
if (ptr->dt_num_supported_clients < 0) {
- CDM_CDBG("No cdm client names found\n");
+ CAM_DBG(CAM_CDM, "No cdm client names found");
ptr->dt_num_supported_clients = 0;
ptr->dt_cdm_shared = false;
} else {
@@ -130,10 +132,10 @@ int cam_cdm_soc_load_dt_private(struct platform_device *pdev,
for (i = 0; i < ptr->dt_num_supported_clients; i++) {
rc = of_property_read_string_index(pdev->dev.of_node,
"cdm-client-names", i, &(ptr->dt_cdm_client_name[i]));
- CDM_CDBG("cdm-client-names[%d] = %s\n", i,
+ CAM_DBG(CAM_CDM, "cdm-client-names[%d] = %s", i,
ptr->dt_cdm_client_name[i]);
if (rc < 0) {
- pr_err("Reading cdm-client-names failed\n");
+ CAM_ERR(CAM_CDM, "Reading cdm-client-names failed");
break;
}
}
@@ -156,7 +158,7 @@ int cam_hw_cdm_soc_get_dt_properties(struct cam_hw_info *cdm_hw,
rc = cam_soc_util_get_dt_properties(soc_ptr);
if (rc != 0) {
- pr_err("Failed to retrieve the CDM dt properties\n");
+ CAM_ERR(CAM_CDM, "Failed to retrieve the CDM dt properties");
} else {
soc_ptr->soc_private = kzalloc(
sizeof(struct cam_cdm_private_dt_data),
@@ -167,15 +169,15 @@ int cam_hw_cdm_soc_get_dt_properties(struct cam_hw_info *cdm_hw,
rc = cam_cdm_soc_load_dt_private(soc_ptr->pdev,
soc_ptr->soc_private);
if (rc != 0) {
- pr_err("Failed to load CDM dt private data\n");
+ CAM_ERR(CAM_CDM, "Failed to load CDM dt private data");
goto error;
}
id = of_match_node(table, soc_ptr->pdev->dev.of_node);
if ((!id) || !(id->data)) {
- pr_err("Failed to retrieve the CDM id table\n");
+ CAM_ERR(CAM_CDM, "Failed to retrieve the CDM id table");
goto error;
}
- CDM_CDBG("CDM Hw Id compatible =%s\n", id->compatible);
+ CAM_DBG(CAM_CDM, "CDM Hw Id compatible =%s", id->compatible);
((struct cam_cdm *)cdm_hw->core_info)->offset_tbl =
(struct cam_cdm_reg_offset_table *)id->data;
strlcpy(((struct cam_cdm *)cdm_hw->core_info)->name,
@@ -199,7 +201,8 @@ int cam_cdm_intf_mgr_soc_get_dt_properties(
rc = of_property_read_u32(pdev->dev.of_node,
"num-hw-cdm", &mgr->dt_supported_hw_cdm);
- CDM_CDBG("Number of HW cdm supported =%d\n", mgr->dt_supported_hw_cdm);
+ CAM_DBG(CAM_CDM, "Number of HW cdm supported =%d",
+ mgr->dt_supported_hw_cdm);
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_util.c b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_util.c
index a3de3d1..a63031b 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_util.c
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_util.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CAM-CDM-UTIL %s:%d " fmt, __func__, __LINE__
-
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/errno.h>
@@ -327,7 +325,7 @@ int cam_cdm_get_ioremap_from_base(uint32_t hw_base,
for (i = 0; i < base_array_size; i++) {
if (base_table[i])
- CDM_CDBG("In loop %d ioremap for %x addr=%x\n",
+ CAM_DBG(CAM_CDM, "In loop %d ioremap for %x addr=%x",
i, (base_table[i])->mem_cam_base, hw_base);
if ((base_table[i]) &&
((base_table[i])->mem_cam_base == hw_base)) {
@@ -349,7 +347,7 @@ static int cam_cdm_util_reg_cont_write(void __iomem *base_addr,
if ((cmd_buf_size < cdm_get_cmd_header_size(CAM_CDM_CMD_REG_CONT)) ||
(!base_addr)) {
- pr_err(" invalid base addr and data length %d %pK\n",
+ CAM_ERR(CAM_CDM, "invalid base addr and data length %d %pK",
cmd_buf_size, base_addr);
return -EINVAL;
}
@@ -359,7 +357,7 @@ static int cam_cdm_util_reg_cont_write(void __iomem *base_addr,
(((reg_cont->count * sizeof(uint32_t)) +
cdm_get_cmd_header_size(CAM_CDM_CMD_REG_CONT)) >
cmd_buf_size)) {
- pr_err(" buffer size %d is not sufficient for count%d\n",
+ CAM_ERR(CAM_CDM, "buffer size %d is not sufficient for count%d",
cmd_buf_size, reg_cont->count);
return -EINVAL;
}
@@ -381,7 +379,7 @@ static int cam_cdm_util_reg_random_write(void __iomem *base_addr,
uint32_t *data;
if (!base_addr) {
- pr_err("invalid base address\n");
+ CAM_ERR(CAM_CDM, "invalid base address");
return -EINVAL;
}
@@ -390,15 +388,16 @@ static int cam_cdm_util_reg_random_write(void __iomem *base_addr,
(((reg_random->count * (sizeof(uint32_t) * 2)) +
cdm_get_cmd_header_size(CAM_CDM_CMD_REG_RANDOM)) >
cmd_buf_size)) {
- pr_err("invalid reg_count %d cmd_buf_size %d\n",
+ CAM_ERR(CAM_CDM, "invalid reg_count %d cmd_buf_size %d",
reg_random->count, cmd_buf_size);
return -EINVAL;
}
data = cmd_buf + cdm_get_cmd_header_size(CAM_CDM_CMD_REG_RANDOM);
for (i = 0; i < reg_random->count; i++) {
- CDM_DUMP_CDBG("reg random: offset 0x%llx, value 0x%x\n",
- ((uint64_t) base_addr + data[0]), data[1]);
+ CAM_DBG(CAM_CDM, "reg random: offset %pK, value 0x%x",
+ ((void __iomem *)(base_addr + data[0])),
+ data[1]);
cam_io_w(data[1], base_addr + data[0]);
data += 2;
}
@@ -420,7 +419,8 @@ static int cam_cdm_util_swd_dmi_write(uint32_t cdm_cmd_type,
swd_dmi = (struct cdm_dmi_cmd *)cmd_buf;
if (cmd_buf_size < (cdm_required_size_dmi() + swd_dmi->length + 1)) {
- pr_err("invalid CDM_SWD_DMI length %d\n", swd_dmi->length + 1);
+ CAM_ERR(CAM_CDM, "invalid CDM_SWD_DMI length %d",
+ swd_dmi->length + 1);
return -EINVAL;
}
data = cmd_buf + cdm_required_size_dmi();
@@ -457,7 +457,7 @@ int cam_cdm_util_cmd_buf_write(void __iomem **current_device_base,
total_cmd_buf_size = cmd_buf_size;
while (cmd_buf_size > 0) {
- CDM_CDBG("cmd data=%x\n", *cmd_buf);
+ CAM_DBG(CAM_CDM, "cmd data=%x", *cmd_buf);
cdm_cmd_type = (*cmd_buf >> CAM_CDM_COMMAND_OFFSET);
switch (cdm_cmd_type) {
case CAM_CDM_CMD_REG_CONT: {
@@ -488,7 +488,8 @@ int cam_cdm_util_cmd_buf_write(void __iomem **current_device_base,
case CAM_CDM_CMD_SWD_DMI_32:
case CAM_CDM_CMD_SWD_DMI_64: {
if (*current_device_base == 0) {
- pr_err("Got SWI DMI cmd =%d for invalid hw\n",
+ CAM_ERR(CAM_CDM,
+ "Got SWI DMI cmd =%d for invalid hw",
cdm_cmd_type);
ret = -EINVAL;
break;
@@ -513,11 +514,12 @@ int cam_cdm_util_cmd_buf_write(void __iomem **current_device_base,
change_base_cmd->base, base_array_size,
base_table, current_device_base);
if (ret != 0) {
- pr_err("Get ioremap change base failed %x\n",
+ CAM_ERR(CAM_CDM,
+ "Get ioremap change base failed %x",
change_base_cmd->base);
break;
}
- CDM_CDBG("Got ioremap for %x addr=%pK\n",
+ CAM_DBG(CAM_CDM, "Got ioremap for %x addr=%pK",
change_base_cmd->base,
current_device_base);
cmd_buf_size -= (4 *
@@ -526,7 +528,7 @@ int cam_cdm_util_cmd_buf_write(void __iomem **current_device_base,
}
break;
default:
- pr_err(" unsupported cdm_cmd_type type 0%x\n",
+ CAM_ERR(CAM_CDM, "unsupported cdm_cmd_type type 0%x",
cdm_cmd_type);
ret = -EINVAL;
break;
diff --git a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_virtual_core.c b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_virtual_core.c
index bfe14e1..b230d4e 100644
--- a/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_virtual_core.c
+++ b/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_virtual_core.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CAM-CDM-VIRTUAL %s:%d " fmt, __func__, __LINE__
-
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/of.h>
@@ -46,7 +44,7 @@ static void cam_virtual_cdm_work(struct work_struct *work)
if (payload->irq_status & 0x2) {
struct cam_cdm_bl_cb_request_entry *node;
- CDM_CDBG("CDM HW Gen/inline IRQ with data=%x\n",
+ CAM_DBG(CAM_CDM, "CDM HW Gen/inline IRQ with data=%x",
payload->irq_data);
mutex_lock(&cdm_hw->hw_mutex);
node = cam_cdm_find_request_by_bl_tag(
@@ -60,18 +58,18 @@ static void cam_virtual_cdm_work(struct work_struct *work)
(void *)node);
} else if (node->request_type ==
CAM_HW_CDM_BL_CB_INTERNAL) {
- pr_err("Invalid node=%pK %d\n", node,
- node->request_type);
+ CAM_ERR(CAM_CDM, "Invalid node=%pK %d",
+ node, node->request_type);
}
list_del_init(&node->entry);
kfree(node);
} else {
- pr_err("Invalid node for inline irq\n");
+ CAM_ERR(CAM_CDM, "Invalid node for inline irq");
}
mutex_unlock(&cdm_hw->hw_mutex);
}
if (payload->irq_status & 0x1) {
- CDM_CDBG("CDM HW reset done IRQ\n");
+ CAM_DBG(CAM_CDM, "CDM HW reset done IRQ");
complete(&core->reset_complete);
}
kfree(payload);
@@ -94,7 +92,8 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw,
if ((!cdm_cmd->cmd[i].len) &&
(cdm_cmd->cmd[i].len > 0x100000)) {
- pr_err("len(%d) is invalid count=%d total cnt=%d\n",
+ CAM_ERR(CAM_CDM,
+ "len(%d) is invalid count=%d total cnt=%d",
cdm_cmd->cmd[i].len, i,
req->data->cmd_arrary_count);
rc = -EINVAL;
@@ -111,7 +110,8 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw,
(uint64_t)cdm_cmd->cmd[i].bl_addr.kernel_iova;
len = cdm_cmd->cmd[i].offset + cdm_cmd->cmd[i].len;
} else {
- pr_err("Only mem hdl/Kernel va type is supported %d\n",
+ CAM_ERR(CAM_CDM,
+ "Only mem hdl/Kernel va type is supported %d",
req->data->type);
rc = -EINVAL;
break;
@@ -119,7 +119,8 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw,
if ((!rc) && (vaddr_ptr) && (len) &&
(len >= cdm_cmd->cmd[i].offset)) {
- CDM_CDBG("hdl=%x vaddr=%pK offset=%d cmdlen=%d:%zu\n",
+ CAM_DBG(CAM_CDM,
+ "hdl=%x vaddr=%pK offset=%d cmdlen=%d:%zu",
cdm_cmd->cmd[i].bl_addr.mem_handle,
(void *)vaddr_ptr, cdm_cmd->cmd[i].offset,
cdm_cmd->cmd[i].len, len);
@@ -130,15 +131,17 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw,
cdm_cmd->cmd[i].len, client->data.base_array,
client->data.base_array_cnt, core->bl_tag);
if (rc) {
- pr_err("write failed for cnt=%d:%d\n",
+ CAM_ERR(CAM_CDM, "write failed for cnt=%d:%d",
i, req->data->cmd_arrary_count);
break;
}
} else {
- pr_err("Sanity check failed for hdl=%x len=%zu:%d\n",
+ CAM_ERR(CAM_CDM,
+ "Sanity check failed for hdl=%x len=%zu:%d",
cdm_cmd->cmd[i].bl_addr.mem_handle, len,
cdm_cmd->cmd[i].offset);
- pr_err("Sanity check failed for cmd_count=%d cnt=%d\n",
+ CAM_ERR(CAM_CDM,
+ "Sanity check failed for cmd_count=%d cnt=%d",
i, req->data->cmd_arrary_count);
rc = -EINVAL;
break;
@@ -146,7 +149,8 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw,
if (!rc) {
struct cam_cdm_work_payload *payload;
- CDM_CDBG("write BL success for cnt=%d with tag=%d\n",
+ CAM_DBG(CAM_CDM,
+ "write BL success for cnt=%d with tag=%d",
i, core->bl_tag);
if ((true == req->data->flag) &&
(i == req->data->cmd_arrary_count)) {
@@ -184,7 +188,8 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw,
}
}
core->bl_tag++;
- CDM_CDBG("Now commit the BL nothing for virtual\n");
+ CAM_DBG(CAM_CDM,
+ "Now commit the BL nothing for virtual");
if (!rc && (core->bl_tag == 63))
core->bl_tag = 0;
}
@@ -230,7 +235,7 @@ int cam_virtual_cdm_probe(struct platform_device *pdev)
rc = cam_cdm_soc_load_dt_private(pdev, cdm_hw->soc_info.soc_private);
if (rc) {
- pr_err("Failed to load CDM dt private data\n");
+ CAM_ERR(CAM_CDM, "Failed to load CDM dt private data");
kfree(cdm_hw->soc_info.soc_private);
cdm_hw->soc_info.soc_private = NULL;
goto soc_load_failed;
@@ -257,7 +262,7 @@ int cam_virtual_cdm_probe(struct platform_device *pdev)
cdm_hw_intf->hw_ops.write = NULL;
cdm_hw_intf->hw_ops.process_cmd = cam_cdm_process_cmd;
- CDM_CDBG("type %d index %d\n", cdm_hw_intf->hw_type,
+ CAM_DBG(CAM_CDM, "type %d index %d", cdm_hw_intf->hw_type,
cdm_hw_intf->hw_idx);
platform_set_drvdata(pdev, cdm_hw_intf);
@@ -285,22 +290,23 @@ int cam_virtual_cdm_probe(struct platform_device *pdev)
CAM_HW_IDENTIFIER_LENGTH);
rc = cam_cpas_register_client(&cpas_parms);
if (rc) {
- pr_err("Virtual CDM CPAS registration failed\n");
+ CAM_ERR(CAM_CDM, "Virtual CDM CPAS registration failed");
goto cpas_registration_failed;
}
- CDM_CDBG("CPAS registration successful handle=%d\n",
+ CAM_DBG(CAM_CDM, "CPAS registration successful handle=%d",
cpas_parms.client_handle);
cdm_core->cpas_handle = cpas_parms.client_handle;
- CDM_CDBG("CDM%d probe successful\n", cdm_hw_intf->hw_idx);
+ CAM_DBG(CAM_CDM, "CDM%d probe successful", cdm_hw_intf->hw_idx);
rc = cam_cdm_intf_register_hw_cdm(cdm_hw_intf,
soc_private, CAM_VIRTUAL_CDM, &cdm_core->index);
if (rc) {
- pr_err("Virtual CDM Interface registration failed\n");
+ CAM_ERR(CAM_CDM, "Virtual CDM Interface registration failed");
goto intf_registration_failed;
}
- CDM_CDBG("CDM%d registered to intf successful\n", cdm_hw_intf->hw_idx);
+ CAM_DBG(CAM_CDM, "CDM%d registered to intf successful",
+ cdm_hw_intf->hw_idx);
mutex_unlock(&cdm_hw->hw_mutex);
return 0;
@@ -328,27 +334,29 @@ int cam_virtual_cdm_remove(struct platform_device *pdev)
cdm_hw_intf = platform_get_drvdata(pdev);
if (!cdm_hw_intf) {
- pr_err("Failed to get dev private data\n");
+ CAM_ERR(CAM_CDM, "Failed to get dev private data");
return rc;
}
cdm_hw = cdm_hw_intf->hw_priv;
if (!cdm_hw) {
- pr_err("Failed to get virtual private data for type=%d idx=%d\n",
+ CAM_ERR(CAM_CDM,
+ "Failed to get virtual private data for type=%d idx=%d",
cdm_hw_intf->hw_type, cdm_hw_intf->hw_idx);
return rc;
}
cdm_core = cdm_hw->core_info;
if (!cdm_core) {
- pr_err("Failed to get virtual core data for type=%d idx=%d\n",
+ CAM_ERR(CAM_CDM,
+ "Failed to get virtual core data for type=%d idx=%d",
cdm_hw_intf->hw_type, cdm_hw_intf->hw_idx);
return rc;
}
rc = cam_cpas_unregister_client(cdm_core->cpas_handle);
if (rc) {
- pr_err("CPAS unregister failed\n");
+ CAM_ERR(CAM_CDM, "CPAS unregister failed");
return rc;
}
@@ -356,7 +364,8 @@ int cam_virtual_cdm_remove(struct platform_device *pdev)
cdm_hw->soc_info.soc_private, CAM_VIRTUAL_CDM,
cdm_core->index);
if (rc) {
- pr_err("Virtual CDM Interface de-registration failed\n");
+ CAM_ERR(CAM_CDM,
+ "Virtual CDM Interface de-registration failed");
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_core/cam_context_utils.c b/drivers/media/platform/msm/camera/cam_core/cam_context_utils.c
index e934dff..a430466 100644
--- a/drivers/media/platform/msm/camera/cam_core/cam_context_utils.c
+++ b/drivers/media/platform/msm/camera/cam_core/cam_context_utils.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CTXT-UTILS %s:%d " fmt, __func__, __LINE__
-
#include <linux/debugfs.h>
#include <linux/videodev2.h>
#include <linux/slab.h>
@@ -25,6 +23,7 @@
#include "cam_req_mgr_util.h"
#include "cam_sync_api.h"
#include "cam_trace.h"
+#include "cam_debug_util.h"
int cam_context_buf_done_from_hw(struct cam_context *ctx,
void *done_event_data, uint32_t bubble_state)
@@ -36,7 +35,7 @@ int cam_context_buf_done_from_hw(struct cam_context *ctx,
(struct cam_hw_done_event_data *)done_event_data;
if (list_empty(&ctx->active_req_list)) {
- pr_err("Buf done with no active request\n");
+ CAM_ERR(CAM_CTXT, "no active request");
return -EIO;
}
@@ -46,13 +45,13 @@ int cam_context_buf_done_from_hw(struct cam_context *ctx,
trace_cam_buf_done("UTILS", ctx, req);
if (done->request_id != req->request_id) {
- pr_err("mismatch: done request [%lld], active request [%lld]\n",
+ CAM_ERR(CAM_CTXT, "mismatch: done req[%lld], active req[%lld]",
done->request_id, req->request_id);
return -EIO;
}
if (!req->num_out_map_entries) {
- pr_err("active request with no output fence objects to signal\n");
+ CAM_ERR(CAM_CTXT, "no output fence to signal");
return -EIO;
}
@@ -80,13 +79,13 @@ int cam_context_apply_req_to_hw(struct cam_context *ctx,
struct cam_hw_config_args cfg;
if (!ctx->hw_mgr_intf) {
- pr_err("HW interface is not ready\n");
+ CAM_ERR(CAM_CTXT, "HW interface is not ready");
rc = -EFAULT;
goto end;
}
if (list_empty(&ctx->pending_req_list)) {
- pr_err("No available request for Apply id %lld\n",
+ CAM_ERR(CAM_CTXT, "No available request for Apply id %lld",
apply->request_id);
rc = -EFAULT;
goto end;
@@ -103,7 +102,7 @@ int cam_context_apply_req_to_hw(struct cam_context *ctx,
cfg.num_hw_update_entries = req->num_hw_update_entries;
cfg.out_map_entries = req->out_map_entries;
cfg.num_out_map_entries = req->num_out_map_entries;
- cfg.priv = (void *)&req->request_id;
+ cfg.priv = req->req_priv;
list_add_tail(&req->list, &ctx->active_req_list);
rc = ctx->hw_mgr_intf->hw_config(ctx->hw_mgr_intf->hw_mgr_priv, &cfg);
@@ -127,7 +126,7 @@ static void cam_context_sync_callback(int32_t sync_obj, int status, void *data)
spin_unlock(&ctx->lock);
if (!req) {
- pr_err("No more request obj free\n");
+ CAM_ERR(CAM_CTXT, "No more request obj free");
return;
}
@@ -146,7 +145,7 @@ int32_t cam_context_release_dev_to_hw(struct cam_context *ctx,
struct cam_ctx_request *req;
if ((!ctx->hw_mgr_intf) || (!ctx->hw_mgr_intf->hw_release)) {
- pr_err("HW interface is not ready\n");
+ CAM_ERR(CAM_CTXT, "HW interface is not ready");
return -EINVAL;
}
@@ -168,7 +167,7 @@ int32_t cam_context_release_dev_to_hw(struct cam_context *ctx,
req = list_first_entry(&ctx->active_req_list,
struct cam_ctx_request, list);
list_del_init(&req->list);
- pr_debug("signal fence in active list. fence num %d\n",
+ CAM_DBG(CAM_CTXT, "signal fence in active list, num %d",
req->num_out_map_entries);
for (i = 0; i < req->num_out_map_entries; i++) {
if (req->out_map_entries[i].sync_id > 0)
@@ -187,7 +186,7 @@ int32_t cam_context_release_dev_to_hw(struct cam_context *ctx,
cam_sync_deregister_callback(
cam_context_sync_callback, ctx,
req->in_map_entries[i].sync_id);
- pr_debug("signal out fence in pending list. fence num %d\n",
+ CAM_DBG(CAM_CTXT, "signal fence in pending list, num %d",
req->num_out_map_entries);
for (i = 0; i < req->num_out_map_entries; i++)
if (req->out_map_entries[i].sync_id > 0)
@@ -211,7 +210,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
int32_t i = 0;
if (!ctx->hw_mgr_intf) {
- pr_err("HW interface is not ready\n");
+ CAM_ERR(CAM_CTXT, "HW interface is not ready");
rc = -EFAULT;
goto end;
}
@@ -225,7 +224,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
spin_unlock(&ctx->lock);
if (!req) {
- pr_err("No more request obj free\n");
+ CAM_ERR(CAM_CTXT, "No more request obj free");
rc = -ENOMEM;
goto end;
}
@@ -239,20 +238,12 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
(uint64_t *) &packet_addr,
&len);
if (rc != 0) {
- pr_err("Can not get packet address\n");
+ CAM_ERR(CAM_CTXT, "Can not get packet address");
rc = -EINVAL;
goto free_req;
}
packet = (struct cam_packet *) (packet_addr + cmd->offset);
- pr_debug("pack_handle %llx\n", cmd->packet_handle);
- pr_debug("packet address is 0x%llx\n", packet_addr);
- pr_debug("packet with length %zu, offset 0x%llx\n",
- len, cmd->offset);
- pr_debug("Packet request id 0x%llx\n",
- packet->header.request_id);
- pr_debug("Packet size 0x%x\n", packet->header.size);
- pr_debug("packet op %d\n", packet->header.op_code);
/* preprocess the configuration */
memset(&cfg, 0, sizeof(cfg));
@@ -269,7 +260,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
rc = ctx->hw_mgr_intf->hw_prepare_update(
ctx->hw_mgr_intf->hw_mgr_priv, &cfg);
if (rc != 0) {
- pr_err("Prepare config packet failed in HW layer\n");
+ CAM_ERR(CAM_CTXT, "Prepare config packet failed in HW layer");
rc = -EFAULT;
goto free_req;
}
@@ -289,7 +280,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
cam_context_sync_callback,
(void *)ctx,
req->in_map_entries[i].sync_id);
- pr_debug("register in fence callback: %d ret = %d\n",
+ CAM_DBG(CAM_CTXT, "register in fence cb: %d ret = %d",
req->in_map_entries[i].sync_id, rc);
}
goto end;
@@ -302,7 +293,6 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
list_add_tail(&req->list, &ctx->free_req_list);
spin_unlock(&ctx->lock);
end:
- pr_debug("Config dev successful\n");
return rc;
}
@@ -315,25 +305,24 @@ int32_t cam_context_acquire_dev_to_hw(struct cam_context *ctx,
struct cam_hw_release_args release;
if (!ctx->hw_mgr_intf) {
- pr_err("HW interface is not ready\n");
+ CAM_ERR(CAM_CTXT, "HW interface is not ready");
rc = -EFAULT;
goto end;
}
- pr_debug("acquire cmd: session_hdl 0x%x, num_resources %d\n",
- cmd->session_handle, cmd->num_resources);
- pr_debug(" handle type %d, res %lld\n", cmd->handle_type,
+ CAM_DBG(CAM_CTXT, "ses hdl: %x, num_res: %d, type: %d, res: %lld",
+ cmd->session_handle, cmd->num_resources, cmd->handle_type,
cmd->resource_hdl);
if (cmd->num_resources > CAM_CTX_RES_MAX) {
- pr_err("Too much resources in the acquire\n");
+ CAM_ERR(CAM_CTXT, "resource limit exceeded");
rc = -ENOMEM;
goto end;
}
/* for now we only support user pointer */
if (cmd->handle_type != 1) {
- pr_err("Only user pointer is supported");
+ CAM_ERR(CAM_CTXT, "Only user pointer is supported");
rc = -EINVAL;
goto end;
}
@@ -344,15 +333,11 @@ int32_t cam_context_acquire_dev_to_hw(struct cam_context *ctx,
param.num_acq = cmd->num_resources;
param.acquire_info = cmd->resource_hdl;
- pr_debug("ctx %pK: acquire hw resource: hw_intf: 0x%pK, priv 0x%pK",
- ctx, ctx->hw_mgr_intf, ctx->hw_mgr_intf->hw_mgr_priv);
- pr_debug("acquire_hw_func 0x%pK\n", ctx->hw_mgr_intf->hw_acquire);
-
/* call HW manager to reserve the resource */
rc = ctx->hw_mgr_intf->hw_acquire(ctx->hw_mgr_intf->hw_mgr_priv,
¶m);
if (rc != 0) {
- pr_err("Acquire device failed\n");
+ CAM_ERR(CAM_CTXT, "Acquire device failed");
goto end;
}
@@ -365,11 +350,10 @@ int32_t cam_context_acquire_dev_to_hw(struct cam_context *ctx,
req_hdl_param.media_entity_flag = 0;
req_hdl_param.priv = ctx;
- pr_debug("get device handle from bridge\n");
ctx->dev_hdl = cam_create_device_hdl(&req_hdl_param);
if (ctx->dev_hdl <= 0) {
rc = -EFAULT;
- pr_err("Can not create device handle\n");
+ CAM_ERR(CAM_CTXT, "Can not create device handle");
goto free_hw;
}
cmd->dev_handle = ctx->dev_hdl;
@@ -377,7 +361,6 @@ int32_t cam_context_acquire_dev_to_hw(struct cam_context *ctx,
/* store session information */
ctx->session_hdl = cmd->session_handle;
- pr_err("dev_handle = %x\n", cmd->dev_handle);
return rc;
free_hw:
@@ -395,14 +378,14 @@ int32_t cam_context_start_dev_to_hw(struct cam_context *ctx,
struct cam_hw_start_args arg;
if (!ctx->hw_mgr_intf) {
- pr_err("HW interface is not ready\n");
+ CAM_ERR(CAM_CTXT, "HW interface is not ready");
rc = -EFAULT;
goto end;
}
if ((cmd->session_handle != ctx->session_hdl) ||
(cmd->dev_handle != ctx->dev_hdl)) {
- pr_err("Invalid session hdl[%d], dev_handle[%d]\n",
+ CAM_ERR(CAM_CTXT, "Invalid session hdl[%d], dev_handle[%d]",
cmd->session_handle, cmd->dev_handle);
rc = -EPERM;
goto end;
@@ -413,12 +396,11 @@ int32_t cam_context_start_dev_to_hw(struct cam_context *ctx,
&arg);
if (rc) {
/* HW failure. user need to clean up the resource */
- pr_err("Start HW failed\n");
+ CAM_ERR(CAM_CTXT, "Start HW failed");
goto end;
}
}
- pr_debug("start device success\n");
end:
return rc;
}
@@ -431,7 +413,7 @@ int32_t cam_context_stop_dev_to_hw(struct cam_context *ctx)
struct cam_ctx_request *req;
if (!ctx->hw_mgr_intf) {
- pr_err("HW interface is not ready\n");
+ CAM_ERR(CAM_CTXT, "HW interface is not ready");
rc = -EFAULT;
goto end;
}
@@ -449,7 +431,7 @@ int32_t cam_context_stop_dev_to_hw(struct cam_context *ctx)
req = list_first_entry(&ctx->pending_req_list,
struct cam_ctx_request, list);
list_del_init(&req->list);
- pr_debug("signal fence in pending list. fence num %d\n",
+ CAM_DBG(CAM_CTXT, "signal fence in pending list. fence num %d",
req->num_out_map_entries);
for (i = 0; i < req->num_out_map_entries; i++)
if (req->out_map_entries[i].sync_id != -1)
@@ -462,7 +444,7 @@ int32_t cam_context_stop_dev_to_hw(struct cam_context *ctx)
req = list_first_entry(&ctx->active_req_list,
struct cam_ctx_request, list);
list_del_init(&req->list);
- pr_debug("signal fence in active list. fence num %d\n",
+ CAM_DBG(CAM_CTXT, "signal fence in active list. fence num %d",
req->num_out_map_entries);
for (i = 0; i < req->num_out_map_entries; i++)
if (req->out_map_entries[i].sync_id != -1)
diff --git a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.c b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.c
index 813f392..82035e9 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.c
+++ b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.c
@@ -21,22 +21,6 @@
#include "cam_cpas_hw_intf.h"
#include "cam_cpas_soc.h"
-int cam_cpas_util_get_string_index(const char **strings,
- uint32_t num_strings, char *matching_string, uint32_t *index)
-{
- int i;
-
- for (i = 0; i < num_strings; i++) {
- if (strnstr(strings[i], matching_string, strlen(strings[i]))) {
- CPAS_CDBG("matched %s : %d\n", matching_string, i);
- *index = i;
- return 0;
- }
- }
-
- return -EINVAL;
-}
-
int cam_cpas_util_reg_update(struct cam_hw_info *cpas_hw,
enum cam_cpas_reg_base reg_base, struct cam_cpas_reg *reg_info)
{
@@ -62,7 +46,7 @@ int cam_cpas_util_reg_update(struct cam_hw_info *cpas_hw,
value = reg_info->value;
}
- CPAS_CDBG("Base[%d] Offset[0x%8x] Value[0x%8x]\n",
+ CAM_DBG(CAM_CPAS, "Base[%d] Offset[0x%8x] Value[0x%8x]",
reg_base, reg_info->offset, value);
cam_io_w_mb(value, soc_info->reg_map[reg_base_index].mem_base +
@@ -75,13 +59,13 @@ static int cam_cpas_util_vote_bus_client_level(
struct cam_cpas_bus_client *bus_client, unsigned int level)
{
if (!bus_client->valid || (bus_client->dyn_vote == true)) {
- pr_err("Invalid params %d %d\n", bus_client->valid,
+ CAM_ERR(CAM_CPAS, "Invalid params %d %d", bus_client->valid,
bus_client->dyn_vote);
return -EINVAL;
}
if (level >= bus_client->num_usecases) {
- pr_err("Invalid vote level=%d, usecases=%d\n", level,
+ CAM_ERR(CAM_CPAS, "Invalid vote level=%d, usecases=%d", level,
bus_client->num_usecases);
return -EINVAL;
}
@@ -89,7 +73,8 @@ static int cam_cpas_util_vote_bus_client_level(
if (level == bus_client->curr_vote_level)
return 0;
- CPAS_CDBG("Bus client[%d] index[%d]\n", bus_client->client_id, level);
+ CAM_DBG(CAM_CPAS, "Bus client[%d] index[%d]", bus_client->client_id,
+ level);
msm_bus_scale_client_update_request(bus_client->client_id, level);
bus_client->curr_vote_level = level;
@@ -104,14 +89,14 @@ static int cam_cpas_util_vote_bus_client_bw(
int idx = 0;
if (!bus_client->valid) {
- pr_err("bus client not valid\n");
+ CAM_ERR(CAM_CPAS, "bus client not valid");
return -EINVAL;
}
if ((bus_client->num_usecases != 2) ||
(bus_client->num_paths != 1) ||
(bus_client->dyn_vote != true)) {
- pr_err("dynamic update not allowed %d %d %d\n",
+ CAM_ERR(CAM_CPAS, "dynamic update not allowed %d %d %d",
bus_client->num_usecases, bus_client->num_paths,
bus_client->dyn_vote);
return -EINVAL;
@@ -120,7 +105,7 @@ static int cam_cpas_util_vote_bus_client_bw(
mutex_lock(&bus_client->lock);
if (bus_client->curr_vote_level > 1) {
- pr_err("curr_vote_level %d cannot be greater than 1\n",
+ CAM_ERR(CAM_CPAS, "curr_vote_level %d cannot be greater than 1",
bus_client->curr_vote_level);
mutex_unlock(&bus_client->lock);
return -EINVAL;
@@ -136,7 +121,7 @@ static int cam_cpas_util_vote_bus_client_bw(
path->vectors[0].ab = ab;
path->vectors[0].ib = ib;
- CPAS_CDBG("Bus client[%d] :ab[%llu] ib[%llu], index[%d]\n",
+ CAM_DBG(CAM_CPAS, "Bus client[%d] :ab[%llu] ib[%llu], index[%d]",
bus_client->client_id, ab, ib, idx);
msm_bus_scale_client_update_request(bus_client->client_id, idx);
@@ -154,20 +139,20 @@ static int cam_cpas_util_register_bus_client(
pdata = msm_bus_pdata_from_node(soc_info->pdev,
dev_node);
if (!pdata) {
- pr_err("failed get_pdata\n");
+ CAM_ERR(CAM_CPAS, "failed get_pdata");
return -EINVAL;
}
if ((pdata->num_usecases == 0) ||
(pdata->usecase[0].num_paths == 0)) {
- pr_err("usecase=%d\n", pdata->num_usecases);
+ CAM_ERR(CAM_CPAS, "usecase=%d", pdata->num_usecases);
rc = -EINVAL;
goto error;
}
client_id = msm_bus_scale_register_client(pdata);
if (!client_id) {
- pr_err("failed in register ahb bus client\n");
+ CAM_ERR(CAM_CPAS, "failed in register ahb bus client");
rc = -EINVAL;
goto error;
}
@@ -176,7 +161,8 @@ static int cam_cpas_util_register_bus_client(
"qcom,msm-bus-vector-dyn-vote");
if (bus_client->dyn_vote && (pdata->num_usecases != 2)) {
- pr_err("Excess or less vectors %d\n", pdata->num_usecases);
+ CAM_ERR(CAM_CPAS, "Excess or less vectors %d",
+ pdata->num_usecases);
rc = -EINVAL;
goto fail_unregister_client;
}
@@ -193,7 +179,7 @@ static int cam_cpas_util_register_bus_client(
bus_client->valid = true;
mutex_init(&bus_client->lock);
- CPAS_CDBG("Bus Client : src=%d, dst=%d, bus_client=%d\n",
+ CAM_DBG(CAM_CPAS, "Bus Client : src=%d, dst=%d, bus_client=%d",
bus_client->src, bus_client->dst, bus_client->client_id);
return 0;
@@ -268,7 +254,7 @@ static int cam_cpas_util_axi_setup(struct cam_cpas *cpas_core,
axi_port_list_node = of_find_node_by_name(soc_info->pdev->dev.of_node,
"qcom,axi-port-list");
if (!axi_port_list_node) {
- pr_err("Node qcom,axi-port-list not found.\n");
+ CAM_ERR(CAM_CPAS, "Node qcom,axi-port-list not found.");
return -EINVAL;
}
@@ -286,14 +272,15 @@ static int cam_cpas_util_axi_setup(struct cam_cpas *cpas_core,
"qcom,axi-port-name", 0,
(const char **)&axi_port->axi_port_name);
if (rc) {
- pr_err("failed to read qcom,axi-port-name rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS,
+ "failed to read qcom,axi-port-name rc=%d", rc);
goto port_name_fail;
}
axi_port_mnoc_node = of_find_node_by_name(axi_port_node,
"qcom,axi-port-mnoc");
if (!axi_port_mnoc_node) {
- pr_err("Node qcom,axi-port-mnoc not found.\n");
+ CAM_ERR(CAM_CPAS, "Node qcom,axi-port-mnoc not found.");
rc = -EINVAL;
goto mnoc_node_get_fail;
}
@@ -308,7 +295,8 @@ static int cam_cpas_util_axi_setup(struct cam_cpas *cpas_core,
axi_port_camnoc_node = of_find_node_by_name(
axi_port_node, "qcom,axi-port-camnoc");
if (!axi_port_camnoc_node) {
- pr_err("Node qcom,axi-port-camnoc not found\n");
+ CAM_ERR(CAM_CPAS,
+ "Node qcom,axi-port-camnoc not found");
rc = -EINVAL;
goto camnoc_node_get_fail;
}
@@ -358,7 +346,8 @@ static int cam_cpas_util_vote_default_ahb_axi(struct cam_hw_info *cpas_hw,
rc = cam_cpas_util_vote_bus_client_level(&cpas_core->ahb_bus_client,
(enable == true) ? CAM_SVS_VOTE : CAM_SUSPEND_VOTE);
if (rc) {
- pr_err("Failed in AHB vote, enable=%d, rc=%d\n", enable, rc);
+ CAM_ERR(CAM_CPAS, "Failed in AHB vote, enable=%d, rc=%d",
+ enable, rc);
return rc;
}
@@ -375,7 +364,8 @@ static int cam_cpas_util_vote_default_ahb_axi(struct cam_hw_info *cpas_hw,
rc = cam_cpas_util_vote_bus_client_bw(&curr_port->mnoc_bus,
mnoc_bw, 0);
if (rc) {
- pr_err("Failed in mnoc vote, enable=%d, rc=%d\n",
+ CAM_ERR(CAM_CPAS,
+ "Failed in mnoc vote, enable=%d, rc=%d",
enable, rc);
goto remove_ahb_vote;
}
@@ -384,7 +374,8 @@ static int cam_cpas_util_vote_default_ahb_axi(struct cam_hw_info *cpas_hw,
cam_cpas_util_vote_bus_client_bw(
&curr_port->camnoc_bus, camnoc_bw, 0);
if (rc) {
- pr_err("Failed in mnoc vote, enable=%d, %d\n",
+ CAM_ERR(CAM_CPAS,
+ "Failed in mnoc vote, enable=%d, %d",
enable, rc);
cam_cpas_util_vote_bus_client_bw(
&curr_port->mnoc_bus, 0, 0);
@@ -446,7 +437,8 @@ static int cam_cpas_hw_reg_write(struct cam_hw_info *cpas_hw,
int rc = 0;
if (reg_base_index < 0 || reg_base_index >= soc_info->num_reg_map) {
- pr_err("Invalid reg_base=%d, reg_base_index=%d, num_map=%d\n",
+ CAM_ERR(CAM_CPAS,
+ "Invalid reg_base=%d, reg_base_index=%d, num_map=%d",
reg_base, reg_base_index, soc_info->num_reg_map);
return -EINVAL;
}
@@ -457,7 +449,7 @@ static int cam_cpas_hw_reg_write(struct cam_hw_info *cpas_hw,
mutex_lock(&cpas_core->client_mutex[client_indx]);
if (!CAM_CPAS_CLIENT_STARTED(cpas_core, client_indx)) {
- pr_err("client has not started%d\n", client_indx);
+ CAM_ERR(CAM_CPAS, "client has not started%d", client_indx);
rc = -EPERM;
goto unlock_client;
}
@@ -489,7 +481,8 @@ static int cam_cpas_hw_reg_read(struct cam_hw_info *cpas_hw,
return -EINVAL;
if (reg_base_index < 0 || reg_base_index >= soc_info->num_reg_map) {
- pr_err("Invalid reg_base=%d, reg_base_index=%d, num_map=%d\n",
+ CAM_ERR(CAM_CPAS,
+ "Invalid reg_base=%d, reg_base_index=%d, num_map=%d",
reg_base, reg_base_index, soc_info->num_reg_map);
return -EINVAL;
}
@@ -500,7 +493,7 @@ static int cam_cpas_hw_reg_read(struct cam_hw_info *cpas_hw,
mutex_lock(&cpas_core->client_mutex[client_indx]);
if (!CAM_CPAS_CLIENT_STARTED(cpas_core, client_indx)) {
- pr_err("client has not started%d\n", client_indx);
+ CAM_ERR(CAM_CPAS, "client has not started%d", client_indx);
rc = -EPERM;
goto unlock_client;
}
@@ -531,7 +524,7 @@ static int cam_cpas_util_apply_client_axi_vote(
int rc = 0;
if (!axi_port) {
- pr_err("axi port does not exists\n");
+ CAM_ERR(CAM_CPAS, "axi port does not exists");
return -EINVAL;
}
@@ -563,7 +556,8 @@ static int cam_cpas_util_apply_client_axi_vote(
if ((!soc_private->axi_camnoc_based) && (mnoc_bw < camnoc_bw))
mnoc_bw = camnoc_bw;
- CPAS_CDBG("axi[(%d, %d),(%d, %d)] : camnoc_bw[%llu], mnoc_bw[%llu]\n",
+ CAM_DBG(CAM_CPAS,
+ "axi[(%d, %d),(%d, %d)] : camnoc_bw[%llu], mnoc_bw[%llu]",
axi_port->mnoc_bus.src, axi_port->mnoc_bus.dst,
axi_port->camnoc_bus.src, axi_port->camnoc_bus.dst,
camnoc_bw, mnoc_bw);
@@ -571,7 +565,8 @@ static int cam_cpas_util_apply_client_axi_vote(
rc = cam_cpas_util_vote_bus_client_bw(&axi_port->mnoc_bus,
mnoc_bw, 0);
if (rc) {
- pr_err("Failed in mnoc vote ab[%llu] ib[%llu] rc=%d\n",
+ CAM_ERR(CAM_CPAS,
+ "Failed in mnoc vote ab[%llu] ib[%llu] rc=%d",
mnoc_bw, mnoc_bw, rc);
goto unlock_axi_port;
}
@@ -580,7 +575,8 @@ static int cam_cpas_util_apply_client_axi_vote(
rc = cam_cpas_util_vote_bus_client_bw(&axi_port->camnoc_bus,
camnoc_bw, 0);
if (rc) {
- pr_err("Failed camnoc vote ab[%llu] ib[%llu] rc=%d\n",
+ CAM_ERR(CAM_CPAS,
+ "Failed camnoc vote ab[%llu] ib[%llu] rc=%d",
camnoc_bw, camnoc_bw, rc);
goto unlock_axi_port;
}
@@ -600,7 +596,8 @@ static int cam_cpas_hw_update_axi_vote(struct cam_hw_info *cpas_hw,
if (!axi_vote || ((axi_vote->compressed_bw == 0) &&
(axi_vote->uncompressed_bw == 0))) {
- pr_err("Invalid vote, client_handle=%d\n", client_handle);
+ CAM_ERR(CAM_CPAS, "Invalid vote, client_handle=%d",
+ client_handle);
return -EINVAL;
}
@@ -610,12 +607,13 @@ static int cam_cpas_hw_update_axi_vote(struct cam_hw_info *cpas_hw,
mutex_lock(&cpas_core->client_mutex[client_indx]);
if (!CAM_CPAS_CLIENT_STARTED(cpas_core, client_indx)) {
- pr_err("client has not started %d\n", client_indx);
+ CAM_ERR(CAM_CPAS, "client has not started %d", client_indx);
rc = -EPERM;
goto unlock_client;
}
- CPAS_CDBG("Client[%d] Requested compressed[%llu], uncompressed[%llu]\n",
+ CAM_DBG(CAM_CPAS,
+ "Client[%d] Requested compressed[%llu], uncompressed[%llu]",
client_indx, axi_vote->compressed_bw,
axi_vote->uncompressed_bw);
@@ -640,13 +638,14 @@ static int cam_cpas_util_get_ahb_level(struct cam_hw_info *cpas_hw,
int i;
if (!dev || !req_level) {
- pr_err("Invalid params %pK, %pK\n", dev, req_level);
+ CAM_ERR(CAM_CPAS, "Invalid params %pK, %pK", dev, req_level);
return -EINVAL;
}
opp = dev_pm_opp_find_freq_ceil(dev, &corner_freq);
if (IS_ERR(opp)) {
- pr_err("Error on OPP freq :%ld, %pK\n", corner_freq, opp);
+ CAM_ERR(CAM_CPAS, "Error on OPP freq :%ld, %pK",
+ corner_freq, opp);
return -EINVAL;
}
@@ -656,7 +655,8 @@ static int cam_cpas_util_get_ahb_level(struct cam_hw_info *cpas_hw,
if (corner == soc_private->vdd_ahb[i].vdd_corner)
level = soc_private->vdd_ahb[i].ahb_level;
- CPAS_CDBG("From OPP table : freq=[%ld][%ld], corner=%d, level=%d\n",
+ CAM_DBG(CAM_CPAS,
+ "From OPP table : freq=[%ld][%ld], corner=%d, level=%d",
freq, corner_freq, corner, level);
*req_level = level;
@@ -675,7 +675,7 @@ static int cam_cpas_util_apply_client_ahb_vote(struct cam_hw_info *cpas_hw,
int i, rc = 0;
if (!ahb_bus_client->valid) {
- pr_err("AHB Bus client not valid\n");
+ CAM_ERR(CAM_CPAS, "AHB Bus client not valid");
return -EINVAL;
}
@@ -694,7 +694,7 @@ static int cam_cpas_util_apply_client_ahb_vote(struct cam_hw_info *cpas_hw,
mutex_lock(&ahb_bus_client->lock);
cpas_client->ahb_level = required_level;
- CPAS_CDBG("Clients required level[%d], curr_level[%d]\n",
+ CAM_DBG(CAM_CPAS, "Clients required level[%d], curr_level[%d]",
required_level, ahb_bus_client->curr_vote_level);
if (required_level == ahb_bus_client->curr_vote_level)
@@ -707,19 +707,20 @@ static int cam_cpas_util_apply_client_ahb_vote(struct cam_hw_info *cpas_hw,
highest_level = cpas_core->cpas_client[i]->ahb_level;
}
- CPAS_CDBG("Required highest_level[%d]\n", highest_level);
+ CAM_DBG(CAM_CPAS, "Required highest_level[%d]", highest_level);
rc = cam_cpas_util_vote_bus_client_level(ahb_bus_client,
highest_level);
if (rc) {
- pr_err("Failed in ahb vote, level=%d, rc=%d\n",
+ CAM_ERR(CAM_CPAS, "Failed in ahb vote, level=%d, rc=%d",
highest_level, rc);
goto unlock_bus_client;
}
rc = cam_soc_util_set_clk_rate_level(&cpas_hw->soc_info, highest_level);
if (rc) {
- pr_err("Failed in scaling clock rate level %d for AHB\n",
+ CAM_ERR(CAM_CPAS,
+ "Failed in scaling clock rate level %d for AHB",
highest_level);
goto unlock_bus_client;
}
@@ -740,7 +741,7 @@ static int cam_cpas_hw_update_ahb_vote(struct cam_hw_info *cpas_hw,
int rc = 0;
if (!ahb_vote || (ahb_vote->vote.level == 0)) {
- pr_err("Invalid AHB vote, %pK\n", ahb_vote);
+ CAM_ERR(CAM_CPAS, "Invalid AHB vote, %pK", ahb_vote);
return -EINVAL;
}
@@ -750,12 +751,13 @@ static int cam_cpas_hw_update_ahb_vote(struct cam_hw_info *cpas_hw,
mutex_lock(&cpas_core->client_mutex[client_indx]);
if (!CAM_CPAS_CLIENT_STARTED(cpas_core, client_indx)) {
- pr_err("client has not started %d\n", client_indx);
+ CAM_ERR(CAM_CPAS, "client has not started %d", client_indx);
rc = -EPERM;
goto unlock_client;
}
- CPAS_CDBG("client[%d] : type[%d], level[%d], freq[%ld], applied[%d]\n",
+ CAM_DBG(CAM_CPAS,
+ "client[%d] : type[%d], level[%d], freq[%ld], applied[%d]",
client_indx, ahb_vote->type, ahb_vote->vote.level,
ahb_vote->vote.freq,
cpas_core->cpas_client[client_indx]->ahb_level);
@@ -782,12 +784,13 @@ static int cam_cpas_hw_start(void *hw_priv, void *start_args,
int rc;
if (!hw_priv || !start_args) {
- pr_err("Invalid arguments %pK %pK\n", hw_priv, start_args);
+ CAM_ERR(CAM_CPAS, "Invalid arguments %pK %pK",
+ hw_priv, start_args);
return -EINVAL;
}
if (sizeof(struct cam_cpas_hw_cmd_start) != arg_size) {
- pr_err("HW_CAPS size mismatch %ld %d\n",
+ CAM_ERR(CAM_CPAS, "HW_CAPS size mismatch %ld %d",
sizeof(struct cam_cpas_hw_cmd_start), arg_size);
return -EINVAL;
}
@@ -804,7 +807,7 @@ static int cam_cpas_hw_start(void *hw_priv, void *start_args,
if ((ahb_vote->vote.level == 0) || ((axi_vote->compressed_bw == 0) &&
(axi_vote->uncompressed_bw == 0))) {
- pr_err("Invalid vote ahb[%d], axi[%llu], [%llu]\n",
+ CAM_ERR(CAM_CPAS, "Invalid vote ahb[%d], axi[%llu], [%llu]",
ahb_vote->vote.level, axi_vote->compressed_bw,
axi_vote->uncompressed_bw);
return -EINVAL;
@@ -817,20 +820,20 @@ static int cam_cpas_hw_start(void *hw_priv, void *start_args,
mutex_lock(&cpas_core->client_mutex[client_indx]);
if (!CAM_CPAS_CLIENT_REGISTERED(cpas_core, client_indx)) {
- pr_err("client is not registered %d\n", client_indx);
+ CAM_ERR(CAM_CPAS, "client is not registered %d", client_indx);
rc = -EPERM;
goto done;
}
if (CAM_CPAS_CLIENT_STARTED(cpas_core, client_indx)) {
- pr_err("Client %d is in start state\n", client_indx);
+ CAM_ERR(CAM_CPAS, "Client %d is in start state", client_indx);
rc = -EPERM;
goto done;
}
cpas_client = cpas_core->cpas_client[client_indx];
- CPAS_CDBG("AHB :client[%d] type[%d], level[%d], applied[%d]\n",
+ CAM_DBG(CAM_CPAS, "AHB :client[%d] type[%d], level[%d], applied[%d]",
client_indx, ahb_vote->type, ahb_vote->vote.level,
cpas_client->ahb_level);
rc = cam_cpas_util_apply_client_ahb_vote(cpas_hw, cpas_client,
@@ -838,7 +841,8 @@ static int cam_cpas_hw_start(void *hw_priv, void *start_args,
if (rc)
goto done;
- CPAS_CDBG("AXI client[%d] compressed_bw[%llu], uncompressed_bw[%llu]\n",
+ CAM_DBG(CAM_CPAS,
+ "AXI client[%d] compressed_bw[%llu], uncompressed_bw[%llu]",
client_indx, axi_vote->compressed_bw,
axi_vote->uncompressed_bw);
rc = cam_cpas_util_apply_client_axi_vote(cpas_core,
@@ -850,7 +854,7 @@ static int cam_cpas_hw_start(void *hw_priv, void *start_args,
rc = cam_cpas_soc_enable_resources(&cpas_hw->soc_info,
applied_level);
if (rc) {
- pr_err("enable_resorce failed, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "enable_resorce failed, rc=%d", rc);
goto done;
}
@@ -859,7 +863,8 @@ static int cam_cpas_hw_start(void *hw_priv, void *start_args,
if (rc) {
cam_cpas_soc_disable_resources(
&cpas_hw->soc_info);
- pr_err("failed in power_on settings rc=%d\n",
+ CAM_ERR(CAM_CPAS,
+ "failed in power_on settings rc=%d",
rc);
goto done;
}
@@ -870,7 +875,7 @@ static int cam_cpas_hw_start(void *hw_priv, void *start_args,
cpas_client->started = true;
cpas_core->streamon_clients++;
- CPAS_CDBG("client_indx=%d, streamon_clients=%d\n",
+ CAM_DBG(CAM_CPAS, "client_indx=%d, streamon_clients=%d",
client_indx, cpas_core->streamon_clients);
done:
mutex_unlock(&cpas_core->client_mutex[client_indx]);
@@ -892,12 +897,13 @@ static int cam_cpas_hw_stop(void *hw_priv, void *stop_args,
int rc = 0;
if (!hw_priv || !stop_args) {
- pr_err("Invalid arguments %pK %pK\n", hw_priv, stop_args);
+ CAM_ERR(CAM_CPAS, "Invalid arguments %pK %pK",
+ hw_priv, stop_args);
return -EINVAL;
}
if (sizeof(struct cam_cpas_hw_cmd_stop) != arg_size) {
- pr_err("HW_CAPS size mismatch %ld %d\n",
+ CAM_ERR(CAM_CPAS, "HW_CAPS size mismatch %ld %d",
sizeof(struct cam_cpas_hw_cmd_stop), arg_size);
return -EINVAL;
}
@@ -913,11 +919,11 @@ static int cam_cpas_hw_stop(void *hw_priv, void *stop_args,
mutex_lock(&cpas_hw->hw_mutex);
mutex_lock(&cpas_core->client_mutex[client_indx]);
- CPAS_CDBG("client_indx=%d, streamon_clients=%d\n",
+ CAM_DBG(CAM_CPAS, "client_indx=%d, streamon_clients=%d",
client_indx, cpas_core->streamon_clients);
if (!CAM_CPAS_CLIENT_STARTED(cpas_core, client_indx)) {
- pr_err("Client %d is not started\n", client_indx);
+ CAM_ERR(CAM_CPAS, "Client %d is not started", client_indx);
rc = -EPERM;
goto done;
}
@@ -930,7 +936,8 @@ static int cam_cpas_hw_stop(void *hw_priv, void *stop_args,
if (cpas_core->internal_ops.power_off) {
rc = cpas_core->internal_ops.power_off(cpas_hw);
if (rc) {
- pr_err("failed in power_off settings rc=%d\n",
+ CAM_ERR(CAM_CPAS,
+ "failed in power_off settings rc=%d",
rc);
/* Do not return error, passthrough */
}
@@ -938,7 +945,7 @@ static int cam_cpas_hw_stop(void *hw_priv, void *stop_args,
rc = cam_cpas_soc_disable_resources(&cpas_hw->soc_info);
if (rc) {
- pr_err("disable_resorce failed, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "disable_resorce failed, rc=%d", rc);
goto done;
}
cpas_hw->hw_state = CAM_HW_STATE_POWER_DOWN;
@@ -970,12 +977,13 @@ static int cam_cpas_hw_init(void *hw_priv, void *init_hw_args,
int rc = 0;
if (!hw_priv || !init_hw_args) {
- pr_err("Invalid arguments %pK %pK\n", hw_priv, init_hw_args);
+ CAM_ERR(CAM_CPAS, "Invalid arguments %pK %pK",
+ hw_priv, init_hw_args);
return -EINVAL;
}
if (sizeof(struct cam_cpas_hw_caps) != arg_size) {
- pr_err("INIT HW size mismatch %ld %d\n",
+ CAM_ERR(CAM_CPAS, "INIT HW size mismatch %ld %d",
sizeof(struct cam_cpas_hw_caps), arg_size);
return -EINVAL;
}
@@ -1002,7 +1010,7 @@ static int cam_cpas_hw_register_client(struct cam_hw_info *cpas_hw,
struct cam_cpas_private_soc *soc_private =
(struct cam_cpas_private_soc *) cpas_hw->soc_info.soc_private;
- CPAS_CDBG("Register params : identifier=%s, cell_index=%d\n",
+ CAM_DBG(CAM_CPAS, "Register params : identifier=%s, cell_index=%d",
register_params->identifier, register_params->cell_index);
if (soc_private->client_id_based)
@@ -1015,11 +1023,11 @@ static int cam_cpas_hw_register_client(struct cam_hw_info *cpas_hw,
mutex_lock(&cpas_hw->hw_mutex);
- rc = cam_cpas_util_get_string_index(soc_private->client_name,
+ rc = cam_common_util_get_string_index(soc_private->client_name,
soc_private->num_clients, client_name, &client_indx);
if (rc || !CAM_CPAS_CLIENT_VALID(client_indx) ||
CAM_CPAS_CLIENT_REGISTERED(cpas_core, client_indx)) {
- pr_err("Invalid Client register : %s %d, %d\n",
+ CAM_ERR(CAM_CPAS, "Invalid Client register : %s %d, %d",
register_params->identifier,
register_params->cell_index, client_indx);
mutex_unlock(&cpas_hw->hw_mutex);
@@ -1035,7 +1043,8 @@ static int cam_cpas_hw_register_client(struct cam_hw_info *cpas_hw,
rc = cam_cpas_util_insert_client_to_axi_port(cpas_core, soc_private,
cpas_client, client_indx);
if (rc) {
- pr_err("axi_port_insert failed client_indx=%d, rc=%d\n",
+ CAM_ERR(CAM_CPAS,
+ "axi_port_insert failed client_indx=%d, rc=%d",
client_indx, rc);
kfree(cpas_client);
mutex_unlock(&cpas_hw->hw_mutex);
@@ -1051,7 +1060,7 @@ static int cam_cpas_hw_register_client(struct cam_hw_info *cpas_hw,
mutex_unlock(&cpas_hw->hw_mutex);
- CPAS_CDBG("client_indx=%d, registered_clients=%d\n",
+ CAM_DBG(CAM_CPAS, "client_indx=%d, registered_clients=%d",
client_indx, cpas_core->registered_clients);
return 0;
@@ -1071,13 +1080,13 @@ static int cam_cpas_hw_unregister_client(struct cam_hw_info *cpas_hw,
mutex_lock(&cpas_core->client_mutex[client_indx]);
if (!CAM_CPAS_CLIENT_REGISTERED(cpas_core, client_indx)) {
- pr_err("client not registered %d\n", client_indx);
+ CAM_ERR(CAM_CPAS, "client not registered %d", client_indx);
rc = -EPERM;
goto done;
}
if (CAM_CPAS_CLIENT_STARTED(cpas_core, client_indx)) {
- pr_err("Client %d is not stopped\n", client_indx);
+ CAM_ERR(CAM_CPAS, "Client %d is not stopped", client_indx);
rc = -EPERM;
goto done;
}
@@ -1085,7 +1094,7 @@ static int cam_cpas_hw_unregister_client(struct cam_hw_info *cpas_hw,
cam_cpas_util_remove_client_from_axi_port(
cpas_core->cpas_client[client_indx]);
- CPAS_CDBG("client_indx=%d, registered_clients=%d\n",
+ CAM_DBG(CAM_CPAS, "client_indx=%d, registered_clients=%d",
client_indx, cpas_core->registered_clients);
kfree(cpas_core->cpas_client[client_indx]);
@@ -1105,12 +1114,13 @@ static int cam_cpas_hw_get_hw_info(void *hw_priv,
struct cam_cpas_hw_caps *hw_caps;
if (!hw_priv || !get_hw_cap_args) {
- pr_err("Invalid arguments %pK %pK\n", hw_priv, get_hw_cap_args);
+ CAM_ERR(CAM_CPAS, "Invalid arguments %pK %pK",
+ hw_priv, get_hw_cap_args);
return -EINVAL;
}
if (sizeof(struct cam_cpas_hw_caps) != arg_size) {
- pr_err("HW_CAPS size mismatch %ld %d\n",
+ CAM_ERR(CAM_CPAS, "HW_CAPS size mismatch %ld %d",
sizeof(struct cam_cpas_hw_caps), arg_size);
return -EINVAL;
}
@@ -1132,8 +1142,8 @@ static int cam_cpas_hw_process_cmd(void *hw_priv,
if (!hw_priv || !cmd_args ||
(cmd_type >= CAM_CPAS_HW_CMD_INVALID)) {
- pr_err("Invalid arguments %pK %pK %d\n", hw_priv, cmd_args,
- cmd_type);
+ CAM_ERR(CAM_CPAS, "Invalid arguments %pK %pK %d",
+ hw_priv, cmd_args, cmd_type);
return -EINVAL;
}
@@ -1142,7 +1152,7 @@ static int cam_cpas_hw_process_cmd(void *hw_priv,
struct cam_cpas_register_params *register_params;
if (sizeof(struct cam_cpas_register_params) != arg_size) {
- pr_err("cmd_type %d, size mismatch %d\n",
+ CAM_ERR(CAM_CPAS, "cmd_type %d, size mismatch %d",
cmd_type, arg_size);
break;
}
@@ -1155,7 +1165,7 @@ static int cam_cpas_hw_process_cmd(void *hw_priv,
uint32_t *client_handle;
if (sizeof(uint32_t) != arg_size) {
- pr_err("cmd_type %d, size mismatch %d\n",
+ CAM_ERR(CAM_CPAS, "cmd_type %d, size mismatch %d",
cmd_type, arg_size);
break;
}
@@ -1169,7 +1179,7 @@ static int cam_cpas_hw_process_cmd(void *hw_priv,
if (sizeof(struct cam_cpas_hw_cmd_reg_read_write) !=
arg_size) {
- pr_err("cmd_type %d, size mismatch %d\n",
+ CAM_ERR(CAM_CPAS, "cmd_type %d, size mismatch %d",
cmd_type, arg_size);
break;
}
@@ -1186,7 +1196,7 @@ static int cam_cpas_hw_process_cmd(void *hw_priv,
if (sizeof(struct cam_cpas_hw_cmd_reg_read_write) !=
arg_size) {
- pr_err("cmd_type %d, size mismatch %d\n",
+ CAM_ERR(CAM_CPAS, "cmd_type %d, size mismatch %d",
cmd_type, arg_size);
break;
}
@@ -1203,7 +1213,7 @@ static int cam_cpas_hw_process_cmd(void *hw_priv,
struct cam_cpas_hw_cmd_ahb_vote *cmd_ahb_vote;
if (sizeof(struct cam_cpas_hw_cmd_ahb_vote) != arg_size) {
- pr_err("cmd_type %d, size mismatch %d\n",
+ CAM_ERR(CAM_CPAS, "cmd_type %d, size mismatch %d",
cmd_type, arg_size);
break;
}
@@ -1217,7 +1227,7 @@ static int cam_cpas_hw_process_cmd(void *hw_priv,
struct cam_cpas_hw_cmd_axi_vote *cmd_axi_vote;
if (sizeof(struct cam_cpas_hw_cmd_axi_vote) != arg_size) {
- pr_err("cmd_type %d, size mismatch %d\n",
+ CAM_ERR(CAM_CPAS, "cmd_type %d, size mismatch %d",
cmd_type, arg_size);
break;
}
@@ -1228,7 +1238,7 @@ static int cam_cpas_hw_process_cmd(void *hw_priv,
break;
}
default:
- pr_err("CPAS HW command not valid =%d\n", cmd_type);
+ CAM_ERR(CAM_CPAS, "CPAS HW command not valid =%d", cmd_type);
break;
}
@@ -1274,7 +1284,7 @@ static int cam_cpas_util_get_internal_ops(struct platform_device *pdev,
rc = of_property_read_string_index(of_node, "arch-compat", 0,
(const char **)&compat_str);
if (rc) {
- pr_err("failed to get arch-compat rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "failed to get arch-compat rc=%d", rc);
return -EINVAL;
}
@@ -1285,7 +1295,7 @@ static int cam_cpas_util_get_internal_ops(struct platform_device *pdev,
hw_intf->hw_type = CAM_HW_CPASTOP;
rc = cam_cpastop_get_internal_ops(internal_ops);
} else {
- pr_err("arch-compat %s not supported\n", compat_str);
+ CAM_ERR(CAM_CPAS, "arch-compat %s not supported", compat_str);
rc = -EINVAL;
}
@@ -1375,7 +1385,7 @@ int cam_cpas_hw_probe(struct platform_device *pdev,
rc = cam_cpas_util_client_setup(cpas_hw);
if (rc) {
- pr_err("failed in client setup, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "failed in client setup, rc=%d", rc);
goto deinit_platform_res;
}
@@ -1383,13 +1393,13 @@ int cam_cpas_hw_probe(struct platform_device *pdev,
cpas_hw->soc_info.pdev->dev.of_node,
&cpas_core->ahb_bus_client);
if (rc) {
- pr_err("failed in ahb setup, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "failed in ahb setup, rc=%d", rc);
goto client_cleanup;
}
rc = cam_cpas_util_axi_setup(cpas_core, &cpas_hw->soc_info);
if (rc) {
- pr_err("failed in axi setup, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "failed in axi setup, rc=%d", rc);
goto ahb_cleanup;
}
@@ -1400,18 +1410,18 @@ int cam_cpas_hw_probe(struct platform_device *pdev,
rc = cam_cpas_soc_enable_resources(&cpas_hw->soc_info, CAM_SVS_VOTE);
if (rc) {
- pr_err("failed in soc_enable_resources, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "failed in soc_enable_resources, rc=%d", rc);
goto remove_default_vote;
}
if (internal_ops->get_hw_info) {
rc = internal_ops->get_hw_info(cpas_hw, &cpas_core->hw_caps);
if (rc) {
- pr_err("failed in get_hw_info, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "failed in get_hw_info, rc=%d", rc);
goto disable_soc_res;
}
} else {
- pr_err("Invalid get_hw_info\n");
+ CAM_ERR(CAM_CPAS, "Invalid get_hw_info");
goto disable_soc_res;
}
@@ -1422,7 +1432,7 @@ int cam_cpas_hw_probe(struct platform_device *pdev,
rc = cam_cpas_soc_disable_resources(&cpas_hw->soc_info);
if (rc) {
- pr_err("failed in soc_disable_resources, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "failed in soc_disable_resources, rc=%d", rc);
goto remove_default_vote;
}
@@ -1453,7 +1463,7 @@ int cam_cpas_hw_probe(struct platform_device *pdev,
kfree(cpas_core);
kfree(cpas_hw);
kfree(cpas_hw_intf);
- pr_err("failed in hw probe\n");
+ CAM_ERR(CAM_CPAS, "failed in hw probe");
return rc;
}
@@ -1463,7 +1473,7 @@ int cam_cpas_hw_remove(struct cam_hw_intf *cpas_hw_intf)
struct cam_cpas *cpas_core;
if (!cpas_hw_intf) {
- pr_err("cpas interface not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas interface not initialized");
return -EINVAL;
}
@@ -1471,7 +1481,7 @@ int cam_cpas_hw_remove(struct cam_hw_intf *cpas_hw_intf)
cpas_core = (struct cam_cpas *)cpas_hw->core_info;
if (cpas_hw->hw_state == CAM_HW_STATE_POWER_UP) {
- pr_err("cpas hw is in power up state\n");
+ CAM_ERR(CAM_CPAS, "cpas hw is in power up state");
return -EINVAL;
}
diff --git a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.h b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.h
index 6d4fafe..bbc99b7 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.h
+++ b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw.h
@@ -15,6 +15,7 @@
#include "cam_cpas_api.h"
#include "cam_cpas_hw_intf.h"
+#include "cam_common_util.h"
#define CPAS_MAX_CLIENTS 20
#define CAM_CPAS_INFLIGHT_WORKS 5
@@ -192,7 +193,5 @@ int cam_cpastop_get_internal_ops(struct cam_cpas_internal_ops *internal_ops);
int cam_cpas_util_reg_update(struct cam_hw_info *cpas_hw,
enum cam_cpas_reg_base reg_base, struct cam_cpas_reg *reg_info);
-int cam_cpas_util_get_string_index(const char **strings,
- uint32_t num_strings, char *matching_string, uint32_t *index);
#endif /* _CAM_CPAS_HW_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw_intf.h b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw_intf.h
index 9ee5a43..fa4018e 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw_intf.h
+++ b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_hw_intf.h
@@ -18,16 +18,7 @@
#include "cam_cpas_api.h"
#include "cam_hw.h"
#include "cam_hw_intf.h"
-
-#ifdef CONFIG_CAM_CPAS_DBG
-#define CPAS_CDBG(fmt, args...) pr_err(fmt, ##args)
-#else
-#define CPAS_CDBG(fmt, args...) pr_debug(fmt, ##args)
-#endif
-#undef pr_fmt
-#define pr_fmt(fmt) "CAM-CPAS %s:%d " fmt, __func__, __LINE__
-
-#define BITS_MASK_SHIFT(x, mask, shift) (((x) & (mask)) >> shift)
+#include "cam_debug_util.h"
/* Number of times to retry while polling */
#define CAM_CPAS_POLL_RETRY_CNT 5
diff --git a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_intf.c b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_intf.c
index aba0caa..3846784 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_intf.c
+++ b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_intf.c
@@ -55,12 +55,12 @@ int cam_cpas_get_hw_info(uint32_t *camera_family,
struct cam_hw_version *cpas_version)
{
if (!CAM_CPAS_INTF_INITIALIZED()) {
- pr_err("cpas intf not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas intf not initialized");
return -ENODEV;
}
if (!camera_family || !camera_version || !cpas_version) {
- pr_err("invalid input %pK %pK %pK\n", camera_family,
+ CAM_ERR(CAM_CPAS, "invalid input %pK %pK %pK", camera_family,
camera_version, cpas_version);
return -EINVAL;
}
@@ -80,7 +80,7 @@ int cam_cpas_reg_write(uint32_t client_handle,
int rc;
if (!CAM_CPAS_INTF_INITIALIZED()) {
- pr_err("cpas intf not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas intf not initialized");
return -ENODEV;
}
@@ -98,9 +98,9 @@ int cam_cpas_reg_write(uint32_t client_handle,
CAM_CPAS_HW_CMD_REG_WRITE, &cmd_reg_write,
sizeof(struct cam_cpas_hw_cmd_reg_read_write));
if (rc)
- pr_err("Failed in process_cmd, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in process_cmd, rc=%d", rc);
} else {
- pr_err("Invalid process_cmd ops\n");
+ CAM_ERR(CAM_CPAS, "Invalid process_cmd ops");
rc = -EINVAL;
}
@@ -115,12 +115,12 @@ int cam_cpas_reg_read(uint32_t client_handle,
int rc;
if (!CAM_CPAS_INTF_INITIALIZED()) {
- pr_err("cpas intf not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas intf not initialized");
return -ENODEV;
}
if (!value) {
- pr_err("Invalid arg value\n");
+ CAM_ERR(CAM_CPAS, "Invalid arg value");
return -EINVAL;
}
@@ -138,13 +138,13 @@ int cam_cpas_reg_read(uint32_t client_handle,
CAM_CPAS_HW_CMD_REG_READ, &cmd_reg_read,
sizeof(struct cam_cpas_hw_cmd_reg_read_write));
if (rc) {
- pr_err("Failed in process_cmd, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in process_cmd, rc=%d", rc);
return rc;
}
*value = cmd_reg_read.value;
} else {
- pr_err("Invalid process_cmd ops\n");
+ CAM_ERR(CAM_CPAS, "Invalid process_cmd ops");
rc = -EINVAL;
}
@@ -158,7 +158,7 @@ int cam_cpas_update_axi_vote(uint32_t client_handle,
int rc;
if (!CAM_CPAS_INTF_INITIALIZED()) {
- pr_err("cpas intf not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas intf not initialized");
return -ENODEV;
}
@@ -173,9 +173,9 @@ int cam_cpas_update_axi_vote(uint32_t client_handle,
CAM_CPAS_HW_CMD_AXI_VOTE, &cmd_axi_vote,
sizeof(struct cam_cpas_hw_cmd_axi_vote));
if (rc)
- pr_err("Failed in process_cmd, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in process_cmd, rc=%d", rc);
} else {
- pr_err("Invalid process_cmd ops\n");
+ CAM_ERR(CAM_CPAS, "Invalid process_cmd ops");
rc = -EINVAL;
}
@@ -189,7 +189,7 @@ int cam_cpas_update_ahb_vote(uint32_t client_handle,
int rc;
if (!CAM_CPAS_INTF_INITIALIZED()) {
- pr_err("cpas intf not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas intf not initialized");
return -ENODEV;
}
@@ -204,9 +204,9 @@ int cam_cpas_update_ahb_vote(uint32_t client_handle,
CAM_CPAS_HW_CMD_AHB_VOTE, &cmd_ahb_vote,
sizeof(struct cam_cpas_hw_cmd_ahb_vote));
if (rc)
- pr_err("Failed in process_cmd, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in process_cmd, rc=%d", rc);
} else {
- pr_err("Invalid process_cmd ops\n");
+ CAM_ERR(CAM_CPAS, "Invalid process_cmd ops");
rc = -EINVAL;
}
@@ -219,7 +219,7 @@ int cam_cpas_stop(uint32_t client_handle)
int rc;
if (!CAM_CPAS_INTF_INITIALIZED()) {
- pr_err("cpas intf not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas intf not initialized");
return -ENODEV;
}
@@ -232,9 +232,9 @@ int cam_cpas_stop(uint32_t client_handle)
g_cpas_intf->hw_intf->hw_priv, &cmd_hw_stop,
sizeof(struct cam_cpas_hw_cmd_stop));
if (rc)
- pr_err("Failed in stop, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in stop, rc=%d", rc);
} else {
- pr_err("Invalid stop ops\n");
+ CAM_ERR(CAM_CPAS, "Invalid stop ops");
rc = -EINVAL;
}
@@ -248,7 +248,7 @@ int cam_cpas_start(uint32_t client_handle,
int rc;
if (!CAM_CPAS_INTF_INITIALIZED()) {
- pr_err("cpas intf not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas intf not initialized");
return -ENODEV;
}
@@ -263,9 +263,9 @@ int cam_cpas_start(uint32_t client_handle,
g_cpas_intf->hw_intf->hw_priv, &cmd_hw_start,
sizeof(struct cam_cpas_hw_cmd_start));
if (rc)
- pr_err("Failed in start, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in start, rc=%d", rc);
} else {
- pr_err("Invalid start ops\n");
+ CAM_ERR(CAM_CPAS, "Invalid start ops");
rc = -EINVAL;
}
@@ -278,7 +278,7 @@ int cam_cpas_unregister_client(uint32_t client_handle)
int rc;
if (!CAM_CPAS_INTF_INITIALIZED()) {
- pr_err("cpas intf not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas intf not initialized");
return -ENODEV;
}
@@ -288,9 +288,9 @@ int cam_cpas_unregister_client(uint32_t client_handle)
CAM_CPAS_HW_CMD_UNREGISTER_CLIENT,
&client_handle, sizeof(uint32_t));
if (rc)
- pr_err("Failed in process_cmd, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in process_cmd, rc=%d", rc);
} else {
- pr_err("Invalid process_cmd ops\n");
+ CAM_ERR(CAM_CPAS, "Invalid process_cmd ops");
rc = -EINVAL;
}
@@ -304,7 +304,7 @@ int cam_cpas_register_client(
int rc;
if (!CAM_CPAS_INTF_INITIALIZED()) {
- pr_err("cpas intf not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas intf not initialized");
return -ENODEV;
}
@@ -314,9 +314,9 @@ int cam_cpas_register_client(
CAM_CPAS_HW_CMD_REGISTER_CLIENT, register_params,
sizeof(struct cam_cpas_register_params));
if (rc)
- pr_err("Failed in process_cmd, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in process_cmd, rc=%d", rc);
} else {
- pr_err("Invalid process_cmd ops\n");
+ CAM_ERR(CAM_CPAS, "Invalid process_cmd ops");
rc = -EINVAL;
}
@@ -330,7 +330,7 @@ int cam_cpas_subdev_cmd(struct cam_cpas_intf *cpas_intf,
int rc = 0;
if (!cmd) {
- pr_err("Invalid input cmd\n");
+ CAM_ERR(CAM_CPAS, "Invalid input cmd");
return -EINVAL;
}
@@ -341,7 +341,8 @@ int cam_cpas_subdev_cmd(struct cam_cpas_intf *cpas_intf,
rc = copy_from_user(&query, (void __user *) cmd->handle,
sizeof(query));
if (rc) {
- pr_err("Failed in copy from user, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in copy from user, rc=%d",
+ rc);
break;
}
@@ -353,14 +354,14 @@ int cam_cpas_subdev_cmd(struct cam_cpas_intf *cpas_intf,
rc = copy_to_user((void __user *) cmd->handle, &query,
sizeof(query));
if (rc)
- pr_err("Failed in copy to user, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in copy to user, rc=%d", rc);
break;
}
case CAM_SD_SHUTDOWN:
break;
default:
- pr_err("Unknown op code %d for CPAS\n", cmd->op_code);
+ CAM_ERR(CAM_CPAS, "Unknown op code %d for CPAS", cmd->op_code);
rc = -EINVAL;
break;
}
@@ -374,13 +375,13 @@ static int cam_cpas_subdev_open(struct v4l2_subdev *sd,
struct cam_cpas_intf *cpas_intf = v4l2_get_subdevdata(sd);
if (!cpas_intf || !cpas_intf->probe_done) {
- pr_err("CPAS not initialized\n");
+ CAM_ERR(CAM_CPAS, "CPAS not initialized");
return -ENODEV;
}
mutex_lock(&cpas_intf->intf_lock);
cpas_intf->open_cnt++;
- CPAS_CDBG("CPAS Subdev open count %d\n", cpas_intf->open_cnt);
+ CAM_DBG(CAM_CPAS, "CPAS Subdev open count %d", cpas_intf->open_cnt);
mutex_unlock(&cpas_intf->intf_lock);
return 0;
@@ -392,13 +393,13 @@ static int cam_cpas_subdev_close(struct v4l2_subdev *sd,
struct cam_cpas_intf *cpas_intf = v4l2_get_subdevdata(sd);
if (!cpas_intf || !cpas_intf->probe_done) {
- pr_err("CPAS not initialized\n");
+ CAM_ERR(CAM_CPAS, "CPAS not initialized");
return -ENODEV;
}
mutex_lock(&cpas_intf->intf_lock);
cpas_intf->open_cnt--;
- CPAS_CDBG("CPAS Subdev close count %d\n", cpas_intf->open_cnt);
+ CAM_DBG(CAM_CPAS, "CPAS Subdev close count %d", cpas_intf->open_cnt);
mutex_unlock(&cpas_intf->intf_lock);
return 0;
@@ -411,7 +412,7 @@ static long cam_cpas_subdev_ioctl(struct v4l2_subdev *sd,
struct cam_cpas_intf *cpas_intf = v4l2_get_subdevdata(sd);
if (!cpas_intf || !cpas_intf->probe_done) {
- pr_err("CPAS not initialized\n");
+ CAM_ERR(CAM_CPAS, "CPAS not initialized");
return -ENODEV;
}
@@ -420,7 +421,7 @@ static long cam_cpas_subdev_ioctl(struct v4l2_subdev *sd,
rc = cam_cpas_subdev_cmd(cpas_intf, (struct cam_control *) arg);
break;
default:
- pr_err("Invalid command %d for CPAS!\n", cmd);
+ CAM_ERR(CAM_CPAS, "Invalid command %d for CPAS!", cmd);
rc = -EINVAL;
break;
}
@@ -437,13 +438,13 @@ static long cam_cpas_subdev_compat_ioctl(struct v4l2_subdev *sd,
struct cam_cpas_intf *cpas_intf = v4l2_get_subdevdata(sd);
if (!cpas_intf || !cpas_intf->probe_done) {
- pr_err("CPAS not initialized\n");
+ CAM_ERR(CAM_CPAS, "CPAS not initialized");
return -ENODEV;
}
if (copy_from_user(&cmd_data, (void __user *)arg,
sizeof(cmd_data))) {
- pr_err("Failed to copy from user_ptr=%pK size=%zu\n",
+ CAM_ERR(CAM_CPAS, "Failed to copy from user_ptr=%pK size=%zu",
(void __user *)arg, sizeof(cmd_data));
return -EFAULT;
}
@@ -453,7 +454,7 @@ static long cam_cpas_subdev_compat_ioctl(struct v4l2_subdev *sd,
rc = cam_cpas_subdev_cmd(cpas_intf, &cmd_data);
break;
default:
- pr_err("Invalid command %d for CPAS!\n", cmd);
+ CAM_ERR(CAM_CPAS, "Invalid command %d for CPAS!", cmd);
rc = -EINVAL;
break;
}
@@ -461,7 +462,8 @@ static long cam_cpas_subdev_compat_ioctl(struct v4l2_subdev *sd,
if (!rc) {
if (copy_to_user((void __user *)arg, &cmd_data,
sizeof(cmd_data))) {
- pr_err("Failed to copy to user_ptr=%pK size=%zu\n",
+ CAM_ERR(CAM_CPAS,
+ "Failed to copy to user_ptr=%pK size=%zu",
(void __user *)arg, sizeof(cmd_data));
rc = -EFAULT;
}
@@ -508,7 +510,8 @@ static int cam_cpas_subdev_register(struct platform_device *pdev)
rc = cam_register_subdev(subdev);
if (rc) {
- pr_err("failed register subdev: %s!\n", CAM_CPAS_DEV_NAME);
+ CAM_ERR(CAM_CPAS, "failed register subdev: %s!",
+ CAM_CPAS_DEV_NAME);
return rc;
}
@@ -523,7 +526,7 @@ static int cam_cpas_dev_probe(struct platform_device *pdev)
int rc;
if (g_cpas_intf) {
- pr_err("cpas dev proble already done\n");
+ CAM_ERR(CAM_CPAS, "cpas dev proble already done");
return -EALREADY;
}
@@ -536,7 +539,7 @@ static int cam_cpas_dev_probe(struct platform_device *pdev)
rc = cam_cpas_hw_probe(pdev, &g_cpas_intf->hw_intf);
if (rc || (g_cpas_intf->hw_intf == NULL)) {
- pr_err("Failed in hw probe, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in hw probe, rc=%d", rc);
goto error_destroy_mem;
}
@@ -546,11 +549,11 @@ static int cam_cpas_dev_probe(struct platform_device *pdev)
rc = hw_intf->hw_ops.get_hw_caps(hw_intf->hw_priv,
hw_caps, sizeof(struct cam_cpas_hw_caps));
if (rc) {
- pr_err("Failed in get_hw_caps, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "Failed in get_hw_caps, rc=%d", rc);
goto error_hw_remove;
}
} else {
- pr_err("Invalid get_hw_caps ops\n");
+ CAM_ERR(CAM_CPAS, "Invalid get_hw_caps ops");
goto error_hw_remove;
}
@@ -559,7 +562,8 @@ static int cam_cpas_dev_probe(struct platform_device *pdev)
goto error_hw_remove;
g_cpas_intf->probe_done = true;
- CPAS_CDBG("CPAS INTF Probe success %d, %d.%d.%d, %d.%d.%d, 0x%x\n",
+ CAM_DBG(CAM_CPAS,
+ "CPAS INTF Probe success %d, %d.%d.%d, %d.%d.%d, 0x%x",
hw_caps->camera_family, hw_caps->camera_version.major,
hw_caps->camera_version.minor, hw_caps->camera_version.incr,
hw_caps->cpas_version.major, hw_caps->cpas_version.minor,
@@ -573,14 +577,14 @@ static int cam_cpas_dev_probe(struct platform_device *pdev)
mutex_destroy(&g_cpas_intf->intf_lock);
kfree(g_cpas_intf);
g_cpas_intf = NULL;
- pr_err("CPAS probe failed\n");
+ CAM_ERR(CAM_CPAS, "CPAS probe failed");
return rc;
}
static int cam_cpas_dev_remove(struct platform_device *dev)
{
if (!CAM_CPAS_INTF_INITIALIZED()) {
- pr_err("cpas intf not initialized\n");
+ CAM_ERR(CAM_CPAS, "cpas intf not initialized");
return -ENODEV;
}
diff --git a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_soc.c b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_soc.c
index 09c2ae5..f85f461 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_soc.c
+++ b/drivers/media/platform/msm/camera/cam_cpas/cam_cpas_soc.c
@@ -29,7 +29,8 @@ int cam_cpas_get_custom_dt_info(struct platform_device *pdev,
int count = 0, i = 0, rc = 0;
if (!soc_private || !pdev) {
- pr_err("invalid input arg %pK %pK\n", soc_private, pdev);
+ CAM_ERR(CAM_CPAS, "invalid input arg %pK %pK",
+ soc_private, pdev);
return -EINVAL;
}
@@ -38,7 +39,8 @@ int cam_cpas_get_custom_dt_info(struct platform_device *pdev,
rc = of_property_read_string_index(of_node, "arch-compat", 0,
(const char **)&soc_private->arch_compat);
if (rc) {
- pr_err("device %s failed to read arch-compat\n", pdev->name);
+ CAM_ERR(CAM_CPAS, "device %s failed to read arch-compat",
+ pdev->name);
return rc;
}
@@ -47,12 +49,13 @@ int cam_cpas_get_custom_dt_info(struct platform_device *pdev,
count = of_property_count_strings(of_node, "client-names");
if (count <= 0) {
- pr_err("no client-names found\n");
+ CAM_ERR(CAM_CPAS, "no client-names found");
count = 0;
return -EINVAL;
}
soc_private->num_clients = count;
- CPAS_CDBG("arch-compat=%s, client_id_based = %d, num_clients=%d\n",
+ CAM_DBG(CAM_CPAS,
+ "arch-compat=%s, client_id_based = %d, num_clients=%d",
soc_private->arch_compat, soc_private->client_id_based,
soc_private->num_clients);
@@ -60,15 +63,16 @@ int cam_cpas_get_custom_dt_info(struct platform_device *pdev,
rc = of_property_read_string_index(of_node,
"client-names", i, &soc_private->client_name[i]);
if (rc) {
- pr_err("no client-name at cnt=%d\n", i);
+ CAM_ERR(CAM_CPAS, "no client-name at cnt=%d", i);
return -ENODEV;
}
- CPAS_CDBG("Client[%d] : %s\n", i, soc_private->client_name[i]);
+ CAM_DBG(CAM_CPAS, "Client[%d] : %s", i,
+ soc_private->client_name[i]);
}
count = of_property_count_strings(of_node, "client-axi-port-names");
if ((count <= 0) || (count != soc_private->num_clients)) {
- pr_err("incorrect client-axi-port-names info %d %d\n",
+ CAM_ERR(CAM_CPAS, "incorrect client-axi-port-names info %d %d",
count, soc_private->num_clients);
count = 0;
return -EINVAL;
@@ -79,10 +83,10 @@ int cam_cpas_get_custom_dt_info(struct platform_device *pdev,
"client-axi-port-names", i,
&soc_private->client_axi_port_name[i]);
if (rc) {
- pr_err("no client-name at cnt=%d\n", i);
+ CAM_ERR(CAM_CPAS, "no client-name at cnt=%d", i);
return -ENODEV;
}
- CPAS_CDBG("Client AXI Port[%d] : %s\n", i,
+ CAM_DBG(CAM_CPAS, "Client AXI Port[%d] : %s", i,
soc_private->client_axi_port_name[i]);
}
@@ -99,25 +103,29 @@ int cam_cpas_get_custom_dt_info(struct platform_device *pdev,
rc = of_property_read_u32_index(of_node, "vdd-corners",
i, &soc_private->vdd_ahb[i].vdd_corner);
if (rc) {
- pr_err("vdd-corners failed at index=%d\n", i);
+ CAM_ERR(CAM_CPAS,
+ "vdd-corners failed at index=%d", i);
return -ENODEV;
}
rc = of_property_read_string_index(of_node,
"vdd-corner-ahb-mapping", i, &ahb_string);
if (rc) {
- pr_err("no ahb-mapping at index=%d\n", i);
+ CAM_ERR(CAM_CPAS,
+ "no ahb-mapping at index=%d", i);
return -ENODEV;
}
rc = cam_soc_util_get_level_from_string(ahb_string,
&soc_private->vdd_ahb[i].ahb_level);
if (rc) {
- pr_err("invalid ahb-string at index=%d\n", i);
+ CAM_ERR(CAM_CPAS,
+ "invalid ahb-string at index=%d", i);
return -EINVAL;
}
- CPAS_CDBG("Vdd-AHB mapping [%d] : [%d] [%s] [%d]\n", i,
+ CAM_DBG(CAM_CPAS,
+ "Vdd-AHB mapping [%d] : [%d] [%s] [%d]", i,
soc_private->vdd_ahb[i].vdd_corner,
ahb_string, soc_private->vdd_ahb[i].ahb_level);
}
@@ -135,19 +143,20 @@ int cam_cpas_soc_init_resources(struct cam_hw_soc_info *soc_info,
rc = cam_soc_util_get_dt_properties(soc_info);
if (rc) {
- pr_err("failed in get_dt_properties, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "failed in get_dt_properties, rc=%d", rc);
return rc;
}
if (soc_info->irq_line && !irq_handler) {
- pr_err("Invalid IRQ handler\n");
+ CAM_ERR(CAM_CPAS, "Invalid IRQ handler");
return -EINVAL;
}
rc = cam_soc_util_request_platform_resource(soc_info, irq_handler,
irq_data);
if (rc) {
- pr_err("failed in request_platform_resource, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "failed in request_platform_resource, rc=%d",
+ rc);
return rc;
}
@@ -160,7 +169,7 @@ int cam_cpas_soc_init_resources(struct cam_hw_soc_info *soc_info,
rc = cam_cpas_get_custom_dt_info(soc_info->pdev, soc_info->soc_private);
if (rc) {
- pr_err("failed in get_custom_info, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "failed in get_custom_info, rc=%d", rc);
goto free_soc_private;
}
@@ -179,7 +188,7 @@ int cam_cpas_soc_deinit_resources(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_release_platform_resource(soc_info);
if (rc)
- pr_err("release platform failed, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "release platform failed, rc=%d", rc);
kfree(soc_info->soc_private);
soc_info->soc_private = NULL;
@@ -195,7 +204,7 @@ int cam_cpas_soc_enable_resources(struct cam_hw_soc_info *soc_info,
rc = cam_soc_util_enable_platform_resource(soc_info, true,
default_level, true);
if (rc)
- pr_err("enable platform resource failed, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "enable platform resource failed, rc=%d", rc);
return rc;
}
@@ -206,7 +215,7 @@ int cam_cpas_soc_disable_resources(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
if (rc)
- pr_err("disable platform failed, rc=%d\n", rc);
+ CAM_ERR(CAM_CPAS, "disable platform failed, rc=%d", rc);
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_cpas/camss_top/cam_camsstop_hw.c b/drivers/media/platform/msm/camera/cam_cpas/camss_top/cam_camsstop_hw.c
index 95e26c5..0669070 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/camss_top/cam_camsstop_hw.c
+++ b/drivers/media/platform/msm/camera/cam_cpas/camss_top/cam_camsstop_hw.c
@@ -29,13 +29,13 @@ int cam_camsstop_get_hw_info(struct cam_hw_info *cpas_hw,
reg_value = cam_io_r_mb(soc_info->reg_map[reg_indx].mem_base + 0x0);
hw_caps->camera_version.major =
- BITS_MASK_SHIFT(reg_value, 0xf0000000, 0x1c);
+ CAM_BITS_MASK_SHIFT(reg_value, 0xf0000000, 0x1c);
hw_caps->camera_version.minor =
- BITS_MASK_SHIFT(reg_value, 0xfff0000, 0x10);
+ CAM_BITS_MASK_SHIFT(reg_value, 0xfff0000, 0x10);
hw_caps->camera_version.incr =
- BITS_MASK_SHIFT(reg_value, 0xffff, 0x0);
+ CAM_BITS_MASK_SHIFT(reg_value, 0xffff, 0x0);
- CPAS_CDBG("Family %d, version %d.%d.%d\n",
+ CAM_DBG(CAM_FD, "Family %d, version %d.%d.%d",
hw_caps->camera_family, hw_caps->camera_version.major,
hw_caps->camera_version.minor, hw_caps->camera_version.incr);
@@ -49,21 +49,22 @@ int cam_camsstop_setup_regbase_indices(struct cam_hw_soc_info *soc_info,
int rc;
if (num_reg_map > CAM_CPAS_REG_MAX) {
- pr_err("invalid num_reg_map=%d\n", num_reg_map);
+ CAM_ERR(CAM_CPAS, "invalid num_reg_map=%d", num_reg_map);
return -EINVAL;
}
if (soc_info->num_mem_block > CAM_SOC_MAX_BLOCK) {
- pr_err("invalid num_mem_block=%d\n", soc_info->num_mem_block);
+ CAM_ERR(CAM_CPAS, "invalid num_mem_block=%d",
+ soc_info->num_mem_block);
return -EINVAL;
}
- rc = cam_cpas_util_get_string_index(soc_info->mem_block_name,
+ rc = cam_common_util_get_string_index(soc_info->mem_block_name,
soc_info->num_mem_block, "cam_camss", &index);
if ((rc == 0) && (index < num_reg_map)) {
regbase_index[CAM_CPAS_REG_CAMSS] = index;
} else {
- pr_err("regbase not found for CAM_CPAS_REG_CAMSS\n");
+ CAM_ERR(CAM_CPAS, "regbase not found for CAM_CPAS_REG_CAMSS");
return -EINVAL;
}
@@ -73,7 +74,7 @@ int cam_camsstop_setup_regbase_indices(struct cam_hw_soc_info *soc_info,
int cam_camsstop_get_internal_ops(struct cam_cpas_internal_ops *internal_ops)
{
if (!internal_ops) {
- pr_err("invalid NULL param\n");
+ CAM_ERR(CAM_CPAS, "invalid NULL param");
return -EINVAL;
}
diff --git a/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cam_cpastop_hw.c b/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cam_cpastop_hw.c
index b901410..32ef2e4 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cam_cpastop_hw.c
+++ b/drivers/media/platform/msm/camera/cam_cpas/cpas_top/cam_cpastop_hw.c
@@ -38,24 +38,24 @@ static int cam_cpastop_get_hw_info(struct cam_hw_info *cpas_hw,
reg_value = cam_io_r_mb(soc_info->reg_map[reg_indx].mem_base + 0x0);
hw_caps->camera_version.major =
- BITS_MASK_SHIFT(reg_value, 0xff0000, 0x10);
+ CAM_BITS_MASK_SHIFT(reg_value, 0xff0000, 0x10);
hw_caps->camera_version.minor =
- BITS_MASK_SHIFT(reg_value, 0xff00, 0x8);
+ CAM_BITS_MASK_SHIFT(reg_value, 0xff00, 0x8);
hw_caps->camera_version.incr =
- BITS_MASK_SHIFT(reg_value, 0xff, 0x0);
+ CAM_BITS_MASK_SHIFT(reg_value, 0xff, 0x0);
reg_value = cam_io_r_mb(soc_info->reg_map[reg_indx].mem_base + 0x4);
hw_caps->cpas_version.major =
- BITS_MASK_SHIFT(reg_value, 0xf0000000, 0x1c);
+ CAM_BITS_MASK_SHIFT(reg_value, 0xf0000000, 0x1c);
hw_caps->cpas_version.minor =
- BITS_MASK_SHIFT(reg_value, 0xfff0000, 0x10);
+ CAM_BITS_MASK_SHIFT(reg_value, 0xfff0000, 0x10);
hw_caps->cpas_version.incr =
- BITS_MASK_SHIFT(reg_value, 0xffff, 0x0);
+ CAM_BITS_MASK_SHIFT(reg_value, 0xffff, 0x0);
reg_value = cam_io_r_mb(soc_info->reg_map[reg_indx].mem_base + 0x8);
hw_caps->camera_capability = reg_value;
- CPAS_CDBG("Family %d, version %d.%d.%d, cpas %d.%d.%d, cap 0x%x\n",
+ CAM_DBG(CAM_FD, "Family %d, version %d.%d.%d, cpas %d.%d.%d, cap 0x%x",
hw_caps->camera_family, hw_caps->camera_version.major,
hw_caps->camera_version.minor, hw_caps->camera_version.incr,
hw_caps->cpas_version.major, hw_caps->cpas_version.minor,
@@ -71,31 +71,32 @@ static int cam_cpastop_setup_regbase_indices(struct cam_hw_soc_info *soc_info,
int rc;
if (num_reg_map > CAM_CPAS_REG_MAX) {
- pr_err("invalid num_reg_map=%d\n", num_reg_map);
+ CAM_ERR(CAM_CPAS, "invalid num_reg_map=%d", num_reg_map);
return -EINVAL;
}
if (soc_info->num_mem_block > CAM_SOC_MAX_BLOCK) {
- pr_err("invalid num_mem_block=%d\n", soc_info->num_mem_block);
+ CAM_ERR(CAM_CPAS, "invalid num_mem_block=%d",
+ soc_info->num_mem_block);
return -EINVAL;
}
- rc = cam_cpas_util_get_string_index(soc_info->mem_block_name,
+ rc = cam_common_util_get_string_index(soc_info->mem_block_name,
soc_info->num_mem_block, "cam_cpas_top", &index);
if ((rc == 0) && (index < num_reg_map)) {
regbase_index[CAM_CPAS_REG_CPASTOP] = index;
} else {
- pr_err("regbase not found for CPASTOP, rc=%d, %d %d\n",
+ CAM_ERR(CAM_CPAS, "regbase not found for CPASTOP, rc=%d, %d %d",
rc, index, num_reg_map);
return -EINVAL;
}
- rc = cam_cpas_util_get_string_index(soc_info->mem_block_name,
+ rc = cam_common_util_get_string_index(soc_info->mem_block_name,
soc_info->num_mem_block, "cam_camnoc", &index);
if ((rc == 0) && (index < num_reg_map)) {
regbase_index[CAM_CPAS_REG_CAMNOC] = index;
} else {
- pr_err("regbase not found for CAMNOC, rc=%d, %d %d\n",
+ CAM_ERR(CAM_CPAS, "regbase not found for CAMNOC, rc=%d, %d %d",
rc, index, num_reg_map);
return -EINVAL;
}
@@ -124,7 +125,8 @@ static int cam_cpastop_handle_errlogger(struct cam_cpas *cpas_core,
reg_value[3] = cam_io_r_mb(
soc_info->reg_map[camnoc_index].mem_base +
camnoc_info->error_logger[i + 3]);
- pr_err("offset[0x%x] values [0x%x] [0x%x] [0x%x] [0x%x]\n",
+ CAM_ERR(CAM_CPAS,
+ "offset[0x%x] values [0x%x] [0x%x] [0x%x] [0x%x]",
camnoc_info->error_logger[i], reg_value[0],
reg_value[1], reg_value[2], reg_value[3]);
}
@@ -139,7 +141,7 @@ static int cam_cpastop_handle_errlogger(struct cam_cpas *cpas_core,
reg_value[2] = cam_io_r_mb(
soc_info->reg_map[camnoc_index].mem_base +
camnoc_info->error_logger[i + 2]);
- pr_err("offset[0x%x] values [0x%x] [0x%x] [0x%x]\n",
+ CAM_ERR(CAM_CPAS, "offset[0x%x] values [0x%x] [0x%x] [0x%x]",
camnoc_info->error_logger[i], reg_value[0],
reg_value[1], reg_value[2]);
i = i + 3;
@@ -152,7 +154,7 @@ static int cam_cpastop_handle_errlogger(struct cam_cpas *cpas_core,
reg_value[1] = cam_io_r_mb(
soc_info->reg_map[camnoc_index].mem_base +
camnoc_info->error_logger[i + 1]);
- pr_err("offset[0x%x] values [0x%x] [0x%x]\n",
+ CAM_ERR(CAM_CPAS, "offset[0x%x] values [0x%x] [0x%x]",
camnoc_info->error_logger[i], reg_value[0],
reg_value[1]);
i = i + 2;
@@ -162,7 +164,7 @@ static int cam_cpastop_handle_errlogger(struct cam_cpas *cpas_core,
reg_value[0] = cam_io_r_mb(
soc_info->reg_map[camnoc_index].mem_base +
camnoc_info->error_logger[i]);
- pr_err("offset[0x%x] values [0x%x]\n",
+ CAM_ERR(CAM_CPAS, "offset[0x%x] values [0x%x]",
camnoc_info->error_logger[i], reg_value[0]);
}
@@ -178,7 +180,8 @@ static int cam_cpastop_handle_ubwc_err(struct cam_cpas *cpas_core,
reg_value = cam_io_r_mb(soc_info->reg_map[camnoc_index].mem_base +
camnoc_info->irq_err[i].err_status.offset);
- pr_err("Dumping ubwc error status [%d]: offset[0x%x] value[0x%x]\n",
+ CAM_ERR(CAM_CPAS,
+ "Dumping ubwc error status [%d]: offset[0x%x] value[0x%x]",
i, camnoc_info->irq_err[i].err_status.offset, reg_value);
return reg_value;
@@ -186,7 +189,7 @@ static int cam_cpastop_handle_ubwc_err(struct cam_cpas *cpas_core,
static int cam_cpastop_handle_ahb_timeout_err(struct cam_hw_info *cpas_hw)
{
- pr_err("ahb timout error\n");
+ CAM_ERR(CAM_CPAS, "ahb timout error");
return 0;
}
@@ -229,7 +232,8 @@ static void cam_cpastop_notify_clients(struct cam_cpas *cpas_core,
int i;
struct cam_cpas_client *cpas_client;
- CPAS_CDBG("Notify CB : num_clients=%d, registered=%d, started=%d\n",
+ CAM_DBG(CAM_CPAS,
+ "Notify CB : num_clients=%d, registered=%d, started=%d",
cpas_core->num_clients, cpas_core->registered_clients,
cpas_core->streamon_clients);
@@ -237,7 +241,8 @@ static void cam_cpastop_notify_clients(struct cam_cpas *cpas_core,
if (CAM_CPAS_CLIENT_STARTED(cpas_core, i)) {
cpas_client = cpas_core->cpas_client[i];
if (cpas_client->data.cam_cpas_client_cb) {
- CPAS_CDBG("Calling client CB %d : %d 0x%x\n",
+ CAM_DBG(CAM_CPAS,
+ "Calling client CB %d : %d 0x%x",
i, irq_type, irq_data);
cpas_client->data.cam_cpas_client_cb(
cpas_client->data.client_handle,
@@ -261,7 +266,7 @@ static void cam_cpastop_work(struct work_struct *work)
payload = container_of(work, struct cam_cpas_work_payload, work);
if (!payload) {
- pr_err("NULL payload");
+ CAM_ERR(CAM_CPAS, "NULL payload");
return;
}
@@ -273,7 +278,7 @@ static void cam_cpastop_work(struct work_struct *work)
if ((payload->irq_status & camnoc_info->irq_err[i].sbm_port) &&
(camnoc_info->irq_err[i].enable)) {
irq_type = camnoc_info->irq_err[i].irq_type;
- pr_err("Error occurred, type=%d\n", irq_type);
+ CAM_ERR(CAM_CPAS, "Error occurred, type=%d", irq_type);
irq_data = 0;
switch (irq_type) {
@@ -293,10 +298,10 @@ static void cam_cpastop_work(struct work_struct *work)
cpas_hw);
break;
case CAM_CAMNOC_HW_IRQ_CAMNOC_TEST:
- CPAS_CDBG("TEST IRQ\n");
+ CAM_DBG(CAM_CPAS, "TEST IRQ");
break;
default:
- pr_err("Invalid IRQ type\n");
+ CAM_ERR(CAM_CPAS, "Invalid IRQ type");
break;
}
@@ -309,7 +314,7 @@ static void cam_cpastop_work(struct work_struct *work)
}
if (payload->irq_status)
- pr_err("IRQ not handled irq_status=0x%x\n",
+ CAM_ERR(CAM_CPAS, "IRQ not handled irq_status=0x%x",
payload->irq_status);
kfree(payload);
@@ -331,7 +336,7 @@ static irqreturn_t cam_cpastop_handle_irq(int irq_num, void *data)
soc_info->reg_map[camnoc_index].mem_base +
camnoc_info->irq_sbm->sbm_status.offset);
- CPAS_CDBG("IRQ callback, irq_status=0x%x\n", payload->irq_status);
+ CAM_DBG(CAM_CPAS, "IRQ callback, irq_status=0x%x", payload->irq_status);
payload->hw = cpas_hw;
INIT_WORK((struct work_struct *)&payload->work, cam_cpastop_work);
@@ -396,7 +401,8 @@ static int cam_cpastop_poweroff(struct cam_hw_info *cpas_hw)
CAM_CPAS_POLL_RETRY_CNT,
CAM_CPAS_POLL_MIN_USECS, CAM_CPAS_POLL_MAX_USECS);
if (rc) {
- pr_err("camnoc flush slave pending trans failed\n");
+ CAM_ERR(CAM_CPAS,
+ "camnoc flush slave pending trans failed");
/* Do not return error, passthrough */
}
}
@@ -415,14 +421,14 @@ static int cam_cpastop_init_hw_version(struct cam_hw_info *cpas_hw,
(hw_caps->cpas_version.incr == 0)) {
camnoc_info = &cam170_cpas100_camnoc_info;
} else {
- pr_err("CPAS Version not supported %d.%d.%d\n",
+ CAM_ERR(CAM_CPAS, "CPAS Version not supported %d.%d.%d",
hw_caps->cpas_version.major,
hw_caps->cpas_version.minor,
hw_caps->cpas_version.incr);
return -EINVAL;
}
} else {
- pr_err("Camera Version not supported %d.%d.%d\n",
+ CAM_ERR(CAM_CPAS, "Camera Version not supported %d.%d.%d",
hw_caps->camera_version.major,
hw_caps->camera_version.minor,
hw_caps->camera_version.incr);
@@ -435,7 +441,7 @@ static int cam_cpastop_init_hw_version(struct cam_hw_info *cpas_hw,
int cam_cpastop_get_internal_ops(struct cam_cpas_internal_ops *internal_ops)
{
if (!internal_ops) {
- pr_err("invalid NULL param\n");
+ CAM_ERR(CAM_CPAS, "invalid NULL param");
return -EINVAL;
}
diff --git a/drivers/media/platform/msm/camera/cam_cpas/include/cam_cpas_api.h b/drivers/media/platform/msm/camera/cam_cpas/include/cam_cpas_api.h
index 801d09d..3977b68 100644
--- a/drivers/media/platform/msm/camera/cam_cpas/include/cam_cpas_api.h
+++ b/drivers/media/platform/msm/camera/cam_cpas/include/cam_cpas_api.h
@@ -94,7 +94,7 @@ struct cam_cpas_register_params {
struct device *dev;
void *userdata;
void (*cam_cpas_client_cb)(
- int32_t client_handle,
+ uint32_t client_handle,
void *userdata,
enum cam_camnoc_irq_type event_type,
uint32_t event_data);
diff --git a/drivers/media/platform/msm/camera/cam_icp/cam_icp_context.c b/drivers/media/platform/msm/camera/cam_icp/cam_icp_context.c
index 776847d..15bd98c 100644
--- a/drivers/media/platform/msm/camera/cam_icp/cam_icp_context.c
+++ b/drivers/media/platform/msm/camera/cam_icp/cam_icp_context.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CAM-ICP-CTXT %s:%d " fmt, __func__, __LINE__
-
#include <linux/debugfs.h>
#include <linux/videodev2.h>
#include <linux/slab.h>
@@ -26,6 +24,7 @@
#include "cam_req_mgr_util.h"
#include "cam_mem_mgr.h"
#include "cam_trace.h"
+#include "cam_debug_util.h"
static int __cam_icp_acquire_dev_in_available(struct cam_context *ctx,
struct cam_acquire_dev_cmd *cmd)
@@ -48,7 +47,7 @@ static int __cam_icp_release_dev_in_acquired(struct cam_context *ctx,
rc = cam_context_release_dev_to_hw(ctx, cmd);
if (rc)
- pr_err("Unable to release device\n");
+ CAM_ERR(CAM_ICP, "Unable to release device");
ctx->state = CAM_CTX_AVAILABLE;
trace_cam_context_state("ICP", ctx);
@@ -76,7 +75,7 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx,
rc = cam_context_prepare_dev_to_hw(ctx, cmd);
if (rc)
- pr_err("Unable to prepare device\n");
+ CAM_ERR(CAM_ICP, "Failed to prepare device");
return rc;
}
@@ -88,7 +87,7 @@ static int __cam_icp_stop_dev_in_ready(struct cam_context *ctx,
rc = cam_context_stop_dev_to_hw(ctx);
if (rc)
- pr_err("Unable to stop device\n");
+ CAM_ERR(CAM_ICP, "Failed to stop device");
ctx->state = CAM_CTX_ACQUIRED;
trace_cam_context_state("ICP", ctx);
@@ -102,11 +101,11 @@ static int __cam_icp_release_dev_in_ready(struct cam_context *ctx,
rc = __cam_icp_stop_dev_in_ready(ctx, NULL);
if (rc)
- pr_err("Unable to stop device\n");
+ CAM_ERR(CAM_ICP, "Failed to stop device");
rc = __cam_icp_release_dev_in_acquired(ctx, cmd);
if (rc)
- pr_err("Unable to stop device\n");
+ CAM_ERR(CAM_ICP, "Failed to release device");
return rc;
}
@@ -167,7 +166,7 @@ int cam_icp_context_init(struct cam_icp_context *ctx,
int rc;
if ((!ctx) || (!ctx->base) || (!hw_intf)) {
- pr_err("Invalid params: %pK %pK\n", ctx, hw_intf);
+ CAM_ERR(CAM_ICP, "Invalid params: %pK %pK", ctx, hw_intf);
rc = -EINVAL;
goto err;
}
@@ -175,7 +174,7 @@ int cam_icp_context_init(struct cam_icp_context *ctx,
rc = cam_context_init(ctx->base, NULL, hw_intf, ctx->req_base,
CAM_CTX_REQ_MAX);
if (rc) {
- pr_err("Camera Context Base init failed!\n");
+ CAM_ERR(CAM_ICP, "Camera Context Base init failed");
goto err;
}
@@ -190,7 +189,7 @@ int cam_icp_context_init(struct cam_icp_context *ctx,
int cam_icp_context_deinit(struct cam_icp_context *ctx)
{
if ((!ctx) || (!ctx->base)) {
- pr_err("Invalid params: %pK\n", ctx);
+ CAM_ERR(CAM_ICP, "Invalid params: %pK", ctx);
return -EINVAL;
}
diff --git a/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c b/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c
index 69c2e03..bbdff27 100644
--- a/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c
+++ b/drivers/media/platform/msm/camera/cam_icp/cam_icp_subdev.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CAM-ICP %s:%d " fmt, __func__, __LINE__
-
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/of.h>
@@ -36,6 +34,7 @@
#include "cam_icp_context.h"
#include "cam_hw_mgr_intf.h"
#include "cam_icp_hw_mgr_intf.h"
+#include "cam_debug_util.h"
#define CAM_ICP_DEV_NAME "cam-icp"
@@ -65,13 +64,13 @@ static int cam_icp_subdev_open(struct v4l2_subdev *sd,
mutex_lock(&g_icp_dev.icp_lock);
if (g_icp_dev.open_cnt >= 1) {
- pr_err("ICP subdev is already opened\n");
+ CAM_ERR(CAM_ICP, "ICP subdev is already opened");
rc = -EALREADY;
goto end;
}
if (!node) {
- pr_err("Invalid args\n");
+ CAM_ERR(CAM_ICP, "Invalid args");
rc = -EINVAL;
goto end;
}
@@ -79,7 +78,7 @@ static int cam_icp_subdev_open(struct v4l2_subdev *sd,
hw_mgr_intf = &node->hw_mgr_intf;
rc = hw_mgr_intf->download_fw(hw_mgr_intf->hw_mgr_priv, NULL);
if (rc < 0) {
- pr_err("FW download failed\n");
+ CAM_ERR(CAM_ICP, "FW download failed");
goto end;
}
g_icp_dev.open_cnt++;
@@ -97,27 +96,27 @@ static int cam_icp_subdev_close(struct v4l2_subdev *sd,
mutex_lock(&g_icp_dev.icp_lock);
if (g_icp_dev.open_cnt <= 0) {
- pr_err("ICP subdev is already closed\n");
+ CAM_ERR(CAM_ICP, "ICP subdev is already closed");
rc = -EINVAL;
goto end;
}
g_icp_dev.open_cnt--;
if (!node) {
- pr_err("Invalid args\n");
+ CAM_ERR(CAM_ICP, "Invalid args");
rc = -EINVAL;
goto end;
}
hw_mgr_intf = &node->hw_mgr_intf;
if (!hw_mgr_intf) {
- pr_err("hw_mgr_intf is not initialized\n");
+ CAM_ERR(CAM_ICP, "hw_mgr_intf is not initialized");
rc = -EINVAL;
goto end;
}
rc = hw_mgr_intf->hw_close(hw_mgr_intf->hw_mgr_priv, NULL);
if (rc < 0) {
- pr_err("HW close failed\n");
+ CAM_ERR(CAM_ICP, "HW close failed");
goto end;
}
@@ -138,7 +137,7 @@ static int cam_icp_probe(struct platform_device *pdev)
struct cam_hw_mgr_intf *hw_mgr_intf;
if (!pdev) {
- pr_err("pdev is NULL\n");
+ CAM_ERR(CAM_ICP, "pdev is NULL");
return -EINVAL;
}
@@ -147,7 +146,7 @@ static int cam_icp_probe(struct platform_device *pdev)
rc = cam_subdev_probe(&g_icp_dev.sd, pdev, CAM_ICP_DEV_NAME,
CAM_ICP_DEVICE_TYPE);
if (rc) {
- pr_err("ICP cam_subdev_probe failed!\n");
+ CAM_ERR(CAM_ICP, "ICP cam_subdev_probe failed");
goto probe_fail;
}
@@ -161,26 +160,24 @@ static int cam_icp_probe(struct platform_device *pdev)
rc = cam_icp_hw_mgr_init(pdev->dev.of_node, (uint64_t *)hw_mgr_intf);
if (rc) {
- pr_err("ICP HW manager init failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "ICP HW manager init failed: %d", rc);
goto hw_init_fail;
}
- pr_debug("Initializing the ICP contexts\n");
for (i = 0; i < CAM_CTX_MAX; i++) {
g_icp_dev.ctx_icp[i].base = &g_icp_dev.ctx[i];
rc = cam_icp_context_init(&g_icp_dev.ctx_icp[i],
hw_mgr_intf);
if (rc) {
- pr_err("ICP context init failed!\n");
+ CAM_ERR(CAM_ICP, "ICP context init failed");
goto ctx_fail;
}
}
- pr_debug("Initializing the ICP Node\n");
rc = cam_node_init(node, hw_mgr_intf, g_icp_dev.ctx,
CAM_CTX_MAX, CAM_ICP_DEV_NAME);
if (rc) {
- pr_err("ICP node init failed!\n");
+ CAM_ERR(CAM_ICP, "ICP node init failed");
goto ctx_fail;
}
@@ -207,20 +204,20 @@ static int cam_icp_remove(struct platform_device *pdev)
struct cam_subdev *subdev;
if (!pdev) {
- pr_err("pdev is NULL\n");
- return -EINVAL;
+ CAM_ERR(CAM_ICP, "pdev is NULL");
+ return -ENODEV;
}
sd = platform_get_drvdata(pdev);
if (!sd) {
- pr_err("V4l2 subdev is NULL\n");
- return -EINVAL;
+ CAM_ERR(CAM_ICP, "V4l2 subdev is NULL");
+ return -ENODEV;
}
subdev = v4l2_get_subdevdata(sd);
if (!subdev) {
- pr_err("cam subdev is NULL\n");
- return -EINVAL;
+ CAM_ERR(CAM_ICP, "cam subdev is NULL");
+ return -ENODEV;
}
for (i = 0; i < CAM_CTX_MAX; i++)
diff --git a/drivers/media/platform/msm/camera/cam_icp/hfi.c b/drivers/media/platform/msm/camera/cam_icp/hfi.c
index b763a39..48e1f1c 100644
--- a/drivers/media/platform/msm/camera/cam_icp/hfi.c
+++ b/drivers/media/platform/msm/camera/cam_icp/hfi.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "HFI-FW %s:%d " fmt, __func__, __LINE__
-
#include <linux/io.h>
#include <linux/delay.h>
#include <linux/slab.h>
@@ -27,6 +25,7 @@
#include "hfi_session_defs.h"
#include "hfi_intf.h"
#include "cam_icp_hw_mgr_intf.h"
+#include "cam_debug_util.h"
#define HFI_VERSION_INFO_MAJOR_VAL 1
#define HFI_VERSION_INFO_MINOR_VAL 1
@@ -39,11 +38,10 @@
#define HFI_VERSION_INFO_STEP_BMSK 0xFF
#define HFI_VERSION_INFO_STEP_SHFT 0
-#undef HFI_DBG
-#define HFI_DBG(fmt, args...) pr_debug(fmt, ##args)
-
static struct hfi_info *g_hfi;
unsigned int g_icp_mmu_hdl;
+static DEFINE_MUTEX(hfi_cmd_q_mutex);
+static DEFINE_MUTEX(hfi_msg_q_mutex);
int hfi_write_cmd(void *cmd_ptr)
{
@@ -52,23 +50,25 @@ int hfi_write_cmd(void *cmd_ptr)
struct hfi_qtbl *q_tbl;
struct hfi_q_hdr *q;
int rc = 0;
- int i = 0;
if (!cmd_ptr) {
- pr_err("Invalid args\n");
+ CAM_ERR(CAM_HFI, "command is null");
return -EINVAL;
}
- if (!g_hfi || (g_hfi->hfi_state != HFI_READY)) {
- pr_err("HFI interface not ready yet\n");
- return -EIO;
+ mutex_lock(&hfi_cmd_q_mutex);
+ if (!g_hfi) {
+ CAM_ERR(CAM_HFI, "HFI interface not setup");
+ rc = -ENODEV;
+ goto err;
}
- mutex_lock(&g_hfi->cmd_q_lock);
- if (!g_hfi->cmd_q_state) {
- pr_err("HFI command interface not ready yet\n");
- mutex_unlock(&g_hfi->cmd_q_lock);
- return -EIO;
+ if (g_hfi->hfi_state != HFI_READY ||
+ !g_hfi->cmd_q_state) {
+ CAM_ERR(CAM_HFI, "HFI state: %u, cmd q state: %u",
+ g_hfi->hfi_state, g_hfi->cmd_q_state);
+ rc = -ENODEV;
+ goto err;
}
q_tbl = (struct hfi_qtbl *)g_hfi->map.qtbl.kva;
@@ -78,24 +78,20 @@ int hfi_write_cmd(void *cmd_ptr)
size_in_words = (*(uint32_t *)cmd_ptr) >> BYTE_WORD_SHIFT;
if (!size_in_words) {
- pr_debug("failed");
+ CAM_DBG(CAM_HFI, "failed");
rc = -EINVAL;
goto err;
}
- HFI_DBG("size_in_words : %u, q->qhdr_write_idx %x\n", size_in_words,
- q->qhdr_write_idx);
-
read_idx = q->qhdr_read_idx;
empty_space = (q->qhdr_write_idx >= read_idx) ?
(q->qhdr_q_size - (q->qhdr_write_idx - read_idx)) :
(read_idx - q->qhdr_write_idx);
if (empty_space <= size_in_words) {
- pr_err("failed");
+ CAM_ERR(CAM_HFI, "failed");
rc = -EIO;
goto err;
}
- HFI_DBG("empty_space : %u\n", empty_space);
new_write_idx = q->qhdr_write_idx + size_in_words;
write_ptr = (uint32_t *)(write_q + q->qhdr_write_idx);
@@ -110,15 +106,12 @@ int hfi_write_cmd(void *cmd_ptr)
memcpy(write_q, (uint8_t *)cmd_ptr + temp,
new_write_idx << BYTE_WORD_SHIFT);
}
- for (i = 0; i < size_in_words; i++)
- pr_debug("%x\n", write_ptr[i]);
q->qhdr_write_idx = new_write_idx;
- HFI_DBG("q->qhdr_write_idx %x\n", q->qhdr_write_idx);
cam_io_w((uint32_t)INTR_ENABLE,
g_hfi->csr_base + HFI_REG_A5_CSR_HOST2ICPINT);
err:
- mutex_unlock(&g_hfi->cmd_q_lock);
+ mutex_unlock(&hfi_cmd_q_mutex);
return rc;
}
@@ -129,32 +122,40 @@ int hfi_read_message(uint32_t *pmsg, uint8_t q_id)
uint32_t new_read_idx, size_in_words, temp;
uint32_t *read_q, *read_ptr;
int rc = 0;
- int i = 0;
- if (!pmsg || q_id > Q_DBG) {
- pr_err("Inavlid args\n");
+ if (!pmsg) {
+ CAM_ERR(CAM_HFI, "Invalid msg");
return -EINVAL;
}
- if (!g_hfi || (g_hfi->hfi_state != HFI_READY)) {
- pr_err("HFI interface not ready yet\n");
- return -EIO;
+ if (q_id > Q_DBG) {
+ CAM_ERR(CAM_HFI, "Inavlid q :%u", q_id);
+ return -EINVAL;
+ }
+
+ mutex_lock(&hfi_msg_q_mutex);
+ if (!g_hfi) {
+ CAM_ERR(CAM_HFI, "hfi not set up yet");
+ rc = -ENODEV;
+ goto err;
+ }
+
+ if ((g_hfi->hfi_state != HFI_READY) ||
+ !g_hfi->msg_q_state) {
+ CAM_ERR(CAM_HFI, "hfi state: %u, msg q state: %u",
+ g_hfi->hfi_state, g_hfi->msg_q_state);
+ rc = -ENODEV;
+ goto err;
}
q_tbl_ptr = (struct hfi_qtbl *)g_hfi->map.qtbl.kva;
q = &q_tbl_ptr->q_hdr[q_id];
if (q->qhdr_read_idx == q->qhdr_write_idx) {
- pr_debug("FW or Q not ready, hfi state : %u, r idx : %u, w idx : %u\n",
+ CAM_DBG(CAM_HFI, "Q not ready, state:%u, r idx:%u, w idx:%u",
g_hfi->hfi_state, q->qhdr_read_idx, q->qhdr_write_idx);
- return -EIO;
- }
-
- mutex_lock(&g_hfi->msg_q_lock);
- if (!g_hfi->msg_q_state) {
- pr_err("HFI message interface not ready yet\n");
- mutex_unlock(&g_hfi->msg_q_lock);
- return -EIO;
+ rc = -EIO;
+ goto err;
}
if (q_id == Q_MSG)
@@ -165,12 +166,9 @@ int hfi_read_message(uint32_t *pmsg, uint8_t q_id)
read_ptr = (uint32_t *)(read_q + q->qhdr_read_idx);
size_in_words = (*read_ptr) >> BYTE_WORD_SHIFT;
- HFI_DBG("size_in_words : %u, read_ptr : %pK\n", size_in_words,
- (void *)read_ptr);
-
if ((size_in_words == 0) ||
(size_in_words > ICP_HFI_MAX_MSG_SIZE_IN_WORDS)) {
- pr_err("invalid HFI message packet size - 0x%08x\n",
+ CAM_ERR(CAM_HFI, "invalid HFI message packet size - 0x%08x",
size_in_words << BYTE_WORD_SHIFT);
q->qhdr_read_idx = q->qhdr_write_idx;
rc = -EIO;
@@ -178,7 +176,6 @@ int hfi_read_message(uint32_t *pmsg, uint8_t q_id)
}
new_read_idx = q->qhdr_read_idx + size_in_words;
- HFI_DBG("new_read_idx : %u\n", new_read_idx);
if (new_read_idx < q->qhdr_q_size) {
memcpy(pmsg, read_ptr, size_in_words << BYTE_WORD_SHIFT);
@@ -190,12 +187,9 @@ int hfi_read_message(uint32_t *pmsg, uint8_t q_id)
new_read_idx << BYTE_WORD_SHIFT);
}
- for (i = 0; i < size_in_words; i++)
- HFI_DBG("%x\n", read_ptr[i]);
-
q->qhdr_read_idx = new_read_idx;
err:
- mutex_unlock(&g_hfi->msg_q_lock);
+ mutex_unlock(&hfi_msg_q_mutex);
return rc;
}
@@ -265,7 +259,7 @@ void hfi_send_system_cmd(uint32_t type, uint64_t data, uint32_t size)
case HFI_CMD_IPEBPS_ASYNC_COMMAND_INDIRECT:
break;
default:
- pr_err("command not supported :%d\n", type);
+ CAM_ERR(CAM_HFI, "command not supported :%d", type);
break;
}
}
@@ -277,7 +271,7 @@ int hfi_get_hw_caps(void *query_buf)
struct cam_icp_query_cap_cmd *query_cmd = NULL;
if (!query_buf) {
- pr_err("%s: query buf is NULL\n", __func__);
+ CAM_ERR(CAM_HFI, "query buf is NULL");
return -EINVAL;
}
@@ -332,6 +326,9 @@ int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
struct hfi_q_hdr *cmd_q_hdr, *msg_q_hdr, *dbg_q_hdr;
uint32_t hw_version, fw_version, status = 0;
+ mutex_lock(&hfi_cmd_q_mutex);
+ mutex_lock(&hfi_msg_q_mutex);
+
if (!g_hfi) {
g_hfi = kzalloc(sizeof(struct hfi_info), GFP_KERNEL);
if (!g_hfi) {
@@ -340,13 +337,13 @@ int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
}
}
- HFI_DBG("g_hfi: %pK\n", (void *)g_hfi);
if (g_hfi->hfi_state != HFI_DEINIT) {
- pr_err("hfi_init: invalid state\n");
+ CAM_ERR(CAM_HFI, "hfi_init: invalid state");
return -EINVAL;
}
memcpy(&g_hfi->map, hfi_mem, sizeof(g_hfi->map));
+ g_hfi->hfi_state = HFI_DEINIT;
if (debug) {
cam_io_w_mb(
@@ -373,7 +370,6 @@ int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
qtbl_hdr->qtbl_num_active_q = ICP_HFI_NUMBER_OF_QS;
/* setup host-to-firmware command queue */
- pr_debug("updating the command queue info\n");
cmd_q_hdr = &qtbl->q_hdr[Q_CMD];
cmd_q_hdr->qhdr_status = QHDR_ACTIVE;
cmd_q_hdr->qhdr_start_addr = hfi_mem->cmd_q.iova;
@@ -384,7 +380,6 @@ int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
cmd_q_hdr->qhdr_write_idx = RESET;
/* setup firmware-to-Host message queue */
- pr_debug("updating the message queue info\n");
msg_q_hdr = &qtbl->q_hdr[Q_MSG];
msg_q_hdr->qhdr_status = QHDR_ACTIVE;
msg_q_hdr->qhdr_start_addr = hfi_mem->msg_q.iova;
@@ -395,7 +390,6 @@ int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
msg_q_hdr->qhdr_write_idx = RESET;
/* setup firmware-to-Host message queue */
- pr_debug("updating the debug queue info\n");
dbg_q_hdr = &qtbl->q_hdr[Q_DBG];
dbg_q_hdr->qhdr_status = QHDR_ACTIVE;
dbg_q_hdr->qhdr_start_addr = hfi_mem->dbg_q.iova;
@@ -404,7 +398,6 @@ int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
dbg_q_hdr->qhdr_pkt_drop_cnt = RESET;
dbg_q_hdr->qhdr_read_idx = RESET;
dbg_q_hdr->qhdr_write_idx = RESET;
- pr_debug("Done updating the debug queue info\n");
switch (event_driven_mode) {
case INTR_MODE:
@@ -473,7 +466,8 @@ int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
break;
default:
- pr_err("Invalid event driven mode :%u", event_driven_mode);
+ CAM_ERR(CAM_HFI, "Invalid event driven mode :%u",
+ event_driven_mode);
break;
}
@@ -490,56 +484,58 @@ int cam_hfi_init(uint8_t event_driven_mode, struct hfi_mem_info *hfi_mem,
icp_base + HFI_REG_HOST_ICP_INIT_REQUEST);
hw_version = cam_io_r(icp_base + HFI_REG_A5_HW_VERSION);
- HFI_DBG("hw version : [%x]\n", hw_version);
rc = readw_poll_timeout((icp_base + HFI_REG_ICP_HOST_INIT_RESPONSE),
status, status != ICP_INIT_RESP_SUCCESS, 15, 200);
if (rc) {
- pr_err("timed out , status = %u\n", status);
+ CAM_ERR(CAM_HFI, "timed out , status = %u", status);
goto regions_fail;
}
fw_version = cam_io_r(icp_base + HFI_REG_FW_VERSION);
- HFI_DBG("fw version : %u[%x]\n", fw_version, fw_version);
+ CAM_DBG(CAM_HFI, "hw version : : [%x], fw version : [%x]",
+ hw_version, fw_version);
g_hfi->csr_base = icp_base;
g_hfi->hfi_state = HFI_READY;
g_hfi->cmd_q_state = true;
g_hfi->msg_q_state = true;
- mutex_init(&g_hfi->cmd_q_lock);
- mutex_init(&g_hfi->msg_q_lock);
cam_io_w((uint32_t)INTR_ENABLE, icp_base + HFI_REG_A5_CSR_A2HOSTINTEN);
+ mutex_unlock(&hfi_cmd_q_mutex);
+ mutex_unlock(&hfi_msg_q_mutex);
+
return rc;
regions_fail:
kfree(g_hfi);
alloc_fail:
+ mutex_unlock(&hfi_cmd_q_mutex);
+ mutex_unlock(&hfi_msg_q_mutex);
return rc;
}
void cam_hfi_deinit(void)
{
+ mutex_lock(&hfi_cmd_q_mutex);
+ mutex_lock(&hfi_msg_q_mutex);
+
if (!g_hfi) {
- pr_err("hfi path not established yet\n");
- return;
+ CAM_ERR(CAM_HFI, "hfi path not established yet");
+ goto err;
}
+
+ g_hfi->cmd_q_state = false;
+ g_hfi->msg_q_state = false;
+
cam_io_w((uint32_t)INTR_DISABLE,
g_hfi->csr_base + HFI_REG_A5_CSR_A2HOSTINTEN);
-
- mutex_lock(&g_hfi->cmd_q_lock);
- g_hfi->cmd_q_state = false;
- mutex_unlock(&g_hfi->cmd_q_lock);
-
- mutex_lock(&g_hfi->msg_q_lock);
- g_hfi->msg_q_state = false;
- mutex_unlock(&g_hfi->msg_q_lock);
-
- mutex_destroy(&g_hfi->cmd_q_lock);
- mutex_destroy(&g_hfi->msg_q_lock);
-
- kfree(g_hfi);
+ kzfree(g_hfi);
g_hfi = NULL;
+
+err:
+ mutex_unlock(&hfi_cmd_q_mutex);
+ mutex_unlock(&hfi_msg_q_mutex);
}
void icp_enable_fw_debug(void)
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_core.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_core.c
index 9f6f940..e200f6f 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_core.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_core.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "A5-CORE %s:%d " fmt, __func__, __LINE__
-
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/debugfs.h>
@@ -35,6 +33,7 @@
#include "hfi_sys_defs.h"
#include "cam_icp_hw_mgr_intf.h"
#include "cam_cpas_api.h"
+#include "cam_debug_util.h"
static int cam_a5_cpas_vote(struct cam_a5_device_core_info *core_info,
struct cam_icp_cpas_vote *cpas_vote)
@@ -50,7 +49,7 @@ static int cam_a5_cpas_vote(struct cam_a5_device_core_info *core_info,
&cpas_vote->axi_vote);
if (rc)
- pr_err("cpas vote is failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "cpas vote is failed: %d", rc);
return rc;
}
@@ -60,26 +59,26 @@ static int32_t cam_icp_validate_fw(const uint8_t *elf)
struct elf32_hdr *elf_hdr;
if (!elf) {
- pr_err("Invalid params\n");
+ CAM_ERR(CAM_ICP, "Invalid params");
return -EINVAL;
}
elf_hdr = (struct elf32_hdr *)elf;
if (memcmp(elf_hdr->e_ident, ELFMAG, SELFMAG)) {
- pr_err("ICP elf identifier is failed\n");
+ CAM_ERR(CAM_ICP, "ICP elf identifier is failed");
return -EINVAL;
}
/* check architecture */
if (elf_hdr->e_machine != EM_ARM) {
- pr_err("unsupported arch\n");
+ CAM_ERR(CAM_ICP, "unsupported arch");
return -EINVAL;
}
/* check elf bit format */
if (elf_hdr->e_ident[EI_CLASS] != ELFCLASS32) {
- pr_err("elf doesn't support 32 bit format\n");
+ CAM_ERR(CAM_ICP, "elf doesn't support 32 bit format");
return -EINVAL;
}
@@ -97,7 +96,7 @@ static int32_t cam_icp_get_fw_size(const uint8_t *elf, uint32_t *fw_size)
struct elf32_phdr *prg_hdr;
if (!elf || !fw_size) {
- pr_err("invalid args\n");
+ CAM_ERR(CAM_ICP, "invalid args");
return -EINVAL;
}
@@ -109,11 +108,11 @@ static int32_t cam_icp_get_fw_size(const uint8_t *elf, uint32_t *fw_size)
prg_hdr = (struct elf32_phdr *)&icp_prg_hdr_tbl[0];
if (!prg_hdr) {
- pr_err("failed to get elf program header attr\n");
+ CAM_ERR(CAM_ICP, "failed to get elf program header attr");
return -EINVAL;
}
- pr_debug("num_prg_hdrs = %d\n", num_prg_hdrs);
+ CAM_DBG(CAM_ICP, "num_prg_hdrs = %d", num_prg_hdrs);
for (i = 0; i < num_prg_hdrs; i++, prg_hdr++) {
if (prg_hdr->p_flags == 0)
continue;
@@ -121,7 +120,7 @@ static int32_t cam_icp_get_fw_size(const uint8_t *elf, uint32_t *fw_size)
seg_mem_size = (prg_hdr->p_memsz + prg_hdr->p_align - 1) &
~(prg_hdr->p_align - 1);
seg_mem_size += prg_hdr->p_vaddr;
- pr_debug("p_memsz = %x p_align = %x p_vaddr = %x seg_mem_size = %x\n",
+ CAM_DBG(CAM_ICP, "memsz:%x align:%x addr:%x seg_mem_size:%x",
(int)prg_hdr->p_memsz, (int)prg_hdr->p_align,
(int)prg_hdr->p_vaddr, (int)seg_mem_size);
if (*fw_size < seg_mem_size)
@@ -130,7 +129,7 @@ static int32_t cam_icp_get_fw_size(const uint8_t *elf, uint32_t *fw_size)
}
if (*fw_size == 0) {
- pr_err("invalid elf fw file\n");
+ CAM_ERR(CAM_ICP, "invalid elf fw file");
return -EINVAL;
}
@@ -155,7 +154,7 @@ static int32_t cam_icp_program_fw(const uint8_t *elf,
prg_hdr = (struct elf32_phdr *)&icp_prg_hdr_tbl[0];
if (!prg_hdr) {
- pr_err("failed to get elf program header attr\n");
+ CAM_ERR(CAM_ICP, "failed to get elf program header attr");
return -EINVAL;
}
@@ -163,15 +162,14 @@ static int32_t cam_icp_program_fw(const uint8_t *elf,
if (prg_hdr->p_flags == 0)
continue;
- pr_debug("Loading FW header size: %u\n", prg_hdr->p_filesz);
+ CAM_DBG(CAM_ICP, "Loading FW header size: %u",
+ prg_hdr->p_filesz);
if (prg_hdr->p_filesz != 0) {
src = (u8 *)((u8 *)elf + prg_hdr->p_offset);
dest = (u8 *)(((u8 *)core_info->fw_kva_addr) +
prg_hdr->p_vaddr);
memcpy_toio(dest, src, prg_hdr->p_filesz);
- pr_debug("fw kva: %pK, p_vaddr: 0x%x\n",
- dest, prg_hdr->p_vaddr);
}
}
@@ -191,7 +189,7 @@ static int32_t cam_a5_download_fw(void *device_priv)
struct a5_soc_info *cam_a5_soc_info = NULL;
if (!device_priv) {
- pr_err("Invalid cam_dev_info\n");
+ CAM_ERR(CAM_ICP, "Invalid cam_dev_info");
return -EINVAL;
}
@@ -202,44 +200,38 @@ static int32_t cam_a5_download_fw(void *device_priv)
cam_a5_soc_info = soc_info->soc_private;
rc = request_firmware(&core_info->fw_elf, "CAMERA_ICP.elf", &pdev->dev);
- pr_debug("request_firmware: %d\n", rc);
- if (rc < 0) {
- pr_err("Failed to locate fw\n");
+ if (rc) {
+ CAM_ERR(CAM_ICP, "Failed to locate fw: %d", rc);
return rc;
}
if (!core_info->fw_elf) {
- pr_err("request_firmware is failed\n");
+ CAM_ERR(CAM_ICP, "Invalid elf size");
return -EINVAL;
}
fw_start = core_info->fw_elf->data;
rc = cam_icp_validate_fw(fw_start);
- if (rc < 0) {
- pr_err("fw elf validation failed\n");
+ if (rc) {
+ CAM_ERR(CAM_ICP, "fw elf validation failed");
return -EINVAL;
}
rc = cam_icp_get_fw_size(fw_start, &fw_size);
- if (rc < 0) {
- pr_err("unable to get fw file size\n");
+ if (rc) {
+ CAM_ERR(CAM_ICP, "unable to get fw size");
return rc;
}
- pr_debug("cam_icp_get_fw_size: %u\n", fw_size);
-
- /* Check FW firmware memory allocation is OK or not */
- pr_debug("cam_icp_get_fw_size: %u %llu\n",
- fw_size, core_info->fw_buf_len);
if (core_info->fw_buf_len < fw_size) {
- pr_err("fw allocation failed\n");
+ CAM_ERR(CAM_ICP, "mismatch in fw size: %u %llu",
+ fw_size, core_info->fw_buf_len);
goto fw_alloc_failed;
}
- /* download fw */
rc = cam_icp_program_fw(fw_start, core_info);
- if (rc < 0) {
- pr_err("fw program is failed\n");
+ if (rc) {
+ CAM_ERR(CAM_ICP, "fw program is failed");
goto fw_program_failed;
}
@@ -259,7 +251,7 @@ int cam_a5_init_hw(void *device_priv,
int rc = 0;
if (!device_priv) {
- pr_err("Invalid cam_dev_info\n");
+ CAM_ERR(CAM_ICP, "Invalid cam_dev_info");
return -EINVAL;
}
@@ -267,7 +259,8 @@ int cam_a5_init_hw(void *device_priv,
core_info = (struct cam_a5_device_core_info *)a5_dev->core_info;
if ((!soc_info) || (!core_info)) {
- pr_err("soc_info = %pK core_info = %pK\n", soc_info, core_info);
+ CAM_ERR(CAM_ICP, "soc_info: %pK core_info: %pK",
+ soc_info, core_info);
return -EINVAL;
}
@@ -279,16 +272,16 @@ int cam_a5_init_hw(void *device_priv,
rc = cam_cpas_start(core_info->cpas_handle,
&cpas_vote.ahb_vote, &cpas_vote.axi_vote);
if (rc) {
- pr_err("cpass start failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "cpass start failed: %d", rc);
return rc;
}
core_info->cpas_start = true;
rc = cam_a5_enable_soc_resources(soc_info);
if (rc) {
- pr_err("soc enable is failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "soc enable is failed: %d", rc);
if (cam_cpas_stop(core_info->cpas_handle))
- pr_err("cpas stop is failed\n");
+ CAM_ERR(CAM_ICP, "cpas stop is failed");
else
core_info->cpas_start = false;
}
@@ -305,24 +298,25 @@ int cam_a5_deinit_hw(void *device_priv,
int rc = 0;
if (!device_priv) {
- pr_err("Invalid cam_dev_info\n");
+ CAM_ERR(CAM_ICP, "Invalid cam_dev_info");
return -EINVAL;
}
soc_info = &a5_dev->soc_info;
core_info = (struct cam_a5_device_core_info *)a5_dev->core_info;
if ((!soc_info) || (!core_info)) {
- pr_err("soc_info = %pK core_info = %pK\n", soc_info, core_info);
+ CAM_ERR(CAM_ICP, "soc_info = %pK core_info = %pK",
+ soc_info, core_info);
return -EINVAL;
}
rc = cam_a5_disable_soc_resources(soc_info);
if (rc)
- pr_err("soc disable is failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "soc disable is failed: %d", rc);
if (core_info->cpas_start) {
if (cam_cpas_stop(core_info->cpas_handle))
- pr_err("cpas stop is failed\n");
+ CAM_ERR(CAM_ICP, "cpas stop is failed");
else
core_info->cpas_start = false;
}
@@ -339,7 +333,7 @@ irqreturn_t cam_a5_irq(int irq_num, void *data)
uint32_t irq_status = 0;
if (!data) {
- pr_err("Invalid cam_dev_info or query_cap args\n");
+ CAM_ERR(CAM_ICP, "Invalid cam_dev_info or query_cap args");
return IRQ_HANDLED;
}
@@ -354,18 +348,15 @@ irqreturn_t cam_a5_irq(int irq_num, void *data)
soc_info->reg_map[A5_SIERRA_BASE].mem_base +
core_info->a5_hw_info->a5_host_int_clr);
- pr_debug("irq_status = %x\n", irq_status);
- if (irq_status & A5_HOST_INT)
- pr_debug("A5 to Host interrupt, read msg Q\n");
-
if ((irq_status & A5_WDT_0) ||
(irq_status & A5_WDT_1)) {
- pr_err_ratelimited("watch dog interrupt from A5\n");
+ CAM_ERR_RATE_LIMIT(CAM_ICP, "watch dog interrupt from A5");
}
if (core_info->irq_cb.icp_hw_mgr_cb)
core_info->irq_cb.icp_hw_mgr_cb(irq_status,
core_info->irq_cb.data);
+
return IRQ_HANDLED;
}
@@ -379,12 +370,12 @@ int cam_a5_process_cmd(void *device_priv, uint32_t cmd_type,
int rc = 0;
if (!device_priv) {
- pr_err("Invalid arguments\n");
+ CAM_ERR(CAM_ICP, "Invalid arguments");
return -EINVAL;
}
if (cmd_type >= CAM_ICP_A5_CMD_MAX) {
- pr_err("Invalid command : %x\n", cmd_type);
+ CAM_ERR(CAM_ICP, "Invalid command : %x", cmd_type);
return -EINVAL;
}
@@ -401,7 +392,7 @@ int cam_a5_process_cmd(void *device_priv, uint32_t cmd_type,
struct cam_icp_a5_set_fw_buf_info *fw_buf_info = cmd_args;
if (!cmd_args) {
- pr_err("cmd args NULL\n");
+ CAM_ERR(CAM_ICP, "cmd args NULL");
return -EINVAL;
}
@@ -409,15 +400,16 @@ int cam_a5_process_cmd(void *device_priv, uint32_t cmd_type,
core_info->fw_kva_addr = fw_buf_info->kva;
core_info->fw_buf_len = fw_buf_info->len;
- pr_debug("fw buf info = %x %llx %lld\n", core_info->fw_buf,
- core_info->fw_kva_addr, core_info->fw_buf_len);
+ CAM_DBG(CAM_ICP, "fw buf info = %x %llx %lld",
+ core_info->fw_buf, core_info->fw_kva_addr,
+ core_info->fw_buf_len);
break;
}
case CAM_ICP_A5_SET_IRQ_CB: {
struct cam_icp_a5_set_irq_cb *irq_cb = cmd_args;
if (!cmd_args) {
- pr_err("cmd args NULL\n");
+ CAM_ERR(CAM_ICP, "cmd args NULL");
return -EINVAL;
}
@@ -433,7 +425,7 @@ int cam_a5_process_cmd(void *device_priv, uint32_t cmd_type,
struct cam_icp_cpas_vote *cpas_vote = cmd_args;
if (!cmd_args) {
- pr_err("cmd args NULL\n");
+ CAM_ERR(CAM_ICP, "cmd args NULL");
return -EINVAL;
}
@@ -445,7 +437,7 @@ int cam_a5_process_cmd(void *device_priv, uint32_t cmd_type,
struct cam_icp_cpas_vote *cpas_vote = cmd_args;
if (!cmd_args) {
- pr_err("cmd args NULL\n");
+ CAM_ERR(CAM_ICP, "cmd args NULL");
return -EINVAL;
}
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_dev.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_dev.c
index f649c3b..08b934e 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_dev.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_dev.c
@@ -23,6 +23,7 @@
#include "cam_a5_hw_intf.h"
#include "cam_icp_hw_mgr_intf.h"
#include "cam_cpas_api.h"
+#include "cam_debug_util.h"
struct a5_soc_info cam_a5_soc_info;
EXPORT_SYMBOL(cam_a5_soc_info);
@@ -64,7 +65,7 @@ int cam_a5_register_cpas(struct cam_hw_soc_info *soc_info,
rc = cam_cpas_register_client(&cpas_register_params);
if (rc < 0) {
- pr_err("cam_cpas_register_client is failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "failed: %d", rc);
return rc;
}
@@ -101,7 +102,7 @@ int cam_a5_probe(struct platform_device *pdev)
a5_dev_intf->hw_ops.process_cmd = cam_a5_process_cmd;
a5_dev_intf->hw_type = CAM_ICP_DEV_A5;
- pr_debug("%s: type %d index %d\n", __func__,
+ CAM_DBG(CAM_ICP, "type %d index %d",
a5_dev_intf->hw_type,
a5_dev_intf->hw_idx);
@@ -118,9 +119,9 @@ int cam_a5_probe(struct platform_device *pdev)
match_dev = of_match_device(pdev->dev.driver->of_match_table,
&pdev->dev);
if (!match_dev) {
- pr_err("%s: No a5 hardware info\n", __func__);
+ CAM_ERR(CAM_ICP, "No a5 hardware info");
rc = -EINVAL;
- goto pr_err;
+ goto match_err;
}
hw_info = (struct cam_a5_device_hw_info *)match_dev->data;
core_info->a5_hw_info = hw_info;
@@ -130,16 +131,16 @@ int cam_a5_probe(struct platform_device *pdev)
rc = cam_a5_init_soc_resources(&a5_dev->soc_info, cam_a5_irq,
a5_dev);
if (rc < 0) {
- pr_err("%s: failed to init_soc\n", __func__);
+ CAM_ERR(CAM_ICP, "failed to init_soc");
goto init_soc_failure;
}
- pr_debug("cam_a5_init_soc_resources : %pK\n",
+ CAM_DBG(CAM_ICP, "soc info : %pK",
(void *)&a5_dev->soc_info);
rc = cam_a5_register_cpas(&a5_dev->soc_info,
core_info, a5_dev_intf->hw_idx);
if (rc < 0) {
- pr_err("a5 cpas registration failed\n");
+ CAM_ERR(CAM_ICP, "a5 cpas registration failed");
goto cpas_reg_failed;
}
a5_dev->hw_state = CAM_HW_STATE_POWER_DOWN;
@@ -147,13 +148,13 @@ int cam_a5_probe(struct platform_device *pdev)
spin_lock_init(&a5_dev->hw_lock);
init_completion(&a5_dev->hw_complete);
- pr_debug("%s: A5%d probe successful\n", __func__,
+ CAM_DBG(CAM_ICP, "A5%d probe successful",
a5_dev_intf->hw_idx);
return 0;
cpas_reg_failed:
init_soc_failure:
-pr_err:
+match_err:
kfree(a5_dev->core_info);
core_info_alloc_failure:
kfree(a5_dev);
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_soc.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_soc.c
index a98f01f..f252931 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_soc.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/a5_hw/a5_soc.c
@@ -18,9 +18,7 @@
#include <media/cam_icp.h>
#include "a5_soc.h"
#include "cam_soc_util.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
static int cam_a5_get_dt_properties(struct cam_hw_soc_info *soc_info)
{
@@ -35,7 +33,7 @@ static int cam_a5_get_dt_properties(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_get_dt_properties(soc_info);
if (rc < 0) {
- pr_err("%s: get a5 dt prop is failed\n", __func__);
+ CAM_ERR(CAM_ICP, "get a5 dt prop is failed");
return rc;
}
@@ -44,7 +42,7 @@ static int cam_a5_get_dt_properties(struct cam_hw_soc_info *soc_info)
rc = of_property_read_string(of_node, "fw_name", &fw_name);
if (rc < 0)
- pr_err("%s: fw_name read failed\n", __func__);
+ CAM_ERR(CAM_ICP, "fw_name read failed");
return rc;
}
@@ -85,7 +83,7 @@ int cam_a5_enable_soc_resources(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_enable_platform_resource(soc_info, true,
CAM_TURBO_VOTE, true);
if (rc)
- pr_err("%s: enable platform failed\n", __func__);
+ CAM_ERR(CAM_ICP, "enable platform failed");
return rc;
}
@@ -96,7 +94,7 @@ int cam_a5_disable_soc_resources(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
if (rc)
- pr_err("%s: disable platform failed\n", __func__);
+ CAM_ERR(CAM_ICP, "disable platform failed");
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c
index cabdc8a..557eaf1 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_core.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "BPS-CORE %s:%d " fmt, __func__, __LINE__
-
#include <linux/of.h>
#include <linux/debugfs.h>
#include <linux/videodev2.h>
@@ -31,6 +29,7 @@
#include "cam_icp_hw_intf.h"
#include "cam_icp_hw_mgr_intf.h"
#include "cam_cpas_api.h"
+#include "cam_debug_util.h"
static int cam_bps_cpas_vote(struct cam_bps_device_core_info *core_info,
struct cam_icp_cpas_vote *cpas_vote)
@@ -45,7 +44,7 @@ static int cam_bps_cpas_vote(struct cam_bps_device_core_info *core_info,
&cpas_vote->axi_vote);
if (rc < 0)
- pr_err("cpas vote is failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "cpas vote is failed: %d", rc);
return rc;
}
@@ -61,7 +60,7 @@ int cam_bps_init_hw(void *device_priv,
int rc = 0;
if (!device_priv) {
- pr_err("Invalid cam_dev_info\n");
+ CAM_ERR(CAM_ICP, "Invalid cam_dev_info");
return -EINVAL;
}
@@ -69,7 +68,8 @@ int cam_bps_init_hw(void *device_priv,
core_info = (struct cam_bps_device_core_info *)bps_dev->core_info;
if ((!soc_info) || (!core_info)) {
- pr_err("soc_info = %pK core_info = %pK\n", soc_info, core_info);
+ CAM_ERR(CAM_ICP, "soc_info = %pK core_info = %pK",
+ soc_info, core_info);
return -EINVAL;
}
@@ -81,16 +81,16 @@ int cam_bps_init_hw(void *device_priv,
rc = cam_cpas_start(core_info->cpas_handle,
&cpas_vote.ahb_vote, &cpas_vote.axi_vote);
if (rc) {
- pr_err("cpass start failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "cpass start failed: %d", rc);
return rc;
}
core_info->cpas_start = true;
rc = cam_bps_enable_soc_resources(soc_info);
if (rc) {
- pr_err("soc enable is failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "soc enable is failed: %d", rc);
if (cam_cpas_stop(core_info->cpas_handle))
- pr_err("cpas stop is failed\n");
+ CAM_ERR(CAM_ICP, "cpas stop is failed");
else
core_info->cpas_start = false;
}
@@ -107,24 +107,25 @@ int cam_bps_deinit_hw(void *device_priv,
int rc = 0;
if (!device_priv) {
- pr_err("Invalid cam_dev_info\n");
+ CAM_ERR(CAM_ICP, "Invalid cam_dev_info");
return -EINVAL;
}
soc_info = &bps_dev->soc_info;
core_info = (struct cam_bps_device_core_info *)bps_dev->core_info;
if ((!soc_info) || (!core_info)) {
- pr_err("soc_info = %pK core_info = %pK\n", soc_info, core_info);
+ CAM_ERR(CAM_ICP, "soc_info = %pK core_info = %pK",
+ soc_info, core_info);
return -EINVAL;
}
rc = cam_bps_disable_soc_resources(soc_info);
if (rc)
- pr_err("soc disable is failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "soc disable is failed: %d", rc);
if (core_info->cpas_start) {
if (cam_cpas_stop(core_info->cpas_handle))
- pr_err("cpas stop is failed\n");
+ CAM_ERR(CAM_ICP, "cpas stop is failed");
else
core_info->cpas_start = false;
}
@@ -142,12 +143,12 @@ int cam_bps_process_cmd(void *device_priv, uint32_t cmd_type,
int rc = 0;
if (!device_priv) {
- pr_err("Invalid arguments\n");
+ CAM_ERR(CAM_ICP, "Invalid arguments");
return -EINVAL;
}
if (cmd_type >= CAM_ICP_BPS_CMD_MAX) {
- pr_err("Invalid command : %x\n", cmd_type);
+ CAM_ERR(CAM_ICP, "Invalid command : %x", cmd_type);
return -EINVAL;
}
@@ -160,7 +161,7 @@ int cam_bps_process_cmd(void *device_priv, uint32_t cmd_type,
struct cam_icp_cpas_vote *cpas_vote = cmd_args;
if (!cmd_args) {
- pr_err("cmd args NULL\n");
+ CAM_ERR(CAM_ICP, "cmd args NULL");
return -EINVAL;
}
@@ -172,7 +173,7 @@ int cam_bps_process_cmd(void *device_priv, uint32_t cmd_type,
struct cam_icp_cpas_vote *cpas_vote = cmd_args;
if (!cmd_args) {
- pr_err("cmd args NULL\n");
+ CAM_ERR(CAM_ICP, "cmd args NULL");
return -EINVAL;
}
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_dev.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_dev.c
index c3477ee..ddff677 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_dev.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_dev.c
@@ -23,9 +23,7 @@
#include "cam_icp_hw_intf.h"
#include "cam_icp_hw_mgr_intf.h"
#include "cam_cpas_api.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
struct cam_bps_device_hw_info cam_bps_hw_info = {
.reserved = 0,
@@ -47,7 +45,7 @@ int cam_bps_register_cpas(struct cam_hw_soc_info *soc_info,
rc = cam_cpas_register_client(&cpas_register_params);
if (rc < 0) {
- pr_err("cam_cpas_register_client is failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "failed: %d", rc);
return rc;
}
core_info->cpas_handle = cpas_register_params.client_handle;
@@ -95,7 +93,7 @@ int cam_bps_probe(struct platform_device *pdev)
match_dev = of_match_device(pdev->dev.driver->of_match_table,
&pdev->dev);
if (!match_dev) {
- pr_err("%s: No bps hardware info\n", __func__);
+ CAM_ERR(CAM_ICP, "No bps hardware info");
kfree(bps_dev->core_info);
kfree(bps_dev);
kfree(bps_dev_intf);
@@ -108,13 +106,13 @@ int cam_bps_probe(struct platform_device *pdev)
rc = cam_bps_init_soc_resources(&bps_dev->soc_info, cam_bps_irq,
bps_dev);
if (rc < 0) {
- pr_err("%s: failed to init_soc\n", __func__);
+ CAM_ERR(CAM_ICP, "failed to init_soc");
kfree(bps_dev->core_info);
kfree(bps_dev);
kfree(bps_dev_intf);
return rc;
}
- pr_debug("cam_bps_init_soc_resources : %pK\n",
+ CAM_DBG(CAM_ICP, "soc info : %pK",
(void *)&bps_dev->soc_info);
rc = cam_bps_register_cpas(&bps_dev->soc_info,
@@ -129,7 +127,7 @@ int cam_bps_probe(struct platform_device *pdev)
mutex_init(&bps_dev->hw_mutex);
spin_lock_init(&bps_dev->hw_lock);
init_completion(&bps_dev->hw_complete);
- pr_debug("%s: BPS%d probe successful\n", __func__,
+ CAM_DBG(CAM_ICP, "BPS%d probe successful",
bps_dev_intf->hw_idx);
return rc;
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.c
index 8a3c7ac..54e898c 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/bps_hw/bps_soc.c
@@ -18,9 +18,7 @@
#include <media/cam_icp.h>
#include "bps_soc.h"
#include "cam_soc_util.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
static int cam_bps_get_dt_properties(struct cam_hw_soc_info *soc_info)
{
@@ -28,7 +26,7 @@ static int cam_bps_get_dt_properties(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_get_dt_properties(soc_info);
if (rc < 0)
- pr_err("get bps dt prop is failed\n");
+ CAM_ERR(CAM_ICP, "get bps dt prop is failed");
return rc;
}
@@ -69,7 +67,7 @@ int cam_bps_enable_soc_resources(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_enable_platform_resource(soc_info, true,
CAM_TURBO_VOTE, false);
if (rc)
- pr_err("%s: enable platform failed\n", __func__);
+ CAM_ERR(CAM_ICP, "enable platform failed");
return rc;
}
@@ -80,7 +78,7 @@ int cam_bps_disable_soc_resources(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_disable_platform_resource(soc_info, true, false);
if (rc)
- pr_err("%s: disable platform failed\n", __func__);
+ CAM_ERR(CAM_ICP, "disable platform failed");
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c
index f273a7b..1b3afc0 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "ICP-HW-MGR %s:%d " fmt, __func__, __LINE__
-
#include <linux/uaccess.h>
#include <linux/slab.h>
#include <linux/of.h>
@@ -46,9 +44,7 @@
#include "cam_mem_mgr.h"
#include "a5_core.h"
#include "hfi_sys_defs.h"
-
-#undef ICP_DBG
-#define ICP_DBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
#define ICP_WORKQ_NUM_TASK 30
#define ICP_WORKQ_TASK_CMD_TYPE 1
@@ -80,7 +76,7 @@ static int cam_icp_mgr_process_cmd(void *priv, void *data)
struct cam_icp_hw_mgr *hw_mgr;
if (!data || !priv) {
- pr_err("Invalid params%pK %pK\n", data, priv);
+ CAM_ERR(CAM_ICP, "Invalid params%pK %pK", data, priv);
return -EINVAL;
}
@@ -88,7 +84,6 @@ static int cam_icp_mgr_process_cmd(void *priv, void *data)
task_data = (struct hfi_cmd_work_data *)data;
rc = hfi_write_cmd(task_data->data);
- ICP_DBG("task type : %u, rc : %d\n", task_data->type, rc);
return rc;
}
@@ -106,14 +101,15 @@ static int cam_icp_mgr_process_msg_frame_process(uint32_t *msg_ptr)
ioconfig_ack = (struct hfi_msg_ipebps_async_ack *)msg_ptr;
if (ioconfig_ack->err_type != HFI_ERR_SYS_NONE) {
- pr_err("failed with error : %u\n", ioconfig_ack->err_type);
+ CAM_ERR(CAM_ICP, "failed with error : %u",
+ ioconfig_ack->err_type);
return -EIO;
}
frame_done =
(struct hfi_msg_frame_process_done *)ioconfig_ack->msg_data;
if (frame_done->result) {
- pr_err("result : %u\n", frame_done->result);
+ CAM_ERR(CAM_ICP, "result : %u", frame_done->result);
return -EIO;
}
@@ -126,7 +122,7 @@ static int cam_icp_mgr_process_msg_frame_process(uint32_t *msg_ptr)
break;
if (i >= CAM_FRAME_CMD_MAX) {
- pr_err("unable to find pkt in ctx data for req_id =%lld\n",
+ CAM_ERR(CAM_ICP, "pkt not found in ctx data for req_id =%lld",
request_id);
return -EINVAL;
}
@@ -136,7 +132,7 @@ static int cam_icp_mgr_process_msg_frame_process(uint32_t *msg_ptr)
ctx_data->ctxt_event_cb(ctx_data->context_priv, false, &buf_data);
/* now release memory for hfi frame process command */
- ICP_DBG("matching request id: %lld\n",
+ CAM_DBG(CAM_ICP, "matching request id: %lld",
hfi_frame_process->request_id[idx]);
mutex_lock(&ctx_data->hfi_frame_process.lock);
hfi_frame_process->request_id[idx] = 0;
@@ -153,40 +149,37 @@ static int cam_icp_mgr_process_msg_config_io(uint32_t *msg_ptr)
struct hfi_msg_bps_common *bps_config_ack = NULL;
ioconfig_ack = (struct hfi_msg_ipebps_async_ack *)msg_ptr;
- ICP_DBG("opcode : %u\n", ioconfig_ack->opcode);
if (ioconfig_ack->opcode == HFI_IPEBPS_CMD_OPCODE_IPE_CONFIG_IO) {
ipe_config_ack =
(struct hfi_msg_ipe_config *)(ioconfig_ack->msg_data);
if (ipe_config_ack->rc) {
- pr_err("rc = %d err = %u\n",
+ CAM_ERR(CAM_ICP, "rc = %d err = %u",
ipe_config_ack->rc, ioconfig_ack->err_type);
return -EIO;
}
ctx_data =
(struct cam_icp_hw_ctx_data *)ioconfig_ack->user_data1;
if (!ctx_data) {
- pr_err("wrong ctx data from IPE response\n");
+ CAM_ERR(CAM_ICP, "wrong ctx data from IPE response");
return -EINVAL;
}
mutex_lock(&ctx_data->ctx_mutex);
ctx_data->scratch_mem_size = ipe_config_ack->scratch_mem_size;
mutex_unlock(&ctx_data->ctx_mutex);
- ICP_DBG("scratch_mem_size = %u\n",
- ipe_config_ack->scratch_mem_size);
} else {
bps_config_ack =
(struct hfi_msg_bps_common *)(ioconfig_ack->msg_data);
if (bps_config_ack->rc) {
- pr_err("rc : %u, opcode :%u\n",
+ CAM_ERR(CAM_ICP, "rc : %u, opcode :%u",
bps_config_ack->rc, ioconfig_ack->opcode);
return -EIO;
}
ctx_data =
(struct cam_icp_hw_ctx_data *)ioconfig_ack->user_data1;
if (!ctx_data) {
- pr_err("wrong ctx data from BPS response\n");
+ CAM_ERR(CAM_ICP, "wrong ctx data from BPS response");
return -EINVAL;
}
}
@@ -202,22 +195,20 @@ static int cam_icp_mgr_process_msg_create_handle(uint32_t *msg_ptr)
create_handle_ack = (struct hfi_msg_create_handle_ack *)msg_ptr;
if (!create_handle_ack) {
- pr_err("Invalid create_handle_ack\n");
+ CAM_ERR(CAM_ICP, "Invalid create_handle_ack");
return -EINVAL;
}
- ICP_DBG("err type : %u\n", create_handle_ack->err_type);
-
ctx_data = (struct cam_icp_hw_ctx_data *)create_handle_ack->user_data1;
if (!ctx_data) {
- pr_err("Invalid ctx_data\n");
+ CAM_ERR(CAM_ICP, "Invalid ctx_data");
return -EINVAL;
}
mutex_lock(&ctx_data->ctx_mutex);
ctx_data->fw_handle = create_handle_ack->fw_handle;
mutex_unlock(&ctx_data->ctx_mutex);
- ICP_DBG("fw_handle = %x\n", ctx_data->fw_handle);
+ CAM_DBG(CAM_ICP, "fw_handle = %x", ctx_data->fw_handle);
complete(&ctx_data->wait_complete);
return 0;
@@ -230,18 +221,16 @@ static int cam_icp_mgr_process_msg_ping_ack(uint32_t *msg_ptr)
ping_ack = (struct hfi_msg_ping_ack *)msg_ptr;
if (!ping_ack) {
- pr_err("Empty ping ack message\n");
+ CAM_ERR(CAM_ICP, "Empty ping ack message");
return -EINVAL;
}
ctx_data = (struct cam_icp_hw_ctx_data *)ping_ack->user_data;
if (!ctx_data) {
- pr_err("Invalid ctx_data\n");
+ CAM_ERR(CAM_ICP, "Invalid ctx_data");
return -EINVAL;
}
- ICP_DBG("%x %x %pK\n", ping_ack->size, ping_ack->pkt_type,
- (void *)ping_ack->user_data);
complete(&ctx_data->wait_complete);
return 0;
@@ -254,7 +243,7 @@ static int cam_icp_mgr_process_indirect_ack_msg(uint32_t *msg_ptr)
switch (msg_ptr[ICP_PACKET_OPCODE]) {
case HFI_IPEBPS_CMD_OPCODE_IPE_CONFIG_IO:
case HFI_IPEBPS_CMD_OPCODE_BPS_CONFIG_IO:
- ICP_DBG("received HFI_IPEBPS_CMD_OPCODE_IPE/BPS_CONFIG_IO:\n");
+ CAM_DBG(CAM_ICP, "received IPE/BPS_CONFIG_IO:");
rc = cam_icp_mgr_process_msg_config_io(msg_ptr);
if (rc)
return rc;
@@ -262,13 +251,12 @@ static int cam_icp_mgr_process_indirect_ack_msg(uint32_t *msg_ptr)
case HFI_IPEBPS_CMD_OPCODE_IPE_FRAME_PROCESS:
case HFI_IPEBPS_CMD_OPCODE_BPS_FRAME_PROCESS:
- ICP_DBG("received OPCODE_IPE/BPS_FRAME_PROCESS:\n");
rc = cam_icp_mgr_process_msg_frame_process(msg_ptr);
if (rc)
return rc;
break;
default:
- pr_err("Invalid opcode : %u\n",
+ CAM_ERR(CAM_ICP, "Invalid opcode : %u",
msg_ptr[ICP_PACKET_OPCODE]);
break;
}
@@ -287,14 +275,14 @@ static int cam_icp_mgr_process_direct_ack_msg(uint32_t *msg_ptr)
case HFI_IPEBPS_CMD_OPCODE_BPS_DESTROY:
case HFI_IPEBPS_CMD_OPCODE_IPE_ABORT:
case HFI_IPEBPS_CMD_OPCODE_BPS_ABORT:
- ICP_DBG("received IPE/BPS_DESTROY/ABORT:\n");
+ CAM_DBG(CAM_ICP, "received IPE/BPS_DESTROY/ABORT:");
ioconfig_ack = (struct hfi_msg_ipebps_async_ack *)msg_ptr;
ctx_data =
(struct cam_icp_hw_ctx_data *)ioconfig_ack->user_data1;
complete(&ctx_data->wait_complete);
break;
default:
- pr_err("Invalid opcode : %u\n",
+ CAM_ERR(CAM_ICP, "Invalid opcode : %u",
msg_ptr[ICP_PACKET_OPCODE]);
rc = -EINVAL;
break;
@@ -312,37 +300,35 @@ static int32_t cam_icp_mgr_process_msg(void *priv, void *data)
int read_len;
if (!data || !priv) {
- pr_err("Invalid data\n");
+ CAM_ERR(CAM_ICP, "Invalid data");
return -EINVAL;
}
task_data = data;
hw_mgr = priv;
- ICP_DBG("irq status : %u\n", task_data->irq_status);
read_len = hfi_read_message(icp_hw_mgr.msg_buf, Q_MSG);
if (read_len < 0) {
- ICP_DBG("Unable to read msg q\n");
+ CAM_DBG(CAM_ICP, "Unable to read msg q");
return read_len;
}
msg_ptr = (uint32_t *)icp_hw_mgr.msg_buf;
- ICP_DBG("packet type: %x\n", msg_ptr[ICP_PACKET_TYPE]);
mutex_lock(&hw_mgr->hw_mgr_mutex);
switch (msg_ptr[ICP_PACKET_TYPE]) {
case HFI_MSG_SYS_INIT_DONE:
- ICP_DBG("received HFI_MSG_SYS_INIT_DONE\n");
+ CAM_DBG(CAM_ICP, "received SYS_INIT_DONE");
complete(&hw_mgr->a5_complete);
break;
case HFI_MSG_SYS_PING_ACK:
- ICP_DBG("received HFI_MSG_SYS_PING_ACK\n");
+ CAM_DBG(CAM_ICP, "received SYS_PING_ACK");
rc = cam_icp_mgr_process_msg_ping_ack(msg_ptr);
break;
case HFI_MSG_IPEBPS_CREATE_HANDLE_ACK:
- ICP_DBG("received HFI_MSG_IPEBPS_CREATE_HANDLE_ACK\n");
+ CAM_DBG(CAM_ICP, "received IPEBPS_CREATE_HANDLE_ACK");
rc = cam_icp_mgr_process_msg_create_handle(msg_ptr);
break;
@@ -355,11 +341,12 @@ static int32_t cam_icp_mgr_process_msg(void *priv, void *data)
break;
case HFI_MSG_EVENT_NOTIFY:
- ICP_DBG("received HFI_MSG_EVENT_NOTIFY\n");
+ CAM_DBG(CAM_ICP, "received EVENT_NOTIFY");
break;
default:
- pr_err("invalid msg : %u\n", msg_ptr[ICP_PACKET_TYPE]);
+ CAM_ERR(CAM_ICP, "invalid msg : %u",
+ msg_ptr[ICP_PACKET_TYPE]);
break;
}
@@ -379,7 +366,7 @@ int32_t cam_icp_hw_mgr_cb(uint32_t irq_status, void *data)
spin_lock_irqsave(&hw_mgr->hw_mgr_lock, flags);
task = cam_req_mgr_workq_get_task(icp_hw_mgr.msg_work);
if (!task) {
- pr_err("no empty task\n");
+ CAM_ERR(CAM_ICP, "no empty task");
spin_unlock_irqrestore(&hw_mgr->hw_mgr_lock, flags);
return -ENOMEM;
}
@@ -424,12 +411,8 @@ static int cam_icp_alloc_shared_mem(struct cam_mem_mgr_memory_desc *qtbl)
return rc;
*qtbl = out;
- ICP_DBG("kva = %llX\n", out.kva);
- ICP_DBG("qtbl IOVA = %X\n", out.iova);
- ICP_DBG("SMMU HDL = %X\n", out.smmu_hdl);
- ICP_DBG("MEM HDL = %X\n", out.mem_handle);
- ICP_DBG("length = %lld\n", out.len);
- ICP_DBG("region = %d\n", out.region);
+ CAM_DBG(CAM_ICP, "kva: %llX, iova: %x, hdl: %x, len: %lld",
+ out.kva, out.iova, out.mem_handle, out.len);
return rc;
}
@@ -451,9 +434,8 @@ static int cam_icp_allocate_fw_mem(void)
icp_hw_mgr.hfi_mem.fw_buf.iova = iova;
icp_hw_mgr.hfi_mem.fw_buf.smmu_hdl = icp_hw_mgr.iommu_hdl;
- ICP_DBG("kva = %llX\n", kvaddr);
- ICP_DBG("IOVA = %llX\n", iova);
- ICP_DBG("length = %zu\n", len);
+ CAM_DBG(CAM_ICP, "kva: %llX, iova: %llx, len: %zu",
+ kvaddr, iova, len);
return rc;
}
@@ -466,43 +448,43 @@ static int cam_icp_allocate_hfi_mem(void)
CAM_SMMU_REGION_SHARED,
&icp_hw_mgr.hfi_mem.shmem);
if (rc) {
- pr_err("Unable to get shared memory info\n");
+ CAM_ERR(CAM_ICP, "Unable to get shared memory info");
return rc;
}
rc = cam_icp_allocate_fw_mem();
if (rc) {
- pr_err("Unable to allocate FW memory\n");
+ CAM_ERR(CAM_ICP, "Unable to allocate FW memory");
return rc;
}
rc = cam_icp_alloc_shared_mem(&icp_hw_mgr.hfi_mem.qtbl);
if (rc) {
- pr_err("Unable to allocate qtbl memory\n");
+ CAM_ERR(CAM_ICP, "Unable to allocate qtbl memory");
goto qtbl_alloc_failed;
}
rc = cam_icp_alloc_shared_mem(&icp_hw_mgr.hfi_mem.cmd_q);
if (rc) {
- pr_err("Unable to allocate cmd q memory\n");
+ CAM_ERR(CAM_ICP, "Unable to allocate cmd q memory");
goto cmd_q_alloc_failed;
}
rc = cam_icp_alloc_shared_mem(&icp_hw_mgr.hfi_mem.msg_q);
if (rc) {
- pr_err("Unable to allocate msg q memory\n");
+ CAM_ERR(CAM_ICP, "Unable to allocate msg q memory");
goto msg_q_alloc_failed;
}
rc = cam_icp_alloc_shared_mem(&icp_hw_mgr.hfi_mem.dbg_q);
if (rc) {
- pr_err("Unable to allocate dbg q memory\n");
+ CAM_ERR(CAM_ICP, "Unable to allocate dbg q memory");
goto dbg_q_alloc_failed;
}
rc = cam_icp_alloc_shared_mem(&icp_hw_mgr.hfi_mem.sec_heap);
if (rc) {
- pr_err("Unable to allocate sec heap q memory\n");
+ CAM_ERR(CAM_ICP, "Unable to allocate sec heap q memory");
goto sec_heap_alloc_failed;
}
@@ -586,13 +568,13 @@ static int cam_icp_mgr_abort_handle(
if (rc)
return rc;
- ICP_DBG("fw_handle = %x ctx_data = %pK\n",
+ CAM_DBG(CAM_ICP, "fw_handle = %x ctx_data = %pK",
ctx_data->fw_handle, ctx_data);
rem_jiffies = wait_for_completion_timeout(&ctx_data->wait_complete,
msecs_to_jiffies((timeout)));
if (!rem_jiffies) {
rc = -ETIMEDOUT;
- ICP_DBG("FW timeout/err in abort handle command\n");
+ CAM_DBG(CAM_ICP, "FW timeout/err in abort handle command");
}
return rc;
@@ -640,13 +622,13 @@ static int cam_icp_mgr_destroy_handle(
if (rc)
return rc;
- ICP_DBG("fw_handle = %x ctx_data = %pK\n",
+ CAM_DBG(CAM_ICP, "fw_handle = %x ctx_data = %pK",
ctx_data->fw_handle, ctx_data);
rem_jiffies = wait_for_completion_timeout(&ctx_data->wait_complete,
msecs_to_jiffies((timeout)));
if (!rem_jiffies) {
rc = -ETIMEDOUT;
- ICP_DBG("FW response timeout: %d\n", rc);
+ CAM_ERR(CAM_ICP, "FW response timeout: %d", rc);
}
return rc;
@@ -657,13 +639,12 @@ static int cam_icp_mgr_release_ctx(struct cam_icp_hw_mgr *hw_mgr, int ctx_id)
int i = 0;
if (ctx_id >= CAM_ICP_CTX_MAX) {
- pr_err("ctx_id is wrong: %d\n", ctx_id);
+ CAM_ERR(CAM_ICP, "ctx_id is wrong: %d", ctx_id);
return -EINVAL;
}
mutex_lock(&hw_mgr->ctx_data[ctx_id].ctx_mutex);
if (!hw_mgr->ctx_data[ctx_id].in_use) {
- ICP_DBG("ctx is not in use: %d\n", ctx_id);
mutex_unlock(&hw_mgr->ctx_data[ctx_id].ctx_mutex);
return 0;
}
@@ -704,7 +685,7 @@ static void cam_icp_mgr_device_deinit(struct cam_icp_hw_mgr *hw_mgr)
bps_dev_intf = hw_mgr->devices[CAM_ICP_DEV_BPS][0];
if ((!a5_dev_intf) || (!ipe0_dev_intf) || (!bps_dev_intf)) {
- pr_err("dev intfs are wrong, failed to close\n");
+ CAM_ERR(CAM_ICP, "dev intfs are wrong, failed to close");
return;
}
@@ -725,14 +706,14 @@ static int cam_icp_mgr_hw_close(void *hw_priv, void *hw_close_args)
mutex_lock(&hw_mgr->hw_mgr_mutex);
if ((hw_mgr->fw_download == false) && (!hw_mgr->ctxt_cnt)) {
- ICP_DBG("hw mgr is already closed\n");
+ CAM_DBG(CAM_ICP, "hw mgr is already closed");
mutex_unlock(&hw_mgr->hw_mgr_mutex);
return 0;
}
a5_dev_intf = hw_mgr->devices[CAM_ICP_DEV_A5][0];
if (!a5_dev_intf) {
- pr_err("a5_dev_intf is NULL\n");
+ CAM_ERR(CAM_ICP, "a5_dev_intf is NULL");
mutex_unlock(&hw_mgr->hw_mgr_mutex);
return -EINVAL;
}
@@ -744,7 +725,7 @@ static int cam_icp_mgr_hw_close(void *hw_priv, void *hw_close_args)
CAM_ICP_A5_SET_IRQ_CB,
&irq_cb, sizeof(irq_cb));
if (rc)
- pr_err("deregister irq call back failed\n");
+ CAM_ERR(CAM_ICP, "deregister irq call back failed");
fw_buf_info.kva = 0;
fw_buf_info.iova = 0;
@@ -755,7 +736,7 @@ static int cam_icp_mgr_hw_close(void *hw_priv, void *hw_close_args)
&fw_buf_info,
sizeof(fw_buf_info));
if (rc)
- pr_err("nullify the fw buf failed\n");
+ CAM_ERR(CAM_ICP, "nullify the fw buf failed");
mutex_unlock(&hw_mgr->hw_mgr_mutex);
for (i = 0; i < CAM_ICP_CTX_MAX; i++)
@@ -784,7 +765,7 @@ static int cam_icp_mgr_device_init(struct cam_icp_hw_mgr *hw_mgr)
bps_dev_intf = hw_mgr->devices[CAM_ICP_DEV_BPS][0];
if ((!a5_dev_intf) || (!ipe0_dev_intf) || (!bps_dev_intf)) {
- pr_err("dev intfs are wrong\n");
+ CAM_ERR(CAM_ICP, "dev intfs are wrong");
return -EINVAL;
}
@@ -877,30 +858,18 @@ static int cam_icp_mgr_hfi_init(struct cam_icp_hw_mgr *hw_mgr)
hfi_mem.qtbl.kva = icp_hw_mgr.hfi_mem.qtbl.kva;
hfi_mem.qtbl.iova = icp_hw_mgr.hfi_mem.qtbl.iova;
hfi_mem.qtbl.len = icp_hw_mgr.hfi_mem.qtbl.len;
- ICP_DBG("kva = %llX\n", hfi_mem.qtbl.kva);
- ICP_DBG("IOVA = %X\n", hfi_mem.qtbl.iova);
- ICP_DBG("length = %lld\n", hfi_mem.qtbl.len);
hfi_mem.cmd_q.kva = icp_hw_mgr.hfi_mem.cmd_q.kva;
hfi_mem.cmd_q.iova = icp_hw_mgr.hfi_mem.cmd_q.iova;
hfi_mem.cmd_q.len = icp_hw_mgr.hfi_mem.cmd_q.len;
- ICP_DBG("kva = %llX\n", hfi_mem.cmd_q.kva);
- ICP_DBG("IOVA = %X\n", hfi_mem.cmd_q.iova);
- ICP_DBG("length = %lld\n", hfi_mem.cmd_q.len);
hfi_mem.msg_q.kva = icp_hw_mgr.hfi_mem.msg_q.kva;
hfi_mem.msg_q.iova = icp_hw_mgr.hfi_mem.msg_q.iova;
hfi_mem.msg_q.len = icp_hw_mgr.hfi_mem.msg_q.len;
- ICP_DBG("kva = %llX\n", hfi_mem.msg_q.kva);
- ICP_DBG("IOVA = %X\n", hfi_mem.msg_q.iova);
- ICP_DBG("length = %lld\n", hfi_mem.msg_q.len);
hfi_mem.dbg_q.kva = icp_hw_mgr.hfi_mem.dbg_q.kva;
hfi_mem.dbg_q.iova = icp_hw_mgr.hfi_mem.dbg_q.iova;
hfi_mem.dbg_q.len = icp_hw_mgr.hfi_mem.dbg_q.len;
- ICP_DBG("kva = %llX\n", hfi_mem.dbg_q.kva);
- ICP_DBG("IOVA = %X\n", hfi_mem.dbg_q.iova);
- ICP_DBG("length = %lld\n", hfi_mem.dbg_q.len);
hfi_mem.sec_heap.kva = icp_hw_mgr.hfi_mem.sec_heap.kva;
hfi_mem.sec_heap.iova = icp_hw_mgr.hfi_mem.sec_heap.iova;
@@ -908,6 +877,7 @@ static int cam_icp_mgr_hfi_init(struct cam_icp_hw_mgr *hw_mgr)
hfi_mem.shmem.iova = icp_hw_mgr.hfi_mem.shmem.iova_start;
hfi_mem.shmem.len = icp_hw_mgr.hfi_mem.shmem.iova_len;
+
return cam_hfi_init(0, &hfi_mem,
a5_dev->soc_info.reg_map[A5_SIERRA_BASE].mem_base,
hw_mgr->a5_debug);
@@ -922,7 +892,7 @@ static int cam_icp_mgr_send_fw_init(struct cam_icp_hw_mgr *hw_mgr)
a5_dev_intf = hw_mgr->devices[CAM_ICP_DEV_A5][0];
reinit_completion(&hw_mgr->a5_complete);
- ICP_DBG("Sending HFI init command\n");
+ CAM_DBG(CAM_ICP, "Sending HFI init command");
rc = a5_dev_intf->hw_ops.process_cmd(
a5_dev_intf->hw_priv,
CAM_ICP_A5_SEND_INIT,
@@ -930,14 +900,13 @@ static int cam_icp_mgr_send_fw_init(struct cam_icp_hw_mgr *hw_mgr)
if (rc)
return rc;
- ICP_DBG("Wait for INIT DONE Message\n");
rem_jiffies = wait_for_completion_timeout(&icp_hw_mgr.a5_complete,
msecs_to_jiffies((timeout)));
if (!rem_jiffies) {
rc = -ETIMEDOUT;
- ICP_DBG("FW response timed out %d\n", rc);
+ CAM_ERR(CAM_ICP, "FW response timed out %d", rc);
}
- ICP_DBG("Done Waiting for INIT DONE Message\n");
+ CAM_DBG(CAM_ICP, "Done Waiting for INIT DONE Message");
return rc;
}
@@ -950,13 +919,13 @@ static int cam_icp_mgr_download_fw(void *hw_mgr_priv, void *download_fw_args)
int rc = 0;
if (!hw_mgr) {
- pr_err("hw_mgr is NULL\n");
+ CAM_ERR(CAM_ICP, "hw_mgr is NULL");
return -EINVAL;
}
mutex_lock(&hw_mgr->hw_mgr_mutex);
if (hw_mgr->fw_download) {
- ICP_DBG("FW already downloaded\n");
+ CAM_DBG(CAM_ICP, "FW already downloaded");
mutex_unlock(&hw_mgr->hw_mgr_mutex);
return rc;
}
@@ -998,7 +967,7 @@ static int cam_icp_mgr_download_fw(void *hw_mgr_priv, void *download_fw_args)
NULL, 0);
hw_mgr->fw_download = true;
hw_mgr->ctxt_cnt = 0;
- ICP_DBG("FW download done successfully\n");
+ CAM_DBG(CAM_ICP, "FW download done successfully");
if (!download_fw_args)
cam_icp_mgr_hw_close(hw_mgr, NULL);
return rc;
@@ -1040,19 +1009,17 @@ static int cam_icp_mgr_enqueue_config(struct cam_icp_hw_mgr *hw_mgr,
request_id = *(uint64_t *)config_args->priv;
hw_update_entries = config_args->hw_update_entries;
- ICP_DBG("req_id = %lld %pK\n", request_id, config_args->priv);
+ CAM_DBG(CAM_ICP, "req_id = %lld %pK", request_id, config_args->priv);
task = cam_req_mgr_workq_get_task(icp_hw_mgr.cmd_work);
if (!task) {
- pr_err("no empty task\n");
+ CAM_ERR(CAM_ICP, "no empty task");
return -ENOMEM;
}
task_data = (struct hfi_cmd_work_data *)task->payload;
task_data->data = (void *)hw_update_entries->addr;
hfi_cmd = (struct hfi_cmd_ipebps_async *)hw_update_entries->addr;
- ICP_DBG("request from hfi_cmd :%llu, hfi_cmd: %pK\n",
- hfi_cmd->user_data2, hfi_cmd);
task_data->request_id = request_id;
task_data->type = ICP_WORKQ_TASK_CMD_TYPE;
task->process_cb = cam_icp_mgr_process_cmd;
@@ -1070,19 +1037,20 @@ static int cam_icp_mgr_config_hw(void *hw_mgr_priv, void *config_hw_args)
struct cam_icp_hw_ctx_data *ctx_data = NULL;
if (!hw_mgr || !config_args) {
- pr_err("Invalid arguments %pK %pK\n", hw_mgr, config_args);
+ CAM_ERR(CAM_ICP, "Invalid arguments %pK %pK",
+ hw_mgr, config_args);
return -EINVAL;
}
if (!config_args->num_hw_update_entries) {
- pr_err("No hw update enteries are available\n");
+ CAM_ERR(CAM_ICP, "No hw update enteries are available");
return -EINVAL;
}
mutex_lock(&hw_mgr->hw_mgr_mutex);
ctx_data = config_args->ctxt_to_hw_map;
if (!ctx_data->in_use) {
- pr_err("ctx is not in use\n");
+ CAM_ERR(CAM_ICP, "ctx is not in use");
mutex_unlock(&hw_mgr->hw_mgr_mutex);
rc = -EINVAL;
goto config_err;
@@ -1117,7 +1085,7 @@ static int cam_icp_mgr_prepare_frame_process_cmd(
hfi_cmd->user_data1 = (uint64_t)ctx_data;
hfi_cmd->user_data2 = request_id;
- ICP_DBG("ctx_data : %pK, request_id :%lld cmd_buf %x\n",
+ CAM_DBG(CAM_ICP, "ctx_data : %pK, request_id :%lld cmd_buf %x",
(void *)ctx_data->context_priv, request_id,
fw_cmd_buf_iova_addr);
@@ -1126,32 +1094,18 @@ static int cam_icp_mgr_prepare_frame_process_cmd(
static int cam_icp_mgr_pkt_validation(struct cam_packet *packet)
{
- ICP_DBG("packet header : opcode = %x size = %x",
- packet->header.op_code, packet->header.size);
-
- ICP_DBG(" req_id = %x flags = %x\n",
- (uint32_t)packet->header.request_id, packet->header.flags);
-
- ICP_DBG("packet data : c_off = %x c_num = %x\n",
- packet->cmd_buf_offset, packet->num_cmd_buf);
-
- ICP_DBG("io_off = %x io_num = %x p_off = %x p_num = %x %x %x\n",
- packet->io_configs_offset, packet->num_io_configs,
- packet->patch_offset, packet->num_patches,
- packet->kmd_cmd_buf_index, packet->kmd_cmd_buf_offset);
-
if (((packet->header.op_code & 0xff) !=
CAM_ICP_OPCODE_IPE_UPDATE) &&
((packet->header.op_code & 0xff) !=
CAM_ICP_OPCODE_BPS_UPDATE)) {
- pr_err("Invalid Opcode in pkt: %d\n",
+ CAM_ERR(CAM_ICP, "Invalid Opcode in pkt: %d",
packet->header.op_code & 0xff);
return -EINVAL;
}
if ((packet->num_cmd_buf > 1) || (!packet->num_patches) ||
(!packet->num_io_configs)) {
- pr_err("wrong number of cmd/patch info: %u %u\n",
+ CAM_ERR(CAM_ICP, "wrong number of cmd/patch info: %u %u",
packet->num_cmd_buf, packet->num_patches);
return -EINVAL;
}
@@ -1170,18 +1124,15 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr,
cmd_desc = (struct cam_cmd_buf_desc *)
((uint32_t *) &packet->payload + packet->cmd_buf_offset/4);
- ICP_DBG("packet = %pK cmd_desc = %pK size = %lu\n",
- (void *)packet, (void *)cmd_desc,
- sizeof(struct cam_cmd_buf_desc));
rc = cam_mem_get_io_buf(cmd_desc->mem_handle,
hw_mgr->iommu_hdl, &iova_addr, &fw_cmd_buf_len);
if (rc) {
- pr_err("unable to get src buf info for cmd buf: %x\n",
+ CAM_ERR(CAM_ICP, "unable to get src buf info for cmd buf: %x",
hw_mgr->iommu_hdl);
return rc;
}
- ICP_DBG("cmd_buf desc cpu and iova address: %pK %zu\n",
+ CAM_DBG(CAM_ICP, "cmd_buf desc cpu and iova address: %pK %zu",
(void *)iova_addr, fw_cmd_buf_len);
*fw_cmd_buf_iova_addr = iova_addr;
@@ -1190,65 +1141,32 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr,
return rc;
}
-static int cam_icp_mgr_process_io_cfg(struct cam_icp_hw_mgr *hw_mgr,
+static void cam_icp_mgr_process_io_cfg(struct cam_icp_hw_mgr *hw_mgr,
struct cam_icp_hw_ctx_data *ctx_data,
struct cam_packet *packet,
struct cam_hw_prepare_update_args *prepare_args)
{
- int rc = 0, i, j;
- int32_t sync_in_obj[CAM_ICP_IPE_IMAGE_MAX];
- int32_t merged_sync_in_obj;
+ int i, j, k;
struct cam_buf_io_cfg *io_cfg_ptr = NULL;
io_cfg_ptr = (struct cam_buf_io_cfg *) ((uint32_t *) &packet->payload +
packet->io_configs_offset/4);
- ICP_DBG("packet = %pK io_cfg_ptr = %pK size = %lu\n",
- (void *)packet, (void *)io_cfg_ptr,
- sizeof(struct cam_buf_io_cfg));
-
prepare_args->num_out_map_entries = 0;
- for (i = 0, j = 0; i < packet->num_io_configs; i++) {
+ prepare_args->num_in_map_entries = 0;
+
+ for (i = 0, j = 0, k = 0; i < packet->num_io_configs; i++) {
if (io_cfg_ptr[i].direction == CAM_BUF_INPUT) {
- ICP_DBG("direction is i : %d :%u\n",
- i, io_cfg_ptr[i].direction);
- ICP_DBG("fence is i : %d :%d\n",
- i, io_cfg_ptr[i].fence);
- continue;
+ prepare_args->in_map_entries[j++].sync_id =
+ io_cfg_ptr[i].fence;
+ prepare_args->num_in_map_entries++;
+ } else {
+ prepare_args->out_map_entries[k++].sync_id =
+ io_cfg_ptr[i].fence;
+ prepare_args->num_out_map_entries++;
}
-
- prepare_args->out_map_entries[j++].sync_id =
- io_cfg_ptr[i].fence;
- prepare_args->num_out_map_entries++;
- ICP_DBG(" out fence = %x index = %d\n", io_cfg_ptr[i].fence, i);
+ CAM_DBG(CAM_ICP, "dir[%d]: %u, fence: %u",
+ i, io_cfg_ptr[i].direction, io_cfg_ptr[i].fence);
}
-
- for (i = 0, j = 0; i < packet->num_io_configs; i++) {
- if (io_cfg_ptr[i].direction == CAM_BUF_INPUT) {
- sync_in_obj[j++] = io_cfg_ptr[i].fence;
- ICP_DBG(" in fence = %x index = %d\n",
- io_cfg_ptr[i].fence, i);
- }
- }
-
- if (j == 1) {
- merged_sync_in_obj = sync_in_obj[j - 1];
- } else if (j > 1) {
- rc = cam_sync_merge(&sync_in_obj[0], j, &merged_sync_in_obj);
- if (rc) {
- pr_err("unable to create in merged object: %d\n", rc);
- return rc;
- }
- } else {
- pr_err("no input fence provided %u\n", j);
- return -EINVAL;
- }
-
- prepare_args->in_map_entries[0].sync_id = merged_sync_in_obj;
- prepare_args->in_map_entries[0].resource_handle =
- ctx_data->icp_dev_acquire_info->dev_type;
- prepare_args->num_in_map_entries = 1;
-
- return rc;
}
static int cam_icp_mgr_update_hfi_frame_process(
@@ -1263,7 +1181,7 @@ static int cam_icp_mgr_update_hfi_frame_process(
index = find_first_zero_bit(ctx_data->hfi_frame_process.bitmap,
ctx_data->hfi_frame_process.bits);
if (index < 0 || index >= CAM_FRAME_CMD_MAX) {
- pr_err("request idx is wrong: %d\n", index);
+ CAM_ERR(CAM_ICP, "request idx is wrong: %d", index);
mutex_unlock(&ctx_data->hfi_frame_process.lock);
return -EINVAL;
}
@@ -1272,8 +1190,7 @@ static int cam_icp_mgr_update_hfi_frame_process(
ctx_data->hfi_frame_process.request_id[index] =
packet->header.request_id;
- ICP_DBG("slot[%d]: %lld\n", index,
- ctx_data->hfi_frame_process.request_id[index]);
+
*idx = index;
return 0;
@@ -1293,7 +1210,7 @@ static int cam_icp_mgr_prepare_hw_update(void *hw_mgr_priv,
prepare_hw_update_args;
if ((!prepare_args) || (!hw_mgr) || (!prepare_args->packet)) {
- pr_err("Invalid args\n");
+ CAM_ERR(CAM_ICP, "Invalid args");
return -EINVAL;
}
@@ -1301,7 +1218,7 @@ static int cam_icp_mgr_prepare_hw_update(void *hw_mgr_priv,
mutex_lock(&hw_mgr->hw_mgr_mutex);
if (!ctx_data->in_use) {
mutex_unlock(&hw_mgr->hw_mgr_mutex);
- pr_err("ctx is not in use\n");
+ CAM_ERR(CAM_ICP, "ctx is not in use");
return -EINVAL;
}
mutex_unlock(&hw_mgr->hw_mgr_mutex);
@@ -1322,10 +1239,8 @@ static int cam_icp_mgr_prepare_hw_update(void *hw_mgr_priv,
if (rc)
return rc;
- rc = cam_icp_mgr_process_io_cfg(hw_mgr, ctx_data,
+ cam_icp_mgr_process_io_cfg(hw_mgr, ctx_data,
packet, prepare_args);
- if (rc)
- return rc;
rc = cam_icp_mgr_update_hfi_frame_process(ctx_data, packet,
prepare_args, &idx);
@@ -1346,9 +1261,6 @@ static int cam_icp_mgr_prepare_hw_update(void *hw_mgr_priv,
prepare_args->num_hw_update_entries = 1;
prepare_args->hw_update_entries[0].addr = (uint64_t)hfi_cmd;
prepare_args->priv = &ctx_data->hfi_frame_process.request_id[idx];
- ICP_DBG("slot : %d, hfi_cmd : %pK, request : %lld\n", idx,
- (void *)hfi_cmd,
- ctx_data->hfi_frame_process.request_id[idx]);
return rc;
}
@@ -1385,14 +1297,14 @@ static int cam_icp_mgr_release_hw(void *hw_mgr_priv, void *release_hw_args)
struct cam_icp_hw_ctx_data *ctx_data = NULL;
if (!release_hw || !hw_mgr) {
- pr_err("Invalid args: %pK %pK\n", release_hw, hw_mgr);
+ CAM_ERR(CAM_ICP, "Invalid args: %pK %pK", release_hw, hw_mgr);
return -EINVAL;
}
ctx_data = release_hw->ctxt_to_hw_map;
ctx_id = ctx_data->ctx_id;
if (ctx_id < 0 || ctx_id >= CAM_ICP_CTX_MAX) {
- pr_err("Invalid ctx id: %d\n", ctx_id);
+ CAM_ERR(CAM_ICP, "Invalid ctx id: %d", ctx_id);
return -EINVAL;
}
@@ -1430,8 +1342,7 @@ static int cam_icp_mgr_send_config_io(struct cam_icp_hw_ctx_data *ctx_data,
ioconfig_cmd.opcode = HFI_IPEBPS_CMD_OPCODE_IPE_CONFIG_IO;
reinit_completion(&ctx_data->wait_complete);
- ICP_DBG("Sending HFI_CMD_IPEBPS_ASYNC_COMMAND: opcode :%u\n",
- ioconfig_cmd.opcode);
+
ioconfig_cmd.num_fw_handles = 1;
ioconfig_cmd.fw_handles[0] = ctx_data->fw_handle;
ioconfig_cmd.payload.indirect = io_buf_addr;
@@ -1447,13 +1358,11 @@ static int cam_icp_mgr_send_config_io(struct cam_icp_hw_ctx_data *ctx_data,
if (rc)
return rc;
- ICP_DBG("fw_hdl = %x ctx_data = %pK\n", ctx_data->fw_handle, ctx_data);
-
rem_jiffies = wait_for_completion_timeout(&ctx_data->wait_complete,
msecs_to_jiffies((timeout)));
if (!rem_jiffies) {
rc = -ETIMEDOUT;
- ICP_DBG("FW response timed out %d\n", rc);
+ CAM_ERR(CAM_ICP, "FW response timed out %d", rc);
}
return rc;
@@ -1477,9 +1386,6 @@ static int cam_icp_mgr_create_handle(uint32_t dev_type,
create_handle.pkt_type = HFI_CMD_IPEBPS_CREATE_HANDLE;
create_handle.handle_type = dev_type;
create_handle.user_data1 = (uint64_t)ctx_data;
- ICP_DBG("%x %x %x %pK\n", create_handle.size, create_handle.pkt_type,
- create_handle.handle_type, (void *)create_handle.user_data1);
- ICP_DBG("Sending HFI_CMD_IPEBPS_CREATE_HANDLE\n");
reinit_completion(&ctx_data->wait_complete);
task_data = (struct hfi_cmd_work_data *)task->payload;
@@ -1496,7 +1402,7 @@ static int cam_icp_mgr_create_handle(uint32_t dev_type,
msecs_to_jiffies((timeout)));
if (!rem_jiffies) {
rc = -ETIMEDOUT;
- ICP_DBG("FW response timed out %d\n", rc);
+ CAM_ERR(CAM_ICP, "FW response timed out %d", rc);
}
return rc;
@@ -1513,16 +1419,13 @@ static int cam_icp_mgr_send_ping(struct cam_icp_hw_ctx_data *ctx_data)
task = cam_req_mgr_workq_get_task(icp_hw_mgr.cmd_work);
if (!task) {
- pr_err("No free task to send ping command\n");
+ CAM_ERR(CAM_ICP, "No free task to send ping command");
return -ENOMEM;
}
ping_pkt.size = sizeof(struct hfi_cmd_ping_pkt);
ping_pkt.pkt_type = HFI_CMD_SYS_PING;
ping_pkt.user_data = (uint64_t)ctx_data;
- ICP_DBG("Sending HFI_CMD_SYS_PING\n");
- ICP_DBG("%x %x %pK\n", ping_pkt.size, ping_pkt.pkt_type,
- (void *)ping_pkt.user_data);
init_completion(&ctx_data->wait_complete);
task_data = (struct hfi_cmd_work_data *)task->payload;
@@ -1540,7 +1443,7 @@ static int cam_icp_mgr_send_ping(struct cam_icp_hw_ctx_data *ctx_data)
msecs_to_jiffies((timeout)));
if (!rem_jiffies) {
rc = -ETIMEDOUT;
- ICP_DBG("FW response timed out %d\n", rc);
+ CAM_ERR(CAM_ICP, "FW response timed out %d", rc);
}
return rc;
@@ -1561,7 +1464,7 @@ static int cam_icp_get_acquire_info(struct cam_icp_hw_mgr *hw_mgr,
return -EFAULT;
if (icp_dev_acquire_info.num_out_res > ICP_MAX_OUTPUT_SUPPORTED) {
- pr_err("num of out resources exceeding : %u\n",
+ CAM_ERR(CAM_ICP, "num of out resources exceeding : %u",
icp_dev_acquire_info.num_out_res);
return -EINVAL;
}
@@ -1580,7 +1483,7 @@ static int cam_icp_get_acquire_info(struct cam_icp_hw_mgr *hw_mgr,
return -EFAULT;
}
- ICP_DBG("%x %x %x %x %x %x %x\n",
+ CAM_DBG(CAM_ICP, "%x %x %x %x %x %x %x",
ctx_data->icp_dev_acquire_info->dev_type,
ctx_data->icp_dev_acquire_info->in_res.format,
ctx_data->icp_dev_acquire_info->in_res.width,
@@ -1591,7 +1494,7 @@ static int cam_icp_get_acquire_info(struct cam_icp_hw_mgr *hw_mgr,
p_icp_out = ctx_data->icp_dev_acquire_info->out_res;
for (i = 0; i < ctx_data->icp_dev_acquire_info->num_out_res; i++)
- ICP_DBG("out[i] %x %x %x %x\n",
+ CAM_DBG(CAM_ICP, "out[i] %x %x %x %x",
p_icp_out[i].format,
p_icp_out[i].width,
p_icp_out[i].height,
@@ -1612,20 +1515,21 @@ static int cam_icp_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
struct cam_icp_acquire_dev_info *icp_dev_acquire_info;
if ((!hw_mgr_priv) || (!acquire_hw_args)) {
- pr_err("Invalid params: %pK %pK\n", hw_mgr_priv,
+ CAM_ERR(CAM_ICP, "Invalid params: %pK %pK", hw_mgr_priv,
acquire_hw_args);
return -EINVAL;
}
if (args->num_acq > 1) {
- pr_err("number of resources are wrong: %u\n", args->num_acq);
+ CAM_ERR(CAM_ICP, "number of resources are wrong: %u",
+ args->num_acq);
return -EINVAL;
}
mutex_lock(&hw_mgr->hw_mgr_mutex);
ctx_id = cam_icp_mgr_get_free_ctx(hw_mgr);
if (ctx_id >= CAM_ICP_CTX_MAX) {
- pr_err("No free ctx space in hw_mgr\n");
+ CAM_ERR(CAM_ICP, "No free ctx space in hw_mgr");
mutex_unlock(&hw_mgr->hw_mgr_mutex);
return -ENOSPC;
}
@@ -1655,13 +1559,13 @@ static int cam_icp_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
&io_buf_addr, &io_buf_size);
if (rc) {
- pr_err("unable to get src buf info from io desc\n");
+ CAM_ERR(CAM_ICP, "unable to get src buf info from io desc");
goto get_io_buf_failed;
}
- ICP_DBG("io_config_cmd_handle : %d\n",
- icp_dev_acquire_info->io_config_cmd_handle);
- ICP_DBG("io_buf_addr : %pK\n", (void *)io_buf_addr);
- ICP_DBG("io_buf_size : %zu\n", io_buf_size);
+
+ CAM_DBG(CAM_ICP, "hdl: %d, addr: %pK, size: %zu",
+ icp_dev_acquire_info->io_config_cmd_handle,
+ (void *)io_buf_addr, io_buf_size);
mutex_lock(&hw_mgr->hw_mgr_mutex);
if (!hw_mgr->ctxt_cnt) {
@@ -1675,20 +1579,20 @@ static int cam_icp_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
rc = cam_icp_mgr_send_ping(ctx_data);
if (rc) {
- pr_err("ping ack not received\n");
+ CAM_ERR(CAM_ICP, "ping ack not received");
goto send_ping_failed;
}
rc = cam_icp_mgr_create_handle(icp_dev_acquire_info->dev_type,
ctx_data);
if (rc) {
- pr_err("create handle failed\n");
+ CAM_ERR(CAM_ICP, "create handle failed");
goto create_handle_failed;
}
rc = cam_icp_mgr_send_config_io(ctx_data, io_buf_addr);
if (rc) {
- pr_err("IO Config command failed\n");
+ CAM_ERR(CAM_ICP, "IO Config command failed");
goto ioconfig_failed;
}
@@ -1711,7 +1615,7 @@ static int cam_icp_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
icp_dev_acquire_info, sizeof(struct cam_icp_acquire_dev_info)))
goto copy_to_user_failed;
- ICP_DBG("scratch mem size = %x fw_handle = %x\n",
+ CAM_DBG(CAM_ICP, "scratch size = %x fw_handle = %x",
(unsigned int)icp_dev_acquire_info->scratch_mem_size,
(unsigned int)ctx_data->fw_handle);
mutex_lock(&hw_mgr->hw_mgr_mutex);
@@ -1744,14 +1648,15 @@ static int cam_icp_mgr_get_hw_caps(void *hw_mgr_priv, void *hw_caps_args)
struct cam_query_cap_cmd *query_cap = hw_caps_args;
if ((!hw_mgr_priv) || (!hw_caps_args)) {
- pr_err("Invalid params: %pK %pK\n", hw_mgr_priv, hw_caps_args);
+ CAM_ERR(CAM_ICP, "Invalid params: %pK %pK",
+ hw_mgr_priv, hw_caps_args);
return -EINVAL;
}
if (copy_from_user(&icp_hw_mgr.icp_caps,
(void __user *)query_cap->caps_handle,
sizeof(struct cam_icp_query_cap_cmd))) {
- pr_err("copy_from_user failed\n");
+ CAM_ERR(CAM_ICP, "copy_from_user failed");
return -EFAULT;
}
@@ -1765,7 +1670,7 @@ static int cam_icp_mgr_get_hw_caps(void *hw_mgr_priv, void *hw_caps_args)
if (copy_to_user((void __user *)query_cap->caps_handle,
&icp_hw_mgr.icp_caps, sizeof(struct cam_icp_query_cap_cmd))) {
- pr_err("copy_to_user failed\n");
+ CAM_ERR(CAM_ICP, "copy_to_user failed");
rc = -EFAULT;
goto hfi_get_caps_fail;
}
@@ -1788,7 +1693,7 @@ int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl)
hw_mgr_intf = (struct cam_hw_mgr_intf *)hw_mgr_hdl;
if (!of_node || !hw_mgr_intf) {
- pr_err("Invalid args of_node %pK hw_mgr %pK\n",
+ CAM_ERR(CAM_ICP, "Invalid args of_node %pK hw_mgr %pK",
of_node, hw_mgr_intf);
return -EINVAL;
}
@@ -1811,7 +1716,7 @@ int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl)
/* Get number of device objects */
count = of_property_count_strings(of_node, "compat-hw-name");
if (!count) {
- pr_err("no compat hw found in dev tree, count = %d\n", count);
+ CAM_ERR(CAM_ICP, "no compat hw found, count = %d", count);
rc = -EINVAL;
goto num_dev_failed;
}
@@ -1819,7 +1724,7 @@ int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl)
/* Get number of a5 device nodes and a5 mem allocation */
rc = of_property_read_u32(of_node, "num-a5", &num_dev);
if (rc) {
- pr_err("getting num of a5 failed\n");
+ CAM_ERR(CAM_ICP, "getting num of a5 failed");
goto num_dev_failed;
}
@@ -1833,7 +1738,7 @@ int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl)
/* Get number of ipe device nodes and ipe mem allocation */
rc = of_property_read_u32(of_node, "num-ipe", &num_dev);
if (rc) {
- pr_err("getting number of ipe dev nodes failed\n");
+ CAM_ERR(CAM_ICP, "getting number of ipe dev nodes failed");
goto num_ipe_failed;
}
@@ -1847,7 +1752,7 @@ int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl)
/* Get number of bps device nodes and bps mem allocation */
rc = of_property_read_u32(of_node, "num-bps", &num_dev);
if (rc) {
- pr_err("read num bps devices failed\n");
+ CAM_ERR(CAM_ICP, "read num bps devices failed");
goto num_bps_failed;
}
icp_hw_mgr.devices[CAM_ICP_DEV_BPS] = kzalloc(
@@ -1861,20 +1766,20 @@ int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl)
rc = of_property_read_string_index(of_node, "compat-hw-name",
i, &name);
if (rc) {
- pr_err("getting dev object name failed\n");
+ CAM_ERR(CAM_ICP, "getting dev object name failed");
goto compat_hw_name_failed;
}
child_node = of_find_node_by_name(NULL, name);
if (!child_node) {
- pr_err("error! Cannot find node in dtsi %s\n", name);
+ CAM_ERR(CAM_ICP, "Cannot find node in dtsi %s", name);
rc = -ENODEV;
goto compat_hw_name_failed;
}
child_pdev = of_find_device_by_node(child_node);
if (!child_pdev) {
- pr_err("failed to find device on bus %s\n",
+ CAM_ERR(CAM_ICP, "failed to find device on bus %s",
child_node->name);
rc = -ENODEV;
of_node_put(child_node);
@@ -1884,13 +1789,10 @@ int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl)
child_dev_intf = (struct cam_hw_intf *)platform_get_drvdata(
child_pdev);
if (!child_dev_intf) {
- pr_err("no child device\n");
+ CAM_ERR(CAM_ICP, "no child device");
of_node_put(child_node);
goto compat_hw_name_failed;
}
- ICP_DBG("child_intf %pK\n", child_dev_intf);
- ICP_DBG("child type %d index %d\n", child_dev_intf->hw_type,
- child_dev_intf->hw_idx);
icp_hw_mgr.devices[child_dev_intf->hw_type]
[child_dev_intf->hw_idx] = child_dev_intf;
@@ -1900,27 +1802,27 @@ int cam_icp_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl)
rc = cam_smmu_get_handle("icp", &icp_hw_mgr.iommu_hdl);
if (rc) {
- pr_err("icp get iommu handle failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "icp get iommu handle failed: %d", rc);
goto compat_hw_name_failed;
}
rc = cam_smmu_ops(icp_hw_mgr.iommu_hdl, CAM_SMMU_ATTACH);
if (rc) {
- pr_err("icp attach failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "icp attach failed: %d", rc);
goto icp_attach_failed;
}
rc = cam_req_mgr_workq_create("icp_command_queue", ICP_WORKQ_NUM_TASK,
&icp_hw_mgr.cmd_work, CRM_WORKQ_USAGE_NON_IRQ);
if (rc) {
- pr_err("unable to create a worker\n");
+ CAM_ERR(CAM_ICP, "unable to create a worker");
goto cmd_work_failed;
}
rc = cam_req_mgr_workq_create("icp_message_queue", ICP_WORKQ_NUM_TASK,
&icp_hw_mgr.msg_work, CRM_WORKQ_USAGE_IRQ);
if (rc) {
- pr_err("unable to create a worker\n");
+ CAM_ERR(CAM_ICP, "unable to create a worker");
goto msg_work_failed;
}
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c
index 99b45aa..b7b3d7b 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_core.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "IPE-CORE %s:%d " fmt, __func__, __LINE__
-
#include <linux/of.h>
#include <linux/debugfs.h>
#include <linux/videodev2.h>
@@ -30,6 +28,7 @@
#include "cam_ipe_hw_intf.h"
#include "cam_icp_hw_mgr_intf.h"
#include "cam_cpas_api.h"
+#include "cam_debug_util.h"
static int cam_ipe_caps_vote(struct cam_ipe_device_core_info *core_info,
struct cam_icp_cpas_vote *cpas_vote)
@@ -44,7 +43,7 @@ static int cam_ipe_caps_vote(struct cam_ipe_device_core_info *core_info,
&cpas_vote->axi_vote);
if (rc)
- pr_err("cpas vote is failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "cpas vote is failed: %d", rc);
return rc;
}
@@ -59,7 +58,7 @@ int cam_ipe_init_hw(void *device_priv,
int rc = 0;
if (!device_priv) {
- pr_err("Invalid cam_dev_info\n");
+ CAM_ERR(CAM_ICP, "Invalid cam_dev_info");
return -EINVAL;
}
@@ -67,7 +66,8 @@ int cam_ipe_init_hw(void *device_priv,
core_info = (struct cam_ipe_device_core_info *)ipe_dev->core_info;
if ((!soc_info) || (!core_info)) {
- pr_err("soc_info = %pK core_info = %pK\n", soc_info, core_info);
+ CAM_ERR(CAM_ICP, "soc_info = %pK core_info = %pK",
+ soc_info, core_info);
return -EINVAL;
}
@@ -79,16 +79,16 @@ int cam_ipe_init_hw(void *device_priv,
rc = cam_cpas_start(core_info->cpas_handle,
&cpas_vote.ahb_vote, &cpas_vote.axi_vote);
if (rc) {
- pr_err("cpass start failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "cpass start failed: %d", rc);
return rc;
}
core_info->cpas_start = true;
rc = cam_ipe_enable_soc_resources(soc_info);
if (rc) {
- pr_err("soc enable is failed : %d\n", rc);
+ CAM_ERR(CAM_ICP, "soc enable is failed : %d", rc);
if (cam_cpas_stop(core_info->cpas_handle))
- pr_err("cpas stop is failed\n");
+ CAM_ERR(CAM_ICP, "cpas stop is failed");
else
core_info->cpas_start = false;
}
@@ -105,24 +105,25 @@ int cam_ipe_deinit_hw(void *device_priv,
int rc = 0;
if (!device_priv) {
- pr_err("Invalid cam_dev_info\n");
+ CAM_ERR(CAM_ICP, "Invalid cam_dev_info");
return -EINVAL;
}
soc_info = &ipe_dev->soc_info;
core_info = (struct cam_ipe_device_core_info *)ipe_dev->core_info;
if ((!soc_info) || (!core_info)) {
- pr_err("soc_info = %pK core_info = %pK\n", soc_info, core_info);
+ CAM_ERR(CAM_ICP, "soc_info = %pK core_info = %pK",
+ soc_info, core_info);
return -EINVAL;
}
rc = cam_ipe_disable_soc_resources(soc_info);
if (rc)
- pr_err("soc disable is failed : %d\n", rc);
+ CAM_ERR(CAM_ICP, "soc disable is failed : %d", rc);
if (core_info->cpas_start) {
if (cam_cpas_stop(core_info->cpas_handle))
- pr_err("cpas stop is failed\n");
+ CAM_ERR(CAM_ICP, "cpas stop is failed");
else
core_info->cpas_start = false;
}
@@ -140,12 +141,12 @@ int cam_ipe_process_cmd(void *device_priv, uint32_t cmd_type,
int rc = 0;
if (!device_priv) {
- pr_err("Invalid arguments\n");
+ CAM_ERR(CAM_ICP, "Invalid arguments");
return -EINVAL;
}
if (cmd_type >= CAM_ICP_IPE_CMD_MAX) {
- pr_err("Invalid command : %x\n", cmd_type);
+ CAM_ERR(CAM_ICP, "Invalid command : %x", cmd_type);
return -EINVAL;
}
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_dev.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_dev.c
index 0efb1de..d95246f 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_dev.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_dev.c
@@ -23,9 +23,7 @@
#include "cam_icp_hw_intf.h"
#include "cam_icp_hw_mgr_intf.h"
#include "cam_cpas_api.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
struct cam_ipe_device_hw_info cam_ipe_hw_info = {
.reserved = 0,
@@ -47,7 +45,7 @@ int cam_ipe_register_cpas(struct cam_hw_soc_info *soc_info,
rc = cam_cpas_register_client(&cpas_register_params);
if (rc < 0) {
- pr_err("cam_cpas_register_client is failed: %d\n", rc);
+ CAM_ERR(CAM_ICP, "failed: %d", rc);
return rc;
}
core_info->cpas_handle = cpas_register_params.client_handle;
@@ -83,7 +81,7 @@ int cam_ipe_probe(struct platform_device *pdev)
ipe_dev_intf->hw_ops.process_cmd = cam_ipe_process_cmd;
ipe_dev_intf->hw_type = CAM_ICP_DEV_IPE;
- pr_debug("%s: type %d index %d\n", __func__,
+ CAM_DBG(CAM_ICP, "type %d index %d",
ipe_dev_intf->hw_type,
ipe_dev_intf->hw_idx);
@@ -101,7 +99,7 @@ int cam_ipe_probe(struct platform_device *pdev)
match_dev = of_match_device(pdev->dev.driver->of_match_table,
&pdev->dev);
if (!match_dev) {
- pr_debug("%s: No ipe hardware info\n", __func__);
+ CAM_DBG(CAM_ICP, "No ipe hardware info");
kfree(ipe_dev->core_info);
kfree(ipe_dev);
kfree(ipe_dev_intf);
@@ -114,14 +112,14 @@ int cam_ipe_probe(struct platform_device *pdev)
rc = cam_ipe_init_soc_resources(&ipe_dev->soc_info, cam_ipe_irq,
ipe_dev);
if (rc < 0) {
- pr_err("%s: failed to init_soc\n", __func__);
+ CAM_ERR(CAM_ICP, "failed to init_soc");
kfree(ipe_dev->core_info);
kfree(ipe_dev);
kfree(ipe_dev_intf);
return rc;
}
- pr_debug("cam_ipe_init_soc_resources : %pK\n",
+ CAM_DBG(CAM_ICP, "cam_ipe_init_soc_resources : %pK",
(void *)&ipe_dev->soc_info);
rc = cam_ipe_register_cpas(&ipe_dev->soc_info,
core_info, ipe_dev_intf->hw_idx);
@@ -136,7 +134,7 @@ int cam_ipe_probe(struct platform_device *pdev)
spin_lock_init(&ipe_dev->hw_lock);
init_completion(&ipe_dev->hw_complete);
- pr_debug("%s: IPE%d probe successful\n", __func__,
+ CAM_DBG(CAM_ICP, "IPE%d probe successful",
ipe_dev_intf->hw_idx);
return rc;
diff --git a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.c b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.c
index e691dad..26dd6d2 100644
--- a/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.c
+++ b/drivers/media/platform/msm/camera/cam_icp/icp_hw/ipe_hw/ipe_soc.c
@@ -18,9 +18,7 @@
#include <media/cam_icp.h>
#include "ipe_soc.h"
#include "cam_soc_util.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
static int cam_ipe_get_dt_properties(struct cam_hw_soc_info *soc_info)
{
@@ -28,7 +26,7 @@ static int cam_ipe_get_dt_properties(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_get_dt_properties(soc_info);
if (rc < 0)
- pr_err("get ipe dt prop is failed\n");
+ CAM_ERR(CAM_ICP, "get ipe dt prop is failed");
return rc;
}
@@ -69,7 +67,7 @@ int cam_ipe_enable_soc_resources(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_enable_platform_resource(soc_info, true,
CAM_TURBO_VOTE, false);
if (rc) {
- pr_err("%s: enable platform failed\n", __func__);
+ CAM_ERR(CAM_ICP, "enable platform failed");
return rc;
}
@@ -82,7 +80,7 @@ int cam_ipe_disable_soc_resources(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_disable_platform_resource(soc_info, true, false);
if (rc)
- pr_err("%s: enable platform failed\n", __func__);
+ CAM_ERR(CAM_ICP, "enable platform failed");
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c b/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c
index 766ea89..a6f60f5 100644
--- a/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c
+++ b/drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c
@@ -22,9 +22,7 @@
#include "cam_sync_api.h"
#include "cam_req_mgr_dev.h"
#include "cam_trace.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
static uint64_t __cam_isp_ctx_get_event_ts(uint32_t evt_id, void *evt_data)
{
@@ -57,7 +55,7 @@ static uint64_t __cam_isp_ctx_get_event_ts(uint32_t evt_id, void *evt_data)
case CAM_ISP_HW_EVENT_DONE:
break;
default:
- CDBG("%s: Invalid Event Type %d\n", __func__, evt_id);
+ CAM_DBG(CAM_ISP, "Invalid Event Type %d", evt_id);
}
return ts;
@@ -75,11 +73,11 @@ static int __cam_isp_ctx_handle_buf_done_in_activated_state(
struct cam_context *ctx = ctx_isp->base;
if (list_empty(&ctx->active_req_list)) {
- CDBG("Buf done with no active request!\n");
+ CAM_DBG(CAM_ISP, "Buf done with no active request!");
goto end;
}
- CDBG("%s: Enter with bubble_state %d\n", __func__, bubble_state);
+ CAM_DBG(CAM_ISP, "Enter with bubble_state %d", bubble_state);
req = list_first_entry(&ctx->active_req_list,
struct cam_ctx_request, list);
@@ -95,29 +93,30 @@ static int __cam_isp_ctx_handle_buf_done_in_activated_state(
}
if (j == req_isp->num_fence_map_out) {
- pr_err("Can not find matching lane handle 0x%x!\n",
+ CAM_ERR(CAM_ISP,
+ "Can not find matching lane handle 0x%x!",
done->resource_handle[i]);
rc = -EINVAL;
continue;
}
if (!bubble_state) {
- CDBG("%s: Sync with success: fd 0x%x\n", __func__,
+ CAM_DBG(CAM_ISP, "Sync with success: fd 0x%x",
req_isp->fence_map_out[j].sync_id);
rc = cam_sync_signal(req_isp->fence_map_out[j].sync_id,
CAM_SYNC_STATE_SIGNALED_SUCCESS);
if (rc)
- pr_err("%s: Sync failed with rc = %d\n",
- __func__, rc);
+ CAM_ERR(CAM_ISP, "Sync failed with rc = %d",
+ rc);
} else if (!req_isp->bubble_report) {
- CDBG("%s: Sync with failure: fd 0x%x\n", __func__,
+ CAM_DBG(CAM_ISP, "Sync with failure: fd 0x%x",
req_isp->fence_map_out[j].sync_id);
rc = cam_sync_signal(req_isp->fence_map_out[j].sync_id,
CAM_SYNC_STATE_SIGNALED_ERROR);
if (rc)
- pr_err("%s: Sync failed with rc = %d\n",
- __func__, rc);
+ CAM_ERR(CAM_ISP, "Sync failed with rc = %d",
+ rc);
} else {
/*
* Ignore the buffer done if bubble detect is on
@@ -130,7 +129,7 @@ static int __cam_isp_ctx_handle_buf_done_in_activated_state(
continue;
}
- CDBG("%s: req %lld, reset sync id 0x%x\n", __func__,
+ CAM_DBG(CAM_ISP, "req %lld, reset sync id 0x%x",
req->request_id,
req_isp->fence_map_out[j].sync_id);
req_isp->num_acked++;
@@ -141,8 +140,9 @@ static int __cam_isp_ctx_handle_buf_done_in_activated_state(
list_del_init(&req->list);
list_add_tail(&req->list, &ctx->free_req_list);
ctx_isp->active_req_cnt--;
- CDBG("%s: Move active request %lld to free list(cnt = %d)\n",
- __func__, req->request_id, ctx_isp->active_req_cnt);
+ CAM_DBG(CAM_ISP,
+ "Move active request %lld to free list(cnt = %d)",
+ req->request_id, ctx_isp->active_req_cnt);
}
end:
@@ -162,15 +162,17 @@ static void __cam_isp_ctx_send_sof_timestamp(
req_msg.u.frame_msg.link_hdl = ctx_isp->base->link_hdl;
req_msg.u.frame_msg.sof_status = sof_event_status;
- CDBG("%s: request id:%lld frame number:%lld SOF time stamp:0x%llx\n",
- __func__, request_id, ctx_isp->frame_id,
+ CAM_DBG(CAM_ISP,
+ "request id:%lld frame number:%lld SOF time stamp:0x%llx",
+ request_id, ctx_isp->frame_id,
ctx_isp->sof_timestamp_val);
- CDBG("%s sof status:%d\n", __func__, sof_event_status);
+ CAM_DBG(CAM_ISP, " sof status:%d", sof_event_status);
if (cam_req_mgr_notify_frame_message(&req_msg,
V4L_EVENT_CAM_REQ_MGR_SOF, V4L_EVENT_CAM_REQ_MGR_EVENT))
- pr_err("%s: Error in notifying the sof time for req id:%lld\n",
- __func__, request_id);
+ CAM_ERR(CAM_ISP,
+ "Error in notifying the sof time for req id:%lld",
+ request_id);
}
static int __cam_isp_ctx_reg_upd_in_activated_state(
@@ -182,7 +184,7 @@ static int __cam_isp_ctx_reg_upd_in_activated_state(
struct cam_isp_ctx_req *req_isp;
if (list_empty(&ctx->pending_req_list)) {
- pr_err("Reg upd ack with no pending request\n");
+ CAM_ERR(CAM_ISP, "Reg upd ack with no pending request");
goto end;
}
req = list_first_entry(&ctx->pending_req_list,
@@ -193,13 +195,14 @@ static int __cam_isp_ctx_reg_upd_in_activated_state(
if (req_isp->num_fence_map_out != 0) {
list_add_tail(&req->list, &ctx->active_req_list);
ctx_isp->active_req_cnt++;
- CDBG("%s: move request %lld to active list(cnt = %d)\n",
- __func__, req->request_id, ctx_isp->active_req_cnt);
+ CAM_DBG(CAM_ISP, "move request %lld to active list(cnt = %d)",
+ req->request_id, ctx_isp->active_req_cnt);
} else {
/* no io config, so the request is completed. */
list_add_tail(&req->list, &ctx->free_req_list);
- CDBG("%s: move active request %lld to free list(cnt = %d)\n",
- __func__, req->request_id, ctx_isp->active_req_cnt);
+ CAM_DBG(CAM_ISP,
+ "move active request %lld to free list(cnt = %d)",
+ req->request_id, ctx_isp->active_req_cnt);
}
/*
@@ -207,7 +210,7 @@ static int __cam_isp_ctx_reg_upd_in_activated_state(
* state so change substate here.
*/
ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_EPOCH;
- CDBG("%s: next substate %d\n", __func__, ctx_isp->substate_activated);
+ CAM_DBG(CAM_ISP, "next substate %d", ctx_isp->substate_activated);
end:
return rc;
@@ -235,7 +238,7 @@ static int __cam_isp_ctx_notify_sof_in_actived_state(
notify.frame_id = ctx_isp->frame_id;
ctx->ctx_crm_intf->notify_sof(¬ify);
- CDBG("%s: Notify CRM SOF frame %lld\n", __func__,
+ CAM_DBG(CAM_ISP, "Notify CRM SOF frame %lld",
ctx_isp->frame_id);
list_for_each_entry(req, &ctx->active_req_list, list) {
@@ -249,7 +252,7 @@ static int __cam_isp_ctx_notify_sof_in_actived_state(
__cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
CAM_REQ_MGR_SOF_EVENT_SUCCESS);
} else {
- pr_err("%s: Can not notify SOF to CRM\n", __func__);
+ CAM_ERR(CAM_ISP, "Can not notify SOF to CRM");
}
return 0;
@@ -263,13 +266,13 @@ static int __cam_isp_ctx_sof_in_activated_state(
struct cam_isp_hw_sof_event_data *sof_event_data = evt_data;
if (!evt_data) {
- pr_err("%s: in valid sof event data\n", __func__);
+ CAM_ERR(CAM_ISP, "in valid sof event data");
return -EINVAL;
}
ctx_isp->frame_id++;
ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
- CDBG("%s: frame id: %lld time stamp:0x%llx\n", __func__,
+ CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
ctx_isp->frame_id, ctx_isp->sof_timestamp_val);
return rc;
@@ -284,7 +287,7 @@ static int __cam_isp_ctx_reg_upd_in_sof(struct cam_isp_context *ctx_isp,
struct cam_context *ctx = ctx_isp->base;
if (ctx->state != CAM_CTX_ACTIVATED) {
- CDBG("%s: invalid RUP\n", __func__);
+ CAM_DBG(CAM_ISP, "invalid RUP");
goto end;
}
@@ -303,8 +306,9 @@ static int __cam_isp_ctx_reg_upd_in_sof(struct cam_isp_context *ctx_isp,
/* need to handle the buf done */
list_add_tail(&req->list, &ctx->active_req_list);
ctx_isp->active_req_cnt++;
- CDBG("%s: move request %lld to active list(cnt = %d)\n",
- __func__, req->request_id,
+ CAM_DBG(CAM_ISP,
+ "move request %lld to active list(cnt = %d)",
+ req->request_id,
ctx_isp->active_req_cnt);
ctx_isp->substate_activated =
CAM_ISP_CTX_ACTIVATED_EPOCH;
@@ -327,7 +331,7 @@ static int __cam_isp_ctx_epoch_in_applied(struct cam_isp_context *ctx_isp,
* If no pending req in epoch, this is an error case.
* The recovery is to go back to sof state
*/
- pr_err("%s: No pending request\n", __func__);
+ CAM_ERR(CAM_ISP, "No pending request");
ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_SOF;
/* Send SOF event as empty frame*/
@@ -341,7 +345,7 @@ static int __cam_isp_ctx_epoch_in_applied(struct cam_isp_context *ctx_isp,
list);
req_isp = (struct cam_isp_ctx_req *)req->req_priv;
- CDBG("Report Bubble flag %d\n", req_isp->bubble_report);
+ CAM_DBG(CAM_ISP, "Report Bubble flag %d", req_isp->bubble_report);
if (req_isp->bubble_report && ctx->ctx_crm_intf &&
ctx->ctx_crm_intf->notify_err) {
struct cam_req_mgr_error_notify notify;
@@ -351,7 +355,7 @@ static int __cam_isp_ctx_epoch_in_applied(struct cam_isp_context *ctx_isp,
notify.req_id = req->request_id;
notify.error = CRM_KMD_ERR_BUBBLE;
ctx->ctx_crm_intf->notify_err(¬ify);
- CDBG("%s: Notify CRM about Bubble frame %lld\n", __func__,
+ CAM_DBG(CAM_ISP, "Notify CRM about Bubble frame %lld",
ctx_isp->frame_id);
} else {
/*
@@ -361,8 +365,8 @@ static int __cam_isp_ctx_epoch_in_applied(struct cam_isp_context *ctx_isp,
list_del_init(&req->list);
list_add_tail(&req->list, &ctx->active_req_list);
ctx_isp->active_req_cnt++;
- CDBG("%s: move request %lld to active list(cnt = %d)\n",
- __func__, req->request_id, ctx_isp->active_req_cnt);
+ CAM_DBG(CAM_ISP, "move request %lld to active list(cnt = %d)",
+ req->request_id, ctx_isp->active_req_cnt);
req_isp->bubble_report = 0;
}
@@ -371,7 +375,7 @@ static int __cam_isp_ctx_epoch_in_applied(struct cam_isp_context *ctx_isp,
CAM_REQ_MGR_SOF_EVENT_ERROR);
ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_BUBBLE;
- CDBG("%s: next substate %d\n", __func__,
+ CAM_DBG(CAM_ISP, "next substate %d",
ctx_isp->substate_activated);
end:
return 0;
@@ -398,7 +402,7 @@ static int __cam_isp_ctx_sof_in_epoch(struct cam_isp_context *ctx_isp,
struct cam_isp_hw_sof_event_data *sof_event_data = evt_data;
if (!evt_data) {
- pr_err("%s: in valid sof event data\n", __func__);
+ CAM_ERR(CAM_ISP, "in valid sof event data");
return -EINVAL;
}
@@ -408,9 +412,9 @@ static int __cam_isp_ctx_sof_in_epoch(struct cam_isp_context *ctx_isp,
if (list_empty(&ctx->active_req_list))
ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_SOF;
else
- CDBG("%s: Still need to wait for the buf done\n", __func__);
+ CAM_DBG(CAM_ISP, "Still need to wait for the buf done");
- CDBG("%s: next substate %d\n", __func__,
+ CAM_DBG(CAM_ISP, "next substate %d",
ctx_isp->substate_activated);
return rc;
@@ -456,7 +460,7 @@ static int __cam_isp_ctx_epoch_in_bubble_applied(
* If no pending req in epoch, this is an error case.
* Just go back to the bubble state.
*/
- pr_err("%s: No pending request.\n", __func__);
+ CAM_ERR(CAM_ISP, "No pending request.");
__cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
CAM_REQ_MGR_SOF_EVENT_SUCCESS);
@@ -477,7 +481,7 @@ static int __cam_isp_ctx_epoch_in_bubble_applied(
notify.req_id = req->request_id;
notify.error = CRM_KMD_ERR_BUBBLE;
ctx->ctx_crm_intf->notify_err(¬ify);
- CDBG("%s: Notify CRM about Bubble frame %lld\n", __func__,
+ CAM_DBG(CAM_ISP, "Notify CRM about Bubble frame %lld",
ctx_isp->frame_id);
} else {
/*
@@ -487,8 +491,8 @@ static int __cam_isp_ctx_epoch_in_bubble_applied(
list_del_init(&req->list);
list_add_tail(&req->list, &ctx->active_req_list);
ctx_isp->active_req_cnt++;
- CDBG("%s: move request %lld to active list(cnt = %d)\n",
- __func__, req->request_id, ctx_isp->active_req_cnt);
+ CAM_DBG(CAM_ISP, "move request %lld to active list(cnt = %d)",
+ req->request_id, ctx_isp->active_req_cnt);
req_isp->bubble_report = 0;
}
@@ -497,7 +501,7 @@ static int __cam_isp_ctx_epoch_in_bubble_applied(
CAM_REQ_MGR_SOF_EVENT_ERROR);
ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_BUBBLE;
- CDBG("%s: next substate %d\n", __func__, ctx_isp->substate_activated);
+ CAM_DBG(CAM_ISP, "next substate %d", ctx_isp->substate_activated);
end:
return 0;
}
@@ -526,7 +530,7 @@ static int __cam_isp_ctx_handle_error(struct cam_isp_context *ctx_isp,
uint32_t error_type = error_event_data->error_type;
- CDBG("%s: Enter error_type = %d\n", __func__, error_type);
+ CAM_DBG(CAM_ISP, "Enter error_type = %d", error_type);
if ((error_type == CAM_ISP_HW_ERROR_OVERFLOW) ||
(error_type == CAM_ISP_HW_ERROR_BUSIF_OVERFLOW))
notify.error = CRM_KMD_ERR_FATAL;
@@ -538,7 +542,7 @@ static int __cam_isp_ctx_handle_error(struct cam_isp_context *ctx_isp,
*/
if (list_empty(&ctx->active_req_list)) {
- pr_err("handling error with no active request!\n");
+ CAM_ERR(CAM_ISP, "handling error with no active request");
rc = -EINVAL;
goto end;
}
@@ -552,10 +556,10 @@ static int __cam_isp_ctx_handle_error(struct cam_isp_context *ctx_isp,
notify.req_id = req->request_id;
ctx->ctx_crm_intf->notify_err(¬ify);
- pr_err("%s: Notify CRM about ERROR frame %lld\n", __func__,
+ CAM_ERR(CAM_ISP, "Notify CRM about ERROR frame %lld",
ctx_isp->frame_id);
} else {
- pr_err("%s: Can not notify ERRROR to CRM\n", __func__);
+ CAM_ERR(CAM_ISP, "Can not notify ERRROR to CRM");
rc = -EFAULT;
}
@@ -564,7 +568,7 @@ static int __cam_isp_ctx_handle_error(struct cam_isp_context *ctx_isp,
/* might need to check if active list is empty */
end:
- CDBG("%s: Exit\n", __func__);
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -641,8 +645,8 @@ static int __cam_isp_ctx_apply_req_in_activated_state(
struct cam_hw_config_args cfg;
if (list_empty(&ctx->pending_req_list)) {
- pr_err("%s: No available request for Apply id %lld\n",
- __func__, apply->request_id);
+ CAM_ERR(CAM_ISP, "No available request for Apply id %lld",
+ apply->request_id);
rc = -EFAULT;
goto end;
}
@@ -655,8 +659,9 @@ static int __cam_isp_ctx_apply_req_in_activated_state(
*/
ctx_isp = (struct cam_isp_context *) ctx->ctx_priv;
if (ctx_isp->active_req_cnt >= 2) {
- CDBG("%s: Reject apply request due to congestion(cnt = %d)\n",
- __func__, ctx_isp->active_req_cnt);
+ CAM_DBG(CAM_ISP,
+ "Reject apply request due to congestion(cnt = %d)",
+ ctx_isp->active_req_cnt);
rc = -EFAULT;
goto end;
}
@@ -673,7 +678,7 @@ static int __cam_isp_ctx_apply_req_in_activated_state(
goto end;
}
- CDBG("%s: Apply request %lld\n", __func__, req->request_id);
+ CAM_DBG(CAM_ISP, "Apply request %lld", req->request_id);
req_isp = (struct cam_isp_ctx_req *) req->req_priv;
req_isp->bubble_report = apply->report_if_bubble;
@@ -684,11 +689,11 @@ static int __cam_isp_ctx_apply_req_in_activated_state(
rc = ctx->hw_mgr_intf->hw_config(ctx->hw_mgr_intf->hw_mgr_priv, &cfg);
if (rc) {
- pr_err("%s: Can not apply the configuration\n", __func__);
+ CAM_ERR(CAM_ISP, "Can not apply the configuration");
} else {
spin_lock_bh(&ctx->lock);
ctx_isp->substate_activated = next_state;
- CDBG("%s: new state %d\n", __func__, next_state);
+ CAM_DBG(CAM_ISP, "new state %d", next_state);
spin_unlock_bh(&ctx->lock);
}
end:
@@ -702,11 +707,11 @@ static int __cam_isp_ctx_apply_req_in_sof(
struct cam_isp_context *ctx_isp =
(struct cam_isp_context *) ctx->ctx_priv;
- CDBG("%s: current substate %d\n", __func__,
+ CAM_DBG(CAM_ISP, "current substate %d",
ctx_isp->substate_activated);
rc = __cam_isp_ctx_apply_req_in_activated_state(ctx, apply,
CAM_ISP_CTX_ACTIVATED_APPLIED);
- CDBG("%s: new substate %d\n", __func__, ctx_isp->substate_activated);
+ CAM_DBG(CAM_ISP, "new substate %d", ctx_isp->substate_activated);
return rc;
}
@@ -718,11 +723,11 @@ static int __cam_isp_ctx_apply_req_in_epoch(
struct cam_isp_context *ctx_isp =
(struct cam_isp_context *) ctx->ctx_priv;
- CDBG("%s: current substate %d\n", __func__,
+ CAM_DBG(CAM_ISP, "current substate %d",
ctx_isp->substate_activated);
rc = __cam_isp_ctx_apply_req_in_activated_state(ctx, apply,
CAM_ISP_CTX_ACTIVATED_APPLIED);
- CDBG("%s: new substate %d\n", __func__, ctx_isp->substate_activated);
+ CAM_DBG(CAM_ISP, "new substate %d", ctx_isp->substate_activated);
return rc;
}
@@ -734,11 +739,11 @@ static int __cam_isp_ctx_apply_req_in_bubble(
struct cam_isp_context *ctx_isp =
(struct cam_isp_context *) ctx->ctx_priv;
- CDBG("%s: current substate %d\n", __func__,
+ CAM_DBG(CAM_ISP, "current substate %d",
ctx_isp->substate_activated);
rc = __cam_isp_ctx_apply_req_in_activated_state(ctx, apply,
CAM_ISP_CTX_ACTIVATED_BUBBLE_APPLIED);
- CDBG("%s: new substate %d\n", __func__, ctx_isp->substate_activated);
+ CAM_DBG(CAM_ISP, "new substate %d", ctx_isp->substate_activated);
return rc;
}
@@ -755,7 +760,7 @@ static int __cam_isp_ctx_flush_req(struct cam_context *ctx,
spin_lock(&ctx->lock);
if (list_empty(req_list)) {
spin_unlock(&ctx->lock);
- CDBG("%s: request list is empty\n", __func__);
+ CAM_DBG(CAM_ISP, "request list is empty");
return 0;
}
@@ -768,15 +773,15 @@ static int __cam_isp_ctx_flush_req(struct cam_context *ctx,
req_isp = (struct cam_isp_ctx_req *) req->req_priv;
for (i = 0; i < req_isp->num_fence_map_out; i++) {
if (req_isp->fence_map_out[i].sync_id != -1) {
- CDBG("%s: Flush req 0x%llx, fence %d\n",
- __func__, req->request_id,
+ CAM_DBG(CAM_ISP, "Flush req 0x%llx, fence %d",
+ req->request_id,
req_isp->fence_map_out[i].sync_id);
rc = cam_sync_signal(
req_isp->fence_map_out[i].sync_id,
CAM_SYNC_STATE_SIGNALED_ERROR);
if (rc)
- pr_err_ratelimited("%s: signal fence failed\n",
- __func__);
+ CAM_ERR_RATE_LIMIT(CAM_ISP,
+ "signal fence failed\n");
req_isp->fence_map_out[i].sync_id = -1;
}
}
@@ -792,8 +797,9 @@ static int __cam_isp_ctx_flush_req(struct cam_context *ctx,
if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ &&
!cancel_req_id_found)
- CDBG("%s:Flush request id:%lld is not found in the list\n",
- __func__, flush_req->req_id);
+ CAM_DBG(CAM_ISP,
+ "Flush request id:%lld is not found in the list",
+ flush_req->req_id);
return 0;
}
@@ -804,10 +810,10 @@ static int __cam_isp_ctx_flush_req_in_top_state(
{
int rc = 0;
- CDBG("%s: try to flush pending list\n", __func__);
+ CAM_DBG(CAM_ISP, "try to flush pending list");
rc = __cam_isp_ctx_flush_req(ctx, &ctx->pending_req_list, flush_req);
- CDBG("%s: Flush request in top state %d\n",
- __func__, ctx->state);
+ CAM_DBG(CAM_ISP, "Flush request in top state %d",
+ ctx->state);
return rc;
}
@@ -817,7 +823,7 @@ static int __cam_isp_ctx_flush_req_in_ready(
{
int rc = 0;
- CDBG("%s: try to flush pending list\n", __func__);
+ CAM_DBG(CAM_ISP, "try to flush pending list");
rc = __cam_isp_ctx_flush_req(ctx, &ctx->pending_req_list, flush_req);
/* if nothing is in pending req list, change state to acquire*/
@@ -828,8 +834,8 @@ static int __cam_isp_ctx_flush_req_in_ready(
trace_cam_context_state("ISP", ctx);
- CDBG("%s: Flush request in ready state. next state %d\n",
- __func__, ctx->state);
+ CAM_DBG(CAM_ISP, "Flush request in ready state. next state %d",
+ ctx->state);
return rc;
}
@@ -879,6 +885,412 @@ static struct cam_ctx_ops
},
};
+static int __cam_isp_ctx_rdi_only_sof_in_top_state(
+ struct cam_isp_context *ctx_isp, void *evt_data)
+{
+ int rc = 0;
+ struct cam_context *ctx = ctx_isp->base;
+ struct cam_req_mgr_sof_notify notify;
+ struct cam_isp_hw_sof_event_data *sof_event_data = evt_data;
+ uint64_t request_id = 0;
+
+ if (!evt_data) {
+ CAM_ERR(CAM_ISP, "in valid sof event data");
+ return -EINVAL;
+ }
+
+ ctx_isp->frame_id++;
+ ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
+ CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
+ ctx_isp->frame_id, ctx_isp->sof_timestamp_val);
+
+ /*
+ * notify reqmgr with sof signal. Note, due to scheduling delay
+ * we can run into situation that two active requests has already
+ * be in the active queue while we try to do the notification.
+ * In this case, we need to skip the current notification. This
+ * helps the state machine to catch up the delay.
+ */
+ if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_sof &&
+ ctx_isp->active_req_cnt <= 2) {
+ notify.link_hdl = ctx->link_hdl;
+ notify.dev_hdl = ctx->dev_hdl;
+ notify.frame_id = ctx_isp->frame_id;
+
+ ctx->ctx_crm_intf->notify_sof(¬ify);
+ CAM_DBG(CAM_ISP, "Notify CRM SOF frame %lld",
+ ctx_isp->frame_id);
+
+ /*
+ * It is idle frame with out any applied request id, send
+ * request id as zero
+ */
+ __cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
+ CAM_REQ_MGR_SOF_EVENT_SUCCESS);
+ } else {
+ CAM_ERR(CAM_ISP, "Can not notify SOF to CRM");
+ }
+
+ if (list_empty(&ctx->active_req_list))
+ ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_SOF;
+ else
+ CAM_DBG(CAM_ISP, "Still need to wait for the buf done");
+
+ CAM_DBG(CAM_ISP, "next substate %d",
+ ctx_isp->substate_activated);
+ return rc;
+}
+
+static int __cam_isp_ctx_rdi_only_sof_in_applied_state(
+ struct cam_isp_context *ctx_isp, void *evt_data)
+{
+ struct cam_isp_hw_sof_event_data *sof_event_data = evt_data;
+
+ if (!evt_data) {
+ CAM_ERR(CAM_ISP, "in valid sof event data");
+ return -EINVAL;
+ }
+
+ ctx_isp->frame_id++;
+ ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
+ CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
+ ctx_isp->frame_id, ctx_isp->sof_timestamp_val);
+
+ ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_BUBBLE_APPLIED;
+ CAM_DBG(CAM_ISP, "next substate %d", ctx_isp->substate_activated);
+
+ return 0;
+}
+
+static int __cam_isp_ctx_rdi_only_sof_in_bubble_applied(
+ struct cam_isp_context *ctx_isp, void *evt_data)
+{
+ struct cam_ctx_request *req;
+ struct cam_isp_ctx_req *req_isp;
+ struct cam_context *ctx = ctx_isp->base;
+ struct cam_isp_hw_sof_event_data *sof_event_data = evt_data;
+ uint64_t request_id = 0;
+
+ ctx_isp->frame_id++;
+ ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
+ CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
+ ctx_isp->frame_id, ctx_isp->sof_timestamp_val);
+
+ if (list_empty(&ctx->pending_req_list)) {
+ /*
+ * If no pending req in epoch, this is an error case.
+ * The recovery is to go back to sof state
+ */
+ CAM_ERR(CAM_ISP, "No pending request");
+ ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_SOF;
+
+ /* Send SOF event as empty frame*/
+ __cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
+ CAM_REQ_MGR_SOF_EVENT_SUCCESS);
+
+ goto end;
+ }
+
+ req = list_first_entry(&ctx->pending_req_list, struct cam_ctx_request,
+ list);
+ req_isp = (struct cam_isp_ctx_req *)req->req_priv;
+
+ CAM_DBG(CAM_ISP, "Report Bubble flag %d", req_isp->bubble_report);
+ if (req_isp->bubble_report && ctx->ctx_crm_intf &&
+ ctx->ctx_crm_intf->notify_err) {
+ struct cam_req_mgr_error_notify notify;
+
+ notify.link_hdl = ctx->link_hdl;
+ notify.dev_hdl = ctx->dev_hdl;
+ notify.req_id = req->request_id;
+ notify.error = CRM_KMD_ERR_BUBBLE;
+ ctx->ctx_crm_intf->notify_err(¬ify);
+ CAM_DBG(CAM_ISP, "Notify CRM about Bubble frame %lld",
+ ctx_isp->frame_id);
+ } else {
+ /*
+ * Since can not bubble report, always move the request to
+ * active list.
+ */
+ list_del_init(&req->list);
+ list_add_tail(&req->list, &ctx->active_req_list);
+ ctx_isp->active_req_cnt++;
+ CAM_DBG(CAM_ISP, "move request %lld to active list(cnt = %d)",
+ req->request_id, ctx_isp->active_req_cnt);
+ req_isp->bubble_report = 0;
+ }
+
+ request_id = req->request_id;
+ __cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
+ CAM_REQ_MGR_SOF_EVENT_ERROR);
+
+ /* change the state to bubble, as reg update has not come */
+ ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_BUBBLE;
+ CAM_DBG(CAM_ISP, "next substate %d", ctx_isp->substate_activated);
+end:
+ return 0;
+}
+
+static int __cam_isp_ctx_rdi_only_sof_in_bubble_state(
+ struct cam_isp_context *ctx_isp, void *evt_data)
+{
+ uint32_t i;
+ struct cam_ctx_request *req;
+ struct cam_context *ctx = ctx_isp->base;
+ struct cam_req_mgr_sof_notify notify;
+ struct cam_isp_hw_sof_event_data *sof_event_data = evt_data;
+ struct cam_isp_ctx_req *req_isp;
+ uint64_t request_id = 0;
+
+ if (!evt_data) {
+ CAM_ERR(CAM_ISP, "in valid sof event data");
+ return -EINVAL;
+ }
+
+ ctx_isp->frame_id++;
+ ctx_isp->sof_timestamp_val = sof_event_data->timestamp;
+ CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx",
+ ctx_isp->frame_id, ctx_isp->sof_timestamp_val);
+ /*
+ * Signal all active requests with error and move the all the active
+ * requests to free list
+ */
+ while (!list_empty(&ctx->active_req_list)) {
+ req = list_first_entry(&ctx->active_req_list,
+ struct cam_ctx_request, list);
+ list_del_init(&req->list);
+ req_isp = (struct cam_isp_ctx_req *) req->req_priv;
+ CAM_DBG(CAM_ISP, "signal fence in active list. fence num %d",
+ req_isp->num_fence_map_out);
+ for (i = 0; i < req_isp->num_fence_map_out; i++)
+ if (req_isp->fence_map_out[i].sync_id != -1) {
+ cam_sync_signal(
+ req_isp->fence_map_out[i].sync_id,
+ CAM_SYNC_STATE_SIGNALED_ERROR);
+ }
+ list_add_tail(&req->list, &ctx->free_req_list);
+ }
+
+ /* notify reqmgr with sof signal */
+ if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_sof) {
+ notify.link_hdl = ctx->link_hdl;
+ notify.dev_hdl = ctx->dev_hdl;
+ notify.frame_id = ctx_isp->frame_id;
+
+ ctx->ctx_crm_intf->notify_sof(¬ify);
+ CAM_DBG(CAM_ISP, "Notify CRM SOF frame %lld",
+ ctx_isp->frame_id);
+
+ } else {
+ CAM_ERR(CAM_ISP, "Can not notify SOF to CRM");
+ }
+
+ /*
+ * It is idle frame with out any applied request id, send
+ * request id as zero
+ */
+ __cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
+ CAM_REQ_MGR_SOF_EVENT_SUCCESS);
+
+ ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_SOF;
+
+ CAM_DBG(CAM_ISP, "next substate %d",
+ ctx_isp->substate_activated);
+
+ return 0;
+}
+
+static int __cam_isp_ctx_rdi_only_reg_upd_in_bubble_applied_state(
+ struct cam_isp_context *ctx_isp, void *evt_data)
+{
+ struct cam_ctx_request *req;
+ struct cam_context *ctx = ctx_isp->base;
+ struct cam_isp_ctx_req *req_isp;
+ struct cam_req_mgr_sof_notify notify;
+ uint64_t request_id = 0;
+
+ /* notify reqmgr with sof signal*/
+ if (ctx->ctx_crm_intf && ctx->ctx_crm_intf->notify_sof) {
+ if (list_empty(&ctx->pending_req_list)) {
+ CAM_ERR(CAM_ISP, "Reg upd ack with no pending request");
+ goto error;
+ }
+ req = list_first_entry(&ctx->pending_req_list,
+ struct cam_ctx_request, list);
+ list_del_init(&req->list);
+
+ req_isp = (struct cam_isp_ctx_req *) req->req_priv;
+ request_id = req->request_id;
+ if (req_isp->num_fence_map_out != 0) {
+ list_add_tail(&req->list, &ctx->active_req_list);
+ ctx_isp->active_req_cnt++;
+ CAM_DBG(CAM_ISP,
+ "move request %lld to active list(cnt = %d)",
+ req->request_id, ctx_isp->active_req_cnt);
+ } else {
+ /* no io config, so the request is completed. */
+ list_add_tail(&req->list, &ctx->free_req_list);
+ CAM_DBG(CAM_ISP,
+ "move active req %lld to free list(cnt=%d)",
+ req->request_id, ctx_isp->active_req_cnt);
+ }
+
+ notify.link_hdl = ctx->link_hdl;
+ notify.dev_hdl = ctx->dev_hdl;
+ notify.frame_id = ctx_isp->frame_id;
+
+ ctx->ctx_crm_intf->notify_sof(¬ify);
+ CAM_DBG(CAM_ISP, "Notify CRM SOF frame %lld",
+ ctx_isp->frame_id);
+ } else {
+ CAM_ERR(CAM_ISP, "Can not notify SOF to CRM");
+ }
+ __cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
+ CAM_REQ_MGR_SOF_EVENT_SUCCESS);
+
+ ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_EPOCH;
+ CAM_DBG(CAM_ISP, "next substate %d", ctx_isp->substate_activated);
+
+ return 0;
+error:
+ /* Send SOF event as idle frame*/
+ __cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id,
+ CAM_REQ_MGR_SOF_EVENT_SUCCESS);
+
+ /*
+ * There is no request in the pending list, move the sub state machine
+ * to SOF sub state
+ */
+ ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_SOF;
+
+ return 0;
+}
+
+static struct cam_isp_ctx_irq_ops
+ cam_isp_ctx_rdi_only_activated_state_machine_irq
+ [CAM_ISP_CTX_ACTIVATED_MAX] = {
+ /* SOF */
+ {
+ .irq_ops = {
+ NULL,
+ __cam_isp_ctx_rdi_only_sof_in_top_state,
+ __cam_isp_ctx_reg_upd_in_sof,
+ NULL,
+ NULL,
+ NULL,
+ },
+ },
+ /* APPLIED */
+ {
+ .irq_ops = {
+ __cam_isp_ctx_handle_error,
+ __cam_isp_ctx_rdi_only_sof_in_applied_state,
+ NULL,
+ NULL,
+ NULL,
+ __cam_isp_ctx_buf_done_in_applied,
+ },
+ },
+ /* EPOCH */
+ {
+ .irq_ops = {
+ __cam_isp_ctx_handle_error,
+ __cam_isp_ctx_rdi_only_sof_in_top_state,
+ NULL,
+ NULL,
+ NULL,
+ __cam_isp_ctx_buf_done_in_epoch,
+ },
+ },
+ /* BUBBLE*/
+ {
+ .irq_ops = {
+ __cam_isp_ctx_handle_error,
+ __cam_isp_ctx_rdi_only_sof_in_bubble_state,
+ NULL,
+ NULL,
+ NULL,
+ __cam_isp_ctx_buf_done_in_bubble,
+ },
+ },
+ /* BUBBLE APPLIED ie PRE_BUBBLE */
+ {
+ .irq_ops = {
+ __cam_isp_ctx_handle_error,
+ __cam_isp_ctx_rdi_only_sof_in_bubble_applied,
+ __cam_isp_ctx_rdi_only_reg_upd_in_bubble_applied_state,
+ NULL,
+ NULL,
+ __cam_isp_ctx_buf_done_in_bubble_applied,
+ },
+ },
+
+ /* HALT */
+ {
+ },
+};
+
+static int __cam_isp_ctx_rdi_only_apply_req_top_state(
+ struct cam_context *ctx, struct cam_req_mgr_apply_request *apply)
+{
+ int rc = 0;
+ struct cam_isp_context *ctx_isp =
+ (struct cam_isp_context *) ctx->ctx_priv;
+
+ CAM_DBG(CAM_ISP, "current substate %d",
+ ctx_isp->substate_activated);
+ rc = __cam_isp_ctx_apply_req_in_activated_state(ctx, apply,
+ CAM_ISP_CTX_ACTIVATED_APPLIED);
+ CAM_DBG(CAM_ISP, "new substate %d", ctx_isp->substate_activated);
+
+ return rc;
+}
+
+static struct cam_ctx_ops
+ cam_isp_ctx_rdi_only_activated_state_machine
+ [CAM_ISP_CTX_ACTIVATED_MAX] = {
+ /* SOF */
+ {
+ .ioctl_ops = {},
+ .crm_ops = {
+ .apply_req = __cam_isp_ctx_rdi_only_apply_req_top_state,
+ },
+ .irq_ops = NULL,
+ },
+ /* APPLIED */
+ {
+ .ioctl_ops = {},
+ .crm_ops = {},
+ .irq_ops = NULL,
+ },
+ /* EPOCH */
+ {
+ .ioctl_ops = {},
+ .crm_ops = {
+ .apply_req = __cam_isp_ctx_rdi_only_apply_req_top_state,
+ },
+ .irq_ops = NULL,
+ },
+ /* PRE BUBBLE */
+ {
+ .ioctl_ops = {},
+ .crm_ops = {},
+ .irq_ops = NULL,
+ },
+ /* BUBBLE */
+ {
+ .ioctl_ops = {},
+ .crm_ops = {},
+ .irq_ops = NULL,
+ },
+ /* HALT */
+ {
+ .ioctl_ops = {},
+ .crm_ops = {},
+ .irq_ops = NULL,
+ },
+};
+
/* top level state machine */
static int __cam_isp_ctx_release_dev_in_top_state(struct cam_context *ctx,
@@ -910,20 +1322,20 @@ static int __cam_isp_ctx_release_dev_in_top_state(struct cam_context *ctx,
* But we still add some sanity check code here to help the debug
*/
if (!list_empty(&ctx->active_req_list))
- pr_err("%s: Active list is not empty\n", __func__);
+ CAM_ERR(CAM_ISP, "Active list is not empty");
/* Flush all the pending request list */
flush_req.type = CAM_REQ_MGR_FLUSH_TYPE_ALL;
flush_req.link_hdl = ctx->link_hdl;
flush_req.dev_hdl = ctx->dev_hdl;
- CDBG("%s: try to flush pending list\n", __func__);
+ CAM_DBG(CAM_ISP, "try to flush pending list");
rc = __cam_isp_ctx_flush_req(ctx, &ctx->pending_req_list, &flush_req);
ctx->state = CAM_CTX_AVAILABLE;
trace_cam_context_state("ISP", ctx);
- CDBG("%s: next state %d\n", __func__, ctx->state);
+ CAM_DBG(CAM_ISP, "next state %d", ctx->state);
return rc;
}
@@ -941,7 +1353,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
struct cam_isp_context *ctx_isp =
(struct cam_isp_context *) ctx->ctx_priv;
- CDBG("%s: get free request object......\n", __func__);
+ CAM_DBG(CAM_ISP, "get free request object......");
/* get free request */
spin_lock_bh(&ctx->lock);
@@ -953,7 +1365,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
spin_unlock_bh(&ctx->lock);
if (!req) {
- pr_err("%s: No more request obj free\n", __func__);
+ CAM_ERR(CAM_ISP, "No more request obj free");
rc = -ENOMEM;
goto end;
}
@@ -965,20 +1377,20 @@ static int __cam_isp_ctx_config_dev_in_top_state(
rc = cam_mem_get_cpu_buf((int32_t) cmd->packet_handle,
(uint64_t *) &packet_addr, &len);
if (rc != 0) {
- pr_err("%s: Can not get packet address\n", __func__);
+ CAM_ERR(CAM_ISP, "Can not get packet address");
rc = -EINVAL;
goto free_req;
}
packet = (struct cam_packet *) (packet_addr + cmd->offset);
- CDBG("%s: pack_handle %llx\n", __func__, cmd->packet_handle);
- CDBG("%s: packet address is 0x%llx\n", __func__, packet_addr);
- CDBG("%s: packet with length %zu, offset 0x%llx\n", __func__,
+ CAM_DBG(CAM_ISP, "pack_handle %llx", cmd->packet_handle);
+ CAM_DBG(CAM_ISP, "packet address is 0x%llx", packet_addr);
+ CAM_DBG(CAM_ISP, "packet with length %zu, offset 0x%llx",
len, cmd->offset);
- CDBG("%s: Packet request id %lld\n", __func__,
+ CAM_DBG(CAM_ISP, "Packet request id %lld",
packet->header.request_id);
- CDBG("%s: Packet size 0x%x\n", __func__, packet->header.size);
- CDBG("%s: packet op %d\n", __func__, packet->header.op_code);
+ CAM_DBG(CAM_ISP, "Packet size 0x%x", packet->header.size);
+ CAM_DBG(CAM_ISP, "packet op %d", packet->header.op_code);
/* preprocess the configuration */
memset(&cfg, 0, sizeof(cfg));
@@ -991,13 +1403,12 @@ static int __cam_isp_ctx_config_dev_in_top_state(
cfg.out_map_entries = req_isp->fence_map_out;
cfg.in_map_entries = req_isp->fence_map_in;
- CDBG("%s: try to prepare config packet......\n", __func__);
+ CAM_DBG(CAM_ISP, "try to prepare config packet......");
rc = ctx->hw_mgr_intf->hw_prepare_update(
ctx->hw_mgr_intf->hw_mgr_priv, &cfg);
if (rc != 0) {
- pr_err("%s: Prepare config packet failed in HW layer\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Prepare config packet failed in HW layer");
rc = -EFAULT;
goto free_req;
}
@@ -1006,8 +1417,8 @@ static int __cam_isp_ctx_config_dev_in_top_state(
req_isp->num_fence_map_in = cfg.num_in_map_entries;
req_isp->num_acked = 0;
- CDBG("%s: num_entry: %d, num fence out: %d, num fence in: %d\n",
- __func__, req_isp->num_cfg, req_isp->num_fence_map_out,
+ CAM_DBG(CAM_ISP, "num_entry: %d, num fence out: %d, num fence in: %d",
+ req_isp->num_cfg, req_isp->num_fence_map_out,
req_isp->num_fence_map_in);
req->request_id = packet->header.request_id;
@@ -1019,20 +1430,20 @@ static int __cam_isp_ctx_config_dev_in_top_state(
add_req.req_id = req->request_id;
rc = ctx->ctx_crm_intf->add_req(&add_req);
if (rc) {
- pr_err("%s: Error: Adding request id=%llu\n", __func__,
+ CAM_ERR(CAM_ISP, "Error: Adding request id=%llu",
req->request_id);
goto free_req;
}
}
- CDBG("%s: Packet request id 0x%llx\n", __func__,
+ CAM_DBG(CAM_ISP, "Packet request id 0x%llx",
packet->header.request_id);
spin_lock_bh(&ctx->lock);
list_add_tail(&req->list, &ctx->pending_req_list);
spin_unlock_bh(&ctx->lock);
- CDBG("%s: Preprocessing Config %lld successful\n", __func__,
+ CAM_DBG(CAM_ISP, "Preprocessing Config %lld successful",
req->request_id);
return rc;
@@ -1055,26 +1466,28 @@ static int __cam_isp_ctx_acquire_dev_in_available(struct cam_context *ctx,
struct cam_hw_release_args release;
struct cam_isp_context *ctx_isp =
(struct cam_isp_context *) ctx->ctx_priv;
+ struct cam_isp_hw_cmd_args hw_cmd_args;
if (!ctx->hw_mgr_intf) {
- pr_err("HW interface is not ready!\n");
+ CAM_ERR(CAM_ISP, "HW interface is not ready");
rc = -EFAULT;
goto end;
}
- CDBG("%s: session_hdl 0x%x, num_resources %d, hdl type %d, res %lld\n",
- __func__, cmd->session_handle, cmd->num_resources,
+ CAM_DBG(CAM_ISP,
+ "session_hdl 0x%x, num_resources %d, hdl type %d, res %lld",
+ cmd->session_handle, cmd->num_resources,
cmd->handle_type, cmd->resource_hdl);
if (cmd->num_resources > CAM_ISP_CTX_RES_MAX) {
- pr_err("Too much resources in the acquire!\n");
+ CAM_ERR(CAM_ISP, "Too much resources in the acquire");
rc = -ENOMEM;
goto end;
}
/* for now we only support user pointer */
if (cmd->handle_type != 1) {
- pr_err("%s: Only user pointer is supported!", __func__);
+ CAM_ERR(CAM_ISP, "Only user pointer is supported");
rc = -EINVAL;
goto end;
}
@@ -1086,8 +1499,8 @@ static int __cam_isp_ctx_acquire_dev_in_available(struct cam_context *ctx,
goto end;
}
- CDBG("%s: start copy %d resources from user\n",
- __func__, cmd->num_resources);
+ CAM_DBG(CAM_ISP, "start copy %d resources from user",
+ cmd->num_resources);
if (copy_from_user(isp_res, (void __user *)cmd->resource_hdl,
sizeof(*isp_res)*cmd->num_resources)) {
@@ -1104,10 +1517,39 @@ static int __cam_isp_ctx_acquire_dev_in_available(struct cam_context *ctx,
rc = ctx->hw_mgr_intf->hw_acquire(ctx->hw_mgr_intf->hw_mgr_priv,
¶m);
if (rc != 0) {
- pr_err("Acquire device failed\n");
+ CAM_ERR(CAM_ISP, "Acquire device failed");
goto free_res;
}
+ /* Query the context has rdi only resource */
+ hw_cmd_args.ctxt_to_hw_map = param.ctxt_to_hw_map;
+ hw_cmd_args.cmd_type = CAM_ISP_HW_MGR_CMD_IS_RDI_ONLY_CONTEXT;
+ rc = ctx->hw_mgr_intf->hw_cmd(ctx->hw_mgr_intf->hw_mgr_priv,
+ &hw_cmd_args);
+ if (rc) {
+ CAM_ERR(CAM_ISP, "HW command failed");
+ goto free_hw;
+ }
+
+ if (hw_cmd_args.u.is_rdi_only_context) {
+ /*
+ * this context has rdi only resource assign rdi only
+ * state machine
+ */
+ CAM_DBG(CAM_ISP, "RDI only session Context");
+
+ ctx_isp->substate_machine_irq =
+ cam_isp_ctx_rdi_only_activated_state_machine_irq;
+ ctx_isp->substate_machine =
+ cam_isp_ctx_rdi_only_activated_state_machine;
+ } else {
+ CAM_DBG(CAM_ISP, "Session has PIX or PIX and RDI resources");
+ ctx_isp->substate_machine_irq =
+ cam_isp_ctx_activated_state_machine_irq;
+ ctx_isp->substate_machine =
+ cam_isp_ctx_activated_state_machine;
+ }
+
ctx_isp->hw_ctx = param.ctxt_to_hw_map;
req_hdl_param.session_hdl = cmd->session_handle;
@@ -1117,11 +1559,11 @@ static int __cam_isp_ctx_acquire_dev_in_available(struct cam_context *ctx,
req_hdl_param.ops = ctx->crm_ctx_intf;
req_hdl_param.priv = ctx;
- CDBG("%s: get device handle form bridge\n", __func__);
+ CAM_DBG(CAM_ISP, "get device handle form bridge");
ctx->dev_hdl = cam_create_device_hdl(&req_hdl_param);
if (ctx->dev_hdl <= 0) {
rc = -EFAULT;
- pr_err("Can not create device handle\n");
+ CAM_ERR(CAM_ISP, "Can not create device handle");
goto free_hw;
}
cmd->dev_handle = ctx->dev_hdl;
@@ -1132,7 +1574,7 @@ static int __cam_isp_ctx_acquire_dev_in_available(struct cam_context *ctx,
ctx->state = CAM_CTX_ACQUIRED;
trace_cam_context_state("ISP", ctx);
- CDBG("%s:%d: Acquire success.\n", __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "Acquire success.");
kfree(isp_res);
return rc;
@@ -1158,7 +1600,7 @@ static int __cam_isp_ctx_config_dev_in_acquired(struct cam_context *ctx,
trace_cam_context_state("ISP", ctx);
}
- CDBG("%s: next state %d\n", __func__, ctx->state);
+ CAM_DBG(CAM_ISP, "next state %d", ctx->state);
return rc;
}
@@ -1167,7 +1609,7 @@ static int __cam_isp_ctx_link_in_acquired(struct cam_context *ctx,
{
int rc = 0;
- CDBG("%s:%d: Enter.........\n", __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "Enter.........");
ctx->link_hdl = link->link_hdl;
ctx->ctx_crm_intf = link->crm_cb;
@@ -1178,7 +1620,7 @@ static int __cam_isp_ctx_link_in_acquired(struct cam_context *ctx,
trace_cam_context_state("ISP", ctx);
}
- CDBG("%s: next state %d\n", __func__, ctx->state);
+ CAM_DBG(CAM_ISP, "next state %d", ctx->state);
return rc;
}
@@ -1225,8 +1667,7 @@ static int __cam_isp_ctx_start_dev_in_ready(struct cam_context *ctx,
if (list_empty(&ctx->pending_req_list)) {
/* should never happen */
- pr_err("%s: Start device with empty configuration\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Start device with empty configuration");
rc = -EFAULT;
goto end;
} else {
@@ -1236,8 +1677,7 @@ static int __cam_isp_ctx_start_dev_in_ready(struct cam_context *ctx,
req_isp = (struct cam_isp_ctx_req *) req->req_priv;
if (!ctx_isp->hw_ctx) {
- pr_err("%s:%d: Wrong hw context pointer.\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Wrong hw context pointer.");
rc = -EFAULT;
goto end;
}
@@ -1260,12 +1700,12 @@ static int __cam_isp_ctx_start_dev_in_ready(struct cam_context *ctx,
rc = ctx->hw_mgr_intf->hw_start(ctx->hw_mgr_intf->hw_mgr_priv, &arg);
if (rc) {
/* HW failure. user need to clean up the resource */
- pr_err("Start HW failed\n");
+ CAM_ERR(CAM_ISP, "Start HW failed");
ctx->state = CAM_CTX_READY;
trace_cam_context_state("ISP", ctx);
goto end;
}
- CDBG("%s: start device success\n", __func__);
+ CAM_DBG(CAM_ISP, "start device success");
end:
return rc;
}
@@ -1298,7 +1738,7 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
spin_lock_bh(&ctx->lock);
ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_HALT;
spin_unlock_bh(&ctx->lock);
- CDBG("%s: next substate %d", __func__, ctx_isp->substate_activated);
+ CAM_DBG(CAM_ISP, "next substate %d", ctx_isp->substate_activated);
/* stop hw first */
if (ctx_isp->hw_ctx) {
@@ -1312,8 +1752,8 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
struct cam_ctx_request, list);
list_del_init(&req->list);
req_isp = (struct cam_isp_ctx_req *) req->req_priv;
- CDBG("%s: signal fence in pending list. fence num %d\n",
- __func__, req_isp->num_fence_map_out);
+ CAM_DBG(CAM_ISP, "signal fence in pending list. fence num %d",
+ req_isp->num_fence_map_out);
for (i = 0; i < req_isp->num_fence_map_out; i++)
if (req_isp->fence_map_out[i].sync_id != -1) {
cam_sync_signal(
@@ -1328,8 +1768,8 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
struct cam_ctx_request, list);
list_del_init(&req->list);
req_isp = (struct cam_isp_ctx_req *) req->req_priv;
- CDBG("%s: signal fence in active list. fence num %d\n",
- __func__, req_isp->num_fence_map_out);
+ CAM_DBG(CAM_ISP, "signal fence in active list. fence num %d",
+ req_isp->num_fence_map_out);
for (i = 0; i < req_isp->num_fence_map_out; i++)
if (req_isp->fence_map_out[i].sync_id != -1) {
cam_sync_signal(
@@ -1342,7 +1782,7 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
ctx_isp->active_req_cnt = 0;
ctx_isp->reported_req_id = 0;
- CDBG("%s: next state %d", __func__, ctx->state);
+ CAM_DBG(CAM_ISP, "next state %d", ctx->state);
return rc;
}
@@ -1394,21 +1834,21 @@ static int __cam_isp_ctx_apply_req(struct cam_context *ctx,
(struct cam_isp_context *) ctx->ctx_priv;
trace_cam_apply_req("ISP", apply);
- CDBG("%s: Enter: apply req in Substate %d request _id:%lld\n",
- __func__, ctx_isp->substate_activated, apply->request_id);
+ CAM_DBG(CAM_ISP, "Enter: apply req in Substate %d request _id:%lld",
+ ctx_isp->substate_activated, apply->request_id);
if (ctx_isp->substate_machine[ctx_isp->substate_activated].
crm_ops.apply_req) {
rc = ctx_isp->substate_machine[ctx_isp->substate_activated].
crm_ops.apply_req(ctx, apply);
} else {
- pr_err("%s: No handle function in activated substate %d\n",
- __func__, ctx_isp->substate_activated);
+ CAM_ERR(CAM_ISP, "No handle function in activated substate %d",
+ ctx_isp->substate_activated);
rc = -EFAULT;
}
if (rc)
- pr_err("%s: Apply failed in active substate %d\n",
- __func__, ctx_isp->substate_activated);
+ CAM_ERR(CAM_ISP, "Apply failed in active substate %d",
+ ctx_isp->substate_activated);
return rc;
}
@@ -1427,18 +1867,18 @@ static int __cam_isp_ctx_handle_irq_in_activated(void *context,
trace_cam_isp_activated_irq(ctx, ctx_isp->substate_activated, evt_id,
__cam_isp_ctx_get_event_ts(evt_id, evt_data));
- CDBG("%s: Enter: State %d, Substate %d, evt id %d\n",
- __func__, ctx->state, ctx_isp->substate_activated, evt_id);
+ CAM_DBG(CAM_ISP, "Enter: State %d, Substate %d, evt id %d",
+ ctx->state, ctx_isp->substate_activated, evt_id);
if (ctx_isp->substate_machine_irq[ctx_isp->substate_activated].
irq_ops[evt_id]) {
rc = ctx_isp->substate_machine_irq[ctx_isp->substate_activated].
irq_ops[evt_id](ctx_isp, evt_data);
} else {
- CDBG("%s: No handle function for substate %d\n", __func__,
+ CAM_DBG(CAM_ISP, "No handle function for substate %d",
ctx_isp->substate_activated);
}
- CDBG("%s: Exit: State %d Substate %d\n",
- __func__, ctx->state, ctx_isp->substate_activated);
+ CAM_DBG(CAM_ISP, "Exit: State %d Substate %d",
+ ctx->state, ctx_isp->substate_activated);
spin_unlock_bh(&ctx->lock);
return rc;
}
@@ -1513,7 +1953,7 @@ int cam_isp_context_init(struct cam_isp_context *ctx,
int i;
if (!ctx || !ctx_base) {
- pr_err("%s: Invalid Context\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid Context");
goto err;
}
@@ -1538,7 +1978,7 @@ int cam_isp_context_init(struct cam_isp_context *ctx,
rc = cam_context_init(ctx_base, crm_node_intf, hw_intf, ctx->req_base,
CAM_CTX_REQ_MAX);
if (rc) {
- pr_err("%s: Camera Context Base init failed\n", __func__);
+ CAM_ERR(CAM_ISP, "Camera Context Base init failed");
goto err;
}
@@ -1558,7 +1998,7 @@ int cam_isp_context_deinit(struct cam_isp_context *ctx)
cam_context_deinit(ctx->base);
if (ctx->substate_activated != CAM_ISP_CTX_ACTIVATED_SOF)
- pr_err("%s: ISP context substate is invalid\n", __func__);
+ CAM_ERR(CAM_ISP, "ISP context substate is invalid");
memset(ctx, 0, sizeof(*ctx));
return rc;
diff --git a/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.c b/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.c
index 4c819cf..2bf7795 100644
--- a/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.c
+++ b/drivers/media/platform/msm/camera/cam_isp/cam_isp_dev.c
@@ -25,6 +25,7 @@
#include "cam_hw_mgr_intf.h"
#include "cam_isp_hw_mgr_intf.h"
#include "cam_node.h"
+#include "cam_debug_util.h"
static struct cam_isp_dev g_isp_dev;
@@ -44,13 +45,13 @@ static int cam_isp_dev_remove(struct platform_device *pdev)
for (i = 0; i < CAM_CTX_MAX; i++) {
rc = cam_isp_context_deinit(&g_isp_dev.ctx_isp[i]);
if (rc)
- pr_err("%s: ISP context %d deinit failed\n",
- __func__, i);
+ CAM_ERR(CAM_ISP, "ISP context %d deinit failed",
+ i);
}
rc = cam_subdev_remove(&g_isp_dev.sd);
if (rc)
- pr_err("%s: Unregister failed\n", __func__);
+ CAM_ERR(CAM_ISP, "Unregister failed");
memset(&g_isp_dev, 0, sizeof(g_isp_dev));
return 0;
@@ -67,7 +68,7 @@ static int cam_isp_dev_probe(struct platform_device *pdev)
rc = cam_subdev_probe(&g_isp_dev.sd, pdev, CAM_ISP_DEV_NAME,
CAM_IFE_DEVICE_TYPE);
if (rc) {
- pr_err("%s: ISP cam_subdev_probe failed!\n", __func__);
+ CAM_ERR(CAM_ISP, "ISP cam_subdev_probe failed!");
goto err;
}
node = (struct cam_node *) g_isp_dev.sd.token;
@@ -75,7 +76,7 @@ static int cam_isp_dev_probe(struct platform_device *pdev)
memset(&hw_mgr_intf, 0, sizeof(hw_mgr_intf));
rc = cam_isp_hw_mgr_init(pdev->dev.of_node, &hw_mgr_intf);
if (rc != 0) {
- pr_err("%s: Can not initialized ISP HW manager!\n", __func__);
+ CAM_ERR(CAM_ISP, "Can not initialized ISP HW manager!");
goto unregister;
}
@@ -85,7 +86,7 @@ static int cam_isp_dev_probe(struct platform_device *pdev)
&node->crm_node_intf,
&node->hw_mgr_intf);
if (rc) {
- pr_err("%s: ISP context init failed!\n", __func__);
+ CAM_ERR(CAM_ISP, "ISP context init failed!");
goto unregister;
}
}
@@ -93,11 +94,11 @@ static int cam_isp_dev_probe(struct platform_device *pdev)
rc = cam_node_init(node, &hw_mgr_intf, g_isp_dev.ctx, CAM_CTX_MAX,
CAM_ISP_DEV_NAME);
if (rc) {
- pr_err("%s: ISP node init failed!\n", __func__);
+ CAM_ERR(CAM_ISP, "ISP node init failed!");
goto unregister;
}
- pr_info("%s: Camera ISP probe complete\n", __func__);
+ CAM_INFO(CAM_ISP, "Camera ISP probe complete");
return 0;
unregister:
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c
index cb38d8f..4a5b1c3 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c
@@ -24,9 +24,7 @@
#include "cam_ife_hw_mgr.h"
#include "cam_cdm_intf_api.h"
#include "cam_packet_util.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
#define CAM_IFE_HW_ENTRIES_MAX 20
@@ -41,7 +39,7 @@ static int cam_ife_mgr_get_hw_caps(void *hw_mgr_priv,
struct cam_query_cap_cmd *query = hw_caps_args;
struct cam_isp_query_cap_cmd query_isp;
- CDBG("%s: enter\n", __func__);
+ CAM_DBG(CAM_ISP, "enter");
if (copy_from_user(&query_isp, (void __user *)query->caps_handle,
sizeof(struct cam_isp_query_cap_cmd))) {
@@ -66,7 +64,7 @@ static int cam_ife_mgr_get_hw_caps(void *hw_mgr_priv,
sizeof(struct cam_isp_query_cap_cmd)))
rc = -EFAULT;
- CDBG("%s: exit rc :%d !\n", __func__, rc);
+ CAM_DBG(CAM_ISP, "exit rc :%d !", rc);
return rc;
}
@@ -100,7 +98,7 @@ static int cam_ife_hw_mgr_init_hw_res(
if (!isp_hw_res->hw_res[i])
continue;
hw_intf = isp_hw_res->hw_res[i]->hw_intf;
- CDBG("%s: enabled vfe hardware %d\n", __func__,
+ CAM_DBG(CAM_ISP, "enabled vfe hardware %d",
hw_intf->hw_idx);
if (hw_intf->hw_ops.init) {
rc = hw_intf->hw_ops.init(hw_intf->hw_priv,
@@ -113,7 +111,7 @@ static int cam_ife_hw_mgr_init_hw_res(
return 0;
err:
- pr_err("%s: INIT HW res failed! (type:%d, id:%d)", __func__,
+ CAM_ERR(CAM_ISP, "INIT HW res failed! (type:%d, id:%d)",
isp_hw_res->res_type, isp_hw_res->res_id);
return rc;
}
@@ -134,19 +132,18 @@ static int cam_ife_hw_mgr_start_hw_res(
isp_hw_res->hw_res[i],
sizeof(struct cam_isp_resource_node));
if (rc) {
- pr_err("%s: Can not start HW resources!\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Can not start HW resources!");
goto err;
}
} else {
- pr_err("%s:function null\n", __func__);
+ CAM_ERR(CAM_ISP, "function null");
goto err;
}
}
return 0;
err:
- pr_err("%s: Start hw res failed! (type:%d, id:%d)", __func__,
+ CAM_ERR(CAM_ISP, "Start hw res failed! (type:%d, id:%d)",
isp_hw_res->res_type, isp_hw_res->res_id);
return rc;
}
@@ -166,7 +163,7 @@ static void cam_ife_hw_mgr_stop_hw_res(
isp_hw_res->hw_res[i],
sizeof(struct cam_isp_resource_node));
else
- pr_err("%s:stop null\n", __func__);
+ CAM_ERR(CAM_ISP, "stop null");
}
}
@@ -213,7 +210,7 @@ static int cam_ife_hw_mgr_get_res(
struct cam_ife_hw_mgr_res, list);
list_del_init(&res_ptr->list);
} else {
- pr_err("No more free ife hw mgr ctx!\n");
+ CAM_ERR(CAM_ISP, "No more free ife hw mgr ctx!");
rc = -1;
}
*res = res_ptr;
@@ -237,11 +234,12 @@ static int cam_ife_hw_mgr_free_hw_res(
isp_hw_res->hw_res[i],
sizeof(struct cam_isp_resource_node));
if (rc)
- pr_err("%s:Release hw resrouce id %d failed!\n",
- __func__, isp_hw_res->res_id);
+ CAM_ERR(CAM_ISP,
+ "Release hw resrouce id %d failed!",
+ isp_hw_res->res_id);
isp_hw_res->hw_res[i] = NULL;
} else
- pr_err("%s:Release null\n", __func__);
+ CAM_ERR(CAM_ISP, "Release null");
}
/* caller should make sure the resource is in a list */
list_del_init(&isp_hw_res->list);
@@ -328,8 +326,8 @@ static int cam_ife_hw_mgr_release_hw_for_ctx(
ife_ctx->common.cb_priv = NULL;
memset(ife_ctx->common.event_cb, 0, sizeof(ife_ctx->common.event_cb));
- CDBG("%s:%d: release context completed ctx id:%d\n",
- __func__, __LINE__, ife_ctx->ctx_index);
+ CAM_DBG(CAM_ISP, "release context completed ctx id:%d",
+ ife_ctx->ctx_index);
return 0;
}
@@ -364,7 +362,7 @@ static int cam_ife_hw_mgr_get_ctx(
struct cam_ife_hw_mgr_ctx, list);
list_del_init(&ctx_ptr->list);
} else {
- pr_err("No more free ife hw mgr ctx!\n");
+ CAM_ERR(CAM_ISP, "No more free ife hw mgr ctx!");
rc = -1;
}
*ife_ctx = ctx_ptr;
@@ -381,7 +379,7 @@ static void cam_ife_mgr_add_base_info(
uint32_t i;
if (!ctx->num_base) {
- CDBG("%s: Add split id = %d for base idx = %d\n", __func__,
+ CAM_DBG(CAM_ISP, "Add split id = %d for base idx = %d",
split_id, base_idx);
ctx->base[0].split_id = split_id;
ctx->base[0].idx = base_idx;
@@ -400,8 +398,8 @@ static void cam_ife_mgr_add_base_info(
}
if (i == CAM_IFE_HW_NUM_MAX) {
- CDBG("%s: Add split id = %d for base idx = %d\n",
- __func__, split_id, base_idx);
+ CAM_DBG(CAM_ISP, "Add split id = %d for base idx = %d",
+ split_id, base_idx);
ctx->base[ctx->num_base].split_id = split_id;
ctx->base[ctx->num_base].idx = base_idx;
ctx->num_base++;
@@ -417,7 +415,7 @@ static int cam_ife_mgr_process_base_info(
uint32_t i;
if (list_empty(&ctx->res_list_ife_src)) {
- pr_err("%s: Error! Mux List empty\n", __func__);
+ CAM_ERR(CAM_ISP, "Error! Mux List empty");
return -ENODEV;
}
@@ -440,7 +438,7 @@ static int cam_ife_mgr_process_base_info(
res->hw_intf->hw_idx);
}
}
- CDBG("%s: ctx base num = %d\n", __func__, ctx->num_base);
+ CAM_DBG(CAM_ISP, "ctx base num = %d", ctx->num_base);
return 0;
}
@@ -474,7 +472,7 @@ static int cam_ife_hw_mgr_acquire_res_ife_out_rdi(
vfe_out_res_id = CAM_ISP_IFE_OUT_RES_RDI_3;
break;
default:
- pr_err("%s: invalid resource type\n", __func__);
+ CAM_ERR(CAM_ISP, "invalid resource type");
goto err;
}
@@ -498,15 +496,15 @@ static int cam_ife_hw_mgr_acquire_res_ife_out_rdi(
&vfe_acquire,
sizeof(struct cam_vfe_acquire_args));
if (rc) {
- pr_err("%s: Can not acquire out resource 0x%x\n",
- __func__, out_port->res_type);
+ CAM_ERR(CAM_ISP, "Can not acquire out resource 0x%x",
+ out_port->res_type);
goto err;
}
break;
}
if (i == in_port->num_out_res) {
- pr_err("%s: Can not acquire out resource\n", __func__);
+ CAM_ERR(CAM_ISP, "Can not acquire out resource");
goto err;
}
@@ -536,16 +534,16 @@ static int cam_ife_hw_mgr_acquire_res_ife_out_pixel(
out_port = &in_port->data[i];
k = out_port->res_type & 0xFF;
if (k >= CAM_IFE_HW_OUT_RES_MAX) {
- pr_err("%s: invalid output resource type 0x%x\n",
- __func__, out_port->res_type);
+ CAM_ERR(CAM_ISP, "invalid output resource type 0x%x",
+ out_port->res_type);
continue;
}
if (cam_ife_hw_mgr_is_rdi_res(out_port->res_type))
continue;
- CDBG("%s: res_type 0x%x\n",
- __func__, out_port->res_type);
+ CAM_DBG(CAM_ISP, "res_type 0x%x",
+ out_port->res_type);
ife_out_res = &ife_ctx->res_list_ife_out[k];
ife_out_res->is_dual_vfe = in_port->usage_type;
@@ -587,15 +585,16 @@ static int cam_ife_hw_mgr_acquire_res_ife_out_pixel(
&vfe_acquire,
sizeof(struct cam_vfe_acquire_args));
if (rc) {
- pr_err("%s:Can not acquire out resource 0x%x\n",
- __func__, out_port->res_type);
+ CAM_ERR(CAM_ISP,
+ "Can not acquire out resource 0x%x",
+ out_port->res_type);
goto err;
}
ife_out_res->hw_res[j] =
vfe_acquire.vfe_out.rsrc_node;
- CDBG("%s: resource type :0x%x res id:0x%x\n",
- __func__, ife_out_res->hw_res[j]->res_type,
+ CAM_DBG(CAM_ISP, "resource type :0x%x res id:0x%x",
+ ife_out_res->hw_res[j]->res_type,
ife_out_res->hw_res[j]->res_id);
}
@@ -635,8 +634,7 @@ static int cam_ife_hw_mgr_acquire_res_ife_out(
ife_src_res, in_port);
break;
default:
- pr_err("%s: Fatal: Unknown IFE SRC resource!\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Fatal: Unknown IFE SRC resource!");
break;
}
if (rc)
@@ -670,7 +668,7 @@ static int cam_ife_hw_mgr_acquire_res_ife_src(
rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list,
&ife_src_res);
if (rc) {
- pr_err("%s: No more free hw mgr resource!\n", __func__);
+ CAM_ERR(CAM_ISP, "No more free hw mgr resource!");
goto err;
}
cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_src,
@@ -710,8 +708,7 @@ static int cam_ife_hw_mgr_acquire_res_ife_src(
vfe_acquire.vfe_in.sync_mode = CAM_ISP_HW_SYNC_NONE;
break;
default:
- pr_err("%s: Wrong IFE CSID Resource Node!\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Wrong IFE CSID Resource Node!");
goto err;
}
ife_src_res->res_type = vfe_acquire.rsrc_type;
@@ -736,13 +733,15 @@ static int cam_ife_hw_mgr_acquire_res_ife_src(
&vfe_acquire,
sizeof(struct cam_vfe_acquire_args));
if (rc) {
- pr_err("%s:Can not acquire IFE HW res %d!\n",
- __func__, csid_res->res_id);
+ CAM_ERR(CAM_ISP,
+ "Can not acquire IFE HW res %d",
+ csid_res->res_id);
goto err;
}
ife_src_res->hw_res[i] = vfe_acquire.vfe_in.rsrc_node;
- CDBG("%s:acquire success res type :0x%x res id:0x%x\n",
- __func__, ife_src_res->hw_res[i]->res_type,
+ CAM_DBG(CAM_ISP,
+ "acquire success res type :0x%x res id:0x%x",
+ ife_src_res->hw_res[i]->res_type,
ife_src_res->hw_res[i]->res_id);
}
@@ -779,7 +778,7 @@ static int cam_ife_hw_mgr_acquire_res_ife_csid_ipp(
rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list, &csid_res);
if (rc) {
- pr_err("%s: No more free hw mgr resource!\n", __func__);
+ CAM_ERR(CAM_ISP, "No more free hw mgr resource!");
goto err;
}
cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_csid, &csid_res);
@@ -810,13 +809,12 @@ static int cam_ife_hw_mgr_acquire_res_ife_csid_ipp(
}
if (i == CAM_IFE_CSID_HW_NUM_MAX) {
- pr_err("%s: Can not acquire ife csid ipp resrouce!\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Can not acquire ife csid ipp resrouce!");
goto err;
}
- CDBG("%s: acquired csid(%d) left ipp resrouce successfully!\n",
- __func__, i);
+ CAM_DBG(CAM_ISP, "acquired csid(%d) left ipp resrouce successfully!",
+ i);
csid_res->res_type = CAM_ISP_RESOURCE_PIX_PATH;
csid_res->res_id = CAM_IFE_PIX_PATH_RES_IPP;
@@ -841,14 +839,14 @@ static int cam_ife_hw_mgr_acquire_res_ife_csid_ipp(
}
if (j == CAM_IFE_CSID_HW_NUM_MAX) {
- pr_err("%s: Can not acquire ife csid rdi resrouce!\n",
- __func__);
+ CAM_ERR(CAM_ISP,
+ "Can not acquire ife csid rdi resrouce!");
goto err;
}
csid_res->hw_res[1] = csid_acquire.node_res;
- CDBG("%s:acquired csid(%d)right ipp resrouce successfully!\n",
- __func__, j);
+ CAM_DBG(CAM_ISP,
+ "acquired csid(%d)right ipp resrouce successfully!", j);
}
csid_res->parent = &ife_ctx->res_list_ife_in;
@@ -881,7 +879,7 @@ static enum cam_ife_pix_path_res_id
break;
default:
path_id = CAM_IFE_PIX_PATH_RES_MAX;
- CDBG("%s: maximum rdi output type exceeded\n", __func__);
+ CAM_DBG(CAM_ISP, "maximum rdi output type exceeded");
break;
}
@@ -912,7 +910,7 @@ static int cam_ife_hw_mgr_acquire_res_ife_csid_rdi(
rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list,
&csid_res);
if (rc) {
- pr_err("%s: No more free hw mgr resource!\n",
+ CAM_ERR(CAM_ISP, "No more free hw mgr resource!",
__func__);
goto err;
}
@@ -930,6 +928,7 @@ static int cam_ife_hw_mgr_acquire_res_ife_csid_rdi(
csid_acquire.res_type = CAM_ISP_RESOURCE_PIX_PATH;
csid_acquire.cid = cid_res_id;
csid_acquire.in_port = in_port;
+ csid_acquire.out_port = out_port;
csid_acquire.sync_mode = CAM_ISP_HW_SYNC_NONE;
for (j = 0; j < CAM_IFE_CSID_HW_NUM_MAX; j++) {
@@ -946,8 +945,8 @@ static int cam_ife_hw_mgr_acquire_res_ife_csid_rdi(
}
if (j == CAM_IFE_CSID_HW_NUM_MAX) {
- pr_err("%s: Can not acquire ife csid rdi resrouce!\n",
- __func__);
+ CAM_ERR(CAM_ISP,
+ "Can not acquire ife csid rdi resrouce!");
goto err;
}
@@ -980,7 +979,7 @@ static int cam_ife_hw_mgr_acquire_res_root(
ife_ctx->res_list_ife_in.res_id = in_port->res_type;
ife_ctx->res_list_ife_in.is_dual_vfe = in_port->usage_type;
} else if (ife_ctx->res_list_ife_in.res_id != in_port->res_type) {
- pr_err("%s: No Free resource for this context!\n", __func__);
+ CAM_ERR(CAM_ISP, "No Free resource for this context!");
goto err;
} else {
/* else do nothing */
@@ -1034,7 +1033,7 @@ static int cam_ife_mgr_acquire_cid_res(
/* no dual vfe for TPG */
if ((in_port->res_type == CAM_ISP_IFE_IN_RES_TPG) &&
(in_port->usage_type != 0)) {
- pr_err("%s: No Dual VFE on TPG input!\n", __func__);
+ CAM_ERR(CAM_ISP, "No Dual VFE on TPG input!");
goto err;
}
@@ -1042,7 +1041,7 @@ static int cam_ife_mgr_acquire_cid_res(
rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list, &cid_res);
if (rc) {
- pr_err("%s: No more free hw mgr resource!\n", __func__);
+ CAM_ERR(CAM_ISP, "No more free hw mgr resource!");
goto err;
}
cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_cid, &cid_res);
@@ -1064,8 +1063,7 @@ static int cam_ife_mgr_acquire_cid_res(
}
if (i == CAM_IFE_CSID_HW_NUM_MAX || !csid_acquire.node_res) {
- pr_err("%s: Can not acquire ife csid rdi resrouce!\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Can not acquire ife csid rdi resrouce!");
goto err;
}
@@ -1095,8 +1093,8 @@ static int cam_ife_mgr_acquire_cid_res(
}
if (j == CAM_IFE_CSID_HW_NUM_MAX) {
- pr_err("%s: Can not acquire ife csid rdi resrouce!\n",
- __func__);
+ CAM_ERR(CAM_ISP,
+ "Can not acquire ife csid rdi resrouce!");
goto err;
}
cid_res->hw_res[1] = csid_acquire.node_res;
@@ -1112,7 +1110,8 @@ static int cam_ife_mgr_acquire_cid_res(
}
static int cam_ife_mgr_acquire_hw_for_ctx(
struct cam_ife_hw_mgr_ctx *ife_ctx,
- struct cam_isp_in_port_info *in_port)
+ struct cam_isp_in_port_info *in_port,
+ uint32_t *num_pix_port, uint32_t *num_rdi_port)
{
int rc = -1;
int is_dual_vfe = 0;
@@ -1125,16 +1124,14 @@ static int cam_ife_mgr_acquire_hw_for_ctx(
/* get root node resource */
rc = cam_ife_hw_mgr_acquire_res_root(ife_ctx, in_port);
if (rc) {
- pr_err("%s:%d: Can not acquire csid rx resource!\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Can not acquire csid rx resource!");
goto err;
}
/* get cid resource */
rc = cam_ife_mgr_acquire_cid_res(ife_ctx, in_port, &cid_res_id);
if (rc) {
- pr_err("%s%d: Acquire IFE CID resource Failed!\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Acquire IFE CID resource Failed!");
goto err;
}
@@ -1142,7 +1139,7 @@ static int cam_ife_mgr_acquire_hw_for_ctx(
&pixel_count, &rdi_count);
if (!pixel_count && !rdi_count) {
- pr_err("%s: Error! no PIX or RDI resource\n", __func__);
+ CAM_ERR(CAM_ISP, "Error! no PIX or RDI resource");
return -EINVAL;
}
@@ -1151,8 +1148,8 @@ static int cam_ife_mgr_acquire_hw_for_ctx(
rc = cam_ife_hw_mgr_acquire_res_ife_csid_ipp(ife_ctx, in_port,
cid_res_id);
if (rc) {
- pr_err("%s%d: Acquire IFE CSID IPP resource Failed!\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP,
+ "Acquire IFE CSID IPP resource Failed!");
goto err;
}
}
@@ -1162,8 +1159,8 @@ static int cam_ife_mgr_acquire_hw_for_ctx(
rc = cam_ife_hw_mgr_acquire_res_ife_csid_rdi(ife_ctx, in_port,
cid_res_id);
if (rc) {
- pr_err("%s%d: Acquire IFE CSID RDI resource Failed!\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP,
+ "Acquire IFE CSID RDI resource Failed!");
goto err;
}
}
@@ -1171,18 +1168,19 @@ static int cam_ife_mgr_acquire_hw_for_ctx(
/* get ife src resource */
rc = cam_ife_hw_mgr_acquire_res_ife_src(ife_ctx, in_port);
if (rc) {
- pr_err("%s%d: Acquire IFE SRC resource Failed!\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Acquire IFE SRC resource Failed!");
goto err;
}
rc = cam_ife_hw_mgr_acquire_res_ife_out(ife_ctx, in_port);
if (rc) {
- pr_err("%s%d: Acquire IFE OUT resource Failed!\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Acquire IFE OUT resource Failed!");
goto err;
}
+ *num_pix_port += pixel_count;
+ *num_rdi_port += rdi_count;
+
return 0;
err:
/* release resource at the acquire entry funciton */
@@ -1192,11 +1190,11 @@ static int cam_ife_mgr_acquire_hw_for_ctx(
void cam_ife_cam_cdm_callback(uint32_t handle, void *userdata,
enum cam_cdm_cb_status status, uint32_t cookie)
{
- CDBG("%s: Called by CDM hdl=%x, udata=%pK, status=%d, cookie=%d\n",
- __func__, handle, userdata, status, cookie);
+ CAM_DBG(CAM_ISP,
+ "Called by CDM hdl=%x, udata=%pK, status=%d, cookie=%d",
+ handle, userdata, status, cookie);
}
-
/* entry function: acquire_hw */
static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv,
void *acquire_hw_args)
@@ -1208,19 +1206,21 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv,
struct cam_ife_hw_mgr_ctx *ife_ctx;
struct cam_isp_in_port_info *in_port = NULL;
struct cam_isp_resource *isp_resource = NULL;
- struct cam_cdm_acquire_data cdm_acquire;
+ struct cam_cdm_acquire_data cdm_acquire;
+ uint32_t num_pix_port = 0;
+ uint32_t num_rdi_port = 0;
- CDBG("%s: Enter...\n", __func__);
+ CAM_DBG(CAM_ISP, "Enter...");
if (!acquire_args || acquire_args->num_acq <= 0) {
- pr_err("%s: Nothing to acquire. Seems like error\n", __func__);
+ CAM_ERR(CAM_ISP, "Nothing to acquire. Seems like error");
return -EINVAL;
}
/* get the ife ctx */
rc = cam_ife_hw_mgr_get_ctx(&ife_hw_mgr->free_ctx_list, &ife_ctx);
if (rc || !ife_ctx) {
- pr_err("Get ife hw context failed!\n");
+ CAM_ERR(CAM_ISP, "Get ife hw context failed!");
goto err;
}
@@ -1247,12 +1247,12 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv,
cdm_acquire.id = CAM_CDM_VIRTUAL;
cdm_acquire.cam_cdm_callback = cam_ife_cam_cdm_callback;
if (!cam_cdm_acquire(&cdm_acquire)) {
- CDBG("Successfully acquired the CDM HW hdl=%x\n",
+ CAM_DBG(CAM_ISP, "Successfully acquired the CDM HW hdl=%x",
cdm_acquire.handle);
ife_ctx->cdm_handle = cdm_acquire.handle;
ife_ctx->cdm_ops = cdm_acquire.ops;
} else {
- pr_err("Failed to acquire the CDM HW\n");
+ CAM_ERR(CAM_ISP, "Failed to acquire the CDM HW");
goto err;
}
@@ -1263,32 +1263,38 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv,
if (isp_resource[i].resource_id != CAM_ISP_RES_ID_PORT)
continue;
- CDBG("%s: start copy from user handle %lld with len = %d\n",
- __func__, isp_resource[i].res_hdl,
+ CAM_DBG(CAM_ISP,
+ "start copy from user handle %lld with len = %d",
+ isp_resource[i].res_hdl,
isp_resource[i].length);
in_port = memdup_user((void __user *)isp_resource[i].res_hdl,
isp_resource[i].length);
if (in_port > 0) {
- rc = cam_ife_mgr_acquire_hw_for_ctx(ife_ctx, in_port);
+ rc = cam_ife_mgr_acquire_hw_for_ctx(ife_ctx, in_port,
+ &num_pix_port, &num_rdi_port);
kfree(in_port);
if (rc) {
- pr_err("%s: can not acquire resource!\n",
- __func__);
+ CAM_ERR(CAM_ISP, "can not acquire resource");
goto free_res;
}
} else {
- pr_err("%s: copy from user failed with in_port = %pK",
- __func__, in_port);
+ CAM_ERR(CAM_ISP,
+ "copy from user failed with in_port = %pK",
+ in_port);
rc = -EFAULT;
goto free_res;
}
}
+
+ /* Check whether context has only RDI resource */
+ if (!num_pix_port)
+ ife_ctx->is_rdi_only_context = 1;
+
/* Process base info */
rc = cam_ife_mgr_process_base_info(ife_ctx);
if (rc) {
- pr_err("%s: Error process) base info!\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Error process) base info!");
return -EINVAL;
}
@@ -1297,14 +1303,14 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv,
cam_ife_hw_mgr_put_ctx(&ife_hw_mgr->used_ctx_list, &ife_ctx);
- CDBG("%s: Exit...(success)!\n", __func__);
+ CAM_DBG(CAM_ISP, "Exit...(success)!");
return 0;
free_res:
cam_ife_hw_mgr_release_hw_for_ctx(ife_ctx);
cam_ife_hw_mgr_put_ctx(&ife_hw_mgr->free_ctx_list, &ife_ctx);
err:
- CDBG("%s: Exit...(rc=%d)!\n", __func__, rc);
+ CAM_DBG(CAM_ISP, "Exit...(rc=%d)!", rc);
return rc;
}
@@ -1318,25 +1324,25 @@ static int cam_ife_mgr_config_hw(void *hw_mgr_priv,
struct cam_cdm_bl_request *cdm_cmd;
struct cam_ife_hw_mgr_ctx *ctx;
- CDBG("%s: Enter\n", __func__);
+ CAM_DBG(CAM_ISP, "Enter");
if (!hw_mgr_priv || !config_hw_args) {
- pr_err("%s%d: Invalid arguments\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
cfg = config_hw_args;
ctx = (struct cam_ife_hw_mgr_ctx *)cfg->ctxt_to_hw_map;
if (!ctx) {
- pr_err("%s: Fatal: Invalid context is used!\n", __func__);
+ CAM_ERR(CAM_ISP, "Fatal: Invalid context is used!");
return -EPERM;
}
if (!ctx->ctx_in_use || !ctx->cdm_cmd) {
- pr_err("%s: Invalid context parameters !\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid context parameters !");
return -EPERM;
}
- CDBG("%s:%d Enter ctx id:%d\n", __func__, __LINE__, ctx->ctx_index);
+ CAM_DBG(CAM_ISP, "Enter ctx id:%d", ctx->ctx_index);
if (cfg->num_hw_update_entries > 0) {
cdm_cmd = ctx->cdm_cmd;
@@ -1355,11 +1361,11 @@ static int cam_ife_mgr_config_hw(void *hw_mgr_priv,
rc = cam_cdm_submit_bls(ctx->cdm_handle, cdm_cmd);
if (rc)
- pr_err("Failed to apply the configs\n");
+ CAM_ERR(CAM_ISP, "Failed to apply the configs");
} else {
- pr_err("No commands to config\n");
+ CAM_ERR(CAM_ISP, "No commands to config");
}
- CDBG("%s: Exit\n", __func__);
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -1374,22 +1380,21 @@ static int cam_ife_mgr_stop_hw_in_overflow(void *hw_mgr_priv,
uint32_t i, master_base_idx = 0;
if (!hw_mgr_priv || !stop_hw_args) {
- pr_err("%s%d: Invalid arguments\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
ctx = (struct cam_ife_hw_mgr_ctx *)stop_args->ctxt_to_hw_map;
if (!ctx || !ctx->ctx_in_use) {
- pr_err("%s: Fatal: Invalid context is used!\n", __func__);
+ CAM_ERR(CAM_ISP, "Fatal: Invalid context is used!");
return -EPERM;
}
- CDBG("%s%d: Enter...ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "Enter...ctx id:%d",
ctx->ctx_index);
/* stop resource will remove the irq mask from the hardware */
if (!ctx->num_base) {
- pr_err("%s%d: error number of bases are zero\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "error number of bases are zero");
return -EINVAL;
}
@@ -1445,7 +1450,7 @@ static int cam_ife_mgr_stop_hw_in_overflow(void *hw_mgr_priv,
/* update vote bandwidth should be done at the HW layer */
- CDBG("%s%d Exit...ctx id:%d rc :%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "Exit...ctx id:%d rc :%d",
ctx->ctx_index, rc);
return rc;
@@ -1461,23 +1466,22 @@ static int cam_ife_mgr_stop_hw(void *hw_mgr_priv, void *stop_hw_args)
uint32_t i, master_base_idx = 0;
if (!hw_mgr_priv || !stop_hw_args) {
- pr_err("%s%d: Invalid arguments\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
ctx = (struct cam_ife_hw_mgr_ctx *)stop_args->ctxt_to_hw_map;
if (!ctx || !ctx->ctx_in_use) {
- pr_err("%s: Fatal: Invalid context is used!\n", __func__);
+ CAM_ERR(CAM_ISP, "Fatal: Invalid context is used!");
return -EPERM;
}
- CDBG("%s%d: Enter...ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, " Enter...ctx id:%d",
ctx->ctx_index);
/* Note:stop resource will remove the irq mask from the hardware */
if (!ctx->num_base) {
- pr_err("%s%d: error number of bases are zero\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "error number of bases are zero");
return -EINVAL;
}
@@ -1522,8 +1526,8 @@ static int cam_ife_mgr_stop_hw(void *hw_mgr_priv, void *stop_hw_args)
}
if (cam_cdm_stream_off(ctx->cdm_handle))
- pr_err("%s%d: CDM stream off failed %d\n",
- __func__, __LINE__, ctx->cdm_handle);
+ CAM_ERR(CAM_ISP, "CDM stream off failed %d",
+ ctx->cdm_handle);
/* IFE mux in resources */
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) {
@@ -1559,8 +1563,7 @@ static int cam_ife_mgr_stop_hw(void *hw_mgr_priv, void *stop_hw_args)
for (i = 0; i < CAM_IFE_HW_OUT_RES_MAX; i++)
cam_ife_hw_mgr_deinit_hw_res(&ctx->res_list_ife_out[i]);
- CDBG("%s%d Exit...ctx id:%d rc :%d\n", __func__, __LINE__,
- ctx->ctx_index, rc);
+ CAM_DBG(CAM_ISP, "Exit...ctx id:%d rc :%d", ctx->ctx_index, rc);
return rc;
}
@@ -1574,7 +1577,7 @@ static int cam_ife_mgr_reset_hw(struct cam_ife_hw_mgr *hw_mgr,
struct cam_csid_reset_cfg_args csid_reset_args;
if (!hw_mgr) {
- CDBG("%s: Invalid arguments\n", __func__);
+ CAM_DBG(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
@@ -1596,13 +1599,13 @@ static int cam_ife_mgr_reset_hw(struct cam_ife_hw_mgr *hw_mgr,
for (i = 0; i < CAM_VFE_HW_NUM_MAX; i++) {
if (hw_idx != hw_mgr->ife_devices[i]->hw_idx)
continue;
- CDBG("%d:VFE (id = %d) reset\n", __LINE__, hw_idx);
+ CAM_DBG(CAM_ISP, "VFE (id = %d) reset", hw_idx);
vfe_hw_intf = hw_mgr->ife_devices[i];
vfe_hw_intf->hw_ops.reset(vfe_hw_intf->hw_priv, NULL, 0);
break;
}
- CDBG("%d: Exit Successfully\n", __LINE__);
+ CAM_DBG(CAM_ISP, "Exit Successfully");
return 0;
}
@@ -1616,74 +1619,68 @@ static int cam_ife_mgr_restart_hw(void *hw_mgr_priv,
uint32_t i;
if (!hw_mgr_priv || !start_hw_args) {
- pr_err("%s%d: Invalid arguments\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
ctx = (struct cam_ife_hw_mgr_ctx *)start_args->ctxt_to_hw_map;
if (!ctx || !ctx->ctx_in_use) {
- pr_err("%s: Invalid context is used!\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid context is used!");
return -EPERM;
}
- CDBG("%s%d Enter... ctx id:%d\n", __func__, __LINE__,
- ctx->ctx_index);
+ CAM_DBG(CAM_ISP, "Enter... ctx id:%d", ctx->ctx_index);
- CDBG("%s%d START IFE OUT ... in ctx id:%d\n", __func__, __LINE__,
- ctx->ctx_index);
+ CAM_DBG(CAM_ISP, "START IFE OUT ... in ctx id:%d", ctx->ctx_index);
/* start the IFE out devices */
for (i = 0; i < CAM_IFE_HW_OUT_RES_MAX; i++) {
rc = cam_ife_hw_mgr_start_hw_res(&ctx->res_list_ife_out[i]);
if (rc) {
- pr_err("%s: Can not start IFE OUT (%d)!\n",
- __func__, i);
+ CAM_ERR(CAM_ISP, "Can not start IFE OUT (%d)!", i);
goto err;
}
}
- CDBG("%s%d START IFE SRC ... in ctx id:%d\n", __func__, __LINE__,
- ctx->ctx_index);
+ CAM_DBG(CAM_ISP, "START IFE SRC ... in ctx id:%d", ctx->ctx_index);
/* Start the IFE mux in devices */
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) {
rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
if (rc) {
- pr_err("%s: Can not start IFE MUX (%d)!\n",
- __func__, hw_mgr_res->res_id);
+ CAM_ERR(CAM_ISP, "Can not start IFE MUX (%d)!",
+ hw_mgr_res->res_id);
goto err;
}
}
- CDBG("%s:%d: START CSID HW ... in ctx id:%d\n", __func__, __LINE__,
- ctx->ctx_index);
+ CAM_DBG(CAM_ISP, "START CSID HW ... in ctx id:%d", ctx->ctx_index);
/* Start the IFE CSID HW devices */
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_csid, list) {
rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
if (rc) {
- pr_err("%s: Can not start IFE CSID (%d)!\n",
- __func__, hw_mgr_res->res_id);
+ CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)!",
+ hw_mgr_res->res_id);
goto err;
}
}
- CDBG("%s%d START CID SRC ... in ctx id:%d\n", __func__, __LINE__,
- ctx->ctx_index);
+ CAM_DBG(CAM_ISP, "START CID SRC ... in ctx id:%d", ctx->ctx_index);
/* Start the IFE CID HW devices */
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_cid, list) {
rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
if (rc) {
- pr_err("%s: Can not start IFE CSID (%d)!\n",
- __func__, hw_mgr_res->res_id);
+ CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)!",
+ hw_mgr_res->res_id);
goto err;
}
}
/* Start IFE root node: do nothing */
- CDBG("%s: Exit...(success)\n", __func__);
+ CAM_DBG(CAM_ISP, "Exit...(success)");
return 0;
err:
cam_ife_mgr_stop_hw(hw_mgr_priv, start_hw_args);
- CDBG("%s: Exit...(rc=%d)\n", __func__, rc);
+ CAM_DBG(CAM_ISP, "Exit...(rc=%d)", rc);
return rc;
}
@@ -1696,17 +1693,17 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
uint32_t i;
if (!hw_mgr_priv || !start_hw_args) {
- pr_err("%s%d: Invalid arguments\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
ctx = (struct cam_ife_hw_mgr_ctx *)start_args->ctxt_to_hw_map;
if (!ctx || !ctx->ctx_in_use) {
- pr_err("%s: Invalid context is used!\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid context is used!");
return -EPERM;
}
- CDBG("%s%d Enter... ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "Enter... ctx id:%d",
ctx->ctx_index);
/* update Bandwidth should be done at the hw layer */
@@ -1715,127 +1712,127 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
/* INIT IFE Root: do nothing */
- CDBG("%s%d INIT IFE CID ... in ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "INIT IFE CID ... in ctx id:%d",
ctx->ctx_index);
/* INIT IFE CID */
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_cid, list) {
rc = cam_ife_hw_mgr_init_hw_res(hw_mgr_res);
if (rc) {
- pr_err("%s: Can not INIT IFE CID.(id :%d)!\n",
- __func__, hw_mgr_res->res_id);
+ CAM_ERR(CAM_ISP, "Can not INIT IFE CID.(id :%d)!",
+ hw_mgr_res->res_id);
goto err;
}
}
- CDBG("%s%d INIT IFE csid ... in ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "INIT IFE csid ... in ctx id:%d",
ctx->ctx_index);
/* INIT IFE csid */
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_csid, list) {
rc = cam_ife_hw_mgr_init_hw_res(hw_mgr_res);
if (rc) {
- pr_err("%s: Can not INIT IFE CSID.(id :%d)!\n",
- __func__, hw_mgr_res->res_id);
+ CAM_ERR(CAM_ISP, "Can not INIT IFE CSID.(id :%d)!",
+ hw_mgr_res->res_id);
goto err;
}
}
/* INIT IFE SRC */
- CDBG("%s%d INIT IFE SRC in ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "INIT IFE SRC in ctx id:%d",
ctx->ctx_index);
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) {
rc = cam_ife_hw_mgr_init_hw_res(hw_mgr_res);
if (rc) {
- pr_err("%s: Can not INIT IFE SRC (%d)!\n",
- __func__, hw_mgr_res->res_id);
+ CAM_ERR(CAM_ISP, "Can not INIT IFE SRC (%d)!",
+ hw_mgr_res->res_id);
goto err;
}
}
/* INIT IFE OUT */
- CDBG("%s%d INIT IFE OUT RESOURCES in ctx id:%d\n", __func__,
- __LINE__, ctx->ctx_index);
+ CAM_DBG(CAM_ISP, "INIT IFE OUT RESOURCES in ctx id:%d",
+ ctx->ctx_index);
for (i = 0; i < CAM_IFE_HW_OUT_RES_MAX; i++) {
rc = cam_ife_hw_mgr_init_hw_res(&ctx->res_list_ife_out[i]);
if (rc) {
- pr_err("%s: Can not INIT IFE OUT (%d)!\n",
- __func__, ctx->res_list_ife_out[i].res_id);
+ CAM_ERR(CAM_ISP, "Can not INIT IFE OUT (%d)!",
+ ctx->res_list_ife_out[i].res_id);
goto err;
}
}
- CDBG("%s: start cdm interface\n", __func__);
+ CAM_DBG(CAM_ISP, "start cdm interface");
rc = cam_cdm_stream_on(ctx->cdm_handle);
if (rc) {
- pr_err("%s: Can not start cdm (%d)!\n",
- __func__, ctx->cdm_handle);
+ CAM_ERR(CAM_ISP, "Can not start cdm (%d)!",
+ ctx->cdm_handle);
goto err;
}
/* Apply initial configuration */
- CDBG("%s: Config HW\n", __func__);
+ CAM_DBG(CAM_ISP, "Config HW");
rc = cam_ife_mgr_config_hw(hw_mgr_priv, start_hw_args);
if (rc) {
- pr_err("%s: Config HW failed\n", __func__);
+ CAM_ERR(CAM_ISP, "Config HW failed");
goto err;
}
- CDBG("%s%d START IFE OUT ... in ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "START IFE OUT ... in ctx id:%d",
ctx->ctx_index);
/* start the IFE out devices */
for (i = 0; i < CAM_IFE_HW_OUT_RES_MAX; i++) {
rc = cam_ife_hw_mgr_start_hw_res(&ctx->res_list_ife_out[i]);
if (rc) {
- pr_err("%s: Can not start IFE OUT (%d)!\n",
- __func__, i);
+ CAM_ERR(CAM_ISP, "Can not start IFE OUT (%d)!",
+ i);
goto err;
}
}
- CDBG("%s%d START IFE SRC ... in ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "START IFE SRC ... in ctx id:%d",
ctx->ctx_index);
/* Start the IFE mux in devices */
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_src, list) {
rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
if (rc) {
- pr_err("%s: Can not start IFE MUX (%d)!\n",
- __func__, hw_mgr_res->res_id);
+ CAM_ERR(CAM_ISP, "Can not start IFE MUX (%d)!",
+ hw_mgr_res->res_id);
goto err;
}
}
- CDBG("%s:%d: START CSID HW ... in ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "START CSID HW ... in ctx id:%d",
ctx->ctx_index);
/* Start the IFE CSID HW devices */
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_csid, list) {
rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
if (rc) {
- pr_err("%s: Can not start IFE CSID (%d)!\n",
- __func__, hw_mgr_res->res_id);
+ CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)!",
+ hw_mgr_res->res_id);
goto err;
}
}
- CDBG("%s%d START CID SRC ... in ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "START CID SRC ... in ctx id:%d",
ctx->ctx_index);
/* Start the IFE CID HW devices */
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_cid, list) {
rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res);
if (rc) {
- pr_err("%s: Can not start IFE CSID (%d)!\n",
- __func__, hw_mgr_res->res_id);
+ CAM_ERR(CAM_ISP, "Can not start IFE CSID (%d)!",
+ hw_mgr_res->res_id);
goto err;
}
}
/* Start IFE root node: do nothing */
- CDBG("%s: Exit...(success)\n", __func__);
+ CAM_DBG(CAM_ISP, "Exit...(success)");
return 0;
err:
cam_ife_mgr_stop_hw(hw_mgr_priv, start_hw_args);
- CDBG("%s: Exit...(rc=%d)\n", __func__, rc);
+ CAM_DBG(CAM_ISP, "Exit...(rc=%d)", rc);
return rc;
}
@@ -1858,17 +1855,17 @@ static int cam_ife_mgr_release_hw(void *hw_mgr_priv,
struct cam_ife_hw_mgr_ctx *ctx;
if (!hw_mgr_priv || !release_hw_args) {
- pr_err("%s%d: Invalid arguments\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
ctx = (struct cam_ife_hw_mgr_ctx *)release_args->ctxt_to_hw_map;
if (!ctx || !ctx->ctx_in_use) {
- pr_err("%s: Fatal: Invalid context is used!\n", __func__);
+ CAM_ERR(CAM_ISP, "Fatal: Invalid context is used!");
return -EPERM;
}
- CDBG("%s%d Enter...ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "Enter...ctx id:%d",
ctx->ctx_index);
/* we should called the stop hw before this already */
@@ -1884,7 +1881,7 @@ static int cam_ife_mgr_release_hw(void *hw_mgr_priv,
/* clean context */
list_del_init(&ctx->list);
ctx->ctx_in_use = 0;
- CDBG("%s%d Exit...ctx id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "Exit...ctx id:%d",
ctx->ctx_index);
cam_ife_hw_mgr_put_ctx(&hw_mgr->free_ctx_list, &ctx);
return rc;
@@ -1898,34 +1895,34 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv,
(struct cam_hw_prepare_update_args *) prepare_hw_update_args;
struct cam_ife_hw_mgr_ctx *ctx;
struct cam_ife_hw_mgr *hw_mgr;
- struct cam_isp_kmd_buf_info kmd_buf;
+ struct cam_kmd_buf_info kmd_buf;
uint32_t i;
bool fill_fence = true;
if (!hw_mgr_priv || !prepare_hw_update_args) {
- pr_err("%s: Invalid args\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid args");
return -EINVAL;
}
- CDBG("%s:%d enter\n", __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "enter");
ctx = (struct cam_ife_hw_mgr_ctx *) prepare->ctxt_to_hw_map;
hw_mgr = (struct cam_ife_hw_mgr *)hw_mgr_priv;
- rc = cam_isp_validate_packet(prepare->packet);
+ rc = cam_packet_util_validate_packet(prepare->packet);
if (rc)
return rc;
- CDBG("%s:%d enter\n", __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "enter");
/* Pre parse the packet*/
- rc = cam_isp_get_kmd_buffer(prepare->packet, &kmd_buf);
+ rc = cam_packet_util_get_kmd_buffer(prepare->packet, &kmd_buf);
if (rc)
return rc;
rc = cam_packet_util_process_patches(prepare->packet,
hw_mgr->mgr_common.cmd_iommu_hdl);
if (rc) {
- pr_err("%s: Patch ISP packet failed.\n", __func__);
+ CAM_ERR(CAM_ISP, "Patch ISP packet failed.");
return rc;
}
@@ -1934,7 +1931,7 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv,
prepare->num_out_map_entries = 0;
for (i = 0; i < ctx->num_base; i++) {
- CDBG("%s: process cmd buffer for device %d\n", __func__, i);
+ CAM_DBG(CAM_ISP, "process cmd buffer for device %d", i);
/* Add change base */
rc = cam_isp_add_change_base(prepare, &ctx->res_list_ife_src,
@@ -1982,6 +1979,41 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv,
return rc;
}
+static int cam_ife_mgr_cmd(void *hw_mgr_priv, void *cmd_args)
+{
+ int rc = 0;
+ struct cam_isp_hw_cmd_args *hw_cmd_args = cmd_args;
+ struct cam_ife_hw_mgr_ctx *ctx;
+
+ if (!hw_mgr_priv || !cmd_args) {
+ CAM_ERR(CAM_ISP, "Invalid arguments");
+ return -EINVAL;
+ }
+
+ ctx = (struct cam_ife_hw_mgr_ctx *)hw_cmd_args->ctxt_to_hw_map;
+ if (!ctx || !ctx->ctx_in_use) {
+ CAM_ERR(CAM_ISP, "Fatal: Invalid context is used!");
+ return -EPERM;
+ }
+
+ switch (hw_cmd_args->cmd_type) {
+ case CAM_ISP_HW_MGR_CMD_IS_RDI_ONLY_CONTEXT:
+ if (ctx->is_rdi_only_context)
+ hw_cmd_args->u.is_rdi_only_context = 1;
+ else
+ hw_cmd_args->u.is_rdi_only_context = 0;
+
+ break;
+ default:
+ CAM_ERR(CAM_ISP, "Invalid HW mgr command:0x%x",
+ hw_cmd_args->cmd_type);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
static int cam_ife_mgr_cmd_get_sof_timestamp(
struct cam_ife_hw_mgr_ctx *ife_ctx,
uint64_t *time_stamp)
@@ -2028,7 +2060,7 @@ static int cam_ife_mgr_cmd_get_sof_timestamp(
}
end:
if (rc)
- pr_err("%s:error in getting sof time stamp\n", __func__);
+ CAM_ERR(CAM_ISP, "error in getting sof time stamp");
return rc;
}
@@ -2046,13 +2078,14 @@ static int cam_ife_mgr_process_recovery_cb(void *priv, void *data)
struct cam_ife_hw_mgr_ctx *ctx = NULL;
/* Here recovery is performed */
- CDBG("%s:Enter: ErrorType = %d\n", __func__, error_type);
+ CAM_DBG(CAM_ISP, "Enter: ErrorType = %d", error_type);
switch (error_type) {
case CAM_ISP_HW_ERROR_OVERFLOW:
case CAM_ISP_HW_ERROR_BUSIF_OVERFLOW:
if (!recovery_data->affected_ctx[0]) {
- pr_err("No context is affected but recovery called\n");
+ CAM_ERR(CAM_ISP,
+ "No context is affected but recovery called");
kfree(recovery_data);
return 0;
}
@@ -2080,9 +2113,9 @@ static int cam_ife_mgr_process_recovery_cb(void *priv, void *data)
break;
default:
- pr_err("%s: Invalid Error\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid Error");
}
- CDBG("%s:Exit: ErrorType = %d\n", __func__, error_type);
+ CAM_DBG(CAM_ISP, "Exit: ErrorType = %d", error_type);
kfree(recovery_data);
return rc;
@@ -2105,12 +2138,11 @@ static int cam_ife_hw_mgr_do_error_recovery(
memcpy(recovery_data, ife_mgr_recovery_data,
sizeof(struct cam_hw_event_recovery_data));
- CDBG("%s: Enter: error_type (%d)\n", __func__,
- recovery_data->error_type);
+ CAM_DBG(CAM_ISP, "Enter: error_type (%d)", recovery_data->error_type);
task = cam_req_mgr_workq_get_task(g_ife_hw_mgr.workq);
if (!task) {
- pr_err("%s: No empty task frame\n", __func__);
+ CAM_ERR(CAM_ISP, "No empty task frame");
kfree(recovery_data);
return -ENOMEM;
}
@@ -2139,7 +2171,7 @@ static int cam_ife_hw_mgr_match_hw_idx(
uint32_t max_idx = ife_hwr_mgr_ctx->num_base;
uint32_t ctx_affected_core_idx[CAM_IFE_HW_NUM_MAX] = {0};
- CDBG("%s:Enter:max_idx = %d\n", __func__, max_idx);
+ CAM_DBG(CAM_ISP, "Enter:max_idx = %d", max_idx);
while (i < max_idx) {
if (affected_core[ife_hwr_mgr_ctx->base[i].idx])
@@ -2160,7 +2192,7 @@ static int cam_ife_hw_mgr_match_hw_idx(
j = j - 1;
}
}
- CDBG("%s:Exit\n", __func__);
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -2186,11 +2218,11 @@ static int cam_ife_hw_mgr_handle_overflow(
struct cam_hw_stop_args stop_args;
uint32_t i = 0;
- CDBG("%s:Enter\n", __func__);
+ CAM_DBG(CAM_ISP, "Enter");
return 0;
if (!recovery_data) {
- pr_err("%s: recovery_data parameter is NULL\n",
+ CAM_ERR(CAM_ISP, "recovery_data parameter is NULL",
__func__);
return -EINVAL;
}
@@ -2207,7 +2239,7 @@ static int cam_ife_hw_mgr_handle_overflow(
* Check if current core_idx matches the HW associated
* with this context
*/
- CDBG("%s:Calling match Hw idx\n", __func__);
+ CAM_DBG(CAM_ISP, "Calling match Hw idx");
if (cam_ife_hw_mgr_match_hw_idx(ife_hwr_mgr_ctx, affected_core))
continue;
@@ -2217,7 +2249,7 @@ static int cam_ife_hw_mgr_handle_overflow(
stop_args.ctxt_to_hw_map = ife_hwr_mgr_ctx;
/* Add affected_context in list of recovery data*/
- CDBG("%s:Add new entry in affected_ctx_list\n", __func__);
+ CAM_DBG(CAM_ISP, "Add new entry in affected_ctx_list");
if (recovery_data->no_of_context < CAM_CTX_MAX)
recovery_data->affected_ctx[
recovery_data->no_of_context++] =
@@ -2230,7 +2262,7 @@ static int cam_ife_hw_mgr_handle_overflow(
*/
if (!cam_ife_mgr_stop_hw_in_overflow(&hw_mgr_priv,
&stop_args)) {
- CDBG("%s:Calling Error handler CB\n", __func__);
+ CAM_DBG(CAM_ISP, "Calling Error handler CB");
ife_hwr_irq_err_cb(ife_hwr_mgr_ctx->common.cb_priv,
CAM_ISP_HW_EVENT_ERROR, error_event_data);
}
@@ -2238,10 +2270,10 @@ static int cam_ife_hw_mgr_handle_overflow(
/* fill the affected_core in recovery data */
for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) {
recovery_data->affected_core[i] = affected_core[i];
- CDBG("%s: Vfe core %d is affected (%d)\n",
- __func__, i, recovery_data->affected_core[i]);
+ CAM_DBG(CAM_ISP, "Vfe core %d is affected (%d)",
+ i, recovery_data->affected_core[i]);
}
- CDBG("%s:Exit\n", __func__);
+ CAM_DBG(CAM_ISP, "Exit");
return 0;
}
@@ -2261,7 +2293,7 @@ static int cam_ife_hw_mgr_handle_camif_error(
core_idx = evt_payload->core_index;
rc = evt_payload->error_type;
- CDBG("%s: Enter: error_type (%d)\n", __func__, evt_payload->error_type);
+ CAM_DBG(CAM_ISP, "Enter: error_type (%d)", evt_payload->error_type);
switch (evt_payload->error_type) {
case CAM_ISP_HW_ERROR_OVERFLOW:
case CAM_ISP_HW_ERROR_P2I_ERROR:
@@ -2280,11 +2312,11 @@ static int cam_ife_hw_mgr_handle_camif_error(
cam_ife_hw_mgr_do_error_recovery(&recovery_data);
break;
default:
- CDBG("%s: None error. Error type (%d)\n", __func__,
+ CAM_DBG(CAM_ISP, "None error. Error type (%d)",
evt_payload->error_type);
}
- CDBG("%s: Exit (%d)\n", __func__, rc);
+ CAM_DBG(CAM_ISP, "Exit (%d)", rc);
return rc;
}
@@ -2294,26 +2326,26 @@ static int cam_ife_hw_mgr_handle_camif_error(
* of dual VFE.
* RDI path does not support DUAl VFE
*/
-static int cam_ife_hw_mgr_handle_rup_for_camif_hw_res(
+static int cam_ife_hw_mgr_handle_reg_update(
void *handler_priv,
void *payload)
{
struct cam_isp_resource_node *hw_res;
struct cam_ife_hw_mgr_ctx *ife_hwr_mgr_ctx;
struct cam_vfe_top_irq_evt_payload *evt_payload;
- struct cam_ife_hw_mgr_res *isp_ife_camif_res = NULL;
+ struct cam_ife_hw_mgr_res *ife_src_res = NULL;
cam_hw_event_cb_func ife_hwr_irq_rup_cb;
struct cam_isp_hw_reg_update_event_data rup_event_data;
uint32_t core_idx;
uint32_t rup_status = -EINVAL;
- CDBG("%s: Enter\n", __func__);
+ CAM_DBG(CAM_ISP, "Enter");
ife_hwr_mgr_ctx = handler_priv;
evt_payload = payload;
if (!handler_priv || !payload) {
- pr_err("%s: Invalid Parameter\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid Parameter");
return -EPERM;
}
@@ -2322,65 +2354,82 @@ static int cam_ife_hw_mgr_handle_rup_for_camif_hw_res(
ife_hwr_mgr_ctx->common.event_cb[CAM_ISP_HW_EVENT_REG_UPDATE];
evt_payload->evt_id = CAM_ISP_HW_EVENT_REG_UPDATE;
- list_for_each_entry(isp_ife_camif_res,
+ list_for_each_entry(ife_src_res,
&ife_hwr_mgr_ctx->res_list_ife_src, list) {
- if (isp_ife_camif_res->res_type == CAM_IFE_HW_MGR_RES_UNINIT)
+ if (ife_src_res->res_type == CAM_IFE_HW_MGR_RES_UNINIT)
continue;
- CDBG("%s: camif resource id = %d, curr_core_idx = %d\n",
- __func__, isp_ife_camif_res->res_id, core_idx);
- switch (isp_ife_camif_res->res_id) {
+ CAM_DBG(CAM_ISP, "resource id = %d, curr_core_idx = %d",
+ ife_src_res->res_id, core_idx);
+ switch (ife_src_res->res_id) {
case CAM_ISP_HW_VFE_IN_CAMIF:
- if (isp_ife_camif_res->is_dual_vfe)
+ if (ife_src_res->is_dual_vfe)
/* It checks for slave core RUP ACK*/
- hw_res = isp_ife_camif_res->hw_res[1];
+ hw_res = ife_src_res->hw_res[1];
else
- hw_res = isp_ife_camif_res->hw_res[0];
+ hw_res = ife_src_res->hw_res[0];
if (!hw_res) {
- pr_err("%s: CAMIF device is NULL\n", __func__);
+ CAM_ERR(CAM_ISP, "CAMIF device is NULL");
break;
}
- CDBG("%s: current_core_id = %d , core_idx res = %d\n",
- __func__, core_idx,
- hw_res->hw_intf->hw_idx);
+ CAM_DBG(CAM_ISP,
+ "current_core_id = %d , core_idx res = %d",
+ core_idx, hw_res->hw_intf->hw_idx);
if (core_idx == hw_res->hw_intf->hw_idx) {
rup_status = hw_res->bottom_half_handler(
hw_res, evt_payload);
}
+
+ if (!rup_status) {
+ ife_hwr_irq_rup_cb(
+ ife_hwr_mgr_ctx->common.cb_priv,
+ CAM_ISP_HW_EVENT_REG_UPDATE,
+ &rup_event_data);
+ }
break;
case CAM_ISP_HW_VFE_IN_RDI0:
case CAM_ISP_HW_VFE_IN_RDI1:
case CAM_ISP_HW_VFE_IN_RDI2:
- hw_res = isp_ife_camif_res->hw_res[0];
+ case CAM_ISP_HW_VFE_IN_RDI3:
+ if (!ife_hwr_mgr_ctx->is_rdi_only_context)
+ continue;
+
+ /*
+ * This is RDI only context, send Reg update and epoch
+ * HW event to cam context
+ */
+ hw_res = ife_src_res->hw_res[0];
if (!hw_res) {
- pr_err("%s: RDI Device is NULL\n", __func__);
+ CAM_ERR(CAM_ISP, "RDI Device is NULL");
break;
}
+
if (core_idx == hw_res->hw_intf->hw_idx)
- /* Need to process rdi reg update */
- rup_status = -EINVAL;
+ rup_status = hw_res->bottom_half_handler(
+ hw_res, evt_payload);
+
+ if (!rup_status) {
+ /* Send the Reg update hw event */
+ ife_hwr_irq_rup_cb(
+ ife_hwr_mgr_ctx->common.cb_priv,
+ CAM_ISP_HW_EVENT_REG_UPDATE,
+ &rup_event_data);
+ }
break;
default:
- pr_err("%s: invalid resource id (%d)", __func__,
- isp_ife_camif_res->res_id);
- }
-
- /* only do callback for pixel reg update for now */
- if (!rup_status && (isp_ife_camif_res->res_id ==
- CAM_ISP_HW_VFE_IN_CAMIF)) {
- ife_hwr_irq_rup_cb(ife_hwr_mgr_ctx->common.cb_priv,
- CAM_ISP_HW_EVENT_REG_UPDATE, &rup_event_data);
+ CAM_ERR(CAM_ISP, "Invalid resource id (%d)",
+ ife_src_res->res_id);
}
}
if (!rup_status)
- CDBG("%s: Exit rup_status = %d\n", __func__, rup_status);
+ CAM_DBG(CAM_ISP, "Exit rup_status = %d", rup_status);
return 0;
}
@@ -2406,13 +2455,13 @@ static int cam_ife_hw_mgr_check_epoch_for_dual_vfe(
if ((epoch_cnt[core_idx0] - epoch_cnt[core_idx1] > 1) ||
(epoch_cnt[core_idx1] - epoch_cnt[core_idx0] > 1)) {
- pr_warn("%s:One of the VFE of dual VFE cound not generate error\n",
- __func__);
+ CAM_WARN(CAM_ISP,
+ "One of the VFE of dual VFE cound not generate error");
rc = -1;
return rc;
}
- CDBG("Only one core_index has given EPOCH\n");
+ CAM_DBG(CAM_ISP, "Only one core_index has given EPOCH");
return rc;
}
@@ -2434,7 +2483,7 @@ static int cam_ife_hw_mgr_handle_epoch_for_camif_hw_res(
uint32_t core_index0;
uint32_t core_index1;
- CDBG("%s:Enter\n", __func__);
+ CAM_DBG(CAM_ISP, "Enter");
ife_hwr_mgr_ctx = handler_priv;
evt_payload = payload;
@@ -2459,8 +2508,7 @@ static int cam_ife_hw_mgr_handle_epoch_for_camif_hw_res(
case 0:
/* EPOCH check for Left side VFE */
if (!hw_res_l) {
- pr_err("%s: Left Device is NULL\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Left Device is NULL");
break;
}
@@ -2481,8 +2529,7 @@ static int cam_ife_hw_mgr_handle_epoch_for_camif_hw_res(
/* SOF check for Left side VFE (Master)*/
if ((!hw_res_l) || (!hw_res_r)) {
- pr_err("%s: Dual VFE Device is NULL\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Dual VFE Device is NULL");
break;
}
if (core_idx == hw_res_l->hw_intf->hw_idx) {
@@ -2520,13 +2567,13 @@ static int cam_ife_hw_mgr_handle_epoch_for_camif_hw_res(
/* Error */
default:
- pr_err("%s: error with hw_res\n", __func__);
+ CAM_ERR(CAM_ISP, "error with hw_res");
}
}
if (!epoch_status)
- CDBG("%s: Exit epoch_status = %d\n", __func__, epoch_status);
+ CAM_DBG(CAM_ISP, "Exit epoch_status = %d", epoch_status);
return 0;
}
@@ -2552,134 +2599,56 @@ static int cam_ife_hw_mgr_check_sof_for_dual_vfe(
if ((sof_cnt[core_idx0] - sof_cnt[core_idx1] > 1) ||
(sof_cnt[core_idx1] - sof_cnt[core_idx0] > 1)) {
- pr_err("%s: One VFE of dual VFE cound not generate SOF\n",
- __func__);
+ CAM_ERR(CAM_ISP, "One VFE of dual VFE cound not generate SOF");
rc = -1;
return rc;
}
- pr_info("Only one core_index has given SOF\n");
+ CAM_INFO(CAM_ISP, "Only one core_index has given SOF");
return rc;
}
-static int cam_ife_hw_mgr_handle_sof_for_camif_hw_res(
- void *handler_priv,
- void *payload)
+static int cam_ife_hw_mgr_process_camif_sof(
+ struct cam_ife_hw_mgr_res *isp_ife_camif_res,
+ struct cam_ife_hw_mgr_ctx *ife_hwr_mgr_ctx,
+ struct cam_vfe_top_irq_evt_payload *evt_payload)
{
- int32_t rc = -1;
+ struct cam_isp_hw_sof_event_data sof_done_event_data;
+ cam_hw_event_cb_func ife_hwr_irq_sof_cb;
struct cam_isp_resource_node *hw_res_l = NULL;
struct cam_isp_resource_node *hw_res_r = NULL;
- struct cam_ife_hw_mgr_ctx *ife_hwr_mgr_ctx;
- struct cam_vfe_top_irq_evt_payload *evt_payload;
- struct cam_ife_hw_mgr_res *isp_ife_camif_res = NULL;
- cam_hw_event_cb_func ife_hwr_irq_sof_cb;
- struct cam_isp_hw_sof_event_data sof_done_event_data;
+ int32_t rc = -EINVAL;
uint32_t core_idx;
uint32_t sof_status = 0;
uint32_t core_index0;
uint32_t core_index1;
- CDBG("%s:Enter\n", __func__);
-
- ife_hwr_mgr_ctx = handler_priv;
- evt_payload = payload;
- if (!evt_payload) {
- pr_err("%s: no payload\n", __func__);
- return IRQ_HANDLED;
- }
+ CAM_DBG(CAM_ISP, "Enter");
core_idx = evt_payload->core_index;
+ hw_res_l = isp_ife_camif_res->hw_res[0];
+ hw_res_r = isp_ife_camif_res->hw_res[1];
+ CAM_DBG(CAM_ISP, "is_dual_vfe ? = %d",
+ isp_ife_camif_res->is_dual_vfe);
+
ife_hwr_irq_sof_cb =
ife_hwr_mgr_ctx->common.event_cb[CAM_ISP_HW_EVENT_SOF];
- evt_payload->evt_id = CAM_ISP_HW_EVENT_SOF;
-
- list_for_each_entry(isp_ife_camif_res,
- &ife_hwr_mgr_ctx->res_list_ife_src, list) {
-
- if ((isp_ife_camif_res->res_type ==
- CAM_IFE_HW_MGR_RES_UNINIT) ||
- (isp_ife_camif_res->res_id != CAM_ISP_HW_VFE_IN_CAMIF))
- continue;
-
- hw_res_l = isp_ife_camif_res->hw_res[0];
- hw_res_r = isp_ife_camif_res->hw_res[1];
-
- CDBG("%s:is_dual_vfe ? = %d\n", __func__,
- isp_ife_camif_res->is_dual_vfe);
- switch (isp_ife_camif_res->is_dual_vfe) {
- /* Handling Single VFE Scenario */
- case 0:
- /* SOF check for Left side VFE */
- if (!hw_res_l) {
- pr_err("%s: VFE Device is NULL\n",
- __func__);
- break;
- }
- CDBG("%s: curr_core_idx = %d, core idx hw = %d\n",
- __func__, core_idx,
- hw_res_l->hw_intf->hw_idx);
-
- if (core_idx == hw_res_l->hw_intf->hw_idx) {
- sof_status = hw_res_l->bottom_half_handler(
- hw_res_l, evt_payload);
- if (!sof_status) {
- cam_ife_mgr_cmd_get_sof_timestamp(
- ife_hwr_mgr_ctx,
- &sof_done_event_data.timestamp);
-
- ife_hwr_irq_sof_cb(
- ife_hwr_mgr_ctx->common.cb_priv,
- CAM_ISP_HW_EVENT_SOF,
- &sof_done_event_data);
- }
- }
-
+ switch (isp_ife_camif_res->is_dual_vfe) {
+ /* Handling Single VFE Scenario */
+ case 0:
+ /* SOF check for Left side VFE */
+ if (!hw_res_l) {
+ CAM_ERR(CAM_ISP, "VFE Device is NULL");
break;
+ }
+ CAM_DBG(CAM_ISP, "curr_core_idx = %d,core idx hw = %d",
+ core_idx, hw_res_l->hw_intf->hw_idx);
- /* Handling Dual VFE Scenario */
- case 1:
- /* SOF check for Left side VFE */
-
- if (!hw_res_l) {
- pr_err("%s: VFE Device is NULL\n",
- __func__);
- break;
- }
- CDBG("%s: curr_core_idx = %d, idx associated hw = %d\n",
- __func__, core_idx,
- hw_res_l->hw_intf->hw_idx);
-
- if (core_idx == hw_res_l->hw_intf->hw_idx) {
- sof_status = hw_res_l->bottom_half_handler(
- hw_res_l, evt_payload);
- if (!sof_status)
- ife_hwr_mgr_ctx->sof_cnt[core_idx]++;
- }
-
- /* SOF check for Right side VFE */
- if (!hw_res_r) {
- pr_err("%s: VFE Device is NULL\n",
- __func__);
- break;
- }
- CDBG("%s: curr_core_idx = %d, idx associated hw = %d\n",
- __func__, core_idx,
- hw_res_r->hw_intf->hw_idx);
- if (core_idx == hw_res_r->hw_intf->hw_idx) {
- sof_status = hw_res_r->bottom_half_handler(
- hw_res_r, evt_payload);
- if (!sof_status)
- ife_hwr_mgr_ctx->sof_cnt[core_idx]++;
- }
-
- core_index0 = hw_res_l->hw_intf->hw_idx;
- core_index1 = hw_res_r->hw_intf->hw_idx;
-
- rc = cam_ife_hw_mgr_check_sof_for_dual_vfe(
- ife_hwr_mgr_ctx, core_index0, core_index1);
-
- if (!rc) {
+ if (core_idx == hw_res_l->hw_intf->hw_idx) {
+ sof_status = hw_res_l->bottom_half_handler(hw_res_l,
+ evt_payload);
+ if (!sof_status) {
cam_ife_mgr_cmd_get_sof_timestamp(
ife_hwr_mgr_ctx,
&sof_done_event_data.timestamp);
@@ -2689,14 +2658,138 @@ static int cam_ife_hw_mgr_handle_sof_for_camif_hw_res(
CAM_ISP_HW_EVENT_SOF,
&sof_done_event_data);
}
+ }
+
+ break;
+
+ /* Handling Dual VFE Scenario */
+ case 1:
+ /* SOF check for Left side VFE */
+
+ if (!hw_res_l) {
+ CAM_ERR(CAM_ISP, "VFE Device is NULL");
+ break;
+ }
+ CAM_DBG(CAM_ISP, "curr_core_idx = %d, res hw idx= %d",
+ core_idx,
+ hw_res_l->hw_intf->hw_idx);
+
+ if (core_idx == hw_res_l->hw_intf->hw_idx) {
+ sof_status = hw_res_l->bottom_half_handler(
+ hw_res_l, evt_payload);
+ if (!sof_status)
+ ife_hwr_mgr_ctx->sof_cnt[core_idx]++;
+ }
+
+ /* SOF check for Right side VFE */
+ if (!hw_res_r) {
+ CAM_ERR(CAM_ISP, "VFE Device is NULL");
+ break;
+ }
+ CAM_DBG(CAM_ISP, "curr_core_idx = %d, ews hw idx= %d",
+ core_idx,
+ hw_res_r->hw_intf->hw_idx);
+ if (core_idx == hw_res_r->hw_intf->hw_idx) {
+ sof_status = hw_res_r->bottom_half_handler(hw_res_r,
+ evt_payload);
+ if (!sof_status)
+ ife_hwr_mgr_ctx->sof_cnt[core_idx]++;
+ }
+
+ core_index0 = hw_res_l->hw_intf->hw_idx;
+ core_index1 = hw_res_r->hw_intf->hw_idx;
+
+ rc = cam_ife_hw_mgr_check_sof_for_dual_vfe(ife_hwr_mgr_ctx,
+ core_index0, core_index1);
+
+ if (!rc)
+ ife_hwr_irq_sof_cb(ife_hwr_mgr_ctx->common.cb_priv,
+ CAM_ISP_HW_EVENT_SOF, &sof_done_event_data);
+
+ break;
+
+ default:
+ CAM_ERR(CAM_ISP, "error with hw_res");
+ break;
+ }
+
+ CAM_DBG(CAM_ISP, "Exit (sof_status = %d)!", sof_status);
+
+ return 0;
+}
+
+static int cam_ife_hw_mgr_handle_sof(
+ void *handler_priv,
+ void *payload)
+{
+ int32_t rc = -EINVAL;
+ struct cam_isp_resource_node *hw_res = NULL;
+ struct cam_ife_hw_mgr_ctx *ife_hw_mgr_ctx;
+ struct cam_vfe_top_irq_evt_payload *evt_payload;
+ struct cam_ife_hw_mgr_res *ife_src_res = NULL;
+ cam_hw_event_cb_func ife_hw_irq_sof_cb;
+ struct cam_isp_hw_sof_event_data sof_done_event_data;
+ uint32_t sof_status = 0;
+
+ CAM_DBG(CAM_ISP, "Enter");
+
+ ife_hw_mgr_ctx = handler_priv;
+ evt_payload = payload;
+ if (!evt_payload) {
+ CAM_ERR(CAM_ISP, "no payload");
+ return IRQ_HANDLED;
+ }
+ ife_hw_irq_sof_cb =
+ ife_hw_mgr_ctx->common.event_cb[CAM_ISP_HW_EVENT_SOF];
+
+ evt_payload->evt_id = CAM_ISP_HW_EVENT_SOF;
+
+ list_for_each_entry(ife_src_res,
+ &ife_hw_mgr_ctx->res_list_ife_src, list) {
+
+ if (ife_src_res->res_type == CAM_IFE_HW_MGR_RES_UNINIT)
+ continue;
+
+ switch (ife_src_res->res_id) {
+ case CAM_ISP_HW_VFE_IN_RDI0:
+ case CAM_ISP_HW_VFE_IN_RDI1:
+ case CAM_ISP_HW_VFE_IN_RDI2:
+ case CAM_ISP_HW_VFE_IN_RDI3:
+ /* check if it is rdi only context */
+ if (ife_hw_mgr_ctx->is_rdi_only_context) {
+ hw_res = ife_src_res->hw_res[0];
+ sof_status = hw_res->bottom_half_handler(
+ hw_res, evt_payload);
+
+ if (!sof_status) {
+ cam_ife_mgr_cmd_get_sof_timestamp(
+ ife_hw_mgr_ctx,
+ &sof_done_event_data.timestamp);
+
+ ife_hw_irq_sof_cb(
+ ife_hw_mgr_ctx->common.cb_priv,
+ CAM_ISP_HW_EVENT_SOF,
+ &sof_done_event_data);
+ }
+
+ CAM_DBG(CAM_ISP, "sof_status = %d", sof_status);
+
+ /* this is RDI only context so exit from here */
+ return 0;
+ }
break;
+ case CAM_ISP_HW_VFE_IN_CAMIF:
+ rc = cam_ife_hw_mgr_process_camif_sof(ife_src_res,
+ ife_hw_mgr_ctx, evt_payload);
+ break;
default:
- pr_err("%s: error with hw_res\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid resource id :%d",
+ ife_src_res->res_id);
+ break;
}
}
- CDBG("%s: Exit (sof_status = %d)!\n", __func__, sof_status);
return 0;
}
@@ -2719,7 +2812,7 @@ static int cam_ife_hw_mgr_handle_buf_done_for_hw_res(
uint32_t error_resc_handle[CAM_IFE_HW_OUT_RES_MAX];
uint32_t num_of_error_handles = 0;
- CDBG("%s:Enter\n", __func__);
+ CAM_DBG(CAM_ISP, "Enter");
ife_hwr_mgr_ctx = evt_payload->ctx;
ife_hwr_irq_wm_done_cb =
@@ -2782,7 +2875,7 @@ static int cam_ife_hw_mgr_handle_buf_done_for_hw_res(
/* Report for Successful buf_done event if any */
if (buf_done_event_data.num_handles > 0 &&
ife_hwr_irq_wm_done_cb) {
- CDBG("%s: notify isp context\n", __func__);
+ CAM_DBG(CAM_ISP, "notify isp context");
ife_hwr_irq_wm_done_cb(
ife_hwr_mgr_ctx->common.cb_priv,
CAM_ISP_HW_EVENT_DONE,
@@ -2802,8 +2895,9 @@ static int cam_ife_hw_mgr_handle_buf_done_for_hw_res(
break;
}
if (!buf_done_status)
- CDBG("buf_done status:(%d),out_res->res_id: 0x%x\n",
- buf_done_status, isp_ife_out_res->res_id);
+ CAM_DBG(CAM_ISP,
+ "buf_done status:(%d),out_res->res_id: 0x%x",
+ buf_done_status, isp_ife_out_res->res_id);
}
return rc;
@@ -2824,8 +2918,8 @@ static int cam_ife_hw_mgr_handle_buf_done_for_hw_res(
* for the first phase, we are going to reset entire HW.
*/
- CDBG("%s: Exit (buf_done_status (Error) = %d)!\n", __func__,
- buf_done_status);
+ CAM_DBG(CAM_ISP, "Exit (buf_done_status (Error) = %d)!",
+ buf_done_status);
return rc;
}
@@ -2842,16 +2936,19 @@ int cam_ife_mgr_do_tasklet_buf_done(void *handler_priv,
evt_payload = evt_payload_priv;
ife_hwr_mgr_ctx = (struct cam_ife_hw_mgr_ctx *)evt_payload->ctx;
- CDBG("addr of evt_payload = %llx\n", (uint64_t)evt_payload);
- CDBG("bus_irq_status_0: = %x\n", evt_payload->irq_reg_val[0]);
- CDBG("bus_irq_status_1: = %x\n", evt_payload->irq_reg_val[1]);
- CDBG("bus_irq_status_2: = %x\n", evt_payload->irq_reg_val[2]);
- CDBG("bus_irq_comp_err: = %x\n", evt_payload->irq_reg_val[3]);
- CDBG("bus_irq_comp_owrt: = %x\n", evt_payload->irq_reg_val[4]);
- CDBG("bus_irq_dual_comp_err: = %x\n", evt_payload->irq_reg_val[5]);
- CDBG("bus_irq_dual_comp_owrt: = %x\n", evt_payload->irq_reg_val[6]);
+ CAM_DBG(CAM_ISP, "addr of evt_payload = %llx", (uint64_t)evt_payload);
+ CAM_DBG(CAM_ISP, "bus_irq_status_0: = %x", evt_payload->irq_reg_val[0]);
+ CAM_DBG(CAM_ISP, "bus_irq_status_1: = %x", evt_payload->irq_reg_val[1]);
+ CAM_DBG(CAM_ISP, "bus_irq_status_2: = %x", evt_payload->irq_reg_val[2]);
+ CAM_DBG(CAM_ISP, "bus_irq_comp_err: = %x", evt_payload->irq_reg_val[3]);
+ CAM_DBG(CAM_ISP, "bus_irq_comp_owrt: = %x",
+ evt_payload->irq_reg_val[4]);
+ CAM_DBG(CAM_ISP, "bus_irq_dual_comp_err: = %x",
+ evt_payload->irq_reg_val[5]);
+ CAM_DBG(CAM_ISP, "bus_irq_dual_comp_owrt: = %x",
+ evt_payload->irq_reg_val[6]);
- CDBG("%s: Calling Buf_done\n", __func__);
+ CAM_DBG(CAM_ISP, "Calling Buf_done");
/* WM Done */
return cam_ife_hw_mgr_handle_buf_done_for_hw_res(ife_hwr_mgr_ctx,
evt_payload_priv);
@@ -2869,10 +2966,11 @@ int cam_ife_mgr_do_tasklet(void *handler_priv, void *evt_payload_priv)
evt_payload = evt_payload_priv;
ife_hwr_mgr_ctx = (struct cam_ife_hw_mgr_ctx *)handler_priv;
- CDBG("addr of evt_payload = %llx\n", (uint64_t)evt_payload);
- CDBG("irq_status_0: = %x\n", evt_payload->irq_reg_val[0]);
- CDBG("irq_status_1: = %x\n", evt_payload->irq_reg_val[1]);
- CDBG("Violation register: = %x\n", evt_payload->irq_reg_val[2]);
+ CAM_DBG(CAM_ISP, "addr of evt_payload = %llx", (uint64_t)evt_payload);
+ CAM_DBG(CAM_ISP, "irq_status_0: = %x", evt_payload->irq_reg_val[0]);
+ CAM_DBG(CAM_ISP, "irq_status_1: = %x", evt_payload->irq_reg_val[1]);
+ CAM_DBG(CAM_ISP, "Violation register: = %x",
+ evt_payload->irq_reg_val[2]);
/*
* If overflow/overwrite/error/violation are pending
@@ -2882,22 +2980,22 @@ int cam_ife_mgr_do_tasklet(void *handler_priv, void *evt_payload_priv)
rc = cam_ife_hw_mgr_handle_camif_error(ife_hwr_mgr_ctx,
evt_payload_priv);
if (rc) {
- pr_err("%s: Encountered Error (%d), ignoring other irqs\n",
- __func__, rc);
+ CAM_ERR(CAM_ISP, "Encountered Error (%d), ignoring other irqs",
+ rc);
return IRQ_HANDLED;
}
- CDBG("%s: Calling SOF\n", __func__);
+ CAM_DBG(CAM_ISP, "Calling SOF");
/* SOF IRQ */
- cam_ife_hw_mgr_handle_sof_for_camif_hw_res(ife_hwr_mgr_ctx,
+ cam_ife_hw_mgr_handle_sof(ife_hwr_mgr_ctx,
evt_payload_priv);
- CDBG("%s: Calling RUP\n", __func__);
+ CAM_DBG(CAM_ISP, "Calling RUP");
/* REG UPDATE */
- cam_ife_hw_mgr_handle_rup_for_camif_hw_res(ife_hwr_mgr_ctx,
+ cam_ife_hw_mgr_handle_reg_update(ife_hwr_mgr_ctx,
evt_payload_priv);
- CDBG("%s: Calling EPOCH\n", __func__);
+ CAM_DBG(CAM_ISP, "Calling EPOCH");
/* EPOCH IRQ */
cam_ife_hw_mgr_handle_epoch_for_camif_hw_res(ife_hwr_mgr_ctx,
evt_payload_priv);
@@ -2943,15 +3041,14 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf)
int i, j;
struct cam_iommu_handle cdm_handles;
- CDBG("%s: Enter\n", __func__);
+ CAM_DBG(CAM_ISP, "Enter");
memset(&g_ife_hw_mgr, 0, sizeof(g_ife_hw_mgr));
mutex_init(&g_ife_hw_mgr.ctx_mutex);
if (CAM_IFE_HW_NUM_MAX != CAM_IFE_CSID_HW_NUM_MAX) {
- pr_err("%s: Fatal, CSID num is different then IFE num!\n",
- __func__);
+ CAM_ERR(CAM_ISP, "Fatal, CSID num is different then IFE num!");
goto end;
}
@@ -2967,15 +3064,16 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf)
j++;
g_ife_hw_mgr.cdm_reg_map[i] = &soc_info->reg_map[0];
- CDBG("reg_map: mem base = 0x%llx, cam_base = 0x%llx\n",
- (uint64_t) soc_info->reg_map[0].mem_base,
+ CAM_DBG(CAM_ISP,
+ "reg_map: mem base = %pK cam_base = 0x%llx",
+ (void __iomem *)soc_info->reg_map[0].mem_base,
(uint64_t) soc_info->reg_map[0].mem_cam_base);
} else {
g_ife_hw_mgr.cdm_reg_map[i] = NULL;
}
}
if (j == 0) {
- pr_err("%s: no valid IFE HW!\n", __func__);
+ CAM_ERR(CAM_ISP, "no valid IFE HW!");
goto end;
}
@@ -2986,7 +3084,7 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf)
j++;
}
if (!j) {
- pr_err("%s: no valid IFE CSID HW!\n", __func__);
+ CAM_ERR(CAM_ISP, "no valid IFE CSID HW!");
goto end;
}
@@ -3005,26 +3103,27 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf)
*/
if (cam_smmu_get_handle("ife",
&g_ife_hw_mgr.mgr_common.img_iommu_hdl)) {
- pr_err("%s: Can not get iommu handle.\n", __func__);
+ CAM_ERR(CAM_ISP, "Can not get iommu handle.");
goto end;
}
if (cam_smmu_ops(g_ife_hw_mgr.mgr_common.img_iommu_hdl,
CAM_SMMU_ATTACH)) {
- pr_err("%s: Attach iommu handle failed.\n", __func__);
+ CAM_ERR(CAM_ISP, "Attach iommu handle failed.");
goto end;
}
- CDBG("got iommu_handle=%d\n", g_ife_hw_mgr.mgr_common.img_iommu_hdl);
+ CAM_DBG(CAM_ISP, "got iommu_handle=%d",
+ g_ife_hw_mgr.mgr_common.img_iommu_hdl);
g_ife_hw_mgr.mgr_common.img_iommu_hdl_secure = -1;
if (!cam_cdm_get_iommu_handle("ife", &cdm_handles)) {
- CDBG("Successfully acquired the CDM iommu handles\n");
+ CAM_DBG(CAM_ISP, "Successfully acquired the CDM iommu handles");
g_ife_hw_mgr.mgr_common.cmd_iommu_hdl = cdm_handles.non_secure;
g_ife_hw_mgr.mgr_common.cmd_iommu_hdl_secure =
cdm_handles.secure;
} else {
- CDBG("Failed to acquire the CDM iommu handles\n");
+ CAM_DBG(CAM_ISP, "Failed to acquire the CDM iommu handles");
g_ife_hw_mgr.mgr_common.cmd_iommu_hdl = -1;
g_ife_hw_mgr.mgr_common.cmd_iommu_hdl_secure = -1;
}
@@ -3059,7 +3158,7 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf)
sizeof(struct cam_cdm_bl_cmd))), GFP_KERNEL);
if (!g_ife_hw_mgr.ctx_pool[i].cdm_cmd) {
rc = -ENOMEM;
- pr_err("Allocation Failed for cdm command\n");
+ CAM_ERR(CAM_ISP, "Allocation Failed for cdm command");
goto end;
}
@@ -3080,7 +3179,7 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf)
&g_ife_hw_mgr.workq, CRM_WORKQ_USAGE_NON_IRQ);
if (rc < 0) {
- pr_err("%s: Unable to create worker\n", __func__);
+ CAM_ERR(CAM_ISP, "Unable to create worker");
goto end;
}
@@ -3095,8 +3194,9 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf)
hw_mgr_intf->hw_release = cam_ife_mgr_release_hw;
hw_mgr_intf->hw_prepare_update = cam_ife_mgr_prepare_hw_update;
hw_mgr_intf->hw_config = cam_ife_mgr_config_hw;
+ hw_mgr_intf->hw_cmd = cam_ife_mgr_cmd;
- CDBG("%s: Exit\n", __func__);
+ CAM_DBG(CAM_ISP, "Exit");
return 0;
end:
if (rc) {
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h
index 174d2ce..6dfdb21 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h
@@ -108,6 +108,7 @@ struct ctx_base_info {
* @epoch_cnt epoch count value per core, used for dual VFE
* @overflow_pending flat to specify the overflow is pending for the
* context
+ * @is_rdi_only_context flag to specify the context has only rdi resource
*/
struct cam_ife_hw_mgr_ctx {
struct list_head list;
@@ -138,6 +139,7 @@ struct cam_ife_hw_mgr_ctx {
uint32_t sof_cnt[CAM_IFE_HW_NUM_MAX];
uint32_t epoch_cnt[CAM_IFE_HW_NUM_MAX];
atomic_t overflow_pending;
+ uint32_t is_rdi_only_context;
};
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c
index 2e23222..2f18895 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.c
@@ -12,6 +12,7 @@
#include "cam_isp_hw_mgr_intf.h"
#include "cam_ife_hw_mgr.h"
+#include "cam_debug_util.h"
int cam_isp_hw_mgr_init(struct device_node *of_node,
@@ -26,7 +27,7 @@ int cam_isp_hw_mgr_init(struct device_node *of_node,
if (strnstr(compat_str, "ife", strlen(compat_str)))
rc = cam_ife_hw_mgr_init(hw_mgr);
else {
- pr_err("%s: Invalid ISP hw type\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid ISP hw type");
rc = -EINVAL;
}
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c
index 3c72279..0a0eecb 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c
@@ -15,130 +15,13 @@
#include "cam_mem_mgr.h"
#include "cam_vfe_hw_intf.h"
#include "cam_isp_packet_parser.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-
-static int cam_isp_get_cmd_mem_addr(int handle, uint32_t **buf_addr,
- size_t *len)
-{
- int rc = 0;
- uint64_t kmd_buf_addr = 0;
-
- rc = cam_mem_get_cpu_buf(handle, &kmd_buf_addr, len);
- if (rc) {
- pr_err("%s:%d Unable to get the virtual address rc:%d\n",
- __func__, __LINE__, rc);
- rc = -ENOMEM;
- } else {
- if (kmd_buf_addr && *len)
- *buf_addr = (uint32_t *)kmd_buf_addr;
- else {
- pr_err("%s:%d Invalid addr and length :%ld\n",
- __func__, __LINE__, *len);
- rc = -ENOMEM;
- }
- }
- return rc;
-}
-
-static int cam_isp_validate_cmd_desc(
- struct cam_cmd_buf_desc *cmd_desc)
-{
- if (cmd_desc->length > cmd_desc->size ||
- (cmd_desc->mem_handle <= 0)) {
- pr_err("%s:%d invalid cmd arg %d %d %d %d\n",
- __func__, __LINE__, cmd_desc->offset,
- cmd_desc->length, cmd_desc->mem_handle,
- cmd_desc->size);
- return -EINVAL;
- }
-
- return 0;
-}
-
-int cam_isp_validate_packet(struct cam_packet *packet)
-{
- if (!packet)
- return -EINVAL;
-
- CDBG("%s:%d num cmd buf:%d num of io config:%d kmd buf index:%d\n",
- __func__, __LINE__, packet->num_cmd_buf,
- packet->num_io_configs, packet->kmd_cmd_buf_index);
-
- if (packet->kmd_cmd_buf_index >= packet->num_cmd_buf ||
- (!packet->header.size) ||
- packet->cmd_buf_offset > packet->header.size ||
- packet->io_configs_offset > packet->header.size) {
- pr_err("%s:%d invalid packet:%d %d %d %d %d\n",
- __func__, __LINE__, packet->kmd_cmd_buf_index,
- packet->num_cmd_buf, packet->cmd_buf_offset,
- packet->io_configs_offset, packet->header.size);
- return -EINVAL;
- }
-
- CDBG("%s:%d exit\n", __func__, __LINE__);
- return 0;
-}
-
-int cam_isp_get_kmd_buffer(struct cam_packet *packet,
- struct cam_isp_kmd_buf_info *kmd_buf)
-{
- int rc = 0;
- size_t len = 0;
- struct cam_cmd_buf_desc *cmd_desc;
- uint32_t *cpu_addr;
-
- if (!packet || !kmd_buf) {
- pr_err("%s:%d Invalid arg\n", __func__, __LINE__);
- rc = -EINVAL;
- return rc;
- }
-
- /* Take first command descriptor and add offset to it for kmd*/
- cmd_desc = (struct cam_cmd_buf_desc *) ((uint8_t *)
- &packet->payload + packet->cmd_buf_offset);
- cmd_desc += packet->kmd_cmd_buf_index;
-
- CDBG("%s:%d enter\n", __func__, __LINE__);
- rc = cam_isp_validate_cmd_desc(cmd_desc);
- if (rc)
- return rc;
-
- CDBG("%s:%d enter\n", __func__, __LINE__);
- rc = cam_isp_get_cmd_mem_addr(cmd_desc->mem_handle, &cpu_addr,
- &len);
- if (rc)
- return rc;
-
- if (len < cmd_desc->size) {
- pr_err("%s:%d invalid memory len:%ld and cmd desc size:%d\n",
- __func__, __LINE__, len, cmd_desc->size);
- return -EINVAL;
- }
-
- cpu_addr += cmd_desc->offset/4 + packet->kmd_cmd_buf_offset/4;
- CDBG("%s:%d total size %d, cmd size: %d, KMD buffer size: %d\n",
- __func__, __LINE__, cmd_desc->size, cmd_desc->length,
- cmd_desc->size - cmd_desc->length);
- CDBG("%s:%d: handle 0x%x, cmd offset %d, kmd offset %d, addr 0x%pK\n",
- __func__, __LINE__, cmd_desc->mem_handle, cmd_desc->offset,
- packet->kmd_cmd_buf_offset, cpu_addr);
-
- kmd_buf->cpu_addr = cpu_addr;
- kmd_buf->handle = cmd_desc->mem_handle;
- kmd_buf->offset = cmd_desc->offset + packet->kmd_cmd_buf_offset;
- kmd_buf->size = cmd_desc->size - cmd_desc->length;
- kmd_buf->used_bytes = 0;
-
- return rc;
-}
+#include "cam_debug_util.h"
int cam_isp_add_change_base(
struct cam_hw_prepare_update_args *prepare,
struct list_head *res_list_isp_src,
uint32_t base_idx,
- struct cam_isp_kmd_buf_info *kmd_buf_info)
+ struct cam_kmd_buf_info *kmd_buf_info)
{
int rc = -EINVAL;
struct cam_ife_hw_mgr_res *hw_mgr_res;
@@ -152,9 +35,8 @@ int cam_isp_add_change_base(
/* Max one hw entries required for each base */
if (num_ent + 1 >= prepare->max_hw_update_entries) {
- pr_err("%s:%d Insufficient HW entries :%d %d\n",
- __func__, __LINE__, num_ent,
- prepare->max_hw_update_entries);
+ CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d",
+ num_ent, prepare->max_hw_update_entries);
return -EINVAL;
}
@@ -220,8 +102,8 @@ int cam_isp_add_command_buffers(
((uint8_t *)&prepare->packet->payload +
prepare->packet->cmd_buf_offset);
- CDBG("%s:%d split id = %d, number of command buffers:%d\n", __func__,
- __LINE__, split_id, prepare->packet->num_cmd_buf);
+ CAM_DBG(CAM_ISP, "split id = %d, number of command buffers:%d",
+ split_id, prepare->packet->num_cmd_buf);
for (i = 0; i < prepare->packet->num_cmd_buf; i++) {
if (!cmd_desc[i].length)
@@ -229,19 +111,18 @@ int cam_isp_add_command_buffers(
/* One hw entry space required for left or right or common */
if (num_ent + 1 >= prepare->max_hw_update_entries) {
- pr_err("%s:%d Insufficient HW entries :%d %d\n",
- __func__, __LINE__, num_ent,
- prepare->max_hw_update_entries);
+ CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d",
+ num_ent, prepare->max_hw_update_entries);
return -EINVAL;
}
- rc = cam_isp_validate_cmd_desc(&cmd_desc[i]);
+ rc = cam_packet_util_validate_cmd_desc(&cmd_desc[i]);
if (rc)
return rc;
cmd_meta_data = cmd_desc[i].meta_data;
- CDBG("%s:%d meta type: %d, split_id: %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "meta type: %d, split_id: %d",
cmd_meta_data, split_id);
switch (cmd_meta_data) {
@@ -288,8 +169,8 @@ int cam_isp_add_command_buffers(
num_ent++;
break;
default:
- pr_err("%s:%d invalid cdm command meta data %d\n",
- __func__, __LINE__, cmd_meta_data);
+ CAM_ERR(CAM_ISP, "invalid cdm command meta data %d",
+ cmd_meta_data);
return -EINVAL;
}
}
@@ -304,7 +185,7 @@ int cam_isp_add_io_buffers(
int iommu_hdl,
struct cam_hw_prepare_update_args *prepare,
uint32_t base_idx,
- struct cam_isp_kmd_buf_info *kmd_buf_info,
+ struct cam_kmd_buf_info *kmd_buf_info,
struct cam_ife_hw_mgr_res *res_list_isp_out,
uint32_t size_isp_out,
bool fill_fence)
@@ -331,33 +212,31 @@ int cam_isp_add_io_buffers(
/* Max one hw entries required for each base */
if (prepare->num_hw_update_entries + 1 >=
prepare->max_hw_update_entries) {
- pr_err("%s:%d Insufficient HW entries :%d %d\n",
- __func__, __LINE__, prepare->num_hw_update_entries,
+ CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d",
+ prepare->num_hw_update_entries,
prepare->max_hw_update_entries);
return -EINVAL;
}
for (i = 0; i < prepare->packet->num_io_configs; i++) {
- CDBG("%s:%d ======= io config idx %d ============\n",
- __func__, __LINE__, i);
- CDBG("%s:%d resource_type:%d fence:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "======= io config idx %d ============", i);
+ CAM_DBG(CAM_ISP, "resource_type:%d fence:%d",
io_cfg[i].resource_type, io_cfg[i].fence);
- CDBG("%s:%d format: %d\n", __func__, __LINE__,
- io_cfg[i].format);
- CDBG("%s:%d direction %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "format: %d", io_cfg[i].format);
+ CAM_DBG(CAM_ISP, "direction %d",
io_cfg[i].direction);
if (io_cfg[i].direction == CAM_BUF_OUTPUT) {
res_id_out = io_cfg[i].resource_type & 0xFF;
if (res_id_out >= size_isp_out) {
- pr_err("%s:%d invalid out restype:%x\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP, "invalid out restype:%x",
io_cfg[i].resource_type);
return -EINVAL;
}
- CDBG("%s:%d configure output io with fill fence %d\n",
- __func__, __LINE__, fill_fence);
+ CAM_DBG(CAM_ISP,
+ "configure output io with fill fence %d",
+ fill_fence);
if (fill_fence) {
if (num_out_buf <
prepare->max_out_map_entries) {
@@ -368,8 +247,7 @@ int cam_isp_add_io_buffers(
sync_id = io_cfg[i].fence;
num_out_buf++;
} else {
- pr_err("%s:%d ln_out:%d max_ln:%d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP, "ln_out:%d max_ln:%d",
num_out_buf,
prepare->max_out_map_entries);
return -EINVAL;
@@ -378,15 +256,15 @@ int cam_isp_add_io_buffers(
hw_mgr_res = &res_list_isp_out[res_id_out];
if (hw_mgr_res->res_type == CAM_IFE_HW_MGR_RES_UNINIT) {
- pr_err("%s:%d io res id:%d not valid\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP, "io res id:%d not valid",
io_cfg[i].resource_type);
return -EINVAL;
}
} else if (io_cfg[i].direction == CAM_BUF_INPUT) {
res_id_in = io_cfg[i].resource_type & 0xFF;
- CDBG("%s:%d configure input io with fill fence %d\n",
- __func__, __LINE__, fill_fence);
+ CAM_DBG(CAM_ISP,
+ "configure input io with fill fence %d",
+ fill_fence);
if (fill_fence) {
if (num_in_buf < prepare->max_in_map_entries) {
prepare->in_map_entries[num_in_buf].
@@ -397,8 +275,7 @@ int cam_isp_add_io_buffers(
io_cfg[i].fence;
num_in_buf++;
} else {
- pr_err("%s:%d ln_in:%d imax_ln:%d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP, "ln_in:%d imax_ln:%d",
num_in_buf,
prepare->max_in_map_entries);
return -EINVAL;
@@ -406,13 +283,12 @@ int cam_isp_add_io_buffers(
}
continue;
} else {
- pr_err("%s:%d Invalid io config direction :%d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP, "Invalid io config direction :%d",
io_cfg[i].direction);
return -EINVAL;
}
- CDBG("%s:%d setup mem io\n", __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "setup mem io");
for (j = 0; j < CAM_ISP_HW_SPLIT_MAX; j++) {
if (!hw_mgr_res->hw_res[j])
continue;
@@ -422,9 +298,9 @@ int cam_isp_add_io_buffers(
res = hw_mgr_res->hw_res[j];
if (res->res_id != io_cfg[i].resource_type) {
- pr_err("%s:%d wm err res id:%d io res id:%d\n",
- __func__, __LINE__, res->res_id,
- io_cfg[i].resource_type);
+ CAM_ERR(CAM_ISP,
+ "wm err res id:%d io res id:%d",
+ res->res_id, io_cfg[i].resource_type);
return -EINVAL;
}
@@ -439,14 +315,16 @@ int cam_isp_add_io_buffers(
io_cfg[i].mem_handle[plane_id],
iommu_hdl, &io_addr[plane_id], &size);
if (rc) {
- pr_err("%s:%d no io addr for plane%d\n",
- __func__, __LINE__, plane_id);
+ CAM_ERR(CAM_ISP,
+ "no io addr for plane%d",
+ plane_id);
rc = -ENOMEM;
return rc;
}
if (io_addr[plane_id] >> 32) {
- pr_err("Invalid mapped address\n");
+ CAM_ERR(CAM_ISP,
+ "Invalid mapped address");
rc = -EINVAL;
return rc;
}
@@ -454,13 +332,13 @@ int cam_isp_add_io_buffers(
/* need to update with offset */
io_addr[plane_id] +=
io_cfg[i].offsets[plane_id];
- CDBG("%s: get io_addr for plane %d: 0x%llx\n",
- __func__, plane_id,
- io_addr[plane_id]);
+ CAM_DBG(CAM_ISP,
+ "get io_addr for plane %d: 0x%llx",
+ plane_id, io_addr[plane_id]);
}
if (!plane_id) {
- pr_err("%s:%d No valid planes for res%d\n",
- __func__, __LINE__, res->res_id);
+ CAM_ERR(CAM_ISP, "No valid planes for res%d",
+ res->res_id);
rc = -ENOMEM;
return rc;
}
@@ -471,8 +349,9 @@ int cam_isp_add_io_buffers(
(kmd_buf_info->used_bytes +
io_cfg_used_bytes);
} else {
- pr_err("%s:%d no free kmd memory for base %d\n",
- __func__, __LINE__, base_idx);
+ CAM_ERR(CAM_ISP,
+ "no free kmd memory for base %d",
+ base_idx);
rc = -ENOMEM;
return rc;
}
@@ -485,8 +364,8 @@ int cam_isp_add_io_buffers(
update_buf.num_buf = plane_id;
update_buf.io_cfg = &io_cfg[i];
- CDBG("%s:%d: cmd buffer 0x%pK, size %d\n", __func__,
- __LINE__, update_buf.cdm.cmd_buf_addr,
+ CAM_DBG(CAM_ISP, "cmd buffer 0x%pK, size %d",
+ update_buf.cdm.cmd_buf_addr,
update_buf.cdm.size);
rc = res->hw_intf->hw_ops.process_cmd(
res->hw_intf->hw_priv,
@@ -494,8 +373,8 @@ int cam_isp_add_io_buffers(
sizeof(struct cam_isp_hw_get_buf_update));
if (rc) {
- pr_err("%s:%d get buf cmd error:%d\n",
- __func__, __LINE__, res->res_id);
+ CAM_ERR(CAM_ISP, "get buf cmd error:%d",
+ res->res_id);
rc = -ENOMEM;
return rc;
}
@@ -503,7 +382,7 @@ int cam_isp_add_io_buffers(
}
}
- CDBG("%s: io_cfg_used_bytes %d, fill_fence %d\n", __func__,
+ CAM_DBG(CAM_ISP, "io_cfg_used_bytes %d, fill_fence %d",
io_cfg_used_bytes, fill_fence);
if (io_cfg_used_bytes) {
/* Update the HW entries */
@@ -533,7 +412,7 @@ int cam_isp_add_reg_update(
struct cam_hw_prepare_update_args *prepare,
struct list_head *res_list_isp_src,
uint32_t base_idx,
- struct cam_isp_kmd_buf_info *kmd_buf_info)
+ struct cam_kmd_buf_info *kmd_buf_info)
{
int rc = -EINVAL;
struct cam_isp_resource_node *res;
@@ -546,8 +425,7 @@ int cam_isp_add_reg_update(
/* Max one hw entries required for each base */
if (prepare->num_hw_update_entries + 1 >=
prepare->max_hw_update_entries) {
- pr_err("%s:%d Insufficient HW entries :%d %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d",
prepare->num_hw_update_entries,
prepare->max_hw_update_entries);
return -EINVAL;
@@ -572,9 +450,8 @@ int cam_isp_add_reg_update(
(kmd_buf_info->used_bytes +
reg_update_size);
} else {
- pr_err("%s:%d no free mem %d %d %d\n",
- __func__, __LINE__, base_idx,
- kmd_buf_info->size,
+ CAM_ERR(CAM_ISP, "no free mem %d %d %d",
+ base_idx, kmd_buf_info->size,
kmd_buf_info->used_bytes +
reg_update_size);
rc = -EINVAL;
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_tasklet_util.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_tasklet_util.c
index ecc71b3..4a7eff8 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_tasklet_util.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/cam_tasklet_util.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
@@ -19,9 +17,7 @@
#include <linux/ratelimit.h>
#include "cam_tasklet_util.h"
#include "cam_irq_controller.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
#define CAM_TASKLETQ_SIZE 256
@@ -95,14 +91,14 @@ static int cam_tasklet_get_cmd(
*tasklet_cmd = NULL;
if (!atomic_read(&tasklet->tasklet_active)) {
- pr_err_ratelimited("Tasklet is not active!\n");
+ CAM_ERR_RATE_LIMIT(CAM_ISP, "Tasklet is not active!\n");
rc = -EPIPE;
return rc;
}
spin_lock_irqsave(&tasklet->tasklet_lock, flags);
if (list_empty(&tasklet->free_cmd_list)) {
- pr_err_ratelimited("No more free tasklet cmd!\n");
+ CAM_ERR_RATE_LIMIT(CAM_ISP, "No more free tasklet cmd!\n");
rc = -ENODEV;
goto spin_unlock;
} else {
@@ -162,22 +158,22 @@ static int cam_tasklet_dequeue_cmd(
*tasklet_cmd = NULL;
if (!atomic_read(&tasklet->tasklet_active)) {
- pr_err("Tasklet is not active!\n");
+ CAM_ERR(CAM_ISP, "Tasklet is not active!");
rc = -EPIPE;
return rc;
}
- CDBG("Dequeue before lock.\n");
+ CAM_DBG(CAM_ISP, "Dequeue before lock.");
spin_lock_irqsave(&tasklet->tasklet_lock, flags);
if (list_empty(&tasklet->used_cmd_list)) {
- CDBG("End of list reached. Exit\n");
+ CAM_DBG(CAM_ISP, "End of list reached. Exit");
rc = -ENODEV;
goto spin_unlock;
} else {
*tasklet_cmd = list_first_entry(&tasklet->used_cmd_list,
struct cam_tasklet_queue_cmd, list);
list_del_init(&(*tasklet_cmd)->list);
- CDBG("Dequeue Successful\n");
+ CAM_DBG(CAM_ISP, "Dequeue Successful");
}
spin_unlock:
@@ -197,14 +193,14 @@ int cam_tasklet_enqueue_cmd(
int rc;
if (!bottom_half) {
- pr_err("NULL bottom half\n");
+ CAM_ERR(CAM_ISP, "NULL bottom half");
return -EINVAL;
}
rc = cam_tasklet_get_cmd(tasklet, &tasklet_cmd);
if (tasklet_cmd) {
- CDBG("%s: Enqueue tasklet cmd\n", __func__);
+ CAM_DBG(CAM_ISP, "Enqueue tasklet cmd");
tasklet_cmd->bottom_half_handler = bottom_half_handler;
tasklet_cmd->payload = evt_payload_priv;
spin_lock_irqsave(&tasklet->tasklet_lock, flags);
@@ -213,7 +209,7 @@ int cam_tasklet_enqueue_cmd(
spin_unlock_irqrestore(&tasklet->tasklet_lock, flags);
tasklet_schedule(&tasklet->tasklet);
} else {
- pr_err("%s: tasklet cmd is NULL!\n", __func__);
+ CAM_ERR(CAM_ISP, "tasklet cmd is NULL!");
}
return rc;
@@ -229,7 +225,8 @@ int cam_tasklet_init(
tasklet = kzalloc(sizeof(struct cam_tasklet_info), GFP_KERNEL);
if (!tasklet) {
- CDBG("Error! Unable to allocate memory for tasklet");
+ CAM_DBG(CAM_ISP,
+ "Error! Unable to allocate memory for tasklet");
*tasklet_info = NULL;
return -ENOMEM;
}
@@ -271,7 +268,8 @@ int cam_tasklet_start(void *tasklet_info)
struct cam_tasklet_queue_cmd *tasklet_cmd_temp;
if (atomic_read(&tasklet->tasklet_active)) {
- pr_err("Tasklet already active. idx = %d\n", tasklet->index);
+ CAM_ERR(CAM_ISP, "Tasklet already active. idx = %d",
+ tasklet->index);
return -EBUSY;
}
atomic_set(&tasklet->tasklet_active, 1);
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h
index 9730fc2..7ac729f 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h
@@ -18,47 +18,7 @@
#include "cam_isp_hw_mgr_intf.h"
#include "cam_ife_hw_mgr.h"
#include "cam_hw_intf.h"
-
-/**
- * @brief KMD scratch buffer information
- *
- * @handle: Memory handle
- * @cpu_addr: Cpu address
- * @offset: Offset from the start of the buffer
- * @size: Size of the buffer
- * @used_bytes: Used memory in bytes
- *
- */
-struct cam_isp_kmd_buf_info {
- int handle;
- uint32_t *cpu_addr;
- uint32_t offset;
- uint32_t size;
- uint32_t used_bytes;
-};
-
-
-/**
- * @brief Validate the packet
- *
- * @packet: Packet to be validated
- *
- * @return: 0 for success
- * -EINVAL for Fail
- */
-int cam_isp_validate_packet(struct cam_packet *packet);
-
-/**
- * @brief Get the kmd buffer from the packet command descriptor
- *
- * @packet: Packet data
- * @kmd_buf: Extracted the KMD buffer information
- *
- * @return: 0 for success
- * -EINVAL for Fail
- */
-int cam_isp_get_kmd_buffer(struct cam_packet *packet,
- struct cam_isp_kmd_buf_info *kmd_buf_info);
+#include "cam_packet_util.h"
/**
* @brief Add change base in the hw entries list
@@ -77,7 +37,7 @@ int cam_isp_add_change_base(
struct cam_hw_prepare_update_args *prepare,
struct list_head *res_list_isp_src,
uint32_t base_idx,
- struct cam_isp_kmd_buf_info *kmd_buf_info);
+ struct cam_kmd_buf_info *kmd_buf_info);
/**
* @brief Add command buffer in the HW entries list for given
@@ -112,7 +72,7 @@ int cam_isp_add_command_buffers(
int cam_isp_add_io_buffers(int iommu_hdl,
struct cam_hw_prepare_update_args *prepare,
uint32_t base_idx,
- struct cam_isp_kmd_buf_info *kmd_buf_info,
+ struct cam_kmd_buf_info *kmd_buf_info,
struct cam_ife_hw_mgr_res *res_list_isp_out,
uint32_t size_isp_out,
bool fill_fence);
@@ -134,7 +94,7 @@ int cam_isp_add_reg_update(
struct cam_hw_prepare_update_args *prepare,
struct list_head *res_list_isp_src,
uint32_t base_idx,
- struct cam_isp_kmd_buf_info *kmd_buf_info);
+ struct cam_kmd_buf_info *kmd_buf_info);
#endif /*_CAM_ISP_HW_PARSER_H */
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c
index 9a42b6e..2341b38 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c
@@ -10,16 +10,12 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include "cam_io_util.h"
#include "cam_irq_controller.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
/**
* struct cam_irq_evt_handler:
@@ -143,21 +139,21 @@ int cam_irq_controller_init(const char *name,
if (!register_info->num_registers || !register_info->irq_reg_set ||
!name || !mem_base) {
- pr_err("Invalid parameters\n");
+ CAM_ERR(CAM_ISP, "Invalid parameters");
rc = -EINVAL;
return rc;
}
controller = kzalloc(sizeof(struct cam_irq_controller), GFP_KERNEL);
if (!controller) {
- CDBG("Failed to allocate IRQ Controller\n");
+ CAM_DBG(CAM_ISP, "Failed to allocate IRQ Controller");
return -ENOMEM;
}
controller->irq_register_arr = kzalloc(register_info->num_registers *
sizeof(struct cam_irq_register_obj), GFP_KERNEL);
if (!controller->irq_register_arr) {
- CDBG("Failed to allocate IRQ register Arr\n");
+ CAM_DBG(CAM_ISP, "Failed to allocate IRQ register Arr");
rc = -ENOMEM;
goto reg_alloc_error;
}
@@ -165,7 +161,7 @@ int cam_irq_controller_init(const char *name,
controller->irq_status_arr = kzalloc(register_info->num_registers *
sizeof(uint32_t), GFP_KERNEL);
if (!controller->irq_status_arr) {
- CDBG("Failed to allocate IRQ status Arr\n");
+ CAM_DBG(CAM_ISP, "Failed to allocate IRQ status Arr");
rc = -ENOMEM;
goto status_alloc_error;
}
@@ -174,14 +170,14 @@ int cam_irq_controller_init(const char *name,
kzalloc(register_info->num_registers * sizeof(uint32_t),
GFP_KERNEL);
if (!controller->th_payload.evt_status_arr) {
- CDBG("Failed to allocate BH payload bit mask Arr\n");
+ CAM_DBG(CAM_ISP, "Failed to allocate BH payload bit mask Arr");
rc = -ENOMEM;
goto evt_mask_alloc_error;
}
controller->name = name;
- CDBG("num_registers: %d\n", register_info->num_registers);
+ CAM_DBG(CAM_ISP, "num_registers: %d", register_info->num_registers);
for (i = 0; i < register_info->num_registers; i++) {
controller->irq_register_arr[i].index = i;
controller->irq_register_arr[i].mask_reg_offset =
@@ -190,11 +186,11 @@ int cam_irq_controller_init(const char *name,
register_info->irq_reg_set[i].clear_reg_offset;
controller->irq_register_arr[i].status_reg_offset =
register_info->irq_reg_set[i].status_reg_offset;
- CDBG("i %d mask_reg_offset: 0x%x\n", i,
+ CAM_DBG(CAM_ISP, "i %d mask_reg_offset: 0x%x", i,
controller->irq_register_arr[i].mask_reg_offset);
- CDBG("i %d clear_reg_offset: 0x%x\n", i,
+ CAM_DBG(CAM_ISP, "i %d clear_reg_offset: 0x%x", i,
controller->irq_register_arr[i].clear_reg_offset);
- CDBG("i %d status_reg_offset: 0x%x\n", i,
+ CAM_DBG(CAM_ISP, "i %d status_reg_offset: 0x%x", i,
controller->irq_register_arr[i].status_reg_offset);
}
controller->num_registers = register_info->num_registers;
@@ -202,11 +198,11 @@ int cam_irq_controller_init(const char *name,
controller->global_clear_offset = register_info->global_clear_offset;
controller->mem_base = mem_base;
- CDBG("global_clear_bitmask: 0x%x\n",
+ CAM_DBG(CAM_ISP, "global_clear_bitmask: 0x%x",
controller->global_clear_bitmask);
- CDBG("global_clear_offset: 0x%x\n",
+ CAM_DBG(CAM_ISP, "global_clear_offset: 0x%x",
controller->global_clear_offset);
- CDBG("mem_base: 0x%llx\n", (uint64_t)controller->mem_base);
+ CAM_DBG(CAM_ISP, "mem_base: %pK", (void __iomem *)controller->mem_base);
INIT_LIST_HEAD(&controller->evt_handler_list_head);
for (i = 0; i < CAM_IRQ_PRIORITY_MAX; i++)
@@ -246,19 +242,21 @@ int cam_irq_controller_subscribe_irq(void *irq_controller,
unsigned long flags;
if (!controller || !handler_priv || !evt_bit_mask_arr) {
- pr_err("Invalid params: ctlr=%pK handler_priv=%pK bit_mask_arr = %pK\n",
+ CAM_ERR(CAM_ISP,
+ "Inval params: ctlr=%pK hdl_priv=%pK bit_mask_arr=%pK",
controller, handler_priv, evt_bit_mask_arr);
return -EINVAL;
}
if (!top_half_handler) {
- pr_err("Missing top half handler\n");
+ CAM_ERR(CAM_ISP, "Missing top half handler");
return -EINVAL;
}
if (bottom_half_handler &&
(!bottom_half || !bottom_half_enqueue_func)) {
- pr_err("Invalid params: bh_handler=%pK bh=%pK bh_enq_f=%pK\n",
+ CAM_ERR(CAM_ISP,
+ "Invalid params: bh_handler=%pK bh=%pK bh_enq_f=%pK",
bottom_half_handler,
bottom_half,
bottom_half_enqueue_func);
@@ -266,21 +264,21 @@ int cam_irq_controller_subscribe_irq(void *irq_controller,
}
if (priority >= CAM_IRQ_PRIORITY_MAX) {
- pr_err("Invalid priority=%u, max=%u\n", priority,
+ CAM_ERR(CAM_ISP, "Invalid priority=%u, max=%u", priority,
CAM_IRQ_PRIORITY_MAX);
return -EINVAL;
}
evt_handler = kzalloc(sizeof(struct cam_irq_evt_handler), GFP_KERNEL);
if (!evt_handler) {
- CDBG("Error allocating hlist_node\n");
+ CAM_DBG(CAM_ISP, "Error allocating hlist_node");
return -ENOMEM;
}
evt_handler->evt_bit_mask_arr = kzalloc(sizeof(uint32_t) *
controller->num_registers, GFP_KERNEL);
if (!evt_handler->evt_bit_mask_arr) {
- CDBG("Error allocating hlist_node\n");
+ CAM_DBG(CAM_ISP, "Error allocating hlist_node");
rc = -ENOMEM;
goto free_evt_handler;
}
@@ -346,7 +344,7 @@ int cam_irq_controller_unsubscribe_irq(void *irq_controller,
list_for_each_entry_safe(evt_handler, evt_handler_temp,
&controller->evt_handler_list_head, list_node) {
if (evt_handler->index == handle) {
- CDBG("unsubscribe item %d\n", handle);
+ CAM_DBG(CAM_ISP, "unsubscribe item %d", handle);
list_del_init(&evt_handler->list_node);
list_del_init(&evt_handler->th_list_node);
found = 1;
@@ -429,7 +427,7 @@ static void cam_irq_controller_th_processing(
int rc = -EINVAL;
int i;
- CDBG("Enter\n");
+ CAM_DBG(CAM_ISP, "Enter");
if (list_empty(th_list_head))
return;
@@ -441,7 +439,7 @@ static void cam_irq_controller_th_processing(
if (!is_irq_match)
continue;
- CDBG("match found\n");
+ CAM_DBG(CAM_ISP, "match found");
cam_irq_th_payload_init(th_payload);
th_payload->handler_priv = evt_handler->handler_priv;
@@ -462,7 +460,7 @@ static void cam_irq_controller_th_processing(
(void *)th_payload);
if (!rc && evt_handler->bottom_half_handler) {
- CDBG("Enqueuing bottom half for %s\n",
+ CAM_DBG(CAM_ISP, "Enqueuing bottom half for %s",
controller->name);
if (evt_handler->bottom_half_enqueue_func) {
evt_handler->bottom_half_enqueue_func(
@@ -474,7 +472,7 @@ static void cam_irq_controller_th_processing(
}
}
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
}
irqreturn_t cam_irq_controller_handle_irq(int irq_num, void *priv)
@@ -487,7 +485,7 @@ irqreturn_t cam_irq_controller_handle_irq(int irq_num, void *priv)
if (!controller)
return IRQ_NONE;
- CDBG("locking controller %pK name %s rw_lock %pK\n",
+ CAM_DBG(CAM_ISP, "locking controller %pK name %s rw_lock %pK",
controller, controller->name, &controller->rw_lock);
read_lock(&controller->rw_lock);
for (i = 0; i < controller->num_registers; i++) {
@@ -497,7 +495,7 @@ irqreturn_t cam_irq_controller_handle_irq(int irq_num, void *priv)
cam_io_w_mb(controller->irq_status_arr[i],
controller->mem_base +
controller->irq_register_arr[i].clear_reg_offset);
- CDBG("Read irq status%d (0x%x) = 0x%x\n", i,
+ CAM_DBG(CAM_ISP, "Read irq status%d (0x%x) = 0x%x", i,
controller->irq_register_arr[i].status_reg_offset,
controller->irq_status_arr[i]);
for (j = 0; j < CAM_IRQ_PRIORITY_MAX; j++) {
@@ -505,25 +503,26 @@ irqreturn_t cam_irq_controller_handle_irq(int irq_num, void *priv)
top_half_enable_mask[j] &
controller->irq_status_arr[i])
need_th_processing[j] = true;
- CDBG("i %d j %d need_th_processing = %d\n",
+ CAM_DBG(CAM_ISP,
+ "i %d j %d need_th_processing = %d",
i, j, need_th_processing[j]);
}
}
read_unlock(&controller->rw_lock);
- CDBG("unlocked controller %pK name %s rw_lock %pK\n",
+ CAM_DBG(CAM_ISP, "unlocked controller %pK name %s rw_lock %pK",
controller, controller->name, &controller->rw_lock);
- CDBG("Status Registers read Successful\n");
+ CAM_DBG(CAM_ISP, "Status Registers read Successful");
if (controller->global_clear_offset)
cam_io_w_mb(controller->global_clear_bitmask,
controller->mem_base + controller->global_clear_offset);
- CDBG("Status Clear done\n");
+ CAM_DBG(CAM_ISP, "Status Clear done");
for (i = 0; i < CAM_IRQ_PRIORITY_MAX; i++) {
if (need_th_processing[i]) {
- CDBG("%s: Invoke TH processing\n", __func__);
+ CAM_DBG(CAM_ISP, "Invoke TH processing");
cam_irq_controller_th_processing(controller,
&controller->th_list_head[i]);
}
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h
index b32bdb2..0480cd3 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h
@@ -115,6 +115,28 @@ struct cam_isp_hw_error_event_data {
uint64_t timestamp;
};
+/* enum cam_isp_hw_mgr_command - Hardware manager command type */
+enum cam_isp_hw_mgr_command {
+ CAM_ISP_HW_MGR_CMD_IS_RDI_ONLY_CONTEXT,
+ CAM_ISP_HW_MGR_CMD_MAX,
+};
+
+/**
+ * struct cam_isp_hw_cmd_args - Payload for hw manager command
+ *
+ * @ctxt_to_hw_map: HW context from the acquire
+ * @cmd_type HW command type
+ * @get_context Get context type information
+ */
+struct cam_isp_hw_cmd_args {
+ void *ctxt_to_hw_map;
+ uint32_t cmd_type;
+ union {
+ uint32_t is_rdi_only_context;
+ } u;
+};
+
+
/**
* cam_isp_hw_mgr_init()
*
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/Makefile b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/Makefile
index 1615d21f..4c6745c 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/Makefile
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/Makefile
@@ -1,5 +1,6 @@
ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
ccflags-y += -Idrivers/media/platform/msm/camera/cam_core
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_cpas/include
ccflags-y += -Idrivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/include
ccflags-y += -Idrivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/include
ccflags-y += -Idrivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/hw_utils/irq_controller
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c
index e779aef..a2f773e 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c
@@ -19,10 +19,7 @@
#include "cam_isp_hw.h"
#include "cam_soc_util.h"
#include "cam_io_util.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-
+#include "cam_debug_util.h"
/* Timeout value in msec */
#define IFE_CSID_TIMEOUT 1000
@@ -62,79 +59,127 @@ static int cam_ife_csid_is_ipp_format_supported(
return rc;
}
-static int cam_ife_csid_get_format(uint32_t res_id,
- uint32_t decode_fmt, uint32_t *path_fmt, uint32_t *plain_fmt)
+static int cam_ife_csid_get_format(uint32_t input_fmt,
+ uint32_t *path_fmt)
{
int rc = 0;
- if (res_id >= CAM_IFE_PIX_PATH_RES_RDI_0 &&
- res_id <= CAM_IFE_PIX_PATH_RES_RDI_3) {
- *path_fmt = 0xf;
- return 0;
- }
-
- switch (decode_fmt) {
+ switch (input_fmt) {
case CAM_FORMAT_MIPI_RAW_6:
*path_fmt = 0;
- *plain_fmt = 0;
break;
case CAM_FORMAT_MIPI_RAW_8:
*path_fmt = 1;
- *plain_fmt = 0;
break;
case CAM_FORMAT_MIPI_RAW_10:
*path_fmt = 2;
- *plain_fmt = 1;
break;
case CAM_FORMAT_MIPI_RAW_12:
*path_fmt = 3;
- *plain_fmt = 1;
break;
case CAM_FORMAT_MIPI_RAW_14:
*path_fmt = 4;
- *plain_fmt = 1;
break;
case CAM_FORMAT_MIPI_RAW_16:
*path_fmt = 5;
- *plain_fmt = 1;
break;
case CAM_FORMAT_MIPI_RAW_20:
*path_fmt = 6;
- *plain_fmt = 2;
break;
case CAM_FORMAT_DPCM_10_6_10:
*path_fmt = 7;
- *plain_fmt = 1;
break;
case CAM_FORMAT_DPCM_10_8_10:
*path_fmt = 8;
- *plain_fmt = 1;
break;
case CAM_FORMAT_DPCM_12_6_12:
*path_fmt = 9;
- *plain_fmt = 1;
break;
case CAM_FORMAT_DPCM_12_8_12:
*path_fmt = 0xA;
- *plain_fmt = 1;
break;
case CAM_FORMAT_DPCM_14_8_14:
*path_fmt = 0xB;
- *plain_fmt = 1;
break;
case CAM_FORMAT_DPCM_14_10_14:
*path_fmt = 0xC;
- *plain_fmt = 1;
break;
default:
- pr_err("%s:%d:CSID:%d un supported format\n",
- __func__, __LINE__, decode_fmt);
+ CAM_ERR(CAM_ISP, "CSID:%d un supported format",
+ input_fmt);
rc = -EINVAL;
}
return rc;
}
+static int cam_ife_csid_get_rdi_format(uint32_t input_fmt,
+ uint32_t output_fmt, uint32_t *path_fmt, uint32_t *plain_fmt)
+{
+ int rc = 0;
+
+ CAM_DBG(CAM_ISP, "input format:%d output format:%d",
+ input_fmt, output_fmt);
+
+ switch (output_fmt) {
+ case CAM_FORMAT_MIPI_RAW_6:
+ case CAM_FORMAT_MIPI_RAW_8:
+ case CAM_FORMAT_MIPI_RAW_10:
+ case CAM_FORMAT_MIPI_RAW_12:
+ case CAM_FORMAT_MIPI_RAW_14:
+ case CAM_FORMAT_MIPI_RAW_16:
+ case CAM_FORMAT_MIPI_RAW_20:
+ case CAM_FORMAT_DPCM_10_6_10:
+ case CAM_FORMAT_DPCM_10_8_10:
+ case CAM_FORMAT_DPCM_12_6_12:
+ case CAM_FORMAT_DPCM_12_8_12:
+ case CAM_FORMAT_DPCM_14_8_14:
+ case CAM_FORMAT_DPCM_14_10_14:
+ *path_fmt = 0xF;
+ *plain_fmt = 0;
+ break;
+
+ case CAM_FORMAT_PLAIN8:
+ rc = cam_ife_csid_get_format(input_fmt, path_fmt);
+ if (rc)
+ goto error;
+
+ *plain_fmt = 0;
+ break;
+ case CAM_FORMAT_PLAIN16_8:
+ case CAM_FORMAT_PLAIN16_10:
+ case CAM_FORMAT_PLAIN16_12:
+ case CAM_FORMAT_PLAIN16_14:
+ case CAM_FORMAT_PLAIN16_16:
+ rc = cam_ife_csid_get_format(input_fmt, path_fmt);
+ if (rc)
+ goto error;
+
+ *plain_fmt = 1;
+ break;
+ case CAM_FORMAT_PLAIN32_20:
+ rc = cam_ife_csid_get_format(input_fmt, path_fmt);
+ if (rc)
+ goto error;
+
+ *plain_fmt = 2;
+ break;
+ default:
+ *path_fmt = 0xF;
+ *plain_fmt = 0;
+ break;
+ }
+
+ CAM_DBG(CAM_ISP, "path format value:%d plain format value:%d",
+ *path_fmt, *plain_fmt);
+
+ return 0;
+error:
+ return rc;
+
+}
+
+
static int cam_ife_csid_cid_get(struct cam_ife_csid_hw *csid_hw,
struct cam_isp_resource_node **res, int32_t vc, uint32_t dt,
uint32_t res_type)
@@ -166,8 +211,8 @@ static int cam_ife_csid_cid_get(struct cam_ife_csid_hw *csid_hw,
if (i == CAM_IFE_CSID_CID_RES_MAX) {
if (res_type == CAM_ISP_IFE_IN_RES_TPG) {
- pr_err("%s:%d:CSID:%d TPG CID not available\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx);
+ CAM_ERR(CAM_ISP, "CSID:%d TPG CID not available",
+ csid_hw->hw_intf->hw_idx);
rc = -EINVAL;
}
@@ -182,8 +227,7 @@ static int cam_ife_csid_cid_get(struct cam_ife_csid_hw *csid_hw,
csid_hw->cid_res[j].res_state =
CAM_ISP_RESOURCE_STATE_RESERVED;
*res = &csid_hw->cid_res[j];
- CDBG("%s:%d:CSID:%d CID %d allocated\n",
- __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d CID %d allocated",
csid_hw->hw_intf->hw_idx,
csid_hw->cid_res[j].res_id);
break;
@@ -191,8 +235,8 @@ static int cam_ife_csid_cid_get(struct cam_ife_csid_hw *csid_hw,
}
if (j == CAM_IFE_CSID_CID_RES_MAX) {
- pr_err("%s:%d:CSID:%d Free cid is not available\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx);
+ CAM_ERR(CAM_ISP, "CSID:%d Free cid is not available",
+ csid_hw->hw_intf->hw_idx);
rc = -EINVAL;
}
}
@@ -213,13 +257,13 @@ static int cam_ife_csid_global_reset(struct cam_ife_csid_hw *csid_hw)
csid_reg = csid_hw->csid_info->csid_reg;
if (csid_hw->hw_info->hw_state != CAM_HW_STATE_POWER_UP) {
- pr_err("%s:%d:CSID:%d Invalid HW State:%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid HW State:%d",
+ csid_hw->hw_intf->hw_idx,
csid_hw->hw_info->hw_state);
return -EINVAL;
}
- CDBG("%s:%d:CSID:%d Csid reset\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d Csid reset",
csid_hw->hw_intf->hw_idx);
init_completion(&csid_hw->csid_top_complete);
@@ -287,14 +331,12 @@ static int cam_ife_csid_global_reset(struct cam_ife_csid_hw *csid_hw)
soc_info->reg_map[0].mem_base +
csid_reg->cmn_reg->csid_rst_strobes_addr);
- CDBG("%s:%d: Waiting for reset complete from irq handler\n",
- __func__, __LINE__);
-
+ CAM_DBG(CAM_ISP, " Waiting for reset complete from irq handler");
rc = wait_for_completion_timeout(&csid_hw->csid_top_complete,
msecs_to_jiffies(IFE_CSID_TIMEOUT));
if (rc <= 0) {
- pr_err("%s:%d:CSID:%d reset completion in fail rc = %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx, rc);
+ CAM_ERR(CAM_ISP, "CSID:%d reset completion in fail rc = %d",
+ csid_hw->hw_intf->hw_idx, rc);
if (rc == 0)
rc = -ETIMEDOUT;
} else {
@@ -331,26 +373,26 @@ static int cam_ife_csid_path_reset(struct cam_ife_csid_hw *csid_hw,
res = reset->node_res;
if (csid_hw->hw_info->hw_state != CAM_HW_STATE_POWER_UP) {
- pr_err("%s:%d:CSID:%d Invalid hw state :%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid hw state :%d",
+ csid_hw->hw_intf->hw_idx,
csid_hw->hw_info->hw_state);
return -EINVAL;
}
if (res->res_id >= CAM_IFE_PIX_PATH_RES_MAX) {
- CDBG("%s:%d:CSID:%d Invalid res id%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_id);
+ CAM_DBG(CAM_ISP, "CSID:%d Invalid res id%d",
+ csid_hw->hw_intf->hw_idx, res->res_id);
rc = -EINVAL;
goto end;
}
- CDBG("%s:%d:CSID:%d resource:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d resource:%d",
csid_hw->hw_intf->hw_idx, res->res_id);
if (res->res_id == CAM_IFE_PIX_PATH_RES_IPP) {
if (!csid_reg->ipp_reg) {
- pr_err("%s:%d:CSID:%d IPP not supported :%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d IPP not supported :%d",
+ csid_hw->hw_intf->hw_idx,
res->res_id);
return -EINVAL;
}
@@ -368,8 +410,8 @@ static int cam_ife_csid_path_reset(struct cam_ife_csid_hw *csid_hw,
} else {
id = res->res_id;
if (!csid_reg->rdi_reg[id]) {
- pr_err("%s:%d:CSID:%d RDI res not supported :%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d RDI res not supported :%d",
+ csid_hw->hw_intf->hw_idx,
res->res_id);
return -EINVAL;
}
@@ -401,8 +443,8 @@ static int cam_ife_csid_path_reset(struct cam_ife_csid_hw *csid_hw,
rc = wait_for_completion_timeout(complete,
msecs_to_jiffies(IFE_CSID_TIMEOUT));
if (rc <= 0) {
- pr_err("%s:%d CSID:%d Res id %d fail rc = %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Res id %d fail rc = %d",
+ csid_hw->hw_intf->hw_idx,
res->res_id, rc);
if (rc == 0)
rc = -ETIMEDOUT;
@@ -423,8 +465,9 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
int rc = 0;
struct cam_ife_csid_cid_data *cid_data;
- CDBG("%s:%d CSID:%d res_sel:%d Lane type:%d lane_num:%d dt:%d vc:%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP,
+ "CSID:%d res_sel:%d Lane type:%d lane_num:%d dt:%d vc:%d",
+ csid_hw->hw_intf->hw_idx,
cid_reserv->in_port->res_type,
cid_reserv->in_port->lane_type,
cid_reserv->in_port->lane_num,
@@ -432,8 +475,8 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
cid_reserv->in_port->vc);
if (cid_reserv->in_port->res_type >= CAM_ISP_IFE_IN_RES_MAX) {
- pr_err("%s:%d:CSID:%d Invalid phy sel %d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid phy sel %d",
+ csid_hw->hw_intf->hw_idx,
cid_reserv->in_port->res_type);
rc = -EINVAL;
goto end;
@@ -441,8 +484,8 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
if (cid_reserv->in_port->lane_type >= CAM_ISP_LANE_TYPE_MAX &&
cid_reserv->in_port->res_type != CAM_ISP_IFE_IN_RES_TPG) {
- pr_err("%s:%d:CSID:%d Invalid lane type %d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid lane type %d",
+ csid_hw->hw_intf->hw_idx,
cid_reserv->in_port->lane_type);
rc = -EINVAL;
goto end;
@@ -451,8 +494,8 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
if ((cid_reserv->in_port->lane_type == CAM_ISP_LANE_TYPE_DPHY &&
cid_reserv->in_port->lane_num > 4) &&
cid_reserv->in_port->res_type != CAM_ISP_IFE_IN_RES_TPG) {
- pr_err("%s:%d:CSID:%d Invalid lane num %d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid lane num %d",
+ csid_hw->hw_intf->hw_idx,
cid_reserv->in_port->lane_num);
rc = -EINVAL;
goto end;
@@ -460,8 +503,8 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
if ((cid_reserv->in_port->lane_type == CAM_ISP_LANE_TYPE_CPHY &&
cid_reserv->in_port->lane_num > 3) &&
cid_reserv->in_port->res_type != CAM_ISP_IFE_IN_RES_TPG) {
- pr_err("%s:%d: CSID:%d Invalid lane type %d & num %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, " CSID:%d Invalid lane type %d & num %d",
+ csid_hw->hw_intf->hw_idx,
cid_reserv->in_port->lane_type,
cid_reserv->in_port->lane_num);
rc = -EINVAL;
@@ -471,8 +514,8 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
/* CSID CSI2 v2.0 supports 31 vc */
if (cid_reserv->in_port->dt > 0x3f ||
cid_reserv->in_port->vc > 0x1f) {
- pr_err("%s:%d:CSID:%d Invalid vc:%d dt %d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid vc:%d dt %d",
+ csid_hw->hw_intf->hw_idx,
cid_reserv->in_port->vc, cid_reserv->in_port->dt);
rc = -EINVAL;
goto end;
@@ -481,8 +524,8 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
if (cid_reserv->in_port->res_type == CAM_ISP_IFE_IN_RES_TPG && (
(cid_reserv->in_port->format < CAM_FORMAT_MIPI_RAW_8 &&
cid_reserv->in_port->format > CAM_FORMAT_MIPI_RAW_16))) {
- pr_err("%s:%d: CSID:%d Invalid tpg decode fmt %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, " CSID:%d Invalid tpg decode fmt %d",
+ csid_hw->hw_intf->hw_idx,
cid_reserv->in_port->format);
rc = -EINVAL;
goto end;
@@ -538,8 +581,7 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
csid_hw->csi2_rx_cfg.phy_sel = 0;
if (cid_reserv->in_port->format >
CAM_FORMAT_MIPI_RAW_16) {
- pr_err("%s:%d: Wrong TPG format\n", __func__,
- __LINE__);
+ CAM_ERR(CAM_ISP, " Wrong TPG format");
rc = -EINVAL;
goto end;
}
@@ -562,8 +604,9 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
cid_reserv->node_res = &csid_hw->cid_res[0];
csid_hw->csi2_reserve_cnt++;
- CDBG("%s:%d:CSID:%d CID :%d resource acquired successfully\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP,
+ "CSID:%d CID :%d resource acquired successfully",
+ csid_hw->hw_intf->hw_idx,
cid_reserv->node_res->res_id);
} else {
rc = cam_ife_csid_cid_get(csid_hw, &cid_reserv->node_res,
@@ -572,14 +615,13 @@ static int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw,
/* if success then increment the reserve count */
if (!rc) {
if (csid_hw->csi2_reserve_cnt == UINT_MAX) {
- pr_err("%s:%d:CSID%d reserve cnt reached max\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP,
+ "CSID%d reserve cnt reached max",
csid_hw->hw_intf->hw_idx);
rc = -EINVAL;
} else {
csid_hw->csi2_reserve_cnt++;
- CDBG("%s:%d:CSID:%d CID:%d acquired\n",
- __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d CID:%d acquired",
csid_hw->hw_intf->hw_idx,
cid_reserv->node_res->res_id);
}
@@ -601,8 +643,8 @@ static int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
/* CSID CSI2 v2.0 supports 31 vc */
if (reserve->in_port->dt > 0x3f || reserve->in_port->vc > 0x1f ||
(reserve->sync_mode >= CAM_ISP_HW_SYNC_MAX)) {
- pr_err("%s:%d:CSID:%d Invalid vc:%d dt %d mode:%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid vc:%d dt %d mode:%d",
+ csid_hw->hw_intf->hw_idx,
reserve->in_port->vc, reserve->in_port->dt,
reserve->sync_mode);
rc = -EINVAL;
@@ -613,8 +655,9 @@ static int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
case CAM_IFE_PIX_PATH_RES_IPP:
if (csid_hw->ipp_res.res_state !=
CAM_ISP_RESOURCE_STATE_AVAILABLE) {
- CDBG("%s:%d:CSID:%d IPP resource not available %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP,
+ "CSID:%d IPP resource not available %d",
+ csid_hw->hw_intf->hw_idx,
csid_hw->ipp_res.res_state);
rc = -EINVAL;
goto end;
@@ -622,8 +665,8 @@ static int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
if (cam_ife_csid_is_ipp_format_supported(
reserve->in_port->format)) {
- pr_err("%s:%d:CSID:%d res id:%d un support format %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP,
+ "CSID:%d res id:%d un support format %d",
csid_hw->hw_intf->hw_idx, reserve->res_id,
reserve->in_port->format);
rc = -EINVAL;
@@ -632,8 +675,8 @@ static int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
/* assign the IPP resource */
res = &csid_hw->ipp_res;
- CDBG("%s:%d:CSID:%d IPP resource:%d acquired successfully\n",
- __func__, __LINE__,
+ CAM_DBG(CAM_ISP,
+ "CSID:%d IPP resource:%d acquired successfully",
csid_hw->hw_intf->hw_idx, res->res_id);
break;
@@ -643,23 +686,24 @@ static int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
case CAM_IFE_PIX_PATH_RES_RDI_3:
if (csid_hw->rdi_res[reserve->res_id].res_state !=
CAM_ISP_RESOURCE_STATE_AVAILABLE) {
- CDBG("%s:%d:CSID:%d RDI:%d resource not available %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP,
+ "CSID:%d RDI:%d resource not available %d",
+ csid_hw->hw_intf->hw_idx,
reserve->res_id,
csid_hw->rdi_res[reserve->res_id].res_state);
rc = -EINVAL;
goto end;
} else {
res = &csid_hw->rdi_res[reserve->res_id];
- CDBG("%s:%d:CSID:%d RDI resource:%d acquire success\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP,
+ "CSID:%d RDI resource:%d acquire success",
+ csid_hw->hw_intf->hw_idx,
res->res_id);
}
break;
default:
- pr_err("%s:%d:CSID:%d Invalid res id:%d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid res id:%d",
csid_hw->hw_intf->hw_idx, reserve->res_id);
rc = -EINVAL;
goto end;
@@ -668,6 +712,18 @@ static int cam_ife_csid_path_reserve(struct cam_ife_csid_hw *csid_hw,
res->res_state = CAM_ISP_RESOURCE_STATE_RESERVED;
path_data = (struct cam_ife_csid_path_cfg *)res->res_priv;
+ /* store the output format for RDI */
+ switch (reserve->res_id) {
+ case CAM_IFE_PIX_PATH_RES_RDI_0:
+ case CAM_IFE_PIX_PATH_RES_RDI_1:
+ case CAM_IFE_PIX_PATH_RES_RDI_2:
+ case CAM_IFE_PIX_PATH_RES_RDI_3:
+ path_data->output_fmt = reserve->out_port->format;
+ break;
+ default:
+ break;
+ }
+
path_data->cid = reserve->cid;
path_data->decode_fmt = reserve->in_port->format;
path_data->master_idx = reserve->master_idx;
@@ -711,31 +767,30 @@ static int cam_ife_csid_enable_hw(struct cam_ife_csid_hw *csid_hw)
/* overflow check before increment */
if (csid_hw->hw_info->open_count == UINT_MAX) {
- pr_err("%s:%d:CSID:%d Open count reached max\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx);
+ CAM_ERR(CAM_ISP, "CSID:%d Open count reached max",
+ csid_hw->hw_intf->hw_idx);
return -EINVAL;
}
/* Increment ref Count */
csid_hw->hw_info->open_count++;
if (csid_hw->hw_info->open_count > 1) {
- CDBG("%s:%d: CSID hw has already been enabled\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "CSID hw has already been enabled");
return rc;
}
- CDBG("%s:%d:CSID:%d init CSID HW\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d init CSID HW",
csid_hw->hw_intf->hw_idx);
rc = cam_ife_csid_enable_soc_resources(soc_info);
if (rc) {
- pr_err("%s:%d:CSID:%d Enable SOC failed\n", __func__, __LINE__,
+ CAM_ERR(CAM_ISP, "CSID:%d Enable SOC failed",
csid_hw->hw_intf->hw_idx);
goto err;
}
- CDBG("%s:%d:CSID:%d enable top irq interrupt\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d enable top irq interrupt",
csid_hw->hw_intf->hw_idx);
csid_hw->hw_info->hw_state = CAM_HW_STATE_POWER_UP;
@@ -745,8 +800,8 @@ static int cam_ife_csid_enable_hw(struct cam_ife_csid_hw *csid_hw)
rc = cam_ife_csid_global_reset(csid_hw);
if (rc) {
- pr_err("%s:%d CSID:%d csid_reset fail rc = %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx, rc);
+ CAM_ERR(CAM_ISP, "CSID:%d csid_reset fail rc = %d",
+ csid_hw->hw_intf->hw_idx, rc);
rc = -ETIMEDOUT;
goto disable_soc;
}
@@ -756,7 +811,7 @@ static int cam_ife_csid_enable_hw(struct cam_ife_csid_hw *csid_hw)
* SW register reset also reset the mask irq, so poll the irq status
* to check the reset complete.
*/
- CDBG("%s:%d:CSID:%d Reset Software registers\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d Reset Software registers",
csid_hw->hw_intf->hw_idx);
cam_io_w_mb(csid_reg->cmn_reg->csid_rst_stb_sw_all,
@@ -768,8 +823,7 @@ static int cam_ife_csid_enable_hw(struct cam_ife_csid_hw *csid_hw)
status, (status & 0x1) == 0x1,
CAM_IFE_CSID_TIMEOUT_SLEEP_US, CAM_IFE_CSID_TIMEOUT_ALL_US);
if (rc < 0) {
- pr_err("%s:%d: software register reset timeout.....\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "software register reset timeout.....");
rc = -ETIMEDOUT;
goto disable_soc;
}
@@ -801,7 +855,7 @@ static int cam_ife_csid_enable_hw(struct cam_ife_csid_hw *csid_hw)
val = cam_io_r_mb(soc_info->reg_map[0].mem_base +
csid_reg->cmn_reg->csid_hw_version_addr);
- CDBG("%s:%d:CSID:%d CSID HW version: 0x%x\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d CSID HW version: 0x%x",
csid_hw->hw_intf->hw_idx, val);
return 0;
@@ -830,7 +884,7 @@ static int cam_ife_csid_disable_hw(struct cam_ife_csid_hw *csid_hw)
soc_info = &csid_hw->hw_info->soc_info;
csid_reg = csid_hw->csid_info->csid_reg;
- CDBG("%s:%d:CSID:%d De-init CSID HW\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d De-init CSID HW",
csid_hw->hw_intf->hw_idx);
/*disable the top IRQ interrupt */
@@ -839,8 +893,8 @@ static int cam_ife_csid_disable_hw(struct cam_ife_csid_hw *csid_hw)
rc = cam_ife_csid_disable_soc_resources(soc_info);
if (rc)
- pr_err("%s:%d:CSID:%d Disable CSID SOC failed\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx);
+ CAM_ERR(CAM_ISP, "CSID:%d Disable CSID SOC failed",
+ csid_hw->hw_intf->hw_idx);
csid_hw->hw_info->hw_state = CAM_HW_STATE_POWER_DOWN;
return rc;
@@ -856,8 +910,8 @@ static int cam_ife_csid_tpg_start(struct cam_ife_csid_hw *csid_hw,
csid_hw->tpg_start_cnt++;
if (csid_hw->tpg_start_cnt == 1) {
/*Enable the TPG */
- CDBG("%s:%d CSID:%d start CSID TPG\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx);
+ CAM_DBG(CAM_ISP, "CSID:%d start CSID TPG",
+ csid_hw->hw_intf->hw_idx);
soc_info = &csid_hw->hw_info->soc_info;
{
@@ -865,44 +919,37 @@ static int cam_ife_csid_tpg_start(struct cam_ife_csid_hw *csid_hw,
uint32_t i;
uint32_t base = 0x600;
- CDBG("%s:%d: ================== TPG ===============\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "================ TPG ============");
for (i = 0; i < 16; i++) {
val = cam_io_r_mb(
soc_info->reg_map[0].mem_base +
base + i * 4);
- CDBG("%s:%d reg 0x%x = 0x%x\n",
- __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "reg 0x%x = 0x%x",
(base + i*4), val);
}
- CDBG("%s:%d: ================== IPP ===============\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "================ IPP =============");
base = 0x200;
for (i = 0; i < 10; i++) {
val = cam_io_r_mb(
soc_info->reg_map[0].mem_base +
base + i * 4);
- CDBG("%s:%d reg 0x%x = 0x%x\n",
- __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "reg 0x%x = 0x%x",
(base + i*4), val);
}
- CDBG("%s:%d: ================== RX ===============\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "================ RX =============");
base = 0x100;
for (i = 0; i < 5; i++) {
val = cam_io_r_mb(
soc_info->reg_map[0].mem_base +
base + i * 4);
- CDBG("%s:%d reg 0x%x = 0x%x\n",
- __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "reg 0x%x = 0x%x",
(base + i*4), val);
}
}
- CDBG("%s:%d: =============== TPG control ===============\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "============ TPG control ============");
val = (4 << 20);
val |= (0x80 << 8);
val |= (((csid_hw->csi2_rx_cfg.lane_num - 1) & 0x3) << 4);
@@ -912,8 +959,7 @@ static int cam_ife_csid_tpg_start(struct cam_ife_csid_hw *csid_hw,
csid_tpg_ctrl_addr);
val = cam_io_r_mb(soc_info->reg_map[0].mem_base + 0x600);
- CDBG("%s:%d reg 0x%x = 0x%x\n", __func__, __LINE__,
- 0x600, val);
+ CAM_DBG(CAM_ISP, "reg 0x%x = 0x%x", 0x600, val);
}
return 0;
@@ -934,8 +980,8 @@ static int cam_ife_csid_tpg_stop(struct cam_ife_csid_hw *csid_hw,
/* disable the TPG */
if (!csid_hw->tpg_start_cnt) {
- CDBG("%s:%d CSID:%d stop CSID TPG\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx);
+ CAM_DBG(CAM_ISP, "CSID:%d stop CSID TPG",
+ csid_hw->hw_intf->hw_idx);
/*stop the TPG */
cam_io_w_mb(0, soc_info->reg_map[0].mem_base +
@@ -956,8 +1002,8 @@ static int cam_ife_csid_config_tpg(struct cam_ife_csid_hw *csid_hw,
csid_reg = csid_hw->csid_info->csid_reg;
soc_info = &csid_hw->hw_info->soc_info;
- CDBG("%s:%d CSID:%d TPG config\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx);
+ CAM_DBG(CAM_ISP, "CSID:%d TPG config",
+ csid_hw->hw_intf->hw_idx);
/* configure one DT, infinite frames */
val = (0 << 16) | (1 << 10) | CAM_IFE_CSID_TPG_VC_VAL;
@@ -1012,13 +1058,13 @@ static int cam_ife_csid_enable_csi2(
csid_reg = csid_hw->csid_info->csid_reg;
soc_info = &csid_hw->hw_info->soc_info;
- CDBG("%s:%d CSID:%d count:%d config csi2 rx\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, csid_hw->csi2_cfg_cnt);
+ CAM_DBG(CAM_ISP, "CSID:%d count:%d config csi2 rx",
+ csid_hw->hw_intf->hw_idx, csid_hw->csi2_cfg_cnt);
/* overflow check before increment */
if (csid_hw->csi2_cfg_cnt == UINT_MAX) {
- pr_err("%s:%d:CSID:%d Open count reached max\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx);
+ CAM_ERR(CAM_ISP, "CSID:%d Open count reached max",
+ csid_hw->hw_intf->hw_idx);
return -EINVAL;
}
@@ -1081,15 +1127,15 @@ static int cam_ife_csid_disable_csi2(
struct cam_hw_soc_info *soc_info;
if (res->res_id >= CAM_IFE_CSID_CID_MAX) {
- pr_err("%s:%d CSID:%d Invalid res id :%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_id);
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid res id :%d",
+ csid_hw->hw_intf->hw_idx, res->res_id);
return -EINVAL;
}
csid_reg = csid_hw->csid_info->csid_reg;
soc_info = &csid_hw->hw_info->soc_info;
- CDBG("%s:%d CSID:%d cnt : %d Disable csi2 rx\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, csid_hw->csi2_cfg_cnt);
+ CAM_DBG(CAM_ISP, "CSID:%d cnt : %d Disable csi2 rx",
+ csid_hw->hw_intf->hw_idx, csid_hw->csi2_cfg_cnt);
if (csid_hw->csi2_cfg_cnt)
csid_hw->csi2_cfg_cnt--;
@@ -1114,22 +1160,21 @@ static int cam_ife_csid_init_config_ipp_path(
struct cam_ife_csid_path_cfg *path_data;
struct cam_ife_csid_reg_offset *csid_reg;
struct cam_hw_soc_info *soc_info;
- uint32_t path_format = 0, plain_format = 0, val = 0;
+ uint32_t path_format = 0, val = 0;
path_data = (struct cam_ife_csid_path_cfg *) res->res_priv;
csid_reg = csid_hw->csid_info->csid_reg;
soc_info = &csid_hw->hw_info->soc_info;
if (!csid_reg->ipp_reg) {
- pr_err("%s:%d CSID:%d IPP:%d is not supported on HW\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d IPP:%d is not supported on HW",
+ csid_hw->hw_intf->hw_idx,
res->res_id);
return -EINVAL;
}
- CDBG("%s:%d: Enabled IPP Path.......\n", __func__, __LINE__);
- rc = cam_ife_csid_get_format(res->res_id,
- path_data->decode_fmt, &path_format, &plain_format);
+ CAM_DBG(CAM_ISP, "Enabled IPP Path.......");
+ rc = cam_ife_csid_get_format(path_data->decode_fmt, &path_format);
if (rc)
return rc;
@@ -1232,15 +1277,16 @@ static int cam_ife_csid_deinit_ipp_path(
soc_info = &csid_hw->hw_info->soc_info;
if (res->res_state != CAM_ISP_RESOURCE_STATE_INIT_HW) {
- pr_err("%s:%d:CSID:%d Res type %d res_id:%d in wrong state %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP,
+ "CSID:%d Res type %d res_id:%d in wrong state %d",
+ csid_hw->hw_intf->hw_idx,
res->res_type, res->res_id, res->res_state);
rc = -EINVAL;
}
if (!csid_reg->ipp_reg) {
- pr_err("%s:%d:CSID:%d IPP %d is not supported on HW\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d IPP %d is not supported on HW",
+ csid_hw->hw_intf->hw_idx,
res->res_id);
rc = -EINVAL;
}
@@ -1270,20 +1316,21 @@ static int cam_ife_csid_enable_ipp_path(
soc_info = &csid_hw->hw_info->soc_info;
if (res->res_state != CAM_ISP_RESOURCE_STATE_INIT_HW) {
- pr_err("%s:%d:CSID:%d res type:%d res_id:%d Invalid state%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP,
+ "CSID:%d res type:%d res_id:%d Invalid state%d",
+ csid_hw->hw_intf->hw_idx,
res->res_type, res->res_id, res->res_state);
return -EINVAL;
}
if (!csid_reg->ipp_reg) {
- pr_err("%s:%d:CSID:%d IPP %d not supported on HW\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d IPP %d not supported on HW",
+ csid_hw->hw_intf->hw_idx,
res->res_id);
return -EINVAL;
}
- CDBG("%s:%d: enable IPP path.......\n", __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "enable IPP path.......");
/*Resume at frame boundary */
if (path_data->sync_mode == CAM_ISP_HW_SYNC_MASTER) {
@@ -1300,8 +1347,7 @@ static int cam_ife_csid_enable_ipp_path(
/* for slave mode, not need to resume for slave device */
/* Enable the required ipp interrupts */
- val = CSID_PATH_INFO_RST_DONE | CSID_PATH_ERROR_FIFO_OVERFLOW|
- CSID_PATH_INFO_INPUT_SOF|CSID_PATH_INFO_INPUT_EOF;
+ val = CSID_PATH_INFO_RST_DONE | CSID_PATH_ERROR_FIFO_OVERFLOW;
cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
csid_reg->ipp_reg->csid_ipp_irq_mask_addr);
@@ -1326,40 +1372,40 @@ static int cam_ife_csid_disable_ipp_path(
soc_info = &csid_hw->hw_info->soc_info;
if (res->res_id >= CAM_IFE_PIX_PATH_RES_MAX) {
- CDBG("%s:%d:CSID:%d Invalid res id%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_id);
+ CAM_DBG(CAM_ISP, "CSID:%d Invalid res id%d",
+ csid_hw->hw_intf->hw_idx, res->res_id);
return -EINVAL;
}
if (res->res_state == CAM_ISP_RESOURCE_STATE_INIT_HW ||
res->res_state == CAM_ISP_RESOURCE_STATE_RESERVED) {
- CDBG("%s:%d:CSID:%d Res:%d already in stopped state:%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP, "CSID:%d Res:%d already in stopped state:%d",
+ csid_hw->hw_intf->hw_idx,
res->res_id, res->res_state);
return rc;
}
if (res->res_state != CAM_ISP_RESOURCE_STATE_STREAMING) {
- CDBG("%s:%d:CSID:%d Res:%d Invalid state%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_id,
+ CAM_DBG(CAM_ISP, "CSID:%d Res:%d Invalid state%d",
+ csid_hw->hw_intf->hw_idx, res->res_id,
res->res_state);
return -EINVAL;
}
if (!csid_reg->ipp_reg) {
- pr_err("%s:%d:CSID:%d IPP%d is not supported on HW\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_id);
+ CAM_ERR(CAM_ISP, "CSID:%d IPP%d is not supported on HW",
+ csid_hw->hw_intf->hw_idx, res->res_id);
return -EINVAL;
}
if (stop_cmd != CAM_CSID_HALT_AT_FRAME_BOUNDARY &&
stop_cmd != CAM_CSID_HALT_IMMEDIATELY) {
- pr_err("%s:%d:CSID:%d un supported stop command:%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, stop_cmd);
+ CAM_ERR(CAM_ISP, "CSID:%d un supported stop command:%d",
+ csid_hw->hw_intf->hw_idx, stop_cmd);
return -EINVAL;
}
- CDBG("%s:%d CSID:%d res_id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d res_id:%d",
csid_hw->hw_intf->hw_idx, res->res_id);
if (path_data->sync_mode == CAM_ISP_HW_SYNC_MASTER) {
@@ -1411,13 +1457,13 @@ static int cam_ife_csid_init_config_rdi_path(
id = res->res_id;
if (!csid_reg->rdi_reg[id]) {
- pr_err("%s:%d CSID:%d RDI:%d is not supported on HW\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx, id);
+ CAM_ERR(CAM_ISP, "CSID:%d RDI:%d is not supported on HW",
+ csid_hw->hw_intf->hw_idx, id);
return -EINVAL;
}
- rc = cam_ife_csid_get_format(res->res_id,
- path_data->decode_fmt, &path_format, &plain_fmt);
+ rc = cam_ife_csid_get_rdi_format(path_data->decode_fmt,
+ path_data->output_fmt, &path_format, &plain_fmt);
if (rc)
return rc;
@@ -1514,8 +1560,8 @@ static int cam_ife_csid_deinit_rdi_path(
if (res->res_id > CAM_IFE_PIX_PATH_RES_RDI_3 ||
res->res_state != CAM_ISP_RESOURCE_STATE_INIT_HW ||
!csid_reg->rdi_reg[id]) {
- pr_err("%s:%d:CSID:%d Invalid res id%d state:%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_id,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid res id%d state:%d",
+ csid_hw->hw_intf->hw_idx, res->res_id,
res->res_state);
return -EINVAL;
}
@@ -1546,8 +1592,9 @@ static int cam_ife_csid_enable_rdi_path(
if (res->res_state != CAM_ISP_RESOURCE_STATE_INIT_HW ||
res->res_id > CAM_IFE_PIX_PATH_RES_RDI_3 ||
!csid_reg->rdi_reg[id]) {
- pr_err("%s:%d:CSID:%d invalid res type:%d res_id:%d state%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP,
+ "CSID:%d invalid res type:%d res_id:%d state%d",
+ csid_hw->hw_intf->hw_idx,
res->res_type, res->res_id, res->res_state);
return -EINVAL;
}
@@ -1558,8 +1605,7 @@ static int cam_ife_csid_enable_rdi_path(
csid_reg->rdi_reg[id]->csid_rdi_ctrl_addr);
/* Enable the required RDI interrupts */
- val = (CSID_PATH_INFO_RST_DONE | CSID_PATH_ERROR_FIFO_OVERFLOW|
- CSID_PATH_INFO_INPUT_SOF | CSID_PATH_INFO_INPUT_EOF);
+ val = CSID_PATH_INFO_RST_DONE | CSID_PATH_ERROR_FIFO_OVERFLOW;
cam_io_w_mb(val, soc_info->reg_map[0].mem_base +
csid_reg->rdi_reg[id]->csid_rdi_irq_mask_addr);
@@ -1585,35 +1631,35 @@ static int cam_ife_csid_disable_rdi_path(
if (res->res_id >= CAM_IFE_PIX_PATH_RES_MAX ||
!csid_reg->rdi_reg[res->res_id]) {
- CDBG("%s:%d:CSID:%d Invalid res id%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_id);
+ CAM_DBG(CAM_ISP, "CSID:%d Invalid res id%d",
+ csid_hw->hw_intf->hw_idx, res->res_id);
return -EINVAL;
}
if (res->res_state == CAM_ISP_RESOURCE_STATE_INIT_HW ||
res->res_state == CAM_ISP_RESOURCE_STATE_RESERVED) {
- CDBG("%s:%d:CSID:%d Res:%d already in stopped state:%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP, "CSID:%d Res:%d already in stopped state:%d",
+ csid_hw->hw_intf->hw_idx,
res->res_id, res->res_state);
return rc;
}
if (res->res_state != CAM_ISP_RESOURCE_STATE_STREAMING) {
- CDBG("%s:%d:CSID:%d Res:%d Invalid res_state%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_id,
+ CAM_DBG(CAM_ISP, "CSID:%d Res:%d Invalid res_state%d",
+ csid_hw->hw_intf->hw_idx, res->res_id,
res->res_state);
return -EINVAL;
}
if (stop_cmd != CAM_CSID_HALT_AT_FRAME_BOUNDARY &&
stop_cmd != CAM_CSID_HALT_IMMEDIATELY) {
- pr_err("%s:%d:CSID:%d un supported stop command:%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, stop_cmd);
+ CAM_ERR(CAM_ISP, "CSID:%d un supported stop command:%d",
+ csid_hw->hw_intf->hw_idx, stop_cmd);
return -EINVAL;
}
- CDBG("%s:%d CSID:%d res_id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d res_id:%d",
csid_hw->hw_intf->hw_idx, res->res_id);
init_completion(&csid_hw->csid_rdin_complete[id]);
@@ -1654,15 +1700,15 @@ static int cam_ife_csid_get_time_stamp(
if (res->res_type != CAM_ISP_RESOURCE_PIX_PATH ||
res->res_id >= CAM_IFE_PIX_PATH_RES_MAX) {
- CDBG("%s:%d:CSID:%d Invalid res_type:%d res id%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_type,
+ CAM_DBG(CAM_ISP, "CSID:%d Invalid res_type:%d res id%d",
+ csid_hw->hw_intf->hw_idx, res->res_type,
res->res_id);
return -EINVAL;
}
if (csid_hw->hw_info->hw_state != CAM_HW_STATE_POWER_UP) {
- pr_err("%s:%d:CSID:%d Invalid dev state :%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid dev state :%d",
+ csid_hw->hw_intf->hw_idx,
csid_hw->hw_info->hw_state);
return -EINVAL;
}
@@ -1706,22 +1752,22 @@ static int cam_ife_csid_res_wait_for_halt(
soc_info = &csid_hw->hw_info->soc_info;
if (res->res_id >= CAM_IFE_PIX_PATH_RES_MAX) {
- CDBG("%s:%d:CSID:%d Invalid res id%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_id);
+ CAM_DBG(CAM_ISP, "CSID:%d Invalid res id%d",
+ csid_hw->hw_intf->hw_idx, res->res_id);
return -EINVAL;
}
if (res->res_state == CAM_ISP_RESOURCE_STATE_INIT_HW ||
res->res_state == CAM_ISP_RESOURCE_STATE_RESERVED) {
- CDBG("%s:%d:CSID:%d Res:%d already in stopped state:%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP, "CSID:%d Res:%d already in stopped state:%d",
+ csid_hw->hw_intf->hw_idx,
res->res_id, res->res_state);
return rc;
}
if (res->res_state != CAM_ISP_RESOURCE_STATE_STREAMING) {
- CDBG("%s:%d:CSID:%d Res:%d Invalid state%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_id,
+ CAM_DBG(CAM_ISP, "CSID:%d Res:%d Invalid state%d",
+ csid_hw->hw_intf->hw_idx, res->res_id,
res->res_state);
return -EINVAL;
}
@@ -1734,8 +1780,8 @@ static int cam_ife_csid_res_wait_for_halt(
rc = wait_for_completion_timeout(complete,
msecs_to_jiffies(IFE_CSID_TIMEOUT));
if (rc <= 0) {
- pr_err("%s:%d:CSID%d stop at frame boundary failid:%drc:%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID%d stop at frame boundary failid:%drc:%d",
+ csid_hw->hw_intf->hw_idx,
res->res_id, rc);
if (rc == 0)
/* continue even have timeout */
@@ -1774,7 +1820,7 @@ static int cam_ife_csid_get_hw_caps(void *hw_priv,
struct cam_ife_csid_reg_offset *csid_reg;
if (!hw_priv || !get_hw_cap_args) {
- pr_err("%s:%d:CSID: Invalid args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID: Invalid args");
return -EINVAL;
}
@@ -1789,8 +1835,9 @@ static int cam_ife_csid_get_hw_caps(void *hw_priv,
hw_caps->minor_version = csid_reg->cmn_reg->minor_version;
hw_caps->version_incr = csid_reg->cmn_reg->version_incr;
- CDBG("%s:%d:CSID:%d No rdis:%d, no pix:%d, major:%d minor:%d ver :%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx, hw_caps->no_rdis,
+ CAM_DBG(CAM_ISP,
+ "CSID:%d No rdis:%d, no pix:%d, major:%d minor:%d ver :%d",
+ csid_hw->hw_intf->hw_idx, hw_caps->no_rdis,
hw_caps->no_pix, hw_caps->major_version, hw_caps->minor_version,
hw_caps->version_incr);
@@ -1807,7 +1854,7 @@ static int cam_ife_csid_reset(void *hw_priv,
if (!hw_priv || !reset_args || (arg_size !=
sizeof(struct cam_csid_reset_cfg_args))) {
- pr_err("%s:%d:CSID:Invalid args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID:Invalid args");
return -EINVAL;
}
@@ -1823,8 +1870,8 @@ static int cam_ife_csid_reset(void *hw_priv,
rc = cam_ife_csid_path_reset(csid_hw, reset);
break;
default:
- pr_err("%s:%d:CSID:Invalid reset type :%d\n", __func__,
- __LINE__, reset->reset_type);
+ CAM_ERR(CAM_ISP, "CSID:Invalid reset type :%d",
+ reset->reset_type);
rc = -EINVAL;
break;
}
@@ -1842,7 +1889,7 @@ static int cam_ife_csid_reserve(void *hw_priv,
if (!hw_priv || !reserve_args || (arg_size !=
sizeof(struct cam_csid_hw_reserve_resource_args))) {
- pr_err("%s:%d:CSID: Invalid args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID: Invalid args");
return -EINVAL;
}
@@ -1859,8 +1906,8 @@ static int cam_ife_csid_reserve(void *hw_priv,
rc = cam_ife_csid_path_reserve(csid_hw, reserv);
break;
default:
- pr_err("%s:%d:CSID:%d Invalid res type :%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, reserv->res_type);
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid res type :%d",
+ csid_hw->hw_intf->hw_idx, reserv->res_type);
rc = -EINVAL;
break;
}
@@ -1879,7 +1926,7 @@ static int cam_ife_csid_release(void *hw_priv,
if (!hw_priv || !release_args ||
(arg_size != sizeof(struct cam_isp_resource_node))) {
- pr_err("%s:%d:CSID: Invalid args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID: Invalid args");
return -EINVAL;
}
@@ -1892,31 +1939,33 @@ static int cam_ife_csid_release(void *hw_priv,
res->res_id >= CAM_IFE_CSID_CID_MAX) ||
(res->res_type == CAM_ISP_RESOURCE_PIX_PATH &&
res->res_id >= CAM_IFE_PIX_PATH_RES_MAX)) {
- pr_err("%s:%d:CSID:%d Invalid res type:%d res id%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_type,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid res type:%d res id%d",
+ csid_hw->hw_intf->hw_idx, res->res_type,
res->res_id);
rc = -EINVAL;
goto end;
}
if (res->res_state == CAM_ISP_RESOURCE_STATE_AVAILABLE) {
- CDBG("%s:%d:CSID:%d res type:%d Res %d in released state\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP,
+ "CSID:%d res type:%d Res %d in released state",
+ csid_hw->hw_intf->hw_idx,
res->res_type, res->res_id);
goto end;
}
if (res->res_type == CAM_ISP_RESOURCE_PIX_PATH &&
res->res_state != CAM_ISP_RESOURCE_STATE_RESERVED) {
- CDBG("%s:%d:CSID:%d res type:%d Res id:%d invalid state:%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP,
+ "CSID:%d res type:%d Res id:%d invalid state:%d",
+ csid_hw->hw_intf->hw_idx,
res->res_type, res->res_id, res->res_state);
rc = -EINVAL;
goto end;
}
- CDBG("%s:%d:CSID:%d res type :%d Resource id:%d\n", __func__, __LINE__,
- csid_hw->hw_intf->hw_idx, res->res_type, res->res_id);
+ CAM_DBG(CAM_ISP, "CSID:%d res type :%d Resource id:%d",
+ csid_hw->hw_intf->hw_idx, res->res_type, res->res_id);
switch (res->res_type) {
case CAM_ISP_RESOURCE_CID:
@@ -1934,8 +1983,8 @@ static int cam_ife_csid_release(void *hw_priv,
memset(&csid_hw->csi2_rx_cfg, 0,
sizeof(struct cam_ife_csid_csi2_rx_cfg));
- CDBG("%s:%d:CSID:%d res id :%d cnt:%d reserv cnt:%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP, "CSID:%d res id :%d cnt:%d reserv cnt:%d",
+ csid_hw->hw_intf->hw_idx,
res->res_id, cid_data->cnt, csid_hw->csi2_reserve_cnt);
break;
@@ -1943,8 +1992,8 @@ static int cam_ife_csid_release(void *hw_priv,
res->res_state = CAM_ISP_RESOURCE_STATE_AVAILABLE;
break;
default:
- pr_err("%s:%d:CSID:%d Invalid res type:%d res id%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_type,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid res type:%d res id%d",
+ csid_hw->hw_intf->hw_idx, res->res_type,
res->res_id);
rc = -EINVAL;
break;
@@ -1966,7 +2015,7 @@ static int cam_ife_csid_init_hw(void *hw_priv,
if (!hw_priv || !init_args ||
(arg_size != sizeof(struct cam_isp_resource_node))) {
- pr_err("%s:%d:CSID: Invalid args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID: Invalid args");
return -EINVAL;
}
@@ -1980,8 +2029,8 @@ static int cam_ife_csid_init_hw(void *hw_priv,
res->res_id >= CAM_IFE_CSID_CID_MAX) ||
(res->res_type == CAM_ISP_RESOURCE_PIX_PATH &&
res->res_id >= CAM_IFE_PIX_PATH_RES_MAX)) {
- pr_err("%s:%d:CSID:%d Invalid res tpe:%d res id%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_type,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid res tpe:%d res id%d",
+ csid_hw->hw_intf->hw_idx, res->res_type,
res->res_id);
rc = -EINVAL;
goto end;
@@ -1990,14 +2039,15 @@ static int cam_ife_csid_init_hw(void *hw_priv,
if ((res->res_type == CAM_ISP_RESOURCE_PIX_PATH) &&
(res->res_state != CAM_ISP_RESOURCE_STATE_RESERVED)) {
- pr_err("%s:%d:CSID:%d res type:%d res_id:%dInvalid state %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP,
+ "CSID:%d res type:%d res_id:%dInvalid state %d",
+ csid_hw->hw_intf->hw_idx,
res->res_type, res->res_id, res->res_state);
rc = -EINVAL;
goto end;
}
- CDBG("%s:%d CSID:%d res type :%d res_id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d res type :%d res_id:%d",
csid_hw->hw_intf->hw_idx, res->res_type, res->res_id);
@@ -2018,8 +2068,8 @@ static int cam_ife_csid_init_hw(void *hw_priv,
break;
default:
- pr_err("%s:%d:CSID:%d Invalid res type state %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid res type state %d",
+ csid_hw->hw_intf->hw_idx,
res->res_type);
break;
}
@@ -2041,7 +2091,7 @@ static int cam_ife_csid_deinit_hw(void *hw_priv,
if (!hw_priv || !deinit_args ||
(arg_size != sizeof(struct cam_isp_resource_node))) {
- pr_err("%s:%d:CSID:Invalid arguments\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID:Invalid arguments");
return -EINVAL;
}
@@ -2051,8 +2101,8 @@ static int cam_ife_csid_deinit_hw(void *hw_priv,
mutex_lock(&csid_hw->hw_info->hw_mutex);
if (res->res_state == CAM_ISP_RESOURCE_STATE_RESERVED) {
- CDBG("%s:%d:CSID:%d Res:%d already in De-init state\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_DBG(CAM_ISP, "CSID:%d Res:%d already in De-init state",
+ csid_hw->hw_intf->hw_idx,
res->res_id);
goto end;
}
@@ -2069,8 +2119,8 @@ static int cam_ife_csid_deinit_hw(void *hw_priv,
break;
default:
- pr_err("%s:%d:CSID:%d Invalid Res type %d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid Res type %d",
+ csid_hw->hw_intf->hw_idx,
res->res_type);
goto end;
}
@@ -2094,7 +2144,7 @@ static int cam_ife_csid_start(void *hw_priv, void *start_args,
if (!hw_priv || !start_args ||
(arg_size != sizeof(struct cam_isp_resource_node))) {
- pr_err("%s:%d:CSID: Invalid args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID: Invalid args");
return -EINVAL;
}
@@ -2103,19 +2153,18 @@ static int cam_ife_csid_start(void *hw_priv, void *start_args,
res = (struct cam_isp_resource_node *)start_args;
csid_reg = csid_hw->csid_info->csid_reg;
- mutex_lock(&csid_hw->hw_info->hw_mutex);
if ((res->res_type == CAM_ISP_RESOURCE_CID &&
res->res_id >= CAM_IFE_CSID_CID_MAX) ||
(res->res_type == CAM_ISP_RESOURCE_PIX_PATH &&
res->res_id >= CAM_IFE_PIX_PATH_RES_MAX)) {
- CDBG("%s:%d:CSID:%d Invalid res tpe:%d res id:%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, res->res_type,
+ CAM_DBG(CAM_ISP, "CSID:%d Invalid res tpe:%d res id:%d",
+ csid_hw->hw_intf->hw_idx, res->res_type,
res->res_id);
rc = -EINVAL;
goto end;
}
- CDBG("%s:%d CSID:%d res_type :%d res_id:%d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d res_type :%d res_id:%d",
csid_hw->hw_intf->hw_idx, res->res_type, res->res_id);
switch (res->res_type) {
@@ -2130,13 +2179,12 @@ static int cam_ife_csid_start(void *hw_priv, void *start_args,
rc = cam_ife_csid_enable_rdi_path(csid_hw, res);
break;
default:
- pr_err("%s:%d:CSID:%d Invalid res type%d\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid res type%d",
+ csid_hw->hw_intf->hw_idx,
res->res_type);
break;
}
end:
- mutex_unlock(&csid_hw->hw_info->hw_mutex);
return rc;
}
@@ -2152,14 +2200,13 @@ static int cam_ife_csid_stop(void *hw_priv,
if (!hw_priv || !stop_args ||
(arg_size != sizeof(struct cam_csid_hw_stop_args))) {
- pr_err("%s:%d:CSID: Invalid args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID: Invalid args");
return -EINVAL;
}
csid_stop = (struct cam_csid_hw_stop_args *) stop_args;
csid_hw_info = (struct cam_hw_info *)hw_priv;
csid_hw = (struct cam_ife_csid_hw *)csid_hw_info->core_info;
- mutex_lock(&csid_hw->hw_info->hw_mutex);
/* Stop the resource first */
for (i = 0; i < csid_stop->num_res; i++) {
res = csid_stop->node_res[i];
@@ -2178,8 +2225,8 @@ static int cam_ife_csid_stop(void *hw_priv,
break;
default:
- pr_err("%s:%d:CSID:%d Invalid res type%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx,
+ CAM_ERR(CAM_ISP, "CSID:%d Invalid res type%d",
+ csid_hw->hw_intf->hw_idx,
res->res_type);
break;
}
@@ -2191,9 +2238,10 @@ static int cam_ife_csid_stop(void *hw_priv,
if (res->res_type == CAM_ISP_RESOURCE_PIX_PATH &&
csid_stop->stop_cmd == CAM_CSID_HALT_AT_FRAME_BOUNDARY)
rc = cam_ife_csid_res_wait_for_halt(csid_hw, res);
+ else
+ res->res_state = CAM_ISP_RESOURCE_STATE_INIT_HW;
}
- mutex_unlock(&csid_hw->hw_info->hw_mutex);
return rc;
}
@@ -2201,7 +2249,7 @@ static int cam_ife_csid_stop(void *hw_priv,
static int cam_ife_csid_read(void *hw_priv,
void *read_args, uint32_t arg_size)
{
- pr_err("%s:%d:CSID: un supported\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID: un supported");
return -EINVAL;
}
@@ -2209,7 +2257,7 @@ static int cam_ife_csid_read(void *hw_priv,
static int cam_ife_csid_write(void *hw_priv,
void *write_args, uint32_t arg_size)
{
- pr_err("%s:%d:CSID: un supported\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID: un supported");
return -EINVAL;
}
@@ -2221,7 +2269,7 @@ static int cam_ife_csid_process_cmd(void *hw_priv,
struct cam_hw_info *csid_hw_info;
if (!hw_priv || !cmd_args) {
- pr_err("%s:%d:CSID: Invalid arguments\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID: Invalid arguments");
return -EINVAL;
}
@@ -2233,8 +2281,8 @@ static int cam_ife_csid_process_cmd(void *hw_priv,
rc = cam_ife_csid_get_time_stamp(csid_hw, cmd_args);
break;
default:
- pr_err("%s:%d:CSID:%d un supported cmd:%d\n", __func__,
- __LINE__, csid_hw->hw_intf->hw_idx, cmd_type);
+ CAM_ERR(CAM_ISP, "CSID:%d un supported cmd:%d",
+ csid_hw->hw_intf->hw_idx, cmd_type);
rc = -EINVAL;
break;
}
@@ -2253,11 +2301,10 @@ irqreturn_t cam_ife_csid_irq(int irq_num, void *data)
csid_hw = (struct cam_ife_csid_hw *)data;
- CDBG("%s:%d:CSID %d IRQ Handling\n", __func__, __LINE__,
- csid_hw->hw_intf->hw_idx);
+ CAM_DBG(CAM_ISP, "CSID %d IRQ Handling", csid_hw->hw_intf->hw_idx);
if (!data) {
- pr_err("%s:%d:CSID: Invalid arguments\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "CSID: Invalid arguments");
return IRQ_HANDLED;
}
@@ -2296,55 +2343,52 @@ irqreturn_t cam_ife_csid_irq(int irq_num, void *data)
cam_io_w_mb(1, soc_info->reg_map[0].mem_base +
csid_reg->cmn_reg->csid_irq_cmd_addr);
- CDBG("%s:%d: irq_status_rx = 0x%x\n", __func__, __LINE__,
- irq_status_rx);
- CDBG("%s:%d: irq_status_ipp = 0x%x\n", __func__, __LINE__,
- irq_status_ipp);
+ CAM_DBG(CAM_ISP, "irq_status_rx = 0x%x", irq_status_rx);
+ CAM_DBG(CAM_ISP, "irq_status_ipp = 0x%x", irq_status_ipp);
if (irq_status_top) {
- CDBG("%s:%d: CSID global reset complete......Exit\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "CSID global reset complete......Exit");
complete(&csid_hw->csid_top_complete);
return IRQ_HANDLED;
}
if (irq_status_rx & BIT(csid_reg->csi2_reg->csi2_rst_done_shift_val)) {
- CDBG("%s:%d: csi rx reset complete\n", __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "csi rx reset complete");
complete(&csid_hw->csid_csi2_complete);
}
if (irq_status_rx & CSID_CSI2_RX_ERROR_LANE0_FIFO_OVERFLOW) {
- pr_err_ratelimited("%s:%d:CSID:%d lane 0 over flow\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx);
+ pr_err_ratelimited("CSID:%d lane 0 over flow",
+ csid_hw->hw_intf->hw_idx);
}
if (irq_status_rx & CSID_CSI2_RX_ERROR_LANE1_FIFO_OVERFLOW) {
- pr_err_ratelimited("%s:%d:CSID:%d lane 1 over flow\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx);
+ pr_err_ratelimited("CSID:%d lane 1 over flow",
+ csid_hw->hw_intf->hw_idx);
}
if (irq_status_rx & CSID_CSI2_RX_ERROR_LANE2_FIFO_OVERFLOW) {
- pr_err_ratelimited("%s:%d:CSID:%d lane 2 over flow\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx);
+ pr_err_ratelimited("CSID:%d lane 2 over flow",
+ csid_hw->hw_intf->hw_idx);
}
if (irq_status_rx & CSID_CSI2_RX_ERROR_LANE3_FIFO_OVERFLOW) {
- pr_err_ratelimited("%s:%d:CSID:%d lane 3 over flow\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx);
+ pr_err_ratelimited("CSID:%d lane 3 over flow",
+ csid_hw->hw_intf->hw_idx);
}
if (irq_status_rx & CSID_CSI2_RX_ERROR_TG_FIFO_OVERFLOW) {
- pr_err_ratelimited("%s:%d:CSID:%d TG OVER FLOW\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx);
+ pr_err_ratelimited("CSID:%d TG OVER FLOW",
+ csid_hw->hw_intf->hw_idx);
}
if (irq_status_rx & CSID_CSI2_RX_ERROR_CPHY_EOT_RECEPTION) {
- pr_err_ratelimited("%s:%d:CSID:%d CPHY_EOT_RECEPTION\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx);
+ pr_err_ratelimited("CSID:%d CPHY_EOT_RECEPTION",
+ csid_hw->hw_intf->hw_idx);
}
if (irq_status_rx & CSID_CSI2_RX_ERROR_CPHY_SOT_RECEPTION) {
- pr_err_ratelimited("%s:%d:CSID:%d CPHY_SOT_RECEPTION\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx);
+ pr_err_ratelimited("CSID:%d CPHY_SOT_RECEPTION",
+ csid_hw->hw_intf->hw_idx);
}
if (irq_status_rx & CSID_CSI2_RX_ERROR_CPHY_PH_CRC) {
- pr_err_ratelimited("%s:%d:CSID:%d CPHY_PH_CRC\n",
- __func__, __LINE__, csid_hw->hw_intf->hw_idx);
+ pr_err_ratelimited("CSID:%d CPHY_PH_CRC",
+ csid_hw->hw_intf->hw_idx);
}
/*read the IPP errors */
@@ -2352,25 +2396,23 @@ irqreturn_t cam_ife_csid_irq(int irq_num, void *data)
/* IPP reset done bit */
if (irq_status_ipp &
BIT(csid_reg->cmn_reg->path_rst_done_shift_val)) {
- CDBG("%s%d: CSID IPP reset complete\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "CSID IPP reset complete");
complete(&csid_hw->csid_ipp_complete);
}
if (irq_status_ipp & CSID_PATH_INFO_INPUT_SOF)
- CDBG("%s: CSID IPP SOF received\n", __func__);
+ CAM_DBG(CAM_ISP, "CSID IPP SOF received");
if (irq_status_ipp & CSID_PATH_INFO_INPUT_SOL)
- CDBG("%s: CSID IPP SOL received\n", __func__);
+ CAM_DBG(CAM_ISP, "CSID IPP SOL received");
if (irq_status_ipp & CSID_PATH_INFO_INPUT_EOL)
- CDBG("%s: CSID IPP EOL received\n", __func__);
+ CAM_DBG(CAM_ISP, "CSID IPP EOL received");
if (irq_status_ipp & CSID_PATH_INFO_INPUT_EOF)
- CDBG("%s: CSID IPP EOF received\n", __func__);
+ CAM_DBG(CAM_ISP, "CSID IPP EOF received");
if (irq_status_ipp & CSID_PATH_INFO_INPUT_EOF)
complete(&csid_hw->csid_ipp_complete);
if (irq_status_ipp & CSID_PATH_ERROR_FIFO_OVERFLOW) {
- pr_err("%s:%d:CSID:%d IPP fifo over flow\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP, "CSID:%d IPP fifo over flow",
csid_hw->hw_intf->hw_idx);
/*Stop IPP path immediately */
cam_io_w_mb(CAM_CSID_HALT_IMMEDIATELY,
@@ -2382,17 +2424,20 @@ irqreturn_t cam_ife_csid_irq(int irq_num, void *data)
for (i = 0; i < csid_reg->cmn_reg->no_rdis; i++) {
if (irq_status_rdi[i] &
BIT(csid_reg->cmn_reg->path_rst_done_shift_val)) {
- CDBG("%s:%d: CSID rdi%d reset complete\n",
- __func__, __LINE__, i);
+ CAM_DBG(CAM_ISP, "CSID rdi%d reset complete", i);
complete(&csid_hw->csid_rdin_complete[i]);
}
+ if (irq_status_rdi[i] & CSID_PATH_INFO_INPUT_SOF)
+ CAM_DBG(CAM_ISP, "CSID RDI SOF received");
+ if (irq_status_rdi[i] & CSID_PATH_INFO_INPUT_EOF)
+ CAM_DBG(CAM_ISP, "CSID RDI EOF received");
+
if (irq_status_rdi[i] & CSID_PATH_INFO_INPUT_EOF)
complete(&csid_hw->csid_rdin_complete[i]);
if (irq_status_rdi[i] & CSID_PATH_ERROR_FIFO_OVERFLOW) {
- pr_err("%s:%d:CSID:%d RDI fifo over flow\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ISP, "CSID:%d RDI fifo over flow",
csid_hw->hw_intf->hw_idx);
/*Stop RDI path immediately */
cam_io_w_mb(CAM_CSID_HALT_IMMEDIATELY,
@@ -2401,7 +2446,7 @@ irqreturn_t cam_ife_csid_irq(int irq_num, void *data)
}
}
- CDBG("%s:%d:IRQ Handling exit\n", __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "IRQ Handling exit");
return IRQ_HANDLED;
}
@@ -2416,8 +2461,7 @@ int cam_ife_csid_hw_probe_init(struct cam_hw_intf *csid_hw_intf,
struct cam_ife_csid_hw *ife_csid_hw = NULL;
if (csid_idx >= CAM_IFE_CSID_HW_RES_MAX) {
- pr_err("%s:%d: Invalid csid index:%d\n", __func__, __LINE__,
- csid_idx);
+ CAM_ERR(CAM_ISP, "Invalid csid index:%d", csid_idx);
return rc;
}
@@ -2427,7 +2471,7 @@ int cam_ife_csid_hw_probe_init(struct cam_hw_intf *csid_hw_intf,
ife_csid_hw->hw_intf = csid_hw_intf;
ife_csid_hw->hw_info = csid_hw_info;
- CDBG("%s:%d: type %d index %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "type %d index %d",
ife_csid_hw->hw_intf->hw_type, csid_idx);
@@ -2446,8 +2490,7 @@ int cam_ife_csid_hw_probe_init(struct cam_hw_intf *csid_hw_intf,
rc = cam_ife_csid_init_soc_resources(&ife_csid_hw->hw_info->soc_info,
cam_ife_csid_irq, ife_csid_hw);
if (rc < 0) {
- pr_err("%s:%d:CSID:%d Failed to init_soc\n", __func__, __LINE__,
- csid_idx);
+ CAM_ERR(CAM_ISP, "CSID:%d Failed to init_soc", csid_idx);
goto err;
}
@@ -2539,7 +2582,7 @@ int cam_ife_csid_hw_deinit(struct cam_ife_csid_hw *ife_csid_hw)
uint32_t i;
if (!ife_csid_hw) {
- pr_err("%s:%d: Invalid param\n", __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "Invalid param");
return rc;
}
@@ -2553,8 +2596,7 @@ int cam_ife_csid_hw_deinit(struct cam_ife_csid_hw *ife_csid_hw)
for (i = 0; i < CAM_IFE_CSID_CID_RES_MAX; i++)
kfree(ife_csid_hw->cid_res[i].res_priv);
+ cam_ife_csid_deinit_soc_resources(&ife_csid_hw->hw_info->soc_info);
return 0;
}
-
-
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h
index 60e184b..ef585c3 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.h
@@ -354,6 +354,7 @@ struct cam_ife_csid_cid_data {
* @dt : Data type number
* @cid cid number, it is same as DT_ID number in HW
* @decode_fmt: input decode format
+ * @output_fmt: output resource format, needed for RDI resource
* @crop_enable: crop is enable or disabled, if enabled
* then remaining parameters are valid.
* @start_pixel: start pixel
@@ -373,6 +374,7 @@ struct cam_ife_csid_path_cfg {
uint32_t dt;
uint32_t cid;
uint32_t decode_fmt;
+ uint32_t output_fmt;
bool crop_enable;
uint32_t start_pixel;
uint32_t width;
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.c
index 003d83f..5a57046 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.c
@@ -16,9 +16,7 @@
#include "cam_ife_csid_core.h"
#include "cam_ife_csid_dev.h"
#include "cam_ife_csid_hw_intf.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
static struct cam_hw_intf *cam_ife_csid_hw_list[CAM_IFE_CSID_HW_RES_MAX] = {
0, 0, 0, 0};
@@ -34,7 +32,7 @@ int cam_ife_csid_probe(struct platform_device *pdev)
uint32_t csid_dev_idx;
int rc = 0;
- CDBG("%s:%d probe called\n", __func__, __LINE__);
+ CAM_DBG(CAM_ISP, "probe called");
csid_hw_intf = kzalloc(sizeof(*csid_hw_intf), GFP_KERNEL);
if (!csid_hw_intf) {
@@ -60,8 +58,7 @@ int cam_ife_csid_probe(struct platform_device *pdev)
match_dev = of_match_device(pdev->dev.driver->of_match_table,
&pdev->dev);
if (!match_dev) {
- pr_err("%s:%d No matching table for the IFE CSID HW!\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ISP, "No matching table for the IFE CSID HW!");
rc = -EINVAL;
goto free_dev;
}
@@ -72,6 +69,7 @@ int cam_ife_csid_probe(struct platform_device *pdev)
csid_hw_info->core_info = csid_dev;
csid_hw_info->soc_info.pdev = pdev;
+ csid_hw_info->soc_info.index = csid_dev_idx;
csid_hw_data = (struct cam_ife_csid_hw_info *)match_dev->data;
/* need to setup the pdev before call the ife hw probe init */
@@ -82,7 +80,7 @@ int cam_ife_csid_probe(struct platform_device *pdev)
goto free_dev;
platform_set_drvdata(pdev, csid_dev);
- CDBG("%s:%d CSID:%d probe successful\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d probe successful",
csid_hw_intf->hw_idx);
@@ -113,7 +111,7 @@ int cam_ife_csid_remove(struct platform_device *pdev)
csid_hw_intf = csid_dev->hw_intf;
csid_hw_info = csid_dev->hw_info;
- CDBG("%s:%d CSID:%d remove\n", __func__, __LINE__,
+ CAM_DBG(CAM_ISP, "CSID:%d remove",
csid_dev->hw_intf->hw_idx);
cam_ife_csid_hw_deinit(csid_dev);
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite170.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite170.c
index 4ed4da5..36c6df0 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite170.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite170.c
@@ -15,7 +15,6 @@
#include "cam_ife_csid_core.h"
#include "cam_ife_csid_dev.h"
-
#define CAM_CSID_LITE_DRV_NAME "csid_lite_170"
#define CAM_CSID_LITE_VERSION_V170 0x10070000
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.c
index c718bba..72050aa 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.c
@@ -9,11 +9,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
-
+#include <linux/slab.h>
#include "cam_ife_csid_soc.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_cpas_api.h"
+#include "cam_debug_util.h"
static int cam_ife_csid_get_dt_properties(struct cam_hw_soc_info *soc_info)
{
@@ -50,6 +49,14 @@ int cam_ife_csid_init_soc_resources(struct cam_hw_soc_info *soc_info,
irq_handler_t csid_irq_handler, void *irq_data)
{
int rc = 0;
+ struct cam_cpas_register_params cpas_register_param;
+ struct cam_csid_soc_private *soc_private;
+
+ soc_private = kzalloc(sizeof(struct cam_csid_soc_private), GFP_KERNEL);
+ if (!soc_private)
+ return -ENOMEM;
+
+ soc_info->soc_private = soc_private;
rc = cam_ife_csid_get_dt_properties(soc_info);
if (rc < 0)
@@ -59,36 +66,117 @@ int cam_ife_csid_init_soc_resources(struct cam_hw_soc_info *soc_info,
rc = cam_ife_csid_request_platform_resource(soc_info, csid_irq_handler,
irq_data);
+ if (rc < 0) {
+ CAM_ERR(CAM_ISP,
+ "Error Request platform resources failed rc=%d", rc);
+ goto free_soc_private;
+ }
+
+ memset(&cpas_register_param, 0, sizeof(cpas_register_param));
+ strlcpy(cpas_register_param.identifier, "csid",
+ CAM_HW_IDENTIFIER_LENGTH);
+ cpas_register_param.cell_index = soc_info->index;
+ cpas_register_param.dev = &soc_info->pdev->dev;
+ rc = cam_cpas_register_client(&cpas_register_param);
+ if (rc) {
+ CAM_ERR(CAM_ISP, "CPAS registration failed rc=%d", rc);
+ goto release_soc;
+ } else {
+ soc_private->cpas_handle = cpas_register_param.client_handle;
+ }
+
+ return rc;
+
+release_soc:
+ cam_soc_util_release_platform_resource(soc_info);
+free_soc_private:
+ kfree(soc_private);
+
+ return rc;
+}
+
+int cam_ife_csid_deinit_soc_resources(
+ struct cam_hw_soc_info *soc_info)
+{
+ int rc = 0;
+ struct cam_csid_soc_private *soc_private;
+
+ soc_private = soc_info->soc_private;
+ if (!soc_private) {
+ CAM_ERR(CAM_ISP, "Error soc_private NULL");
+ return -ENODEV;
+ }
+
+ rc = cam_cpas_unregister_client(soc_private->cpas_handle);
+ if (rc)
+ CAM_ERR(CAM_ISP, "CPAS unregistration failed rc=%d", rc);
+
+ rc = cam_soc_util_release_platform_resource(soc_info);
if (rc < 0)
return rc;
- CDBG("%s: mem_base is 0x%llx\n", __func__,
- (uint64_t) soc_info->reg_map[0].mem_base);
-
return rc;
}
int cam_ife_csid_enable_soc_resources(struct cam_hw_soc_info *soc_info)
{
int rc = 0;
+ struct cam_csid_soc_private *soc_private;
+ struct cam_ahb_vote ahb_vote;
+ struct cam_axi_vote axi_vote;
+
+ soc_private = soc_info->soc_private;
+
+ ahb_vote.type = CAM_VOTE_ABSOLUTE;
+ ahb_vote.vote.level = CAM_SVS_VOTE;
+ axi_vote.compressed_bw = 640000000;
+ axi_vote.uncompressed_bw = 640000000;
+
+ CAM_DBG(CAM_ISP, "csid vote compressed_bw:%lld uncompressed_bw:%lld",
+ axi_vote.compressed_bw, axi_vote.uncompressed_bw);
+
+ rc = cam_cpas_start(soc_private->cpas_handle, &ahb_vote, &axi_vote);
+ if (rc) {
+ CAM_ERR(CAM_ISP, "Error CPAS start failed");
+ rc = -EFAULT;
+ goto end;
+ }
rc = cam_soc_util_enable_platform_resource(soc_info, true,
CAM_TURBO_VOTE, true);
if (rc) {
- pr_err("%s: enable platform failed\n", __func__);
- return rc;
+ CAM_ERR(CAM_ISP, "enable platform failed");
+ goto stop_cpas;
}
return rc;
+
+stop_cpas:
+ cam_cpas_stop(soc_private->cpas_handle);
+end:
+ return rc;
}
int cam_ife_csid_disable_soc_resources(struct cam_hw_soc_info *soc_info)
{
int rc = 0;
+ struct cam_csid_soc_private *soc_private;
+
+ if (!soc_info) {
+ CAM_ERR(CAM_ISP, "Error Invalid params");
+ return -EINVAL;
+ }
+ soc_private = soc_info->soc_private;
rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
if (rc)
- pr_err("%s: Disable platform failed\n", __func__);
+ CAM_ERR(CAM_ISP, "Disable platform failed");
+
+ rc = cam_cpas_stop(soc_private->cpas_handle);
+ if (rc) {
+ CAM_ERR(CAM_ISP, "Error CPAS stop failed rc=%d", rc);
+ return rc;
+ }
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.h
index 218e05a..1a30722 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_soc.h
@@ -15,6 +15,19 @@
#include "cam_isp_hw.h"
+/*
+ * struct cam_csid_soc_private:
+ *
+ * @Brief: Private SOC data specific to CSID HW Driver
+ *
+ * @cpas_handle: Handle returned on registering with CPAS driver.
+ * This handle is used for all further interface
+ * with CPAS.
+ */
+struct cam_csid_soc_private {
+ uint32_t cpas_handle;
+};
+
/**
* struct csid_device_soc_info - CSID SOC info object
*
@@ -38,6 +51,17 @@ struct csid_device_soc_info {
int cam_ife_csid_init_soc_resources(struct cam_hw_soc_info *soc_info,
irq_handler_t csid_irq_handler, void *irq_data);
+
+/**
+ * cam_ife_csid_deinit_soc_resources()
+ *
+ * @brief: csid de initialization function for the soc info
+ *
+ * @soc_info: soc info structure pointer
+ *
+ */
+int cam_ife_csid_deinit_soc_resources(struct cam_hw_soc_info *soc_info);
+
/**
* cam_ife_csid_enable_soc_resources()
*
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_ife_csid_hw_intf.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_ife_csid_hw_intf.h
index ecc6f0e..52b712a 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_ife_csid_hw_intf.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/include/cam_ife_csid_hw_intf.h
@@ -69,6 +69,7 @@ struct cam_ife_csid_hw_caps {
* if type is path then res id need to be filled
* @res_id : res id to be reserved
* @in_port : input port resource info
+ * @out_port: output port resource info, used for RDI path only
* @sync_mode : Sync mode
* Sync mode could be master, slave or none
* @master_idx: master device index to be configured in the slave path
@@ -83,6 +84,7 @@ struct cam_csid_hw_reserve_resource_args {
enum cam_isp_resource_type res_type;
uint32_t res_id;
struct cam_isp_in_port_info *in_port;
+ struct cam_isp_out_port_info *out_port;
enum cam_isp_hw_sync_mode sync_mode;
uint32_t master_idx;
uint32_t cid;
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c
index e25d973..e330c84 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/list.h>
@@ -24,9 +22,7 @@
#include "cam_vfe_bus.h"
#include "cam_vfe_top.h"
#include "cam_ife_hw_mgr.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
static const char drv_name[] = "vfe";
@@ -58,7 +54,7 @@ static int cam_vfe_get_evt_payload(struct cam_vfe_hw_core_info *core_info,
if (list_empty(&core_info->free_payload_list)) {
*evt_payload = NULL;
spin_unlock(&core_info->spin_lock);
- pr_err_ratelimited("No free payload, core info 0x%x\n",
+ CAM_ERR_RATE_LIMIT(CAM_ISP, "No free payload, core info 0x%x\n",
core_info->cpas_handle);
return -ENODEV;
}
@@ -78,11 +74,11 @@ int cam_vfe_put_evt_payload(void *core_info,
unsigned long flags;
if (!core_info) {
- pr_err("Invalid param core_info NULL");
+ CAM_ERR(CAM_ISP, "Invalid param core_info NULL");
return -EINVAL;
}
if (*evt_payload == NULL) {
- pr_err("No payload to put\n");
+ CAM_ERR(CAM_ISP, "No payload to put");
return -EINVAL;
}
@@ -100,9 +96,9 @@ int cam_vfe_get_hw_caps(void *hw_priv, void *get_hw_cap_args, uint32_t arg_size)
struct cam_vfe_hw_core_info *core_info = NULL;
int rc = 0;
- CDBG("Enter\n");
+ CAM_DBG(CAM_ISP, "Enter");
if (!hw_priv) {
- pr_err("%s: Invalid arguments\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
@@ -113,7 +109,7 @@ int cam_vfe_get_hw_caps(void *hw_priv, void *get_hw_cap_args, uint32_t arg_size)
core_info->vfe_top->top_priv,
get_hw_cap_args, arg_size);
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -125,11 +121,11 @@ int cam_vfe_reset_irq_top_half(uint32_t evt_id,
handler_priv = th_payload->handler_priv;
- CDBG("Enter\n");
- CDBG("IRQ status_0 = 0x%x\n", th_payload->evt_status_arr[0]);
+ CAM_DBG(CAM_ISP, "Enter");
+ CAM_DBG(CAM_ISP, "IRQ status_0 = 0x%x", th_payload->evt_status_arr[0]);
if (th_payload->evt_status_arr[0] & (1<<31)) {
- CDBG("Calling Complete for RESET CMD\n");
+ CAM_DBG(CAM_ISP, "Calling Complete for RESET CMD");
complete(handler_priv->reset_complete);
/*
@@ -143,7 +139,7 @@ int cam_vfe_reset_irq_top_half(uint32_t evt_id,
rc = 0;
}
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -154,9 +150,9 @@ int cam_vfe_init_hw(void *hw_priv, void *init_hw_args, uint32_t arg_size)
struct cam_vfe_hw_core_info *core_info = NULL;
int rc = 0;
- CDBG("Enter\n");
+ CAM_DBG(CAM_ISP, "Enter");
if (!hw_priv) {
- pr_err("Invalid arguments\n");
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
@@ -164,7 +160,7 @@ int cam_vfe_init_hw(void *hw_priv, void *init_hw_args, uint32_t arg_size)
vfe_hw->open_count++;
if (vfe_hw->open_count > 1) {
mutex_unlock(&vfe_hw->hw_mutex);
- CDBG("VFE has already been initialized cnt %d\n",
+ CAM_DBG(CAM_ISP, "VFE has already been initialized cnt %d",
vfe_hw->open_count);
return 0;
}
@@ -176,24 +172,24 @@ int cam_vfe_init_hw(void *hw_priv, void *init_hw_args, uint32_t arg_size)
/* Turn ON Regulators, Clocks and other SOC resources */
rc = cam_vfe_enable_soc_resources(soc_info);
if (rc) {
- pr_err("Enable SOC failed\n");
+ CAM_ERR(CAM_ISP, "Enable SOC failed");
rc = -EFAULT;
goto decrement_open_cnt;
}
- CDBG("Enable soc done\n");
+ CAM_DBG(CAM_ISP, "Enable soc done");
rc = core_info->vfe_bus->hw_ops.init(core_info->vfe_bus->bus_priv,
NULL, 0);
if (rc) {
- pr_err("Bus HW init Failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Bus HW init Failed rc=%d", rc);
goto disable_soc;
}
/* Do HW Reset */
rc = cam_vfe_reset(hw_priv, NULL, 0);
if (rc) {
- pr_err("Reset Failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Reset Failed rc=%d", rc);
goto deinit_bus;
}
@@ -217,22 +213,22 @@ int cam_vfe_deinit_hw(void *hw_priv, void *deinit_hw_args, uint32_t arg_size)
struct cam_hw_soc_info *soc_info = NULL;
int rc = 0;
- CDBG("Enter\n");
+ CAM_DBG(CAM_ISP, "Enter");
if (!hw_priv) {
- pr_err("%s: Invalid arguments\n", __func__);
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
mutex_lock(&vfe_hw->hw_mutex);
if (!vfe_hw->open_count) {
mutex_unlock(&vfe_hw->hw_mutex);
- pr_err("Error! Unbalanced deinit\n");
+ CAM_ERR(CAM_ISP, "Error! Unbalanced deinit");
return -EFAULT;
}
vfe_hw->open_count--;
if (vfe_hw->open_count) {
mutex_unlock(&vfe_hw->hw_mutex);
- CDBG("open_cnt non-zero =%d\n", vfe_hw->open_count);
+ CAM_DBG(CAM_ISP, "open_cnt non-zero =%d", vfe_hw->open_count);
return 0;
}
mutex_unlock(&vfe_hw->hw_mutex);
@@ -240,14 +236,14 @@ int cam_vfe_deinit_hw(void *hw_priv, void *deinit_hw_args, uint32_t arg_size)
soc_info = &vfe_hw->soc_info;
/* Turn OFF Regulators, Clocks and other SOC resources */
- CDBG("Disable SOC resource\n");
+ CAM_DBG(CAM_ISP, "Disable SOC resource");
rc = cam_vfe_disable_soc_resources(soc_info);
if (rc)
- pr_err("Disable SOC failed\n");
+ CAM_ERR(CAM_ISP, "Disable SOC failed");
vfe_hw->hw_state = CAM_HW_STATE_POWER_DOWN;
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -258,10 +254,10 @@ int cam_vfe_reset(void *hw_priv, void *reset_core_args, uint32_t arg_size)
struct cam_vfe_hw_core_info *core_info = NULL;
int rc;
- CDBG("Enter\n");
+ CAM_DBG(CAM_ISP, "Enter");
if (!hw_priv) {
- pr_err("Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Invalid input arguments");
return -EINVAL;
}
@@ -279,28 +275,28 @@ int cam_vfe_reset(void *hw_priv, void *reset_core_args, uint32_t arg_size)
top_reset_irq_reg_mask, &core_info->irq_payload,
cam_vfe_reset_irq_top_half, NULL, NULL, NULL);
if (core_info->irq_handle < 0) {
- pr_err("subscribe irq controller failed\n");
+ CAM_ERR(CAM_ISP, "subscribe irq controller failed");
return -EFAULT;
}
reinit_completion(&vfe_hw->hw_complete);
- CDBG("calling RESET\n");
+ CAM_DBG(CAM_ISP, "calling RESET");
core_info->vfe_top->hw_ops.reset(core_info->vfe_top->top_priv, NULL, 0);
- CDBG("waiting for vfe reset complete\n");
+ CAM_DBG(CAM_ISP, "waiting for vfe reset complete");
/* Wait for Completion or Timeout of 500ms */
rc = wait_for_completion_timeout(&vfe_hw->hw_complete, 500);
if (!rc)
- pr_err("Error! Reset Timeout\n");
+ CAM_ERR(CAM_ISP, "Error! Reset Timeout");
- CDBG("reset complete done (%d)\n", rc);
+ CAM_DBG(CAM_ISP, "reset complete done (%d)", rc);
rc = cam_irq_controller_unsubscribe_irq(
core_info->vfe_irq_controller, core_info->irq_handle);
if (rc)
- pr_err("Error! Unsubscribe failed\n");
+ CAM_ERR(CAM_ISP, "Error! Unsubscribe failed");
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -324,12 +320,13 @@ int cam_vfe_irq_top_half(uint32_t evt_id,
handler_priv = th_payload->handler_priv;
- CDBG("IRQ status_0 = %x\n", th_payload->evt_status_arr[0]);
- CDBG("IRQ status_1 = %x\n", th_payload->evt_status_arr[1]);
+ CAM_DBG(CAM_ISP, "IRQ status_0 = %x", th_payload->evt_status_arr[0]);
+ CAM_DBG(CAM_ISP, "IRQ status_1 = %x", th_payload->evt_status_arr[1]);
rc = cam_vfe_get_evt_payload(handler_priv->core_info, &evt_payload);
if (rc) {
- pr_err_ratelimited("No tasklet_cmd is free in queue\n");
+ CAM_ERR_RATE_LIMIT(CAM_ISP,
+ "No tasklet_cmd is free in queue\n");
return rc;
}
@@ -346,14 +343,14 @@ int cam_vfe_irq_top_half(uint32_t evt_id,
evt_payload->irq_reg_val[i] = cam_io_r(handler_priv->mem_base +
irq_reg_offset[i]);
}
- CDBG("Violation status = %x\n", evt_payload->irq_reg_val[2]);
+ CAM_DBG(CAM_ISP, "Violation status = %x", evt_payload->irq_reg_val[2]);
/*
* need to handle overflow condition here, otherwise irq storm
* will block everything.
*/
if (evt_payload->irq_reg_val[1]) {
- pr_err("Mask all the interrupts\n");
+ CAM_ERR(CAM_ISP, "Mask all the interrupts");
cam_io_w(0, handler_priv->mem_base + 0x60);
cam_io_w(0, handler_priv->mem_base + 0x5C);
@@ -362,7 +359,7 @@ int cam_vfe_irq_top_half(uint32_t evt_id,
th_payload->evt_payload_priv = evt_payload;
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -376,7 +373,7 @@ int cam_vfe_reserve(void *hw_priv, void *reserve_args, uint32_t arg_size)
if (!hw_priv || !reserve_args || (arg_size !=
sizeof(struct cam_vfe_acquire_args))) {
- pr_err("Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Invalid input arguments");
return -EINVAL;
}
core_info = (struct cam_vfe_hw_core_info *)vfe_hw->core_info;
@@ -393,7 +390,7 @@ int cam_vfe_reserve(void *hw_priv, void *reserve_args, uint32_t arg_size)
core_info->vfe_bus->bus_priv, acquire,
sizeof(*acquire));
else
- pr_err("Invalid res type:%d\n", acquire->rsrc_type);
+ CAM_ERR(CAM_ISP, "Invalid res type:%d", acquire->rsrc_type);
mutex_unlock(&vfe_hw->hw_mutex);
@@ -410,7 +407,7 @@ int cam_vfe_release(void *hw_priv, void *release_args, uint32_t arg_size)
if (!hw_priv || !release_args ||
(arg_size != sizeof(struct cam_isp_resource_node))) {
- pr_err("Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Invalid input arguments");
return -EINVAL;
}
@@ -427,7 +424,7 @@ int cam_vfe_release(void *hw_priv, void *release_args, uint32_t arg_size)
core_info->vfe_bus->bus_priv, isp_res,
sizeof(*isp_res));
else
- pr_err("Invalid res type:%d\n", isp_res->res_type);
+ CAM_ERR(CAM_ISP, "Invalid res type:%d", isp_res->res_type);
mutex_unlock(&vfe_hw->hw_mutex);
@@ -444,7 +441,7 @@ int cam_vfe_start(void *hw_priv, void *start_args, uint32_t arg_size)
if (!hw_priv || !start_args ||
(arg_size != sizeof(struct cam_isp_resource_node))) {
- pr_err("Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Invalid input arguments");
return -EINVAL;
}
@@ -473,11 +470,12 @@ int cam_vfe_start(void *hw_priv, void *start_args, uint32_t arg_size)
core_info->vfe_top->top_priv, isp_res,
sizeof(struct cam_isp_resource_node));
else
- pr_err("Error! subscribe irq controller failed\n");
+ CAM_ERR(CAM_ISP,
+ "Error! subscribe irq controller failed");
} else if (isp_res->res_type == CAM_ISP_RESOURCE_VFE_OUT) {
rc = core_info->vfe_bus->hw_ops.start(isp_res, NULL, 0);
} else {
- pr_err("Invalid res type:%d\n", isp_res->res_type);
+ CAM_ERR(CAM_ISP, "Invalid res type:%d", isp_res->res_type);
}
mutex_unlock(&vfe_hw->hw_mutex);
@@ -494,7 +492,7 @@ int cam_vfe_stop(void *hw_priv, void *stop_args, uint32_t arg_size)
if (!hw_priv || !stop_args ||
(arg_size != sizeof(struct cam_isp_resource_node))) {
- pr_err("Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Invalid input arguments");
return -EINVAL;
}
@@ -513,7 +511,7 @@ int cam_vfe_stop(void *hw_priv, void *stop_args, uint32_t arg_size)
core_info->vfe_irq_controller, isp_res->irq_handle);
rc = core_info->vfe_bus->hw_ops.stop(isp_res, NULL, 0);
} else {
- pr_err("Invalid res type:%d\n", isp_res->res_type);
+ CAM_ERR(CAM_ISP, "Invalid res type:%d", isp_res->res_type);
}
mutex_unlock(&vfe_hw->hw_mutex);
@@ -541,7 +539,7 @@ int cam_vfe_process_cmd(void *hw_priv, uint32_t cmd_type,
int rc = 0;
if (!hw_priv) {
- pr_err("Invalid arguments\n");
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
@@ -564,7 +562,7 @@ int cam_vfe_process_cmd(void *hw_priv, uint32_t cmd_type,
break;
default:
- pr_err("Invalid cmd type:%d\n", cmd_type);
+ CAM_ERR(CAM_ISP, "Invalid cmd type:%d", cmd_type);
rc = -EINVAL;
break;
}
@@ -594,13 +592,13 @@ int cam_vfe_core_init(struct cam_vfe_hw_core_info *core_info,
int rc = -EINVAL;
int i;
- CDBG("Enter");
+ CAM_DBG(CAM_ISP, "Enter");
rc = cam_irq_controller_init(drv_name,
CAM_SOC_GET_REG_MAP_START(soc_info, VFE_CORE_BASE_IDX),
vfe_hw_info->irq_reg_info, &core_info->vfe_irq_controller);
if (rc) {
- pr_err("Error! cam_irq_controller_init failed\n");
+ CAM_ERR(CAM_ISP, "Error! cam_irq_controller_init failed");
return rc;
}
@@ -608,7 +606,7 @@ int cam_vfe_core_init(struct cam_vfe_hw_core_info *core_info,
soc_info, hw_intf, vfe_hw_info->top_hw_info,
&core_info->vfe_top);
if (rc) {
- pr_err("Error! cam_vfe_top_init failed\n");
+ CAM_ERR(CAM_ISP, "Error! cam_vfe_top_init failed");
goto deinit_controller;
}
@@ -616,7 +614,7 @@ int cam_vfe_core_init(struct cam_vfe_hw_core_info *core_info,
vfe_hw_info->bus_hw_info, core_info->vfe_irq_controller,
&core_info->vfe_bus);
if (rc) {
- pr_err("Error! cam_vfe_bus_init failed\n");
+ CAM_ERR(CAM_ISP, "Error! cam_vfe_bus_init failed");
goto deinit_top;
}
@@ -657,16 +655,17 @@ int cam_vfe_core_deinit(struct cam_vfe_hw_core_info *core_info,
rc = cam_vfe_bus_deinit(vfe_hw_info->bus_version,
&core_info->vfe_bus);
if (rc)
- pr_err("Error cam_vfe_bus_deinit failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Error cam_vfe_bus_deinit failed rc=%d", rc);
rc = cam_vfe_top_deinit(vfe_hw_info->top_version,
&core_info->vfe_top);
if (rc)
- pr_err("Error cam_vfe_top_deinit failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Error cam_vfe_top_deinit failed rc=%d", rc);
rc = cam_irq_controller_deinit(&core_info->vfe_irq_controller);
if (rc)
- pr_err("Error cam_irq_controller_deinit failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP,
+ "Error cam_irq_controller_deinit failed rc=%d", rc);
spin_unlock_irqrestore(&core_info->spin_lock, flags);
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c
index cdb8d6f..3e2307c 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_dev.c
@@ -10,7 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
#include <linux/slab.h>
#include <linux/mod_devicetable.h>
@@ -18,9 +17,7 @@
#include "cam_vfe_dev.h"
#include "cam_vfe_core.h"
#include "cam_vfe_soc.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
static struct cam_hw_intf *cam_vfe_hw_list[CAM_VFE_HW_NUM_MAX] = {0, 0, 0, 0};
@@ -62,14 +59,15 @@ int cam_vfe_probe(struct platform_device *pdev)
vfe_hw_intf->hw_ops.process_cmd = cam_vfe_process_cmd;
vfe_hw_intf->hw_type = CAM_ISP_HW_TYPE_VFE;
- CDBG("type %d index %d\n", vfe_hw_intf->hw_type, vfe_hw_intf->hw_idx);
+ CAM_DBG(CAM_ISP, "type %d index %d",
+ vfe_hw_intf->hw_type, vfe_hw_intf->hw_idx);
platform_set_drvdata(pdev, vfe_hw_intf);
vfe_hw->core_info = kzalloc(sizeof(struct cam_vfe_hw_core_info),
GFP_KERNEL);
if (!vfe_hw->core_info) {
- CDBG("Failed to alloc for core\n");
+ CAM_DBG(CAM_ISP, "Failed to alloc for core");
rc = -ENOMEM;
goto free_vfe_hw;
}
@@ -78,7 +76,7 @@ int cam_vfe_probe(struct platform_device *pdev)
match_dev = of_match_device(pdev->dev.driver->of_match_table,
&pdev->dev);
if (!match_dev) {
- pr_err("Of_match Failed\n");
+ CAM_ERR(CAM_ISP, "Of_match Failed");
rc = -EINVAL;
goto free_core_info;
}
@@ -88,14 +86,14 @@ int cam_vfe_probe(struct platform_device *pdev)
rc = cam_vfe_init_soc_resources(&vfe_hw->soc_info, cam_vfe_irq,
vfe_hw);
if (rc < 0) {
- pr_err("Failed to init soc rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Failed to init soc rc=%d", rc);
goto free_core_info;
}
rc = cam_vfe_core_init(core_info, &vfe_hw->soc_info,
vfe_hw_intf, hw_info);
if (rc < 0) {
- pr_err("Failed to init core rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Failed to init core rc=%d", rc);
goto deinit_soc;
}
@@ -110,13 +108,13 @@ int cam_vfe_probe(struct platform_device *pdev)
cam_vfe_init_hw(vfe_hw, NULL, 0);
cam_vfe_deinit_hw(vfe_hw, NULL, 0);
- CDBG("VFE%d probe successful\n", vfe_hw_intf->hw_idx);
+ CAM_DBG(CAM_ISP, "VFE%d probe successful", vfe_hw_intf->hw_idx);
return rc;
deinit_soc:
if (cam_vfe_deinit_soc_resources(&vfe_hw->soc_info))
- pr_err("Failed to deinit soc\n");
+ CAM_ERR(CAM_ISP, "Failed to deinit soc");
free_core_info:
kfree(vfe_hw->core_info);
free_vfe_hw:
@@ -136,44 +134,45 @@ int cam_vfe_remove(struct platform_device *pdev)
vfe_hw_intf = platform_get_drvdata(pdev);
if (!vfe_hw_intf) {
- pr_err("Error! No data in pdev\n");
+ CAM_ERR(CAM_ISP, "Error! No data in pdev");
return -EINVAL;
}
- CDBG("type %d index %d\n", vfe_hw_intf->hw_type, vfe_hw_intf->hw_idx);
+ CAM_DBG(CAM_ISP, "type %d index %d",
+ vfe_hw_intf->hw_type, vfe_hw_intf->hw_idx);
if (vfe_hw_intf->hw_idx < CAM_VFE_HW_NUM_MAX)
cam_vfe_hw_list[vfe_hw_intf->hw_idx] = NULL;
vfe_hw = vfe_hw_intf->hw_priv;
if (!vfe_hw) {
- pr_err("Error! HW data is NULL\n");
+ CAM_ERR(CAM_ISP, "Error! HW data is NULL");
rc = -ENODEV;
goto free_vfe_hw_intf;
}
core_info = (struct cam_vfe_hw_core_info *)vfe_hw->core_info;
if (!core_info) {
- pr_err("Error! core data NULL");
+ CAM_ERR(CAM_ISP, "Error! core data NULL");
rc = -EINVAL;
goto deinit_soc;
}
rc = cam_vfe_core_deinit(core_info, core_info->vfe_hw_info);
if (rc < 0)
- pr_err("Failed to deinit core rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Failed to deinit core rc=%d", rc);
kfree(vfe_hw->core_info);
deinit_soc:
rc = cam_vfe_deinit_soc_resources(&vfe_hw->soc_info);
if (rc < 0)
- pr_err("Failed to deinit soc rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Failed to deinit soc rc=%d", rc);
mutex_destroy(&vfe_hw->hw_mutex);
kfree(vfe_hw);
- CDBG("VFE%d remove successful\n", vfe_hw_intf->hw_idx);
+ CAM_DBG(CAM_ISP, "VFE%d remove successful", vfe_hw_intf->hw_idx);
free_vfe_hw_intf:
kfree(vfe_hw_intf);
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_soc.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_soc.c
index fa9d86b..3b2ead2 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_soc.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_soc.c
@@ -10,14 +10,10 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
#include <linux/slab.h>
#include "cam_cpas_api.h"
#include "cam_vfe_soc.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
static int cam_vfe_get_dt_properties(struct cam_hw_soc_info *soc_info)
{
@@ -25,7 +21,7 @@ static int cam_vfe_get_dt_properties(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_get_dt_properties(soc_info);
if (rc) {
- pr_err("Error! get DT properties failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Error! get DT properties failed rc=%d", rc);
return rc;
}
@@ -41,7 +37,8 @@ static int cam_vfe_request_platform_resource(
rc = cam_soc_util_request_platform_resource(soc_info, vfe_irq_handler,
irq_data);
if (rc)
- pr_err("Error! Request platform resource failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP,
+ "Error! Request platform resource failed rc=%d", rc);
return rc;
}
@@ -52,7 +49,8 @@ static int cam_vfe_release_platform_resource(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_release_platform_resource(soc_info);
if (rc)
- pr_err("Error! Release platform resource failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP,
+ "Error! Release platform resource failed rc=%d", rc);
return rc;
}
@@ -67,21 +65,22 @@ int cam_vfe_init_soc_resources(struct cam_hw_soc_info *soc_info,
soc_private = kzalloc(sizeof(struct cam_vfe_soc_private),
GFP_KERNEL);
if (!soc_private) {
- CDBG("Error! soc_private Alloc Failed\n");
+ CAM_DBG(CAM_ISP, "Error! soc_private Alloc Failed");
return -ENOMEM;
}
soc_info->soc_private = soc_private;
rc = cam_vfe_get_dt_properties(soc_info);
if (rc < 0) {
- pr_err("Error! Get DT properties failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Error! Get DT properties failed rc=%d", rc);
goto free_soc_private;
}
rc = cam_vfe_request_platform_resource(soc_info, vfe_irq_handler,
irq_data);
if (rc < 0) {
- pr_err("Error! Request platform resources failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP,
+ "Error! Request platform resources failed rc=%d", rc);
goto free_soc_private;
}
@@ -92,7 +91,7 @@ int cam_vfe_init_soc_resources(struct cam_hw_soc_info *soc_info,
cpas_register_param.dev = &soc_info->pdev->dev;
rc = cam_cpas_register_client(&cpas_register_param);
if (rc) {
- pr_err("CPAS registration failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "CPAS registration failed rc=%d", rc);
goto release_soc;
} else {
soc_private->cpas_handle = cpas_register_param.client_handle;
@@ -114,23 +113,24 @@ int cam_vfe_deinit_soc_resources(struct cam_hw_soc_info *soc_info)
struct cam_vfe_soc_private *soc_private;
if (!soc_info) {
- pr_err("Error! soc_info NULL\n");
+ CAM_ERR(CAM_ISP, "Error! soc_info NULL");
return -ENODEV;
}
soc_private = soc_info->soc_private;
if (!soc_private) {
- pr_err("Error! soc_private NULL\n");
+ CAM_ERR(CAM_ISP, "Error! soc_private NULL");
return -ENODEV;
}
rc = cam_cpas_unregister_client(soc_private->cpas_handle);
if (rc)
- pr_err("CPAS unregistration failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "CPAS unregistration failed rc=%d", rc);
rc = cam_vfe_release_platform_resource(soc_info);
if (rc < 0)
- pr_err("Error! Release platform resources failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP,
+ "Error! Release platform resources failed rc=%d", rc);
kfree(soc_private);
@@ -145,7 +145,7 @@ int cam_vfe_enable_soc_resources(struct cam_hw_soc_info *soc_info)
struct cam_axi_vote axi_vote;
if (!soc_info) {
- pr_err("Error! Invalid params\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid params");
rc = -EINVAL;
goto end;
}
@@ -159,7 +159,7 @@ int cam_vfe_enable_soc_resources(struct cam_hw_soc_info *soc_info)
rc = cam_cpas_start(soc_private->cpas_handle, &ahb_vote, &axi_vote);
if (rc) {
- pr_err("Error! CPAS start failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Error! CPAS start failed rc=%d", rc);
rc = -EFAULT;
goto end;
}
@@ -167,7 +167,7 @@ int cam_vfe_enable_soc_resources(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_enable_platform_resource(soc_info, true,
CAM_TURBO_VOTE, true);
if (rc) {
- pr_err("Error! enable platform failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Error! enable platform failed rc=%d", rc);
goto stop_cpas;
}
@@ -186,7 +186,7 @@ int cam_vfe_disable_soc_resources(struct cam_hw_soc_info *soc_info)
struct cam_vfe_soc_private *soc_private;
if (!soc_info) {
- pr_err("Error! Invalid params\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid params");
rc = -EINVAL;
return rc;
}
@@ -194,13 +194,13 @@ int cam_vfe_disable_soc_resources(struct cam_hw_soc_info *soc_info)
rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
if (rc) {
- pr_err("Disable platform failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Disable platform failed rc=%d", rc);
return rc;
}
rc = cam_cpas_stop(soc_private->cpas_handle);
if (rc) {
- pr_err("Error! CPAS stop failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Error! CPAS stop failed rc=%d", rc);
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.c
index 0ac5f6d..0af32ad 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.c
@@ -16,9 +16,6 @@
#include "cam_vfe_core.h"
#include "cam_vfe_dev.h"
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-
static const struct of_device_id cam_vfe170_dt_match[] = {
{
.compatible = "qcom,vfe170",
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h
index b550071..275c7b5 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe170/cam_vfe170.h
@@ -117,6 +117,28 @@ static struct cam_vfe_top_ver2_reg_offset_common vfe170_top_common_reg = {
.reg_update_cmd = 0x000004AC,
};
+static struct cam_vfe_rdi_ver2_reg vfe170_rdi_reg = {
+ .reg_update_cmd = 0x000004AC,
+};
+
+static struct cam_vfe_rdi_reg_data vfe_170_rdi_0_data = {
+ .reg_update_cmd_data = 0x2,
+ .sof_irq_mask = 0x8000000,
+ .reg_update_irq_mask = 0x20,
+};
+
+static struct cam_vfe_rdi_reg_data vfe_170_rdi_1_data = {
+ .reg_update_cmd_data = 0x4,
+ .sof_irq_mask = 0x10000000,
+ .reg_update_irq_mask = 0x40,
+};
+
+static struct cam_vfe_rdi_reg_data vfe_170_rdi_2_data = {
+ .reg_update_cmd_data = 0x8,
+ .sof_irq_mask = 0x20000000,
+ .reg_update_irq_mask = 0x80,
+};
+
static struct cam_vfe_top_ver2_hw_info vfe170_top_hw_info = {
.common_reg = &vfe170_top_common_reg,
.camif_hw_info = {
@@ -124,6 +146,16 @@ static struct cam_vfe_top_ver2_hw_info vfe170_top_hw_info = {
.camif_reg = &vfe170_camif_reg,
.reg_data = &vfe_170_camif_reg_data,
},
+ .rdi_hw_info = {
+ .common_reg = &vfe170_top_common_reg,
+ .rdi_reg = &vfe170_rdi_reg,
+ .reg_data = {
+ &vfe_170_rdi_0_data,
+ &vfe_170_rdi_1_data,
+ &vfe_170_rdi_2_data,
+ NULL,
+ },
+ },
.mux_type = {
CAM_VFE_CAMIF_VER_2_0,
CAM_VFE_RDI_VER_1_0,
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus.c
index 63ca5c2..c6c3272 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus.c
@@ -10,11 +10,10 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
#include "cam_vfe_bus.h"
#include "cam_vfe_bus_ver1.h"
#include "cam_vfe_bus_ver2.h"
+#include "cam_debug_util.h"
int cam_vfe_bus_init(uint32_t bus_version,
struct cam_hw_soc_info *soc_info,
@@ -31,7 +30,7 @@ int cam_vfe_bus_init(uint32_t bus_version,
vfe_irq_controller, vfe_bus);
break;
default:
- pr_err("Unsupported Bus Version %x\n", bus_version);
+ CAM_ERR(CAM_ISP, "Unsupported Bus Version %x", bus_version);
break;
}
@@ -48,7 +47,7 @@ int cam_vfe_bus_deinit(uint32_t bus_version,
rc = cam_vfe_bus_ver2_deinit(vfe_bus);
break;
default:
- pr_err("Unsupported Bus Version %x\n", bus_version);
+ CAM_ERR(CAM_ISP, "Unsupported Bus Version %x", bus_version);
break;
}
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.c
index 489689c..f37ec38 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
#include <linux/ratelimit.h>
#include <linux/slab.h>
#include "cam_io_util.h"
@@ -24,9 +22,7 @@
#include "cam_vfe_bus.h"
#include "cam_vfe_bus_ver2.h"
#include "cam_vfe_core.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
static const char drv_name[] = "vfe_bus";
@@ -37,6 +33,9 @@ static const char drv_name[] = "vfe_bus";
#define CAM_VFE_BUS_VER2_PAYLOAD_MAX 256
+#define CAM_VFE_RDI_BUS_DEFAULT_WIDTH 0xFF01
+#define CAM_VFE_RDI_BUS_DEFAULT_STRIDE 0xFF01
+
#define MAX_BUF_UPDATE_REG_NUM \
(sizeof(struct cam_vfe_bus_ver2_reg_offset_bus_client)/4)
#define MAX_REG_VAL_PAIR_SIZE \
@@ -174,7 +173,7 @@ static int cam_vfe_bus_get_evt_payload(
{
if (list_empty(&common_data->free_payload_list)) {
*evt_payload = NULL;
- pr_err("No free payload\n");
+ CAM_ERR(CAM_ISP, "No free payload");
return -ENODEV;
}
@@ -192,11 +191,11 @@ static int cam_vfe_bus_put_evt_payload(void *core_info,
uint32_t status_reg0, status_reg1, status_reg2;
if (!core_info) {
- pr_err("Invalid param core_info NULL");
+ CAM_ERR(CAM_ISP, "Invalid param core_info NULL");
return -EINVAL;
}
if (*evt_payload == NULL) {
- pr_err("No payload to put\n");
+ CAM_ERR(CAM_ISP, "No payload to put");
return -EINVAL;
}
@@ -206,7 +205,7 @@ static int cam_vfe_bus_put_evt_payload(void *core_info,
status_reg2 = ife_irq_regs[CAM_IFE_IRQ_BUS_REG_STATUS2];
if (status_reg0 || status_reg1 || status_reg2) {
- CDBG("status0 0x%x status1 0x%x status2 0x%x\n",
+ CAM_DBG(CAM_ISP, "status0 0x%x status1 0x%x status2 0x%x",
status_reg0, status_reg1, status_reg2);
return 0;
}
@@ -229,7 +228,8 @@ static int cam_vfe_bus_ver2_get_intra_client_mask(
*intra_client_mask = 0;
if (dual_slave_core == current_core) {
- pr_err("Invalid params. Same core as Master and Slave\n");
+ CAM_ERR(CAM_ISP,
+ "Invalid params. Same core as Master and Slave");
return -EINVAL;
}
@@ -243,7 +243,7 @@ static int cam_vfe_bus_ver2_get_intra_client_mask(
*intra_client_mask = 0x2;
break;
default:
- pr_err("Invalid value for slave core %u\n",
+ CAM_ERR(CAM_ISP, "Invalid value for slave core %u",
dual_slave_core);
rc = -EINVAL;
break;
@@ -258,7 +258,7 @@ static int cam_vfe_bus_ver2_get_intra_client_mask(
*intra_client_mask = 0x2;
break;
default:
- pr_err("Invalid value for slave core %u\n",
+ CAM_ERR(CAM_ISP, "Invalid value for slave core %u",
dual_slave_core);
rc = -EINVAL;
break;
@@ -273,14 +273,15 @@ static int cam_vfe_bus_ver2_get_intra_client_mask(
*intra_client_mask = 0x2;
break;
default:
- pr_err("Invalid value for slave core %u\n",
+ CAM_ERR(CAM_ISP, "Invalid value for slave core %u",
dual_slave_core);
rc = -EINVAL;
break;
}
break;
default:
- pr_err("Invalid value for master core %u\n", current_core);
+ CAM_ERR(CAM_ISP,
+ "Invalid value for master core %u", current_core);
rc = -EINVAL;
break;
}
@@ -348,6 +349,19 @@ static int cam_vfe_bus_get_num_wm(
case CAM_FORMAT_MIPI_RAW_14:
case CAM_FORMAT_MIPI_RAW_16:
case CAM_FORMAT_MIPI_RAW_20:
+ case CAM_FORMAT_DPCM_10_6_10:
+ case CAM_FORMAT_DPCM_10_8_10:
+ case CAM_FORMAT_DPCM_12_6_12:
+ case CAM_FORMAT_DPCM_12_8_12:
+ case CAM_FORMAT_DPCM_14_8_14:
+ case CAM_FORMAT_DPCM_14_10_14:
+ case CAM_FORMAT_PLAIN8:
+ case CAM_FORMAT_PLAIN16_8:
+ case CAM_FORMAT_PLAIN16_10:
+ case CAM_FORMAT_PLAIN16_12:
+ case CAM_FORMAT_PLAIN16_14:
+ case CAM_FORMAT_PLAIN16_16:
+ case CAM_FORMAT_PLAIN32_20:
case CAM_FORMAT_PLAIN128:
return 1;
default:
@@ -442,7 +456,8 @@ static int cam_vfe_bus_get_num_wm(
break;
}
- pr_err("Unsupported format %u for resource_type %u", format, res_type);
+ CAM_ERR(CAM_ISP, "Unsupported format %u for resource_type %u",
+ format, res_type);
return -EINVAL;
}
@@ -636,8 +651,6 @@ static enum cam_vfe_bus_packer_format
case CAM_FORMAT_NV21:
case CAM_FORMAT_NV12:
return PACKER_FMT_PLAIN_8_LSB_MSB_10;
- case CAM_FORMAT_PLAIN16_16:
- return PACKER_FMT_PLAIN_16_16BPP;
case CAM_FORMAT_PLAIN64:
return PACKER_FMT_PLAIN_64;
case CAM_FORMAT_MIPI_RAW_6:
@@ -652,6 +665,13 @@ static enum cam_vfe_bus_packer_format
case CAM_FORMAT_QTI_RAW_12:
case CAM_FORMAT_QTI_RAW_14:
case CAM_FORMAT_PLAIN128:
+ case CAM_FORMAT_PLAIN8:
+ case CAM_FORMAT_PLAIN16_8:
+ case CAM_FORMAT_PLAIN16_10:
+ case CAM_FORMAT_PLAIN16_12:
+ case CAM_FORMAT_PLAIN16_14:
+ case CAM_FORMAT_PLAIN16_16:
+ case CAM_FORMAT_PLAIN32_20:
case CAM_FORMAT_PD8:
case CAM_FORMAT_PD10:
return PACKER_FMT_PLAIN_128;
@@ -682,7 +702,7 @@ static int cam_vfe_bus_acquire_wm(
/* No need to allocate for BUS VER2. VFE OUT to WM is fixed. */
wm_idx = cam_vfe_bus_get_wm_idx(vfe_out_res_id, plane);
if (wm_idx < 0 || wm_idx >= CAM_VFE_BUS_VER2_MAX_CLIENTS) {
- pr_err("Unsupported VFE out %d plane %d\n",
+ CAM_ERR(CAM_ISP, "Unsupported VFE out %d plane %d",
vfe_out_res_id, plane);
return -EINVAL;
}
@@ -701,8 +721,10 @@ static int cam_vfe_bus_acquire_wm(
rsrc_data->height = out_port_info->height;
if (rsrc_data->index < 3) {
- rsrc_data->width = rsrc_data->width * 5/4 * rsrc_data->height;
- rsrc_data->height = 1;
+ rsrc_data->width = CAM_VFE_RDI_BUS_DEFAULT_WIDTH;
+ rsrc_data->height = 0;
+ rsrc_data->stride = CAM_VFE_RDI_BUS_DEFAULT_STRIDE;
+ rsrc_data->pack_fmt = 0x0;
rsrc_data->en_cfg = 0x3;
} else if (rsrc_data->index < 5 ||
rsrc_data->index == 7 || rsrc_data->index == 8) {
@@ -735,7 +757,7 @@ static int cam_vfe_bus_acquire_wm(
}
break;
default:
- pr_err("Invalid plane type %d\n", plane);
+ CAM_ERR(CAM_ISP, "Invalid plane type %d", plane);
return -EINVAL;
}
rsrc_data->en_cfg = 0x1;
@@ -807,7 +829,6 @@ static int cam_vfe_bus_start_wm(struct cam_isp_resource_node *wm_res)
cam_io_w_mb(0, common_data->mem_base + rsrc_data->hw_regs->header_addr);
cam_io_w_mb(0, common_data->mem_base + rsrc_data->hw_regs->header_cfg);
- cam_io_w_mb(0, common_data->mem_base + rsrc_data->hw_regs->frame_inc);
cam_io_w(0xf, common_data->mem_base + rsrc_data->hw_regs->burst_limit);
cam_io_w_mb(rsrc_data->width,
@@ -817,19 +838,14 @@ static int cam_vfe_bus_start_wm(struct cam_isp_resource_node *wm_res)
cam_io_w(rsrc_data->pack_fmt,
common_data->mem_base + rsrc_data->hw_regs->packer_cfg);
- cam_io_w(0xFFFFFFFF, common_data->mem_base +
- rsrc_data->hw_regs->irq_subsample_pattern);
- cam_io_w(0x0, common_data->mem_base +
- rsrc_data->hw_regs->irq_subsample_period);
-
- cam_io_w(0xFFFFFFFF,
- common_data->mem_base + rsrc_data->hw_regs->framedrop_pattern);
- cam_io_w(0x0,
- common_data->mem_base + rsrc_data->hw_regs->framedrop_period);
+ /* Configure stride for RDIs */
+ if (rsrc_data->index < 3)
+ cam_io_w_mb(rsrc_data->stride, (common_data->mem_base +
+ rsrc_data->hw_regs->stride));
/* Subscribe IRQ */
if (rsrc_data->irq_enabled) {
- CDBG("Subscribe WM%d IRQ\n", rsrc_data->index);
+ CAM_DBG(CAM_ISP, "Subscribe WM%d IRQ", rsrc_data->index);
bus_irq_reg_mask[CAM_VFE_BUS_IRQ_REG1] =
(1 << rsrc_data->index);
wm_res->irq_handle = cam_irq_controller_subscribe_irq(
@@ -839,24 +855,31 @@ static int cam_vfe_bus_start_wm(struct cam_isp_resource_node *wm_res)
cam_ife_mgr_do_tasklet_buf_done,
wm_res->tasklet_info, cam_tasklet_enqueue_cmd);
if (wm_res->irq_handle < 0) {
- pr_err("Subscribe IRQ failed for WM %d\n",
+ CAM_ERR(CAM_ISP, "Subscribe IRQ failed for WM %d",
rsrc_data->index);
return -EFAULT;
}
}
+ /* enable ubwc if needed*/
+ if (rsrc_data->en_ubwc) {
+ cam_io_w_mb(0x1, common_data->mem_base +
+ rsrc_data->hw_regs->ubwc_regs->mode_cfg);
+ }
+
/* Enable WM */
cam_io_w_mb(rsrc_data->en_cfg, common_data->mem_base +
rsrc_data->hw_regs->cfg);
- CDBG("WM res %d width = %d, height = %d\n", rsrc_data->index,
+ CAM_DBG(CAM_ISP, "WM res %d width = %d, height = %d", rsrc_data->index,
rsrc_data->width, rsrc_data->height);
- CDBG("WM res %d pk_fmt = %d\n", rsrc_data->index,
+ CAM_DBG(CAM_ISP, "WM res %d pk_fmt = %d", rsrc_data->index,
rsrc_data->pack_fmt & PACKER_FMT_MAX);
- CDBG("WM res %d stride = %d, burst len = %d\n",
+ CAM_DBG(CAM_ISP, "WM res %d stride = %d, burst len = %d",
rsrc_data->index, rsrc_data->stride, 0xf);
- CDBG("enable WM res %d offset 0x%x val 0x%x\n", rsrc_data->index,
- (uint32_t) rsrc_data->hw_regs->cfg, rsrc_data->en_cfg);
+ CAM_DBG(CAM_ISP, "enable WM res %d offset 0x%x val 0x%x",
+ rsrc_data->index, (uint32_t) rsrc_data->hw_regs->cfg,
+ rsrc_data->en_cfg);
wm_res->res_state = CAM_ISP_RESOURCE_STATE_STREAMING;
@@ -875,7 +898,7 @@ static int cam_vfe_bus_stop_wm(struct cam_isp_resource_node *wm_res)
cam_io_w_mb(0x0,
common_data->mem_base + rsrc_data->hw_regs->cfg);
- CDBG("irq_enabled %d", rsrc_data->irq_enabled);
+ CAM_DBG(CAM_ISP, "irq_enabled %d", rsrc_data->irq_enabled);
/* Unsubscribe IRQ */
if (rsrc_data->irq_enabled)
rc = cam_irq_controller_unsubscribe_irq(
@@ -902,18 +925,19 @@ static int cam_vfe_bus_handle_wm_done_top_half(uint32_t evt_id,
wm_res = th_payload->handler_priv;
if (!wm_res) {
- pr_err_ratelimited("Error! No resource\n");
+ CAM_ERR_RATE_LIMIT(CAM_ISP, "Error! No resource\n");
return -ENODEV;
}
rsrc_data = wm_res->res_priv;
- CDBG("IRQ status_0 = %x\n", th_payload->evt_status_arr[0]);
- CDBG("IRQ status_1 = %x\n", th_payload->evt_status_arr[1]);
+ CAM_DBG(CAM_ISP, "IRQ status_0 = %x", th_payload->evt_status_arr[0]);
+ CAM_DBG(CAM_ISP, "IRQ status_1 = %x", th_payload->evt_status_arr[1]);
rc = cam_vfe_bus_get_evt_payload(rsrc_data->common_data, &evt_payload);
if (rc) {
- pr_err_ratelimited("No tasklet_cmd is free in queue\n");
+ CAM_ERR_RATE_LIMIT(CAM_ISP,
+ "No tasklet_cmd is free in queue\n");
return rc;
}
@@ -928,7 +952,7 @@ static int cam_vfe_bus_handle_wm_done_top_half(uint32_t evt_id,
th_payload->evt_payload_priv = evt_payload;
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -954,7 +978,7 @@ static int cam_vfe_bus_handle_wm_done_bottom_half(void *wm_node,
~BIT(rsrc_data->index);
rc = CAM_VFE_IRQ_STATUS_SUCCESS;
}
- CDBG("status_reg %x rc %d\n", status_reg, rc);
+ CAM_DBG(CAM_ISP, "status_reg %x rc %d", status_reg, rc);
if (rc == CAM_VFE_IRQ_STATUS_SUCCESS)
cam_vfe_bus_put_evt_payload(rsrc_data->common_data,
@@ -973,7 +997,7 @@ static int cam_vfe_bus_init_wm_resource(uint32_t index,
rsrc_data = kzalloc(sizeof(struct cam_vfe_bus_ver2_wm_resource_data),
GFP_KERNEL);
if (!rsrc_data) {
- CDBG("Failed to alloc for WM res priv\n");
+ CAM_DBG(CAM_ISP, "Failed to alloc for WM res priv");
return -ENOMEM;
}
wm_res->res_priv = rsrc_data;
@@ -1011,7 +1035,7 @@ static int cam_vfe_bus_deinit_wm_resource(
rsrc_data = wm_res->res_priv;
wm_res->res_priv = NULL;
if (!rsrc_data) {
- pr_err("Error! WM res priv is NULL\n");
+ CAM_ERR(CAM_ISP, "Error! WM res priv is NULL");
return -ENOMEM;
}
kfree(rsrc_data);
@@ -1074,7 +1098,7 @@ static int cam_vfe_bus_acquire_comp_grp(
/* First find a free group */
if (is_dual) {
if (list_empty(&ver2_bus_priv->free_dual_comp_grp)) {
- pr_err("No Free Composite Group\n");
+ CAM_ERR(CAM_ISP, "No Free Composite Group");
return -ENODEV;
}
comp_grp_local = list_first_entry(
@@ -1087,7 +1111,7 @@ static int cam_vfe_bus_acquire_comp_grp(
&rsrc_data->intra_client_mask);
} else {
if (list_empty(&ver2_bus_priv->free_comp_grp)) {
- pr_err("No Free Composite Group\n");
+ CAM_ERR(CAM_ISP, "No Free Composite Group");
return -ENODEV;
}
comp_grp_local = list_first_entry(
@@ -1113,7 +1137,7 @@ static int cam_vfe_bus_acquire_comp_grp(
/* Do not support runtime change in composite mask */
if (comp_grp_local->res_state ==
CAM_ISP_RESOURCE_STATE_STREAMING) {
- pr_err("Invalid State %d Comp Grp %u\n",
+ CAM_ERR(CAM_ISP, "Invalid State %d Comp Grp %u",
comp_grp_local->res_state,
rsrc_data->comp_grp_type);
return -EBUSY;
@@ -1135,7 +1159,7 @@ static int cam_vfe_bus_release_comp_grp(
int match_found = 0;
if (!in_comp_grp) {
- pr_err("Invalid Params Comp Grp %pK\n", in_rsrc_data);
+ CAM_ERR(CAM_ISP, "Invalid Params Comp Grp %pK", in_rsrc_data);
return -EINVAL;
}
@@ -1154,7 +1178,7 @@ static int cam_vfe_bus_release_comp_grp(
}
if (!match_found) {
- pr_err("Could not find matching Comp Grp type %u\n",
+ CAM_ERR(CAM_ISP, "Could not find matching Comp Grp type %u",
in_rsrc_data->comp_grp_type);
return -ENODEV;
}
@@ -1192,8 +1216,9 @@ static int cam_vfe_bus_start_comp_grp(struct cam_isp_resource_node *comp_grp)
cam_io_w_mb(rsrc_data->composite_mask, common_data->mem_base +
rsrc_data->hw_regs->comp_mask);
- CDBG("composite_mask is 0x%x\n", rsrc_data->composite_mask);
- CDBG("composite_mask addr 0x%x\n", rsrc_data->hw_regs->comp_mask);
+ CAM_DBG(CAM_ISP, "composite_mask is 0x%x", rsrc_data->composite_mask);
+ CAM_DBG(CAM_ISP, "composite_mask addr 0x%x",
+ rsrc_data->hw_regs->comp_mask);
if (rsrc_data->comp_grp_type >= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_0 &&
rsrc_data->comp_grp_type <= CAM_VFE_BUS_VER2_COMP_GRP_DUAL_5 &&
@@ -1218,7 +1243,7 @@ static int cam_vfe_bus_start_comp_grp(struct cam_isp_resource_node *comp_grp)
}
/* Subscribe IRQ */
- CDBG("Subscribe COMP_GRP%d IRQ\n", rsrc_data->comp_grp_type);
+ CAM_DBG(CAM_ISP, "Subscribe COMP_GRP%d IRQ", rsrc_data->comp_grp_type);
comp_grp->irq_handle = cam_irq_controller_subscribe_irq(
common_data->bus_irq_controller, CAM_IRQ_PRIORITY_1,
bus_irq_reg_mask, comp_grp,
@@ -1226,7 +1251,7 @@ static int cam_vfe_bus_start_comp_grp(struct cam_isp_resource_node *comp_grp)
cam_ife_mgr_do_tasklet_buf_done,
comp_grp->tasklet_info, cam_tasklet_enqueue_cmd);
if (comp_grp->irq_handle < 0) {
- pr_err("Subscribe IRQ failed for comp_grp %d\n",
+ CAM_ERR(CAM_ISP, "Subscribe IRQ failed for comp_grp %d",
rsrc_data->comp_grp_type);
return -EFAULT;
}
@@ -1283,18 +1308,19 @@ static int cam_vfe_bus_handle_comp_done_top_half(uint32_t evt_id,
comp_grp = th_payload->handler_priv;
if (!comp_grp) {
- pr_err_ratelimited("Error! No resource\n");
+ CAM_ERR_RATE_LIMIT(CAM_ISP, "Error! No resource\n");
return -ENODEV;
}
rsrc_data = comp_grp->res_priv;
- CDBG("IRQ status_0 = %x\n", th_payload->evt_status_arr[0]);
- CDBG("IRQ status_1 = %x\n", th_payload->evt_status_arr[1]);
+ CAM_DBG(CAM_ISP, "IRQ status_0 = %x", th_payload->evt_status_arr[0]);
+ CAM_DBG(CAM_ISP, "IRQ status_1 = %x", th_payload->evt_status_arr[1]);
rc = cam_vfe_bus_get_evt_payload(rsrc_data->common_data, &evt_payload);
if (rc) {
- pr_err_ratelimited("No tasklet_cmd is free in queue\n");
+ CAM_ERR_RATE_LIMIT(CAM_ISP,
+ "No tasklet_cmd is free in queue\n");
return rc;
}
@@ -1309,7 +1335,7 @@ static int cam_vfe_bus_handle_comp_done_top_half(uint32_t evt_id,
th_payload->evt_payload_priv = evt_payload;
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -1326,7 +1352,7 @@ static int cam_vfe_bus_handle_comp_done_bottom_half(
uint32_t comp_err_reg;
uint32_t comp_grp_id;
- CDBG("comp grp type %d\n", rsrc_data->comp_grp_type);
+ CAM_DBG(CAM_ISP, "comp grp type %d", rsrc_data->comp_grp_type);
if (!evt_payload)
return rc;
@@ -1369,7 +1395,7 @@ static int cam_vfe_bus_handle_comp_done_bottom_half(
rc = CAM_VFE_IRQ_STATUS_SUCCESS;
}
- CDBG("status reg = 0x%x, bit index = %d rc %d\n",
+ CAM_DBG(CAM_ISP, "status reg = 0x%x, bit index = %d rc %d",
status_reg, (comp_grp_id + 5), rc);
break;
@@ -1411,7 +1437,7 @@ static int cam_vfe_bus_handle_comp_done_bottom_half(
break;
default:
rc = CAM_VFE_IRQ_STATUS_ERR;
- pr_err("Error! Invalid comp_grp_type %u\n",
+ CAM_ERR(CAM_ISP, "Error! Invalid comp_grp_type %u",
rsrc_data->comp_grp_type);
break;
}
@@ -1433,7 +1459,7 @@ static int cam_vfe_bus_init_comp_grp(uint32_t index,
rsrc_data = kzalloc(sizeof(struct cam_vfe_bus_ver2_comp_grp_data),
GFP_KERNEL);
if (!rsrc_data) {
- CDBG("Failed to alloc for comp_grp_priv\n");
+ CAM_DBG(CAM_ISP, "Failed to alloc for comp_grp_priv");
return -ENOMEM;
}
comp_grp->res_priv = rsrc_data;
@@ -1482,7 +1508,7 @@ static int cam_vfe_bus_deinit_comp_grp(
comp_grp->res_priv = NULL;
if (!rsrc_data) {
- pr_err("Error! comp_grp_priv is NULL\n");
+ CAM_ERR(CAM_ISP, "Error! comp_grp_priv is NULL");
return -ENODEV;
}
kfree(rsrc_data);
@@ -1507,14 +1533,14 @@ static int cam_vfe_bus_acquire_vfe_out(void *bus_priv, void *acquire_args,
struct cam_vfe_bus_ver2_vfe_out_data *rsrc_data = NULL;
if (!bus_priv || !acquire_args) {
- pr_err("Invalid Param");
+ CAM_ERR(CAM_ISP, "Invalid Param");
return -EINVAL;
}
out_acquire_args = &acq_args->vfe_out;
format = out_acquire_args->out_port_info->format;
- CDBG("Acquiring resource type 0x%x\n",
+ CAM_DBG(CAM_ISP, "Acquiring resource type 0x%x",
out_acquire_args->out_port_info->res_type);
vfe_out_res_id = cam_vfe_bus_get_out_res_id(
@@ -1528,7 +1554,7 @@ static int cam_vfe_bus_acquire_vfe_out(void *bus_priv, void *acquire_args,
rsrc_node = &ver2_bus_priv->vfe_out[vfe_out_res_id];
if (rsrc_node->res_state != CAM_ISP_RESOURCE_STATE_AVAILABLE) {
- pr_err("Resource not available: Res_id %d state:%d\n",
+ CAM_ERR(CAM_ISP, "Resource not available: Res_id %d state:%d",
vfe_out_res_id, rsrc_node->res_state);
return -EBUSY;
}
@@ -1555,7 +1581,8 @@ static int cam_vfe_bus_acquire_vfe_out(void *bus_priv, void *acquire_args,
out_acquire_args->dual_slave_core,
&rsrc_data->comp_grp);
if (rc) {
- pr_err("VFE%d Comp_Grp acquire failed for Out %d rc=%d\n",
+ CAM_ERR(CAM_ISP,
+ "VFE%d Comp_Grp acquire fail for Out %d rc=%d",
rsrc_data->common_data->core_index,
vfe_out_res_id, rc);
return rc;
@@ -1579,7 +1606,8 @@ static int cam_vfe_bus_acquire_vfe_out(void *bus_priv, void *acquire_args,
&rsrc_data->wm_res[i],
&client_done_mask);
if (rc) {
- pr_err("VFE%d WM acquire failed for Out %d rc=%d\n",
+ CAM_ERR(CAM_ISP,
+ "VFE%d WM acquire failed for Out %d rc=%d",
rsrc_data->common_data->core_index,
vfe_out_res_id, rc);
goto release_wm;
@@ -1593,7 +1621,7 @@ static int cam_vfe_bus_acquire_vfe_out(void *bus_priv, void *acquire_args,
rsrc_node->res_state = CAM_ISP_RESOURCE_STATE_RESERVED;
out_acquire_args->rsrc_node = rsrc_node;
- CDBG("Acquire successful\n");
+ CAM_DBG(CAM_ISP, "Acquire successful");
return rc;
release_wm:
@@ -1614,7 +1642,7 @@ static int cam_vfe_bus_release_vfe_out(void *bus_priv, void *release_args,
struct cam_vfe_bus_ver2_vfe_out_data *rsrc_data = NULL;
if (!bus_priv || !release_args) {
- pr_err("Invalid input bus_priv %pK release_args %pK\n",
+ CAM_ERR(CAM_ISP, "Invalid input bus_priv %pK release_args %pK",
bus_priv, release_args);
return -EINVAL;
}
@@ -1623,7 +1651,7 @@ static int cam_vfe_bus_release_vfe_out(void *bus_priv, void *release_args,
rsrc_data = vfe_out->res_priv;
if (vfe_out->res_state != CAM_ISP_RESOURCE_STATE_RESERVED) {
- pr_err("Error! Invalid resource state:%d\n",
+ CAM_ERR(CAM_ISP, "Error! Invalid resource state:%d",
vfe_out->res_state);
}
@@ -1653,17 +1681,17 @@ static int cam_vfe_bus_start_vfe_out(
struct cam_vfe_bus_ver2_common_data *common_data = NULL;
if (!vfe_out) {
- pr_err("Invalid input\n");
+ CAM_ERR(CAM_ISP, "Invalid input");
return -EINVAL;
}
rsrc_data = vfe_out->res_priv;
common_data = rsrc_data->common_data;
- CDBG("Start resource index %d\n", rsrc_data->out_type);
+ CAM_DBG(CAM_ISP, "Start resource index %d", rsrc_data->out_type);
if (vfe_out->res_state != CAM_ISP_RESOURCE_STATE_RESERVED) {
- pr_err("Error! Invalid resource state:%d\n",
+ CAM_ERR(CAM_ISP, "Error! Invalid resource state:%d",
vfe_out->res_state);
return -EACCES;
}
@@ -1707,7 +1735,7 @@ static int cam_vfe_bus_stop_vfe_out(
struct cam_vfe_bus_ver2_vfe_out_data *rsrc_data = NULL;
if (!vfe_out) {
- pr_err("Invalid input\n");
+ CAM_ERR(CAM_ISP, "Invalid input");
return -EINVAL;
}
@@ -1770,7 +1798,7 @@ static int cam_vfe_bus_init_vfe_out_resource(uint32_t index,
rsrc_data = kzalloc(sizeof(struct cam_vfe_bus_ver2_vfe_out_data),
GFP_KERNEL);
if (!rsrc_data) {
- CDBG("Error! Failed to alloc for vfe out priv\n");
+ CAM_DBG(CAM_ISP, "Error! Failed to alloc for vfe out priv");
rc = -ENOMEM;
return rc;
}
@@ -1813,7 +1841,7 @@ static int cam_vfe_bus_deinit_vfe_out_resource(
vfe_out->res_priv = NULL;
if (!rsrc_data) {
- pr_err("Error! vfe out priv is NULL\n");
+ CAM_ERR(CAM_ISP, "Error! vfe out priv is NULL");
return -ENOMEM;
}
kfree(rsrc_data);
@@ -1827,7 +1855,7 @@ static int cam_vfe_bus_ver2_handle_irq(uint32_t evt_id,
struct cam_vfe_bus_ver2_priv *bus_priv;
bus_priv = th_payload->handler_priv;
- CDBG("Enter\n");
+ CAM_DBG(CAM_ISP, "Enter");
return cam_irq_controller_handle_irq(evt_id,
bus_priv->common_data.bus_irq_controller);
}
@@ -1856,12 +1884,13 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
update_buf->cdm.res->res_priv;
if (!vfe_out_data || !vfe_out_data->cdm_util_ops) {
- pr_err("Failed! Invalid data\n");
+ CAM_ERR(CAM_ISP, "Failed! Invalid data");
return -EINVAL;
}
if (update_buf->num_buf != vfe_out_data->num_wm) {
- pr_err("Failed! Invalid number buffers:%d required:%d\n",
+ CAM_ERR(CAM_ISP,
+ "Failed! Invalid number buffers:%d required:%d",
update_buf->num_buf, vfe_out_data->num_wm);
return -EINVAL;
}
@@ -1871,7 +1900,8 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
for (i = 0, j = 0; i < vfe_out_data->num_wm; i++) {
if (j >= (MAX_REG_VAL_PAIR_SIZE - MAX_BUF_UPDATE_REG_NUM * 2)) {
- pr_err("reg_val_pair %d exceeds the array limit %lu\n",
+ CAM_ERR(CAM_ISP,
+ "reg_val_pair %d exceeds the array limit %lu",
j, MAX_REG_VAL_PAIR_SIZE);
return -ENOMEM;
}
@@ -1879,14 +1909,14 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
wm_data = vfe_out_data->wm_res[i]->res_priv;
/* For initial configuration program all bus registers */
- if (wm_data->stride != io_cfg->planes[i].plane_stride ||
- !wm_data->init_cfg_done) {
+ if ((wm_data->stride != io_cfg->planes[i].plane_stride ||
+ !wm_data->init_cfg_done) && (wm_data->index >= 3)) {
CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
wm_data->hw_regs->stride,
io_cfg->planes[i].plane_stride);
wm_data->stride = io_cfg->planes[i].plane_stride;
}
- CDBG("image stride 0x%x\n", wm_data->stride);
+ CAM_DBG(CAM_ISP, "image stride 0x%x", wm_data->stride);
if (wm_data->framedrop_pattern != io_cfg->framedrop_pattern ||
!wm_data->init_cfg_done) {
@@ -1895,7 +1925,8 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
io_cfg->framedrop_pattern);
wm_data->framedrop_pattern = io_cfg->framedrop_pattern;
}
- CDBG("framedrop pattern 0x%x\n", wm_data->framedrop_pattern);
+ CAM_DBG(CAM_ISP, "framedrop pattern 0x%x",
+ wm_data->framedrop_pattern);
if (wm_data->framedrop_period != io_cfg->framedrop_period ||
!wm_data->init_cfg_done) {
@@ -1904,7 +1935,8 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
io_cfg->framedrop_period);
wm_data->framedrop_period = io_cfg->framedrop_period;
}
- CDBG("framedrop period 0x%x\n", wm_data->framedrop_period);
+ CAM_DBG(CAM_ISP, "framedrop period 0x%x",
+ wm_data->framedrop_period);
if (wm_data->irq_subsample_period != io_cfg->subsample_period
|| !wm_data->init_cfg_done) {
@@ -1914,7 +1946,7 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
wm_data->irq_subsample_period =
io_cfg->subsample_period;
}
- CDBG("irq subsample period 0x%x\n",
+ CAM_DBG(CAM_ISP, "irq subsample period 0x%x",
wm_data->irq_subsample_period);
if (wm_data->irq_subsample_pattern != io_cfg->subsample_pattern
@@ -1925,13 +1957,13 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
wm_data->irq_subsample_pattern =
io_cfg->subsample_pattern;
}
- CDBG("irq subsample pattern 0x%x\n",
+ CAM_DBG(CAM_ISP, "irq subsample pattern 0x%x",
wm_data->irq_subsample_pattern);
if (wm_data->en_ubwc) {
if (!wm_data->hw_regs->ubwc_regs) {
- pr_err("%s: No UBWC register to configure.\n",
- __func__);
+ CAM_ERR(CAM_ISP,
+ "No UBWC register to configure.");
return -EINVAL;
}
if (wm_data->packer_cfg !=
@@ -1943,7 +1975,8 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
wm_data->packer_cfg =
io_cfg->planes[i].packer_config;
}
- CDBG("packer cfg 0x%x\n", wm_data->packer_cfg);
+ CAM_DBG(CAM_ISP, "packer cfg 0x%x",
+ wm_data->packer_cfg);
if (wm_data->tile_cfg != io_cfg->planes[i].tile_config
|| !wm_data->init_cfg_done) {
@@ -1953,7 +1986,7 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
wm_data->tile_cfg =
io_cfg->planes[i].tile_config;
}
- CDBG("tile cfg 0x%x\n", wm_data->tile_cfg);
+ CAM_DBG(CAM_ISP, "tile cfg 0x%x", wm_data->tile_cfg);
if (wm_data->h_init != io_cfg->planes[i].h_init ||
!wm_data->init_cfg_done) {
@@ -1962,7 +1995,7 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
io_cfg->planes[i].h_init);
wm_data->h_init = io_cfg->planes[i].h_init;
}
- CDBG("h_init 0x%x\n", wm_data->h_init);
+ CAM_DBG(CAM_ISP, "h_init 0x%x", wm_data->h_init);
if (wm_data->v_init != io_cfg->planes[i].v_init ||
!wm_data->init_cfg_done) {
@@ -1971,7 +2004,7 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
io_cfg->planes[i].v_init);
wm_data->v_init = io_cfg->planes[i].v_init;
}
- CDBG("v_init 0x%x\n", wm_data->v_init);
+ CAM_DBG(CAM_ISP, "v_init 0x%x", wm_data->v_init);
if (wm_data->ubwc_meta_stride !=
io_cfg->planes[i].meta_stride ||
@@ -1983,7 +2016,8 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
wm_data->ubwc_meta_stride =
io_cfg->planes[i].meta_stride;
}
- CDBG("meta stride 0x%x\n", wm_data->ubwc_meta_stride);
+ CAM_DBG(CAM_ISP, "meta stride 0x%x",
+ wm_data->ubwc_meta_stride);
if (wm_data->ubwc_mode_cfg !=
io_cfg->planes[i].mode_config ||
@@ -1994,7 +2028,8 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
wm_data->ubwc_mode_cfg =
io_cfg->planes[i].mode_config;
}
- CDBG("ubwc mode cfg 0x%x\n", wm_data->ubwc_mode_cfg);
+ CAM_DBG(CAM_ISP, "ubwc mode cfg 0x%x",
+ wm_data->ubwc_mode_cfg);
if (wm_data->ubwc_meta_offset !=
io_cfg->planes[i].meta_offset ||
@@ -2006,14 +2041,14 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
wm_data->ubwc_meta_offset =
io_cfg->planes[i].meta_offset;
}
- CDBG("ubwc meta offset 0x%x\n",
+ CAM_DBG(CAM_ISP, "ubwc meta offset 0x%x",
wm_data->ubwc_meta_offset);
/* UBWC meta address */
CAM_VFE_ADD_REG_VAL_PAIR(reg_val_pair, j,
wm_data->hw_regs->ubwc_regs->meta_addr,
update_buf->image_buf[i]);
- CDBG("ubwc meta addr 0x%llx\n",
+ CAM_DBG(CAM_ISP, "ubwc meta addr 0x%llx",
update_buf->image_buf[i]);
}
@@ -2028,7 +2063,7 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
wm_data->hw_regs->image_addr,
update_buf->image_buf[i]);
- CDBG("image address 0x%x\n", reg_val_pair[j-1]);
+ CAM_DBG(CAM_ISP, "image address 0x%x", reg_val_pair[j-1]);
frame_inc = io_cfg->planes[i].plane_stride *
io_cfg->planes[i].slice_height;
@@ -2049,7 +2084,8 @@ static int cam_vfe_bus_update_buf(void *priv, void *cmd_args,
/* cdm util returns dwords, need to convert to bytes */
if ((size * 4) > update_buf->cdm.size) {
- pr_err("Failed! Buf size:%d insufficient, expected size:%d\n",
+ CAM_ERR(CAM_ISP,
+ "Failed! Buf size:%d insufficient, expected size:%d",
update_buf->cdm.size, size);
return -ENOMEM;
}
@@ -2082,7 +2118,7 @@ static int cam_vfe_bus_init_hw(void *hw_priv,
uint32_t top_irq_reg_mask[2] = {0};
if (!bus_priv) {
- pr_err("Error! Invalid args\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid args");
return -EINVAL;
}
@@ -2099,7 +2135,7 @@ static int cam_vfe_bus_init_hw(void *hw_priv,
NULL);
if (bus_priv->irq_handle <= 0) {
- pr_err("Failed to subscribe BUS IRQ\n");
+ CAM_ERR(CAM_ISP, "Failed to subscribe BUS IRQ");
return -EFAULT;
}
@@ -2113,7 +2149,7 @@ static int cam_vfe_bus_deinit_hw(void *hw_priv,
int rc;
if (!bus_priv || (bus_priv->irq_handle <= 0)) {
- pr_err("Error! Invalid args\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid args");
return -EINVAL;
}
@@ -2121,7 +2157,7 @@ static int cam_vfe_bus_deinit_hw(void *hw_priv,
bus_priv->common_data.vfe_irq_controller,
bus_priv->irq_handle);
if (rc)
- pr_err("Failed to unsubscribe irq rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Failed to unsubscribe irq rc=%d", rc);
return rc;
}
@@ -2132,7 +2168,7 @@ static int cam_vfe_bus_process_cmd(void *priv,
int rc = -EINVAL;
if (!priv || !cmd_args) {
- pr_err_ratelimited("Error! Invalid input arguments\n");
+ CAM_ERR_RATE_LIMIT(CAM_ISP, "Error! Invalid input arguments\n");
return -EINVAL;
}
@@ -2141,7 +2177,7 @@ static int cam_vfe_bus_process_cmd(void *priv,
rc = cam_vfe_bus_update_buf(priv, cmd_args, arg_size);
break;
default:
- pr_err_ratelimited("Error! Invalid camif process command:%d\n",
+ CAM_ERR_RATE_LIMIT(CAM_ISP, "Inval camif process command:%d\n",
cmd_type);
break;
}
@@ -2161,18 +2197,20 @@ int cam_vfe_bus_ver2_init(
struct cam_vfe_bus *vfe_bus_local;
struct cam_vfe_bus_ver2_hw_info *ver2_hw_info = bus_hw_info;
- CDBG("Enter\n");
+ CAM_DBG(CAM_ISP, "Enter");
if (!soc_info || !hw_intf || !bus_hw_info || !vfe_irq_controller) {
- pr_err("Error! Invalid params soc_info %pK hw_intf %pK hw_info %pK controller %pK\n",
- soc_info, hw_intf, bus_hw_info, vfe_irq_controller);
+ CAM_ERR(CAM_ISP,
+ "Inval_prms soc_info:%pK hw_intf:%pK hw_info%pK",
+ soc_info, hw_intf, bus_hw_info);
+ CAM_ERR(CAM_ISP, "controller: %pK", vfe_irq_controller);
rc = -EINVAL;
goto end;
}
vfe_bus_local = kzalloc(sizeof(struct cam_vfe_bus), GFP_KERNEL);
if (!vfe_bus_local) {
- CDBG("Failed to alloc for vfe_bus\n");
+ CAM_DBG(CAM_ISP, "Failed to alloc for vfe_bus");
rc = -ENOMEM;
goto end;
}
@@ -2180,7 +2218,7 @@ int cam_vfe_bus_ver2_init(
bus_priv = kzalloc(sizeof(struct cam_vfe_bus_ver2_priv),
GFP_KERNEL);
if (!bus_priv) {
- CDBG("Failed to alloc for vfe_bus_priv\n");
+ CAM_DBG(CAM_ISP, "Failed to alloc for vfe_bus_priv");
rc = -ENOMEM;
goto free_bus_local;
}
@@ -2197,7 +2235,7 @@ int cam_vfe_bus_ver2_init(
&ver2_hw_info->common_reg.irq_reg_info,
&bus_priv->common_data.bus_irq_controller);
if (rc) {
- pr_err("Error! cam_irq_controller_init failed\n");
+ CAM_ERR(CAM_ISP, "Error! cam_irq_controller_init failed");
goto free_bus_priv;
}
@@ -2209,7 +2247,7 @@ int cam_vfe_bus_ver2_init(
rc = cam_vfe_bus_init_wm_resource(i, bus_priv, bus_hw_info,
&bus_priv->bus_client[i]);
if (rc < 0) {
- pr_err("Error! Init WM failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Error! Init WM failed rc=%d", rc);
goto deinit_wm;
}
}
@@ -2218,7 +2256,7 @@ int cam_vfe_bus_ver2_init(
rc = cam_vfe_bus_init_comp_grp(i, bus_priv, bus_hw_info,
&bus_priv->comp_grp[i]);
if (rc < 0) {
- pr_err("Error! Init Comp Grp failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Init Comp Grp failed rc=%d", rc);
goto deinit_comp_grp;
}
}
@@ -2227,7 +2265,7 @@ int cam_vfe_bus_ver2_init(
rc = cam_vfe_bus_init_vfe_out_resource(i, bus_priv, bus_hw_info,
&bus_priv->vfe_out[i]);
if (rc < 0) {
- pr_err("Error! Init VFE Out failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "Init VFE Out failed rc=%d", rc);
goto deinit_vfe_out;
}
}
@@ -2251,7 +2289,7 @@ int cam_vfe_bus_ver2_init(
*vfe_bus = vfe_bus_local;
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
deinit_vfe_out:
@@ -2290,14 +2328,14 @@ int cam_vfe_bus_ver2_deinit(
struct cam_vfe_bus *vfe_bus_local;
if (!vfe_bus || !*vfe_bus) {
- pr_err("Error! Invalid input\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input");
return -EINVAL;
}
vfe_bus_local = *vfe_bus;
bus_priv = vfe_bus_local->bus_priv;
if (!bus_priv) {
- pr_err("Error! bus_priv is NULL\n");
+ CAM_ERR(CAM_ISP, "Error! bus_priv is NULL");
rc = -ENODEV;
goto free_bus_local;
}
@@ -2309,19 +2347,22 @@ int cam_vfe_bus_ver2_deinit(
for (i = 0; i < CAM_VFE_BUS_VER2_MAX_CLIENTS; i++) {
rc = cam_vfe_bus_deinit_wm_resource(&bus_priv->bus_client[i]);
if (rc < 0)
- pr_err("Error! Deinit WM failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP,
+ "Error! Deinit WM failed rc=%d", rc);
}
for (i = 0; i < CAM_VFE_BUS_VER2_COMP_GRP_MAX; i++) {
rc = cam_vfe_bus_deinit_comp_grp(&bus_priv->comp_grp[i]);
if (rc < 0)
- pr_err("Error! Deinit Comp Grp failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP,
+ "Error! Deinit Comp Grp failed rc=%d", rc);
}
for (i = 0; i < CAM_VFE_BUS_VER2_VFE_OUT_MAX; i++) {
rc = cam_vfe_bus_deinit_vfe_out_resource(&bus_priv->vfe_out[i]);
if (rc < 0)
- pr_err("Error! Deinit VFE Out failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP,
+ "Error! Deinit VFE Out failed rc=%d", rc);
}
INIT_LIST_HEAD(&bus_priv->free_comp_grp);
@@ -2331,7 +2372,8 @@ int cam_vfe_bus_ver2_deinit(
rc = cam_irq_controller_deinit(
&bus_priv->common_data.bus_irq_controller);
if (rc)
- pr_err("Error! Deinit IRQ Controller failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP,
+ "Error! Deinit IRQ Controller failed rc=%d", rc);
kfree(vfe_bus_local->bus_priv);
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c
index fa00769..e70ecc5 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_camif_ver2.c
@@ -10,9 +10,7 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
-#include <linux/slab.h>
+ #include <linux/slab.h>
#include <uapi/media/cam_isp.h>
#include "cam_io_util.h"
#include "cam_isp_hw_mgr_intf.h"
@@ -20,9 +18,7 @@
#include "cam_vfe_top.h"
#include "cam_vfe_top_ver2.h"
#include "cam_vfe_camif_ver2.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
struct cam_vfe_mux_camif_data {
void __iomem *mem_base;
@@ -55,7 +51,7 @@ static int cam_vfe_camif_validate_pix_pattern(uint32_t pattern)
rc = 0;
break;
default:
- pr_err("Error! Invalid pix pattern:%d\n", pattern);
+ CAM_ERR(CAM_ISP, "Error! Invalid pix pattern:%d", pattern);
rc = -EINVAL;
break;
}
@@ -96,12 +92,12 @@ static int cam_vfe_camif_resource_start(
uint32_t val = 0;
if (!camif_res) {
- pr_err("Error! Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input arguments");
return -EINVAL;
}
if (camif_res->res_state != CAM_ISP_RESOURCE_STATE_RESERVED) {
- pr_err("Error! Invalid camif res res_state:%d\n",
+ CAM_ERR(CAM_ISP, "Error! Invalid camif res res_state:%d",
camif_res->res_state);
return -EINVAL;
}
@@ -129,7 +125,7 @@ static int cam_vfe_camif_resource_start(
/* Reg Update */
cam_io_w_mb(0x1, rsrc_data->mem_base + 0x4AC);
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
return 0;
}
@@ -142,7 +138,7 @@ static int cam_vfe_camif_resource_stop(
int rc = 0;
if (!camif_res) {
- pr_err("Error! Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input arguments");
return -EINVAL;
}
@@ -188,26 +184,26 @@ static int cam_vfe_camif_handle_irq_bottom_half(void *handler_priv,
payload = evt_payload_priv;
irq_status0 = payload->irq_reg_val[CAM_IFE_IRQ_CAMIF_REG_STATUS0];
- CDBG("event ID:%d\n", payload->evt_id);
- CDBG("irq_status_0 = %x\n", irq_status0);
+ CAM_DBG(CAM_ISP, "event ID:%d", payload->evt_id);
+ CAM_DBG(CAM_ISP, "irq_status_0 = %x", irq_status0);
switch (payload->evt_id) {
case CAM_ISP_HW_EVENT_SOF:
if (irq_status0 & camif_priv->reg_data->sof_irq_mask) {
- CDBG("Received SOF\n");
+ CAM_DBG(CAM_ISP, "Received SOF");
ret = CAM_VFE_IRQ_STATUS_SUCCESS;
}
break;
case CAM_ISP_HW_EVENT_EPOCH:
if (irq_status0 & camif_priv->reg_data->epoch0_irq_mask) {
- CDBG("Received EPOCH\n");
+ CAM_DBG(CAM_ISP, "Received EPOCH");
ret = CAM_VFE_IRQ_STATUS_SUCCESS;
}
cam_vfe_put_evt_payload(payload->core_info, &payload);
break;
case CAM_ISP_HW_EVENT_REG_UPDATE:
if (irq_status0 & camif_priv->reg_data->reg_update_irq_mask) {
- CDBG("Received REG_UPDATE_ACK\n");
+ CAM_DBG(CAM_ISP, "Received REG_UPDATE_ACK");
ret = CAM_VFE_IRQ_STATUS_SUCCESS;
}
break;
@@ -215,7 +211,7 @@ static int cam_vfe_camif_handle_irq_bottom_half(void *handler_priv,
break;
}
- CDBG("returing status = %d\n", ret);
+ CAM_DBG(CAM_ISP, "returing status = %d", ret);
return ret;
}
@@ -231,7 +227,7 @@ int cam_vfe_camif_ver2_init(
camif_priv = kzalloc(sizeof(struct cam_vfe_mux_camif_data),
GFP_KERNEL);
if (!camif_priv) {
- CDBG("Error! Failed to alloc for camif_priv\n");
+ CAM_DBG(CAM_ISP, "Error! Failed to alloc for camif_priv");
return -ENOMEM;
}
@@ -264,7 +260,7 @@ int cam_vfe_camif_ver2_deinit(
camif_node->res_priv = NULL;
if (!camif_priv) {
- pr_err("Error! camif_priv is NULL\n");
+ CAM_ERR(CAM_ISP, "Error! camif_priv is NULL");
return -ENODEV;
}
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.c
index f96f4d9..df7b0f9 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.c
@@ -10,21 +10,19 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
#include <linux/slab.h>
#include "cam_vfe_rdi.h"
#include "cam_isp_hw_mgr_intf.h"
#include "cam_vfe_hw_intf.h"
#include "cam_io_util.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
struct cam_vfe_mux_rdi_data {
void __iomem *mem_base;
struct cam_hw_intf *hw_intf;
struct cam_vfe_top_ver2_reg_offset_common *common_reg;
+ struct cam_vfe_rdi_ver2_reg *rdi_reg;
+ struct cam_vfe_rdi_reg_data *reg_data;
enum cam_isp_hw_sync_mode sync_mode;
};
@@ -51,12 +49,12 @@ static int cam_vfe_rdi_resource_start(
int rc = 0;
if (!rdi_res) {
- pr_err("Error! Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input arguments");
return -EINVAL;
}
if (rdi_res->res_state != CAM_ISP_RESOURCE_STATE_RESERVED) {
- pr_err("Error! Invalid rdi res res_state:%d\n",
+ CAM_ERR(CAM_ISP, "Error! Invalid rdi res res_state:%d",
rdi_res->res_state);
return -EINVAL;
}
@@ -67,7 +65,7 @@ static int cam_vfe_rdi_resource_start(
/* Reg Update */
cam_io_w_mb(0x2, rsrc_data->mem_base + 0x4AC);
- CDBG("Exit\n");
+ CAM_DBG(CAM_ISP, "Exit");
return rc;
}
@@ -80,7 +78,7 @@ static int cam_vfe_rdi_resource_stop(
int rc = 0;
if (!rdi_res) {
- pr_err("Error! Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input arguments");
return -EINVAL;
}
@@ -103,13 +101,14 @@ int cam_vfe_rdi_process_cmd(void *priv,
int rc = -EINVAL;
if (!priv || !cmd_args) {
- pr_err("Error! Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input arguments");
return -EINVAL;
}
switch (cmd_type) {
default:
- pr_err("Error! unsupported RDI process command:%d\n", cmd_type);
+ CAM_ERR(CAM_ISP,
+ "unsupported RDI process command:%d", cmd_type);
break;
}
@@ -139,23 +138,28 @@ static int cam_vfe_rdi_handle_irq_bottom_half(void *handler_priv,
payload = evt_payload_priv;
irq_status0 = payload->irq_reg_val[CAM_IFE_IRQ_CAMIF_REG_STATUS0];
- CDBG("event ID:%d\n", payload->evt_id);
- CDBG("irq_status_0 = %x\n", irq_status0);
+ CAM_DBG(CAM_ISP, "event ID:%d", payload->evt_id);
+ CAM_DBG(CAM_ISP, "irq_status_0 = %x", irq_status0);
switch (payload->evt_id) {
case CAM_ISP_HW_EVENT_SOF:
- if (irq_status0 & 0x8000000)
+ if (irq_status0 & rdi_priv->reg_data->sof_irq_mask) {
+ CAM_DBG(CAM_ISP, "Received SOF");
ret = CAM_VFE_IRQ_STATUS_SUCCESS;
+ }
break;
case CAM_ISP_HW_EVENT_REG_UPDATE:
- if (irq_status0 & 0x20)
+ if (irq_status0 & rdi_priv->reg_data->reg_update_irq_mask) {
+ CAM_DBG(CAM_ISP, "Received REG UPDATE");
ret = CAM_VFE_IRQ_STATUS_SUCCESS;
+ }
+ cam_vfe_put_evt_payload(payload->core_info, &payload);
break;
default:
break;
}
- CDBG("returing status = %d\n", ret);
+ CAM_DBG(CAM_ISP, "returing status = %d", ret);
return ret;
}
@@ -166,11 +170,12 @@ int cam_vfe_rdi_ver2_init(
struct cam_isp_resource_node *rdi_node)
{
struct cam_vfe_mux_rdi_data *rdi_priv = NULL;
+ struct cam_vfe_rdi_ver2_hw_info *rdi_info = rdi_hw_info;
rdi_priv = kzalloc(sizeof(struct cam_vfe_mux_rdi_data),
GFP_KERNEL);
if (!rdi_priv) {
- CDBG("Error! Failed to alloc for rdi_priv\n");
+ CAM_DBG(CAM_ISP, "Error! Failed to alloc for rdi_priv");
return -ENOMEM;
}
@@ -178,6 +183,31 @@ int cam_vfe_rdi_ver2_init(
rdi_priv->mem_base = soc_info->reg_map[VFE_CORE_BASE_IDX].mem_base;
rdi_priv->hw_intf = hw_intf;
+ rdi_priv->common_reg = rdi_info->common_reg;
+ rdi_priv->rdi_reg = rdi_info->rdi_reg;
+
+ switch (rdi_node->res_id) {
+ case CAM_ISP_HW_VFE_IN_RDI0:
+ rdi_priv->reg_data = rdi_info->reg_data[0];
+ break;
+ case CAM_ISP_HW_VFE_IN_RDI1:
+ rdi_priv->reg_data = rdi_info->reg_data[1];
+ break;
+ case CAM_ISP_HW_VFE_IN_RDI2:
+ rdi_priv->reg_data = rdi_info->reg_data[2];
+ break;
+ case CAM_ISP_HW_VFE_IN_RDI3:
+ if (rdi_info->reg_data[3]) {
+ rdi_priv->reg_data = rdi_info->reg_data[3];
+ } else {
+ CAM_ERR(CAM_ISP, "Error! RDI3 is not supported");
+ goto err_init;
+ }
+ break;
+ default:
+ CAM_DBG(CAM_ISP, "invalid Resource id:%d", rdi_node->res_id);
+ goto err_init;
+ }
rdi_node->start = cam_vfe_rdi_resource_start;
rdi_node->stop = cam_vfe_rdi_resource_stop;
@@ -185,6 +215,9 @@ int cam_vfe_rdi_ver2_init(
rdi_node->bottom_half_handler = cam_vfe_rdi_handle_irq_bottom_half;
return 0;
+err_init:
+ kfree(rdi_priv);
+ return -EINVAL;
}
int cam_vfe_rdi_ver2_deinit(
@@ -200,7 +233,7 @@ int cam_vfe_rdi_ver2_deinit(
rdi_node->res_priv = NULL;
if (!rdi_priv) {
- pr_err("Error! rdi_priv NULL\n");
+ CAM_ERR(CAM_ISP, "Error! rdi_priv NULL");
return -ENODEV;
}
kfree(rdi_priv);
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.h
index 9893474..04e4f02 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_rdi.h
@@ -16,18 +16,22 @@
#include "cam_isp_hw.h"
#include "cam_vfe_top.h"
+#define CAM_VFE_RDI_VER2_MAX 4
+
struct cam_vfe_rdi_ver2_reg {
uint32_t reg_update_cmd;
};
struct cam_vfe_rdi_reg_data {
+ uint32_t reg_update_cmd_data;
+ uint32_t sof_irq_mask;
uint32_t reg_update_irq_mask;
};
struct cam_vfe_rdi_ver2_hw_info {
- struct cam_vfe_top_ver2_reg_offset_common *common_reg;
- struct cam_vfe_rdi_ver2_reg *rdi_reg;
- struct cam_vfe_rdi_reg_data *reg_data;
+ struct cam_vfe_top_ver2_reg_offset_common *common_reg;
+ struct cam_vfe_rdi_ver2_reg *rdi_reg;
+ struct cam_vfe_rdi_reg_data *reg_data[CAM_VFE_RDI_VER2_MAX];
};
int cam_vfe_rdi_ver2_acquire_resource(
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top.c
index ee608fa..8eb1835 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top.c
@@ -10,10 +10,9 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
#include "cam_vfe_top.h"
#include "cam_vfe_top_ver2.h"
+#include "cam_debug_util.h"
int cam_vfe_top_init(uint32_t top_version,
struct cam_hw_soc_info *soc_info,
@@ -29,7 +28,7 @@ int cam_vfe_top_init(uint32_t top_version,
vfe_top);
break;
default:
- pr_err("Error! Unsupported Version %x\n", top_version);
+ CAM_ERR(CAM_ISP, "Error! Unsupported Version %x", top_version);
break;
}
@@ -46,7 +45,7 @@ int cam_vfe_top_deinit(uint32_t top_version,
rc = cam_vfe_top_ver2_deinit(vfe_top);
break;
default:
- pr_err("Error! Unsupported Version %x\n", top_version);
+ CAM_ERR(CAM_ISP, "Error! Unsupported Version %x", top_version);
break;
}
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.c b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.c
index ce7c63e..1a3eeae 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.c
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.c
@@ -10,17 +10,13 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
#include <linux/slab.h>
#include "cam_io_util.h"
#include "cam_cdm_util.h"
#include "cam_vfe_hw_intf.h"
#include "cam_vfe_top.h"
#include "cam_vfe_top_ver2.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+#include "cam_debug_util.h"
struct cam_vfe_top_ver2_common_data {
struct cam_hw_soc_info *soc_info;
@@ -43,13 +39,13 @@ static int cam_vfe_top_mux_get_base(struct cam_vfe_top_ver2_priv *top_priv,
struct cam_cdm_utils_ops *cdm_util_ops = NULL;
if (arg_size != sizeof(struct cam_isp_hw_get_cdm_args)) {
- pr_err("Error! Invalid cmd size\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid cmd size");
return -EINVAL;
}
if (!cdm_args || !cdm_args->res || !top_priv ||
!top_priv->common_data.soc_info) {
- pr_err("Error! Invalid args\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid args");
return -EINVAL;
}
@@ -57,22 +53,22 @@ static int cam_vfe_top_mux_get_base(struct cam_vfe_top_ver2_priv *top_priv,
(struct cam_cdm_utils_ops *)cdm_args->res->cdm_ops;
if (!cdm_util_ops) {
- pr_err("Invalid CDM ops\n");
+ CAM_ERR(CAM_ISP, "Invalid CDM ops");
return -EINVAL;
}
size = cdm_util_ops->cdm_required_size_changebase();
/* since cdm returns dwords, we need to convert it into bytes */
if ((size * 4) > cdm_args->size) {
- pr_err("buf size:%d is not sufficient, expected: %d\n",
+ CAM_ERR(CAM_ISP, "buf size:%d is not sufficient, expected: %d",
cdm_args->size, size);
return -EINVAL;
}
mem_base = CAM_SOC_GET_REG_MAP_CAM_BASE(
top_priv->common_data.soc_info, VFE_CORE_BASE_IDX);
- CDBG("core %d mem_base 0x%x\n", top_priv->common_data.soc_info->index,
- mem_base);
+ CAM_DBG(CAM_ISP, "core %d mem_base 0x%x",
+ top_priv->common_data.soc_info->index, mem_base);
cdm_util_ops->cdm_write_changebase(cdm_args->cmd_buf_addr, mem_base);
cdm_args->used_bytes = (size * 4);
@@ -90,26 +86,26 @@ static int cam_vfe_top_mux_get_reg_update(
struct cam_cdm_utils_ops *cdm_util_ops = NULL;
if (arg_size != sizeof(struct cam_isp_hw_get_cdm_args)) {
- pr_err("Error! Invalid cmd size\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid cmd size");
return -EINVAL;
}
if (!cdm_args || !cdm_args->res) {
- pr_err("Error! Invalid args\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid args");
return -EINVAL;
}
cdm_util_ops = (struct cam_cdm_utils_ops *)cdm_args->res->cdm_ops;
if (!cdm_util_ops) {
- pr_err("Error! Invalid CDM ops\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid CDM ops");
return -EINVAL;
}
size = cdm_util_ops->cdm_required_size_reg_random(1);
/* since cdm returns dwords, we need to convert it into bytes */
if ((size * 4) > cdm_args->size) {
- pr_err("Error! buf size:%d is not sufficient, expected: %d\n",
+ CAM_ERR(CAM_ISP, "buf size:%d is not sufficient, expected: %d",
cdm_args->size, size);
return -EINVAL;
}
@@ -153,7 +149,7 @@ int cam_vfe_top_reset(void *device_priv,
struct cam_vfe_top_ver2_reg_offset_common *reg_common = NULL;
if (!top_priv) {
- pr_err("Invalid arguments\n");
+ CAM_ERR(CAM_ISP, "Invalid arguments");
return -EINVAL;
}
@@ -169,7 +165,7 @@ int cam_vfe_top_reset(void *device_priv,
CAM_SOC_GET_REG_MAP_START(soc_info, VFE_CORE_BASE_IDX) +
reg_common->global_reset_cmd);
- CDBG("Reset HW exit\n");
+ CAM_DBG(CAM_ISP, "Reset HW exit");
return 0;
}
@@ -183,7 +179,7 @@ int cam_vfe_top_reserve(void *device_priv,
int rc = -EINVAL;
if (!device_priv || !reserve_args) {
- pr_err("Error! Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input arguments");
return -EINVAL;
}
@@ -228,16 +224,16 @@ int cam_vfe_top_release(void *device_priv,
struct cam_isp_resource_node *mux_res;
if (!device_priv || !release_args) {
- pr_err("Error! Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input arguments");
return -EINVAL;
}
top_priv = (struct cam_vfe_top_ver2_priv *)device_priv;
mux_res = (struct cam_isp_resource_node *)release_args;
- CDBG("%s: Resource in state %d\n", __func__, mux_res->res_state);
+ CAM_DBG(CAM_ISP, "Resource in state %d", mux_res->res_state);
if (mux_res->res_state < CAM_ISP_RESOURCE_STATE_RESERVED) {
- pr_err("Error! Resource in Invalid res_state :%d\n",
+ CAM_ERR(CAM_ISP, "Error! Resource in Invalid res_state :%d",
mux_res->res_state);
return -EINVAL;
}
@@ -254,7 +250,7 @@ int cam_vfe_top_start(void *device_priv,
int rc = 0;
if (!device_priv || !start_args) {
- pr_err("Error! Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input arguments");
return -EINVAL;
}
@@ -268,7 +264,7 @@ int cam_vfe_top_start(void *device_priv,
mux_res->res_state = CAM_ISP_RESOURCE_STATE_STREAMING;
rc = 0;
} else {
- pr_err("Invalid res id:%d\n", mux_res->res_id);
+ CAM_ERR(CAM_ISP, "Invalid res id:%d", mux_res->res_id);
rc = -EINVAL;
}
@@ -283,7 +279,7 @@ int cam_vfe_top_stop(void *device_priv,
int rc = 0;
if (!device_priv || !stop_args) {
- pr_err("Error! Invalid input arguments\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input arguments");
return -EINVAL;
}
@@ -295,7 +291,7 @@ int cam_vfe_top_stop(void *device_priv,
mux_res->res_id <= CAM_ISP_HW_VFE_IN_RDI3)) {
rc = mux_res->stop(mux_res);
} else {
- pr_err("Invalid res id:%d\n", mux_res->res_id);
+ CAM_ERR(CAM_ISP, "Invalid res id:%d", mux_res->res_id);
rc = -EINVAL;
}
@@ -322,7 +318,7 @@ int cam_vfe_top_process_cmd(void *device_priv, uint32_t cmd_type,
struct cam_vfe_top_ver2_priv *top_priv;
if (!device_priv || !cmd_args) {
- pr_err("Error! Invalid arguments\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid arguments");
return -EINVAL;
}
top_priv = (struct cam_vfe_top_ver2_priv *)device_priv;
@@ -337,7 +333,7 @@ int cam_vfe_top_process_cmd(void *device_priv, uint32_t cmd_type,
break;
default:
rc = -EINVAL;
- pr_err("Error! Invalid cmd:%d\n", cmd_type);
+ CAM_ERR(CAM_ISP, "Error! Invalid cmd:%d", cmd_type);
break;
}
@@ -357,7 +353,7 @@ int cam_vfe_top_ver2_init(
vfe_top = kzalloc(sizeof(struct cam_vfe_top), GFP_KERNEL);
if (!vfe_top) {
- CDBG("Error! Failed to alloc for vfe_top\n");
+ CAM_DBG(CAM_ISP, "Error! Failed to alloc for vfe_top");
rc = -ENOMEM;
goto end;
}
@@ -365,7 +361,7 @@ int cam_vfe_top_ver2_init(
top_priv = kzalloc(sizeof(struct cam_vfe_top_ver2_priv),
GFP_KERNEL);
if (!top_priv) {
- CDBG("Error! Failed to alloc for vfe_top_priv\n");
+ CAM_DBG(CAM_ISP, "Error! Failed to alloc for vfe_top_priv");
rc = -ENOMEM;
goto free_vfe_top;
}
@@ -391,7 +387,8 @@ int cam_vfe_top_ver2_init(
CAM_ISP_HW_VFE_IN_RDI0 + j++;
rc = cam_vfe_rdi_ver2_init(hw_intf, soc_info,
- NULL, &top_priv->mux_rsrc[i]);
+ &ver2_hw_info->rdi_hw_info,
+ &top_priv->mux_rsrc[i]);
if (rc)
goto deinit_resources;
}
@@ -419,10 +416,10 @@ int cam_vfe_top_ver2_init(
for (--i; i >= 0; i--) {
if (ver2_hw_info->mux_type[i] == CAM_VFE_CAMIF_VER_2_0) {
if (cam_vfe_camif_ver2_deinit(&top_priv->mux_rsrc[i]))
- pr_err("Camif Deinit failed\n");
+ CAM_ERR(CAM_ISP, "Camif Deinit failed");
} else {
if (cam_vfe_rdi_ver2_deinit(&top_priv->mux_rsrc[i]))
- pr_err("RDI Deinit failed\n");
+ CAM_ERR(CAM_ISP, "RDI Deinit failed");
}
top_priv->mux_rsrc[i].res_state =
CAM_ISP_RESOURCE_STATE_UNAVAILABLE;
@@ -442,19 +439,19 @@ int cam_vfe_top_ver2_deinit(struct cam_vfe_top **vfe_top_ptr)
struct cam_vfe_top *vfe_top;
if (!vfe_top_ptr) {
- pr_err("Error! Invalid input\n");
+ CAM_ERR(CAM_ISP, "Error! Invalid input");
return -EINVAL;
}
vfe_top = *vfe_top_ptr;
if (!vfe_top) {
- pr_err("Error! vfe_top NULL\n");
+ CAM_ERR(CAM_ISP, "Error! vfe_top NULL");
return -ENODEV;
}
top_priv = vfe_top->top_priv;
if (!top_priv) {
- pr_err("Error! vfe_top_priv NULL\n");
+ CAM_ERR(CAM_ISP, "Error! vfe_top_priv NULL");
rc = -ENODEV;
goto free_vfe_top;
}
@@ -466,12 +463,12 @@ int cam_vfe_top_ver2_deinit(struct cam_vfe_top **vfe_top_ptr)
CAM_ISP_HW_VFE_IN_CAMIF) {
rc = cam_vfe_camif_ver2_deinit(&top_priv->mux_rsrc[i]);
if (rc)
- pr_err("Error! Camif deinit failed rc=%d\n",
+ CAM_ERR(CAM_ISP, "Camif deinit failed rc=%d",
rc);
} else {
rc = cam_vfe_rdi_ver2_deinit(&top_priv->mux_rsrc[i]);
if (rc)
- pr_err("Error! RDI deinit failed rc=%d\n", rc);
+ CAM_ERR(CAM_ISP, "RDI deinit failed rc=%d", rc);
}
}
diff --git a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.h b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.h
index 0813202..bafd7f2 100644
--- a/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.h
+++ b/drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_top_ver2.h
@@ -52,6 +52,7 @@ struct cam_vfe_top_ver2_reg_offset_common {
struct cam_vfe_top_ver2_hw_info {
struct cam_vfe_top_ver2_reg_offset_common *common_reg;
struct cam_vfe_camif_ver2_hw_info camif_hw_info;
+ struct cam_vfe_rdi_ver2_hw_info rdi_hw_info;
uint32_t mux_type[CAM_VFE_TOP_VER2_MUX_MAX];
};
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c
index 2f9db97..c150244 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c
@@ -10,14 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CAM-MEM-MGR %s:%d " fmt, __func__, __LINE__
-
-#ifdef CONFIG_MEM_MGR_DBG
-#define CDBG(fmt, args...) pr_err(fmt, ##args)
-#else
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-#endif
-
#include <linux/module.h>
#include <linux/types.h>
#include <linux/mutex.h>
@@ -27,6 +19,7 @@
#include "cam_req_mgr_util.h"
#include "cam_mem_mgr.h"
#include "cam_smmu_api.h"
+#include "cam_debug_util.h"
static struct cam_mem_table tbl;
@@ -36,12 +29,12 @@ static int cam_mem_util_map_cpu_va(struct ion_handle *hdl,
{
*vaddr = (uintptr_t)ion_map_kernel(tbl.client, hdl);
if (IS_ERR_OR_NULL((void *)*vaddr)) {
- pr_err("kernel map fail");
+ CAM_ERR(CAM_CRM, "kernel map fail");
return -ENOSPC;
}
if (ion_handle_get_size(tbl.client, hdl, len)) {
- pr_err("kernel get len failed");
+ CAM_ERR(CAM_CRM, "kernel get len failed");
ion_unmap_kernel(tbl.client, hdl);
return -ENOSPC;
}
@@ -69,7 +62,7 @@ static int cam_mem_util_client_create(void)
tbl.client = msm_ion_client_create("camera_global_pool");
if (IS_ERR_OR_NULL(tbl.client)) {
- pr_err("fail to create client\n");
+ CAM_ERR(CAM_CRM, "fail to create client");
rc = -EINVAL;
}
@@ -92,7 +85,7 @@ int cam_mem_mgr_init(void)
rc = cam_mem_util_client_create();
if (rc < 0) {
- pr_err("fail to create ion client\n");
+ CAM_ERR(CAM_CRM, "fail to create ion client");
goto client_fail;
}
@@ -127,10 +120,12 @@ static int cam_mem_mgr_cleanup_table(void)
mutex_lock(&tbl.m_lock);
for (i = 1; i < CAM_MEM_BUFQ_MAX; i++) {
if (!tbl.bufq[i].active) {
- CDBG("Buffer inactive at idx=%d, continuing\n", i);
+ CAM_DBG(CAM_CRM,
+ "Buffer inactive at idx=%d, continuing", i);
continue;
} else {
- pr_err("Active buffer at idx=%d, possible leak\n", i);
+ CAM_ERR(CAM_CRM,
+ "Active buffer at idx=%d, possible leak", i);
}
mutex_lock(&tbl.bufq[i].q_lock);
@@ -221,7 +216,7 @@ int cam_mem_get_io_buf(int32_t buf_handle, int32_t mmu_handle,
iova_ptr,
len_ptr);
if (rc < 0)
- pr_err("fail to get buf hdl :%d", buf_handle);
+ CAM_ERR(CAM_CRM, "fail to get buf hdl :%d", buf_handle);
handle_mismatch:
mutex_unlock(&tbl.bufq[idx].q_lock);
@@ -255,7 +250,7 @@ int cam_mem_get_cpu_buf(int32_t buf_handle, uint64_t *vaddr_ptr, size_t *len)
ion_hdl = tbl.bufq[idx].i_hdl;
if (!ion_hdl) {
- pr_err("Invalid ION handle\n");
+ CAM_ERR(CAM_CRM, "Invalid ION handle");
rc = -EINVAL;
goto exit_func;
}
@@ -310,7 +305,7 @@ int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd)
rc = ion_handle_get_flags(tbl.client, tbl.bufq[idx].i_hdl,
&ion_flag);
if (rc) {
- pr_err("cache get flags failed %d\n", rc);
+ CAM_ERR(CAM_CRM, "cache get flags failed %d", rc);
goto fail;
}
@@ -326,7 +321,8 @@ int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd)
ion_cache_ops = ION_IOC_CLEAN_INV_CACHES;
break;
default:
- pr_err("invalid cache ops :%d", cmd->mem_cache_ops);
+ CAM_ERR(CAM_CRM,
+ "invalid cache ops :%d", cmd->mem_cache_ops);
rc = -EINVAL;
goto fail;
}
@@ -337,7 +333,7 @@ int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd)
tbl.bufq[idx].len,
ion_cache_ops);
if (rc)
- pr_err("cache operation failed %d\n", rc);
+ CAM_ERR(CAM_CRM, "cache operation failed %d", rc);
}
fail:
mutex_unlock(&tbl.bufq[idx].q_lock);
@@ -360,7 +356,7 @@ static int cam_mem_util_get_ion_buffer(size_t len,
*fd = ion_share_dma_buf_fd(tbl.client, *hdl);
if (*fd < 0) {
- pr_err("dma buf get fd fail");
+ CAM_ERR(CAM_CRM, "dma buf get fd fail");
rc = -EINVAL;
goto get_fd_fail;
}
@@ -404,19 +400,19 @@ static int cam_mem_util_ion_alloc(struct cam_mem_mgr_alloc_cmd *cmd,
static int cam_mem_util_check_flags(struct cam_mem_mgr_alloc_cmd *cmd)
{
if (!cmd->flags) {
- pr_err("Invalid flags\n");
+ CAM_ERR(CAM_CRM, "Invalid flags");
return -EINVAL;
}
if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) {
- pr_err("Num of mmu hdl exceeded maximum(%d)\n",
+ CAM_ERR(CAM_CRM, "Num of mmu hdl exceeded maximum(%d)",
CAM_MEM_MMU_MAX_HANDLE);
return -EINVAL;
}
if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE &&
cmd->flags & CAM_MEM_FLAG_KMD_ACCESS) {
- pr_err("Kernel mapping in secure mode not allowed");
+ CAM_ERR(CAM_CRM, "Kernel mapping in secure mode not allowed");
return -EINVAL;
}
@@ -426,24 +422,25 @@ static int cam_mem_util_check_flags(struct cam_mem_mgr_alloc_cmd *cmd)
static int cam_mem_util_check_map_flags(struct cam_mem_mgr_map_cmd *cmd)
{
if (!cmd->flags) {
- pr_err("Invalid flags\n");
+ CAM_ERR(CAM_CRM, "Invalid flags");
return -EINVAL;
}
if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) {
- pr_err("Num of mmu hdl exceeded maximum(%d)\n",
+ CAM_ERR(CAM_CRM, "Num of mmu hdl exceeded maximum(%d)",
CAM_MEM_MMU_MAX_HANDLE);
return -EINVAL;
}
if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE &&
cmd->flags & CAM_MEM_FLAG_KMD_ACCESS) {
- pr_err("Kernel mapping in secure mode not allowed");
+ CAM_ERR(CAM_CRM, "Kernel mapping in secure mode not allowed");
return -EINVAL;
}
if (cmd->flags & CAM_MEM_FLAG_HW_SHARED_ACCESS) {
- pr_err("Shared memory buffers are not allowed to be mapped\n");
+ CAM_ERR(CAM_CRM,
+ "Shared memory buffers are not allowed to be mapped");
return -EINVAL;
}
@@ -463,7 +460,7 @@ static int cam_mem_util_map_hw_va(uint32_t flags,
int dir = cam_mem_util_get_dma_dir(flags);
if (dir < 0) {
- pr_err("fail to map DMA direction\n");
+ CAM_ERR(CAM_CRM, "fail to map DMA direction");
return dir;
}
@@ -476,7 +473,8 @@ static int cam_mem_util_map_hw_va(uint32_t flags,
len);
if (rc < 0) {
- pr_err("Failed to securely map to smmu");
+ CAM_ERR(CAM_CRM,
+ "Failed to securely map to smmu");
goto multi_map_fail;
}
}
@@ -490,7 +488,7 @@ static int cam_mem_util_map_hw_va(uint32_t flags,
region);
if (rc < 0) {
- pr_err("Failed to map to smmu");
+ CAM_ERR(CAM_CRM, "Failed to map to smmu");
goto multi_map_fail;
}
}
@@ -520,14 +518,14 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd)
size_t len;
if (!cmd) {
- pr_err(" Invalid argument\n");
+ CAM_ERR(CAM_CRM, " Invalid argument");
return -EINVAL;
}
len = cmd->len;
rc = cam_mem_util_check_flags(cmd);
if (rc) {
- pr_err("Invalid flags: flags = %X\n", cmd->flags);
+ CAM_ERR(CAM_CRM, "Invalid flags: flags = %X", cmd->flags);
return rc;
}
@@ -535,7 +533,7 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd)
&ion_hdl,
&ion_fd);
if (rc) {
- pr_err("Ion allocation failed\n");
+ CAM_ERR(CAM_CRM, "Ion allocation failed");
return rc;
}
@@ -591,7 +589,7 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd)
cmd->out.fd = tbl.bufq[idx].fd;
cmd->out.vaddr = 0;
- CDBG("buf handle: %x, fd: %d, len: %zu\n",
+ CAM_DBG(CAM_CRM, "buf handle: %x, fd: %d, len: %zu",
cmd->out.buf_handle, cmd->out.fd,
tbl.bufq[idx].len);
@@ -613,7 +611,7 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
size_t len = 0;
if (!cmd || (cmd->fd < 0)) {
- pr_err("Invalid argument\n");
+ CAM_ERR(CAM_CRM, "Invalid argument");
return -EINVAL;
}
@@ -622,13 +620,13 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
rc = cam_mem_util_check_map_flags(cmd);
if (rc) {
- pr_err("Invalid flags: flags = %X\n", cmd->flags);
+ CAM_ERR(CAM_CRM, "Invalid flags: flags = %X", cmd->flags);
return rc;
}
ion_hdl = ion_import_dma_buf_fd(tbl.client, cmd->fd);
if (IS_ERR_OR_NULL((void *)(ion_hdl))) {
- pr_err("Failed to import ion fd\n");
+ CAM_ERR(CAM_CRM, "Failed to import ion fd");
return -EINVAL;
}
@@ -690,7 +688,7 @@ static int cam_mem_util_unmap_hw_va(int32_t idx,
int rc = -EINVAL;
if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) {
- pr_err("Incorrect index\n");
+ CAM_ERR(CAM_CRM, "Incorrect index");
return rc;
}
@@ -725,11 +723,11 @@ static int cam_mem_util_unmap(int32_t idx)
enum cam_smmu_region_id region = CAM_SMMU_REGION_SHARED;
if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) {
- pr_err("Incorrect index\n");
+ CAM_ERR(CAM_CRM, "Incorrect index");
return -EINVAL;
}
- CDBG("Flags = %X\n", tbl.bufq[idx].flags);
+ CAM_DBG(CAM_CRM, "Flags = %X", tbl.bufq[idx].flags);
if (tbl.bufq[idx].flags & CAM_MEM_FLAG_KMD_ACCESS)
if (tbl.bufq[idx].i_hdl && tbl.bufq[idx].kmdvaddr)
@@ -755,7 +753,8 @@ static int cam_mem_util_unmap(int32_t idx)
memset(tbl.bufq[idx].hdls, 0,
sizeof(int32_t) * CAM_MEM_MMU_MAX_HANDLE);
- CDBG("Ion handle at idx = %d freeing = %pK, fd = %d, imported %d\n",
+ CAM_DBG(CAM_CRM,
+ "Ion handle at idx = %d freeing = %pK, fd = %d, imported %d",
idx, tbl.bufq[idx].i_hdl, tbl.bufq[idx].fd,
tbl.bufq[idx].is_imported);
@@ -780,27 +779,28 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd)
int rc;
if (!cmd) {
- pr_err("Invalid argument\n");
+ CAM_ERR(CAM_CRM, "Invalid argument");
return -EINVAL;
}
idx = CAM_MEM_MGR_GET_HDL_IDX(cmd->buf_handle);
if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) {
- pr_err("Incorrect index extracted from mem handle\n");
+ CAM_ERR(CAM_CRM, "Incorrect index extracted from mem handle");
return -EINVAL;
}
if (!tbl.bufq[idx].active) {
- pr_err("Released buffer state should be active\n");
+ CAM_ERR(CAM_CRM, "Released buffer state should be active");
return -EINVAL;
}
if (tbl.bufq[idx].buf_handle != cmd->buf_handle) {
- pr_err("Released buf handle not matching within table\n");
+ CAM_ERR(CAM_CRM,
+ "Released buf handle not matching within table");
return -EINVAL;
}
- CDBG("Releasing hdl = %u\n", cmd->buf_handle);
+ CAM_DBG(CAM_CRM, "Releasing hdl = %u", cmd->buf_handle);
rc = cam_mem_util_unmap(idx);
return rc;
@@ -824,14 +824,14 @@ int cam_mem_mgr_request_mem(struct cam_mem_mgr_request_desc *inp,
enum cam_smmu_region_id region = CAM_SMMU_REGION_SHARED;
if (!inp || !out) {
- pr_err("Invalid params\n");
+ CAM_ERR(CAM_CRM, "Invalid params");
return -EINVAL;
}
if (!(inp->flags & CAM_MEM_FLAG_HW_READ_WRITE ||
inp->flags & CAM_MEM_FLAG_HW_SHARED_ACCESS ||
inp->flags & CAM_MEM_FLAG_CACHE)) {
- pr_err("Invalid flags for request mem\n");
+ CAM_ERR(CAM_CRM, "Invalid flags for request mem");
return -EINVAL;
}
@@ -850,20 +850,20 @@ int cam_mem_mgr_request_mem(struct cam_mem_mgr_request_desc *inp,
&ion_fd);
if (rc) {
- pr_err("ION alloc failed for shared buffer\n");
+ CAM_ERR(CAM_CRM, "ION alloc failed for shared buffer");
goto ion_fail;
} else {
- CDBG("Got ION fd = %d, hdl = %pK\n", ion_fd, hdl);
+ CAM_DBG(CAM_CRM, "Got ION fd = %d, hdl = %pK", ion_fd, hdl);
}
rc = cam_mem_util_map_cpu_va(hdl, &kvaddr, &request_len);
if (rc) {
- pr_err("Failed to get kernel vaddr\n");
+ CAM_ERR(CAM_CRM, "Failed to get kernel vaddr");
goto map_fail;
}
if (!inp->smmu_hdl) {
- pr_err("Invalid SMMU handle\n");
+ CAM_ERR(CAM_CRM, "Invalid SMMU handle");
rc = -EINVAL;
goto smmu_fail;
}
@@ -884,7 +884,7 @@ int cam_mem_mgr_request_mem(struct cam_mem_mgr_request_desc *inp,
region);
if (rc < 0) {
- pr_err("SMMU mapping failed\n");
+ CAM_ERR(CAM_CRM, "SMMU mapping failed");
goto smmu_fail;
}
@@ -941,27 +941,28 @@ int cam_mem_mgr_release_mem(struct cam_mem_mgr_memory_desc *inp)
int rc;
if (!inp) {
- pr_err("Invalid argument\n");
+ CAM_ERR(CAM_CRM, "Invalid argument");
return -EINVAL;
}
idx = CAM_MEM_MGR_GET_HDL_IDX(inp->mem_handle);
if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) {
- pr_err("Incorrect index extracted from mem handle\n");
+ CAM_ERR(CAM_CRM, "Incorrect index extracted from mem handle");
return -EINVAL;
}
if (!tbl.bufq[idx].active) {
- pr_err("Released buffer state should be active\n");
+ CAM_ERR(CAM_CRM, "Released buffer state should be active");
return -EINVAL;
}
if (tbl.bufq[idx].buf_handle != inp->mem_handle) {
- pr_err("Released buf handle not matching within table\n");
+ CAM_ERR(CAM_CRM,
+ "Released buf handle not matching within table");
return -EINVAL;
}
- CDBG("Releasing hdl = %X\n", inp->mem_handle);
+ CAM_DBG(CAM_CRM, "Releasing hdl = %X", inp->mem_handle);
rc = cam_mem_util_unmap(idx);
return rc;
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c
index f5dfcf2..3fd42f7 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c
@@ -20,6 +20,7 @@
#include "cam_req_mgr_workq.h"
#include "cam_req_mgr_debug.h"
#include "cam_trace.h"
+#include "cam_debug_util.h"
static struct cam_req_mgr_core_device *g_crm_core_dev;
@@ -59,24 +60,25 @@ static int __cam_req_mgr_print_req_tbl(struct cam_req_mgr_req_data *req)
struct cam_req_mgr_req_tbl *req_tbl = req->l_tbl;
if (!in_q || !req_tbl) {
- CRM_WARN("NULL pointer %pK %pK", in_q, req_tbl);
+ CAM_WARN(CAM_CRM, "NULL pointer %pK %pK", in_q, req_tbl);
return -EINVAL;
}
- CRM_DBG("in_q %pK %pK %d", in_q, req_tbl, req_tbl->num_slots);
+ CAM_DBG(CAM_CRM, "in_q %pK %pK %d", in_q, req_tbl, req_tbl->num_slots);
mutex_lock(&req->lock);
for (i = 0; i < in_q->num_slots; i++) {
- CRM_DBG("IN_Q %d: idx %d, red_id %lld", i,
+ CAM_DBG(CAM_CRM, "IN_Q %d: idx %d, red_id %lld", i,
in_q->slot[i].idx, CRM_GET_REQ_ID(in_q, i));
}
while (req_tbl != NULL) {
for (i = 0; i < req_tbl->num_slots; i++) {
- CRM_DBG("idx= %d, map= %x, state= %d",
+ CAM_DBG(CAM_CRM, "idx= %d, map= %x, state= %d",
req_tbl->slot[i].idx,
req_tbl->slot[i].req_ready_map,
req_tbl->slot[i].state);
}
- CRM_DBG("TBL:id= %d, pd=%d cnt=%d mask=%x skip=%d num_slt= %d",
+ CAM_DBG(CAM_CRM,
+ "TBL:id= %d, pd=%d cnt=%d mask=%x skip=%d num_slt= %d",
req_tbl->id, req_tbl->pd, req_tbl->dev_count,
req_tbl->dev_mask, req_tbl->skip_traverse,
req_tbl->num_slots);
@@ -166,7 +168,7 @@ static int __cam_req_mgr_traverse(struct cam_req_mgr_traverse *traverse_data)
struct cam_req_mgr_apply *apply_data;
if (!traverse_data->tbl || !traverse_data->apply_data) {
- CRM_ERR("NULL pointer %pK %pK",
+ CAM_ERR(CAM_CRM, "NULL pointer %pK %pK",
traverse_data->tbl, traverse_data->apply_data);
traverse_data->result = 0;
return -EINVAL;
@@ -174,7 +176,7 @@ static int __cam_req_mgr_traverse(struct cam_req_mgr_traverse *traverse_data)
tbl = traverse_data->tbl;
apply_data = traverse_data->apply_data;
- CRM_DBG("Enter pd %d idx %d state %d skip %d status %d",
+ CAM_DBG(CAM_CRM, "Enter pd %d idx %d state %d skip %d status %d",
tbl->pd, curr_idx, tbl->slot[curr_idx].state,
tbl->skip_traverse, traverse_data->in_q->slot[curr_idx].status);
@@ -229,7 +231,7 @@ static void __cam_req_mgr_in_q_skip_idx(struct cam_req_mgr_req_queue *in_q,
in_q->slot[idx].req_id = -1;
in_q->slot[idx].skip_idx = 1;
in_q->slot[idx].status = CRM_SLOT_STATUS_REQ_ADDED;
- CRM_DBG("SET IDX SKIP on slot= %d", idx);
+ CAM_DBG(CAM_CRM, "SET IDX SKIP on slot= %d", idx);
}
/**
@@ -247,7 +249,7 @@ static void __cam_req_mgr_tbl_set_id(struct cam_req_mgr_req_tbl *tbl,
return;
do {
tbl->id = req->num_tbl++;
- CRM_DBG("%d: pd %d skip_traverse %d delta %d",
+ CAM_DBG(CAM_CRM, "%d: pd %d skip_traverse %d delta %d",
tbl->id, tbl->pd, tbl->skip_traverse,
tbl->pd_delta);
tbl = tbl->next;
@@ -276,7 +278,7 @@ static void __cam_req_mgr_tbl_set_all_skip_cnt(
max_pd = tbl->pd;
do {
tbl->skip_traverse = max_pd - tbl->pd;
- CRM_DBG("%d: pd %d skip_traverse %d delta %d",
+ CAM_DBG(CAM_CRM, "%d: pd %d skip_traverse %d delta %d",
tbl->id, tbl->pd, tbl->skip_traverse,
tbl->pd_delta);
tbl = tbl->next;
@@ -299,7 +301,7 @@ static void __cam_req_mgr_reset_req_slot(struct cam_req_mgr_core_link *link,
struct cam_req_mgr_req_queue *in_q = link->req.in_q;
slot = &in_q->slot[idx];
- CRM_DBG("RESET: idx: %d: slot->status %d", idx, slot->status);
+ CAM_DBG(CAM_CRM, "RESET: idx: %d: slot->status %d", idx, slot->status);
/* Check if CSL has already pushed new request*/
if (slot->status == CRM_SLOT_STATUS_REQ_ADDED)
@@ -313,7 +315,7 @@ static void __cam_req_mgr_reset_req_slot(struct cam_req_mgr_core_link *link,
/* Reset all pd table slot */
while (tbl != NULL) {
- CRM_DBG("pd: %d: idx %d state %d",
+ CAM_DBG(CAM_CRM, "pd: %d: idx %d state %d",
tbl->pd, idx, tbl->slot[idx].state);
tbl->slot[idx].req_ready_map = 0;
tbl->slot[idx].state = CRM_REQ_STATE_EMPTY;
@@ -339,13 +341,14 @@ static void __cam_req_mgr_check_next_req_slot(
__cam_req_mgr_inc_idx(&idx, 1, in_q->num_slots);
slot = &in_q->slot[idx];
- CRM_DBG("idx: %d: slot->status %d", idx, slot->status);
+ CAM_DBG(CAM_CRM, "idx: %d: slot->status %d", idx, slot->status);
/* Check if there is new req from CSL, if not complete req */
if (slot->status == CRM_SLOT_STATUS_NO_REQ) {
__cam_req_mgr_in_q_skip_idx(in_q, idx);
if (in_q->wr_idx != idx)
- CRM_WARN("CHECK here wr %d, rd %d", in_q->wr_idx, idx);
+ CAM_WARN(CAM_CRM,
+ "CHECK here wr %d, rd %d", in_q->wr_idx, idx);
__cam_req_mgr_inc_idx(&in_q->wr_idx, 1, in_q->num_slots);
}
}
@@ -377,13 +380,13 @@ static int __cam_req_mgr_send_req(struct cam_req_mgr_core_link *link,
if (dev) {
pd = dev->dev_info.p_delay;
if (pd >= CAM_PIPELINE_DELAY_MAX) {
- CRM_WARN("pd %d greater than max",
+ CAM_WARN(CAM_CRM, "pd %d greater than max",
pd);
continue;
}
if (link->req.apply_data[pd].skip_idx ||
link->req.apply_data[pd].req_id < 0) {
- CRM_DBG("skip %d req_id %lld",
+ CAM_DBG(CAM_CRM, "skip %d req_id %lld",
link->req.apply_data[pd].skip_idx,
link->req.apply_data[pd].req_id);
continue;
@@ -394,7 +397,10 @@ static int __cam_req_mgr_send_req(struct cam_req_mgr_core_link *link,
idx = link->req.apply_data[pd].idx;
apply_req.report_if_bubble =
in_q->slot[idx].recover;
- CRM_DBG("SEND: pd %d req_id %lld",
+
+ trace_cam_req_mgr_apply_request(link, &apply_req, dev);
+
+ CAM_DBG(CAM_CRM, "SEND: pd %d req_id %lld",
pd, apply_req.request_id);
if (dev->ops && dev->ops->apply_req) {
rc = dev->ops->apply_req(&apply_req);
@@ -404,7 +410,7 @@ static int __cam_req_mgr_send_req(struct cam_req_mgr_core_link *link,
}
}
if (rc < 0) {
- CRM_ERR("APPLY FAILED pd %d req_id %lld",
+ CAM_ERR(CAM_CRM, "APPLY FAILED pd %d req_id %lld",
dev->dev_info.p_delay, apply_req.request_id);
/* Apply req failed notify already applied devs */
for (; i >= 0; i--) {
@@ -457,11 +463,12 @@ static int __cam_req_mgr_check_link_is_ready(struct cam_req_mgr_core_link *link,
*/
rc = __cam_req_mgr_traverse(&traverse_data);
- CRM_DBG("SOF: idx %d result %x pd_mask %x rc %d",
+ CAM_DBG(CAM_CRM, "SOF: idx %d result %x pd_mask %x rc %d",
idx, traverse_data.result, link->pd_mask, rc);
if (!rc && traverse_data.result == link->pd_mask) {
- CRM_DBG("APPLY: link_hdl= %x idx= %d, req_id= %lld :%lld :%lld",
+ CAM_DBG(CAM_CRM,
+ "APPLY: link_hdl= %x idx= %d, req_id= %lld :%lld :%lld",
link->link_hdl, idx,
apply_data[2].req_id, apply_data[1].req_id,
apply_data[0].req_id);
@@ -498,12 +505,12 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link)
* - if in applied_state, somthign wrong.
* - if in no_req state, no new req
*/
- CRM_DBG("idx %d req_status %d",
+ CAM_DBG(CAM_CRM, "idx %d req_status %d",
in_q->rd_idx, in_q->slot[in_q->rd_idx].status);
slot = &in_q->slot[in_q->rd_idx];
if (slot->status == CRM_SLOT_STATUS_NO_REQ) {
- CRM_DBG("No Pending req");
+ CAM_DBG(CAM_CRM, "No Pending req");
return 0;
}
@@ -517,7 +524,8 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link)
slot->status = CRM_SLOT_STATUS_REQ_APPLIED;
if (link->state == CAM_CRM_LINK_STATE_ERR) {
- CRM_WARN("Err recovery done idx %d status %d",
+ CAM_WARN(CAM_CRM,
+ "Err recovery done idx %d status %d",
in_q->rd_idx,
in_q->slot[in_q->rd_idx].status);
mutex_lock(&link->lock);
@@ -553,7 +561,8 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link)
* don't expect to enter here.
* @TODO: gracefully handle if recovery fails.
*/
- CRM_ERR("FATAL recovery cant finish idx %d status %d",
+ CAM_ERR(CAM_CRM,
+ "FATAL recovery cant finish idx %d status %d",
in_q->rd_idx, in_q->slot[in_q->rd_idx].status);
rc = -EPERM;
}
@@ -601,7 +610,7 @@ static void __cam_req_mgr_add_tbl_to_link(struct cam_req_mgr_req_tbl **l_tbl,
tbl->next = new_tbl;
tbl->pd_delta = tbl->pd - new_tbl->pd;
}
- CRM_DBG("added pd %d tbl to link delta %d", new_tbl->pd,
+ CAM_DBG(CAM_CRM, "added pd %d tbl to link delta %d", new_tbl->pd,
new_tbl->pd_delta);
}
@@ -620,7 +629,7 @@ static struct cam_req_mgr_req_tbl *__cam_req_mgr_create_pd_tbl(int32_t delay)
kzalloc(sizeof(struct cam_req_mgr_req_tbl), GFP_KERNEL);
if (tbl != NULL) {
tbl->num_slots = MAX_REQ_SLOTS;
- CRM_DBG("pd= %d slots= %d", delay, tbl->num_slots);
+ CAM_DBG(CAM_CRM, "pd= %d slots= %d", delay, tbl->num_slots);
}
return tbl;
@@ -637,7 +646,7 @@ static void __cam_req_mgr_destroy_all_tbl(struct cam_req_mgr_req_tbl **l_tbl)
{
struct cam_req_mgr_req_tbl *tbl = *l_tbl, *temp;
- CRM_DBG("*l_tbl %pK", tbl);
+ CAM_DBG(CAM_CRM, "*l_tbl %pK", tbl);
while (tbl != NULL) {
temp = tbl->next;
kfree(tbl);
@@ -666,7 +675,7 @@ static int32_t __cam_req_mgr_find_slot_for_req(
for (i = 0; i < in_q->num_slots; i++) {
slot = &in_q->slot[idx];
if (slot->req_id == req_id) {
- CRM_DBG("req %lld found at %d %d status %d",
+ CAM_DBG(CAM_CRM, "req %lld found at %d %d status %d",
req_id, idx, slot->idx,
slot->status);
break;
@@ -694,7 +703,7 @@ static int __cam_req_mgr_setup_in_q(struct cam_req_mgr_req_data *req)
struct cam_req_mgr_req_queue *in_q = req->in_q;
if (!in_q) {
- CRM_ERR("NULL in_q");
+ CAM_ERR(CAM_CRM, "NULL in_q");
return -EINVAL;
}
@@ -729,7 +738,7 @@ static int __cam_req_mgr_reset_in_q(struct cam_req_mgr_req_data *req)
struct cam_req_mgr_req_queue *in_q = req->in_q;
if (!in_q) {
- CRM_ERR("NULL in_q");
+ CAM_ERR(CAM_CRM, "NULL in_q");
return -EINVAL;
}
@@ -758,11 +767,11 @@ static void __cam_req_mgr_sof_freeze(unsigned long data)
struct cam_req_mgr_core_link *link = NULL;
if (!timer) {
- CRM_ERR("NULL timer");
+ CAM_ERR(CAM_CRM, "NULL timer");
return;
}
link = (struct cam_req_mgr_core_link *)timer->parent;
- CRM_ERR("SOF freeze for link %x", link->link_hdl);
+ CAM_ERR(CAM_CRM, "SOF freeze for link %x", link->link_hdl);
}
/**
@@ -859,12 +868,12 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link(
struct cam_req_mgr_req_queue *in_q;
if (!session || !g_crm_core_dev) {
- CRM_ERR("NULL session/core_dev ptr");
+ CAM_ERR(CAM_CRM, "NULL session/core_dev ptr");
return NULL;
}
if (session->num_links >= MAX_LINKS_PER_SESSION) {
- CRM_ERR("Reached max links %d per session limit %d",
+ CAM_ERR(CAM_CRM, "Reached max links %d per session limit %d",
session->num_links, MAX_LINKS_PER_SESSION);
return NULL;
}
@@ -872,7 +881,7 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link(
link = (struct cam_req_mgr_core_link *)
kzalloc(sizeof(struct cam_req_mgr_core_link), GFP_KERNEL);
if (!link) {
- CRM_ERR("failed to create link, no mem");
+ CAM_ERR(CAM_CRM, "failed to create link, no mem");
return NULL;
}
in_q = &session->in_q;
@@ -893,7 +902,7 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link(
mutex_lock(&session->lock);
session->links[session->num_links] = link;
session->num_links++;
- CRM_DBG("Active session links (%d)",
+ CAM_DBG(CAM_CRM, "Active session links (%d)",
session->num_links);
mutex_unlock(&session->lock);
@@ -915,14 +924,14 @@ static void __cam_req_mgr_unreserve_link(
int32_t i = 0;
if (!session || !*link) {
- CRM_ERR("NULL session/link ptr %pK %pK",
+ CAM_ERR(CAM_CRM, "NULL session/link ptr %pK %pK",
session, *link);
return;
}
mutex_lock(&session->lock);
if (!session->num_links)
- CRM_WARN("No active link or invalid state %d",
+ CAM_WARN(CAM_CRM, "No active link or invalid state %d",
session->num_links);
else {
for (i = 0; i < session->num_links; i++) {
@@ -930,7 +939,7 @@ static void __cam_req_mgr_unreserve_link(
session->links[i] = NULL;
}
session->num_links--;
- CRM_DBG("Active session links (%d)",
+ CAM_DBG(CAM_CRM, "Active session links (%d)",
session->num_links);
}
kfree(*link);
@@ -959,7 +968,7 @@ int cam_req_mgr_process_send_req(void *priv, void *data)
struct cam_req_mgr_req_queue *in_q = NULL;
if (!data || !priv) {
- CRM_ERR("input args NULL %pK %pK", data, priv);
+ CAM_ERR(CAM_CRM, "input args NULL %pK %pK", data, priv);
rc = -EINVAL;
goto end;
}
@@ -994,21 +1003,21 @@ int cam_req_mgr_process_flush_req(void *priv, void *data)
struct crm_task_payload *task_data = NULL;
if (!data || !priv) {
- CRM_ERR("input args NULL %pK %pK", data, priv);
+ CAM_ERR(CAM_CRM, "input args NULL %pK %pK", data, priv);
rc = -EINVAL;
goto end;
}
link = (struct cam_req_mgr_core_link *)priv;
task_data = (struct crm_task_payload *)data;
flush_info = (struct cam_req_mgr_flush_info *)&task_data->u;
- CRM_DBG("link_hdl %x req_id %lld type %d",
+ CAM_DBG(CAM_CRM, "link_hdl %x req_id %lld type %d",
flush_info->link_hdl,
flush_info->req_id,
flush_info->flush_type);
in_q = link->req.in_q;
- trace_cam_flush_req(flush_info);
+ trace_cam_flush_req(link, flush_info);
mutex_lock(&link->req.lock);
if (flush_info->flush_type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
@@ -1024,15 +1033,16 @@ int cam_req_mgr_process_flush_req(void *priv, void *data)
CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ) {
idx = __cam_req_mgr_find_slot_for_req(in_q, flush_info->req_id);
if (idx < 0) {
- CRM_ERR("req_id %lld not found in input queue",
+ CAM_ERR(CAM_CRM, "req_id %lld not found in input queue",
flush_info->req_id);
} else {
- CRM_DBG("req_id %lld found at idx %d",
+ CAM_DBG(CAM_CRM, "req_id %lld found at idx %d",
flush_info->req_id, idx);
slot = &in_q->slot[idx];
if (slot->status == CRM_SLOT_STATUS_REQ_PENDING ||
slot->status == CRM_SLOT_STATUS_REQ_APPLIED) {
- CRM_WARN("req_id %lld can not be cancelled",
+ CAM_WARN(CAM_CRM,
+ "req_id %lld can not be cancelled",
flush_info->req_id);
mutex_unlock(&link->req.lock);
return -EINVAL;
@@ -1078,14 +1088,14 @@ int cam_req_mgr_process_sched_req(void *priv, void *data)
struct crm_task_payload *task_data = NULL;
if (!data || !priv) {
- CRM_ERR("input args NULL %pK %pK", data, priv);
+ CAM_ERR(CAM_CRM, "input args NULL %pK %pK", data, priv);
rc = -EINVAL;
goto end;
}
link = (struct cam_req_mgr_core_link *)priv;
task_data = (struct crm_task_payload *)data;
sched_req = (struct cam_req_mgr_sched_request *)&task_data->u;
- CRM_DBG("link_hdl %x req_id %lld",
+ CAM_DBG(CAM_CRM, "link_hdl %x req_id %lld",
sched_req->link_hdl,
sched_req->req_id);
@@ -1096,9 +1106,9 @@ int cam_req_mgr_process_sched_req(void *priv, void *data)
if (slot->status != CRM_SLOT_STATUS_NO_REQ &&
slot->status != CRM_SLOT_STATUS_REQ_APPLIED)
- CRM_WARN("in_q overwrite %d", slot->status);
+ CAM_WARN(CAM_CRM, "in_q overwrite %d", slot->status);
- CRM_DBG("sched_req %lld at slot %d",
+ CAM_DBG(CAM_CRM, "sched_req %lld at slot %d",
sched_req->req_id, in_q->wr_idx);
slot->status = CRM_SLOT_STATUS_REQ_ADDED;
@@ -1133,7 +1143,7 @@ int cam_req_mgr_process_add_req(void *priv, void *data)
struct crm_task_payload *task_data = NULL;
if (!data || !priv) {
- CRM_ERR("input args NULL %pK %pK", data, priv);
+ CAM_ERR(CAM_CRM, "input args NULL %pK %pK", data, priv);
rc = -EINVAL;
goto end;
}
@@ -1150,7 +1160,7 @@ int cam_req_mgr_process_add_req(void *priv, void *data)
}
}
if (!tbl) {
- CRM_ERR("dev_hdl not found %x, %x %x",
+ CAM_ERR(CAM_CRM, "dev_hdl not found %x, %x %x",
add_req->dev_hdl,
link->l_dev[0].dev_hdl,
link->l_dev[1].dev_hdl);
@@ -1168,7 +1178,7 @@ int cam_req_mgr_process_add_req(void *priv, void *data)
mutex_lock(&link->req.lock);
idx = __cam_req_mgr_find_slot_for_req(link->req.in_q, add_req->req_id);
if (idx < 0) {
- CRM_ERR("req %lld not found in in_q", add_req->req_id);
+ CAM_ERR(CAM_CRM, "req %lld not found in in_q", add_req->req_id);
rc = -EBADSLT;
mutex_unlock(&link->req.lock);
goto end;
@@ -1176,19 +1186,21 @@ int cam_req_mgr_process_add_req(void *priv, void *data)
slot = &tbl->slot[idx];
if (slot->state != CRM_REQ_STATE_PENDING &&
slot->state != CRM_REQ_STATE_EMPTY) {
- CRM_WARN("Unexpected state %d for slot %d map %x",
+ CAM_WARN(CAM_CRM, "Unexpected state %d for slot %d map %x",
slot->state, idx, slot->req_ready_map);
}
slot->state = CRM_REQ_STATE_PENDING;
slot->req_ready_map |= (1 << device->dev_bit);
- CRM_DBG("idx %d dev_hdl %x req_id %lld pd %d ready_map %x",
+ CAM_DBG(CAM_CRM, "idx %d dev_hdl %x req_id %lld pd %d ready_map %x",
idx, add_req->dev_hdl, add_req->req_id, tbl->pd,
slot->req_ready_map);
+ trace_cam_req_mgr_add_req(link, idx, add_req, tbl, device);
+
if (slot->req_ready_map == tbl->dev_mask) {
- CRM_DBG("idx %d req_id %lld pd %d SLOT READY",
+ CAM_DBG(CAM_CRM, "idx %d req_id %lld pd %d SLOT READY",
idx, add_req->req_id, tbl->pd);
slot->state = CRM_REQ_STATE_READY;
}
@@ -1219,14 +1231,14 @@ int cam_req_mgr_process_error(void *priv, void *data)
struct crm_task_payload *task_data = NULL;
if (!data || !priv) {
- CRM_ERR("input args NULL %pK %pK", data, priv);
+ CAM_ERR(CAM_CRM, "input args NULL %pK %pK", data, priv);
rc = -EINVAL;
goto end;
}
link = (struct cam_req_mgr_core_link *)priv;
task_data = (struct crm_task_payload *)data;
err_info = (struct cam_req_mgr_error_notify *)&task_data->u;
- CRM_DBG("link_hdl %x req_id %lld error %d",
+ CAM_DBG(CAM_CRM, "link_hdl %x req_id %lld error %d",
err_info->link_hdl,
err_info->req_id,
err_info->error);
@@ -1237,20 +1249,22 @@ int cam_req_mgr_process_error(void *priv, void *data)
if (err_info->error == CRM_KMD_ERR_BUBBLE) {
idx = __cam_req_mgr_find_slot_for_req(in_q, err_info->req_id);
if (idx < 0) {
- CRM_ERR("req_id %lld not found in input queue",
+ CAM_ERR(CAM_CRM, "req_id %lld not found in input queue",
err_info->req_id);
} else {
- CRM_DBG("req_id %lld found at idx %d",
+ CAM_DBG(CAM_CRM, "req_id %lld found at idx %d",
err_info->req_id, idx);
slot = &in_q->slot[idx];
if (!slot->recover) {
- CRM_WARN("err recovery disabled req_id %lld",
+ CAM_WARN(CAM_CRM,
+ "err recovery disabled req_id %lld",
err_info->req_id);
mutex_unlock(&link->req.lock);
return 0;
} else if (slot->status != CRM_SLOT_STATUS_REQ_PENDING
&& slot->status != CRM_SLOT_STATUS_REQ_APPLIED) {
- CRM_WARN("req_id %lld can not be recovered %d",
+ CAM_WARN(CAM_CRM,
+ "req_id %lld can not be recovered %d",
err_info->req_id, slot->status);
mutex_unlock(&link->req.lock);
return -EINVAL;
@@ -1305,7 +1319,7 @@ static int cam_req_mgr_process_sof(void *priv, void *data)
struct crm_task_payload *task_data = NULL;
if (!data || !priv) {
- CRM_ERR("input args NULL %pK %pK", data, priv);
+ CAM_ERR(CAM_CRM, "input args NULL %pK %pK", data, priv);
rc = -EINVAL;
goto end;
}
@@ -1313,7 +1327,7 @@ static int cam_req_mgr_process_sof(void *priv, void *data)
task_data = (struct crm_task_payload *)data;
sof_data = (struct cam_req_mgr_sof_notify *)&task_data->u;
- CRM_DBG("link_hdl %x frame_id %lld",
+ CAM_DBG(CAM_CRM, "link_hdl %x frame_id %lld",
sof_data->link_hdl,
sof_data->frame_id);
@@ -1324,11 +1338,11 @@ static int cam_req_mgr_process_sof(void *priv, void *data)
* Check if current read index is in applied state, if yes make it free
* and increment read index to next slot.
*/
- CRM_DBG("link_hdl %x curent idx %d req_status %d",
+ CAM_DBG(CAM_CRM, "link_hdl %x curent idx %d req_status %d",
link->link_hdl, in_q->rd_idx, in_q->slot[in_q->rd_idx].status);
if (link->state == CAM_CRM_LINK_STATE_ERR)
- CRM_WARN("Error recovery idx %d status %d",
+ CAM_WARN(CAM_CRM, "Error recovery idx %d status %d",
in_q->rd_idx,
in_q->slot[in_q->rd_idx].status);
@@ -1367,17 +1381,18 @@ static int cam_req_mgr_cb_add_req(struct cam_req_mgr_add_request *add_req)
struct crm_task_payload *task_data;
if (!add_req) {
- CRM_ERR("sof_data is NULL");
+ CAM_ERR(CAM_CRM, "sof_data is NULL");
rc = -EINVAL;
goto end;
}
- CRM_DBG("E: dev %x dev req %lld", add_req->dev_hdl, add_req->req_id);
+ CAM_DBG(CAM_CRM, "E: dev %x dev req %lld",
+ add_req->dev_hdl, add_req->req_id);
link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(add_req->link_hdl);
if (!link) {
- CRM_DBG("link ptr NULL %x", add_req->link_hdl);
+ CAM_DBG(CAM_CRM, "link ptr NULL %x", add_req->link_hdl);
rc = -EINVAL;
goto end;
}
@@ -1385,14 +1400,14 @@ static int cam_req_mgr_cb_add_req(struct cam_req_mgr_add_request *add_req)
/* Validate if req id is present in input queue */
idx = __cam_req_mgr_find_slot_for_req(link->req.in_q, add_req->req_id);
if (idx < 0) {
- CRM_ERR("req %lld not found in in_q", add_req->req_id);
+ CAM_ERR(CAM_CRM, "req %lld not found in in_q", add_req->req_id);
rc = -ENOENT;
goto end;
}
task = cam_req_mgr_workq_get_task(link->workq);
if (!task) {
- CRM_ERR("no empty task dev %x req %lld",
+ CAM_ERR(CAM_CRM, "no empty task dev %x req %lld",
add_req->dev_hdl, add_req->req_id);
rc = -EBUSY;
goto end;
@@ -1406,7 +1421,8 @@ static int cam_req_mgr_cb_add_req(struct cam_req_mgr_add_request *add_req)
dev_req->dev_hdl = add_req->dev_hdl;
task->process_cb = &cam_req_mgr_process_add_req;
rc = cam_req_mgr_workq_enqueue_task(task, link, CRM_TASK_PRIORITY_0);
- CRM_DBG("X: dev %x dev req %lld", add_req->dev_hdl, add_req->req_id);
+ CAM_DBG(CAM_CRM, "X: dev %x dev req %lld",
+ add_req->dev_hdl, add_req->req_id);
end:
return rc;
@@ -1431,7 +1447,7 @@ static int cam_req_mgr_cb_notify_err(
struct crm_task_payload *task_data;
if (!err_info) {
- CRM_ERR("err_info is NULL");
+ CAM_ERR(CAM_CRM, "err_info is NULL");
rc = -EINVAL;
goto end;
}
@@ -1439,7 +1455,7 @@ static int cam_req_mgr_cb_notify_err(
link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(err_info->link_hdl);
if (!link) {
- CRM_DBG("link ptr NULL %x", err_info->link_hdl);
+ CAM_DBG(CAM_CRM, "link ptr NULL %x", err_info->link_hdl);
rc = -EINVAL;
goto end;
}
@@ -1447,7 +1463,7 @@ static int cam_req_mgr_cb_notify_err(
crm_timer_reset(link->watchdog);
task = cam_req_mgr_workq_get_task(link->workq);
if (!task) {
- CRM_ERR("no empty task req_id %lld", err_info->req_id);
+ CAM_ERR(CAM_CRM, "no empty task req_id %lld", err_info->req_id);
rc = -EBUSY;
goto end;
}
@@ -1485,7 +1501,7 @@ static int cam_req_mgr_cb_notify_sof(
struct crm_task_payload *task_data;
if (!sof_data) {
- CRM_ERR("sof_data is NULL");
+ CAM_ERR(CAM_CRM, "sof_data is NULL");
rc = -EINVAL;
goto end;
}
@@ -1493,7 +1509,7 @@ static int cam_req_mgr_cb_notify_sof(
link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(sof_data->link_hdl);
if (!link) {
- CRM_DBG("link ptr NULL %x", sof_data->link_hdl);
+ CAM_DBG(CAM_CRM, "link ptr NULL %x", sof_data->link_hdl);
rc = -EINVAL;
goto end;
}
@@ -1501,7 +1517,8 @@ static int cam_req_mgr_cb_notify_sof(
crm_timer_reset(link->watchdog);
task = cam_req_mgr_workq_get_task(link->workq);
if (!task) {
- CRM_ERR("no empty task frame %lld", sof_data->frame_id);
+ CAM_ERR(CAM_CRM, "no empty task frame %lld",
+ sof_data->frame_id);
rc = -EBUSY;
goto end;
}
@@ -1548,7 +1565,7 @@ static int __cam_req_mgr_setup_link_info(struct cam_req_mgr_core_link *link,
return -EPERM;
mutex_init(&link->req.lock);
- CRM_DBG("LOCK_DBG in_q lock %pK", &link->req.lock);
+ CAM_DBG(CAM_CRM, "LOCK_DBG in_q lock %pK", &link->req.lock);
link->req.num_tbl = 0;
rc = __cam_req_mgr_setup_in_q(&link->req);
@@ -1565,7 +1582,7 @@ static int __cam_req_mgr_setup_link_info(struct cam_req_mgr_core_link *link,
if (!dev->ops ||
!dev->ops->get_dev_info ||
!dev->ops->link_setup) {
- CRM_ERR("FATAL: device ops NULL");
+ CAM_ERR(CAM_CRM, "FATAL: device ops NULL");
rc = -ENXIO;
goto error;
}
@@ -1573,7 +1590,10 @@ static int __cam_req_mgr_setup_link_info(struct cam_req_mgr_core_link *link,
dev->parent = (void *)link;
dev->dev_info.dev_hdl = dev->dev_hdl;
rc = dev->ops->get_dev_info(&dev->dev_info);
- CRM_DBG("%x: connected: %s, id %d, delay %d",
+
+ trace_cam_req_mgr_connect_device(link, &dev->dev_info);
+
+ CAM_DBG(CAM_CRM, "%x: connected: %s, id %d, delay %d",
link_info->session_hdl, dev->dev_info.name,
dev->dev_info.dev_id, dev->dev_info.p_delay);
if (rc < 0 ||
@@ -1581,10 +1601,10 @@ static int __cam_req_mgr_setup_link_info(struct cam_req_mgr_core_link *link,
CAM_PIPELINE_DELAY_MAX ||
dev->dev_info.p_delay <
CAM_PIPELINE_DELAY_0) {
- CRM_ERR("get device info failed");
+ CAM_ERR(CAM_CRM, "get device info failed");
goto error;
} else {
- CRM_DBG("%x: connected: %s, delay %d",
+ CAM_DBG(CAM_CRM, "%x: connected: %s, delay %d",
link_info->session_hdl,
dev->dev_info.name,
dev->dev_info.p_delay);
@@ -1613,7 +1633,7 @@ static int __cam_req_mgr_setup_link_info(struct cam_req_mgr_core_link *link,
pd_tbl = __cam_req_mgr_find_pd_tbl(link->req.l_tbl,
dev->dev_info.p_delay);
if (!pd_tbl) {
- CRM_ERR("pd %d tbl not found",
+ CAM_ERR(CAM_CRM, "pd %d tbl not found",
dev->dev_info.p_delay);
rc = -ENXIO;
goto error;
@@ -1622,7 +1642,7 @@ static int __cam_req_mgr_setup_link_info(struct cam_req_mgr_core_link *link,
pd_tbl = __cam_req_mgr_create_pd_tbl(
dev->dev_info.p_delay);
if (pd_tbl == NULL) {
- CRM_ERR("create new pd tbl failed");
+ CAM_ERR(CAM_CRM, "create new pd tbl failed");
rc = -ENXIO;
goto error;
}
@@ -1669,7 +1689,7 @@ int cam_req_mgr_create_session(
struct cam_req_mgr_core_session *cam_session = NULL;
if (!ses_info) {
- CRM_DBG("NULL session info pointer");
+ CAM_DBG(CAM_CRM, "NULL session info pointer");
return -EINVAL;
}
mutex_lock(&g_crm_core_dev->crm_lock);
@@ -1682,7 +1702,8 @@ int cam_req_mgr_create_session(
session_hdl = cam_create_session_hdl((void *)cam_session);
if (session_hdl < 0) {
- CRM_ERR("unable to create session_hdl = %x", session_hdl);
+ CAM_ERR(CAM_CRM, "unable to create session_hdl = %x",
+ session_hdl);
rc = session_hdl;
kfree(cam_session);
goto end;
@@ -1690,7 +1711,7 @@ int cam_req_mgr_create_session(
ses_info->session_hdl = session_hdl;
mutex_init(&cam_session->lock);
- CRM_DBG("LOCK_DBG session lock %pK", &cam_session->lock);
+ CAM_DBG(CAM_CRM, "LOCK_DBG session lock %pK", &cam_session->lock);
mutex_lock(&cam_session->lock);
cam_session->session_hdl = session_hdl;
@@ -1709,7 +1730,7 @@ int cam_req_mgr_destroy_session(
struct cam_req_mgr_core_session *cam_session = NULL;
if (!ses_info) {
- CRM_DBG("NULL session info pointer");
+ CAM_DBG(CAM_CRM, "NULL session info pointer");
return -EINVAL;
}
@@ -1717,14 +1738,14 @@ int cam_req_mgr_destroy_session(
cam_session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(ses_info->session_hdl);
if (!cam_session) {
- CRM_ERR("failed to get session priv");
+ CAM_ERR(CAM_CRM, "failed to get session priv");
rc = -ENOENT;
goto end;
}
mutex_lock(&cam_session->lock);
if (cam_session->num_links) {
- CRM_ERR("destroy session %x num_active_links %d",
+ CAM_ERR(CAM_CRM, "destroy session %x num_active_links %d",
ses_info->session_hdl,
cam_session->num_links);
/* @TODO : Go through active links and destroy ? */
@@ -1736,7 +1757,7 @@ int cam_req_mgr_destroy_session(
rc = cam_destroy_session_hdl(ses_info->session_hdl);
if (rc < 0)
- CRM_ERR("unable to destroy session_hdl = %x rc %d",
+ CAM_ERR(CAM_CRM, "unable to destroy session_hdl = %x rc %d",
ses_info->session_hdl, rc);
end:
@@ -1753,11 +1774,12 @@ int cam_req_mgr_link(struct cam_req_mgr_link_info *link_info)
struct cam_req_mgr_core_link *link;
if (!link_info) {
- CRM_DBG("NULL pointer");
+ CAM_DBG(CAM_CRM, "NULL pointer");
return -EINVAL;
}
if (link_info->num_devices > CAM_REQ_MGR_MAX_HANDLES) {
- CRM_ERR("Invalid num devices %d", link_info->num_devices);
+ CAM_ERR(CAM_CRM, "Invalid num devices %d",
+ link_info->num_devices);
return -EINVAL;
}
@@ -1765,7 +1787,7 @@ int cam_req_mgr_link(struct cam_req_mgr_link_info *link_info)
cam_session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(link_info->session_hdl);
if (!cam_session) {
- CRM_DBG("NULL pointer");
+ CAM_DBG(CAM_CRM, "NULL pointer");
return -EINVAL;
}
@@ -1774,11 +1796,11 @@ int cam_req_mgr_link(struct cam_req_mgr_link_info *link_info)
/* Allocate link struct and map it with session's request queue */
link = __cam_req_mgr_reserve_link(cam_session);
if (!link) {
- CRM_ERR("failed to reserve new link");
+ CAM_ERR(CAM_CRM, "failed to reserve new link");
mutex_unlock(&g_crm_core_dev->crm_lock);
return -EINVAL;
}
- CRM_DBG("link reserved %pK %x", link, link->link_hdl);
+ CAM_DBG(CAM_CRM, "link reserved %pK %x", link, link->link_hdl);
memset(&root_dev, 0, sizeof(struct cam_create_dev_hdl));
root_dev.session_hdl = link_info->session_hdl;
@@ -1788,7 +1810,8 @@ int cam_req_mgr_link(struct cam_req_mgr_link_info *link_info)
/* Create unique dev handle for link */
link->link_hdl = cam_create_device_hdl(&root_dev);
if (link->link_hdl < 0) {
- CRM_ERR("Insufficient memory to create new device handle");
+ CAM_ERR(CAM_CRM,
+ "Insufficient memory to create new device handle");
mutex_unlock(&link->lock);
rc = link->link_hdl;
goto link_hdl_fail;
@@ -1800,7 +1823,8 @@ int cam_req_mgr_link(struct cam_req_mgr_link_info *link_info)
rc = __cam_req_mgr_create_subdevs(&link->l_dev,
link_info->num_devices);
if (rc < 0) {
- CRM_ERR("Insufficient memory to create new crm subdevs");
+ CAM_ERR(CAM_CRM,
+ "Insufficient memory to create new crm subdevs");
goto create_subdev_failed;
}
@@ -1819,7 +1843,7 @@ int cam_req_mgr_link(struct cam_req_mgr_link_info *link_info)
rc = cam_req_mgr_workq_create(buf, CRM_WORKQ_NUM_TASKS,
&link->workq, CRM_WORKQ_USAGE_NON_IRQ);
if (rc < 0) {
- CRM_ERR("FATAL: unable to create worker");
+ CAM_ERR(CAM_CRM, "FATAL: unable to create worker");
__cam_req_mgr_destroy_link_info(link);
goto setup_failed;
}
@@ -1865,18 +1889,18 @@ int cam_req_mgr_unlink(struct cam_req_mgr_unlink_info *unlink_info)
struct cam_req_mgr_core_link *link;
if (!unlink_info) {
- CRM_ERR("NULL pointer");
+ CAM_ERR(CAM_CRM, "NULL pointer");
return -EINVAL;
}
mutex_lock(&g_crm_core_dev->crm_lock);
- CRM_DBG("link_hdl %x", unlink_info->link_hdl);
+ CAM_DBG(CAM_CRM, "link_hdl %x", unlink_info->link_hdl);
/* session hdl's priv data is cam session struct */
cam_session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(unlink_info->session_hdl);
if (!cam_session) {
- CRM_ERR("NULL pointer");
+ CAM_ERR(CAM_CRM, "NULL pointer");
mutex_unlock(&g_crm_core_dev->crm_lock);
return -EINVAL;
}
@@ -1884,7 +1908,7 @@ int cam_req_mgr_unlink(struct cam_req_mgr_unlink_info *unlink_info)
/* link hdl's priv data is core_link struct */
link = cam_get_device_priv(unlink_info->link_hdl);
if (!link) {
- CRM_ERR("NULL pointer");
+ CAM_ERR(CAM_CRM, "NULL pointer");
mutex_unlock(&g_crm_core_dev->crm_lock);
return -EINVAL;
}
@@ -1908,7 +1932,7 @@ int cam_req_mgr_unlink(struct cam_req_mgr_unlink_info *unlink_info)
/* Destroy the link handle */
rc = cam_destroy_device_hdl(unlink_info->link_hdl);
if (rc < 0) {
- CRM_ERR("error while destroying dev handle %d %x",
+ CAM_ERR(CAM_CRM, "error while destroying dev handle %d %x",
rc, link->link_hdl);
}
@@ -1929,7 +1953,7 @@ int cam_req_mgr_schedule_request(
struct crm_task_payload task_data;
if (!sched_req) {
- CRM_ERR("csl_req is NULL");
+ CAM_ERR(CAM_CRM, "csl_req is NULL");
rc = -EINVAL;
goto end;
}
@@ -1937,15 +1961,16 @@ int cam_req_mgr_schedule_request(
link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(sched_req->link_hdl);
if (!link) {
- CRM_DBG("link ptr NULL %x", sched_req->link_hdl);
+ CAM_DBG(CAM_CRM, "link ptr NULL %x", sched_req->link_hdl);
return -EINVAL;
}
session = (struct cam_req_mgr_core_session *)link->parent;
if (!session) {
- CRM_WARN("session ptr NULL %x", sched_req->link_hdl);
+ CAM_WARN(CAM_CRM, "session ptr NULL %x", sched_req->link_hdl);
return -EINVAL;
}
- CRM_DBG("link %x req %lld", sched_req->link_hdl, sched_req->req_id);
+ CAM_DBG(CAM_CRM, "link %x req %lld",
+ sched_req->link_hdl, sched_req->req_id);
task_data.type = CRM_WORKQ_TASK_SCHED_REQ;
sched = (struct cam_req_mgr_sched_request *)&task_data.u;
@@ -1960,7 +1985,8 @@ int cam_req_mgr_schedule_request(
rc = cam_req_mgr_process_sched_req(link, &task_data);
- CRM_DBG("DONE dev %x req %lld", sched_req->link_hdl, sched_req->req_id);
+ CAM_DBG(CAM_CRM, "DONE dev %x req %lld",
+ sched_req->link_hdl, sched_req->req_id);
end:
return rc;
}
@@ -1969,7 +1995,7 @@ int cam_req_mgr_sync_link(
struct cam_req_mgr_sync_mode *sync_links)
{
if (!sync_links) {
- CRM_ERR("NULL pointer");
+ CAM_ERR(CAM_CRM, "NULL pointer");
return -EINVAL;
}
@@ -1988,12 +2014,13 @@ int cam_req_mgr_flush_requests(
struct cam_req_mgr_core_session *session = NULL;
if (!flush_info) {
- CRM_ERR("flush req is NULL");
+ CAM_ERR(CAM_CRM, "flush req is NULL");
rc = -EFAULT;
goto end;
}
if (flush_info->flush_type >= CAM_REQ_MGR_FLUSH_TYPE_MAX) {
- CRM_ERR("incorrect flush type %x", flush_info->flush_type);
+ CAM_ERR(CAM_CRM, "incorrect flush type %x",
+ flush_info->flush_type);
rc = -EINVAL;
goto end;
}
@@ -2002,12 +2029,12 @@ int cam_req_mgr_flush_requests(
session = (struct cam_req_mgr_core_session *)
cam_get_device_priv(flush_info->session_hdl);
if (!session) {
- CRM_ERR("Invalid session %x", flush_info->session_hdl);
+ CAM_ERR(CAM_CRM, "Invalid session %x", flush_info->session_hdl);
rc = -EINVAL;
goto end;
}
if (session->num_links <= 0) {
- CRM_WARN("No active links in session %x",
+ CAM_WARN(CAM_CRM, "No active links in session %x",
flush_info->session_hdl);
goto end;
}
@@ -2015,7 +2042,7 @@ int cam_req_mgr_flush_requests(
link = (struct cam_req_mgr_core_link *)
cam_get_device_priv(flush_info->link_hdl);
if (!link) {
- CRM_DBG("link ptr NULL %x", flush_info->link_hdl);
+ CAM_DBG(CAM_CRM, "link ptr NULL %x", flush_info->link_hdl);
rc = -EINVAL;
goto end;
}
@@ -2047,10 +2074,10 @@ int cam_req_mgr_flush_requests(
int cam_req_mgr_core_device_init(void)
{
- CRM_DBG("Enter g_crm_core_dev %pK", g_crm_core_dev);
+ CAM_DBG(CAM_CRM, "Enter g_crm_core_dev %pK", g_crm_core_dev);
if (g_crm_core_dev) {
- CRM_WARN("core device is already initialized");
+ CAM_WARN(CAM_CRM, "core device is already initialized");
return 0;
}
g_crm_core_dev = (struct cam_req_mgr_core_device *)
@@ -2058,7 +2085,7 @@ int cam_req_mgr_core_device_init(void)
if (!g_crm_core_dev)
return -ENOMEM;
- CRM_DBG("g_crm_core_dev %pK", g_crm_core_dev);
+ CAM_DBG(CAM_CRM, "g_crm_core_dev %pK", g_crm_core_dev);
INIT_LIST_HEAD(&g_crm_core_dev->session_head);
mutex_init(&g_crm_core_dev->crm_lock);
cam_req_mgr_debug_register(g_crm_core_dev);
@@ -2069,11 +2096,11 @@ int cam_req_mgr_core_device_init(void)
int cam_req_mgr_core_device_deinit(void)
{
if (!g_crm_core_dev) {
- CRM_ERR("NULL pointer");
+ CAM_ERR(CAM_CRM, "NULL pointer");
return -EINVAL;
}
- CRM_DBG("g_crm_core_dev %pK", g_crm_core_dev);
+ CAM_DBG(CAM_CRM, "g_crm_core_dev %pK", g_crm_core_dev);
mutex_destroy(&g_crm_core_dev->crm_lock);
kfree(g_crm_core_dev);
g_crm_core_dev = NULL;
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core_defs.h b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core_defs.h
index 2a831e8..f61c41e 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core_defs.h
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core_defs.h
@@ -25,30 +25,5 @@
#define CRM_GET_REQ_ID(in_q, idx) in_q->slot[idx].req_id
-#if (CRM_TRACE_ENABLE == 1)
- #define CRM_DBG(fmt, args...) do { \
- trace_printk("%d: [crm_dbg] "fmt"\n", __LINE__, ##args); \
- pr_debug("%s:%d "fmt"\n", __func__, __LINE__, ##args); \
- } while (0)
-
- #define CRM_WARN(fmt, args...) do { \
- trace_printk("%d: [crm_warn] "fmt"\n", __LINE__, ##args); \
- pr_warn("%s:%d "fmt"\n", __func__, __LINE__, ##args); \
- } while (0)
-
- #define CRM_ERR(fmt, args...) do { \
- trace_printk("%d: [crm_err] "fmt"\n", __LINE__, ##args); \
- pr_err("%s:%d "fmt"\n", __func__, __LINE__, ##args);\
- } while (0)
-#else
- #define CRM_DBG(fmt, args...) pr_debug("%s:%d "fmt"\n", \
- __func__, __LINE__, ##args)
-
- #define CRM_WARN(fmt, args...) pr_warn("%s:%d "fmt"\n", \
- __func__, __LINE__, ##args)
-
- #define CRM_ERR(fmt, args...) pr_err("%s:%d "fmt"\n", \
- __func__, __LINE__, ##args)
-#endif
#endif
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c
index c495088..7a2bc09 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_dev.c
@@ -10,8 +10,6 @@
* GNU General Public License for more details.
*/
-#define pr_fmt(fmt) "CAM-REQ-MGR %s:%d " fmt, __func__, __LINE__
-
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
@@ -26,6 +24,7 @@
#include "cam_req_mgr_core.h"
#include "cam_subdev.h"
#include "cam_mem_mgr.h"
+#include "cam_debug_util.h"
#define CAM_REQ_MGR_EVENT_MAX 30
@@ -108,7 +107,7 @@ static int cam_req_mgr_open(struct file *filep)
rc = v4l2_fh_open(filep);
if (rc) {
- pr_err("v4l2_fh_open failed: %d\n", rc);
+ CAM_ERR(CAM_CRM, "v4l2_fh_open failed: %d", rc);
goto end;
}
@@ -120,7 +119,7 @@ static int cam_req_mgr_open(struct file *filep)
rc = cam_mem_mgr_init();
if (rc) {
g_dev.open_cnt--;
- pr_err("mem mgr init failed\n");
+ CAM_ERR(CAM_CRM, "mem mgr init failed");
goto mem_mgr_init_fail;
}
@@ -507,19 +506,20 @@ int cam_register_subdev(struct cam_subdev *csd)
int rc;
if (g_dev.state != true) {
- pr_err("camera root device not ready yet");
+ CAM_ERR(CAM_CRM, "camera root device not ready yet");
return -ENODEV;
}
if (!csd || !csd->name) {
- pr_err("invalid arguments");
+ CAM_ERR(CAM_CRM, "invalid arguments");
return -EINVAL;
}
mutex_lock(&g_dev.dev_lock);
if ((g_dev.subdev_nodes_created) &&
(csd->sd_flags & V4L2_SUBDEV_FL_HAS_DEVNODE)) {
- pr_err("dynamic node is not allowed, name: %s, type : %d",
+ CAM_ERR(CAM_CRM,
+ "dynamic node is not allowed, name: %s, type :%d",
csd->name, csd->ent_function);
rc = -EINVAL;
goto reg_fail;
@@ -538,7 +538,7 @@ int cam_register_subdev(struct cam_subdev *csd)
rc = v4l2_device_register_subdev(g_dev.v4l2_dev, sd);
if (rc) {
- pr_err("register subdev failed");
+ CAM_ERR(CAM_CRM, "register subdev failed");
goto reg_fail;
}
g_dev.count++;
@@ -552,7 +552,7 @@ EXPORT_SYMBOL(cam_register_subdev);
int cam_unregister_subdev(struct cam_subdev *csd)
{
if (g_dev.state != true) {
- pr_err("camera root device not ready yet");
+ CAM_ERR(CAM_CRM, "camera root device not ready yet");
return -ENODEV;
}
@@ -603,19 +603,19 @@ static int cam_req_mgr_probe(struct platform_device *pdev)
rc = cam_req_mgr_util_init();
if (rc) {
- pr_err("cam req mgr util init is failed\n");
+ CAM_ERR(CAM_CRM, "cam req mgr util init is failed");
goto req_mgr_util_fail;
}
rc = cam_mem_mgr_init();
if (rc) {
- pr_err("mem mgr init failed\n");
+ CAM_ERR(CAM_CRM, "mem mgr init failed");
goto mem_mgr_init_fail;
}
rc = cam_req_mgr_core_device_init();
if (rc) {
- pr_err("core device setup failed\n");
+ CAM_ERR(CAM_CRM, "core device setup failed");
goto req_mgr_core_fail;
}
@@ -663,7 +663,7 @@ int cam_dev_mgr_create_subdev_nodes(void)
return -EINVAL;
if (g_dev.state != true) {
- pr_err("camera root device not ready yet");
+ CAM_ERR(CAM_CRM, "camera root device not ready yet");
return -ENODEV;
}
@@ -675,7 +675,7 @@ int cam_dev_mgr_create_subdev_nodes(void)
rc = v4l2_device_register_subdev_nodes(g_dev.v4l2_dev);
if (rc) {
- pr_err("failed to register the sub devices");
+ CAM_ERR(CAM_CRM, "failed to register the sub devices");
goto create_fail;
}
@@ -683,7 +683,7 @@ int cam_dev_mgr_create_subdev_nodes(void)
if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
continue;
sd->entity.name = video_device_node_name(sd->devnode);
- pr_debug("created node :%s\n", sd->entity.name);
+ CAM_DBG(CAM_CRM, "created node :%s", sd->entity.name);
}
g_dev.subdev_nodes_created = true;
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_interface.h b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_interface.h
index 91860f6..8faf35a 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_interface.h
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_interface.h
@@ -196,9 +196,9 @@ struct cam_req_mgr_sof_notify {
* @error : what error device hit while processing this req
*/
struct cam_req_mgr_error_notify {
- int32_t link_hdl;
- int32_t dev_hdl;
- int64_t req_id;
+ int32_t link_hdl;
+ int32_t dev_hdl;
+ uint64_t req_id;
enum cam_req_mgr_device_error error;
};
@@ -210,9 +210,9 @@ struct cam_req_mgr_error_notify {
*
*/
struct cam_req_mgr_add_request {
- int32_t link_hdl;
- int32_t dev_hdl;
- int64_t req_id;
+ int32_t link_hdl;
+ int32_t dev_hdl;
+ uint64_t req_id;
};
@@ -260,7 +260,7 @@ struct cam_req_mgr_core_dev_link_setup {
struct cam_req_mgr_apply_request {
int32_t link_hdl;
int32_t dev_hdl;
- int64_t request_id;
+ uint64_t request_id;
int32_t report_if_bubble;
};
@@ -276,7 +276,7 @@ struct cam_req_mgr_flush_request {
int32_t link_hdl;
int32_t dev_hdl;
uint32_t type;
- int64_t req_id;
+ uint64_t req_id;
};
/**
@@ -286,9 +286,9 @@ struct cam_req_mgr_flush_request {
*
*/
struct cam_req_mgr_link_evt_data {
- int32_t link_hdl;
- int32_t dev_hdl;
- int64_t req_id;
+ int32_t link_hdl;
+ int32_t dev_hdl;
+ uint64_t req_id;
enum cam_req_mgr_link_evt_type evt_type;
union {
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_timer.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_timer.c
index 9da445d..2aa2ab1 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_timer.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_timer.c
@@ -11,12 +11,13 @@
*/
#include "cam_req_mgr_timer.h"
+#include "cam_debug_util.h"
void crm_timer_reset(struct cam_req_mgr_timer *crm_timer)
{
if (!crm_timer)
return;
- CRM_DBG("Starting timer to fire in %d ms. (jiffies=%lu)\n",
+ CAM_DBG(CAM_CRM, "Starting timer to fire in %d ms. (jiffies=%lu)\n",
crm_timer->expires, jiffies);
mod_timer(&crm_timer->sys_timer,
(jiffies + msecs_to_jiffies(crm_timer->expires)));
@@ -27,17 +28,17 @@ void crm_timer_callback(unsigned long data)
struct cam_req_mgr_timer *timer = (struct cam_req_mgr_timer *)data;
if (!timer) {
- CRM_ERR("NULL timer");
+ CAM_ERR(CAM_CRM, "NULL timer");
return;
}
- CRM_DBG("timer %pK parent %pK", timer, timer->parent);
+ CAM_DBG(CAM_CRM, "timer %pK parent %pK", timer, timer->parent);
crm_timer_reset(timer);
}
void crm_timer_modify(struct cam_req_mgr_timer *crm_timer,
int32_t expires)
{
- CRM_DBG("new time %d", expires);
+ CAM_DBG(CAM_CRM, "new time %d", expires);
if (crm_timer) {
crm_timer->expires = expires;
crm_timer_reset(crm_timer);
@@ -50,7 +51,7 @@ int crm_timer_init(struct cam_req_mgr_timer **timer,
int ret = 0;
struct cam_req_mgr_timer *crm_timer = NULL;
- CRM_DBG("init timer %d %pK", expires, *timer);
+ CAM_DBG(CAM_CRM, "init timer %d %pK", expires, *timer);
if (*timer == NULL) {
crm_timer = (struct cam_req_mgr_timer *)
kzalloc(sizeof(struct cam_req_mgr_timer), GFP_KERNEL);
@@ -71,7 +72,7 @@ int crm_timer_init(struct cam_req_mgr_timer **timer,
crm_timer_reset(crm_timer);
*timer = crm_timer;
} else {
- CRM_WARN("Timer already exists!!");
+ CAM_WARN(CAM_CRM, "Timer already exists!!");
ret = -EINVAL;
}
end:
@@ -79,7 +80,7 @@ int crm_timer_init(struct cam_req_mgr_timer **timer,
}
void crm_timer_exit(struct cam_req_mgr_timer **crm_timer)
{
- CRM_DBG("destroy timer %pK", *crm_timer);
+ CAM_DBG(CAM_CRM, "destroy timer %pK", *crm_timer);
if (*crm_timer) {
del_timer(&(*crm_timer)->sys_timer);
kfree(*crm_timer);
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_util.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_util.c
index 38048d5..a9134fb 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_util.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_util.c
@@ -20,12 +20,7 @@
#include <linux/random.h>
#include <media/cam_req_mgr.h>
#include "cam_req_mgr_util.h"
-
-#ifdef CONFIG_CAM_REQ_MGR_UTIL_DEBUG
-#define CDBG(fmt, args...) pr_err(fmt, ##args)
-#else
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-#endif
+#include "cam_debug_util.h"
static struct cam_req_mgr_util_hdl_tbl *hdl_tbl;
static DEFINE_SPINLOCK(hdl_tbl_lock);
@@ -38,7 +33,7 @@ int cam_req_mgr_util_init(void)
if (hdl_tbl) {
rc = -EINVAL;
- pr_err("Hdl_tbl is already present\n");
+ CAM_ERR(CAM_CRM, "Hdl_tbl is already present");
goto hdl_tbl_check_failed;
}
@@ -79,7 +74,7 @@ int cam_req_mgr_util_deinit(void)
{
spin_lock_bh(&hdl_tbl_lock);
if (!hdl_tbl) {
- pr_err("Hdl tbl is NULL\n");
+ CAM_ERR(CAM_CRM, "Hdl tbl is NULL");
spin_unlock_bh(&hdl_tbl_lock);
return -EINVAL;
}
@@ -99,14 +94,14 @@ int cam_req_mgr_util_free_hdls(void)
spin_lock_bh(&hdl_tbl_lock);
if (!hdl_tbl) {
- pr_err("Hdl tbl is NULL\n");
+ CAM_ERR(CAM_CRM, "Hdl tbl is NULL");
spin_unlock_bh(&hdl_tbl_lock);
return -EINVAL;
}
for (i = 0; i < CAM_REQ_MGR_MAX_HANDLES; i++) {
if (hdl_tbl->hdl[i].state == HDL_ACTIVE) {
- pr_err("Dev handle = %x session_handle = %x\n",
+ CAM_ERR(CAM_CRM, "Dev handle = %x session_handle = %x",
hdl_tbl->hdl[i].hdl_value,
hdl_tbl->hdl[i].session_hdl);
hdl_tbl->hdl[i].state = HDL_FREE;
@@ -141,14 +136,14 @@ int32_t cam_create_session_hdl(void *priv)
spin_lock_bh(&hdl_tbl_lock);
if (!hdl_tbl) {
- pr_err("Hdl tbl is NULL\n");
+ CAM_ERR(CAM_CRM, "Hdl tbl is NULL");
spin_unlock_bh(&hdl_tbl_lock);
return -EINVAL;
}
idx = cam_get_free_handle_index();
if (idx < 0) {
- pr_err("Unable to create session handle\n");
+ CAM_ERR(CAM_CRM, "Unable to create session handle");
spin_unlock_bh(&hdl_tbl_lock);
return idx;
}
@@ -174,14 +169,14 @@ int32_t cam_create_device_hdl(struct cam_create_dev_hdl *hdl_data)
spin_lock_bh(&hdl_tbl_lock);
if (!hdl_tbl) {
- pr_err("Hdl tbl is NULL\n");
+ CAM_ERR(CAM_CRM, "Hdl tbl is NULL");
spin_unlock_bh(&hdl_tbl_lock);
return -EINVAL;
}
idx = cam_get_free_handle_index();
if (idx < 0) {
- pr_err("Unable to create device handle\n");
+ CAM_ERR(CAM_CRM, "Unable to create device handle");
spin_unlock_bh(&hdl_tbl_lock);
return idx;
}
@@ -196,7 +191,7 @@ int32_t cam_create_device_hdl(struct cam_create_dev_hdl *hdl_data)
hdl_tbl->hdl[idx].ops = hdl_data->ops;
spin_unlock_bh(&hdl_tbl_lock);
- pr_debug("%s: handle = %x\n", __func__, handle);
+ pr_debug("%s: handle = %x", __func__, handle);
return handle;
}
@@ -208,29 +203,29 @@ void *cam_get_device_priv(int32_t dev_hdl)
spin_lock_bh(&hdl_tbl_lock);
if (!hdl_tbl) {
- pr_err("Hdl tbl is NULL\n");
+ CAM_ERR(CAM_CRM, "Hdl tbl is NULL");
goto device_priv_fail;
}
idx = CAM_REQ_MGR_GET_HDL_IDX(dev_hdl);
if (idx >= CAM_REQ_MGR_MAX_HANDLES) {
- pr_err("Invalid idx\n");
+ CAM_ERR(CAM_CRM, "Invalid idx");
goto device_priv_fail;
}
if (hdl_tbl->hdl[idx].state != HDL_ACTIVE) {
- pr_err("Invalid state\n");
+ CAM_ERR(CAM_CRM, "Invalid state");
goto device_priv_fail;
}
type = CAM_REQ_MGR_GET_HDL_TYPE(dev_hdl);
if (HDL_TYPE_DEV != type && HDL_TYPE_SESSION != type) {
- pr_err("Invalid type\n");
+ CAM_ERR(CAM_CRM, "Invalid type");
goto device_priv_fail;
}
if (hdl_tbl->hdl[idx].hdl_value != dev_hdl) {
- pr_err("Invalid hdl\n");
+ CAM_ERR(CAM_CRM, "Invalid hdl");
goto device_priv_fail;
}
@@ -252,29 +247,29 @@ void *cam_get_device_ops(int32_t dev_hdl)
spin_lock_bh(&hdl_tbl_lock);
if (!hdl_tbl) {
- pr_err("Hdl tbl is NULL\n");
+ CAM_ERR(CAM_CRM, "Hdl tbl is NULL");
goto device_ops_fail;
}
idx = CAM_REQ_MGR_GET_HDL_IDX(dev_hdl);
if (idx >= CAM_REQ_MGR_MAX_HANDLES) {
- pr_err("Invalid idx\n");
+ CAM_ERR(CAM_CRM, "Invalid idx");
goto device_ops_fail;
}
if (hdl_tbl->hdl[idx].state != HDL_ACTIVE) {
- pr_err("Invalid state\n");
+ CAM_ERR(CAM_CRM, "Invalid state");
goto device_ops_fail;
}
type = CAM_REQ_MGR_GET_HDL_TYPE(dev_hdl);
if (HDL_TYPE_DEV != type && HDL_TYPE_SESSION != type) {
- pr_err("Invalid type\n");
+ CAM_ERR(CAM_CRM, "Invalid type");
goto device_ops_fail;
}
if (hdl_tbl->hdl[idx].hdl_value != dev_hdl) {
- pr_err("Invalid hdl\n");
+ CAM_ERR(CAM_CRM, "Invalid hdl");
goto device_ops_fail;
}
@@ -295,29 +290,29 @@ static int cam_destroy_hdl(int32_t dev_hdl, int dev_hdl_type)
spin_lock_bh(&hdl_tbl_lock);
if (!hdl_tbl) {
- pr_err("Hdl tbl is NULL\n");
+ CAM_ERR(CAM_CRM, "Hdl tbl is NULL");
goto destroy_hdl_fail;
}
idx = CAM_REQ_MGR_GET_HDL_IDX(dev_hdl);
if (idx >= CAM_REQ_MGR_MAX_HANDLES) {
- pr_err("Invalid idx\n");
+ CAM_ERR(CAM_CRM, "Invalid idx");
goto destroy_hdl_fail;
}
if (hdl_tbl->hdl[idx].state != HDL_ACTIVE) {
- pr_err("Invalid state\n");
+ CAM_ERR(CAM_CRM, "Invalid state");
goto destroy_hdl_fail;
}
type = CAM_REQ_MGR_GET_HDL_TYPE(dev_hdl);
if (type != dev_hdl_type) {
- pr_err("Invalid type %d, %d\n", type, dev_hdl_type);
+ CAM_ERR(CAM_CRM, "Invalid type %d, %d", type, dev_hdl_type);
goto destroy_hdl_fail;
}
if (hdl_tbl->hdl[idx].hdl_value != dev_hdl) {
- pr_err("Invalid hdl\n");
+ CAM_ERR(CAM_CRM, "Invalid hdl");
goto destroy_hdl_fail;
}
diff --git a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_workq.c b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_workq.c
index 38dcb42..c48a391 100644
--- a/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_workq.c
+++ b/drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_workq.c
@@ -11,6 +11,7 @@
*/
#include "cam_req_mgr_workq.h"
+#include "cam_debug_util.h"
#define WORKQ_ACQUIRE_LOCK(workq, flags) {\
if ((workq)->in_irq) \
@@ -84,7 +85,7 @@ static int cam_req_mgr_process_task(struct crm_workq_task *task)
if (task->process_cb)
task->process_cb(task->priv, task->payload);
else
- CRM_WARN("FATAL:no task handler registered for workq");
+ CAM_WARN(CAM_CRM, "FATAL:no task handler registered for workq");
cam_req_mgr_workq_put_task(task);
return 0;
@@ -100,7 +101,7 @@ static void cam_req_mgr_process_workq(struct work_struct *w)
struct crm_workq_task *task, *task_save;
int32_t i = CRM_TASK_PRIORITY_0;
if (!w) {
- CRM_ERR("NULL task pointer can not schedule");
+ CAM_ERR(CAM_CRM, "NULL task pointer can not schedule");
return;
}
workq = (struct cam_req_mgr_core_workq *)
@@ -113,7 +114,7 @@ static void cam_req_mgr_process_workq(struct work_struct *w)
atomic_sub(1, &workq->task.pending_cnt);
cam_req_mgr_process_task(task);
}
- CRM_DBG("processed task %pK free_cnt %d",
+ CAM_DBG(CAM_CRM, "processed task %pK free_cnt %d",
task, atomic_read(&workq->task.free_cnt));
}
i++;
@@ -125,7 +126,7 @@ void crm_workq_clear_q(struct cam_req_mgr_core_workq *workq)
int32_t i = CRM_TASK_PRIORITY_0;
struct crm_workq_task *task, *task_save;
- CRM_DBG("pending_cnt %d",
+ CAM_DBG(CAM_CRM, "pending_cnt %d",
atomic_read(&workq->task.pending_cnt));
while (i < CRM_TASK_PRIORITY_MAX) {
@@ -133,7 +134,7 @@ void crm_workq_clear_q(struct cam_req_mgr_core_workq *workq)
list_for_each_entry_safe(task, task_save,
&workq->task.process_head[i], entry) {
cam_req_mgr_workq_put_task(task);
- CRM_WARN("flush task %pK, %d, cnt %d",
+ CAM_WARN(CAM_CRM, "flush task %pK, %d, cnt %d",
task, i, atomic_read(
&workq->task.free_cnt));
}
@@ -150,13 +151,13 @@ int cam_req_mgr_workq_enqueue_task(struct crm_workq_task *task,
unsigned long flags = 0;
if (!task) {
- CRM_WARN("NULL task pointer can not schedule");
+ CAM_WARN(CAM_CRM, "NULL task pointer can not schedule");
rc = -EINVAL;
goto end;
}
workq = (struct cam_req_mgr_core_workq *)task->parent;
if (!workq) {
- CRM_DBG("NULL workq pointer suspect mem corruption");
+ CAM_DBG(CAM_CRM, "NULL workq pointer suspect mem corruption");
rc = -EINVAL;
goto end;
}
@@ -167,7 +168,7 @@ int cam_req_mgr_workq_enqueue_task(struct crm_workq_task *task,
if (task->cancel == 1) {
cam_req_mgr_workq_put_task(task);
- CRM_WARN("task aborted and queued back to pool");
+ CAM_WARN(CAM_CRM, "task aborted and queued back to pool");
rc = 0;
goto end;
}
@@ -182,7 +183,7 @@ int cam_req_mgr_workq_enqueue_task(struct crm_workq_task *task,
WORKQ_RELEASE_LOCK(workq, flags);
atomic_add(1, &workq->task.pending_cnt);
- CRM_DBG("enq task %pK pending_cnt %d",
+ CAM_DBG(CAM_CRM, "enq task %pK pending_cnt %d",
task, atomic_read(&workq->task.pending_cnt));
queue_work(workq->job, &workq->work);
@@ -207,7 +208,7 @@ int cam_req_mgr_workq_create(char *name, int32_t num_tasks,
return -ENOMEM;
strlcat(buf, name, sizeof(buf));
- CRM_DBG("create workque crm_workq-%s", name);
+ CAM_DBG(CAM_CRM, "create workque crm_workq-%s", name);
crm_workq->job = alloc_workqueue(buf,
WQ_HIGHPRI | WQ_UNBOUND, 0, NULL);
if (!crm_workq->job) {
@@ -218,7 +219,7 @@ int cam_req_mgr_workq_create(char *name, int32_t num_tasks,
/* Workq attributes initialization */
INIT_WORK(&crm_workq->work, cam_req_mgr_process_workq);
spin_lock_init(&crm_workq->lock_bh);
- CRM_DBG("LOCK_DBG workq %s lock %pK",
+ CAM_DBG(CAM_CRM, "LOCK_DBG workq %s lock %pK",
name, &crm_workq->lock_bh);
/* Task attributes initialization */
@@ -234,7 +235,7 @@ int cam_req_mgr_workq_create(char *name, int32_t num_tasks,
crm_workq->task.num_task,
GFP_KERNEL);
if (!crm_workq->task.pool) {
- CRM_WARN("Insufficient memory %lu",
+ CAM_WARN(CAM_CRM, "Insufficient memory %lu",
sizeof(struct crm_workq_task) *
crm_workq->task.num_task);
kfree(crm_workq);
@@ -250,7 +251,7 @@ int cam_req_mgr_workq_create(char *name, int32_t num_tasks,
cam_req_mgr_workq_put_task(task);
}
*workq = crm_workq;
- CRM_DBG("free tasks %d",
+ CAM_DBG(CAM_CRM, "free tasks %d",
atomic_read(&crm_workq->task.free_cnt));
}
@@ -259,7 +260,7 @@ int cam_req_mgr_workq_create(char *name, int32_t num_tasks,
void cam_req_mgr_workq_destroy(struct cam_req_mgr_core_workq **crm_workq)
{
- CRM_DBG("destroy workque %pK", crm_workq);
+ CAM_DBG(CAM_CRM, "destroy workque %pK", crm_workq);
if (*crm_workq) {
crm_workq_clear_q(*crm_workq);
if ((*crm_workq)->job) {
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/Makefile b/drivers/media/platform/msm/camera/cam_sensor_module/Makefile
index e515a40..b66480c 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/Makefile
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/Makefile
@@ -4,3 +4,5 @@
obj-$(CONFIG_SPECTRA_CAMERA) += cam_csiphy/
obj-$(CONFIG_SPECTRA_CAMERA) += cam_actuator/
obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor/
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_flash/
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_eeprom/
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
index 37dbf9e..1dcc54f 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
@@ -23,7 +23,7 @@ int32_t cam_actuator_slaveInfo_pkt_parser(struct cam_actuator_ctrl_t *a_ctrl,
struct cam_cmd_i2c_info *i2c_info;
if (!a_ctrl || !cmd_buf) {
- pr_err("%s:%d Invalid Args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Invalid Args");
return -EINVAL;
}
@@ -32,8 +32,8 @@ int32_t cam_actuator_slaveInfo_pkt_parser(struct cam_actuator_ctrl_t *a_ctrl,
i2c_info->i2c_freq_mode;
a_ctrl->io_master_info.cci_client->sid =
i2c_info->slave_addr >> 1;
- CDBG("%s:%d Slave addr: 0x%x Freq Mode: %d\n", __func__,
- __LINE__, i2c_info->slave_addr, i2c_info->i2c_freq_mode);
+ CAM_DBG(CAM_ACTUATOR, "Slave addr: 0x%x Freq Mode: %d",
+ i2c_info->slave_addr, i2c_info->i2c_freq_mode);
return rc;
}
@@ -46,13 +46,12 @@ int32_t cam_actuator_apply_settings(struct cam_actuator_ctrl_t *a_ctrl,
uint32_t i, size;
if (a_ctrl == NULL || i2c_set == NULL) {
- pr_err("%s:%d Invalid Args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Invalid Args");
return -EINVAL;
}
if (i2c_set->is_settings_valid != 1) {
- pr_err("%s: %d :Error: Invalid settings\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, " Invalid settings");
return -EINVAL;
}
@@ -62,8 +61,8 @@ int32_t cam_actuator_apply_settings(struct cam_actuator_ctrl_t *a_ctrl,
rc = camera_io_dev_write(&(a_ctrl->io_master_info),
&(i2c_list->i2c_settings));
if (rc < 0) {
- pr_err("%s: %d :Error: Failed in Applying i2c write settings\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed in Applying i2c wrt settings");
return rc;
}
} else if (i2c_list->op_code == CAM_SENSOR_I2C_POLL) {
@@ -82,8 +81,8 @@ int32_t cam_actuator_apply_settings(struct cam_actuator_ctrl_t *a_ctrl,
i2c_list->i2c_settings.
reg_setting[i].delay);
if (rc < 0) {
- pr_err("%s: %d :Error: Failed in Applying i2c poll settings\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR,
+ "i2c poll apply setting Fail");
return rc;
}
}
@@ -99,24 +98,21 @@ int32_t cam_actuator_apply_request(struct cam_req_mgr_apply_request *apply)
struct cam_actuator_ctrl_t *a_ctrl = NULL;
if (!apply) {
- pr_err("%s:%d :Error: Invalid Input Args\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Invalid Input Args");
return -EINVAL;
}
a_ctrl = (struct cam_actuator_ctrl_t *)
cam_get_device_priv(apply->dev_hdl);
if (!a_ctrl) {
- pr_err("%s: %d :Error: Device data is NULL\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Device data is NULL");
return -EINVAL;
}
request_id = apply->request_id % MAX_PER_FRAME_ARRAY;
trace_cam_apply_req("Actuator", apply);
- CDBG("%s:%d Request Id: %lld\n",
- __func__, __LINE__, apply->request_id);
+ CAM_DBG(CAM_ACTUATOR, "Request Id: %lld", apply->request_id);
if ((apply->request_id ==
a_ctrl->i2c_data.per_frame[request_id].request_id) &&
@@ -125,8 +121,9 @@ int32_t cam_actuator_apply_request(struct cam_req_mgr_apply_request *apply)
rc = cam_actuator_apply_settings(a_ctrl,
&a_ctrl->i2c_data.per_frame[request_id]);
if (rc < 0) {
- pr_err("%s:%d Failed in applying the request: %lld\n",
- __func__, __LINE__, apply->request_id);
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed in applying the request: %lld\n",
+ apply->request_id);
return rc;
}
}
@@ -139,12 +136,13 @@ int32_t cam_actuator_apply_request(struct cam_req_mgr_apply_request *apply)
a_ctrl->i2c_data.per_frame[del_req_id].request_id = 0;
rc = delete_request(&a_ctrl->i2c_data.per_frame[del_req_id]);
if (rc < 0) {
- pr_err("%s: %d :Error: Fail deleting the req: %d err: %d\n",
- __func__, __LINE__, del_req_id, rc);
+ CAM_ERR(CAM_ACTUATOR,
+ "Fail deleting the req: %d err: %d\n",
+ del_req_id, rc);
return rc;
}
} else {
- CDBG("%s:%d No Valid Req to clean Up\n", __func__, __LINE__);
+ CAM_DBG(CAM_ACTUATOR, "No Valid Req to clean Up");
}
return rc;
@@ -156,15 +154,14 @@ int32_t cam_actuator_establish_link(
struct cam_actuator_ctrl_t *a_ctrl = NULL;
if (!link) {
- pr_err("%s:%d Invalid Args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Invalid Args");
return -EINVAL;
}
a_ctrl = (struct cam_actuator_ctrl_t *)
cam_get_device_priv(link->dev_hdl);
if (!a_ctrl) {
- pr_err("%s:%d :Error: Device data is NULL\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Device data is NULL");
return -EINVAL;
}
if (link->link_enable) {
@@ -181,7 +178,7 @@ int32_t cam_actuator_establish_link(
int32_t cam_actuator_publish_dev_info(struct cam_req_mgr_device_info *info)
{
if (!info) {
- pr_err("%s:%d Invalid Args\n", __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Invalid Args");
return -EINVAL;
}
@@ -208,8 +205,7 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl,
struct cam_req_mgr_add_request add_req;
if (!a_ctrl || !arg) {
- pr_err("%s:%d :Error: Invalid Args\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Invalid Args");
return -EINVAL;
}
@@ -220,21 +216,21 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl,
rc = cam_mem_get_cpu_buf(config.packet_handle,
(uint64_t *)&generic_ptr, &len_of_buff);
if (rc < 0) {
- pr_err("%s:%d :Error: error in converting command Handle %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR, "Error in converting command Handle %d",
+ rc);
return rc;
}
if (config.offset > len_of_buff) {
- pr_err("%s: %d offset is out of bounds: offset: %lld len: %zu\n",
- __func__, __LINE__, config.offset, len_of_buff);
+ CAM_ERR(CAM_ACTUATOR,
+ "offset is out of bounds: offset: %lld len: %zu",
+ config.offset, len_of_buff);
return -EINVAL;
}
csl_packet = (struct cam_packet *)(generic_ptr +
config.offset);
- CDBG("%s:%d Pkt opcode: %d\n",
- __func__, __LINE__, csl_packet->header.op_code);
+ CAM_DBG(CAM_ACTUATOR, "Pkt opcode: %d", csl_packet->header.op_code);
if ((csl_packet->header.op_code & 0xFFFFFF) ==
CAM_ACTUATOR_PACKET_OPCODE_INIT) {
@@ -246,24 +242,22 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl,
cmd_desc = (struct cam_cmd_buf_desc *)(offset);
if (csl_packet->num_cmd_buf != 2) {
- pr_err("%s:: %d :Error: cmd Buffers in Init : %d\n",
- __func__, __LINE__, csl_packet->num_cmd_buf);
+ CAM_ERR(CAM_ACTUATOR, "cmd Buffers in Init : %d",
+ csl_packet->num_cmd_buf);
return -EINVAL;
}
rc = cam_mem_get_cpu_buf(cmd_desc[0].mem_handle,
(uint64_t *)&generic_ptr, &len_of_buff);
if (rc < 0) {
- pr_err("%s:%d Failed to get cpu buf\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Failed to get cpu buf");
return rc;
}
cmd_buf = (uint32_t *)generic_ptr;
cmd_buf += cmd_desc->offset / sizeof(uint32_t);
rc = cam_actuator_slaveInfo_pkt_parser(a_ctrl, cmd_buf);
if (rc < 0) {
- pr_err("%s:%d Failed in parsing the pkt\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Failed in parsing the pkt");
return rc;
}
cmd_buf += (sizeof(struct cam_cmd_i2c_info)/sizeof(uint32_t));
@@ -272,8 +266,8 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl,
rc = cam_sensor_i2c_pkt_parser(i2c_reg_settings,
&cmd_desc[1], 1);
if (rc < 0) {
- pr_err("%s:%d :Error: actuator pkt parsing failed: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR, "Actuator pkt parsing failed: %d",
+ rc);
return rc;
}
} else if ((csl_packet->header.op_code & 0xFFFFFF) ==
@@ -293,8 +287,8 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl,
rc = cam_sensor_i2c_pkt_parser(i2c_reg_settings,
cmd_desc, 1);
if (rc < 0) {
- pr_err("%s:%d :Error: actuator pkt parsing failed: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR, "Actuator pkt parsing failed: %d",
+ rc);
return rc;
}
} else if ((csl_packet->header.op_code & 0xFFFFFF) ==
@@ -313,8 +307,8 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl,
rc = cam_sensor_i2c_pkt_parser(i2c_reg_settings,
cmd_desc, 1);
if (rc < 0) {
- pr_err("%s:%d :Error: actuator pkt parsing failed: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR, "Actuator pkt parsing failed: %d",
+ rc);
return rc;
}
}
@@ -327,8 +321,8 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl,
if (a_ctrl->bridge_intf.crm_cb &&
a_ctrl->bridge_intf.crm_cb->add_req)
a_ctrl->bridge_intf.crm_cb->add_req(&add_req);
- CDBG("%s: %d Req Id: %lld added to Bridge\n",
- __func__, __LINE__, add_req.req_id);
+ CAM_DBG(CAM_ACTUATOR, "Req Id: %lld added to Bridge",
+ add_req.req_id);
}
return rc;
@@ -348,8 +342,7 @@ static int32_t cam_actuator_vreg_control(
return 0;
if (cnt >= CAM_SOC_MAX_REGULATOR) {
- pr_err("%s:%d Regulators more than supported %d\n",
- __func__, __LINE__, cnt);
+ CAM_ERR(CAM_ACTUATOR, "Regulators more than supported %d", cnt);
return -EINVAL;
}
@@ -372,8 +365,7 @@ static int32_t cam_actuator_power_up(struct cam_actuator_ctrl_t *a_ctrl)
rc = cam_actuator_vreg_control(a_ctrl, 1);
if (rc < 0) {
- pr_err("%s:%d Actuator Reg Failed %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR, "Actuator Reg Failed %d", rc);
return rc;
}
@@ -387,8 +379,7 @@ static int32_t cam_actuator_power_up(struct cam_actuator_ctrl_t *a_ctrl)
rc = cam_soc_util_enable_platform_resource(&a_ctrl->soc_info,
false, 0, false);
if (rc < 0) {
- pr_err("%s:%d :Error: Failed in req gpio: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR, "Failed in req gpio: %d", rc);
return rc;
}
@@ -412,7 +403,7 @@ static int32_t cam_actuator_power_down(struct cam_actuator_ctrl_t *a_ctrl)
rc = cam_actuator_vreg_control(a_ctrl, 0);
if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Failed %d");
return rc;
}
@@ -430,8 +421,8 @@ static int32_t cam_actuator_power_down(struct cam_actuator_ctrl_t *a_ctrl)
rc |= cam_soc_util_disable_platform_resource(&a_ctrl->soc_info,
0, 0);
if (rc < 0)
- pr_err("%s:%d Failed to disable platform resources: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed to disable platform resources: %d", rc);
}
return rc;
@@ -444,13 +435,11 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
struct cam_control *cmd = (struct cam_control *)arg;
if (!a_ctrl || !cmd) {
- pr_err("%s: %d :Error: Invalid Args\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, " Invalid Args");
return -EINVAL;
}
- pr_debug("%s:%d Opcode to Actuator: %d\n",
- __func__, __LINE__, cmd->op_code);
+ pr_debug("Opcode to Actuator: %d", cmd->op_code);
mutex_lock(&(a_ctrl->actuator_mutex));
switch (cmd->op_code) {
@@ -459,8 +448,7 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
struct cam_create_dev_hdl bridge_params;
if (a_ctrl->bridge_intf.device_hdl != -1) {
- pr_err("%s:%d Device is already acquired\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Device is already acquired");
rc = -EINVAL;
goto release_mutex;
}
@@ -468,8 +456,7 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
(void __user *) cmd->handle,
sizeof(actuator_acq_dev));
if (rc < 0) {
- pr_err("%s:%d :Error: Failed Copying from user\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Failed Copying from user\n");
goto release_mutex;
}
@@ -485,12 +472,11 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
a_ctrl->bridge_intf.session_hdl =
actuator_acq_dev.session_handle;
- CDBG("%s:%d Device Handle: %d\n",
- __func__, __LINE__, actuator_acq_dev.device_handle);
+ CAM_DBG(CAM_ACTUATOR, "Device Handle: %d",
+ actuator_acq_dev.device_handle);
if (copy_to_user((void __user *) cmd->handle, &actuator_acq_dev,
sizeof(struct cam_sensor_acquire_dev))) {
- pr_err("%s:%d :Error: Failed Copy to User\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Failed Copy to User");
rc = -EFAULT;
goto release_mutex;
}
@@ -499,8 +485,7 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
break;
case CAM_RELEASE_DEV: {
if (a_ctrl->bridge_intf.device_hdl == -1) {
- pr_err("%s:%d :Error: link hdl: %d device hdl: %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_ACTUATOR, "link hdl: %d device hdl: %d",
a_ctrl->bridge_intf.device_hdl,
a_ctrl->bridge_intf.link_hdl);
rc = -EINVAL;
@@ -508,8 +493,7 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
}
rc = cam_destroy_device_hdl(a_ctrl->bridge_intf.device_hdl);
if (rc < 0)
- pr_err("%s:%d :Error: destroying the device hdl\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "destroying the device hdl");
a_ctrl->bridge_intf.device_hdl = -1;
a_ctrl->bridge_intf.link_hdl = -1;
a_ctrl->bridge_intf.session_hdl = -1;
@@ -521,8 +505,7 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
actuator_cap.slot_info = a_ctrl->id;
if (copy_to_user((void __user *) cmd->handle, &actuator_cap,
sizeof(struct cam_actuator_query_cap))) {
- pr_err("%s:%d :Error: Failed Copy to User\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Failed Copy to User");
rc = -EFAULT;
goto release_mutex;
}
@@ -531,28 +514,25 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
case CAM_START_DEV: {
rc = cam_actuator_power_up(a_ctrl);
if (rc < 0) {
- pr_err("%s: %d :Error: Actuator Power up failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, " Actuator Power up failed");
goto release_mutex;
}
rc = camera_io_init(&a_ctrl->io_master_info);
if (rc < 0) {
- pr_err("%s:%d :Error: cci_init failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "cci_init failed");
cam_actuator_power_down(a_ctrl);
}
rc = cam_actuator_apply_settings(a_ctrl,
&a_ctrl->i2c_data.init_settings);
if (rc < 0)
- pr_err("%s: %d :Error: Cannot apply Init settings\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Cannot apply Init settings");
/* Delete the request even if the apply is failed */
rc = delete_request(&a_ctrl->i2c_data.init_settings);
if (rc < 0) {
- pr_err("%s:%d Fail in deleting the Init settings\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR,
+ "Fail in deleting the Init settings");
rc = -EINVAL;
goto release_mutex;
}
@@ -561,12 +541,10 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
case CAM_STOP_DEV: {
rc = camera_io_release(&a_ctrl->io_master_info);
if (rc < 0)
- pr_err("%s:%d :Error: Failed in releasing CCI\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Failed in releasing CCI");
rc = cam_actuator_power_down(a_ctrl);
if (rc < 0) {
- pr_err("%s:%d :Error: Actuator Power down failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Actuator Power down failed");
goto release_mutex;
}
}
@@ -576,8 +554,7 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
ACT_APPLY_SETTINGS_LATER;
rc = cam_actuator_i2c_pkt_parse(a_ctrl, arg);
if (rc < 0) {
- pr_err("%s:%d :Error: Failed in actuator Parsing\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Failed in actuator Parsing");
}
if (a_ctrl->act_apply_state ==
@@ -585,14 +562,15 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
rc = cam_actuator_apply_settings(a_ctrl,
&a_ctrl->i2c_data.init_settings);
if (rc < 0)
- pr_err("%s:%d :Error: Cannot apply Update settings\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR,
+ "Cannot apply Update settings");
/* Delete the request even if the apply is failed */
rc = delete_request(&a_ctrl->i2c_data.init_settings);
if (rc < 0) {
- pr_err("%s: %d :Error: Failed in Deleting the Init Pkt: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed in Deleting the Init Pkt: %d",
+ rc);
goto release_mutex;
}
}
@@ -601,8 +579,7 @@ int32_t cam_actuator_driver_cmd(struct cam_actuator_ctrl_t *a_ctrl,
case CAM_SD_SHUTDOWN:
break;
default:
- pr_err("%s:%d Invalid Opcode %d\n",
- __func__, __LINE__, cmd->op_code);
+ CAM_ERR(CAM_ACTUATOR, "Invalid Opcode %d", cmd->op_code);
}
release_mutex:
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.c
index f8ea769..7eba9d1 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.c
@@ -28,8 +28,7 @@ static long cam_actuator_subdev_ioctl(struct v4l2_subdev *sd,
rc = cam_actuator_driver_cmd(a_ctrl, arg);
break;
default:
- pr_err("%s:%d Invalid ioctl cmd\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Invalid ioctl cmd");
rc = -EINVAL;
break;
}
@@ -43,14 +42,14 @@ static int32_t cam_actuator_driver_i2c_probe(struct i2c_client *client,
struct cam_actuator_ctrl_t *a_ctrl;
if (client == NULL || id == NULL) {
- pr_err("%s:%d: :Error: Invalid Args client: %pK id: %pK\n",
- __func__, __LINE__, client, id);
+ CAM_ERR(CAM_ACTUATOR, "Invalid Args client: %pK id: %pK",
+ client, id);
return -EINVAL;
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
- pr_err("%s %s :Error: i2c_check_functionality failed\n",
- __func__, client->name);
+ CAM_ERR(CAM_ACTUATOR, "%s :: i2c_check_functionality failed",
+ client->name);
rc = -EFAULT;
return rc;
}
@@ -81,7 +80,7 @@ static int32_t cam_actuator_driver_i2c_probe(struct i2c_client *client,
rc = cam_actuator_parse_dt(a_ctrl, &client->dev);
if (rc < 0) {
- pr_err("failed: cam_sensor_parse_dt rc %d", rc);
+ CAM_ERR(CAM_ACTUATOR, "failed: cam_sensor_parse_dt rc %d", rc);
goto free_mem;
}
@@ -100,7 +99,7 @@ static int32_t cam_actuator_platform_remove(struct platform_device *pdev)
a_ctrl = platform_get_drvdata(pdev);
if (!a_ctrl) {
- pr_err("%s: Actuator device is NULL\n", __func__);
+ CAM_ERR(CAM_ACTUATOR, "Actuator device is NULL");
return 0;
}
@@ -120,7 +119,7 @@ static int32_t cam_actuator_driver_i2c_remove(struct i2c_client *client)
/* Handle I2C Devices */
if (!a_ctrl) {
- pr_err("%s: Actuator device is NULL\n", __func__);
+ CAM_ERR(CAM_ACTUATOR, "Actuator device is NULL");
return -EINVAL;
}
/*Free Allocated Mem */
@@ -139,7 +138,8 @@ static long cam_actuator_init_subdev_do_ioctl(struct v4l2_subdev *sd,
if (copy_from_user(&cmd_data, (void __user *)arg,
sizeof(cmd_data))) {
- pr_err("Failed to copy from user_ptr=%pK size=%zu\n",
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed to copy from user_ptr=%pK size=%zu\n",
(void __user *)arg, sizeof(cmd_data));
return -EFAULT;
}
@@ -149,21 +149,21 @@ static long cam_actuator_init_subdev_do_ioctl(struct v4l2_subdev *sd,
cmd = VIDIOC_CAM_CONTROL;
rc = cam_actuator_subdev_ioctl(sd, cmd, &cmd_data);
if (rc < 0) {
- pr_err("%s:%d Failed in actuator suddev handling",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed in actuator suddev handling");
return rc;
}
break;
default:
- pr_err("%s:%d Invalid compat ioctl: %d\n",
- __func__, __LINE__, cmd);
+ CAM_ERR(CAM_ACTUATOR, "Invalid compat ioctl: %d", cmd);
rc = -EINVAL;
}
if (!rc) {
if (copy_to_user((void __user *)arg, &cmd_data,
sizeof(cmd_data))) {
- pr_err("Failed to copy to user_ptr=%pK size=%zu\n",
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed to copy to user_ptr=%pK size=%zu\n",
(void __user *)arg, sizeof(cmd_data));
rc = -EFAULT;
}
@@ -228,8 +228,7 @@ static int32_t cam_actuator_driver_platform_probe(
rc = cam_actuator_parse_dt(a_ctrl, &(pdev->dev));
if (rc < 0) {
- pr_err("%s:%d :Error: Paring actuator dt failed rc %d",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR, "Paring actuator dt failed rc %d", rc);
goto free_ctrl;
}
@@ -252,16 +251,15 @@ static int32_t cam_actuator_driver_platform_probe(
rc = cam_register_subdev(&(a_ctrl->v4l2_dev_str));
if (rc < 0) {
- pr_err("%s:%d :ERROR: Fail with cam_register_subdev\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "Fail with cam_register_subdev");
goto free_mem;
}
rc = cam_soc_util_request_platform_resource(&a_ctrl->soc_info,
NULL, NULL);
if (rc < 0) {
- pr_err("%s:%d :Error: Requesting Platform Resources failed rc %d",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR,
+ "Requesting Platform Resources failed rc %d", rc);
goto free_ctrl;
}
@@ -316,14 +314,13 @@ static int __init cam_actuator_driver_init(void)
rc = platform_driver_register(&cam_actuator_platform_driver);
if (rc < 0) {
- pr_err("%s platform_driver_register failed rc = %d",
- __func__, rc);
+ CAM_ERR(CAM_ACTUATOR,
+ "platform_driver_register failed rc = %d", rc);
return rc;
}
rc = i2c_add_driver(&cam_actuator_driver_i2c);
if (rc)
- pr_err("%s:%d :Error: i2c_add_driver failed rc = %d",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR, "i2c_add_driver failed rc = %d", rc);
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.h
index 19fe4af..fdf881f3 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_dev.h
@@ -33,6 +33,7 @@
#include <cam_subdev.h>
#include "cam_sensor_util.h"
#include "cam_soc_util.h"
+#include "cam_debug_util.h"
#define NUM_MASTERS 2
#define NUM_QUEUES 2
@@ -40,13 +41,6 @@
#define TRUE 1
#define FALSE 0
-#undef CDBG
-#ifdef CAM_SENSOR_DEBUG
-#define CDBG(fmt, args...) pr_err(fmt, ##args)
-#else
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-#endif
-
#define ACTUATOR_DRIVER_I2C "i2c_actuator"
#define CAMX_ACTUATOR_DEV_NAME "cam-actuator-driver"
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_soc.c
index 584e4d2..ddc89a8 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_soc.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_soc.c
@@ -28,8 +28,7 @@ int32_t cam_actuator_parse_dt(struct cam_actuator_ctrl_t *a_ctrl,
struct platform_device *pdev = NULL;
if (!soc_info->pdev) {
- pr_err("%s:%d :Error:soc_info is not initialized\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "soc_info is not initialized");
return -EINVAL;
}
@@ -41,27 +40,27 @@ int32_t cam_actuator_parse_dt(struct cam_actuator_ctrl_t *a_ctrl,
rc = cam_soc_util_get_dt_properties(soc_info);
if (rc < 0) {
- pr_err("%s:%d :Error: parsing common soc dt(rc %d)\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_ACTUATOR, "parsing common soc dt(rc %d)", rc);
return rc;
}
rc = of_property_read_u32(of_node, "cci-master",
&(a_ctrl->cci_i2c_master));
- CDBG("cci-master %d, rc %d\n", a_ctrl->cci_i2c_master, rc);
+ CAM_DBG(CAM_ACTUATOR, "cci-master %d, rc %d",
+ a_ctrl->cci_i2c_master, rc);
if (rc < 0 || a_ctrl->cci_i2c_master >= MASTER_MAX) {
- pr_err("%s:%d :Error: Wrong info from dt CCI master as : %d\n",
- __func__, __LINE__, a_ctrl->cci_i2c_master);
+ CAM_ERR(CAM_ACTUATOR, "Wrong info from dt CCI master as : %d",
+ a_ctrl->cci_i2c_master);
return rc;
}
if (!soc_info->gpio_data) {
- pr_info("%s:%d No GPIO found\n", __func__, __LINE__);
+ CAM_INFO(CAM_ACTUATOR, "No GPIO found");
rc = 0;
return rc;
}
if (!soc_info->gpio_data->cam_gpio_common_tbl_size) {
- pr_info("%s:%d No GPIO found\n", __func__, __LINE__);
+ CAM_INFO(CAM_ACTUATOR, "No GPIO found");
return -EINVAL;
}
@@ -69,8 +68,7 @@ int32_t cam_actuator_parse_dt(struct cam_actuator_ctrl_t *a_ctrl,
&a_ctrl->gpio_num_info);
if ((rc < 0) || (!a_ctrl->gpio_num_info)) {
- pr_err("%s:%d No/Error Actuator GPIOs\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_ACTUATOR, "No/Error Actuator GPIOs");
return -EINVAL;
}
return rc;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_core.c
index 83e0c19..c69eeaa 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_core.c
@@ -33,7 +33,7 @@ static int32_t cam_cci_convert_type_to_num_bytes(
num_bytes = 4;
break;
default:
- pr_err("%s: %d failed: %d\n", __func__, __LINE__, type);
+ CAM_ERR(CAM_CCI, "failed: %d", type);
num_bytes = 0;
break;
}
@@ -52,9 +52,9 @@ static void cam_cci_flush_queue(struct cci_device *cci_dev,
rc = wait_for_completion_timeout(
&cci_dev->cci_master_info[master].reset_complete, CCI_TIMEOUT);
if (rc < 0) {
- pr_err("%s:%d wait failed\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "wait failed");
} else if (rc == 0) {
- pr_err("%s:%d wait timeout\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "wait timeout");
/* Set reset pending flag to TRUE */
cci_dev->cci_master_info[master].reset_pending = TRUE;
@@ -72,8 +72,7 @@ static void cam_cci_flush_queue(struct cci_device *cci_dev,
&cci_dev->cci_master_info[master].reset_complete,
CCI_TIMEOUT);
if (rc <= 0)
- pr_err("%s:%d wait failed %d\n", __func__, __LINE__,
- rc);
+ CAM_ERR(CAM_CCI, "wait failed %d", rc);
}
}
@@ -91,37 +90,36 @@ static int32_t cam_cci_validate_queue(struct cci_device *cci_dev,
read_val = cam_io_r_mb(base +
CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset);
- CDBG("%s line %d CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR %d len %d max %d\n",
- __func__, __LINE__, read_val, len,
+ CAM_DBG(CAM_CCI, "CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR %d len %d max %d",
+ read_val, len,
cci_dev->cci_i2c_queue_info[master][queue].max_queue_size);
if ((read_val + len + 1) > cci_dev->
cci_i2c_queue_info[master][queue].max_queue_size) {
uint32_t reg_val = 0;
uint32_t report_val = CCI_I2C_REPORT_CMD | (1 << 8);
- CDBG("%s:%d CCI_I2C_REPORT_CMD\n", __func__, __LINE__);
+ CAM_DBG(CAM_CCI, "CCI_I2C_REPORT_CMD");
cam_io_w_mb(report_val,
base + CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
reg_offset);
read_val++;
- CDBG("%s:%d CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR %d, queue: %d\n",
- __func__, __LINE__, read_val, queue);
+ CAM_DBG(CAM_CCI,
+ "CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR %d, queue: %d",
+ read_val, queue);
cam_io_w_mb(read_val, base +
CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR + reg_offset);
reg_val = 1 << ((master * 2) + queue);
- CDBG("%s:%d CCI_QUEUE_START_ADDR\n", __func__, __LINE__);
+ CAM_DBG(CAM_CCI, "CCI_QUEUE_START_ADDR");
atomic_set(&cci_dev->cci_master_info[master].
done_pending[queue], 1);
cam_io_w_mb(reg_val, base +
CCI_QUEUE_START_ADDR);
- CDBG("%s line %d wait_for_completion_timeout\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_CCI, "wait_for_completion_timeout");
atomic_set(&cci_dev->cci_master_info[master].q_free[queue], 1);
rc = wait_for_completion_timeout(&cci_dev->
cci_master_info[master].report_q[queue], CCI_TIMEOUT);
if (rc <= 0) {
- pr_err("%s: wait_for_completion_timeout %d\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "Wait_for_completion_timeout %d");
if (rc == 0)
rc = -ETIMEDOUT;
cam_cci_flush_queue(cci_dev, master);
@@ -129,7 +127,7 @@ static int32_t cam_cci_validate_queue(struct cci_device *cci_dev,
}
rc = cci_dev->cci_master_info[master].status;
if (rc < 0)
- pr_err("%s failed rc %d\n", __func__, rc);
+ CAM_ERR(CAM_CCI, "Failed rc %d", rc);
}
return rc;
@@ -147,17 +145,17 @@ static int32_t cam_cci_write_i2c_queue(struct cci_device *cci_dev,
void __iomem *base = soc_info->reg_map[0].mem_base;
if (!cci_dev) {
- pr_err("%s: failed %d", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "%s: failed %d");
return -EINVAL;
}
rc = cam_cci_validate_queue(cci_dev, 1, master, queue);
if (rc < 0) {
- pr_err("%s: failed %d", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "Failed %d");
return rc;
}
- CDBG("%s CCI_I2C_M0_Q0_LOAD_DATA_ADDR:val 0x%x:0x%x\n",
- __func__, CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
+ CAM_DBG(CAM_CCI, "CCI_I2C_M0_Q0_LOAD_DATA_ADDR:val 0x%x:0x%x",
+ CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
reg_offset, val);
cam_io_w_mb(val, base + CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
reg_offset);
@@ -186,45 +184,43 @@ static void cam_cci_dump_registers(struct cci_device *cci_dev,
uint32_t reg_offset = 0;
/* CCI Top Registers */
- CCI_DBG(" **** %s : %d CCI TOP Registers ****\n", __func__, __LINE__);
+ CCI_DBG(" **** %s : %d CCI TOP Registers ****");
for (i = 0; i < DEBUG_TOP_REG_COUNT; i++) {
reg_offset = DEBUG_TOP_REG_START + i * 4;
read_val = cam_io_r_mb(cci_dev->base + reg_offset);
- CCI_DBG("%s : %d offset = 0x%X value = 0x%X\n",
- __func__, __LINE__, reg_offset, read_val);
+ CCI_DBG("offset = 0x%X value = 0x%X",
+ reg_offset, read_val);
}
/* CCI Master registers */
- CCI_DBG(" **** %s : %d CCI MASTER%d Registers ****\n",
- __func__, __LINE__, master);
+ CCI_DBG(" ****CCI MASTER %d Registers ****",
+ master);
for (i = 0; i < DEBUG_MASTER_REG_COUNT; i++) {
if (i == 6)
continue;
reg_offset = DEBUG_MASTER_REG_START + master*0x100 + i * 4;
read_val = cam_io_r_mb(cci_dev->base + reg_offset);
- CCI_DBG("%s : %d offset = 0x%X value = 0x%X\n",
- __func__, __LINE__, reg_offset, read_val);
+ CCI_DBG("offset = 0x%X value = 0x%X", reg_offset, read_val);
}
/* CCI Master Queue registers */
- CCI_DBG(" **** %s : %d CCI MASTER%d QUEUE%d Registers ****\n",
- __func__, __LINE__, master, queue);
+ CCI_DBG(" **** CCI MASTER%d QUEUE%d Registers ****",
+ master, queue);
for (i = 0; i < DEBUG_MASTER_QUEUE_REG_COUNT; i++) {
reg_offset = DEBUG_MASTER_QUEUE_REG_START + master*0x200 +
queue*0x100 + i * 4;
read_val = cam_io_r_mb(cci_dev->base + reg_offset);
- CCI_DBG("%s : %d offset = 0x%X value = 0x%X\n",
- __func__, __LINE__, reg_offset, read_val);
+ CCI_DBG("offset = 0x%X value = 0x%X",
+ reg_offset, read_val);
}
/* CCI Interrupt registers */
- CCI_DBG(" **** %s : %d CCI Interrupt Registers ****\n",
- __func__, __LINE__);
+ CCI_DBG(" ****CCI Interrupt Registers ****");
for (i = 0; i < DEBUG_INTR_REG_COUNT; i++) {
reg_offset = DEBUG_INTR_REG_START + i * 4;
read_val = cam_io_r_mb(cci_dev->base + reg_offset);
- CCI_DBG("%s : %d offset = 0x%X value = 0x%X\n",
- __func__, __LINE__, reg_offset, read_val);
+ CCI_DBG("offset = 0x%X value = 0x%X",
+ reg_offset, read_val);
}
}
#endif
@@ -236,21 +232,19 @@ static uint32_t cam_cci_wait(struct cci_device *cci_dev,
int32_t rc = 0;
if (!cci_dev) {
- pr_err("%s: failed %d", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "failed");
return -EINVAL;
}
rc = wait_for_completion_timeout(&cci_dev->
cci_master_info[master].report_q[queue], CCI_TIMEOUT);
- CDBG("%s line %d wait DONE_for_completion_timeout\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_CCI, "wait DONE_for_completion_timeout");
if (rc <= 0) {
#ifdef DUMP_CCI_REGISTERS
cam_cci_dump_registers(cci_dev, master, queue);
#endif
- pr_err("%s: %d wait for queue: %d\n",
- __func__, __LINE__, queue);
+ CAM_ERR(CAM_CCI, "wait for queue: %d", queue);
if (rc == 0)
rc = -ETIMEDOUT;
cam_cci_flush_queue(cci_dev, master);
@@ -258,7 +252,7 @@ static uint32_t cam_cci_wait(struct cci_device *cci_dev,
}
rc = cci_dev->cci_master_info[master].status;
if (rc < 0) {
- pr_err("%s: %d failed rc %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "failed rc %d", rc);
return rc;
}
@@ -278,15 +272,13 @@ static void cam_cci_load_report_cmd(struct cci_device *cci_dev,
CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset);
uint32_t report_val = CCI_I2C_REPORT_CMD | (1 << 8);
- CDBG("%s:%d CCI_I2C_REPORT_CMD curr_w_cnt: %d\n",
- __func__, __LINE__, read_val);
+ CAM_DBG(CAM_CCI, "CCI_I2C_REPORT_CMD curr_w_cnt: %d", read_val);
cam_io_w_mb(report_val,
base + CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
reg_offset);
read_val++;
- CDBG("%s:%d CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR %d\n",
- __func__, __LINE__, read_val);
+ CAM_DBG(CAM_CCI, "CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR %d", read_val);
cam_io_w_mb(read_val, base +
CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR + reg_offset);
}
@@ -319,12 +311,12 @@ static int32_t cam_cci_transfer_end(struct cci_device *cci_dev,
if (atomic_read(&cci_dev->cci_master_info[master].q_free[queue]) == 0) {
rc = cam_cci_lock_queue(cci_dev, master, queue, 0);
if (rc < 0) {
- pr_err("%s failed line %d\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "failed line %d");
return rc;
}
rc = cam_cci_wait_report_cmd(cci_dev, master, queue);
if (rc < 0) {
- pr_err("%s: %d failed rc %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "failed rc %d", rc);
return rc;
}
} else {
@@ -332,17 +324,17 @@ static int32_t cam_cci_transfer_end(struct cci_device *cci_dev,
done_pending[queue], 1);
rc = cam_cci_wait(cci_dev, master, queue);
if (rc < 0) {
- pr_err("%s: %d failed rc %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "failed rc %d", rc);
return rc;
}
rc = cam_cci_lock_queue(cci_dev, master, queue, 0);
if (rc < 0) {
- pr_err("%s failed line %d\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "failed rc %d", rc);
return rc;
}
rc = cam_cci_wait_report_cmd(cci_dev, master, queue);
if (rc < 0) {
- pr_err("%s: %d failed rc %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "Failed rc %d", rc);
return rc;
}
}
@@ -362,8 +354,7 @@ static int32_t cam_cci_get_queue_free_size(struct cci_device *cci_dev,
read_val = cam_io_r_mb(base +
CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset);
- CDBG("%s line %d CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR %d max %d\n",
- __func__, __LINE__, read_val,
+ CAM_DBG(CAM_CCI, "CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR %d max %d", read_val,
cci_dev->cci_i2c_queue_info[master][queue].max_queue_size);
return (cci_dev->
cci_i2c_queue_info[master][queue].max_queue_size) -
@@ -398,13 +389,13 @@ static int32_t cam_cci_process_full_q(struct cci_device *cci_dev,
done_pending[queue], 1);
rc = cam_cci_wait(cci_dev, master, queue);
if (rc < 0) {
- pr_err("%s: %d failed rc %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "failed rc %d", rc);
return rc;
}
} else {
rc = cam_cci_wait_report_cmd(cci_dev, master, queue);
if (rc < 0) {
- pr_err("%s: %d failed rc %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "failed rc %d", rc);
return rc;
}
}
@@ -425,7 +416,7 @@ static int32_t cam_cci_calc_cmd_len(struct cci_device *cci_dev,
uint32_t size = cmd_size;
if (!cci_dev || !c_ctrl) {
- pr_err("%s: failed %d", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "failed");
return -EINVAL;
}
@@ -458,8 +449,8 @@ static int32_t cam_cci_calc_cmd_len(struct cci_device *cci_dev,
}
if (len > cci_dev->payload_size) {
- pr_err("%s: %d Len error: %d",
- __func__, __LINE__, len);
+ CAM_ERR(CAM_CCI, "%s: %d Len error: %d",
+ len);
return -EINVAL;
}
@@ -476,8 +467,8 @@ static uint32_t cam_cci_cycles_per_ms(unsigned long clk)
if (clk) {
cycles_per_us = ((clk/1000)*256)/1000;
} else {
- pr_err("%s:%d, failed: Can use default: %d",
- __func__, __LINE__, CYCLES_PER_MICRO_SEC_DEFAULT);
+ CAM_ERR(CAM_CCI, "failed: Can use default: %d",
+ CYCLES_PER_MICRO_SEC_DEFAULT);
cycles_per_us = CYCLES_PER_MICRO_SEC_DEFAULT;
}
@@ -498,8 +489,8 @@ void cam_cci_get_clk_rates(struct cci_device *cci_dev,
if (i2c_freq_mode >= I2C_MAX_MODES ||
i2c_freq_mode < I2C_STANDARD_MODE) {
- pr_err("%s:%d Invalid frequency mode: %d\n",
- __func__, __LINE__, (int32_t)i2c_freq_mode);
+ CAM_ERR(CAM_CCI, "Invalid frequency mode: %d",
+ (int32_t)i2c_freq_mode);
cci_dev->clk_level_index = -1;
return;
}
@@ -544,8 +535,7 @@ static int32_t cam_cci_set_clk_param(struct cci_device *cci_dev,
void __iomem *base = soc_info->reg_map[0].mem_base;
if ((i2c_freq_mode >= I2C_MAX_MODES) || (i2c_freq_mode < 0)) {
- pr_err("%s:%d invalid i2c_freq_mode = %d",
- __func__, __LINE__, i2c_freq_mode);
+ CAM_ERR(CAM_CCI, "invalid i2c_freq_mode = %d", i2c_freq_mode);
return -EINVAL;
}
@@ -608,28 +598,27 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev,
void __iomem *base = soc_info->reg_map[0].mem_base;
if (i2c_cmd == NULL) {
- pr_err("%s:%d Failed line\n", __func__,
- __LINE__);
+ CAM_ERR(CAM_CCI, "Failed: i2c cmd is NULL");
return -EINVAL;
}
if ((!cmd_size) || (cmd_size > CCI_I2C_MAX_WRITE)) {
- pr_err("%s:%d failed: invalid cmd_size %d\n",
- __func__, __LINE__, cmd_size);
+ CAM_ERR(CAM_CCI, "failed: invalid cmd_size %d",
+ cmd_size);
return -EINVAL;
}
- CDBG("%s addr type %d data type %d cmd_size %d\n", __func__,
+ CAM_DBG(CAM_CCI, "addr type %d data type %d cmd_size %d",
i2c_msg->addr_type, i2c_msg->data_type, cmd_size);
if (i2c_msg->addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX) {
- pr_err("%s:%d failed: invalid addr_type 0x%X\n",
- __func__, __LINE__, i2c_msg->addr_type);
+ CAM_ERR(CAM_CCI, "failed: invalid addr_type 0x%X",
+ i2c_msg->addr_type);
return -EINVAL;
}
if (i2c_msg->data_type >= CAMERA_SENSOR_I2C_TYPE_MAX) {
- pr_err("%s:%d failed: invalid data_type 0x%X\n",
- __func__, __LINE__, i2c_msg->data_type);
+ CAM_ERR(CAM_CCI, "failed: invalid data_type 0x%X",
+ i2c_msg->data_type);
return -EINVAL;
}
reg_offset = master * 0x200 + queue * 0x100;
@@ -643,8 +632,8 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev,
c_ctrl->cci_info->retries << 16 |
c_ctrl->cci_info->id_map << 18;
- CDBG("%s CCI_I2C_M0_Q0_LOAD_DATA_ADDR:val 0x%x:0x%x\n",
- __func__, CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
+ CAM_DBG(CAM_CCI, "CCI_I2C_M0_Q0_LOAD_DATA_ADDR:val 0x%x:0x%x",
+ CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
reg_offset, val);
cam_io_w_mb(val, base + CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
reg_offset);
@@ -671,7 +660,7 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev,
rc = cam_cci_lock_queue(cci_dev, master, queue, 1);
if (rc < 0) {
- pr_err("%s failed line %d\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "%s failed line %d");
return rc;
}
@@ -681,22 +670,21 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev,
len = cam_cci_calc_cmd_len(cci_dev, c_ctrl, cmd_size,
i2c_cmd, &pack);
if (len <= 0) {
- pr_err("%s failed line %d\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "%s failed line %d");
return -EINVAL;
}
read_val = cam_io_r_mb(base +
CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset);
- CDBG("%s line %d CUR_WORD_CNT_ADDR %d len %d max %d\n",
- __func__, __LINE__, read_val, len, max_queue_size);
+ CAM_DBG(CAM_CCI, "CUR_WORD_CNT_ADDR %d len %d max %d",
+ read_val, len, max_queue_size);
/* + 1 - space alocation for Report CMD */
if ((read_val + len + 1) > queue_size) {
if ((read_val + len + 1) > max_queue_size) {
rc = cam_cci_process_full_q(cci_dev,
master, queue);
if (rc < 0) {
- pr_err("%s failed line %d\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "failed rc: %d", rc);
return rc;
}
continue;
@@ -704,7 +692,7 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev,
cam_cci_process_half_q(cci_dev, master, queue);
}
- CDBG("%s cmd_size %d addr 0x%x data 0x%x\n", __func__,
+ CAM_DBG(CAM_CCI, "cmd_size %d addr 0x%x data 0x%x",
cmd_size, i2c_cmd->reg_addr, i2c_cmd->reg_data);
delay = i2c_cmd->delay;
i = 0;
@@ -772,8 +760,9 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev,
cmd = 0;
for (j = 0; (j < 4 && k < i); j++)
cmd |= (data[k++] << (j * 8));
- CDBG("%s LOAD_DATA_ADDR 0x%x, q: %d, len:%d, cnt: %d\n",
- __func__, cmd, queue, len, read_val);
+ CAM_DBG(CAM_CCI,
+ "LOAD_DATA_ADDR 0x%x, q: %d, len:%d, cnt: %d",
+ cmd, queue, len, read_val);
cam_io_w_mb(cmd, base +
CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
master * 0x200 + queue * 0x100);
@@ -789,8 +778,8 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev,
0x100);
cmd <<= 4;
cmd |= CCI_I2C_WAIT_CMD;
- CDBG("%s CCI_I2C_M0_Q0_LOAD_DATA_ADDR 0x%x\n",
- __func__, cmd);
+ CAM_DBG(CAM_CCI,
+ "CCI_I2C_M0_Q0_LOAD_DATA_ADDR 0x%x", cmd);
cam_io_w_mb(cmd, base +
CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
master * 0x200 + queue * 0x100);
@@ -802,7 +791,7 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev,
rc = cam_cci_transfer_end(cci_dev, master, queue);
if (rc < 0) {
- pr_err("%s: %d failed rc %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "failed rc %d", rc);
return rc;
}
@@ -830,7 +819,7 @@ static int32_t cam_cci_read(struct v4l2_subdev *sd,
if (c_ctrl->cci_info->cci_i2c_master >= MASTER_MAX
|| c_ctrl->cci_info->cci_i2c_master < 0) {
- pr_err("%s:%d Invalid I2C master addr\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "Invalid I2C master addr");
return -EINVAL;
}
@@ -847,8 +836,7 @@ static int32_t cam_cci_read(struct v4l2_subdev *sd,
/* Set the I2C Frequency */
rc = cam_cci_set_clk_param(cci_dev, c_ctrl);
if (rc < 0) {
- pr_err("%s:%d cam_cci_set_clk_param failed rc = %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "cam_cci_set_clk_param failed rc = %d", rc);
goto rel_mutex;
}
@@ -861,25 +849,22 @@ static int32_t cam_cci_read(struct v4l2_subdev *sd,
cci_dev->cci_i2c_queue_info[master][queue].max_queue_size - 1,
master, queue);
if (rc < 0) {
- pr_err("%s:%d Initial validataion failed rc %d\n", __func__,
- __LINE__, rc);
+ CAM_ERR(CAM_CCI, "Initial validataion failed rc %d", rc);
goto rel_mutex;
}
if (c_ctrl->cci_info->retries > CCI_I2C_READ_MAX_RETRIES) {
- pr_err("%s:%d More than max retries\n", __func__,
- __LINE__);
+ CAM_ERR(CAM_CCI, "More than max retries");
goto rel_mutex;
}
if (read_cfg->data == NULL) {
- pr_err("%s:%d Data ptr is NULL\n", __func__,
- __LINE__);
+ CAM_ERR(CAM_CCI, "Data ptr is NULL");
goto rel_mutex;
}
- CDBG("%s master %d, queue %d\n", __func__, master, queue);
- CDBG("%s set param sid 0x%x retries %d id_map %d\n", __func__,
+ CAM_DBG(CAM_CCI, "master %d, queue %d", master, queue);
+ CAM_DBG(CAM_CCI, "set param sid 0x%x retries %d id_map %d",
c_ctrl->cci_info->sid, c_ctrl->cci_info->retries,
c_ctrl->cci_info->id_map);
val = CCI_I2C_SET_PARAM_CMD | c_ctrl->cci_info->sid << 4 |
@@ -887,19 +872,20 @@ static int32_t cam_cci_read(struct v4l2_subdev *sd,
c_ctrl->cci_info->id_map << 18;
rc = cam_cci_write_i2c_queue(cci_dev, val, master, queue);
if (rc < 0) {
- CDBG("%s failed line %d\n", __func__, __LINE__);
+ CAM_DBG(CAM_CCI, "failed rc: %d", rc);
goto rel_mutex;
}
val = CCI_I2C_LOCK_CMD;
rc = cam_cci_write_i2c_queue(cci_dev, val, master, queue);
if (rc < 0) {
- CDBG("%s failed line %d\n", __func__, __LINE__);
+ CAM_DBG(CAM_CCI, "failed rc: %d", rc);
goto rel_mutex;
}
if (read_cfg->addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX) {
- pr_err("%s failed line %d\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "failed : Invalid addr type: %u",
+ read_cfg->addr_type);
rc = -EINVAL;
goto rel_mutex;
}
@@ -912,34 +898,33 @@ static int32_t cam_cci_read(struct v4l2_subdev *sd,
rc = cam_cci_write_i2c_queue(cci_dev, val, master, queue);
if (rc < 0) {
- CDBG("%s failed line %d\n", __func__, __LINE__);
+ CAM_DBG(CAM_CCI, "failed rc: %d", rc);
goto rel_mutex;
}
val = CCI_I2C_READ_CMD | (read_cfg->num_byte << 4);
rc = cam_cci_write_i2c_queue(cci_dev, val, master, queue);
if (rc < 0) {
- CDBG("%s failed line %d\n", __func__, __LINE__);
+ CAM_DBG(CAM_CCI, "failed rc: %d", rc);
goto rel_mutex;
}
val = CCI_I2C_UNLOCK_CMD;
rc = cam_cci_write_i2c_queue(cci_dev, val, master, queue);
if (rc < 0) {
- CDBG("%s failed line %d\n", __func__, __LINE__);
+ CAM_DBG(CAM_CCI, "failed rc: %d", rc);
goto rel_mutex;
}
val = cam_io_r_mb(base + CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR
+ master * 0x200 + queue * 0x100);
- CDBG("%s cur word cnt 0x%x\n", __func__, val);
+ CAM_DBG(CAM_CCI, "%s cur word cnt 0x%x", val);
cam_io_w_mb(val, base + CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR
+ master * 0x200 + queue * 0x100);
val = 1 << ((master * 2) + queue);
cam_io_w_mb(val, base + CCI_QUEUE_START_ADDR);
- CDBG("%s:%d E wait_for_completion_timeout\n", __func__,
- __LINE__);
+ CAM_DBG(CAM_CCI, "wait_for_completion_timeout");
rc = wait_for_completion_timeout(&cci_dev->
cci_master_info[master].reset_complete, CCI_TIMEOUT);
@@ -949,8 +934,7 @@ static int32_t cam_cci_read(struct v4l2_subdev *sd,
#endif
if (rc == 0)
rc = -ETIMEDOUT;
- pr_err("%s: %d wait_for_completion_timeout rc = %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "wait_for_completion_timeout rc = %d", rc);
cam_cci_flush_queue(cci_dev, master);
goto rel_mutex;
} else {
@@ -961,29 +945,28 @@ static int32_t cam_cci_read(struct v4l2_subdev *sd,
CCI_I2C_M0_READ_BUF_LEVEL_ADDR + master * 0x100);
exp_words = ((read_cfg->num_byte / 4) + 1);
if (read_words != exp_words) {
- pr_err("%s:%d read_words = %d, exp words = %d\n", __func__,
- __LINE__, read_words, exp_words);
+ CAM_ERR(CAM_CCI, "read_words = %d, exp words = %d",
+ read_words, exp_words);
memset(read_cfg->data, 0, read_cfg->num_byte);
rc = -EINVAL;
goto rel_mutex;
}
index = 0;
- CDBG("%s index %d num_type %d\n", __func__, index,
- read_cfg->num_byte);
+ CAM_DBG(CAM_CCI, "index %d num_type %d", index, read_cfg->num_byte);
first_byte = 0;
do {
val = cam_io_r_mb(base +
CCI_I2C_M0_READ_DATA_ADDR + master * 0x100);
- CDBG("%s read val 0x%x\n", __func__, val);
+ CAM_DBG(CAM_CCI, "read val 0x%x", val);
for (i = 0; (i < 4) && (index < read_cfg->num_byte); i++) {
- CDBG("%s i %d index %d\n", __func__, i, index);
+ CAM_DBG(CAM_CCI, "i:%d index:%d", i, index);
if (!first_byte) {
- CDBG("%s sid 0x%x\n", __func__, val & 0xFF);
+ CAM_DBG(CAM_CCI, "sid 0x%x", val & 0xFF);
first_byte++;
} else {
read_cfg->data[index] =
(val >> (i * 8)) & 0xFF;
- CDBG("%s data[%d] 0x%x\n", __func__, index,
+ CAM_DBG(CAM_CCI, "data[%d] 0x%x", index,
read_cfg->data[index]);
index++;
}
@@ -1006,20 +989,19 @@ static int32_t cam_cci_i2c_write(struct v4l2_subdev *sd,
cci_dev = v4l2_get_subdevdata(sd);
if (cci_dev->cci_state != CCI_STATE_ENABLED) {
- pr_err("%s invalid cci state %d\n",
- __func__, cci_dev->cci_state);
+ CAM_ERR(CAM_CCI, "%s invalid cci state %d",
+ cci_dev->cci_state);
return -EINVAL;
}
master = c_ctrl->cci_info->cci_i2c_master;
- CDBG("%s set param sid 0x%x retries %d id_map %d\n", __func__,
+ CAM_DBG(CAM_CCI, "set param sid 0x%x retries %d id_map %d",
c_ctrl->cci_info->sid, c_ctrl->cci_info->retries,
c_ctrl->cci_info->id_map);
/* Set the I2C Frequency */
rc = cam_cci_set_clk_param(cci_dev, c_ctrl);
if (rc < 0) {
- pr_err("%s:%d cam_cci_set_clk_param failed rc = %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "cam_cci_set_clk_param failed rc = %d", rc);
return rc;
}
/*
@@ -1031,18 +1013,17 @@ static int32_t cam_cci_i2c_write(struct v4l2_subdev *sd,
cci_dev->cci_i2c_queue_info[master][queue].max_queue_size-1,
master, queue);
if (rc < 0) {
- pr_err("%s:%d Initial validataion failed rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "%s:%d Initial validataion failed rc %d",
+ rc);
return rc;
}
if (c_ctrl->cci_info->retries > CCI_I2C_READ_MAX_RETRIES) {
- pr_err("%s:%d More than max retries\n", __func__,
- __LINE__);
+ CAM_ERR(CAM_CCI, "More than max retries");
return rc;
}
rc = cam_cci_data_queue(cci_dev, c_ctrl, queue, sync_en);
if (rc < 0) {
- pr_err("%s failed line %d\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "failed rc: %d", rc);
return rc;
}
@@ -1069,7 +1050,7 @@ static void cam_cci_write_async_helper(struct work_struct *work)
&write_async->c_ctrl, write_async->queue, write_async->sync_en);
mutex_unlock(&cci_master_info->mutex_q[write_async->queue]);
if (rc < 0)
- pr_err("%s: %d failed\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "failed rc: %d", rc);
kfree(write_async->c_ctrl.cfg.cci_i2c_write_cfg.reg_setting);
kfree(write_async);
@@ -1110,7 +1091,7 @@ static int32_t cam_cci_i2c_write_async(struct v4l2_subdev *sd,
kzalloc(sizeof(struct cam_sensor_i2c_reg_array)*
cci_i2c_write_cfg->size, GFP_KERNEL);
if (!cci_i2c_write_cfg_w->reg_setting) {
- pr_err("%s: %d Couldn't allocate memory\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "Couldn't allocate memory");
kfree(write_async);
return -ENOMEM;
}
@@ -1140,35 +1121,33 @@ static int32_t cam_cci_read_bytes(struct v4l2_subdev *sd,
uint16_t read_bytes = 0;
if (!sd || !c_ctrl) {
- pr_err("%s:%d sd %pK c_ctrl %pK\n", __func__,
- __LINE__, sd, c_ctrl);
+ CAM_ERR(CAM_CCI, "sd %pK c_ctrl %pK", sd, c_ctrl);
return -EINVAL;
}
if (!c_ctrl->cci_info) {
- pr_err("%s:%d cci_info NULL\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "cci_info NULL");
return -EINVAL;
}
cci_dev = v4l2_get_subdevdata(sd);
if (!cci_dev) {
- pr_err("%s:%d cci_dev NULL\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "cci_dev NULL");
return -EINVAL;
}
if (cci_dev->cci_state != CCI_STATE_ENABLED) {
- pr_err("%s invalid cci state %d\n",
- __func__, cci_dev->cci_state);
+ CAM_ERR(CAM_CCI, "invalid cci state %d", cci_dev->cci_state);
return -EINVAL;
}
if (c_ctrl->cci_info->cci_i2c_master >= MASTER_MAX
|| c_ctrl->cci_info->cci_i2c_master < 0) {
- pr_err("%s:%d Invalid I2C master addr\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "Invalid I2C master addr");
return -EINVAL;
}
master = c_ctrl->cci_info->cci_i2c_master;
read_cfg = &c_ctrl->cfg.cci_i2c_read_cfg;
if ((!read_cfg->num_byte) || (read_cfg->num_byte > CCI_I2C_MAX_READ)) {
- pr_err("%s:%d read num bytes 0\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "read num bytes 0");
rc = -EINVAL;
goto ERROR;
}
@@ -1181,7 +1160,7 @@ static int32_t cam_cci_read_bytes(struct v4l2_subdev *sd,
read_cfg->num_byte = read_bytes;
rc = cam_cci_read(sd, c_ctrl);
if (rc < 0) {
- pr_err("%s:%d failed rc %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "failed rc %d", rc);
goto ERROR;
}
if (read_bytes > CCI_READ_MAX) {
@@ -1205,8 +1184,8 @@ static int32_t cam_cci_i2c_set_sync_prms(struct v4l2_subdev *sd,
cci_dev = v4l2_get_subdevdata(sd);
if (!cci_dev || !c_ctrl) {
- pr_err("%s:%d failed: invalid params %pK %pK\n", __func__,
- __LINE__, cci_dev, c_ctrl);
+ CAM_ERR(CAM_CCI, "failed: invalid params %pK %pK",
+ cci_dev, c_ctrl);
rc = -EINVAL;
return rc;
}
@@ -1225,8 +1204,7 @@ static int32_t cam_cci_release(struct v4l2_subdev *sd)
rc = cam_cci_soc_release(cci_dev);
if (rc < 0) {
- pr_err("%s:%d Failed in releasing the cci: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "Failed in releasing the cci: %d", rc);
cam_cpas_stop(cci_dev->cpas_handle);
return rc;
}
@@ -1246,8 +1224,8 @@ static int32_t cam_cci_write(struct v4l2_subdev *sd,
cci_dev = v4l2_get_subdevdata(sd);
if (!cci_dev || !c_ctrl) {
- pr_err("%s:%d failed: invalid params %pK %pK\n", __func__,
- __LINE__, cci_dev, c_ctrl);
+ CAM_ERR(CAM_CCI, "failed: invalid params %pK %pK",
+ cci_dev, c_ctrl);
rc = -EINVAL;
return rc;
}
@@ -1256,7 +1234,7 @@ static int32_t cam_cci_write(struct v4l2_subdev *sd,
if (c_ctrl->cci_info->cci_i2c_master >= MASTER_MAX
|| c_ctrl->cci_info->cci_i2c_master < 0) {
- pr_err("%s:%d Invalid I2C master addr\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "Invalid I2C master addr");
return -EINVAL;
}
@@ -1304,8 +1282,7 @@ int32_t cam_cci_core_cfg(struct v4l2_subdev *sd,
{
int32_t rc = 0;
- CDBG("%s line %d cmd %d\n", __func__, __LINE__,
- cci_ctrl->cmd);
+ CAM_DBG(CAM_CCI, "cmd %d", cci_ctrl->cmd);
switch (cci_ctrl->cmd) {
case MSM_CCI_INIT:
rc = cam_cci_init(sd, cci_ctrl);
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.c
index 63655a4..dad02bf 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.c
@@ -37,8 +37,7 @@ static long cam_cci_subdev_ioctl(struct v4l2_subdev *sd,
case VIDIOC_CAM_CONTROL:
break;
default:
- pr_err("%s:%d Invalid ioctl cmd: %d\n",
- __func__, __LINE__, cmd);
+ CAM_ERR(CAM_CCI, "Invalid ioctl cmd: %d", cmd);
rc = -ENOIOCTLCMD;
}
@@ -134,13 +133,13 @@ irqreturn_t cam_cci_irq(int irq_num, void *data)
base + CCI_RESET_CMD_ADDR);
}
if (irq & CCI_IRQ_STATUS_0_I2C_M0_ERROR_BMSK) {
- pr_err("%s:%d MASTER_0 error 0x%x\n", __func__, __LINE__, irq);
+ CAM_ERR(CAM_CCI, "MASTER_0 error 0x%x", irq);
cci_dev->cci_master_info[MASTER_0].status = -EINVAL;
cam_io_w_mb(CCI_M0_HALT_REQ_RMSK,
base + CCI_HALT_REQ_ADDR);
}
if (irq & CCI_IRQ_STATUS_0_I2C_M1_ERROR_BMSK) {
- pr_err("%s:%d MASTER_1 error 0x%x\n", __func__, __LINE__, irq);
+ CAM_ERR(CAM_CCI, "MASTER_1 error 0x%x", irq);
cci_dev->cci_master_info[MASTER_1].status = -EINVAL;
cam_io_w_mb(CCI_M1_HALT_REQ_RMSK,
base + CCI_HALT_REQ_ADDR);
@@ -192,8 +191,7 @@ static int cam_cci_platform_probe(struct platform_device *pdev)
rc = cam_cci_parse_dt_info(pdev, new_cci_dev);
if (rc < 0) {
- pr_err("%s: %d Resource get Failed: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "Resource get Failed: %d", rc);
goto cci_no_resource;
}
@@ -214,8 +212,7 @@ static int cam_cci_platform_probe(struct platform_device *pdev)
rc = cam_register_subdev(&(new_cci_dev->v4l2_dev_str));
if (rc < 0) {
- pr_err("%s:%d :Error: Fail with cam_register_subdev\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "Fail with cam_register_subdev");
goto cci_no_resource;
}
@@ -230,10 +227,10 @@ static int cam_cci_platform_probe(struct platform_device *pdev)
strlcpy(cpas_parms.identifier, "cci", CAM_HW_IDENTIFIER_LENGTH);
rc = cam_cpas_register_client(&cpas_parms);
if (rc) {
- pr_err("%s:%d CPAS registration failed\n", __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "CPAS registration failed");
goto cci_no_resource;
}
- CDBG("CPAS registration successful handle=%d\n",
+ CAM_DBG(CAM_CCI, "CPAS registration successful handle=%d",
cpas_parms.client_handle);
new_cci_dev->cpas_handle = cpas_parms.client_handle;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.h
index 6268a1b..cb01c6c 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_dev.h
@@ -37,6 +37,7 @@
#include <cam_cpas_api.h>
#include "cam_cci_hwreg.h"
#include "cam_soc_util.h"
+#include "cam_debug_util.h"
#define V4L2_IDENT_CCI 50005
#define CCI_I2C_QUEUE_0_SIZE 128
@@ -80,16 +81,6 @@
#define PRIORITY_QUEUE (QUEUE_0)
#define SYNC_QUEUE (QUEUE_1)
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-
-#undef CCI_DBG
-#ifdef MSM_CCI_DEBUG
-#define CCI_DBG(fmt, args...) pr_err(fmt, ##args)
-#else
-#define CCI_DBG(fmt, args...) pr_debug(fmt, ##args)
-#endif
-
enum cci_i2c_sync {
MSM_SYNC_DISABLE,
MSM_SYNC_ENABLE,
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_soc.c
index d976788..83cb49e3 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_soc.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_cci/cam_cci_soc.c
@@ -27,8 +27,8 @@ int cam_cci_init(struct v4l2_subdev *sd,
cci_dev = v4l2_get_subdevdata(sd);
if (!cci_dev || !c_ctrl) {
- pr_err("%s:%d failed: invalid params %pK %pK\n", __func__,
- __LINE__, cci_dev, c_ctrl);
+ CAM_ERR(CAM_CCI, "failed: invalid params %pK %pK",
+ cci_dev, c_ctrl);
rc = -EINVAL;
return rc;
}
@@ -37,19 +37,18 @@ int cam_cci_init(struct v4l2_subdev *sd,
base = soc_info->reg_map[0].mem_base;
if (!soc_info || !base) {
- pr_err("%s:%d failed: invalid params %pK %pK\n", __func__,
- __LINE__, soc_info, base);
+ CAM_ERR(CAM_CCI, "failed: invalid params %pK %pK",
+ soc_info, base);
rc = -EINVAL;
return rc;
}
- CDBG("%s:%d Base address %pK\n", __func__, __LINE__, base);
+ CAM_DBG(CAM_CCI, "Base address %pK", base);
if (cci_dev->ref_count++) {
- CDBG("%s:%d ref_count %d\n", __func__, __LINE__,
- cci_dev->ref_count);
+ CAM_DBG(CAM_CCI, "ref_count %d", cci_dev->ref_count);
master = c_ctrl->cci_info->cci_i2c_master;
- CDBG("%s:%d master %d\n", __func__, __LINE__, master);
+ CAM_DBG(CAM_CCI, "master %d", master);
if (master < MASTER_MAX && master >= 0) {
mutex_lock(&cci_dev->cci_master_info[master].mutex);
flush_workqueue(cci_dev->write_wq[master]);
@@ -74,8 +73,7 @@ int cam_cci_init(struct v4l2_subdev *sd,
reset_complete,
CCI_TIMEOUT);
if (rc <= 0)
- pr_err("%s:%d wait failed %d\n", __func__,
- __LINE__, rc);
+ CAM_ERR(CAM_CCI, "wait failed %d", rc);
mutex_unlock(&cci_dev->cci_master_info[master].mutex);
}
return 0;
@@ -89,8 +87,7 @@ int cam_cci_init(struct v4l2_subdev *sd,
rc = cam_cpas_start(cci_dev->cpas_handle,
&ahb_vote, &axi_vote);
if (rc != 0) {
- pr_err("%s:%d CPAS start failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "CPAS start failed");
}
cam_cci_get_clk_rates(cci_dev, c_ctrl);
@@ -104,15 +101,13 @@ int cam_cci_init(struct v4l2_subdev *sd,
rc = cam_soc_util_enable_platform_resource(soc_info, true,
CAM_TURBO_VOTE, true);
if (rc < 0) {
- CDBG("%s:%d request platform resources failed\n", __func__,
- __LINE__);
+ CAM_DBG(CAM_CCI, "request platform resources failed");
goto platform_enable_failed;
}
cci_dev->hw_version = cam_io_r_mb(base +
CCI_HW_VERSION_ADDR);
- CDBG("%s:%d: hw_version = 0x%x\n", __func__, __LINE__,
- cci_dev->hw_version);
+ CAM_DBG(CAM_CCI, "hw_version = 0x%x", cci_dev->hw_version);
cci_dev->payload_size =
MSM_CCI_WRITE_DATA_PAYLOAD_SIZE_11;
@@ -129,12 +124,11 @@ int cam_cci_init(struct v4l2_subdev *sd,
max_queue_size =
CCI_I2C_QUEUE_1_SIZE;
- CDBG("%s:%d : CCI Master[%d] :: Q0 : %d Q1 : %d\n",
- __func__, __LINE__, i,
+ CAM_DBG(CAM_CCI, "CCI Master[%d] :: Q0 : %d Q1 : %d", i
+ , cci_dev->cci_i2c_queue_info[i][j].
+ max_queue_size,
cci_dev->cci_i2c_queue_info[i][j].
- max_queue_size,
- cci_dev->cci_i2c_queue_info[i][j].
- max_queue_size);
+ max_queue_size);
}
}
@@ -146,8 +140,7 @@ int cam_cci_init(struct v4l2_subdev *sd,
&cci_dev->cci_master_info[MASTER_0].reset_complete,
CCI_TIMEOUT);
if (rc <= 0) {
- pr_err("%s:%d wait_for_completion_timeout\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "wait_for_completion_timeout");
if (rc == 0)
rc = -ETIMEDOUT;
goto reset_complete_failed;
@@ -162,8 +155,7 @@ int cam_cci_init(struct v4l2_subdev *sd,
for (i = 0; i < MASTER_MAX; i++) {
if (!cci_dev->write_wq[i]) {
- pr_err("%s:%d Failed to flush write wq\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "Failed to flush write wq");
rc = -ENOMEM;
goto reset_complete_failed;
} else {
@@ -251,77 +243,75 @@ static void cam_cci_init_clk_params(struct cci_device *cci_dev)
"qcom,i2c_custom_mode");
rc = of_property_read_u32(src_node, "hw-thigh", &val);
- CDBG("%s:%d hw-thigh %d, rc %d\n", __func__, __LINE__, val, rc);
+ CAM_DBG(CAM_CCI, "hw-thigh %d, rc %d", val, rc);
if (!rc) {
cci_dev->cci_clk_params[count].hw_thigh = val;
rc = of_property_read_u32(src_node, "hw-tlow",
&val);
- CDBG("%s:%d hw-tlow %d, rc %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_CCI, "hw-tlow %d, rc %d",
val, rc);
}
if (!rc) {
cci_dev->cci_clk_params[count].hw_tlow = val;
rc = of_property_read_u32(src_node, "hw-tsu-sto",
&val);
- CDBG("%s:%d hw-tsu-sto %d, rc %d\n",
- __func__, __LINE__, val, rc);
+ CAM_DBG(CAM_CCI, "hw-tsu-sto %d, rc %d",
+ val, rc);
}
if (!rc) {
cci_dev->cci_clk_params[count].hw_tsu_sto = val;
rc = of_property_read_u32(src_node, "hw-tsu-sta",
&val);
- CDBG("%s:%d hw-tsu-sta %d, rc %d\n",
- __func__, __LINE__, val, rc);
+ CAM_DBG(CAM_CCI, "hw-tsu-sta %d, rc %d",
+ val, rc);
}
if (!rc) {
cci_dev->cci_clk_params[count].hw_tsu_sta = val;
rc = of_property_read_u32(src_node, "hw-thd-dat",
&val);
- CDBG("%s:%d hw-thd-dat %d, rc %d\n",
- __func__, __LINE__, val, rc);
+ CAM_DBG(CAM_CCI, "hw-thd-dat %d, rc %d",
+ val, rc);
}
if (!rc) {
cci_dev->cci_clk_params[count].hw_thd_dat = val;
rc = of_property_read_u32(src_node, "hw-thd-sta",
&val);
- CDBG("%s:%d hw-thd-sta %d, rc %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_CCI, "hw-thd-sta %d, rc %d",
val, rc);
}
if (!rc) {
cci_dev->cci_clk_params[count].hw_thd_sta = val;
rc = of_property_read_u32(src_node, "hw-tbuf",
&val);
- CDBG("%s:%d hw-tbuf %d, rc %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_CCI, "hw-tbuf %d, rc %d",
val, rc);
}
if (!rc) {
cci_dev->cci_clk_params[count].hw_tbuf = val;
rc = of_property_read_u32(src_node,
"hw-scl-stretch-en", &val);
- CDBG("%s:%d hw-scl-stretch-en %d, rc %d\n",
- __func__, __LINE__, val, rc);
+ CAM_DBG(CAM_CCI, "hw-scl-stretch-en %d, rc %d",
+ val, rc);
}
if (!rc) {
cci_dev->cci_clk_params[count].hw_scl_stretch_en = val;
rc = of_property_read_u32(src_node, "hw-trdhld",
&val);
- CDBG("%s:%d hw-trdhld %d, rc %d\n",
- __func__, __LINE__, val, rc);
+ CAM_DBG(CAM_CCI, "hw-trdhld %d, rc %d",
+ val, rc);
}
if (!rc) {
cci_dev->cci_clk_params[count].hw_trdhld = val;
rc = of_property_read_u32(src_node, "hw-tsp",
&val);
- CDBG("%s:%d hw-tsp %d, rc %d\n", __func__, __LINE__,
- val, rc);
+ CAM_DBG(CAM_CCI, "hw-tsp %d, rc %d", val, rc);
}
if (!rc) {
cci_dev->cci_clk_params[count].hw_tsp = val;
val = 0;
rc = of_property_read_u32(src_node, "cci-clk-src",
&val);
- CDBG("%s:%d cci-clk-src %d, rc %d\n",
- __func__, __LINE__, val, rc);
+ CAM_DBG(CAM_CCI, "cci-clk-src %d, rc %d", val, rc);
cci_dev->cci_clk_params[count].cci_clk_src = val;
} else
cam_cci_init_default_clk_params(cci_dev, count);
@@ -339,8 +329,7 @@ int cam_cci_parse_dt_info(struct platform_device *pdev,
rc = cam_soc_util_get_dt_properties(soc_info);
if (rc < 0) {
- pr_err("%s:%d :Error: Parsing DT data failed:%d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "Parsing DT data failed:%d", rc);
return -EINVAL;
}
@@ -349,8 +338,7 @@ int cam_cci_parse_dt_info(struct platform_device *pdev,
rc = cam_soc_util_request_platform_resource(soc_info,
cam_cci_irq, new_cci_dev);
if (rc < 0) {
- pr_err("%s:%d :Error: requesting platform resources failed:%d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "requesting platform resources failed:%d", rc);
return -EINVAL;
}
new_cci_dev->v4l2_dev_str.pdev = pdev;
@@ -359,17 +347,15 @@ int cam_cci_parse_dt_info(struct platform_device *pdev,
rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
if (rc)
- pr_err("%s:%d failed to add child nodes, rc=%d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "failed to add child nodes, rc=%d", rc);
for (i = 0; i < MASTER_MAX; i++) {
new_cci_dev->write_wq[i] = create_singlethread_workqueue(
"cam_cci_wq");
if (!new_cci_dev->write_wq[i])
- pr_err("%s:%d Failed to create write wq\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CCI, "Failed to create write wq");
}
- CDBG("%s line %d\n", __func__, __LINE__);
+ CAM_DBG(CAM_CCI, "Exit");
return 0;
}
@@ -380,13 +366,12 @@ int cam_cci_soc_release(struct cci_device *cci_dev)
&cci_dev->soc_info;
if (!cci_dev->ref_count || cci_dev->cci_state != CCI_STATE_ENABLED) {
- pr_err("%s:%d invalid ref count %d / cci state %d\n", __func__,
- __LINE__, cci_dev->ref_count, cci_dev->cci_state);
+ CAM_ERR(CAM_CCI, "invalid ref count %d / cci state %d",
+ cci_dev->ref_count, cci_dev->cci_state);
return -EINVAL;
}
if (--cci_dev->ref_count) {
- CDBG("%s:%d ref_count Exit %d\n", __func__, __LINE__,
- cci_dev->ref_count);
+ CAM_DBG(CAM_CCI, "ref_count Exit %d", cci_dev->ref_count);
return 0;
}
for (i = 0; i < MASTER_MAX; i++)
@@ -398,8 +383,8 @@ int cam_cci_soc_release(struct cci_device *cci_dev)
rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
if (rc) {
- pr_err("%s:%d: platform resources disable failed, rc=%d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CCI, "platform resources disable failed, rc=%d",
+ rc);
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c
index 6b20bcc..2655202 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_core.c
@@ -63,7 +63,7 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev,
size_t len;
if (!cfg_dev || !csiphy_dev) {
- pr_err("%s:%d Invalid Args\n", __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "Invalid Args");
return -EINVAL;
}
@@ -75,16 +75,16 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev,
rc = cam_mem_get_cpu_buf((int32_t) cfg_dev->packet_handle,
(uint64_t *)&generic_ptr, &len);
if (rc < 0) {
- pr_err("%s:%d :ERROR: Failed to get packet Mem address: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CSIPHY, "Failed to get packet Mem address: %d", rc);
kfree(csiphy_dev->csiphy_info);
csiphy_dev->csiphy_info = NULL;
return rc;
}
if (cfg_dev->offset > len) {
- pr_err("%s: %d offset is out of bounds: offset: %lld len: %zu\n",
- __func__, __LINE__, cfg_dev->offset, len);
+ CAM_ERR(CAM_CSIPHY,
+ "offset is out of bounds: offset: %lld len: %zu",
+ cfg_dev->offset, len);
kfree(csiphy_dev->csiphy_info);
csiphy_dev->csiphy_info = NULL;
return -EINVAL;
@@ -99,8 +99,8 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev,
rc = cam_mem_get_cpu_buf(cmd_desc->mem_handle,
(uint64_t *)&generic_ptr, &len);
if (rc < 0) {
- pr_err("%s:%d :ERROR: Failed to get cmd buf Mem address : %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CSIPHY,
+ "Failed to get cmd buf Mem address : %d", rc);
kfree(csiphy_dev->csiphy_info);
csiphy_dev->csiphy_info = NULL;
return rc;
@@ -158,8 +158,7 @@ irqreturn_t cam_csiphy_irq(int irq_num, void *data)
void __iomem *base = NULL;
if (!csiphy_dev) {
- pr_err("%s:%d Invalid Args\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "Invalid Args");
return -EINVAL;
}
@@ -175,9 +174,9 @@ irqreturn_t cam_csiphy_irq(int irq_num, void *data)
base +
csiphy_dev->ctrl_reg->csiphy_reg.
mipi_csiphy_interrupt_clear0_addr + 0x4*i);
- pr_err_ratelimited(
- "%s CSIPHY%d_IRQ_STATUS_ADDR%d = 0x%x\n",
- __func__, soc_info->index, i, irq);
+ CAM_ERR_RATE_LIMIT(CAM_CSIPHY,
+ "CSIPHY%d_IRQ_STATUS_ADDR%d = 0x%x",
+ soc_info->index, i, irq);
cam_io_w_mb(0x0,
base +
csiphy_dev->ctrl_reg->csiphy_reg.
@@ -204,8 +203,7 @@ int32_t cam_csiphy_config_dev(struct csiphy_device *csiphy_dev)
struct csiphy_reg_t (*reg_array)[MAX_SETTINGS_PER_LANE];
if (csiphy_dev->csiphy_info == NULL) {
- pr_err("%s:%d csiphy_info is NULL, No/Fail CONFIG_DEV ?\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "csiphy_info is NULL, No/Fail CONFIG_DEV?");
return -EINVAL;
}
@@ -215,7 +213,7 @@ int32_t cam_csiphy_config_dev(struct csiphy_device *csiphy_dev)
csiphybase = csiphy_dev->soc_info.reg_map[0].mem_base;
if (!csiphybase) {
- pr_err("%s: csiphybase NULL\n", __func__);
+ CAM_ERR(CAM_CSIPHY, "csiphybase NULL");
return -EINVAL;
}
@@ -305,7 +303,7 @@ int32_t cam_csiphy_config_dev(struct csiphy_device *csiphy_dev)
reg_array[lane_pos][i].reg_addr);
break;
default:
- CDBG("%s: %d Do Nothing\n", __func__, __LINE__);
+ CAM_DBG(CAM_CSIPHY, "Do Nothing");
break;
}
usleep_range(reg_array[lane_pos][i].delay*1000,
@@ -329,13 +327,11 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
int32_t rc = 0;
if (!csiphy_dev || !cmd) {
- pr_err("%s:%d Invalid input args\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "Invalid input args");
return -EINVAL;
}
- pr_debug("%s:%d Opcode received: %d\n", __func__, __LINE__,
- cmd->op_code);
+ CAM_DBG(CAM_CSIPHY, "Opcode received: %d", cmd->op_code);
mutex_lock(&csiphy_dev->mutex);
switch (cmd->op_code) {
case CAM_ACQUIRE_DEV: {
@@ -348,16 +344,15 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
(void __user *)cmd->handle,
sizeof(csiphy_acq_dev));
if (rc < 0) {
- pr_err("%s:%d :ERROR: Failed copying from User\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "Failed copying from User");
goto release_mutex;
}
csiphy_acq_params.combo_mode = 0;
if (csiphy_dev->acquire_count == 2) {
- pr_err("%s:%d CSIPHY device do not allow more than 2 acquires\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY,
+ "CSIPHY device do not allow more than 2 acquires");
rc = -EINVAL;
goto release_mutex;
}
@@ -380,8 +375,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
if (copy_to_user((void __user *)cmd->handle,
&csiphy_acq_dev,
sizeof(struct cam_sensor_acquire_dev))) {
- pr_err("%s:%d :ERROR: Failed copying from User\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "Failed copying from User");
rc = -EINVAL;
goto release_mutex;
}
@@ -396,8 +390,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
cam_csiphy_query_cap(csiphy_dev, &csiphy_cap);
if (copy_to_user((void __user *)cmd->handle,
&csiphy_cap, sizeof(struct cam_csiphy_query_cap))) {
- pr_err("%s:%d :ERROR: Failed copying from User\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "Failed copying from User");
rc = -EINVAL;
goto release_mutex;
}
@@ -406,15 +399,13 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
case CAM_STOP_DEV: {
rc = cam_csiphy_disable_hw(csiphy_dev);
if (rc < 0) {
- pr_err("%s:%d Failed in csiphy release\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "Failed in csiphy release");
cam_cpas_stop(csiphy_dev->cpas_handle);
goto release_mutex;
}
rc = cam_cpas_stop(csiphy_dev->cpas_handle);
if (rc < 0) {
- pr_err("%s:%d :Error: de-voting CPAS: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CSIPHY, "de-voting CPAS: %d", rc);
goto release_mutex;
}
}
@@ -423,8 +414,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
struct cam_release_dev_cmd release;
if (!csiphy_dev->acquire_count) {
- pr_err("%s:%d No valid devices to release\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "No valid devices to release");
rc = -EINVAL;
goto release_mutex;
}
@@ -437,8 +427,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
rc = cam_destroy_device_hdl(release.dev_handle);
if (rc < 0)
- pr_err("%s:%d :ERROR: destroying the device hdl\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "destroying the device hdl");
if (release.dev_handle ==
csiphy_dev->bridge_intf.device_hdl[0]) {
csiphy_dev->bridge_intf.device_hdl[0] = -1;
@@ -462,8 +451,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
} else {
rc = cam_cmd_buf_parser(csiphy_dev, &config);
if (rc < 0) {
- pr_err("%s:%d Fail in cmd buf parser\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "Fail in cmd buf parser");
goto release_mutex;
}
}
@@ -481,22 +469,19 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
rc = cam_cpas_start(csiphy_dev->cpas_handle,
&ahb_vote, &axi_vote);
if (rc < 0) {
- pr_err("%s:%d :Error: voting CPAS: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CSIPHY, "voting CPAS: %d", rc);
goto release_mutex;
}
rc = cam_csiphy_enable_hw(csiphy_dev);
if (rc != 0) {
- pr_err("%s: %d cam_csiphy_enable_hw failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "cam_csiphy_enable_hw failed");
cam_cpas_stop(csiphy_dev->cpas_handle);
goto release_mutex;
}
rc = cam_csiphy_config_dev(csiphy_dev);
if (rc < 0) {
- pr_err("%s: %d cam_csiphy_config_dev failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "cam_csiphy_config_dev failed");
cam_cpas_stop(csiphy_dev->cpas_handle);
goto release_mutex;
}
@@ -505,8 +490,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
case CAM_SD_SHUTDOWN:
break;
default:
- pr_err("%s:%d :Error: Invalid Opcode: %d\n",
- __func__, __LINE__, cmd->op_code);
+ CAM_ERR(CAM_CSIPHY, "Invalid Opcode: %d", cmd->op_code);
rc = -EINVAL;
goto release_mutex;
}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c
index 7783b2e..1c93a1a 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c
@@ -16,13 +16,6 @@
#include "cam_csiphy_core.h"
#include <media/cam_sensor.h>
-#undef CDBG
-#ifdef CAM_CSIPHY_DEV_DEBUG
-#define CDBG(fmt, args...) pr_err(fmt, ##args)
-#else
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-#endif
-
static long cam_csiphy_subdev_ioctl(struct v4l2_subdev *sd,
unsigned int cmd, void *arg)
{
@@ -33,13 +26,12 @@ static long cam_csiphy_subdev_ioctl(struct v4l2_subdev *sd,
case VIDIOC_CAM_CONTROL:
rc = cam_csiphy_core_cfg(csiphy_dev, arg);
if (rc != 0) {
- pr_err("%s: %d :ERROR: in configuring the device\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "in configuring the device");
return rc;
}
break;
default:
- pr_err("%s:%d :ERROR: Wrong ioctl\n", __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "Wrong ioctl : %d", cmd);
break;
}
@@ -55,7 +47,7 @@ static long cam_csiphy_subdev_compat_ioctl(struct v4l2_subdev *sd,
if (copy_from_user(&cmd_data, (void __user *)arg,
sizeof(cmd_data))) {
- pr_err("Failed to copy from user_ptr=%pK size=%zu\n",
+ CAM_ERR(CAM_CSIPHY, "Failed to copy from user_ptr=%pK size=%zu",
(void __user *)arg, sizeof(cmd_data));
return -EFAULT;
}
@@ -68,15 +60,15 @@ static long cam_csiphy_subdev_compat_ioctl(struct v4l2_subdev *sd,
rc = cam_csiphy_subdev_ioctl(sd, cmd, &cmd_data);
break;
default:
- pr_err("%s:%d Invalid compat ioctl cmd: %d\n",
- __func__, __LINE__, cmd);
+ CAM_ERR(CAM_CSIPHY, "Invalid compat ioctl cmd: %d", cmd);
rc = -EINVAL;
}
if (!rc) {
if (copy_to_user((void __user *)arg, &cmd_data,
sizeof(cmd_data))) {
- pr_err("Failed to copy to user_ptr=%pK size=%zu\n",
+ CAM_ERR(CAM_CSIPHY,
+ "Failed to copy to user_ptr=%pK size=%zu",
(void __user *)arg, sizeof(cmd_data));
rc = -EFAULT;
}
@@ -126,8 +118,7 @@ static int32_t cam_csiphy_platform_probe(struct platform_device *pdev)
rc = cam_csiphy_parse_dt_info(pdev, new_csiphy_dev);
if (rc < 0) {
- pr_err("%s:%d :ERROR: dt parsing failed: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CSIPHY, "DT parsing failed: %d", rc);
goto csiphy_no_resource;
}
@@ -148,8 +139,7 @@ static int32_t cam_csiphy_platform_probe(struct platform_device *pdev)
rc = cam_register_subdev(&(new_csiphy_dev->v4l2_dev_str));
if (rc < 0) {
- pr_err("%s:%d :ERROR: In cam_register_subdev\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "cam_register_subdev Failed rc: %d", rc);
goto csiphy_no_resource;
}
@@ -176,11 +166,10 @@ static int32_t cam_csiphy_platform_probe(struct platform_device *pdev)
strlcpy(cpas_parms.identifier, "csiphy", CAM_HW_IDENTIFIER_LENGTH);
rc = cam_cpas_register_client(&cpas_parms);
if (rc) {
- pr_err("%s:%d CPAS registration failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "CPAS registration failed rc: %d", rc);
goto csiphy_no_resource;
}
- CDBG("CPAS registration successful handle=%d\n",
+ CAM_DBG(CAM_CSIPHY, "CPAS registration successful handle=%d",
cpas_parms.client_handle);
new_csiphy_dev->cpas_handle = cpas_parms.client_handle;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h
index c4258bd..8ed5ba4 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h
@@ -34,6 +34,7 @@
#include <cam_io_util.h>
#include <cam_cpas_api.h>
#include "cam_soc_util.h"
+#include "cam_debug_util.h"
#define MAX_CSIPHY 3
#define MAX_DPHY_DATA_LN 4
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_soc.c
index 6b5aba9..ea6b7c8 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_soc.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_csiphy/cam_csiphy_soc.c
@@ -22,16 +22,16 @@ int32_t cam_csiphy_enable_hw(struct csiphy_device *csiphy_dev)
soc_info = &csiphy_dev->soc_info;
if (csiphy_dev->ref_count++) {
- pr_err("%s:%d csiphy refcount = %d\n", __func__,
- __LINE__, csiphy_dev->ref_count);
+ CAM_ERR(CAM_CSIPHY, "csiphy refcount = %d",
+ csiphy_dev->ref_count);
return rc;
}
rc = cam_soc_util_enable_platform_resource(soc_info, true,
CAM_TURBO_VOTE, ENABLE_IRQ);
if (rc < 0) {
- pr_err("%s:%d failed to enable platform resources %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CSIPHY, "failed to enable platform resources %d",
+ rc);
return rc;
}
@@ -41,8 +41,7 @@ int32_t cam_csiphy_enable_hw(struct csiphy_device *csiphy_dev)
soc_info->clk_rate[0][csiphy_dev->csiphy_clk_index]);
if (rc < 0) {
- pr_err("%s:%d csiphy_clk_set_rate failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "csiphy_clk_set_rate failed rc: %d", rc);
goto csiphy_disable_platform_resource;
}
@@ -62,15 +61,14 @@ int32_t cam_csiphy_disable_hw(struct csiphy_device *csiphy_dev)
struct cam_hw_soc_info *soc_info;
if (!csiphy_dev || !csiphy_dev->ref_count) {
- pr_err("%s:%d csiphy dev NULL / ref_count ZERO\n", __func__,
- __LINE__);
+ CAM_ERR(CAM_CSIPHY, "csiphy dev NULL / ref_count ZERO");
return 0;
}
soc_info = &csiphy_dev->soc_info;
if (--csiphy_dev->ref_count) {
- pr_err("%s:%d csiphy refcount = %d\n", __func__,
- __LINE__, csiphy_dev->ref_count);
+ CAM_ERR(CAM_CSIPHY, "csiphy refcount = %d",
+ csiphy_dev->ref_count);
return 0;
}
@@ -95,8 +93,7 @@ int32_t cam_csiphy_parse_dt_info(struct platform_device *pdev,
rc = cam_soc_util_get_dt_properties(soc_info);
if (rc < 0) {
- pr_err("%s:%d :Error: parsing common soc dt(rc %d)\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_CSIPHY, "parsing common soc dt(rc %d)", rc);
return rc;
}
@@ -117,15 +114,15 @@ int32_t cam_csiphy_parse_dt_info(struct platform_device *pdev,
csiphy_dev->is_csiphy_3phase_hw = CSI_3PHASE_HW;
csiphy_dev->clk_lane = 0;
} else {
- pr_err("%s:%d, invalid hw version : 0x%x\n", __func__, __LINE__,
- csiphy_dev->hw_version);
+ CAM_ERR(CAM_CSIPHY, "invalid hw version : 0x%x",
+ csiphy_dev->hw_version);
rc = -EINVAL;
return rc;
}
if (soc_info->num_clk > CSIPHY_NUM_CLK_MAX) {
- pr_err("%s:%d invalid clk count=%d, max is %d\n", __func__,
- __LINE__, soc_info->num_clk, CSIPHY_NUM_CLK_MAX);
+ CAM_ERR(CAM_CSIPHY, "invalid clk count=%d, max is %d",
+ soc_info->num_clk, CSIPHY_NUM_CLK_MAX);
return -EINVAL;
}
for (i = 0; i < soc_info->num_clk; i++) {
@@ -155,7 +152,7 @@ int32_t cam_csiphy_parse_dt_info(struct platform_device *pdev,
soc_info->clk_rate[0][clk_cnt];
csiphy_dev->csiphy_clk_index = clk_cnt;
}
- CDBG("%s:%d clk_rate[%d] = %d\n", __func__, __LINE__, clk_cnt,
+ CAM_DBG(CAM_CSIPHY, "clk_rate[%d] = %d", clk_cnt,
soc_info->clk_rate[0][clk_cnt]);
clk_cnt++;
}
@@ -168,7 +165,7 @@ int32_t cam_csiphy_parse_dt_info(struct platform_device *pdev,
int32_t cam_csiphy_soc_release(struct csiphy_device *csiphy_dev)
{
if (!csiphy_dev) {
- pr_err("%s:%d csiphy dev NULL\n", __func__, __LINE__);
+ CAM_ERR(CAM_CSIPHY, "csiphy dev NULL");
return 0;
}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/Makefile b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/Makefile
new file mode 100644
index 0000000..5490992
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/Makefile
@@ -0,0 +1,8 @@
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_cpas/include
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_cci
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_smmu/
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_eeprom_dev.o cam_eeprom_core.o cam_eeprom_soc.o
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c
new file mode 100644
index 0000000..96697f9
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.c
@@ -0,0 +1,784 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/crc32.h>
+#include <media/cam_sensor.h>
+
+#include "cam_eeprom_core.h"
+#include "cam_eeprom_soc.h"
+#include "cam_debug_util.h"
+
+/**
+ * cam_eeprom_read_memory() - read map data into buffer
+ * @e_ctrl: eeprom control struct
+ * @block: block to be read
+ *
+ * This function iterates through blocks stored in block->map, reads each
+ * region and concatenate them into the pre-allocated block->mapdata
+ */
+static int cam_eeprom_read_memory(struct cam_eeprom_ctrl_t *e_ctrl,
+ struct cam_eeprom_memory_block_t *block)
+{
+ int rc = 0;
+ int j;
+ struct cam_sensor_i2c_reg_setting i2c_reg_settings;
+ struct cam_sensor_i2c_reg_array i2c_reg_array;
+ struct cam_eeprom_memory_map_t *emap = block->map;
+ struct cam_eeprom_soc_private *eb_info;
+ uint8_t *memptr = block->mapdata;
+
+ if (!e_ctrl) {
+ CAM_ERR(CAM_EEPROM, "e_ctrl is NULL");
+ return -EINVAL;
+ }
+
+ eb_info = (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+
+ for (j = 0; j < block->num_map; j++) {
+ CAM_DBG(CAM_EEPROM, "slave-addr = 0x%X", emap[j].saddr);
+ if (emap[j].saddr) {
+ eb_info->i2c_info.slave_addr = emap[j].saddr;
+ rc = cam_eeprom_update_i2c_info(e_ctrl,
+ &eb_info->i2c_info);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM,
+ "failed: to update i2c info rc %d",
+ rc);
+ return rc;
+ }
+ }
+
+ if (emap[j].page.valid_size) {
+ i2c_reg_settings.addr_type = emap[j].page.addr_type;
+ i2c_reg_settings.data_type = emap[j].page.data_type;
+ i2c_reg_settings.size = 1;
+ i2c_reg_array.reg_addr = emap[j].page.addr;
+ i2c_reg_array.reg_data = emap[j].page.data;
+ i2c_reg_array.delay = emap[j].page.delay;
+ i2c_reg_settings.reg_setting = &i2c_reg_array;
+ rc = camera_io_dev_write(&e_ctrl->io_master_info,
+ &i2c_reg_settings);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "page write failed rc %d",
+ rc);
+ return rc;
+ }
+ }
+
+ if (emap[j].pageen.valid_size) {
+ i2c_reg_settings.addr_type = emap[j].pageen.addr_type;
+ i2c_reg_settings.data_type = emap[j].pageen.data_type;
+ i2c_reg_settings.size = 1;
+ i2c_reg_array.reg_addr = emap[j].pageen.addr;
+ i2c_reg_array.reg_data = emap[j].pageen.data;
+ i2c_reg_array.delay = emap[j].pageen.delay;
+ i2c_reg_settings.reg_setting = &i2c_reg_array;
+ rc = camera_io_dev_write(&e_ctrl->io_master_info,
+ &i2c_reg_settings);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "page enable failed rc %d",
+ rc);
+ return rc;
+ }
+ }
+
+ if (emap[j].poll.valid_size) {
+ rc = camera_io_dev_poll(&e_ctrl->io_master_info,
+ emap[j].poll.addr, emap[j].poll.data,
+ 0, emap[j].poll.addr_type,
+ emap[j].poll.data_type,
+ emap[j].poll.delay);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "poll failed rc %d",
+ rc);
+ return rc;
+ }
+ }
+
+ if (emap[j].mem.valid_size) {
+ rc = camera_io_dev_read_seq(&e_ctrl->io_master_info,
+ emap[j].mem.addr, memptr,
+ emap[j].mem.addr_type,
+ emap[j].mem.valid_size);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "read failed rc %d",
+ rc);
+ return rc;
+ }
+ memptr += emap[j].mem.valid_size;
+ }
+
+ if (emap[j].pageen.valid_size) {
+ i2c_reg_settings.addr_type = emap[j].pageen.addr_type;
+ i2c_reg_settings.data_type = emap[j].pageen.data_type;
+ i2c_reg_settings.size = 1;
+ i2c_reg_array.reg_addr = emap[j].pageen.addr;
+ i2c_reg_array.reg_data = 0;
+ i2c_reg_array.delay = emap[j].pageen.delay;
+ i2c_reg_settings.reg_setting = &i2c_reg_array;
+ rc = camera_io_dev_write(&e_ctrl->io_master_info,
+ &i2c_reg_settings);
+
+ if (rc) {
+ CAM_ERR(CAM_EEPROM,
+ "page disable failed rc %d",
+ rc);
+ return rc;
+ }
+ }
+ }
+ return rc;
+}
+
+/**
+ * cam_eeprom_power_up - Power up eeprom hardware
+ * @e_ctrl: ctrl structure
+ * @power_info: power up/down info for eeprom
+ *
+ * Returns success or failure
+ */
+static int cam_eeprom_power_up(struct cam_eeprom_ctrl_t *e_ctrl,
+ struct cam_sensor_power_ctrl_t *power_info)
+{
+ int32_t rc = 0;
+ struct cam_hw_soc_info *soc_info =
+ &e_ctrl->soc_info;
+
+ /* Parse and fill vreg params for power up settings */
+ rc = msm_camera_fill_vreg_params(
+ &e_ctrl->soc_info,
+ power_info->power_setting,
+ power_info->power_setting_size);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM,
+ "failed to fill vreg params for power up rc:%d", rc);
+ return rc;
+ }
+
+ /* Parse and fill vreg params for power down settings*/
+ rc = msm_camera_fill_vreg_params(
+ &e_ctrl->soc_info,
+ power_info->power_down_setting,
+ power_info->power_down_setting_size);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM,
+ "failed to fill vreg params power down rc:%d", rc);
+ return rc;
+ }
+
+ rc = cam_sensor_core_power_up(power_info, soc_info);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "failed in eeprom power up rc %d", rc);
+ return rc;
+ }
+
+ if (e_ctrl->io_master_info.master_type == CCI_MASTER) {
+ rc = camera_io_init(&(e_ctrl->io_master_info));
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "cci_init failed");
+ return -EINVAL;
+ }
+ }
+ return rc;
+}
+
+/**
+ * cam_eeprom_power_down - Power down eeprom hardware
+ * @e_ctrl: ctrl structure
+ *
+ * Returns success or failure
+ */
+static int cam_eeprom_power_down(struct cam_eeprom_ctrl_t *e_ctrl)
+{
+ struct cam_sensor_power_ctrl_t *power_info;
+ struct cam_hw_soc_info *soc_info;
+ struct cam_eeprom_soc_private *soc_private;
+ int rc = 0;
+
+ if (!e_ctrl) {
+ CAM_ERR(CAM_EEPROM, "failed: e_ctrl %pK", e_ctrl);
+ return -EINVAL;
+ }
+
+ soc_private =
+ (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+ power_info = &soc_private->power_info;
+ soc_info = &e_ctrl->soc_info;
+
+ if (!power_info) {
+ CAM_ERR(CAM_EEPROM, "failed: power_info %pK", power_info);
+ return -EINVAL;
+ }
+ rc = msm_camera_power_down(power_info, soc_info);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "power down the core is failed:%d", rc);
+ return rc;
+ }
+
+ if (e_ctrl->io_master_info.master_type == CCI_MASTER)
+ camera_io_release(&(e_ctrl->io_master_info));
+
+ return rc;
+}
+
+/**
+ * cam_eeprom_match_id - match eeprom id
+ * @e_ctrl: ctrl structure
+ *
+ * Returns success or failure
+ */
+static int cam_eeprom_match_id(struct cam_eeprom_ctrl_t *e_ctrl)
+{
+ int rc;
+ struct camera_io_master *client = &e_ctrl->io_master_info;
+ uint8_t id[2];
+
+ rc = cam_spi_query_id(client, 0, &id[0], 2);
+ if (rc)
+ return rc;
+ CAM_DBG(CAM_EEPROM, "read 0x%x 0x%x, check 0x%x 0x%x",
+ id[0], id[1], client->spi_client->mfr_id0,
+ client->spi_client->device_id0);
+ if (id[0] != client->spi_client->mfr_id0
+ || id[1] != client->spi_client->device_id0)
+ return -ENODEV;
+ return 0;
+}
+
+/**
+ * cam_eeprom_parse_read_memory_map - Parse memory map
+ * @of_node: device node
+ * @e_ctrl: ctrl structure
+ *
+ * Returns success or failure
+ */
+int32_t cam_eeprom_parse_read_memory_map(struct device_node *of_node,
+ struct cam_eeprom_ctrl_t *e_ctrl)
+{
+ int32_t rc = 0;
+ struct cam_eeprom_soc_private *soc_private;
+ struct cam_sensor_power_ctrl_t *power_info;
+
+ if (!e_ctrl) {
+ CAM_ERR(CAM_EEPROM, "failed: e_ctrl is NULL");
+ return -EINVAL;
+ }
+
+ soc_private =
+ (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+ power_info = &soc_private->power_info;
+
+ rc = cam_eeprom_parse_dt_memory_map(of_node, &e_ctrl->cal_data);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "failed: eeprom dt parse rc %d", rc);
+ return rc;
+ }
+ rc = cam_eeprom_power_up(e_ctrl, power_info);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "failed: eeprom power up rc %d", rc);
+ goto data_mem_free;
+ }
+ if (e_ctrl->eeprom_device_type == MSM_CAMERA_SPI_DEVICE) {
+ rc = cam_eeprom_match_id(e_ctrl);
+ if (rc) {
+ CAM_DBG(CAM_EEPROM, "eeprom not matching %d", rc);
+ goto power_down;
+ }
+ }
+ rc = cam_eeprom_read_memory(e_ctrl, &e_ctrl->cal_data);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "read_eeprom_memory failed");
+ goto power_down;
+ }
+
+ rc = cam_eeprom_power_down(e_ctrl);
+ if (rc)
+ CAM_ERR(CAM_EEPROM, "failed: eeprom power down rc %d", rc);
+ return rc;
+power_down:
+ rc = cam_eeprom_power_down(e_ctrl);
+data_mem_free:
+ kfree(e_ctrl->cal_data.mapdata);
+ kfree(e_ctrl->cal_data.map);
+ return rc;
+}
+
+/**
+ * cam_eeprom_get_dev_handle - get device handle
+ * @e_ctrl: ctrl structure
+ * @arg: Camera control command argument
+ *
+ * Returns success or failure
+ */
+static int32_t cam_eeprom_get_dev_handle(struct cam_eeprom_ctrl_t *e_ctrl,
+ void *arg)
+{
+ struct cam_sensor_acquire_dev eeprom_acq_dev;
+ struct cam_create_dev_hdl bridge_params;
+ struct cam_control *cmd = (struct cam_control *)arg;
+
+ if (e_ctrl->bridge_intf.device_hdl != -1) {
+ CAM_ERR(CAM_EEPROM, "Device is already acquired");
+ return -EFAULT;
+ }
+ if (copy_from_user(&eeprom_acq_dev, (void __user *) cmd->handle,
+ sizeof(eeprom_acq_dev))) {
+ CAM_ERR(CAM_EEPROM,
+ "EEPROM:ACQUIRE_DEV: copy from user failed");
+ return -EFAULT;
+ }
+
+ bridge_params.session_hdl = eeprom_acq_dev.session_handle;
+ bridge_params.ops = &e_ctrl->bridge_intf.ops;
+ bridge_params.v4l2_sub_dev_flag = 0;
+ bridge_params.media_entity_flag = 0;
+ bridge_params.priv = e_ctrl;
+
+ eeprom_acq_dev.device_handle =
+ cam_create_device_hdl(&bridge_params);
+ e_ctrl->bridge_intf.device_hdl = eeprom_acq_dev.device_handle;
+ e_ctrl->bridge_intf.session_hdl = eeprom_acq_dev.session_handle;
+
+ CAM_DBG(CAM_EEPROM, "Device Handle: %d", eeprom_acq_dev.device_handle);
+ if (copy_to_user((void __user *) cmd->handle, &eeprom_acq_dev,
+ sizeof(struct cam_sensor_acquire_dev))) {
+ CAM_ERR(CAM_EEPROM, "EEPROM:ACQUIRE_DEV: copy to user failed");
+ return -EFAULT;
+ }
+ return 0;
+}
+
+/**
+ * cam_eeprom_update_slaveInfo - Update slave info
+ * @e_ctrl: ctrl structure
+ * @cmd_buf: command buffer
+ *
+ * Returns success or failure
+ */
+static int32_t cam_eeprom_update_slaveInfo(struct cam_eeprom_ctrl_t *e_ctrl,
+ void *cmd_buf)
+{
+ int32_t rc = 0;
+ struct cam_eeprom_soc_private *soc_private;
+ struct cam_cmd_i2c_info *cmd_i2c_info = NULL;
+
+ soc_private =
+ (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+ cmd_i2c_info = (struct cam_cmd_i2c_info *)cmd_buf;
+ soc_private->i2c_info.slave_addr = cmd_i2c_info->slave_addr;
+ soc_private->i2c_info.i2c_freq_mode = cmd_i2c_info->i2c_freq_mode;
+
+ rc = cam_eeprom_update_i2c_info(e_ctrl,
+ &soc_private->i2c_info);
+ CAM_DBG(CAM_EEPROM, "Slave addr: 0x%x Freq Mode: %d",
+ soc_private->i2c_info.slave_addr,
+ soc_private->i2c_info.i2c_freq_mode);
+
+ return rc;
+}
+
+/**
+ * cam_eeprom_parse_memory_map - Parse memory map info
+ * @data: memory block data
+ * @cmd_buf: command buffer
+ * @cmd_length: command buffer length
+ * @num_map: memory map size
+ * @cmd_length_bytes: command length processed in this function
+ *
+ * Returns success or failure
+ */
+static int32_t cam_eeprom_parse_memory_map(
+ struct cam_eeprom_memory_block_t *data,
+ void *cmd_buf, int cmd_length, uint16_t *cmd_length_bytes,
+ int16_t num_map)
+{
+ int32_t rc = 0;
+ int32_t processed_size = 0;
+ struct cam_eeprom_memory_map_t *map = data->map;
+ struct common_header *cmm_hdr =
+ (struct common_header *)cmd_buf;
+ uint16_t cmd_length_in_bytes = 0;
+ struct cam_cmd_i2c_random_wr *i2c_random_wr = NULL;
+ struct cam_cmd_i2c_continuous_rd *i2c_cont_rd = NULL;
+ struct cam_cmd_conditional_wait *i2c_poll = NULL;
+
+ switch (cmm_hdr->cmd_type) {
+ case CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_WR:
+ i2c_random_wr = (struct cam_cmd_i2c_random_wr *)cmd_buf;
+ cmd_length_in_bytes = sizeof(struct cam_cmd_i2c_random_wr);
+
+ map[num_map].page.addr =
+ i2c_random_wr->random_wr_payload[0].reg_addr;
+ map[num_map].page.addr_type = i2c_random_wr->header.addr_type;
+ map[num_map].page.data =
+ i2c_random_wr->random_wr_payload[0].reg_data;
+ map[num_map].page.data_type = i2c_random_wr->header.data_type;
+ map[num_map].page.valid_size = 1;
+ cmd_buf += cmd_length_in_bytes / sizeof(int32_t);
+ processed_size +=
+ cmd_length_in_bytes;
+ break;
+ case CAMERA_SENSOR_CMD_TYPE_I2C_CONT_RD:
+ i2c_cont_rd = (struct cam_cmd_i2c_continuous_rd *)cmd_buf;
+ cmd_length_in_bytes = sizeof(struct cam_cmd_i2c_continuous_rd);
+
+ map[num_map].mem.addr = i2c_cont_rd->reg_addr;
+ map[num_map].mem.addr_type = i2c_cont_rd->header.addr_type;
+ map[num_map].mem.data_type = i2c_cont_rd->header.data_type;
+ map[num_map].mem.valid_size =
+ i2c_cont_rd->header.count;
+ cmd_buf += cmd_length_in_bytes / sizeof(int32_t);
+ processed_size +=
+ cmd_length_in_bytes;
+ data->num_data += map[num_map].mem.valid_size;
+ break;
+ case CAMERA_SENSOR_CMD_TYPE_WAIT:
+ i2c_poll = (struct cam_cmd_conditional_wait *)cmd_buf;
+ cmd_length_in_bytes = sizeof(struct cam_cmd_conditional_wait);
+
+ map[num_map].poll.addr = i2c_poll->reg_addr;
+ map[num_map].poll.addr_type = i2c_poll->addr_type;
+ map[num_map].poll.data = i2c_poll->reg_data;
+ map[num_map].poll.data_type = i2c_poll->data_type;
+ map[num_map].poll.delay = i2c_poll->timeout;
+ map[num_map].poll.valid_size = 1;
+ break;
+ default:
+ break;
+ }
+ *cmd_length_bytes = processed_size;
+ return rc;
+}
+
+/**
+ * cam_eeprom_init_pkt_parser - Parse eeprom packet
+ * @e_ctrl: ctrl structure
+ * @csl_packet: csl packet received
+ *
+ * Returns success or failure
+ */
+static int32_t cam_eeprom_init_pkt_parser(struct cam_eeprom_ctrl_t *e_ctrl,
+ struct cam_packet *csl_packet)
+{
+ int32_t rc = 0;
+ int i = 0;
+ struct cam_cmd_buf_desc *cmd_desc = NULL;
+ uint32_t *offset = NULL;
+ uint32_t *cmd_buf = NULL;
+ uint64_t generic_pkt_addr;
+ size_t pkt_len = 0;
+ uint32_t total_cmd_buf_in_bytes = 0;
+ uint32_t processed_cmd_buf_in_bytes = 0;
+ struct common_header *cmm_hdr = NULL;
+ uint16_t cmd_length_in_bytes = 0;
+ struct cam_cmd_i2c_info *i2c_info = NULL;
+ int num_map = -1;
+ struct cam_eeprom_memory_map_t *map;
+ struct cam_eeprom_soc_private *soc_private =
+ (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+ struct cam_sensor_power_ctrl_t *power_info = &soc_private->power_info;
+
+ e_ctrl->cal_data.map = kcalloc((MSM_EEPROM_MEMORY_MAP_MAX_SIZE *
+ MSM_EEPROM_MAX_MEM_MAP_CNT),
+ (sizeof(struct cam_eeprom_memory_map_t)), GFP_KERNEL);
+ if (!e_ctrl->cal_data.map) {
+ rc = -ENOMEM;
+ CAM_ERR(CAM_EEPROM, "failed");
+ return rc;
+ }
+ map = e_ctrl->cal_data.map;
+
+ offset = (uint32_t *)&csl_packet->payload;
+ offset += (csl_packet->cmd_buf_offset / sizeof(uint32_t));
+ cmd_desc = (struct cam_cmd_buf_desc *)(offset);
+
+ /* Loop through multiple command buffers */
+ for (i = 0; i < csl_packet->num_cmd_buf; i++) {
+ total_cmd_buf_in_bytes = cmd_desc[i].length;
+ processed_cmd_buf_in_bytes = 0;
+ if (!total_cmd_buf_in_bytes)
+ continue;
+ rc = cam_mem_get_cpu_buf(cmd_desc[i].mem_handle,
+ (uint64_t *)&generic_pkt_addr, &pkt_len);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "Failed to get cpu buf");
+ return rc;
+ }
+ cmd_buf = (uint32_t *)generic_pkt_addr;
+ if (!cmd_buf) {
+ CAM_ERR(CAM_EEPROM, "invalid cmd buf");
+ return -EINVAL;
+ }
+ cmd_buf += cmd_desc[i].offset / sizeof(uint32_t);
+ /* Loop through multiple cmd formats in one cmd buffer */
+ while (processed_cmd_buf_in_bytes < total_cmd_buf_in_bytes) {
+ cmm_hdr = (struct common_header *)cmd_buf;
+ switch (cmm_hdr->cmd_type) {
+ case CAMERA_SENSOR_CMD_TYPE_I2C_INFO:
+ i2c_info = (struct cam_cmd_i2c_info *)cmd_buf;
+ num_map++;
+ map[num_map].saddr = i2c_info->slave_addr;
+ rc = cam_eeprom_update_slaveInfo(e_ctrl,
+ cmd_buf);
+ cmd_length_in_bytes =
+ sizeof(struct cam_cmd_i2c_info);
+ processed_cmd_buf_in_bytes +=
+ cmd_length_in_bytes;
+ cmd_buf += cmd_length_in_bytes/4;
+ e_ctrl->cal_data.num_map = num_map + 1;
+ break;
+ case CAMERA_SENSOR_CMD_TYPE_PWR_UP:
+ case CAMERA_SENSOR_CMD_TYPE_PWR_DOWN:
+ cmd_length_in_bytes =
+ sizeof(struct cam_cmd_power);
+ rc = cam_sensor_update_power_settings(cmd_buf,
+ cmd_length_in_bytes, power_info);
+ processed_cmd_buf_in_bytes +=
+ total_cmd_buf_in_bytes;
+ cmd_buf += total_cmd_buf_in_bytes/4;
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "Failed");
+ return rc;
+ }
+ break;
+ case CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_WR:
+ case CAMERA_SENSOR_CMD_TYPE_I2C_CONT_RD:
+ case CAMERA_SENSOR_CMD_TYPE_WAIT:
+ rc = cam_eeprom_parse_memory_map(
+ &e_ctrl->cal_data, cmd_buf,
+ total_cmd_buf_in_bytes,
+ &cmd_length_in_bytes, num_map);
+ processed_cmd_buf_in_bytes +=
+ cmd_length_in_bytes;
+ cmd_buf += cmd_length_in_bytes/4;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ return rc;
+}
+
+/**
+ * cam_eeprom_get_cal_data - parse the userspace IO config and
+ * copy read data to share with userspace
+ * @e_ctrl: ctrl structure
+ * @csl_packet: csl packet received
+ *
+ * Returns success or failure
+ */
+static int32_t cam_eeprom_get_cal_data(struct cam_eeprom_ctrl_t *e_ctrl,
+ struct cam_packet *csl_packet)
+{
+ struct cam_buf_io_cfg *io_cfg;
+ uint32_t i = 0;
+ int rc = 0;
+ uint64_t buf_addr;
+ size_t buf_size;
+ uint8_t *read_buffer;
+
+ io_cfg = (struct cam_buf_io_cfg *) ((uint8_t *)
+ &csl_packet->payload +
+ csl_packet->io_configs_offset);
+
+ CAM_DBG(CAM_EEPROM, "number of IO configs: %d:",
+ csl_packet->num_io_configs);
+
+ for (i = 0; i < csl_packet->num_io_configs; i++) {
+ CAM_DBG(CAM_EEPROM, "Direction: %d:", io_cfg->direction);
+ if (io_cfg->direction == CAM_BUF_OUTPUT) {
+ rc = cam_mem_get_cpu_buf(io_cfg->mem_handle[0],
+ (uint64_t *)&buf_addr, &buf_size);
+ CAM_DBG(CAM_EEPROM, "buf_addr : %pK, buf_size : %zu\n",
+ (void *)buf_addr, buf_size);
+
+ read_buffer = (uint8_t *)buf_addr;
+ if (!read_buffer) {
+ CAM_ERR(CAM_EEPROM,
+ "invalid buffer to copy data");
+ return -EINVAL;
+ }
+ read_buffer += io_cfg->offsets[0];
+
+ if (buf_size < e_ctrl->cal_data.num_data) {
+ CAM_ERR(CAM_EEPROM,
+ "failed to copy, Invalid size");
+ return -EINVAL;
+ }
+
+ CAM_ERR(CAM_EEPROM, "copy the data, len:%d",
+ e_ctrl->cal_data.num_data);
+ memcpy(read_buffer, e_ctrl->cal_data.mapdata,
+ e_ctrl->cal_data.num_data);
+
+ } else {
+ CAM_ERR(CAM_EEPROM, "Invalid direction");
+ rc = -EINVAL;
+ }
+ }
+ return rc;
+}
+
+/**
+ * cam_eeprom_pkt_parse - Parse csl packet
+ * @e_ctrl: ctrl structure
+ * @arg: Camera control command argument
+ *
+ * Returns success or failure
+ */
+static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg)
+{
+ int32_t rc = 0;
+ struct cam_control *ioctl_ctrl = NULL;
+ struct cam_config_dev_cmd dev_config;
+ uint64_t generic_pkt_addr;
+ size_t pkt_len;
+ struct cam_packet *csl_packet = NULL;
+ struct cam_eeprom_soc_private *soc_private =
+ (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+
+ ioctl_ctrl = (struct cam_control *)arg;
+ if (copy_from_user(&dev_config, (void __user *) ioctl_ctrl->handle,
+ sizeof(dev_config)))
+ return -EFAULT;
+ rc = cam_mem_get_cpu_buf(dev_config.packet_handle,
+ (uint64_t *)&generic_pkt_addr, &pkt_len);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM,
+ "error in converting command Handle Error: %d", rc);
+ return rc;
+ }
+ csl_packet = (struct cam_packet *)
+ (generic_pkt_addr + dev_config.offset);
+ switch (csl_packet->header.op_code & 0xFFFFFF) {
+ case CAM_EEPROM_PACKET_OPCODE_INIT:
+ if (e_ctrl->userspace_probe == false) {
+ rc = cam_eeprom_get_cal_data(e_ctrl, csl_packet);
+ CAM_ERR(CAM_EEPROM,
+ "Eeprom already probed at kernel boot");
+ rc = -EINVAL;
+ break;
+ }
+ if (e_ctrl->cal_data.num_data == 0) {
+ rc = cam_eeprom_init_pkt_parser(e_ctrl, csl_packet);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM,
+ "Failed in parsing the pkt");
+ return rc;
+ }
+
+ e_ctrl->cal_data.mapdata =
+ kzalloc(e_ctrl->cal_data.num_data, GFP_KERNEL);
+ if (!e_ctrl->cal_data.mapdata) {
+ rc = -ENOMEM;
+ CAM_ERR(CAM_EEPROM, "failed");
+ goto error;
+ }
+
+ rc = cam_eeprom_power_up(e_ctrl,
+ &soc_private->power_info);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "failed rc %d", rc);
+ goto memdata_free;
+ }
+
+ rc = cam_eeprom_read_memory(e_ctrl, &e_ctrl->cal_data);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM,
+ "read_eeprom_memory failed");
+ goto power_down;
+ }
+
+ rc = cam_eeprom_get_cal_data(e_ctrl, csl_packet);
+ rc = cam_eeprom_power_down(e_ctrl);
+ } else {
+ CAM_DBG(CAM_EEPROM, "Already read eeprom");
+ }
+ break;
+ default:
+ break;
+ }
+ kfree(e_ctrl->cal_data.mapdata);
+ kfree(e_ctrl->cal_data.map);
+ return rc;
+power_down:
+ rc = cam_eeprom_power_down(e_ctrl);
+memdata_free:
+ kfree(e_ctrl->cal_data.mapdata);
+error:
+ kfree(e_ctrl->cal_data.map);
+ return rc;
+}
+
+/**
+ * cam_eeprom_driver_cmd - Handle eeprom cmds
+ * @e_ctrl: ctrl structure
+ * @arg: Camera control command argument
+ *
+ * Returns success or failure
+ */
+int32_t cam_eeprom_driver_cmd(struct cam_eeprom_ctrl_t *e_ctrl, void *arg)
+{
+ int rc = 0;
+ struct cam_eeprom_query_cap_t eeprom_cap;
+ struct cam_control *cmd = (struct cam_control *)arg;
+
+ if (!e_ctrl) {
+ CAM_ERR(CAM_EEPROM, "e_ctrl is NULL");
+ return -EINVAL;
+ }
+
+ mutex_lock(&(e_ctrl->eeprom_mutex));
+ switch (cmd->op_code) {
+ case CAM_QUERY_CAP:
+ eeprom_cap.slot_info = e_ctrl->subdev_id;
+ if (e_ctrl->userspace_probe == false)
+ eeprom_cap.eeprom_kernel_probe = true;
+ else
+ eeprom_cap.eeprom_kernel_probe = false;
+
+ if (copy_to_user((void __user *) cmd->handle,
+ &eeprom_cap,
+ sizeof(struct cam_eeprom_query_cap_t))) {
+ CAM_ERR(CAM_EEPROM, "Failed Copy to User");
+ return -EFAULT;
+ goto release_mutex;
+ }
+ CAM_DBG(CAM_EEPROM, "eeprom_cap: ID: %d", eeprom_cap.slot_info);
+ break;
+ case CAM_ACQUIRE_DEV:
+ rc = cam_eeprom_get_dev_handle(e_ctrl, arg);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "Failed to acquire dev");
+ goto release_mutex;
+ }
+ break;
+ case CAM_CONFIG_DEV:
+ rc = cam_eeprom_pkt_parse(e_ctrl, arg);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "Failed in eeprom pkt Parsing");
+ goto release_mutex;
+ }
+ break;
+ default:
+ CAM_DBG(CAM_EEPROM, "invalid opcode");
+ break;
+ }
+
+release_mutex:
+ mutex_unlock(&(e_ctrl->eeprom_mutex));
+
+ return rc;
+}
+
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.h
new file mode 100644
index 0000000..84736df
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_core.h
@@ -0,0 +1,21 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#ifndef _CAM_EEPROM_CORE_H_
+#define _CAM_EEPROM_CORE_H_
+
+#include "cam_eeprom_dev.h"
+
+int32_t cam_eeprom_driver_cmd(struct cam_eeprom_ctrl_t *e_ctrl, void *arg);
+int32_t cam_eeprom_parse_read_memory_map(struct device_node *of_node,
+ struct cam_eeprom_ctrl_t *e_ctrl);
+#endif
+/* _CAM_EEPROM_CORE_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c
new file mode 100644
index 0000000..82dcc9c
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c
@@ -0,0 +1,487 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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 "cam_eeprom_dev.h"
+#include "cam_req_mgr_dev.h"
+#include "cam_eeprom_soc.h"
+#include "cam_eeprom_core.h"
+#include "cam_debug_util.h"
+
+static long cam_eeprom_subdev_ioctl(struct v4l2_subdev *sd,
+ unsigned int cmd, void *arg)
+{
+ int rc = 0;
+ struct cam_eeprom_ctrl_t *e_ctrl = v4l2_get_subdevdata(sd);
+
+ switch (cmd) {
+ case VIDIOC_CAM_CONTROL:
+ rc = cam_eeprom_driver_cmd(e_ctrl, arg);
+ break;
+ default:
+ rc = -ENOIOCTLCMD;
+ break;
+ }
+
+ return rc;
+}
+
+int32_t cam_eeprom_update_i2c_info(struct cam_eeprom_ctrl_t *e_ctrl,
+ struct cam_eeprom_i2c_info_t *i2c_info)
+{
+ struct cam_sensor_cci_client *cci_client = NULL;
+
+ if (e_ctrl->io_master_info.master_type == CCI_MASTER) {
+ cci_client = e_ctrl->io_master_info.cci_client;
+ if (!cci_client) {
+ CAM_ERR(CAM_EEPROM, "failed: cci_client %pK",
+ cci_client);
+ return -EINVAL;
+ }
+ cci_client->cci_i2c_master = e_ctrl->cci_i2c_master;
+ cci_client->sid = (i2c_info->slave_addr) >> 1;
+ cci_client->retries = 3;
+ cci_client->id_map = 0;
+ cci_client->i2c_freq_mode = i2c_info->i2c_freq_mode;
+ }
+ return 0;
+}
+
+#ifdef CONFIG_COMPAT
+static long cam_eeprom_init_subdev_do_ioctl(struct v4l2_subdev *sd,
+ unsigned int cmd, unsigned long arg)
+{
+ struct cam_control cmd_data;
+ int32_t rc = 0;
+
+ if (copy_from_user(&cmd_data, (void __user *)arg,
+ sizeof(cmd_data))) {
+ CAM_ERR(CAM_EEPROM,
+ "Failed to copy from user_ptr=%pK size=%zu",
+ (void __user *)arg, sizeof(cmd_data));
+ return -EFAULT;
+ }
+
+ switch (cmd) {
+ case VIDIOC_CAM_CONTROL:
+ rc = cam_eeprom_subdev_ioctl(sd, cmd, &cmd_data);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM,
+ "Failed in eeprom suddev handling rc %d",
+ rc);
+ return rc;
+ }
+ break;
+ default:
+ CAM_ERR(CAM_EEPROM, "Invalid compat ioctl: %d", cmd);
+ rc = -EINVAL;
+ }
+
+ if (!rc) {
+ if (copy_to_user((void __user *)arg, &cmd_data,
+ sizeof(cmd_data))) {
+ CAM_ERR(CAM_EEPROM,
+ "Failed to copy from user_ptr=%pK size=%zu",
+ (void __user *)arg, sizeof(cmd_data));
+ rc = -EFAULT;
+ }
+ }
+ return rc;
+}
+#endif
+
+static const struct v4l2_subdev_internal_ops cam_eeprom_internal_ops;
+
+static struct v4l2_subdev_core_ops cam_eeprom_subdev_core_ops = {
+ .ioctl = cam_eeprom_subdev_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl32 = cam_eeprom_init_subdev_do_ioctl,
+#endif
+};
+
+static struct v4l2_subdev_ops cam_eeprom_subdev_ops = {
+ .core = &cam_eeprom_subdev_core_ops,
+};
+
+static int cam_eeprom_i2c_driver_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ int rc = 0;
+ struct cam_eeprom_ctrl_t *e_ctrl = NULL;
+ struct cam_eeprom_soc_private *soc_private = NULL;
+
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+ CAM_ERR(CAM_EEPROM, "i2c_check_functionality failed");
+ goto probe_failure;
+ }
+
+ e_ctrl = kzalloc(sizeof(*e_ctrl), GFP_KERNEL);
+ if (!e_ctrl) {
+ CAM_ERR(CAM_EEPROM, "kzalloc failed");
+ rc = -ENOMEM;
+ goto probe_failure;
+ }
+ e_ctrl->v4l2_dev_str.ops = &cam_eeprom_subdev_ops;
+ soc_private = (struct cam_eeprom_soc_private *)(id->driver_data);
+ if (!soc_private) {
+ CAM_ERR(CAM_EEPROM, "board info NULL");
+ rc = -EINVAL;
+ goto ectrl_free;
+ }
+ e_ctrl->cal_data.mapdata = NULL;
+ e_ctrl->cal_data.map = NULL;
+ e_ctrl->userspace_probe = false;
+
+ e_ctrl->eeprom_device_type = MSM_CAMERA_I2C_DEVICE;
+ e_ctrl->io_master_info.master_type = I2C_MASTER;
+ e_ctrl->io_master_info.client = client;
+
+ if (soc_private->i2c_info.slave_addr != 0)
+ e_ctrl->io_master_info.client->addr =
+ soc_private->i2c_info.slave_addr;
+
+ return rc;
+
+ectrl_free:
+ kfree(e_ctrl);
+probe_failure:
+ return rc;
+}
+
+static int cam_eeprom_i2c_driver_remove(struct i2c_client *client)
+{
+ struct v4l2_subdev *sd = i2c_get_clientdata(client);
+ struct cam_eeprom_ctrl_t *e_ctrl;
+ struct cam_eeprom_soc_private *soc_private;
+
+ if (!sd) {
+ CAM_ERR(CAM_EEPROM, "Subdevice is NULL");
+ return -EINVAL;
+ }
+
+ e_ctrl = (struct cam_eeprom_ctrl_t *)v4l2_get_subdevdata(sd);
+ if (!e_ctrl) {
+ CAM_ERR(CAM_EEPROM, "eeprom device is NULL");
+ return -EINVAL;
+ }
+
+ soc_private =
+ (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+ if (!soc_private) {
+ CAM_ERR(CAM_EEPROM, "soc_info.soc_private is NULL");
+ return -EINVAL;
+ }
+
+ kfree(e_ctrl->cal_data.mapdata);
+ kfree(e_ctrl->cal_data.map);
+ if (soc_private) {
+ kfree(soc_private->power_info.gpio_num_info);
+ kfree(soc_private);
+ }
+ kfree(e_ctrl);
+
+ return 0;
+}
+
+static int cam_eeprom_spi_setup(struct spi_device *spi)
+{
+ struct cam_eeprom_ctrl_t *e_ctrl = NULL;
+ struct cam_sensor_spi_client *spi_client;
+ struct cam_eeprom_soc_private *eb_info;
+ struct cam_sensor_power_ctrl_t *power_info = NULL;
+ int rc = 0;
+
+ e_ctrl = kzalloc(sizeof(*e_ctrl), GFP_KERNEL);
+ if (!e_ctrl)
+ return -ENOMEM;
+
+ e_ctrl->v4l2_dev_str.ops = &cam_eeprom_subdev_ops;
+ e_ctrl->userspace_probe = false;
+ e_ctrl->cal_data.mapdata = NULL;
+ e_ctrl->cal_data.map = NULL;
+
+ spi_client = kzalloc(sizeof(*spi_client), GFP_KERNEL);
+ if (!spi_client) {
+ kfree(e_ctrl);
+ return -ENOMEM;
+ }
+
+ eb_info = kzalloc(sizeof(*eb_info), GFP_KERNEL);
+ if (!eb_info)
+ goto spi_free;
+ e_ctrl->soc_info.soc_private = eb_info;
+
+ e_ctrl->eeprom_device_type = MSM_CAMERA_SPI_DEVICE;
+ e_ctrl->io_master_info.spi_client = spi_client;
+ e_ctrl->io_master_info.master_type = SPI_MASTER;
+ spi_client->spi_master = spi;
+
+ power_info = &eb_info->power_info;
+ power_info->dev = &spi->dev;
+
+ /* set spi instruction info */
+ spi_client->retry_delay = 1;
+ spi_client->retries = 0;
+
+ /* Initialize mutex */
+ mutex_init(&(e_ctrl->eeprom_mutex));
+
+ rc = cam_eeprom_spi_driver_soc_init(e_ctrl);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "failed: spi soc init rc %d", rc);
+ goto board_free;
+ }
+
+ if (e_ctrl->userspace_probe == false) {
+ rc = cam_eeprom_parse_read_memory_map(spi->dev.of_node,
+ e_ctrl);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "failed: read mem map rc %d", rc);
+ goto board_free;
+ }
+ }
+
+ return rc;
+
+board_free:
+ kfree(e_ctrl->soc_info.soc_private);
+spi_free:
+ kfree(spi_client);
+ kfree(e_ctrl);
+ return rc;
+}
+
+static int cam_eeprom_spi_driver_probe(struct spi_device *spi)
+{
+ spi->bits_per_word = 8;
+ spi->mode = SPI_MODE_0;
+ spi_setup(spi);
+
+ CAM_DBG(CAM_EEPROM, "irq[%d] cs[%x] CPHA[%x] CPOL[%x] CS_HIGH[%x]",
+ spi->irq, spi->chip_select, (spi->mode & SPI_CPHA) ? 1 : 0,
+ (spi->mode & SPI_CPOL) ? 1 : 0,
+ (spi->mode & SPI_CS_HIGH) ? 1 : 0);
+ CAM_DBG(CAM_EEPROM, "max_speed[%u]", spi->max_speed_hz);
+
+ return cam_eeprom_spi_setup(spi);
+}
+
+static int cam_eeprom_spi_driver_remove(struct spi_device *sdev)
+{
+ struct v4l2_subdev *sd = spi_get_drvdata(sdev);
+ struct cam_eeprom_ctrl_t *e_ctrl;
+ struct cam_eeprom_soc_private *soc_private;
+
+ if (!sd) {
+ CAM_ERR(CAM_EEPROM, "Subdevice is NULL");
+ return -EINVAL;
+ }
+
+ e_ctrl = (struct cam_eeprom_ctrl_t *)v4l2_get_subdevdata(sd);
+ if (!e_ctrl) {
+ CAM_ERR(CAM_EEPROM, "eeprom device is NULL");
+ return -EINVAL;
+ }
+
+ kfree(e_ctrl->io_master_info.spi_client);
+ kfree(e_ctrl->cal_data.mapdata);
+ kfree(e_ctrl->cal_data.map);
+ soc_private =
+ (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+ if (soc_private) {
+ kfree(soc_private->power_info.gpio_num_info);
+ kfree(soc_private);
+ }
+ kfree(e_ctrl);
+
+ return 0;
+}
+
+static int32_t cam_eeprom_platform_driver_probe(
+ struct platform_device *pdev)
+{
+ int32_t rc = 0;
+ struct cam_eeprom_ctrl_t *e_ctrl = NULL;
+ struct cam_eeprom_soc_private *soc_private = NULL;
+
+ e_ctrl = kzalloc(sizeof(struct cam_eeprom_ctrl_t), GFP_KERNEL);
+ if (!e_ctrl)
+ return -ENOMEM;
+
+ e_ctrl->soc_info.pdev = pdev;
+ e_ctrl->eeprom_device_type = MSM_CAMERA_PLATFORM_DEVICE;
+ e_ctrl->cal_data.mapdata = NULL;
+ e_ctrl->cal_data.map = NULL;
+ e_ctrl->userspace_probe = false;
+
+ e_ctrl->io_master_info.master_type = CCI_MASTER;
+ e_ctrl->io_master_info.cci_client = kzalloc(
+ sizeof(struct cam_sensor_cci_client), GFP_KERNEL);
+ if (!e_ctrl->io_master_info.cci_client)
+ goto free_e_ctrl;
+
+ soc_private = kzalloc(sizeof(struct cam_eeprom_soc_private),
+ GFP_KERNEL);
+ if (!soc_private) {
+ rc = -ENOMEM;
+ goto free_cci_client;
+ }
+ e_ctrl->soc_info.soc_private = soc_private;
+
+ /* Initialize mutex */
+ mutex_init(&(e_ctrl->eeprom_mutex));
+ rc = cam_eeprom_platform_driver_soc_init(e_ctrl);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "failed: soc init rc %d", rc);
+ goto free_soc;
+ }
+ rc = cam_eeprom_update_i2c_info(e_ctrl, &soc_private->i2c_info);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "failed: to update i2c info rc %d", rc);
+ goto free_soc;
+ }
+
+ if (e_ctrl->userspace_probe == false) {
+ rc = cam_eeprom_parse_read_memory_map(pdev->dev.of_node,
+ e_ctrl);
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "failed: read mem map rc %d", rc);
+ goto free_soc;
+ }
+ }
+
+ e_ctrl->v4l2_dev_str.internal_ops = &cam_eeprom_internal_ops;
+ e_ctrl->v4l2_dev_str.ops = &cam_eeprom_subdev_ops;
+ strlcpy(e_ctrl->device_name, CAM_EEPROM_NAME,
+ sizeof(e_ctrl->device_name));
+ e_ctrl->v4l2_dev_str.name = e_ctrl->device_name;
+ e_ctrl->v4l2_dev_str.sd_flags =
+ (V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS);
+ e_ctrl->v4l2_dev_str.ent_function = CAM_EEPROM_DEVICE_TYPE;
+ e_ctrl->v4l2_dev_str.token = e_ctrl;
+
+ rc = cam_register_subdev(&(e_ctrl->v4l2_dev_str));
+ if (rc) {
+ CAM_ERR(CAM_EEPROM, "fail to create subdev");
+ goto free_soc;
+ }
+
+ e_ctrl->bridge_intf.device_hdl = -1;
+ e_ctrl->bridge_intf.ops.get_dev_info = NULL;
+ e_ctrl->bridge_intf.ops.link_setup = NULL;
+ e_ctrl->bridge_intf.ops.apply_req = NULL;
+
+ platform_set_drvdata(pdev, e_ctrl);
+ v4l2_set_subdevdata(&e_ctrl->v4l2_dev_str.sd, e_ctrl);
+ return rc;
+free_soc:
+ kfree(soc_private);
+free_cci_client:
+ kfree(e_ctrl->io_master_info.cci_client);
+free_e_ctrl:
+ kfree(e_ctrl);
+ return rc;
+}
+
+static int cam_eeprom_platform_driver_remove(struct platform_device *pdev)
+{
+ struct cam_eeprom_ctrl_t *e_ctrl;
+
+ e_ctrl = platform_get_drvdata(pdev);
+ if (!e_ctrl) {
+ CAM_ERR(CAM_EEPROM, "eeprom device is NULL");
+ return -EINVAL;
+ }
+
+ kfree(e_ctrl->soc_info.soc_private);
+ kfree(e_ctrl->io_master_info.cci_client);
+ kfree(e_ctrl);
+ return 0;
+}
+
+static const struct of_device_id cam_eeprom_dt_match[] = {
+ { .compatible = "qcom,eeprom" },
+ { }
+};
+
+
+MODULE_DEVICE_TABLE(of, cam_eeprom_dt_match);
+
+static struct platform_driver cam_eeprom_platform_driver = {
+ .driver = {
+ .name = "qcom,eeprom",
+ .owner = THIS_MODULE,
+ .of_match_table = cam_eeprom_dt_match,
+ },
+ .probe = cam_eeprom_platform_driver_probe,
+ .remove = cam_eeprom_platform_driver_remove,
+};
+
+static const struct i2c_device_id cam_eeprom_i2c_id[] = {
+ { "msm_eeprom", (kernel_ulong_t)NULL},
+ { }
+};
+
+static struct i2c_driver cam_eeprom_i2c_driver = {
+ .id_table = cam_eeprom_i2c_id,
+ .probe = cam_eeprom_i2c_driver_probe,
+ .remove = cam_eeprom_i2c_driver_remove,
+ .driver = {
+ .name = "msm_eeprom",
+ },
+};
+
+static struct spi_driver cam_eeprom_spi_driver = {
+ .driver = {
+ .name = "qcom_eeprom",
+ .owner = THIS_MODULE,
+ .of_match_table = cam_eeprom_dt_match,
+ },
+ .probe = cam_eeprom_spi_driver_probe,
+ .remove = cam_eeprom_spi_driver_remove,
+};
+static int __init cam_eeprom_driver_init(void)
+{
+ int rc = 0;
+
+ rc = platform_driver_register(&cam_eeprom_platform_driver);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "platform_driver_register failed rc = %d",
+ rc);
+ return rc;
+ }
+
+ rc = spi_register_driver(&cam_eeprom_spi_driver);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "spi_register_driver failed rc = %d", rc);
+ return rc;
+ }
+
+ rc = i2c_add_driver(&cam_eeprom_i2c_driver);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "i2c_add_driver failed rc = %d", rc);
+ return rc;
+ }
+
+ return rc;
+}
+
+static void __exit cam_eeprom_driver_exit(void)
+{
+ platform_driver_unregister(&cam_eeprom_platform_driver);
+ spi_unregister_driver(&cam_eeprom_spi_driver);
+ i2c_del_driver(&cam_eeprom_i2c_driver);
+}
+
+module_init(cam_eeprom_driver_init);
+module_exit(cam_eeprom_driver_exit);
+MODULE_DESCRIPTION("CAM EEPROM driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h
new file mode 100644
index 0000000..a98bf00
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h
@@ -0,0 +1,183 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#ifndef _CAM_EEPROM_DEV_H_
+#define _CAM_EEPROM_DEV_H_
+
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+#include <media/v4l2-event.h>
+#include <media/v4l2-subdev.h>
+#include <media/v4l2-ioctl.h>
+#include <media/cam_sensor.h>
+#include <cam_sensor_i2c.h>
+#include <cam_sensor_spi.h>
+#include <cam_sensor_io.h>
+#include <cam_cci_dev.h>
+#include <cam_req_mgr_util.h>
+#include <cam_req_mgr_interface.h>
+#include <cam_mem_mgr.h>
+#include <cam_subdev.h>
+#include "cam_soc_util.h"
+
+#define DEFINE_MSM_MUTEX(mutexname) \
+ static struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
+
+#define PROPERTY_MAXSIZE 32
+
+#define MSM_EEPROM_MEMORY_MAP_MAX_SIZE 80
+#define MSM_EEPROM_MAX_MEM_MAP_CNT 8
+#define MSM_EEPROM_MEM_MAP_PROPERTIES_CNT 8
+
+/**
+ * struct cam_eeprom_map_t - eeprom map
+ * @data_type : Data type
+ * @addr_type : Address type
+ * @addr : Address
+ * @data : data
+ * @delay : Delay
+ *
+ */
+struct cam_eeprom_map_t {
+ uint32_t valid_size;
+ uint32_t addr;
+ uint32_t addr_type;
+ uint32_t data;
+ uint32_t data_type;
+ uint32_t delay;
+};
+
+/**
+ * struct cam_eeprom_memory_map_t - eeprom memory map types
+ * @page : page memory
+ * @pageen : pageen memory
+ * @poll : poll memory
+ * @mem : mem
+ * @saddr : slave addr
+ *
+ */
+struct cam_eeprom_memory_map_t {
+ struct cam_eeprom_map_t page;
+ struct cam_eeprom_map_t pageen;
+ struct cam_eeprom_map_t poll;
+ struct cam_eeprom_map_t mem;
+ uint32_t saddr;
+};
+
+/**
+ * struct cam_eeprom_memory_block_t - eeprom mem block info
+ * @map : eeprom memory map
+ * @num_map : number of map blocks
+ * @mapdata : map data
+ * @cmd_type : size of total mapdata
+ *
+ */
+struct cam_eeprom_memory_block_t {
+ struct cam_eeprom_memory_map_t *map;
+ uint32_t num_map;
+ uint8_t *mapdata;
+ uint32_t num_data;
+};
+
+/**
+ * struct cam_eeprom_cmm_t - camera multimodule
+ * @cmm_support : cmm support flag
+ * @cmm_compression : cmm compression flag
+ * @cmm_offset : cmm data start offset
+ * @cmm_size : cmm data size
+ *
+ */
+struct cam_eeprom_cmm_t {
+ uint32_t cmm_support;
+ uint32_t cmm_compression;
+ uint32_t cmm_offset;
+ uint32_t cmm_size;
+};
+
+/**
+ * struct cam_eeprom_i2c_info_t - I2C info
+ * @slave_addr : slave address
+ * @i2c_freq_mode : i2c frequency mode
+ *
+ */
+struct cam_eeprom_i2c_info_t {
+ uint16_t slave_addr;
+ uint8_t i2c_freq_mode;
+};
+
+/**
+ * struct cam_eeprom_soc_private - eeprom soc private data structure
+ * @eeprom_name : eeprom name
+ * @i2c_info : i2c info structure
+ * @power_info : eeprom power info
+ * @cmm_data : cmm data
+ *
+ */
+struct cam_eeprom_soc_private {
+ const char *eeprom_name;
+ struct cam_eeprom_i2c_info_t i2c_info;
+ struct cam_sensor_power_ctrl_t power_info;
+ struct cam_eeprom_cmm_t cmm_data;
+};
+
+/**
+ * struct cam_eeprom_intf_params - bridge interface params
+ * @device_hdl : Device Handle
+ * @session_hdl : Session Handle
+ * @ops : KMD operations
+ * @crm_cb : Callback API pointers
+ */
+struct cam_eeprom_intf_params {
+ int32_t device_hdl;
+ int32_t session_hdl;
+ int32_t link_hdl;
+ struct cam_req_mgr_kmd_ops ops;
+ struct cam_req_mgr_crm_cb *crm_cb;
+};
+
+/**
+ * struct cam_cmd_conditional_wait - Conditional wait command
+ * @pdev : platform device
+ * @spi : spi device
+ * @eeprom_mutex : eeprom mutex
+ * @soc_info : eeprom soc related info
+ * @io_master_info : Information about the communication master
+ * @gpio_num_info : gpio info
+ * @cci_i2c_master : I2C structure
+ * @v4l2_dev_str : V4L2 device structure
+ * @bridge_intf : bridge interface params
+ * @subdev_id : subdev id
+ * @userspace_probe : flag indicates userspace or kernel probe
+ * @cal_data : Calibration data
+ * @device_name : Device name
+ *
+ */
+struct cam_eeprom_ctrl_t {
+ struct platform_device *pdev;
+ struct spi_device *spi;
+ struct mutex eeprom_mutex;
+ struct cam_hw_soc_info soc_info;
+ struct camera_io_master io_master_info;
+ struct msm_camera_gpio_num_info *gpio_num_info;
+ enum cci_i2c_master_t cci_i2c_master;
+ struct cam_subdev v4l2_dev_str;
+ struct cam_eeprom_intf_params bridge_intf;
+ enum msm_camera_device_type_t eeprom_device_type;
+ uint32_t subdev_id;
+ bool userspace_probe;
+ struct cam_eeprom_memory_block_t cal_data;
+ char device_name[20];
+};
+
+int32_t cam_eeprom_update_i2c_info(struct cam_eeprom_ctrl_t *e_ctrl,
+ struct cam_eeprom_i2c_info_t *i2c_info);
+
+#endif /*_CAM_EEPROM_DEV_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.c
new file mode 100644
index 0000000..84e723f
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.c
@@ -0,0 +1,323 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <cam_sensor_cmn_header.h>
+#include <cam_sensor_util.h>
+#include <cam_sensor_io.h>
+#include <cam_req_mgr_util.h>
+
+#include "cam_eeprom_soc.h"
+#include "cam_debug_util.h"
+
+/*
+ * cam_eeprom_parse_memory_map() - parse memory map in device node
+ * @of: device node
+ * @data: memory block for output
+ *
+ * This functions parses @of to fill @data. It allocates map itself, parses
+ * the @of node, calculate total data length, and allocates required buffer.
+ * It only fills the map, but does not perform actual reading.
+ */
+int cam_eeprom_parse_dt_memory_map(struct device_node *node,
+ struct cam_eeprom_memory_block_t *data)
+{
+ int i, rc = 0;
+ char property[PROPERTY_MAXSIZE];
+ uint32_t count = MSM_EEPROM_MEM_MAP_PROPERTIES_CNT;
+ struct cam_eeprom_memory_map_t *map;
+
+ snprintf(property, PROPERTY_MAXSIZE, "num-blocks");
+ rc = of_property_read_u32(node, property, &data->num_map);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "failed: num-blocks not available rc %d",
+ rc);
+ return rc;
+ }
+
+ map = kzalloc((sizeof(*map) * data->num_map), GFP_KERNEL);
+ if (!map) {
+ rc = -ENOMEM;
+ return rc;
+ }
+ data->map = map;
+
+ for (i = 0; i < data->num_map; i++) {
+ snprintf(property, PROPERTY_MAXSIZE, "page%d", i);
+ rc = of_property_read_u32_array(node, property,
+ (uint32_t *) &map[i].page, count);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "failed: page not available rc %d",
+ rc);
+ goto ERROR;
+ }
+
+ snprintf(property, PROPERTY_MAXSIZE, "pageen%d", i);
+ rc = of_property_read_u32_array(node, property,
+ (uint32_t *) &map[i].pageen, count);
+ if (rc < 0)
+ CAM_DBG(CAM_EEPROM, "pageen not needed");
+
+ snprintf(property, PROPERTY_MAXSIZE, "saddr%d", i);
+ rc = of_property_read_u32_array(node, property,
+ (uint32_t *) &map[i].saddr, 1);
+ if (rc < 0)
+ CAM_DBG(CAM_EEPROM, "saddr not needed - block %d", i);
+
+ snprintf(property, PROPERTY_MAXSIZE, "poll%d", i);
+ rc = of_property_read_u32_array(node, property,
+ (uint32_t *) &map[i].poll, count);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "failed: poll not available rc %d",
+ rc);
+ goto ERROR;
+ }
+
+ snprintf(property, PROPERTY_MAXSIZE, "mem%d", i);
+ rc = of_property_read_u32_array(node, property,
+ (uint32_t *) &map[i].mem, count);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "failed: mem not available rc %d",
+ rc);
+ goto ERROR;
+ }
+ data->num_data += map[i].mem.valid_size;
+ }
+
+ data->mapdata = kzalloc(data->num_data, GFP_KERNEL);
+ if (!data->mapdata) {
+ rc = -ENOMEM;
+ goto ERROR;
+ }
+ return rc;
+
+ERROR:
+ kfree(data->map);
+ memset(data, 0, sizeof(*data));
+ return rc;
+}
+
+/**
+ * @e_ctrl: ctrl structure
+ *
+ * Parses eeprom dt
+ */
+static int cam_eeprom_get_dt_data(struct cam_eeprom_ctrl_t *e_ctrl)
+{
+ int rc = 0;
+ struct cam_hw_soc_info *soc_info = &e_ctrl->soc_info;
+ struct cam_eeprom_soc_private *soc_private =
+ (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+ struct cam_sensor_power_ctrl_t *power_info = &soc_private->power_info;
+ struct device_node *of_node = NULL;
+
+ if (e_ctrl->eeprom_device_type == MSM_CAMERA_SPI_DEVICE)
+ of_node = e_ctrl->io_master_info.
+ spi_client->spi_master->dev.of_node;
+ else if (e_ctrl->eeprom_device_type == MSM_CAMERA_PLATFORM_DEVICE)
+ of_node = soc_info->pdev->dev.of_node;
+
+ if (!of_node) {
+ CAM_ERR(CAM_EEPROM, "of_node is NULL, device type %d",
+ e_ctrl->eeprom_device_type);
+ return -EINVAL;
+ }
+ rc = cam_soc_util_get_dt_properties(soc_info);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "cam_soc_util_get_dt_properties rc %d",
+ rc);
+ return rc;
+ }
+
+ if (e_ctrl->userspace_probe == false) {
+ rc = cam_get_dt_power_setting_data(of_node,
+ soc_info, power_info);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "failed in getting power settings");
+ return rc;
+ }
+ }
+
+ if (!soc_info->gpio_data) {
+ CAM_INFO(CAM_EEPROM, "No GPIO found");
+ return 0;
+ }
+
+ if (!soc_info->gpio_data->cam_gpio_common_tbl_size) {
+ CAM_INFO(CAM_EEPROM, "No GPIO found");
+ return -EINVAL;
+ }
+
+ rc = cam_sensor_util_init_gpio_pin_tbl(soc_info,
+ &power_info->gpio_num_info);
+ if ((rc < 0) || (!power_info->gpio_num_info)) {
+ CAM_ERR(CAM_EEPROM, "No/Error EEPROM GPIOs");
+ return -EINVAL;
+ }
+
+ return rc;
+}
+
+/**
+ * @eb_info: eeprom private data structure
+ * @of_node: eeprom device node
+ *
+ * This function parses the eeprom dt to get the MM data
+ */
+static int cam_eeprom_cmm_dts(struct cam_eeprom_soc_private *eb_info,
+ struct device_node *of_node)
+{
+ int rc = 0;
+ struct cam_eeprom_cmm_t *cmm_data = &eb_info->cmm_data;
+
+ cmm_data->cmm_support =
+ of_property_read_bool(of_node, "cmm-data-support");
+ if (!cmm_data->cmm_support) {
+ CAM_DBG(CAM_EEPROM, "No cmm support");
+ return 0;
+ }
+
+ cmm_data->cmm_compression =
+ of_property_read_bool(of_node, "cmm-data-compressed");
+
+ rc = of_property_read_u32(of_node, "cmm-data-offset",
+ &cmm_data->cmm_offset);
+ if (rc < 0)
+ CAM_DBG(CAM_EEPROM, "No MM offset data rc %d", rc);
+
+ rc = of_property_read_u32(of_node, "cmm-data-size",
+ &cmm_data->cmm_size);
+ if (rc < 0)
+ CAM_DBG(CAM_EEPROM, "No MM size data rc %d", rc);
+
+ CAM_DBG(CAM_EEPROM, "cmm_compr %d, cmm_offset %d, cmm_size %d",
+ cmm_data->cmm_compression, cmm_data->cmm_offset,
+ cmm_data->cmm_size);
+ return 0;
+}
+
+/**
+ * @e_ctrl: ctrl structure
+ *
+ * This function is called from cam_eeprom_spi_driver_probe, it parses
+ * the eeprom dt node and decides for userspace or kernel probe.
+ */
+int cam_eeprom_spi_driver_soc_init(struct cam_eeprom_ctrl_t *e_ctrl)
+{
+ int rc = 0;
+ struct cam_eeprom_soc_private *soc_private =
+ (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+
+ rc = of_property_read_u32(e_ctrl->spi->dev.of_node, "cell-index",
+ &e_ctrl->subdev_id);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "failed rc %d", rc);
+ return rc;
+ }
+ rc = of_property_read_string(e_ctrl->spi->dev.of_node,
+ "eeprom-name", &soc_private->eeprom_name);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "failed rc %d", rc);
+ e_ctrl->userspace_probe = true;
+ }
+
+ CAM_DBG(CAM_EEPROM, "eeprom-name %s, rc %d", soc_private->eeprom_name,
+ rc);
+ rc = cam_eeprom_cmm_dts(soc_private,
+ e_ctrl->io_master_info.spi_client->spi_master->dev.of_node);
+ if (rc < 0)
+ CAM_DBG(CAM_EEPROM, "MM data not available rc %d", rc);
+ rc = cam_eeprom_get_dt_data(e_ctrl);
+ if (rc < 0)
+ CAM_DBG(CAM_EEPROM, "failed: eeprom get dt data rc %d", rc);
+
+ return rc;
+}
+
+/**
+ * @e_ctrl: ctrl structure
+ *
+ * This function is called from cam_eeprom_platform_driver_probe, it parses
+ * the eeprom dt node and decides for userspace or kernel probe.
+ */
+int cam_eeprom_platform_driver_soc_init(struct cam_eeprom_ctrl_t *e_ctrl)
+{
+ int rc = 0;
+ struct cam_hw_soc_info *soc_info = &e_ctrl->soc_info;
+ struct device_node *of_node = NULL;
+ struct platform_device *pdev = NULL;
+ struct cam_eeprom_soc_private *soc_private =
+ (struct cam_eeprom_soc_private *)e_ctrl->soc_info.soc_private;
+ uint32_t temp;
+
+ if (!soc_info->pdev) {
+ CAM_ERR(CAM_EEPROM, "Error:soc_info is not initialized");
+ return -EINVAL;
+ }
+
+ pdev = soc_info->pdev;
+ of_node = pdev->dev.of_node;
+ if (!of_node) {
+ CAM_ERR(CAM_EEPROM, "dev.of_node NULL");
+ return -EINVAL;
+ }
+
+ rc = of_property_read_u32(of_node, "cell-index",
+ &e_ctrl->subdev_id);
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "failed rc %d\n", rc);
+ return rc;
+ }
+
+ rc = of_property_read_u32(of_node, "cci-master",
+ &e_ctrl->cci_i2c_master);
+ if (rc < 0) {
+ CAM_DBG(CAM_EEPROM, "failed rc %d", rc);
+ return rc;
+ }
+
+ rc = of_property_read_string(of_node, "eeprom-name",
+ &soc_private->eeprom_name);
+ if (rc < 0) {
+ CAM_DBG(CAM_EEPROM, "kernel probe is not enabled");
+ e_ctrl->userspace_probe = true;
+ }
+
+ rc = cam_eeprom_get_dt_data(e_ctrl);
+ if (rc < 0)
+ CAM_DBG(CAM_EEPROM, "failed: eeprom get dt data rc %d", rc);
+
+ if (e_ctrl->userspace_probe == false) {
+ rc = of_property_read_u32(of_node, "slave-addr", &temp);
+ if (rc < 0)
+ CAM_DBG(CAM_EEPROM, "failed: no slave-addr rc %d", rc);
+
+ soc_private->i2c_info.slave_addr = temp;
+
+ rc = of_property_read_u32(of_node, "i2c-freq-mode", &temp);
+ soc_private->i2c_info.i2c_freq_mode = temp;
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM,
+ "i2c-freq-mode read fail %d", rc);
+ soc_private->i2c_info.i2c_freq_mode = 0;
+ }
+ if (soc_private->i2c_info.i2c_freq_mode >= I2C_MAX_MODES) {
+ CAM_ERR(CAM_EEPROM, "invalid i2c_freq_mode = %d",
+ soc_private->i2c_info.i2c_freq_mode);
+ soc_private->i2c_info.i2c_freq_mode = 0;
+ }
+ CAM_DBG(CAM_EEPROM, "slave-addr = 0x%X",
+ soc_private->i2c_info.slave_addr);
+ }
+ return rc;
+}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.h
new file mode 100644
index 0000000..02e59d7
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_eeprom/cam_eeprom_soc.h
@@ -0,0 +1,22 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#ifndef _CAM_EEPROM_SOC_H_
+#define _CAM_EEPROM_SOC_H_
+
+#include "cam_eeprom_dev.h"
+
+int cam_eeprom_parse_dt_memory_map(struct device_node *of,
+ struct cam_eeprom_memory_block_t *data);
+
+int cam_eeprom_platform_driver_soc_init(struct cam_eeprom_ctrl_t *e_ctrl);
+int cam_eeprom_spi_driver_soc_init(struct cam_eeprom_ctrl_t *e_ctrl);
+#endif/* _CAM_EEPROM_SOC_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/Makefile b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/Makefile
new file mode 100644
index 0000000..9aab0e4
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/Makefile
@@ -0,0 +1,9 @@
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sync
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_sensor_module/cam_cci
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr
+ccflags-y += -Idrivers/media/platform/msm/camera/cam_smmu/
+
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_flash_dev.o cam_flash_core.o cam_flash_soc.o
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c
new file mode 100644
index 0000000..7af7efc
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.c
@@ -0,0 +1,741 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+
+#include "cam_sensor_cmn_header.h"
+#include "cam_flash_core.h"
+
+int cam_flash_prepare(struct cam_flash_ctrl *flash_ctrl,
+ enum cam_flash_state state)
+{
+ int rc = 0;
+
+ if (!(flash_ctrl->switch_trigger)) {
+ CAM_ERR(CAM_FLASH, "Invalid argument");
+ return -EINVAL;
+ }
+
+ if ((state == CAM_FLASH_STATE_INIT) &&
+ (flash_ctrl->is_regulator_enabled == false)) {
+ rc = qpnp_flash_led_prepare(flash_ctrl->switch_trigger,
+ ENABLE_REGULATOR, NULL);
+ if (rc) {
+ CAM_ERR(CAM_FLASH, "regulator enable failed rc = %d",
+ rc);
+ return rc;
+ }
+ flash_ctrl->is_regulator_enabled = true;
+ } else if ((state == CAM_FLASH_STATE_RELEASE) &&
+ (flash_ctrl->is_regulator_enabled == true)) {
+ rc = qpnp_flash_led_prepare(flash_ctrl->switch_trigger,
+ DISABLE_REGULATOR, NULL);
+ if (rc) {
+ CAM_ERR(CAM_FLASH, "regulator disable failed rc = %d",
+ rc);
+ return rc;
+ }
+ flash_ctrl->is_regulator_enabled = false;
+ } else {
+ CAM_ERR(CAM_FLASH, "Wrong Flash State : %d",
+ flash_ctrl->flash_state);
+ rc = -EINVAL;
+ }
+
+ return rc;
+}
+
+static int cam_flash_ops(struct cam_flash_ctrl *flash_ctrl,
+ struct cam_flash_frame_setting *flash_data, enum camera_flash_opcode op)
+{
+ uint32_t curr = 0, max_current = 0;
+ struct cam_flash_private_soc *soc_private = NULL;
+ int i = 0;
+
+ if (!flash_ctrl || !flash_data) {
+ CAM_ERR(CAM_FLASH, "Fctrl or Data NULL");
+ return -EINVAL;
+ }
+
+ soc_private = (struct cam_flash_private_soc *)
+ &flash_ctrl->soc_info.soc_private;
+
+ if (op == CAMERA_SENSOR_FLASH_OP_FIRELOW) {
+ for (i = 0; i < flash_ctrl->torch_num_sources; i++) {
+ if (flash_ctrl->torch_trigger[i]) {
+ max_current = soc_private->torch_max_current[i];
+
+ if (flash_data->led_current_ma[i] <=
+ max_current)
+ curr = flash_data->led_current_ma[i];
+ else
+ curr = soc_private->torch_op_current[i];
+
+ CAM_DBG(CAM_FLASH,
+ "Led_Current[%d] = %d", i, curr);
+ led_trigger_event(flash_ctrl->torch_trigger[i],
+ curr);
+ }
+ }
+ } else if (op == CAMERA_SENSOR_FLASH_OP_FIREHIGH) {
+ for (i = 0; i < flash_ctrl->flash_num_sources; i++) {
+ if (flash_ctrl->flash_trigger[i]) {
+ max_current = soc_private->flash_max_current[i];
+
+ if (flash_data->led_current_ma[i] <=
+ max_current)
+ curr = flash_data->led_current_ma[i];
+ else
+ curr = soc_private->flash_op_current[i];
+
+ CAM_DBG(CAM_FLASH, "LED flash_current[%d]: %d",
+ i, curr);
+ led_trigger_event(flash_ctrl->flash_trigger[i],
+ curr);
+ }
+ }
+ } else {
+ CAM_ERR(CAM_FLASH, "Wrong Operation: %d", op);
+ return -EINVAL;
+ }
+
+ if (flash_ctrl->switch_trigger)
+ led_trigger_event(flash_ctrl->switch_trigger, LED_SWITCH_ON);
+
+ return 0;
+}
+
+int cam_flash_off(struct cam_flash_ctrl *flash_ctrl)
+{
+ int i = 0;
+
+ if (!flash_ctrl) {
+ CAM_ERR(CAM_FLASH, "Flash control Null");
+ return -EINVAL;
+ }
+
+ for (i = 0; i < flash_ctrl->flash_num_sources; i++)
+ if (flash_ctrl->flash_trigger[i])
+ led_trigger_event(flash_ctrl->flash_trigger[i],
+ LED_OFF);
+
+ for (i = 0; i < flash_ctrl->torch_num_sources; i++)
+ if (flash_ctrl->torch_trigger[i])
+ led_trigger_event(flash_ctrl->torch_trigger[i],
+ LED_OFF);
+
+ if (flash_ctrl->switch_trigger)
+ led_trigger_event(flash_ctrl->switch_trigger,
+ LED_SWITCH_OFF);
+
+ return 0;
+}
+
+static int cam_flash_low(
+ struct cam_flash_ctrl *flash_ctrl,
+ struct cam_flash_frame_setting *flash_data)
+{
+ int i = 0, rc = 0;
+
+ if (!flash_data) {
+ CAM_ERR(CAM_FLASH, "Flash Data Null");
+ return -EINVAL;
+ }
+
+ for (i = 0; i < flash_ctrl->flash_num_sources; i++)
+ if (flash_ctrl->flash_trigger[i])
+ led_trigger_event(flash_ctrl->flash_trigger[i],
+ LED_OFF);
+
+ rc = cam_flash_ops(flash_ctrl, flash_data,
+ CAMERA_SENSOR_FLASH_OP_FIRELOW);
+ if (rc)
+ CAM_ERR(CAM_FLASH, "Fire Torch failed: %d", rc);
+
+ return rc;
+}
+
+static int cam_flash_high(
+ struct cam_flash_ctrl *flash_ctrl,
+ struct cam_flash_frame_setting *flash_data)
+{
+ int i = 0, rc = 0;
+
+ if (!flash_data) {
+ CAM_ERR(CAM_FLASH, "Flash Data Null");
+ return -EINVAL;
+ }
+
+ for (i = 0; i < flash_ctrl->torch_num_sources; i++)
+ if (flash_ctrl->torch_trigger[i])
+ led_trigger_event(flash_ctrl->torch_trigger[i],
+ LED_OFF);
+
+ rc = cam_flash_ops(flash_ctrl, flash_data,
+ CAMERA_SENSOR_FLASH_OP_FIREHIGH);
+ if (rc)
+ CAM_ERR(CAM_FLASH, "Fire Flash Failed: %d", rc);
+
+ return rc;
+}
+
+static int delete_req(struct cam_flash_ctrl *fctrl, uint64_t req_id)
+{
+ int i = 0;
+ int frame_offset = 0;
+ struct cam_flash_frame_setting *flash_data = NULL;
+
+ if (req_id == 0) {
+ flash_data = &fctrl->nrt_info;
+ if ((fctrl->nrt_info.cmn_attr.cmd_type ==
+ CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET) ||
+ (fctrl->nrt_info.cmn_attr.cmd_type ==
+ CAMERA_SENSOR_FLASH_CMD_TYPE_RER)) {
+ flash_data->cmn_attr.is_settings_valid = false;
+ for (i = 0; i < flash_data->cmn_attr.count; i++)
+ flash_data->led_current_ma[i] = 0;
+ } else {
+ fctrl->flash_init_setting.cmn_attr.
+ is_settings_valid = false;
+ }
+ } else {
+ frame_offset = (req_id + MAX_PER_FRAME_ARRAY -
+ CAM_FLASH_PIPELINE_DELAY) % 8;
+ flash_data = &fctrl->per_frame[frame_offset];
+ if (req_id > flash_data->cmn_attr.request_id) {
+ flash_data->cmn_attr.request_id = 0;
+ flash_data->cmn_attr.is_settings_valid = false;
+ for (i = 0; i < flash_data->cmn_attr.count; i++)
+ flash_data->led_current_ma[i] = 0;
+ }
+ }
+
+ return 0;
+}
+
+int cam_flash_apply_setting(struct cam_flash_ctrl *fctrl,
+ uint64_t req_id)
+{
+ int rc = 0, i = 0;
+ int frame_offset = 0;
+ uint16_t num_iterations;
+ struct cam_flash_frame_setting *flash_data = NULL;
+
+ if (req_id == 0) {
+ if (fctrl->nrt_info.cmn_attr.cmd_type ==
+ CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET) {
+ flash_data = &fctrl->nrt_info;
+ if (flash_data->opcode ==
+ CAMERA_SENSOR_FLASH_OP_FIRELOW) {
+ if (!(fctrl->is_regulator_enabled)) {
+ rc = cam_flash_prepare(fctrl,
+ CAM_FLASH_STATE_INIT);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Reg Enable Failed %d",
+ rc);
+ goto nrt_del_req;
+ }
+ fctrl->flash_state =
+ CAM_FLASH_STATE_INIT;
+ rc = cam_flash_low(fctrl, flash_data);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Torch ON failed : %d",
+ rc);
+ goto nrt_del_req;
+ }
+ fctrl->flash_state =
+ CAM_FLASH_STATE_LOW;
+ }
+ } else if (flash_data->opcode ==
+ CAMERA_SENSOR_FLASH_OP_OFF) {
+ if (fctrl->flash_state !=
+ CAM_FLASH_STATE_INIT) {
+ rc = cam_flash_off(fctrl);
+ if (rc)
+ CAM_ERR(CAM_FLASH,
+ "LED off failed: %d",
+ rc);
+ }
+
+ rc = cam_flash_prepare(fctrl,
+ CAM_FLASH_STATE_RELEASE);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Regulator Disable failed %d",
+ rc);
+ goto nrt_del_req;
+ }
+
+ fctrl->flash_state =
+ CAM_FLASH_STATE_RELEASE;
+ fctrl->is_regulator_enabled = false;
+ }
+ } else if (fctrl->nrt_info.cmn_attr.cmd_type ==
+ CAMERA_SENSOR_FLASH_CMD_TYPE_RER) {
+ flash_data = &fctrl->nrt_info;
+
+ if (fctrl->flash_state != CAM_FLASH_STATE_INIT) {
+ rc = cam_flash_off(fctrl);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Flash off failed: %d",
+ rc);
+ } else {
+ fctrl->flash_state =
+ CAM_FLASH_STATE_INIT;
+ }
+ }
+
+ num_iterations = flash_data->num_iterations;
+ for (i = 0; i < num_iterations; i++) {
+ /* Turn On Torch */
+ if (fctrl->flash_state ==
+ CAM_FLASH_STATE_INIT) {
+ rc = cam_flash_low(fctrl, flash_data);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Fire Torch Failed");
+ goto nrt_del_req;
+ }
+ fctrl->flash_state =
+ CAM_FLASH_STATE_LOW;
+ }
+ usleep_range(
+ flash_data->led_on_delay_ms * 1000,
+ flash_data->led_on_delay_ms * 1000 + 100);
+
+ /* Turn Off Torch */
+ rc = cam_flash_off(fctrl);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Flash off failed: %d",
+ rc);
+ continue;
+ }
+ fctrl->flash_state = CAM_FLASH_STATE_INIT;
+ usleep_range(
+ flash_data->led_off_delay_ms * 1000,
+ flash_data->led_off_delay_ms * 1000 + 100);
+ }
+ }
+ } else {
+ frame_offset = req_id % MAX_PER_FRAME_ARRAY;
+ flash_data = &fctrl->per_frame[frame_offset];
+
+ if ((flash_data->opcode == CAMERA_SENSOR_FLASH_OP_FIREHIGH) &&
+ (flash_data->cmn_attr.is_settings_valid)) {
+ /* Turn On Flash */
+ if (fctrl->flash_state == CAM_FLASH_STATE_INIT) {
+ rc = cam_flash_high(fctrl, flash_data);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Flash ON failed: rc= %d",
+ rc);
+ goto apply_setting_err;
+ }
+ fctrl->flash_state = CAM_FLASH_STATE_HIGH;
+ }
+ } else if ((flash_data->opcode ==
+ CAMERA_SENSOR_FLASH_OP_FIRELOW) &&
+ (flash_data->cmn_attr.is_settings_valid)) {
+ /* Turn Off Flash */
+ if (fctrl->flash_state == CAM_FLASH_STATE_INIT) {
+ rc = cam_flash_low(fctrl, flash_data);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Torch ON failed: rc= %d",
+ rc);
+ goto apply_setting_err;
+ }
+ fctrl->flash_state = CAM_FLASH_STATE_LOW;
+ }
+ } else if ((flash_data->opcode == CAMERA_SENSOR_FLASH_OP_OFF) &&
+ (flash_data->cmn_attr.is_settings_valid)) {
+ if ((fctrl->flash_state != CAM_FLASH_STATE_RELEASE) ||
+ (fctrl->flash_state != CAM_FLASH_STATE_INIT)) {
+ rc = cam_flash_off(fctrl);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Flash off failed %d", rc);
+ } else {
+ fctrl->flash_state =
+ CAM_FLASH_STATE_INIT;
+ }
+ }
+ } else {
+ CAM_ERR(CAM_FLASH, "Wrong opcode : %d",
+ flash_data->opcode);
+ rc = -EINVAL;
+ goto apply_setting_err;
+ }
+ }
+
+nrt_del_req:
+ delete_req(fctrl, req_id);
+apply_setting_err:
+ return rc;
+}
+
+int cam_flash_parser(struct cam_flash_ctrl *fctrl, void *arg)
+{
+ int rc = 0, i = 0;
+ uint64_t generic_ptr;
+ uint32_t *cmd_buf = NULL;
+ uint32_t *offset = NULL;
+ uint32_t frame_offset = 0;
+ size_t len_of_buffer;
+ struct cam_control *ioctl_ctrl = NULL;
+ struct cam_packet *csl_packet = NULL;
+ struct cam_cmd_buf_desc *cmd_desc = NULL;
+ struct common_header *cmn_hdr;
+ struct cam_config_dev_cmd config;
+ struct cam_req_mgr_add_request add_req;
+ struct cam_flash_init *cam_flash_info = NULL;
+ struct cam_flash_set_rer *flash_rer_info = NULL;
+ struct cam_flash_set_on_off *flash_operation_info = NULL;
+ struct cam_flash_query_curr *flash_query_info = NULL;
+
+ if (!fctrl || !arg) {
+ CAM_ERR(CAM_FLASH, "fctrl/arg is NULL");
+ return -EINVAL;
+ }
+ /* getting CSL Packet */
+ ioctl_ctrl = (struct cam_control *)arg;
+
+ if (copy_from_user((&config), (void __user *) ioctl_ctrl->handle,
+ sizeof(config))) {
+ CAM_ERR(CAM_FLASH, "Copy cmd handle from user failed");
+ rc = -EFAULT;
+ return rc;
+ }
+
+ rc = cam_mem_get_cpu_buf(config.packet_handle,
+ (uint64_t *)&generic_ptr, &len_of_buffer);
+ if (rc) {
+ CAM_ERR(CAM_FLASH, "Failed in getting the buffer : %d", rc);
+ return rc;
+ }
+
+ csl_packet = (struct cam_packet *)generic_ptr;
+
+ switch (csl_packet->header.op_code & 0xFFFFFF) {
+ case CAM_FLASH_PACKET_OPCODE_INIT: {
+ /* INIT packet*/
+ offset = (uint32_t *)((uint8_t *)&csl_packet->payload +
+ csl_packet->cmd_buf_offset);
+ fctrl->flash_init_setting.cmn_attr.request_id = 0;
+ fctrl->flash_init_setting.cmn_attr.is_settings_valid = true;
+ cmd_desc = (struct cam_cmd_buf_desc *)(offset);
+ rc = cam_mem_get_cpu_buf(cmd_desc->mem_handle,
+ (uint64_t *)&generic_ptr, &len_of_buffer);
+ cmd_buf = (uint32_t *)((uint8_t *)generic_ptr +
+ cmd_desc->offset);
+ cam_flash_info = (struct cam_flash_init *)cmd_buf;
+
+ switch (cam_flash_info->cmd_type) {
+ case CAMERA_SENSOR_FLASH_CMD_TYPE_INIT:
+ fctrl->flash_type = cam_flash_info->flash_type;
+ fctrl->is_regulator_enabled = false;
+ fctrl->nrt_info.cmn_attr.cmd_type =
+ CAMERA_SENSOR_FLASH_CMD_TYPE_INIT;
+ break;
+ default:
+ CAM_ERR(CAM_FLASH, "Wrong cmd_type = %d",
+ cam_flash_info->cmd_type);
+ return -EINVAL;
+ }
+ break;
+ }
+ case CAM_FLASH_PACKET_OPCODE_SET_OPS: {
+ offset = (uint32_t *)((uint8_t *)&csl_packet->payload +
+ csl_packet->cmd_buf_offset);
+ frame_offset = csl_packet->header.request_id %
+ MAX_PER_FRAME_ARRAY;
+ fctrl->per_frame[frame_offset].cmn_attr.request_id =
+ csl_packet->header.request_id;
+ fctrl->per_frame[frame_offset].cmn_attr.is_settings_valid =
+ true;
+ cmd_desc = (struct cam_cmd_buf_desc *)(offset);
+ rc = cam_mem_get_cpu_buf(cmd_desc->mem_handle,
+ (uint64_t *)&generic_ptr, &len_of_buffer);
+ cmd_buf = (uint32_t *)((uint8_t *)generic_ptr +
+ cmd_desc->offset);
+ cmn_hdr = (struct common_header *)cmd_buf;
+
+ switch (cmn_hdr->cmd_type) {
+ case CAMERA_SENSOR_FLASH_CMD_TYPE_FIRE: {
+ CAM_DBG(CAM_FLASH,
+ "CAMERA_FLASH_CMD_TYPE_OPS case called");
+ flash_operation_info =
+ (struct cam_flash_set_on_off *) cmd_buf;
+ fctrl->per_frame[frame_offset].opcode =
+ flash_operation_info->opcode;
+ fctrl->per_frame[frame_offset].cmn_attr.count =
+ flash_operation_info->count;
+ for (i = 0; i < flash_operation_info->count; i++)
+ fctrl->per_frame[frame_offset].led_current_ma[i]
+ = flash_operation_info->
+ led_current_ma[i];
+ break;
+ }
+ default:
+ CAM_ERR(CAM_FLASH, "Wrong cmd_type = %d",
+ cmn_hdr->cmd_type);
+ return -EINVAL;
+ }
+
+ break;
+ }
+ case CAM_FLASH_PACKET_OPCODE_NON_REALTIME_SET_OPS: {
+ offset = (uint32_t *)((uint8_t *)&csl_packet->payload +
+ csl_packet->cmd_buf_offset);
+ fctrl->nrt_info.cmn_attr.is_settings_valid = true;
+ cmd_desc = (struct cam_cmd_buf_desc *)(offset);
+ rc = cam_mem_get_cpu_buf(cmd_desc->mem_handle,
+ (uint64_t *)&generic_ptr, &len_of_buffer);
+ cmd_buf = (uint32_t *)((uint8_t *)generic_ptr +
+ cmd_desc->offset);
+ cmn_hdr = (struct common_header *)cmd_buf;
+
+ switch (cmn_hdr->cmd_type) {
+ case CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET: {
+ CAM_DBG(CAM_FLASH, "Widget Flash Operation");
+ flash_operation_info =
+ (struct cam_flash_set_on_off *) cmd_buf;
+ fctrl->nrt_info.cmn_attr.count =
+ flash_operation_info->count;
+ fctrl->nrt_info.cmn_attr.request_id = 0;
+ fctrl->nrt_info.opcode =
+ flash_operation_info->opcode;
+ fctrl->nrt_info.cmn_attr.cmd_type =
+ CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET;
+
+ for (i = 0; i < flash_operation_info->count; i++)
+ fctrl->nrt_info.led_current_ma[i] =
+ flash_operation_info->led_current_ma[i];
+
+ mutex_lock(&fctrl->flash_wq_mutex);
+ rc = cam_flash_apply_setting(fctrl, 0);
+ if (rc)
+ CAM_ERR(CAM_FLASH, "Apply setting failed: %d",
+ rc);
+ mutex_unlock(&fctrl->flash_wq_mutex);
+ return rc;
+ }
+ case CAMERA_SENSOR_FLASH_CMD_TYPE_QUERYCURR: {
+ int query_curr_ma = 0;
+
+ flash_query_info =
+ (struct cam_flash_query_curr *)cmd_buf;
+
+ rc = qpnp_flash_led_prepare(fctrl->switch_trigger,
+ QUERY_MAX_CURRENT, &query_curr_ma);
+ CAM_DBG(CAM_FLASH, "query_curr_ma = %d",
+ query_curr_ma);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Query current failed with rc=%d", rc);
+ return rc;
+ }
+ flash_query_info->query_current_ma = query_curr_ma;
+ break;
+ }
+ case CAMERA_SENSOR_FLASH_CMD_TYPE_RER: {
+ rc = 0;
+ flash_rer_info = (struct cam_flash_set_rer *)cmd_buf;
+ fctrl->nrt_info.cmn_attr.cmd_type =
+ CAMERA_SENSOR_FLASH_CMD_TYPE_RER;
+ fctrl->nrt_info.opcode = flash_rer_info->opcode;
+ fctrl->nrt_info.cmn_attr.count = flash_rer_info->count;
+ fctrl->nrt_info.cmn_attr.request_id = 0;
+ fctrl->nrt_info.num_iterations =
+ flash_rer_info->num_iteration;
+ fctrl->nrt_info.led_on_delay_ms =
+ flash_rer_info->led_on_delay_ms;
+ fctrl->nrt_info.led_off_delay_ms =
+ flash_rer_info->led_off_delay_ms;
+
+ for (i = 0; i < flash_rer_info->count; i++)
+ fctrl->nrt_info.led_current_ma[i] =
+ flash_rer_info->led_current_ma[i];
+
+
+ mutex_lock(&fctrl->flash_wq_mutex);
+ rc = cam_flash_apply_setting(fctrl, 0);
+ if (rc)
+ CAM_ERR(CAM_FLASH, "apply_setting failed: %d",
+ rc);
+ mutex_unlock(&fctrl->flash_wq_mutex);
+ return rc;
+ }
+ default:
+ CAM_ERR(CAM_FLASH, "Wrong cmd_type : %d",
+ cmn_hdr->cmd_type);
+ return -EINVAL;
+ }
+
+ break;
+ }
+ case CAM_PKT_NOP_OPCODE: {
+ goto update_req_mgr;
+ }
+ default:
+ CAM_ERR(CAM_FLASH, "Wrong Opcode : %d",
+ (csl_packet->header.op_code & 0xFFFFFF));
+ return -EINVAL;
+ }
+update_req_mgr:
+ if (((csl_packet->header.op_code & 0xFFFFF) ==
+ CAM_PKT_NOP_OPCODE) ||
+ ((csl_packet->header.op_code & 0xFFFFF) ==
+ CAM_FLASH_PACKET_OPCODE_SET_OPS)) {
+ add_req.link_hdl = fctrl->bridge_intf.link_hdl;
+ add_req.req_id = csl_packet->header.request_id;
+ add_req.dev_hdl = fctrl->bridge_intf.device_hdl;
+ if (fctrl->bridge_intf.crm_cb &&
+ fctrl->bridge_intf.crm_cb->add_req)
+ fctrl->bridge_intf.crm_cb->add_req(&add_req);
+ CAM_DBG(CAM_FLASH, "add req to req_mgr= %lld", add_req.req_id);
+ }
+
+ return rc;
+}
+
+int cam_flash_publish_dev_info(struct cam_req_mgr_device_info *info)
+{
+ info->dev_id = CAM_REQ_MGR_DEVICE_FLASH;
+ strlcpy(info->name, CAM_FLASH_NAME, sizeof(info->name));
+ info->p_delay = CAM_FLASH_PIPELINE_DELAY;
+ return 0;
+}
+
+int cam_flash_establish_link(struct cam_req_mgr_core_dev_link_setup *link)
+{
+ struct cam_flash_ctrl *fctrl = NULL;
+
+ if (!link)
+ return -EINVAL;
+
+ fctrl = (struct cam_flash_ctrl *)cam_get_device_priv(link->dev_hdl);
+ if (!fctrl) {
+ CAM_ERR(CAM_FLASH, " Device data is NULL");
+ return -EINVAL;
+ }
+
+ if (link->link_enable) {
+ fctrl->bridge_intf.link_hdl = link->link_hdl;
+ fctrl->bridge_intf.crm_cb = link->crm_cb;
+ } else {
+ fctrl->bridge_intf.link_hdl = -1;
+ fctrl->bridge_intf.crm_cb = NULL;
+ }
+
+ return 0;
+}
+
+static int cam_flash_flush_nrt(struct cam_flash_ctrl *fctrl)
+{
+ int j = 0;
+ struct cam_flash_frame_setting *nrt_settings;
+
+ if (!fctrl)
+ return -EINVAL;
+
+ nrt_settings = &fctrl->nrt_info;
+
+ if (nrt_settings->cmn_attr.cmd_type ==
+ CAMERA_SENSOR_FLASH_CMD_TYPE_INIT) {
+ fctrl->flash_init_setting.cmn_attr.is_settings_valid = false;
+ } else if ((nrt_settings->cmn_attr.cmd_type ==
+ CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET) ||
+ (nrt_settings->cmn_attr.cmd_type ==
+ CAMERA_SENSOR_FLASH_CMD_TYPE_RER)) {
+ fctrl->nrt_info.cmn_attr.is_settings_valid = false;
+ fctrl->nrt_info.cmn_attr.count = 0;
+ fctrl->nrt_info.num_iterations = 0;
+ fctrl->nrt_info.led_on_delay_ms = 0;
+ fctrl->nrt_info.led_off_delay_ms = 0;
+ for (j = 0; j < CAM_FLASH_MAX_LED_TRIGGERS; j++)
+ fctrl->nrt_info.led_current_ma[j] = 0;
+ }
+
+ return 0;
+}
+
+int cam_flash_flush_request(struct cam_req_mgr_flush_request *flush)
+{
+ int rc = 0;
+ int i = 0, j = 0;
+ struct cam_flash_ctrl *fctrl = NULL;
+ int frame_offset = 0;
+
+ fctrl = (struct cam_flash_ctrl *) cam_get_device_priv(flush->dev_hdl);
+ if (!fctrl) {
+ CAM_ERR(CAM_FLASH, "Device data is NULL");
+ return -EINVAL;
+ }
+
+ if (flush->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
+ /* flush all requests*/
+ for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
+ fctrl->per_frame[i].cmn_attr.request_id = 0;
+ fctrl->per_frame[i].cmn_attr.is_settings_valid = false;
+ fctrl->per_frame[i].cmn_attr.count = 0;
+ for (j = 0; j < CAM_FLASH_MAX_LED_TRIGGERS; j++)
+ fctrl->per_frame[i].led_current_ma[j] = 0;
+ }
+
+ rc = cam_flash_flush_nrt(fctrl);
+ if (rc)
+ CAM_ERR(CAM_FLASH, "NonRealTime flush error");
+ } else if (flush->type == CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ) {
+ /* flush request with req_id*/
+ frame_offset = flush->req_id % MAX_PER_FRAME_ARRAY;
+ fctrl->per_frame[frame_offset].cmn_attr.request_id = 0;
+ fctrl->per_frame[frame_offset].cmn_attr.is_settings_valid =
+ false;
+ fctrl->per_frame[frame_offset].cmn_attr.count = 0;
+ for (i = 0; i < CAM_FLASH_MAX_LED_TRIGGERS; i++)
+ fctrl->per_frame[frame_offset].led_current_ma[i] = 0;
+ }
+ return rc;
+}
+
+int cam_flash_apply_request(struct cam_req_mgr_apply_request *apply)
+{
+ int rc = 0;
+ struct cam_flash_ctrl *fctrl = NULL;
+
+ if (!apply)
+ return -EINVAL;
+
+ fctrl = (struct cam_flash_ctrl *) cam_get_device_priv(apply->dev_hdl);
+ if (!fctrl) {
+ CAM_ERR(CAM_FLASH, "Device data is NULL");
+ rc = -EINVAL;
+ goto free_resource;
+ }
+
+ if (!(apply->report_if_bubble)) {
+ mutex_lock(&fctrl->flash_wq_mutex);
+ rc = cam_flash_apply_setting(fctrl, apply->request_id);
+ if (rc)
+ CAM_ERR(CAM_FLASH, "apply_setting failed with rc=%d",
+ rc);
+ mutex_unlock(&fctrl->flash_wq_mutex);
+ }
+
+free_resource:
+ return rc;
+}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.h
new file mode 100644
index 0000000..4b0cf8d
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_core.h
@@ -0,0 +1,33 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _CAM_FLASH_CORE_H_
+#define _CAM_FLASH_CORE_H_
+
+#include <linux/leds-qpnp-flash.h>
+#include <media/cam_sensor.h>
+#include "cam_flash_dev.h"
+#include "cam_sync_api.h"
+#include "cam_mem_mgr_api.h"
+
+int cam_flash_parser(struct cam_flash_ctrl *fctrl, void *arg);
+int cam_flash_publish_dev_info(struct cam_req_mgr_device_info *info);
+int cam_flash_establish_link(struct cam_req_mgr_core_dev_link_setup *link);
+int cam_flash_apply_setting(struct cam_flash_ctrl *fctrl, uint64_t req_id);
+int cam_flash_apply_request(struct cam_req_mgr_apply_request *apply);
+int cam_flash_process_evt(struct cam_req_mgr_link_evt_data *event_data);
+int cam_flash_flush_request(struct cam_req_mgr_flush_request *flush);
+int cam_flash_off(struct cam_flash_ctrl *fctrl);
+int cam_flash_prepare(struct cam_flash_ctrl *flash_ctrl,
+ enum cam_flash_state state);
+
+#endif /*_CAM_FLASH_CORE_H_*/
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c
new file mode 100644
index 0000000..32df2f1
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.c
@@ -0,0 +1,361 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/module.h>
+#include "cam_flash_dev.h"
+#include "cam_flash_soc.h"
+#include "cam_flash_core.h"
+
+static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl,
+ void *arg, struct cam_flash_private_soc *soc_private)
+{
+ int rc = 0;
+ int i = 0;
+ struct cam_control *cmd = (struct cam_control *)arg;
+
+ if (!fctrl || !arg) {
+ CAM_ERR(CAM_FLASH, "fctrl/arg is NULL with arg:%pK fctrl%pK",
+ fctrl, arg);
+ return -EINVAL;
+ }
+
+ mutex_lock(&(fctrl->flash_mutex));
+ switch (cmd->op_code) {
+ case CAM_ACQUIRE_DEV: {
+ struct cam_sensor_acquire_dev flash_acq_dev;
+ struct cam_create_dev_hdl bridge_params;
+
+ CAM_DBG(CAM_FLASH, "CAM_ACQUIRE_DEV");
+ if (fctrl->bridge_intf.device_hdl != -1) {
+ CAM_ERR(CAM_FLASH, "Device is already acquired");
+ rc = -EINVAL;
+ goto release_mutex;
+ }
+
+ rc = copy_from_user(&flash_acq_dev, (void __user *)cmd->handle,
+ sizeof(flash_acq_dev));
+ if (rc) {
+ CAM_ERR(CAM_FLASH, "Failed Copying from User");
+ goto release_mutex;
+ }
+
+ bridge_params.session_hdl = flash_acq_dev.session_handle;
+ bridge_params.ops = &fctrl->bridge_intf.ops;
+ bridge_params.v4l2_sub_dev_flag = 0;
+ bridge_params.media_entity_flag = 0;
+ bridge_params.priv = fctrl;
+
+ flash_acq_dev.device_handle =
+ cam_create_device_hdl(&bridge_params);
+ fctrl->bridge_intf.device_hdl =
+ flash_acq_dev.device_handle;
+ fctrl->bridge_intf.session_hdl =
+ flash_acq_dev.session_handle;
+
+ rc = copy_to_user((void __user *) cmd->handle, &flash_acq_dev,
+ sizeof(struct cam_sensor_acquire_dev));
+ if (rc) {
+ CAM_ERR(CAM_FLASH, "Failed Copy to User with rc = %d",
+ rc);
+ rc = -EFAULT;
+ goto release_mutex;
+ }
+ break;
+ }
+ case CAM_RELEASE_DEV: {
+ CAM_DBG(CAM_FLASH, "CAM_RELEASE_DEV");
+ if (fctrl->bridge_intf.device_hdl == -1) {
+ CAM_ERR(CAM_FLASH,
+ "Invalid Handle: Link Hdl: %d device hdl: %d",
+ fctrl->bridge_intf.device_hdl,
+ fctrl->bridge_intf.link_hdl);
+ rc = -EINVAL;
+ goto release_mutex;
+ }
+ rc = cam_destroy_device_hdl(fctrl->bridge_intf.device_hdl);
+ if (rc)
+ CAM_ERR(CAM_FLASH,
+ "Failed in destroying the device Handle rc= %d",
+ rc);
+ fctrl->bridge_intf.device_hdl = -1;
+ fctrl->bridge_intf.link_hdl = -1;
+ fctrl->bridge_intf.session_hdl = -1;
+ break;
+ }
+ case CAM_QUERY_CAP: {
+ struct cam_flash_query_cap_info flash_cap;
+
+ CAM_DBG(CAM_FLASH, "CAM_QUERY_CAP");
+ flash_cap.slot_info = fctrl->soc_info.index;
+ for (i = 0; i < fctrl->flash_num_sources; i++) {
+ flash_cap.max_current_flash[i] =
+ soc_private->flash_max_current[i];
+ flash_cap.max_duration_flash[i] =
+ soc_private->flash_max_duration[i];
+ }
+
+ for (i = 0; i < fctrl->torch_num_sources; i++)
+ flash_cap.max_current_torch[i] =
+ soc_private->torch_max_current[i];
+
+ if (copy_to_user((void __user *) cmd->handle, &flash_cap,
+ sizeof(struct cam_flash_query_cap_info))) {
+ CAM_ERR(CAM_FLASH, "Failed Copy to User");
+ rc = -EFAULT;
+ goto release_mutex;
+ }
+ break;
+ }
+ case CAM_START_DEV: {
+ CAM_DBG(CAM_FLASH, "CAM_START_DEV");
+ rc = cam_flash_prepare(fctrl, CAM_FLASH_STATE_INIT);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "Enable Regulator Failed rc = %d", rc);
+ goto release_mutex;
+ }
+ fctrl->flash_state = CAM_FLASH_STATE_INIT;
+ rc = cam_flash_apply_setting(fctrl, 0);
+ if (rc) {
+ CAM_ERR(CAM_FLASH, "cannot apply settings rc = %d", rc);
+ goto release_mutex;
+ }
+ break;
+ }
+ case CAM_STOP_DEV: {
+ CAM_DBG(CAM_FLASH, "CAM_STOP_DEV");
+ if (fctrl->flash_state != CAM_FLASH_STATE_INIT)
+ cam_flash_off(fctrl);
+
+ rc = cam_flash_prepare(fctrl, CAM_FLASH_STATE_RELEASE);
+ if (rc) {
+ CAM_ERR(CAM_FLASH, "Disable Regulator Failed ret = %d",
+ rc);
+ goto release_mutex;
+ }
+ fctrl->flash_state = CAM_FLASH_STATE_RELEASE;
+
+ break;
+ }
+ case CAM_CONFIG_DEV: {
+ CAM_DBG(CAM_FLASH, "CAM_CONFIG_DEV");
+ rc = cam_flash_parser(fctrl, arg);
+ if (rc) {
+ CAM_ERR(CAM_FLASH, "Failed Flash Config: rc=%d\n", rc);
+ goto release_mutex;
+ }
+ break;
+ }
+ default:
+ CAM_ERR(CAM_FLASH, "Invalid Opcode: %d", cmd->op_code);
+ rc = -EINVAL;
+ }
+
+release_mutex:
+ mutex_unlock(&(fctrl->flash_mutex));
+ return rc;
+}
+
+static const struct of_device_id cam_flash_dt_match[] = {
+ {.compatible = "qcom,camera-flash", .data = NULL},
+ {}
+};
+
+static long cam_flash_subdev_ioctl(struct v4l2_subdev *sd,
+ unsigned int cmd, void *arg)
+{
+ int rc = 0;
+ struct cam_flash_ctrl *fctrl = NULL;
+ struct cam_flash_private_soc *soc_private = NULL;
+
+ CAM_DBG(CAM_FLASH, "Enter");
+
+ fctrl = v4l2_get_subdevdata(sd);
+ soc_private = fctrl->soc_info.soc_private;
+
+ switch (cmd) {
+ case VIDIOC_CAM_CONTROL: {
+ rc = cam_flash_driver_cmd(fctrl, arg,
+ soc_private);
+ break;
+ }
+ default:
+ CAM_ERR(CAM_FLASH, "Invalid ioctl cmd type");
+ rc = -EINVAL;
+ break;
+ }
+
+ CAM_DBG(CAM_FLASH, "Exit");
+ return rc;
+}
+
+#ifdef CONFIG_COMPAT
+static long cam_flash_subdev_do_ioctl(struct v4l2_subdev *sd,
+ unsigned int cmd, unsigned long arg)
+{
+ struct cam_control cmd_data;
+ int32_t rc = 0;
+
+ if (copy_from_user(&cmd_data, (void __user *)arg,
+ sizeof(cmd_data))) {
+ CAM_ERR(CAM_FLASH,
+ "Failed to copy from user_ptr=%pK size=%zu",
+ (void __user *)arg, sizeof(cmd_data));
+ return -EFAULT;
+ }
+
+ switch (cmd) {
+ case VIDIOC_CAM_CONTROL: {
+ rc = cam_flash_subdev_ioctl(sd, cmd, &cmd_data);
+ if (rc)
+ CAM_ERR(CAM_FLASH, "cam_flash_ioctl failed");
+ break;
+ }
+ default:
+ CAM_ERR(CAM_FLASH, "Invalid compat ioctl cmd_type:%d",
+ cmd);
+ rc = -EINVAL;
+ }
+
+ if (!rc) {
+ if (copy_to_user((void __user *)arg, &cmd_data,
+ sizeof(cmd_data))) {
+ CAM_ERR(CAM_FLASH,
+ "Failed to copy to user_ptr=%pK size=%zu",
+ (void __user *)arg, sizeof(cmd_data));
+ rc = -EFAULT;
+ }
+ }
+
+ return rc;
+}
+#endif
+
+static int cam_flash_platform_remove(struct platform_device *pdev)
+{
+ struct cam_flash_ctrl *fctrl;
+
+ fctrl = platform_get_drvdata(pdev);
+ if (!fctrl) {
+ CAM_ERR(CAM_FLASH, "Flash device is NULL");
+ return 0;
+ }
+
+ devm_kfree(&pdev->dev, fctrl);
+
+ return 0;
+}
+
+static struct v4l2_subdev_core_ops cam_flash_subdev_core_ops = {
+ .ioctl = cam_flash_subdev_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl32 = cam_flash_subdev_do_ioctl
+#endif
+};
+
+static struct v4l2_subdev_ops cam_flash_subdev_ops = {
+ .core = &cam_flash_subdev_core_ops,
+};
+
+static const struct v4l2_subdev_internal_ops cam_flash_internal_ops;
+
+static int32_t cam_flash_platform_probe(struct platform_device *pdev)
+{
+ int32_t rc = 0;
+ struct cam_flash_ctrl *flash_ctrl = NULL;
+
+ CAM_DBG(CAM_FLASH, "Enter");
+ if (!pdev->dev.of_node) {
+ CAM_ERR(CAM_FLASH, "of_node NULL");
+ return -EINVAL;
+ }
+
+ flash_ctrl = kzalloc(sizeof(struct cam_flash_ctrl), GFP_KERNEL);
+ if (!flash_ctrl)
+ return -ENOMEM;
+
+ flash_ctrl->pdev = pdev;
+ flash_ctrl->soc_info.pdev = pdev;
+
+ rc = cam_flash_get_dt_data(flash_ctrl, &flash_ctrl->soc_info);
+ if (rc) {
+ CAM_ERR(CAM_FLASH, "cam_flash_get_dt_data failed with %d", rc);
+ kfree(flash_ctrl);
+ return -EINVAL;
+ }
+
+ flash_ctrl->v4l2_dev_str.internal_ops =
+ &cam_flash_internal_ops;
+ flash_ctrl->v4l2_dev_str.ops = &cam_flash_subdev_ops;
+ flash_ctrl->v4l2_dev_str.name = CAMX_FLASH_DEV_NAME;
+ flash_ctrl->v4l2_dev_str.sd_flags =
+ V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
+ flash_ctrl->v4l2_dev_str.ent_function = CAM_FLASH_DEVICE_TYPE;
+ flash_ctrl->v4l2_dev_str.token = flash_ctrl;
+
+ rc = cam_register_subdev(&(flash_ctrl->v4l2_dev_str));
+ if (rc) {
+ CAM_ERR(CAM_FLASH, "Fail to create subdev with %d", rc);
+ goto free_resource;
+ }
+ flash_ctrl->bridge_intf.device_hdl = -1;
+ flash_ctrl->bridge_intf.ops.get_dev_info = cam_flash_publish_dev_info;
+ flash_ctrl->bridge_intf.ops.link_setup = cam_flash_establish_link;
+ flash_ctrl->bridge_intf.ops.apply_req = cam_flash_apply_request;
+ flash_ctrl->bridge_intf.ops.flush_req = cam_flash_flush_request;
+
+ platform_set_drvdata(pdev, flash_ctrl);
+ v4l2_set_subdevdata(&flash_ctrl->v4l2_dev_str.sd, flash_ctrl);
+
+ mutex_init(&(flash_ctrl->flash_mutex));
+ mutex_init(&(flash_ctrl->flash_wq_mutex));
+
+ CAM_DBG(CAM_FLASH, "Probe success");
+ return rc;
+free_resource:
+ kfree(flash_ctrl);
+ return rc;
+}
+
+MODULE_DEVICE_TABLE(of, cam_flash_dt_match);
+
+static struct platform_driver cam_flash_platform_driver = {
+ .probe = cam_flash_platform_probe,
+ .remove = cam_flash_platform_remove,
+ .driver = {
+ .name = "CAM-FLASH-DRIVER",
+ .owner = THIS_MODULE,
+ .of_match_table = cam_flash_dt_match,
+ },
+};
+
+static int __init cam_flash_init_module(void)
+{
+ int32_t rc = 0;
+
+ rc = platform_driver_register(&cam_flash_platform_driver);
+ if (rc)
+ CAM_ERR(CAM_FLASH, "platform probe for flash failed");
+
+ return rc;
+}
+
+static void __exit cam_flash_exit_module(void)
+{
+ platform_driver_unregister(&cam_flash_platform_driver);
+}
+
+module_init(cam_flash_init_module);
+module_exit(cam_flash_exit_module);
+MODULE_DESCRIPTION("CAM FLASH");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.h
new file mode 100644
index 0000000..1897eb6
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_dev.h
@@ -0,0 +1,181 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _CAM_FLASH_DEV_H_
+#define _CAM_FLASH_DEV_H_
+
+#include <linux/leds.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <media/v4l2-subdev.h>
+#include <media/v4l2-ioctl.h>
+#include <media/v4l2-event.h>
+#include <media/cam_sensor.h>
+#include <media/cam_req_mgr.h>
+#include "cam_req_mgr_util.h"
+#include "cam_req_mgr_interface.h"
+#include "cam_subdev.h"
+#include "cam_mem_mgr.h"
+#include "cam_sensor_cmn_header.h"
+#include "cam_soc_util.h"
+#include "cam_debug_util.h"
+
+#define CAMX_FLASH_DEV_NAME "cam-flash-dev"
+
+#define CAM_FLASH_PIPELINE_DELAY 1
+
+#define CAM_FLASH_PACKET_OPCODE_INIT 0
+#define CAM_FLASH_PACKET_OPCODE_SET_OPS 1
+#define CAM_FLASH_PACKET_OPCODE_NON_REALTIME_SET_OPS 2
+
+enum cam_flash_switch_trigger_ops {
+ LED_SWITCH_OFF = 0,
+ LED_SWITCH_ON,
+};
+
+enum cam_flash_state {
+ CAM_FLASH_STATE_INIT,
+ CAM_FLASH_STATE_LOW,
+ CAM_FLASH_STATE_HIGH,
+ CAM_FLASH_STATE_RELEASE,
+};
+
+/**
+ * struct cam_flash_intf_params
+ * @device_hdl : Device Handle
+ * @session_hdl : Session Handle
+ * @link_hdl : Link Handle
+ * @ops : KMD operations
+ * @crm_cb : Callback API pointers
+ */
+struct cam_flash_intf_params {
+ int32_t device_hdl;
+ int32_t session_hdl;
+ int32_t link_hdl;
+ struct cam_req_mgr_kmd_ops ops;
+ struct cam_req_mgr_crm_cb *crm_cb;
+};
+
+/**
+ * struct cam_flash_common_attr
+ * @is_settings_valid : Notify the valid settings
+ * @request_id : Request id provided by umd
+ * @count : Number of led count
+ * @cmd_type : Command buffer type
+ */
+struct cam_flash_common_attr {
+ bool is_settings_valid;
+ int32_t request_id;
+ uint16_t count;
+ uint8_t cmd_type;
+};
+
+/**
+ * struct flash_init_packet
+ * @cmn_attr : Provides common attributes
+ * @flash_type : Flash type(PMIC/I2C/GPIO)
+ */
+struct cam_flash_init_packet {
+ struct cam_flash_common_attr cmn_attr;
+ uint8_t flash_type;
+};
+
+/**
+ * struct flash_frame_setting
+ * @cmn_attr : Provides common attributes
+ * @num_iterations : Iterations used to perform RER
+ * @led_on_delay_ms : LED on time in milisec
+ * @led_off_delay_ms : LED off time in milisec
+ * @opcode : Command buffer opcode
+ * @led_current_ma[] : LED current array in miliamps
+ *
+ */
+struct cam_flash_frame_setting {
+ struct cam_flash_common_attr cmn_attr;
+ uint16_t num_iterations;
+ uint16_t led_on_delay_ms;
+ uint16_t led_off_delay_ms;
+ int8_t opcode;
+ uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
+};
+
+/**
+ * struct cam_flash_private_soc
+ * @switch_trigger_name : Switch trigger name
+ * @flash_trigger_name : Flash trigger name array
+ * @flash_op_current : Flash operational current
+ * @flash_max_current : Max supported current for LED in flash mode
+ * @flash_max_duration : Max turn on duration for LED in Flash mode
+ * @torch_trigger_name : Torch trigger name array
+ * @torch_op_current : Torch operational current
+ * @torch_max_current : Max supported current for LED in torch mode
+ */
+
+struct cam_flash_private_soc {
+ const char *switch_trigger_name;
+ const char *flash_trigger_name[CAM_FLASH_MAX_LED_TRIGGERS];
+ uint32_t flash_op_current[CAM_FLASH_MAX_LED_TRIGGERS];
+ uint32_t flash_max_current[CAM_FLASH_MAX_LED_TRIGGERS];
+ uint32_t flash_max_duration[CAM_FLASH_MAX_LED_TRIGGERS];
+ const char *torch_trigger_name[CAM_FLASH_MAX_LED_TRIGGERS];
+ uint32_t torch_op_current[CAM_FLASH_MAX_LED_TRIGGERS];
+ uint32_t torch_max_current[CAM_FLASH_MAX_LED_TRIGGERS];
+};
+
+/**
+ * struct cam_flash_ctrl
+ * @soc_info : Soc related information
+ * @pdev : Platform device
+ * @per_frame[] : Per_frame setting array
+ * @nrt_info : NonRealTime settings
+ * @of_node : Of Node ptr
+ * @v4l2_dev_str : V4L2 device structure
+ * @bridge_intf : CRM interface
+ * @flash_init_setting : Init command buffer structure
+ * @switch_trigger : Switch trigger ptr
+ * @flash_num_sources : Number of flash sources
+ * @torch_num_source : Number of torch sources
+ * @flash_mutex : Mutex for flash operations
+ * @flash_wq_mutex : Mutex for flash apply setting
+ * @flash_state : Current flash state (LOW/OFF/ON/INIT)
+ * @flash_type : Flash types (PMIC/I2C/GPIO)
+ * @is_regulator_enable : Regulator disable/enable notifier
+ * @flash_trigger : Flash trigger ptr
+ * @torch_trigger : Torch trigger ptr
+ */
+struct cam_flash_ctrl {
+ struct cam_hw_soc_info soc_info;
+ struct platform_device *pdev;
+ struct cam_flash_frame_setting per_frame[MAX_PER_FRAME_ARRAY];
+ struct cam_flash_frame_setting nrt_info;
+ struct device_node *of_node;
+ struct cam_subdev v4l2_dev_str;
+ struct cam_flash_intf_params bridge_intf;
+ struct cam_flash_init_packet flash_init_setting;
+ struct led_trigger *switch_trigger;
+ uint32_t flash_num_sources;
+ uint32_t torch_num_sources;
+ struct mutex flash_mutex;
+ struct mutex flash_wq_mutex;
+ enum cam_flash_state flash_state;
+ uint8_t flash_type;
+ bool is_regulator_enabled;
+ struct led_trigger *flash_trigger[CAM_FLASH_MAX_LED_TRIGGERS];
+ struct led_trigger *torch_trigger[CAM_FLASH_MAX_LED_TRIGGERS];
+};
+
+#endif /*_CAM_FLASH_DEV_H_*/
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_soc.c
new file mode 100644
index 0000000..a9ab169
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_soc.c
@@ -0,0 +1,224 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include "cam_flash_soc.h"
+
+static int32_t cam_get_source_node_info(
+ struct device_node *of_node,
+ struct cam_flash_ctrl *fctrl,
+ struct cam_flash_private_soc *soc_private)
+{
+ int32_t rc = 0;
+ uint32_t count = 0, i = 0;
+ struct device_node *flash_src_node = NULL;
+ struct device_node *torch_src_node = NULL;
+ struct device_node *switch_src_node = NULL;
+
+ switch_src_node = of_parse_phandle(of_node, "switch-source", 0);
+ if (!switch_src_node) {
+ CAM_DBG(CAM_FLASH, "switch_src_node NULL");
+ } else {
+ rc = of_property_read_string(switch_src_node,
+ "qcom,default-led-trigger",
+ &soc_private->switch_trigger_name);
+ if (rc) {
+ CAM_ERR(CAM_FLASH,
+ "default-led-trigger read failed rc=%d", rc);
+ } else {
+ CAM_DBG(CAM_FLASH, "switch trigger %s",
+ soc_private->switch_trigger_name);
+ led_trigger_register_simple(
+ soc_private->switch_trigger_name,
+ &fctrl->switch_trigger);
+ }
+
+ of_node_put(switch_src_node);
+ }
+
+ if (of_get_property(of_node, "flash-source", &count)) {
+ count /= sizeof(uint32_t);
+
+ if (count > CAM_FLASH_MAX_LED_TRIGGERS) {
+ CAM_ERR(CAM_FLASH, "Invalid LED count: %d", count);
+ return -EINVAL;
+ }
+
+ fctrl->flash_num_sources = count;
+
+ for (i = 0; i < count; i++) {
+ flash_src_node = of_parse_phandle(of_node,
+ "flash-source", i);
+ if (!flash_src_node) {
+ CAM_WARN(CAM_FLASH, "flash_src_node NULL");
+ continue;
+ }
+
+ rc = of_property_read_string(flash_src_node,
+ "qcom,default-led-trigger",
+ &soc_private->flash_trigger_name[i]);
+ if (rc) {
+ CAM_WARN(CAM_FLASH,
+ "defalut-led-trigger read failed rc=%d", rc);
+ of_node_put(flash_src_node);
+ continue;
+ }
+
+ CAM_DBG(CAM_FLASH, "default trigger %s",
+ soc_private->flash_trigger_name[i]);
+
+ /* Read operational-current */
+ rc = of_property_read_u32(flash_src_node,
+ "qcom,current-ma",
+ &soc_private->flash_op_current[i]);
+ if (rc) {
+ CAM_WARN(CAM_FLASH, "op-current: read failed");
+ of_node_put(flash_src_node);
+ continue;
+ }
+
+ /* Read max-current */
+ rc = of_property_read_u32(flash_src_node,
+ "qcom,max-current",
+ &soc_private->flash_max_current[i]);
+ if (rc) {
+ CAM_WARN(CAM_FLASH,
+ "max-current: read failed");
+ of_node_put(flash_src_node);
+ continue;
+ }
+
+ /* Read max-duration */
+ rc = of_property_read_u32(flash_src_node,
+ "qcom,duration-ms",
+ &soc_private->flash_max_duration[i]);
+ if (rc)
+ CAM_WARN(CAM_FLASH,
+ "max-duration: read failed");
+
+ of_node_put(flash_src_node);
+
+ CAM_DBG(CAM_FLASH, "max_current[%d]: %d",
+ i, soc_private->flash_max_current[i]);
+
+ led_trigger_register_simple(
+ soc_private->flash_trigger_name[i],
+ &fctrl->flash_trigger[i]);
+ }
+ }
+
+ if (of_get_property(of_node, "torch-source", &count)) {
+ count /= sizeof(uint32_t);
+ if (count > CAM_FLASH_MAX_LED_TRIGGERS) {
+ CAM_ERR(CAM_FLASH, "Invalid LED count : %d", count);
+ return -EINVAL;
+ }
+
+ fctrl->torch_num_sources = count;
+
+ CAM_DBG(CAM_FLASH, "torch_num_sources = %d",
+ fctrl->torch_num_sources);
+ for (i = 0; i < count; i++) {
+ torch_src_node = of_parse_phandle(of_node,
+ "torch-source", i);
+ if (!torch_src_node) {
+ CAM_WARN(CAM_FLASH, "torch_src_node NULL");
+ continue;
+ }
+
+ rc = of_property_read_string(torch_src_node,
+ "qcom,default-led-trigger",
+ &soc_private->torch_trigger_name[i]);
+ if (rc < 0) {
+ CAM_WARN(CAM_FLASH,
+ "default-trigger read failed");
+ of_node_put(torch_src_node);
+ continue;
+ }
+
+ /* Read operational-current */
+ rc = of_property_read_u32(torch_src_node,
+ "qcom,current-ma",
+ &soc_private->torch_op_current[i]);
+ if (rc < 0) {
+ CAM_WARN(CAM_FLASH, "current: read failed");
+ of_node_put(torch_src_node);
+ continue;
+ }
+
+ /* Read max-current */
+ rc = of_property_read_u32(torch_src_node,
+ "qcom,max-current",
+ &soc_private->torch_max_current[i]);
+ if (rc < 0) {
+ CAM_WARN(CAM_FLASH,
+ "max-current: read failed");
+ of_node_put(torch_src_node);
+ continue;
+ }
+
+ of_node_put(torch_src_node);
+
+ CAM_DBG(CAM_FLASH, "max_current[%d]: %d",
+ i, soc_private->torch_max_current[i]);
+
+ led_trigger_register_simple(
+ soc_private->torch_trigger_name[i],
+ &fctrl->torch_trigger[i]);
+ }
+ }
+
+ return rc;
+}
+
+int cam_flash_get_dt_data(struct cam_flash_ctrl *fctrl,
+ struct cam_hw_soc_info *soc_info)
+{
+ int32_t rc = 0;
+ struct device_node *of_node = NULL;
+
+ if (!fctrl) {
+ CAM_ERR(CAM_FLASH, "NULL flash control structure");
+ return -EINVAL;
+ }
+
+ of_node = fctrl->pdev->dev.of_node;
+
+ rc = cam_soc_util_get_dt_properties(soc_info);
+ if (rc < 0) {
+ CAM_ERR(CAM_FLASH, "Get_dt_properties failed rc %d", rc);
+ return rc;
+ }
+
+ soc_info->soc_private =
+ kzalloc(sizeof(struct cam_flash_private_soc), GFP_KERNEL);
+ if (!soc_info->soc_private) {
+ rc = -ENOMEM;
+ goto release_soc_res;
+ }
+
+ rc = cam_get_source_node_info(of_node, fctrl, soc_info->soc_private);
+ if (rc < 0) {
+ CAM_ERR(CAM_FLASH,
+ "cam_flash_get_pmic_source_info failed rc %d", rc);
+ goto free_soc_private;
+ }
+
+ return rc;
+
+free_soc_private:
+ kfree(soc_info->soc_private);
+release_soc_res:
+ cam_soc_util_release_platform_resource(soc_info);
+ return rc;
+}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_soc.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_soc.h
new file mode 100644
index 0000000..2e1da69
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_flash/cam_flash_soc.h
@@ -0,0 +1,21 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _CAM_FLASH_SOC_H_
+#define _CAM_FLASH_SOC_H_
+
+#include "cam_flash_dev.h"
+
+int cam_flash_get_dt_data(struct cam_flash_ctrl *fctrl,
+ struct cam_hw_soc_info *soc_info);
+
+#endif /*_CAM_FLASH_SOC_H_*/
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c
index be8306c..f6e6a9a 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_core.c
@@ -35,8 +35,7 @@ static int32_t cam_sensor_i2c_pkt_parse(struct cam_sensor_ctrl_t *s_ctrl,
ioctl_ctrl = (struct cam_control *)arg;
if (ioctl_ctrl->handle_type != CAM_HANDLE_USER_POINTER) {
- pr_err("%s:%d :Error: Invalid Handle Type\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Invalid Handle Type");
return -EINVAL;
}
@@ -49,22 +48,21 @@ static int32_t cam_sensor_i2c_pkt_parse(struct cam_sensor_ctrl_t *s_ctrl,
(uint64_t *)&generic_ptr,
&len_of_buff);
if (rc < 0) {
- pr_err("%s:%d :Error: Failed in getting the buffer: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "Failed in getting the buffer: %d", rc);
return rc;
}
csl_packet = (struct cam_packet *)(generic_ptr +
config.offset);
if (config.offset > len_of_buff) {
- pr_err("%s: %d offset is out of bounds: off: %lld len: %zu\n",
- __func__, __LINE__, config.offset, len_of_buff);
+ CAM_ERR(CAM_SENSOR,
+ "offset is out of bounds: off: %lld len: %zu",
+ config.offset, len_of_buff);
return -EINVAL;
}
i2c_data = &(s_ctrl->i2c_data);
- CDBG("%s:%d Header OpCode: %d\n",
- __func__, __LINE__, csl_packet->header.op_code);
+ CAM_DBG(CAM_SENSOR, "Header OpCode: %d", csl_packet->header.op_code);
if ((csl_packet->header.op_code & 0xFFFFFF) ==
CAM_SENSOR_PACKET_OPCODE_SENSOR_INITIAL_CONFIG) {
i2c_reg_settings = &i2c_data->init_settings;
@@ -76,16 +74,16 @@ static int32_t cam_sensor_i2c_pkt_parse(struct cam_sensor_ctrl_t *s_ctrl,
&i2c_data->
per_frame[csl_packet->header.request_id %
MAX_PER_FRAME_ARRAY];
- CDBG("%s:%d Received Packet: %lld\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "Received Packet: %lld",
csl_packet->header.request_id % MAX_PER_FRAME_ARRAY);
if (i2c_reg_settings->is_settings_valid == 1) {
- pr_err("%s:%d :Error: Already some pkt in offset req : %lld\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR,
+ "Already some pkt in offset req : %lld",
csl_packet->header.request_id);
rc = delete_request(i2c_reg_settings);
if (rc < 0) {
- pr_err("%s: %d :Error: Failed in Deleting the err: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "Failed in Deleting the err: %d", rc);
return rc;
}
}
@@ -97,7 +95,7 @@ static int32_t cam_sensor_i2c_pkt_parse(struct cam_sensor_ctrl_t *s_ctrl,
CAM_PKT_NOP_OPCODE) {
goto update_req_mgr;
} else {
- pr_err("%s:%d Invalid Packet Header\n", __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Invalid Packet Header");
return -EINVAL;
}
@@ -107,8 +105,7 @@ static int32_t cam_sensor_i2c_pkt_parse(struct cam_sensor_ctrl_t *s_ctrl,
rc = cam_sensor_i2c_pkt_parser(i2c_reg_settings, cmd_desc, 1);
if (rc < 0) {
- pr_err("%s:%d :Error: Fail parsing I2C Pkt: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "Fail parsing I2C Pkt: %d", rc);
return rc;
}
@@ -118,14 +115,14 @@ static int32_t cam_sensor_i2c_pkt_parse(struct cam_sensor_ctrl_t *s_ctrl,
CAM_SENSOR_PACKET_OPCODE_SENSOR_UPDATE)) {
add_req.link_hdl = s_ctrl->bridge_intf.link_hdl;
add_req.req_id = csl_packet->header.request_id;
- CDBG("%s:%d Rxed Req Id: %lld\n",
- __func__, __LINE__, csl_packet->header.request_id);
+ CAM_DBG(CAM_SENSOR, " Rxed Req Id: %lld",
+ csl_packet->header.request_id);
add_req.dev_hdl = s_ctrl->bridge_intf.device_hdl;
if (s_ctrl->bridge_intf.crm_cb &&
s_ctrl->bridge_intf.crm_cb->add_req)
s_ctrl->bridge_intf.crm_cb->add_req(&add_req);
- CDBG("%s:%d add req to req mgr: %lld\n",
- __func__, __LINE__, add_req.req_id);
+ CAM_DBG(CAM_SENSOR, " add req to req mgr: %lld",
+ add_req.req_id);
}
return rc;
}
@@ -139,7 +136,8 @@ int32_t cam_sensor_update_i2c_info(struct cam_cmd_i2c_info *i2c_info,
if (s_ctrl->io_master_info.master_type == CCI_MASTER) {
cci_client = s_ctrl->io_master_info.cci_client;
if (!cci_client) {
- pr_err("failed: cci_client %pK", cci_client);
+ CAM_ERR(CAM_SENSOR, "failed: cci_client %pK",
+ cci_client);
return -EINVAL;
}
cci_client->cci_i2c_master = s_ctrl->cci_i2c_master;
@@ -147,8 +145,7 @@ int32_t cam_sensor_update_i2c_info(struct cam_cmd_i2c_info *i2c_info,
cci_client->retries = 3;
cci_client->id_map = 0;
cci_client->i2c_freq_mode = i2c_info->i2c_freq_mode;
- CDBG("%s:%d Master: %d sid: %d freq_mode: %d\n",
- __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, " Master: %d sid: %d freq_mode: %d",
cci_client->cci_i2c_master, i2c_info->slave_addr,
i2c_info->i2c_freq_mode);
}
@@ -170,211 +167,14 @@ int32_t cam_sensor_update_slave_info(struct cam_cmd_probe *probe_info,
s_ctrl->sensor_probe_addr_type = probe_info->addr_type;
s_ctrl->sensor_probe_data_type = probe_info->data_type;
- CDBG("%s:%d Sensor Addr: 0x%x sensor_id: 0x%x sensor_mask: 0x%x\n",
- __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR,
+ "Sensor Addr: 0x%x sensor_id: 0x%x sensor_mask: 0x%x",
s_ctrl->sensordata->slave_info.sensor_id_reg_addr,
s_ctrl->sensordata->slave_info.sensor_id,
s_ctrl->sensordata->slave_info.sensor_id_mask);
return rc;
}
-int32_t cam_sensor_update_power_settings(void *cmd_buf,
- int cmd_length, struct cam_sensor_ctrl_t *s_ctrl)
-{
- int32_t rc = 0, tot_size = 0, last_cmd_type = 0;
- int32_t i = 0, pwr_up = 0, pwr_down = 0;
- void *ptr = cmd_buf, *scr;
- struct cam_cmd_power *pwr_cmd = (struct cam_cmd_power *)cmd_buf;
- struct common_header *cmm_hdr = (struct common_header *)cmd_buf;
- struct cam_sensor_power_ctrl_t *power_info =
- &s_ctrl->sensordata->power_info;
-
- if (!pwr_cmd || !cmd_length) {
- pr_err("%s:%d Invalid Args: pwr_cmd %pK, cmd_length: %d\n",
- __func__, __LINE__, pwr_cmd, cmd_length);
- return -EINVAL;
- }
-
- power_info->power_setting_size = 0;
- power_info->power_setting =
- (struct cam_sensor_power_setting *)
- kzalloc(sizeof(struct cam_sensor_power_setting) *
- MAX_POWER_CONFIG, GFP_KERNEL);
- if (!power_info->power_setting)
- return -ENOMEM;
-
- power_info->power_down_setting =
- (struct cam_sensor_power_setting *)
- kzalloc(sizeof(struct cam_sensor_power_setting) *
- MAX_POWER_CONFIG, GFP_KERNEL);
- if (!power_info->power_down_setting) {
- rc = -ENOMEM;
- goto free_power_settings;
- }
-
- while (tot_size < cmd_length) {
- if (cmm_hdr->cmd_type ==
- CAMERA_SENSOR_CMD_TYPE_PWR_UP) {
- struct cam_cmd_power *pwr_cmd =
- (struct cam_cmd_power *)ptr;
-
- power_info->
- power_setting_size +=
- pwr_cmd->count;
- scr = ptr + sizeof(struct cam_cmd_power);
- tot_size = tot_size + sizeof(struct cam_cmd_power);
-
- if (pwr_cmd->count == 0)
- CDBG("%s:%d Un expected Command\n",
- __func__, __LINE__);
-
- for (i = 0; i < pwr_cmd->count; i++, pwr_up++) {
- power_info->
- power_setting[pwr_up].seq_type =
- pwr_cmd->power_settings[i].
- power_seq_type;
- power_info->
- power_setting[pwr_up].config_val =
- pwr_cmd->power_settings[i].
- config_val_low;
- power_info->power_setting[pwr_up].delay = 0;
- if (i) {
- scr = scr +
- sizeof(
- struct cam_power_settings);
- tot_size = tot_size +
- sizeof(
- struct cam_power_settings);
- }
- if (tot_size > cmd_length) {
- pr_err("%s:%d :Error: Command Buffer is wrong\n",
- __func__, __LINE__);
- rc = -EINVAL;
- goto free_power_down_settings;
- }
- CDBG("Seq Type[%d]: %d Config_val: %ldn",
- pwr_up,
- power_info->
- power_setting[pwr_up].seq_type,
- power_info->
- power_setting[pwr_up].
- config_val);
- }
- last_cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_UP;
- ptr = (void *) scr;
- cmm_hdr = (struct common_header *)ptr;
- } else if (cmm_hdr->cmd_type == CAMERA_SENSOR_CMD_TYPE_WAIT) {
- struct cam_cmd_unconditional_wait *wait_cmd =
- (struct cam_cmd_unconditional_wait *)ptr;
- if (wait_cmd->op_code ==
- CAMERA_SENSOR_WAIT_OP_SW_UCND) {
- if (last_cmd_type ==
- CAMERA_SENSOR_CMD_TYPE_PWR_UP) {
- if (pwr_up > 0)
- power_info->
- power_setting
- [pwr_up - 1].delay +=
- wait_cmd->delay;
- else
- pr_err("%s:%d Delay is expected only after valid power up setting\n",
- __func__, __LINE__);
- } else if (last_cmd_type ==
- CAMERA_SENSOR_CMD_TYPE_PWR_DOWN) {
- if (pwr_down > 0)
- power_info->
- power_down_setting
- [pwr_down - 1].delay +=
- wait_cmd->delay;
- else
- pr_err("%s:%d Delay is expected only after valid power down setting\n",
- __func__, __LINE__);
- }
- } else
- CDBG("%s:%d Invalid op code: %d\n",
- __func__, __LINE__, wait_cmd->op_code);
- tot_size = tot_size +
- sizeof(struct cam_cmd_unconditional_wait);
- if (tot_size > cmd_length) {
- pr_err("Command Buffer is wrong\n");
- return -EINVAL;
- }
- scr = (void *) (wait_cmd);
- ptr = (void *)
- (scr +
- sizeof(struct cam_cmd_unconditional_wait));
- CDBG("%s:%d ptr: %pK sizeof: %d Next: %pK\n",
- __func__, __LINE__, scr,
- (int32_t)sizeof(
- struct cam_cmd_unconditional_wait), ptr);
-
- cmm_hdr = (struct common_header *)ptr;
- } else if (cmm_hdr->cmd_type ==
- CAMERA_SENSOR_CMD_TYPE_PWR_DOWN) {
- struct cam_cmd_power *pwr_cmd =
- (struct cam_cmd_power *)ptr;
-
- scr = ptr + sizeof(struct cam_cmd_power);
- tot_size = tot_size + sizeof(struct cam_cmd_power);
- power_info->power_down_setting_size += pwr_cmd->count;
-
- if (pwr_cmd->count == 0)
- pr_err("%s:%d Invalid Command\n",
- __func__, __LINE__);
-
- for (i = 0; i < pwr_cmd->count; i++, pwr_down++) {
- power_info->
- power_down_setting[pwr_down].
- seq_type =
- pwr_cmd->power_settings[i].
- power_seq_type;
- power_info->
- power_down_setting[pwr_down].
- config_val =
- pwr_cmd->power_settings[i].
- config_val_low;
- power_info->
- power_down_setting[pwr_down].delay = 0;
- if (i) {
- scr = scr +
- sizeof(
- struct cam_power_settings);
- tot_size =
- tot_size +
- sizeof(
- struct cam_power_settings);
- }
- if (tot_size > cmd_length) {
- pr_err("Command Buffer is wrong\n");
- rc = -EINVAL;
- goto free_power_down_settings;
- }
- CDBG("%s:%d Seq Type[%d]: %d Config_val: %ldn",
- __func__, __LINE__,
- pwr_down,
- power_info->
- power_down_setting[pwr_down].
- seq_type,
- power_info->
- power_down_setting[pwr_down].
- config_val);
- }
- last_cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN;
- ptr = (void *) scr;
- cmm_hdr = (struct common_header *)ptr;
- } else {
- pr_err("%s:%d: :Error: Un expected Header Type: %d\n",
- __func__, __LINE__, cmm_hdr->cmd_type);
- }
- }
-
- return rc;
-free_power_down_settings:
- kfree(power_info->power_down_setting);
-free_power_settings:
- kfree(power_info->power_setting);
- return rc;
-}
-
int32_t cam_handle_cmd_buffers_for_probe(void *cmd_buf,
struct cam_sensor_ctrl_t *s_ctrl,
int32_t cmd_buf_num, int cmd_buf_length)
@@ -389,16 +189,14 @@ int32_t cam_handle_cmd_buffers_for_probe(void *cmd_buf,
i2c_info = (struct cam_cmd_i2c_info *)cmd_buf;
rc = cam_sensor_update_i2c_info(i2c_info, s_ctrl);
if (rc < 0) {
- pr_err("%s:%d Failed in Updating the i2c Info\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Failed in Updating the i2c Info");
return rc;
}
probe_info = (struct cam_cmd_probe *)
(cmd_buf + sizeof(struct cam_cmd_i2c_info));
rc = cam_sensor_update_slave_info(probe_info, s_ctrl);
if (rc < 0) {
- pr_err("%s:%d :Error: Updating the slave Info\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Updating the slave Info");
return rc;
}
cmd_buf = probe_info;
@@ -406,16 +204,16 @@ int32_t cam_handle_cmd_buffers_for_probe(void *cmd_buf,
break;
case 1: {
rc = cam_sensor_update_power_settings(cmd_buf,
- cmd_buf_length, s_ctrl);
+ cmd_buf_length, &s_ctrl->sensordata->power_info);
if (rc < 0) {
- pr_err("Failed in updating power settings\n");
+ CAM_ERR(CAM_SENSOR,
+ "Failed in updating power settings");
return rc;
}
}
break;
default:
- pr_err("%s:%d Invalid command buffer\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Invalid command buffer");
break;
}
return rc;
@@ -434,21 +232,19 @@ int32_t cam_handle_mem_ptr(uint64_t handle, struct cam_sensor_ctrl_t *s_ctrl)
rc = cam_mem_get_cpu_buf(handle,
(uint64_t *)&packet, &len);
if (rc < 0) {
- pr_err("%s: %d Failed to get the command Buffer\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Failed to get the command Buffer");
return -EINVAL;
}
pkt = (struct cam_packet *)packet;
cmd_desc = (struct cam_cmd_buf_desc *)
((uint32_t *)&pkt->payload + pkt->cmd_buf_offset/4);
if (cmd_desc == NULL) {
- pr_err("%s: %d command descriptor pos is invalid\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "command descriptor pos is invalid");
return -EINVAL;
}
if (pkt->num_cmd_buf != 2) {
- pr_err("%s: %d Expected More Command Buffers : %d\n",
- __func__, __LINE__, pkt->num_cmd_buf);
+ CAM_ERR(CAM_SENSOR, "Expected More Command Buffers : %d",
+ pkt->num_cmd_buf);
return -EINVAL;
}
for (i = 0; i < pkt->num_cmd_buf; i++) {
@@ -457,8 +253,8 @@ int32_t cam_handle_mem_ptr(uint64_t handle, struct cam_sensor_ctrl_t *s_ctrl)
rc = cam_mem_get_cpu_buf(cmd_desc[i].mem_handle,
(uint64_t *)&cmd_buf1, &len);
if (rc < 0) {
- pr_err("%s: %d Failed to parse the command Buffer Header\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "Failed to parse the command Buffer Header");
return -EINVAL;
}
cmd_buf = (uint32_t *)cmd_buf1;
@@ -468,8 +264,8 @@ int32_t cam_handle_mem_ptr(uint64_t handle, struct cam_sensor_ctrl_t *s_ctrl)
rc = cam_handle_cmd_buffers_for_probe(ptr, s_ctrl,
i, cmd_desc[i].length);
if (rc < 0) {
- pr_err("%s: %d Failed to parse the command Buffer Header\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "Failed to parse the command Buffer Header");
return -EINVAL;
}
}
@@ -525,8 +321,8 @@ int cam_sensor_match_id(struct cam_sensor_ctrl_t *s_ctrl)
slave_info = &(s_ctrl->sensordata->slave_info);
if (!slave_info) {
- pr_err("%s:%d failed: %pK\n",
- __func__, __LINE__, slave_info);
+ CAM_ERR(CAM_SENSOR, " failed: %pK",
+ slave_info);
return -EINVAL;
}
@@ -536,11 +332,11 @@ int cam_sensor_match_id(struct cam_sensor_ctrl_t *s_ctrl)
&chipid, CAMERA_SENSOR_I2C_TYPE_WORD,
CAMERA_SENSOR_I2C_TYPE_WORD);
- CDBG("%s:%d read id: 0x%x expected id 0x%x:\n",
- __func__, __LINE__, chipid, slave_info->sensor_id);
+ CAM_DBG(CAM_SENSOR, "read id: 0x%x expected id 0x%x:",
+ chipid, slave_info->sensor_id);
if (cam_sensor_id_by_mask(s_ctrl, chipid) != slave_info->sensor_id) {
- pr_err("%s: chip id %x does not match %x\n",
- __func__, chipid, slave_info->sensor_id);
+ CAM_ERR(CAM_SENSOR, "chip id %x does not match %x",
+ chipid, slave_info->sensor_id);
return -ENODEV;
}
return rc;
@@ -557,8 +353,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
&s_ctrl->sensordata->power_info;
if (!s_ctrl || !arg) {
- pr_err("%s: %d s_ctrl is NULL\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "s_ctrl is NULL");
return -EINVAL;
}
@@ -566,7 +361,8 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
switch (cmd->op_code) {
case CAM_SENSOR_PROBE_CMD: {
if (s_ctrl->is_probe_succeed == 1) {
- pr_err("Already Sensor Probed in the slot\n");
+ CAM_ERR(CAM_SENSOR,
+ "Already Sensor Probed in the slot");
break;
}
/* Allocate memory for power up setting */
@@ -592,15 +388,14 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
CAM_HANDLE_MEM_HANDLE) {
rc = cam_handle_mem_ptr(cmd->handle, s_ctrl);
if (rc < 0) {
- pr_err("%s: %d Get Buffer Handle Failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Get Buffer Handle Failed");
kfree(pu);
kfree(pd);
goto release_mutex;
}
} else {
- pr_err("%s:%d :Error: Invalid Command Type: %d",
- __func__, __LINE__, cmd->handle_type);
+ CAM_ERR(CAM_SENSOR, "Invalid Command Type: %d",
+ cmd->handle_type);
}
/* Parse and fill vreg params for powerup settings */
@@ -609,8 +404,9 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
s_ctrl->sensordata->power_info.power_setting,
s_ctrl->sensordata->power_info.power_setting_size);
if (rc < 0) {
- pr_err("%s:%d :Error: Fail in filling vreg params for PUP rc %d",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "Fail in filling vreg params for PUP rc %d",
+ rc);
kfree(pu);
kfree(pd);
goto release_mutex;
@@ -622,8 +418,9 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
s_ctrl->sensordata->power_info.power_down_setting,
s_ctrl->sensordata->power_info.power_down_setting_size);
if (rc < 0) {
- pr_err("%s:%d :Error: Fail in filling vreg params for PDOWN rc %d",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "Fail in filling vreg params for PDOWN rc %d",
+ rc);
kfree(pu);
kfree(pd);
goto release_mutex;
@@ -632,7 +429,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
/* Power up and probe sensor */
rc = cam_sensor_power_up(s_ctrl);
if (rc < 0) {
- pr_err("power up failed");
+ CAM_ERR(CAM_SENSOR, "power up failed");
cam_sensor_power_down(s_ctrl);
kfree(pu);
kfree(pd);
@@ -649,13 +446,11 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
goto release_mutex;
}
- CDBG("%s:%d Probe Succeeded on the slot: %d\n",
- __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "Probe Succeeded on the slot: %d",
s_ctrl->soc_info.index);
rc = cam_sensor_power_down(s_ctrl);
if (rc < 0) {
- pr_err("%s:%d :Error: fail in Sensor Power Down\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "fail in Sensor Power Down");
kfree(pu);
kfree(pd);
goto release_mutex;
@@ -672,15 +467,14 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
struct cam_create_dev_hdl bridge_params;
if (s_ctrl->bridge_intf.device_hdl != -1) {
- pr_err("%s:%d Device is already acquired\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Device is already acquired");
rc = -EINVAL;
goto release_mutex;
}
rc = copy_from_user(&sensor_acq_dev,
(void __user *) cmd->handle, sizeof(sensor_acq_dev));
if (rc < 0) {
- pr_err("Failed Copying from user\n");
+ CAM_ERR(CAM_SENSOR, "Failed Copying from user");
goto release_mutex;
}
@@ -695,11 +489,11 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
s_ctrl->bridge_intf.device_hdl = sensor_acq_dev.device_handle;
s_ctrl->bridge_intf.session_hdl = sensor_acq_dev.session_handle;
- CDBG("%s:%d Device Handle: %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "Device Handle: %d",
sensor_acq_dev.device_handle);
if (copy_to_user((void __user *) cmd->handle, &sensor_acq_dev,
sizeof(struct cam_sensor_acquire_dev))) {
- pr_err("Failed Copy to User\n");
+ CAM_ERR(CAM_SENSOR, "Failed Copy to User");
rc = -EFAULT;
goto release_mutex;
}
@@ -707,8 +501,8 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
break;
case CAM_RELEASE_DEV: {
if (s_ctrl->bridge_intf.device_hdl == -1) {
- pr_err("%s:%d Invalid Handles: link hdl: %d device hdl: %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR,
+ "Invalid Handles: link hdl: %d device hdl: %d",
s_ctrl->bridge_intf.device_hdl,
s_ctrl->bridge_intf.link_hdl);
rc = -EINVAL;
@@ -716,8 +510,8 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
}
rc = cam_destroy_device_hdl(s_ctrl->bridge_intf.device_hdl);
if (rc < 0)
- pr_err("%s:%d Failed in destroying the device hdl\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "failed in destroying the device hdl");
s_ctrl->bridge_intf.device_hdl = -1;
s_ctrl->bridge_intf.link_hdl = -1;
s_ctrl->bridge_intf.session_hdl = -1;
@@ -729,7 +523,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
cam_sensor_query_cap(s_ctrl, &sensor_cap);
if (copy_to_user((void __user *) cmd->handle, &sensor_cap,
sizeof(struct cam_sensor_query_cap))) {
- pr_err("Failed Copy to User\n");
+ CAM_ERR(CAM_SENSOR, "Failed Copy to User");
rc = -EFAULT;
goto release_mutex;
}
@@ -738,19 +532,18 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
case CAM_START_DEV: {
rc = cam_sensor_power_up(s_ctrl);
if (rc < 0) {
- pr_err("%s:%d :Error: Sensor Power up failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Sensor Power up failed");
goto release_mutex;
}
rc = cam_sensor_apply_settings(s_ctrl, 0);
if (rc < 0) {
- pr_err("cannot apply settings\n");
+ CAM_ERR(CAM_SENSOR, "cannot apply settings");
goto release_mutex;
}
rc = delete_request(&s_ctrl->i2c_data.init_settings);
if (rc < 0) {
- pr_err("%s:%d Fail in deleting the Init settings\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "Fail in deleting the Init settings");
rc = -EINVAL;
goto release_mutex;
}
@@ -759,8 +552,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
case CAM_STOP_DEV: {
rc = cam_sensor_power_down(s_ctrl);
if (rc < 0) {
- pr_err("%s:%d Sensor Power Down failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Sensor Power Down failed");
goto release_mutex;
}
}
@@ -768,8 +560,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
case CAM_CONFIG_DEV: {
rc = cam_sensor_i2c_pkt_parse(s_ctrl, arg);
if (rc < 0) {
- pr_err("%s:%d :Error: Failed CCI Config: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "Failed CCI Config: %d", rc);
goto release_mutex;
}
}
@@ -777,8 +568,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
case CAM_SD_SHUTDOWN:
break;
default:
- pr_err("%s:%d :Error: Invalid Opcode: %d\n",
- __func__, __LINE__, cmd->op_code);
+ CAM_ERR(CAM_SENSOR, "Invalid Opcode: %d", cmd->op_code);
rc = -EINVAL;
goto release_mutex;
}
@@ -812,7 +602,7 @@ int cam_sensor_establish_link(struct cam_req_mgr_core_dev_link_setup *link)
s_ctrl = (struct cam_sensor_ctrl_t *)
cam_get_device_priv(link->dev_hdl);
if (!s_ctrl) {
- pr_err("%s: Device data is NULL\n", __func__);
+ CAM_ERR(CAM_SENSOR, "Device data is NULL");
return -EINVAL;
}
if (link->link_enable) {
@@ -849,8 +639,7 @@ int cam_sensor_power_up(struct cam_sensor_ctrl_t *s_ctrl)
&s_ctrl->soc_info;
if (!s_ctrl) {
- pr_err("%s:%d failed: %pK\n",
- __func__, __LINE__, s_ctrl);
+ CAM_ERR(CAM_SENSOR, "failed: %pK", s_ctrl);
return -EINVAL;
}
@@ -858,23 +647,20 @@ int cam_sensor_power_up(struct cam_sensor_ctrl_t *s_ctrl)
slave_info = &(s_ctrl->sensordata->slave_info);
if (!power_info || !slave_info) {
- pr_err("%s:%d failed: %pK %pK\n",
- __func__, __LINE__, power_info,
- slave_info);
+ CAM_ERR(CAM_SENSOR, "failed: %pK %pK", power_info, slave_info);
return -EINVAL;
}
rc = cam_sensor_core_power_up(power_info, soc_info);
if (rc < 0) {
- pr_err("%s:%d power up the core is failed:%d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "power up the core is failed:%d", rc);
return rc;
}
if (s_ctrl->io_master_info.master_type == CCI_MASTER) {
rc = camera_io_init(&(s_ctrl->io_master_info));
if (rc < 0) {
- pr_err("%s cci_init failed\n", __func__);
+ CAM_ERR(CAM_SENSOR, "cci_init failed");
return -EINVAL;
}
}
@@ -891,8 +677,7 @@ int cam_sensor_power_down(struct cam_sensor_ctrl_t *s_ctrl)
int rc = 0;
if (!s_ctrl) {
- pr_err("%s:%d failed: s_ctrl %pK\n",
- __func__, __LINE__, s_ctrl);
+ CAM_ERR(CAM_SENSOR, "failed: s_ctrl %pK", s_ctrl);
return -EINVAL;
}
@@ -900,14 +685,12 @@ int cam_sensor_power_down(struct cam_sensor_ctrl_t *s_ctrl)
soc_info = &s_ctrl->soc_info;
if (!power_info) {
- pr_err("%s:%d failed: power_info %pK\n",
- __func__, __LINE__, power_info);
+ CAM_ERR(CAM_SENSOR, "failed: power_info %pK", power_info);
return -EINVAL;
}
rc = msm_camera_power_down(power_info, soc_info);
if (rc < 0) {
- pr_err("%s:%d power down the core is failed:%d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "power down the core is failed:%d", rc);
return rc;
}
@@ -935,15 +718,16 @@ int cam_sensor_apply_settings(struct cam_sensor_ctrl_t *s_ctrl,
&(s_ctrl->io_master_info),
&(i2c_list->i2c_settings));
if (rc < 0) {
- pr_err("Failed to write the I2C settings\n");
+ CAM_ERR(CAM_SENSOR,
+ "Failed to write the I2C settings");
return rc;
}
}
rc = delete_request(&(s_ctrl->i2c_data.init_settings));
i2c_set->is_settings_valid = 0;
if (rc < 0) {
- pr_err("%s:%d :Error: Failed in deleting the Init request: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "Failed in deleting the Init request: %d", rc);
}
}
} else {
@@ -957,8 +741,9 @@ int cam_sensor_apply_settings(struct cam_sensor_ctrl_t *s_ctrl,
&(s_ctrl->io_master_info),
&(i2c_list->i2c_settings));
if (rc < 0) {
- pr_err("%s:%d :Error: Fail to write the I2C settings: %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "Fail to write the I2C settings: %d",
+ rc);
return rc;
}
}
@@ -966,8 +751,8 @@ int cam_sensor_apply_settings(struct cam_sensor_ctrl_t *s_ctrl,
MAX_PER_FRAME_ARRAY -
MAX_SYSTEM_PIPELINE_DELAY) %
MAX_PER_FRAME_ARRAY;
- CDBG("%s:%d Deleting the Request: %d\n",
- __func__, __LINE__, del_req_id);
+ CAM_DBG(CAM_SENSOR, "Deleting the Request: %d",
+ del_req_id);
if (req_id >
s_ctrl->i2c_data.per_frame[del_req_id].
request_id) {
@@ -977,13 +762,13 @@ int cam_sensor_apply_settings(struct cam_sensor_ctrl_t *s_ctrl,
&(s_ctrl->i2c_data.
per_frame[del_req_id]));
if (rc < 0)
- pr_err("%s:%d :Error: Failed in deleting the request: %d rc: %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR,
+ "Delete request Fail:%d rc:%d",
del_req_id, rc);
}
} else {
- CDBG("%s:%d Invalid/NOP request to apply: %lld\n",
- __func__, __LINE__, req_id);
+ CAM_DBG(CAM_SENSOR,
+ "Invalid/NOP request to apply: %lld", req_id);
}
}
return rc;
@@ -1000,14 +785,11 @@ int32_t cam_sensor_apply_request(struct cam_req_mgr_apply_request *apply)
s_ctrl = (struct cam_sensor_ctrl_t *)
cam_get_device_priv(apply->dev_hdl);
if (!s_ctrl) {
- pr_err("%s: Device data is NULL\n", __func__);
+ CAM_ERR(CAM_SENSOR, "Device data is NULL");
return -EINVAL;
}
- CDBG("%s:%d Req Id: %lld\n", __func__, __LINE__,
- apply->request_id);
-
+ CAM_DBG(CAM_SENSOR, " Req Id: %lld", apply->request_id);
trace_cam_apply_req("Sensor", apply);
-
rc = cam_sensor_apply_settings(s_ctrl, apply->request_id);
return rc;
}
@@ -1025,7 +807,7 @@ int32_t cam_sensor_flush_request(struct cam_req_mgr_flush_request *flush_req)
s_ctrl = (struct cam_sensor_ctrl_t *)
cam_get_device_priv(flush_req->dev_hdl);
if (!s_ctrl) {
- pr_err("%s: Device data is NULL\n", __func__);
+ CAM_ERR(CAM_SENSOR, "Device data is NULL");
return -EINVAL;
}
@@ -1039,8 +821,8 @@ int32_t cam_sensor_flush_request(struct cam_req_mgr_flush_request *flush_req)
if (i2c_set->is_settings_valid == 1) {
rc = delete_request(i2c_set);
if (rc < 0)
- pr_err("%s:%d :Error: delete request: %lld rc: %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR,
+ "delete request: %lld rc: %d",
i2c_set->request_id, rc);
if (flush_req->type ==
@@ -1053,7 +835,8 @@ int32_t cam_sensor_flush_request(struct cam_req_mgr_flush_request *flush_req)
if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ &&
!cancel_req_id_found)
- CDBG("%s:Flush request id:%lld not found in the pending list\n",
- __func__, flush_req->req_id);
+ CAM_DBG(CAM_SENSOR,
+ "Flush request id:%lld not found in the pending list",
+ flush_req->req_id);
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.c
index c06a1b3..1453fb3 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.c
@@ -27,8 +27,7 @@ static long cam_sensor_subdev_ioctl(struct v4l2_subdev *sd,
rc = cam_sensor_driver_cmd(s_ctrl, arg);
break;
default:
- pr_err("%s:%d Invalid ioctl cmd: %d\n",
- __func__, __LINE__, cmd);
+ CAM_ERR(CAM_SENSOR, " Invalid ioctl cmd: %d", cmd);
rc = -EINVAL;
break;
}
@@ -42,8 +41,8 @@ static int32_t cam_sensor_driver_i2c_probe(struct i2c_client *client,
struct cam_sensor_ctrl_t *s_ctrl;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
- pr_err("%s %s :Error: i2c_check_functionality failed\n",
- __func__, client->name);
+ CAM_ERR(CAM_SENSOR,
+ "%s :i2c_check_functionality failed", client->name);
return -EFAULT;
}
@@ -60,8 +59,7 @@ static int32_t cam_sensor_driver_i2c_probe(struct i2c_client *client,
rc = cam_sensor_parse_dt(s_ctrl);
if (rc < 0) {
- pr_err("%s:%d :Error: cam_sensor_parse_dt rc %d",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "cam_sensor_parse_dt rc %d", rc);
goto free_s_ctrl;
}
@@ -77,7 +75,7 @@ static int cam_sensor_platform_remove(struct platform_device *pdev)
s_ctrl = platform_get_drvdata(pdev);
if (!s_ctrl) {
- pr_err("%s: sensor device is NULL\n", __func__);
+ CAM_ERR(CAM_SENSOR, "sensor device is NULL");
return 0;
}
@@ -92,7 +90,7 @@ static int cam_sensor_driver_i2c_remove(struct i2c_client *client)
struct cam_sensor_ctrl_t *s_ctrl = i2c_get_clientdata(client);
if (!s_ctrl) {
- pr_err("%s: sensor device is NULL\n", __func__);
+ CAM_ERR(CAM_SENSOR, "sensor device is NULL");
return 0;
}
@@ -111,7 +109,7 @@ static long cam_sensor_init_subdev_do_ioctl(struct v4l2_subdev *sd,
if (copy_from_user(&cmd_data, (void __user *)arg,
sizeof(cmd_data))) {
- pr_err("Failed to copy from user_ptr=%pK size=%zu\n",
+ CAM_ERR(CAM_SENSOR, "Failed to copy from user_ptr=%pK size=%zu",
(void __user *)arg, sizeof(cmd_data));
return -EFAULT;
}
@@ -120,19 +118,18 @@ static long cam_sensor_init_subdev_do_ioctl(struct v4l2_subdev *sd,
case VIDIOC_CAM_CONTROL:
rc = cam_sensor_subdev_ioctl(sd, cmd, &cmd_data);
if (rc < 0)
- pr_err("%s:%d cam_sensor_subdev_ioctl failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "cam_sensor_subdev_ioctl failed");
break;
default:
- pr_err("%s:%d Invalid compat ioctl cmd_type: %d\n",
- __func__, __LINE__, cmd);
+ CAM_ERR(CAM_SENSOR, "Invalid compat ioctl cmd_type: %d", cmd);
rc = -EINVAL;
}
if (!rc) {
if (copy_to_user((void __user *)arg, &cmd_data,
sizeof(cmd_data))) {
- pr_err("Failed to copy to user_ptr=%pK size=%zu\n",
+ CAM_ERR(CAM_SENSOR,
+ "Failed to copy to user_ptr=%pK size=%zu",
(void __user *)arg, sizeof(cmd_data));
rc = -EFAULT;
}
@@ -188,7 +185,7 @@ static int32_t cam_sensor_driver_platform_probe(
rc = cam_sensor_parse_dt(s_ctrl);
if (rc < 0) {
- pr_err("failed: cam_sensor_parse_dt rc %d", rc);
+ CAM_ERR(CAM_SENSOR, "failed: cam_sensor_parse_dt rc %d", rc);
goto free_s_ctrl;
}
@@ -211,8 +208,7 @@ static int32_t cam_sensor_driver_platform_probe(
rc = cam_register_subdev(&(s_ctrl->v4l2_dev_str));
if (rc < 0) {
- pr_err("%s:%d :ERROR: Fail with cam_register_subdev\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Fail with cam_register_subdev");
goto free_s_ctrl;
}
@@ -278,11 +274,11 @@ static int __init cam_sensor_driver_init(void)
rc = platform_driver_register(&cam_sensor_platform_driver);
if (rc)
- pr_err("%s platform_driver_register failed rc = %d",
- __func__, rc);
+ CAM_ERR(CAM_SENSOR, "platform_driver_register failed rc = %d",
+ rc);
rc = i2c_add_driver(&cam_sensor_driver_i2c);
if (rc)
- pr_err("%s i2c_add_driver failed rc = %d", __func__, rc);
+ CAM_ERR(CAM_SENSOR, "i2c_add_driver failed rc = %d", rc);
return rc;
}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.h
index ae14c9d..f3c70c4 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_dev.h
@@ -31,6 +31,7 @@
#include <cam_sensor_cmn_header.h>
#include <cam_subdev.h>
#include <cam_sensor_io.h>
+#include "cam_debug_util.h"
#define NUM_MASTERS 2
#define NUM_QUEUES 2
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_soc.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_soc.c
index 78edec1..c2f1b4d 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_soc.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor/cam_sensor_soc.c
@@ -34,13 +34,12 @@ int32_t cam_sensor_get_sub_module_index(struct device_node *of_node,
src_node = of_parse_phandle(of_node, "actuator-src", 0);
if (!src_node) {
- CDBG("%s:%d src_node NULL\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "src_node NULL");
} else {
rc = of_property_read_u32(src_node, "cell-index", &val);
- CDBG("%s:%d actuator cell index %d, rc %d\n", __func__,
- __LINE__, val, rc);
+ CAM_DBG(CAM_SENSOR, "actuator cell index %d, rc %d", val, rc);
if (rc < 0) {
- pr_err("%s:%d failed %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "failed %d", rc);
of_node_put(src_node);
return rc;
}
@@ -50,13 +49,12 @@ int32_t cam_sensor_get_sub_module_index(struct device_node *of_node,
src_node = of_parse_phandle(of_node, "ois-src", 0);
if (!src_node) {
- CDBG("%s:%d src_node NULL\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "src_node NULL");
} else {
rc = of_property_read_u32(src_node, "cell-index", &val);
- CDBG("%s:%d ois cell index %d, rc %d\n", __func__, __LINE__,
- val, rc);
+ CAM_DBG(CAM_SENSOR, " ois cell index %d, rc %d", val, rc);
if (rc < 0) {
- pr_err("%s:%d failed %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "failed %d", rc);
of_node_put(src_node);
return rc;
}
@@ -66,13 +64,12 @@ int32_t cam_sensor_get_sub_module_index(struct device_node *of_node,
src_node = of_parse_phandle(of_node, "eeprom-src", 0);
if (!src_node) {
- CDBG("%s:%d eeprom src_node NULL\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "eeprom src_node NULL");
} else {
rc = of_property_read_u32(src_node, "cell-index", &val);
- CDBG("%s:%d eeprom cell index %d, rc %d\n", __func__, __LINE__,
- val, rc);
+ CAM_DBG(CAM_SENSOR, "eeprom cell index %d, rc %d", val, rc);
if (rc < 0) {
- pr_err("%s:%d failed %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "failed %d", rc);
of_node_put(src_node);
return rc;
}
@@ -82,13 +79,12 @@ int32_t cam_sensor_get_sub_module_index(struct device_node *of_node,
src_node = of_parse_phandle(of_node, "led-flash-src", 0);
if (!src_node) {
- CDBG("%s:%d src_node NULL\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, " src_node NULL");
} else {
rc = of_property_read_u32(src_node, "cell-index", &val);
- CDBG("%s:%d led flash cell index %d, rc %d\n", __func__,
- __LINE__, val, rc);
+ CAM_DBG(CAM_SENSOR, "led flash cell index %d, rc %d", val, rc);
if (rc < 0) {
- pr_err("%s:%d failed %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "failed %d", rc);
of_node_put(src_node);
return rc;
}
@@ -98,8 +94,7 @@ int32_t cam_sensor_get_sub_module_index(struct device_node *of_node,
rc = of_property_read_u32(of_node, "csiphy-sd-index", &val);
if (rc < 0)
- pr_err("%s:%d :Error: paring the dt node for csiphy rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "paring the dt node for csiphy rc %d", rc);
else
sensor_info->subdev_id[SUB_MODULE_CSIPHY] = val;
@@ -120,15 +115,14 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl)
rc = cam_soc_util_get_dt_properties(soc_info);
if (rc < 0) {
- pr_err("%s:%d Failed to read DT properties rc %d",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "Failed to read DT properties rc %d", rc);
goto FREE_SENSOR_DATA;
}
rc = cam_sensor_util_init_gpio_pin_tbl(soc_info,
&sensordata->power_info.gpio_num_info);
if (rc < 0) {
- pr_err("%s:%d Failed to read gpios %d", __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "Failed to read gpios %d", rc);
goto FREE_SENSOR_DATA;
}
@@ -136,8 +130,7 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl)
/* Validate cell_id */
if (s_ctrl->id >= MAX_CAMERAS) {
- pr_err("%s:%d Failed invalid cell_id %d", __func__, __LINE__,
- s_ctrl->id);
+ CAM_ERR(CAM_SENSOR, "Failed invalid cell_id %d", s_ctrl->id);
rc = -EINVAL;
goto FREE_SENSOR_DATA;
}
@@ -145,16 +138,15 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl)
/* Read subdev info */
rc = cam_sensor_get_sub_module_index(of_node, sensordata);
if (rc < 0) {
- pr_err("%s:%d failed to get sub module index, rc=%d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "failed to get sub module index, rc=%d",
+ rc);
goto FREE_SENSOR_DATA;
}
/* Get CCI master */
rc = of_property_read_u32(of_node, "cci-master",
&s_ctrl->cci_i2c_master);
- CDBG("%s:%d cci-master %d, rc %d", __func__, __LINE__,
- s_ctrl->cci_i2c_master, rc);
+ CAM_DBG(CAM_SENSOR, "cci-master %d, rc %d", s_ctrl->cci_i2c_master, rc);
if (rc < 0) {
/* Set default master 0 */
s_ctrl->cci_i2c_master = MASTER_0;
@@ -163,17 +155,17 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl)
if (of_property_read_u32(of_node, "sensor-position-pitch",
&sensordata->pos_pitch) < 0) {
- CDBG("%s:%d Invalid sensor position\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "Invalid sensor position");
sensordata->pos_pitch = 360;
}
if (of_property_read_u32(of_node, "sensor-position-roll",
&sensordata->pos_roll) < 0) {
- CDBG("%s:%d Invalid sensor position\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "Invalid sensor position");
sensordata->pos_roll = 360;
}
if (of_property_read_u32(of_node, "sensor-position-yaw",
&sensordata->pos_yaw) < 0) {
- CDBG("%s:%d Invalid sensor position\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "Invalid sensor position");
sensordata->pos_yaw = 360;
}
@@ -188,13 +180,13 @@ int32_t msm_sensor_init_default_params(struct cam_sensor_ctrl_t *s_ctrl)
{
/* Validate input parameters */
if (!s_ctrl) {
- pr_err("%s:%d failed: invalid params s_ctrl %pK\n", __func__,
- __LINE__, s_ctrl);
+ CAM_ERR(CAM_SENSOR, "failed: invalid params s_ctrl %pK",
+ s_ctrl);
return -EINVAL;
}
- CDBG("%s: %d master_type: %d\n", __func__, __LINE__,
- s_ctrl->io_master_info.master_type);
+ CAM_DBG(CAM_SENSOR,
+ "master_type: %d", s_ctrl->io_master_info.master_type);
/* Initialize cci_client */
if (s_ctrl->io_master_info.master_type == CCI_MASTER) {
s_ctrl->io_master_info.cci_client = kzalloc(sizeof(
@@ -203,8 +195,8 @@ int32_t msm_sensor_init_default_params(struct cam_sensor_ctrl_t *s_ctrl)
return -ENOMEM;
} else {
- pr_err("%s:%d Invalid master / Master type Not supported\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "Invalid master / Master type Not supported");
return -EINVAL;
}
@@ -219,30 +211,29 @@ int32_t cam_sensor_parse_dt(struct cam_sensor_ctrl_t *s_ctrl)
/* Parse dt information and store in sensor control structure */
rc = cam_sensor_driver_get_dt_data(s_ctrl);
if (rc < 0) {
- pr_err("%s:%d Failed to get dt data rc %d", __func__, __LINE__,
- rc);
+ CAM_ERR(CAM_SENSOR, "Failed to get dt data rc %d", rc);
return rc;
}
/* Initialize mutex */
mutex_init(&(s_ctrl->cam_sensor_mutex));
- CDBG("%s: %d\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "%s: %d");
/* Initialize default parameters */
for (i = 0; i < soc_info->num_clk; i++) {
soc_info->clk[i] = devm_clk_get(&soc_info->pdev->dev,
soc_info->clk_name[i]);
if (!soc_info->clk[i]) {
- pr_err("%s:%d get failed for %s\n",
- __func__, __LINE__, soc_info->clk_name[i]);
+ CAM_ERR(CAM_SENSOR, "get failed for %s",
+ soc_info->clk_name[i]);
rc = -ENOENT;
return rc;
}
}
rc = msm_sensor_init_default_params(s_ctrl);
if (rc < 0) {
- pr_err("%s;%d failed: msm_sensor_init_default_params rc %d",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "failed: msm_sensor_init_default_params rc %d", rc);
goto FREE_DT_DATA;
}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/Makefile b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/Makefile
index 4c3b8e8..6a0a0e1 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/Makefile
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/Makefile
@@ -6,4 +6,4 @@
ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr
ccflags-y += -Idrivers/media/platform/msm/camera/cam_smmu/
-obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor_io.o cam_sensor_cci_i2c.o cam_sensor_qup_i2c.o
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor_io.o cam_sensor_cci_i2c.o cam_sensor_qup_i2c.o cam_sensor_spi.o
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c
index 40a69ef..915e2f7 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c
@@ -14,9 +14,6 @@
#include "cam_sensor_i2c.h"
#include "cam_cci_dev.h"
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-
int32_t cam_cci_i2c_read(struct cam_sensor_cci_client *cci_client,
uint32_t addr, uint32_t *data,
enum camera_sensor_i2c_type addr_type,
@@ -41,9 +38,10 @@ int32_t cam_cci_i2c_read(struct cam_sensor_cci_client *cci_client,
rc = v4l2_subdev_call(cci_client->cci_subdev,
core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl);
if (rc < 0) {
- pr_err("%s: line %d rc = %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "line %d rc = %d", rc);
return rc;
}
+
rc = cci_ctrl.status;
if (data_type == CAMERA_SENSOR_I2C_TYPE_BYTE)
*data = buf[0];
@@ -58,6 +56,46 @@ int32_t cam_cci_i2c_read(struct cam_sensor_cci_client *cci_client,
return rc;
}
+int32_t cam_camera_cci_i2c_read_seq(struct cam_sensor_cci_client *cci_client,
+ uint32_t addr, uint8_t *data,
+ enum camera_sensor_i2c_type addr_type,
+ uint32_t num_byte)
+{
+ int32_t rc = -EFAULT;
+ unsigned char *buf = NULL;
+ int i = 0;
+ struct cam_cci_ctrl cci_ctrl;
+
+ if ((addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX)
+ || (num_byte > I2C_REG_DATA_MAX)) {
+ CAM_ERR(CAM_SENSOR, "addr_type %d num_byte %d", addr_type,
+ num_byte);
+ return rc;
+ }
+
+ buf = kzalloc(num_byte, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ cci_ctrl.cmd = MSM_CCI_I2C_READ;
+ cci_ctrl.cci_info = cci_client;
+ cci_ctrl.cfg.cci_i2c_read_cfg.addr = addr;
+ cci_ctrl.cfg.cci_i2c_read_cfg.addr_type = addr_type;
+ cci_ctrl.cfg.cci_i2c_read_cfg.data = buf;
+ cci_ctrl.cfg.cci_i2c_read_cfg.num_byte = num_byte;
+ cci_ctrl.status = -EFAULT;
+ rc = v4l2_subdev_call(cci_client->cci_subdev,
+ core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl);
+ rc = cci_ctrl.status;
+ CAM_DBG(CAM_SENSOR, "addr = 0x%x, rc = %d", addr, rc);
+ for (i = 0; i < num_byte; i++) {
+ data[i] = buf[i];
+ CAM_DBG(CAM_SENSOR, "Byte %d: Data: 0x%x\n", i, data[i]);
+ }
+ kfree(buf);
+ return rc;
+}
+
static int32_t cam_cci_i2c_write_table_cmd(
struct camera_io_master *client,
struct cam_sensor_i2c_reg_setting *write_setting,
@@ -85,7 +123,7 @@ static int32_t cam_cci_i2c_write_table_cmd(
rc = v4l2_subdev_call(client->cci_client->cci_subdev,
core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl);
if (rc < 0) {
- pr_err("%s: line %d rc = %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "Failed rc = %d", rc);
return rc;
}
rc = cci_ctrl.status;
@@ -135,12 +173,12 @@ int32_t cam_cci_i2c_poll(struct cam_sensor_cci_client *client,
int32_t rc = -EINVAL;
int32_t i = 0;
- CDBG("%s: addr: 0x%x data: 0x%x dt: %d\n",
- __func__, addr, data, data_type);
+ CAM_DBG(CAM_SENSOR, "addr: 0x%x data: 0x%x dt: %d",
+ addr, data, data_type);
if (delay_ms > MAX_POLL_DELAY_MS) {
- pr_err("%s:%d invalid delay = %d max_delay = %d\n",
- __func__, __LINE__, delay_ms, MAX_POLL_DELAY_MS);
+ CAM_ERR(CAM_SENSOR, "invalid delay = %d max_delay = %d",
+ delay_ms, MAX_POLL_DELAY_MS);
return -EINVAL;
}
for (i = 0; i < delay_ms; i++) {
@@ -154,11 +192,10 @@ int32_t cam_cci_i2c_poll(struct cam_sensor_cci_client *client,
/* If rc is 1 then read is successful but poll is failure */
if (rc == 1)
- pr_err("%s:%d poll failed rc=%d(non-fatal)\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "poll failed rc=%d(non-fatal)", rc);
if (rc < 0)
- pr_err("%s:%d poll failed rc=%d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "poll failed rc=%d", rc);
return rc;
}
@@ -169,13 +206,13 @@ int32_t cam_sensor_cci_i2c_util(struct cam_sensor_cci_client *cci_client,
int32_t rc = 0;
struct cam_cci_ctrl cci_ctrl;
- CDBG("%s line %d\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "%s line %d");
cci_ctrl.cmd = cci_cmd;
cci_ctrl.cci_info = cci_client;
rc = v4l2_subdev_call(cci_client->cci_subdev,
core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl);
if (rc < 0) {
- pr_err("%s line %d rc = %d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "Failed rc = %d", rc);
return rc;
}
return cci_ctrl.status;
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h
index 06e8104..6207a8a 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h
@@ -26,6 +26,8 @@
#define I2C_COMPARE_MATCH 0
#define I2C_COMPARE_MISMATCH 1
+#define I2C_REG_DATA_MAX (8*1024)
+
/**
* @client: CCI client structure
* @data: I2C data
@@ -41,6 +43,20 @@ int32_t cam_cci_i2c_read(struct cam_sensor_cci_client *client,
/**
* @client: CCI client structure
+ * @addr: I2c address
+ * @data: I2C data
+ * @addr_type: I2c address type
+ * @num_byte: number of bytes
+ *
+ * This API handles CCI sequential read
+ */
+int32_t cam_camera_cci_i2c_read_seq(struct cam_sensor_cci_client *client,
+ uint32_t addr, uint8_t *data,
+ enum camera_sensor_i2c_type addr_type,
+ uint32_t num_byte);
+
+/**
+ * @client: CCI client structure
* @cci_cmd: CCI command type
*
* This API handles CCI random write
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.c
index 3e1b331..9e38e1a 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.c
@@ -10,9 +10,14 @@
* GNU General Public License for more details.
*/
+#define pr_fmt(fmt) "CAM-SENSOR_IO %s:%d " fmt, __func__, __LINE__
+
#include "cam_sensor_io.h"
#include "cam_sensor_i2c.h"
+#undef CDBG
+#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+
int32_t camera_io_dev_poll(struct camera_io_master *io_master_info,
uint32_t addr, uint16_t data, uint32_t data_mask,
enum camera_sensor_i2c_type data_type,
@@ -22,7 +27,7 @@ int32_t camera_io_dev_poll(struct camera_io_master *io_master_info,
int16_t mask = data_mask & 0xFF;
if (!io_master_info) {
- pr_err("%s:%d Invalid Args\n", __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Invalid Args");
return -EINVAL;
}
@@ -34,8 +39,8 @@ int32_t camera_io_dev_poll(struct camera_io_master *io_master_info,
addr, data, data_mask, addr_type, data_type,
delay_ms);
} else {
- pr_err("%s:%d Invalid Comm. Master:%d\n", __func__,
- __LINE__, io_master_info->master_type);
+ CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
+ io_master_info->master_type);
return -EINVAL;
}
}
@@ -46,7 +51,7 @@ int32_t camera_io_dev_read(struct camera_io_master *io_master_info,
enum camera_sensor_i2c_type data_type)
{
if (!io_master_info) {
- pr_err("%s:%d Invalid Args\n", __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Invalid Args");
return -EINVAL;
}
@@ -56,18 +61,44 @@ int32_t camera_io_dev_read(struct camera_io_master *io_master_info,
} else if (io_master_info->master_type == I2C_MASTER) {
return cam_qup_i2c_read(io_master_info->client,
addr, data, addr_type, data_type);
+ } else if (io_master_info->master_type == SPI_MASTER) {
+ return cam_spi_read(io_master_info,
+ addr, data, addr_type);
} else {
- pr_err("%s:%d Invalid Comm. Master:%d\n", __func__,
- __LINE__, io_master_info->master_type);
+ CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
+ io_master_info->master_type);
return -EINVAL;
}
+ return 0;
+}
+
+int32_t camera_io_dev_read_seq(struct camera_io_master *io_master_info,
+ uint32_t addr, uint8_t *data,
+ enum camera_sensor_i2c_type addr_type, int32_t num_bytes)
+{
+ if (io_master_info->master_type == CCI_MASTER) {
+ return cam_camera_cci_i2c_read_seq(io_master_info->cci_client,
+ addr, data, addr_type, num_bytes);
+ } else if (io_master_info->master_type == I2C_MASTER) {
+ return cam_qup_i2c_read_seq(io_master_info->client,
+ addr, data, addr_type, num_bytes);
+ } else if (io_master_info->master_type == SPI_MASTER) {
+ return cam_spi_read(io_master_info,
+ addr, (uint32_t *)data, addr_type);
+ } else {
+ CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
+ io_master_info->master_type);
+ return -EINVAL;
+ }
+ return 0;
}
int32_t camera_io_dev_write(struct camera_io_master *io_master_info,
struct cam_sensor_i2c_reg_setting *write_setting)
{
if (!write_setting || !io_master_info) {
- pr_err("Input parameters not valid ws: %pK ioinfo: %pK",
+ CAM_ERR(CAM_SENSOR,
+ "Input parameters not valid ws: %pK ioinfo: %pK",
write_setting, io_master_info);
return -EINVAL;
}
@@ -79,8 +110,8 @@ int32_t camera_io_dev_write(struct camera_io_master *io_master_info,
return cam_qup_i2c_write_table(io_master_info,
write_setting);
} else {
- pr_err("%s:%d Invalid Comm. Master:%d\n", __func__,
- __LINE__, io_master_info->master_type);
+ CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
+ io_master_info->master_type);
return -EINVAL;
}
}
@@ -88,7 +119,7 @@ int32_t camera_io_dev_write(struct camera_io_master *io_master_info,
int32_t camera_io_init(struct camera_io_master *io_master_info)
{
if (!io_master_info) {
- pr_err("%s:%d Invalid Args\n", __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Invalid Args");
return -EINVAL;
}
@@ -98,8 +129,8 @@ int32_t camera_io_init(struct camera_io_master *io_master_info)
return cam_sensor_cci_i2c_util(io_master_info->cci_client,
MSM_CCI_INIT);
} else {
- pr_err("%s:%d Invalid Comm. Master:%d\n", __func__,
- __LINE__, io_master_info->master_type);
+ CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
+ io_master_info->master_type);
return -EINVAL;
}
}
@@ -107,7 +138,7 @@ int32_t camera_io_init(struct camera_io_master *io_master_info)
int32_t camera_io_release(struct camera_io_master *io_master_info)
{
if (!io_master_info) {
- pr_err("%s:%d Invalid Args\n", __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Invalid Args");
return -EINVAL;
}
@@ -115,8 +146,8 @@ int32_t camera_io_release(struct camera_io_master *io_master_info)
return cam_sensor_cci_i2c_util(io_master_info->cci_client,
MSM_CCI_RELEASE);
} else {
- pr_err("%s:%d Invalid Comm. Master:%d\n", __func__,
- __LINE__, io_master_info->master_type);
+ CAM_ERR(CAM_SENSOR, "Invalid Comm. Master:%d",
+ io_master_info->master_type);
return -EINVAL;
}
}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.h
index f721afd..9a60fd0e 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_io.h
@@ -52,16 +52,15 @@ int32_t camera_io_dev_read(struct camera_io_master *io_master_info,
* @io_master_info: I2C/SPI master information
* @addr: I2C address
* @data: I2C data
- * @addr_type: I2C addr type
+ * @data_type: I2C data type
* @num_bytes: number of bytes
*
- * This API abstracts sequential read functionality based on master type
+ * This API abstracts read functionality based on master type
*/
int32_t camera_io_dev_read_seq(struct camera_io_master *io_master_info,
uint32_t addr, uint8_t *data,
enum camera_sensor_i2c_type addr_type,
- uint32_t num_bytes);
-
+ int32_t num_bytes);
/**
* @io_master_info: I2C/SPI master information
@@ -103,4 +102,6 @@ int32_t camera_io_dev_poll(struct camera_io_master *io_master_info,
enum camera_sensor_i2c_type addr_type,
uint32_t delay_ms);
+#include "cam_sensor_i2c.h"
+#include "cam_sensor_spi.h"
#endif /* _CAM_SENSOR_IO_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_qup_i2c.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_qup_i2c.c
index b25b1855..b64e0d0 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_qup_i2c.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_qup_i2c.c
@@ -40,7 +40,7 @@ static int32_t cam_qup_i2c_rxdata(
};
rc = i2c_transfer(dev_client->adapter, msgs, 2);
if (rc < 0)
- pr_err("%s:failed 0x%x\n", __func__, saddr);
+ CAM_ERR(CAM_SENSOR, "%s:failed 0x%x", saddr);
return rc;
}
@@ -61,7 +61,7 @@ static int32_t cam_qup_i2c_txdata(
};
rc = i2c_transfer(dev_client->client->adapter, msg, 1);
if (rc < 0)
- pr_err("%s: failed 0x%x\n", __func__, saddr);
+ CAM_ERR(CAM_SENSOR, "failed 0x%x", saddr);
return rc;
}
@@ -77,8 +77,7 @@ int32_t cam_qup_i2c_read(struct i2c_client *client,
|| addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX
|| data_type <= CAMERA_SENSOR_I2C_TYPE_INVALID
|| data_type >= CAMERA_SENSOR_I2C_TYPE_MAX) {
- pr_err("ERR: %s Failed with addr/data_type verfication\n",
- __func__);
+ CAM_ERR(CAM_SENSOR, "Failed with addr/data_type verfication");
return rc;
}
@@ -105,7 +104,7 @@ int32_t cam_qup_i2c_read(struct i2c_client *client,
rc = cam_qup_i2c_rxdata(client, buf, addr_type, data_type);
if (rc < 0) {
- pr_err("%s fail\n", __func__);
+ CAM_ERR(CAM_SENSOR, "failed rc: %d", rc);
goto read_fail;
}
@@ -119,7 +118,7 @@ int32_t cam_qup_i2c_read(struct i2c_client *client,
*data = buf[0] << 24 | buf[1] << 16 |
buf[2] << 8 | buf[3];
- CDBG("%s addr = 0x%x data: 0x%x\n", __func__, addr, *data);
+ CAM_DBG(CAM_SENSOR, "addr = 0x%x data: 0x%x", addr, *data);
read_fail:
kfree(buf);
buf = NULL;
@@ -137,14 +136,13 @@ int32_t cam_qup_i2c_read_seq(struct i2c_client *client,
if (addr_type <= CAMERA_SENSOR_I2C_TYPE_INVALID
|| addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX) {
- pr_err("ERR: %s Failed with addr_type verification\n",
- __func__);
+ CAM_ERR(CAM_SENSOR, "Failed with addr_type verification");
return rc;
}
if ((num_byte == 0) || (num_byte > I2C_REG_DATA_MAX)) {
- pr_err("%s: Error num_byte:0x%x max supported:0x%x\n",
- __func__, num_byte, I2C_REG_DATA_MAX);
+ CAM_ERR(CAM_SENSOR, "num_byte:0x%x max supported:0x%x",
+ num_byte, I2C_REG_DATA_MAX);
return rc;
}
@@ -170,7 +168,7 @@ int32_t cam_qup_i2c_read_seq(struct i2c_client *client,
rc = cam_qup_i2c_rxdata(client, buf, addr_type, num_byte);
if (rc < 0) {
- pr_err("%s fail\n", __func__);
+ CAM_ERR(CAM_SENSOR, "failed rc: %d", rc);
goto read_seq_fail;
}
@@ -213,8 +211,8 @@ int32_t cam_qup_i2c_poll(struct i2c_client *client,
int i = 0;
if ((delay_ms > MAX_POLL_DELAY_MS) || (delay_ms == 0)) {
- pr_err("%s:%d invalid delay = %d max_delay = %d\n",
- __func__, __LINE__, delay_ms, MAX_POLL_DELAY_MS);
+ CAM_ERR(CAM_SENSOR, "invalid delay = %d max_delay = %d",
+ delay_ms, MAX_POLL_DELAY_MS);
return -EINVAL;
}
@@ -234,10 +232,9 @@ int32_t cam_qup_i2c_poll(struct i2c_client *client,
}
/* If rc is MISMATCH then read is successful but poll is failure */
if (rc == I2C_COMPARE_MISMATCH)
- pr_err("%s:%d poll failed rc=%d(non-fatal)\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "poll failed rc=%d(non-fatal)", rc);
if (rc < 0)
- pr_err("%s:%d poll failed rc=%d\n", __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "poll failed rc=%d", rc);
return rc;
}
@@ -251,20 +248,17 @@ static int32_t cam_qup_i2c_write(struct camera_io_master *client,
unsigned char buf[I2C_REG_MAX_BUF_SIZE];
uint8_t len = 0;
- CDBG("%s reg addr = 0x%x data type: %d\n",
- __func__, reg_setting->reg_addr, data_type);
+ CAM_DBG(CAM_SENSOR, "reg addr = 0x%x data type: %d",
+ reg_setting->reg_addr, data_type);
if (addr_type == CAMERA_SENSOR_I2C_TYPE_BYTE) {
buf[0] = reg_setting->reg_addr;
- CDBG("%s byte %d: 0x%x\n", __func__,
- len, buf[len]);
+ CAM_DBG(CAM_SENSOR, "byte %d: 0x%x", len, buf[len]);
len = 1;
} else if (addr_type == CAMERA_SENSOR_I2C_TYPE_WORD) {
buf[0] = reg_setting->reg_addr >> 8;
buf[1] = reg_setting->reg_addr;
- CDBG("%s byte %d: 0x%x\n", __func__,
- len, buf[len]);
- CDBG("%s byte %d: 0x%x\n", __func__,
- len+1, buf[len+1]);
+ CAM_DBG(CAM_SENSOR, "byte %d: 0x%x", len, buf[len]);
+ CAM_DBG(CAM_SENSOR, "byte %d: 0x%x", len+1, buf[len+1]);
len = 2;
} else if (addr_type == CAMERA_SENSOR_I2C_TYPE_3B) {
buf[0] = reg_setting->reg_addr >> 16;
@@ -278,47 +272,47 @@ static int32_t cam_qup_i2c_write(struct camera_io_master *client,
buf[3] = reg_setting->reg_addr;
len = 4;
} else {
- pr_err("%s: Invalid I2C addr type\n", __func__);
+ CAM_ERR(CAM_SENSOR, "Invalid I2C addr type");
return -EINVAL;
}
- CDBG("Data: 0x%x\n", reg_setting->reg_data);
+ CAM_DBG(CAM_SENSOR, "Data: 0x%x", reg_setting->reg_data);
if (data_type == CAMERA_SENSOR_I2C_TYPE_BYTE) {
buf[len] = reg_setting->reg_data;
- CDBG("Byte %d: 0x%x\n", len, buf[len]);
+ CAM_DBG(CAM_SENSOR, "Byte %d: 0x%x", len, buf[len]);
len += 1;
} else if (data_type == CAMERA_SENSOR_I2C_TYPE_WORD) {
buf[len] = reg_setting->reg_data >> 8;
buf[len+1] = reg_setting->reg_data;
- CDBG("Byte %d: 0x%x\n", len, buf[len]);
- CDBG("Byte %d: 0x%x\n", len+1, buf[len+1]);
+ CAM_DBG(CAM_SENSOR, "Byte %d: 0x%x", len, buf[len]);
+ CAM_DBG(CAM_SENSOR, "Byte %d: 0x%x", len+1, buf[len+1]);
len += 2;
} else if (data_type == CAMERA_SENSOR_I2C_TYPE_3B) {
buf[len] = reg_setting->reg_data >> 16;
buf[len + 1] = reg_setting->reg_data >> 8;
buf[len + 2] = reg_setting->reg_data;
- CDBG("Byte %d: 0x%x\n", len, buf[len]);
- CDBG("Byte %d: 0x%x\n", len+1, buf[len+1]);
- CDBG("Byte %d: 0x%x\n", len+2, buf[len+2]);
+ CAM_DBG(CAM_SENSOR, "Byte %d: 0x%x", len, buf[len]);
+ CAM_DBG(CAM_SENSOR, "Byte %d: 0x%x", len+1, buf[len+1]);
+ CAM_DBG(CAM_SENSOR, "Byte %d: 0x%x", len+2, buf[len+2]);
len += 3;
} else if (data_type == CAMERA_SENSOR_I2C_TYPE_DWORD) {
buf[len] = reg_setting->reg_data >> 24;
buf[len + 1] = reg_setting->reg_data >> 16;
buf[len + 2] = reg_setting->reg_data >> 8;
buf[len + 3] = reg_setting->reg_data;
- CDBG("Byte %d: 0x%x\n", len, buf[len]);
- CDBG("Byte %d: 0x%x\n", len+1, buf[len+1]);
- CDBG("Byte %d: 0x%x\n", len+2, buf[len+2]);
- CDBG("Byte %d: 0x%x\n", len+3, buf[len+3]);
+ CAM_DBG(CAM_SENSOR, "Byte %d: 0x%x", len, buf[len]);
+ CAM_DBG(CAM_SENSOR, "Byte %d: 0x%x", len+1, buf[len+1]);
+ CAM_DBG(CAM_SENSOR, "Byte %d: 0x%x", len+2, buf[len+2]);
+ CAM_DBG(CAM_SENSOR, "Byte %d: 0x%x", len+3, buf[len+3]);
len += 4;
} else {
- pr_err("%s: Invalid Data Type\n", __func__);
+ CAM_ERR(CAM_SENSOR, "Invalid Data Type");
return -EINVAL;
}
rc = cam_qup_i2c_txdata(client, buf, len);
if (rc < 0)
- pr_err("%s fail\n", __func__);
+ CAM_ERR(CAM_SENSOR, "failed rc: %d", rc);
return rc;
}
@@ -341,7 +335,7 @@ int32_t cam_qup_i2c_write_table(struct camera_io_master *client,
reg_setting = write_setting->reg_setting;
for (i = 0; i < write_setting->size; i++) {
- CDBG("%s addr 0x%x data 0x%x\n", __func__,
+ CAM_DBG(CAM_SENSOR, "addr 0x%x data 0x%x",
reg_setting->reg_addr, reg_setting->reg_data);
rc = cam_qup_i2c_write(client, reg_setting,
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c
new file mode 100644
index 0000000..e0b737e
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c
@@ -0,0 +1,469 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT 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 "cam_sensor_spi.h"
+#include "cam_debug_util.h"
+
+static int cam_spi_txfr(struct spi_device *spi, char *txbuf,
+ char *rxbuf, int num_byte)
+{
+ struct spi_transfer txfr;
+ struct spi_message msg;
+
+ memset(&txfr, 0, sizeof(txfr));
+ txfr.tx_buf = txbuf;
+ txfr.rx_buf = rxbuf;
+ txfr.len = num_byte;
+ spi_message_init(&msg);
+ spi_message_add_tail(&txfr, &msg);
+
+ return spi_sync(spi, &msg);
+}
+
+static int cam_spi_txfr_read(struct spi_device *spi, char *txbuf,
+ char *rxbuf, int txlen, int rxlen)
+{
+ struct spi_transfer tx;
+ struct spi_transfer rx;
+ struct spi_message m;
+
+ memset(&tx, 0, sizeof(tx));
+ memset(&rx, 0, sizeof(rx));
+ tx.tx_buf = txbuf;
+ rx.rx_buf = rxbuf;
+ tx.len = txlen;
+ rx.len = rxlen;
+ spi_message_init(&m);
+ spi_message_add_tail(&tx, &m);
+ spi_message_add_tail(&rx, &m);
+ return spi_sync(spi, &m);
+}
+
+/**
+ * cam_set_addr() - helper function to set transfer address
+ * @addr: device address
+ * @addr_len: the addr field length of an instruction
+ * @type: type (i.e. byte-length) of @addr
+ * @str: shifted address output, must be zeroed when passed in
+ *
+ * This helper function sets @str based on the addr field length of an
+ * instruction and the data length.
+ */
+static void cam_set_addr(uint32_t addr, uint8_t addr_len,
+ enum camera_sensor_i2c_type type,
+ char *str)
+{
+ int i, len;
+
+ if (!addr_len)
+ return;
+
+ if (addr_len < type)
+ CAM_DBG(CAM_EEPROM, "omitting higher bits in address");
+
+ /* only support transfer MSB first for now */
+ len = addr_len - type;
+ for (i = len; i < addr_len; i++) {
+ if (i >= 0)
+ str[i] = (addr >> (BITS_PER_BYTE * (addr_len - i - 1)))
+ & 0xFF;
+ }
+
+}
+
+/**
+ * cam_spi_tx_helper() - wrapper for SPI transaction
+ * @client: io client
+ * @inst: inst of this transaction
+ * @addr: device addr following the inst
+ * @data: output byte array (could be NULL)
+ * @num_byte: size of @data
+ * @tx, rx: optional transfer buffer. It must be at least header
+ * + @num_byte long.
+ *
+ * This is the core function for SPI transaction, except for writes. It first
+ * checks address type, then allocates required memory for tx/rx buffers.
+ * It sends out <opcode><addr>, and optionally receives @num_byte of response,
+ * if @data is not NULL. This function does not check for wait conditions,
+ * and will return immediately once bus transaction finishes.
+ *
+ * This function will allocate buffers of header + @num_byte long. For
+ * large transfers, the allocation could fail. External buffer @tx, @rx
+ * should be passed in to bypass allocation. The size of buffer should be
+ * at least header + num_byte long. Since buffer is managed externally,
+ * @data will be ignored, and read results will be in @rx.
+ * @tx, @rx also can be used for repeated transfers to improve performance.
+ */
+static int32_t cam_spi_tx_helper(struct camera_io_master *client,
+ struct cam_camera_spi_inst *inst, uint32_t addr, uint8_t *data,
+ uint32_t num_byte, char *tx, char *rx)
+{
+ int32_t rc = -EINVAL;
+ struct spi_device *spi = client->spi_client->spi_master;
+ char *ctx = NULL, *crx = NULL;
+ uint32_t len, hlen;
+ uint8_t retries = client->spi_client->retries;
+ enum camera_sensor_i2c_type addr_type = CAMERA_SENSOR_I2C_TYPE_WORD;
+
+ if (addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX)
+ return rc;
+
+ hlen = cam_camera_spi_get_hlen(inst);
+ len = hlen + num_byte;
+
+ if (tx) {
+ ctx = tx;
+ } else {
+ ctx = kzalloc(len, GFP_KERNEL | GFP_DMA);
+ if (!ctx)
+ return -ENOMEM;
+ }
+
+ if (num_byte) {
+ if (rx) {
+ crx = rx;
+ } else {
+ crx = kzalloc(len, GFP_KERNEL | GFP_DMA);
+ if (!crx) {
+ if (!tx)
+ kfree(ctx);
+ return -ENOMEM;
+ }
+ }
+ } else {
+ crx = NULL;
+ }
+
+ ctx[0] = inst->opcode;
+ cam_set_addr(addr, inst->addr_len, addr_type, ctx + 1);
+ while ((rc = cam_spi_txfr(spi, ctx, crx, len)) && retries) {
+ retries--;
+ msleep(client->spi_client->retry_delay);
+ }
+ if (rc < 0) {
+ CAM_ERR(CAM_EEPROM, "failed: spi txfr rc %d", rc);
+ goto out;
+ }
+ if (data && num_byte && !rx)
+ memcpy(data, crx + hlen, num_byte);
+
+out:
+ if (!tx)
+ kfree(ctx);
+ if (!rx)
+ kfree(crx);
+ return rc;
+}
+
+static int32_t cam_spi_tx_read(struct camera_io_master *client,
+ struct cam_camera_spi_inst *inst, uint32_t addr, uint8_t *data,
+ uint32_t num_byte, char *tx, char *rx)
+{
+ int32_t rc = -EINVAL;
+ struct spi_device *spi = client->spi_client->spi_master;
+ char *ctx = NULL, *crx = NULL;
+ uint32_t hlen;
+ uint8_t retries = client->spi_client->retries;
+ enum camera_sensor_i2c_type addr_type = CAMERA_SENSOR_I2C_TYPE_WORD;
+
+ if ((addr_type != CAMERA_SENSOR_I2C_TYPE_WORD)
+ && (addr_type != CAMERA_SENSOR_I2C_TYPE_BYTE)
+ && (addr_type != CAMERA_SENSOR_I2C_TYPE_3B))
+ return rc;
+
+ hlen = cam_camera_spi_get_hlen(inst);
+ if (tx) {
+ ctx = tx;
+ } else {
+ ctx = kzalloc(hlen, GFP_KERNEL | GFP_DMA);
+ if (!ctx)
+ return -ENOMEM;
+ }
+ if (num_byte) {
+ if (rx) {
+ crx = rx;
+ } else {
+ crx = kzalloc(num_byte, GFP_KERNEL | GFP_DMA);
+ if (!crx) {
+ if (!tx)
+ kfree(ctx);
+ return -ENOMEM;
+ }
+ }
+ } else {
+ crx = NULL;
+ }
+
+ ctx[0] = inst->opcode;
+ if (addr_type == CAMERA_SENSOR_I2C_TYPE_3B) {
+ cam_set_addr(addr, inst->addr_len, addr_type,
+ ctx + 1);
+ } else {
+ ctx[1] = (addr >> BITS_PER_BYTE) & 0xFF;
+ ctx[2] = (addr & 0xFF);
+ ctx[3] = 0;
+ }
+ CAM_DBG(CAM_EEPROM, "tx(%u): %02x %02x %02x %02x", hlen, ctx[0],
+ ctx[1], ctx[2], ctx[3]);
+ while ((rc = cam_spi_txfr_read(spi, ctx, crx, hlen, num_byte))
+ && retries) {
+ retries--;
+ msleep(client->spi_client->retry_delay);
+ }
+ if (rc < 0) {
+ pr_err("%s: failed %d\n", __func__, rc);
+ goto out;
+ }
+ if (data && num_byte && !rx)
+ memcpy(data, crx, num_byte);
+out:
+ if (!tx)
+ kfree(ctx);
+ if (!rx)
+ kfree(crx);
+ return rc;
+}
+
+int cam_spi_read(struct camera_io_master *client,
+ uint32_t addr, uint32_t *data,
+ enum camera_sensor_i2c_type data_type)
+{
+ int rc = -EINVAL;
+ uint8_t temp[CAMERA_SENSOR_I2C_TYPE_MAX];
+
+ if ((data_type <= CAMERA_SENSOR_I2C_TYPE_INVALID)
+ || (data_type >= CAMERA_SENSOR_I2C_TYPE_MAX))
+ return rc;
+
+ rc = cam_spi_tx_read(client,
+ &client->spi_client->cmd_tbl.read, addr, &temp[0],
+ data_type, NULL, NULL);
+ if (rc < 0) {
+ pr_err("%s: failed %d\n", __func__, rc);
+ return rc;
+ }
+
+ if (data_type == CAMERA_SENSOR_I2C_TYPE_BYTE)
+ *data = temp[0];
+ else
+ *data = (temp[0] << BITS_PER_BYTE) | temp[1];
+
+ CAM_DBG(CAM_SENSOR, "addr 0x%x, data %u\n", addr, *data);
+ return rc;
+}
+
+int cam_spi_query_id(struct camera_io_master *client,
+ uint32_t addr, uint8_t *data, uint32_t num_byte)
+{
+ return cam_spi_tx_helper(client,
+ &client->spi_client->cmd_tbl.query_id, addr, data, num_byte,
+ NULL, NULL);
+}
+
+static int32_t cam_spi_read_status_reg(
+ struct camera_io_master *client, uint8_t *status)
+{
+ struct cam_camera_spi_inst *rs =
+ &client->spi_client->cmd_tbl.read_status;
+
+ if (rs->addr_len != 0) {
+ pr_err("%s: not implemented yet\n", __func__);
+ return -EINVAL;
+ }
+ return cam_spi_tx_helper(client, rs, 0, status, 1, NULL, NULL);
+}
+
+static int32_t cam_spi_device_busy(struct camera_io_master *client,
+ uint8_t *busy)
+{
+ int rc;
+ uint8_t st = 0;
+
+ rc = cam_spi_read_status_reg(client, &st);
+ if (rc < 0) {
+ pr_err("%s: failed to read status reg\n", __func__);
+ return rc;
+ }
+ *busy = st & client->spi_client->busy_mask;
+ return 0;
+}
+
+static int32_t cam_spi_wait(struct camera_io_master *client,
+ struct cam_camera_spi_inst *inst)
+{
+ uint8_t busy;
+ int i, rc;
+
+ CAM_DBG(CAM_SENSOR, "op 0x%x wait start", inst->opcode);
+ for (i = 0; i < inst->delay_count; i++) {
+ rc = cam_spi_device_busy(client, &busy);
+ if (rc < 0)
+ return rc;
+ if (!busy)
+ break;
+ msleep(inst->delay_intv);
+ CAM_DBG(CAM_SENSOR, "op 0x%x wait", inst->opcode);
+ }
+ if (i > inst->delay_count) {
+ pr_err("%s: op %x timed out\n", __func__, inst->opcode);
+ return -ETIMEDOUT;
+ }
+ CAM_DBG(CAM_SENSOR, "op %x finished", inst->opcode);
+ return 0;
+}
+
+static int32_t cam_spi_write_enable(
+ struct camera_io_master *client)
+{
+ struct cam_camera_spi_inst *we =
+ &client->spi_client->cmd_tbl.write_enable;
+ int rc;
+
+ if (we->opcode == 0)
+ return 0;
+ if (we->addr_len != 0) {
+ pr_err("%s: not implemented yet\n", __func__);
+ return -EINVAL;
+ }
+ rc = cam_spi_tx_helper(client, we, 0, NULL, 0, NULL, NULL);
+ if (rc < 0)
+ pr_err("%s: write enable failed\n", __func__);
+ return rc;
+}
+
+/**
+ * cam_spi_page_program() - core function to perform write
+ * @client: need for obtaining SPI device
+ * @addr: address to program on device
+ * @data: data to write
+ * @len: size of data
+ * @tx: tx buffer, size >= header + len
+ *
+ * This function performs SPI write, and has no boundary check. Writing range
+ * should not cross page boundary, or data will be corrupted. Transaction is
+ * guaranteed to be finished when it returns. This function should never be
+ * used outside cam_spi_write_seq().
+ */
+static int32_t cam_spi_page_program(struct camera_io_master *client,
+ uint32_t addr, uint8_t *data, uint16_t len, uint8_t *tx)
+{
+ int rc;
+ struct cam_camera_spi_inst *pg =
+ &client->spi_client->cmd_tbl.page_program;
+ struct spi_device *spi = client->spi_client->spi_master;
+ uint8_t retries = client->spi_client->retries;
+ uint8_t header_len = sizeof(pg->opcode) + pg->addr_len + pg->dummy_len;
+ enum camera_sensor_i2c_type addr_type = CAMERA_SENSOR_I2C_TYPE_WORD;
+
+ CAM_DBG(CAM_SENSOR, "addr 0x%x, size 0x%x", addr, len);
+ rc = cam_spi_write_enable(client);
+ if (rc < 0)
+ return rc;
+ memset(tx, 0, header_len);
+ tx[0] = pg->opcode;
+ cam_set_addr(addr, pg->addr_len, addr_type, tx + 1);
+ memcpy(tx + header_len, data, len);
+ CAM_DBG(CAM_SENSOR, "tx(%u): %02x %02x %02x %02x\n",
+ len, tx[0], tx[1], tx[2], tx[3]);
+ while ((rc = spi_write(spi, tx, len + header_len)) && retries) {
+ rc = cam_spi_wait(client, pg);
+ msleep(client->spi_client->retry_delay);
+ retries--;
+ }
+ if (rc < 0) {
+ pr_err("%s: failed %d\n", __func__, rc);
+ return rc;
+ }
+ rc = cam_spi_wait(client, pg);
+ return rc;
+}
+
+int cam_spi_write(struct camera_io_master *client,
+ uint32_t addr, uint16_t data,
+ enum camera_sensor_i2c_type data_type)
+{
+ struct cam_camera_spi_inst *pg =
+ &client->spi_client->cmd_tbl.page_program;
+ uint8_t header_len = sizeof(pg->opcode) + pg->addr_len + pg->dummy_len;
+ uint16_t len = 0;
+ char buf[2];
+ char *tx;
+ int rc = -EINVAL;
+ enum camera_sensor_i2c_type addr_type = CAMERA_SENSOR_I2C_TYPE_WORD;
+
+ if ((addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX)
+ || (data_type != CAMERA_SENSOR_I2C_TYPE_BYTE
+ && data_type != CAMERA_SENSOR_I2C_TYPE_WORD))
+ return rc;
+ CAM_DBG(CAM_EEPROM, "Data: 0x%x", data);
+ len = header_len + (uint8_t)data_type;
+ tx = kmalloc(len, GFP_KERNEL | GFP_DMA);
+ if (!tx)
+ goto NOMEM;
+ if (data_type == CAMERA_SENSOR_I2C_TYPE_BYTE) {
+ buf[0] = data;
+ CAM_DBG(CAM_EEPROM, "Byte %d: 0x%x", len, buf[0]);
+ } else if (data_type == CAMERA_SENSOR_I2C_TYPE_WORD) {
+ buf[0] = (data >> BITS_PER_BYTE) & 0x00FF;
+ buf[1] = (data & 0x00FF);
+ }
+ rc = cam_spi_page_program(client, addr, buf,
+ (uint16_t)data_type, tx);
+ if (rc < 0)
+ goto ERROR;
+ goto OUT;
+NOMEM:
+ pr_err("%s: memory allocation failed\n", __func__);
+ return -ENOMEM;
+ERROR:
+ pr_err("%s: error write\n", __func__);
+OUT:
+ kfree(tx);
+ return rc;
+}
+
+int cam_spi_write_table(struct camera_io_master *client,
+ struct cam_sensor_i2c_reg_setting *write_setting)
+{
+ int i;
+ int rc = -EFAULT;
+ struct cam_sensor_i2c_reg_array *reg_setting;
+ uint16_t client_addr_type;
+ enum camera_sensor_i2c_type addr_type;
+
+ if (!client || !write_setting)
+ return rc;
+ if (write_setting->addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX
+ || (write_setting->data_type != CAMERA_SENSOR_I2C_TYPE_BYTE
+ && write_setting->data_type != CAMERA_SENSOR_I2C_TYPE_WORD))
+ return rc;
+ reg_setting = write_setting->reg_setting;
+ client_addr_type = addr_type;
+ addr_type = write_setting->addr_type;
+ for (i = 0; i < write_setting->size; i++) {
+ CAM_DBG(CAM_SENSOR, "addr %x data %x",
+ reg_setting->reg_addr, reg_setting->reg_data);
+ rc = cam_spi_write(client, reg_setting->reg_addr,
+ reg_setting->reg_data, write_setting->data_type);
+ if (rc < 0)
+ break;
+ reg_setting++;
+ }
+ if (write_setting->delay > 20)
+ msleep(write_setting->delay);
+ else if (write_setting->delay)
+ usleep_range(write_setting->delay * 1000,
+ (write_setting->delay
+ * 1000) + 1000);
+ addr_type = client_addr_type;
+ return rc;
+}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.h
new file mode 100644
index 0000000..a497491
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_io/cam_sensor_spi.h
@@ -0,0 +1,93 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _CAM_SENSOR_SPI_H_
+#define _CAM_SENSOR_SPI_H_
+
+#include <linux/spi/spi.h>
+#include <media/cam_sensor.h>
+#include "cam_sensor_i2c.h"
+
+#define MAX_SPI_SIZE 110
+#define SPI_DYNAMIC_ALLOC
+
+struct cam_camera_spi_inst {
+ uint8_t opcode;
+ uint8_t addr_len;
+ uint8_t dummy_len;
+ uint8_t delay_intv;
+ uint8_t delay_count;
+};
+
+struct cam_spi_write_burst_data {
+ u8 data_msb;
+ u8 data_lsb;
+};
+
+struct cam_spi_write_burst_packet {
+ u8 cmd;
+ u8 addr_msb;
+ u8 addr_lsb;
+ struct cam_spi_write_burst_data data_arr[MAX_SPI_SIZE];
+};
+
+struct cam_camera_burst_info {
+ uint32_t burst_addr;
+ uint32_t burst_start;
+ uint32_t burst_len;
+ uint32_t chunk_size;
+};
+
+struct cam_camera_spi_inst_tbl {
+ struct cam_camera_spi_inst read;
+ struct cam_camera_spi_inst read_seq;
+ struct cam_camera_spi_inst query_id;
+ struct cam_camera_spi_inst page_program;
+ struct cam_camera_spi_inst write_enable;
+ struct cam_camera_spi_inst read_status;
+ struct cam_camera_spi_inst erase;
+};
+
+struct cam_sensor_spi_client {
+ struct spi_device *spi_master;
+ struct cam_camera_spi_inst_tbl cmd_tbl;
+ uint8_t device_id0;
+ uint8_t device_id1;
+ uint8_t mfr_id0;
+ uint8_t mfr_id1;
+ uint8_t retry_delay;
+ uint8_t retries;
+ uint8_t busy_mask;
+ uint16_t page_size;
+ uint32_t erase_size;
+};
+static __always_inline
+uint16_t cam_camera_spi_get_hlen(struct cam_camera_spi_inst *inst)
+{
+ return sizeof(inst->opcode) + inst->addr_len + inst->dummy_len;
+}
+
+int cam_spi_read(struct camera_io_master *client,
+ uint32_t addr, uint32_t *data,
+ enum camera_sensor_i2c_type data_type);
+
+int cam_spi_query_id(struct camera_io_master *client,
+ uint32_t addr, uint8_t *data, uint32_t num_byte);
+
+int cam_spi_write(struct camera_io_master *client,
+ uint32_t addr, uint16_t data,
+ enum camera_sensor_i2c_type data_type);
+
+int cam_spi_write_table(struct camera_io_master *client,
+ struct cam_sensor_i2c_reg_setting *write_setting);
+
+#endif
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h
index d12ff2b..6520042b 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h
@@ -31,6 +31,8 @@
#define CAM_SENSOR_NAME "cam-sensor"
#define CAM_ACTUATOR_NAME "cam-actuator"
#define CAM_CSIPHY_NAME "cam-csiphy"
+#define CAM_FLASH_NAME "cam-flash"
+#define CAM_EEPROM_NAME "cam-eeprom"
#define MAX_SYSTEM_PIPELINE_DELAY 2
@@ -47,6 +49,11 @@ enum camera_sensor_cmd_type {
CAMERA_SENSOR_CMD_TYPE_I2C_CONT_WR,
CAMERA_SENSOR_CMD_TYPE_I2C_CONT_RD,
CAMERA_SENSOR_CMD_TYPE_WAIT,
+ CAMERA_SENSOR_FLASH_CMD_TYPE_INIT,
+ CAMERA_SENSOR_FLASH_CMD_TYPE_FIRE,
+ CAMERA_SENSOR_FLASH_CMD_TYPE_RER,
+ CAMERA_SENSOR_FLASH_CMD_TYPE_QUERYCURR,
+ CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET,
CAMERA_SENSOR_CMD_TYPE_MAX,
};
@@ -69,6 +76,14 @@ enum camera_sensor_wait_op_code {
CAMERA_SENSOR_WAIT_OP_MAX,
};
+enum camera_flash_opcode {
+ CAMERA_SENSOR_FLASH_OP_INVALID,
+ CAMERA_SENSOR_FLASH_OP_OFF,
+ CAMERA_SENSOR_FLASH_OP_FIRELOW,
+ CAMERA_SENSOR_FLASH_OP_FIREHIGH,
+ CAMERA_SENSOR_FLASH_OP_MAX,
+};
+
enum camera_sensor_i2c_type {
CAMERA_SENSOR_I2C_TYPE_INVALID,
CAMERA_SENSOR_I2C_TYPE_BYTE,
@@ -146,6 +161,10 @@ enum cam_actuator_packet_opcodes {
CAM_ACTUATOR_PACKET_MANUAL_MOVE_LENS
};
+enum cam_eeprom_packet_opcodes {
+ CAM_EEPROM_PACKET_OPCODE_INIT
+};
+
enum msm_bus_perf_setting {
S_INIT,
S_PREVIEW,
@@ -166,6 +185,12 @@ enum msm_camera_device_type_t {
MSM_CAMERA_SPI_DEVICE,
};
+enum cam_flash_device_type {
+ CAMERA_FLASH_DEVICE_TYPE_PMIC = 0,
+ CAMERA_FLASH_DEVICE_TYPE_I2C,
+ CAMERA_FLASH_DEVICE_TYPE_GPIO,
+};
+
enum cci_i2c_master_t {
MASTER_0,
MASTER_1,
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
index 9f16e93..40a8c179 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
@@ -12,6 +12,7 @@
#include <linux/kernel.h>
#include "cam_sensor_util.h"
+#include <cam_mem_mgr.h>
#define CAM_SENSOR_PINCTRL_STATE_SLEEP "cam_suspend"
#define CAM_SENSOR_PINCTRL_STATE_DEFAULT "cam_default"
@@ -19,9 +20,6 @@
#define VALIDATE_VOLTAGE(min, max, config_val) ((config_val) && \
(config_val >= min) && (config_val <= max))
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-
static struct i2c_settings_list*
cam_sensor_get_i2c_ptr(struct i2c_settings_array *i2c_reg_settings,
uint32_t size)
@@ -56,8 +54,7 @@ int32_t delete_request(struct i2c_settings_array *i2c_array)
int32_t rc = 0;
if (i2c_array == NULL) {
- pr_err("%s:%d ::FATAL:: Invalid argument\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "FATAL:: Invalid argument");
return -EINVAL;
}
@@ -86,8 +83,7 @@ int32_t cam_sensor_handle_delay(
struct i2c_settings_list *i2c_list = NULL;
if (i2c_list == NULL) {
- pr_err("%s:%d Invalid list ptr\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Invalid list ptr");
return -EINVAL;
}
@@ -109,8 +105,7 @@ int32_t cam_sensor_handle_delay(
sizeof(
struct cam_cmd_unconditional_wait);
} else {
- pr_err("%s: %d Error: Delay Rxed Before any buffer: %d\n",
- __func__, __LINE__, offset);
+ CAM_ERR(CAM_SENSOR, "Delay Rxed Before any buffer: %d", offset);
return -EINVAL;
}
@@ -131,8 +126,7 @@ int32_t cam_sensor_handle_poll(
i2c_list =
cam_sensor_get_i2c_ptr(i2c_reg_settings, 1);
if (!i2c_list || !i2c_list->i2c_settings.reg_setting) {
- pr_err("%s: %d Failed in allocating mem for list\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Failed in allocating mem for list");
return -ENOMEM;
}
@@ -171,8 +165,7 @@ int32_t cam_sensor_handle_random_write(
cam_cmd_i2c_random_wr->header.count);
if (i2c_list == NULL ||
i2c_list->i2c_settings.reg_setting == NULL) {
- pr_err("%s: %d Failed in allocating i2c_list\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Failed in allocating i2c_list");
return -ENOMEM;
}
@@ -234,8 +227,8 @@ int cam_sensor_i2c_pkt_parser(struct i2c_settings_array *i2c_reg_settings,
* be spread across multiple cmd buffers
*/
- CDBG("%s:%d Total cmd Buf in Bytes: %d\n", __func__,
- __LINE__, cmd_desc[i].length);
+ CAM_DBG(CAM_SENSOR, "Total cmd Buf in Bytes: %d",
+ cmd_desc[i].length);
if (!cmd_desc[i].length)
continue;
@@ -244,10 +237,9 @@ int cam_sensor_i2c_pkt_parser(struct i2c_settings_array *i2c_reg_settings,
(uint64_t *)&generic_ptr, &len_of_buff);
cmd_buf = (uint32_t *)generic_ptr;
if (rc < 0) {
- pr_err("%s:%d Failed in getting cmd hdl: %d Err: %d Buffer Len: %ld\n",
- __func__, __LINE__,
- cmd_desc[i].mem_handle, rc,
- len_of_buff);
+ CAM_ERR(CAM_SENSOR,
+ "cmd hdl failed:%d, Err: %d, Buffer_len: %ld",
+ cmd_desc[i].mem_handle, rc, len_of_buff);
return rc;
}
cmd_buf += cmd_desc[i].offset / sizeof(uint32_t);
@@ -267,8 +259,8 @@ int cam_sensor_i2c_pkt_parser(struct i2c_settings_array *i2c_reg_settings,
i2c_reg_settings,
&cmd_length_in_bytes, &j, &list);
if (rc < 0) {
- pr_err("%s:%d :Error: Failed in random read %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "Failed in random read %d", rc);
return rc;
}
@@ -288,8 +280,9 @@ int cam_sensor_i2c_pkt_parser(struct i2c_settings_array *i2c_reg_settings,
i2c_reg_settings, j, &byte_cnt,
list);
if (rc < 0) {
- pr_err("%s:%d :Error: Failed in handling delay %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "delay hdl failed: %d",
+ rc);
return rc;
}
@@ -299,21 +292,22 @@ int cam_sensor_i2c_pkt_parser(struct i2c_settings_array *i2c_reg_settings,
&cmd_buf, i2c_reg_settings,
&byte_cnt, &j, &list);
if (rc < 0) {
- pr_err("%s:%d :Error: Failed in random read %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "Random read fail: %d",
+ rc);
return rc;
}
} else {
- pr_err("%s: %d Wrong Wait Command: %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR,
+ "Wrong Wait Command: %d",
generic_op_code);
return -EINVAL;
}
break;
}
default:
- pr_err("%s:%d Invalid Command Type:%d\n",
- __func__, __LINE__, cmm_hdr->cmd_type);
+ CAM_ERR(CAM_SENSOR, "Invalid Command Type:%d",
+ cmm_hdr->cmd_type);
return -EINVAL;
}
}
@@ -333,20 +327,18 @@ int32_t msm_camera_fill_vreg_params(
/* Validate input parameters */
if (!soc_info || !power_setting) {
- pr_err("%s:%d failed: soc_info %pK power_setting %pK", __func__,
- __LINE__, soc_info, power_setting);
+ CAM_ERR(CAM_SENSOR, "failed: soc_info %pK power_setting %pK",
+ soc_info, power_setting);
return -EINVAL;
}
num_vreg = soc_info->num_rgltr;
if (num_vreg <= 0) {
- pr_err("%s:%d failed: num_vreg %d", __func__, __LINE__,
- num_vreg);
+ CAM_ERR(CAM_SENSOR, "failed: num_vreg %d", num_vreg);
return -EINVAL;
}
-
for (i = 0; i < power_setting_size; i++) {
switch (power_setting[i].seq_type) {
case SENSOR_VDIG:
@@ -354,8 +346,8 @@ int32_t msm_camera_fill_vreg_params(
if (!strcmp(soc_info->rgltr_name[j],
"cam_vdig")) {
- CDBG("%s:%d i %d j %d cam_vdig\n",
- __func__, __LINE__, i, j);
+ CAM_DBG(CAM_SENSOR,
+ "i: %d j: %d cam_vdig", i, j);
power_setting[i].seq_val = j;
if (VALIDATE_VOLTAGE(
@@ -378,8 +370,8 @@ int32_t msm_camera_fill_vreg_params(
if (!strcmp(soc_info->rgltr_name[j],
"cam_vio")) {
- CDBG("%s:%d i %d j %d cam_vio\n",
- __func__, __LINE__, i, j);
+ CAM_DBG(CAM_SENSOR,
+ "i: %d j: %d cam_vio", i, j);
power_setting[i].seq_val = j;
if (VALIDATE_VOLTAGE(
@@ -403,8 +395,8 @@ int32_t msm_camera_fill_vreg_params(
if (!strcmp(soc_info->rgltr_name[j],
"cam_vana")) {
- CDBG("%s:%d i %d j %d cam_vana\n",
- __func__, __LINE__, i, j);
+ CAM_DBG(CAM_SENSOR,
+ "i: %d j: %d cam_vana", i, j);
power_setting[i].seq_val = j;
if (VALIDATE_VOLTAGE(
@@ -428,8 +420,8 @@ int32_t msm_camera_fill_vreg_params(
if (!strcmp(soc_info->rgltr_name[j],
"cam_vaf")) {
- CDBG("%s:%d i %d j %d cam_vaf\n",
- __func__, __LINE__, i, j);
+ CAM_DBG(CAM_SENSOR,
+ "i: %d j: %d cam_vaf", i, j);
power_setting[i].seq_val = j;
if (VALIDATE_VOLTAGE(
@@ -454,8 +446,8 @@ int32_t msm_camera_fill_vreg_params(
if (!strcmp(soc_info->rgltr_name[j],
"cam_v_custom1")) {
- CDBG("%s:%d i %d j %d cam_vcustom1\n",
- __func__, __LINE__, i, j);
+ CAM_DBG(CAM_SENSOR,
+ "i:%d j:%d cam_vcustom1", i, j);
power_setting[i].seq_val = j;
if (VALIDATE_VOLTAGE(
@@ -478,8 +470,8 @@ int32_t msm_camera_fill_vreg_params(
if (!strcmp(soc_info->rgltr_name[j],
"cam_v_custom2")) {
- CDBG("%s:%d i %d j %d cam_vcustom2\n",
- __func__, __LINE__, i, j);
+ CAM_DBG(CAM_SENSOR,
+ "i:%d j:%d cam_vcustom2", i, j);
power_setting[i].seq_val = j;
if (VALIDATE_VOLTAGE(
@@ -498,8 +490,8 @@ int32_t msm_camera_fill_vreg_params(
break;
default: {
- pr_err("%s:%d invalid seq_val %d\n", __func__,
- __LINE__, power_setting[i].seq_val);
+ CAM_ERR(CAM_SENSOR, "invalid seq_val %d",
+ power_setting[i].seq_val);
break;
}
}
@@ -520,19 +512,19 @@ int cam_sensor_util_request_gpio_table(
size = gpio_conf->cam_gpio_req_tbl_size;
if (gpio_conf->cam_gpio_common_tbl_size <= 0) {
- pr_info("%s:%d No GPIO entry\n", __func__, __LINE__);
+ CAM_INFO(CAM_SENSOR, "No GPIO entry");
return 0;
}
if (!gpio_tbl || !size) {
- pr_err("%s:%d invalid gpio_tbl %pK / size %d\n", __func__,
- __LINE__, gpio_tbl, size);
+ CAM_ERR(CAM_SENSOR, "invalid gpio_tbl %pK / size %d",
+ gpio_tbl, size);
return -EINVAL;
}
for (i = 0; i < size; i++) {
- CDBG("%s:%d i %d, gpio %d dir %ld\n", __func__, __LINE__, i,
- gpio_tbl[i].gpio, gpio_tbl[i].flags);
+ CAM_DBG(CAM_SENSOR, "i: %d, gpio %d dir %ld", i,
+ gpio_tbl[i].gpio, gpio_tbl[i].flags);
}
if (gpio_en) {
@@ -545,8 +537,7 @@ int cam_sensor_util_request_gpio_table(
* apply new gpios, outout a error message
* for driver bringup debug
*/
- pr_err("%s:%d gpio %d:%s request fails\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR, "gpio %d:%s request fails",
gpio_tbl[i].gpio, gpio_tbl[i].label);
}
}
@@ -557,6 +548,307 @@ int cam_sensor_util_request_gpio_table(
return rc;
}
+int32_t cam_sensor_update_power_settings(void *cmd_buf,
+ int cmd_length, struct cam_sensor_power_ctrl_t *power_info)
+{
+ int32_t rc = 0, tot_size = 0, last_cmd_type = 0;
+ int32_t i = 0, pwr_up = 0, pwr_down = 0;
+ void *ptr = cmd_buf, *scr;
+ struct cam_cmd_power *pwr_cmd = (struct cam_cmd_power *)cmd_buf;
+ struct common_header *cmm_hdr = (struct common_header *)cmd_buf;
+
+ if (!pwr_cmd || !cmd_length) {
+ CAM_ERR(CAM_SENSOR, "Invalid Args: pwr_cmd %pK, cmd_length: %d",
+ pwr_cmd, cmd_length);
+ return -EINVAL;
+ }
+
+ power_info->power_setting_size = 0;
+ power_info->power_setting =
+ (struct cam_sensor_power_setting *)
+ kzalloc(sizeof(struct cam_sensor_power_setting) *
+ MAX_POWER_CONFIG, GFP_KERNEL);
+ if (!power_info->power_setting)
+ return -ENOMEM;
+
+ power_info->power_down_setting =
+ (struct cam_sensor_power_setting *)
+ kzalloc(sizeof(struct cam_sensor_power_setting) *
+ MAX_POWER_CONFIG, GFP_KERNEL);
+ if (!power_info->power_down_setting) {
+ rc = -ENOMEM;
+ goto free_power_settings;
+ }
+
+ while (tot_size < cmd_length) {
+ if (cmm_hdr->cmd_type ==
+ CAMERA_SENSOR_CMD_TYPE_PWR_UP) {
+ struct cam_cmd_power *pwr_cmd =
+ (struct cam_cmd_power *)ptr;
+
+ power_info->
+ power_setting_size +=
+ pwr_cmd->count;
+ scr = ptr + sizeof(struct cam_cmd_power);
+ tot_size = tot_size + sizeof(struct cam_cmd_power);
+
+ if (pwr_cmd->count == 0)
+ CAM_DBG(CAM_SENSOR, "Un expected Command");
+
+ for (i = 0; i < pwr_cmd->count; i++, pwr_up++) {
+ power_info->
+ power_setting[pwr_up].seq_type =
+ pwr_cmd->power_settings[i].
+ power_seq_type;
+ power_info->
+ power_setting[pwr_up].config_val =
+ pwr_cmd->power_settings[i].
+ config_val_low;
+ power_info->power_setting[pwr_up].delay = 0;
+ if (i) {
+ scr = scr +
+ sizeof(
+ struct cam_power_settings);
+ tot_size = tot_size +
+ sizeof(
+ struct cam_power_settings);
+ }
+ if (tot_size > cmd_length) {
+ CAM_ERR(CAM_SENSOR,
+ "Error: Cmd Buffer is wrong");
+ rc = -EINVAL;
+ goto free_power_down_settings;
+ }
+ CAM_DBG(CAM_SENSOR,
+ "Seq Type[%d]: %d Config_val: %ld",
+ pwr_up,
+ power_info->
+ power_setting[pwr_up].seq_type,
+ power_info->
+ power_setting[pwr_up].
+ config_val);
+ }
+ last_cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_UP;
+ ptr = (void *) scr;
+ cmm_hdr = (struct common_header *)ptr;
+ } else if (cmm_hdr->cmd_type == CAMERA_SENSOR_CMD_TYPE_WAIT) {
+ struct cam_cmd_unconditional_wait *wait_cmd =
+ (struct cam_cmd_unconditional_wait *)ptr;
+ if (wait_cmd->op_code ==
+ CAMERA_SENSOR_WAIT_OP_SW_UCND) {
+ if (last_cmd_type ==
+ CAMERA_SENSOR_CMD_TYPE_PWR_UP) {
+ if (pwr_up > 0)
+ power_info->
+ power_setting
+ [pwr_up - 1].delay +=
+ wait_cmd->delay;
+ else
+ CAM_ERR(CAM_SENSOR,
+ "Delay is expected only after valid power up setting");
+ } else if (last_cmd_type ==
+ CAMERA_SENSOR_CMD_TYPE_PWR_DOWN) {
+ if (pwr_down > 0)
+ power_info->
+ power_down_setting
+ [pwr_down - 1].delay +=
+ wait_cmd->delay;
+ else
+ CAM_ERR(CAM_SENSOR,
+ "Delay is expected only after valid power up setting");
+ }
+ } else
+ CAM_DBG(CAM_SENSOR, "Invalid op code: %d",
+ wait_cmd->op_code);
+ tot_size = tot_size +
+ sizeof(struct cam_cmd_unconditional_wait);
+ if (tot_size > cmd_length) {
+ CAM_ERR(CAM_SENSOR, "Command Buffer is wrong");
+ return -EINVAL;
+ }
+ scr = (void *) (wait_cmd);
+ ptr = (void *)
+ (scr +
+ sizeof(struct cam_cmd_unconditional_wait));
+ CAM_DBG(CAM_SENSOR, "ptr: %pK sizeof: %d Next: %pK",
+ scr, (int32_t)sizeof(
+ struct cam_cmd_unconditional_wait), ptr);
+
+ cmm_hdr = (struct common_header *)ptr;
+ } else if (cmm_hdr->cmd_type ==
+ CAMERA_SENSOR_CMD_TYPE_PWR_DOWN) {
+ struct cam_cmd_power *pwr_cmd =
+ (struct cam_cmd_power *)ptr;
+
+ scr = ptr + sizeof(struct cam_cmd_power);
+ tot_size = tot_size + sizeof(struct cam_cmd_power);
+ power_info->power_down_setting_size += pwr_cmd->count;
+
+ if (pwr_cmd->count == 0)
+ CAM_ERR(CAM_SENSOR, "Invalid Command");
+
+ for (i = 0; i < pwr_cmd->count; i++, pwr_down++) {
+ power_info->
+ power_down_setting[pwr_down].
+ seq_type =
+ pwr_cmd->power_settings[i].
+ power_seq_type;
+ power_info->
+ power_down_setting[pwr_down].
+ config_val =
+ pwr_cmd->power_settings[i].
+ config_val_low;
+ power_info->
+ power_down_setting[pwr_down].delay = 0;
+ if (i) {
+ scr = scr +
+ sizeof(
+ struct cam_power_settings);
+ tot_size =
+ tot_size +
+ sizeof(
+ struct cam_power_settings);
+ }
+ if (tot_size > cmd_length) {
+ CAM_ERR(CAM_SENSOR,
+ "Command Buffer is wrong");
+ rc = -EINVAL;
+ goto free_power_down_settings;
+ }
+ CAM_DBG(CAM_SENSOR,
+ "Seq Type[%d]: %d Config_val: %ld",
+ pwr_down,
+ power_info->
+ power_down_setting[pwr_down].
+ seq_type,
+ power_info->
+ power_down_setting[pwr_down].
+ config_val);
+ }
+ last_cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN;
+ ptr = (void *) scr;
+ cmm_hdr = (struct common_header *)ptr;
+ } else {
+ CAM_ERR(CAM_SENSOR,
+ "Error: Un expected Header Type: %d",
+ cmm_hdr->cmd_type);
+ }
+ }
+
+ return rc;
+free_power_down_settings:
+ kfree(power_info->power_down_setting);
+free_power_settings:
+ kfree(power_info->power_setting);
+ return rc;
+}
+
+int cam_get_dt_power_setting_data(struct device_node *of_node,
+ struct cam_hw_soc_info *soc_info,
+ struct cam_sensor_power_ctrl_t *power_info)
+{
+ int rc = 0, i;
+ int count = 0;
+ const char *seq_name = NULL;
+ uint32_t *array = NULL;
+ struct cam_sensor_power_setting *ps;
+ int c, end;
+
+ if (!power_info)
+ return -EINVAL;
+
+ count = of_property_count_strings(of_node, "qcom,cam-power-seq-type");
+ power_info->power_setting_size = count;
+
+ CAM_DBG(CAM_SENSOR, "qcom,cam-power-seq-type count %d", count);
+
+ if (count <= 0)
+ return 0;
+
+ ps = kcalloc(count, sizeof(*ps), GFP_KERNEL);
+ if (!ps)
+ return -ENOMEM;
+ power_info->power_setting = ps;
+
+ for (i = 0; i < count; i++) {
+ rc = of_property_read_string_index(of_node,
+ "qcom,cam-power-seq-type", i, &seq_name);
+ if (rc < 0) {
+ CAM_ERR(CAM_SENSOR, "failed");
+ goto ERROR1;
+ }
+ CAM_DBG(CAM_SENSOR, "seq_name[%d] = %s", i, seq_name);
+ if (!strcmp(seq_name, "cam_vio")) {
+ ps[i].seq_type = SENSOR_VIO;
+ } else if (!strcmp(seq_name, "cam_vana")) {
+ ps[i].seq_type = SENSOR_VANA;
+ } else if (!strcmp(seq_name, "cam_clk")) {
+ ps[i].seq_type = SENSOR_MCLK;
+ } else {
+ CAM_ERR(CAM_SENSOR, "unrecognized seq-type %s",
+ seq_name);
+ rc = -EILSEQ;
+ goto ERROR1;
+ }
+ CAM_DBG(CAM_SENSOR, "seq_type[%d] %d", i, ps[i].seq_type);
+ }
+
+ array = kcalloc(count, sizeof(uint32_t), GFP_KERNEL);
+ if (!array) {
+ rc = -ENOMEM;
+ goto ERROR1;
+ }
+
+ rc = of_property_read_u32_array(of_node, "qcom,cam-power-seq-cfg-val",
+ array, count);
+ if (rc < 0) {
+ CAM_ERR(CAM_SENSOR, "failed ");
+ goto ERROR2;
+ }
+
+ for (i = 0; i < count; i++) {
+ ps[i].config_val = array[i];
+ CAM_DBG(CAM_SENSOR, "power_setting[%d].config_val = %ld", i,
+ ps[i].config_val);
+ }
+
+ rc = of_property_read_u32_array(of_node, "qcom,cam-power-seq-delay",
+ array, count);
+ if (rc < 0) {
+ CAM_ERR(CAM_SENSOR, "failed");
+ goto ERROR2;
+ }
+ for (i = 0; i < count; i++) {
+ ps[i].delay = array[i];
+ CAM_DBG(CAM_SENSOR, "power_setting[%d].delay = %d", i,
+ ps[i].delay);
+ }
+ kfree(array);
+
+ power_info->power_down_setting =
+ kzalloc(sizeof(*ps) * count, GFP_KERNEL);
+
+ if (!power_info->power_down_setting) {
+ CAM_ERR(CAM_SENSOR, "failed");
+ rc = -ENOMEM;
+ goto ERROR1;
+ }
+
+ power_info->power_down_setting_size = count;
+
+ end = count - 1;
+
+ for (c = 0; c < count; c++) {
+ power_info->power_down_setting[c] = ps[end];
+ end--;
+ }
+ return rc;
+ERROR2:
+ kfree(array);
+ERROR1:
+ kfree(ps);
+ return rc;
+}
int cam_sensor_util_init_gpio_pin_tbl(
struct cam_hw_soc_info *soc_info,
@@ -574,22 +866,19 @@ int cam_sensor_util_init_gpio_pin_tbl(
gconf = soc_info->gpio_data;
if (!gconf) {
- pr_err("%s:%d No gpio_common_table is found\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "No gpio_common_table is found");
return -EINVAL;
}
if (!gconf->cam_gpio_common_tbl) {
- pr_err("%s:%d gpio_common_table is not initialized\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "gpio_common_table is not initialized");
return -EINVAL;
}
gpio_array_size = gconf->cam_gpio_common_tbl_size;
if (!gpio_array_size) {
- pr_err("%s:%d invalid size of gpio table\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "invalid size of gpio table");
return -EINVAL;
}
@@ -602,12 +891,10 @@ int cam_sensor_util_init_gpio_pin_tbl(
rc = of_property_read_u32(of_node, "gpio-vana", &val);
if (rc != -EINVAL) {
if (rc < 0) {
- pr_err("%s:%d read gpio-vana failed rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "read gpio-vana failed rc %d", rc);
goto free_gpio_info;
} else if (val >= gpio_array_size) {
- pr_err("%s:%d gpio-vana invalid %d\n",
- __func__, __LINE__, val);
+ CAM_ERR(CAM_SENSOR, "gpio-vana invalid %d", val);
rc = -EINVAL;
goto free_gpio_info;
}
@@ -615,38 +902,34 @@ int cam_sensor_util_init_gpio_pin_tbl(
gconf->cam_gpio_common_tbl[val].gpio;
gpio_num_info->valid[SENSOR_VANA] = 1;
- CDBG("%s:%d gpio-vana %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "%s:%d gpio-vana %d",
gpio_num_info->gpio_num[SENSOR_VANA]);
}
rc = of_property_read_u32(of_node, "gpio-vio", &val);
if (rc != -EINVAL) {
if (rc < 0) {
- pr_err("%s:%d read gpio-vio failed rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "read gpio-vio failed rc %d", rc);
goto free_gpio_info;
} else if (val >= gpio_array_size) {
- pr_err("%s:%d gpio-vio invalid %d\n",
- __func__, __LINE__, val);
+ CAM_ERR(CAM_SENSOR, "gpio-vio invalid %d", val);
goto free_gpio_info;
}
gpio_num_info->gpio_num[SENSOR_VIO] =
gconf->cam_gpio_common_tbl[val].gpio;
gpio_num_info->valid[SENSOR_VIO] = 1;
- CDBG("%s:%d gpio-vio %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "gpio-vio %d",
gpio_num_info->gpio_num[SENSOR_VIO]);
}
rc = of_property_read_u32(of_node, "gpio-vaf", &val);
if (rc != -EINVAL) {
if (rc < 0) {
- pr_err("%s:%d read gpio-vaf failed rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "read gpio-vaf failed rc %d", rc);
goto free_gpio_info;
} else if (val >= gpio_array_size) {
- pr_err("%s:%d gpio-vaf invalid %d\n",
- __func__, __LINE__, val);
+ CAM_ERR(CAM_SENSOR, "gpio-vaf invalid %d", val);
rc = -EINVAL;
goto free_gpio_info;
}
@@ -654,19 +937,17 @@ int cam_sensor_util_init_gpio_pin_tbl(
gconf->cam_gpio_common_tbl[val].gpio;
gpio_num_info->valid[SENSOR_VAF] = 1;
- CDBG("%s:%d gpio-vaf %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "gpio-vaf %d",
gpio_num_info->gpio_num[SENSOR_VAF]);
}
rc = of_property_read_u32(of_node, "gpio-vdig", &val);
if (rc != -EINVAL) {
if (rc < 0) {
- pr_err("%s:%d read gpio-vdig failed rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "read gpio-vdig failed rc %d", rc);
goto free_gpio_info;
} else if (val >= gpio_array_size) {
- pr_err("%s:%d gpio-vdig invalid %d\n",
- __func__, __LINE__, val);
+ CAM_ERR(CAM_SENSOR, "gpio-vdig invalid %d", val);
rc = -EINVAL;
goto free_gpio_info;
}
@@ -674,19 +955,17 @@ int cam_sensor_util_init_gpio_pin_tbl(
gconf->cam_gpio_common_tbl[val].gpio;
gpio_num_info->valid[SENSOR_VDIG] = 1;
- CDBG("%s:%d gpio-vdig %d\n", __func__, __LINE__,
- gpio_num_info->gpio_num[SENSOR_VDIG]);
+ CAM_DBG(CAM_SENSOR, "gpio-vdig %d",
+ gpio_num_info->gpio_num[SENSOR_VDIG]);
}
rc = of_property_read_u32(of_node, "gpio-reset", &val);
if (rc != -EINVAL) {
if (rc < 0) {
- pr_err("%s:%d read gpio-reset failed rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR, "read gpio-reset failed rc %d", rc);
goto free_gpio_info;
} else if (val >= gpio_array_size) {
- pr_err("%s:%d gpio-reset invalid %d\n",
- __func__, __LINE__, val);
+ CAM_ERR(CAM_SENSOR, "gpio-reset invalid %d", val);
rc = -EINVAL;
goto free_gpio_info;
}
@@ -694,19 +973,18 @@ int cam_sensor_util_init_gpio_pin_tbl(
gconf->cam_gpio_common_tbl[val].gpio;
gpio_num_info->valid[SENSOR_RESET] = 1;
- CDBG("%s:%d gpio-reset %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "gpio-reset %d",
gpio_num_info->gpio_num[SENSOR_RESET]);
}
rc = of_property_read_u32(of_node, "gpio-standby", &val);
if (rc != -EINVAL) {
if (rc < 0) {
- pr_err("%s:%d read gpio-standby failed rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "read gpio-standby failed rc %d", rc);
goto free_gpio_info;
} else if (val >= gpio_array_size) {
- pr_err("%s:%d gpio-standby invalid %d\n",
- __func__, __LINE__, val);
+ CAM_ERR(CAM_SENSOR, "gpio-standby invalid %d", val);
rc = -EINVAL;
goto free_gpio_info;
}
@@ -714,19 +992,18 @@ int cam_sensor_util_init_gpio_pin_tbl(
gconf->cam_gpio_common_tbl[val].gpio;
gpio_num_info->valid[SENSOR_STANDBY] = 1;
- CDBG("%s:%d gpio-standby %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "gpio-standby %d",
gpio_num_info->gpio_num[SENSOR_STANDBY]);
}
rc = of_property_read_u32(of_node, "gpio-af-pwdm", &val);
if (rc != -EINVAL) {
if (rc < 0) {
- pr_err("%s:%d read gpio-af-pwdm failed rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "read gpio-af-pwdm failed rc %d", rc);
goto free_gpio_info;
} else if (val >= gpio_array_size) {
- pr_err("%s:%d gpio-af-pwdm invalid %d\n",
- __func__, __LINE__, val);
+ CAM_ERR(CAM_SENSOR, "gpio-af-pwdm invalid %d", val);
rc = -EINVAL;
goto free_gpio_info;
}
@@ -734,19 +1011,18 @@ int cam_sensor_util_init_gpio_pin_tbl(
gconf->cam_gpio_common_tbl[val].gpio;
gpio_num_info->valid[SENSOR_VAF_PWDM] = 1;
- CDBG("%s:%d gpio-af-pwdm %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "gpio-af-pwdm %d",
gpio_num_info->gpio_num[SENSOR_VAF_PWDM]);
}
rc = of_property_read_u32(of_node, "gpio-custom1", &val);
if (rc != -EINVAL) {
if (rc < 0) {
- pr_err("%s:%d read gpio-custom1 failed rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "read gpio-custom1 failed rc %d", rc);
goto free_gpio_info;
} else if (val >= gpio_array_size) {
- pr_err("%s:%d gpio-custom1 invalid %d\n",
- __func__, __LINE__, val);
+ CAM_ERR(CAM_SENSOR, "gpio-custom1 invalid %d", val);
rc = -EINVAL;
goto free_gpio_info;
}
@@ -754,19 +1030,18 @@ int cam_sensor_util_init_gpio_pin_tbl(
gconf->cam_gpio_common_tbl[val].gpio;
gpio_num_info->valid[SENSOR_CUSTOM_GPIO1] = 1;
- CDBG("%s:%d gpio-custom1 %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "gpio-custom1 %d",
gpio_num_info->gpio_num[SENSOR_CUSTOM_GPIO1]);
}
rc = of_property_read_u32(of_node, "gpio-custom2", &val);
if (rc != -EINVAL) {
if (rc < 0) {
- pr_err("%s:%d read gpio-custom2 failed rc %d\n",
- __func__, __LINE__, rc);
+ CAM_ERR(CAM_SENSOR,
+ "read gpio-custom2 failed rc %d", rc);
goto free_gpio_info;
} else if (val >= gpio_array_size) {
- pr_err("%s:%d gpio-custom2 invalid %d\n",
- __func__, __LINE__, val);
+ CAM_ERR(CAM_SENSOR, "gpio-custom2 invalid %d", val);
rc = -EINVAL;
goto free_gpio_info;
}
@@ -774,7 +1049,7 @@ int cam_sensor_util_init_gpio_pin_tbl(
gconf->cam_gpio_common_tbl[val].gpio;
gpio_num_info->valid[SENSOR_CUSTOM_GPIO2] = 1;
- CDBG("%s:%d gpio-custom2 %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "gpio-custom2 %d",
gpio_num_info->gpio_num[SENSOR_CUSTOM_GPIO2]);
} else {
rc = 0;
@@ -793,24 +1068,23 @@ int msm_camera_pinctrl_init(
sensor_pctrl->pinctrl = devm_pinctrl_get(dev);
if (IS_ERR_OR_NULL(sensor_pctrl->pinctrl)) {
- pr_err("%s:%d Getting pinctrl handle failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Getting pinctrl handle failed");
return -EINVAL;
}
sensor_pctrl->gpio_state_active =
pinctrl_lookup_state(sensor_pctrl->pinctrl,
CAM_SENSOR_PINCTRL_STATE_DEFAULT);
if (IS_ERR_OR_NULL(sensor_pctrl->gpio_state_active)) {
- pr_err("%s:%d Failed to get the active state pinctrl handle\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "Failed to get the active state pinctrl handle");
return -EINVAL;
}
sensor_pctrl->gpio_state_suspend
= pinctrl_lookup_state(sensor_pctrl->pinctrl,
CAM_SENSOR_PINCTRL_STATE_SLEEP);
if (IS_ERR_OR_NULL(sensor_pctrl->gpio_state_suspend)) {
- pr_err("%s:%d Failed to get the suspend state pinctrl handle\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "Failed to get the suspend state pinctrl handle");
return -EINVAL;
}
return 0;
@@ -821,19 +1095,17 @@ int msm_cam_sensor_handle_reg_gpio(int seq_type,
int gpio_offset = -1;
if (!gpio_num_info) {
- pr_err("%s:%d Input Parameters are not proper\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Input Parameters are not proper");
return -EINVAL;
}
- CDBG("%s: %d Seq type: %d, config: %d", __func__, __LINE__,
- seq_type, val);
+ CAM_DBG(CAM_SENSOR, "Seq type: %d, config: %d", seq_type, val);
gpio_offset = seq_type;
if (gpio_num_info->valid[gpio_offset] == 1) {
- CDBG("%s: %d VALID GPIO offset: %d, seqtype: %d\n",
- __func__, __LINE__, gpio_offset, seq_type);
+ CAM_DBG(CAM_SENSOR, "VALID GPIO offset: %d, seqtype: %d",
+ gpio_offset, seq_type);
gpio_set_value_cansleep(
gpio_num_info->gpio_num
[gpio_offset], val);
@@ -850,9 +1122,9 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
struct cam_sensor_power_setting *power_setting = NULL;
struct msm_camera_gpio_num_info *gpio_num_info = NULL;
- CDBG("%s:%d\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "Enter");
if (!ctrl) {
- pr_err("%s:%d Invalid ctrl handle\n", __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Invalid ctrl handle");
return -EINVAL;
}
@@ -860,15 +1132,13 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
num_vreg = soc_info->num_rgltr;
if ((num_vreg == 0) || (num_vreg > CAM_SOC_MAX_REGULATOR)) {
- pr_err("%s:%d Regulators are not initialized\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Regulators are not initialized");
return -EINVAL;
}
ret = msm_camera_pinctrl_init(&(ctrl->pinctrl_info), ctrl->dev);
if (ret < 0) {
- pr_err("%s:%d Initialization of pinctrl failed\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "Initialization of pinctrl failed");
ctrl->cam_pinctrl_status = 0;
} else {
ctrl->cam_pinctrl_status = 1;
@@ -882,19 +1152,18 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
ret = pinctrl_select_state(ctrl->pinctrl_info.pinctrl,
ctrl->pinctrl_info.gpio_state_active);
if (ret)
- pr_err("%s:%d cannot set pin to active state",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "cannot set pin to active state");
}
for (index = 0; index < ctrl->power_setting_size; index++) {
- CDBG("%s:%d index %d\n", __func__, __LINE__, index);
+ CAM_DBG(CAM_SENSOR, "index: %d", index);
power_setting = &ctrl->power_setting[index];
+ CAM_DBG(CAM_SENSOR, "seq_type %d", power_setting->seq_type);
switch (power_setting->seq_type) {
case SENSOR_MCLK:
if (power_setting->seq_val >= soc_info->num_clk) {
- pr_err("%s:%d :Error: clk index %d >= max %u\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR, "clk index %d >= max %u",
power_setting->seq_val,
soc_info->num_clk);
goto power_up_failed;
@@ -902,8 +1171,8 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
for (j = 0; j < num_vreg; j++) {
if (!strcmp(soc_info->rgltr_name[j],
"cam_clk")) {
- CDBG("%s:%d Enable cam_clk: %d\n",
- __func__, __LINE__, j);
+ CAM_DBG(CAM_SENSOR,
+ "Enable cam_clk: %d", j);
soc_info->rgltr[j] =
regulator_get(
@@ -915,8 +1184,8 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
rc = PTR_ERR(
soc_info->rgltr[j]);
rc = rc ? rc : -EINVAL;
- pr_err("%s:%d :vreg %s %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR,
+ "vreg %s %d",
soc_info->rgltr_name[j],
rc);
soc_info->rgltr[j] = NULL;
@@ -947,8 +1216,7 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
}
if (rc < 0) {
- pr_err("%s:%d clk enable failed\n", __func__,
- __LINE__);
+ CAM_ERR(CAM_SENSOR, "clk enable failed");
goto power_up_failed;
}
break;
@@ -957,20 +1225,17 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
case SENSOR_CUSTOM_GPIO1:
case SENSOR_CUSTOM_GPIO2:
if (no_gpio) {
- pr_err("%s:%d request gpio failed\n", __func__,
- __LINE__);
+ CAM_ERR(CAM_SENSOR, "request gpio failed");
return no_gpio;
}
if (power_setting->seq_val >= CAM_VREG_MAX ||
!gpio_num_info) {
- pr_err("%s:%d gpio index %d >= max %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR, "gpio index %d >= max %d",
power_setting->seq_val,
CAM_VREG_MAX);
goto power_up_failed;
}
- CDBG("%s:%d gpio set val %d\n",
- __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "gpio set val %d",
gpio_num_info->gpio_num
[power_setting->seq_val]);
@@ -978,8 +1243,8 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
power_setting->seq_type,
gpio_num_info, 1);
if (rc < 0) {
- pr_err("%s:%d Error in handling VREG GPIO\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "Error in handling VREG GPIO");
goto power_up_failed;
}
break;
@@ -994,15 +1259,13 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
break;
if (power_setting->seq_val >= CAM_VREG_MAX) {
- pr_err("%s:%d vreg index %d >= max %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR, "vreg index %d >= max %d",
power_setting->seq_val,
CAM_VREG_MAX);
goto power_up_failed;
}
if (power_setting->seq_val < num_vreg) {
- CDBG("%s:%d Enable Regulator\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "Enable Regulator");
vreg_idx = power_setting->seq_val;
soc_info->rgltr[vreg_idx] =
@@ -1013,8 +1276,7 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
rc = PTR_ERR(soc_info->rgltr[vreg_idx]);
rc = rc ? rc : -EINVAL;
- pr_err("%s:%d, %s get failed %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR, "%s get failed %d",
soc_info->rgltr_name[vreg_idx],
rc);
@@ -1033,22 +1295,21 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
soc_info->rgltr[vreg_idx];
}
else
- pr_err("%s: %d usr_idx:%d dts_idx:%d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR, "usr_idx:%d dts_idx:%d",
power_setting->seq_val, num_vreg);
rc = msm_cam_sensor_handle_reg_gpio(
power_setting->seq_type,
gpio_num_info, 1);
if (rc < 0) {
- pr_err("%s:%d Error in handling VREG GPIO\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "Error in handling VREG GPIO");
goto power_up_failed;
}
break;
default:
- pr_err("%s:%d error power seq type %d\n", __func__,
- __LINE__, power_setting->seq_type);
+ CAM_ERR(CAM_SENSOR, "error power seq type %d",
+ power_setting->seq_type);
break;
}
if (power_setting->delay > 20)
@@ -1060,11 +1321,11 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
return 0;
power_up_failed:
- pr_err("%s:%d failed\n", __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "failed");
for (index--; index >= 0; index--) {
- CDBG("%s:%d index %d\n", __func__, __LINE__, index);
+ CAM_DBG(CAM_SENSOR, "index %d", index);
power_setting = &ctrl->power_setting[index];
- CDBG("%s:%d type %d\n", __func__, __LINE__,
+ CAM_DBG(CAM_SENSOR, "type %d",
power_setting->seq_type);
switch (power_setting->seq_type) {
case SENSOR_RESET:
@@ -1088,8 +1349,7 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
case SENSOR_CUSTOM_REG1:
case SENSOR_CUSTOM_REG2:
if (power_setting->seq_val < num_vreg) {
- CDBG("%s:%d Disable Regulator\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "Disable Regulator");
vreg_idx = power_setting->seq_val;
rc = cam_soc_util_regulator_disable(
@@ -1105,8 +1365,7 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
}
else
- pr_err("%s:%d:seq_val: %d > num_vreg: %d\n",
- __func__, __LINE__,
+ CAM_ERR(CAM_SENSOR, "seq_val:%d > num_vreg: %d",
power_setting->seq_val, num_vreg);
msm_cam_sensor_handle_reg_gpio(power_setting->seq_type,
@@ -1114,8 +1373,8 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
break;
default:
- pr_err("%s:%d error power seq type %d\n", __func__,
- __LINE__, power_setting->seq_type);
+ CAM_ERR(CAM_SENSOR, "error power seq type %d",
+ power_setting->seq_type);
break;
}
if (power_setting->delay > 20) {
@@ -1129,8 +1388,7 @@ int cam_sensor_core_power_up(struct cam_sensor_power_ctrl_t *ctrl,
ret = pinctrl_select_state(ctrl->pinctrl_info.pinctrl,
ctrl->pinctrl_info.gpio_state_suspend);
if (ret)
- pr_err("%s:%d cannot set pin to suspend state\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "cannot set pin to suspend state");
devm_pinctrl_put(ctrl->pinctrl_info.pinctrl);
}
ctrl->cam_pinctrl_status = 0;
@@ -1186,8 +1444,7 @@ static int cam_config_mclk_reg(struct cam_sensor_power_ctrl_t *ctrl,
}
if (ps != NULL) {
- CDBG("%s:%d Disable Regulator\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "Disable Regulator");
rc = cam_soc_util_regulator_disable(
soc_info->rgltr[j],
@@ -1214,9 +1471,9 @@ int msm_camera_power_down(struct cam_sensor_power_ctrl_t *ctrl,
struct cam_sensor_power_setting *ps;
struct msm_camera_gpio_num_info *gpio_num_info = NULL;
- CDBG("%s:%d\n", __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR, "Enter");
if (!ctrl || !soc_info) {
- pr_err("%s:%d failed ctrl %pK\n", __func__, __LINE__, ctrl);
+ CAM_ERR(CAM_SENSOR, "failed ctrl %pK", ctrl);
return -EINVAL;
}
@@ -1224,16 +1481,16 @@ int msm_camera_power_down(struct cam_sensor_power_ctrl_t *ctrl,
num_vreg = soc_info->num_rgltr;
for (index = 0; index < ctrl->power_down_setting_size; index++) {
- CDBG("%s:%d index %d\n", __func__, __LINE__, index);
+ CAM_DBG(CAM_SENSOR, "index %d", index);
pd = &ctrl->power_down_setting[index];
ps = NULL;
- CDBG("%s:%d type %d\n", __func__, __LINE__, pd->seq_type);
+ CAM_DBG(CAM_SENSOR, "type %d", pd->seq_type);
switch (pd->seq_type) {
case SENSOR_MCLK:
ret = cam_config_mclk_reg(ctrl, soc_info, index);
if (ret < 0) {
- pr_err("%s:%d :Error: in config clk reg\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "config clk reg failed rc: %d", ret);
return ret;
}
//cam_soc_util_clk_disable_default(soc_info);
@@ -1272,8 +1529,8 @@ int msm_camera_power_down(struct cam_sensor_power_ctrl_t *ctrl,
pd->seq_val);
if (ps) {
if (pd->seq_val < num_vreg) {
- CDBG("%s:%d Disable Regulator\n",
- __func__, __LINE__);
+ CAM_DBG(CAM_SENSOR,
+ "Disable Regulator");
ret = cam_soc_util_regulator_disable(
soc_info->rgltr[ps->seq_val],
soc_info->rgltr_name[ps->seq_val],
@@ -1286,23 +1543,24 @@ int msm_camera_power_down(struct cam_sensor_power_ctrl_t *ctrl,
soc_info->rgltr[ps->seq_val];
}
else
- pr_err("%s:%d:seq_val:%d > num_vreg: %d\n",
- __func__, __LINE__, pd->seq_val,
+ CAM_ERR(CAM_SENSOR,
+ "seq_val:%d > num_vreg: %d",
+ pd->seq_val,
num_vreg);
} else
- pr_err("%s:%d error in power up/down seq\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "error in power up/down seq");
ret = msm_cam_sensor_handle_reg_gpio(pd->seq_type,
gpio_num_info, GPIOF_OUT_INIT_LOW);
if (ret < 0)
- pr_err("%s:%d Error disabling VREG GPIO\n",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR,
+ "Error disabling VREG GPIO");
break;
default:
- pr_err("%s:%d error power seq type %d\n", __func__,
- __LINE__, pd->seq_type);
+ CAM_ERR(CAM_SENSOR, "error power seq type %d",
+ pd->seq_type);
break;
}
if (pd->delay > 20)
@@ -1316,8 +1574,7 @@ int msm_camera_power_down(struct cam_sensor_power_ctrl_t *ctrl,
ret = pinctrl_select_state(ctrl->pinctrl_info.pinctrl,
ctrl->pinctrl_info.gpio_state_suspend);
if (ret)
- pr_err("%s:%d cannot set pin to suspend state",
- __func__, __LINE__);
+ CAM_ERR(CAM_SENSOR, "cannot set pin to suspend state");
devm_pinctrl_put(ctrl->pinctrl_info.pinctrl);
}
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h
index 912f06b..8a26369 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.h
@@ -23,11 +23,12 @@
#include <cam_req_mgr_interface.h>
#include <cam_mem_mgr.h>
#include "cam_soc_util.h"
+#include "cam_debug_util.h"
#define INVALID_VREG 100
-int msm_camera_get_dt_power_setting_data(struct device_node *of_node,
- struct camera_vreg_t *cam_vreg, int num_vreg,
+int cam_get_dt_power_setting_data(struct device_node *of_node,
+ struct cam_hw_soc_info *soc_info,
struct cam_sensor_power_ctrl_t *power_info);
int msm_camera_pinctrl_init
@@ -52,4 +53,7 @@ int msm_camera_power_down(struct cam_sensor_power_ctrl_t *ctrl,
int msm_camera_fill_vreg_params(struct cam_hw_soc_info *soc_info,
struct cam_sensor_power_setting *power_setting,
uint16_t power_setting_size);
+
+int32_t cam_sensor_update_power_settings(void *cmd_buf,
+ int cmd_length, struct cam_sensor_power_ctrl_t *power_info);
#endif /* _CAM_SENSOR_UTIL_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_utils/Makefile b/drivers/media/platform/msm/camera/cam_utils/Makefile
index 370651f..4702963 100644
--- a/drivers/media/platform/msm/camera/cam_utils/Makefile
+++ b/drivers/media/platform/msm/camera/cam_utils/Makefile
@@ -2,4 +2,4 @@
ccflags-y += -Idrivers/media/platform/msm/camera/cam_req_mgr/
ccflags-y += -Idrivers/media/platform/msm/camera/cam_smmu/
-obj-$(CONFIG_SPECTRA_CAMERA) += cam_soc_util.o cam_io_util.o cam_packet_util.o cam_debug_util.o cam_trace.o
+obj-$(CONFIG_SPECTRA_CAMERA) += cam_soc_util.o cam_io_util.o cam_packet_util.o cam_debug_util.o cam_trace.o cam_common_util.o
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_common_util.c b/drivers/media/platform/msm/camera/cam_utils/cam_common_util.c
new file mode 100644
index 0000000..199d3ea
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_common_util.c
@@ -0,0 +1,35 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+
+#include "cam_common_util.h"
+#include "cam_debug_util.h"
+
+int cam_common_util_get_string_index(const char **strings,
+ uint32_t num_strings, char *matching_string, uint32_t *index)
+{
+ int i;
+
+ for (i = 0; i < num_strings; i++) {
+ if (strnstr(strings[i], matching_string, strlen(strings[i]))) {
+ CAM_DBG(CAM_UTIL, "matched %s : %d\n",
+ matching_string, i);
+ *index = i;
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+}
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_common_util.h b/drivers/media/platform/msm/camera/cam_utils/cam_common_util.h
new file mode 100644
index 0000000..d6a11b7
--- /dev/null
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_common_util.h
@@ -0,0 +1,35 @@
+/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _CAM_COMMON_UTIL_H_
+#define _CAM_COMMON_UTIL_H_
+
+#define CAM_BITS_MASK_SHIFT(x, mask, shift) (((x) & (mask)) >> shift)
+
+/**
+ * cam_common_util_get_string_index()
+ *
+ * @brief Match the string from list of strings to return
+ * matching index
+ *
+ * @strings: Pointer to list of strings
+ * @num_strings: Number of strings in 'strings'
+ * @matching_string: String to match
+ * @index: Pointer to index to return matching index
+ *
+ * @return: 0 for success
+ * -EINVAL for Fail
+ */
+int cam_common_util_get_string_index(const char **strings,
+ uint32_t num_strings, char *matching_string, uint32_t *index);
+
+#endif /* _CAM_COMMON_UTIL_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.c b/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.c
index eb5e7d8..21f90ca 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.c
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.c
@@ -11,9 +11,14 @@
*/
#include <linux/io.h>
+#include <linux/module.h>
+
#include "cam_debug_util.h"
-static const char *cam_debug_module_id_to_name(unsigned int module_id)
+static uint debug_mdl;
+module_param(debug_mdl, uint, 0644);
+
+const char *cam_get_module_name(unsigned int module_id)
{
const char *name = NULL;
@@ -57,6 +62,27 @@ static const char *cam_debug_module_id_to_name(unsigned int module_id)
case CAM_FLASH:
name = "CAM-FLASH";
break;
+ case CAM_ACTUATOR:
+ name = "CAM-ACTUATOR";
+ break;
+ case CAM_CCI:
+ name = "CAM-CCI";
+ break;
+ case CAM_CSIPHY:
+ name = "CAM-CSIPHY";
+ break;
+ case CAM_EEPROM:
+ name = "CAM-EEPROM";
+ break;
+ case CAM_UTIL:
+ name = "CAM-UTIL";
+ break;
+ case CAM_CTXT:
+ name = "CAM-CTXT";
+ break;
+ case CAM_HFI:
+ name = "CAM-HFI";
+ break;
default:
name = "CAM";
break;
@@ -69,31 +95,37 @@ void cam_debug_log(unsigned int module_id, enum cam_debug_level dbg_level,
const char *func, const int line, const char *fmt, ...)
{
char str_buffer[STR_BUFFER_MAX_LENGTH];
- const char *module_name;
va_list args;
va_start(args, fmt);
- vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);
- va_end(args);
-
- module_name = cam_debug_module_id_to_name(module_id);
switch (dbg_level) {
- case CAM_LEVEL_INFO:
- pr_info("CAM_INFO: %s: %s: %d: %s\n",
- module_name, func, line, str_buffer);
- break;
- case CAM_LEVEL_WARN:
- pr_warn("CAM_WARN: %s: %s: %d: %s\n",
- module_name, func, line, str_buffer);
+ case CAM_LEVEL_DBG:
+ if (debug_mdl & module_id) {
+ vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);
+ pr_info("CAM_DBG: %s: %s: %d: %s\n",
+ cam_get_module_name(module_id),
+ func, line, str_buffer);
+ va_end(args);
+ }
break;
case CAM_LEVEL_ERR:
+ vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);
pr_err("CAM_ERR: %s: %s: %d: %s\n",
- module_name, func, line, str_buffer);
+ cam_get_module_name(module_id), func, line, str_buffer);
+ va_end(args);
break;
- case CAM_LEVEL_DBG:
- pr_info("CAM_DBG: %s: %s: %d: %s\n",
- module_name, func, line, str_buffer);
+ case CAM_LEVEL_INFO:
+ vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);
+ pr_info("CAM_INFO: %s: %s: %d: %s\n",
+ cam_get_module_name(module_id), func, line, str_buffer);
+ va_end(args);
+ break;
+ case CAM_LEVEL_WARN:
+ vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);
+ pr_warn("CAM_WARN: %s: %s: %d: %s\n",
+ cam_get_module_name(module_id), func, line, str_buffer);
+ va_end(args);
break;
default:
break;
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h b/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h
index 34adb0e..7275d56 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h
@@ -13,22 +13,28 @@
#ifndef _CAM_DEBUG_UTIL_H_
#define _CAM_DEBUG_UTIL_H_
-#define CAM_CDM (1 << 0)
-#define CAM_CORE (1 << 1)
-#define CAM_CPAS (1 << 2)
-#define CAM_ISP (1 << 3)
-#define CAM_CRM (1 << 4)
-#define CAM_SENSOR (1 << 5)
-#define CAM_SMMU (1 << 6)
-#define CAM_SYNC (1 << 7)
-#define CAM_ICP (1 << 8)
-#define CAM_JPEG (1 << 9)
-#define CAM_FD (1 << 10)
-#define CAM_LRME (1 << 11)
-#define CAM_FLASH (1 << 12)
+#define CAM_CDM (1 << 0)
+#define CAM_CORE (1 << 1)
+#define CAM_CPAS (1 << 2)
+#define CAM_ISP (1 << 3)
+#define CAM_CRM (1 << 4)
+#define CAM_SENSOR (1 << 5)
+#define CAM_SMMU (1 << 6)
+#define CAM_SYNC (1 << 7)
+#define CAM_ICP (1 << 8)
+#define CAM_JPEG (1 << 9)
+#define CAM_FD (1 << 10)
+#define CAM_LRME (1 << 11)
+#define CAM_FLASH (1 << 12)
+#define CAM_ACTUATOR (1 << 13)
+#define CAM_CCI (1 << 14)
+#define CAM_CSIPHY (1 << 15)
+#define CAM_EEPROM (1 << 16)
+#define CAM_UTIL (1 << 17)
+#define CAM_HFI (1 << 18)
+#define CAM_CTXT (1 << 19)
#define STR_BUFFER_MAX_LENGTH 1024
-#define GROUP 0x0000
enum cam_debug_level {
CAM_LEVEL_INFO,
@@ -40,61 +46,61 @@ enum cam_debug_level {
/*
* cam_debug_log()
*
- * @brief: Get the Module name form module ID and print
- * respective debug logs
+ * @brief : Get the Module name from module ID and print
+ * respective debug logs
*
* @module_id : Respective Module ID which is calling this function
* @dbg_level : Debug level from cam_module_debug_level enum entries
- * @func : Function which is calling to print logs
- * @line : Line number associated with the function which is calling
+ * @func : Function which is calling to print logs
+ * @line : Line number associated with the function which is calling
* to print log
- * @fmt : Formatted string which needs to be print in the log
+ * @fmt : Formatted string which needs to be print in the log
*
*/
void cam_debug_log(unsigned int module_id, enum cam_debug_level dbg_level,
const char *func, const int line, const char *fmt, ...);
/*
+ * cam_get_module_name()
+ *
+ * @brief : Get the module name from module ID
+ *
+ * @module_id : Module ID which is using this function
+ */
+const char *cam_get_module_name(unsigned int module_id);
+
+/*
* CAM_ERR
- * @brief : This Macro will print error logs
+ * @brief : This Macro will print error logs
*
* @__module : Respective module id which is been calling this Macro
- * @fmt : Formatted string which needs to be print in log
- * @args: Arguments which needs to be print in log
+ * @fmt : Formatted string which needs to be print in log
+ * @args : Arguments which needs to be print in log
*/
#define CAM_ERR(__module, fmt, args...) \
- { \
- cam_debug_log(__module, CAM_LEVEL_ERR, \
- __func__, __LINE__, fmt, ##args); \
- }
+ cam_debug_log(__module, CAM_LEVEL_ERR, __func__, __LINE__, fmt, ##args)
/*
* CAM_WARN
- * @brief : This Macro will print warning logs
+ * @brief : This Macro will print warning logs
*
* @__module : Respective module id which is been calling this Macro
* @fmt : Formatted string which needs to be print in log
* @args : Arguments which needs to be print in log
*/
#define CAM_WARN(__module, fmt, args...) \
- { \
- cam_debug_log(__module, CAM_LEVEL_WARN, \
- __func__, __LINE__, fmt, ##args); \
- }
+ cam_debug_log(__module, CAM_LEVEL_WARN, __func__, __LINE__, fmt, ##args)
/*
* CAM_INFO
- * @brief : This Macro will print Information logs
+ * @brief : This Macro will print Information logs
*
* @__module : Respective module id which is been calling this Macro
* @fmt : Formatted string which needs to be print in log
* @args : Arguments which needs to be print in log
*/
#define CAM_INFO(__module, fmt, args...) \
- { \
- cam_debug_log(__module, CAM_LEVEL_INFO, \
- __func__, __LINE__, fmt, ##args); \
- }
+ cam_debug_log(__module, CAM_LEVEL_INFO, __func__, __LINE__, fmt, ##args)
/*
* CAM_DBG
@@ -105,11 +111,14 @@ void cam_debug_log(unsigned int module_id, enum cam_debug_level dbg_level,
* @args : Arguments which needs to be print in log
*/
#define CAM_DBG(__module, fmt, args...) \
- do { \
- if (GROUP & __module) { \
- cam_debug_log(__module, CAM_LEVEL_DBG, \
- __func__, __LINE__, fmt, ##args); \
- } \
- } while (0)
+ cam_debug_log(__module, CAM_LEVEL_DBG, __func__, __LINE__, fmt, ##args)
+
+/*
+ * CAM_ERR_RATE_LIMIT
+ * @brief : This Macro will prevent error print logs with ratelimit
+ */
+#define CAM_ERR_RATE_LIMIT(__module, fmt, args...) \
+ pr_err_ratelimited("CAM_ERR: %s: %s: %d\n" fmt, \
+ cam_get_module_name(__module), __func__, __LINE__, ##args)
#endif /* _CAM_DEBUG_UTIL_H_ */
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.c b/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.c
index 6d90c1e..442d0bd 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.c
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.c
@@ -12,11 +12,118 @@
#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
+#include <linux/types.h>
+#include <linux/slab.h>
+
#include "cam_mem_mgr.h"
#include "cam_packet_util.h"
+#include "cam_debug_util.h"
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+static int cam_packet_util_get_cmd_mem_addr(int handle, uint32_t **buf_addr,
+ size_t *len)
+{
+ int rc = 0;
+ uint64_t kmd_buf_addr = 0;
+
+ rc = cam_mem_get_cpu_buf(handle, &kmd_buf_addr, len);
+ if (rc) {
+ CAM_ERR(CAM_UTIL, "Unable to get the virtual address %d", rc);
+ } else {
+ if (kmd_buf_addr && *len) {
+ *buf_addr = (uint32_t *)kmd_buf_addr;
+ } else {
+ CAM_ERR(CAM_UTIL, "Invalid addr and length :%ld", *len);
+ rc = -ENOMEM;
+ }
+ }
+ return rc;
+}
+
+int cam_packet_util_validate_cmd_desc(struct cam_cmd_buf_desc *cmd_desc)
+{
+ if ((cmd_desc->length > cmd_desc->size) ||
+ (cmd_desc->mem_handle <= 0)) {
+ CAM_ERR(CAM_UTIL, "invalid cmd arg %d %d %d %d",
+ cmd_desc->offset, cmd_desc->length,
+ cmd_desc->mem_handle, cmd_desc->size);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+int cam_packet_util_validate_packet(struct cam_packet *packet)
+{
+ if (!packet)
+ return -EINVAL;
+
+ CAM_DBG(CAM_UTIL, "num cmd buf:%d num of io config:%d kmd buf index:%d",
+ packet->num_cmd_buf, packet->num_io_configs,
+ packet->kmd_cmd_buf_index);
+
+ if ((packet->kmd_cmd_buf_index >= packet->num_cmd_buf) ||
+ (!packet->header.size) ||
+ (packet->cmd_buf_offset > packet->header.size) ||
+ (packet->io_configs_offset > packet->header.size)) {
+ CAM_ERR(CAM_UTIL, "invalid packet:%d %d %d %d %d",
+ packet->kmd_cmd_buf_index,
+ packet->num_cmd_buf, packet->cmd_buf_offset,
+ packet->io_configs_offset, packet->header.size);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+int cam_packet_util_get_kmd_buffer(struct cam_packet *packet,
+ struct cam_kmd_buf_info *kmd_buf)
+{
+ int rc = 0;
+ size_t len = 0;
+ struct cam_cmd_buf_desc *cmd_desc;
+ uint32_t *cpu_addr;
+
+ if (!packet || !kmd_buf) {
+ CAM_ERR(CAM_UTIL, "Invalid arg %pK %pK", packet, kmd_buf);
+ return -EINVAL;
+ }
+
+ /* Take first command descriptor and add offset to it for kmd*/
+ cmd_desc = (struct cam_cmd_buf_desc *) ((uint8_t *)
+ &packet->payload + packet->cmd_buf_offset);
+ cmd_desc += packet->kmd_cmd_buf_index;
+
+ rc = cam_packet_util_validate_cmd_desc(cmd_desc);
+ if (rc)
+ return rc;
+
+ rc = cam_packet_util_get_cmd_mem_addr(cmd_desc->mem_handle, &cpu_addr,
+ &len);
+ if (rc)
+ return rc;
+
+ if (len < cmd_desc->size) {
+ CAM_ERR(CAM_UTIL, "invalid memory len:%ld and cmd desc size:%d",
+ len, cmd_desc->size);
+ return -EINVAL;
+ }
+
+ cpu_addr += (cmd_desc->offset / 4) + (packet->kmd_cmd_buf_offset / 4);
+ CAM_DBG(CAM_UTIL, "total size %d, cmd size: %d, KMD buffer size: %d",
+ cmd_desc->size, cmd_desc->length,
+ cmd_desc->size - cmd_desc->length);
+ CAM_DBG(CAM_UTIL, "hdl 0x%x, cmd offset %d, kmd offset %d, addr 0x%pK",
+ cmd_desc->mem_handle, cmd_desc->offset,
+ packet->kmd_cmd_buf_offset, cpu_addr);
+
+ kmd_buf->cpu_addr = cpu_addr;
+ kmd_buf->handle = cmd_desc->mem_handle;
+ kmd_buf->offset = cmd_desc->offset + packet->kmd_cmd_buf_offset;
+ kmd_buf->size = cmd_desc->size - cmd_desc->length;
+ kmd_buf->used_bytes = 0;
+
+ return rc;
+}
int cam_packet_util_process_patches(struct cam_packet *packet,
int32_t iommu_hdl)
@@ -36,7 +143,7 @@ int cam_packet_util_process_patches(struct cam_packet *packet,
patch_desc = (struct cam_patch_desc *)
((uint32_t *) &packet->payload +
packet->patch_offset/4);
- CDBG("packet = %pK patch_desc = %pK size = %lu\n",
+ CAM_DBG(CAM_UTIL, "packet = %pK patch_desc = %pK size = %lu",
(void *)packet, (void *)patch_desc,
sizeof(struct cam_patch_desc));
@@ -44,7 +151,7 @@ int cam_packet_util_process_patches(struct cam_packet *packet,
rc = cam_mem_get_io_buf(patch_desc[i].src_buf_hdl,
iommu_hdl, &iova_addr, &src_buf_size);
if (rc < 0) {
- pr_err("unable to get src buf address\n");
+ CAM_ERR(CAM_UTIL, "unable to get src buf address");
return rc;
}
src_buf_iova_addr = (uint32_t *)iova_addr;
@@ -53,12 +160,12 @@ int cam_packet_util_process_patches(struct cam_packet *packet,
rc = cam_mem_get_cpu_buf(patch_desc[i].dst_buf_hdl,
&cpu_addr, &dst_buf_len);
if (rc < 0) {
- pr_err("unable to get dst buf address\n");
+ CAM_ERR(CAM_UTIL, "unable to get dst buf address");
return rc;
}
dst_cpu_addr = (uint32_t *)cpu_addr;
- CDBG("i = %d patch info = %x %x %x %x\n", i,
+ CAM_DBG(CAM_UTIL, "i = %d patch info = %x %x %x %x", i,
patch_desc[i].dst_buf_hdl, patch_desc[i].dst_offset,
patch_desc[i].src_buf_hdl, patch_desc[i].src_offset);
@@ -68,7 +175,8 @@ int cam_packet_util_process_patches(struct cam_packet *packet,
*dst_cpu_addr = temp;
- CDBG("patch is done for dst %pK with src %pK value %llx\n",
+ CAM_DBG(CAM_UTIL,
+ "patch is done for dst %pK with src %pK value %llx",
dst_cpu_addr, src_buf_iova_addr,
*((uint64_t *)dst_cpu_addr));
}
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.h b/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.h
index 614e868..8b590a7 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.h
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_packet_util.h
@@ -16,6 +16,62 @@
#include <uapi/media/cam_defs.h>
/**
+ * @brief KMD scratch buffer information
+ *
+ * @handle: Memory handle
+ * @cpu_addr: Cpu address
+ * @offset: Offset from the start of the buffer
+ * @size: Size of the buffer
+ * @used_bytes: Used memory in bytes
+ *
+ */
+struct cam_kmd_buf_info {
+ int handle;
+ uint32_t *cpu_addr;
+ uint32_t offset;
+ uint32_t size;
+ uint32_t used_bytes;
+};
+
+/**
+ * cam_packet_util_validate_packet()
+ *
+ * @brief Validate the packet
+ *
+ * @packet: Packet to be validated
+ *
+ * @return: 0 for success
+ * -EINVAL for Fail
+ */
+int cam_packet_util_validate_packet(struct cam_packet *packet);
+
+/**
+ * cam_packet_util_validate_cmd_desc()
+ *
+ * @brief Validate the packet
+ *
+ * @cmd_desc: Command descriptor to be validated
+ *
+ * @return: 0 for success
+ * -EINVAL for Fail
+ */
+int cam_packet_util_validate_cmd_desc(struct cam_cmd_buf_desc *cmd_desc);
+
+/**
+ * cam_packet_util_get_kmd_buffer()
+ *
+ * @brief Get the kmd buffer from the packet command descriptor
+ *
+ * @packet: Packet data
+ * @kmd_buf: Extracted the KMD buffer information
+ *
+ * @return: 0 for success
+ * -EINVAL for Fail
+ */
+int cam_packet_util_get_kmd_buffer(struct cam_packet *packet,
+ struct cam_kmd_buf_info *kmd_buf_info);
+
+/**
* cam_packet_util_process_patches()
*
* @brief: Replace the handle in Packet to Address using the
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_trace.h b/drivers/media/platform/msm/camera/cam_utils/cam_trace.h
index f233799..2e9e61f 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_trace.h
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_trace.h
@@ -23,6 +23,8 @@
#include <linux/tracepoint.h>
#include <media/cam_req_mgr.h>
+#include "cam_req_mgr_core.h"
+#include "cam_req_mgr_interface.h"
#include "cam_context.h"
TRACE_EVENT(cam_context_state,
@@ -107,19 +109,112 @@ TRACE_EVENT(cam_apply_req,
);
TRACE_EVENT(cam_flush_req,
- TP_PROTO(struct cam_req_mgr_flush_info *info),
- TP_ARGS(info),
+ TP_PROTO(struct cam_req_mgr_core_link *link,
+ struct cam_req_mgr_flush_info *info),
+ TP_ARGS(link, info),
TP_STRUCT__entry(
__field(uint32_t, type)
__field(int64_t, req_id)
+ __field(void*, link)
+ __field(void*, session)
),
TP_fast_assign(
- __entry->type = info->flush_type;
- __entry->req_id = info->req_id;
+ __entry->type = info->flush_type;
+ __entry->req_id = info->req_id;
+ __entry->link = link;
+ __entry->session = link->parent;
),
TP_printk(
- "FlushRequest type=%u request=%llu",
- __entry->type, __entry->req_id
+ "FlushRequest type=%u request=%llu link=%pK session=%pK",
+ __entry->type, __entry->req_id, __entry->link,
+ __entry->session
+ )
+);
+
+TRACE_EVENT(cam_req_mgr_connect_device,
+ TP_PROTO(struct cam_req_mgr_core_link *link,
+ struct cam_req_mgr_device_info *info),
+ TP_ARGS(link, info),
+ TP_STRUCT__entry(
+ __string(name, info->name)
+ __field(uint32_t, id)
+ __field(uint32_t, delay)
+ __field(void*, link)
+ __field(void*, session)
+ ),
+ TP_fast_assign(
+ __assign_str(name, info->name);
+ __entry->id = info->dev_id;
+ __entry->delay = info->p_delay;
+ __entry->link = link;
+ __entry->session = link->parent;
+ ),
+ TP_printk(
+ "ReqMgr Connect name=%s id=%u pd=%d link=%pK session=%pK",
+ __get_str(name), __entry->id, __entry->delay,
+ __entry->link, __entry->session
+ )
+);
+
+TRACE_EVENT(cam_req_mgr_apply_request,
+ TP_PROTO(struct cam_req_mgr_core_link *link,
+ struct cam_req_mgr_apply_request *req,
+ struct cam_req_mgr_connected_device *dev),
+ TP_ARGS(link, req, dev),
+ TP_STRUCT__entry(
+ __string(name, dev->dev_info.name)
+ __field(uint32_t, dev_id)
+ __field(uint64_t, req_id)
+ __field(void*, link)
+ __field(void*, session)
+ ),
+ TP_fast_assign(
+ __assign_str(name, dev->dev_info.name);
+ __entry->dev_id = dev->dev_info.dev_id;
+ __entry->req_id = req->request_id;
+ __entry->link = link;
+ __entry->session = link->parent;
+ ),
+ TP_printk(
+ "ReqMgr ApplyRequest devname=%s devid=%u request=%lld link=%pK session=%pK",
+ __get_str(name), __entry->dev_id, __entry->req_id,
+ __entry->link, __entry->session
+ )
+);
+
+TRACE_EVENT(cam_req_mgr_add_req,
+ TP_PROTO(struct cam_req_mgr_core_link *link,
+ int idx, struct cam_req_mgr_add_request *add_req,
+ struct cam_req_mgr_req_tbl *tbl,
+ struct cam_req_mgr_connected_device *dev),
+ TP_ARGS(link, idx, add_req, tbl, dev),
+ TP_STRUCT__entry(
+ __string(name, dev->dev_info.name)
+ __field(uint32_t, dev_id)
+ __field(uint64_t, req_id)
+ __field(uint32_t, slot_id)
+ __field(uint32_t, delay)
+ __field(uint32_t, readymap)
+ __field(uint32_t, devicemap)
+ __field(void*, link)
+ __field(void*, session)
+ ),
+ TP_fast_assign(
+ __assign_str(name, dev->dev_info.name);
+ __entry->dev_id = dev->dev_info.dev_id;
+ __entry->req_id = add_req->req_id;
+ __entry->slot_id = idx;
+ __entry->delay = tbl->pd;
+ __entry->readymap = tbl->slot[idx].req_ready_map;
+ __entry->devicemap = tbl->dev_mask;
+ __entry->link = link;
+ __entry->session = link->parent;
+ ),
+ TP_printk(
+ "ReqMgr AddRequest devname=%s devid=%d request=%lld slot=%d pd=%d readymap=%x devicemap=%d link=%pk session=%pK",
+ __get_str(name), __entry->dev_id, __entry->req_id,
+ __entry->slot_id, __entry->delay, __entry->readymap,
+ __entry->devicemap, __entry->link, __entry->session
)
);
#endif /* _CAM_TRACE_H */
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_debug.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_debug.c
index 3e686e9..da36e38 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_debug.c
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_debug.c
@@ -1136,6 +1136,9 @@ static ssize_t sde_rotator_debug_base_offset_write(struct file *file,
if (sscanf(buf, "%5x %x", &off, &cnt) < 2)
return -EINVAL;
+ if (off % sizeof(u32))
+ return -EINVAL;
+
if (off > dbg->max_offset)
return -EINVAL;
@@ -1204,6 +1207,9 @@ static ssize_t sde_rotator_debug_base_reg_write(struct file *file,
if (cnt < 2)
return -EFAULT;
+ if (off % sizeof(u32))
+ return -EFAULT;
+
if (off >= dbg->max_offset)
return -EFAULT;
@@ -1252,6 +1258,9 @@ static ssize_t sde_rotator_debug_base_reg_read(struct file *file,
goto debug_read_error;
}
+ if (dbg->off % sizeof(u32))
+ return -EFAULT;
+
ptr = dbg->base + dbg->off;
tot = 0;
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c
index d300de2..8727535 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_dev.c
@@ -486,7 +486,7 @@ static void sde_rotator_stop_streaming(struct vb2_queue *q)
struct sde_rotator_vbinfo *vbinfo =
&ctx->vbinfo_cap[i];
- if (vbinfo->fence && vbinfo->fd < 0) {
+ if (vbinfo->fence) {
/* fence is not used */
SDEDEV_DBG(rot_dev->dev,
"put fence s:%d t:%d i:%d\n",
@@ -2158,7 +2158,7 @@ static int sde_rotator_dqbuf(struct file *file,
&& (buf->index < ctx->nbuf_cap)) {
int idx = buf->index;
- if (ctx->vbinfo_cap[idx].fence && ctx->vbinfo_cap[idx].fd < 0) {
+ if (ctx->vbinfo_cap[idx].fence) {
/* fence is not used */
SDEDEV_DBG(ctx->rot_dev->dev, "put fence s:%d i:%d\n",
ctx->session_id, idx);
@@ -2487,6 +2487,7 @@ static long sde_rotator_private_ioctl(struct file *file, void *fh,
struct msm_sde_rotator_fence *fence = arg;
struct msm_sde_rotator_comp_ratio *comp_ratio = arg;
struct sde_rotator_vbinfo *vbinfo;
+ int ret;
switch (cmd) {
case VIDIOC_S_SDE_ROTATOR_FENCE:
@@ -2545,17 +2546,37 @@ static long sde_rotator_private_ioctl(struct file *file, void *fh,
vbinfo = &ctx->vbinfo_cap[fence->index];
- if (vbinfo->fence == NULL) {
- vbinfo->fd = -1;
- } else {
- vbinfo->fd =
- sde_rotator_get_sync_fence_fd(vbinfo->fence);
- if (vbinfo->fd < 0) {
+ if (!vbinfo)
+ return -EINVAL;
+
+ if (vbinfo->fence) {
+ ret = sde_rotator_get_sync_fence_fd(vbinfo->fence);
+ if (ret < 0) {
SDEDEV_ERR(rot_dev->dev,
- "fail get fence fd s:%d\n",
- ctx->session_id);
- return vbinfo->fd;
+ "fail get fence fd s:%d\n",
+ ctx->session_id);
+ return ret;
}
+
+ /**
+ * Loose any reference to sync fence once we pass
+ * it to user. Driver does not clean up user
+ * unclosed fence descriptors.
+ */
+ vbinfo->fence = NULL;
+
+ /**
+ * Cache fence descriptor in case user calls this
+ * ioctl multiple times. Cached value would be stale
+ * if user duplicated and closed old descriptor.
+ */
+ vbinfo->fd = ret;
+ } else if (!sde_rotator_get_fd_sync_fence(vbinfo->fd)) {
+ /**
+ * User has closed cached fence descriptor.
+ * Invalidate descriptor cache.
+ */
+ vbinfo->fd = -1;
}
fence->fd = vbinfo->fd;
diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_formats.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_formats.c
index 573e0a8..27e9ba6 100644
--- a/drivers/media/platform/msm/sde/rotator/sde_rotator_formats.c
+++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_formats.c
@@ -783,10 +783,15 @@ struct sde_mdp_format_params *sde_get_format_params(u32 format)
if (!fmt_found) {
for (i = 0; i < ARRAY_SIZE(sde_mdp_format_ubwc_map); i++) {
fmt = &sde_mdp_format_ubwc_map[i].mdp_format;
- if (format == fmt->format)
+ if (format == fmt->format) {
+ fmt_found = true;
break;
+ }
}
}
+ /* If format not supported than return NULL */
+ if (!fmt_found)
+ fmt = NULL;
return fmt;
}
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.c b/drivers/media/platform/msm/vidc/msm_vidc_common.c
index 03ad0a0..ee538a9 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_common.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_common.c
@@ -4067,9 +4067,14 @@ int msm_vidc_update_host_buff_counts(struct msm_vidc_inst *inst)
return -EINVAL;
}
extra_buffers = msm_vidc_get_extra_buff_count(inst, HAL_BUFFER_INPUT);
-
bufreq->buffer_count_min_host = bufreq->buffer_count_min +
extra_buffers;
+ bufreq = get_buff_req_buffer(inst, HAL_BUFFER_EXTRADATA_INPUT);
+ if (bufreq) {
+ if (bufreq->buffer_count_min)
+ bufreq->buffer_count_min_host =
+ bufreq->buffer_count_min + extra_buffers;
+ }
if (msm_comm_get_stream_output_mode(inst) ==
HAL_VIDEO_DECODER_SECONDARY) {
diff --git a/drivers/mmc/host/sdhci-msm-ice.c b/drivers/mmc/host/sdhci-msm-ice.c
index acc4ae0..d624b48 100644
--- a/drivers/mmc/host/sdhci-msm-ice.c
+++ b/drivers/mmc/host/sdhci-msm-ice.c
@@ -212,6 +212,38 @@ void sdhci_msm_ice_cfg_reset(struct sdhci_host *host, u32 slot)
}
static
+int sdhci_msm_ice_get_cfg(struct sdhci_msm_host *msm_host, struct request *req,
+ unsigned int *bypass, short *key_index)
+{
+ int err = 0;
+ struct ice_data_setting ice_set;
+
+ memset(&ice_set, 0, sizeof(struct ice_data_setting));
+ if (msm_host->ice.vops->config_start) {
+ err = msm_host->ice.vops->config_start(
+ msm_host->ice.pdev,
+ req, &ice_set, false);
+ if (err) {
+ pr_err("%s: ice config failed %d\n",
+ mmc_hostname(msm_host->mmc), err);
+ return err;
+ }
+ }
+ /* if writing data command */
+ if (rq_data_dir(req) == WRITE)
+ *bypass = ice_set.encr_bypass ?
+ SDHCI_MSM_ICE_ENABLE_BYPASS :
+ SDHCI_MSM_ICE_DISABLE_BYPASS;
+ /* if reading data command */
+ else if (rq_data_dir(req) == READ)
+ *bypass = ice_set.decr_bypass ?
+ SDHCI_MSM_ICE_ENABLE_BYPASS :
+ SDHCI_MSM_ICE_DISABLE_BYPASS;
+ *key_index = ice_set.crypto_data.key_index;
+ return err;
+}
+
+static
void sdhci_msm_ice_update_cfg(struct sdhci_host *host, u64 lba,
u32 slot, unsigned int bypass, short key_index)
{
@@ -250,7 +282,7 @@ int sdhci_msm_ice_cfg(struct sdhci_host *host, struct mmc_request *mrq,
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_msm_host *msm_host = pltfm_host->priv;
int err = 0;
- struct ice_data_setting ice_set;
+ short key_index = 0;
sector_t lba = 0;
unsigned int bypass = SDHCI_MSM_ICE_ENABLE_BYPASS;
struct request *req;
@@ -261,41 +293,22 @@ int sdhci_msm_ice_cfg(struct sdhci_host *host, struct mmc_request *mrq,
return -EINVAL;
}
- BUG_ON(!mrq);
- memset(&ice_set, 0, sizeof(struct ice_data_setting));
+ WARN_ON(!mrq);
+ if (!mrq)
+ return -EINVAL;
req = mrq->req;
if (req) {
lba = req->__sector;
- if (msm_host->ice.vops->config_start) {
- err = msm_host->ice.vops->config_start(
- msm_host->ice.pdev,
- req, &ice_set, false);
- if (err) {
- pr_err("%s: ice config failed %d\n",
- mmc_hostname(host->mmc), err);
- return err;
- }
- }
- /* if writing data command */
- if (rq_data_dir(req) == WRITE)
- bypass = ice_set.encr_bypass ?
- SDHCI_MSM_ICE_ENABLE_BYPASS :
- SDHCI_MSM_ICE_DISABLE_BYPASS;
- /* if reading data command */
- else if (rq_data_dir(req) == READ)
- bypass = ice_set.decr_bypass ?
- SDHCI_MSM_ICE_ENABLE_BYPASS :
- SDHCI_MSM_ICE_DISABLE_BYPASS;
- pr_debug("%s: %s: slot %d encr_bypass %d bypass %d decr_bypass %d key_index %d\n",
+ err = sdhci_msm_ice_get_cfg(msm_host, req, &bypass, &key_index);
+ if (err)
+ return err;
+ pr_debug("%s: %s: slot %d bypass %d key_index %d\n",
mmc_hostname(host->mmc),
(rq_data_dir(req) == WRITE) ? "WRITE" : "READ",
- slot, ice_set.encr_bypass, bypass,
- ice_set.decr_bypass,
- ice_set.crypto_data.key_index);
+ slot, bypass, key_index);
}
- sdhci_msm_ice_update_cfg(host, lba, slot, bypass,
- ice_set.crypto_data.key_index);
+ sdhci_msm_ice_update_cfg(host, lba, slot, bypass, key_index);
return 0;
}
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index b6c17ec0..4b45ea5 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -691,7 +691,7 @@ static inline void msm_cm_dll_set_freq(struct sdhci_host *host)
mclk_freq = 5;
else if (host->clock <= 187000000)
mclk_freq = 6;
- else if (host->clock <= 200000000)
+ else if (host->clock <= 208000000)
mclk_freq = 7;
writel_relaxed(((readl_relaxed(host->ioaddr +
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 9520166..db15141 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -951,7 +951,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
ret = gpiochip_irqchip_add(chip,
&msm_gpio_irq_chip,
0,
- handle_edge_irq,
+ handle_fasteoi_irq,
IRQ_TYPE_NONE);
if (ret) {
dev_err(pctrl->dev, "Failed to add irqchip to gpiochip\n");
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa.c b/drivers/platform/msm/ipa/ipa_v2/ipa.c
index 53ab299..bfd0446 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa.c
@@ -641,7 +641,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_nat_dma_cmd *)param)->entries
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_nat_dma_cmd *)param)->entries,
pre_entry);
retval = -EFAULT;
@@ -688,7 +688,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_add_hdr *)param)->num_hdrs
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_add_hdr *)param)->num_hdrs,
pre_entry);
retval = -EFAULT;
@@ -727,7 +727,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_del_hdr *)param)->num_hdls
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_del_hdr *)param)->num_hdls,
pre_entry);
retval = -EFAULT;
@@ -767,7 +767,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_add_rt_rule *)param)->num_rules
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_add_rt_rule *)param)->
num_rules,
pre_entry);
@@ -807,7 +807,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_mdfy_rt_rule *)param)->num_rules
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_mdfy_rt_rule *)param)->
num_rules,
pre_entry);
@@ -847,7 +847,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_del_rt_rule *)param)->num_hdls
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_del_rt_rule *)param)->num_hdls,
pre_entry);
retval = -EFAULT;
@@ -886,7 +886,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_add_flt_rule *)param)->num_rules
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_add_flt_rule *)param)->
num_rules,
pre_entry);
@@ -926,7 +926,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_del_flt_rule *)param)->num_hdls
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_del_flt_rule *)param)->
num_hdls,
pre_entry);
@@ -966,7 +966,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_mdfy_flt_rule *)param)->num_rules
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_mdfy_flt_rule *)param)->
num_rules,
pre_entry);
@@ -1104,7 +1104,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
if (unlikely(((struct ipa_ioc_query_intf_tx_props *)
param)->num_tx_props
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_query_intf_tx_props *)
param)->num_tx_props, pre_entry);
retval = -EFAULT;
@@ -1149,7 +1149,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_query_intf_rx_props *)
param)->num_rx_props != pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_query_intf_rx_props *)
param)->num_rx_props, pre_entry);
retval = -EFAULT;
@@ -1194,7 +1194,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_query_intf_ext_props *)
param)->num_ext_props != pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_query_intf_ext_props *)
param)->num_ext_props, pre_entry);
retval = -EFAULT;
@@ -1232,7 +1232,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_msg_meta *)param)->msg_len
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_msg_meta *)param)->msg_len,
pre_entry);
retval = -EFAULT;
@@ -1372,7 +1372,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_add_hdr_proc_ctx *)
param)->num_proc_ctxs != pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_add_hdr_proc_ctx *)
param)->num_proc_ctxs, pre_entry);
retval = -EFAULT;
@@ -1411,7 +1411,7 @@ static long ipa_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_del_hdr_proc_ctx *)
param)->num_hdls != pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_del_hdr_proc_ctx *)param)->
num_hdls,
pre_entry);
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_flt.c b/drivers/platform/msm/ipa/ipa_v2/ipa_flt.c
index 8d9f0e0..f7b0864 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_flt.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_flt.c
@@ -1015,25 +1015,25 @@ static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
if (rule->action != IPA_PASS_TO_EXCEPTION) {
if (!rule->eq_attrib_type) {
if (!rule->rt_tbl_hdl) {
- IPAERR("invalid RT tbl\n");
+ IPAERR_RL("invalid RT tbl\n");
goto error;
}
rt_tbl = ipa_id_find(rule->rt_tbl_hdl);
if (rt_tbl == NULL) {
- IPAERR("RT tbl not found\n");
+ IPAERR_RL("RT tbl not found\n");
goto error;
}
if (rt_tbl->cookie != IPA_RT_TBL_COOKIE) {
- IPAERR("RT table cookie is invalid\n");
+ IPAERR_RL("RT table cookie is invalid\n");
goto error;
}
} else {
if (rule->rt_tbl_idx > ((ip == IPA_IP_v4) ?
IPA_MEM_PART(v4_modem_rt_index_hi) :
IPA_MEM_PART(v6_modem_rt_index_hi))) {
- IPAERR("invalid RT tbl\n");
+ IPAERR_RL("invalid RT tbl\n");
goto error;
}
}
@@ -1089,12 +1089,12 @@ static int __ipa_del_flt_rule(u32 rule_hdl)
entry = ipa_id_find(rule_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
return -EINVAL;
}
if (entry->cookie != IPA_FLT_COOKIE) {
- IPAERR("bad params\n");
+ IPAERR_RL("bad params\n");
return -EINVAL;
}
id = entry->id;
@@ -1121,12 +1121,12 @@ static int __ipa_mdfy_flt_rule(struct ipa_flt_rule_mdfy *frule,
entry = ipa_id_find(frule->rule_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
goto error;
}
if (entry->cookie != IPA_FLT_COOKIE) {
- IPAERR("bad params\n");
+ IPAERR_RL("bad params\n");
goto error;
}
@@ -1136,25 +1136,25 @@ static int __ipa_mdfy_flt_rule(struct ipa_flt_rule_mdfy *frule,
if (frule->rule.action != IPA_PASS_TO_EXCEPTION) {
if (!frule->rule.eq_attrib_type) {
if (!frule->rule.rt_tbl_hdl) {
- IPAERR("invalid RT tbl\n");
+ IPAERR_RL("invalid RT tbl\n");
goto error;
}
rt_tbl = ipa_id_find(frule->rule.rt_tbl_hdl);
if (rt_tbl == NULL) {
- IPAERR("RT tbl not found\n");
+ IPAERR_RL("RT tbl not found\n");
goto error;
}
if (rt_tbl->cookie != IPA_RT_TBL_COOKIE) {
- IPAERR("RT table cookie is invalid\n");
+ IPAERR_RL("RT table cookie is invalid\n");
goto error;
}
} else {
if (frule->rule.rt_tbl_idx > ((ip == IPA_IP_v4) ?
IPA_MEM_PART(v4_modem_rt_index_hi) :
IPA_MEM_PART(v6_modem_rt_index_hi))) {
- IPAERR("invalid RT tbl\n");
+ IPAERR_RL("invalid RT tbl\n");
goto error;
}
}
@@ -1178,7 +1178,7 @@ static int __ipa_add_global_flt_rule(enum ipa_ip_type ip,
struct ipa_flt_tbl *tbl;
if (rule == NULL || rule_hdl == NULL) {
- IPAERR("bad parms rule=%p rule_hdl=%p\n", rule, rule_hdl);
+ IPAERR_RL("bad parms rule=%p rule_hdl=%p\n", rule, rule_hdl);
return -EINVAL;
}
@@ -1197,14 +1197,14 @@ static int __ipa_add_ep_flt_rule(enum ipa_ip_type ip, enum ipa_client_type ep,
int ipa_ep_idx;
if (rule == NULL || rule_hdl == NULL || ep >= IPA_CLIENT_MAX) {
- IPAERR("bad parms rule=%p rule_hdl=%p ep=%d\n", rule,
+ IPAERR_RL("bad parms rule=%p rule_hdl=%p ep=%d\n", rule,
rule_hdl, ep);
return -EINVAL;
}
ipa_ep_idx = ipa2_get_ep_mapping(ep);
if (ipa_ep_idx == IPA_FLT_TABLE_INDEX_NOT_FOUND) {
- IPAERR("ep not valid ep=%d\n", ep);
+ IPAERR_RL("ep not valid ep=%d\n", ep);
return -EINVAL;
}
if (ipa_ctx->ep[ipa_ep_idx].valid == 0)
@@ -1231,7 +1231,7 @@ int ipa2_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
if (rules == NULL || rules->num_rules == 0 ||
rules->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1249,7 +1249,7 @@ int ipa2_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
rules->rules[i].at_rear,
&rules->rules[i].flt_rule_hdl);
if (result) {
- IPAERR("failed to add flt rule %d\n", i);
+ IPAERR_RL("failed to add flt rule %d\n", i);
rules->rules[i].status = IPA_FLT_STATUS_OF_ADD_FAILED;
} else {
rules->rules[i].status = 0;
@@ -1282,14 +1282,14 @@ int ipa2_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls)
int result;
if (hdls == NULL || hdls->num_hdls == 0 || hdls->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa_ctx->lock);
for (i = 0; i < hdls->num_hdls; i++) {
if (__ipa_del_flt_rule(hdls->hdl[i].hdl)) {
- IPAERR("failed to del rt rule %i\n", i);
+ IPAERR_RL("failed to del rt rule %i\n", i);
hdls->hdl[i].status = IPA_FLT_STATUS_OF_DEL_FAILED;
} else {
hdls->hdl[i].status = 0;
@@ -1322,14 +1322,14 @@ int ipa2_mdfy_flt_rule(struct ipa_ioc_mdfy_flt_rule *hdls)
int result;
if (hdls == NULL || hdls->num_rules == 0 || hdls->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa_ctx->lock);
for (i = 0; i < hdls->num_rules; i++) {
if (__ipa_mdfy_flt_rule(&hdls->rules[i], hdls->ip)) {
- IPAERR("failed to mdfy rt rule %i\n", i);
+ IPAERR_RL("failed to mdfy rt rule %i\n", i);
hdls->rules[i].status = IPA_FLT_STATUS_OF_MDFY_FAILED;
} else {
hdls->rules[i].status = 0;
@@ -1363,7 +1363,7 @@ int ipa2_commit_flt(enum ipa_ip_type ip)
int result;
if (ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1399,7 +1399,7 @@ int ipa2_reset_flt(enum ipa_ip_type ip)
int id;
if (ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_hdr.c b/drivers/platform/msm/ipa/ipa_v2/ipa_hdr.c
index a6a7613..c8663c9 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_hdr.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_hdr.c
@@ -558,13 +558,13 @@ static int __ipa_add_hdr_proc_ctx(struct ipa_hdr_proc_ctx_add *proc_ctx,
proc_ctx->type, proc_ctx->hdr_hdl);
if (!HDR_PROC_TYPE_IS_VALID(proc_ctx->type)) {
- IPAERR("invalid processing type %d\n", proc_ctx->type);
+ IPAERR_RL("invalid processing type %d\n", proc_ctx->type);
return -EINVAL;
}
hdr_entry = ipa_id_find(proc_ctx->hdr_hdl);
if (!hdr_entry || (hdr_entry->cookie != IPA_HDR_COOKIE)) {
- IPAERR("hdr_hdl is invalid\n");
+ IPAERR_RL("hdr_hdl is invalid\n");
return -EINVAL;
}
@@ -592,7 +592,7 @@ static int __ipa_add_hdr_proc_ctx(struct ipa_hdr_proc_ctx_add *proc_ctx,
ipa_hdr_proc_ctx_bin_sz[IPA_HDR_PROC_CTX_BIN1]) {
bin = IPA_HDR_PROC_CTX_BIN1;
} else {
- IPAERR("unexpected needed len %d\n", needed_len);
+ IPAERR_RL("unexpected needed len %d\n", needed_len);
WARN_ON(1);
goto bad_len;
}
@@ -602,7 +602,7 @@ static int __ipa_add_hdr_proc_ctx(struct ipa_hdr_proc_ctx_add *proc_ctx,
IPA_MEM_PART(apps_hdr_proc_ctx_size_ddr);
if (list_empty(&htbl->head_free_offset_list[bin])) {
if (htbl->end + ipa_hdr_proc_ctx_bin_sz[bin] > mem_size) {
- IPAERR("hdr proc ctx table overflow\n");
+ IPAERR_RL("hdr proc ctx table overflow\n");
goto bad_len;
}
@@ -676,12 +676,12 @@ static int __ipa_add_hdr(struct ipa_hdr_add *hdr)
gfp_t flag = GFP_KERNEL | (ipa_ctx->use_dma_zone ? GFP_DMA : 0);
if (hdr->hdr_len == 0 || hdr->hdr_len > IPA_HDR_MAX_SIZE) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
goto error;
}
if (!HDR_TYPE_IS_VALID(hdr->type)) {
- IPAERR("invalid hdr type %d\n", hdr->type);
+ IPAERR_RL("invalid hdr type %d\n", hdr->type);
goto error;
}
@@ -713,7 +713,7 @@ static int __ipa_add_hdr(struct ipa_hdr_add *hdr)
else if (hdr->hdr_len <= ipa_hdr_bin_sz[IPA_HDR_BIN4])
bin = IPA_HDR_BIN4;
else {
- IPAERR("unexpected hdr len %d\n", hdr->hdr_len);
+ IPAERR_RL("unexpected hdr len %d\n", hdr->hdr_len);
goto bad_hdr_len;
}
@@ -844,7 +844,7 @@ static int __ipa_del_hdr_proc_ctx(u32 proc_ctx_hdl,
entry = ipa_id_find(proc_ctx_hdl);
if (!entry || (entry->cookie != IPA_PROC_HDR_COOKIE)) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -852,7 +852,7 @@ static int __ipa_del_hdr_proc_ctx(u32 proc_ctx_hdl,
htbl->proc_ctx_cnt, entry->offset_entry->offset);
if (by_user && entry->user_deleted) {
- IPAERR("proc_ctx already deleted by user\n");
+ IPAERR_RL("proc_ctx already deleted by user\n");
return -EINVAL;
}
@@ -890,12 +890,12 @@ int __ipa_del_hdr(u32 hdr_hdl, bool by_user)
entry = ipa_id_find(hdr_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
return -EINVAL;
}
if (entry->cookie != IPA_HDR_COOKIE) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -907,7 +907,7 @@ int __ipa_del_hdr(u32 hdr_hdl, bool by_user)
htbl->hdr_cnt, entry->offset_entry->offset);
if (by_user && entry->user_deleted) {
- IPAERR("hdr already deleted by user\n");
+ IPAERR_RL("hdr already deleted by user\n");
return -EINVAL;
}
@@ -956,12 +956,12 @@ int ipa2_add_hdr(struct ipa_ioc_add_hdr *hdrs)
int result = -EFAULT;
if (unlikely(!ipa_ctx)) {
- IPAERR("IPA driver was not initialized\n");
+ IPAERR_RL("IPA driver was not initialized\n");
return -EINVAL;
}
if (hdrs == NULL || hdrs->num_hdrs == 0) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -970,7 +970,7 @@ int ipa2_add_hdr(struct ipa_ioc_add_hdr *hdrs)
hdrs->num_hdrs);
for (i = 0; i < hdrs->num_hdrs; i++) {
if (__ipa_add_hdr(&hdrs->hdr[i])) {
- IPAERR("failed to add hdr %d\n", i);
+ IPAERR_RL("failed to add hdr %d\n", i);
hdrs->hdr[i].status = -1;
} else {
hdrs->hdr[i].status = 0;
@@ -1011,14 +1011,14 @@ int ipa2_del_hdr_by_user(struct ipa_ioc_del_hdr *hdls, bool by_user)
}
if (hdls == NULL || hdls->num_hdls == 0) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa_ctx->lock);
for (i = 0; i < hdls->num_hdls; i++) {
if (__ipa_del_hdr(hdls->hdl[i].hdl, by_user)) {
- IPAERR("failed to del hdr %i\n", i);
+ IPAERR_RL("failed to del hdr %i\n", i);
hdls->hdl[i].status = -1;
} else {
hdls->hdl[i].status = 0;
@@ -1067,13 +1067,13 @@ int ipa2_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs)
if (ipa_ctx->ipa_hw_type <= IPA_HW_v2_0 ||
ipa_ctx->ipa_hw_type == IPA_HW_v2_6L) {
- IPAERR("Processing context not supported on IPA HW %d\n",
+ IPAERR_RL("Processing context not supported on IPA HW %d\n",
ipa_ctx->ipa_hw_type);
return -EFAULT;
}
if (proc_ctxs == NULL || proc_ctxs->num_proc_ctxs == 0) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1082,7 +1082,7 @@ int ipa2_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs)
proc_ctxs->num_proc_ctxs);
for (i = 0; i < proc_ctxs->num_proc_ctxs; i++) {
if (__ipa_add_hdr_proc_ctx(&proc_ctxs->proc_ctx[i], true)) {
- IPAERR("failed to add hdr pric ctx %d\n", i);
+ IPAERR_RL("failed to add hdr pric ctx %d\n", i);
proc_ctxs->proc_ctx[i].status = -1;
} else {
proc_ctxs->proc_ctx[i].status = 0;
@@ -1127,14 +1127,14 @@ int ipa2_del_hdr_proc_ctx_by_user(struct ipa_ioc_del_hdr_proc_ctx *hdls,
}
if (hdls == NULL || hdls->num_hdls == 0) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa_ctx->lock);
for (i = 0; i < hdls->num_hdls; i++) {
if (__ipa_del_hdr_proc_ctx(hdls->hdl[i].hdl, true, by_user)) {
- IPAERR("failed to del hdr %i\n", i);
+ IPAERR_RL("failed to del hdr %i\n", i);
hdls->hdl[i].status = -1;
} else {
hdls->hdl[i].status = 0;
@@ -1371,7 +1371,7 @@ int ipa2_get_hdr(struct ipa_ioc_get_hdr *lookup)
}
if (lookup == NULL) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa_ctx->lock);
@@ -1458,13 +1458,13 @@ int ipa2_put_hdr(u32 hdr_hdl)
entry = ipa_id_find(hdr_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
result = -EINVAL;
goto bail;
}
if (entry->cookie != IPA_HDR_COOKIE) {
- IPAERR("invalid header entry\n");
+ IPAERR_RL("invalid header entry\n");
result = -EINVAL;
goto bail;
}
@@ -1493,7 +1493,7 @@ int ipa2_copy_hdr(struct ipa_ioc_copy_hdr *copy)
int result = -EFAULT;
if (copy == NULL) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa_ctx->lock);
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_i.h b/drivers/platform/msm/ipa/ipa_v2/ipa_i.h
index 0c2410f..a85addb 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_i.h
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_i.h
@@ -68,6 +68,18 @@
#define IPAERR(fmt, args...) \
pr_err(DRV_NAME " %s:%d " fmt, __func__, __LINE__, ## args)
+#define IPAERR_RL(fmt, args...) \
+ do { \
+ pr_err_ratelimited(DRV_NAME " %s:%d " fmt, __func__, \
+ __LINE__, ## args);\
+ if (ipa_ctx) { \
+ IPA_IPC_LOGGING(ipa_ctx->logbuf, \
+ DRV_NAME " %s:%d " fmt, ## args); \
+ IPA_IPC_LOGGING(ipa_ctx->logbuf_low, \
+ DRV_NAME " %s:%d " fmt, ## args); \
+ } \
+ } while (0)
+
#define WLAN_AMPDU_TX_EP 15
#define WLAN_PROD_TX_EP 19
#define WLAN1_CONS_RX_EP 14
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_intf.c b/drivers/platform/msm/ipa/ipa_v2/ipa_intf.c
index 12b1a99..e6954b7 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_intf.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_intf.c
@@ -404,13 +404,13 @@ int ipa2_send_msg(struct ipa_msg_meta *meta, void *buff,
if (meta == NULL || (buff == NULL && callback != NULL) ||
(buff != NULL && callback == NULL)) {
- IPAERR("invalid param meta=%p buff=%p, callback=%p\n",
+ IPAERR_RL("invalid param meta=%p buff=%p, callback=%p\n",
meta, buff, callback);
return -EINVAL;
}
if (meta->msg_type >= IPA_EVENT_MAX_NUM) {
- IPAERR("unsupported message type %d\n", meta->msg_type);
+ IPAERR_RL("unsupported message type %d\n", meta->msg_type);
return -EINVAL;
}
@@ -633,7 +633,7 @@ int ipa_pull_msg(struct ipa_msg_meta *meta, char *buff, size_t count)
int result = -EINVAL;
if (meta == NULL || buff == NULL || !count) {
- IPAERR("invalid param name=%p buff=%p count=%zu\n",
+ IPAERR_RL("invalid param name=%p buff=%p count=%zu\n",
meta, buff, count);
return result;
}
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_nat.c b/drivers/platform/msm/ipa/ipa_v2/ipa_nat.c
index a7f983e..50b2706 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_nat.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_nat.c
@@ -252,8 +252,8 @@ int ipa2_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem)
mutex_lock(&nat_ctx->lock);
if (strcmp(mem->dev_name, NAT_DEV_NAME)) {
- IPAERR("Nat device name mismatch\n");
- IPAERR("Expect: %s Recv: %s\n", NAT_DEV_NAME, mem->dev_name);
+ IPAERR_RL("Nat device name mismatch\n");
+ IPAERR_RL("Expect: %s Recv: %s\n", NAT_DEV_NAME, mem->dev_name);
result = -EPERM;
goto bail;
}
@@ -272,7 +272,7 @@ int ipa2_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem)
if (mem->size <= 0 ||
nat_ctx->is_dev_init == true) {
- IPAERR("Invalid Parameters or device is already init\n");
+ IPAERR_RL("Invalid Parameters or device is already init\n");
result = -EPERM;
goto bail;
}
@@ -335,8 +335,8 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
/* check for integer overflow */
if (init->ipv4_rules_offset >
- UINT_MAX - (TBL_ENTRY_SIZE * (init->table_entries + 1))) {
- IPAERR("Detected overflow\n");
+ (UINT_MAX - (TBL_ENTRY_SIZE * (init->table_entries + 1)))) {
+ IPAERR_RL("Detected overflow\n");
return -EPERM;
}
/* Check Table Entry offset is not
@@ -345,8 +345,8 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
tmp = init->ipv4_rules_offset +
(TBL_ENTRY_SIZE * (init->table_entries + 1));
if (tmp > ipa_ctx->nat_mem.size) {
- IPAERR("Table rules offset not valid\n");
- IPAERR("offset:%d entrys:%d size:%zu mem_size:%zu\n",
+ IPAERR_RL("Table rules offset not valid\n");
+ IPAERR_RL("offset:%d entrys:%d size:%zu mem_size:%zu\n",
init->ipv4_rules_offset, (init->table_entries + 1),
tmp, ipa_ctx->nat_mem.size);
return -EPERM;
@@ -355,7 +355,7 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
/* check for integer overflow */
if (init->expn_rules_offset >
UINT_MAX - (TBL_ENTRY_SIZE * init->expn_table_entries)) {
- IPAERR("Detected overflow\n");
+ IPAERR_RL("Detected overflow\n");
return -EPERM;
}
/* Check Expn Table Entry offset is not
@@ -364,8 +364,8 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
tmp = init->expn_rules_offset +
(TBL_ENTRY_SIZE * init->expn_table_entries);
if (tmp > ipa_ctx->nat_mem.size) {
- IPAERR("Expn Table rules offset not valid\n");
- IPAERR("offset:%d entrys:%d size:%zu mem_size:%zu\n",
+ IPAERR_RL("Expn Table rules offset not valid\n");
+ IPAERR_RL("offset:%d entrys:%d size:%zu mem_size:%zu\n",
init->expn_rules_offset, init->expn_table_entries,
tmp, ipa_ctx->nat_mem.size);
return -EPERM;
@@ -374,7 +374,7 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
/* check for integer overflow */
if (init->index_offset >
UINT_MAX - (INDX_TBL_ENTRY_SIZE * (init->table_entries + 1))) {
- IPAERR("Detected overflow\n");
+ IPAERR_RL("Detected overflow\n");
return -EPERM;
}
/* Check Indx Table Entry offset is not
@@ -383,8 +383,8 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
tmp = init->index_offset +
(INDX_TBL_ENTRY_SIZE * (init->table_entries + 1));
if (tmp > ipa_ctx->nat_mem.size) {
- IPAERR("Indx Table rules offset not valid\n");
- IPAERR("offset:%d entrys:%d size:%zu mem_size:%zu\n",
+ IPAERR_RL("Indx Table rules offset not valid\n");
+ IPAERR_RL("offset:%d entrys:%d size:%zu mem_size:%zu\n",
init->index_offset, (init->table_entries + 1),
tmp, ipa_ctx->nat_mem.size);
return -EPERM;
@@ -392,8 +392,8 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
/* check for integer overflow */
if (init->index_expn_offset >
- UINT_MAX - (INDX_TBL_ENTRY_SIZE * init->expn_table_entries)) {
- IPAERR("Detected overflow\n");
+ (UINT_MAX - (INDX_TBL_ENTRY_SIZE * init->expn_table_entries))) {
+ IPAERR_RL("Detected overflow\n");
return -EPERM;
}
/* Check Expn Table entry offset is not
@@ -402,8 +402,8 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
tmp = init->index_expn_offset +
(INDX_TBL_ENTRY_SIZE * init->expn_table_entries);
if (tmp > ipa_ctx->nat_mem.size) {
- IPAERR("Indx Expn Table rules offset not valid\n");
- IPAERR("offset:%d entrys:%d size:%zu mem_size:%zu\n",
+ IPAERR_RL("Indx Expn Table rules offset not valid\n");
+ IPAERR_RL("offset:%d entrys:%d size:%zu mem_size:%zu\n",
init->index_expn_offset, init->expn_table_entries,
tmp, ipa_ctx->nat_mem.size);
return -EPERM;
@@ -448,16 +448,16 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
(init->expn_rules_offset > offset) ||
(init->index_offset > offset) ||
(init->index_expn_offset > offset)) {
- IPAERR("Failed due to integer overflow\n");
- IPAERR("nat.mem.dma_handle: 0x%pa\n",
+ IPAERR_RL("Failed due to integer overflow\n");
+ IPAERR_RL("nat.mem.dma_handle: 0x%pa\n",
&ipa_ctx->nat_mem.dma_handle);
- IPAERR("ipv4_rules_offset: 0x%x\n",
+ IPAERR_RL("ipv4_rules_offset: 0x%x\n",
init->ipv4_rules_offset);
- IPAERR("expn_rules_offset: 0x%x\n",
+ IPAERR_RL("expn_rules_offset: 0x%x\n",
init->expn_rules_offset);
- IPAERR("index_offset: 0x%x\n",
+ IPAERR_RL("index_offset: 0x%x\n",
init->index_offset);
- IPAERR("index_expn_offset: 0x%x\n",
+ IPAERR_RL("index_expn_offset: 0x%x\n",
init->index_expn_offset);
result = -EPERM;
goto free_mem;
@@ -513,7 +513,7 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
desc[1].len = size;
IPADBG("posting v4 init command\n");
if (ipa_send_cmd(2, desc)) {
- IPAERR("Fail to send immediate command\n");
+ IPAERR_RL("Fail to send immediate command\n");
result = -EPERM;
goto free_mem;
}
@@ -578,7 +578,7 @@ int ipa2_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
IPADBG("\n");
if (dma->entries <= 0) {
- IPAERR("Invalid number of commands %d\n",
+ IPAERR_RL("Invalid number of commands %d\n",
dma->entries);
ret = -EPERM;
goto bail;
@@ -586,7 +586,7 @@ int ipa2_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
for (cnt = 0; cnt < dma->entries; cnt++) {
if (dma->dma[cnt].table_index >= 1) {
- IPAERR("Invalid table index %d\n",
+ IPAERR_RL("Invalid table index %d\n",
dma->dma[cnt].table_index);
ret = -EPERM;
goto bail;
@@ -597,7 +597,7 @@ int ipa2_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
if (dma->dma[cnt].offset >=
(ipa_ctx->nat_mem.size_base_tables + 1) *
NAT_TABLE_ENTRY_SIZE_BYTE) {
- IPAERR("Invalid offset %d\n",
+ IPAERR_RL("Invalid offset %d\n",
dma->dma[cnt].offset);
ret = -EPERM;
goto bail;
@@ -609,7 +609,7 @@ int ipa2_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
if (dma->dma[cnt].offset >=
ipa_ctx->nat_mem.size_expansion_tables *
NAT_TABLE_ENTRY_SIZE_BYTE) {
- IPAERR("Invalid offset %d\n",
+ IPAERR_RL("Invalid offset %d\n",
dma->dma[cnt].offset);
ret = -EPERM;
goto bail;
@@ -621,7 +621,7 @@ int ipa2_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
if (dma->dma[cnt].offset >=
(ipa_ctx->nat_mem.size_base_tables + 1) *
NAT_INTEX_TABLE_ENTRY_SIZE_BYTE) {
- IPAERR("Invalid offset %d\n",
+ IPAERR_RL("Invalid offset %d\n",
dma->dma[cnt].offset);
ret = -EPERM;
goto bail;
@@ -633,7 +633,7 @@ int ipa2_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
if (dma->dma[cnt].offset >=
ipa_ctx->nat_mem.size_expansion_tables *
NAT_INTEX_TABLE_ENTRY_SIZE_BYTE) {
- IPAERR("Invalid offset %d\n",
+ IPAERR_RL("Invalid offset %d\n",
dma->dma[cnt].offset);
ret = -EPERM;
goto bail;
@@ -642,7 +642,7 @@ int ipa2_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
break;
default:
- IPAERR("Invalid base_addr %d\n",
+ IPAERR_RL("Invalid base_addr %d\n",
dma->dma[cnt].base_addr);
ret = -EPERM;
goto bail;
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c b/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
index 1faa795..0a3c0e5 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
@@ -850,7 +850,7 @@ int ipa2_query_rt_index(struct ipa_ioc_get_rt_tbl_indx *in)
struct ipa_rt_tbl *entry;
if (in->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -942,12 +942,12 @@ static int __ipa_del_rt_tbl(struct ipa_rt_tbl *entry)
u32 id;
if (entry == NULL || (entry->cookie != IPA_RT_TBL_COOKIE)) {
- IPAERR("bad parms\n");
+ IPAERR_RL("bad parms\n");
return -EINVAL;
}
id = entry->id;
if (ipa_id_find(id) == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
return -EPERM;
}
@@ -1086,7 +1086,7 @@ int ipa2_add_rt_rule(struct ipa_ioc_add_rt_rule *rules)
int ret;
if (rules == NULL || rules->num_rules == 0 || rules->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1096,7 +1096,7 @@ int ipa2_add_rt_rule(struct ipa_ioc_add_rt_rule *rules)
&rules->rules[i].rule,
rules->rules[i].at_rear,
&rules->rules[i].rt_rule_hdl)) {
- IPAERR("failed to add rt rule %d\n", i);
+ IPAERR_RL("failed to add rt rule %d\n", i);
rules->rules[i].status = IPA_RT_STATUS_OF_ADD_FAILED;
} else {
rules->rules[i].status = 0;
@@ -1123,12 +1123,12 @@ int __ipa_del_rt_rule(u32 rule_hdl)
entry = ipa_id_find(rule_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
return -EINVAL;
}
if (entry->cookie != IPA_RT_RULE_COOKIE) {
- IPAERR("bad params\n");
+ IPAERR_RL("bad params\n");
return -EINVAL;
}
@@ -1142,7 +1142,7 @@ int __ipa_del_rt_rule(u32 rule_hdl)
entry->tbl->rule_cnt);
if (entry->tbl->rule_cnt == 0 && entry->tbl->ref_cnt == 0) {
if (__ipa_del_rt_tbl(entry->tbl))
- IPAERR("fail to del RT tbl\n");
+ IPAERR_RL("fail to del RT tbl\n");
}
entry->cookie = 0;
id = entry->id;
@@ -1169,14 +1169,14 @@ int ipa2_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls)
int ret;
if (hdls == NULL || hdls->num_hdls == 0 || hdls->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa_ctx->lock);
for (i = 0; i < hdls->num_hdls; i++) {
if (__ipa_del_rt_rule(hdls->hdl[i].hdl)) {
- IPAERR("failed to del rt rule %i\n", i);
+ IPAERR_RL("failed to del rt rule %i\n", i);
hdls->hdl[i].status = IPA_RT_STATUS_OF_DEL_FAILED;
} else {
hdls->hdl[i].status = 0;
@@ -1209,7 +1209,7 @@ int ipa2_commit_rt(enum ipa_ip_type ip)
int ret;
if (ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1253,7 +1253,7 @@ int ipa2_reset_rt(enum ipa_ip_type ip)
int id;
if (ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1271,7 +1271,7 @@ int ipa2_reset_rt(enum ipa_ip_type ip)
* filtering rules point to routing tables
*/
if (ipa2_reset_flt(ip))
- IPAERR("fail to reset flt ip=%d\n", ip);
+ IPAERR_RL("fail to reset flt ip=%d\n", ip);
set = &ipa_ctx->rt_tbl_set[ip];
rset = &ipa_ctx->reap_rt_tbl_set[ip];
@@ -1357,7 +1357,7 @@ int ipa2_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)
int result = -EFAULT;
if (lookup == NULL || lookup->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa_ctx->lock);
@@ -1368,7 +1368,7 @@ int ipa2_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)
/* commit for get */
if (ipa_ctx->ctrl->ipa_commit_rt(lookup->ip))
- IPAERR("fail to commit RT tbl\n");
+ IPAERR_RL("fail to commit RT tbl\n");
result = 0;
}
@@ -1394,13 +1394,13 @@ int ipa2_put_rt_tbl(u32 rt_tbl_hdl)
mutex_lock(&ipa_ctx->lock);
entry = ipa_id_find(rt_tbl_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
result = -EINVAL;
goto ret;
}
if ((entry->cookie != IPA_RT_TBL_COOKIE) || entry->ref_cnt == 0) {
- IPAERR("bad parms\n");
+ IPAERR_RL("bad parms\n");
result = -EINVAL;
goto ret;
}
@@ -1418,10 +1418,10 @@ int ipa2_put_rt_tbl(u32 rt_tbl_hdl)
entry->ref_cnt--;
if (entry->ref_cnt == 0 && entry->rule_cnt == 0) {
if (__ipa_del_rt_tbl(entry))
- IPAERR("fail to del RT tbl\n");
+ IPAERR_RL("fail to del RT tbl\n");
/* commit for put */
if (ipa_ctx->ctrl->ipa_commit_rt(ip))
- IPAERR("fail to commit RT tbl\n");
+ IPAERR_RL("fail to commit RT tbl\n");
}
result = 0;
@@ -1441,19 +1441,19 @@ static int __ipa_mdfy_rt_rule(struct ipa_rt_rule_mdfy *rtrule)
if (rtrule->rule.hdr_hdl) {
hdr = ipa_id_find(rtrule->rule.hdr_hdl);
if ((hdr == NULL) || (hdr->cookie != IPA_HDR_COOKIE)) {
- IPAERR("rt rule does not point to valid hdr\n");
+ IPAERR_RL("rt rule does not point to valid hdr\n");
goto error;
}
}
entry = ipa_id_find(rtrule->rt_rule_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
goto error;
}
if (entry->cookie != IPA_RT_RULE_COOKIE) {
- IPAERR("bad params\n");
+ IPAERR_RL("bad params\n");
goto error;
}
@@ -1486,14 +1486,14 @@ int ipa2_mdfy_rt_rule(struct ipa_ioc_mdfy_rt_rule *hdls)
int result;
if (hdls == NULL || hdls->num_rules == 0 || hdls->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa_ctx->lock);
for (i = 0; i < hdls->num_rules; i++) {
if (__ipa_mdfy_rt_rule(&hdls->rules[i])) {
- IPAERR("failed to mdfy rt rule %i\n", i);
+ IPAERR_RL("failed to mdfy rt rule %i\n", i);
hdls->rules[i].status = IPA_RT_STATUS_OF_MDFY_FAILED;
} else {
hdls->rules[i].status = 0;
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_uc_wdi.c b/drivers/platform/msm/ipa/ipa_v2/ipa_uc_wdi.c
index b7815cb..a454382 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_uc_wdi.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_uc_wdi.c
@@ -1673,7 +1673,7 @@ int ipa_write_qmapid_wdi_pipe(u32 clnt_hdl, u8 qmap_id)
if (clnt_hdl >= ipa_ctx->ipa_num_pipes ||
ipa_ctx->ep[clnt_hdl].valid == 0) {
- IPAERR("bad parm, %d\n", clnt_hdl);
+ IPAERR_RL("bad parm, %d\n", clnt_hdl);
return -EINVAL;
}
@@ -1686,7 +1686,7 @@ int ipa_write_qmapid_wdi_pipe(u32 clnt_hdl, u8 qmap_id)
ep = &ipa_ctx->ep[clnt_hdl];
if (!(ep->uc_offload_state & IPA_WDI_CONNECTED)) {
- IPAERR("WDI channel bad state %d\n", ep->uc_offload_state);
+ IPAERR_RL("WDI channel bad state %d\n", ep->uc_offload_state);
return -EFAULT;
}
diff --git a/drivers/platform/msm/ipa/ipa_v2/ipa_utils.c b/drivers/platform/msm/ipa/ipa_v2/ipa_utils.c
index b133f9c..2c88244 100644
--- a/drivers/platform/msm/ipa/ipa_v2/ipa_utils.c
+++ b/drivers/platform/msm/ipa/ipa_v2/ipa_utils.c
@@ -847,7 +847,7 @@ int ipa2_get_ep_mapping(enum ipa_client_type client)
}
if (client >= IPA_CLIENT_MAX || client < 0) {
- IPAERR("Bad client number! client =%d\n", client);
+ IPAERR_RL("Bad client number! client =%d\n", client);
return INVALID_EP_MAPPING_INDEX;
}
@@ -1700,7 +1700,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_NEXT_HDR ||
attrib->attrib_mask & IPA_FLT_TC || attrib->attrib_mask &
IPA_FLT_FLOW_LABEL) {
- IPAERR("v6 attrib's specified for v4 rule\n");
+ IPAERR_RL("v6 attrib's specified for v4 rule\n");
return -EPERM;
}
@@ -1712,7 +1712,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_TOS_MASKED) {
if (ipa_ofst_meq32[ofst_meq32] == -1) {
- IPAERR("ran out of meq32 eq\n");
+ IPAERR_RL("ran out of meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq32[ofst_meq32];
@@ -1732,7 +1732,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_SRC_ADDR) {
if (ipa_ofst_meq32[ofst_meq32] == -1) {
- IPAERR("ran out of meq32 eq\n");
+ IPAERR_RL("ran out of meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq32[ofst_meq32];
@@ -1746,7 +1746,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_DST_ADDR) {
if (ipa_ofst_meq32[ofst_meq32] == -1) {
- IPAERR("ran out of meq32 eq\n");
+ IPAERR_RL("ran out of meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq32[ofst_meq32];
@@ -1760,11 +1760,11 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_SRC_PORT_RANGE) {
if (ipa_ihl_ofst_rng16[ihl_ofst_rng16] == -1) {
- IPAERR("ran out of ihl_rng16 eq\n");
+ IPAERR_RL("ran out of ihl_rng16 eq\n");
return -EPERM;
}
if (attrib->src_port_hi < attrib->src_port_lo) {
- IPAERR("bad src port range param\n");
+ IPAERR_RL("bad src port range param\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_rng16[ihl_ofst_rng16];
@@ -1778,11 +1778,11 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_DST_PORT_RANGE) {
if (ipa_ihl_ofst_rng16[ihl_ofst_rng16] == -1) {
- IPAERR("ran out of ihl_rng16 eq\n");
+ IPAERR_RL("ran out of ihl_rng16 eq\n");
return -EPERM;
}
if (attrib->dst_port_hi < attrib->dst_port_lo) {
- IPAERR("bad dst port range param\n");
+ IPAERR_RL("bad dst port range param\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_rng16[ihl_ofst_rng16];
@@ -1796,7 +1796,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_TYPE) {
if (ipa_ihl_ofst_meq32[ihl_ofst_meq32] == -1) {
- IPAERR("ran out of ihl_meq32 eq\n");
+ IPAERR_RL("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_meq32[ihl_ofst_meq32];
@@ -1809,7 +1809,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_CODE) {
if (ipa_ihl_ofst_meq32[ihl_ofst_meq32] == -1) {
- IPAERR("ran out of ihl_meq32 eq\n");
+ IPAERR_RL("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_meq32[ihl_ofst_meq32];
@@ -1822,7 +1822,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_SPI) {
if (ipa_ihl_ofst_meq32[ihl_ofst_meq32] == -1) {
- IPAERR("ran out of ihl_meq32 eq\n");
+ IPAERR_RL("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_meq32[ihl_ofst_meq32];
@@ -1836,7 +1836,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_SRC_PORT) {
if (ipa_ihl_ofst_rng16[ihl_ofst_rng16] == -1) {
- IPAERR("ran out of ihl_rng16 eq\n");
+ IPAERR_RL("ran out of ihl_rng16 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_rng16[ihl_ofst_rng16];
@@ -1850,7 +1850,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_DST_PORT) {
if (ipa_ihl_ofst_rng16[ihl_ofst_rng16] == -1) {
- IPAERR("ran out of ihl_rng16 eq\n");
+ IPAERR_RL("ran out of ihl_rng16 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_rng16[ihl_ofst_rng16];
@@ -1877,7 +1877,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_MAC_DST_ADDR_ETHER_II) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -1892,7 +1892,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_MAC_SRC_ADDR_ETHER_II) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -1907,7 +1907,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_MAC_DST_ADDR_802_3) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -1922,7 +1922,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_MAC_SRC_ADDR_802_3) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -1937,7 +1937,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_MAC_ETHER_TYPE) {
if (ipa_ofst_meq32[ofst_meq32] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq32[ofst_meq32];
@@ -1955,7 +1955,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
/* error check */
if (attrib->attrib_mask & IPA_FLT_TOS ||
attrib->attrib_mask & IPA_FLT_PROTOCOL) {
- IPAERR("v4 attrib's specified for v6 rule\n");
+ IPAERR_RL("v4 attrib's specified for v6 rule\n");
return -EPERM;
}
@@ -1967,7 +1967,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_TYPE) {
if (ipa_ihl_ofst_meq32[ihl_ofst_meq32] == -1) {
- IPAERR("ran out of ihl_meq32 eq\n");
+ IPAERR_RL("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_meq32[ihl_ofst_meq32];
@@ -1980,7 +1980,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_CODE) {
if (ipa_ihl_ofst_meq32[ihl_ofst_meq32] == -1) {
- IPAERR("ran out of ihl_meq32 eq\n");
+ IPAERR_RL("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_meq32[ihl_ofst_meq32];
@@ -1993,7 +1993,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_SPI) {
if (ipa_ihl_ofst_meq32[ihl_ofst_meq32] == -1) {
- IPAERR("ran out of ihl_meq32 eq\n");
+ IPAERR_RL("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_meq32[ihl_ofst_meq32];
@@ -2007,7 +2007,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_SRC_PORT) {
if (ipa_ihl_ofst_rng16[ihl_ofst_rng16] == -1) {
- IPAERR("ran out of ihl_rng16 eq\n");
+ IPAERR_RL("ran out of ihl_rng16 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_rng16[ihl_ofst_rng16];
@@ -2021,7 +2021,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_DST_PORT) {
if (ipa_ihl_ofst_rng16[ihl_ofst_rng16] == -1) {
- IPAERR("ran out of ihl_rng16 eq\n");
+ IPAERR_RL("ran out of ihl_rng16 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_rng16[ihl_ofst_rng16];
@@ -2035,11 +2035,11 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_SRC_PORT_RANGE) {
if (ipa_ihl_ofst_rng16[ihl_ofst_rng16] == -1) {
- IPAERR("ran out of ihl_rng16 eq\n");
+ IPAERR_RL("ran out of ihl_rng16 eq\n");
return -EPERM;
}
if (attrib->src_port_hi < attrib->src_port_lo) {
- IPAERR("bad src port range param\n");
+ IPAERR_RL("bad src port range param\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_rng16[ihl_ofst_rng16];
@@ -2053,11 +2053,11 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_DST_PORT_RANGE) {
if (ipa_ihl_ofst_rng16[ihl_ofst_rng16] == -1) {
- IPAERR("ran out of ihl_rng16 eq\n");
+ IPAERR_RL("ran out of ihl_rng16 eq\n");
return -EPERM;
}
if (attrib->dst_port_hi < attrib->dst_port_lo) {
- IPAERR("bad dst port range param\n");
+ IPAERR_RL("bad dst port range param\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_rng16[ihl_ofst_rng16];
@@ -2071,7 +2071,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_SRC_ADDR) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -2097,7 +2097,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_DST_ADDR) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -2129,7 +2129,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_TOS_MASKED) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -2174,7 +2174,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_MAC_DST_ADDR_ETHER_II) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -2189,7 +2189,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_MAC_SRC_ADDR_ETHER_II) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -2204,7 +2204,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_MAC_DST_ADDR_802_3) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -2219,7 +2219,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_MAC_SRC_ADDR_802_3) {
if (ipa_ofst_meq128[ofst_meq128] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq128[ofst_meq128];
@@ -2234,7 +2234,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
if (attrib->attrib_mask & IPA_FLT_MAC_ETHER_TYPE) {
if (ipa_ofst_meq32[ofst_meq32] == -1) {
- IPAERR("ran out of meq128 eq\n");
+ IPAERR_RL("ran out of meq128 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq32[ofst_meq32];
@@ -2247,7 +2247,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
}
} else {
- IPAERR("unsupported ip %d\n", ip);
+ IPAERR_RL("unsupported ip %d\n", ip);
return -EPERM;
}
@@ -2257,7 +2257,7 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
*/
if (attrib->attrib_mask == 0) {
if (ipa_ofst_meq32[ofst_meq32] == -1) {
- IPAERR("ran out of meq32 eq\n");
+ IPAERR_RL("ran out of meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ofst_meq32[ofst_meq32];
@@ -3548,19 +3548,19 @@ int ipa2_write_qmap_id(struct ipa_ioc_write_qmapid *param_in)
}
if (param_in->client >= IPA_CLIENT_MAX) {
- IPAERR("bad parm client:%d\n", param_in->client);
+ IPAERR_RL("bad parm client:%d\n", param_in->client);
goto fail;
}
ipa_ep_idx = ipa2_get_ep_mapping(param_in->client);
if (ipa_ep_idx == -1) {
- IPAERR("Invalid client.\n");
+ IPAERR_RL("Invalid client.\n");
goto fail;
}
ep = &ipa_ctx->ep[ipa_ep_idx];
if (!ep->valid) {
- IPAERR("EP not allocated.\n");
+ IPAERR_RL("EP not allocated.\n");
goto fail;
}
@@ -3574,7 +3574,7 @@ int ipa2_write_qmap_id(struct ipa_ioc_write_qmapid *param_in)
ipa_ctx->ep[ipa_ep_idx].cfg.meta = meta;
result = ipa_write_qmapid_wdi_pipe(ipa_ep_idx, meta.qmap_id);
if (result)
- IPAERR("qmap_id %d write failed on ep=%d\n",
+ IPAERR_RL("qmap_id %d write failed on ep=%d\n",
meta.qmap_id, ipa_ep_idx);
result = 0;
}
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c
index 4b056f6c..cd4e016 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c
@@ -542,7 +542,7 @@ static int ipa3_send_wan_msg(unsigned long usr_param, uint8_t msg_type)
msg_meta.msg_len = sizeof(struct ipa_wan_msg);
retval = ipa3_send_msg(&msg_meta, wan_msg, ipa3_wan_msg_free_cb);
if (retval) {
- IPAERR("ipa3_send_msg failed: %d\n", retval);
+ IPAERR_RL("ipa3_send_msg failed: %d\n", retval);
kfree(wan_msg);
return retval;
}
@@ -719,7 +719,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_nat_dma_cmd *)param)->entries
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_nat_dma_cmd *)param)->entries,
pre_entry);
retval = -EFAULT;
@@ -778,7 +778,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_add_hdr *)param)->num_hdrs
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_add_hdr *)param)->num_hdrs,
pre_entry);
retval = -EFAULT;
@@ -817,7 +817,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_del_hdr *)param)->num_hdls
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_del_hdr *)param)->num_hdls,
pre_entry);
retval = -EFAULT;
@@ -857,7 +857,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_add_rt_rule *)param)->num_rules
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_add_rt_rule *)param)->
num_rules,
pre_entry);
@@ -897,7 +897,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_add_rt_rule_after *)param)->
num_rules != pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_add_rt_rule_after *)param)->
num_rules,
pre_entry);
@@ -939,7 +939,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_mdfy_rt_rule *)param)->num_rules
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_mdfy_rt_rule *)param)->
num_rules,
pre_entry);
@@ -979,7 +979,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_del_rt_rule *)param)->num_hdls
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_del_rt_rule *)param)->num_hdls,
pre_entry);
retval = -EFAULT;
@@ -1018,7 +1018,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_add_flt_rule *)param)->num_rules
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_add_flt_rule *)param)->
num_rules,
pre_entry);
@@ -1060,7 +1060,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_add_flt_rule_after *)param)->
num_rules != pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_add_flt_rule_after *)param)->
num_rules,
pre_entry);
@@ -1101,7 +1101,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_del_flt_rule *)param)->num_hdls
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_del_flt_rule *)param)->
num_hdls,
pre_entry);
@@ -1141,7 +1141,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_mdfy_flt_rule *)param)->num_rules
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_mdfy_flt_rule *)param)->
num_rules,
pre_entry);
@@ -1279,7 +1279,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
if (unlikely(((struct ipa_ioc_query_intf_tx_props *)
param)->num_tx_props
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_query_intf_tx_props *)
param)->num_tx_props, pre_entry);
retval = -EFAULT;
@@ -1324,7 +1324,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_query_intf_rx_props *)
param)->num_rx_props != pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_query_intf_rx_props *)
param)->num_rx_props, pre_entry);
retval = -EFAULT;
@@ -1369,7 +1369,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_query_intf_ext_props *)
param)->num_ext_props != pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_query_intf_ext_props *)
param)->num_ext_props, pre_entry);
retval = -EFAULT;
@@ -1407,7 +1407,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_msg_meta *)param)->msg_len
!= pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_msg_meta *)param)->msg_len,
pre_entry);
retval = -EFAULT;
@@ -1547,7 +1547,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_add_hdr_proc_ctx *)
param)->num_proc_ctxs != pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_add_hdr_proc_ctx *)
param)->num_proc_ctxs, pre_entry);
retval = -EFAULT;
@@ -1586,7 +1586,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* add check in case user-space module compromised */
if (unlikely(((struct ipa_ioc_del_hdr_proc_ctx *)
param)->num_hdls != pre_entry)) {
- IPAERR("current %d pre %d\n",
+ IPAERR_RL("current %d pre %d\n",
((struct ipa_ioc_del_hdr_proc_ctx *)param)->
num_hdls,
pre_entry);
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c b/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c
index b1e50ac..827fbe2 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_flt.c
@@ -900,7 +900,7 @@ static int __ipa_add_flt_rule_after(struct ipa3_flt_tbl *tbl,
goto error;
if (rule == NULL || rule_hdl == NULL) {
- IPAERR("bad parms rule=%p rule_hdl=%p\n", rule,
+ IPAERR_RL("bad parms rule=%p rule_hdl=%p\n", rule,
rule_hdl);
goto error;
}
@@ -942,12 +942,12 @@ static int __ipa_del_flt_rule(u32 rule_hdl)
entry = ipa3_id_find(rule_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
return -EINVAL;
}
if (entry->cookie != IPA_FLT_COOKIE) {
- IPAERR("bad params\n");
+ IPAERR_RL("bad params\n");
return -EINVAL;
}
id = entry->id;
@@ -979,12 +979,12 @@ static int __ipa_mdfy_flt_rule(struct ipa_flt_rule_mdfy *frule,
entry = ipa3_id_find(frule->rule_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
goto error;
}
if (entry->cookie != IPA_FLT_COOKIE) {
- IPAERR("bad params\n");
+ IPAERR_RL("bad params\n");
goto error;
}
@@ -994,25 +994,25 @@ static int __ipa_mdfy_flt_rule(struct ipa_flt_rule_mdfy *frule,
if (frule->rule.action != IPA_PASS_TO_EXCEPTION) {
if (!frule->rule.eq_attrib_type) {
if (!frule->rule.rt_tbl_hdl) {
- IPAERR("invalid RT tbl\n");
+ IPAERR_RL("invalid RT tbl\n");
goto error;
}
rt_tbl = ipa3_id_find(frule->rule.rt_tbl_hdl);
if (rt_tbl == NULL) {
- IPAERR("RT tbl not found\n");
+ IPAERR_RL("RT tbl not found\n");
goto error;
}
if (rt_tbl->cookie != IPA_RT_TBL_COOKIE) {
- IPAERR("RT table cookie is invalid\n");
+ IPAERR_RL("RT table cookie is invalid\n");
goto error;
}
} else {
if (frule->rule.rt_tbl_idx > ((ip == IPA_IP_v4) ?
IPA_MEM_PART(v4_modem_rt_index_hi) :
IPA_MEM_PART(v6_modem_rt_index_hi))) {
- IPAERR("invalid RT tbl\n");
+ IPAERR_RL("invalid RT tbl\n");
goto error;
}
}
@@ -1057,7 +1057,7 @@ static int __ipa_add_ep_flt_rule(enum ipa_ip_type ip, enum ipa_client_type ep,
int ipa_ep_idx;
if (rule == NULL || rule_hdl == NULL || ep >= IPA_CLIENT_MAX) {
- IPAERR("bad parms rule=%p rule_hdl=%p ep=%d\n", rule,
+ IPAERR_RL("bad parms rule=%p rule_hdl=%p ep=%d\n", rule,
rule_hdl, ep);
return -EINVAL;
@@ -1087,7 +1087,7 @@ int ipa3_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
if (rules == NULL || rules->num_rules == 0 ||
rules->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1102,7 +1102,7 @@ int ipa3_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
result = -1;
if (result) {
- IPAERR("failed to add flt rule %d\n", i);
+ IPAERR_RL("failed to add flt rule %d\n", i);
rules->rules[i].status = IPA_FLT_STATUS_OF_ADD_FAILED;
} else {
rules->rules[i].status = 0;
@@ -1110,7 +1110,7 @@ int ipa3_add_flt_rule(struct ipa_ioc_add_flt_rule *rules)
}
if (rules->global) {
- IPAERR("no support for global filter rules\n");
+ IPAERR_RL("no support for global filter rules\n");
result = -EPERM;
goto bail;
}
@@ -1145,12 +1145,12 @@ int ipa3_add_flt_rule_after(struct ipa_ioc_add_flt_rule_after *rules)
if (rules == NULL || rules->num_rules == 0 ||
rules->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
if (rules->ep >= IPA_CLIENT_MAX) {
- IPAERR("bad parms ep=%d\n", rules->ep);
+ IPAERR_RL("bad parms ep=%d\n", rules->ep);
return -EINVAL;
}
@@ -1165,20 +1165,20 @@ int ipa3_add_flt_rule_after(struct ipa_ioc_add_flt_rule_after *rules)
entry = ipa3_id_find(rules->add_after_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
result = -EINVAL;
goto bail;
}
if (entry->tbl != tbl) {
- IPAERR("given entry does not match the table\n");
+ IPAERR_RL("given entry does not match the table\n");
result = -EINVAL;
goto bail;
}
if (tbl->sticky_rear)
if (&entry->link == tbl->head_flt_rule_list.prev) {
- IPAERR("cannot add rule at end of a sticky table");
+ IPAERR_RL("cannot add rule at end of a sticky table");
result = -EINVAL;
goto bail;
}
@@ -1200,7 +1200,7 @@ int ipa3_add_flt_rule_after(struct ipa_ioc_add_flt_rule_after *rules)
&entry);
if (result) {
- IPAERR("failed to add flt rule %d\n", i);
+ IPAERR_RL("failed to add flt rule %d\n", i);
rules->rules[i].status = IPA_FLT_STATUS_OF_ADD_FAILED;
} else {
rules->rules[i].status = 0;
@@ -1234,14 +1234,14 @@ int ipa3_del_flt_rule(struct ipa_ioc_del_flt_rule *hdls)
int result;
if (hdls == NULL || hdls->num_hdls == 0 || hdls->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa3_ctx->lock);
for (i = 0; i < hdls->num_hdls; i++) {
if (__ipa_del_flt_rule(hdls->hdl[i].hdl)) {
- IPAERR("failed to del flt rule %i\n", i);
+ IPAERR_RL("failed to del flt rule %i\n", i);
hdls->hdl[i].status = IPA_FLT_STATUS_OF_DEL_FAILED;
} else {
hdls->hdl[i].status = 0;
@@ -1274,14 +1274,14 @@ int ipa3_mdfy_flt_rule(struct ipa_ioc_mdfy_flt_rule *hdls)
int result;
if (hdls == NULL || hdls->num_rules == 0 || hdls->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa3_ctx->lock);
for (i = 0; i < hdls->num_rules; i++) {
if (__ipa_mdfy_flt_rule(&hdls->rules[i], hdls->ip)) {
- IPAERR("failed to mdfy flt rule %i\n", i);
+ IPAERR_RL("failed to mdfy flt rule %i\n", i);
hdls->rules[i].status = IPA_FLT_STATUS_OF_MDFY_FAILED;
} else {
hdls->rules[i].status = 0;
@@ -1315,7 +1315,7 @@ int ipa3_commit_flt(enum ipa_ip_type ip)
int result;
if (ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1351,7 +1351,7 @@ int ipa3_reset_flt(enum ipa_ip_type ip)
int id;
if (ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_hdr.c b/drivers/platform/msm/ipa/ipa_v3/ipa_hdr.c
index 0c1832c..da7bcd0 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_hdr.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_hdr.c
@@ -327,17 +327,17 @@ static int __ipa_add_hdr_proc_ctx(struct ipa_hdr_proc_ctx_add *proc_ctx,
proc_ctx->type, proc_ctx->hdr_hdl);
if (!HDR_PROC_TYPE_IS_VALID(proc_ctx->type)) {
- IPAERR("invalid processing type %d\n", proc_ctx->type);
+ IPAERR_RL("invalid processing type %d\n", proc_ctx->type);
return -EINVAL;
}
hdr_entry = ipa3_id_find(proc_ctx->hdr_hdl);
if (!hdr_entry) {
- IPAERR("hdr_hdl is invalid\n");
+ IPAERR_RL("hdr_hdl is invalid\n");
return -EINVAL;
}
if (hdr_entry->cookie != IPA_HDR_COOKIE) {
- IPAERR("Invalid header cookie %u\n", hdr_entry->cookie);
+ IPAERR_RL("Invalid header cookie %u\n", hdr_entry->cookie);
WARN_ON(1);
return -EINVAL;
}
@@ -367,7 +367,7 @@ static int __ipa_add_hdr_proc_ctx(struct ipa_hdr_proc_ctx_add *proc_ctx,
ipa_hdr_proc_ctx_bin_sz[IPA_HDR_PROC_CTX_BIN1]) {
bin = IPA_HDR_PROC_CTX_BIN1;
} else {
- IPAERR("unexpected needed len %d\n", needed_len);
+ IPAERR_RL("unexpected needed len %d\n", needed_len);
WARN_ON(1);
goto bad_len;
}
@@ -377,7 +377,7 @@ static int __ipa_add_hdr_proc_ctx(struct ipa_hdr_proc_ctx_add *proc_ctx,
IPA_MEM_PART(apps_hdr_proc_ctx_size_ddr);
if (list_empty(&htbl->head_free_offset_list[bin])) {
if (htbl->end + ipa_hdr_proc_ctx_bin_sz[bin] > mem_size) {
- IPAERR("hdr proc ctx table overflow\n");
+ IPAERR_RL("hdr proc ctx table overflow\n");
goto bad_len;
}
@@ -450,12 +450,12 @@ static int __ipa_add_hdr(struct ipa_hdr_add *hdr)
int mem_size;
if (hdr->hdr_len == 0 || hdr->hdr_len > IPA_HDR_MAX_SIZE) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
goto error;
}
if (!HDR_TYPE_IS_VALID(hdr->type)) {
- IPAERR("invalid hdr type %d\n", hdr->type);
+ IPAERR_RL("invalid hdr type %d\n", hdr->type);
goto error;
}
@@ -487,7 +487,7 @@ static int __ipa_add_hdr(struct ipa_hdr_add *hdr)
else if (hdr->hdr_len <= ipa_hdr_bin_sz[IPA_HDR_BIN4])
bin = IPA_HDR_BIN4;
else {
- IPAERR("unexpected hdr len %d\n", hdr->hdr_len);
+ IPAERR_RL("unexpected hdr len %d\n", hdr->hdr_len);
goto bad_hdr_len;
}
@@ -609,7 +609,7 @@ static int __ipa3_del_hdr_proc_ctx(u32 proc_ctx_hdl,
entry = ipa3_id_find(proc_ctx_hdl);
if (!entry || (entry->cookie != IPA_PROC_HDR_COOKIE)) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -617,7 +617,7 @@ static int __ipa3_del_hdr_proc_ctx(u32 proc_ctx_hdl,
htbl->proc_ctx_cnt, entry->offset_entry->offset);
if (by_user && entry->user_deleted) {
- IPAERR("proc_ctx already deleted by user\n");
+ IPAERR_RL("proc_ctx already deleted by user\n");
return -EINVAL;
}
@@ -655,12 +655,12 @@ int __ipa3_del_hdr(u32 hdr_hdl, bool by_user)
entry = ipa3_id_find(hdr_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
return -EINVAL;
}
if (entry->cookie != IPA_HDR_COOKIE) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -673,7 +673,7 @@ int __ipa3_del_hdr(u32 hdr_hdl, bool by_user)
entry->offset_entry->offset);
if (by_user && entry->user_deleted) {
- IPAERR("proc_ctx already deleted by user\n");
+ IPAERR_RL("proc_ctx already deleted by user\n");
return -EINVAL;
}
@@ -722,7 +722,7 @@ int ipa3_add_hdr(struct ipa_ioc_add_hdr *hdrs)
int result = -EFAULT;
if (hdrs == NULL || hdrs->num_hdrs == 0) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -731,7 +731,7 @@ int ipa3_add_hdr(struct ipa_ioc_add_hdr *hdrs)
hdrs->num_hdrs);
for (i = 0; i < hdrs->num_hdrs; i++) {
if (__ipa_add_hdr(&hdrs->hdr[i])) {
- IPAERR("failed to add hdr %d\n", i);
+ IPAERR_RL("failed to add hdr %d\n", i);
hdrs->hdr[i].status = -1;
} else {
hdrs->hdr[i].status = 0;
@@ -767,14 +767,14 @@ int ipa3_del_hdr_by_user(struct ipa_ioc_del_hdr *hdls, bool by_user)
int result = -EFAULT;
if (hdls == NULL || hdls->num_hdls == 0) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa3_ctx->lock);
for (i = 0; i < hdls->num_hdls; i++) {
if (__ipa3_del_hdr(hdls->hdl[i].hdl, by_user)) {
- IPAERR("failed to del hdr %i\n", i);
+ IPAERR_RL("failed to del hdr %i\n", i);
hdls->hdl[i].status = -1;
} else {
hdls->hdl[i].status = 0;
@@ -822,7 +822,7 @@ int ipa3_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs)
int result = -EFAULT;
if (proc_ctxs == NULL || proc_ctxs->num_proc_ctxs == 0) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -831,7 +831,7 @@ int ipa3_add_hdr_proc_ctx(struct ipa_ioc_add_hdr_proc_ctx *proc_ctxs)
proc_ctxs->num_proc_ctxs);
for (i = 0; i < proc_ctxs->num_proc_ctxs; i++) {
if (__ipa_add_hdr_proc_ctx(&proc_ctxs->proc_ctx[i], true)) {
- IPAERR("failed to add hdr pric ctx %d\n", i);
+ IPAERR_RL("failed to add hdr pric ctx %d\n", i);
proc_ctxs->proc_ctx[i].status = -1;
} else {
proc_ctxs->proc_ctx[i].status = 0;
@@ -869,14 +869,14 @@ int ipa3_del_hdr_proc_ctx_by_user(struct ipa_ioc_del_hdr_proc_ctx *hdls,
int result;
if (hdls == NULL || hdls->num_hdls == 0) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa3_ctx->lock);
for (i = 0; i < hdls->num_hdls; i++) {
if (__ipa3_del_hdr_proc_ctx(hdls->hdl[i].hdl, true, by_user)) {
- IPAERR("failed to del hdr %i\n", i);
+ IPAERR_RL("failed to del hdr %i\n", i);
hdls->hdl[i].status = -1;
} else {
hdls->hdl[i].status = 0;
@@ -1083,7 +1083,7 @@ static struct ipa3_hdr_entry *__ipa_find_hdr(const char *name)
struct ipa3_hdr_entry *entry;
if (strnlen(name, IPA_RESOURCE_NAME_MAX) == IPA_RESOURCE_NAME_MAX) {
- IPAERR("Header name too long: %s\n", name);
+ IPAERR_RL("Header name too long: %s\n", name);
return NULL;
}
@@ -1113,7 +1113,7 @@ int ipa3_get_hdr(struct ipa_ioc_get_hdr *lookup)
int result = -1;
if (lookup == NULL) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa3_ctx->lock);
@@ -1200,13 +1200,13 @@ int ipa3_put_hdr(u32 hdr_hdl)
entry = ipa3_id_find(hdr_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
result = -EINVAL;
goto bail;
}
if (entry->cookie != IPA_HDR_COOKIE) {
- IPAERR("invalid header entry\n");
+ IPAERR_RL("invalid header entry\n");
result = -EINVAL;
goto bail;
}
@@ -1235,7 +1235,7 @@ int ipa3_copy_hdr(struct ipa_ioc_copy_hdr *copy)
int result = -EFAULT;
if (copy == NULL) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa3_ctx->lock);
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
index 1bed1c8..ed31423 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
@@ -100,6 +100,18 @@
} \
} while (0)
+#define IPAERR_RL(fmt, args...) \
+ do { \
+ pr_err_ratelimited(DRV_NAME " %s:%d " fmt, __func__,\
+ __LINE__, ## args);\
+ if (ipa3_ctx) { \
+ IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
+ DRV_NAME " %s:%d " fmt, ## args); \
+ IPA_IPC_LOGGING(ipa3_ctx->logbuf_low, \
+ DRV_NAME " %s:%d " fmt, ## args); \
+ } \
+ } while (0)
+
#define WLAN_AMPDU_TX_EP 15
#define WLAN_PROD_TX_EP 19
#define WLAN1_CONS_RX_EP 14
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c b/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c
index 38e8d4e..2bd7b79 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c
@@ -227,7 +227,7 @@ int ipa3_query_intf(struct ipa_ioc_query_intf *lookup)
if (strnlen(lookup->name, IPA_RESOURCE_NAME_MAX) ==
IPA_RESOURCE_NAME_MAX) {
- IPAERR("Interface name too long. (%s)\n", lookup->name);
+ IPAERR_RL("Interface name too long. (%s)\n", lookup->name);
return result;
}
@@ -268,7 +268,7 @@ int ipa3_query_intf_tx_props(struct ipa_ioc_query_intf_tx_props *tx)
}
if (strnlen(tx->name, IPA_RESOURCE_NAME_MAX) == IPA_RESOURCE_NAME_MAX) {
- IPAERR("Interface name too long. (%s)\n", tx->name);
+ IPAERR_RL("Interface name too long. (%s)\n", tx->name);
return result;
}
@@ -315,7 +315,7 @@ int ipa3_query_intf_rx_props(struct ipa_ioc_query_intf_rx_props *rx)
}
if (strnlen(rx->name, IPA_RESOURCE_NAME_MAX) == IPA_RESOURCE_NAME_MAX) {
- IPAERR("Interface name too long. (%s)\n", rx->name);
+ IPAERR_RL("Interface name too long. (%s)\n", rx->name);
return result;
}
@@ -410,13 +410,13 @@ int ipa3_send_msg(struct ipa_msg_meta *meta, void *buff,
if (meta == NULL || (buff == NULL && callback != NULL) ||
(buff != NULL && callback == NULL)) {
- IPAERR("invalid param meta=%p buff=%p, callback=%p\n",
+ IPAERR_RL("invalid param meta=%p buff=%p, callback=%p\n",
meta, buff, callback);
return -EINVAL;
}
if (meta->msg_type >= IPA_EVENT_MAX_NUM) {
- IPAERR("unsupported message type %d\n", meta->msg_type);
+ IPAERR_RL("unsupported message type %d\n", meta->msg_type);
return -EINVAL;
}
@@ -640,7 +640,7 @@ int ipa3_pull_msg(struct ipa_msg_meta *meta, char *buff, size_t count)
int result = -EINVAL;
if (meta == NULL || buff == NULL || !count) {
- IPAERR("invalid param name=%p buff=%p count=%zu\n",
+ IPAERR_RL("invalid param name=%p buff=%p count=%zu\n",
meta, buff, count);
return result;
}
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_nat.c b/drivers/platform/msm/ipa/ipa_v3/ipa_nat.c
index a153f2d..958fc6c 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_nat.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_nat.c
@@ -253,8 +253,8 @@ int ipa3_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem)
mutex_lock(&nat_ctx->lock);
if (strcmp(mem->dev_name, NAT_DEV_NAME)) {
- IPAERR("Nat device name mismatch\n");
- IPAERR("Expect: %s Recv: %s\n", NAT_DEV_NAME, mem->dev_name);
+ IPAERR_RL("Nat device name mismatch\n");
+ IPAERR_RL("Expect: %s Recv: %s\n", NAT_DEV_NAME, mem->dev_name);
result = -EPERM;
goto bail;
}
@@ -273,7 +273,7 @@ int ipa3_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem)
if (mem->size <= 0 ||
nat_ctx->is_dev_init == true) {
- IPAERR("Invalid Parameters or device is already init\n");
+ IPAERR_RL("Invalid Parameters or device is already init\n");
result = -EPERM;
goto bail;
}
@@ -371,7 +371,7 @@ int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
/* check for integer overflow */
if (init->ipv4_rules_offset >
UINT_MAX - (TBL_ENTRY_SIZE * (init->table_entries + 1))) {
- IPAERR("Detected overflow\n");
+ IPAERR_RL("Detected overflow\n");
return -EPERM;
}
/* Check Table Entry offset is not
@@ -380,8 +380,8 @@ int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
tmp = init->ipv4_rules_offset +
(TBL_ENTRY_SIZE * (init->table_entries + 1));
if (tmp > ipa3_ctx->nat_mem.size) {
- IPAERR("Table rules offset not valid\n");
- IPAERR("offset:%d entrys:%d size:%zu mem_size:%zu\n",
+ IPAERR_RL("Table rules offset not valid\n");
+ IPAERR_RL("offset:%d entrys:%d size:%zu mem_size:%zu\n",
init->ipv4_rules_offset, (init->table_entries + 1),
tmp, ipa3_ctx->nat_mem.size);
return -EPERM;
@@ -389,8 +389,8 @@ int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
/* check for integer overflow */
if (init->expn_rules_offset >
- UINT_MAX - (TBL_ENTRY_SIZE * init->expn_table_entries)) {
- IPAERR("Detected overflow\n");
+ (UINT_MAX - (TBL_ENTRY_SIZE * init->expn_table_entries))) {
+ IPAERR_RL("Detected overflow\n");
return -EPERM;
}
/* Check Expn Table Entry offset is not
@@ -399,8 +399,8 @@ int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
tmp = init->expn_rules_offset +
(TBL_ENTRY_SIZE * init->expn_table_entries);
if (tmp > ipa3_ctx->nat_mem.size) {
- IPAERR("Expn Table rules offset not valid\n");
- IPAERR("offset:%d entrys:%d size:%zu mem_size:%zu\n",
+ IPAERR_RL("Expn Table rules offset not valid\n");
+ IPAERR_RL("offset:%d entrys:%d size:%zu mem_size:%zu\n",
init->expn_rules_offset, init->expn_table_entries,
tmp, ipa3_ctx->nat_mem.size);
return -EPERM;
@@ -409,7 +409,7 @@ int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
/* check for integer overflow */
if (init->index_offset >
UINT_MAX - (INDX_TBL_ENTRY_SIZE * (init->table_entries + 1))) {
- IPAERR("Detected overflow\n");
+ IPAERR_RL("Detected overflow\n");
return -EPERM;
}
/* Check Indx Table Entry offset is not
@@ -418,8 +418,8 @@ int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
tmp = init->index_offset +
(INDX_TBL_ENTRY_SIZE * (init->table_entries + 1));
if (tmp > ipa3_ctx->nat_mem.size) {
- IPAERR("Indx Table rules offset not valid\n");
- IPAERR("offset:%d entrys:%d size:%zu mem_size:%zu\n",
+ IPAERR_RL("Indx Table rules offset not valid\n");
+ IPAERR_RL("offset:%d entrys:%d size:%zu mem_size:%zu\n",
init->index_offset, (init->table_entries + 1),
tmp, ipa3_ctx->nat_mem.size);
return -EPERM;
@@ -428,7 +428,7 @@ int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
/* check for integer overflow */
if (init->index_expn_offset >
UINT_MAX - (INDX_TBL_ENTRY_SIZE * init->expn_table_entries)) {
- IPAERR("Detected overflow\n");
+ IPAERR_RL("Detected overflow\n");
return -EPERM;
}
/* Check Expn Table entry offset is not
@@ -437,8 +437,8 @@ int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
tmp = init->index_expn_offset +
(INDX_TBL_ENTRY_SIZE * init->expn_table_entries);
if (tmp > ipa3_ctx->nat_mem.size) {
- IPAERR("Indx Expn Table rules offset not valid\n");
- IPAERR("offset:%d entrys:%d size:%zu mem_size:%zu\n",
+ IPAERR_RL("Indx Expn Table rules offset not valid\n");
+ IPAERR_RL("offset:%d entrys:%d size:%zu mem_size:%zu\n",
init->index_expn_offset, init->expn_table_entries,
tmp, ipa3_ctx->nat_mem.size);
return -EPERM;
@@ -476,16 +476,16 @@ int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
(init->expn_rules_offset > offset) ||
(init->index_offset > offset) ||
(init->index_expn_offset > offset)) {
- IPAERR("Failed due to integer overflow\n");
- IPAERR("nat.mem.dma_handle: 0x%pa\n",
+ IPAERR_RL("Failed due to integer overflow\n");
+ IPAERR_RL("nat.mem.dma_handle: 0x%pa\n",
&ipa3_ctx->nat_mem.dma_handle);
- IPAERR("ipv4_rules_offset: 0x%x\n",
+ IPAERR_RL("ipv4_rules_offset: 0x%x\n",
init->ipv4_rules_offset);
- IPAERR("expn_rules_offset: 0x%x\n",
+ IPAERR_RL("expn_rules_offset: 0x%x\n",
init->expn_rules_offset);
- IPAERR("index_offset: 0x%x\n",
+ IPAERR_RL("index_offset: 0x%x\n",
init->index_offset);
- IPAERR("index_expn_offset: 0x%x\n",
+ IPAERR_RL("index_expn_offset: 0x%x\n",
init->index_expn_offset);
result = -EPERM;
goto destroy_imm_cmd;
@@ -544,7 +544,7 @@ int ipa3_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
cmd_pyld[num_cmd] = ipahal_construct_imm_cmd(
IPA_IMM_CMD_IP_V4_NAT_INIT, &cmd, false);
if (!cmd_pyld[num_cmd]) {
- IPAERR("Fail to construct ip_v4_nat_init imm cmd\n");
+ IPAERR_RL("Fail to construct ip_v4_nat_init imm cmd\n");
result = -EPERM;
goto destroy_imm_cmd;
}
@@ -747,7 +747,7 @@ int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
IPADBG("\n");
if (dma->entries <= 0) {
- IPAERR("Invalid number of commands %d\n",
+ IPAERR_RL("Invalid number of commands %d\n",
dma->entries);
ret = -EPERM;
goto bail;
@@ -755,7 +755,7 @@ int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
for (cnt = 0; cnt < dma->entries; cnt++) {
if (dma->dma[cnt].table_index >= 1) {
- IPAERR("Invalid table index %d\n",
+ IPAERR_RL("Invalid table index %d\n",
dma->dma[cnt].table_index);
ret = -EPERM;
goto bail;
@@ -766,7 +766,7 @@ int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
if (dma->dma[cnt].offset >=
(ipa3_ctx->nat_mem.size_base_tables + 1) *
NAT_TABLE_ENTRY_SIZE_BYTE) {
- IPAERR("Invalid offset %d\n",
+ IPAERR_RL("Invalid offset %d\n",
dma->dma[cnt].offset);
ret = -EPERM;
goto bail;
@@ -778,7 +778,7 @@ int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
if (dma->dma[cnt].offset >=
ipa3_ctx->nat_mem.size_expansion_tables *
NAT_TABLE_ENTRY_SIZE_BYTE) {
- IPAERR("Invalid offset %d\n",
+ IPAERR_RL("Invalid offset %d\n",
dma->dma[cnt].offset);
ret = -EPERM;
goto bail;
@@ -790,7 +790,7 @@ int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
if (dma->dma[cnt].offset >=
(ipa3_ctx->nat_mem.size_base_tables + 1) *
NAT_INTEX_TABLE_ENTRY_SIZE_BYTE) {
- IPAERR("Invalid offset %d\n",
+ IPAERR_RL("Invalid offset %d\n",
dma->dma[cnt].offset);
ret = -EPERM;
goto bail;
@@ -802,7 +802,7 @@ int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
if (dma->dma[cnt].offset >=
ipa3_ctx->nat_mem.size_expansion_tables *
NAT_INTEX_TABLE_ENTRY_SIZE_BYTE) {
- IPAERR("Invalid offset %d\n",
+ IPAERR_RL("Invalid offset %d\n",
dma->dma[cnt].offset);
ret = -EPERM;
goto bail;
@@ -811,7 +811,7 @@ int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
break;
default:
- IPAERR("Invalid base_addr %d\n",
+ IPAERR_RL("Invalid base_addr %d\n",
dma->dma[cnt].base_addr);
ret = -EPERM;
goto bail;
@@ -853,7 +853,7 @@ int ipa3_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
cmd.data = dma->dma[cnt].data;
cmd_pyld = ipahal_construct_imm_cmd(cmd_name, &cmd, false);
if (!cmd_pyld) {
- IPAERR("Fail to construct nat_dma imm cmd\n");
+ IPAERR_RL("Fail to construct nat_dma imm cmd\n");
continue;
}
desc[1].type = IPA_IMM_CMD_DESC;
@@ -1016,7 +1016,7 @@ int ipa3_nat_del_cmd(struct ipa_ioc_v4_nat_del *del)
cmd_pyld = ipahal_construct_imm_cmd(
IPA_IMM_CMD_IP_V4_NAT_INIT, &cmd, false);
if (!cmd_pyld) {
- IPAERR("Fail to construct ip_v4_nat_init imm cmd\n");
+ IPAERR_RL("Fail to construct ip_v4_nat_init imm cmd\n");
result = -EPERM;
goto destroy_regwrt_imm_cmd;
}
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c b/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
index 234b945..5f14032 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
@@ -694,7 +694,7 @@ struct ipa3_rt_tbl *__ipa3_find_rt_tbl(enum ipa_ip_type ip, const char *name)
struct ipa3_rt_tbl_set *set;
if (strnlen(name, IPA_RESOURCE_NAME_MAX) == IPA_RESOURCE_NAME_MAX) {
- IPAERR("Name too long: %s\n", name);
+ IPAERR_RL("Name too long: %s\n", name);
return NULL;
}
@@ -720,7 +720,7 @@ int ipa3_query_rt_index(struct ipa_ioc_get_rt_tbl_indx *in)
struct ipa3_rt_tbl *entry;
if (in->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -746,7 +746,7 @@ static struct ipa3_rt_tbl *__ipa_add_rt_tbl(enum ipa_ip_type ip,
int max_tbl_indx;
if (name == NULL) {
- IPAERR("no tbl name\n");
+ IPAERR_RL("no tbl name\n");
goto error;
}
@@ -759,7 +759,7 @@ static struct ipa3_rt_tbl *__ipa_add_rt_tbl(enum ipa_ip_type ip,
max(IPA_MEM_PART(v6_modem_rt_index_hi),
IPA_MEM_PART(v6_apps_rt_index_hi));
} else {
- IPAERR("bad ip family type\n");
+ IPAERR_RL("bad ip family type\n");
goto error;
}
@@ -835,12 +835,12 @@ static int __ipa_del_rt_tbl(struct ipa3_rt_tbl *entry)
struct ipa3_rt_tbl_set *rset;
if (entry == NULL || (entry->cookie != IPA_RT_TBL_COOKIE)) {
- IPAERR("bad parms\n");
+ IPAERR_RL("bad parms\n");
return -EINVAL;
}
id = entry->id;
if (ipa3_id_find(id) == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
return -EPERM;
}
@@ -987,7 +987,7 @@ static int __ipa_add_rt_rule(enum ipa_ip_type ip, const char *name,
tbl = __ipa_add_rt_tbl(ip, name);
if (tbl == NULL || (tbl->cookie != IPA_RT_TBL_COOKIE)) {
- IPAERR("failed adding rt tbl name = %s\n",
+ IPAERR_RL("failed adding rt tbl name = %s\n",
name ? name : "");
goto error;
}
@@ -997,8 +997,8 @@ static int __ipa_add_rt_rule(enum ipa_ip_type ip, const char *name,
*/
if (!strcmp(tbl->name, IPA_DFLT_RT_TBL_NAME) &&
(tbl->rule_cnt > 0) && (at_rear != 0)) {
- IPAERR("cannot add rule at end of tbl rule_cnt=%d at_rear=%d\n",
- tbl->rule_cnt, at_rear);
+ IPAERR_RL("cannot add rule at end of tbl rule_cnt=%d at_rear=%d"
+ , tbl->rule_cnt, at_rear);
goto error;
}
@@ -1068,7 +1068,7 @@ int ipa3_add_rt_rule(struct ipa_ioc_add_rt_rule *rules)
int ret;
if (rules == NULL || rules->num_rules == 0 || rules->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1078,7 +1078,7 @@ int ipa3_add_rt_rule(struct ipa_ioc_add_rt_rule *rules)
&rules->rules[i].rule,
rules->rules[i].at_rear,
&rules->rules[i].rt_rule_hdl)) {
- IPAERR("failed to add rt rule %d\n", i);
+ IPAERR_RL("failed to add rt rule %d\n", i);
rules->rules[i].status = IPA_RT_STATUS_OF_ADD_FAILED;
} else {
rules->rules[i].status = 0;
@@ -1114,7 +1114,7 @@ int ipa3_add_rt_rule_after(struct ipa_ioc_add_rt_rule_after *rules)
struct ipa3_rt_entry *entry = NULL;
if (rules == NULL || rules->num_rules == 0 || rules->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1122,28 +1122,28 @@ int ipa3_add_rt_rule_after(struct ipa_ioc_add_rt_rule_after *rules)
tbl = __ipa3_find_rt_tbl(rules->ip, rules->rt_tbl_name);
if (tbl == NULL || (tbl->cookie != IPA_RT_TBL_COOKIE)) {
- IPAERR("failed finding rt tbl name = %s\n",
+ IPAERR_RL("failed finding rt tbl name = %s\n",
rules->rt_tbl_name ? rules->rt_tbl_name : "");
ret = -EINVAL;
goto bail;
}
if (tbl->rule_cnt <= 0) {
- IPAERR("tbl->rule_cnt <= 0");
+ IPAERR_RL("tbl->rule_cnt <= 0");
ret = -EINVAL;
goto bail;
}
entry = ipa3_id_find(rules->add_after_hdl);
if (!entry) {
- IPAERR("failed finding rule %d in rt tbls\n",
+ IPAERR_RL("failed finding rule %d in rt tbls\n",
rules->add_after_hdl);
ret = -EINVAL;
goto bail;
}
if (entry->tbl != tbl) {
- IPAERR("given rt rule does not match the table\n");
+ IPAERR_RL("given rt rule does not match the table\n");
ret = -EINVAL;
goto bail;
}
@@ -1154,7 +1154,7 @@ int ipa3_add_rt_rule_after(struct ipa_ioc_add_rt_rule_after *rules)
*/
if (!strcmp(tbl->name, IPA_DFLT_RT_TBL_NAME) &&
(&entry->link == tbl->head_rt_rule_list.prev)) {
- IPAERR("cannot add rule at end of tbl rule_cnt=%d\n",
+ IPAERR_RL("cannot add rule at end of tbl rule_cnt=%d\n",
tbl->rule_cnt);
ret = -EINVAL;
goto bail;
@@ -1171,7 +1171,7 @@ int ipa3_add_rt_rule_after(struct ipa_ioc_add_rt_rule_after *rules)
&rules->rules[i].rule,
&rules->rules[i].rt_rule_hdl,
&entry)) {
- IPAERR("failed to add rt rule %d\n", i);
+ IPAERR_RL("failed to add rt rule %d\n", i);
rules->rules[i].status = IPA_RT_STATUS_OF_ADD_FAILED;
} else {
rules->rules[i].status = 0;
@@ -1180,7 +1180,7 @@ int ipa3_add_rt_rule_after(struct ipa_ioc_add_rt_rule_after *rules)
if (rules->commit)
if (ipa3_ctx->ctrl->ipa3_commit_rt(rules->ip)) {
- IPAERR("failed to commit\n");
+ IPAERR_RL("failed to commit\n");
ret = -EPERM;
goto bail;
}
@@ -1201,12 +1201,12 @@ int __ipa3_del_rt_rule(u32 rule_hdl)
entry = ipa3_id_find(rule_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
return -EINVAL;
}
if (entry->cookie != IPA_RT_RULE_COOKIE) {
- IPAERR("bad params\n");
+ IPAERR_RL("bad params\n");
return -EINVAL;
}
@@ -1222,7 +1222,7 @@ int __ipa3_del_rt_rule(u32 rule_hdl)
idr_remove(&entry->tbl->rule_ids, entry->rule_id);
if (entry->tbl->rule_cnt == 0 && entry->tbl->ref_cnt == 0) {
if (__ipa_del_rt_tbl(entry->tbl))
- IPAERR("fail to del RT tbl\n");
+ IPAERR_RL("fail to del RT tbl\n");
}
entry->cookie = 0;
id = entry->id;
@@ -1249,14 +1249,14 @@ int ipa3_del_rt_rule(struct ipa_ioc_del_rt_rule *hdls)
int ret;
if (hdls == NULL || hdls->num_hdls == 0 || hdls->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa3_ctx->lock);
for (i = 0; i < hdls->num_hdls; i++) {
if (__ipa3_del_rt_rule(hdls->hdl[i].hdl)) {
- IPAERR("failed to del rt rule %i\n", i);
+ IPAERR_RL("failed to del rt rule %i\n", i);
hdls->hdl[i].status = IPA_RT_STATUS_OF_DEL_FAILED;
} else {
hdls->hdl[i].status = 0;
@@ -1289,7 +1289,7 @@ int ipa3_commit_rt(enum ipa_ip_type ip)
int ret;
if (ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1333,7 +1333,7 @@ int ipa3_reset_rt(enum ipa_ip_type ip)
int id;
if (ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
@@ -1349,7 +1349,7 @@ int ipa3_reset_rt(enum ipa_ip_type ip)
* filtering rules point to routing tables
*/
if (ipa3_reset_flt(ip))
- IPAERR("fail to reset flt ip=%d\n", ip);
+ IPAERR_RL("fail to reset flt ip=%d\n", ip);
set = &ipa3_ctx->rt_tbl_set[ip];
rset = &ipa3_ctx->reap_rt_tbl_set[ip];
@@ -1438,7 +1438,7 @@ int ipa3_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)
int result = -EFAULT;
if (lookup == NULL || lookup->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa3_ctx->lock);
@@ -1449,7 +1449,7 @@ int ipa3_get_rt_tbl(struct ipa_ioc_get_rt_tbl *lookup)
/* commit for get */
if (ipa3_ctx->ctrl->ipa3_commit_rt(lookup->ip))
- IPAERR("fail to commit RT tbl\n");
+ IPAERR_RL("fail to commit RT tbl\n");
result = 0;
}
@@ -1475,13 +1475,13 @@ int ipa3_put_rt_tbl(u32 rt_tbl_hdl)
mutex_lock(&ipa3_ctx->lock);
entry = ipa3_id_find(rt_tbl_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
result = -EINVAL;
goto ret;
}
if ((entry->cookie != IPA_RT_TBL_COOKIE) || entry->ref_cnt == 0) {
- IPAERR("bad parms\n");
+ IPAERR_RL("bad parms\n");
result = -EINVAL;
goto ret;
}
@@ -1501,10 +1501,10 @@ int ipa3_put_rt_tbl(u32 rt_tbl_hdl)
IPADBG("zero ref_cnt, delete rt tbl (idx=%u)\n",
entry->idx);
if (__ipa_del_rt_tbl(entry))
- IPAERR("fail to del RT tbl\n");
+ IPAERR_RL("fail to del RT tbl\n");
/* commit for put */
if (ipa3_ctx->ctrl->ipa3_commit_rt(ip))
- IPAERR("fail to commit RT tbl\n");
+ IPAERR_RL("fail to commit RT tbl\n");
}
result = 0;
@@ -1525,26 +1525,26 @@ static int __ipa_mdfy_rt_rule(struct ipa_rt_rule_mdfy *rtrule)
if (rtrule->rule.hdr_hdl) {
hdr = ipa3_id_find(rtrule->rule.hdr_hdl);
if ((hdr == NULL) || (hdr->cookie != IPA_HDR_COOKIE)) {
- IPAERR("rt rule does not point to valid hdr\n");
+ IPAERR_RL("rt rule does not point to valid hdr\n");
goto error;
}
} else if (rtrule->rule.hdr_proc_ctx_hdl) {
proc_ctx = ipa3_id_find(rtrule->rule.hdr_proc_ctx_hdl);
if ((proc_ctx == NULL) ||
(proc_ctx->cookie != IPA_PROC_HDR_COOKIE)) {
- IPAERR("rt rule does not point to valid proc ctx\n");
+ IPAERR_RL("rt rule does not point to valid proc ctx\n");
goto error;
}
}
entry = ipa3_id_find(rtrule->rt_rule_hdl);
if (entry == NULL) {
- IPAERR("lookup failed\n");
+ IPAERR_RL("lookup failed\n");
goto error;
}
if (entry->cookie != IPA_RT_RULE_COOKIE) {
- IPAERR("bad params\n");
+ IPAERR_RL("bad params\n");
goto error;
}
@@ -1585,14 +1585,14 @@ int ipa3_mdfy_rt_rule(struct ipa_ioc_mdfy_rt_rule *hdls)
int result;
if (hdls == NULL || hdls->num_rules == 0 || hdls->ip >= IPA_IP_MAX) {
- IPAERR("bad parm\n");
+ IPAERR_RL("bad parm\n");
return -EINVAL;
}
mutex_lock(&ipa3_ctx->lock);
for (i = 0; i < hdls->num_rules; i++) {
if (__ipa_mdfy_rt_rule(&hdls->rules[i])) {
- IPAERR("failed to mdfy rt rule %i\n", i);
+ IPAERR_RL("failed to mdfy rt rule %i\n", i);
hdls->rules[i].status = IPA_RT_STATUS_OF_MDFY_FAILED;
} else {
hdls->rules[i].status = 0;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c b/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c
index 60dc04f..c97d2b3 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c
@@ -1668,7 +1668,7 @@ int ipa3_write_qmapid_wdi_pipe(u32 clnt_hdl, u8 qmap_id)
if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
ipa3_ctx->ep[clnt_hdl].valid == 0) {
- IPAERR("bad parm, %d\n", clnt_hdl);
+ IPAERR_RL("bad parm, %d\n", clnt_hdl);
return -EINVAL;
}
@@ -1681,7 +1681,7 @@ int ipa3_write_qmapid_wdi_pipe(u32 clnt_hdl, u8 qmap_id)
ep = &ipa3_ctx->ep[clnt_hdl];
if (!(ep->uc_offload_state & IPA_WDI_CONNECTED)) {
- IPAERR("WDI channel bad state %d\n", ep->uc_offload_state);
+ IPAERR_RL("WDI channel bad state %d\n", ep->uc_offload_state);
return -EFAULT;
}
IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c b/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c
index a251359..9ca4b7d 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c
@@ -1988,7 +1988,7 @@ int ipa3_cfg_route(struct ipahal_reg_route *route)
*/
int ipa3_cfg_filter(u32 disable)
{
- IPAERR("Filter disable is not supported!\n");
+ IPAERR_RL("Filter disable is not supported!\n");
return -EPERM;
}
@@ -2123,7 +2123,7 @@ int ipa3_get_ep_mapping(enum ipa_client_type client)
int ipa_ep_idx;
if (client >= IPA_CLIENT_MAX || client < 0) {
- IPAERR("Bad client number! client =%d\n", client);
+ IPAERR_RL("Bad client number! client =%d\n", client);
return IPA_EP_NOT_ALLOCATED;
}
@@ -3281,19 +3281,19 @@ int ipa3_write_qmap_id(struct ipa_ioc_write_qmapid *param_in)
int result = -EINVAL;
if (param_in->client >= IPA_CLIENT_MAX) {
- IPAERR("bad parm client:%d\n", param_in->client);
+ IPAERR_RL("bad parm client:%d\n", param_in->client);
goto fail;
}
ipa_ep_idx = ipa3_get_ep_mapping(param_in->client);
if (ipa_ep_idx == -1) {
- IPAERR("Invalid client.\n");
+ IPAERR_RL("Invalid client.\n");
goto fail;
}
ep = &ipa3_ctx->ep[ipa_ep_idx];
if (!ep->valid) {
- IPAERR("EP not allocated.\n");
+ IPAERR_RL("EP not allocated.\n");
goto fail;
}
@@ -3307,7 +3307,7 @@ int ipa3_write_qmap_id(struct ipa_ioc_write_qmapid *param_in)
ipa3_ctx->ep[ipa_ep_idx].cfg.meta = meta;
result = ipa3_write_qmapid_wdi_pipe(ipa_ep_idx, meta.qmap_id);
if (result)
- IPAERR("qmap_id %d write failed on ep=%d\n",
+ IPAERR_RL("qmap_id %d write failed on ep=%d\n",
meta.qmap_id, ipa_ep_idx);
result = 0;
}
diff --git a/drivers/platform/msm/seemp_core/seemp_logk.c b/drivers/platform/msm/seemp_core/seemp_logk.c
index e55260d..204142b 100644
--- a/drivers/platform/msm/seemp_core/seemp_logk.c
+++ b/drivers/platform/msm/seemp_core/seemp_logk.c
@@ -624,16 +624,17 @@ static int seemp_logk_rtic_thread(void *data)
/* determine legitimacy of report */
if (report->report_valid &&
- report->sequence_number <=
- header->num_incidents &&
(last_sequence_number == 0
|| report->sequence_number >
last_sequence_number)) {
seemp_logk_rtic(report->report_type,
- report->report.incident.actor,
- report->report.incident.asset_id,
- report->report.incident.asset_category,
- report->report.incident.response);
+ report->actor,
+ /* leave this empty until
+ * asset id is provided
+ */
+ "",
+ report->asset_category,
+ report->response);
last_sequence_number = report->sequence_number;
} else {
last_pos = cur_pos - 1;
diff --git a/drivers/platform/msm/seemp_core/seemp_logk.h b/drivers/platform/msm/seemp_core/seemp_logk.h
index 871de0e..eecf4f7 100644
--- a/drivers/platform/msm/seemp_core/seemp_logk.h
+++ b/drivers/platform/msm/seemp_core/seemp_logk.h
@@ -164,39 +164,23 @@ struct el2_report_header_t {
__u64 report_version; /* Version of the EL2 report */
__u64 mp_catalog_version;
/* Version of MP catalogue used for kernel protection */
+ __u64 num_incidents; /* Number of Incidents Observed by EL2 */
__u8 protection_enabled; /* Kernel Assets protected by EL2 */
__u8 pad1;
__u8 pad2;
__u8 pad3;
__u32 pad4;
- __u64 num_incidents; /* Number of Incidents Observed by EL2 */
-};
-
-/* individual report contents */
-union el2_report {
- struct {
- __u8 asset_id[0x20]; /* Asset Identifier */
- __u64 actor;
- /* Actor that caused the Incident. */
- __u8 asset_category; /* Asset Category */
- __u8 response; /* Response From EL2 */
- __u16 pad1;
- __u32 pad2;
- } incident;
- struct {
- __u64 reserved; /* TBD */
- } info;
};
/* individual report */
struct el2_report_data_t {
+ __u64 sequence_number; /* Sequence number of the report */
+ __u64 actor; /* Actor that caused the Incident. */
__u8 report_valid;
/* Flag to indicate whether report instance is valid */
__u8 report_type; /* Report Type */
- __u8 pad1;
- __u8 pad2;
- __u64 sequence_number; /* Sequence number of the report */
- union el2_report report; /* Report Contents */
+ __u8 asset_category; /* Asset Category */
+ __u8 response; /* Response From EL2 */
};
#endif
diff --git a/drivers/power/supply/qcom/fg-core.h b/drivers/power/supply/qcom/fg-core.h
index cdd09dd..c77b808 100644
--- a/drivers/power/supply/qcom/fg-core.h
+++ b/drivers/power/supply/qcom/fg-core.h
@@ -67,6 +67,7 @@
#define MAX_LINE_LENGTH (ADDR_LEN + (ITEMS_PER_LINE * \
CHARS_PER_ITEM) + 1) \
+#define NUM_PARTITIONS 3
#define FG_SRAM_ADDRESS_MAX 255
#define FG_SRAM_LEN 504
#define PROFILE_LEN 224
@@ -192,6 +193,18 @@ struct fg_sram_param {
int val);
};
+struct fg_dma_address {
+ /* Starting word address of the partition */
+ u16 partition_start;
+ /* Last word address of the partition */
+ u16 partition_end;
+ /*
+ * Byte offset in the FG_DMA peripheral that maps to the partition_start
+ * in SRAM
+ */
+ u16 spmi_addr_base;
+};
+
enum fg_alg_flag_id {
ALG_FLAG_SOC_LT_OTG_MIN = 0,
ALG_FLAG_SOC_LT_RECHARGE,
@@ -360,12 +373,12 @@ struct fg_chip {
struct power_supply *parallel_psy;
struct iio_channel *batt_id_chan;
struct iio_channel *die_temp_chan;
- struct fg_memif *sram;
struct fg_irq_info *irqs;
struct votable *awake_votable;
struct votable *delta_bsoc_irq_en_votable;
struct votable *batt_miss_irq_en_votable;
struct fg_sram_param *sp;
+ struct fg_dma_address *addr_map;
struct fg_alg_flag *alg_flags;
int *debug_mask;
char batt_profile[PROFILE_LEN];
@@ -409,8 +422,10 @@ struct fg_chip {
bool esr_flt_cold_temp_en;
bool slope_limit_en;
bool use_ima_single_mode;
+ bool use_dma;
struct completion soc_update;
struct completion soc_ready;
+ struct completion mem_grant;
struct delayed_work profile_load_work;
struct work_struct status_change_work;
struct work_struct cycle_count_work;
@@ -459,10 +474,15 @@ extern int fg_interleaved_mem_read(struct fg_chip *chip, u16 address,
u8 offset, u8 *val, int len);
extern int fg_interleaved_mem_write(struct fg_chip *chip, u16 address,
u8 offset, u8 *val, int len, bool atomic_access);
+extern int fg_direct_mem_read(struct fg_chip *chip, u16 address,
+ u8 offset, u8 *val, int len);
+extern int fg_direct_mem_write(struct fg_chip *chip, u16 address,
+ u8 offset, u8 *val, int len, bool atomic_access);
extern int fg_read(struct fg_chip *chip, int addr, u8 *val, int len);
extern int fg_write(struct fg_chip *chip, int addr, u8 *val, int len);
extern int fg_masked_write(struct fg_chip *chip, int addr, u8 mask, u8 val);
extern int fg_ima_init(struct fg_chip *chip);
+extern int fg_dma_init(struct fg_chip *chip);
extern int fg_clear_ima_errors_if_any(struct fg_chip *chip, bool check_hw_sts);
extern int fg_clear_dma_errors_if_any(struct fg_chip *chip);
extern int fg_debugfs_create(struct fg_chip *chip);
diff --git a/drivers/power/supply/qcom/fg-memif.c b/drivers/power/supply/qcom/fg-memif.c
index 8a949bf..0abc9df 100644
--- a/drivers/power/supply/qcom/fg-memif.c
+++ b/drivers/power/supply/qcom/fg-memif.c
@@ -746,6 +746,257 @@ int fg_interleaved_mem_write(struct fg_chip *chip, u16 address, u8 offset,
return rc;
}
+#define MEM_GRANT_WAIT_MS 200
+static int fg_direct_mem_request(struct fg_chip *chip, bool request)
+{
+ int rc, ret;
+ u8 val, mask;
+ bool tried_again = false;
+
+ if (request)
+ reinit_completion(&chip->mem_grant);
+
+ mask = MEM_ACCESS_REQ_BIT | IACS_SLCT_BIT;
+ val = request ? MEM_ACCESS_REQ_BIT : 0;
+ rc = fg_masked_write(chip, MEM_IF_MEM_INTF_CFG(chip), mask, val);
+ if (rc < 0) {
+ pr_err("failed to configure mem_if_mem_intf_cfg rc=%d\n", rc);
+ return rc;
+ }
+
+ mask = MEM_ARB_LO_LATENCY_EN_BIT | MEM_ARB_REQ_BIT;
+ val = request ? mask : 0;
+ rc = fg_masked_write(chip, MEM_IF_MEM_ARB_CFG(chip), mask, val);
+ if (rc < 0) {
+ pr_err("failed to configure mem_if_mem_arb_cfg rc:%d\n", rc);
+ return rc;
+ }
+
+ if (request)
+ pr_debug("requesting access\n");
+ else
+ pr_debug("releasing access\n");
+
+ if (!request)
+ return 0;
+
+wait:
+ ret = wait_for_completion_interruptible_timeout(
+ &chip->mem_grant, msecs_to_jiffies(MEM_GRANT_WAIT_MS));
+ /* If we were interrupted wait again one more time. */
+ if (ret <= 0) {
+ if ((ret == -ERESTARTSYS || ret == 0) && !tried_again) {
+ pr_debug("trying again, ret=%d\n", ret);
+ tried_again = true;
+ goto wait;
+ } else {
+ pr_err("wait for mem_grant timed out ret=%d\n",
+ ret);
+ }
+ }
+
+ if (ret <= 0) {
+ val = 0;
+ mask = MEM_ACCESS_REQ_BIT | IACS_SLCT_BIT;
+ rc = fg_masked_write(chip, MEM_IF_MEM_INTF_CFG(chip), mask,
+ val);
+ if (rc < 0) {
+ pr_err("failed to configure mem_if_mem_intf_cfg rc=%d\n",
+ rc);
+ return rc;
+ }
+
+ mask = MEM_ARB_LO_LATENCY_EN_BIT | MEM_ARB_REQ_BIT;
+ rc = fg_masked_write(chip, MEM_IF_MEM_ARB_CFG(chip), mask,
+ val);
+ if (rc < 0) {
+ pr_err("failed to configure mem_if_mem_arb_cfg rc:%d\n",
+ rc);
+ return rc;
+ }
+
+ return -ETIMEDOUT;
+ }
+
+ return rc;
+}
+
+static int fg_get_dma_address(struct fg_chip *chip, u16 sram_addr, u8 offset,
+ u16 *addr)
+{
+ int i;
+ u16 start_sram_addr, end_sram_addr;
+
+ for (i = 0; i < NUM_PARTITIONS; i++) {
+ start_sram_addr = chip->addr_map[i].partition_start;
+ end_sram_addr = chip->addr_map[i].partition_end;
+ if (sram_addr >= start_sram_addr &&
+ sram_addr <= end_sram_addr) {
+ *addr = chip->addr_map[i].spmi_addr_base + offset +
+ (sram_addr - start_sram_addr) *
+ BYTES_PER_SRAM_WORD;
+ return 0;
+ }
+ }
+
+ pr_err("Couldn't find address for %d from address map\n", sram_addr);
+ return -ENXIO;
+}
+
+static int fg_get_partition_count(struct fg_chip *chip, u16 sram_addr, int len,
+ int *count)
+{
+ int i, num = 0;
+ u16 end_addr, last_addr = 0;
+
+ end_addr = sram_addr + len / BYTES_PER_SRAM_WORD;
+ if (!(len % BYTES_PER_SRAM_WORD))
+ end_addr -= 1;
+
+ if (sram_addr == end_addr) {
+ *count = 1;
+ return 0;
+ }
+
+ for (i = 0; i < NUM_PARTITIONS; i++) {
+ pr_debug("address: %d last_addr: %d\n", sram_addr, last_addr);
+ if (sram_addr >= chip->addr_map[i].partition_start
+ && sram_addr <= chip->addr_map[i].partition_end
+ && last_addr < end_addr) {
+ num++;
+ last_addr = chip->addr_map[i].partition_end;
+ sram_addr = chip->addr_map[i+1].partition_start;
+ }
+ }
+
+ if (num > 0) {
+ *count = num;
+ return 0;
+ }
+
+ pr_err("Couldn't find number of partitions for address %d\n",
+ sram_addr);
+ return -ENXIO;
+}
+
+static int fg_get_partition_avail_bytes(struct fg_chip *chip, u16 sram_addr,
+ int len, int *rem_len)
+{
+ int i, part_len = 0, temp;
+ u16 end_addr;
+
+ for (i = 0; i < NUM_PARTITIONS; i++) {
+ if (sram_addr >= chip->addr_map[i].partition_start
+ && sram_addr <= chip->addr_map[i].partition_end) {
+ part_len = (chip->addr_map[i].partition_end -
+ chip->addr_map[i].partition_start + 1);
+ part_len *= BYTES_PER_SRAM_WORD;
+ end_addr = chip->addr_map[i].partition_end;
+ break;
+ }
+ }
+
+ if (part_len <= 0) {
+ pr_err("Bad address? total_len=%d\n", part_len);
+ return -ENXIO;
+ }
+
+ temp = (end_addr - sram_addr + 1) * BYTES_PER_SRAM_WORD;
+ if (temp > part_len || !temp) {
+ pr_err("Bad length=%d\n", temp);
+ return -ENXIO;
+ }
+
+ *rem_len = temp;
+ pr_debug("address %d len %d rem_len %d\n", sram_addr, len, *rem_len);
+ return 0;
+}
+
+static int __fg_direct_mem_rw(struct fg_chip *chip, u16 sram_addr, u8 offset,
+ u8 *val, int len, bool access)
+{
+ int rc, ret, num_partitions, num_bytes = 0;
+ u16 addr;
+ u8 *ptr = val;
+ char *temp_str;
+
+ if (offset > 3) {
+ pr_err("offset too large %d\n", offset);
+ return -EINVAL;
+ }
+
+ rc = fg_get_partition_count(chip, sram_addr, len, &num_partitions);
+ if (rc < 0)
+ return rc;
+
+ pr_debug("number of partitions: %d\n", num_partitions);
+
+ rc = fg_direct_mem_request(chip, true);
+ if (rc < 0) {
+ pr_err("Error in requesting direct_mem access rc=%d\n", rc);
+ return rc;
+ }
+
+ while (num_partitions-- && len) {
+ rc = fg_get_dma_address(chip, sram_addr, offset, &addr);
+ if (rc < 0) {
+ pr_err("Incorrect address %d/offset %d\n", sram_addr,
+ offset);
+ break;
+ }
+
+ rc = fg_get_partition_avail_bytes(chip, sram_addr + offset, len,
+ &num_bytes);
+ if (rc < 0)
+ break;
+
+ if (num_bytes > len)
+ num_bytes = len;
+
+ pr_debug("reading from address: [%d %d] dma_address = %x\n",
+ sram_addr, offset, addr);
+
+ if (access == FG_READ) {
+ rc = fg_read(chip, addr, ptr, num_bytes);
+ temp_str = "read";
+ } else {
+ rc = fg_write(chip, addr, ptr, num_bytes);
+ temp_str = "write";
+ }
+
+ if (rc < 0) {
+ pr_err("Error in %sing address %d rc=%d\n", temp_str,
+ sram_addr, rc);
+ break;
+ }
+
+ ptr += num_bytes;
+ len -= num_bytes;
+ sram_addr += (num_bytes / BYTES_PER_SRAM_WORD);
+ offset = 0;
+ }
+
+ ret = fg_direct_mem_request(chip, false);
+ if (ret < 0) {
+ pr_err("Error in releasing direct_mem access rc=%d\n", rc);
+ return ret;
+ }
+
+ return rc;
+}
+
+int fg_direct_mem_read(struct fg_chip *chip, u16 sram_addr, u8 offset,
+ u8 *val, int len)
+{
+ return __fg_direct_mem_rw(chip, sram_addr, offset, val, len, FG_READ);
+}
+
+int fg_direct_mem_write(struct fg_chip *chip, u16 sram_addr, u8 offset,
+ u8 *val, int len, bool atomic_access)
+{
+ return __fg_direct_mem_rw(chip, sram_addr, offset, val, len, FG_WRITE);
+}
+
int fg_ima_init(struct fg_chip *chip)
{
int rc;
@@ -778,3 +1029,59 @@ int fg_ima_init(struct fg_chip *chip)
return 0;
}
+
+/*
+ * This SRAM partition to DMA address partition mapping remains identical for
+ * PMICs that use GEN3 FG.
+ */
+static struct fg_dma_address fg_gen3_addr_map[NUM_PARTITIONS] = {
+ /* system partition */
+ {
+ .partition_start = 0,
+ .partition_end = 23,
+ .spmi_addr_base = FG_DMA0_BASE + SRAM_ADDR_OFFSET,
+ },
+ /* battery profile partition */
+ {
+ .partition_start = 24,
+ .partition_end = 79,
+ .spmi_addr_base = FG_DMA1_BASE + SRAM_ADDR_OFFSET,
+ },
+ /* scratch pad partition */
+ {
+ .partition_start = 80,
+ .partition_end = 125,
+ .spmi_addr_base = FG_DMA2_BASE + SRAM_ADDR_OFFSET,
+ },
+};
+int fg_dma_init(struct fg_chip *chip)
+{
+ int rc;
+
+ chip->addr_map = fg_gen3_addr_map;
+
+ /* Clear DMA errors if any before clearing IMA errors */
+ rc = fg_clear_dma_errors_if_any(chip);
+ if (rc < 0) {
+ pr_err("Error in checking DMA errors rc:%d\n", rc);
+ return rc;
+ }
+
+ /* Configure the DMA peripheral addressing to partition */
+ rc = fg_masked_write(chip, MEM_IF_DMA_CTL(chip), ADDR_KIND_BIT,
+ ADDR_KIND_BIT);
+ if (rc < 0) {
+ pr_err("failed to configure DMA_CTL rc:%d\n", rc);
+ return rc;
+ }
+
+ /* Release the DMA initially so that request can happen */
+ rc = fg_direct_mem_request(chip, false);
+ if (rc < 0) {
+ pr_err("Error in releasing direct_mem access rc=%d\n",
+ rc);
+ return rc;
+ }
+
+ return 0;
+}
diff --git a/drivers/power/supply/qcom/fg-reg.h b/drivers/power/supply/qcom/fg-reg.h
index cd0b2fb..8ca4376 100644
--- a/drivers/power/supply/qcom/fg-reg.h
+++ b/drivers/power/supply/qcom/fg-reg.h
@@ -31,6 +31,7 @@
#define BATT_SOC_LOW_PWR_STS(chip) (chip->batt_soc_base + 0x56)
/* BATT_SOC_INT_RT_STS */
+#define SOC_READY_BIT BIT(1)
#define MSOC_EMPTY_BIT BIT(5)
/* BATT_SOC_EN_CTL */
@@ -266,6 +267,7 @@
/* FG_MEM_IF register and bit definitions */
#define MEM_IF_INT_RT_STS(chip) ((chip->mem_if_base) + 0x10)
+#define MEM_IF_MEM_ARB_CFG(chip) ((chip->mem_if_base) + 0x40)
#define MEM_IF_MEM_INTF_CFG(chip) ((chip->mem_if_base) + 0x50)
#define MEM_IF_IMA_CTL(chip) ((chip->mem_if_base) + 0x51)
#define MEM_IF_IMA_CFG(chip) ((chip->mem_if_base) + 0x52)
@@ -286,6 +288,11 @@
/* MEM_IF_INT_RT_STS */
#define MEM_XCP_BIT BIT(1)
+#define MEM_GNT_BIT BIT(2)
+
+/* MEM_IF_MEM_ARB_CFG */
+#define MEM_ARB_LO_LATENCY_EN_BIT BIT(1)
+#define MEM_ARB_REQ_BIT BIT(0)
/* MEM_IF_MEM_INTF_CFG */
#define MEM_ACCESS_REQ_BIT BIT(7)
@@ -325,5 +332,13 @@
#define DMA_READ_ERROR_BIT BIT(2)
/* MEM_IF_DMA_CTL */
+#define ADDR_KIND_BIT BIT(1)
#define DMA_CLEAR_LOG_BIT BIT(0)
+
+/* FG_DMAx */
+#define FG_DMA0_BASE 0x4800
+#define FG_DMA1_BASE 0x4900
+#define FG_DMA2_BASE 0x4A00
+#define FG_DMA3_BASE 0x4B00
+#define SRAM_ADDR_OFFSET 0x20
#endif
diff --git a/drivers/power/supply/qcom/fg-util.c b/drivers/power/supply/qcom/fg-util.c
index 38d9594..d9ca47c 100644
--- a/drivers/power/supply/qcom/fg-util.c
+++ b/drivers/power/supply/qcom/fg-util.c
@@ -255,8 +255,6 @@ int fg_sram_write(struct fg_chip *chip, u16 address, u8 offset,
reinit_completion(&chip->soc_update);
enable_irq(chip->irqs[SOC_UPDATE_IRQ].irq);
atomic_access = true;
- } else {
- flags = FG_IMA_DEFAULT;
}
wait:
/*
@@ -282,11 +280,17 @@ int fg_sram_write(struct fg_chip *chip, u16 address, u8 offset,
}
}
- rc = fg_interleaved_mem_write(chip, address, offset, val, len,
- atomic_access);
+ if (chip->use_dma)
+ rc = fg_direct_mem_write(chip, address, offset, val, len,
+ false);
+ else
+ rc = fg_interleaved_mem_write(chip, address, offset, val, len,
+ atomic_access);
+
if (rc < 0)
pr_err("Error in writing SRAM address 0x%x[%d], rc=%d\n",
address, offset, rc);
+
out:
if (atomic_access)
disable_irq_nosync(chip->irqs[SOC_UPDATE_IRQ].irq);
@@ -313,9 +317,14 @@ int fg_sram_read(struct fg_chip *chip, u16 address, u8 offset,
if (!(flags & FG_IMA_NO_WLOCK))
vote(chip->awake_votable, SRAM_READ, true, 0);
+
mutex_lock(&chip->sram_rw_lock);
- rc = fg_interleaved_mem_read(chip, address, offset, val, len);
+ if (chip->use_dma)
+ rc = fg_direct_mem_read(chip, address, offset, val, len);
+ else
+ rc = fg_interleaved_mem_read(chip, address, offset, val, len);
+
if (rc < 0)
pr_err("Error in reading SRAM address 0x%x[%d], rc=%d\n",
address, offset, rc);
diff --git a/drivers/power/supply/qcom/qpnp-fg-gen3.c b/drivers/power/supply/qcom/qpnp-fg-gen3.c
index e5a3a07..42a16d6 100644
--- a/drivers/power/supply/qcom/qpnp-fg-gen3.c
+++ b/drivers/power/supply/qcom/qpnp-fg-gen3.c
@@ -533,7 +533,7 @@ static int fg_get_sram_prop(struct fg_chip *chip, enum fg_sram_param_id id,
rc = fg_sram_read(chip, chip->sp[id].addr_word, chip->sp[id].addr_byte,
buf, chip->sp[id].len, FG_IMA_DEFAULT);
if (rc < 0) {
- pr_err("Error reading address 0x%04x[%d] rc=%d\n",
+ pr_err("Error reading address %d[%d] rc=%d\n",
chip->sp[id].addr_word, chip->sp[id].addr_byte, rc);
return rc;
}
@@ -3503,6 +3503,9 @@ static int fg_hw_init(struct fg_chip *chip)
static int fg_memif_init(struct fg_chip *chip)
{
+ if (chip->use_dma)
+ return fg_dma_init(chip);
+
return fg_ima_init(chip);
}
@@ -3542,6 +3545,26 @@ static int fg_adjust_timebase(struct fg_chip *chip)
/* INTERRUPT HANDLERS STAY HERE */
+static irqreturn_t fg_dma_grant_irq_handler(int irq, void *data)
+{
+ struct fg_chip *chip = data;
+ u8 status;
+ int rc;
+
+ rc = fg_read(chip, MEM_IF_INT_RT_STS(chip), &status, 1);
+ if (rc < 0) {
+ pr_err("failed to read addr=0x%04x, rc=%d\n",
+ MEM_IF_INT_RT_STS(chip), rc);
+ return IRQ_HANDLED;
+ }
+
+ fg_dbg(chip, FG_IRQ, "irq %d triggered, status:%d\n", irq, status);
+ if (status & MEM_GNT_BIT)
+ complete_all(&chip->mem_grant);
+
+ return IRQ_HANDLED;
+}
+
static irqreturn_t fg_mem_xcp_irq_handler(int irq, void *data)
{
struct fg_chip *chip = data;
@@ -3822,7 +3845,8 @@ static struct fg_irq_info fg_irqs[FG_IRQ_MAX] = {
/* MEM_IF irqs */
[DMA_GRANT_IRQ] = {
.name = "dma-grant",
- .handler = fg_dummy_irq_handler,
+ .handler = fg_dma_grant_irq_handler,
+ .wakeable = true,
},
[MEM_XCP_IRQ] = {
.name = "mem-xcp",
@@ -4046,6 +4070,7 @@ static int fg_parse_dt(struct fg_chip *chip)
switch (chip->pmic_rev_id->pmic_subtype) {
case PMI8998_SUBTYPE:
+ chip->use_dma = true;
if (chip->pmic_rev_id->rev4 < PMI8998_V2P0_REV4) {
chip->sp = pmi8998_v1_sram_params;
chip->alg_flags = pmi8998_v1_alg_flags;
@@ -4466,6 +4491,7 @@ static int fg_gen3_probe(struct platform_device *pdev)
mutex_init(&chip->charge_full_lock);
init_completion(&chip->soc_update);
init_completion(&chip->soc_ready);
+ init_completion(&chip->mem_grant);
INIT_DELAYED_WORK(&chip->profile_load_work, profile_load_work);
INIT_WORK(&chip->status_change_work, status_change_work);
INIT_WORK(&chip->cycle_count_work, cycle_count_work);
@@ -4479,6 +4505,25 @@ static int fg_gen3_probe(struct platform_device *pdev)
goto exit;
}
+ platform_set_drvdata(pdev, chip);
+
+ rc = fg_register_interrupts(chip);
+ if (rc < 0) {
+ dev_err(chip->dev, "Error in registering interrupts, rc:%d\n",
+ rc);
+ goto exit;
+ }
+
+ /* Keep SOC_UPDATE irq disabled until we require it */
+ if (fg_irqs[SOC_UPDATE_IRQ].irq)
+ disable_irq_nosync(fg_irqs[SOC_UPDATE_IRQ].irq);
+
+ /* Keep BSOC_DELTA_IRQ disabled until we require it */
+ vote(chip->delta_bsoc_irq_en_votable, DELTA_BSOC_IRQ_VOTER, false, 0);
+
+ /* Keep BATT_MISSING_IRQ disabled until we require it */
+ vote(chip->batt_miss_irq_en_votable, BATT_MISS_IRQ_VOTER, false, 0);
+
rc = fg_hw_init(chip);
if (rc < 0) {
dev_err(chip->dev, "Error in initializing FG hardware, rc:%d\n",
@@ -4486,8 +4531,6 @@ static int fg_gen3_probe(struct platform_device *pdev)
goto exit;
}
- platform_set_drvdata(pdev, chip);
-
/* Register the power supply */
fg_psy_cfg.drv_data = chip;
fg_psy_cfg.of_node = NULL;
@@ -4508,23 +4551,6 @@ static int fg_gen3_probe(struct platform_device *pdev)
goto exit;
}
- rc = fg_register_interrupts(chip);
- if (rc < 0) {
- dev_err(chip->dev, "Error in registering interrupts, rc:%d\n",
- rc);
- goto exit;
- }
-
- /* Keep SOC_UPDATE_IRQ disabled until we require it */
- if (fg_irqs[SOC_UPDATE_IRQ].irq)
- disable_irq_nosync(fg_irqs[SOC_UPDATE_IRQ].irq);
-
- /* Keep BSOC_DELTA_IRQ disabled until we require it */
- vote(chip->delta_bsoc_irq_en_votable, DELTA_BSOC_IRQ_VOTER, false, 0);
-
- /* Keep BATT_MISSING_IRQ disabled until we require it */
- vote(chip->batt_miss_irq_en_votable, BATT_MISS_IRQ_VOTER, false, 0);
-
rc = fg_debugfs_create(chip);
if (rc < 0) {
dev_err(chip->dev, "Error in creating debugfs entries, rc:%d\n",
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 370e092..c78bb9e 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1487,7 +1487,7 @@ int ufshcd_hold(struct ufs_hba *hba, bool async)
hba->clk_gating.state = REQ_CLKS_ON;
trace_ufshcd_clk_gating(dev_name(hba->dev),
hba->clk_gating.state);
- queue_work(hba->clk_gating.ungating_workq,
+ queue_work(hba->clk_gating.clk_gating_workq,
&hba->clk_gating.ungate_work);
/*
* fall through to check if we should wait for this
@@ -1755,7 +1755,8 @@ static enum hrtimer_restart ufshcd_clkgate_hrtimer_handler(
struct ufs_hba *hba = container_of(timer, struct ufs_hba,
clk_gating.gate_hrtimer);
- schedule_work(&hba->clk_gating.gate_work);
+ queue_work(hba->clk_gating.clk_gating_workq,
+ &hba->clk_gating.gate_work);
return HRTIMER_NORESTART;
}
@@ -1763,7 +1764,7 @@ static enum hrtimer_restart ufshcd_clkgate_hrtimer_handler(
static void ufshcd_init_clk_gating(struct ufs_hba *hba)
{
struct ufs_clk_gating *gating = &hba->clk_gating;
- char wq_name[sizeof("ufs_clk_ungating_00")];
+ char wq_name[sizeof("ufs_clk_gating_00")];
hba->clk_gating.state = CLKS_ON;
@@ -1792,9 +1793,10 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba)
hrtimer_init(&gating->gate_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
gating->gate_hrtimer.function = ufshcd_clkgate_hrtimer_handler;
- snprintf(wq_name, ARRAY_SIZE(wq_name), "ufs_clk_ungating_%d",
+ snprintf(wq_name, ARRAY_SIZE(wq_name), "ufs_clk_gating_%d",
hba->host->host_no);
- hba->clk_gating.ungating_workq = create_singlethread_workqueue(wq_name);
+ hba->clk_gating.clk_gating_workq =
+ create_singlethread_workqueue(wq_name);
gating->is_enabled = true;
@@ -1858,7 +1860,7 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba)
device_remove_file(hba->dev, &hba->clk_gating.enable_attr);
ufshcd_cancel_gate_work(hba);
cancel_work_sync(&hba->clk_gating.ungate_work);
- destroy_workqueue(hba->clk_gating.ungating_workq);
+ destroy_workqueue(hba->clk_gating.clk_gating_workq);
}
static void ufshcd_set_auto_hibern8_timer(struct ufs_hba *hba, u32 delay)
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 343f327..eaed1b3 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -446,7 +446,7 @@ struct ufs_clk_gating {
struct device_attribute enable_attr;
bool is_enabled;
int active_reqs;
- struct workqueue_struct *ungating_workq;
+ struct workqueue_struct *clk_gating_workq;
};
/* Hibern8 state */
diff --git a/drivers/soc/qcom/glink.c b/drivers/soc/qcom/glink.c
index d31bf8d..1d605e3 100644
--- a/drivers/soc/qcom/glink.c
+++ b/drivers/soc/qcom/glink.c
@@ -30,7 +30,6 @@
#include "glink_private.h"
#include "glink_xprt_if.h"
-#define GLINK_CTX_CANARY 0x58544324 /* "$CTX" */
/* Number of internal IPC Logging log pages */
#define NUM_LOG_PAGES 10
#define GLINK_PM_QOS_HOLDOFF_MS 10
@@ -40,7 +39,6 @@
#define GLINK_KTHREAD_PRIO 1
-static rwlock_t magic_lock;
/**
* struct glink_qos_priority_bin - Packet Scheduler's priority bucket
* @max_rate_kBps: Maximum rate supported by the priority bucket.
@@ -232,6 +230,8 @@ static DEFINE_MUTEX(edge_list_lock_lhd0);
* @req_rate_kBps: Current QoS request by the channel.
* @tx_intent_cnt: Intent count to transmit soon in future.
* @tx_cnt: Packets to be picked by tx scheduler.
+ * @rt_vote_on: Number of times RT vote on is called.
+ * @rt_vote_off: Number of times RT vote off is called.
*/
struct channel_ctx {
struct rwref_lock ch_state_lhb2;
@@ -312,7 +312,9 @@ struct channel_ctx {
unsigned long req_rate_kBps;
uint32_t tx_intent_cnt;
uint32_t tx_cnt;
- uint32_t magic_number;
+
+ uint32_t rt_vote_on;
+ uint32_t rt_vote_off;
};
static struct glink_core_if core_impl;
@@ -443,33 +445,15 @@ static void glink_core_deinit_xprt_qos_cfg(
static int glink_get_ch_ctx(struct channel_ctx *ctx)
{
- unsigned long flags;
-
if (!ctx)
return -EINVAL;
- read_lock_irqsave(&magic_lock, flags);
- if (ctx->magic_number != GLINK_CTX_CANARY) {
- read_unlock_irqrestore(&magic_lock, flags);
- return -EINVAL;
- }
rwref_get(&ctx->ch_state_lhb2);
- read_unlock_irqrestore(&magic_lock, flags);
return 0;
}
-static int glink_put_ch_ctx(struct channel_ctx *ctx, bool update_magic)
+static void glink_put_ch_ctx(struct channel_ctx *ctx)
{
- unsigned long flags;
-
- if (!update_magic) {
- rwref_put(&ctx->ch_state_lhb2);
- return 0;
- }
- write_lock_irqsave(&magic_lock, flags);
- ctx->magic_number = 0;
rwref_put(&ctx->ch_state_lhb2);
- write_unlock_irqrestore(&magic_lock, flags);
- return 0;
}
/**
@@ -1931,13 +1915,13 @@ static struct channel_ctx *ch_name_to_ch_ctx_create(
}
ctx->transport_ptr = xprt_ctx;
+ rwref_get(&ctx->ch_state_lhb2);
list_add_tail(&ctx->port_list_node, &xprt_ctx->channels);
GLINK_INFO_PERF_CH_XPRT(ctx, xprt_ctx,
"%s: local:GLINK_CHANNEL_CLOSED\n",
__func__);
}
- rwref_get(&ctx->ch_state_lhb2);
spin_unlock_irqrestore(&xprt_ctx->xprt_ctx_lock_lhb1, flags);
rwref_write_put(&xprt_ctx->xprt_state_lhb0);
mutex_lock(&xprt_ctx->xprt_dbgfs_lock_lhb4);
@@ -2419,6 +2403,25 @@ static int dummy_power_unvote(struct glink_transport_if *if_ptr)
}
/**
+ * dummy_rx_rt_vote() - Dummy RX Realtime thread vote
+ * @if_ptr: The transport to transmit on.
+
+ */
+static int dummy_rx_rt_vote(struct glink_transport_if *if_ptr)
+{
+ return -EOPNOTSUPP;
+}
+
+/**
+ * dummy_rx_rt_unvote() - Dummy RX Realtime thread unvote
+ * @if_ptr: The transport to transmit on.
+ */
+static int dummy_rx_rt_unvote(struct glink_transport_if *if_ptr)
+{
+ return -EOPNOTSUPP;
+}
+
+/**
* notif_if_up_all_xprts() - Check and notify existing transport state if up
* @notif_info: Data structure containing transport information to be notified.
*
@@ -2600,7 +2603,6 @@ void *glink_open(const struct glink_open_config *cfg)
ctx->notify_tx_abort = cfg->notify_tx_abort;
ctx->notify_rx_tracer_pkt = cfg->notify_rx_tracer_pkt;
ctx->notify_remote_rx_intent = cfg->notify_remote_rx_intent;
- ctx->magic_number = GLINK_CTX_CANARY;
if (!ctx->notify_rx_intent_req)
ctx->notify_rx_intent_req = glink_dummy_notify_rx_intent_req;
@@ -2742,13 +2744,13 @@ int glink_close(void *handle)
GLINK_INFO_CH(ctx, "%s: Closing channel, ctx: %p\n", __func__, ctx);
if (ctx->local_open_state == GLINK_CHANNEL_CLOSED) {
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return 0;
}
if (ctx->local_open_state == GLINK_CHANNEL_CLOSING) {
/* close already pending */
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -EBUSY;
}
@@ -2813,7 +2815,7 @@ relock: xprt_ctx = ctx->transport_ptr;
rwref_put(&ctx->ch_state_lhb2);
rwref_read_put(&xprt_ctx->xprt_state_lhb0);
- glink_put_ch_ctx(ctx, true);
+ glink_put_ch_ctx(ctx);
return ret;
}
EXPORT_SYMBOL(glink_close);
@@ -3029,13 +3031,13 @@ static int glink_tx_common(void *handle, void *pkt_priv,
xprt_schedule_tx(ctx->transport_ptr, ctx, tx_info);
rwref_read_put(&ctx->ch_state_lhb2);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return ret;
glink_tx_common_err:
rwref_read_put(&ctx->ch_state_lhb2);
glink_tx_common_err_2:
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
kfree(tx_info);
return ret;
}
@@ -3085,7 +3087,7 @@ int glink_queue_rx_intent(void *handle, const void *pkt_priv, size_t size)
/* Can only queue rx intents if channel is fully opened */
GLINK_ERR_CH(ctx, "%s: Channel is not fully opened\n",
__func__);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -EBUSY;
}
@@ -3094,14 +3096,14 @@ int glink_queue_rx_intent(void *handle, const void *pkt_priv, size_t size)
GLINK_ERR_CH(ctx,
"%s: Intent pointer allocation failed size[%zu]\n",
__func__, size);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -ENOMEM;
}
GLINK_DBG_CH(ctx, "%s: L[%u]:%zu\n", __func__, intent_ptr->id,
intent_ptr->intent_size);
if (ctx->transport_ptr->capabilities & GCAP_INTENTLESS) {
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return ret;
}
@@ -3111,7 +3113,7 @@ int glink_queue_rx_intent(void *handle, const void *pkt_priv, size_t size)
if (ret)
/* unable to transmit, dequeue intent */
ch_remove_local_rx_intent(ctx, intent_ptr->id);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return ret;
}
EXPORT_SYMBOL(glink_queue_rx_intent);
@@ -3143,12 +3145,12 @@ bool glink_rx_intent_exists(void *handle, size_t size)
if (size <= intent->intent_size) {
spin_unlock_irqrestore(
&ctx->local_rx_intent_lst_lock_lhc1, flags);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return true;
}
}
spin_unlock_irqrestore(&ctx->local_rx_intent_lst_lock_lhc1, flags);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return false;
}
EXPORT_SYMBOL(glink_rx_intent_exists);
@@ -3177,7 +3179,7 @@ int glink_rx_done(void *handle, const void *ptr, bool reuse)
if (IS_ERR_OR_NULL(liid_ptr)) {
/* invalid pointer */
GLINK_ERR_CH(ctx, "%s: Invalid pointer %p\n", __func__, ptr);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -EINVAL;
}
@@ -3203,7 +3205,7 @@ int glink_rx_done(void *handle, const void *ptr, bool reuse)
/* send rx done */
ctx->transport_ptr->ops->tx_cmd_local_rx_done(ctx->transport_ptr->ops,
ctx->lcid, id, reuse);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return ret;
}
EXPORT_SYMBOL(glink_rx_done);
@@ -3257,7 +3259,7 @@ int glink_sigs_set(void *handle, uint32_t sigs)
if (!ch_is_fully_opened(ctx)) {
GLINK_ERR_CH(ctx, "%s: Channel is not fully opened\n",
__func__);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -EBUSY;
}
@@ -3267,7 +3269,7 @@ int glink_sigs_set(void *handle, uint32_t sigs)
ctx->lcid, ctx->lsigs);
GLINK_INFO_CH(ctx, "%s: Sent SIGNAL SET command\n", __func__);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return ret;
}
EXPORT_SYMBOL(glink_sigs_set);
@@ -3293,12 +3295,12 @@ int glink_sigs_local_get(void *handle, uint32_t *sigs)
if (!ch_is_fully_opened(ctx)) {
GLINK_ERR_CH(ctx, "%s: Channel is not fully opened\n",
__func__);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -EBUSY;
}
*sigs = ctx->lsigs;
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return 0;
}
EXPORT_SYMBOL(glink_sigs_local_get);
@@ -3325,12 +3327,12 @@ int glink_sigs_remote_get(void *handle, uint32_t *sigs)
if (!ch_is_fully_opened(ctx)) {
GLINK_ERR_CH(ctx, "%s: Channel is not fully opened\n",
__func__);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -EBUSY;
}
*sigs = ctx->rsigs;
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return 0;
}
EXPORT_SYMBOL(glink_sigs_remote_get);
@@ -3434,7 +3436,7 @@ int glink_qos_latency(void *handle, unsigned long latency_us, size_t pkt_size)
if (!ch_is_fully_opened(ctx)) {
GLINK_ERR_CH(ctx, "%s: Channel is not fully opened\n",
__func__);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -EBUSY;
}
@@ -3444,7 +3446,7 @@ int glink_qos_latency(void *handle, unsigned long latency_us, size_t pkt_size)
if (ret < 0)
GLINK_ERR_CH(ctx, "%s: QoS %lu:%zu cannot be met\n",
__func__, latency_us, pkt_size);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return ret;
}
EXPORT_SYMBOL(glink_qos_latency);
@@ -3468,12 +3470,12 @@ int glink_qos_cancel(void *handle)
if (!ch_is_fully_opened(ctx)) {
GLINK_ERR_CH(ctx, "%s: Channel is not fully opened\n",
__func__);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -EBUSY;
}
ret = glink_qos_reset_priority(ctx);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return ret;
}
EXPORT_SYMBOL(glink_qos_cancel);
@@ -3500,7 +3502,7 @@ int glink_qos_start(void *handle)
if (!ch_is_fully_opened(ctx)) {
GLINK_ERR_CH(ctx, "%s: Channel is not fully opened\n",
__func__);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -EBUSY;
}
@@ -3509,7 +3511,7 @@ int glink_qos_start(void *handle)
ret = glink_qos_add_ch_tx_intent(ctx);
spin_unlock(&ctx->tx_lists_lock_lhc3);
spin_unlock_irqrestore(&ctx->transport_ptr->tx_ready_lock_lhb3, flags);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return ret;
}
EXPORT_SYMBOL(glink_qos_start);
@@ -3537,11 +3539,11 @@ unsigned long glink_qos_get_ramp_time(void *handle, size_t pkt_size)
if (!ch_is_fully_opened(ctx)) {
GLINK_ERR_CH(ctx, "%s: Channel is not fully opened\n",
__func__);
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return (unsigned long)-EBUSY;
}
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return ctx->transport_ptr->ops->get_power_vote_ramp_time(
ctx->transport_ptr->ops,
glink_prio_to_power_state(ctx->transport_ptr,
@@ -3549,6 +3551,61 @@ unsigned long glink_qos_get_ramp_time(void *handle, size_t pkt_size)
}
EXPORT_SYMBOL(glink_qos_get_ramp_time);
+
+/**
+ * glink_start_rx_rt() - Vote for RT thread priority on RX.
+ * @handle: Channel handle for which transaction are occurring.
+ *
+ * Return: 0 on success, standard Linux error codes on failure
+ */
+int glink_start_rx_rt(void *handle)
+{
+ struct channel_ctx *ctx = (struct channel_ctx *)handle;
+ int ret;
+
+ ret = glink_get_ch_ctx(ctx);
+ if (ret)
+ return ret;
+ if (!ch_is_fully_opened(ctx)) {
+ GLINK_ERR_CH(ctx, "%s: Channel is not fully opened\n",
+ __func__);
+ glink_put_ch_ctx(ctx);
+ return -EBUSY;
+ }
+ ret = ctx->transport_ptr->ops->rx_rt_vote(ctx->transport_ptr->ops);
+ ctx->rt_vote_on++;
+ GLINK_INFO_CH(ctx, "%s: Voting RX Realtime Thread %d", __func__, ret);
+ glink_put_ch_ctx(ctx);
+ return ret;
+}
+
+/**
+ * glink_end_rx_rt() - Vote for RT thread priority on RX.
+ * @handle: Channel handle for which transaction are occurring.
+ *
+ * Return: 0 on success, standard Linux error codes on failure
+ */
+int glink_end_rx_rt(void *handle)
+{
+ struct channel_ctx *ctx = (struct channel_ctx *)handle;
+ int ret;
+
+ ret = glink_get_ch_ctx(ctx);
+ if (ret)
+ return ret;
+ if (!ch_is_fully_opened(ctx)) {
+ GLINK_ERR_CH(ctx, "%s: Channel is not fully opened\n",
+ __func__);
+ glink_put_ch_ctx(ctx);
+ return -EBUSY;
+ }
+ ret = ctx->transport_ptr->ops->rx_rt_unvote(ctx->transport_ptr->ops);
+ ctx->rt_vote_off++;
+ GLINK_INFO_CH(ctx, "%s: Unvoting RX Realtime Thread %d", __func__, ret);
+ glink_put_ch_ctx(ctx);
+ return ret;
+}
+
/**
* glink_rpm_rx_poll() - Poll and receive any available events
* @handle: Channel handle in which this operation is performed.
@@ -3631,10 +3688,10 @@ int glink_wait_link_down(void *handle)
if (ret)
return ret;
if (!ctx->transport_ptr) {
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return -EOPNOTSUPP;
}
- glink_put_ch_ctx(ctx, false);
+ glink_put_ch_ctx(ctx);
return ctx->transport_ptr->ops->wait_link_down(ctx->transport_ptr->ops);
}
EXPORT_SYMBOL(glink_wait_link_down);
@@ -3956,6 +4013,10 @@ int glink_core_register_transport(struct glink_transport_if *if_ptr,
if_ptr->power_vote = dummy_power_vote;
if (!if_ptr->power_unvote)
if_ptr->power_unvote = dummy_power_unvote;
+ if (!if_ptr->rx_rt_vote)
+ if_ptr->rx_rt_vote = dummy_rx_rt_vote;
+ if (!if_ptr->rx_rt_unvote)
+ if_ptr->rx_rt_unvote = dummy_rx_rt_unvote;
xprt_ptr->capabilities = 0;
xprt_ptr->ops = if_ptr;
spin_lock_init(&xprt_ptr->xprt_ctx_lock_lhb1);
@@ -6175,7 +6236,6 @@ EXPORT_SYMBOL(glink_get_xprt_log_ctx);
static int glink_init(void)
{
log_ctx = ipc_log_context_create(NUM_LOG_PAGES, "glink", 0);
- rwlock_init(&magic_lock);
if (!log_ctx)
GLINK_ERR("%s: unable to create log context\n", __func__);
glink_debugfs_init();
diff --git a/drivers/soc/qcom/glink_smem_native_xprt.c b/drivers/soc/qcom/glink_smem_native_xprt.c
index 94dffa5..384347d 100644
--- a/drivers/soc/qcom/glink_smem_native_xprt.c
+++ b/drivers/soc/qcom/glink_smem_native_xprt.c
@@ -182,6 +182,8 @@ struct mailbox_config_info {
* @deferred_cmds: List of deferred commands that need to be
* processed in process context.
* @deferred_cmds_cnt: Number of deferred commands in queue.
+ * @rt_vote_lock: Serialize access to RT rx votes
+ * @rt_votes: Vote count for RT rx thread priority
* @num_pw_states: Size of @ramp_time_us.
* @ramp_time_us: Array of ramp times in microseconds where array
* index position represents a power state.
@@ -221,6 +223,8 @@ struct edge_info {
spinlock_t rx_lock;
struct list_head deferred_cmds;
uint32_t deferred_cmds_cnt;
+ spinlock_t rt_vote_lock;
+ uint32_t rt_votes;
uint32_t num_pw_states;
unsigned long *ramp_time_us;
struct mailbox_config_info *mailbox;
@@ -2125,6 +2129,52 @@ static int power_unvote(struct glink_transport_if *if_ptr)
}
/**
+ * rx_rt_vote() - Increment and RX thread RT vote
+ * @if_ptr: The transport interface on which power voting is requested.
+ *
+ * Return: 0 on Success, standard error otherwise.
+ */
+static int rx_rt_vote(struct glink_transport_if *if_ptr)
+{
+ struct edge_info *einfo;
+ struct sched_param param = { .sched_priority = 1 };
+ int ret = 0;
+ unsigned long flags;
+
+ einfo = container_of(if_ptr, struct edge_info, xprt_if);
+ spin_lock_irqsave(&einfo->rt_vote_lock, flags);
+ if (!einfo->rt_votes)
+ ret = sched_setscheduler_nocheck(einfo->task, SCHED_FIFO,
+ ¶m);
+ einfo->rt_votes++;
+ spin_unlock_irqrestore(&einfo->rt_vote_lock, flags);
+ return ret;
+}
+
+/**
+ * rx_rt_unvote() - Remove a RX thread RT vote
+ * @if_ptr: The transport interface on which power voting is requested.
+ *
+ * Return: 0 on Success, standard error otherwise.
+ */
+static int rx_rt_unvote(struct glink_transport_if *if_ptr)
+{
+ struct edge_info *einfo;
+ struct sched_param param = { .sched_priority = 0 };
+ int ret = 0;
+ unsigned long flags;
+
+ einfo = container_of(if_ptr, struct edge_info, xprt_if);
+ spin_lock_irqsave(&einfo->rt_vote_lock, flags);
+ einfo->rt_votes--;
+ if (!einfo->rt_votes)
+ ret = sched_setscheduler_nocheck(einfo->task, SCHED_NORMAL,
+ ¶m);
+ spin_unlock_irqrestore(&einfo->rt_vote_lock, flags);
+ return ret;
+}
+
+/**
* negotiate_features_v1() - determine what features of a version can be used
* @if_ptr: The transport for which features are negotiated for.
* @version: The version negotiated.
@@ -2169,6 +2219,8 @@ static void init_xprt_if(struct edge_info *einfo)
einfo->xprt_if.get_power_vote_ramp_time = get_power_vote_ramp_time;
einfo->xprt_if.power_vote = power_vote;
einfo->xprt_if.power_unvote = power_unvote;
+ einfo->xprt_if.rx_rt_vote = rx_rt_vote;
+ einfo->xprt_if.rx_rt_unvote = rx_rt_unvote;
}
/**
@@ -2341,6 +2393,8 @@ static int glink_smem_native_probe(struct platform_device *pdev)
init_srcu_struct(&einfo->use_ref);
spin_lock_init(&einfo->rx_lock);
INIT_LIST_HEAD(&einfo->deferred_cmds);
+ spin_lock_init(&einfo->rt_vote_lock);
+ einfo->rt_votes = 0;
mutex_lock(&probe_lock);
if (edge_infos[einfo->remote_proc_id]) {
diff --git a/drivers/soc/qcom/glink_xprt_if.h b/drivers/soc/qcom/glink_xprt_if.h
index f4d5a3b..47c1580 100644
--- a/drivers/soc/qcom/glink_xprt_if.h
+++ b/drivers/soc/qcom/glink_xprt_if.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -141,6 +141,8 @@ struct glink_transport_if {
struct glink_transport_if *if_ptr, uint32_t state);
int (*power_vote)(struct glink_transport_if *if_ptr, uint32_t state);
int (*power_unvote)(struct glink_transport_if *if_ptr);
+ int (*rx_rt_vote)(struct glink_transport_if *if_ptr);
+ int (*rx_rt_unvote)(struct glink_transport_if *if_ptr);
/*
* Keep data pointers at the end of the structure after all function
* pointer to allow for in-place initialization.
diff --git a/drivers/soc/qcom/icnss.c b/drivers/soc/qcom/icnss.c
index a0982bc..0b6c80d 100644
--- a/drivers/soc/qcom/icnss.c
+++ b/drivers/soc/qcom/icnss.c
@@ -2579,21 +2579,22 @@ static int icnss_service_notifier_notify(struct notifier_block *nb,
if (event_data == NULL)
return notifier_from_errno(-ENOMEM);
+ event_data->crashed = true;
+
if (state == NULL) {
- event_data->crashed = true;
priv->stats.recovery.root_pd_crash++;
goto event_post;
}
switch (*state) {
case ROOT_PD_WDOG_BITE:
- event_data->crashed = true;
event_data->wdog_bite = true;
priv->stats.recovery.root_pd_crash++;
break;
case ROOT_PD_SHUTDOWN:
cause = ICNSS_ROOT_PD_SHUTDOWN;
priv->stats.recovery.root_pd_shutdown++;
+ event_data->crashed = false;
break;
case USER_PD_STATE_CHANGE:
if (test_bit(ICNSS_HOST_TRIGGERED_PDR, &priv->state)) {
@@ -2605,7 +2606,6 @@ static int icnss_service_notifier_notify(struct notifier_block *nb,
}
break;
default:
- event_data->crashed = true;
priv->stats.recovery.root_pd_crash++;
break;
}
diff --git a/drivers/soc/qcom/msm_bus/msm_bus_dbg_voter.c b/drivers/soc/qcom/msm_bus/msm_bus_dbg_voter.c
index 3f8b52c..6c69bec 100644
--- a/drivers/soc/qcom/msm_bus/msm_bus_dbg_voter.c
+++ b/drivers/soc/qcom/msm_bus/msm_bus_dbg_voter.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -133,7 +133,7 @@ static ssize_t bus_floor_vote_store_api(struct device *dev,
return 0;
}
- if (sscanf(buf, "%s %llu", name, &vote_khz) != 2) {
+ if (sscanf(buf, "%9s %llu", name, &vote_khz) != 2) {
pr_err("%s:return error", __func__);
return -EINVAL;
}
diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 17e0a4c..1b41269 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -77,6 +77,8 @@ struct rpmh_mbox {
DECLARE_BITMAP(fast_req, RPMH_MAX_FAST_RES);
bool dirty;
bool in_solver_mode;
+ /* Cache sleep and wake requests sent as passthru */
+ struct rpmh_msg *passthru_cache[2 * RPMH_MAX_REQ_IN_BATCH];
};
struct rpmh_client {
@@ -111,17 +113,24 @@ static struct rpmh_msg *get_msg_from_pool(struct rpmh_client *rc)
return msg;
}
+static void __free_msg_to_pool(struct rpmh_msg *rpm_msg)
+{
+ struct rpmh_mbox *rpm = rpm_msg->rc->rpmh;
+
+ /* If we allocated the pool, set it as available */
+ if (rpm_msg->bit >= 0 && rpm_msg->bit != RPMH_MAX_FAST_RES) {
+ bitmap_clear(rpm->fast_req, rpm_msg->bit, 1);
+ }
+}
+
static void free_msg_to_pool(struct rpmh_msg *rpm_msg)
{
struct rpmh_mbox *rpm = rpm_msg->rc->rpmh;
unsigned long flags;
- /* If we allocated the pool, set it as available */
- if (rpm_msg->bit >= 0 && rpm_msg->bit != RPMH_MAX_FAST_RES) {
- spin_lock_irqsave(&rpm->lock, flags);
- bitmap_clear(rpm->fast_req, rpm_msg->bit, 1);
- spin_unlock_irqrestore(&rpm->lock, flags);
- }
+ spin_lock_irqsave(&rpm->lock, flags);
+ __free_msg_to_pool(rpm_msg);
+ spin_unlock_irqrestore(&rpm->lock, flags);
}
static void rpmh_rx_cb(struct mbox_client *cl, void *msg)
@@ -181,6 +190,7 @@ static inline void wait_for_tx_done(struct rpmh_client *rc,
{
int ret;
int count = 4;
+ int skip = 0;
do {
ret = wait_for_completion_timeout(compl, RPMH_TIMEOUT);
@@ -192,6 +202,10 @@ static inline void wait_for_tx_done(struct rpmh_client *rc,
return;
}
if (!count) {
+ if (skip++ % 100)
+ continue;
+ dev_err(rc->dev,
+ "RPMH waiting for interrupt from AOSS\n");
mbox_chan_debug(rc->chan);
} else {
dev_err(rc->dev,
@@ -511,6 +525,70 @@ int rpmh_write(struct rpmh_client *rc, enum rpmh_state state,
}
EXPORT_SYMBOL(rpmh_write);
+static int cache_passthru(struct rpmh_client *rc, struct rpmh_msg **rpm_msg,
+ int count)
+{
+ struct rpmh_mbox *rpm = rc->rpmh;
+ unsigned long flags;
+ int ret = 0;
+ int index = 0;
+ int i;
+
+ spin_lock_irqsave(&rpm->lock, flags);
+ while (rpm->passthru_cache[index])
+ index++;
+ if (index + count >= 2 * RPMH_MAX_REQ_IN_BATCH) {
+ ret = -ENOMEM;
+ goto fail;
+ }
+
+ for (i = 0; i < count; i++)
+ rpm->passthru_cache[index + i] = rpm_msg[i];
+fail:
+ spin_unlock_irqrestore(&rpm->lock, flags);
+
+ return ret;
+}
+
+static int flush_passthru(struct rpmh_client *rc)
+{
+ struct rpmh_mbox *rpm = rc->rpmh;
+ struct rpmh_msg *rpm_msg;
+ unsigned long flags;
+ int ret = 0;
+ int i;
+
+ /* Send Sleep/Wake requests to the controller, expect no response */
+ spin_lock_irqsave(&rpm->lock, flags);
+ for (i = 0; rpm->passthru_cache[i]; i++) {
+ rpm_msg = rpm->passthru_cache[i];
+ ret = mbox_send_controller_data(rc->chan, &rpm_msg->msg);
+ if (ret)
+ goto fail;
+ }
+fail:
+ spin_unlock_irqrestore(&rpm->lock, flags);
+
+ return ret;
+}
+
+static void invalidate_passthru(struct rpmh_client *rc)
+{
+ struct rpmh_mbox *rpm = rc->rpmh;
+ unsigned long flags;
+ int index = 0;
+ int i;
+
+ spin_lock_irqsave(&rpm->lock, flags);
+ while (rpm->passthru_cache[index])
+ index++;
+ for (i = 0; i < index; i++) {
+ __free_msg_to_pool(rpm->passthru_cache[i]);
+ rpm->passthru_cache[i] = NULL;
+ }
+ spin_unlock_irqrestore(&rpm->lock, flags);
+}
+
/**
* rpmh_write_passthru: Write multiple batches of RPMH commands without caching
*
@@ -530,7 +608,7 @@ EXPORT_SYMBOL(rpmh_write);
int rpmh_write_passthru(struct rpmh_client *rc, enum rpmh_state state,
struct tcs_cmd *cmd, int *n)
{
- struct rpmh_msg *rpm_msg[RPMH_MAX_REQ_IN_BATCH];
+ struct rpmh_msg *rpm_msg[RPMH_MAX_REQ_IN_BATCH] = { NULL };
DECLARE_COMPLETION_ONSTACK(compl);
atomic_t wait_count = ATOMIC_INIT(0); /* overwritten */
int count = 0;
@@ -548,7 +626,7 @@ int rpmh_write_passthru(struct rpmh_client *rc, enum rpmh_state state,
if (ret)
return ret;
- while (n[count++])
+ while (n[count++] > 0)
;
count--;
if (!count || count > RPMH_MAX_REQ_IN_BATCH)
@@ -607,14 +685,11 @@ int rpmh_write_passthru(struct rpmh_client *rc, enum rpmh_state state,
rpmh_tx_done(&rc->client, &rpm_msg[j]->msg, ret);
wait_for_tx_done(rc, &compl, addr, data);
} else {
- /* Send Sleep requests to the controller, expect no response */
- for (i = 0; i < count; i++) {
- rpm_msg[i]->completion = NULL;
- ret = mbox_send_controller_data(rc->chan,
- &rpm_msg[i]->msg);
- free_msg_to_pool(rpm_msg[i]);
- }
- return 0;
+ /*
+ * Cache sleep/wake data in store.
+ * But flush passthru first before flushing all other data.
+ */
+ return cache_passthru(rc, rpm_msg, count);
}
return 0;
@@ -674,7 +749,7 @@ int rpmh_write_control(struct rpmh_client *rc, struct tcs_cmd *cmd, int n)
{
DEFINE_RPMH_MSG_ONSTACK(rc, 0, NULL, NULL, rpm_msg);
- if (IS_ERR_OR_NULL(rc) || n > MAX_RPMH_PAYLOAD)
+ if (IS_ERR_OR_NULL(rc) || n <= 0 || n > MAX_RPMH_PAYLOAD)
return -EINVAL;
if (rpmh_standalone)
@@ -710,6 +785,8 @@ int rpmh_invalidate(struct rpmh_client *rc)
if (rpmh_standalone)
return 0;
+ invalidate_passthru(rc);
+
rpm = rc->rpmh;
rpm_msg.msg.invalidate = true;
rpm_msg.msg.is_complete = false;
@@ -823,6 +900,11 @@ int rpmh_flush(struct rpmh_client *rc)
}
spin_unlock_irqrestore(&rpm->lock, flags);
+ /* First flush the cached passthru's */
+ ret = flush_passthru(rc);
+ if (ret)
+ return ret;
+
/*
* Nobody else should be calling this function other than sleep,
* hence we can run without locks.
@@ -906,8 +988,10 @@ static struct rpmh_mbox *get_mbox(struct platform_device *pdev,
rpmh->msg_pool = kzalloc(sizeof(struct rpmh_msg) *
RPMH_MAX_FAST_RES, GFP_KERNEL);
- if (!rpmh->msg_pool)
+ if (!rpmh->msg_pool) {
+ of_node_put(spec.np);
return ERR_PTR(-ENOMEM);
+ }
rpmh->mbox_dn = spec.np;
INIT_LIST_HEAD(&rpmh->resources);
diff --git a/drivers/thermal/msm-tsens.c b/drivers/thermal/msm-tsens.c
index a04ddae..fe0a7c7 100644
--- a/drivers/thermal/msm-tsens.c
+++ b/drivers/thermal/msm-tsens.c
@@ -160,14 +160,18 @@ static int tsens_thermal_zone_register(struct tsens_device *tmdev)
for (i = 0; i < TSENS_MAX_SENSORS; i++) {
tmdev->sensor[i].tmdev = tmdev;
tmdev->sensor[i].hw_id = i;
- tmdev->sensor[i].tzd =
- devm_thermal_zone_of_sensor_register(
- &tmdev->pdev->dev, i,
- &tmdev->sensor[i], &tsens_tm_thermal_zone_ops);
- if (IS_ERR(tmdev->sensor[i].tzd)) {
- pr_debug("Error registering sensor:%d\n", i);
- sensor_missing++;
- continue;
+ if (tmdev->ops->sensor_en(tmdev, i)) {
+ tmdev->sensor[i].tzd =
+ devm_thermal_zone_of_sensor_register(
+ &tmdev->pdev->dev, i,
+ &tmdev->sensor[i], &tsens_tm_thermal_zone_ops);
+ if (IS_ERR(tmdev->sensor[i].tzd)) {
+ pr_debug("Error registering sensor:%d\n", i);
+ sensor_missing++;
+ continue;
+ }
+ } else {
+ pr_debug("Sensor not enabled:%d\n", i);
}
}
diff --git a/drivers/thermal/tsens.h b/drivers/thermal/tsens.h
index 770b982..a695d57 100644
--- a/drivers/thermal/tsens.h
+++ b/drivers/thermal/tsens.h
@@ -91,6 +91,7 @@ struct tsens_ops {
int (*set_trips)(struct tsens_sensor *, int, int);
int (*interrupts_reg)(struct tsens_device *);
int (*dbg)(struct tsens_device *, u32, u32, int *);
+ int (*sensor_en)(struct tsens_device *, u32);
};
struct tsens_irqs {
diff --git a/drivers/thermal/tsens2xxx.c b/drivers/thermal/tsens2xxx.c
index 55be2f9..de9f27f 100644
--- a/drivers/thermal/tsens2xxx.c
+++ b/drivers/thermal/tsens2xxx.c
@@ -61,6 +61,7 @@
#define TSENS_TM_WATCHDOG_LOG(n) ((n) + 0x13c)
#define TSENS_EN BIT(0)
+#define TSENS_CTRL_SENSOR_EN_MASK(n) ((n >> 3) & 0xffff)
static void msm_tsens_convert_temp(int last_temp, int *temp)
{
@@ -499,6 +500,21 @@ static irqreturn_t tsens_tm_irq_thread(int irq, void *data)
return IRQ_HANDLED;
}
+static int tsens2xxx_hw_sensor_en(struct tsens_device *tmdev,
+ u32 sensor_id)
+{
+ void __iomem *srot_addr;
+ unsigned int srot_val, sensor_en;
+
+ srot_addr = TSENS_CTRL_ADDR(tmdev->tsens_srot_addr + 0x4);
+ srot_val = readl_relaxed(srot_addr);
+ srot_val = TSENS_CTRL_SENSOR_EN_MASK(srot_val);
+
+ sensor_en = ((1 << sensor_id) & srot_val);
+
+ return sensor_en;
+}
+
static int tsens2xxx_hw_init(struct tsens_device *tmdev)
{
void __iomem *srot_addr;
@@ -602,6 +618,7 @@ static const struct tsens_ops ops_tsens2xxx = {
.set_trips = tsens2xxx_set_trip_temp,
.interrupts_reg = tsens2xxx_register_interrupts,
.dbg = tsens2xxx_dbg,
+ .sensor_en = tsens2xxx_hw_sensor_en,
};
const struct tsens_data data_tsens2xxx = {
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
index 3e9d233..0dc81d2 100644
--- a/drivers/usb/dwc3/dwc3-msm.c
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -2912,6 +2912,7 @@ static int dwc3_msm_extcon_register(struct dwc3_msm *mdwc)
}
}
+ edev = NULL;
/* Use third phandle (optional) for EUD based detach/attach events */
if (of_count_phandle_with_args(node, "extcon", NULL) > 2) {
edev = extcon_get_edev_by_phandle(mdwc->dev, 2);
@@ -2921,7 +2922,7 @@ static int dwc3_msm_extcon_register(struct dwc3_msm *mdwc)
}
}
- if (!IS_ERR(edev)) {
+ if (!IS_ERR_OR_NULL(edev)) {
mdwc->extcon_eud = edev;
mdwc->eud_event_nb.notifier_call = dwc3_msm_eud_notifier;
ret = extcon_register_notifier(edev, EXTCON_USB,
diff --git a/drivers/usb/pd/policy_engine.c b/drivers/usb/pd/policy_engine.c
index 1fad512..141b916 100644
--- a/drivers/usb/pd/policy_engine.c
+++ b/drivers/usb/pd/policy_engine.c
@@ -1432,6 +1432,7 @@ static void reset_vdm_state(struct usbpd *pd)
static void dr_swap(struct usbpd *pd)
{
reset_vdm_state(pd);
+ usbpd_dbg(&pd->dev, "dr_swap: current_dr(%d)\n", pd->current_dr);
if (pd->current_dr == DR_DFP) {
stop_usb_host(pd);
@@ -1439,9 +1440,9 @@ static void dr_swap(struct usbpd *pd)
pd->current_dr = DR_UFP;
} else if (pd->current_dr == DR_UFP) {
stop_usb_peripheral(pd);
+ start_usb_host(pd, true);
pd->current_dr = DR_DFP;
- /* don't start USB host until after SVDM discovery */
usbpd_send_svdm(pd, USBPD_SID, USBPD_SVDM_DISCOVER_IDENTITY,
SVDM_CMD_TYPE_INITIATOR, 0, NULL, 0);
}
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 71b62b8..c585e7e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1617,6 +1617,9 @@ struct reclaim_param reclaim_task_anon(struct task_struct *task,
if (vma->vm_file)
continue;
+ if (vma->vm_flags & VM_LOCKED)
+ continue;
+
if (!rp.nr_to_reclaim)
break;
diff --git a/include/dt-bindings/clock/mdss-10nm-pll-clk.h b/include/dt-bindings/clock/mdss-10nm-pll-clk.h
index 75ddcfa..8108c98 100644
--- a/include/dt-bindings/clock/mdss-10nm-pll-clk.h
+++ b/include/dt-bindings/clock/mdss-10nm-pll-clk.h
@@ -17,23 +17,25 @@
/* DSI PLL clocks */
#define VCO_CLK_0 0
-#define BITCLK_SRC_0_CLK 1
-#define BYTECLK_SRC_0_CLK 2
-#define POST_BIT_DIV_0_CLK 3
-#define POST_VCO_DIV_0_CLK 4
-#define BYTECLK_MUX_0_CLK 5
-#define PCLK_SRC_MUX_0_CLK 6
-#define PCLK_SRC_0_CLK 7
-#define PCLK_MUX_0_CLK 8
-#define VCO_CLK_1 9
-#define BITCLK_SRC_1_CLK 10
-#define BYTECLK_SRC_1_CLK 11
-#define POST_BIT_DIV_1_CLK 12
-#define POST_VCO_DIV_1_CLK 13
-#define BYTECLK_MUX_1_CLK 14
-#define PCLK_SRC_MUX_1_CLK 15
-#define PCLK_SRC_1_CLK 16
-#define PCLK_MUX_1_CLK 17
+#define PLL_OUT_DIV_0_CLK 1
+#define BITCLK_SRC_0_CLK 2
+#define BYTECLK_SRC_0_CLK 3
+#define POST_BIT_DIV_0_CLK 4
+#define POST_VCO_DIV_0_CLK 5
+#define BYTECLK_MUX_0_CLK 6
+#define PCLK_SRC_MUX_0_CLK 7
+#define PCLK_SRC_0_CLK 8
+#define PCLK_MUX_0_CLK 9
+#define VCO_CLK_1 10
+#define PLL_OUT_DIV_1_CLK 11
+#define BITCLK_SRC_1_CLK 12
+#define BYTECLK_SRC_1_CLK 13
+#define POST_BIT_DIV_1_CLK 14
+#define POST_VCO_DIV_1_CLK 15
+#define BYTECLK_MUX_1_CLK 16
+#define PCLK_SRC_MUX_1_CLK 17
+#define PCLK_SRC_1_CLK 18
+#define PCLK_MUX_1_CLK 19
/* DP PLL clocks */
#define DP_VCO_CLK 0
diff --git a/include/dt-bindings/clock/qcom,gcc-sdm845.h b/include/dt-bindings/clock/qcom,gcc-sdm845.h
index 3d58645..339d470 100644
--- a/include/dt-bindings/clock/qcom,gcc-sdm845.h
+++ b/include/dt-bindings/clock/qcom,gcc-sdm845.h
@@ -211,6 +211,7 @@
#define GCC_VS_CTRL_CLK 193
#define GCC_VS_CTRL_CLK_SRC 194
#define GCC_VSENSOR_CLK_SRC 195
+#define GPLL4 196
/* GCC reset clocks */
#define GCC_MMSS_BCR 0
diff --git a/include/linux/coresight.h b/include/linux/coresight.h
index 0538291..10842bb 100644
--- a/include/linux/coresight.h
+++ b/include/linux/coresight.h
@@ -266,9 +266,13 @@ static inline int coresight_timeout(void __iomem *addr, u32 offset,
#ifdef CONFIG_OF
extern struct coresight_platform_data *of_get_coresight_platform_data(
struct device *dev, struct device_node *node);
+extern struct coresight_cti_data *of_get_coresight_cti_data(
+ struct device *dev, struct device_node *node);
#else
static inline struct coresight_platform_data *of_get_coresight_platform_data(
struct device *dev, struct device_node *node) { return NULL; }
+static inlint struct coresight_cti_data *of_get_coresight_cti_data(
+ struct device *dev, struct device_node *node) { return NULL; }
#endif
#ifdef CONFIG_PID_NS
diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
index 322bc23..8410c32 100644
--- a/include/linux/sched/sysctl.h
+++ b/include/linux/sched/sysctl.h
@@ -72,9 +72,6 @@ int sched_proc_update_handler(struct ctl_table *table, int write,
extern int sched_migrate_notify_proc_handler(struct ctl_table *table,
int write, void __user *buffer, size_t *lenp, loff_t *ppos);
-extern int sched_hmp_proc_update_handler(struct ctl_table *table,
- int write, void __user *buffer, size_t *lenp, loff_t *ppos);
-
extern int sched_boost_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos);
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 45dbffb..8529be6 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -784,19 +784,15 @@ struct cfg80211_csa_settings {
* @iftype_num: array with the number of interfaces of each interface
* type. The index is the interface type as specified in &enum
* nl80211_iftype.
- * @beacon_int_gcd: a value specifying GCD of all beaconing interfaces,
- * the GCD of a single value is considered the value itself, so for
- * a single interface this should be set to that interface's beacon
- * interval
- * @beacon_int_different: a flag indicating whether or not all beacon
- * intervals (of beaconing interfaces) are different or not.
+ * @new_beacon_int: set this to the beacon interval of a new interface
+ * that's not operating yet, if such is to be checked as part of
+ * the verification
*/
struct iface_combination_params {
int num_different_channels;
u8 radar_detect;
int iftype_num[NUM_NL80211_IFTYPES];
- u32 beacon_int_gcd;
- bool beacon_int_different;
+ u32 new_beacon_int;
};
/**
diff --git a/include/soc/qcom/glink.h b/include/soc/qcom/glink.h
index 7b86481..4522b11 100644
--- a/include/soc/qcom/glink.h
+++ b/include/soc/qcom/glink.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -340,6 +340,22 @@ int glink_qos_start(void *handle);
*/
unsigned long glink_qos_get_ramp_time(void *handle, size_t pkt_size);
+/**
+ * glink_start_rx_rt() - Vote for RT thread priority on RX.
+ * @handle: Channel handle for which transaction are occurring.
+ *
+ * Return: 0 on success, standard Linux error codes on failure
+ */
+int glink_start_rx_rt(void *handle);
+
+/**
+ * glink_end_rx_rt() - Vote for RT thread priority on RX.
+ * @handle: Channel handle for which transaction are occurring.
+ *
+ * Return: 0 on success, standard Linux error codes on failure
+ */
+int glink_end_rx_rt(void *handle);
+
#else /* CONFIG_MSM_GLINK */
static inline void *glink_open(const struct glink_open_config *cfg_ptr)
{
@@ -428,5 +444,16 @@ static inline unsigned long glink_qos_get_ramp_time(void *handle,
{
return 0;
}
+
+static inline int glink_start_rx_rt(void *handle)
+{
+ return -ENODEV;
+}
+
+static inline int glink_end_rx_rt(void *handle)
+{
+ return -ENODEV;
+}
+
#endif /* CONFIG_MSM_GLINK */
#endif /* _SOC_QCOM_GLINK_H_ */
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index bbcb3d5..cf3f5e3 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -71,10 +71,8 @@ TRACE_EVENT(sched_enq_deq_task,
__field(unsigned long, cpu_load )
__field(unsigned int, rt_nr_running )
__field(unsigned int, cpus_allowed )
-#ifdef CONFIG_SCHED_WALT
__field(unsigned int, demand )
__field(unsigned int, pred_demand )
-#endif
),
TP_fast_assign(
@@ -87,24 +85,17 @@ TRACE_EVENT(sched_enq_deq_task,
__entry->cpu_load = task_rq(p)->cpu_load[0];
__entry->rt_nr_running = task_rq(p)->rt.rt_nr_running;
__entry->cpus_allowed = cpus_allowed;
-#ifdef CONFIG_SCHED_WALT
- __entry->demand = p->ravg.demand;
- __entry->pred_demand = p->ravg.pred_demand;
-#endif
+ __entry->demand = task_load(p);
+ __entry->pred_demand = task_pl(p);
),
- TP_printk("cpu=%d %s comm=%s pid=%d prio=%d nr_running=%u cpu_load=%lu rt_nr_running=%u affine=%x"
-#ifdef CONFIG_SCHED_WALT
- " demand=%u pred_demand=%u"
-#endif
- , __entry->cpu,
+ TP_printk("cpu=%d %s comm=%s pid=%d prio=%d nr_running=%u cpu_load=%lu rt_nr_running=%u affine=%x demand=%u pred_demand=%u",
+ __entry->cpu,
__entry->enqueue ? "enqueue" : "dequeue",
__entry->comm, __entry->pid,
__entry->prio, __entry->nr_running,
__entry->cpu_load, __entry->rt_nr_running, __entry->cpus_allowed
-#ifdef CONFIG_SCHED_WALT
, __entry->demand, __entry->pred_demand
-#endif
)
);
@@ -254,7 +245,7 @@ TRACE_EVENT(sched_update_history,
__entry->pred_demand = p->ravg.pred_demand;
memcpy(__entry->hist, p->ravg.sum_history,
RAVG_HIST_SIZE_MAX * sizeof(u32));
- __entry->nr_big_tasks = rq->hmp_stats.nr_big_tasks;
+ __entry->nr_big_tasks = rq->walt_stats.nr_big_tasks;
__entry->cpu = rq->cpu;
),
@@ -572,10 +563,10 @@ DECLARE_EVENT_CLASS(sched_cpu_load,
__entry->cpu = rq->cpu;
__entry->idle = idle;
__entry->nr_running = rq->nr_running;
- __entry->nr_big_tasks = rq->hmp_stats.nr_big_tasks;
+ __entry->nr_big_tasks = rq->walt_stats.nr_big_tasks;
__entry->load_scale_factor = cpu_load_scale_factor(rq->cpu);
__entry->capacity = cpu_capacity(rq->cpu);
- __entry->cumulative_runnable_avg = rq->hmp_stats.cumulative_runnable_avg;
+ __entry->cumulative_runnable_avg = rq->walt_stats.cumulative_runnable_avg;
__entry->irqload = irqload;
__entry->max_freq = cpu_max_freq(rq->cpu);
__entry->power_cost = power_cost;
@@ -627,7 +618,7 @@ TRACE_EVENT(sched_load_to_gov,
__entry->grp_rq_ps = rq->grp_time.prev_runnable_sum;
__entry->nt_ps = rq->nt_prev_runnable_sum;
__entry->grp_nt_ps = rq->grp_time.nt_prev_runnable_sum;
- __entry->pl = rq->hmp_stats.pred_demands_sum;
+ __entry->pl = rq->walt_stats.pred_demands_sum;
__entry->load = load;
),
diff --git a/include/uapi/media/cam_req_mgr.h b/include/uapi/media/cam_req_mgr.h
index e073c5c..23a8ccf 100644
--- a/include/uapi/media/cam_req_mgr.h
+++ b/include/uapi/media/cam_req_mgr.h
@@ -22,6 +22,7 @@
#define CAM_ACTUATOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 9)
#define CAM_CCI_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 10)
#define CAM_FLASH_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 11)
+#define CAM_EEPROM_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 12)
/* cam_req_mgr hdl info */
#define CAM_REQ_MGR_HDL_IDX_POS 8
diff --git a/include/uapi/media/cam_sensor.h b/include/uapi/media/cam_sensor.h
index 83f1a02..ac370ba 100644
--- a/include/uapi/media/cam_sensor.h
+++ b/include/uapi/media/cam_sensor.h
@@ -6,7 +6,7 @@
#include <media/cam_defs.h>
#define CAM_SENSOR_PROBE_CMD (CAM_COMMON_OPCODE_MAX + 1)
-#define CAM_SENSOR_MAX_LED_TRIGGERS 3
+#define CAM_FLASH_MAX_LED_TRIGGERS 3
/**
* struct cam_sensor_query_cap - capabilities info for sensor
*
@@ -63,6 +63,18 @@ struct cam_actuator_query_cap {
} __attribute__((packed));
/**
+ * struct cam_eeprom_query_cap_t - capabilities info for eeprom
+ *
+ * @slot_info : Indicates about the slotId or cell Index
+ * @eeprom_kernel_probe : Indicates about the kernel or userspace probe
+ */
+struct cam_eeprom_query_cap_t {
+ uint32_t slot_info;
+ uint16_t eeprom_kernel_probe;
+ uint16_t reserved;
+} __attribute__((packed));
+
+/**
* struct cam_cmd_i2c_info - Contains slave I2C related info
*
* @slave_addr : Slave address
@@ -360,7 +372,7 @@ struct cam_flash_set_rer {
uint16_t reserved;
uint32_t led_on_delay_ms;
uint32_t led_off_delay_ms;
- uint32_t led_current_ma[CAM_SENSOR_MAX_LED_TRIGGERS];
+ uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
} __attribute__((packed));
/**
@@ -379,7 +391,7 @@ struct cam_flash_set_on_off {
uint16_t count;
uint8_t opcode;
uint8_t cmd_type;
- uint32_t led_current_ma[CAM_SENSOR_MAX_LED_TRIGGERS];
+ uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
} __attribute__((packed));
/**
@@ -409,9 +421,9 @@ struct cam_flash_query_curr {
*/
struct cam_flash_query_cap_info {
uint32_t slot_info;
- uint32_t max_current_flash[CAM_SENSOR_MAX_LED_TRIGGERS];
- uint32_t max_duration_flash[CAM_SENSOR_MAX_LED_TRIGGERS];
- uint32_t max_current_torch[CAM_SENSOR_MAX_LED_TRIGGERS];
+ uint32_t max_current_flash[CAM_FLASH_MAX_LED_TRIGGERS];
+ uint32_t max_duration_flash[CAM_FLASH_MAX_LED_TRIGGERS];
+ uint32_t max_current_torch[CAM_FLASH_MAX_LED_TRIGGERS];
} __attribute__ ((packed));
#endif
diff --git a/kernel/sched/boost.c b/kernel/sched/boost.c
index 1a3309b..1ccd19d 100644
--- a/kernel/sched/boost.c
+++ b/kernel/sched/boost.c
@@ -32,7 +32,7 @@ static inline void boost_kick(int cpu)
{
struct rq *rq = cpu_rq(cpu);
- if (!test_and_set_bit(BOOST_KICK, &rq->hmp_flags))
+ if (!test_and_set_bit(BOOST_KICK, &rq->walt_flags))
smp_send_reschedule(cpu);
}
@@ -57,14 +57,14 @@ int got_boost_kick(void)
int cpu = smp_processor_id();
struct rq *rq = cpu_rq(cpu);
- return test_bit(BOOST_KICK, &rq->hmp_flags);
+ return test_bit(BOOST_KICK, &rq->walt_flags);
}
void clear_boost_kick(int cpu)
{
struct rq *rq = cpu_rq(cpu);
- clear_bit(BOOST_KICK, &rq->hmp_flags);
+ clear_bit(BOOST_KICK, &rq->walt_flags);
}
/*
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 46e4643..f3ebc06 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1679,7 +1679,7 @@ int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags)
return cpu;
}
-void update_avg(u64 *avg, u64 sample)
+static void update_avg(u64 *avg, u64 sample)
{
s64 diff = sample - *avg;
*avg += diff >> 3;
@@ -5958,7 +5958,7 @@ int do_isolation_work_cpu_stop(void *data)
*/
nohz_balance_clear_nohz_mask(cpu);
- clear_hmp_request(cpu);
+ clear_walt_request(cpu);
local_irq_enable();
return 0;
}
@@ -8068,7 +8068,7 @@ int sched_cpu_dying(unsigned int cpu)
BUG_ON(rq->nr_running != 1);
raw_spin_unlock_irqrestore(&rq->lock, flags);
- clear_hmp_request(cpu);
+ clear_walt_request(cpu);
calc_load_migrate(rq);
update_max_interval();
@@ -8308,7 +8308,6 @@ void __init sched_init(void)
rq->avg_idle = 2*sysctl_sched_migration_cost;
rq->max_idle_balance_cost = sysctl_sched_migration_cost;
rq->push_task = NULL;
-
walt_sched_init(rq);
INIT_LIST_HEAD(&rq->cfs_tasks);
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 10a807c..08d4511 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -19,41 +19,6 @@
#include <linux/slab.h>
-#ifdef CONFIG_SCHED_WALT
-
-static void
-inc_hmp_sched_stats_dl(struct rq *rq, struct task_struct *p)
-{
- inc_cumulative_runnable_avg(&rq->hmp_stats, p);
-}
-
-static void
-dec_hmp_sched_stats_dl(struct rq *rq, struct task_struct *p)
-{
- dec_cumulative_runnable_avg(&rq->hmp_stats, p);
-}
-
-static void
-fixup_hmp_sched_stats_dl(struct rq *rq, struct task_struct *p,
- u32 new_task_load, u32 new_pred_demand)
-{
- s64 task_load_delta = (s64)new_task_load - task_load(p);
- s64 pred_demand_delta = PRED_DEMAND_DELTA;
-
- fixup_cumulative_runnable_avg(&rq->hmp_stats, p, task_load_delta,
- pred_demand_delta);
-}
-
-#else /* CONFIG_SCHED_WALT */
-
-static inline void
-inc_hmp_sched_stats_dl(struct rq *rq, struct task_struct *p) { }
-
-static inline void
-dec_hmp_sched_stats_dl(struct rq *rq, struct task_struct *p) { }
-
-#endif /* CONFIG_SCHED_WALT */
-
struct dl_bandwidth def_dl_bandwidth;
static inline struct task_struct *dl_task_of(struct sched_dl_entity *dl_se)
@@ -865,7 +830,7 @@ void inc_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
WARN_ON(!dl_prio(prio));
dl_rq->dl_nr_running++;
add_nr_running(rq_of_dl_rq(dl_rq), 1);
- inc_hmp_sched_stats_dl(rq_of_dl_rq(dl_rq), dl_task_of(dl_se));
+ walt_inc_cumulative_runnable_avg(rq_of_dl_rq(dl_rq), dl_task_of(dl_se));
inc_dl_deadline(dl_rq, deadline);
inc_dl_migration(dl_se, dl_rq);
@@ -880,7 +845,7 @@ void dec_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
WARN_ON(!dl_rq->dl_nr_running);
dl_rq->dl_nr_running--;
sub_nr_running(rq_of_dl_rq(dl_rq), 1);
- dec_hmp_sched_stats_dl(rq_of_dl_rq(dl_rq), dl_task_of(dl_se));
+ walt_dec_cumulative_runnable_avg(rq_of_dl_rq(dl_rq), dl_task_of(dl_se));
dec_dl_deadline(dl_rq, dl_se->deadline);
dec_dl_migration(dl_se, dl_rq);
@@ -1845,7 +1810,7 @@ const struct sched_class dl_sched_class = {
.update_curr = update_curr_dl,
#ifdef CONFIG_SCHED_WALT
- .fixup_hmp_sched_stats = fixup_hmp_sched_stats_dl,
+ .fixup_walt_sched_stats = fixup_walt_sched_stats_common,
#endif
};
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index b520691..0f8c0b2 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -600,12 +600,6 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
cfs_rq->throttle_count);
SEQ_printf(m, " .%-30s: %d\n", "runtime_enabled",
cfs_rq->runtime_enabled);
-#ifdef CONFIG_SCHED_WALT
- SEQ_printf(m, " .%-30s: %d\n", "nr_big_tasks",
- cfs_rq->hmp_stats.nr_big_tasks);
- SEQ_printf(m, " .%-30s: %llu\n", "cumulative_runnable_avg",
- cfs_rq->hmp_stats.cumulative_runnable_avg);
-#endif
#endif
#ifdef CONFIG_FAIR_GROUP_SCHED
@@ -706,10 +700,10 @@ do { \
P(cluster->max_freq);
P(cluster->exec_scale_factor);
#ifdef CONFIG_SCHED_WALT
- P(hmp_stats.nr_big_tasks);
+ P(walt_stats.nr_big_tasks);
#endif
- SEQ_printf(m, " .%-30s: %llu\n", "hmp_stats.cumulative_runnable_avg",
- rq->hmp_stats.cumulative_runnable_avg);
+ SEQ_printf(m, " .%-30s: %llu\n", "walt_stats.cumulative_runnable_avg",
+ rq->walt_stats.cumulative_runnable_avg);
#endif
#undef P
#undef PN
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index e0ab4d6..6b54c26 100755
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -37,46 +37,6 @@
#include "walt.h"
#include <trace/events/sched.h>
-/* QHMP/Zone forward declarations */
-
-struct lb_env;
-struct sd_lb_stats;
-struct sg_lb_stats;
-
-#ifdef CONFIG_SCHED_WALT
-static void fixup_hmp_sched_stats_fair(struct rq *rq, struct task_struct *p,
- u32 new_task_load, u32 new_pred_demand);
-#endif
-
-static inline void inc_cfs_rq_hmp_stats(struct cfs_rq *cfs_rq,
- struct task_struct *p, int change_cra) { }
-static inline void dec_cfs_rq_hmp_stats(struct cfs_rq *cfs_rq,
- struct task_struct *p, int change_cra) { }
-static inline void dec_throttled_cfs_rq_hmp_stats(
- struct hmp_sched_stats *stats,
- struct cfs_rq *cfs_rq) { }
-static inline void inc_throttled_cfs_rq_hmp_stats(
- struct hmp_sched_stats *stats,
- struct cfs_rq *cfs_rq) { }
-static inline void init_cfs_rq_hmp_stats(struct cfs_rq *cfs_rq) { }
-
-#ifdef CONFIG_SMP
-
-static inline int
-bail_inter_cluster_balance(struct lb_env *env, struct sd_lb_stats *sds)
-{
- return 0;
-}
-
-static inline bool update_sd_pick_busiest_active_balance(struct lb_env *env,
- struct sd_lb_stats *sds,
- struct sched_group *sg,
- struct sg_lb_stats *sgs)
-{
- return false;
-}
-#endif /* CONFIG_SMP */
-
#ifdef CONFIG_SCHED_WALT
static inline bool task_fits_max(struct task_struct *p, int cpu);
#endif
@@ -4047,16 +4007,13 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq)
if (dequeue)
dequeue_entity(qcfs_rq, se, DEQUEUE_SLEEP);
qcfs_rq->h_nr_running -= task_delta;
- dec_throttled_cfs_rq_hmp_stats(&qcfs_rq->hmp_stats, cfs_rq);
if (qcfs_rq->load.weight)
dequeue = 0;
}
- if (!se) {
+ if (!se)
sub_nr_running(rq, task_delta);
- dec_throttled_cfs_rq_hmp_stats(&rq->hmp_stats, cfs_rq);
- }
cfs_rq->throttled = 1;
cfs_rq->throttled_clock = rq_clock(rq);
@@ -4077,11 +4034,6 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq)
start_cfs_bandwidth(cfs_b);
raw_spin_unlock(&cfs_b->lock);
-
- /* Log effect on hmp stats after throttling */
- trace_sched_cpu_load_cgroup(rq, idle_cpu(cpu_of(rq)),
- sched_irqload(cpu_of(rq)),
- power_cost(cpu_of(rq), 0));
}
void unthrottle_cfs_rq(struct cfs_rq *cfs_rq)
@@ -4119,25 +4071,17 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq)
if (enqueue)
enqueue_entity(cfs_rq, se, ENQUEUE_WAKEUP);
cfs_rq->h_nr_running += task_delta;
- inc_throttled_cfs_rq_hmp_stats(&cfs_rq->hmp_stats, tcfs_rq);
if (cfs_rq_throttled(cfs_rq))
break;
}
- if (!se) {
+ if (!se)
add_nr_running(rq, task_delta);
- inc_throttled_cfs_rq_hmp_stats(&rq->hmp_stats, tcfs_rq);
- }
/* determine whether we need to wake up potentially idle cpu */
if (rq->curr == rq->idle && rq->cfs.nr_running)
resched_curr(rq);
-
- /* Log effect on hmp stats after un-throttling */
- trace_sched_cpu_load_cgroup(rq, idle_cpu(cpu_of(rq)),
- sched_irqload(cpu_of(rq)),
- power_cost(cpu_of(rq), 0));
}
static u64 distribute_cfs_runtime(struct cfs_bandwidth *cfs_b,
@@ -4475,7 +4419,6 @@ static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq)
{
cfs_rq->runtime_enabled = 0;
INIT_LIST_HEAD(&cfs_rq->throttled_list);
- init_cfs_rq_hmp_stats(cfs_rq);
}
void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b)
@@ -4693,7 +4636,6 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
if (cfs_rq_throttled(cfs_rq))
break;
cfs_rq->h_nr_running++;
- inc_cfs_rq_hmp_stats(cfs_rq, p, 1);
flags = ENQUEUE_WAKEUP;
}
@@ -4701,7 +4643,6 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
for_each_sched_entity(se) {
cfs_rq = cfs_rq_of(se);
cfs_rq->h_nr_running++;
- inc_cfs_rq_hmp_stats(cfs_rq, p, 1);
if (cfs_rq_throttled(cfs_rq))
break;
@@ -4715,7 +4656,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
#ifdef CONFIG_SCHED_WALT
p->misfit = !task_fits_max(p, rq->cpu);
#endif
- inc_rq_hmp_stats(rq, p, 1);
+ inc_rq_walt_stats(rq, p);
}
#ifdef CONFIG_SMP
@@ -4771,7 +4712,6 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
if (cfs_rq_throttled(cfs_rq))
break;
cfs_rq->h_nr_running--;
- dec_cfs_rq_hmp_stats(cfs_rq, p, 1);
/* Don't dequeue parent if it has other entities besides us */
if (cfs_rq->load.weight) {
@@ -4791,7 +4731,6 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
for_each_sched_entity(se) {
cfs_rq = cfs_rq_of(se);
cfs_rq->h_nr_running--;
- dec_cfs_rq_hmp_stats(cfs_rq, p, 1);
if (cfs_rq_throttled(cfs_rq))
break;
@@ -4802,7 +4741,7 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
if (!se) {
sub_nr_running(rq, 1);
- dec_rq_hmp_stats(rq, p, 1);
+ dec_rq_walt_stats(rq, p);
}
#ifdef CONFIG_SMP
@@ -8657,9 +8596,6 @@ static bool update_sd_pick_busiest(struct lb_env *env,
{
struct sg_lb_stats *busiest = &sds->busiest_stat;
- if (update_sd_pick_busiest_active_balance(env, sds, sg, sgs))
- return true;
-
if (sgs->group_type > busiest->group_type)
return true;
@@ -9123,9 +9059,6 @@ static struct sched_group *find_busiest_group(struct lb_env *env)
if (env->flags & LBF_BIG_TASK_ACTIVE_BALANCE)
goto force_balance;
- if (bail_inter_cluster_balance(env, &sds))
- goto out_balanced;
-
sds.avg_load = (SCHED_CAPACITY_SCALE * sds.total_load)
/ sds.total_capacity;
@@ -10458,7 +10391,7 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
rq->misfit_task = misfit;
if (old_misfit != misfit) {
- adjust_nr_big_tasks(&rq->hmp_stats, 1, misfit);
+ walt_adjust_nr_big_tasks(rq, 1, misfit);
curr->misfit = misfit;
}
#endif
@@ -10923,7 +10856,7 @@ const struct sched_class fair_sched_class = {
.task_change_group = task_change_group_fair,
#endif
#ifdef CONFIG_SCHED_WALT
- .fixup_hmp_sched_stats = fixup_hmp_sched_stats_fair,
+ .fixup_walt_sched_stats = fixup_walt_sched_stats_common,
#endif
};
@@ -10973,120 +10906,7 @@ __init void init_sched_fair_class(void)
}
/* WALT sched implementation begins here */
-
-#if defined(CONFIG_SCHED_WALT) && defined(CONFIG_CFS_BANDWIDTH)
-static inline struct task_group *next_task_group(struct task_group *tg)
-{
- tg = list_entry_rcu(tg->list.next, typeof(struct task_group), list);
-
- return (&tg->list == &task_groups) ? NULL : tg;
-}
-
-/* Iterate over all cfs_rq in a cpu */
-#define for_each_cfs_rq(cfs_rq, tg, cpu) \
- for (tg = container_of(&task_groups, struct task_group, list); \
- ((tg = next_task_group(tg)) && (cfs_rq = tg->cfs_rq[cpu]));)
-
-void reset_cfs_rq_hmp_stats(int cpu, int reset_cra)
-{
- struct task_group *tg;
- struct cfs_rq *cfs_rq;
-
- rcu_read_lock();
-
- for_each_cfs_rq(cfs_rq, tg, cpu)
- reset_hmp_stats(&cfs_rq->hmp_stats, reset_cra);
-
- rcu_read_unlock();
-}
-
-static inline int cfs_rq_throttled(struct cfs_rq *cfs_rq);
-
-static void inc_cfs_rq_hmp_stats(struct cfs_rq *cfs_rq,
- struct task_struct *p, int change_cra);
-static void dec_cfs_rq_hmp_stats(struct cfs_rq *cfs_rq,
- struct task_struct *p, int change_cra);
-
-/* Add task's contribution to a cpu' HMP statistics */
-void inc_hmp_sched_stats_fair(struct rq *rq,
- struct task_struct *p, int change_cra)
-{
- struct cfs_rq *cfs_rq;
- struct sched_entity *se = &p->se;
-
- /*
- * Although below check is not strictly required (as
- * inc/dec_nr_big_task and inc/dec_cumulative_runnable_avg called
- * from inc_cfs_rq_hmp_stats() have similar checks), we gain a bit on
- * efficiency by short-circuiting for_each_sched_entity() loop when
- * sched_disable_window_stats
- */
- if (sched_disable_window_stats)
- return;
-
- for_each_sched_entity(se) {
- cfs_rq = cfs_rq_of(se);
- inc_cfs_rq_hmp_stats(cfs_rq, p, change_cra);
- if (cfs_rq_throttled(cfs_rq))
- break;
- }
-
- /* Update rq->hmp_stats only if we didn't find any throttled cfs_rq */
- if (!se)
- inc_rq_hmp_stats(rq, p, change_cra);
-}
-
-static void fixup_hmp_sched_stats_fair(struct rq *rq, struct task_struct *p,
- u32 new_task_load, u32 new_pred_demand)
-{
- struct cfs_rq *cfs_rq;
- struct sched_entity *se = &p->se;
- s64 task_load_delta = (s64)new_task_load - task_load(p);
- s64 pred_demand_delta = PRED_DEMAND_DELTA;
-
- for_each_sched_entity(se) {
- cfs_rq = cfs_rq_of(se);
-
- fixup_cumulative_runnable_avg(&cfs_rq->hmp_stats, p,
- task_load_delta,
- pred_demand_delta);
- if (cfs_rq_throttled(cfs_rq))
- break;
- }
-
- /* Fix up rq->hmp_stats only if we didn't find any throttled cfs_rq */
- if (!se) {
- fixup_cumulative_runnable_avg(&rq->hmp_stats, p,
- task_load_delta,
- pred_demand_delta);
- }
-}
-
-#elif defined(CONFIG_SCHED_WALT)
-
-inline void reset_cfs_rq_hmp_stats(int cpu, int reset_cra) { }
-
-static void
-fixup_hmp_sched_stats_fair(struct rq *rq, struct task_struct *p,
- u32 new_task_load, u32 new_pred_demand)
-{
- s64 task_load_delta = (s64)new_task_load - task_load(p);
- s64 pred_demand_delta = PRED_DEMAND_DELTA;
-
- fixup_cumulative_runnable_avg(&rq->hmp_stats, p, task_load_delta,
- pred_demand_delta);
-}
-
-static inline int task_will_be_throttled(struct task_struct *p)
-{
- return 0;
-}
-
-void inc_hmp_sched_stats_fair(struct rq *rq,
- struct task_struct *p, int change_cra)
-{
- inc_nr_big_task(&rq->hmp_stats, p);
-}
+#ifdef CONFIG_SCHED_WALT
static inline int
kick_active_balance(struct rq *rq, struct task_struct *p, int new_cpu)
@@ -11108,17 +10928,6 @@ kick_active_balance(struct rq *rq, struct task_struct *p, int new_cpu)
return rc;
}
-#else
-
-static inline int task_will_be_throttled(struct task_struct *p)
-{
- return 0;
-}
-
-#endif
-
-#if defined(CONFIG_SCHED_WALT)
-
static DEFINE_RAW_SPINLOCK(migration_lock);
void check_for_migration(struct rq *rq, struct task_struct *p)
{
diff --git a/kernel/sched/idle_task.c b/kernel/sched/idle_task.c
index b852cbe..5405d3f 100644
--- a/kernel/sched/idle_task.c
+++ b/kernel/sched/idle_task.c
@@ -78,14 +78,6 @@ static void update_curr_idle(struct rq *rq)
{
}
-#ifdef CONFIG_SCHED_WALT
-static void
-fixup_hmp_sched_stats_idle(struct rq *rq, struct task_struct *p,
- u32 new_task_load, u32 new_pred_demand)
-{
-}
-#endif
-
/*
* Simple, special scheduling class for the per-CPU idle tasks:
*/
@@ -114,7 +106,4 @@ const struct sched_class idle_sched_class = {
.prio_changed = prio_changed_idle,
.switched_to = switched_to_idle,
.update_curr = update_curr_idle,
-#ifdef CONFIG_SCHED_WALT
- .fixup_hmp_sched_stats = fixup_hmp_sched_stats_idle,
-#endif
};
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 2b556d0..96f5654 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -11,45 +11,6 @@
#include <linux/irq_work.h>
#include <trace/events/sched.h>
-#ifdef CONFIG_SCHED_WALT
-
-static void
-inc_hmp_sched_stats_rt(struct rq *rq, struct task_struct *p)
-{
- inc_cumulative_runnable_avg(&rq->hmp_stats, p);
-}
-
-static void
-dec_hmp_sched_stats_rt(struct rq *rq, struct task_struct *p)
-{
- dec_cumulative_runnable_avg(&rq->hmp_stats, p);
-}
-
-static void
-fixup_hmp_sched_stats_rt(struct rq *rq, struct task_struct *p,
- u32 new_task_load, u32 new_pred_demand)
-{
- s64 task_load_delta = (s64)new_task_load - task_load(p);
- s64 pred_demand_delta = PRED_DEMAND_DELTA;
-
- fixup_cumulative_runnable_avg(&rq->hmp_stats, p, task_load_delta,
- pred_demand_delta);
-}
-
-#ifdef CONFIG_SMP
-static int find_lowest_rq(struct task_struct *task);
-
-#endif /* CONFIG_SMP */
-#else /* CONFIG_SCHED_WALT */
-
-static inline void
-inc_hmp_sched_stats_rt(struct rq *rq, struct task_struct *p) { }
-
-static inline void
-dec_hmp_sched_stats_rt(struct rq *rq, struct task_struct *p) { }
-
-#endif /* CONFIG_SCHED_WALT */
-
#include "walt.h"
int sched_rr_timeslice = RR_TIMESLICE;
@@ -1421,7 +1382,7 @@ enqueue_task_rt(struct rq *rq, struct task_struct *p, int flags)
rt_se->timeout = 0;
enqueue_rt_entity(rt_se, flags);
- inc_hmp_sched_stats_rt(rq, p);
+ walt_inc_cumulative_runnable_avg(rq, p);
if (!task_current(rq, p) && tsk_nr_cpus_allowed(p) > 1)
enqueue_pushable_task(rq, p);
@@ -1433,7 +1394,7 @@ static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int flags)
update_curr_rt(rq);
dequeue_rt_entity(rt_se, flags);
- dec_hmp_sched_stats_rt(rq, p);
+ walt_dec_cumulative_runnable_avg(rq, p);
dequeue_pushable_task(rq, p);
}
@@ -2623,7 +2584,7 @@ const struct sched_class rt_sched_class = {
.update_curr = update_curr_rt,
#ifdef CONFIG_SCHED_WALT
- .fixup_hmp_sched_stats = fixup_hmp_sched_stats_rt,
+ .fixup_walt_sched_stats = fixup_walt_sched_stats_common,
#endif
};
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 07d7731..95e7fd9 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -28,7 +28,7 @@ struct cpuidle_state;
#ifdef CONFIG_SCHED_WALT
extern unsigned int sched_ravg_window;
-struct hmp_sched_stats {
+struct walt_sched_stats {
int nr_big_tasks;
u64 cumulative_runnable_avg;
u64 pred_demands_sum;
@@ -503,15 +503,7 @@ struct cfs_rq {
struct list_head leaf_cfs_rq_list;
struct task_group *tg; /* group that "owns" this runqueue */
-#ifdef CONFIG_SCHED_WALT
- u64 cumulative_runnable_avg;
-#endif
-
#ifdef CONFIG_CFS_BANDWIDTH
-#ifdef CONFIG_SCHED_WALT
- struct hmp_sched_stats hmp_stats;
-#endif
-
int runtime_enabled;
u64 runtime_expires;
s64 runtime_remaining;
@@ -768,13 +760,13 @@ struct rq {
#ifdef CONFIG_SCHED_WALT
struct sched_cluster *cluster;
struct cpumask freq_domain_cpumask;
- struct hmp_sched_stats hmp_stats;
+ struct walt_sched_stats walt_stats;
int cstate, wakeup_latency, wakeup_energy;
u64 window_start;
s64 cum_window_start;
u64 load_reported_window;
- unsigned long hmp_flags;
+ unsigned long walt_flags;
u64 cur_irqload;
u64 avg_irqload;
@@ -1424,7 +1416,7 @@ struct sched_class {
void (*task_change_group) (struct task_struct *p, int type);
#endif
#ifdef CONFIG_SCHED_WALT
- void (*fixup_hmp_sched_stats)(struct rq *rq, struct task_struct *p,
+ void (*fixup_walt_sched_stats)(struct rq *rq, struct task_struct *p,
u32 new_task_load, u32 new_pred_demand);
#endif
};
@@ -1752,7 +1744,7 @@ static inline unsigned long __cpu_util(int cpu, int delta)
#ifdef CONFIG_SCHED_WALT
if (!walt_disabled && sysctl_sched_use_walt_cpu_util) {
- util = cpu_rq(cpu)->hmp_stats.cumulative_runnable_avg;
+ util = cpu_rq(cpu)->walt_stats.cumulative_runnable_avg;
util = div64_u64(util,
sched_ravg_window >> SCHED_CAPACITY_SHIFT);
}
@@ -2206,14 +2198,12 @@ static inline u64 irq_time_read(int cpu)
#ifdef CONFIG_SCHED_WALT
u64 sched_ktime_clock(void);
void note_task_waking(struct task_struct *p, u64 wallclock);
-extern void update_avg_burst(struct task_struct *p);
#else /* CONFIG_SCHED_WALT */
static inline u64 sched_ktime_clock(void)
{
return 0;
}
static inline void note_task_waking(struct task_struct *p, u64 wallclock) { }
-static inline void update_avg_burst(struct task_struct *p) { }
#endif /* CONFIG_SCHED_WALT */
#ifdef CONFIG_CPU_FREQ
@@ -2348,13 +2338,11 @@ extern unsigned int __read_mostly sysctl_sched_spill_nr_run;
extern unsigned int __read_mostly sched_load_granule;
extern int register_cpu_cycle_counter_cb(struct cpu_cycle_counter_cb *cb);
-extern void reset_cpu_hmp_stats(int cpu, int reset_cra);
extern int update_preferred_cluster(struct related_thread_group *grp,
struct task_struct *p, u32 old_load);
extern void set_preferred_cluster(struct related_thread_group *grp);
extern void add_new_task_to_grp(struct task_struct *new);
extern unsigned int update_freq_aggregate_threshold(unsigned int threshold);
-extern void update_avg(u64 *avg, u64 sample);
#define NO_BOOST 0
#define FULL_THROTTLE_BOOST 1
@@ -2536,6 +2524,11 @@ static inline unsigned int task_load(struct task_struct *p)
return p->ravg.demand;
}
+static inline unsigned int task_pl(struct task_struct *p)
+{
+ return p->ravg.pred_demand;
+}
+
#define pct_to_real(tunable) \
(div64_u64((u64)tunable * (u64)max_task_load(), 100))
@@ -2569,54 +2562,11 @@ static inline int same_freq_domain(int src_cpu, int dst_cpu)
#define BOOST_KICK 0
#define CPU_RESERVED 1
-static inline u64 cpu_cravg_sync(int cpu, int sync)
-{
- struct rq *rq = cpu_rq(cpu);
- u64 load;
-
- load = rq->hmp_stats.cumulative_runnable_avg;
-
- /*
- * If load is being checked in a sync wakeup environment,
- * we may want to discount the load of the currently running
- * task.
- */
- if (sync && cpu == smp_processor_id()) {
- if (load > rq->curr->ravg.demand)
- load -= rq->curr->ravg.demand;
- else
- load = 0;
- }
-
- return load;
-}
-
-extern int power_delta_exceeded(unsigned int cpu_cost, unsigned int base_cost);
-extern void reset_all_window_stats(u64 window_start, unsigned int window_size);
extern int sched_boost(void);
-extern int task_load_will_fit(struct task_struct *p, u64 task_load, int cpu,
- enum sched_boost_policy boost_policy);
-extern int task_will_fit(struct task_struct *p, int cpu);
-extern u64 cpu_load(int cpu);
-extern u64 cpu_load_sync(int cpu, int sync);
extern int preferred_cluster(struct sched_cluster *cluster,
struct task_struct *p);
-extern void inc_rq_hmp_stats(struct rq *rq,
- struct task_struct *p, int change_cra);
-extern void dec_rq_hmp_stats(struct rq *rq,
- struct task_struct *p, int change_cra);
-extern void reset_hmp_stats(struct hmp_sched_stats *stats, int reset_cra);
-extern int upmigrate_discouraged(struct task_struct *p);
extern struct sched_cluster *rq_cluster(struct rq *rq);
-extern int nr_big_tasks(struct rq *rq);
extern void reset_task_stats(struct task_struct *p);
-extern void reset_cfs_rq_hmp_stats(int cpu, int reset_cra);
-extern void inc_hmp_sched_stats_fair(struct rq *rq,
- struct task_struct *p, int change_cra);
-extern u64 cpu_upmigrate_discourage_read_u64(struct cgroup_subsys_state *css,
- struct cftype *cft);
-extern int cpu_upmigrate_discourage_write_u64(struct cgroup_subsys_state *css,
- struct cftype *cft, u64 upmigrate_discourage);
extern void clear_top_tasks_bitmap(unsigned long *bitmap);
#if defined(CONFIG_SCHED_TUNE) && defined(CONFIG_CGROUP_SCHEDTUNE)
@@ -2652,21 +2602,21 @@ static inline int is_reserved(int cpu)
{
struct rq *rq = cpu_rq(cpu);
- return test_bit(CPU_RESERVED, &rq->hmp_flags);
+ return test_bit(CPU_RESERVED, &rq->walt_flags);
}
static inline int mark_reserved(int cpu)
{
struct rq *rq = cpu_rq(cpu);
- return test_and_set_bit(CPU_RESERVED, &rq->hmp_flags);
+ return test_and_set_bit(CPU_RESERVED, &rq->walt_flags);
}
static inline void clear_reserved(int cpu)
{
struct rq *rq = cpu_rq(cpu);
- clear_bit(CPU_RESERVED, &rq->hmp_flags);
+ clear_bit(CPU_RESERVED, &rq->walt_flags);
}
static inline bool
@@ -2698,7 +2648,7 @@ extern void update_cpu_cluster_capacity(const cpumask_t *cpus);
extern unsigned long thermal_cap(int cpu);
-extern void clear_hmp_request(int cpu);
+extern void clear_walt_request(int cpu);
extern int got_boost_kick(void);
extern void clear_boost_kick(int cpu);
@@ -2714,7 +2664,7 @@ static inline unsigned int power_cost(int cpu, u64 demand)
#else /* CONFIG_SCHED_WALT */
-struct hmp_sched_stats;
+struct walt_sched_stats;
struct related_thread_group;
struct sched_cluster;
@@ -2725,44 +2675,13 @@ static inline bool task_sched_boost(struct task_struct *p)
static inline void check_for_migration(struct rq *rq, struct task_struct *p) { }
-static inline int task_will_fit(struct task_struct *p, int cpu)
-{
- return 1;
-}
-
static inline int sched_boost(void)
{
return 0;
}
-static inline int is_big_task(struct task_struct *p)
-{
- return 0;
-}
-
-static inline int nr_big_tasks(struct rq *rq)
-{
- return 0;
-}
-
-static inline int is_cpu_throttling_imminent(int cpu)
-{
- return 0;
-}
-
-static inline int is_task_migration_throttled(struct task_struct *p)
-{
- return 0;
-}
-
static inline bool is_max_capacity_cpu(int cpu) { return true; }
-static inline void
-inc_rq_hmp_stats(struct rq *rq, struct task_struct *p, int change_cra) { }
-
-static inline void
-dec_rq_hmp_stats(struct rq *rq, struct task_struct *p, int change_cra) { }
-
static inline int
preferred_cluster(struct sched_cluster *cluster, struct task_struct *p)
{
@@ -2798,6 +2717,7 @@ struct related_thread_group *task_related_thread_group(struct task_struct *p)
}
static inline u32 task_load(struct task_struct *p) { return 0; }
+static inline u32 task_pl(struct task_struct *p) { return 0; }
static inline int update_preferred_cluster(struct related_thread_group *grp,
struct task_struct *p, u32 old_load)
@@ -2843,7 +2763,7 @@ static inline unsigned long thermal_cap(int cpu)
}
#endif
-static inline void clear_hmp_request(int cpu) { }
+static inline void clear_walt_request(int cpu) { }
static inline int got_boost_kick(void)
{
diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
index dcc4a36..11a1888 100644
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -18,41 +18,6 @@ select_task_rq_stop(struct task_struct *p, int cpu, int sd_flag, int flags)
}
#endif /* CONFIG_SMP */
-#ifdef CONFIG_SCHED_WALT
-
-static void
-inc_hmp_sched_stats_stop(struct rq *rq, struct task_struct *p)
-{
- inc_cumulative_runnable_avg(&rq->hmp_stats, p);
-}
-
-static void
-dec_hmp_sched_stats_stop(struct rq *rq, struct task_struct *p)
-{
- dec_cumulative_runnable_avg(&rq->hmp_stats, p);
-}
-
-static void
-fixup_hmp_sched_stats_stop(struct rq *rq, struct task_struct *p,
- u32 new_task_load, u32 new_pred_demand)
-{
- s64 task_load_delta = (s64)new_task_load - task_load(p);
- s64 pred_demand_delta = PRED_DEMAND_DELTA;
-
- fixup_cumulative_runnable_avg(&rq->hmp_stats, p, task_load_delta,
- pred_demand_delta);
-}
-
-#else /* CONFIG_SCHED_WALT */
-
-static inline void
-inc_hmp_sched_stats_stop(struct rq *rq, struct task_struct *p) { }
-
-static inline void
-dec_hmp_sched_stats_stop(struct rq *rq, struct task_struct *p) { }
-
-#endif /* CONFIG_SCHED_WALT */
-
static void
check_preempt_curr_stop(struct rq *rq, struct task_struct *p, int flags)
{
@@ -78,14 +43,14 @@ static void
enqueue_task_stop(struct rq *rq, struct task_struct *p, int flags)
{
add_nr_running(rq, 1);
- inc_hmp_sched_stats_stop(rq, p);
+ walt_inc_cumulative_runnable_avg(rq, p);
}
static void
dequeue_task_stop(struct rq *rq, struct task_struct *p, int flags)
{
sub_nr_running(rq, 1);
- dec_hmp_sched_stats_stop(rq, p);
+ walt_dec_cumulative_runnable_avg(rq, p);
}
static void yield_task_stop(struct rq *rq)
@@ -173,6 +138,6 @@ const struct sched_class stop_sched_class = {
.switched_to = switched_to_stop,
.update_curr = update_curr_stop,
#ifdef CONFIG_SCHED_WALT
- .fixup_hmp_sched_stats = fixup_hmp_sched_stats_stop,
+ .fixup_walt_sched_stats = fixup_walt_sched_stats_common,
#endif
};
diff --git a/kernel/sched/walt.c b/kernel/sched/walt.c
index 6f7d34d..51ceedc 100644
--- a/kernel/sched/walt.c
+++ b/kernel/sched/walt.c
@@ -207,27 +207,26 @@ static int __init set_sched_predl(char *str)
}
early_param("sched_predl", set_sched_predl);
-void inc_rq_hmp_stats(struct rq *rq, struct task_struct *p, int change_cra)
+void inc_rq_walt_stats(struct rq *rq, struct task_struct *p)
{
- inc_nr_big_task(&rq->hmp_stats, p);
- if (change_cra)
- inc_cumulative_runnable_avg(&rq->hmp_stats, p);
+ inc_nr_big_task(&rq->walt_stats, p);
+ walt_inc_cumulative_runnable_avg(rq, p);
}
-void dec_rq_hmp_stats(struct rq *rq, struct task_struct *p, int change_cra)
+void dec_rq_walt_stats(struct rq *rq, struct task_struct *p)
{
- dec_nr_big_task(&rq->hmp_stats, p);
- if (change_cra)
- dec_cumulative_runnable_avg(&rq->hmp_stats, p);
+ dec_nr_big_task(&rq->walt_stats, p);
+ walt_dec_cumulative_runnable_avg(rq, p);
}
-void reset_hmp_stats(struct hmp_sched_stats *stats, int reset_cra)
+void fixup_walt_sched_stats_common(struct rq *rq, struct task_struct *p,
+ u32 new_task_load, u32 new_pred_demand)
{
- stats->nr_big_tasks = 0; /* never happens on EAS */
- if (reset_cra) {
- stats->cumulative_runnable_avg = 0;
- stats->pred_demands_sum = 0;
- }
+ s64 task_load_delta = (s64)new_task_load - task_load(p);
+ s64 pred_demand_delta = PRED_DEMAND_DELTA;
+
+ fixup_cumulative_runnable_avg(&rq->walt_stats, task_load_delta,
+ pred_demand_delta);
}
/*
@@ -295,7 +294,7 @@ update_window_start(struct rq *rq, u64 wallclock, int event)
nr_windows = div64_u64(delta, sched_ravg_window);
rq->window_start += (u64)nr_windows * (u64)sched_ravg_window;
- rq->cum_window_demand = rq->hmp_stats.cumulative_runnable_avg;
+ rq->cum_window_demand = rq->walt_stats.cumulative_runnable_avg;
if (event == PUT_PREV_TASK)
rq->cum_window_demand += rq->curr->ravg.demand;
@@ -379,12 +378,12 @@ unsigned int nr_eligible_big_tasks(int cpu)
struct rq *rq = cpu_rq(cpu);
if (!is_max_capacity_cpu(cpu))
- return rq->hmp_stats.nr_big_tasks;
+ return rq->walt_stats.nr_big_tasks;
return rq->nr_running;
}
-void clear_hmp_request(int cpu)
+void clear_walt_request(int cpu)
{
struct rq *rq = cpu_rq(cpu);
unsigned long flags;
@@ -622,20 +621,6 @@ void update_cluster_load_subtractions(struct task_struct *p,
raw_spin_unlock(&cluster->load_lock);
}
-static inline void
-init_new_task_load_hmp(struct task_struct *p, bool idle_task)
-{
-}
-
-static inline void
-update_task_burst(struct task_struct *p, struct rq *rq, int event, int runtime)
-{
-}
-
-static void reset_task_stats_hmp(struct task_struct *p)
-{
-}
-
static inline void inter_cluster_migration_fixup
(struct task_struct *p, int new_cpu, int task_cpu, bool new_task)
{
@@ -1071,7 +1056,7 @@ void update_task_pred_demand(struct rq *rq, struct task_struct *p, int event)
if (task_on_rq_queued(p) && (!task_has_dl_policy(p) ||
!p->dl.dl_throttled))
- p->sched_class->fixup_hmp_sched_stats(rq, p,
+ p->sched_class->fixup_walt_sched_stats(rq, p,
p->ravg.demand,
new);
@@ -1666,12 +1651,12 @@ static void update_history(struct rq *rq, struct task_struct *p,
/*
* A throttled deadline sched class task gets dequeued without
- * changing p->on_rq. Since the dequeue decrements hmp stats
+ * changing p->on_rq. Since the dequeue decrements walt stats
* avoid decrementing it here again.
*/
if (task_on_rq_queued(p) && (!task_has_dl_policy(p) ||
!p->dl.dl_throttled))
- p->sched_class->fixup_hmp_sched_stats(rq, p, demand,
+ p->sched_class->fixup_walt_sched_stats(rq, p, demand,
pred_demand);
p->ravg.demand = demand;
@@ -1879,7 +1864,7 @@ static inline void run_walt_irq_work(u64 old_window_start, struct rq *rq)
void update_task_ravg(struct task_struct *p, struct rq *rq, int event,
u64 wallclock, u64 irqtime)
{
- u64 runtime, old_window_start;
+ u64 old_window_start;
if (!rq->window_start || sched_disable_window_stats ||
p->ravg.mark_start == wallclock)
@@ -1895,9 +1880,7 @@ void update_task_ravg(struct task_struct *p, struct rq *rq, int event,
}
update_task_rq_cpu_cycles(p, rq, event, wallclock, irqtime);
- runtime = update_task_demand(p, rq, event, wallclock);
- if (runtime)
- update_task_burst(p, rq, event, runtime);
+ update_task_demand(p, rq, event, wallclock);
update_cpu_busy_time(p, rq, event, wallclock, irqtime);
update_task_pred_demand(rq, p, event);
done:
@@ -1938,8 +1921,6 @@ void init_new_task_load(struct task_struct *p, bool idle_task)
memset(&p->ravg, 0, sizeof(struct ravg));
p->cpu_cycles = 0;
- init_new_task_load_hmp(p, idle_task);
-
p->ravg.curr_window_cpu = kcalloc(nr_cpu_ids, sizeof(u32), GFP_KERNEL);
p->ravg.prev_window_cpu = kcalloc(nr_cpu_ids, sizeof(u32), GFP_KERNEL);
@@ -1995,8 +1976,6 @@ void reset_task_stats(struct task_struct *p)
p->ravg.curr_window_cpu = curr_window_ptr;
p->ravg.prev_window_cpu = prev_window_ptr;
- reset_task_stats_hmp(p);
-
/* Retain EXITING_TASK marker */
p->ravg.sum_history[0] = sum;
}
@@ -3069,11 +3048,11 @@ void walt_sched_init(struct rq *rq)
cpumask_set_cpu(cpu_of(rq), &rq->freq_domain_cpumask);
init_irq_work(&walt_migration_irq_work, walt_irq_work);
init_irq_work(&walt_cpufreq_irq_work, walt_irq_work);
- rq->hmp_stats.cumulative_runnable_avg = 0;
+ rq->walt_stats.cumulative_runnable_avg = 0;
rq->window_start = 0;
rq->cum_window_start = 0;
- rq->hmp_stats.nr_big_tasks = 0;
- rq->hmp_flags = 0;
+ rq->walt_stats.nr_big_tasks = 0;
+ rq->walt_flags = 0;
rq->cur_irqload = 0;
rq->avg_irqload = 0;
rq->irqload_ts = 0;
@@ -3096,7 +3075,7 @@ void walt_sched_init(struct rq *rq)
rq->old_busy_time = 0;
rq->old_estimated_time = 0;
rq->old_busy_time_group = 0;
- rq->hmp_stats.pred_demands_sum = 0;
+ rq->walt_stats.pred_demands_sum = 0;
rq->ed_task = NULL;
rq->curr_table = 0;
rq->prev_top = 0;
diff --git a/kernel/sched/walt.h b/kernel/sched/walt.h
index 3f4739e..f390a043 100644
--- a/kernel/sched/walt.h
+++ b/kernel/sched/walt.h
@@ -66,7 +66,7 @@ extern void update_task_ravg(struct task_struct *p, struct rq *rq, int event,
extern unsigned int nr_eligible_big_tasks(int cpu);
static inline void
-inc_nr_big_task(struct hmp_sched_stats *stats, struct task_struct *p)
+inc_nr_big_task(struct walt_sched_stats *stats, struct task_struct *p)
{
if (sched_disable_window_stats)
return;
@@ -76,7 +76,7 @@ inc_nr_big_task(struct hmp_sched_stats *stats, struct task_struct *p)
}
static inline void
-dec_nr_big_task(struct hmp_sched_stats *stats, struct task_struct *p)
+dec_nr_big_task(struct walt_sched_stats *stats, struct task_struct *p)
{
if (sched_disable_window_stats)
return;
@@ -88,57 +88,20 @@ dec_nr_big_task(struct hmp_sched_stats *stats, struct task_struct *p)
}
static inline void
-adjust_nr_big_tasks(struct hmp_sched_stats *stats, int delta, bool inc)
+walt_adjust_nr_big_tasks(struct rq *rq, int delta, bool inc)
{
- struct rq *rq = container_of(stats, struct rq, hmp_stats);
-
if (sched_disable_window_stats)
return;
sched_update_nr_prod(cpu_of(rq), 0, true);
- stats->nr_big_tasks += inc ? delta : -delta;
+ rq->walt_stats.nr_big_tasks += inc ? delta : -delta;
- BUG_ON(stats->nr_big_tasks < 0);
+ BUG_ON(rq->walt_stats.nr_big_tasks < 0);
}
static inline void
-inc_cumulative_runnable_avg(struct hmp_sched_stats *stats,
- struct task_struct *p)
-{
- u32 task_load;
-
- if (sched_disable_window_stats)
- return;
-
- task_load = sched_disable_window_stats ? 0 : p->ravg.demand;
-
- stats->cumulative_runnable_avg += task_load;
- stats->pred_demands_sum += p->ravg.pred_demand;
-}
-
-static inline void
-dec_cumulative_runnable_avg(struct hmp_sched_stats *stats,
- struct task_struct *p)
-{
- u32 task_load;
-
- if (sched_disable_window_stats)
- return;
-
- task_load = sched_disable_window_stats ? 0 : p->ravg.demand;
-
- stats->cumulative_runnable_avg -= task_load;
-
- BUG_ON((s64)stats->cumulative_runnable_avg < 0);
-
- stats->pred_demands_sum -= p->ravg.pred_demand;
- BUG_ON((s64)stats->pred_demands_sum < 0);
-}
-
-static inline void
-fixup_cumulative_runnable_avg(struct hmp_sched_stats *stats,
- struct task_struct *p, s64 task_load_delta,
- s64 pred_demand_delta)
+fixup_cumulative_runnable_avg(struct walt_sched_stats *stats,
+ s64 task_load_delta, s64 pred_demand_delta)
{
if (sched_disable_window_stats)
return;
@@ -150,11 +113,31 @@ fixup_cumulative_runnable_avg(struct hmp_sched_stats *stats,
BUG_ON((s64)stats->pred_demands_sum < 0);
}
-extern void inc_rq_hmp_stats(struct rq *rq,
- struct task_struct *p, int change_cra);
-extern void dec_rq_hmp_stats(struct rq *rq,
- struct task_struct *p, int change_cra);
-extern void reset_hmp_stats(struct hmp_sched_stats *stats, int reset_cra);
+static inline void
+walt_inc_cumulative_runnable_avg(struct rq *rq, struct task_struct *p)
+{
+ if (sched_disable_window_stats)
+ return;
+
+ fixup_cumulative_runnable_avg(&rq->walt_stats, p->ravg.demand,
+ p->ravg.pred_demand);
+}
+
+static inline void
+walt_dec_cumulative_runnable_avg(struct rq *rq, struct task_struct *p)
+{
+ if (sched_disable_window_stats)
+ return;
+
+ fixup_cumulative_runnable_avg(&rq->walt_stats, -(s64)p->ravg.demand,
+ -(s64)p->ravg.pred_demand);
+}
+
+extern void fixup_walt_sched_stats_common(struct rq *rq, struct task_struct *p,
+ u32 new_task_load,
+ u32 new_pred_demand);
+extern void inc_rq_walt_stats(struct rq *rq, struct task_struct *p);
+extern void dec_rq_walt_stats(struct rq *rq, struct task_struct *p);
extern void fixup_busy_time(struct task_struct *p, int new_cpu);
extern void init_new_task_load(struct task_struct *p, bool idle_task);
extern void mark_task_starting(struct task_struct *p);
@@ -297,8 +280,8 @@ static inline void walt_sched_init(struct rq *rq) { }
static inline void update_task_ravg(struct task_struct *p, struct rq *rq,
int event, u64 wallclock, u64 irqtime) { }
-static inline void inc_cumulative_runnable_avg(struct hmp_sched_stats *stats,
- struct task_struct *p)
+static inline void walt_inc_cumulative_runnable_avg(struct rq *rq,
+ struct task_struct *p)
{
}
@@ -307,21 +290,21 @@ static inline unsigned int nr_eligible_big_tasks(int cpu)
return 0;
}
-static inline void adjust_nr_big_tasks(struct hmp_sched_stats *stats,
+static inline void walt_adjust_nr_big_tasks(struct rq *rq,
int delta, bool inc)
{
}
-static inline void inc_nr_big_task(struct hmp_sched_stats *stats,
+static inline void inc_nr_big_task(struct walt_sched_stats *stats,
struct task_struct *p)
{
}
-static inline void dec_nr_big_task(struct hmp_sched_stats *stats,
+static inline void dec_nr_big_task(struct walt_sched_stats *stats,
struct task_struct *p)
{
}
-static inline void dec_cumulative_runnable_avg(struct hmp_sched_stats *stats,
+static inline void walt_dec_cumulative_runnable_avg(struct rq *rq,
struct task_struct *p)
{
}
@@ -349,6 +332,18 @@ static inline void sched_account_irqtime(int cpu, struct task_struct *curr,
static inline int same_cluster(int src_cpu, int dst_cpu) { return 1; }
+static inline void
+inc_rq_walt_stats(struct rq *rq, struct task_struct *p) { }
+
+static inline void
+dec_rq_walt_stats(struct rq *rq, struct task_struct *p) { }
+
+static inline void
+fixup_walt_sched_stats_common(struct rq *rq, struct task_struct *p,
+ u32 new_task_load, u32 new_pred_demand)
+{
+}
+
#endif /* CONFIG_SCHED_WALT */
#endif
diff --git a/mm/page_owner.c b/mm/page_owner.c
index d2db436..65e24fb 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -285,7 +285,11 @@ void pagetypeinfo_showmixedcount_print(struct seq_file *m,
continue;
if (PageBuddy(page)) {
- pfn += (1UL << page_order(page)) - 1;
+ unsigned long freepage_order;
+
+ freepage_order = page_order_unsafe(page);
+ if (freepage_order < MAX_ORDER)
+ pfn += (1UL << freepage_order) - 1;
continue;
}
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 42098b4..513c37a 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1122,6 +1122,7 @@ static void frag_stop(struct seq_file *m, void *arg)
/* Walk all the zones in a node and print using a callback */
static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat,
+ bool nolock,
void (*print)(struct seq_file *m, pg_data_t *, struct zone *))
{
struct zone *zone;
@@ -1132,9 +1133,11 @@ static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat,
if (!populated_zone(zone))
continue;
- spin_lock_irqsave(&zone->lock, flags);
+ if (!nolock)
+ spin_lock_irqsave(&zone->lock, flags);
print(m, pgdat, zone);
- spin_unlock_irqrestore(&zone->lock, flags);
+ if (!nolock)
+ spin_unlock_irqrestore(&zone->lock, flags);
}
}
#endif
@@ -1157,7 +1160,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
static int frag_show(struct seq_file *m, void *arg)
{
pg_data_t *pgdat = (pg_data_t *)arg;
- walk_zones_in_node(m, pgdat, frag_show_print);
+ walk_zones_in_node(m, pgdat, false, frag_show_print);
return 0;
}
@@ -1198,7 +1201,7 @@ static int pagetypeinfo_showfree(struct seq_file *m, void *arg)
seq_printf(m, "%6d ", order);
seq_putc(m, '\n');
- walk_zones_in_node(m, pgdat, pagetypeinfo_showfree_print);
+ walk_zones_in_node(m, pgdat, false, pagetypeinfo_showfree_print);
return 0;
}
@@ -1250,7 +1253,8 @@ static int pagetypeinfo_showblockcount(struct seq_file *m, void *arg)
for (mtype = 0; mtype < MIGRATE_TYPES; mtype++)
seq_printf(m, "%12s ", migratetype_names[mtype]);
seq_putc(m, '\n');
- walk_zones_in_node(m, pgdat, pagetypeinfo_showblockcount_print);
+ walk_zones_in_node(m, pgdat, false,
+ pagetypeinfo_showblockcount_print);
return 0;
}
@@ -1276,7 +1280,8 @@ static void pagetypeinfo_showmixedcount(struct seq_file *m, pg_data_t *pgdat)
seq_printf(m, "%12s ", migratetype_names[mtype]);
seq_putc(m, '\n');
- walk_zones_in_node(m, pgdat, pagetypeinfo_showmixedcount_print);
+ walk_zones_in_node(m, pgdat, true,
+ pagetypeinfo_showmixedcount_print);
#endif /* CONFIG_PAGE_OWNER */
}
@@ -1433,7 +1438,7 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
static int zoneinfo_show(struct seq_file *m, void *arg)
{
pg_data_t *pgdat = (pg_data_t *)arg;
- walk_zones_in_node(m, pgdat, zoneinfo_show_print);
+ walk_zones_in_node(m, pgdat, false, zoneinfo_show_print);
return 0;
}
@@ -1862,7 +1867,7 @@ static int unusable_show(struct seq_file *m, void *arg)
if (!node_state(pgdat->node_id, N_MEMORY))
return 0;
- walk_zones_in_node(m, pgdat, unusable_show_print);
+ walk_zones_in_node(m, pgdat, false, unusable_show_print);
return 0;
}
@@ -1914,7 +1919,7 @@ static int extfrag_show(struct seq_file *m, void *arg)
{
pg_data_t *pgdat = (pg_data_t *)arg;
- walk_zones_in_node(m, pgdat, extfrag_show_print);
+ walk_zones_in_node(m, pgdat, false, extfrag_show_print);
return 0;
}
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index f45f619..227c249 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -687,7 +687,7 @@ void neigh_destroy(struct neighbour *neigh)
NEIGH_CACHE_STAT_INC(neigh->tbl, destroys);
if (!neigh->dead) {
- pr_warn("Destroying alive neighbour %p\n", neigh);
+ pr_warn("Destroying alive neighbour %pK\n", neigh);
dump_stack();
return;
}
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 877e9d3..3da17e3 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -15,6 +15,7 @@
#include <linux/mpls.h>
#include <net/ndisc.h>
#include <linux/if_arp.h>
+#include <linux/gcd.h>
#include "core.h"
#include "rdev-ops.h"
@@ -1559,47 +1560,53 @@ bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
}
EXPORT_SYMBOL(ieee80211_chandef_to_operating_class);
+static void cfg80211_calculate_bi_data(struct wiphy *wiphy, u32 new_beacon_int,
+ u32 *beacon_int_gcd,
+ bool *beacon_int_different)
+{
+ struct wireless_dev *wdev;
+
+ *beacon_int_gcd = 0;
+ *beacon_int_different = false;
+
+ list_for_each_entry(wdev, &wiphy->wdev_list, list) {
+ if (!wdev->beacon_interval)
+ continue;
+
+ if (!*beacon_int_gcd) {
+ *beacon_int_gcd = wdev->beacon_interval;
+ continue;
+ }
+
+ if (wdev->beacon_interval == *beacon_int_gcd)
+ continue;
+
+ *beacon_int_different = true;
+ *beacon_int_gcd = gcd(*beacon_int_gcd, wdev->beacon_interval);
+ }
+
+ if (new_beacon_int && *beacon_int_gcd != new_beacon_int) {
+ if (*beacon_int_gcd)
+ *beacon_int_different = true;
+ *beacon_int_gcd = gcd(*beacon_int_gcd, new_beacon_int);
+ }
+}
+
int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
enum nl80211_iftype iftype, u32 beacon_int)
{
- struct wireless_dev *wdev;
- struct iface_combination_params params = {
- .beacon_int_gcd = beacon_int, /* GCD(n) = n */
- };
+ /*
+ * This is just a basic pre-condition check; if interface combinations
+ * are possible the driver must already be checking those with a call
+ * to cfg80211_check_combinations(), in which case we'll validate more
+ * through the cfg80211_calculate_bi_data() call and code in
+ * cfg80211_iter_combinations().
+ */
if (beacon_int < 10 || beacon_int > 10000)
return -EINVAL;
- params.iftype_num[iftype] = 1;
- list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
- if (!wdev->beacon_interval)
- continue;
-
- params.iftype_num[wdev->iftype]++;
- }
-
- list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
- u32 bi_prev = wdev->beacon_interval;
-
- if (!wdev->beacon_interval)
- continue;
-
- /* slight optimisation - skip identical BIs */
- if (wdev->beacon_interval == beacon_int)
- continue;
-
- params.beacon_int_different = true;
-
- /* Get the GCD */
- while (bi_prev != 0) {
- u32 tmp_bi = bi_prev;
-
- bi_prev = params.beacon_int_gcd % bi_prev;
- params.beacon_int_gcd = tmp_bi;
- }
- }
-
- return cfg80211_check_combinations(&rdev->wiphy, ¶ms);
+ return 0;
}
int cfg80211_iter_combinations(struct wiphy *wiphy,
@@ -1613,6 +1620,21 @@ int cfg80211_iter_combinations(struct wiphy *wiphy,
int i, j, iftype;
int num_interfaces = 0;
u32 used_iftypes = 0;
+ u32 beacon_int_gcd;
+ bool beacon_int_different;
+
+ /*
+ * This is a bit strange, since the iteration used to rely only on
+ * the data given by the driver, but here it now relies on context,
+ * in form of the currently operating interfaces.
+ * This is OK for all current users, and saves us from having to
+ * push the GCD calculations into all the drivers.
+ * In the future, this should probably rely more on data that's in
+ * cfg80211 already - the only thing not would appear to be any new
+ * interfaces (while being brought up) and channel/radar data.
+ */
+ cfg80211_calculate_bi_data(wiphy, params->new_beacon_int,
+ &beacon_int_gcd, &beacon_int_different);
if (params->radar_detect) {
rcu_read_lock();
@@ -1675,12 +1697,11 @@ int cfg80211_iter_combinations(struct wiphy *wiphy,
if ((all_iftypes & used_iftypes) != used_iftypes)
goto cont;
- if (params->beacon_int_gcd) {
+ if (beacon_int_gcd) {
if (c->beacon_int_min_gcd &&
- params->beacon_int_gcd < c->beacon_int_min_gcd)
- return -EINVAL;
- if (!c->beacon_int_min_gcd &&
- params->beacon_int_different)
+ beacon_int_gcd < c->beacon_int_min_gcd)
+ goto cont;
+ if (!c->beacon_int_min_gcd && beacon_int_different)
goto cont;
}
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
old mode 100755
new mode 100644
index f742c65..1b9e67b
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -145,6 +145,25 @@
${CC} ${aflags} -c -o ${2} ${afile}
}
+# Generates ${2} .o file with RTIC MP's from the ${1} object file (vmlinux)
+# ${3} the file name where the sizes of the RTIC MP structure are stored
+# just in case, save copy of the RTIC mp to ${4}
+# Note: RTIC_MPGEN has to be set if MPGen is available
+rtic_mp()
+{
+ # assume that RTIC_MP_O generation may fail
+ RTIC_MP_O=
+
+ ${RTIC_MPGEN} --objcopy="${OBJCOPY}" --objdump="${OBJDUMP}" \
+ --binpath='' --vmlinux=${1} --config=${KCONFIG_CONFIG} && \
+ cat rtic_mp.c | ${CC} -c -o ${2} -x c - && \
+ cp rtic_mp.c ${4} && \
+ ${NM} --print-size --size-sort ${2} > ${3} && \
+ RTIC_MP_O=${2}
+ # NM - save generated variable sizes for verification
+ # RTIC_MP_O is our retval - great success if set to generated .o file
+}
+
# Create map file with all symbols from ${1}
# See mksymap for additional details
mksysmap()
@@ -169,6 +188,8 @@
rm -f System.map
rm -f vmlinux
rm -f vmlinux.o
+ rm -f .tmp_rtic_mp_sz*
+ rm -f rtic_mp.*
}
on_exit()
@@ -231,6 +252,15 @@
# final build of init/
${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}"
+# Generate RTIC MP placeholder compile unit of the correct size
+# and add it to the list of link objects
+# this needs to be done before generating kallsyms
+if [ ! -z ${RTIC_MPGEN+x} ]; then
+ rtic_mp vmlinux.o rtic_mp.o .tmp_rtic_mp_sz1 .tmp_rtic_mp1.c
+ KBUILD_VMLINUX_MAIN+=" "
+ KBUILD_VMLINUX_MAIN+=$RTIC_MP_O
+fi
+
kallsymso=""
kallsyms_vmlinux=""
if [ -n "${CONFIG_KALLSYMS}" ]; then
@@ -276,6 +306,18 @@
fi
fi
+# Update RTIC MP object by replacing the place holder
+# with actual MP data of the same size
+# Also double check that object size did not change
+if [ ! -z ${RTIC_MPGEN+x} ]; then
+ rtic_mp "${kallsyms_vmlinux}" rtic_mp.o .tmp_rtic_mp_sz2 \
+ .tmp_rtic_mp2.c
+ if ! cmp -s .tmp_rtic_mp_sz1 .tmp_rtic_mp_sz2; then
+ echo >&2 'ERROR: RTIC MP object files size mismatch'
+ exit 1
+ fi
+fi
+
info LD vmlinux
vmlinux_link "${kallsymso}" vmlinux
diff --git a/techpack/.gitignore b/techpack/.gitignore
new file mode 100644
index 0000000..58da0b8
--- /dev/null
+++ b/techpack/.gitignore
@@ -0,0 +1,2 @@
+# ignore all subdirs except stub
+!/stub/
diff --git a/techpack/Kbuild b/techpack/Kbuild
new file mode 100644
index 0000000..3c7c8e6
--- /dev/null
+++ b/techpack/Kbuild
@@ -0,0 +1,5 @@
+techpack-dirs := $(shell find $(srctree)/$(src) -maxdepth 1 -mindepth 1 -type d -not -name ".*")
+obj-y += stub/ $(addsuffix /,$(subst $(srctree)/$(src)/,,$(techpack-dirs)))
+
+techpack-header-dirs := $(shell find $(srctree)/techpack -maxdepth 1 -mindepth 1 -type d -not -name ".*")
+header-y += $(addsuffix /include/uapi/,$(subst $(srctree)/techpack/,,$(techpack-header-dirs)))
diff --git a/techpack/stub/Makefile b/techpack/stub/Makefile
new file mode 100644
index 0000000..184b5c7
--- /dev/null
+++ b/techpack/stub/Makefile
@@ -0,0 +1,2 @@
+ccflags-y := -Wno-unused-function
+obj-y := stub.o
diff --git a/techpack/stub/include/uapi/Kbuild b/techpack/stub/include/uapi/Kbuild
new file mode 100644
index 0000000..87bfa65
--- /dev/null
+++ b/techpack/stub/include/uapi/Kbuild
@@ -0,0 +1 @@
+#Stub place holder
diff --git a/techpack/stub/stub.c b/techpack/stub/stub.c
new file mode 100644
index 0000000..6024341
--- /dev/null
+++ b/techpack/stub/stub.c
@@ -0,0 +1,3 @@
+static void _techpack_stub(void)
+{
+}