Merge "msm: camera: Add support for active deactive feature" into dev/msm-4.9-camx
This commit is contained in:
commit
9d1406e96b
6 changed files with 156 additions and 74 deletions
|
|
@ -36,7 +36,6 @@ int cam_flash_prepare(struct cam_flash_ctrl *flash_ctrl,
|
|||
return rc;
|
||||
}
|
||||
flash_ctrl->is_regulator_enabled = true;
|
||||
flash_ctrl->flash_state = CAM_FLASH_STATE_START;
|
||||
} else if ((!regulator_enable) &&
|
||||
(flash_ctrl->is_regulator_enabled == true)) {
|
||||
rc = qpnp_flash_led_prepare(flash_ctrl->switch_trigger,
|
||||
|
|
@ -47,7 +46,6 @@ int cam_flash_prepare(struct cam_flash_ctrl *flash_ctrl,
|
|||
return rc;
|
||||
}
|
||||
flash_ctrl->is_regulator_enabled = false;
|
||||
flash_ctrl->flash_state = CAM_FLASH_STATE_ACQUIRE;
|
||||
} else {
|
||||
CAM_ERR(CAM_FLASH, "Wrong Flash State : %d",
|
||||
flash_ctrl->flash_state);
|
||||
|
|
@ -68,12 +66,14 @@ static int cam_flash_flush_nrt(struct cam_flash_ctrl *fctrl)
|
|||
nrt_settings = &fctrl->nrt_info;
|
||||
|
||||
if (nrt_settings->cmn_attr.cmd_type ==
|
||||
CAMERA_SENSOR_FLASH_CMD_TYPE_INIT) {
|
||||
CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO) {
|
||||
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)) {
|
||||
CAMERA_SENSOR_FLASH_CMD_TYPE_RER) ||
|
||||
(nrt_settings->cmn_attr.cmd_type ==
|
||||
CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE)) {
|
||||
fctrl->nrt_info.cmn_attr.is_settings_valid = false;
|
||||
fctrl->nrt_info.cmn_attr.count = 0;
|
||||
fctrl->nrt_info.num_iterations = 0;
|
||||
|
|
@ -312,6 +312,49 @@ int cam_flash_apply_setting(struct cam_flash_ctrl *fctrl,
|
|||
|
||||
if (req_id == 0) {
|
||||
if (fctrl->nrt_info.cmn_attr.cmd_type ==
|
||||
CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE) {
|
||||
flash_data = &fctrl->nrt_info;
|
||||
if (flash_data->opcode ==
|
||||
CAMERA_SENSOR_FLASH_OP_FIREHIGH) {
|
||||
if (fctrl->flash_state !=
|
||||
CAM_FLASH_STATE_CONFIG) {
|
||||
CAM_WARN(CAM_FLASH,
|
||||
"Cannot apply Start Dev:Prev state: %d",
|
||||
fctrl->flash_state);
|
||||
return rc;
|
||||
}
|
||||
rc = cam_flash_prepare(fctrl, true);
|
||||
if (rc) {
|
||||
CAM_ERR(CAM_FLASH,
|
||||
"Enable Regulator Failed rc = %d", rc);
|
||||
return rc;
|
||||
}
|
||||
rc = cam_flash_high(fctrl, flash_data);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_FLASH,
|
||||
"FLASH ON failed : %d",
|
||||
rc);
|
||||
}
|
||||
if (flash_data->opcode ==
|
||||
CAMERA_SENSOR_FLASH_OP_OFF) {
|
||||
rc = cam_flash_off(fctrl);
|
||||
if (rc) {
|
||||
CAM_ERR(CAM_FLASH,
|
||||
"LED OFF FAILED: %d",
|
||||
rc);
|
||||
return rc;
|
||||
}
|
||||
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: %d",
|
||||
rc);
|
||||
}
|
||||
}
|
||||
} else if (fctrl->nrt_info.cmn_attr.cmd_type ==
|
||||
CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET) {
|
||||
flash_data = &fctrl->nrt_info;
|
||||
if (flash_data->opcode ==
|
||||
|
|
@ -491,11 +534,39 @@ int cam_flash_parser(struct cam_flash_ctrl *fctrl, void *arg)
|
|||
cam_flash_info = (struct cam_flash_init *)cmd_buf;
|
||||
|
||||
switch (cam_flash_info->cmd_type) {
|
||||
case CAMERA_SENSOR_FLASH_CMD_TYPE_INIT:
|
||||
case CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO:
|
||||
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;
|
||||
CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO;
|
||||
fctrl->flash_state =
|
||||
CAM_FLASH_STATE_CONFIG;
|
||||
break;
|
||||
case CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE:
|
||||
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_INIT_FIRE;
|
||||
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);
|
||||
fctrl->flash_state =
|
||||
CAM_FLASH_STATE_CONFIG;
|
||||
break;
|
||||
default:
|
||||
CAM_ERR(CAM_FLASH, "Wrong cmd_type = %d",
|
||||
|
|
@ -541,28 +612,35 @@ int cam_flash_parser(struct cam_flash_ctrl *fctrl, void *arg)
|
|||
case CAMERA_SENSOR_FLASH_CMD_TYPE_FIRE: {
|
||||
CAM_DBG(CAM_FLASH,
|
||||
"CAMERA_FLASH_CMD_TYPE_OPS case called");
|
||||
if (fctrl->flash_state != CAM_FLASH_STATE_START) {
|
||||
if ((fctrl->flash_state == CAM_FLASH_STATE_START) ||
|
||||
(fctrl->flash_state ==
|
||||
CAM_FLASH_STATE_CONFIG)) {
|
||||
flash_operation_info =
|
||||
(struct cam_flash_set_on_off *) cmd_buf;
|
||||
if (!flash_operation_info) {
|
||||
CAM_ERR(CAM_FLASH,
|
||||
"flash_operation_info Null");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
} else {
|
||||
CAM_ERR(CAM_FLASH,
|
||||
"Rxed Update packets without linking");
|
||||
fctrl->per_frame[frame_offset].
|
||||
cmn_attr.is_settings_valid = false;
|
||||
return -EINVAL;
|
||||
}
|
||||
flash_operation_info =
|
||||
(struct cam_flash_set_on_off *) cmd_buf;
|
||||
if (!flash_operation_info) {
|
||||
CAM_ERR(CAM_FLASH, "flash_operation_info Null");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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:
|
||||
|
|
@ -663,17 +741,18 @@ int cam_flash_parser(struct cam_flash_ctrl *fctrl, void *arg)
|
|||
break;
|
||||
}
|
||||
case CAM_PKT_NOP_OPCODE: {
|
||||
if (fctrl->flash_state != CAM_FLASH_STATE_START) {
|
||||
if ((fctrl->flash_state == CAM_FLASH_STATE_START) ||
|
||||
(fctrl->flash_state == CAM_FLASH_STATE_CONFIG)) {
|
||||
CAM_DBG(CAM_FLASH, "NOP Packet is Received: req_id: %u",
|
||||
csl_packet->header.request_id);
|
||||
goto update_req_mgr;
|
||||
} else {
|
||||
CAM_ERR(CAM_FLASH,
|
||||
"Rxed Update packets without linking");
|
||||
fctrl->per_frame[frame_offset].
|
||||
cmn_attr.is_settings_valid = false;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
CAM_DBG(CAM_FLASH, "NOP Packet is Received: req_id: %u",
|
||||
csl_packet->header.request_id);
|
||||
goto update_req_mgr;
|
||||
}
|
||||
default:
|
||||
CAM_ERR(CAM_FLASH, "Wrong Opcode : %d",
|
||||
|
|
@ -795,15 +874,13 @@ void cam_flash_shutdown(struct cam_flash_ctrl *fctrl)
|
|||
if (fctrl->flash_state == CAM_FLASH_STATE_INIT)
|
||||
return;
|
||||
|
||||
if (fctrl->flash_state == CAM_FLASH_STATE_ACQUIRE) {
|
||||
cam_flash_release_dev(fctrl);
|
||||
return;
|
||||
if ((fctrl->flash_state == CAM_FLASH_STATE_CONFIG) ||
|
||||
(fctrl->flash_state == CAM_FLASH_STATE_START)) {
|
||||
rc = cam_flash_stop_dev(fctrl);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_FLASH, "Stop Failed rc: %d", rc);
|
||||
}
|
||||
|
||||
rc = cam_flash_stop_dev(fctrl);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_FLASH, "Stop Failed rc: %d", rc);
|
||||
|
||||
rc = cam_flash_release_dev(fctrl);
|
||||
if (rc)
|
||||
CAM_ERR(CAM_FLASH, "Release failed rc: %d", rc);
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl,
|
|||
}
|
||||
case CAM_START_DEV: {
|
||||
CAM_DBG(CAM_FLASH, "CAM_START_DEV");
|
||||
if (fctrl->flash_state != CAM_FLASH_STATE_ACQUIRE) {
|
||||
if (fctrl->flash_state != CAM_FLASH_STATE_CONFIG) {
|
||||
CAM_WARN(CAM_FLASH,
|
||||
"Cannot apply Start Dev: Prev state: %d",
|
||||
fctrl->flash_state);
|
||||
|
|
@ -154,6 +154,7 @@ static int32_t cam_flash_driver_cmd(struct cam_flash_ctrl *fctrl,
|
|||
break;
|
||||
}
|
||||
case CAM_STOP_DEV: {
|
||||
CAM_DBG(CAM_FLASH, "CAM_STOP_DEV ENTER");
|
||||
if (fctrl->flash_state != CAM_FLASH_STATE_START) {
|
||||
CAM_WARN(CAM_FLASH,
|
||||
"Cannot apply Stop dev: Prev state is: %d",
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ enum cam_flash_switch_trigger_ops {
|
|||
enum cam_flash_state {
|
||||
CAM_FLASH_STATE_INIT,
|
||||
CAM_FLASH_STATE_ACQUIRE,
|
||||
CAM_FLASH_STATE_CONFIG,
|
||||
CAM_FLASH_STATE_START,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -165,38 +165,41 @@ static int32_t cam_sensor_i2c_pkt_parse(struct cam_sensor_ctrl_t *s_ctrl,
|
|||
}
|
||||
|
||||
case CAM_SENSOR_PACKET_OPCODE_SENSOR_UPDATE: {
|
||||
if (s_ctrl->sensor_state != CAM_SENSOR_START) {
|
||||
if ((s_ctrl->sensor_state == CAM_SENSOR_CONFIG) ||
|
||||
(s_ctrl->sensor_state == CAM_SENSOR_START)) {
|
||||
i2c_reg_settings =
|
||||
&i2c_data->
|
||||
per_frame[csl_packet->header.request_id %
|
||||
MAX_PER_FRAME_ARRAY];
|
||||
CAM_DBG(CAM_SENSOR, "Received Packet: %lld",
|
||||
csl_packet->header.request_id % MAX_PER_FRAME_ARRAY);
|
||||
if (i2c_reg_settings->is_settings_valid == 1) {
|
||||
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) {
|
||||
CAM_ERR(CAM_SENSOR,
|
||||
"Failed in Deleting the err: %d", rc);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CAM_ERR(CAM_SENSOR,
|
||||
"Rxed Update packets without linking");
|
||||
return -EINVAL;
|
||||
}
|
||||
i2c_reg_settings =
|
||||
&i2c_data->
|
||||
per_frame[csl_packet->header.request_id %
|
||||
MAX_PER_FRAME_ARRAY];
|
||||
CAM_DBG(CAM_SENSOR, "Received Packet: %lld",
|
||||
csl_packet->header.request_id % MAX_PER_FRAME_ARRAY);
|
||||
if (i2c_reg_settings->is_settings_valid == 1) {
|
||||
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) {
|
||||
CAM_ERR(CAM_SENSOR,
|
||||
"Failed in Deleting the err: %d", rc);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CAM_SENSOR_PACKET_OPCODE_SENSOR_NOP: {
|
||||
if (s_ctrl->sensor_state != CAM_SENSOR_START) {
|
||||
if ((s_ctrl->sensor_state == CAM_SENSOR_CONFIG) ||
|
||||
(s_ctrl->sensor_state == CAM_SENSOR_START)) {
|
||||
cam_sensor_update_req_mgr(s_ctrl, csl_packet);
|
||||
} else {
|
||||
CAM_ERR(CAM_SENSOR,
|
||||
"Rxed Update packets without linking");
|
||||
return -EINVAL;
|
||||
rc = -EINVAL;
|
||||
}
|
||||
|
||||
cam_sensor_update_req_mgr(s_ctrl, csl_packet);
|
||||
return rc;
|
||||
}
|
||||
default:
|
||||
|
|
@ -487,22 +490,18 @@ void cam_sensor_shutdown(struct cam_sensor_ctrl_t *s_ctrl)
|
|||
|
||||
cam_sensor_release_resource(s_ctrl);
|
||||
|
||||
if ((s_ctrl->sensor_state == CAM_SENSOR_START) ||
|
||||
(s_ctrl->sensor_state == CAM_SENSOR_ACQUIRE)) {
|
||||
if (s_ctrl->sensor_state >= CAM_SENSOR_ACQUIRE)
|
||||
cam_sensor_power_down(s_ctrl);
|
||||
rc = cam_destroy_device_hdl(s_ctrl->bridge_intf.device_hdl);
|
||||
if (rc < 0)
|
||||
CAM_ERR(CAM_SENSOR, " failed destroying dhdl");
|
||||
s_ctrl->bridge_intf.device_hdl = -1;
|
||||
s_ctrl->bridge_intf.link_hdl = -1;
|
||||
s_ctrl->bridge_intf.session_hdl = -1;
|
||||
s_ctrl->sensor_state = CAM_SENSOR_PROBE;
|
||||
}
|
||||
|
||||
if (s_ctrl->sensor_state == CAM_SENSOR_PROBE) {
|
||||
kfree(power_info->power_setting);
|
||||
kfree(power_info->power_down_setting);
|
||||
}
|
||||
rc = cam_destroy_device_hdl(s_ctrl->bridge_intf.device_hdl);
|
||||
if (rc < 0)
|
||||
CAM_ERR(CAM_SENSOR, " failed destroying dhdl");
|
||||
s_ctrl->bridge_intf.device_hdl = -1;
|
||||
s_ctrl->bridge_intf.link_hdl = -1;
|
||||
s_ctrl->bridge_intf.session_hdl = -1;
|
||||
|
||||
kfree(power_info->power_setting);
|
||||
kfree(power_info->power_down_setting);
|
||||
|
||||
s_ctrl->sensor_state = CAM_SENSOR_INIT;
|
||||
}
|
||||
|
|
@ -707,7 +706,8 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
|
|||
}
|
||||
break;
|
||||
case CAM_RELEASE_DEV: {
|
||||
if (s_ctrl->sensor_state != CAM_SENSOR_ACQUIRE) {
|
||||
if ((s_ctrl->sensor_state < CAM_SENSOR_ACQUIRE) ||
|
||||
(s_ctrl->sensor_state > CAM_SENSOR_CONFIG)) {
|
||||
rc = -EINVAL;
|
||||
CAM_WARN(CAM_SENSOR,
|
||||
"Not in right state to release : %d",
|
||||
|
|
@ -754,7 +754,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
|
|||
break;
|
||||
}
|
||||
case CAM_START_DEV: {
|
||||
if (s_ctrl->sensor_state != CAM_SENSOR_ACQUIRE) {
|
||||
if (s_ctrl->sensor_state != CAM_SENSOR_CONFIG) {
|
||||
rc = -EINVAL;
|
||||
CAM_WARN(CAM_SENSOR,
|
||||
"Not in right state to start : %d",
|
||||
|
|
@ -836,6 +836,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
|
|||
"Fail in deleting the config settings");
|
||||
goto release_mutex;
|
||||
}
|
||||
s_ctrl->sensor_state = CAM_SENSOR_CONFIG;
|
||||
s_ctrl->i2c_data.config_settings.request_id = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@
|
|||
|
||||
enum cam_sensor_state_t {
|
||||
CAM_SENSOR_INIT,
|
||||
CAM_SENSOR_PROBE,
|
||||
CAM_SENSOR_ACQUIRE,
|
||||
CAM_SENSOR_CONFIG,
|
||||
CAM_SENSOR_START,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -50,11 +50,13 @@ 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_INIT_INFO,
|
||||
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_RD_DATA,
|
||||
CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE,
|
||||
CAMERA_SENSOR_CMD_TYPE_MAX,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue