summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/audio/uda1341.c184
1 files changed, 184 insertions, 0 deletions
diff --git a/firmware/drivers/audio/uda1341.c b/firmware/drivers/audio/uda1341.c
new file mode 100644
index 0000000000..f9d95eff02
--- /dev/null
+++ b/firmware/drivers/audio/uda1341.c
@@ -0,0 +1,184 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: uda1380.c 21975 2009-07-19 22:45:32Z bertrik $
9 *
10 * Copyright (C) 2009 by Bob Cousins
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#include <string.h>
22
23#include "config.h"
24#include "logf.h"
25#include "system.h"
26#include "audio.h"
27#include "debug.h"
28
29#include "audiohw.h"
30
31
32const struct sound_settings_info audiohw_settings[] = {
33 [SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25},
34 [SOUND_BASS] = {"dB", 0, 2, 0, 24, 0},
35 [SOUND_TREBLE] = {"dB", 0, 2, 0, 6, 0},
36 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
37 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
38 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
39#ifdef HAVE_RECORDING
40 [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0},
41 [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0},
42 [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16},
43#endif
44};
45
46/****************************************************************************/
47
48/* ------------------------------------------------- */
49/* Local functions and variables */
50/* ------------------------------------------------- */
51
52/* Generic L3 functions */
53
54#define L3PORT GPBDAT
55#define L3MODE (1 << 2)
56#define L3DATA (1 << 3)
57#define L3CLOCK (1 << 4)
58
59static void l3_init (void)
60{
61 L3PORT |= L3MODE | L3CLOCK;
62 L3PORT &= L3DATA;
63
64 S3C2440_GPIO_CONFIG (GPBCON, 2, GPIO_OUTPUT); /* L3 MODE */
65 S3C2440_GPIO_CONFIG (GPBCON, 3, GPIO_OUTPUT); /* L3 DATA */
66 S3C2440_GPIO_CONFIG (GPBCON, 4, GPIO_OUTPUT); /* L3 CLOCK */
67
68 S3C2440_GPIO_PULLUP (GPBUP, 2, GPIO_PULLUP_DISABLE);
69 S3C2440_GPIO_PULLUP (GPBUP, 3, GPIO_PULLUP_DISABLE);
70 S3C2440_GPIO_PULLUP (GPBUP, 4, GPIO_PULLUP_DISABLE);
71}
72
73static void bit_delay (void)
74{
75 int j;
76 for (j=0; j<4; j++)
77 ;
78}
79
80static void l3_write_byte (unsigned char data, bool address_mode)
81{
82 int bit;
83
84 L3PORT |= L3CLOCK;
85 if (address_mode)
86 L3PORT &= ~L3MODE;
87 else
88 L3PORT |= L3MODE;
89
90 for (bit=0; bit < 8; bit++)
91 {
92 if (data & 1)
93 {
94 L3PORT |= L3DATA;
95 }
96 else
97 {
98 L3PORT &= ~L3DATA;
99 }
100 L3PORT &= ~L3CLOCK;
101 bit_delay();
102 L3PORT |= L3CLOCK;
103 bit_delay();
104
105 data >>= 1;
106 }
107
108 if (address_mode)
109 L3PORT |= L3MODE;
110 else
111 L3PORT &= ~L3MODE;
112 bit_delay();
113}
114
115static void l3_write_addr (unsigned char addr)
116{
117 /* write address byte */
118 l3_write_byte (addr, true);
119}
120
121static void l3_write_data (unsigned char data)
122{
123 /* write data byte */
124 l3_write_byte (data, false);
125}
126
127/****************************************************************************/
128
129/* UDA1341 access functions */
130
131static int udacodec_write(unsigned char reg, unsigned short value)
132{
133 l3_write_addr (UDA1341_ADDR | reg);
134 l3_write_data (value & 0xff);
135 return 0;
136}
137
138static void udacodec_reset(void)
139{
140 /* uda reset */
141 l3_init();
142
143 udacodec_write (UDA_REG_STATUS, UDA_STATUS_0 | UDA_RESET | UDA_SYSCLK_256FS |
144 I2S_IFMT_IIS);
145 udacodec_write (UDA_REG_STATUS, UDA_STATUS_0 | UDA_SYSCLK_256FS | I2S_IFMT_IIS);
146 udacodec_write (UDA_REG_STATUS, UDA_STATUS_1 | UDA_POWER_DAC_ON);
147}
148
149/****************************************************************************/
150
151/* Audio API functions */
152
153void audiohw_init(void)
154{
155 udacodec_reset();
156}
157
158void audiohw_close(void)
159{
160}
161
162void audiohw_set_bass(int value)
163{
164}
165
166void audiohw_set_treble(int value)
167{
168}
169
170void audiohw_mute(bool mute)
171{
172}
173
174void audiohw_set_prescaler(int val)
175{
176}
177
178void audiohw_postinit(void)
179{
180}
181
182void audiohw_set_frequency(int fsel)
183{
184}