Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29a187b5 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ARM: dts: msm: Add WLED support for SM8150 platforms"

parents ba79feb7 1ab6df96
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -65,6 +65,11 @@ First Level Node - CAM FLASH device
  Value type: <u32>
  Definition: Max duration in ms flash can glow.

- wled-flash-support
  Usage: optional
  Value type: <boolean>
  Definition: To identity wled flash hardware support.

- gpios
  Usage: optional
  Value type: <u32>
@@ -109,6 +114,7 @@ led_flash_rear: qcom,camera-flash@0 {
		flash-source = <&pmi8998_flash0 &pmi8998_flash1>;
		torch-source = <&pmi8998_torch0 &pmi8998_torch1>;
		switch-source = <&pmi8998_switch0>;
		wled-flash-support;
		qcom,slave-id = <0x00 0x00 0x0011>;
		qcom,cci-master = <0>;
		gpios = <&msmgpio 23 0>,
+12 −0
Original line number Diff line number Diff line
@@ -32,6 +32,17 @@
		status = "ok";
	};

	led_flash_front: qcom,camera-flash@2 {
		cell-index = <2>;
		reg = <0x02 0x00>;
		compatible = "qcom,camera-flash";
		wled-flash-support;
		flash-source = <&wled_flash>;
		torch-source = <&wled_torch>;
		switch-source = <&wled_switch>;
		status = "ok";
	};

	led_flash_iris: qcom,camera-flash@3 {
		cell-index = <3>;
		reg = <0x03 0x00>;
@@ -313,6 +324,7 @@
		sensor-position-yaw = <0>;
		eeprom-src = <&eeprom_front>;
		actuator-src = <&actuator_front>;
		led-flash-src = <&led_flash_front>;
		cam_vio-supply = <&pm8150l_l1>;
		cam_vana-supply = <&pm8009_l6>;
		cam_vdig-supply = <&pm8009_l2>;
+12 −0
Original line number Diff line number Diff line
@@ -32,6 +32,17 @@
		status = "ok";
	};

	led_flash_front: qcom,camera-flash@2 {
		cell-index = <2>;
		reg = <0x02 0x00>;
		compatible = "qcom,camera-flash";
		wled-flash-support;
		flash-source = <&wled_flash>;
		torch-source = <&wled_torch>;
		switch-source = <&wled_switch>;
		status = "ok";
	};

	led_flash_iris: qcom,camera-flash@3 {
		cell-index = <3>;
		reg = <0x03 0x00>;
@@ -313,6 +324,7 @@
		sensor-position-yaw = <0>;
		eeprom-src = <&eeprom_front>;
		actuator-src = <&actuator_front>;
		led-flash-src = <&led_flash_front>;
		cam_vio-supply = <&pm8150l_l1>;
		cam_vana-supply = <&pm8009_l6>;
		cam_vdig-supply = <&pm8009_l2>;
+83 −41
Original line number Diff line number Diff line
@@ -20,38 +20,72 @@ int cam_flash_prepare(struct cam_flash_ctrl *flash_ctrl,
	bool regulator_enable)
{
	int rc = 0;
	struct cam_flash_private_soc *soc_private =
		(struct cam_flash_private_soc *)
		flash_ctrl->soc_info.soc_private;

	if (!(flash_ctrl->switch_trigger)) {
		CAM_ERR(CAM_FLASH, "Invalid argument");
		return -EINVAL;
	}

	if (soc_private->is_wled_flash) {
		if (regulator_enable &&
			flash_ctrl->is_regulator_enabled == false) {
			rc = wled_flash_led_prepare(flash_ctrl->switch_trigger,
				ENABLE_REGULATOR, NULL);
			if (rc) {
				CAM_ERR(CAM_FLASH, "enable reg failed: rc: %d",
					rc);
				return rc;
			}

			flash_ctrl->is_regulator_enabled = true;
		} else if (!regulator_enable &&
				flash_ctrl->is_regulator_enabled == true) {
			rc = wled_flash_led_prepare(flash_ctrl->switch_trigger,
				DISABLE_REGULATOR, NULL);
			if (rc) {
				CAM_ERR(CAM_FLASH, "disalbe reg fail: rc: %d",
					rc);
				return rc;
			}

			flash_ctrl->is_regulator_enabled = false;
		} else {
			CAM_ERR(CAM_FLASH, "Wrong Wled flash state: %d",
				flash_ctrl->flash_state);
			rc = -EINVAL;
		}
	} else {
		if (regulator_enable &&
			(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);
				CAM_ERR(CAM_FLASH,
					"Regulator enable failed rc = %d", rc);
				return rc;
			}

			flash_ctrl->is_regulator_enabled = true;
		} else if ((!regulator_enable) &&
			(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);
				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;
}

@@ -144,37 +178,31 @@ static int cam_flash_ops(struct cam_flash_ctrl *flash_ctrl,
		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);
				cam_res_mgr_led_trigger_event(
					flash_ctrl->torch_trigger[i],
					curr);
					curr = max_current;
			}
			CAM_DBG(CAM_FLASH, "Led_Torch[%d]: Current: %d",
				i, curr);
			cam_res_mgr_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",
					curr = max_current;
			}
			CAM_DBG(CAM_FLASH, "LED_Flash[%d]: Current: %d",
				i, curr);
			cam_res_mgr_led_trigger_event(
					flash_ctrl->flash_trigger[i],
					curr);
			}
				flash_ctrl->flash_trigger[i], curr);
		}
	} else {
		CAM_ERR(CAM_FLASH, "Wrong Operation: %d", op);
@@ -525,11 +553,16 @@ int cam_flash_parser(struct cam_flash_ctrl *fctrl, void *arg)
	struct cam_flash_set_on_off *flash_operation_info = NULL;
	struct cam_flash_query_curr *flash_query_info = NULL;
	struct cam_flash_frame_setting *flash_data = NULL;
	struct cam_flash_private_soc *soc_private = NULL;

	if (!fctrl || !arg) {
		CAM_ERR(CAM_FLASH, "fctrl/arg is NULL");
		return -EINVAL;
	}

	soc_private = (struct cam_flash_private_soc *)
		fctrl->soc_info.soc_private;

	/* getting CSL Packet */
	ioctl_ctrl = (struct cam_control *)arg;

@@ -718,8 +751,17 @@ int cam_flash_parser(struct cam_flash_ctrl *fctrl, void *arg)
			flash_query_info =
				(struct cam_flash_query_curr *)cmd_buf;

			rc = qpnp_flash_led_prepare(fctrl->switch_trigger,
				QUERY_MAX_AVAIL_CURRENT, &query_curr_ma);
			if (soc_private->is_wled_flash)
				rc = wled_flash_led_prepare(
					fctrl->switch_trigger,
					QUERY_MAX_AVAIL_CURRENT,
					&query_curr_ma);
			else
				rc = qpnp_flash_led_prepare(
					fctrl->switch_trigger,
					QUERY_MAX_AVAIL_CURRENT,
					&query_curr_ma);

			CAM_DBG(CAM_FLASH, "query_curr_ma = %d",
				query_curr_ma);
			if (rc) {
+0 −1
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
#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"
Loading