techpack: camera: Add guarding for header struct changes

* We don't build the Camera HAL from source
  so userspace does not need access to
  cam_sensor.h, move it and implement guarding
  for breaking changes for devices with older
  Camera Blobs.

Change-Id: I5a45b83e01ad85752e99035805ee2a6d1f8dfa93
Signed-off-by: electimon <electimon@gmail.com>
This commit is contained in:
electimon 2023-06-11 17:18:56 -04:00 • committed by Vivekachooz
commit 67cfbd9fb2
No known key found for this signature in database
GPG key ID: B7434A1044B09189
6 changed files with 25 additions and 2 deletions

View file

@ -1985,6 +1985,12 @@ config CAM_SENSOR_PROBE_RETRY
help
Add retries for sensor id matching
config CAMERA_CCI_MASTER_CHANGE
bool "For cam cci master chance"
default y
help
Enable it to switch cci master i2c address.
config CAMERA_CCI_ADDR_SWITCH
bool "For cam switch i2c address"
default n

View file

@ -453,9 +453,11 @@ int32_t cam_sensor_update_slave_info(struct cam_cmd_probe *probe_info,
s_ctrl->sub_device_addr_type = probe_info->sub_device_addr_type;
s_ctrl->sub_device_id_addr = probe_info->sub_device_id_addr;
s_ctrl->expected_sub_device_id = probe_info->expected_sub_device_id;
#ifdef CONFIG_CAMERA_CCI_MASTER_CHANGE
s_ctrl->sub_device_cci_master = probe_info->sub_device_cci_master;
s_ctrl->sub_device_cci_device = probe_info->sub_device_cci_device;
s_ctrl->sub_device_i2c_freq_mode = probe_info->sub_device_i2c_freq_mode;
#endif
#ifdef CONFIG_CAMERA_CCI_ADDR_SWITCH
s_ctrl->i2c_addr_switch = probe_info->i2c_addr_switch;
s_ctrl->second_i2c_address = probe_info->second_i2c_address;
@ -822,13 +824,15 @@ int cam_sensor_match_sub_device_id(struct cam_sensor_ctrl_t *s_ctrl)
int ret = 0;
uint32_t sub_device_id = 0;
uint16_t sensor_address = 0;
#ifdef CONFIG_CAMERA_CCI_MASTER_CHANGE
uint16_t sensor_freq_mode = 0;
uint8_t sensor_cci_master = 0;
uint8_t sensor_cci_device = 0;
#endif
/* if hal doesn't config ProbeSubDevice parameter in sensor xml, return success immediately */
if (!s_ctrl->probe_sub_device) {
return 0;
return ret;
}
/* save sensor i2c address */
@ -839,6 +843,7 @@ int cam_sensor_match_sub_device_id(struct cam_sensor_ctrl_t *s_ctrl)
s_ctrl->io_master_info.cci_client->sid = s_ctrl->sub_device_addr >> 1;
}
#ifdef CONFIG_CAMERA_CCI_MASTER_CHANGE
/*if need change cci master*/
if (s_ctrl->need_change_cci_master) {
sensor_cci_master = s_ctrl->io_master_info.cci_client->cci_i2c_master;
@ -869,6 +874,7 @@ int cam_sensor_match_sub_device_id(struct cam_sensor_ctrl_t *s_ctrl)
}
}
}
#endif
rc = camera_io_dev_read(
&(s_ctrl->io_master_info),
@ -883,6 +889,7 @@ int cam_sensor_match_sub_device_id(struct cam_sensor_ctrl_t *s_ctrl)
/* restore sensor i2c address */
s_ctrl->io_master_info.cci_client->sid = sensor_address;
#ifdef CONFIG_CAMERA_CCI_MASTER_CHANGE
/* reset cci master */
if (s_ctrl->need_change_cci_master) {
ret = camera_io_release(&(s_ctrl->io_master_info));
@ -906,6 +913,7 @@ int cam_sensor_match_sub_device_id(struct cam_sensor_ctrl_t *s_ctrl)
}
}
}
#endif
if (sub_device_id == s_ctrl->expected_sub_device_id) {
CAM_INFO(CAM_SENSOR,

View file

@ -117,10 +117,13 @@ struct cam_sensor_ctrl_t {
uint8_t sub_device_addr_type;
uint16_t sub_device_id_addr;
uint16_t expected_sub_device_id;
#ifdef CONFIG_CAMERA_CCI_MASTER_CHANGE
uint8_t sub_device_cci_master;
uint8_t sub_device_cci_device;
uint8_t sub_device_i2c_freq_mode;
bool need_change_cci_master;
#endif
#ifdef CONFIG_CAMERA_CCI_ADDR_SWITCH
uint8_t i2c_addr_switch;
uint16_t second_i2c_address;
uint8_t i2c_switch_reg_addr_Type;
@ -128,6 +131,7 @@ struct cam_sensor_ctrl_t {
uint16_t i2c_switch_reg_addr;
uint16_t i2c_switch_reg_data;
uint16_t i2c_switch_reg_delayMs;
#endif
#ifdef CONFIG_MOT_SENSOR_PRE_POWERUP
bool sensor_power_up_done;
#endif

View file

@ -187,12 +187,14 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl)
CAM_DBG(CAM_SENSOR, "cci-index %d", s_ctrl->cci_num);
}
#ifdef CONFIG_CAMERA_CCI_MASTER_CHANGE
if (of_property_read_bool(of_node, "need-change-cci-master")) {
CAM_DBG(CAM_SENSOR, "need-change-cci-master found in this imgsensor");
s_ctrl->need_change_cci_master = true;
} else {
s_ctrl->need_change_cci_master = false;
}
#endif
if (of_property_read_u32(of_node, "sensor-position-pitch",
&sensordata->pos_pitch) < 0) {

View file

@ -178,9 +178,12 @@ struct cam_cmd_probe {
__u8 sub_device_addr_type;
__u32 sub_device_id_addr;
__u32 expected_sub_device_id;
#ifdef CONFIG_CAMERA_CCI_MASTER_CHANGE
__u8 sub_device_cci_master;
__u8 sub_device_cci_device;
__u8 sub_device_i2c_freq_mode;
#endif
#ifdef CONFIG_CAMERA_CCI_ADDR_SWITCH
__u8 i2c_addr_switch;
__u32 second_i2c_address;
__u8 i2c_switch_reg_addr_Type;
@ -188,6 +191,7 @@ struct cam_cmd_probe {
__u32 i2c_switch_reg_addr;
__u32 i2c_switch_reg_data;
__u32 i2c_switch_reg_delayMs;
#endif
} __attribute__((packed));
/**

View file

@ -14,7 +14,6 @@ header-y += camera/media/cam_isp.h
header-y += camera/media/cam_jpeg.h
header-y += camera/media/cam_lrme.h
header-y += camera/media/cam_req_mgr.h
header-y += camera/media/cam_sensor.h
header-y += camera/media/cam_sync.h
header-y += camera/media/cam_ope.h
header-y += camera/media/cam_isp_tfe.h