Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 1 | /* |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 2 | * Copyright (C) 2014, 2017 The Linux Foundation. All rights reserved. |
| 3 | * Not a contribution |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 4 | * Copyright (C) 2008 The Android Open Source Project |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | |
| 20 | // #define LOG_NDEBUG 0 |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 21 | |
| 22 | #include <cutils/log.h> |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 23 | #include <cutils/properties.h> |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 24 | #include <stdint.h> |
Arun Kumar K.R | 6203161 | 2015-07-30 11:38:19 -0700 | [diff] [blame] | 25 | #include <stdlib.h> |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 26 | #include <string.h> |
| 27 | #include <unistd.h> |
| 28 | #include <errno.h> |
| 29 | #include <fcntl.h> |
| 30 | #include <pthread.h> |
| 31 | |
| 32 | #include <sys/ioctl.h> |
| 33 | #include <sys/types.h> |
| 34 | |
| 35 | #include <hardware/lights.h> |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 36 | #include "lights_prv.h" |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 37 | |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 38 | #ifndef DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS |
| 39 | #define DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS 0x80 |
| 40 | #endif |
| 41 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 42 | /******************************************************************************/ |
| 43 | |
| 44 | static pthread_once_t g_init = PTHREAD_ONCE_INIT; |
| 45 | static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; |
| 46 | static struct light_state_t g_notification; |
| 47 | static struct light_state_t g_battery; |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 48 | static int g_last_backlight_mode = BRIGHTNESS_MODE_USER; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 49 | static int g_attention = 0; |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 50 | static int g_brightness_max = 0; |
Pullakavi Srinivas | da0b325 | 2017-10-12 17:50:41 +0530 | [diff] [blame^] | 51 | static bool g_has_persistence_node = false; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 52 | |
| 53 | char const*const RED_LED_FILE |
| 54 | = "/sys/class/leds/red/brightness"; |
| 55 | |
| 56 | char const*const GREEN_LED_FILE |
| 57 | = "/sys/class/leds/green/brightness"; |
| 58 | |
| 59 | char const*const BLUE_LED_FILE |
| 60 | = "/sys/class/leds/blue/brightness"; |
| 61 | |
| 62 | char const*const LCD_FILE |
| 63 | = "/sys/class/leds/lcd-backlight/brightness"; |
| 64 | |
Saurabh Shah | 8b021cf | 2017-03-14 12:16:43 -0700 | [diff] [blame] | 65 | char const*const LCD_FILE2 |
| 66 | = "/sys/class/backlight/panel0-backlight/brightness"; |
| 67 | |
HuiWang | f73bc57 | 2013-07-31 10:48:36 +0800 | [diff] [blame] | 68 | char const*const BUTTON_FILE |
| 69 | = "/sys/class/leds/button-backlight/brightness"; |
| 70 | |
samin.ryu | d57c7d5 | 2012-08-03 23:59:41 +0900 | [diff] [blame] | 71 | char const*const RED_BLINK_FILE |
Yulian Shandorov | 784d739 | 2013-06-20 04:28:59 -0700 | [diff] [blame] | 72 | = "/sys/class/leds/red/blink"; |
samin.ryu | d57c7d5 | 2012-08-03 23:59:41 +0900 | [diff] [blame] | 73 | |
Ameya Thakur | 192c8ac | 2013-08-12 16:50:01 -0700 | [diff] [blame] | 74 | char const*const GREEN_BLINK_FILE |
| 75 | = "/sys/class/leds/green/blink"; |
| 76 | |
| 77 | char const*const BLUE_BLINK_FILE |
| 78 | = "/sys/class/leds/blue/blink"; |
| 79 | |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 80 | char const*const PERSISTENCE_FILE |
| 81 | = "/sys/class/graphics/fb0/msm_fb_persist_mode"; |
| 82 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 83 | /** |
| 84 | * device methods |
| 85 | */ |
| 86 | |
| 87 | void init_globals(void) |
| 88 | { |
| 89 | // init the mutex |
| 90 | pthread_mutex_init(&g_lock, NULL); |
| 91 | } |
| 92 | |
| 93 | static int |
| 94 | write_int(char const* path, int value) |
| 95 | { |
| 96 | int fd; |
| 97 | static int already_warned = 0; |
| 98 | |
| 99 | fd = open(path, O_RDWR); |
| 100 | if (fd >= 0) { |
| 101 | char buffer[20]; |
Manoj Kumar AVM | 001b309 | 2014-04-29 22:08:51 -0700 | [diff] [blame] | 102 | int bytes = snprintf(buffer, sizeof(buffer), "%d\n", value); |
Dileep Kumar Reddi | bf333c7 | 2014-02-25 14:32:51 +0530 | [diff] [blame] | 103 | ssize_t amt = write(fd, buffer, (size_t)bytes); |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 104 | close(fd); |
| 105 | return amt == -1 ? -errno : 0; |
| 106 | } else { |
| 107 | if (already_warned == 0) { |
| 108 | ALOGE("write_int failed to open %s\n", path); |
| 109 | already_warned = 1; |
| 110 | } |
| 111 | return -errno; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | static int |
| 116 | is_lit(struct light_state_t const* state) |
| 117 | { |
| 118 | return state->color & 0x00ffffff; |
| 119 | } |
| 120 | |
| 121 | static int |
| 122 | rgb_to_brightness(struct light_state_t const* state) |
| 123 | { |
| 124 | int color = state->color & 0x00ffffff; |
| 125 | return ((77*((color>>16)&0x00ff)) |
| 126 | + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8; |
| 127 | } |
| 128 | |
| 129 | static int |
| 130 | set_light_backlight(struct light_device_t* dev, |
| 131 | struct light_state_t const* state) |
| 132 | { |
| 133 | int err = 0; |
| 134 | int brightness = rgb_to_brightness(state); |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 135 | unsigned int lpEnabled = |
| 136 | state->brightnessMode == BRIGHTNESS_MODE_LOW_PERSISTENCE; |
Arun Kumar K.R | 0efad60 | 2014-01-21 21:32:36 -0800 | [diff] [blame] | 137 | if(!dev) { |
| 138 | return -1; |
| 139 | } |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 140 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 141 | pthread_mutex_lock(&g_lock); |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 142 | // Toggle low persistence mode state |
Pullakavi Srinivas | da0b325 | 2017-10-12 17:50:41 +0530 | [diff] [blame^] | 143 | bool persistence_mode = ((g_last_backlight_mode != state->brightnessMode && lpEnabled) || |
| 144 | (!lpEnabled && |
| 145 | g_last_backlight_mode == BRIGHTNESS_MODE_LOW_PERSISTENCE)); |
| 146 | bool cannot_handle_persistence = !g_has_persistence_node && persistence_mode; |
| 147 | if (g_has_persistence_node) { |
| 148 | if (persistence_mode) { |
| 149 | if ((err = write_int(PERSISTENCE_FILE, lpEnabled)) != 0) { |
| 150 | ALOGE("%s: Failed to write to %s: %s\n", __FUNCTION__, |
| 151 | PERSISTENCE_FILE, strerror(errno)); |
| 152 | } |
| 153 | if (lpEnabled != 0) { |
| 154 | brightness = DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS; |
| 155 | } |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 156 | } |
Pullakavi Srinivas | da0b325 | 2017-10-12 17:50:41 +0530 | [diff] [blame^] | 157 | g_last_backlight_mode = state->brightnessMode; |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 158 | } |
| 159 | |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 160 | if (!err) { |
Saurabh Shah | 8b021cf | 2017-03-14 12:16:43 -0700 | [diff] [blame] | 161 | if (!access(LCD_FILE, F_OK)) { |
| 162 | err = write_int(LCD_FILE, brightness); |
| 163 | } else { |
| 164 | err = write_int(LCD_FILE2, brightness); |
| 165 | } |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 166 | } |
| 167 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 168 | pthread_mutex_unlock(&g_lock); |
Pullakavi Srinivas | da0b325 | 2017-10-12 17:50:41 +0530 | [diff] [blame^] | 169 | return cannot_handle_persistence ? -ENOSYS : err; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | static int |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 173 | set_light_backlight_ext(struct light_device_t* dev, |
| 174 | struct light_state_t const* state) |
| 175 | { |
| 176 | int err = 0; |
| 177 | |
| 178 | if(!dev) { |
| 179 | return -1; |
| 180 | } |
| 181 | |
| 182 | int brightness = state->color & 0x00ffffff; |
| 183 | pthread_mutex_lock(&g_lock); |
| 184 | |
| 185 | if (brightness >= 0 && brightness <= g_brightness_max) { |
| 186 | set_brightness_ext_level(brightness); |
| 187 | } |
| 188 | |
| 189 | pthread_mutex_unlock(&g_lock); |
| 190 | |
| 191 | return err; |
| 192 | } |
| 193 | |
| 194 | static int |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 195 | set_speaker_light_locked(struct light_device_t* dev, |
| 196 | struct light_state_t const* state) |
| 197 | { |
Arun Kumar K.R | 0efad60 | 2014-01-21 21:32:36 -0800 | [diff] [blame] | 198 | int red, green, blue; |
Yulian Shandorov | 784d739 | 2013-06-20 04:28:59 -0700 | [diff] [blame] | 199 | int blink; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 200 | int onMS, offMS; |
| 201 | unsigned int colorRGB; |
| 202 | |
Arun Kumar K.R | 0efad60 | 2014-01-21 21:32:36 -0800 | [diff] [blame] | 203 | if(!dev) { |
| 204 | return -1; |
| 205 | } |
| 206 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 207 | switch (state->flashMode) { |
| 208 | case LIGHT_FLASH_TIMED: |
| 209 | onMS = state->flashOnMS; |
| 210 | offMS = state->flashOffMS; |
| 211 | break; |
| 212 | case LIGHT_FLASH_NONE: |
| 213 | default: |
| 214 | onMS = 0; |
| 215 | offMS = 0; |
| 216 | break; |
| 217 | } |
| 218 | |
| 219 | colorRGB = state->color; |
| 220 | |
| 221 | #if 0 |
samin.ryu | d57c7d5 | 2012-08-03 23:59:41 +0900 | [diff] [blame] | 222 | ALOGD("set_speaker_light_locked mode %d, colorRGB=%08X, onMS=%d, offMS=%d\n", |
| 223 | state->flashMode, colorRGB, onMS, offMS); |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 224 | #endif |
| 225 | |
| 226 | red = (colorRGB >> 16) & 0xFF; |
| 227 | green = (colorRGB >> 8) & 0xFF; |
| 228 | blue = colorRGB & 0xFF; |
| 229 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 230 | if (onMS > 0 && offMS > 0) { |
Ashay Jaiswal | 26f0b53 | 2015-05-03 17:58:58 +0530 | [diff] [blame] | 231 | /* |
| 232 | * if ON time == OFF time |
| 233 | * use blink mode 2 |
| 234 | * else |
| 235 | * use blink mode 1 |
| 236 | */ |
| 237 | if (onMS == offMS) |
| 238 | blink = 2; |
| 239 | else |
| 240 | blink = 1; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 241 | } else { |
| 242 | blink = 0; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | if (blink) { |
Mao Li | 728ee0b | 2014-07-01 23:06:16 +0800 | [diff] [blame] | 246 | if (red) { |
| 247 | if (write_int(RED_BLINK_FILE, blink)) |
| 248 | write_int(RED_LED_FILE, 0); |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 249 | } |
Mao Li | 728ee0b | 2014-07-01 23:06:16 +0800 | [diff] [blame] | 250 | if (green) { |
| 251 | if (write_int(GREEN_BLINK_FILE, blink)) |
| 252 | write_int(GREEN_LED_FILE, 0); |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 253 | } |
Mao Li | 728ee0b | 2014-07-01 23:06:16 +0800 | [diff] [blame] | 254 | if (blue) { |
| 255 | if (write_int(BLUE_BLINK_FILE, blink)) |
| 256 | write_int(BLUE_LED_FILE, 0); |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 257 | } |
Yulian Shandorov | 784d739 | 2013-06-20 04:28:59 -0700 | [diff] [blame] | 258 | } else { |
| 259 | write_int(RED_LED_FILE, red); |
| 260 | write_int(GREEN_LED_FILE, green); |
| 261 | write_int(BLUE_LED_FILE, blue); |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 262 | } |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 263 | |
| 264 | return 0; |
| 265 | } |
| 266 | |
| 267 | static void |
| 268 | handle_speaker_battery_locked(struct light_device_t* dev) |
| 269 | { |
| 270 | if (is_lit(&g_battery)) { |
| 271 | set_speaker_light_locked(dev, &g_battery); |
| 272 | } else { |
| 273 | set_speaker_light_locked(dev, &g_notification); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | static int |
Mao Li | a4e053a | 2014-06-16 23:05:17 +0530 | [diff] [blame] | 278 | set_light_battery(struct light_device_t* dev, |
| 279 | struct light_state_t const* state) |
| 280 | { |
| 281 | pthread_mutex_lock(&g_lock); |
| 282 | g_battery = *state; |
| 283 | handle_speaker_battery_locked(dev); |
| 284 | pthread_mutex_unlock(&g_lock); |
| 285 | return 0; |
| 286 | } |
| 287 | |
| 288 | static int |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 289 | set_light_notifications(struct light_device_t* dev, |
| 290 | struct light_state_t const* state) |
| 291 | { |
| 292 | pthread_mutex_lock(&g_lock); |
| 293 | g_notification = *state; |
| 294 | handle_speaker_battery_locked(dev); |
| 295 | pthread_mutex_unlock(&g_lock); |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | static int |
| 300 | set_light_attention(struct light_device_t* dev, |
| 301 | struct light_state_t const* state) |
| 302 | { |
| 303 | pthread_mutex_lock(&g_lock); |
| 304 | if (state->flashMode == LIGHT_FLASH_HARDWARE) { |
| 305 | g_attention = state->flashOnMS; |
| 306 | } else if (state->flashMode == LIGHT_FLASH_NONE) { |
| 307 | g_attention = 0; |
| 308 | } |
| 309 | handle_speaker_battery_locked(dev); |
| 310 | pthread_mutex_unlock(&g_lock); |
| 311 | return 0; |
| 312 | } |
| 313 | |
Arun Kumar K.R | edd9998 | 2017-08-23 08:09:06 +0530 | [diff] [blame] | 314 | static int |
| 315 | set_light_buttons(struct light_device_t* dev, |
| 316 | struct light_state_t const* state) |
| 317 | { |
| 318 | int err = 0; |
| 319 | if(!dev) { |
| 320 | return -1; |
| 321 | } |
| 322 | pthread_mutex_lock(&g_lock); |
| 323 | err = write_int(BUTTON_FILE, state->color & 0xFF); |
| 324 | pthread_mutex_unlock(&g_lock); |
| 325 | return err; |
| 326 | } |
| 327 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 328 | /** Close the lights device */ |
| 329 | static int |
| 330 | close_lights(struct light_device_t *dev) |
| 331 | { |
| 332 | if (dev) { |
| 333 | free(dev); |
| 334 | } |
| 335 | return 0; |
| 336 | } |
| 337 | |
| 338 | |
| 339 | /******************************************************************************/ |
| 340 | |
| 341 | /** |
| 342 | * module methods |
| 343 | */ |
| 344 | |
| 345 | /** Open a new instance of a lights device using name */ |
| 346 | static int open_lights(const struct hw_module_t* module, char const* name, |
| 347 | struct hw_device_t** device) |
| 348 | { |
| 349 | int (*set_light)(struct light_device_t* dev, |
| 350 | struct light_state_t const* state); |
| 351 | |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 352 | if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) { |
| 353 | char property[PROPERTY_VALUE_MAX]; |
| 354 | property_get("persist.extend.brightness", property, "0"); |
| 355 | |
| 356 | if(!(strncmp(property, "1", PROPERTY_VALUE_MAX)) || |
| 357 | !(strncmp(property, "true", PROPERTY_VALUE_MAX))) { |
| 358 | property_get("persist.display.max_brightness", property, "255"); |
| 359 | g_brightness_max = atoi(property); |
| 360 | set_brightness_ext_init(); |
| 361 | set_light = set_light_backlight_ext; |
Pullakavi Srinivas | da0b325 | 2017-10-12 17:50:41 +0530 | [diff] [blame^] | 362 | } else { |
| 363 | g_has_persistence_node = !access(PERSISTENCE_FILE, F_OK); |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 364 | set_light = set_light_backlight; |
Pullakavi Srinivas | da0b325 | 2017-10-12 17:50:41 +0530 | [diff] [blame^] | 365 | } |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 366 | } else if (0 == strcmp(LIGHT_ID_BATTERY, name)) |
Mao Li | a4e053a | 2014-06-16 23:05:17 +0530 | [diff] [blame] | 367 | set_light = set_light_battery; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 368 | else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) |
| 369 | set_light = set_light_notifications; |
Arun Kumar K.R | 9ae5a34 | 2017-08-23 13:46:03 +0530 | [diff] [blame] | 370 | else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) { |
| 371 | if (!access(BUTTON_FILE, F_OK)) { |
| 372 | // enable light button when the file is present |
| 373 | set_light = set_light_buttons; |
| 374 | } else { |
| 375 | return -EINVAL; |
| 376 | } |
| 377 | } |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 378 | else if (0 == strcmp(LIGHT_ID_ATTENTION, name)) |
| 379 | set_light = set_light_attention; |
| 380 | else |
| 381 | return -EINVAL; |
| 382 | |
| 383 | pthread_once(&g_init, init_globals); |
| 384 | |
| 385 | struct light_device_t *dev = malloc(sizeof(struct light_device_t)); |
Manoj Kumar AVM | 001b309 | 2014-04-29 22:08:51 -0700 | [diff] [blame] | 386 | |
| 387 | if(!dev) |
| 388 | return -ENOMEM; |
| 389 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 390 | memset(dev, 0, sizeof(*dev)); |
| 391 | |
| 392 | dev->common.tag = HARDWARE_DEVICE_TAG; |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 393 | dev->common.version = LIGHTS_DEVICE_API_VERSION_2_0; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 394 | dev->common.module = (struct hw_module_t*)module; |
| 395 | dev->common.close = (int (*)(struct hw_device_t*))close_lights; |
| 396 | dev->set_light = set_light; |
| 397 | |
| 398 | *device = (struct hw_device_t*)dev; |
| 399 | return 0; |
| 400 | } |
| 401 | |
| 402 | static struct hw_module_methods_t lights_module_methods = { |
| 403 | .open = open_lights, |
| 404 | }; |
| 405 | |
| 406 | /* |
| 407 | * The lights Module |
| 408 | */ |
| 409 | struct hw_module_t HAL_MODULE_INFO_SYM = { |
| 410 | .tag = HARDWARE_MODULE_TAG, |
| 411 | .version_major = 1, |
| 412 | .version_minor = 0, |
| 413 | .id = LIGHTS_HARDWARE_MODULE_ID, |
| 414 | .name = "lights Module", |
| 415 | .author = "Google, Inc.", |
| 416 | .methods = &lights_module_methods, |
| 417 | }; |