summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES2
-rw-r--r--firmware/drivers/audio/wm8731.c13
-rw-r--r--firmware/export/config-h10.h6
-rw-r--r--firmware/export/config-h10_5gb.h6
-rw-r--r--firmware/target/arm/audio-pp.c16
-rw-r--r--firmware/target/arm/iriver/h10/fmradio_i2c-h10.c206
-rw-r--r--firmware/target/arm/iriver/h10/power-h10.c2
7 files changed, 237 insertions, 14 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index e78d74a198..465d10e662 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -557,6 +557,7 @@ target/arm/i2s-pp.c
557target/arm/iriver/h10/adc-h10.c 557target/arm/iriver/h10/adc-h10.c
558target/arm/iriver/h10/backlight-h10.c 558target/arm/iriver/h10/backlight-h10.c
559target/arm/iriver/h10/button-h10.c 559target/arm/iriver/h10/button-h10.c
560target/arm/iriver/h10/fmradio_i2c-h10.c
560target/arm/iriver/h10/lcd-h10_20gb.c 561target/arm/iriver/h10/lcd-h10_20gb.c
561target/arm/iriver/h10/power-h10.c 562target/arm/iriver/h10/power-h10.c
562target/arm/iriver/h10/powermgmt-h10.c 563target/arm/iriver/h10/powermgmt-h10.c
@@ -573,6 +574,7 @@ target/arm/i2s-pp.c
573target/arm/iriver/h10/adc-h10.c 574target/arm/iriver/h10/adc-h10.c
574target/arm/iriver/h10/backlight-h10.c 575target/arm/iriver/h10/backlight-h10.c
575target/arm/iriver/h10/button-h10.c 576target/arm/iriver/h10/button-h10.c
577target/arm/iriver/h10/fmradio_i2c-h10.c
576target/arm/iriver/h10/lcd-h10_5gb.c 578target/arm/iriver/h10/lcd-h10_5gb.c
577target/arm/iriver/h10/power-h10.c 579target/arm/iriver/h10/power-h10.c
578target/arm/iriver/h10/powermgmt-h10.c 580target/arm/iriver/h10/powermgmt-h10.c
diff --git a/firmware/drivers/audio/wm8731.c b/firmware/drivers/audio/wm8731.c
index 785cb2a91c..44aeefe791 100644
--- a/firmware/drivers/audio/wm8731.c
+++ b/firmware/drivers/audio/wm8731.c
@@ -319,6 +319,15 @@ void audiohw_set_recvol(int left, int right, int type)
319 319
320void audiohw_set_monitor(int enable) 320void audiohw_set_monitor(int enable)
321{ 321{
322 /* TODO: Implement for FM monitoring */ 322 if(enable)
323 (void)enable; 323 {
324 wm8731_regs[AAPCTRL] |= AAPCTRL_BYPASS;
325 wm8731_regs[AAPCTRL] &=~ (AAPCTRL_DACSEL | AAPCTRL_SIDETONE);
326 wm8731_write(AAPCTRL, wm8731_regs[AAPCTRL]);
327 }
328 else {
329 wm8731_regs[AAPCTRL] &=~ AAPCTRL_BYPASS;
330 wm8731_regs[AAPCTRL] |= AAPCTRL_DACSEL | AAPCTRL_SIDETONE;
331 wm8731_write(AAPCTRL, wm8731_regs[AAPCTRL]);
332 }
324} 333}
diff --git a/firmware/export/config-h10.h b/firmware/export/config-h10.h
index 039ebc588f..e1e0b54e28 100644
--- a/firmware/export/config-h10.h
+++ b/firmware/export/config-h10.h
@@ -12,7 +12,7 @@
12#define HAVE_RECORDING 12#define HAVE_RECORDING
13/* Define bitmask of input sources - recordable bitmask can be defined 13/* Define bitmask of input sources - recordable bitmask can be defined
14 explicitly if different */ 14 explicitly if different */
15#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN) 15#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO)
16 16
17/* define the bitmask of hardware sample rates */ 17/* define the bitmask of hardware sample rates */
18#define HW_SAMPR_CAPS (SAMPR_CAP_44) 18#define HW_SAMPR_CAPS (SAMPR_CAP_44)
@@ -88,8 +88,8 @@
88#define AB_REPEAT_ENABLE 1 88#define AB_REPEAT_ENABLE 1
89 89
90/* FM Tuner */ 90/* FM Tuner */
91/*#define CONFIG_TUNER TEA5767 91#define CONFIG_TUNER TEA5767
92#define CONFIG_TUNER_XTAL 32768 *//* TODO: what is this? */ 92#define CONFIG_TUNER_XTAL 32768
93 93
94/* Define this for LCD backlight available */ 94/* Define this for LCD backlight available */
95#define HAVE_BACKLIGHT 95#define HAVE_BACKLIGHT
diff --git a/firmware/export/config-h10_5gb.h b/firmware/export/config-h10_5gb.h
index 3d10af26cf..b7195221ca 100644
--- a/firmware/export/config-h10_5gb.h
+++ b/firmware/export/config-h10_5gb.h
@@ -12,7 +12,7 @@
12#define HAVE_RECORDING 12#define HAVE_RECORDING
13/* Define bitmask of input sources - recordable bitmask can be defined 13/* Define bitmask of input sources - recordable bitmask can be defined
14 explicitly if different */ 14 explicitly if different */
15#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN) 15#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO)
16 16
17/* define the bitmask of hardware sample rates */ 17/* define the bitmask of hardware sample rates */
18#define HW_SAMPR_CAPS (SAMPR_CAP_44) 18#define HW_SAMPR_CAPS (SAMPR_CAP_44)
@@ -74,8 +74,8 @@
74#define AB_REPEAT_ENABLE 1 74#define AB_REPEAT_ENABLE 1
75 75
76/* FM Tuner */ 76/* FM Tuner */
77/*#define CONFIG_TUNER TEA5767 77#define CONFIG_TUNER TEA5767
78#define CONFIG_TUNER_XTAL 32768 *//* TODO: what is this? */ 78#define CONFIG_TUNER_XTAL 32768
79 79
80/* Define this for LCD backlight available */ 80/* Define this for LCD backlight available */
81#define HAVE_BACKLIGHT 81#define HAVE_BACKLIGHT
diff --git a/firmware/target/arm/audio-pp.c b/firmware/target/arm/audio-pp.c
index 9fff197520..783342ef37 100644
--- a/firmware/target/arm/audio-pp.c
+++ b/firmware/target/arm/audio-pp.c
@@ -35,6 +35,7 @@ void audio_input_mux(int source, unsigned flags)
35 /* Prevent pops from unneeded switching */ 35 /* Prevent pops from unneeded switching */
36 static int last_source = AUDIO_SRC_PLAYBACK; 36 static int last_source = AUDIO_SRC_PLAYBACK;
37#ifdef HAVE_FMRADIO_REC 37#ifdef HAVE_FMRADIO_REC
38 bool recording = flags & SRCF_RECORDING;
38 static bool last_recording = false; 39 static bool last_recording = false;
39#endif 40#endif
40 41
@@ -62,6 +63,10 @@ void audio_input_mux(int source, unsigned flags)
62#endif 63#endif
63#ifdef HAVE_LINEIN_REC 64#ifdef HAVE_LINEIN_REC
64 case AUDIO_SRC_LINEIN: /* recording only */ 65 case AUDIO_SRC_LINEIN: /* recording only */
66#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
67 /* Switch line in source to line-in */
68 GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x04);
69#endif
65 if (source != last_source) 70 if (source != last_source)
66 { 71 {
67 audiohw_enable_recording(false); /* source line */ 72 audiohw_enable_recording(false); /* source line */
@@ -71,17 +76,20 @@ void audio_input_mux(int source, unsigned flags)
71#endif 76#endif
72#ifdef HAVE_FMRADIO_REC 77#ifdef HAVE_FMRADIO_REC
73 case AUDIO_SRC_FMRADIO: /* recording and playback */ 78 case AUDIO_SRC_FMRADIO: /* recording and playback */
79#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
80 /* Switch line in source to tuner */
81 GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x04);
82#endif /* Set line-in vol to 0dB*/
74 if (!recording) 83 if (!recording)
75 audiohw_set_recvol(0, 0, AUDIO_GAIN_LINEIN); 84 audiohw_set_recvol(0x17, 0x17, AUDIO_GAIN_LINEIN);
76 85
77 if (source == last_source && recording == last_recording) 86 if (source == last_source && recording == last_recording)
78 break; 87 break;
79 88
80 last_recording = recording; 89 last_recording = recording;
81 90
82 /* I2S recording and playback */ 91 audiohw_enable_recording(false); /* select line-in source */
83 audiohw_enable_recording(false); /* source line */ 92 audiohw_set_monitor(!recording); /* enable bypass mode */
84 audiohw_set_monitor(!recording);
85 break; 93 break;
86#endif 94#endif
87 } /* end switch */ 95 } /* end switch */
diff --git a/firmware/target/arm/iriver/h10/fmradio_i2c-h10.c b/firmware/target/arm/iriver/h10/fmradio_i2c-h10.c
new file mode 100644
index 0000000000..f3d3075df9
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/fmradio_i2c-h10.c
@@ -0,0 +1,206 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 * Physical interface of the Philips TEA5767 in iriver H10 series
10 *
11 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 *
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#include "config.h"
21#include "cpu.h"
22#include "logf.h"
23#include "system.h"
24
25/* cute little functions, atomic read-modify-write */
26
27#define SDA_OUTINIT GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x08)
28#define SDA_HI_IN GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_EN, 0x08)
29#define SDA_LO_OUT GPIO_SET_BITWISE(GPIOD_OUTPUT_EN, 0x08)
30#define SDA (GPIOD_INPUT_VAL & 0x08)
31
32#define SCL_INPUT GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_EN, 0x10)
33#define SCL_OUTPUT GPIO_SET_BITWISE(GPIOD_OUTPUT_EN, 0x10)
34#define SCL_LO GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x10)
35#define SCL_HI GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL,0x10)
36#define SCL (GPIOD_INPUT_VAL & 0x10)
37
38#define DELAY udelay(2)
39
40static void fmradio_i2c_start(void)
41{
42 SCL_HI;
43 SCL_OUTPUT;
44 SDA_HI_IN;
45 SDA_OUTINIT;
46 DELAY;
47 SDA_LO_OUT;
48 DELAY;
49 SCL_LO;
50}
51
52static void fmradio_i2c_stop(void)
53{
54 SDA_LO_OUT;
55 DELAY;
56 SCL_HI;
57 DELAY;
58 SDA_HI_IN;
59}
60
61/* Generate ACK or NACK */
62static void fmradio_i2c_ack(bool nack)
63{
64 /* Here's the deal. The slave is slow, and sometimes needs to wait
65 before it can receive the acknowledge. Therefore it forces the clock
66 low until it is ready. We need to poll the clock line until it goes
67 high before we release the ack.
68
69 In their infinite wisdom, iriver didn't pull up the SCL line, so
70 we have to drive the SCL high repeatedly to simulate a pullup. */
71
72 if (nack)
73 SDA_HI_IN;
74 else
75 SDA_LO_OUT;
76 DELAY;
77
78 SCL_HI;
79 do
80 {
81 SCL_OUTPUT; /* Set the clock to output */
82 SCL_INPUT; /* Set the clock to input */
83 DELAY;
84 }
85 while(!SCL); /* and wait for the slave to release it */
86
87 SCL_OUTPUT;
88 SCL_LO;
89}
90
91static int fmradio_i2c_getack(void)
92{
93 int ret = 1;
94
95 /* Here's the deal. The slave is slow, and sometimes needs to wait
96 before it can send the acknowledge. Therefore it forces the clock
97 low until it is ready. We need to poll the clock line until it goes
98 high before we read the ack.
99
100 In their infinite wisdom, iriver didn't pull up the SCL line, so
101 we have to drive the SCL high repeatedly to simulate a pullup. */
102
103 SDA_HI_IN;
104 DELAY;
105
106 SCL_HI; /* set clock to high */
107 do
108 {
109 SCL_OUTPUT; /* Set the clock to output */
110 SCL_INPUT; /* Set the clock to input */
111 DELAY;
112 }
113 while(!SCL); /* and wait for the slave to release it */
114
115 if (SDA)
116 ret = 0; /* ack failed */
117
118 SCL_OUTPUT;
119 SCL_LO;
120
121 return ret;
122}
123
124static void fmradio_i2c_outb(unsigned char byte)
125{
126 int i;
127
128 /* clock out each bit, MSB first */
129 for ( i=0x80; i; i>>=1 ) {
130 if ( i & byte )
131 SDA_HI_IN;
132 else
133 SDA_LO_OUT;
134 DELAY;
135 SCL_HI;
136 DELAY;
137 SCL_LO;
138 }
139}
140
141static unsigned char fmradio_i2c_inb(void)
142{
143 int i;
144 unsigned char byte = 0;
145
146 SDA_HI_IN;
147 /* clock in each bit, MSB first */
148 for ( i=0x80; i; i>>=1 ) {
149 DELAY;
150 SCL_HI;
151 DELAY;
152 if ( SDA )
153 byte |= i;
154 SCL_LO;
155 }
156
157 return byte;
158}
159
160int fmradio_i2c_write(int address, const unsigned char* buf, int count)
161{
162 int i,x=0;
163
164 fmradio_i2c_start();
165 fmradio_i2c_outb(address & 0xfe);
166 if (fmradio_i2c_getack())
167 {
168 for (i=0; i<count; i++)
169 {
170 fmradio_i2c_outb(buf[i]);
171 if (!fmradio_i2c_getack())
172 {
173 x=-2;
174 break;
175 }
176 }
177 }
178 else
179 {
180 logf("fmradio_i2c_write() - no ack\n");
181 x=-1;
182 }
183 fmradio_i2c_stop();
184 return x;
185}
186
187int fmradio_i2c_read(int address, unsigned char* buf, int count)
188{
189 int i,x=0;
190
191 fmradio_i2c_start();
192 fmradio_i2c_outb(address | 1);
193
194 if (fmradio_i2c_getack())
195 {
196 for (i=count; i>0; i--)
197 {
198 *buf++ = fmradio_i2c_inb();
199 fmradio_i2c_ack(i == 1);
200 }
201 }
202 else
203 x=-1;
204 fmradio_i2c_stop();
205 return x;
206}
diff --git a/firmware/target/arm/iriver/h10/power-h10.c b/firmware/target/arm/iriver/h10/power-h10.c
index 7f3fb40b36..f4d5be49a6 100644
--- a/firmware/target/arm/iriver/h10/power-h10.c
+++ b/firmware/target/arm/iriver/h10/power-h10.c
@@ -35,7 +35,6 @@
35bool charger_enabled; 35bool charger_enabled;
36#endif 36#endif
37 37
38#if 0
39#if CONFIG_TUNER 38#if CONFIG_TUNER
40 39
41bool tuner_power(bool status) 40bool tuner_power(bool status)
@@ -46,7 +45,6 @@ bool tuner_power(bool status)
46} 45}
47 46
48#endif /* #if CONFIG_TUNER */ 47#endif /* #if CONFIG_TUNER */
49#endif
50 48
51void power_init(void) 49void power_init(void)
52{ 50{