Prepare new maemo release
[maemo-rb.git] / apps / plugins / lib / helper.c
blob780d636f410749b646aed33a324a9c602359aa1a
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Peter D'Hoye
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "plugin.h"
23 #include "helper.h"
25 #ifdef CPU_SH
26 /* Lookup table for using the BIT_N() macro in plugins */
27 const unsigned bit_n_table[32] = {
28 1LU<< 0, 1LU<< 1, 1LU<< 2, 1LU<< 3,
29 1LU<< 4, 1LU<< 5, 1LU<< 6, 1LU<< 7,
30 1LU<< 8, 1LU<< 9, 1LU<<10, 1LU<<11,
31 1LU<<12, 1LU<<13, 1LU<<14, 1LU<<15,
32 1LU<<16, 1LU<<17, 1LU<<18, 1LU<<19,
33 1LU<<20, 1LU<<21, 1LU<<22, 1LU<<23,
34 1LU<<24, 1LU<<25, 1LU<<26, 1LU<<27,
35 1LU<<28, 1LU<<29, 1LU<<30, 1LU<<31
37 #endif
39 /* Force the backlight on */
40 void backlight_force_on(void)
42 rb->backlight_set_timeout(0);
43 #if CONFIG_CHARGING
44 rb->backlight_set_timeout_plugged(0);
45 #endif /* CONFIG_CHARGING */
48 /* Turn off backlight timeout */
49 void backlight_ignore_timeout(void)
51 if (rb->global_settings->backlight_timeout > 0)
52 rb->backlight_set_timeout(0);
53 #if CONFIG_CHARGING
54 if (rb->global_settings->backlight_timeout_plugged > 0)
55 rb->backlight_set_timeout_plugged(0);
56 #endif /* CONFIG_CHARGING */
59 /* Reset backlight operation to its settings */
60 void backlight_use_settings(void)
62 rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
63 #if CONFIG_CHARGING
64 rb->backlight_set_timeout_plugged(rb->global_settings->
65 backlight_timeout_plugged);
66 #endif /* CONFIG_CHARGING */
69 #ifdef HAVE_REMOTE_LCD
70 /* Force the backlight on */
71 void remote_backlight_force_on(void)
73 rb->remote_backlight_set_timeout(0);
74 #if CONFIG_CHARGING
75 rb->remote_backlight_set_timeout_plugged(0);
76 #endif /* CONFIG_CHARGING */
79 /* Turn off backlight timeout */
80 void remote_backlight_ignore_timeout(void)
82 if (rb->global_settings->remote_backlight_timeout > 0)
83 rb->remote_backlight_set_timeout(0);
84 #if CONFIG_CHARGING
85 if (rb->global_settings->remote_backlight_timeout_plugged > 0)
86 rb->remote_backlight_set_timeout_plugged(0);
87 #endif /* CONFIG_CHARGING */
90 /* Reset backlight operation to its settings */
91 void remote_backlight_use_settings(void)
93 rb->remote_backlight_set_timeout(rb->global_settings->
94 remote_backlight_timeout);
95 #if CONFIG_CHARGING
96 rb->remote_backlight_set_timeout_plugged(rb->global_settings->
97 remote_backlight_timeout_plugged);
98 #endif /* CONFIG_CHARGING */
100 #endif /* HAVE_REMOTE_LCD */
102 #ifdef HAVE_BUTTON_LIGHT
103 /* Force the buttonlight on */
104 void buttonlight_force_on(void)
106 rb->buttonlight_set_timeout(0);
109 /* Turn off backlight timeout */
110 void buttonlight_ignore_timeout(void)
112 if (rb->global_settings->buttonlight_timeout > 0)
113 rb->buttonlight_set_timeout(0);
116 /* Reset buttonlight operation to its settings */
117 void buttonlight_use_settings(void)
119 rb->buttonlight_set_timeout(rb->global_settings->buttonlight_timeout);
121 #endif /* HAVE_BUTTON_LIGHT */
123 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
124 void backlight_brightness_set(int brightness)
126 rb->backlight_set_brightness(brightness);
129 void backlight_brightness_use_setting(void)
131 rb->backlight_set_brightness(rb->global_settings->brightness);
133 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
135 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
136 void buttonlight_brightness_set(int brightness)
138 rb->buttonlight_set_brightness(brightness);
141 void buttonlight_brightness_use_setting(void)
143 rb->buttonlight_set_brightness(rb->global_settings->buttonlight_brightness);
145 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */