msm: camera: add logic for sensor compatibility issue

Add logic to fix same sensor at one board compatibility
issue.

Change-Id: I6c6721e8ff890feaf2d618c8170e346367a68c28
Signed-off-by: Wei Ding <weiding@codeaurora.org>
This commit is contained in:
Wei Ding 2015-05-19 10:05:32 +08:00
parent 668b279026
commit c1aa5f2974
4 changed files with 70 additions and 3 deletions

View File

@ -174,6 +174,8 @@ Optional properties:
property should contain phandle of respective eeprom nodes
- qcom,ois-src : if optical image stabilization is supported by this sensor,
this property should contain phandle of respective ois node
- qcom,special-support-sensors: if only some special sensors are supported
on this board, add sensor name in this property.
* Qualcomm MSM ACTUATOR

View File

@ -624,6 +624,24 @@ static void msm_sensor_fill_sensor_info(struct msm_sensor_ctrl_t *s_ctrl,
strlcpy(entity_name, s_ctrl->msm_sd.sd.entity.name, MAX_SENSOR_NAME);
}
/* static function definition */
static int32_t msm_sensor_driver_is_special_support(
struct msm_sensor_ctrl_t *s_ctrl,
char *sensor_name)
{
int32_t rc = 0;
int32_t i = 0;
struct msm_camera_sensor_board_info *sensordata = s_ctrl->sensordata;
for (i = 0; i < sensordata->special_support_size; i++) {
if (!strcmp(sensordata->special_support_sensors[i],
sensor_name)) {
rc = TRUE;
break;
}
}
return rc;
}
/* static function definition */
int32_t msm_sensor_driver_probe(void *setting,
struct msm_sensor_info_t *probed_info, char *entity_name)
@ -779,6 +797,16 @@ int32_t msm_sensor_driver_probe(void *setting,
goto free_slave_info;
}
if (s_ctrl->sensordata->special_support_size > 0) {
if (!msm_sensor_driver_is_special_support(s_ctrl,
slave_info->sensor_name)) {
pr_err("%s:%s is not support on this board\n",
__func__, slave_info->sensor_name);
rc = 0;
goto free_slave_info;
}
}
if (slave_info->power_setting_array.size == 0 &&
slave_info->slave_addr == 0) {
s_ctrl->is_csid_tg_mode = 1;
@ -1031,7 +1059,8 @@ static int32_t msm_sensor_driver_get_dt_data(struct msm_sensor_ctrl_t *s_ctrl)
int32_t rc = 0;
struct msm_camera_sensor_board_info *sensordata = NULL;
struct device_node *of_node = s_ctrl->of_node;
uint32_t cell_id;
uint32_t cell_id;
int32_t i;
s_ctrl->sensordata = kzalloc(sizeof(*sensordata), GFP_KERNEL);
if (!s_ctrl->sensordata) {
@ -1066,6 +1095,35 @@ static int32_t msm_sensor_driver_get_dt_data(struct msm_sensor_ctrl_t *s_ctrl)
goto FREE_SENSOR_DATA;
}
sensordata->special_support_size =
of_property_count_strings(of_node,
"qcom,special-support-sensors");
if (sensordata->special_support_size < 0)
sensordata->special_support_size = 0;
if (sensordata->special_support_size > MAX_SPECIAL_SUPPORT_SIZE) {
pr_err("%s:support_size exceed max support size\n", __func__);
sensordata->special_support_size = MAX_SPECIAL_SUPPORT_SIZE;
}
if (sensordata->special_support_size) {
for (i = 0; i < sensordata->special_support_size; i++) {
rc = of_property_read_string_index(of_node,
"qcom,special-support-sensors", i,
&(sensordata->special_support_sensors[i]));
if (rc < 0) {
/* if read sensor support names failed,
* set support all sensors, break;
*/
sensordata->special_support_size = 0;
break;
}
CDBG("%s special_support_sensors[%d] = %s\n", __func__,
i, sensordata->special_support_sensors[i]);
}
}
/* Read subdev info */
rc = msm_sensor_get_sub_module_index(of_node, &sensordata->sensor_info);
if (rc < 0) {

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -20,6 +20,8 @@
#include <linux/of_device.h>
#include <linux/of.h>
#define MAX_SPECIAL_SUPPORT_SIZE 10
enum msm_camera_device_type_t {
MSM_CAMERA_I2C_DEVICE,
MSM_CAMERA_PLATFORM_DEVICE,
@ -94,6 +96,8 @@ struct msm_camera_sensor_board_info {
const char *eeprom_name;
const char *actuator_name;
const char *ois_name;
const char *special_support_sensors[MAX_SPECIAL_SUPPORT_SIZE];
int32_t special_support_size;
struct msm_camera_slave_info *slave_info;
struct msm_camera_csi_lane_params *csi_lane_params;
struct msm_camera_sensor_strobe_flash_data *strobe_flash_data;

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -20,6 +20,7 @@
#include <linux/of_device.h>
#include <linux/of.h>
#define MAX_SPECIAL_SUPPORT_SIZE 10
enum msm_camera_device_type_t {
MSM_CAMERA_I2C_DEVICE,
@ -148,6 +149,8 @@ struct msm_camera_sensor_board_info {
const char *eeprom_name;
const char *actuator_name;
const char *ois_name;
const char *special_support_sensors[MAX_SPECIAL_SUPPORT_SIZE];
int32_t special_support_size;
struct msm_camera_slave_info *slave_info;
struct msm_camera_csi_lane_params *csi_lane_params;
struct msm_camera_sensor_strobe_flash_data *strobe_flash_data;