summaryrefslogtreecommitdiff
path: root/bootloader/samsung_yps3.c
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader/samsung_yps3.c')
-rw-r--r--bootloader/samsung_yps3.c67
1 files changed, 53 insertions, 14 deletions
diff --git a/bootloader/samsung_yps3.c b/bootloader/samsung_yps3.c
index 511b6208a4..33115a92ac 100644
--- a/bootloader/samsung_yps3.c
+++ b/bootloader/samsung_yps3.c
@@ -54,6 +54,7 @@
54#include "tuner.h" 54#include "tuner.h"
55#include "si4700.h" 55#include "si4700.h"
56#include "fmradio_i2c.h" 56#include "fmradio_i2c.h"
57#include "wmcodec.h"
57 58
58char version[] = APPSVERSION; 59char version[] = APPSVERSION;
59#define LONG_DELAY 200000 60#define LONG_DELAY 200000
@@ -77,8 +78,10 @@ void main(void)
77 int i; 78 int i;
78 struct si4700_dbg_info si4700_info; 79 struct si4700_dbg_info si4700_info;
79// unsigned int data; 80// unsigned int data;
80 int brightness = 0; 81 int brightness = DEFAULT_BRIGHTNESS_SETTING;
81 unsigned int button; 82 unsigned int button;
83 unsigned int fm_frequency = 100700000;
84 int audiovol = 0x60;
82 85
83 // enable all peripherals 86 // enable all peripherals
84 PWRCON = 0; 87 PWRCON = 0;
@@ -113,18 +116,31 @@ void main(void)
113 fmradio_i2c_init(); 116 fmradio_i2c_init();
114 adc_init(); 117 adc_init();
115 _backlight_init(); 118 _backlight_init();
116 119 button_init_device();
120
117 // FM power 121 // FM power
118 si4700_init(); 122 si4700_init();
119 tuner_power(true); 123 tuner_power(true);
120 si4700_set(RADIO_SLEEP, 0); 124 si4700_set(RADIO_SLEEP, 0);
121 si4700_set(RADIO_MUTE, 0); 125 si4700_set(RADIO_MUTE, 0);
122 si4700_set(RADIO_FREQUENCY, 100700000); 126 si4700_set(RADIO_FREQUENCY, fm_frequency);
123 127
124 lcd_puts_scroll(0,0,"+++ this is a very very long line to test scrolling. ---"); 128 lcd_puts_scroll(0,0,"+++ this is a very very long line to test scrolling. ---");
125 129
126 button_init_device(); 130 // WM1800 codec configuration
131 wmcodec_write(0x0F, 0); // codec reset
132 wmcodec_write(0x19, 0xF0); // pwr mgmt1: VMID = 1, VREF, AINL, AINR
133 wmcodec_write(0x1A, 0x60); // pwr mgmt2: LOUT1, ROUT1
134 wmcodec_write(0x2F, 0x0C); // pwr mgmt3: LOMIX, ROMIX
135 wmcodec_write(0x02, audiovol); // LOUT1VOL
136 wmcodec_write(0x03, audiovol | (1 << 8)); // ROUT1VOL
137 wmcodec_write(0x22, (1 << 7) | (7 << 4)); // left out mix (1)
138 wmcodec_write(0x25, (1 << 7) | (7 << 4)); // right out mix (2)
127 139
140 // enable audio
141 PCON5 = (PCON5 & ~0x0000000F) | 0x00000001;
142 PDAT5 |= 1;
143
128 while (true) 144 while (true)
129 { 145 {
130 line = 1; 146 line = 1;
@@ -143,17 +159,19 @@ void main(void)
143 lcd_puts(0, line++, mystring); 159 lcd_puts(0, line++, mystring);
144#endif 160#endif
145 161
146#if 0 /* enable this so see info about the codec */ 162#if 1 /* enable this to see radio debug info */
147 memset(read_data, 0, sizeof(read_data)); 163 button = button_read_device();
148 for (i = 0; i < 1; i++) { 164 if (button & BUTTON_RIGHT) {
149 i2c_read(0x34, i, 2, read_data); 165 fm_frequency += 100000;
150 data = read_data[0] << 8 | read_data[1]; 166 si4700_set(RADIO_FREQUENCY, fm_frequency);
151 snprintf(mystring + 4 * i, 64, "%04X", data); 167 }
168 if (button & BUTTON_LEFT) {
169 fm_frequency -= 100000;
170 si4700_set(RADIO_FREQUENCY, fm_frequency);
152 } 171 }
172 snprintf(mystring, 64, "FM frequency: %9d", fm_frequency);
153 lcd_puts(0, line++, mystring); 173 lcd_puts(0, line++, mystring);
154#endif
155 174
156#if 1 /* enable this to see radio debug info */
157 si4700_dbg_info(&si4700_info); 175 si4700_dbg_info(&si4700_info);
158 col = snprintf(mystring, 64, "FM: "); 176 col = snprintf(mystring, 64, "FM: ");
159 for (i = 0; i < 16; i++) { 177 for (i = 0; i < 16; i++) {
@@ -166,6 +184,26 @@ void main(void)
166 line = rds_decode(line, &si4700_info); 184 line = rds_decode(line, &si4700_info);
167#endif 185#endif
168 186
187#if 1 /* volume control with up/down keys */
188 button = button_read_device();
189 if (button & BUTTON_UP) {
190 if (audiovol < 127) {
191 audiovol++;
192 wmcodec_write(0x02, audiovol);
193 wmcodec_write(0x03, (1 << 8) | audiovol);
194 }
195 }
196 if (button & BUTTON_DOWN) {
197 if (audiovol > 0) {
198 audiovol--;
199 wmcodec_write(0x02, audiovol);
200 wmcodec_write(0x03, (1 << 8) | audiovol);
201 }
202 }
203 snprintf(mystring, 64, "volume %3d", audiovol);
204 lcd_puts(0, line++, mystring);
205#endif
206
169#if 1 /* enable this to see ADC info */ 207#if 1 /* enable this to see ADC info */
170 snprintf(mystring, 64, "%04X %04X %04X %04X", adc_read(0), adc_read(1), adc_read(2), adc_read(3)); 208 snprintf(mystring, 64, "%04X %04X %04X %04X", adc_read(0), adc_read(1), adc_read(2), adc_read(3));
171 lcd_puts(0, line++, mystring); 209 lcd_puts(0, line++, mystring);
@@ -211,13 +249,14 @@ void main(void)
211#endif 249#endif
212 250
213#if 1 /* backlight brightness controlled by up/down keys */ 251#if 1 /* backlight brightness controlled by up/down keys */
214 if (button_read_device() & BUTTON_UP) { 252 button = button_read_device();
253 if (button & BUTTON_MENU) {
215 if (brightness < MAX_BRIGHTNESS_SETTING) { 254 if (brightness < MAX_BRIGHTNESS_SETTING) {
216 brightness++; 255 brightness++;
217 _backlight_set_brightness(brightness); 256 _backlight_set_brightness(brightness);
218 } 257 }
219 } 258 }
220 else if (button_read_device() & BUTTON_DOWN) { 259 else if (button & BUTTON_BACK) {
221 if (brightness > MIN_BRIGHTNESS_SETTING) { 260 if (brightness > MIN_BRIGHTNESS_SETTING) {
222 brightness--; 261 brightness--;
223 _backlight_set_brightness(brightness); 262 _backlight_set_brightness(brightness);