Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 by Linus Nielsen Feltzing |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 11 | * Additional work by Martin Ritter (2007) and Thomas Martitz (2008) |
| 12 | * for backlight thread fading |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 13 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License |
| 16 | * as published by the Free Software Foundation; either version 2 |
| 17 | * of the License, or (at your option) any later version. |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 18 | * |
| 19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 20 | * KIND, either express or implied. |
| 21 | * |
| 22 | ****************************************************************************/ |
| 23 | #include "config.h" |
| 24 | #include <stdlib.h> |
Linus Nielsen Feltzing | eb5463d | 2004-10-07 08:38:51 +0000 | [diff] [blame] | 25 | #include "cpu.h" |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 26 | #include "kernel.h" |
| 27 | #include "thread.h" |
| 28 | #include "i2c.h" |
| 29 | #include "debug.h" |
| 30 | #include "rtc.h" |
Linus Nielsen Feltzing | 392f385 | 2002-06-29 23:01:10 +0000 | [diff] [blame] | 31 | #include "usb.h" |
Daniel Stenberg | b95fe1a | 2002-10-01 10:59:36 +0000 | [diff] [blame] | 32 | #include "power.h" |
Jörg Hohensohn | 75bab49 | 2003-11-06 01:34:50 +0000 | [diff] [blame] | 33 | #include "system.h" |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 34 | #include "button.h" |
Jens Arnold | e44372e | 2005-07-26 20:01:11 +0000 | [diff] [blame] | 35 | #include "timer.h" |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 36 | #include "backlight.h" |
Jens Arnold | 8e66491 | 2008-03-19 00:34:56 +0000 | [diff] [blame] | 37 | #include "lcd.h" |
Jens Arnold | 11ad7b4 | 2009-02-10 23:43:37 +0000 | [diff] [blame] | 38 | #include "screendump.h" |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 39 | |
Christian Gmeiner | cf2b821 | 2005-04-15 13:51:19 +0000 | [diff] [blame] | 40 | #ifdef HAVE_REMOTE_LCD |
| 41 | #include "lcd-remote.h" |
| 42 | #endif |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 43 | |
Jens Arnold | 47bf6c5 | 2007-04-12 22:12:13 +0000 | [diff] [blame] | 44 | #ifndef SIMULATOR |
Udo Schläpfer | dbabd0d | 2015-02-02 21:44:29 +0100 | [diff] [blame] | 45 | /* |
| 46 | Device specific implementation: |
| 47 | bool backlight_hw_init(void); |
| 48 | void backlight_hw_on(void); |
| 49 | void backlight_hw_off(void); |
| 50 | void backlight_hw_brightness(int brightness); |
| 51 | */ |
Linus Nielsen Feltzing | 1361800 | 2006-03-22 14:17:45 +0000 | [diff] [blame] | 52 | #include "backlight-target.h" |
Thomas Martitz | 0a5beba | 2009-04-26 02:27:11 +0000 | [diff] [blame] | 53 | #else |
| 54 | #include "backlight-sim.h" |
Linus Nielsen Feltzing | 1361800 | 2006-03-22 14:17:45 +0000 | [diff] [blame] | 55 | #endif |
Christian Gmeiner | cf2b821 | 2005-04-15 13:51:19 +0000 | [diff] [blame] | 56 | |
Thomas Martitz | 4e26db3 | 2010-06-21 17:26:50 +0000 | [diff] [blame] | 57 | #if defined(HAVE_BACKLIGHT) && defined(BACKLIGHT_FULL_INIT) |
Thomas Martitz | 6370105 | 2010-06-21 17:10:22 +0000 | [diff] [blame] | 58 | |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 59 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \ |
| 60 | || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG) |
Thomas Martitz | 81df953 | 2009-01-22 10:50:11 +0000 | [diff] [blame] | 61 | #include "backlight-sw-fading.h" |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 62 | #endif |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 63 | |
Thomas Martitz | 14731bc | 2009-04-28 08:57:38 +0000 | [diff] [blame] | 64 | #define BACKLIGHT_FADE_IN_THREAD \ |
| 65 | (CONFIG_BACKLIGHT_FADING & (BACKLIGHT_FADING_SW_SETTING \ |
| 66 | |BACKLIGHT_FADING_SW_HW_REG \ |
| 67 | |BACKLIGHT_FADING_PWM) ) |
| 68 | |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 69 | #define BACKLIGHT_THREAD_TIMEOUT HZ |
| 70 | |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 71 | enum { |
| 72 | BACKLIGHT_ON, |
| 73 | BACKLIGHT_OFF, |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 74 | BACKLIGHT_TMO_CHANGED, |
Boris Gjenero | f4943b9 | 2009-05-01 03:18:20 +0000 | [diff] [blame] | 75 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
| 76 | BACKLIGHT_BRIGHTNESS_CHANGED, |
| 77 | #endif |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 78 | #ifdef HAVE_REMOTE_LCD |
| 79 | REMOTE_BACKLIGHT_ON, |
| 80 | REMOTE_BACKLIGHT_OFF, |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 81 | REMOTE_BACKLIGHT_TMO_CHANGED, |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 82 | #endif |
| 83 | #if defined(_BACKLIGHT_FADE_BOOST) || defined(_BACKLIGHT_FADE_ENABLE) |
| 84 | BACKLIGHT_FADE_FINISH, |
| 85 | #endif |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 86 | #ifdef HAVE_LCD_SLEEP |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 87 | LCD_SLEEP, |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 88 | #endif |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 89 | #ifdef HAVE_BUTTON_LIGHT |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 90 | BUTTON_LIGHT_ON, |
| 91 | BUTTON_LIGHT_OFF, |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 92 | BUTTON_LIGHT_TMO_CHANGED, |
Boris Gjenero | f4943b9 | 2009-05-01 03:18:20 +0000 | [diff] [blame] | 93 | #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS |
| 94 | BUTTON_LIGHT_BRIGHTNESS_CHANGED, |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 95 | #endif |
Boris Gjenero | f4943b9 | 2009-05-01 03:18:20 +0000 | [diff] [blame] | 96 | #endif /* HAVE_BUTTON_LIGHT */ |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 97 | #ifdef BACKLIGHT_DRIVER_CLOSE |
| 98 | BACKLIGHT_QUIT, |
| 99 | #endif |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 100 | }; |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 101 | |
| 102 | static void backlight_thread(void); |
| 103 | static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)]; |
| 104 | static const char backlight_thread_name[] = "backlight"; |
Michael Sevakis | b15aa47 | 2011-02-14 11:27:45 +0000 | [diff] [blame] | 105 | static struct event_queue backlight_queue SHAREDBSS_ATTR; |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 106 | static bool ignore_backlight_on = false; |
| 107 | static int backlight_ignored_timer = 0; |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 108 | #ifdef BACKLIGHT_DRIVER_CLOSE |
Michael Sevakis | 8cfbd36 | 2008-12-10 08:57:10 +0000 | [diff] [blame] | 109 | static unsigned int backlight_thread_id = 0; |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 110 | #endif |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 111 | |
Thomas Martitz | 0017dfb | 2009-04-25 18:15:50 +0000 | [diff] [blame] | 112 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
| 113 | int backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; |
| 114 | #endif |
Jens Arnold | 94c6e6f | 2008-04-06 15:15:44 +0000 | [diff] [blame] | 115 | static int backlight_timer SHAREDBSS_ATTR; |
Jens Arnold | ffeaea6 | 2007-08-10 21:55:48 +0000 | [diff] [blame] | 116 | static int backlight_timeout_normal = 5*HZ; |
Jonathan Gordon | 9a6f419 | 2007-02-18 05:32:06 +0000 | [diff] [blame] | 117 | #if CONFIG_CHARGING |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 118 | static int backlight_timeout_plugged = 5*HZ; |
| 119 | #endif |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 120 | #ifdef HAS_BUTTON_HOLD |
| 121 | static int backlight_on_button_hold = 0; |
| 122 | #endif |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 123 | static void backlight_timeout_handler(void); |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 124 | |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 125 | #ifdef HAVE_BUTTON_LIGHT |
Jens Arnold | 5f1ec30 | 2007-10-07 15:02:02 +0000 | [diff] [blame] | 126 | static int buttonlight_timer; |
Thomas Martitz | 0017dfb | 2009-04-25 18:15:50 +0000 | [diff] [blame] | 127 | static int buttonlight_timeout = 5*HZ; |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 128 | static bool ignore_buttonlight_on = false; |
| 129 | static int buttonlight_ignored_timer = 0; |
Karl Kurbjun | 1fc2d91 | 2007-05-10 03:08:47 +0000 | [diff] [blame] | 130 | |
| 131 | /* Update state of buttonlight according to timeout setting */ |
| 132 | static void buttonlight_update_state(void) |
| 133 | { |
Thomas Martitz | 0017dfb | 2009-04-25 18:15:50 +0000 | [diff] [blame] | 134 | buttonlight_timer = buttonlight_timeout; |
Karl Kurbjun | 1fc2d91 | 2007-05-10 03:08:47 +0000 | [diff] [blame] | 135 | |
| 136 | /* Buttonlight == OFF in the setting? */ |
Jens Arnold | 5f1ec30 | 2007-10-07 15:02:02 +0000 | [diff] [blame] | 137 | if (buttonlight_timer < 0) |
Karl Kurbjun | 1fc2d91 | 2007-05-10 03:08:47 +0000 | [diff] [blame] | 138 | { |
Jens Arnold | 5f1ec30 | 2007-10-07 15:02:02 +0000 | [diff] [blame] | 139 | buttonlight_timer = 0; /* Disable the timeout */ |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 140 | buttonlight_hw_off(); |
Karl Kurbjun | 1fc2d91 | 2007-05-10 03:08:47 +0000 | [diff] [blame] | 141 | } |
| 142 | else |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 143 | buttonlight_hw_on(); |
Karl Kurbjun | 1fc2d91 | 2007-05-10 03:08:47 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 146 | /* external interface */ |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 147 | |
Jens Arnold | 5f1ec30 | 2007-10-07 15:02:02 +0000 | [diff] [blame] | 148 | void buttonlight_on(void) |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 149 | { |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 150 | if(!ignore_buttonlight_on) |
| 151 | { |
| 152 | queue_remove_from_head(&backlight_queue, BUTTON_LIGHT_ON); |
| 153 | queue_post(&backlight_queue, BUTTON_LIGHT_ON, 0); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | void buttonlight_on_ignore(bool value, int timeout) |
| 158 | { |
| 159 | ignore_buttonlight_on = value; |
| 160 | buttonlight_ignored_timer = timeout; |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 161 | } |
| 162 | |
Jens Arnold | 5f1ec30 | 2007-10-07 15:02:02 +0000 | [diff] [blame] | 163 | void buttonlight_off(void) |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 164 | { |
| 165 | queue_post(&backlight_queue, BUTTON_LIGHT_OFF, 0); |
| 166 | } |
| 167 | |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 168 | void buttonlight_set_timeout(int value) |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 169 | { |
Thomas Martitz | 0017dfb | 2009-04-25 18:15:50 +0000 | [diff] [blame] | 170 | buttonlight_timeout = HZ * value; |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 171 | queue_post(&backlight_queue, BUTTON_LIGHT_TMO_CHANGED, 0); |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Thomas Martitz | 0017dfb | 2009-04-25 18:15:50 +0000 | [diff] [blame] | 174 | int buttonlight_get_current_timeout(void) |
| 175 | { |
| 176 | return buttonlight_timeout; |
| 177 | } |
| 178 | |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 179 | #endif /* HAVE_BUTTON_LIGHT */ |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 180 | |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 181 | #ifdef HAVE_REMOTE_LCD |
| 182 | static int remote_backlight_timer; |
Jens Arnold | ffeaea6 | 2007-08-10 21:55:48 +0000 | [diff] [blame] | 183 | static int remote_backlight_timeout_normal = 5*HZ; |
Jonathan Gordon | 9a6f419 | 2007-02-18 05:32:06 +0000 | [diff] [blame] | 184 | #if CONFIG_CHARGING |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 185 | static int remote_backlight_timeout_plugged = 5*HZ; |
| 186 | #endif |
Michael Sevakis | 3d2e10b | 2006-09-10 02:00:40 +0000 | [diff] [blame] | 187 | #ifdef HAS_REMOTE_BUTTON_HOLD |
| 188 | static int remote_backlight_on_button_hold = 0; |
| 189 | #endif |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 190 | #endif /* HAVE_REMOTE_LCD */ |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 191 | |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 192 | #ifdef HAVE_LCD_SLEEP |
Michael Sevakis | 009cebe | 2008-05-14 19:29:25 +0000 | [diff] [blame] | 193 | #ifdef HAVE_LCD_SLEEP_SETTING |
Michael Sevakis | 009cebe | 2008-05-14 19:29:25 +0000 | [diff] [blame] | 194 | static int lcd_sleep_timeout = 10*HZ; |
| 195 | #else |
| 196 | /* Target defines needed value */ |
Thomas Martitz | 0017dfb | 2009-04-25 18:15:50 +0000 | [diff] [blame] | 197 | #define lcd_sleep_timeout LCD_SLEEP_TIMEOUT |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 198 | #endif |
| 199 | |
Boris Gjenero | d50d1df | 2009-04-21 21:49:29 +0000 | [diff] [blame] | 200 | static int lcd_sleep_timer SHAREDDATA_ATTR = 0; |
Michael Sevakis | 009cebe | 2008-05-14 19:29:25 +0000 | [diff] [blame] | 201 | |
Thomas Martitz | 6abae1f | 2009-04-26 01:23:39 +0000 | [diff] [blame] | 202 | static void backlight_lcd_sleep_countdown(bool start) |
Michael Sevakis | 009cebe | 2008-05-14 19:29:25 +0000 | [diff] [blame] | 203 | { |
| 204 | if (!start) |
| 205 | { |
| 206 | /* Cancel the LCD sleep countdown */ |
| 207 | lcd_sleep_timer = 0; |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | /* Start LCD sleep countdown */ |
| 212 | if (lcd_sleep_timeout < 0) |
| 213 | { |
| 214 | lcd_sleep_timer = 0; /* Setting == Always */ |
Boris Gjenero | d50d1df | 2009-04-21 21:49:29 +0000 | [diff] [blame] | 215 | /* Ensure lcd_sleep() is called from backlight_thread() */ |
Thomas Martitz | 6abae1f | 2009-04-26 01:23:39 +0000 | [diff] [blame] | 216 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_PWM) |
Boris Gjenero | d50d1df | 2009-04-21 21:49:29 +0000 | [diff] [blame] | 217 | queue_post(&backlight_queue, LCD_SLEEP, 0); |
| 218 | #else |
Michael Sevakis | 009cebe | 2008-05-14 19:29:25 +0000 | [diff] [blame] | 219 | lcd_sleep(); |
Boris Gjenero | d50d1df | 2009-04-21 21:49:29 +0000 | [diff] [blame] | 220 | #endif |
Michael Sevakis | 009cebe | 2008-05-14 19:29:25 +0000 | [diff] [blame] | 221 | } |
| 222 | else |
| 223 | { |
| 224 | lcd_sleep_timer = lcd_sleep_timeout; |
| 225 | } |
| 226 | } |
| 227 | #endif /* HAVE_LCD_SLEEP */ |
| 228 | |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 229 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \ |
| 230 | || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG) |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 231 | static int backlight_fading_type = (FADING_UP|FADING_DOWN); |
| 232 | static int backlight_fading_state = NOT_FADING; |
| 233 | #endif |
| 234 | |
| 235 | |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 236 | /* backlight fading */ |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 237 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_PWM) |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 238 | #define BL_PWM_INTERVAL 5 /* Cycle interval in ms */ |
| 239 | #define BL_PWM_BITS 8 |
| 240 | #define BL_PWM_COUNT (1<<BL_PWM_BITS) |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 241 | |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 242 | /* s15.16 fixed point variables */ |
| 243 | static int32_t bl_fade_in_step = ((BL_PWM_INTERVAL*BL_PWM_COUNT)<<16)/300; |
| 244 | static int32_t bl_fade_out_step = ((BL_PWM_INTERVAL*BL_PWM_COUNT)<<16)/2000; |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 245 | static int32_t bl_dim_fraction = 0; |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 246 | |
Miika Pekkarinen | 73cd9f3 | 2007-01-12 20:26:23 +0000 | [diff] [blame] | 247 | static int bl_dim_target = 0; |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 248 | static int bl_dim_current = 0; |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 249 | static enum {DIM_STATE_START, DIM_STATE_MAIN} bl_dim_state = DIM_STATE_START; |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 250 | static bool bl_timer_active = false; |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 251 | |
| 252 | static void backlight_isr(void) |
| 253 | { |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 254 | int timer_period = (TIMER_FREQ*BL_PWM_INTERVAL/1000); |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 255 | bool idle = false; |
Antoine Cellerier | 6f13f4c | 2007-07-27 17:53:43 +0000 | [diff] [blame] | 256 | |
Antoine Cellerier | 6f13f4c | 2007-07-27 17:53:43 +0000 | [diff] [blame] | 257 | switch (bl_dim_state) |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 258 | { |
| 259 | /* New cycle */ |
| 260 | case DIM_STATE_START: |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 261 | bl_dim_current = bl_dim_fraction >> 16; |
Antoine Cellerier | 6f13f4c | 2007-07-27 17:53:43 +0000 | [diff] [blame] | 262 | |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 263 | if (bl_dim_current > 0 && bl_dim_current < BL_PWM_COUNT) |
| 264 | { |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 265 | _backlight_on_isr(); |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 266 | timer_period = (timer_period * bl_dim_current) >> BL_PWM_BITS; |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 267 | bl_dim_state = DIM_STATE_MAIN; |
Antoine Cellerier | 6f13f4c | 2007-07-27 17:53:43 +0000 | [diff] [blame] | 268 | } |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 269 | else |
| 270 | { |
| 271 | if (bl_dim_current) |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 272 | _backlight_on_isr(); |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 273 | else |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 274 | _backlight_off_isr(); |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 275 | if (bl_dim_current == bl_dim_target) |
| 276 | idle = true; |
| 277 | } |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 278 | if (bl_dim_current < bl_dim_target) |
| 279 | { |
| 280 | bl_dim_fraction = MIN(bl_dim_fraction + bl_fade_in_step, |
| 281 | (BL_PWM_COUNT<<16)); |
| 282 | } |
| 283 | else if (bl_dim_current > bl_dim_target) |
| 284 | { |
| 285 | bl_dim_fraction = MAX(bl_dim_fraction - bl_fade_out_step, 0); |
| 286 | } |
| 287 | break; |
Antoine Cellerier | 6f13f4c | 2007-07-27 17:53:43 +0000 | [diff] [blame] | 288 | |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 289 | /* Dim main screen */ |
| 290 | case DIM_STATE_MAIN: |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 291 | _backlight_off_isr(); |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 292 | timer_period = (timer_period * (BL_PWM_COUNT - bl_dim_current)) |
| 293 | >> BL_PWM_BITS; |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 294 | bl_dim_state = DIM_STATE_START; |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 295 | break ; |
| 296 | } |
Antoine Cellerier | 6f13f4c | 2007-07-27 17:53:43 +0000 | [diff] [blame] | 297 | if (idle) |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 298 | { |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 299 | #if defined(_BACKLIGHT_FADE_BOOST) || defined(_BACKLIGHT_FADE_ENABLE) |
| 300 | queue_post(&backlight_queue, BACKLIGHT_FADE_FINISH, 0); |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 301 | #endif |
| 302 | timer_unregister(); |
| 303 | bl_timer_active = false; |
Boris Gjenero | d50d1df | 2009-04-21 21:49:29 +0000 | [diff] [blame] | 304 | |
| 305 | #ifdef HAVE_LCD_SLEEP |
| 306 | if (bl_dim_current == 0) |
| 307 | backlight_lcd_sleep_countdown(true); |
| 308 | #endif |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 309 | } |
| 310 | else |
| 311 | timer_set_period(timer_period); |
| 312 | } |
| 313 | |
| 314 | static void backlight_switch(void) |
| 315 | { |
| 316 | if (bl_dim_target > (BL_PWM_COUNT/2)) |
| 317 | { |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 318 | _backlight_on_normal(); |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 319 | bl_dim_fraction = (BL_PWM_COUNT<<16); |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 320 | } |
| 321 | else |
| 322 | { |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 323 | _backlight_off_normal(); |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 324 | bl_dim_fraction = 0; |
Boris Gjenero | d50d1df | 2009-04-21 21:49:29 +0000 | [diff] [blame] | 325 | |
| 326 | #ifdef HAVE_LCD_SLEEP |
| 327 | backlight_lcd_sleep_countdown(true); |
| 328 | #endif |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 329 | } |
| 330 | } |
| 331 | |
| 332 | static void backlight_release_timer(void) |
| 333 | { |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 334 | #ifdef _BACKLIGHT_FADE_BOOST |
Miika Pekkarinen | 1ff7652 | 2006-12-05 20:21:11 +0000 | [diff] [blame] | 335 | cpu_boost(false); |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 336 | #endif |
| 337 | timer_unregister(); |
| 338 | bl_timer_active = false; |
| 339 | backlight_switch(); |
| 340 | } |
| 341 | |
| 342 | static void backlight_dim(int value) |
| 343 | { |
| 344 | /* protect from extraneous calls with the same target value */ |
| 345 | if (value == bl_dim_target) |
| 346 | return; |
| 347 | |
| 348 | bl_dim_target = value; |
| 349 | |
| 350 | if (bl_timer_active) |
| 351 | return ; |
| 352 | |
Rafaël Carré | 89ccd5c | 2009-06-29 14:29:46 +0000 | [diff] [blame] | 353 | if (timer_register(0, backlight_release_timer, 2, backlight_isr |
Jens Arnold | ac9b927 | 2008-04-04 19:38:46 +0000 | [diff] [blame] | 354 | IF_COP(, CPU))) |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 355 | { |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 356 | #ifdef _BACKLIGHT_FADE_BOOST |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 357 | /* Prevent cpu frequency changes while dimming. */ |
Miika Pekkarinen | 1ff7652 | 2006-12-05 20:21:11 +0000 | [diff] [blame] | 358 | cpu_boost(true); |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 359 | #endif |
| 360 | bl_timer_active = true; |
| 361 | } |
| 362 | else |
| 363 | backlight_switch(); |
| 364 | } |
| 365 | |
Thomas Martitz | 14731bc | 2009-04-28 08:57:38 +0000 | [diff] [blame] | 366 | static void backlight_setup_fade_up(void) |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 367 | { |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 368 | if (bl_fade_in_step > 0) |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 369 | { |
| 370 | #ifdef _BACKLIGHT_FADE_ENABLE |
| 371 | _backlight_hw_enable(true); |
| 372 | #endif |
| 373 | backlight_dim(BL_PWM_COUNT); |
| 374 | } |
| 375 | else |
| 376 | { |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 377 | bl_dim_target = BL_PWM_COUNT; |
| 378 | bl_dim_fraction = (BL_PWM_COUNT<<16); |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 379 | _backlight_on_normal(); |
| 380 | } |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 381 | } |
| 382 | |
Thomas Martitz | 14731bc | 2009-04-28 08:57:38 +0000 | [diff] [blame] | 383 | static void backlight_setup_fade_down(void) |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 384 | { |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 385 | if (bl_fade_out_step > 0) |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 386 | { |
| 387 | backlight_dim(0); |
| 388 | } |
| 389 | else |
| 390 | { |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 391 | bl_dim_target = bl_dim_fraction = 0; |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 392 | _backlight_off_normal(); |
Thomas Martitz | 14731bc | 2009-04-28 08:57:38 +0000 | [diff] [blame] | 393 | #ifdef HAVE_LCD_SLEEP |
| 394 | backlight_lcd_sleep_countdown(true); |
| 395 | #endif |
Boris Gjenero | d50d1df | 2009-04-21 21:49:29 +0000 | [diff] [blame] | 396 | } |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 397 | } |
| 398 | |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 399 | void backlight_set_fade_in(int value) |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 400 | { |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 401 | if (value > 0) |
| 402 | bl_fade_in_step = ((BL_PWM_INTERVAL*BL_PWM_COUNT)<<16) / value; |
| 403 | else |
| 404 | bl_fade_in_step = 0; |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 405 | } |
| 406 | |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 407 | void backlight_set_fade_out(int value) |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 408 | { |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 409 | if (value > 0) |
| 410 | bl_fade_out_step = ((BL_PWM_INTERVAL*BL_PWM_COUNT)<<16) / value; |
| 411 | else |
| 412 | bl_fade_out_step = 0; |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 413 | } |
Thom Johansen | 3c7278f | 2006-03-19 17:42:58 +0000 | [diff] [blame] | 414 | |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 415 | #elif (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \ |
| 416 | || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG) |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 417 | |
| 418 | void backlight_set_fade_out(bool value) |
| 419 | { |
| 420 | if(value) /* on */ |
| 421 | backlight_fading_type |= FADING_DOWN; |
| 422 | else |
| 423 | backlight_fading_type &= FADING_UP; |
| 424 | } |
| 425 | |
| 426 | void backlight_set_fade_in(bool value) |
| 427 | { |
| 428 | if(value) /* on */ |
| 429 | backlight_fading_type |= FADING_UP; |
| 430 | else |
| 431 | backlight_fading_type &= FADING_DOWN; |
| 432 | } |
| 433 | |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 434 | static void backlight_setup_fade_up(void) |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 435 | { |
| 436 | if (backlight_fading_type & FADING_UP) |
| 437 | { |
| 438 | if (backlight_fading_state == NOT_FADING) |
| 439 | { |
| 440 | /* make sure the backlight is at lowest level */ |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 441 | backlight_hw_on(); |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 442 | } |
| 443 | backlight_fading_state = FADING_UP; |
| 444 | } |
| 445 | else |
| 446 | { |
| 447 | backlight_fading_state = NOT_FADING; |
| 448 | _backlight_fade_update_state(backlight_brightness); |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 449 | backlight_hw_on(); |
| 450 | backlight_hw_brightness(backlight_brightness); |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 451 | } |
| 452 | } |
| 453 | |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 454 | static void backlight_setup_fade_down(void) |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 455 | { |
| 456 | if (backlight_fading_type & FADING_DOWN) |
| 457 | { |
| 458 | backlight_fading_state = FADING_DOWN; |
| 459 | } |
| 460 | else |
| 461 | { |
| 462 | backlight_fading_state = NOT_FADING; |
| 463 | _backlight_fade_update_state(MIN_BRIGHTNESS_SETTING-1); |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 464 | backlight_hw_off(); |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 465 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG) |
| 466 | /* write the lowest brightness level to the hardware so that |
| 467 | * fading up is glitch free */ |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 468 | backlight_hw_brightness(MIN_BRIGHTNESS_SETTING); |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 469 | #endif |
Thomas Martitz | 14731bc | 2009-04-28 08:57:38 +0000 | [diff] [blame] | 470 | #ifdef HAVE_LCD_SLEEP |
| 471 | backlight_lcd_sleep_countdown(true); |
| 472 | #endif |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 473 | } |
| 474 | } |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 475 | #endif /* CONFIG_BACKLIGHT_FADING */ |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 476 | |
Thomas Martitz | 14731bc | 2009-04-28 08:57:38 +0000 | [diff] [blame] | 477 | static inline void do_backlight_off(void) |
| 478 | { |
| 479 | backlight_timer = 0; |
| 480 | #if BACKLIGHT_FADE_IN_THREAD |
| 481 | backlight_setup_fade_down(); |
| 482 | #else |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 483 | backlight_hw_off(); |
Thomas Martitz | 14731bc | 2009-04-28 08:57:38 +0000 | [diff] [blame] | 484 | /* targets that have fading need to start the countdown when done with |
| 485 | * fading */ |
| 486 | #ifdef HAVE_LCD_SLEEP |
| 487 | backlight_lcd_sleep_countdown(true); |
| 488 | #endif |
| 489 | #endif |
| 490 | } |
| 491 | |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 492 | /* Update state of backlight according to timeout setting */ |
| 493 | static void backlight_update_state(void) |
| 494 | { |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 495 | |
| 496 | int timeout = backlight_get_current_timeout(); |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 497 | |
| 498 | /* Backlight == OFF in the setting? */ |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 499 | if (UNLIKELY(timeout < 0)) |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 500 | { |
Thomas Martitz | 14731bc | 2009-04-28 08:57:38 +0000 | [diff] [blame] | 501 | do_backlight_off(); |
Rob Purchase | 0b30eb7 | 2009-11-23 23:30:55 +0000 | [diff] [blame] | 502 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \ |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 503 | || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG) |
Rob Purchase | 0b30eb7 | 2009-11-23 23:30:55 +0000 | [diff] [blame] | 504 | /* necessary step to issue fading down when the setting is selected */ |
| 505 | if (queue_empty(&backlight_queue)) |
| 506 | queue_post(&backlight_queue, SYS_TIMEOUT, 0); |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 507 | #endif |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 508 | } |
| 509 | else |
| 510 | { |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 511 | backlight_timer = timeout; |
Thomas Martitz | 6abae1f | 2009-04-26 01:23:39 +0000 | [diff] [blame] | 512 | |
| 513 | #ifdef HAVE_LCD_SLEEP |
| 514 | backlight_lcd_sleep_countdown(false); /* wake up lcd */ |
| 515 | #endif |
| 516 | |
Thomas Martitz | 14731bc | 2009-04-28 08:57:38 +0000 | [diff] [blame] | 517 | #if BACKLIGHT_FADE_IN_THREAD |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 518 | backlight_setup_fade_up(); |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 519 | #else |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 520 | backlight_hw_on(); |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 521 | #endif |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 522 | } |
| 523 | } |
| 524 | |
| 525 | #ifdef HAVE_REMOTE_LCD |
| 526 | /* Update state of remote backlight according to timeout setting */ |
| 527 | static void remote_backlight_update_state(void) |
| 528 | { |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 529 | int timeout = remote_backlight_get_current_timeout(); |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 530 | /* Backlight == OFF in the setting? */ |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 531 | if (timeout < 0) |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 532 | { |
| 533 | remote_backlight_timer = 0; /* Disable the timeout */ |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 534 | remote_backlight_hw_off(); |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 535 | } |
| 536 | else |
| 537 | { |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 538 | remote_backlight_timer = timeout; |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 539 | remote_backlight_hw_on(); |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | #endif /* HAVE_REMOTE_LCD */ |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 543 | |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 544 | void backlight_thread(void) |
| 545 | { |
Michael Sevakis | a9b2fb5 | 2007-10-16 01:25:17 +0000 | [diff] [blame] | 546 | struct queue_event ev; |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 547 | bool locked = false; |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 548 | |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 549 | while(1) |
| 550 | { |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 551 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \ |
| 552 | || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG) |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 553 | if (backlight_fading_state != NOT_FADING) |
Steve Bavin | f684726 | 2008-11-26 08:26:13 +0000 | [diff] [blame] | 554 | queue_wait_w_tmo(&backlight_queue, &ev, FADE_DELAY); |
| 555 | else |
| 556 | #endif |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 557 | queue_wait_w_tmo(&backlight_queue, &ev, BACKLIGHT_THREAD_TIMEOUT); |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 558 | switch(ev.id) |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 559 | { /* These events must always be processed */ |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 560 | #ifdef _BACKLIGHT_FADE_BOOST |
| 561 | case BACKLIGHT_FADE_FINISH: |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 562 | cpu_boost(false); |
| 563 | break; |
| 564 | #endif |
Jens Arnold | ef12b3b | 2007-11-12 18:49:53 +0000 | [diff] [blame] | 565 | #ifdef _BACKLIGHT_FADE_ENABLE |
| 566 | case BACKLIGHT_FADE_FINISH: |
| 567 | _backlight_hw_enable((bl_dim_current|bl_dim_target) != 0); |
| 568 | break; |
| 569 | #endif |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 570 | |
Jens Arnold | 8e66491 | 2008-03-19 00:34:56 +0000 | [diff] [blame] | 571 | #ifndef SIMULATOR |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 572 | /* Here for now or else the aggressive init messes up scrolling */ |
Jens Arnold | 8e66491 | 2008-03-19 00:34:56 +0000 | [diff] [blame] | 573 | #ifdef HAVE_REMOTE_LCD |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 574 | case SYS_REMOTE_PLUGGED: |
| 575 | lcd_remote_on(); |
| 576 | lcd_remote_update(); |
| 577 | break; |
| 578 | |
| 579 | case SYS_REMOTE_UNPLUGGED: |
| 580 | lcd_remote_off(); |
| 581 | break; |
Jens Arnold | 8e66491 | 2008-03-19 00:34:56 +0000 | [diff] [blame] | 582 | #elif defined HAVE_REMOTE_LCD_AS_MAIN |
Jens Arnold | 1f4bcc8 | 2008-03-25 19:57:23 +0000 | [diff] [blame] | 583 | case SYS_REMOTE_PLUGGED: |
Jens Arnold | 8e66491 | 2008-03-19 00:34:56 +0000 | [diff] [blame] | 584 | lcd_on(); |
| 585 | lcd_update(); |
| 586 | break; |
| 587 | |
| 588 | case SYS_REMOTE_UNPLUGGED: |
| 589 | lcd_off(); |
| 590 | break; |
| 591 | #endif /* HAVE_REMOTE_LCD/ HAVE_REMOTE_LCD_AS_MAIN */ |
| 592 | #endif /* !SIMULATOR */ |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 593 | case SYS_USB_CONNECTED: |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 594 | usb_acknowledge(SYS_USB_CONNECTED_ACK); |
| 595 | break; |
| 596 | |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 597 | #ifdef BACKLIGHT_DRIVER_CLOSE |
| 598 | /* Get out of here */ |
| 599 | case BACKLIGHT_QUIT: |
| 600 | return; |
| 601 | #endif |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 602 | } |
| 603 | if (locked) |
| 604 | continue; |
| 605 | |
| 606 | switch(ev.id) |
| 607 | { /* These events are only processed if backlight isn't locked */ |
Linus Nielsen Feltzing | 19631f4 | 2005-04-15 16:16:26 +0000 | [diff] [blame] | 608 | #ifdef HAVE_REMOTE_LCD |
Thomas Martitz | b056f06 | 2009-04-24 09:08:43 +0000 | [diff] [blame] | 609 | case REMOTE_BACKLIGHT_TMO_CHANGED: |
Linus Nielsen Feltzing | 19631f4 | 2005-04-15 16:16:26 +0000 | [diff] [blame] | 610 | case REMOTE_BACKLIGHT_ON: |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 611 | remote_backlight_update_state(); |
Linus Nielsen Feltzing | 19631f4 | 2005-04-15 16:16:26 +0000 | [diff] [blame] | 612 | break; |
| 613 | |
| 614 | case REMOTE_BACKLIGHT_OFF: |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 615 | remote_backlight_timer = 0; /* Disable the timeout */ |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 616 | remote_backlight_hw_off(); |
Linus Nielsen Feltzing | 19631f4 | 2005-04-15 16:16:26 +0000 | [diff] [blame] | 617 | break; |
Michael Sevakis | 3d2e10b | 2006-09-10 02:00:40 +0000 | [diff] [blame] | 618 | #endif /* HAVE_REMOTE_LCD */ |
| 619 | |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 620 | case BACKLIGHT_TMO_CHANGED: |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 621 | case BACKLIGHT_ON: |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 622 | backlight_update_state(); |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 623 | break; |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 624 | |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 625 | case BACKLIGHT_OFF: |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 626 | do_backlight_off(); |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 627 | break; |
Boris Gjenero | f4943b9 | 2009-05-01 03:18:20 +0000 | [diff] [blame] | 628 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
| 629 | case BACKLIGHT_BRIGHTNESS_CHANGED: |
| 630 | backlight_brightness = (int)ev.data; |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 631 | backlight_hw_brightness((int)ev.data); |
Boris Gjenero | f4943b9 | 2009-05-01 03:18:20 +0000 | [diff] [blame] | 632 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \ |
| 633 | || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG) |
| 634 | /* receive backlight brightness */ |
| 635 | _backlight_fade_update_state((int)ev.data); |
| 636 | #endif |
| 637 | break; |
| 638 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 639 | #ifdef HAVE_LCD_SLEEP |
| 640 | case LCD_SLEEP: |
| 641 | lcd_sleep(); |
| 642 | break; |
| 643 | #endif |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 644 | #ifdef HAVE_BUTTON_LIGHT |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 645 | case BUTTON_LIGHT_TMO_CHANGED: |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 646 | case BUTTON_LIGHT_ON: |
Karl Kurbjun | 1fc2d91 | 2007-05-10 03:08:47 +0000 | [diff] [blame] | 647 | buttonlight_update_state(); |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 648 | break; |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 649 | |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 650 | case BUTTON_LIGHT_OFF: |
Jens Arnold | 5f1ec30 | 2007-10-07 15:02:02 +0000 | [diff] [blame] | 651 | buttonlight_timer = 0; |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 652 | buttonlight_hw_off(); |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 653 | break; |
Boris Gjenero | f4943b9 | 2009-05-01 03:18:20 +0000 | [diff] [blame] | 654 | #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 655 | case BUTTON_LIGHT_BRIGHTNESS_CHANGED: |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 656 | buttonlight_hw_brightness((int)ev.data); |
Boris Gjenero | f4943b9 | 2009-05-01 03:18:20 +0000 | [diff] [blame] | 657 | break; |
| 658 | #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ |
| 659 | #endif /* HAVE_BUTTON_LIGHT */ |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 660 | |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 661 | case SYS_POWEROFF: /* Lock backlight on poweroff so it doesn't */ |
| 662 | locked = true; /* go off before power is actually cut. */ |
| 663 | /* fall through */ |
Jens Arnold | ffeaea6 | 2007-08-10 21:55:48 +0000 | [diff] [blame] | 664 | #if CONFIG_CHARGING |
| 665 | case SYS_CHARGER_CONNECTED: |
| 666 | case SYS_CHARGER_DISCONNECTED: |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 667 | #endif |
Jens Arnold | ffeaea6 | 2007-08-10 21:55:48 +0000 | [diff] [blame] | 668 | backlight_update_state(); |
| 669 | #ifdef HAVE_REMOTE_LCD |
| 670 | remote_backlight_update_state(); |
| 671 | #endif |
| 672 | break; |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 673 | case SYS_TIMEOUT: |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 674 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \ |
| 675 | || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG) |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 676 | if (backlight_fading_state != NOT_FADING) |
| 677 | { |
| 678 | if ((_backlight_fade_step(backlight_fading_state))) |
Thomas Martitz | 6abae1f | 2009-04-26 01:23:39 +0000 | [diff] [blame] | 679 | { /* finished fading */ |
| 680 | #ifdef HAVE_LCD_SLEEP |
| 681 | if (backlight_fading_state == FADING_DOWN) |
| 682 | { /* start sleep countdown */ |
| 683 | backlight_lcd_sleep_countdown(true); |
| 684 | } |
| 685 | #endif |
| 686 | backlight_fading_state = NOT_FADING; |
| 687 | } |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 688 | } |
| 689 | else |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 690 | #endif /* CONFIG_BACKLIGHT_FADING */ |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 691 | backlight_timeout_handler(); |
| 692 | break; |
Jens Arnold | 671f5d4 | 2007-08-12 11:18:52 +0000 | [diff] [blame] | 693 | } |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 694 | } /* end while */ |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 695 | } |
| 696 | |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 697 | static void backlight_timeout_handler(void) |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 698 | { |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 699 | if(backlight_timer > 0) |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 700 | { |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 701 | backlight_timer -= BACKLIGHT_THREAD_TIMEOUT; |
| 702 | if(backlight_timer <= 0) |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 703 | { |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 704 | do_backlight_off(); |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 705 | } |
| 706 | } |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 707 | #ifdef HAVE_LCD_SLEEP |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 708 | else if(lcd_sleep_timer > 0) |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 709 | { |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 710 | lcd_sleep_timer -= BACKLIGHT_THREAD_TIMEOUT; |
| 711 | if(lcd_sleep_timer <= 0) |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 712 | { |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 713 | lcd_sleep(); |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 714 | } |
| 715 | } |
| 716 | #endif /* HAVE_LCD_SLEEP */ |
Linus Nielsen Feltzing | 19631f4 | 2005-04-15 16:16:26 +0000 | [diff] [blame] | 717 | #ifdef HAVE_REMOTE_LCD |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 718 | if(remote_backlight_timer > 0) |
Linus Nielsen Feltzing | 19631f4 | 2005-04-15 16:16:26 +0000 | [diff] [blame] | 719 | { |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 720 | remote_backlight_timer -= BACKLIGHT_THREAD_TIMEOUT; |
| 721 | if(remote_backlight_timer <= 0) |
Linus Nielsen Feltzing | 19631f4 | 2005-04-15 16:16:26 +0000 | [diff] [blame] | 722 | { |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 723 | remote_backlight_hw_off(); |
Linus Nielsen Feltzing | 19631f4 | 2005-04-15 16:16:26 +0000 | [diff] [blame] | 724 | } |
| 725 | } |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 726 | #endif /* HAVE_REMOVE_LCD */ |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 727 | #ifdef HAVE_BUTTON_LIGHT |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 728 | if (buttonlight_timer > 0) |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 729 | { |
Thomas Martitz | c40af94 | 2009-04-26 00:47:35 +0000 | [diff] [blame] | 730 | buttonlight_timer -= BACKLIGHT_THREAD_TIMEOUT; |
| 731 | if (buttonlight_timer <= 0) |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 732 | { |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 733 | buttonlight_hw_off(); |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 734 | } |
| 735 | } |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 736 | if (buttonlight_ignored_timer > 0) |
| 737 | { |
| 738 | buttonlight_ignored_timer -= BACKLIGHT_THREAD_TIMEOUT; |
| 739 | if (buttonlight_ignored_timer <= 0) |
| 740 | ignore_buttonlight_on = false; |
| 741 | } |
Jonathan Gordon | 4b1d1b4 | 2007-04-22 13:02:24 +0000 | [diff] [blame] | 742 | #endif /* HAVE_BUTTON_LIGHT */ |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 743 | if (backlight_ignored_timer > 0) |
| 744 | { |
| 745 | backlight_ignored_timer -= BACKLIGHT_THREAD_TIMEOUT; |
| 746 | if (backlight_ignored_timer <= 0) |
| 747 | ignore_backlight_on = false; |
| 748 | } |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | void backlight_init(void) |
| 752 | { |
Miika Pekkarinen | a85044b | 2006-09-16 16:18:11 +0000 | [diff] [blame] | 753 | queue_init(&backlight_queue, true); |
Antoine Cellerier | 6f13f4c | 2007-07-27 17:53:43 +0000 | [diff] [blame] | 754 | |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 755 | if (backlight_hw_init()) |
Miika Pekkarinen | 73cd9f3 | 2007-01-12 20:26:23 +0000 | [diff] [blame] | 756 | { |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 757 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_PWM) |
Miika Pekkarinen | 73cd9f3 | 2007-01-12 20:26:23 +0000 | [diff] [blame] | 758 | /* If backlight is already on, don't fade in. */ |
Miika Pekkarinen | 73cd9f3 | 2007-01-12 20:26:23 +0000 | [diff] [blame] | 759 | bl_dim_target = BL_PWM_COUNT; |
Jens Arnold | 09a7861 | 2007-11-26 23:10:20 +0000 | [diff] [blame] | 760 | bl_dim_fraction = (BL_PWM_COUNT<<16); |
Thomas Martitz | 12a0ed3 | 2009-01-26 23:21:49 +0000 | [diff] [blame] | 761 | #endif |
Miika Pekkarinen | 73cd9f3 | 2007-01-12 20:26:23 +0000 | [diff] [blame] | 762 | } |
Jens Arnold | f265ee9 | 2007-09-12 22:24:58 +0000 | [diff] [blame] | 763 | /* Leave all lights as set by the bootloader here. The settings load will |
| 764 | * call the appropriate backlight_set_*() functions, only changing light |
| 765 | * status if necessary. */ |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 766 | #ifdef BACKLIGHT_DRIVER_CLOSE |
Michael Sevakis | 8cfbd36 | 2008-12-10 08:57:10 +0000 | [diff] [blame] | 767 | backlight_thread_id = |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 768 | #endif |
Miika Pekkarinen | 73cd9f3 | 2007-01-12 20:26:23 +0000 | [diff] [blame] | 769 | create_thread(backlight_thread, backlight_stack, |
Michael Sevakis | a9b2fb5 | 2007-10-16 01:25:17 +0000 | [diff] [blame] | 770 | sizeof(backlight_stack), 0, backlight_thread_name |
Michael Giacomelli | 2d8cd81 | 2008-03-07 00:51:36 +0000 | [diff] [blame] | 771 | IF_PRIO(, PRIORITY_USER_INTERFACE) |
Michael Sevakis | a9b2fb5 | 2007-10-16 01:25:17 +0000 | [diff] [blame] | 772 | IF_COP(, CPU)); |
Linus Nielsen Feltzing | 2a4de23 | 2002-06-24 13:48:42 +0000 | [diff] [blame] | 773 | } |
Jörg Hohensohn | 76994fb | 2004-09-10 13:56:54 +0000 | [diff] [blame] | 774 | |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 775 | #ifdef BACKLIGHT_DRIVER_CLOSE |
| 776 | void backlight_close(void) |
| 777 | { |
Michael Sevakis | 8cfbd36 | 2008-12-10 08:57:10 +0000 | [diff] [blame] | 778 | unsigned int thread = backlight_thread_id; |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 779 | |
| 780 | /* Wait for thread to exit */ |
Michael Sevakis | 8cfbd36 | 2008-12-10 08:57:10 +0000 | [diff] [blame] | 781 | if (thread == 0) |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 782 | return; |
| 783 | |
Michael Sevakis | 8cfbd36 | 2008-12-10 08:57:10 +0000 | [diff] [blame] | 784 | backlight_thread_id = 0; |
Michael Sevakis | 80278e4 | 2008-05-10 18:00:11 +0000 | [diff] [blame] | 785 | |
| 786 | queue_post(&backlight_queue, BACKLIGHT_QUIT, 0); |
| 787 | thread_wait(thread); |
| 788 | } |
| 789 | #endif /* BACKLIGHT_DRIVER_CLOSE */ |
| 790 | |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 791 | void backlight_on(void) |
| 792 | { |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 793 | if(!ignore_backlight_on) |
| 794 | { |
| 795 | queue_remove_from_head(&backlight_queue, BACKLIGHT_ON); |
| 796 | queue_post(&backlight_queue, BACKLIGHT_ON, 0); |
| 797 | } |
| 798 | } |
| 799 | |
| 800 | void backlight_on_ignore(bool value, int timeout) |
| 801 | { |
| 802 | ignore_backlight_on = value; |
| 803 | backlight_ignored_timer = timeout; |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | void backlight_off(void) |
| 807 | { |
Michael Sevakis | 4b90267 | 2006-12-19 16:50:07 +0000 | [diff] [blame] | 808 | queue_post(&backlight_queue, BACKLIGHT_OFF, 0); |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 809 | } |
| 810 | |
Jens Arnold | 5c87a98 | 2008-04-02 22:16:14 +0000 | [diff] [blame] | 811 | /* returns true when the backlight is on, |
| 812 | * and optionally when it's set to always off. */ |
| 813 | bool is_backlight_on(bool ignore_always_off) |
Björn Stenberg | da5fb18 | 2006-03-24 13:47:24 +0000 | [diff] [blame] | 814 | { |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 815 | int timeout = backlight_get_current_timeout(); |
Jens Arnold | 5c87a98 | 2008-04-02 22:16:14 +0000 | [diff] [blame] | 816 | return (backlight_timer > 0) /* countdown */ |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 817 | || (timeout == 0) /* always on */ |
| 818 | || ((timeout < 0) && !ignore_always_off); |
Björn Stenberg | da5fb18 | 2006-03-24 13:47:24 +0000 | [diff] [blame] | 819 | } |
| 820 | |
Jens Arnold | a6d409d | 2005-11-23 20:12:33 +0000 | [diff] [blame] | 821 | /* return value in ticks; 0 means always on, <0 means always off */ |
| 822 | int backlight_get_current_timeout(void) |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 823 | { |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 824 | #ifdef HAS_BUTTON_HOLD |
| 825 | if ((backlight_on_button_hold != 0) |
| 826 | #ifdef HAVE_REMOTE_LCD_AS_MAIN |
| 827 | && remote_button_hold() |
| 828 | #else |
| 829 | && button_hold() |
| 830 | #endif |
| 831 | ) |
| 832 | return (backlight_on_button_hold == 2) ? 0 : -1; |
| 833 | /* always on or always off */ |
| 834 | else |
| 835 | #endif |
| 836 | #if CONFIG_CHARGING |
| 837 | if (power_input_present()) |
| 838 | return backlight_timeout_plugged; |
| 839 | else |
| 840 | #endif |
| 841 | return backlight_timeout_normal; |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 842 | } |
| 843 | |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 844 | void backlight_set_timeout(int value) |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 845 | { |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 846 | backlight_timeout_normal = HZ * value; |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 847 | queue_post(&backlight_queue, BACKLIGHT_TMO_CHANGED, 0); |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 848 | } |
| 849 | |
Jonathan Gordon | 9a6f419 | 2007-02-18 05:32:06 +0000 | [diff] [blame] | 850 | #if CONFIG_CHARGING |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 851 | void backlight_set_timeout_plugged(int value) |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 852 | { |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 853 | backlight_timeout_plugged = HZ * value; |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 854 | queue_post(&backlight_queue, BACKLIGHT_TMO_CHANGED, 0); |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 855 | } |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 856 | #endif /* CONFIG_CHARGING */ |
| 857 | |
| 858 | #ifdef HAS_BUTTON_HOLD |
| 859 | /* Hold button change event handler. */ |
| 860 | void backlight_hold_changed(bool hold_button) |
| 861 | { |
Jens Arnold | ffeaea6 | 2007-08-10 21:55:48 +0000 | [diff] [blame] | 862 | if (!hold_button || (backlight_on_button_hold > 0)) |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 863 | { |
Jens Arnold | ffeaea6 | 2007-08-10 21:55:48 +0000 | [diff] [blame] | 864 | /* if unlocked or override in effect */ |
William Wilgus | dc87e9e | 2016-11-22 06:21:31 +0100 | [diff] [blame] | 865 | |
| 866 | /*backlight_on(); REMOVED*/ |
| 867 | queue_remove_from_head(&backlight_queue, BACKLIGHT_ON); |
| 868 | queue_post(&backlight_queue, BACKLIGHT_ON, 0); |
| 869 | } |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | void backlight_set_on_button_hold(int index) |
| 873 | { |
| 874 | if ((unsigned)index >= 3) |
| 875 | /* if given a weird value, use default */ |
| 876 | index = 0; |
| 877 | |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 878 | backlight_on_button_hold = index; |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 879 | queue_post(&backlight_queue, BACKLIGHT_TMO_CHANGED, 0); |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 880 | } |
| 881 | #endif /* HAS_BUTTON_HOLD */ |
| 882 | |
Michael Sevakis | 009cebe | 2008-05-14 19:29:25 +0000 | [diff] [blame] | 883 | #ifdef HAVE_LCD_SLEEP_SETTING |
William Wilgus | a06d9c8 | 2018-12-17 22:27:55 -0600 | [diff] [blame] | 884 | void lcd_set_sleep_after_backlight_off(int timeout_seconds) |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 885 | { |
William Wilgus | a06d9c8 | 2018-12-17 22:27:55 -0600 | [diff] [blame] | 886 | lcd_sleep_timeout = HZ * timeout_seconds; |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 887 | |
Thomas Martitz | cbe67dc | 2009-04-26 01:35:19 +0000 | [diff] [blame] | 888 | if (is_backlight_on(true)) |
William Wilgus | a06d9c8 | 2018-12-17 22:27:55 -0600 | [diff] [blame] | 889 | /* Timer will be set when bl turns off or bl set to on. */ |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 890 | return; |
| 891 | |
| 892 | /* Backlight is Off */ |
Michael Sevakis | 009cebe | 2008-05-14 19:29:25 +0000 | [diff] [blame] | 893 | if (lcd_sleep_timeout < 0) |
William Wilgus | a06d9c8 | 2018-12-17 22:27:55 -0600 | [diff] [blame] | 894 | lcd_sleep_timer = 0; /* Never */ |
| 895 | else if (lcd_sleep_timeout == 0) |
Michael Sevakis | 009cebe | 2008-05-14 19:29:25 +0000 | [diff] [blame] | 896 | lcd_sleep_timer = 1; /* Always - sleep next tick */ |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 897 | else |
William Wilgus | a06d9c8 | 2018-12-17 22:27:55 -0600 | [diff] [blame] | 898 | lcd_sleep_timer = lcd_sleep_timeout; /* other */ |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 899 | } |
Michael Sevakis | 009cebe | 2008-05-14 19:29:25 +0000 | [diff] [blame] | 900 | #endif /* HAVE_LCD_SLEEP_SETTING */ |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 901 | |
| 902 | #ifdef HAVE_REMOTE_LCD |
| 903 | void remote_backlight_on(void) |
| 904 | { |
Michael Sevakis | 4b90267 | 2006-12-19 16:50:07 +0000 | [diff] [blame] | 905 | queue_post(&backlight_queue, REMOTE_BACKLIGHT_ON, 0); |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | void remote_backlight_off(void) |
| 909 | { |
Michael Sevakis | 4b90267 | 2006-12-19 16:50:07 +0000 | [diff] [blame] | 910 | queue_post(&backlight_queue, REMOTE_BACKLIGHT_OFF, 0); |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 911 | } |
| 912 | |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 913 | void remote_backlight_set_timeout(int value) |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 914 | { |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 915 | remote_backlight_timeout_normal = HZ * value; |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 916 | queue_post(&backlight_queue, REMOTE_BACKLIGHT_TMO_CHANGED, 0); |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 917 | } |
| 918 | |
Jonathan Gordon | 9a6f419 | 2007-02-18 05:32:06 +0000 | [diff] [blame] | 919 | #if CONFIG_CHARGING |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 920 | void remote_backlight_set_timeout_plugged(int value) |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 921 | { |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 922 | remote_backlight_timeout_plugged = HZ * value; |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 923 | queue_post(&backlight_queue, REMOTE_BACKLIGHT_TMO_CHANGED, 0); |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 924 | } |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 925 | #endif /* CONFIG_CHARGING */ |
Hristo Kovachev | a70c6b9 | 2006-03-25 19:16:45 +0000 | [diff] [blame] | 926 | |
Michael Sevakis | 3d2e10b | 2006-09-10 02:00:40 +0000 | [diff] [blame] | 927 | #ifdef HAS_REMOTE_BUTTON_HOLD |
| 928 | /* Remote hold button change event handler. */ |
| 929 | void remote_backlight_hold_changed(bool rc_hold_button) |
| 930 | { |
Jens Arnold | ffeaea6 | 2007-08-10 21:55:48 +0000 | [diff] [blame] | 931 | if (!rc_hold_button || (remote_backlight_on_button_hold > 0)) |
| 932 | /* if unlocked or override */ |
Michael Sevakis | 3d2e10b | 2006-09-10 02:00:40 +0000 | [diff] [blame] | 933 | remote_backlight_on(); |
Michael Sevakis | 3d2e10b | 2006-09-10 02:00:40 +0000 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | void remote_backlight_set_on_button_hold(int index) |
| 937 | { |
| 938 | if ((unsigned)index >= 3) |
| 939 | /* if given a weird value, use default */ |
| 940 | index = 0; |
| 941 | |
Michael Sevakis | 3d2e10b | 2006-09-10 02:00:40 +0000 | [diff] [blame] | 942 | remote_backlight_on_button_hold = index; |
Thomas Martitz | b0ac944 | 2009-04-24 08:54:10 +0000 | [diff] [blame] | 943 | queue_post(&backlight_queue, REMOTE_BACKLIGHT_TMO_CHANGED, 0); |
Michael Sevakis | 3d2e10b | 2006-09-10 02:00:40 +0000 | [diff] [blame] | 944 | } |
| 945 | #endif /* HAS_REMOTE_BUTTON_HOLD */ |
| 946 | |
Hristo Kovachev | a70c6b9 | 2006-03-25 19:16:45 +0000 | [diff] [blame] | 947 | /* return value in ticks; 0 means always on, <0 means always off */ |
| 948 | int remote_backlight_get_current_timeout(void) |
| 949 | { |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 950 | #ifdef HAS_REMOTE_BUTTON_HOLD |
| 951 | if (remote_button_hold() && (remote_backlight_on_button_hold != 0)) |
| 952 | return (remote_backlight_on_button_hold == 2) |
| 953 | ? 0 : -1; /* always on or always off */ |
| 954 | else |
| 955 | #endif |
| 956 | #if CONFIG_CHARGING |
| 957 | if (power_input_present()) |
| 958 | return remote_backlight_timeout_plugged; |
| 959 | else |
| 960 | #endif |
| 961 | return remote_backlight_timeout_normal; |
Hristo Kovachev | a70c6b9 | 2006-03-25 19:16:45 +0000 | [diff] [blame] | 962 | } |
| 963 | |
Jens Arnold | 5c87a98 | 2008-04-02 22:16:14 +0000 | [diff] [blame] | 964 | /* returns true when the backlight is on, and |
| 965 | * optionally when it's set to always off */ |
| 966 | bool is_remote_backlight_on(bool ignore_always_off) |
Hristo Kovachev | a70c6b9 | 2006-03-25 19:16:45 +0000 | [diff] [blame] | 967 | { |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 968 | int timeout = remote_backlight_get_current_timeout(); |
Jens Arnold | 5c87a98 | 2008-04-02 22:16:14 +0000 | [diff] [blame] | 969 | return (remote_backlight_timer > 0) /* countdown */ |
Thomas Martitz | 5b316af | 2009-04-25 21:11:16 +0000 | [diff] [blame] | 970 | || (timeout == 0) /* always on */ |
| 971 | || ((timeout < 0) && !ignore_always_off); |
Hristo Kovachev | a70c6b9 | 2006-03-25 19:16:45 +0000 | [diff] [blame] | 972 | } |
| 973 | |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 974 | #endif /* HAVE_REMOTE_LCD */ |
| 975 | |
Michael Sevakis | 58825f6 | 2006-11-10 18:47:41 +0000 | [diff] [blame] | 976 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
| 977 | void backlight_set_brightness(int val) |
| 978 | { |
| 979 | if (val < MIN_BRIGHTNESS_SETTING) |
| 980 | val = MIN_BRIGHTNESS_SETTING; |
| 981 | else if (val > MAX_BRIGHTNESS_SETTING) |
| 982 | val = MAX_BRIGHTNESS_SETTING; |
| 983 | |
Boris Gjenero | f4943b9 | 2009-05-01 03:18:20 +0000 | [diff] [blame] | 984 | queue_post(&backlight_queue, BACKLIGHT_BRIGHTNESS_CHANGED, val); |
Michael Sevakis | 58825f6 | 2006-11-10 18:47:41 +0000 | [diff] [blame] | 985 | } |
| 986 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ |
| 987 | |
Karl Kurbjun | 6f95ab7 | 2007-05-08 06:45:38 +0000 | [diff] [blame] | 988 | #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS |
| 989 | void buttonlight_set_brightness(int val) |
| 990 | { |
| 991 | if (val < MIN_BRIGHTNESS_SETTING) |
| 992 | val = MIN_BRIGHTNESS_SETTING; |
| 993 | else if (val > MAX_BRIGHTNESS_SETTING) |
| 994 | val = MAX_BRIGHTNESS_SETTING; |
| 995 | |
Boris Gjenero | f4943b9 | 2009-05-01 03:18:20 +0000 | [diff] [blame] | 996 | queue_post(&backlight_queue, BUTTON_LIGHT_BRIGHTNESS_CHANGED, val); |
Karl Kurbjun | 6f95ab7 | 2007-05-08 06:45:38 +0000 | [diff] [blame] | 997 | } |
| 998 | #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ |
| 999 | |
Thomas Martitz | 4e26db3 | 2010-06-21 17:26:50 +0000 | [diff] [blame] | 1000 | #else /* !defined(HAVE_BACKLIGHT) || !defined(BACKLIGHT_FULL_INIT) |
Rani Hod | c9f59e6 | 2006-08-08 22:03:56 +0000 | [diff] [blame] | 1001 | -- no backlight, empty dummy functions */ |
Thomas Martitz | 4e26db3 | 2010-06-21 17:26:50 +0000 | [diff] [blame] | 1002 | |
| 1003 | #if defined(HAVE_BACKLIGHT) && !defined(BACKLIGHT_FULL_INIT) |
Jens Arnold | 8042640 | 2005-11-22 01:39:41 +0000 | [diff] [blame] | 1004 | void backlight_init(void) |
| 1005 | { |
Marcin Bukat | 89ba7e8 | 2015-01-09 00:22:40 +0100 | [diff] [blame] | 1006 | (void)backlight_hw_init(); |
| 1007 | backlight_hw_on(); |
Jens Arnold | 8042640 | 2005-11-22 01:39:41 +0000 | [diff] [blame] | 1008 | } |
Thomas Martitz | 4e26db3 | 2010-06-21 17:26:50 +0000 | [diff] [blame] | 1009 | #endif |
Jens Arnold | 8042640 | 2005-11-22 01:39:41 +0000 | [diff] [blame] | 1010 | |
Jörg Hohensohn | 76994fb | 2004-09-10 13:56:54 +0000 | [diff] [blame] | 1011 | void backlight_on(void) {} |
| 1012 | void backlight_off(void) {} |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 1013 | void backlight_set_timeout(int value) {(void)value;} |
Jens Arnold | d5f37b2 | 2008-04-02 22:28:08 +0000 | [diff] [blame] | 1014 | |
| 1015 | bool is_backlight_on(bool ignore_always_off) |
| 1016 | { |
| 1017 | (void)ignore_always_off; |
| 1018 | return true; |
| 1019 | } |
Linus Nielsen Feltzing | 19631f4 | 2005-04-15 16:16:26 +0000 | [diff] [blame] | 1020 | #ifdef HAVE_REMOTE_LCD |
| 1021 | void remote_backlight_on(void) {} |
| 1022 | void remote_backlight_off(void) {} |
Jens Arnold | d490f44 | 2007-11-25 17:36:21 +0000 | [diff] [blame] | 1023 | void remote_backlight_set_timeout(int value) {(void)value;} |
Jens Arnold | d5f37b2 | 2008-04-02 22:28:08 +0000 | [diff] [blame] | 1024 | |
Jens Arnold | ac9b927 | 2008-04-04 19:38:46 +0000 | [diff] [blame] | 1025 | bool is_remote_backlight_on(bool ignore_always_off) |
Jens Arnold | d5f37b2 | 2008-04-02 22:28:08 +0000 | [diff] [blame] | 1026 | { |
| 1027 | (void)ignore_always_off; |
| 1028 | return true; |
| 1029 | } |
Michael Sevakis | 58825f6 | 2006-11-10 18:47:41 +0000 | [diff] [blame] | 1030 | #endif /* HAVE_REMOTE_LCD */ |
| 1031 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
| 1032 | void backlight_set_brightness(int val) { (void)val; } |
Linus Nielsen Feltzing | 19631f4 | 2005-04-15 16:16:26 +0000 | [diff] [blame] | 1033 | #endif |
Bertrik Sikken | 3a8e7e6 | 2010-08-01 10:07:05 +0000 | [diff] [blame] | 1034 | |
Bertrik Sikken | 38caf2c | 2010-08-01 10:17:17 +0000 | [diff] [blame] | 1035 | #ifdef HAVE_BUTTON_LIGHT |
Bertrik Sikken | 3a8e7e6 | 2010-08-01 10:07:05 +0000 | [diff] [blame] | 1036 | void buttonlight_on(void) {} |
Karl Kurbjun | 6f95ab7 | 2007-05-08 06:45:38 +0000 | [diff] [blame] | 1037 | #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS |
| 1038 | void buttonlight_set_brightness(int val) { (void)val; } |
| 1039 | #endif |
Bertrik Sikken | 38caf2c | 2010-08-01 10:17:17 +0000 | [diff] [blame] | 1040 | #endif /* HAVE_BUTTON_LIGHT */ |
Bertrik Sikken | 3a8e7e6 | 2010-08-01 10:07:05 +0000 | [diff] [blame] | 1041 | |
Thomas Martitz | 4e26db3 | 2010-06-21 17:26:50 +0000 | [diff] [blame] | 1042 | #endif /* defined(HAVE_BACKLIGHT) && defined(BACKLIGHT_FULL_INIT) */ |