summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2009-06-28 17:43:04 +0000
committerBertrik Sikken <bertrik@sikken.nl>2009-06-28 17:43:04 +0000
commit7df759c95107bc8e5f9a6ba17f77114fa9d80357 (patch)
tree476eba9a9add512991bd237e366c0704124d9c12 /firmware
parentc3f9ab46dea336437b7fb6113a76d75fe1b0c119 (diff)
downloadrockbox-7df759c95107bc8e5f9a6ba17f77114fa9d80357.tar.gz
rockbox-7df759c95107bc8e5f9a6ba17f77114fa9d80357.tar.bz2
rockbox-7df759c95107bc8e5f9a6ba17f77114fa9d80357.zip
Create an udacodec interface (similar to ascodec and wmcoded) and adapt/implement it for the iriver h1xx/h3xx and the meizus.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21546 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES3
-rw-r--r--firmware/drivers/audio/uda1380.c43
-rw-r--r--firmware/export/config-meizu-m3.h4
-rw-r--r--firmware/export/udacodec.h31
-rw-r--r--firmware/sound.c3
-rw-r--r--firmware/target/arm/s5l8700/udacodec-meizu.c62
-rw-r--r--firmware/target/coldfire/iriver/udacodec-iriver.c76
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
target/coldfire/iriver/h300/usb-h300.c
#ifndef BOOTLOADER
target/coldfire/iriver/audio-iriver.c
+target/coldfire/iriver/udacodec-iriver.c
#endif
#endif /* SIMULATOR */
#endif /* IRIVER_H300_SERIES */
@@ -711,6 +712,7 @@ target/coldfire/iriver/h100/power-h100.c
target/coldfire/iriver/h100/powermgmt-h100.c
#ifndef BOOTLOADER
target/coldfire/iriver/audio-iriver.c
+target/coldfire/iriver/udacodec-iriver.c
target/coldfire/iriver/h100/spdif-h100.c
#endif
target/coldfire/iriver/h100/usb-h100.c
@@ -1250,6 +1252,7 @@ target/arm/s5l8700/meizu-m3/lcd-m3.c
drivers/qt1106.c
#ifndef SIMULATOR
#ifndef BOOTLOADER
+target/arm/s5l8700/udacodec-meizu.c
#endif /* BOOTLOADER */
#endif /* SIMULATOR */
#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 @@
* KIND, either express or implied.
*
****************************************************************************/
+#include <string.h>
+
+#include "config.h"
#include "logf.h"
#include "system.h"
-#include "string.h"
#include "audio.h"
#include "debug.h"
+#include "udacodec.h"
-#include "i2c-coldfire.h"
#include "audiohw.h"
-#include "pcf50606.h"
const struct sound_settings_info audiohw_settings[] = {
[SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25},
@@ -109,13 +110,7 @@ unsigned short uda1380_defaults[2*NUM_DEFAULT_REGS] =
/* Returns 0 if register was written or -1 if write failed */
static int uda1380_write_reg(unsigned char reg, unsigned short value)
{
- unsigned char data[3];
-
- data[0] = reg;
- data[1] = value >> 8;
- data[2] = value & 0xff;
-
- if (i2c_write(I2C_IFACE_0, UDA1380_ADDR, data, 3) != 3)
+ if (udacodec_write(reg, value) < 0)
{
DEBUGF("uda1380 error reg=0x%x", reg);
return -1;
@@ -193,23 +188,6 @@ static int audiohw_set_regs(void)
return 0;
}
-static void reset(void)
-{
-#ifdef IRIVER_H300_SERIES
- int mask = disable_irq_save();
- pcf50606_write(0x3b, 0x00); /* GPOOD2 high Z */
- pcf50606_write(0x3b, 0x07); /* GPOOD2 low */
- restore_irq(mask);
-#else
- /* RESET signal */
- or_l(1<<29, &GPIO_OUT);
- or_l(1<<29, &GPIO_ENABLE);
- or_l(1<<29, &GPIO_FUNCTION);
- sleep(HZ/100);
- and_l(~(1<<29), &GPIO_OUT);
-#endif
-}
-
/**
* Sets frequency settings for DAC and ADC relative to MCLK
*
@@ -268,7 +246,7 @@ void audiohw_init(void)
recgain_mic = 0;
recgain_line = 0;
- reset();
+ udacodec_reset();
if (audiohw_set_regs() == -1)
{
@@ -419,20 +397,13 @@ void audiohw_set_recvol(int left, int right, int type)
{
/* for this order we can combine both registers,
making the glitch even smaller */
- unsigned char data[5];
unsigned short value_dec;
unsigned short value_pga;
value_dec = DEC_VOLL(left) | DEC_VOLR(right);
value_pga = (uda1380_regs[REG_PGA] & ~PGA_GAIN_MASK)
| PGA_GAINL(left_ag) | PGA_GAINR(right_ag);
- data[0] = REG_DEC_VOL;
- data[1] = value_dec >> 8;
- data[2] = value_dec & 0xff;
- data[3] = value_pga >> 8;
- data[4] = value_pga & 0xff;
-
- if (i2c_write(I2C_IFACE_0, UDA1380_ADDR, data, 5) != 5)
+ if (udacodec_write2(REG_DEC_VOL, value_dec, value_pga) < 0)
{
DEBUGF("uda1380 error reg=combi rec gain");
}
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 @@
#define CONFIG_LCD LCD_MEIZUM6
-/* Define this if you have the WM8975 audio codec */
-#define HAVE_WM8751 //FIXME
+/* Define the type of audio codec */
+#define HAVE_UDA1380
/* Define this for LCD backlight available */
#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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2009 by Bertrik Sikken
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+/* perform a hardware reset of the codec */
+void udacodec_reset(void);
+
+/* write a single register */
+int udacodec_write(unsigned char reg, unsigned short value);
+
+/* write two consecutive registers */
+int udacodec_write2(unsigned char reg,
+ unsigned short value1, unsigned short value2);
+
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)
switch(setting)
{
+#ifdef HAVE_RECORDING
case SOUND_LEFT_GAIN:
case SOUND_RIGHT_GAIN:
case SOUND_MIC_GAIN:
result = value * 5; /* (1/2) * 10 */
break;
-
+#endif
default:
result = value;
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2009 by Bertrik Sikken
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "kernel.h"
+#include "s5l8700.h"
+#include "i2c-s5l8700.h"
+#include "uda1380.h"
+#include "udacodec.h"
+
+void udacodec_reset(void)
+{
+ /* Reset codec using GPIO P5.0 */
+ PCON5 = (PCON5 & ~0xF) | 1;
+ PDAT5 |= (1 << 0);
+ sleep(HZ/100);
+
+ /* Set codec reset pin inactive */
+ PDAT5 &= ~(1 << 0);
+}
+
+int udacodec_write(unsigned char reg, unsigned short value)
+{
+ unsigned char data[2];
+
+ data[0] = value >> 8;
+ data[1] = value & 0xFF;
+
+ return i2c_write(UDA1380_ADDR, reg, 2, data);
+}
+
+int udacodec_write2(unsigned char reg,
+ unsigned short value1, unsigned short value2)
+{
+ unsigned char data[4];
+
+ data[0] = value1 >> 8;
+ data[1] = value1 & 0xFF;
+ data[2] = value2 >> 8;
+ data[3] = value2 & 0xFF;
+
+ return i2c_write(UDA1380_ADDR, reg, 4, data);
+}
+
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2009 by Bertrik Sikken
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "kernel.h"
+#include "i2c-coldfire.h"
+#include "pcf50606.h"
+#include "uda1380.h"
+#include "udacodec.h"
+
+void udacodec_reset(void)
+{
+#ifdef IRIVER_H300_SERIES
+ int mask = disable_irq_save();
+ pcf50606_write(0x3b, 0x00); /* GPOOD2 high Z */
+ pcf50606_write(0x3b, 0x07); /* GPOOD2 low */
+ restore_irq(mask);
+#else
+ /* RESET signal */
+ or_l(1<<29, &GPIO_OUT);
+ or_l(1<<29, &GPIO_ENABLE);
+ or_l(1<<29, &GPIO_FUNCTION);
+ sleep(HZ/100);
+ and_l(~(1<<29), &GPIO_OUT);
+#endif
+}
+
+int udacodec_write(unsigned char reg, unsigned short value)
+{
+ unsigned char data[3];
+
+ data[0] = reg;
+ data[1] = value >> 8;
+ data[2] = value & 0xff;
+
+ if (i2c_write(I2C_IFACE_0, UDA1380_ADDR, data, 3) != 3) {
+ return -1;
+ }
+ return 0;
+}
+
+int udacodec_write2(unsigned char reg,
+ unsigned short value1, unsigned short value2)
+{
+ unsigned char data[5];
+
+ data[0] = reg;
+ data[1] = value1 >> 8;
+ data[2] = value1 & 0xFF;
+ data[3] = value2 >> 8;
+ data[4] = value2 & 0xFF;
+
+ if (i2c_write(I2C_IFACE_0, UDA1380_ADDR, data, 5) != 5) {
+ return -1;
+ }
+ return 0;
+}
+