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

Commit 0111e59a authored by Camera Software Integration's avatar Camera Software Integration Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: sensor: Turn off the flash while flushing" into camera-kernel.lnx.1.0

parents e9bc5a9c 04325984
Loading
Loading
Loading
Loading
+51 −10
Original line number Original line Diff line number Diff line
@@ -287,6 +287,8 @@ int cam_flash_pmic_flush_request(struct cam_flash_ctrl *fctrl,
	int rc = 0;
	int rc = 0;
	int i = 0, j = 0;
	int i = 0, j = 0;
	int frame_offset = 0;
	int frame_offset = 0;
	bool is_off_needed = false;
	struct cam_flash_frame_setting *flash_data = NULL;


	if (!fctrl) {
	if (!fctrl) {
		CAM_ERR(CAM_FLASH, "Device data is NULL");
		CAM_ERR(CAM_FLASH, "Device data is NULL");
@@ -296,23 +298,47 @@ int cam_flash_pmic_flush_request(struct cam_flash_ctrl *fctrl,
	if (type == FLUSH_ALL) {
	if (type == FLUSH_ALL) {
	/* flush all requests*/
	/* flush all requests*/
		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
			fctrl->per_frame[i].cmn_attr.request_id = 0;
			flash_data =
			fctrl->per_frame[i].cmn_attr.is_settings_valid = false;
				&fctrl->per_frame[i];
			fctrl->per_frame[i].cmn_attr.count = 0;
			if ((flash_data->opcode ==
				CAMERA_SENSOR_FLASH_OP_OFF) &&
				(flash_data->cmn_attr.request_id > 0) &&
				(flash_data->cmn_attr.request_id <= req_id) &&
				flash_data->cmn_attr.is_settings_valid) {
				is_off_needed = true;
				CAM_DBG(CAM_FLASH,
					"FLASH_ALL: Turn off the flash for req %llu",
					flash_data->cmn_attr.request_id);
			}

			flash_data->cmn_attr.request_id = 0;
			flash_data->cmn_attr.is_settings_valid = false;
			flash_data->cmn_attr.count = 0;
			for (j = 0; j < CAM_FLASH_MAX_LED_TRIGGERS; j++)
			for (j = 0; j < CAM_FLASH_MAX_LED_TRIGGERS; j++)
				fctrl->per_frame[i].led_current_ma[j] = 0;
				flash_data->led_current_ma[j] = 0;
		}
		}


		cam_flash_pmic_flush_nrt(fctrl);
		cam_flash_pmic_flush_nrt(fctrl);
	} else if ((type == FLUSH_REQ) && (req_id != 0)) {
	} else if ((type == FLUSH_REQ) && (req_id != 0)) {
	/* flush request with req_id*/
	/* flush request with req_id*/
		frame_offset = req_id % MAX_PER_FRAME_ARRAY;
		frame_offset = req_id % MAX_PER_FRAME_ARRAY;
		fctrl->per_frame[frame_offset].cmn_attr.request_id = 0;
		flash_data =
		fctrl->per_frame[frame_offset].cmn_attr.is_settings_valid =
			&fctrl->per_frame[frame_offset];

		if (flash_data->opcode ==
			CAMERA_SENSOR_FLASH_OP_OFF) {
			is_off_needed = true;
			CAM_DBG(CAM_FLASH,
				"FLASH_REQ: Turn off the flash for req %llu",
				flash_data->cmn_attr.request_id);
		}

		flash_data->cmn_attr.request_id = 0;
		flash_data->cmn_attr.is_settings_valid =
			false;
			false;
		fctrl->per_frame[frame_offset].cmn_attr.count = 0;
		flash_data->cmn_attr.count = 0;
		for (i = 0; i < CAM_FLASH_MAX_LED_TRIGGERS; i++)
		for (i = 0; i < CAM_FLASH_MAX_LED_TRIGGERS; i++)
			fctrl->per_frame[frame_offset].led_current_ma[i] = 0;
			flash_data->led_current_ma[i] = 0;
	} else if ((type == FLUSH_REQ) && (req_id == 0)) {
	} else if ((type == FLUSH_REQ) && (req_id == 0)) {
		/* Handels NonRealTime usecase */
		/* Handels NonRealTime usecase */
		cam_flash_pmic_flush_nrt(fctrl);
		cam_flash_pmic_flush_nrt(fctrl);
@@ -321,6 +347,9 @@ int cam_flash_pmic_flush_request(struct cam_flash_ctrl *fctrl,
		return -EINVAL;
		return -EINVAL;
	}
	}


	if (is_off_needed)
		cam_flash_off(fctrl);

	return rc;
	return rc;
}
}


@@ -567,7 +596,9 @@ static int cam_flash_i2c_delete_req(struct cam_flash_ctrl *fctrl,
		CAM_DBG(CAM_FLASH, "top: %llu, del_req_id:%llu",
		CAM_DBG(CAM_FLASH, "top: %llu, del_req_id:%llu",
			top, del_req_id);
			top, del_req_id);
	}
	}
	fctrl->func_tbl.flush_req(fctrl, FLUSH_REQ, del_req_id);

	cam_flash_i2c_flush_nrt(fctrl);

	return 0;
	return 0;
}
}


@@ -577,6 +608,7 @@ static int cam_flash_pmic_delete_req(struct cam_flash_ctrl *fctrl,
	int i = 0;
	int i = 0;
	struct cam_flash_frame_setting *flash_data = NULL;
	struct cam_flash_frame_setting *flash_data = NULL;
	uint64_t top = 0, del_req_id = 0;
	uint64_t top = 0, del_req_id = 0;
	int frame_offset = 0;


	if (req_id != 0) {
	if (req_id != 0) {
		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
		for (i = 0; i < MAX_PER_FRAME_ARRAY; i++) {
@@ -612,7 +644,16 @@ static int cam_flash_pmic_delete_req(struct cam_flash_ctrl *fctrl,
			top, del_req_id);
			top, del_req_id);
	}
	}


	fctrl->func_tbl.flush_req(fctrl, FLUSH_REQ, del_req_id);
	/* delete the request */
	frame_offset = del_req_id % MAX_PER_FRAME_ARRAY;
	flash_data = &fctrl->per_frame[frame_offset];
	flash_data->cmn_attr.request_id = 0;
	flash_data->cmn_attr.is_settings_valid = false;
	flash_data->cmn_attr.count = 0;

	for (i = 0; i < CAM_FLASH_MAX_LED_TRIGGERS; i++)
		flash_data->led_current_ma[i] = 0;

	return 0;
	return 0;
}
}