Merge "msm: camera: flash: Add qti flash support in camera" into camera-kernel.lnx.4.0

Tento commit je obsažen v:
Camera Software Integration
2020-03-02 15:05:29 -08:00
odevzdal Gerrit - the friendly Code Review server
8 změnil soubory, kde provedl 77 přidání a 134 odebrání

Zobrazit soubor

@@ -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 \

Zobrazit soubor

@@ -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 (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;
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;
}
#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 (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;
#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;
}
}
return rc;
}
@@ -180,39 +139,6 @@ free_power_settings:
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)
{
@@ -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;
@@ -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);
@@ -1784,10 +1696,12 @@ 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);
rc = fctrl->func_tbl.power_ops(fctrl, false);
if (rc)
CAM_ERR(CAM_FLASH, "Power Down Failed rc: %d",
rc);
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);

Zobrazit soubor

@@ -1,6 +1,6 @@
/* 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_
@@ -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_*/

Zobrazit soubor

@@ -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(fctrl, false))
CAM_WARN(CAM_FLASH, "Power Down Failed");
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;
@@ -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;
}

Zobrazit soubor

@@ -1,6 +1,6 @@
/* 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_
@@ -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"

Zobrazit soubor

@@ -1,6 +1,6 @@
// 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.
*/
#include <linux/of.h>
@@ -78,10 +78,11 @@ static int32_t cam_get_source_node_info(
&fctrl->flash_trigger[i]);
if (soc_private->is_wled_flash) {
rc = wled_flash_led_prepare(
rc = cam_flash_led_prepare(
fctrl->flash_trigger[i],
QUERY_MAX_CURRENT,
&soc_private->flash_max_current[i]);
QUERY_MAX_AVAIL_CURRENT,
&soc_private->flash_max_current[i],
true);
if (rc) {
CAM_ERR(CAM_FLASH,
"WLED FLASH max_current read fail: %d",
@@ -94,6 +95,9 @@ static int32_t cam_get_source_node_info(
rc = of_property_read_u32(flash_src_node,
"qcom,max-current",
&soc_private->flash_max_current[i]);
rc &= of_property_read_u32(flash_src_node,
"qcom,max-current-ma",
&soc_private->flash_max_current[i]);
if (rc < 0) {
CAM_WARN(CAM_FLASH,
"LED FLASH max-current read fail: %d",
@@ -165,10 +169,11 @@ static int32_t cam_get_source_node_info(
&fctrl->torch_trigger[i]);
if (soc_private->is_wled_flash) {
rc = wled_flash_led_prepare(
rc = cam_flash_led_prepare(
fctrl->torch_trigger[i],
QUERY_MAX_CURRENT,
&soc_private->torch_max_current[i]);
QUERY_MAX_AVAIL_CURRENT,
&soc_private->torch_max_current[i],
true);
if (rc) {
CAM_ERR(CAM_FLASH,
"WLED TORCH max_current read fail: %d",
@@ -180,6 +185,9 @@ static int32_t cam_get_source_node_info(
rc = of_property_read_u32(torch_src_node,
"qcom,max-current",
&soc_private->torch_max_current[i]);
rc &= of_property_read_u32(torch_src_node,
"qcom,max-current-ma",
&soc_private->torch_max_current[i]);
if (rc < 0) {
CAM_WARN(CAM_FLASH,
"LED-TORCH max-current read failed: %d",

Zobrazit soubor

@@ -23,7 +23,8 @@
#include "cam_eeprom_dev.h"
#include "cam_ois_dev.h"
#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2)
#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) || \
IS_REACHABLE(CONFIG_LEDS_QTI_FLASH)
#include "cam_flash_dev.h"
#endif
@@ -102,7 +103,8 @@ static const struct camera_submodule_component camera_sensor[] = {
{&cam_sensor_driver_init, &cam_sensor_driver_exit},
{&cam_eeprom_driver_init, &cam_eeprom_driver_exit},
{&cam_ois_driver_init, &cam_ois_driver_exit},
#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2)
#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) || \
IS_REACHABLE(CONFIG_LEDS_QTI_FLASH)
{&cam_flash_init_module, &cam_flash_exit_module},
#endif
#endif
@@ -238,7 +240,8 @@ static struct platform_driver *const cam_component_drivers[] = {
&cam_sensor_platform_driver,
&cam_eeprom_platform_driver,
&cam_ois_platform_driver,
#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2)
#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) || \
IS_REACHABLE(CONFIG_LEDS_QTI_FLASH)
&cam_flash_platform_driver,
#endif
#endif

Zobrazit soubor

@@ -34,7 +34,8 @@ extern struct platform_driver cam_actuator_platform_driver;
extern struct platform_driver cam_sensor_platform_driver;
extern struct platform_driver cam_eeprom_platform_driver;
extern struct platform_driver cam_ois_platform_driver;
#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2)
#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) || \
IS_REACHABLE(CONFIG_LEDS_QTI_FLASH)
extern struct platform_driver cam_flash_platform_driver;
#endif
#endif