msm: camera: common: Enabling EOF support for flash
New usecase for flash driver requires to be trigger at EOF. This change adds the new operation code support in flash driver along with EOF enable support in crm and across other drivers. Also to improve the performance, this change adds the logic to dynamically update the subscribe event to CRM, so that CRM can enqueue EOF events when Flash or any other device add the request for EOF. CRs-Fixed: 2633194 Change-Id: I2f68ac7fc6a4699debd39b64319728cdf17bbcfa Signed-off-by: Jigarkumar Zala <jzala@codeaurora.org>
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

szülő
d5c5960288
commit
438fc6a877
@@ -370,6 +370,7 @@ static void cam_actuator_update_req_mgr(
|
||||
add_req.req_id = csl_packet->header.request_id;
|
||||
add_req.dev_hdl = a_ctrl->bridge_intf.device_hdl;
|
||||
add_req.skip_before_applying = 0;
|
||||
add_req.trigger_eof = false;
|
||||
|
||||
if (a_ctrl->bridge_intf.crm_cb &&
|
||||
a_ctrl->bridge_intf.crm_cb->add_req) {
|
||||
|
@@ -11,6 +11,9 @@
|
||||
#include "cam_common_util.h"
|
||||
#include "cam_packet_util.h"
|
||||
|
||||
static uint default_on_timer = 2;
|
||||
module_param(default_on_timer, uint, 0644);
|
||||
|
||||
int cam_flash_led_prepare(struct led_trigger *trigger, int options,
|
||||
int *max_current, bool is_wled)
|
||||
{
|
||||
@@ -396,7 +399,8 @@ static int cam_flash_ops(struct cam_flash_ctrl *flash_ctrl,
|
||||
cam_res_mgr_led_trigger_event(
|
||||
flash_ctrl->torch_trigger[i], curr);
|
||||
}
|
||||
} else if (op == CAMERA_SENSOR_FLASH_OP_FIREHIGH) {
|
||||
} else if ((op == CAMERA_SENSOR_FLASH_OP_FIREHIGH) ||
|
||||
(op == CAMERA_SENSOR_FLASH_OP_FIREDURATION)) {
|
||||
for (i = 0; i < flash_ctrl->flash_num_sources; i++) {
|
||||
if (flash_ctrl->flash_trigger[i]) {
|
||||
max_current = soc_private->flash_max_current[i];
|
||||
@@ -416,10 +420,39 @@ static int cam_flash_ops(struct cam_flash_ctrl *flash_ctrl,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (flash_ctrl->switch_trigger)
|
||||
if (flash_ctrl->switch_trigger) {
|
||||
#if IS_ENABLED(CONFIG_LEDS_QTI_FLASH)
|
||||
int rc = 0;
|
||||
|
||||
if (op == CAMERA_SENSOR_FLASH_OP_FIREDURATION) {
|
||||
struct flash_led_param param;
|
||||
|
||||
param.off_time_ms =
|
||||
flash_data->flash_active_time_ms;
|
||||
/* This is to dynamically change the turn on time */
|
||||
param.on_time_ms = default_on_timer;
|
||||
CAM_DBG(CAM_FLASH,
|
||||
"Precise flash_on time: %u, Precise flash_off time: %u",
|
||||
param.on_time_ms, param.off_time_ms);
|
||||
rc = qti_flash_led_set_param(
|
||||
flash_ctrl->switch_trigger,
|
||||
param);
|
||||
if (rc) {
|
||||
CAM_ERR(CAM_FLASH,
|
||||
"LED set param fail rc= %d", rc);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (op == CAMERA_SENSOR_FLASH_OP_FIREDURATION) {
|
||||
CAM_ERR(CAM_FLASH, "FIREDURATION op not supported");
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
cam_res_mgr_led_trigger_event(
|
||||
flash_ctrl->switch_trigger,
|
||||
(enum led_brightness)LED_SWITCH_ON);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -489,6 +522,30 @@ static int cam_flash_high(
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_flash_duration(struct cam_flash_ctrl *fctrl,
|
||||
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 < fctrl->torch_num_sources; i++)
|
||||
if (fctrl->torch_trigger[i])
|
||||
cam_res_mgr_led_trigger_event(
|
||||
fctrl->torch_trigger[i],
|
||||
LED_OFF);
|
||||
|
||||
rc = cam_flash_ops(fctrl, flash_data,
|
||||
CAMERA_SENSOR_FLASH_OP_FIREDURATION);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_FLASH, "Fire PreciseFlash Failed: %d", rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_flash_i2c_delete_req(struct cam_flash_ctrl *fctrl,
|
||||
uint64_t req_id)
|
||||
{
|
||||
@@ -850,6 +907,19 @@ int cam_flash_pmic_apply_setting(struct cam_flash_ctrl *fctrl,
|
||||
"Flash off failed %d", rc);
|
||||
goto apply_setting_err;
|
||||
}
|
||||
} else if ((flash_data->opcode ==
|
||||
CAMERA_SENSOR_FLASH_OP_FIREDURATION) &&
|
||||
(flash_data->cmn_attr.is_settings_valid) &&
|
||||
(flash_data->cmn_attr.request_id == req_id)) {
|
||||
if (fctrl->flash_state == CAM_FLASH_STATE_START) {
|
||||
rc = cam_flash_duration(fctrl, flash_data);
|
||||
if (rc) {
|
||||
CAM_ERR(CAM_FLASH,
|
||||
"PreciaseFlash op failed:%d",
|
||||
rc);
|
||||
goto apply_setting_err;
|
||||
}
|
||||
}
|
||||
} else if (flash_data->opcode == CAM_PKT_NOP_OPCODE) {
|
||||
CAM_DBG(CAM_FLASH, "NOP Packet");
|
||||
} else {
|
||||
@@ -1473,6 +1543,18 @@ int cam_flash_pmic_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg)
|
||||
|
||||
if (flash_data->opcode == CAMERA_SENSOR_FLASH_OP_OFF)
|
||||
add_req.skip_before_applying |= SKIP_NEXT_FRAME;
|
||||
|
||||
if (flash_data->opcode ==
|
||||
CAMERA_SENSOR_FLASH_OP_FIREDURATION) {
|
||||
add_req.trigger_eof = true;
|
||||
/* Active time for the preflash */
|
||||
flash_data->flash_active_time_ms =
|
||||
(flash_operation_info->time_on_duration_ns)
|
||||
/ 1000000;
|
||||
CAM_DBG(CAM_FLASH,
|
||||
"PRECISE FLASH: active_time: %llu",
|
||||
flash_data->flash_active_time_ms);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1660,15 +1742,24 @@ int cam_flash_pmic_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg)
|
||||
add_req.dev_hdl = fctrl->bridge_intf.device_hdl;
|
||||
|
||||
if ((csl_packet->header.op_code & 0xFFFFF) ==
|
||||
CAM_FLASH_PACKET_OPCODE_SET_OPS)
|
||||
add_req.skip_before_applying |= 1;
|
||||
else
|
||||
CAM_FLASH_PACKET_OPCODE_SET_OPS) {
|
||||
if ((flash_data->opcode !=
|
||||
CAMERA_SENSOR_FLASH_OP_FIREDURATION))
|
||||
add_req.skip_before_applying |= 1;
|
||||
else if (flash_data->opcode ==
|
||||
CAMERA_SENSOR_FLASH_OP_FIREDURATION)
|
||||
add_req.trigger_eof = true;
|
||||
else
|
||||
add_req.skip_before_applying = 0;
|
||||
} else {
|
||||
add_req.skip_before_applying = 0;
|
||||
|
||||
}
|
||||
CAM_DBG(CAM_FLASH,
|
||||
"add req to req_mgr= %lld:: trigger_eof: %d",
|
||||
add_req.req_id, add_req.trigger_eof);
|
||||
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;
|
||||
|
@@ -108,13 +108,13 @@ struct cam_flash_init_packet {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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
|
||||
* @flash_active_time_ms : Flash_On time with precise flash
|
||||
*/
|
||||
struct cam_flash_frame_setting {
|
||||
struct cam_flash_common_attr cmn_attr;
|
||||
@@ -123,6 +123,7 @@ struct cam_flash_frame_setting {
|
||||
uint16_t led_off_delay_ms;
|
||||
int8_t opcode;
|
||||
uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
|
||||
uint64_t flash_active_time_ms;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -25,6 +25,7 @@ static void cam_sensor_update_req_mgr(
|
||||
csl_packet->header.request_id);
|
||||
add_req.dev_hdl = s_ctrl->bridge_intf.device_hdl;
|
||||
add_req.skip_before_applying = 0;
|
||||
add_req.trigger_eof = false;
|
||||
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);
|
||||
|
@@ -77,6 +77,7 @@ enum camera_flash_opcode {
|
||||
CAMERA_SENSOR_FLASH_OP_OFF,
|
||||
CAMERA_SENSOR_FLASH_OP_FIRELOW,
|
||||
CAMERA_SENSOR_FLASH_OP_FIREHIGH,
|
||||
CAMERA_SENSOR_FLASH_OP_FIREDURATION,
|
||||
CAMERA_SENSOR_FLASH_OP_MAX,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user