diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2006-07-26 13:38:31 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2006-07-26 13:38:31 +0000 |
commit | 40a3fd6938962a13b4f73c77b2058942c2a9c701 (patch) | |
tree | d51d4f8b159591aecbd6030b21bc0968fb40e64c /firmware/target | |
parent | b98b895bab8c63c889f47a70b341d1ddfc585da9 (diff) | |
download | rockbox-40a3fd6938962a13b4f73c77b2058942c2a9c701.tar.gz rockbox-40a3fd6938962a13b4f73c77b2058942c2a9c701.zip |
Remote LCD communication driver for X5, very loosely based on patch FS#5634 by Rani Hod
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10331 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
4 files changed, 219 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iaudio/x5/backlight-target.h b/firmware/target/coldfire/iaudio/x5/backlight-target.h index 5b6f7e1f8f..262650ae24 100755 --- a/firmware/target/coldfire/iaudio/x5/backlight-target.h +++ b/firmware/target/coldfire/iaudio/x5/backlight-target.h | |||
@@ -21,5 +21,7 @@ | |||
21 | 21 | ||
22 | void __backlight_on(void); | 22 | void __backlight_on(void); |
23 | void __backlight_off(void); | 23 | void __backlight_off(void); |
24 | void __remote_backlight_on(void); | ||
25 | void __remote_backlight_off(void); | ||
24 | 26 | ||
25 | #endif | 27 | #endif |
diff --git a/firmware/target/coldfire/iaudio/x5/backlight-x5.c b/firmware/target/coldfire/iaudio/x5/backlight-x5.c index 2b09d14b55..91c7224267 100755 --- a/firmware/target/coldfire/iaudio/x5/backlight-x5.c +++ b/firmware/target/coldfire/iaudio/x5/backlight-x5.c | |||
@@ -35,3 +35,13 @@ void __backlight_off(void) | |||
35 | pcf50606_write(0x38, 0x80); /* Backlight OFF, GPO1INV=1, GPO1ACT=000 */ | 35 | pcf50606_write(0x38, 0x80); /* Backlight OFF, GPO1INV=1, GPO1ACT=000 */ |
36 | set_irq_level(level); | 36 | set_irq_level(level); |
37 | } | 37 | } |
38 | |||
39 | void __remote_backlight_on(void) | ||
40 | { | ||
41 | and_l(~0x00200000, &GPIO_OUT); | ||
42 | } | ||
43 | |||
44 | void __remote_backlight_off(void) | ||
45 | { | ||
46 | or_l(0x00200000, &GPIO_OUT); | ||
47 | } | ||
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h b/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h new file mode 100755 index 0000000000..72d4ed9fb2 --- /dev/null +++ b/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef LCD_REMOTE_TARGET_H | ||
20 | #define LCD_REMOTE_TARGET_H | ||
21 | |||
22 | void lcd_remote_write_command(int cmd); | ||
23 | void lcd_remote_write_command_ex(int cmd, int data); | ||
24 | void lcd_remote_write_data(const unsigned char* p_bytes, int count); | ||
25 | bool remote_detect(void); | ||
26 | void lcd_remote_powersave(bool on); | ||
27 | void lcd_remote_set_contrast(int val); | ||
28 | void remote_set_row_and_col(int row, int col); | ||
29 | |||
30 | #endif | ||
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c b/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c new file mode 100755 index 0000000000..c1ec00f0e7 --- /dev/null +++ b/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c | |||
@@ -0,0 +1,177 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "system.h" | ||
21 | #include "kernel.h" | ||
22 | |||
23 | /* The LCD in the iAudio M3/M5/X5 remote control is a Tomato LSI 0350 */ | ||
24 | |||
25 | #define LCD_SET_DUTY_RATIO 0x48 | ||
26 | #define LCD_SELECT_ADC 0xa0 | ||
27 | #define LCD_SELECT_SHL 0xc0 | ||
28 | #define LCD_SET_COM0 0x44 | ||
29 | #define LCD_OSC_ON 0xab | ||
30 | #define LCD_SELECT_DCDC 0x64 | ||
31 | #define LCD_SELECT_RES 0x20 | ||
32 | #define LCD_SET_VOLUME 0x81 | ||
33 | #define LCD_SET_BIAS 0x50 | ||
34 | #define LCD_CONTROL_POWER 0x28 | ||
35 | #define LCD_DISPLAY_ON 0xae | ||
36 | #define LCD_SET_INITLINE 0x40 | ||
37 | #define LCD_SET_COLUMN 0x10 | ||
38 | #define LCD_SET_PAGE 0xb0 | ||
39 | #define LCD_SET_GRAY 0x88 | ||
40 | #define LCD_SET_PWM_FRC 0x90 | ||
41 | #define LCD_SET_POWER_SAVE 0xa8 | ||
42 | |||
43 | #define CS_LO and_l(~0x00000020, &GPIO1_OUT) | ||
44 | #define CS_HI or_l(0x00000020, &GPIO1_OUT) | ||
45 | #define CLK_LO and_l(~0x00004000, &GPIO_OUT) | ||
46 | #define CLK_HI or_l(0x00004000, &GPIO_OUT) | ||
47 | #define DATA_LO and_l(~0x00002000, &GPIO_OUT) | ||
48 | #define DATA_HI or_l(0x00002000, &GPIO_OUT) | ||
49 | #define RS_LO and_l(~0x00008000, &GPIO_OUT) | ||
50 | #define RS_HI or_l(0x00008000, &GPIO_OUT) | ||
51 | |||
52 | #define LCD_REMOTE_DEFAULT_CONTRAST 0x18; | ||
53 | |||
54 | static int cached_contrast = LCD_REMOTE_DEFAULT_CONTRAST; | ||
55 | static bool remote_initialized = false; | ||
56 | |||
57 | static void remote_write(unsigned char byte, bool is_command) | ||
58 | { | ||
59 | int i; | ||
60 | |||
61 | CS_LO; | ||
62 | if (is_command) | ||
63 | RS_LO; | ||
64 | else | ||
65 | RS_HI; | ||
66 | |||
67 | for (i = 0x80; i; i >>= 1) | ||
68 | { | ||
69 | CLK_LO; | ||
70 | if (i & byte) | ||
71 | DATA_HI; | ||
72 | else | ||
73 | DATA_LO; | ||
74 | CLK_HI; | ||
75 | } | ||
76 | |||
77 | CS_HI; | ||
78 | } | ||
79 | |||
80 | void lcd_remote_write_command(int cmd) | ||
81 | { | ||
82 | remote_write(cmd, true); | ||
83 | } | ||
84 | |||
85 | void lcd_remote_write_command_ex(int cmd, int data) | ||
86 | { | ||
87 | remote_write(cmd, true); | ||
88 | remote_write(data, true); | ||
89 | } | ||
90 | |||
91 | void lcd_remote_write_data(const unsigned char* p_bytes, int count) | ||
92 | { | ||
93 | while(count--) | ||
94 | remote_write(*p_bytes++, false); | ||
95 | } | ||
96 | |||
97 | void remote_set_row_and_col(int row, int col) | ||
98 | { | ||
99 | lcd_remote_write_command(LCD_SET_PAGE | (row & 0xf)); | ||
100 | lcd_remote_write_command_ex(LCD_SET_COLUMN | ((col >> 4) & 0xf), | ||
101 | col & 0xf); | ||
102 | } | ||
103 | |||
104 | int lcd_remote_default_contrast(void) | ||
105 | { | ||
106 | return LCD_REMOTE_DEFAULT_CONTRAST; | ||
107 | } | ||
108 | |||
109 | void lcd_remote_powersave(bool on) | ||
110 | { | ||
111 | if (on) | ||
112 | lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); | ||
113 | else | ||
114 | lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); | ||
115 | } | ||
116 | |||
117 | void lcd_remote_set_contrast(int val) | ||
118 | { | ||
119 | cached_contrast = val; | ||
120 | lcd_remote_write_command_ex(LCD_SET_VOLUME, val); | ||
121 | } | ||
122 | |||
123 | bool remote_detect(void) | ||
124 | { | ||
125 | return (GPIO_READ & 0x01000000); | ||
126 | } | ||
127 | |||
128 | void remote_init(void) | ||
129 | { | ||
130 | or_l(0x0000e000, &GPIO_OUT); | ||
131 | or_l(0x0000e000, &GPIO_ENABLE); | ||
132 | or_l(0x0000e000, &GPIO_FUNCTION); | ||
133 | |||
134 | or_l(0x00000020, &GPIO1_OUT); | ||
135 | or_l(0x00000020, &GPIO1_ENABLE); | ||
136 | or_l(0x00000020, &GPIO1_FUNCTION); | ||
137 | |||
138 | sleep(10); | ||
139 | |||
140 | lcd_remote_write_command(LCD_SET_DUTY_RATIO); | ||
141 | lcd_remote_write_command(0x70); /* 1/128 */ | ||
142 | |||
143 | lcd_remote_write_command(LCD_SELECT_ADC | 1); /* Reverse direction */ | ||
144 | lcd_remote_write_command(LCD_SELECT_SHL | 8); /* Reverse direction */ | ||
145 | |||
146 | lcd_remote_write_command(LCD_SET_COM0); | ||
147 | lcd_remote_write_command(0x00); | ||
148 | |||
149 | lcd_remote_write_command(LCD_OSC_ON); | ||
150 | |||
151 | lcd_remote_write_command(LCD_SELECT_DCDC | 2); /* DC/DC 5xboost */ | ||
152 | |||
153 | lcd_remote_write_command(LCD_SELECT_RES | 7); /* Regulator resistor: 7.2 */ | ||
154 | |||
155 | lcd_remote_write_command(LCD_SET_BIAS | 6); /* 1/11 */ | ||
156 | |||
157 | lcd_remote_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ | ||
158 | |||
159 | sleep(30); | ||
160 | |||
161 | lcd_remote_write_command_ex(LCD_SET_GRAY | 0, 0x00); | ||
162 | lcd_remote_write_command_ex(LCD_SET_GRAY | 1, 0x00); | ||
163 | lcd_remote_write_command_ex(LCD_SET_GRAY | 2, 0x0c); | ||
164 | lcd_remote_write_command_ex(LCD_SET_GRAY | 3, 0x00); | ||
165 | lcd_remote_write_command_ex(LCD_SET_GRAY | 4, 0xcc); | ||
166 | lcd_remote_write_command_ex(LCD_SET_GRAY | 5, 0x00); | ||
167 | lcd_remote_write_command_ex(LCD_SET_GRAY | 6, 0xcc); | ||
168 | lcd_remote_write_command_ex(LCD_SET_GRAY | 7, 0x0c); | ||
169 | |||
170 | lcd_remote_write_command(LCD_SET_PWM_FRC | 6); /* 4FRC + 12PWM */ | ||
171 | |||
172 | lcd_remote_write_command(LCD_DISPLAY_ON | 1); /* display on */ | ||
173 | |||
174 | remote_initialized = true; | ||
175 | |||
176 | lcd_remote_set_contrast(cached_contrast); | ||
177 | } | ||