• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * linux-5.4/drivers/media/platform/sunxi-vin/modules/flash/flash.h
3  *
4  * Copyright (c) 2007-2017 Allwinnertech Co., Ltd.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16 
17 #ifndef __FLASH_H__
18 #define __FLASH_H__
19 
20 #include <linux/module.h>
21 #include <media/v4l2-subdev.h>
22 #include <media/v4l2-dev.h>
23 #include <media/v4l2-ctrls.h>
24 
25 #include "../../utility/vin_os.h"
26 
27 #include "../../utility/vin_supply.h"
28 #include "../sensor/camera_cfg.h"
29 
30 typedef enum sunxi_flash_ctrl {
31 	SW_CTRL_FLASH_OFF = 0x100,
32 	SW_CTRL_FLASH_ON = 0x101,
33 	SW_CTRL_TORCH_ON = 0x102,
34 
35 	CAM_CTRL_FLASH_OFF = 0x200,
36 	CAM_CTRL_FLASH_ON = 0x201,
37 	CAM_CTRL_TORCH_ON = 0x202,
38 
39 	EXT_SYNC_FLASH_OFF = 0x300,
40 	EXT_SYNC_FLASH_ON = 0x301,
41 	EXT_SYNC_TORCH_ON = 0x302,
42 
43 } __flash_ctrl_t;
44 
45 typedef enum sunxi_flash_driver_ic_type {
46 	FLASH_RELATING,
47 	FLASH_EN_INDEPEND,
48 	FLASH_VIRTUAL,
49 	FLASH_POWER,
50 } __flash_driver_ic_type;
51 
52 typedef enum sunxi_flash_sync {
53 	NONE,
54 	LED_SINGLE,
55 	LED_CONTIN,
56 	LED_ALTERNATE,
57 	XENON_PULSE,
58 } __flash_sync_t;
59 
60 struct flash_dev_info {
61 	unsigned int dev_if;	/*0-io type 1-i2c type*/
62 	unsigned int en_pol;	/*polarity*/
63 	unsigned int fl_mode_pol;	/*polarity*/
64 
65 	unsigned int light_src;	/*0x01-LEDX1 0x02-LEDX2 0x10-XENON*/
66 	unsigned int light_temperature;	/*in K*/
67 
68 	unsigned int flash_intensity;
69 	unsigned int flash_level;	/*in lux*/
70 	unsigned int torch_intensity;
71 	unsigned int torch_level;	/*in lux*/
72 
73 	unsigned int timeout_counter;	/*in us*/
74 
75 	unsigned int status;	/*0-led_off/1-flash_on/2-torch_on/*/
76 	enum sunxi_flash_driver_ic_type flash_driver_ic;
77 	enum v4l2_flash_led_mode flash_mode;
78 	enum sunxi_flash_sync flash_sync;
79 };
80 
81 struct flash_dev {
82 	int use_cnt;
83 	struct v4l2_subdev subdev;
84 	struct platform_device *pdev;
85 	unsigned int id;
86 	struct flash_dev_info fl_info;
87 	struct v4l2_ctrl_handler handler;
88 	struct list_head flash_list;
89 };
90 
91 struct v4l2_subdev *sunxi_flash_get_subdev(int id);
92 int sunxi_flash_platform_register(void);
93 void sunxi_flash_platform_unregister(void);
94 int sunxi_flash_check_to_start(struct v4l2_subdev *sd,
95 			       enum sunxi_flash_ctrl ctrl);
96 int sunxi_flash_stop(struct v4l2_subdev *sd);
97 int io_set_flash_ctrl(struct v4l2_subdev *sd, enum sunxi_flash_ctrl ctrl);
98 
99 #endif	/* __FLASH_H__ */
100