diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/video/backlight/adp5520_bl.c | 123 |
1 files changed, 70 insertions, 53 deletions
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c index ad05da5ba3c7..4c10edecfb66 100644 --- a/drivers/video/backlight/adp5520_bl.c +++ b/drivers/video/backlight/adp5520_bl.c | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | struct adp5520_bl { | 16 | struct adp5520_bl { |
17 | struct device *master; | 17 | struct device *master; |
18 | struct adp5520_backlight_platfrom_data *pdata; | 18 | struct adp5520_backlight_platform_data *pdata; |
19 | struct mutex lock; | 19 | struct mutex lock; |
20 | unsigned long cached_daylight_max; | 20 | unsigned long cached_daylight_max; |
21 | int id; | 21 | int id; |
@@ -31,29 +31,30 @@ static int adp5520_bl_set(struct backlight_device *bl, int brightness) | |||
31 | if (data->pdata->en_ambl_sens) { | 31 | if (data->pdata->en_ambl_sens) { |
32 | if ((brightness > 0) && (brightness < ADP5020_MAX_BRIGHTNESS)) { | 32 | if ((brightness > 0) && (brightness < ADP5020_MAX_BRIGHTNESS)) { |
33 | /* Disable Ambient Light auto adjust */ | 33 | /* Disable Ambient Light auto adjust */ |
34 | ret |= adp5520_clr_bits(master, BL_CONTROL, | 34 | ret |= adp5520_clr_bits(master, ADP5520_BL_CONTROL, |
35 | BL_AUTO_ADJ); | 35 | ADP5520_BL_AUTO_ADJ); |
36 | ret |= adp5520_write(master, DAYLIGHT_MAX, brightness); | 36 | ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, |
37 | brightness); | ||
37 | } else { | 38 | } else { |
38 | /* | 39 | /* |
39 | * MAX_BRIGHTNESS -> Enable Ambient Light auto adjust | 40 | * MAX_BRIGHTNESS -> Enable Ambient Light auto adjust |
40 | * restore daylight l3 sysfs brightness | 41 | * restore daylight l3 sysfs brightness |
41 | */ | 42 | */ |
42 | ret |= adp5520_write(master, DAYLIGHT_MAX, | 43 | ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, |
43 | data->cached_daylight_max); | 44 | data->cached_daylight_max); |
44 | ret |= adp5520_set_bits(master, BL_CONTROL, | 45 | ret |= adp5520_set_bits(master, ADP5520_BL_CONTROL, |
45 | BL_AUTO_ADJ); | 46 | ADP5520_BL_AUTO_ADJ); |
46 | } | 47 | } |
47 | } else { | 48 | } else { |
48 | ret |= adp5520_write(master, DAYLIGHT_MAX, brightness); | 49 | ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, brightness); |
49 | } | 50 | } |
50 | 51 | ||
51 | if (data->current_brightness && brightness == 0) | 52 | if (data->current_brightness && brightness == 0) |
52 | ret |= adp5520_set_bits(master, | 53 | ret |= adp5520_set_bits(master, |
53 | MODE_STATUS, DIM_EN); | 54 | ADP5520_MODE_STATUS, ADP5520_DIM_EN); |
54 | else if (data->current_brightness == 0 && brightness) | 55 | else if (data->current_brightness == 0 && brightness) |
55 | ret |= adp5520_clr_bits(master, | 56 | ret |= adp5520_clr_bits(master, |
56 | MODE_STATUS, DIM_EN); | 57 | ADP5520_MODE_STATUS, ADP5520_DIM_EN); |
57 | 58 | ||
58 | if (!ret) | 59 | if (!ret) |
59 | data->current_brightness = brightness; | 60 | data->current_brightness = brightness; |
@@ -79,7 +80,7 @@ static int adp5520_bl_get_brightness(struct backlight_device *bl) | |||
79 | int error; | 80 | int error; |
80 | uint8_t reg_val; | 81 | uint8_t reg_val; |
81 | 82 | ||
82 | error = adp5520_read(data->master, BL_VALUE, ®_val); | 83 | error = adp5520_read(data->master, ADP5520_BL_VALUE, ®_val); |
83 | 84 | ||
84 | return error ? data->current_brightness : reg_val; | 85 | return error ? data->current_brightness : reg_val; |
85 | } | 86 | } |
@@ -93,33 +94,46 @@ static int adp5520_bl_setup(struct backlight_device *bl) | |||
93 | { | 94 | { |
94 | struct adp5520_bl *data = bl_get_data(bl); | 95 | struct adp5520_bl *data = bl_get_data(bl); |
95 | struct device *master = data->master; | 96 | struct device *master = data->master; |
96 | struct adp5520_backlight_platfrom_data *pdata = data->pdata; | 97 | struct adp5520_backlight_platform_data *pdata = data->pdata; |
97 | int ret = 0; | 98 | int ret = 0; |
98 | 99 | ||
99 | ret |= adp5520_write(master, DAYLIGHT_MAX, pdata->l1_daylight_max); | 100 | ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, |
100 | ret |= adp5520_write(master, DAYLIGHT_DIM, pdata->l1_daylight_dim); | 101 | pdata->l1_daylight_max); |
102 | ret |= adp5520_write(master, ADP5520_DAYLIGHT_DIM, | ||
103 | pdata->l1_daylight_dim); | ||
101 | 104 | ||
102 | if (pdata->en_ambl_sens) { | 105 | if (pdata->en_ambl_sens) { |
103 | data->cached_daylight_max = pdata->l1_daylight_max; | 106 | data->cached_daylight_max = pdata->l1_daylight_max; |
104 | ret |= adp5520_write(master, OFFICE_MAX, pdata->l2_office_max); | 107 | ret |= adp5520_write(master, ADP5520_OFFICE_MAX, |
105 | ret |= adp5520_write(master, OFFICE_DIM, pdata->l2_office_dim); | 108 | pdata->l2_office_max); |
106 | ret |= adp5520_write(master, DARK_MAX, pdata->l3_dark_max); | 109 | ret |= adp5520_write(master, ADP5520_OFFICE_DIM, |
107 | ret |= adp5520_write(master, DARK_DIM, pdata->l3_dark_dim); | 110 | pdata->l2_office_dim); |
108 | ret |= adp5520_write(master, L2_TRIP, pdata->l2_trip); | 111 | ret |= adp5520_write(master, ADP5520_DARK_MAX, |
109 | ret |= adp5520_write(master, L2_HYS, pdata->l2_hyst); | 112 | pdata->l3_dark_max); |
110 | ret |= adp5520_write(master, L3_TRIP, pdata->l3_trip); | 113 | ret |= adp5520_write(master, ADP5520_DARK_DIM, |
111 | ret |= adp5520_write(master, L3_HYS, pdata->l3_hyst); | 114 | pdata->l3_dark_dim); |
112 | ret |= adp5520_write(master, ALS_CMPR_CFG, | 115 | ret |= adp5520_write(master, ADP5520_L2_TRIP, |
113 | ALS_CMPR_CFG_VAL(pdata->abml_filt, L3_EN)); | 116 | pdata->l2_trip); |
117 | ret |= adp5520_write(master, ADP5520_L2_HYS, | ||
118 | pdata->l2_hyst); | ||
119 | ret |= adp5520_write(master, ADP5520_L3_TRIP, | ||
120 | pdata->l3_trip); | ||
121 | ret |= adp5520_write(master, ADP5520_L3_HYS, | ||
122 | pdata->l3_hyst); | ||
123 | ret |= adp5520_write(master, ADP5520_ALS_CMPR_CFG, | ||
124 | ALS_CMPR_CFG_VAL(pdata->abml_filt, | ||
125 | ADP5520_L3_EN)); | ||
114 | } | 126 | } |
115 | 127 | ||
116 | ret |= adp5520_write(master, BL_CONTROL, | 128 | ret |= adp5520_write(master, ADP5520_BL_CONTROL, |
117 | BL_CTRL_VAL(pdata->fade_led_law, pdata->en_ambl_sens)); | 129 | BL_CTRL_VAL(pdata->fade_led_law, |
130 | pdata->en_ambl_sens)); | ||
118 | 131 | ||
119 | ret |= adp5520_write(master, BL_FADE, FADE_VAL(pdata->fade_in, | 132 | ret |= adp5520_write(master, ADP5520_BL_FADE, FADE_VAL(pdata->fade_in, |
120 | pdata->fade_out)); | 133 | pdata->fade_out)); |
121 | 134 | ||
122 | ret |= adp5520_set_bits(master, MODE_STATUS, BL_EN | DIM_EN); | 135 | ret |= adp5520_set_bits(master, ADP5520_MODE_STATUS, |
136 | ADP5520_BL_EN | ADP5520_DIM_EN); | ||
123 | 137 | ||
124 | return ret; | 138 | return ret; |
125 | } | 139 | } |
@@ -156,29 +170,31 @@ static ssize_t adp5520_store(struct device *dev, const char *buf, | |||
156 | } | 170 | } |
157 | 171 | ||
158 | static ssize_t adp5520_bl_dark_max_show(struct device *dev, | 172 | static ssize_t adp5520_bl_dark_max_show(struct device *dev, |
159 | struct device_attribute *attr, char *buf) | 173 | struct device_attribute *attr, char *buf) |
160 | { | 174 | { |
161 | return adp5520_show(dev, buf, DARK_MAX); | 175 | return adp5520_show(dev, buf, ADP5520_DARK_MAX); |
162 | } | 176 | } |
163 | 177 | ||
164 | static ssize_t adp5520_bl_dark_max_store(struct device *dev, | 178 | static ssize_t adp5520_bl_dark_max_store(struct device *dev, |
165 | struct device_attribute *attr, const char *buf, size_t count) | 179 | struct device_attribute *attr, |
180 | const char *buf, size_t count) | ||
166 | { | 181 | { |
167 | return adp5520_store(dev, buf, count, DARK_MAX); | 182 | return adp5520_store(dev, buf, count, ADP5520_DARK_MAX); |
168 | } | 183 | } |
169 | static DEVICE_ATTR(dark_max, 0664, adp5520_bl_dark_max_show, | 184 | static DEVICE_ATTR(dark_max, 0664, adp5520_bl_dark_max_show, |
170 | adp5520_bl_dark_max_store); | 185 | adp5520_bl_dark_max_store); |
171 | 186 | ||
172 | static ssize_t adp5520_bl_office_max_show(struct device *dev, | 187 | static ssize_t adp5520_bl_office_max_show(struct device *dev, |
173 | struct device_attribute *attr, char *buf) | 188 | struct device_attribute *attr, char *buf) |
174 | { | 189 | { |
175 | return adp5520_show(dev, buf, OFFICE_MAX); | 190 | return adp5520_show(dev, buf, ADP5520_OFFICE_MAX); |
176 | } | 191 | } |
177 | 192 | ||
178 | static ssize_t adp5520_bl_office_max_store(struct device *dev, | 193 | static ssize_t adp5520_bl_office_max_store(struct device *dev, |
179 | struct device_attribute *attr, const char *buf, size_t count) | 194 | struct device_attribute *attr, |
195 | const char *buf, size_t count) | ||
180 | { | 196 | { |
181 | return adp5520_store(dev, buf, count, OFFICE_MAX); | 197 | return adp5520_store(dev, buf, count, ADP5520_OFFICE_MAX); |
182 | } | 198 | } |
183 | static DEVICE_ATTR(office_max, 0664, adp5520_bl_office_max_show, | 199 | static DEVICE_ATTR(office_max, 0664, adp5520_bl_office_max_show, |
184 | adp5520_bl_office_max_store); | 200 | adp5520_bl_office_max_store); |
@@ -186,16 +202,17 @@ static DEVICE_ATTR(office_max, 0664, adp5520_bl_office_max_show, | |||
186 | static ssize_t adp5520_bl_daylight_max_show(struct device *dev, | 202 | static ssize_t adp5520_bl_daylight_max_show(struct device *dev, |
187 | struct device_attribute *attr, char *buf) | 203 | struct device_attribute *attr, char *buf) |
188 | { | 204 | { |
189 | return adp5520_show(dev, buf, DAYLIGHT_MAX); | 205 | return adp5520_show(dev, buf, ADP5520_DAYLIGHT_MAX); |
190 | } | 206 | } |
191 | 207 | ||
192 | static ssize_t adp5520_bl_daylight_max_store(struct device *dev, | 208 | static ssize_t adp5520_bl_daylight_max_store(struct device *dev, |
193 | struct device_attribute *attr, const char *buf, size_t count) | 209 | struct device_attribute *attr, |
210 | const char *buf, size_t count) | ||
194 | { | 211 | { |
195 | struct adp5520_bl *data = dev_get_drvdata(dev); | 212 | struct adp5520_bl *data = dev_get_drvdata(dev); |
196 | 213 | ||
197 | strict_strtoul(buf, 10, &data->cached_daylight_max); | 214 | strict_strtoul(buf, 10, &data->cached_daylight_max); |
198 | return adp5520_store(dev, buf, count, DAYLIGHT_MAX); | 215 | return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_MAX); |
199 | } | 216 | } |
200 | static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show, | 217 | static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show, |
201 | adp5520_bl_daylight_max_store); | 218 | adp5520_bl_daylight_max_store); |
@@ -203,14 +220,14 @@ static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show, | |||
203 | static ssize_t adp5520_bl_dark_dim_show(struct device *dev, | 220 | static ssize_t adp5520_bl_dark_dim_show(struct device *dev, |
204 | struct device_attribute *attr, char *buf) | 221 | struct device_attribute *attr, char *buf) |
205 | { | 222 | { |
206 | return adp5520_show(dev, buf, DARK_DIM); | 223 | return adp5520_show(dev, buf, ADP5520_DARK_DIM); |
207 | } | 224 | } |
208 | 225 | ||
209 | static ssize_t adp5520_bl_dark_dim_store(struct device *dev, | 226 | static ssize_t adp5520_bl_dark_dim_store(struct device *dev, |
210 | struct device_attribute *attr, | 227 | struct device_attribute *attr, |
211 | const char *buf, size_t count) | 228 | const char *buf, size_t count) |
212 | { | 229 | { |
213 | return adp5520_store(dev, buf, count, DARK_DIM); | 230 | return adp5520_store(dev, buf, count, ADP5520_DARK_DIM); |
214 | } | 231 | } |
215 | static DEVICE_ATTR(dark_dim, 0664, adp5520_bl_dark_dim_show, | 232 | static DEVICE_ATTR(dark_dim, 0664, adp5520_bl_dark_dim_show, |
216 | adp5520_bl_dark_dim_store); | 233 | adp5520_bl_dark_dim_store); |
@@ -218,29 +235,29 @@ static DEVICE_ATTR(dark_dim, 0664, adp5520_bl_dark_dim_show, | |||
218 | static ssize_t adp5520_bl_office_dim_show(struct device *dev, | 235 | static ssize_t adp5520_bl_office_dim_show(struct device *dev, |
219 | struct device_attribute *attr, char *buf) | 236 | struct device_attribute *attr, char *buf) |
220 | { | 237 | { |
221 | return adp5520_show(dev, buf, OFFICE_DIM); | 238 | return adp5520_show(dev, buf, ADP5520_OFFICE_DIM); |
222 | } | 239 | } |
223 | 240 | ||
224 | static ssize_t adp5520_bl_office_dim_store(struct device *dev, | 241 | static ssize_t adp5520_bl_office_dim_store(struct device *dev, |
225 | struct device_attribute *attr, | 242 | struct device_attribute *attr, |
226 | const char *buf, size_t count) | 243 | const char *buf, size_t count) |
227 | { | 244 | { |
228 | return adp5520_store(dev, buf, count, OFFICE_DIM); | 245 | return adp5520_store(dev, buf, count, ADP5520_OFFICE_DIM); |
229 | } | 246 | } |
230 | static DEVICE_ATTR(office_dim, 0664, adp5520_bl_office_dim_show, | 247 | static DEVICE_ATTR(office_dim, 0664, adp5520_bl_office_dim_show, |
231 | adp5520_bl_office_dim_store); | 248 | adp5520_bl_office_dim_store); |
232 | 249 | ||
233 | static ssize_t adp5520_bl_daylight_dim_show(struct device *dev, | 250 | static ssize_t adp5520_bl_daylight_dim_show(struct device *dev, |
234 | struct device_attribute *attr, char *buf) | 251 | struct device_attribute *attr, char *buf) |
235 | { | 252 | { |
236 | return adp5520_show(dev, buf, DAYLIGHT_DIM); | 253 | return adp5520_show(dev, buf, ADP5520_DAYLIGHT_DIM); |
237 | } | 254 | } |
238 | 255 | ||
239 | static ssize_t adp5520_bl_daylight_dim_store(struct device *dev, | 256 | static ssize_t adp5520_bl_daylight_dim_store(struct device *dev, |
240 | struct device_attribute *attr, | 257 | struct device_attribute *attr, |
241 | const char *buf, size_t count) | 258 | const char *buf, size_t count) |
242 | { | 259 | { |
243 | return adp5520_store(dev, buf, count, DAYLIGHT_DIM); | 260 | return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_DIM); |
244 | } | 261 | } |
245 | static DEVICE_ATTR(daylight_dim, 0664, adp5520_bl_daylight_dim_show, | 262 | static DEVICE_ATTR(daylight_dim, 0664, adp5520_bl_daylight_dim_show, |
246 | adp5520_bl_daylight_dim_store); | 263 | adp5520_bl_daylight_dim_store); |
@@ -316,7 +333,7 @@ static int __devexit adp5520_bl_remove(struct platform_device *pdev) | |||
316 | struct backlight_device *bl = platform_get_drvdata(pdev); | 333 | struct backlight_device *bl = platform_get_drvdata(pdev); |
317 | struct adp5520_bl *data = bl_get_data(bl); | 334 | struct adp5520_bl *data = bl_get_data(bl); |
318 | 335 | ||
319 | adp5520_clr_bits(data->master, MODE_STATUS, BL_EN); | 336 | adp5520_clr_bits(data->master, ADP5520_MODE_STATUS, ADP5520_BL_EN); |
320 | 337 | ||
321 | if (data->pdata->en_ambl_sens) | 338 | if (data->pdata->en_ambl_sens) |
322 | sysfs_remove_group(&bl->dev.kobj, | 339 | sysfs_remove_group(&bl->dev.kobj, |