Loading drivers/Makefile +7 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,13 @@ camera-$(CONFIG_LEDS_QPNP_FLASH_V2) += \ cam_sensor_module/cam_flash/cam_flash_core.o \ cam_sensor_module/cam_flash/cam_flash_soc.o ifneq (,$(filter $(CONFIG_LEDS_QTI_FLASH),y m)) camera-y += \ cam_sensor_module/cam_flash/cam_flash_dev.o \ cam_sensor_module/cam_flash/cam_flash_core.o \ cam_sensor_module/cam_flash/cam_flash_soc.o endif camera-$(CONFIG_SPECTRA_CUSTOM) += \ cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_soc.o \ cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.o \ Loading drivers/cam_sensor_module/cam_flash/cam_flash_core.c +31 −117 Original line number Diff line number Diff line Loading @@ -11,76 +11,35 @@ #include "cam_common_util.h" #include "cam_packet_util.h" static int cam_flash_prepare(struct cam_flash_ctrl *flash_ctrl, bool regulator_enable) int cam_flash_led_prepare(struct led_trigger *trigger, int options, int *max_current, bool is_wled) { 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 (is_wled) { #ifdef CONFIG_BACKLIGHT_QCOM_SPMI_WLED rc = wled_flash_led_prepare(trigger, options, max_current); 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 return -EPERM; #endif } else { if (regulator_enable && (flash_ctrl->is_regulator_enabled == false)) { rc = qpnp_flash_led_prepare(flash_ctrl->switch_trigger, ENABLE_REGULATOR, NULL); #if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) rc = qpnp_flash_led_prepare(trigger, options, max_current); #elif IS_REACHABLE(CONFIG_LEDS_QTI_FLASH) rc = qti_flash_led_prepare(trigger, options, max_current); #endif if (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); 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; } Loading Loading @@ -180,39 +139,6 @@ static int cam_flash_construct_default_power_setting( return rc; } int cam_flash_pmic_power_ops(struct cam_flash_ctrl *fctrl, bool regulator_enable) { int rc = 0; if (!(fctrl->switch_trigger)) { CAM_ERR(CAM_FLASH, "Invalid argument"); return -EINVAL; } if (regulator_enable) { rc = cam_flash_prepare(fctrl, true); if (rc) { CAM_ERR(CAM_FLASH, "Enable Regulator Failed rc = %d", rc); return rc; } fctrl->last_flush_req = 0; } if (!regulator_enable) { if ((fctrl->flash_state == CAM_FLASH_STATE_START) && (fctrl->is_regulator_enabled == true)) { rc = cam_flash_prepare(fctrl, false); if (rc) CAM_ERR(CAM_FLASH, "Disable Regulator Failed rc: %d", rc); } } return rc; } int cam_flash_i2c_power_ops(struct cam_flash_ctrl *fctrl, bool regulator_enable) { Loading Loading @@ -1366,13 +1292,6 @@ int cam_flash_pmic_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) fctrl->nrt_info.cmn_attr.cmd_type = CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO; rc = fctrl->func_tbl.power_ops(fctrl, true); if (rc) { CAM_ERR(CAM_FLASH, "Enable Regulator Failed rc = %d", rc); return rc; } fctrl->flash_state = CAM_FLASH_STATE_CONFIG; break; Loading Loading @@ -1599,16 +1518,9 @@ int cam_flash_pmic_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) flash_query_info = (struct cam_flash_query_curr *)cmd_buf; 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); rc = cam_flash_led_prepare(fctrl->switch_trigger, QUERY_MAX_AVAIL_CURRENT, &query_curr_ma, soc_private->is_wled_flash); CAM_DBG(CAM_FLASH, "query_curr_ma = %d", query_curr_ma); Loading Loading @@ -1784,11 +1696,13 @@ void cam_flash_shutdown(struct cam_flash_ctrl *fctrl) if ((fctrl->flash_state == CAM_FLASH_STATE_CONFIG) || (fctrl->flash_state == CAM_FLASH_STATE_START)) { fctrl->func_tbl.flush_req(fctrl, FLUSH_ALL, 0); if (fctrl->func_tbl.power_ops) { rc = fctrl->func_tbl.power_ops(fctrl, false); if (rc) CAM_ERR(CAM_FLASH, "Power Down Failed rc: %d", rc); } } rc = cam_flash_release_dev(fctrl); if (rc) Loading drivers/cam_sensor_module/cam_flash/cam_flash_core.h +3 −1 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. */ #ifndef _CAM_FLASH_CORE_H_ Loading @@ -14,6 +14,8 @@ int cam_flash_establish_link(struct cam_req_mgr_core_dev_link_setup *link); 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_led_prepare(struct led_trigger *trigger, int options, int *max_current, bool is_wled); #endif /*_CAM_FLASH_CORE_H_*/ drivers/cam_sensor_module/cam_flash/cam_flash_dev.c +5 −3 Original line number Diff line number Diff line Loading @@ -120,8 +120,10 @@ static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl, CAM_WARN(CAM_FLASH, "Failed in destroying the device Handle"); if (fctrl->func_tbl.power_ops) { if (fctrl->func_tbl.power_ops(fctrl, false)) CAM_WARN(CAM_FLASH, "Power Down Failed"); } fctrl->flash_state = CAM_FLASH_STATE_INIT; break; Loading Loading @@ -461,7 +463,7 @@ static int cam_flash_component_bind(struct device *dev, /* PMIC Flash */ fctrl->func_tbl.parser = cam_flash_pmic_pkt_parser; fctrl->func_tbl.apply_setting = cam_flash_pmic_apply_setting; fctrl->func_tbl.power_ops = cam_flash_pmic_power_ops; fctrl->func_tbl.power_ops = NULL; fctrl->func_tbl.flush_req = cam_flash_pmic_flush_request; } Loading drivers/cam_sensor_module/cam_flash/cam_flash_dev.h +8 −2 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. */ #ifndef _CAM_FLASH_DEV_H_ Loading @@ -13,12 +13,18 @@ #include <linux/of.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/leds-qpnp-flash.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> #if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) #include <linux/leds-qpnp-flash.h> #elif IS_REACHABLE(CONFIG_LEDS_QTI_FLASH) #include <linux/leds-qti-flash.h> #endif #include "cam_req_mgr_util.h" #include "cam_req_mgr_interface.h" #include "cam_subdev.h" Loading Loading
drivers/Makefile +7 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,13 @@ camera-$(CONFIG_LEDS_QPNP_FLASH_V2) += \ cam_sensor_module/cam_flash/cam_flash_core.o \ cam_sensor_module/cam_flash/cam_flash_soc.o ifneq (,$(filter $(CONFIG_LEDS_QTI_FLASH),y m)) camera-y += \ cam_sensor_module/cam_flash/cam_flash_dev.o \ cam_sensor_module/cam_flash/cam_flash_core.o \ cam_sensor_module/cam_flash/cam_flash_soc.o endif camera-$(CONFIG_SPECTRA_CUSTOM) += \ cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_soc.o \ cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.o \ Loading
drivers/cam_sensor_module/cam_flash/cam_flash_core.c +31 −117 Original line number Diff line number Diff line Loading @@ -11,76 +11,35 @@ #include "cam_common_util.h" #include "cam_packet_util.h" static int cam_flash_prepare(struct cam_flash_ctrl *flash_ctrl, bool regulator_enable) int cam_flash_led_prepare(struct led_trigger *trigger, int options, int *max_current, bool is_wled) { 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 (is_wled) { #ifdef CONFIG_BACKLIGHT_QCOM_SPMI_WLED rc = wled_flash_led_prepare(trigger, options, max_current); 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 return -EPERM; #endif } else { if (regulator_enable && (flash_ctrl->is_regulator_enabled == false)) { rc = qpnp_flash_led_prepare(flash_ctrl->switch_trigger, ENABLE_REGULATOR, NULL); #if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) rc = qpnp_flash_led_prepare(trigger, options, max_current); #elif IS_REACHABLE(CONFIG_LEDS_QTI_FLASH) rc = qti_flash_led_prepare(trigger, options, max_current); #endif if (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); 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; } Loading Loading @@ -180,39 +139,6 @@ static int cam_flash_construct_default_power_setting( return rc; } int cam_flash_pmic_power_ops(struct cam_flash_ctrl *fctrl, bool regulator_enable) { int rc = 0; if (!(fctrl->switch_trigger)) { CAM_ERR(CAM_FLASH, "Invalid argument"); return -EINVAL; } if (regulator_enable) { rc = cam_flash_prepare(fctrl, true); if (rc) { CAM_ERR(CAM_FLASH, "Enable Regulator Failed rc = %d", rc); return rc; } fctrl->last_flush_req = 0; } if (!regulator_enable) { if ((fctrl->flash_state == CAM_FLASH_STATE_START) && (fctrl->is_regulator_enabled == true)) { rc = cam_flash_prepare(fctrl, false); if (rc) CAM_ERR(CAM_FLASH, "Disable Regulator Failed rc: %d", rc); } } return rc; } int cam_flash_i2c_power_ops(struct cam_flash_ctrl *fctrl, bool regulator_enable) { Loading Loading @@ -1366,13 +1292,6 @@ int cam_flash_pmic_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) fctrl->nrt_info.cmn_attr.cmd_type = CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO; rc = fctrl->func_tbl.power_ops(fctrl, true); if (rc) { CAM_ERR(CAM_FLASH, "Enable Regulator Failed rc = %d", rc); return rc; } fctrl->flash_state = CAM_FLASH_STATE_CONFIG; break; Loading Loading @@ -1599,16 +1518,9 @@ int cam_flash_pmic_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) flash_query_info = (struct cam_flash_query_curr *)cmd_buf; 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); rc = cam_flash_led_prepare(fctrl->switch_trigger, QUERY_MAX_AVAIL_CURRENT, &query_curr_ma, soc_private->is_wled_flash); CAM_DBG(CAM_FLASH, "query_curr_ma = %d", query_curr_ma); Loading Loading @@ -1784,11 +1696,13 @@ void cam_flash_shutdown(struct cam_flash_ctrl *fctrl) if ((fctrl->flash_state == CAM_FLASH_STATE_CONFIG) || (fctrl->flash_state == CAM_FLASH_STATE_START)) { fctrl->func_tbl.flush_req(fctrl, FLUSH_ALL, 0); if (fctrl->func_tbl.power_ops) { rc = fctrl->func_tbl.power_ops(fctrl, false); if (rc) CAM_ERR(CAM_FLASH, "Power Down Failed rc: %d", rc); } } rc = cam_flash_release_dev(fctrl); if (rc) Loading
drivers/cam_sensor_module/cam_flash/cam_flash_core.h +3 −1 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. */ #ifndef _CAM_FLASH_CORE_H_ Loading @@ -14,6 +14,8 @@ int cam_flash_establish_link(struct cam_req_mgr_core_dev_link_setup *link); 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_led_prepare(struct led_trigger *trigger, int options, int *max_current, bool is_wled); #endif /*_CAM_FLASH_CORE_H_*/
drivers/cam_sensor_module/cam_flash/cam_flash_dev.c +5 −3 Original line number Diff line number Diff line Loading @@ -120,8 +120,10 @@ static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl, CAM_WARN(CAM_FLASH, "Failed in destroying the device Handle"); if (fctrl->func_tbl.power_ops) { if (fctrl->func_tbl.power_ops(fctrl, false)) CAM_WARN(CAM_FLASH, "Power Down Failed"); } fctrl->flash_state = CAM_FLASH_STATE_INIT; break; Loading Loading @@ -461,7 +463,7 @@ static int cam_flash_component_bind(struct device *dev, /* PMIC Flash */ fctrl->func_tbl.parser = cam_flash_pmic_pkt_parser; fctrl->func_tbl.apply_setting = cam_flash_pmic_apply_setting; fctrl->func_tbl.power_ops = cam_flash_pmic_power_ops; fctrl->func_tbl.power_ops = NULL; fctrl->func_tbl.flush_req = cam_flash_pmic_flush_request; } Loading
drivers/cam_sensor_module/cam_flash/cam_flash_dev.h +8 −2 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. */ #ifndef _CAM_FLASH_DEV_H_ Loading @@ -13,12 +13,18 @@ #include <linux/of.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/leds-qpnp-flash.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> #if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) #include <linux/leds-qpnp-flash.h> #elif IS_REACHABLE(CONFIG_LEDS_QTI_FLASH) #include <linux/leds-qti-flash.h> #endif #include "cam_req_mgr_util.h" #include "cam_req_mgr_interface.h" #include "cam_subdev.h" Loading