diff options
author | Tomasz Moń <desowin@gmail.com> | 2011-11-16 14:08:01 +0000 |
---|---|---|
committer | Tomasz Moń <desowin@gmail.com> | 2011-11-16 14:08:01 +0000 |
commit | e8a8a1be43afe63079ae48ce1a9eb3052df3b1a4 (patch) | |
tree | 084e1cdf27a339ce58e24cff8fec8c31432b52db /firmware/target/arm/tms320dm320/sansa-connect/backlight-sansaconnect.c | |
parent | 992d4eb775cac48e107e18d72783ebfb39c4234f (diff) | |
download | rockbox-e8a8a1be43afe63079ae48ce1a9eb3052df3b1a4.tar.gz rockbox-e8a8a1be43afe63079ae48ce1a9eb3052df3b1a4.zip |
Sandisk Sansa Connect port (FS #12363)
Included are drivers for buttons, backlight, lcd, audio and storage.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31000 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tms320dm320/sansa-connect/backlight-sansaconnect.c')
-rw-r--r-- | firmware/target/arm/tms320dm320/sansa-connect/backlight-sansaconnect.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/backlight-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/backlight-sansaconnect.c new file mode 100644 index 0000000000..b7989849d7 --- /dev/null +++ b/firmware/target/arm/tms320dm320/sansa-connect/backlight-sansaconnect.c | |||
@@ -0,0 +1,93 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Tomasz Moń | ||
11 | * | ||
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. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "cpu.h" | ||
24 | #include "system.h" | ||
25 | #include "backlight-target.h" | ||
26 | #include "backlight.h" | ||
27 | #include "lcd.h" | ||
28 | #include "power.h" | ||
29 | #include "spi-target.h" | ||
30 | #include "lcd-target.h" | ||
31 | |||
32 | static void _backlight_write_brightness(int brightness) | ||
33 | { | ||
34 | /* | ||
35 | Maps brightness int to percentage value found in OF | ||
36 | |||
37 | OF PWM1H | ||
38 | 5% 14 | ||
39 | 10% 140 | ||
40 | 15% 210 | ||
41 | 20% 280 | ||
42 | ... | ||
43 | 95% 1330 | ||
44 | 100% 1400 | ||
45 | */ | ||
46 | if (brightness > 20) | ||
47 | brightness = 20; | ||
48 | else if (brightness < 0) | ||
49 | brightness = 0; | ||
50 | |||
51 | IO_CLK_PWM1H = brightness*70; | ||
52 | } | ||
53 | |||
54 | void _backlight_on(void) | ||
55 | { | ||
56 | /* set GIO34 as PWM1 */ | ||
57 | IO_GIO_FSEL3 = (IO_GIO_FSEL3 & 0xFFF3) | (1 << 2); | ||
58 | |||
59 | #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_NO_FADING) | ||
60 | _backlight_write_brightness(backlight_brightness); | ||
61 | #endif | ||
62 | } | ||
63 | |||
64 | void _backlight_off(void) | ||
65 | { | ||
66 | _backlight_write_brightness(0); | ||
67 | |||
68 | bitclr16(&IO_GIO_FSEL3, 0xC); /* set GIO34 to normal GIO */ | ||
69 | bitclr16(&IO_GIO_INV2, (1 << 2)); /* make sure GIO34 is not inverted */ | ||
70 | IO_GIO_BITCLR2 = (1 << 2); /* drive GIO34 low */ | ||
71 | } | ||
72 | |||
73 | /* Assumes that the backlight has been initialized */ | ||
74 | void _backlight_set_brightness(int brightness) | ||
75 | { | ||
76 | _backlight_write_brightness(brightness); | ||
77 | } | ||
78 | |||
79 | void __backlight_dim(bool dim_now) | ||
80 | { | ||
81 | _backlight_set_brightness(dim_now ? | ||
82 | DEFAULT_BRIGHTNESS_SETTING : | ||
83 | DEFAULT_DIMNESS_SETTING); | ||
84 | } | ||
85 | |||
86 | bool _backlight_init(void) | ||
87 | { | ||
88 | IO_CLK_PWM1C = 0x58D; /* as found in OF */ | ||
89 | |||
90 | _backlight_set_brightness(backlight_brightness); | ||
91 | return true; | ||
92 | } | ||
93 | |||