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

Commit c1592988 authored by Rajesh Bondugula's avatar Rajesh Bondugula
Browse files

msm: camera: sensor: Add unified flash driver



pmic and i2c based flash use common driver.
Single driver handles all types of flashes
like i2c based / pmic based / strobe flash
unlike previous driver.

Receives same ioctls from userspace to control
the flash hardware for all types of flashes.

Flash driver is driven from usersapce like
the previous implementation.

Change-Id: Ie6e4aad6056af6ebb7242d7327abf8f003a7bec2
Signed-off-by: default avatarRajesh Bondugula <rajeshb@codeaurora.org>
parent ab01e731
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ Required properties:
    - 0, 1, 2, 3
- compatible :
    - "qcom,camera-led-flash"
    - "qcom,camera-flash"
    - "qcom,led-flash"
    - "qcom,led-flash1"
- reg : offset and length of the register set for the device.
+2 −0
Original line number Diff line number Diff line
ccflags-y += -Idrivers/media/platform/msm/camera_v2/sensor/cci
ccflags-y += -Idrivers/media/platform/msm/camera_v2
ccflags-y += -Idrivers/media/platform/msm/camera_v2/sensor/io
obj-$(CONFIG_MSMB_CAMERA) += msm_led_flash.o
@@ -6,3 +7,4 @@ obj-$(CONFIG_MSMB_CAMERA) += msm_led_i2c_trigger.o
obj-$(CONFIG_MSMB_CAMERA) += adp1660.o
obj-$(CONFIG_MSMB_CAMERA) += bd7710.o
obj-$(CONFIG_MSMB_CAMERA) += msm_led_torch.o
obj-$(CONFIG_MSMB_CAMERA) += msm_flash.o
+1051 −0

File added.

Preview size limit exceeded, changes collapsed.

+116 −0
Original line number Diff line number Diff line
/* Copyright (c) 2009-2014, 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
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */
#ifndef MSM_FLASH_H
#define MSM_FLASH_H

#include <linux/leds.h>
#include <linux/platform_device.h>
#include <media/v4l2-subdev.h>
#include <media/v4l2-ioctl.h>
#include <media/msm_cam_sensor.h>
#include <soc/qcom/camera2.h>
#include "msm_camera_i2c.h"
#include "msm_sd.h"

#define DEFINE_MSM_MUTEX(mutexname) \
	static struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)

enum msm_camera_flash_state_t {
	MSM_CAMERA_FLASH_INIT,
	MSM_CAMERA_FLASH_RELEASE,
};

struct msm_flash_ctrl_t;

struct msm_flash_func_t {
	int32_t (*camera_flash_init)(struct msm_flash_ctrl_t *,
		struct msm_flash_cfg_data_t *);
	int32_t (*camera_flash_release)(struct msm_flash_ctrl_t *);
	int32_t (*camera_flash_off)(struct msm_flash_ctrl_t *,
		struct msm_flash_cfg_data_t *);
	int32_t (*camera_flash_low)(struct msm_flash_ctrl_t *,
		struct msm_flash_cfg_data_t *);
	int32_t (*camera_flash_high)(struct msm_flash_ctrl_t *,
		struct msm_flash_cfg_data_t *);
};

struct msm_flash_table {
	enum msm_flash_driver_type flash_driver_type;
	struct msm_flash_func_t func_tbl;
};

struct msm_flash_reg_t {
	struct msm_camera_i2c_reg_setting *init_setting;
	struct msm_camera_i2c_reg_setting *off_setting;
	struct msm_camera_i2c_reg_setting *release_setting;
	struct msm_camera_i2c_reg_setting *low_setting;
	struct msm_camera_i2c_reg_setting *high_setting;
};

struct msm_flash_ctrl_t {
	struct msm_camera_i2c_client flash_i2c_client;
	struct msm_sd_subdev msm_sd;
	struct platform_device *pdev;
	struct msm_flash_func_t *func_tbl;
	struct msm_camera_power_ctrl_t power_info;

	/* Flash */
	uint32_t flash_num_sources;
	const char *flash_trigger_name[MAX_LED_TRIGGERS];
	struct led_trigger *flash_trigger[MAX_LED_TRIGGERS];
	uint32_t flash_op_current[MAX_LED_TRIGGERS];
	uint32_t flash_max_current[MAX_LED_TRIGGERS];
	uint32_t flash_max_duration[MAX_LED_TRIGGERS];

	/* Torch */
	uint32_t torch_num_sources;
	const char *torch_trigger_name[MAX_LED_TRIGGERS];
	struct led_trigger *torch_trigger[MAX_LED_TRIGGERS];
	uint32_t torch_op_current[MAX_LED_TRIGGERS];
	uint32_t torch_max_current[MAX_LED_TRIGGERS];

	void *data;
	enum msm_camera_device_type_t flash_device_type;
	enum cci_i2c_master_t cci_i2c_master;
	uint32_t subdev_id;
	struct mutex *flash_mutex;
	struct msm_sensor_power_setting_array power_setting_array;

	/* flash driver type */
	enum msm_flash_driver_type flash_driver_type;

	/* flash state */
	enum msm_camera_flash_state_t flash_state;
};

int msm_flash_i2c_probe(struct i2c_client *client,
	const struct i2c_device_id *id);

int msm_flash_probe(struct platform_device *pdev, const void *data);

int32_t msm_flash_create_v4lsubdev(struct platform_device *pdev,
	void *data);
int32_t msm_led_i2c_flash_create_v4lsubdev(void *data);

int32_t msm_led_i2c_trigger_get_subdev_id(struct msm_flash_ctrl_t *fctrl,
	void *arg);

int32_t msm_led_i2c_trigger_config(struct msm_flash_ctrl_t *fctrl,
	void *data);

int msm_flash_led_init(struct msm_flash_ctrl_t *fctrl);
int msm_flash_led_release(struct msm_flash_ctrl_t *fctrl);
int msm_flash_led_off(struct msm_flash_ctrl_t *fctrl);
int msm_flash_led_low(struct msm_flash_ctrl_t *fctrl);
int msm_flash_led_high(struct msm_flash_ctrl_t *fctrl);
#endif
+3 −0
Original line number Diff line number Diff line
@@ -670,6 +670,9 @@ int32_t msm_sensor_driver_probe(void *setting,
		strlcpy(slave_info->ois_name, setting32.ois_name,
			sizeof(slave_info->ois_name));

		strlcpy(slave_info->flash_name, setting32.flash_name,
			sizeof(slave_info->flash_name));

		slave_info->addr_type = setting32.addr_type;
		slave_info->camera_id = setting32.camera_id;

Loading