diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 3 | ||||
-rw-r--r-- | firmware/drivers/audio/uda1380.c | 43 | ||||
-rw-r--r-- | firmware/export/config-meizu-m3.h | 4 | ||||
-rw-r--r-- | firmware/export/udacodec.h | 31 | ||||
-rw-r--r-- | firmware/sound.c | 3 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/udacodec-meizu.c | 62 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/udacodec-iriver.c | 76 |
7 files changed, 183 insertions, 39 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 5365d70040..f6bc547f45 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -689,6 +689,7 @@ target/coldfire/iriver/h300/powermgmt-h300.c | |||
689 | target/coldfire/iriver/h300/usb-h300.c | 689 | target/coldfire/iriver/h300/usb-h300.c |
690 | #ifndef BOOTLOADER | 690 | #ifndef BOOTLOADER |
691 | target/coldfire/iriver/audio-iriver.c | 691 | target/coldfire/iriver/audio-iriver.c |
692 | target/coldfire/iriver/udacodec-iriver.c | ||
692 | #endif | 693 | #endif |
693 | #endif /* SIMULATOR */ | 694 | #endif /* SIMULATOR */ |
694 | #endif /* IRIVER_H300_SERIES */ | 695 | #endif /* IRIVER_H300_SERIES */ |
@@ -711,6 +712,7 @@ target/coldfire/iriver/h100/power-h100.c | |||
711 | target/coldfire/iriver/h100/powermgmt-h100.c | 712 | target/coldfire/iriver/h100/powermgmt-h100.c |
712 | #ifndef BOOTLOADER | 713 | #ifndef BOOTLOADER |
713 | target/coldfire/iriver/audio-iriver.c | 714 | target/coldfire/iriver/audio-iriver.c |
715 | target/coldfire/iriver/udacodec-iriver.c | ||
714 | target/coldfire/iriver/h100/spdif-h100.c | 716 | target/coldfire/iriver/h100/spdif-h100.c |
715 | #endif | 717 | #endif |
716 | target/coldfire/iriver/h100/usb-h100.c | 718 | target/coldfire/iriver/h100/usb-h100.c |
@@ -1250,6 +1252,7 @@ target/arm/s5l8700/meizu-m3/lcd-m3.c | |||
1250 | drivers/qt1106.c | 1252 | drivers/qt1106.c |
1251 | #ifndef SIMULATOR | 1253 | #ifndef SIMULATOR |
1252 | #ifndef BOOTLOADER | 1254 | #ifndef BOOTLOADER |
1255 | target/arm/s5l8700/udacodec-meizu.c | ||
1253 | #endif /* BOOTLOADER */ | 1256 | #endif /* BOOTLOADER */ |
1254 | #endif /* SIMULATOR */ | 1257 | #endif /* SIMULATOR */ |
1255 | #endif /* MEIZU_M3 */ | 1258 | #endif /* MEIZU_M3 */ |
diff --git a/firmware/drivers/audio/uda1380.c b/firmware/drivers/audio/uda1380.c index efe02caca8..11a0604a1b 100644 --- a/firmware/drivers/audio/uda1380.c +++ b/firmware/drivers/audio/uda1380.c | |||
@@ -18,15 +18,16 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include <string.h> | ||
22 | |||
23 | #include "config.h" | ||
21 | #include "logf.h" | 24 | #include "logf.h" |
22 | #include "system.h" | 25 | #include "system.h" |
23 | #include "string.h" | ||
24 | #include "audio.h" | 26 | #include "audio.h" |
25 | #include "debug.h" | 27 | #include "debug.h" |
28 | #include "udacodec.h" | ||
26 | 29 | ||
27 | #include "i2c-coldfire.h" | ||
28 | #include "audiohw.h" | 30 | #include "audiohw.h" |
29 | #include "pcf50606.h" | ||
30 | 31 | ||
31 | const struct sound_settings_info audiohw_settings[] = { | 32 | const struct sound_settings_info audiohw_settings[] = { |
32 | [SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25}, | 33 | [SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25}, |
@@ -109,13 +110,7 @@ unsigned short uda1380_defaults[2*NUM_DEFAULT_REGS] = | |||
109 | /* Returns 0 if register was written or -1 if write failed */ | 110 | /* Returns 0 if register was written or -1 if write failed */ |
110 | static int uda1380_write_reg(unsigned char reg, unsigned short value) | 111 | static int uda1380_write_reg(unsigned char reg, unsigned short value) |
111 | { | 112 | { |
112 | unsigned char data[3]; | 113 | if (udacodec_write(reg, value) < 0) |
113 | |||
114 | data[0] = reg; | ||
115 | data[1] = value >> 8; | ||
116 | data[2] = value & 0xff; | ||
117 | |||
118 | if (i2c_write(I2C_IFACE_0, UDA1380_ADDR, data, 3) != 3) | ||
119 | { | 114 | { |
120 | DEBUGF("uda1380 error reg=0x%x", reg); | 115 | DEBUGF("uda1380 error reg=0x%x", reg); |
121 | return -1; | 116 | return -1; |
@@ -193,23 +188,6 @@ static int audiohw_set_regs(void) | |||
193 | return 0; | 188 | return 0; |
194 | } | 189 | } |
195 | 190 | ||
196 | static void reset(void) | ||
197 | { | ||
198 | #ifdef IRIVER_H300_SERIES | ||
199 | int mask = disable_irq_save(); | ||
200 | pcf50606_write(0x3b, 0x00); /* GPOOD2 high Z */ | ||
201 | pcf50606_write(0x3b, 0x07); /* GPOOD2 low */ | ||
202 | restore_irq(mask); | ||
203 | #else | ||
204 | /* RESET signal */ | ||
205 | or_l(1<<29, &GPIO_OUT); | ||
206 | or_l(1<<29, &GPIO_ENABLE); | ||
207 | or_l(1<<29, &GPIO_FUNCTION); | ||
208 | sleep(HZ/100); | ||
209 | and_l(~(1<<29), &GPIO_OUT); | ||
210 | #endif | ||
211 | } | ||
212 | |||
213 | /** | 191 | /** |
214 | * Sets frequency settings for DAC and ADC relative to MCLK | 192 | * Sets frequency settings for DAC and ADC relative to MCLK |
215 | * | 193 | * |
@@ -268,7 +246,7 @@ void audiohw_init(void) | |||
268 | recgain_mic = 0; | 246 | recgain_mic = 0; |
269 | recgain_line = 0; | 247 | recgain_line = 0; |
270 | 248 | ||
271 | reset(); | 249 | udacodec_reset(); |
272 | 250 | ||
273 | if (audiohw_set_regs() == -1) | 251 | if (audiohw_set_regs() == -1) |
274 | { | 252 | { |
@@ -419,20 +397,13 @@ void audiohw_set_recvol(int left, int right, int type) | |||
419 | { | 397 | { |
420 | /* for this order we can combine both registers, | 398 | /* for this order we can combine both registers, |
421 | making the glitch even smaller */ | 399 | making the glitch even smaller */ |
422 | unsigned char data[5]; | ||
423 | unsigned short value_dec; | 400 | unsigned short value_dec; |
424 | unsigned short value_pga; | 401 | unsigned short value_pga; |
425 | value_dec = DEC_VOLL(left) | DEC_VOLR(right); | 402 | value_dec = DEC_VOLL(left) | DEC_VOLR(right); |
426 | value_pga = (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) | 403 | value_pga = (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK) |
427 | | PGA_GAINL(left_ag) | PGA_GAINR(right_ag); | 404 | | PGA_GAINL(left_ag) | PGA_GAINR(right_ag); |
428 | 405 | ||
429 | data[0] = REG_DEC_VOL; | 406 | if (udacodec_write2(REG_DEC_VOL, value_dec, value_pga) < 0) |
430 | data[1] = value_dec >> 8; | ||
431 | data[2] = value_dec & 0xff; | ||
432 | data[3] = value_pga >> 8; | ||
433 | data[4] = value_pga & 0xff; | ||
434 | |||
435 | if (i2c_write(I2C_IFACE_0, UDA1380_ADDR, data, 5) != 5) | ||
436 | { | 407 | { |
437 | DEBUGF("uda1380 error reg=combi rec gain"); | 408 | DEBUGF("uda1380 error reg=combi rec gain"); |
438 | } | 409 | } |
diff --git a/firmware/export/config-meizu-m3.h b/firmware/export/config-meizu-m3.h index 2a02052381..4bb2e68725 100644 --- a/firmware/export/config-meizu-m3.h +++ b/firmware/export/config-meizu-m3.h | |||
@@ -85,8 +85,8 @@ | |||
85 | 85 | ||
86 | #define CONFIG_LCD LCD_MEIZUM6 | 86 | #define CONFIG_LCD LCD_MEIZUM6 |
87 | 87 | ||
88 | /* Define this if you have the WM8975 audio codec */ | 88 | /* Define the type of audio codec */ |
89 | #define HAVE_WM8751 //FIXME | 89 | #define HAVE_UDA1380 |
90 | 90 | ||
91 | /* Define this for LCD backlight available */ | 91 | /* Define this for LCD backlight available */ |
92 | #define HAVE_BACKLIGHT | 92 | #define HAVE_BACKLIGHT |
diff --git a/firmware/export/udacodec.h b/firmware/export/udacodec.h new file mode 100644 index 0000000000..beca43329e --- /dev/null +++ b/firmware/export/udacodec.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Bertrik Sikken | ||
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 | /* perform a hardware reset of the codec */ | ||
23 | void udacodec_reset(void); | ||
24 | |||
25 | /* write a single register */ | ||
26 | int udacodec_write(unsigned char reg, unsigned short value); | ||
27 | |||
28 | /* write two consecutive registers */ | ||
29 | int udacodec_write2(unsigned char reg, | ||
30 | unsigned short value1, unsigned short value2); | ||
31 | |||
diff --git a/firmware/sound.c b/firmware/sound.c index bca98b039c..f4a2f87ca5 100644 --- a/firmware/sound.c +++ b/firmware/sound.c | |||
@@ -615,12 +615,13 @@ int sound_val2phys(int setting, int value) | |||
615 | 615 | ||
616 | switch(setting) | 616 | switch(setting) |
617 | { | 617 | { |
618 | #ifdef HAVE_RECORDING | ||
618 | case SOUND_LEFT_GAIN: | 619 | case SOUND_LEFT_GAIN: |
619 | case SOUND_RIGHT_GAIN: | 620 | case SOUND_RIGHT_GAIN: |
620 | case SOUND_MIC_GAIN: | 621 | case SOUND_MIC_GAIN: |
621 | result = value * 5; /* (1/2) * 10 */ | 622 | result = value * 5; /* (1/2) * 10 */ |
622 | break; | 623 | break; |
623 | 624 | #endif | |
624 | default: | 625 | default: |
625 | result = value; | 626 | result = value; |
626 | break; | 627 | break; |
diff --git a/firmware/target/arm/s5l8700/udacodec-meizu.c b/firmware/target/arm/s5l8700/udacodec-meizu.c new file mode 100644 index 0000000000..89588367c4 --- /dev/null +++ b/firmware/target/arm/s5l8700/udacodec-meizu.c | |||
@@ -0,0 +1,62 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Bertrik Sikken | ||
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 "kernel.h" | ||
24 | #include "s5l8700.h" | ||
25 | #include "i2c-s5l8700.h" | ||
26 | #include "uda1380.h" | ||
27 | #include "udacodec.h" | ||
28 | |||
29 | void udacodec_reset(void) | ||
30 | { | ||
31 | /* Reset codec using GPIO P5.0 */ | ||
32 | PCON5 = (PCON5 & ~0xF) | 1; | ||
33 | PDAT5 |= (1 << 0); | ||
34 | sleep(HZ/100); | ||
35 | |||
36 | /* Set codec reset pin inactive */ | ||
37 | PDAT5 &= ~(1 << 0); | ||
38 | } | ||
39 | |||
40 | int udacodec_write(unsigned char reg, unsigned short value) | ||
41 | { | ||
42 | unsigned char data[2]; | ||
43 | |||
44 | data[0] = value >> 8; | ||
45 | data[1] = value & 0xFF; | ||
46 | |||
47 | return i2c_write(UDA1380_ADDR, reg, 2, data); | ||
48 | } | ||
49 | |||
50 | int udacodec_write2(unsigned char reg, | ||
51 | unsigned short value1, unsigned short value2) | ||
52 | { | ||
53 | unsigned char data[4]; | ||
54 | |||
55 | data[0] = value1 >> 8; | ||
56 | data[1] = value1 & 0xFF; | ||
57 | data[2] = value2 >> 8; | ||
58 | data[3] = value2 & 0xFF; | ||
59 | |||
60 | return i2c_write(UDA1380_ADDR, reg, 4, data); | ||
61 | } | ||
62 | |||
diff --git a/firmware/target/coldfire/iriver/udacodec-iriver.c b/firmware/target/coldfire/iriver/udacodec-iriver.c new file mode 100644 index 0000000000..6c41964ffa --- /dev/null +++ b/firmware/target/coldfire/iriver/udacodec-iriver.c | |||
@@ -0,0 +1,76 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Bertrik Sikken | ||
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 "kernel.h" | ||
24 | #include "i2c-coldfire.h" | ||
25 | #include "pcf50606.h" | ||
26 | #include "uda1380.h" | ||
27 | #include "udacodec.h" | ||
28 | |||
29 | void udacodec_reset(void) | ||
30 | { | ||
31 | #ifdef IRIVER_H300_SERIES | ||
32 | int mask = disable_irq_save(); | ||
33 | pcf50606_write(0x3b, 0x00); /* GPOOD2 high Z */ | ||
34 | pcf50606_write(0x3b, 0x07); /* GPOOD2 low */ | ||
35 | restore_irq(mask); | ||
36 | #else | ||
37 | /* RESET signal */ | ||
38 | or_l(1<<29, &GPIO_OUT); | ||
39 | or_l(1<<29, &GPIO_ENABLE); | ||
40 | or_l(1<<29, &GPIO_FUNCTION); | ||
41 | sleep(HZ/100); | ||
42 | and_l(~(1<<29), &GPIO_OUT); | ||
43 | #endif | ||
44 | } | ||
45 | |||
46 | int udacodec_write(unsigned char reg, unsigned short value) | ||
47 | { | ||
48 | unsigned char data[3]; | ||
49 | |||
50 | data[0] = reg; | ||
51 | data[1] = value >> 8; | ||
52 | data[2] = value & 0xff; | ||
53 | |||
54 | if (i2c_write(I2C_IFACE_0, UDA1380_ADDR, data, 3) != 3) { | ||
55 | return -1; | ||
56 | } | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | int udacodec_write2(unsigned char reg, | ||
61 | unsigned short value1, unsigned short value2) | ||
62 | { | ||
63 | unsigned char data[5]; | ||
64 | |||
65 | data[0] = reg; | ||
66 | data[1] = value1 >> 8; | ||
67 | data[2] = value1 & 0xFF; | ||
68 | data[3] = value2 >> 8; | ||
69 | data[4] = value2 & 0xFF; | ||
70 | |||
71 | if (i2c_write(I2C_IFACE_0, UDA1380_ADDR, data, 5) != 5) { | ||
72 | return -1; | ||
73 | } | ||
74 | return 0; | ||
75 | } | ||
76 | |||