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

Commit 65bab291 authored by Rajesh Bondugula's avatar Rajesh Bondugula
Browse files

msm: camera: sensor: flash: Fix flash driver



Fix flash issues after adding "unified flash driver".
Unified flash driver commit Id: c1592988
These are the changes made:
Max current and max duration are properly propogated to userspace
Flash current (main and torch) are properly sent to kernel

Change-Id: Ic9d715d41a842b258d1c88a5379bc2a5b0e38092
Signed-off-by: default avatarIvan Tiyanov <ivant@codeaurora.org>
Signed-off-by: default avatarRajesh Bondugula <rajeshb@codeaurora.org>
parent 4f91f3d1
Loading
Loading
Loading
Loading
+35 −10
Original line number 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 ==
		FLASH_DRIVER_DEFAULT) {
		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 ==
		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) {
@@ -422,21 +434,23 @@ static int32_t msm_flash_low(
	CDBG("Enter\n");
	/* Turn off flash triggers */
	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);

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

	/* Turn off torch triggers */
	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);

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

	CDBG("Enter");
	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) {
	case VIDIOC_MSM_FLASH_CFG32:
		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);
	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");
	return rc;
}
+7 −13
Original line number Diff line number Diff line
@@ -37,8 +37,6 @@
#define MAX_AF_ITERATIONS 3
#define MAX_NUMBER_OF_STEPS 47

#define MAX_LED_TRIGGERS 3

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

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

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

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

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

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

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

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

enum msm_sensor_camera_id_t {
	CAMERA_0,