Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15a5a1db authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: sensor: flash: Fix flash driver"

parents 249f8494 65bab291
Loading
Loading
Loading
Loading
+35 −10
Original line number Original line Diff line number Diff line
@@ -375,9 +375,21 @@ static int32_t msm_flash_init(
	if (flash_data->cfg.flash_init_info->flash_driver_type ==
	if (flash_data->cfg.flash_init_info->flash_driver_type ==
		FLASH_DRIVER_DEFAULT) {
		FLASH_DRIVER_DEFAULT) {
		flash_driver_type = flash_ctrl->flash_driver_type;
		flash_driver_type = flash_ctrl->flash_driver_type;
		for (i = 0; i < MAX_LED_TRIGGERS; i++) {
			flash_data->flash_current[i] =
				flash_ctrl->flash_max_current[i];
			flash_data->flash_duration[i] =
				flash_ctrl->flash_max_duration[i];
		}
	} else if (flash_data->cfg.flash_init_info->flash_driver_type ==
	} else if (flash_data->cfg.flash_init_info->flash_driver_type ==
		flash_ctrl->flash_driver_type) {
		flash_ctrl->flash_driver_type) {
		flash_driver_type = flash_ctrl->flash_driver_type;
		flash_driver_type = flash_ctrl->flash_driver_type;
		for (i = 0; i < MAX_LED_TRIGGERS; i++) {
			flash_ctrl->flash_max_current[i] =
				flash_data->flash_current[i];
			flash_data->flash_duration[i] =
				flash_ctrl->flash_max_duration[i];
		}
	}
	}


	if (flash_driver_type == FLASH_DRIVER_DEFAULT) {
	if (flash_driver_type == FLASH_DRIVER_DEFAULT) {
@@ -422,21 +434,23 @@ static int32_t msm_flash_low(
	CDBG("Enter\n");
	CDBG("Enter\n");
	/* Turn off flash triggers */
	/* Turn off flash triggers */
	for (i = 0; i < flash_ctrl->flash_num_sources; i++)
	for (i = 0; i < flash_ctrl->flash_num_sources; i++)
		if (flash_ctrl->flash_trigger[i])
			led_trigger_event(flash_ctrl->flash_trigger[i], 0);
			led_trigger_event(flash_ctrl->flash_trigger[i], 0);


	/* Turn on flash triggers */
	/* Turn on flash triggers */
	for (i = 0; i < flash_ctrl->torch_num_sources; i++) {
	for (i = 0; i < flash_ctrl->torch_num_sources; i++) {
		if (flash_ctrl->torch_trigger[i]) {
		if (flash_ctrl->torch_trigger[i]) {
			max_current = flash_ctrl->torch_max_current[i];
			max_current = flash_ctrl->torch_max_current[i];
			if (flash_data->cfg.flash_current[i] >= 0 &&
			if (flash_data->flash_current[i] >= 0 &&
				flash_data->cfg.flash_current[i] <
				flash_data->flash_current[i] <
				max_current) {
				max_current) {
				curr = flash_data->cfg.flash_current[i];
				curr = flash_data->flash_current[i];
			} else {
			} else {
				curr = flash_ctrl->torch_op_current[i];
				curr = flash_ctrl->torch_op_current[i];
				pr_debug("LED current clamped to %d\n",
				pr_debug("LED current clamped to %d\n",
					curr);
					curr);
			}
			}
			CDBG("low_flash_current[%d] = %d", i, curr);
			led_trigger_event(flash_ctrl->torch_trigger[i],
			led_trigger_event(flash_ctrl->torch_trigger[i],
				curr);
				curr);
		}
		}
@@ -456,21 +470,23 @@ static int32_t msm_flash_high(


	/* Turn off torch triggers */
	/* Turn off torch triggers */
	for (i = 0; i < flash_ctrl->torch_num_sources; i++)
	for (i = 0; i < flash_ctrl->torch_num_sources; i++)
		if (flash_ctrl->torch_trigger[i])
			led_trigger_event(flash_ctrl->torch_trigger[i], 0);
			led_trigger_event(flash_ctrl->torch_trigger[i], 0);


	/* Turn on flash triggers */
	/* Turn on flash triggers */
	for (i = 0; i < flash_ctrl->flash_num_sources; i++) {
	for (i = 0; i < flash_ctrl->flash_num_sources; i++) {
		if (flash_ctrl->flash_trigger[i]) {
		if (flash_ctrl->flash_trigger[i]) {
			max_current = flash_ctrl->flash_max_current[i];
			max_current = flash_ctrl->flash_max_current[i];
			if (flash_data->cfg.flash_current[i] >= 0 &&
			if (flash_data->flash_current[i] >= 0 &&
				flash_data->cfg.flash_current[i] <
				flash_data->flash_current[i] <
				max_current) {
				max_current) {
				curr = flash_data->cfg.flash_current[i];
				curr = flash_data->flash_current[i];
			} else {
			} else {
				curr = flash_ctrl->flash_op_current[i];
				curr = flash_ctrl->flash_op_current[i];
				pr_debug("LED current clamped to %d\n",
				pr_debug("LED flash_current[%d] clamped %d\n",
					curr);
					i, curr);
			}
			}
			CDBG("high_flash_current[%d] = %d", i, curr);
			led_trigger_event(flash_ctrl->flash_trigger[i],
			led_trigger_event(flash_ctrl->flash_trigger[i],
				curr);
				curr);
		}
		}
@@ -871,6 +887,7 @@ static int32_t msm_flash_get_dt_data(struct device_node *of_node,
static long msm_flash_subdev_do_ioctl(
static long msm_flash_subdev_do_ioctl(
	struct file *file, unsigned int cmd, void *arg)
	struct file *file, unsigned int cmd, void *arg)
{
{
	int32_t i = 0;
	int32_t rc = 0;
	int32_t rc = 0;
	struct video_device *vdev = video_devdata(file);
	struct video_device *vdev = video_devdata(file);
	struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
	struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
@@ -882,6 +899,10 @@ static long msm_flash_subdev_do_ioctl(


	CDBG("Enter");
	CDBG("Enter");
	flash_data.cfg_type = u32->cfg_type;
	flash_data.cfg_type = u32->cfg_type;
	for (i = 0; i < MAX_LED_TRIGGERS; i++) {
		flash_data.flash_current[i] = u32->flash_current[i];
		flash_data.flash_duration[i] = u32->flash_duration[i];
	}
	switch (cmd) {
	switch (cmd) {
	case VIDIOC_MSM_FLASH_CFG32:
	case VIDIOC_MSM_FLASH_CFG32:
		cmd = VIDIOC_MSM_FLASH_CFG;
		cmd = VIDIOC_MSM_FLASH_CFG;
@@ -917,6 +938,10 @@ static long msm_flash_subdev_do_ioctl(
	}
	}


	rc =  msm_flash_subdev_ioctl(sd, cmd, &flash_data);
	rc =  msm_flash_subdev_ioctl(sd, cmd, &flash_data);
	for (i = 0; i < MAX_LED_TRIGGERS; i++) {
		u32->flash_current[i] = flash_data.flash_current[i];
		u32->flash_duration[i] = flash_data.flash_duration[i];
	}
	CDBG("Exit");
	CDBG("Exit");
	return rc;
	return rc;
}
}
+7 −13
Original line number Original line Diff line number Diff line
@@ -37,8 +37,6 @@
#define MAX_AF_ITERATIONS 3
#define MAX_AF_ITERATIONS 3
#define MAX_NUMBER_OF_STEPS 47
#define MAX_NUMBER_OF_STEPS 47


#define MAX_LED_TRIGGERS 3

enum flash_type {
enum flash_type {
	LED_FLASH = 1,
	LED_FLASH = 1,
	STROBE_FLASH,
	STROBE_FLASH,
@@ -553,9 +551,9 @@ enum msm_camera_led_config_t {


struct msm_camera_led_cfg_t {
struct msm_camera_led_cfg_t {
	enum msm_camera_led_config_t cfgtype;
	enum msm_camera_led_config_t cfgtype;
	uint32_t torch_current[MAX_LED_TRIGGERS];
	int32_t torch_current[MAX_LED_TRIGGERS];
	uint32_t flash_current[MAX_LED_TRIGGERS];
	int32_t flash_current[MAX_LED_TRIGGERS];
	uint32_t flash_duration[MAX_LED_TRIGGERS];
	int32_t flash_duration[MAX_LED_TRIGGERS];
};
};


struct msm_flash_init_info_t {
struct msm_flash_init_info_t {
@@ -566,13 +564,11 @@ struct msm_flash_init_info_t {


struct msm_flash_cfg_data_t {
struct msm_flash_cfg_data_t {
	enum msm_flash_cfg_type_t cfg_type;
	enum msm_flash_cfg_type_t cfg_type;
	uint32_t torch_current;
	int32_t flash_current[MAX_LED_TRIGGERS];
	uint32_t flash_current[MAX_LED_TRIGGERS];
	int32_t flash_duration[MAX_LED_TRIGGERS];
	uint32_t flash_duration[MAX_LED_TRIGGERS];
	union {
	union {
		struct msm_flash_init_info_t *flash_init_info;
		struct msm_flash_init_info_t *flash_init_info;
		struct msm_camera_i2c_reg_setting_array *settings;
		struct msm_camera_i2c_reg_setting_array *settings;
		uint32_t flash_current[MAX_LED_TRIGGERS];
	} cfg;
	} cfg;
};
};


@@ -739,13 +735,11 @@ struct msm_flash_init_info_t32 {


struct msm_flash_cfg_data_t32 {
struct msm_flash_cfg_data_t32 {
	enum msm_flash_cfg_type_t cfg_type;
	enum msm_flash_cfg_type_t cfg_type;
	uint32_t torch_current;
	int32_t flash_current[MAX_LED_TRIGGERS];
	uint32_t flash_current[MAX_LED_TRIGGERS];
	int32_t flash_duration[MAX_LED_TRIGGERS];
	uint32_t flash_duration[MAX_LED_TRIGGERS];
	union {
	union {
		compat_uptr_t flash_init_info;
		compat_uptr_t flash_init_info;
		compat_uptr_t settings;
		compat_uptr_t settings;
		uint32_t flash_current[MAX_LED_TRIGGERS];
	} cfg;
	} cfg;
};
};


+1 −1
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@
#define MAX_I2C_REG_SET           12
#define MAX_I2C_REG_SET           12


#define MAX_NAME_SIZE             32
#define MAX_NAME_SIZE             32
#define MAX_FLASH_NUM             8
#define MAX_LED_TRIGGERS          3


enum msm_sensor_camera_id_t {
enum msm_sensor_camera_id_t {
	CAMERA_0,
	CAMERA_0,