summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iaudio/x5/audio-x5.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2006-11-23 19:21:15 +0000
committerMichael Sevakis <jethead71@rockbox.org>2006-11-23 19:21:15 +0000
commitab1861a3c2c06cf3edff7c42348d117f21235e48 (patch)
treee41eddf45f5348a2d954ac97984fbf7a7c61bd6c /firmware/target/coldfire/iaudio/x5/audio-x5.c
parent069c54d5d87378ccd73d84be2606ec2ab654bc21 (diff)
downloadrockbox-ab1861a3c2c06cf3edff7c42348d117f21235e48.tar.gz
rockbox-ab1861a3c2c06cf3edff7c42348d117f21235e48.zip
iRiver/iAudio: Added audio_set_recording gain and sound_default to plugin API. Simplified plugin recording by target/-ing some audio functions. UDA1380 records with WSPLL as a result.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11577 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/coldfire/iaudio/x5/audio-x5.c')
-rw-r--r--firmware/target/coldfire/iaudio/x5/audio-x5.c126
1 files changed, 126 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iaudio/x5/audio-x5.c b/firmware/target/coldfire/iaudio/x5/audio-x5.c
new file mode 100644
index 0000000000..70ef78ff22
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/x5/audio-x5.c
@@ -0,0 +1,126 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Michael Sevakis
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 "system.h"
20#include "cpu.h"
21#include "audio.h"
22#include "tlv320.h"
23
24/**
25 * Note that microphone is mono, only left value is used
26 * See tlv320_set_recvol() for exact ranges.
27 *
28 * @param type 0=line-in (radio), 1=mic
29 *
30 */
31void audio_set_recording_gain(int left, int right, int type)
32{
33 //logf("rcmrec: t=%d l=%d r=%d", type, left, right);
34 tlv320_set_recvol(left, right, type);
35} /* audio_set_recording_gain */
36
37void audio_set_output_source(int source)
38{
39 unsigned long txsrc;
40
41 if ((unsigned)source >= AUDIO_NUM_SOURCES)
42 txsrc = (3 << 8); /* playback, PDOR3 */
43 else
44 txsrc = (4 << 8); /* recording, iis1RcvData */
45
46 IIS1CONFIG = (IIS1CONFIG & ~(7 << 8)) | txsrc;
47} /* audio_set_output_source */
48
49void audio_set_source(int source, unsigned flags)
50{
51 /* Prevent pops from unneeded switching */
52 static int last_source = AUDIO_SRC_PLAYBACK;
53 static bool last_recording = false;
54
55 bool recording = flags & SRCF_RECORDING;
56
57 switch (source)
58 {
59 default: /* playback - no recording */
60 source = AUDIO_SRC_PLAYBACK;
61 case AUDIO_SRC_PLAYBACK:
62 if (source != last_source)
63 {
64 tlv320_disable_recording();
65 tlv320_set_monitor(false);
66 /* Reset PDIR2 data flow */
67 DATAINCONTROL = (1 << 9);
68 }
69 break;
70
71 case AUDIO_SRC_MIC: /* recording only */
72 if (source != last_source)
73 {
74 tlv320_enable_recording(true); /* source mic */
75 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
76 DATAINCONTROL = (3 << 14) | (4 << 3);
77 }
78 break;
79
80 case AUDIO_SRC_LINEIN: /* recording only */
81 if (source != last_source)
82 {
83 tlv320_enable_recording(false); /* source line */
84 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
85 DATAINCONTROL = (3 << 14) | (4 << 3);
86 }
87 break;
88
89 case AUDIO_SRC_FMRADIO: /* recording and playback */
90 if (!recording)
91 tlv320_set_recvol(23, 23, AUDIO_GAIN_LINEIN);
92
93 /* I2S recording and analog playback */
94 if (source == last_source && recording == last_recording)
95 break;
96
97 last_recording = recording;
98
99 if (recording)
100 {
101 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
102 DATAINCONTROL = (3 << 14) | (4 << 3);
103 tlv320_enable_recording(false); /* source line */
104 }
105 else
106 {
107 tlv320_disable_recording();
108 tlv320_set_monitor(true); /* analog bypass */
109 /* Reset PDIR2 data flow */
110 DATAINCONTROL = (1 << 9);
111 }
112 break;
113 } /* end switch */
114
115 /* set line multiplexer */
116 if (source == AUDIO_SRC_FMRADIO)
117 and_l(~(1 << 29), &GPIO_OUT); /* FM radio */
118 else
119 or_l((1 << 29), &GPIO_OUT); /* Line In */
120
121 or_l((1 << 29), &GPIO_ENABLE);
122 or_l((1 << 29), &GPIO_FUNCTION);
123
124 last_source = source;
125} /* audio_set_source */
126