Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 1 | /* |
Fenglin Wu | 862b56b | 2018-02-02 10:20:28 +0800 | [diff] [blame] | 2 | * Copyright (C) 2014, 2017-2018 The Linux Foundation. All rights reserved. |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 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 | |
Naseer Ahmed | fcad05e | 2018-03-06 20:41:14 -0500 | [diff] [blame] | 22 | #include <log/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> |
| 36 | |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 37 | #ifndef DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS |
| 38 | #define DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS 0x80 |
| 39 | #endif |
| 40 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 41 | /******************************************************************************/ |
| 42 | |
| 43 | static pthread_once_t g_init = PTHREAD_ONCE_INIT; |
| 44 | static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; |
| 45 | static struct light_state_t g_notification; |
| 46 | static struct light_state_t g_battery; |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 47 | static int g_last_backlight_mode = BRIGHTNESS_MODE_USER; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 48 | static int g_attention = 0; |
Pullakavi Srinivas | da0b325 | 2017-10-12 17:50:41 +0530 | [diff] [blame] | 49 | static bool g_has_persistence_node = false; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 50 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 51 | char const*const LCD_FILE |
| 52 | = "/sys/class/leds/lcd-backlight/brightness"; |
| 53 | |
Saurabh Shah | 8b021cf | 2017-03-14 12:16:43 -0700 | [diff] [blame] | 54 | char const*const LCD_FILE2 |
| 55 | = "/sys/class/backlight/panel0-backlight/brightness"; |
| 56 | |
HuiWang | f73bc57 | 2013-07-31 10:48:36 +0800 | [diff] [blame] | 57 | char const*const BUTTON_FILE |
| 58 | = "/sys/class/leds/button-backlight/brightness"; |
| 59 | |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 60 | char const*const PERSISTENCE_FILE |
| 61 | = "/sys/class/graphics/fb0/msm_fb_persist_mode"; |
| 62 | |
Fenglin Wu | 862b56b | 2018-02-02 10:20:28 +0800 | [diff] [blame] | 63 | enum rgb_led { |
| 64 | LED_RED = 0, |
| 65 | LED_GREEN, |
| 66 | LED_BLUE, |
| 67 | }; |
| 68 | |
| 69 | char *led_names[] = { |
| 70 | "red", |
| 71 | "green", |
| 72 | "blue", |
| 73 | }; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 74 | /** |
| 75 | * device methods |
| 76 | */ |
| 77 | |
| 78 | void init_globals(void) |
| 79 | { |
| 80 | // init the mutex |
| 81 | pthread_mutex_init(&g_lock, NULL); |
| 82 | } |
| 83 | |
Fenglin Wu | 862b56b | 2018-02-02 10:20:28 +0800 | [diff] [blame] | 84 | static int write_int(char const* path, int value) |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 85 | { |
| 86 | int fd; |
| 87 | static int already_warned = 0; |
| 88 | |
| 89 | fd = open(path, O_RDWR); |
| 90 | if (fd >= 0) { |
| 91 | char buffer[20]; |
Manoj Kumar AVM | 001b309 | 2014-04-29 22:08:51 -0700 | [diff] [blame] | 92 | int bytes = snprintf(buffer, sizeof(buffer), "%d\n", value); |
Dileep Kumar Reddi | bf333c7 | 2014-02-25 14:32:51 +0530 | [diff] [blame] | 93 | ssize_t amt = write(fd, buffer, (size_t)bytes); |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 94 | close(fd); |
| 95 | return amt == -1 ? -errno : 0; |
| 96 | } else { |
| 97 | if (already_warned == 0) { |
Fenglin Wu | 862b56b | 2018-02-02 10:20:28 +0800 | [diff] [blame] | 98 | ALOGE("write_int failed to open %s, errno = %d\n", path, errno); |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 99 | already_warned = 1; |
| 100 | } |
| 101 | return -errno; |
| 102 | } |
| 103 | } |
| 104 | |
Fenglin Wu | 862b56b | 2018-02-02 10:20:28 +0800 | [diff] [blame] | 105 | static bool file_exists(const char *file) |
| 106 | { |
| 107 | int fd; |
| 108 | |
| 109 | fd = open(file, O_RDWR); |
| 110 | if (fd < 0) { |
| 111 | ALOGE("failed to open %s, errno=%d\n", file, errno); |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | close(fd); |
| 116 | return true; |
| 117 | } |
| 118 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 119 | static int |
| 120 | is_lit(struct light_state_t const* state) |
| 121 | { |
| 122 | return state->color & 0x00ffffff; |
| 123 | } |
| 124 | |
| 125 | static int |
| 126 | rgb_to_brightness(struct light_state_t const* state) |
| 127 | { |
| 128 | int color = state->color & 0x00ffffff; |
| 129 | return ((77*((color>>16)&0x00ff)) |
| 130 | + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8; |
| 131 | } |
| 132 | |
| 133 | static int |
| 134 | set_light_backlight(struct light_device_t* dev, |
| 135 | struct light_state_t const* state) |
| 136 | { |
| 137 | int err = 0; |
| 138 | int brightness = rgb_to_brightness(state); |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 139 | unsigned int lpEnabled = |
| 140 | state->brightnessMode == BRIGHTNESS_MODE_LOW_PERSISTENCE; |
Arun Kumar K.R | 0efad60 | 2014-01-21 21:32:36 -0800 | [diff] [blame] | 141 | if(!dev) { |
| 142 | return -1; |
| 143 | } |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 144 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 145 | pthread_mutex_lock(&g_lock); |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 146 | // Toggle low persistence mode state |
Pullakavi Srinivas | da0b325 | 2017-10-12 17:50:41 +0530 | [diff] [blame] | 147 | bool persistence_mode = ((g_last_backlight_mode != state->brightnessMode && lpEnabled) || |
| 148 | (!lpEnabled && |
| 149 | g_last_backlight_mode == BRIGHTNESS_MODE_LOW_PERSISTENCE)); |
| 150 | bool cannot_handle_persistence = !g_has_persistence_node && persistence_mode; |
| 151 | if (g_has_persistence_node) { |
| 152 | if (persistence_mode) { |
| 153 | if ((err = write_int(PERSISTENCE_FILE, lpEnabled)) != 0) { |
| 154 | ALOGE("%s: Failed to write to %s: %s\n", __FUNCTION__, |
| 155 | PERSISTENCE_FILE, strerror(errno)); |
| 156 | } |
| 157 | if (lpEnabled != 0) { |
| 158 | brightness = DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS; |
| 159 | } |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 160 | } |
Pullakavi Srinivas | da0b325 | 2017-10-12 17:50:41 +0530 | [diff] [blame] | 161 | g_last_backlight_mode = state->brightnessMode; |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 162 | } |
| 163 | |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 164 | if (!err) { |
Saurabh Shah | 8b021cf | 2017-03-14 12:16:43 -0700 | [diff] [blame] | 165 | if (!access(LCD_FILE, F_OK)) { |
| 166 | err = write_int(LCD_FILE, brightness); |
| 167 | } else { |
| 168 | err = write_int(LCD_FILE2, brightness); |
| 169 | } |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 170 | } |
| 171 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 172 | pthread_mutex_unlock(&g_lock); |
Pullakavi Srinivas | da0b325 | 2017-10-12 17:50:41 +0530 | [diff] [blame] | 173 | return cannot_handle_persistence ? -ENOSYS : err; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Fenglin Wu | 862b56b | 2018-02-02 10:20:28 +0800 | [diff] [blame] | 176 | static int set_rgb_led_brightness(enum rgb_led led, int brightness) |
| 177 | { |
| 178 | char file[48]; |
| 179 | |
| 180 | snprintf(file, sizeof(file), "/sys/class/leds/%s/brightness", led_names[led]); |
| 181 | return write_int(file, brightness); |
| 182 | } |
| 183 | |
| 184 | static int set_rgb_led_timer_trigger(enum rgb_led led, int onMS, int offMS) |
| 185 | { |
| 186 | char file[48]; |
| 187 | int rc; |
| 188 | |
| 189 | snprintf(file, sizeof(file), "/sys/class/leds/%s/delay_off", led_names[led]); |
| 190 | rc = write_int(file, offMS); |
| 191 | if (rc < 0) |
| 192 | goto out; |
| 193 | |
| 194 | snprintf(file, sizeof(file), "/sys/class/leds/%s/delay_on", led_names[led]); |
| 195 | rc = write_int(file, onMS); |
| 196 | if (rc < 0) |
| 197 | goto out; |
| 198 | |
| 199 | return 0; |
| 200 | out: |
| 201 | ALOGD("%s doesn't support timer trigger\n", led_names[led]); |
| 202 | return rc; |
| 203 | } |
| 204 | |
| 205 | static int set_rgb_led_hw_blink(enum rgb_led led, int blink) |
| 206 | { |
| 207 | char file[48]; |
| 208 | |
| 209 | snprintf(file, sizeof(file), "/sys/class/leds/%s/breath", led_names[led]); |
| 210 | if (!file_exists(file)) |
| 211 | snprintf(file, sizeof(file), "/sys/class/leds/%s/blink", led_names[led]); |
| 212 | |
| 213 | return write_int(file, blink); |
| 214 | } |
| 215 | |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 216 | static int |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 217 | set_speaker_light_locked(struct light_device_t* dev, |
| 218 | struct light_state_t const* state) |
| 219 | { |
Arun Kumar K.R | 0efad60 | 2014-01-21 21:32:36 -0800 | [diff] [blame] | 220 | int red, green, blue; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 221 | int onMS, offMS; |
| 222 | unsigned int colorRGB; |
Fenglin Wu | 862b56b | 2018-02-02 10:20:28 +0800 | [diff] [blame] | 223 | int blink = 0; |
| 224 | int rc = 0; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 225 | |
Arun Kumar K.R | 0efad60 | 2014-01-21 21:32:36 -0800 | [diff] [blame] | 226 | if(!dev) { |
| 227 | return -1; |
| 228 | } |
| 229 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 230 | colorRGB = state->color; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 231 | red = (colorRGB >> 16) & 0xFF; |
| 232 | green = (colorRGB >> 8) & 0xFF; |
| 233 | blue = colorRGB & 0xFF; |
| 234 | |
Fenglin Wu | 862b56b | 2018-02-02 10:20:28 +0800 | [diff] [blame] | 235 | onMS = state->flashOnMS; |
| 236 | offMS = state->flashOffMS; |
| 237 | |
| 238 | if (onMS != 0 && offMS != 0) |
| 239 | blink = 1; |
| 240 | |
| 241 | switch (state->flashMode) { |
| 242 | case LIGHT_FLASH_HARDWARE: |
| 243 | if (!!red) |
| 244 | rc = set_rgb_led_hw_blink(LED_RED, blink); |
| 245 | if (!!green) |
| 246 | rc |= set_rgb_led_hw_blink(LED_GREEN, blink); |
| 247 | if (!!blue) |
| 248 | rc |= set_rgb_led_hw_blink(LED_BLUE, blink); |
| 249 | /* fallback to timed blinking if breath is not supported */ |
| 250 | if (rc == 0) |
| 251 | break; |
| 252 | case LIGHT_FLASH_TIMED: |
| 253 | if (!!red) |
| 254 | rc = set_rgb_led_timer_trigger(LED_RED, onMS, offMS); |
| 255 | if (!!green) |
| 256 | rc |= set_rgb_led_timer_trigger(LED_GREEN, onMS, offMS); |
| 257 | if (!!blue) |
| 258 | rc |= set_rgb_led_timer_trigger(LED_BLUE, onMS, offMS); |
| 259 | /* fallback to constant on if timed blinking is not supported */ |
| 260 | if (rc == 0) |
| 261 | break; |
| 262 | case LIGHT_FLASH_NONE: |
| 263 | default: |
| 264 | rc = set_rgb_led_brightness(LED_RED, red); |
| 265 | rc |= set_rgb_led_brightness(LED_GREEN, green); |
| 266 | rc |= set_rgb_led_brightness(LED_BLUE, blue); |
| 267 | break; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Fenglin Wu | 862b56b | 2018-02-02 10:20:28 +0800 | [diff] [blame] | 270 | ALOGD("set_speaker_light_locked mode=%d, colorRGB=%08X, onMS=%d, offMS=%d, rc=%d\n", |
| 271 | state->flashMode, colorRGB, onMS, offMS, rc); |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 272 | |
Fenglin Wu | 862b56b | 2018-02-02 10:20:28 +0800 | [diff] [blame] | 273 | return rc; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | static void |
| 277 | handle_speaker_battery_locked(struct light_device_t* dev) |
| 278 | { |
| 279 | if (is_lit(&g_battery)) { |
| 280 | set_speaker_light_locked(dev, &g_battery); |
| 281 | } else { |
| 282 | set_speaker_light_locked(dev, &g_notification); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | static int |
Mao Li | a4e053a | 2014-06-16 23:05:17 +0530 | [diff] [blame] | 287 | set_light_battery(struct light_device_t* dev, |
| 288 | struct light_state_t const* state) |
| 289 | { |
| 290 | pthread_mutex_lock(&g_lock); |
| 291 | g_battery = *state; |
| 292 | handle_speaker_battery_locked(dev); |
| 293 | pthread_mutex_unlock(&g_lock); |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | static int |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 298 | set_light_notifications(struct light_device_t* dev, |
| 299 | struct light_state_t const* state) |
| 300 | { |
| 301 | pthread_mutex_lock(&g_lock); |
| 302 | g_notification = *state; |
| 303 | handle_speaker_battery_locked(dev); |
| 304 | pthread_mutex_unlock(&g_lock); |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | static int |
| 309 | set_light_attention(struct light_device_t* dev, |
| 310 | struct light_state_t const* state) |
| 311 | { |
| 312 | pthread_mutex_lock(&g_lock); |
| 313 | if (state->flashMode == LIGHT_FLASH_HARDWARE) { |
| 314 | g_attention = state->flashOnMS; |
| 315 | } else if (state->flashMode == LIGHT_FLASH_NONE) { |
| 316 | g_attention = 0; |
| 317 | } |
| 318 | handle_speaker_battery_locked(dev); |
| 319 | pthread_mutex_unlock(&g_lock); |
| 320 | return 0; |
| 321 | } |
| 322 | |
Arun Kumar K.R | edd9998 | 2017-08-23 08:09:06 +0530 | [diff] [blame] | 323 | static int |
| 324 | set_light_buttons(struct light_device_t* dev, |
| 325 | struct light_state_t const* state) |
| 326 | { |
| 327 | int err = 0; |
| 328 | if(!dev) { |
| 329 | return -1; |
| 330 | } |
| 331 | pthread_mutex_lock(&g_lock); |
| 332 | err = write_int(BUTTON_FILE, state->color & 0xFF); |
| 333 | pthread_mutex_unlock(&g_lock); |
| 334 | return err; |
| 335 | } |
| 336 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 337 | /** Close the lights device */ |
| 338 | static int |
| 339 | close_lights(struct light_device_t *dev) |
| 340 | { |
| 341 | if (dev) { |
| 342 | free(dev); |
| 343 | } |
| 344 | return 0; |
| 345 | } |
| 346 | |
| 347 | |
| 348 | /******************************************************************************/ |
| 349 | |
| 350 | /** |
| 351 | * module methods |
| 352 | */ |
| 353 | |
| 354 | /** Open a new instance of a lights device using name */ |
| 355 | static int open_lights(const struct hw_module_t* module, char const* name, |
| 356 | struct hw_device_t** device) |
| 357 | { |
| 358 | int (*set_light)(struct light_device_t* dev, |
| 359 | struct light_state_t const* state); |
| 360 | |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 361 | if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) { |
Ch Ganesh Kumar | ae5a42e | 2018-03-14 16:51:43 +0530 | [diff] [blame] | 362 | g_has_persistence_node = !access(PERSISTENCE_FILE, F_OK); |
| 363 | set_light = set_light_backlight; |
Xu Yang | 586c6d5 | 2016-09-19 17:54:16 +0800 | [diff] [blame] | 364 | } else if (0 == strcmp(LIGHT_ID_BATTERY, name)) |
Mao Li | a4e053a | 2014-06-16 23:05:17 +0530 | [diff] [blame] | 365 | set_light = set_light_battery; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 366 | else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) |
| 367 | set_light = set_light_notifications; |
Arun Kumar K.R | 9ae5a34 | 2017-08-23 13:46:03 +0530 | [diff] [blame] | 368 | else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) { |
| 369 | if (!access(BUTTON_FILE, F_OK)) { |
| 370 | // enable light button when the file is present |
| 371 | set_light = set_light_buttons; |
| 372 | } else { |
| 373 | return -EINVAL; |
| 374 | } |
| 375 | } |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 376 | else if (0 == strcmp(LIGHT_ID_ATTENTION, name)) |
| 377 | set_light = set_light_attention; |
| 378 | else |
| 379 | return -EINVAL; |
| 380 | |
| 381 | pthread_once(&g_init, init_globals); |
| 382 | |
| 383 | struct light_device_t *dev = malloc(sizeof(struct light_device_t)); |
Manoj Kumar AVM | 001b309 | 2014-04-29 22:08:51 -0700 | [diff] [blame] | 384 | |
| 385 | if(!dev) |
| 386 | return -ENOMEM; |
| 387 | |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 388 | memset(dev, 0, sizeof(*dev)); |
| 389 | |
| 390 | dev->common.tag = HARDWARE_DEVICE_TAG; |
Sathish Ambley | 4342f27 | 2017-01-04 10:57:05 -0800 | [diff] [blame] | 391 | dev->common.version = LIGHTS_DEVICE_API_VERSION_2_0; |
Sungmin Choi | b514889 | 2012-07-02 17:00:07 -0700 | [diff] [blame] | 392 | dev->common.module = (struct hw_module_t*)module; |
| 393 | dev->common.close = (int (*)(struct hw_device_t*))close_lights; |
| 394 | dev->set_light = set_light; |
| 395 | |
| 396 | *device = (struct hw_device_t*)dev; |
| 397 | return 0; |
| 398 | } |
| 399 | |
| 400 | static struct hw_module_methods_t lights_module_methods = { |
| 401 | .open = open_lights, |
| 402 | }; |
| 403 | |
| 404 | /* |
| 405 | * The lights Module |
| 406 | */ |
| 407 | struct hw_module_t HAL_MODULE_INFO_SYM = { |
| 408 | .tag = HARDWARE_MODULE_TAG, |
| 409 | .version_major = 1, |
| 410 | .version_minor = 0, |
| 411 | .id = LIGHTS_HARDWARE_MODULE_ID, |
| 412 | .name = "lights Module", |
| 413 | .author = "Google, Inc.", |
| 414 | .methods = &lights_module_methods, |
| 415 | }; |