Merge tag 'lsk-v3.10-15.04-android'
[firefly-linux-kernel-4.4.55.git] / drivers / media / video / rk_camsys / ext_flashled_drv / rtfled.h
1 /*include/linux/leds/rtfled.h
2  *Header of Richtek Flash LED Driver
3  *
4  *Copyright (C) 2013 Richtek Technology Corp.
5  *Author: Patrick Chang <patrick_chang@richtek.com>
6  *
7  *This program is free software; you can redistribute it and/or modify
8  *it under the terms of the GNU General Public License version 2 as
9  *published by the Free Software Foundation; either version 2
10  *of the License, or (at your option) any later version.
11  */
12
13 #ifndef LINUX_LEDS_RTFLED_H
14 #define LINUX_LEDS_RTFLED_H
15 #include "flashlight.h"
16
17 struct rt_fled_info;
18 typedef int (*rt_hal_fled_init) (struct rt_fled_info *info);
19 typedef int (*rt_hal_fled_suspend) (struct rt_fled_info *info,
20                                     pm_message_t state);
21 typedef int (*rt_hal_fled_resume) (struct rt_fled_info *info);
22 typedef int (*rt_hal_fled_set_mode) (struct rt_fled_info *info,
23                                      flashlight_mode_t mode);
24 typedef int (*rt_hal_fled_get_mode) (struct rt_fled_info *info);
25 typedef int (*rt_hal_fled_strobe) (struct rt_fled_info *info);
26
27 /*
28  *Return value : -EINVAL => selector parameter is out of range,
29  *otherwise current in uA
30  */
31 typedef int (*rt_hal_fled_torch_current_list) (struct rt_fled_info *info,
32                                                int selector);
33 typedef int (*rt_hal_fled_strobe_current_list) (struct rt_fled_info *info,
34                                                 int selector);
35 typedef int (*rt_hal_fled_timeout_level_list) (struct rt_fled_info *info,
36                                                int selector);
37 /*
38  *Return value : -EINVAL => selector parameter is out of range,
39  *otherwise voltage in mV
40  */
41 typedef int (*rt_hal_fled_lv_protection_list) (struct rt_fled_info *info,
42                                                int selector);
43 /*
44  *Return value : -EINVAL => selector parameter is out of range,
45  *otherwise time in ms
46  */
47 typedef int (*rt_hal_fled_strobe_timeout_list) (struct rt_fled_info *info,
48                                                 int selector);
49 typedef int (*rt_hal_fled_set_torch_current) (struct rt_fled_info *info,
50                                               int min_uA, int max_uA,
51                                               int *selector);
52 typedef int (*rt_hal_fled_set_strobe_current) (struct rt_fled_info *info,
53                                                int min_uA, int max_uA,
54                                                int *selector);
55 typedef int (*rt_hal_fled_set_timeout_level) (struct rt_fled_info *info,
56                                               int min_uA, int max_uA,
57                                               int *selector);
58 typedef int (*rt_hal_fled_set_lv_protection) (struct rt_fled_info *info,
59                                               int min_mV, int max_mV,
60                                               int *selector);
61 typedef int (*rt_hal_fled_set_strobe_timeout) (struct rt_fled_info *info,
62                                                int min_ms, int max_ms,
63                                                int *selector);
64 typedef int (*rt_hal_fled_set_torch_current_sel) (struct rt_fled_info *info,
65                                                   int selector);
66 typedef int (*rt_hal_fled_set_strobe_current_sel) (struct rt_fled_info *info,
67                                                    int selector);
68 typedef int (*rt_hal_fled_set_timeout_level_sel) (struct rt_fled_info *info,
69                                                   int selector);
70 typedef int (*rt_hal_fled_set_lv_protection_sel) (struct rt_fled_info *info,
71                                                   int selector);
72 typedef int (*rt_hal_fled_set_strobe_timeout_sel) (struct rt_fled_info *info,
73                                                    int selector);
74 typedef int (*rt_hal_fled_get_torch_current_sel) (struct rt_fled_info *info);
75 typedef int (*rt_hal_fled_get_strobe_current_sel) (struct rt_fled_info *info);
76 typedef int (*rt_hal_fled_get_timeout_level_sel) (struct rt_fled_info *info);
77 typedef int (*rt_hal_fled_get_lv_protection_sel) (struct rt_fled_info *info);
78 typedef int (*rt_hal_fled_get_strobe_timeout_sel) (struct rt_fled_info *info);
79 typedef int (*rt_hal_fled_get_torch_current) (struct rt_fled_info *info);
80 typedef int (*rt_hal_fled_get_strobe_current) (struct rt_fled_info *info);
81 typedef int (*rt_hal_fled_get_timeout_level) (struct rt_fled_info *info);
82 typedef int (*rt_hal_fled_get_lv_protection) (struct rt_fled_info *info);
83 typedef int (*rt_hal_fled_get_strobe_timeout) (struct rt_fled_info *info);
84 typedef void (*rt_hal_fled_shutdown) (struct rt_fled_info *info);
85
86 struct rt_fled_hal {
87         rt_hal_fled_init fled_init;
88         rt_hal_fled_suspend fled_suspend;
89         rt_hal_fled_resume fled_resume;
90         rt_hal_fled_set_mode fled_set_mode;
91         rt_hal_fled_get_mode fled_get_mode;
92         rt_hal_fled_strobe fled_strobe;
93         rt_hal_fled_torch_current_list fled_torch_current_list;
94         rt_hal_fled_strobe_current_list fled_strobe_current_list;
95         rt_hal_fled_timeout_level_list fled_timeout_level_list;
96         rt_hal_fled_lv_protection_list fled_lv_protection_list;
97         rt_hal_fled_strobe_timeout_list fled_strobe_timeout_list;
98         /*method to set */
99         rt_hal_fled_set_torch_current_sel fled_set_torch_current_sel;
100         rt_hal_fled_set_strobe_current_sel fled_set_strobe_current_sel;
101         rt_hal_fled_set_timeout_level_sel fled_set_timeout_level_sel;
102         rt_hal_fled_set_lv_protection_sel fled_set_lv_protection_sel;
103         rt_hal_fled_set_strobe_timeout_sel fled_set_strobe_timeout_sel;
104         /*method to set, optional */
105         rt_hal_fled_set_torch_current fled_set_torch_current;
106         rt_hal_fled_set_strobe_current fled_set_strobe_current;
107         rt_hal_fled_set_timeout_level fled_set_timeout_level;
108         rt_hal_fled_set_lv_protection fled_set_lv_protection;
109         rt_hal_fled_set_strobe_timeout fled_set_strobe_timeout;
110         /*method to get */
111         rt_hal_fled_get_torch_current_sel fled_get_torch_current_sel;
112         rt_hal_fled_get_strobe_current_sel fled_get_strobe_current_sel;
113         rt_hal_fled_get_timeout_level_sel fled_get_timeout_level_sel;
114         rt_hal_fled_get_lv_protection_sel fled_get_lv_protection_sel;
115         rt_hal_fled_get_strobe_timeout_sel fled_get_strobe_timeout_sel;
116         /*method to get, optional */
117         rt_hal_fled_get_torch_current fled_get_torch_current;
118         rt_hal_fled_get_strobe_current fled_get_strobe_current;
119         rt_hal_fled_get_timeout_level fled_get_timeout_level;
120         rt_hal_fled_get_lv_protection fled_get_lv_protection;
121         rt_hal_fled_get_strobe_timeout fled_get_strobe_timeout;
122         /*PM shutdown, optional */
123         rt_hal_fled_shutdown fled_shutdown;
124 };
125
126 typedef struct rt_fled_info {
127         struct rt_fled_hal *hal;
128         struct flashlight_device *flashlight_dev;
129         const struct flashlight_properties *init_props;
130         char *name;
131         char *chip_name;
132 } rt_fled_info_t;
133
134 /*Public funtions
135  *argument
136  *  @name : Flash LED's name;pass NULL menas "rt-flash-led"
137  */
138
139 rt_fled_info_t *rt_fled_get_info_by_name(char *name);
140
141 /*Usage :
142  *fled_info = rt_fled_get_info_by_name("FlashLED1");
143  *fled_info->hal->fled_set_strobe_current(fled_info,
144  *                                       150, 200);
145  */
146
147 #endif /*LINUX_LEDS_RTFLED_H */