summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-11-26 14:25:45 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-11-26 14:25:45 +0000
commit888451fb0f3f8b8a3e6e81a087e4545eeba7a774 (patch)
treec10cba5f31fd4b0e33d1c54c43289247aa6f6590 /firmware/drivers/audio
parente73383ea324e5f86105cc74983a88452bb261033 (diff)
Get rid of remaining audiohw_enable_output style codec setup and use pre/post split initialization. Move some SoC-specific code like i2s_reset out of the codec drivers. Helps to unify drivers and it was only ever used to enable. I cannot possibly test everything so report (I'll be on call ;) or fix problems if any crop up.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19228 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/audio')
-rw-r--r--firmware/drivers/audio/tsc2100.c11
-rw-r--r--firmware/drivers/audio/uda1380.c14
-rw-r--r--firmware/drivers/audio/wm8721.c50
-rw-r--r--firmware/drivers/audio/wm8731.c3
-rw-r--r--firmware/drivers/audio/wm8751.c1
-rw-r--r--firmware/drivers/audio/wm8758.c3
-rw-r--r--firmware/drivers/audio/wm8975.c3
-rw-r--r--firmware/drivers/audio/wm8985.c75
8 files changed, 57 insertions, 103 deletions
diff --git a/firmware/drivers/audio/tsc2100.c b/firmware/drivers/audio/tsc2100.c
index 038f3ed178..e0e2c53e69 100644
--- a/firmware/drivers/audio/tsc2100.c
+++ b/firmware/drivers/audio/tsc2100.c
@@ -90,16 +90,7 @@ void audiohw_init(void)
void audiohw_postinit(void)
{
-}
-
-/* Silently enable / disable audio output */
-void audiohw_enable_output(bool enable)
-{
- if (enable) {
- audiohw_mute(0);
- } else {
- audiohw_mute(1);
- }
+ audiohw_mute(0);
}
void audiohw_set_master_vol(int vol_l, int vol_r)
diff --git a/firmware/drivers/audio/uda1380.c b/firmware/drivers/audio/uda1380.c
index e76b08a429..a0e7ef56d8 100644
--- a/firmware/drivers/audio/uda1380.c
+++ b/firmware/drivers/audio/uda1380.c
@@ -193,17 +193,6 @@ static int audiohw_set_regs(void)
return 0;
}
-/* Silently enable / disable audio output */
-void audiohw_enable_output(bool enable)
-{
- if (enable) {
- uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] | PON_DAC | PON_HP);
- } else {
- uda1380_write_reg(REG_MUTE, MUTE_MASTER);
- uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] & ~PON_DAC);
- }
-}
-
static void reset(void)
{
#ifdef IRIVER_H300_SERIES
@@ -278,8 +267,9 @@ void audiohw_postinit(void)
/* Sleep a while so the power can stabilize (especially a long
delay is needed for the line out connector). */
sleep(HZ);
+
/* Power on FSDAC and HP amp. */
- audiohw_enable_output(true);
+ uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] | PON_DAC | PON_HP);
/* UDA1380: Unmute the master channel
(DAC should be at zero point now). */
diff --git a/firmware/drivers/audio/wm8721.c b/firmware/drivers/audio/wm8721.c
index 6c4e12b9dc..3f14ca467e 100644
--- a/firmware/drivers/audio/wm8721.c
+++ b/firmware/drivers/audio/wm8721.c
@@ -33,7 +33,6 @@
#include "wmcodec.h"
#include "audiohw.h"
-#include "i2s.h"
#define IPOD_PCM_LEVEL 0x65 /* -6dB */
@@ -91,43 +90,38 @@ static void codec_set_active(int active)
/* Silently enable / disable audio output */
-void audiohw_enable_output(bool enable)
+void audiohw_preinit(void)
{
- if (enable)
- {
- /* reset the I2S controller into known state */
- i2s_reset();
-
- wmcodec_write(RESET, 0x0); /*Reset*/
+ wmcodec_write(RESET, 0x0); /*Reset*/
- codec_set_active(0x0);
+ codec_set_active(0x0);
- /* DACSEL=1 */
- wmcodec_write(0x4, 0x10);
+ /* DACSEL=1 */
+ wmcodec_write(0x4, 0x10);
- /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */
- wmcodec_write(PDCTRL, 0x67);
+ /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */
+ wmcodec_write(PDCTRL, 0x67);
- /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
- /* IWL=00(16 bit) FORMAT=10(I2S format) */
- wmcodec_write(AINTFCE, 0x42);
+ /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
+ /* IWL=00(16 bit) FORMAT=10(I2S format) */
+ wmcodec_write(AINTFCE, 0x42);
- audiohw_set_sample_rate(WM8721_USB24_44100HZ);
+ audiohw_set_sample_rate(WM8721_USB24_44100HZ);
- /* set the volume to -6dB */
- wmcodec_write(LOUTVOL, IPOD_PCM_LEVEL);
- wmcodec_write(ROUTVOL, 0x100 | IPOD_PCM_LEVEL);
+ /* set the volume to -6dB */
+ wmcodec_write(LOUTVOL, IPOD_PCM_LEVEL);
+ wmcodec_write(ROUTVOL, 0x100 | IPOD_PCM_LEVEL);
- /* ACTIVE=1 */
- codec_set_active(1);
+ /* ACTIVE=1 */
+ codec_set_active(1);
- /* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */
- wmcodec_write(DAPCTRL, 0x0);
+ /* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */
+ wmcodec_write(DAPCTRL, 0x0);
+}
- audiohw_mute(0);
- } else {
- audiohw_mute(1);
- }
+void audiohw_postinit(void)
+{
+ audiohw_mute(0);
}
void audiohw_set_master_vol(int vol_l, int vol_r)
diff --git a/firmware/drivers/audio/wm8731.c b/firmware/drivers/audio/wm8731.c
index d6e21c34de..2f882e8fe1 100644
--- a/firmware/drivers/audio/wm8731.c
+++ b/firmware/drivers/audio/wm8731.c
@@ -33,7 +33,6 @@
#include "wmcodec.h"
#include "audiohw.h"
-#include "i2s.h"
#include "sound.h"
const struct sound_settings_info audiohw_settings[] = {
@@ -150,8 +149,6 @@ static void codec_set_active(int active)
void audiohw_preinit(void)
{
- i2s_reset();
-
/* POWER UP SEQUENCE */
/* 1) Switch on power supplies. By default the WM8731 is in Standby Mode,
* the DAC is digitally muted and the Audio Interface and Outputs are
diff --git a/firmware/drivers/audio/wm8751.c b/firmware/drivers/audio/wm8751.c
index 7145fe4ea4..d53cfa3d79 100644
--- a/firmware/drivers/audio/wm8751.c
+++ b/firmware/drivers/audio/wm8751.c
@@ -27,7 +27,6 @@
****************************************************************************/
#include "kernel.h"
#include "wmcodec.h"
-#include "i2s.h"
#include "audio.h"
#include "audiohw.h"
#include "system.h"
diff --git a/firmware/drivers/audio/wm8758.c b/firmware/drivers/audio/wm8758.c
index e9d4b5c5c7..8ebfbe8e26 100644
--- a/firmware/drivers/audio/wm8758.c
+++ b/firmware/drivers/audio/wm8758.c
@@ -31,7 +31,6 @@
#include "wmcodec.h"
#include "audiohw.h"
-#include "i2s.h"
const struct sound_settings_info audiohw_settings[] = {
[SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25},
@@ -95,8 +94,6 @@ void audiohw_mute(bool mute)
void audiohw_preinit(void)
{
- i2s_reset();
-
wmcodec_write(RESET, RESET_RESET);
wmcodec_write(PWRMGMT1, PWRMGMT1_PLLEN | PWRMGMT1_BIASEN
diff --git a/firmware/drivers/audio/wm8975.c b/firmware/drivers/audio/wm8975.c
index 86e463cdff..aa519e8819 100644
--- a/firmware/drivers/audio/wm8975.c
+++ b/firmware/drivers/audio/wm8975.c
@@ -33,7 +33,6 @@
#include "wmcodec.h"
#include "audiohw.h"
-#include "i2s.h"
const struct sound_settings_info audiohw_settings[] = {
[SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25},
@@ -129,8 +128,6 @@ void audiohw_mute(bool mute)
void audiohw_preinit(void)
{
- i2s_reset();
-
/* POWER UP SEQUENCE */
wmcodec_write(RESET, RESET_RESET);
diff --git a/firmware/drivers/audio/wm8985.c b/firmware/drivers/audio/wm8985.c
index 9d80f9e374..0467e3718a 100644
--- a/firmware/drivers/audio/wm8985.c
+++ b/firmware/drivers/audio/wm8985.c
@@ -23,7 +23,6 @@
#include "wmcodec.h"
#include "audiohw.h"
-#include "i2s.h"
/* Register addresses as per datasheet Rev.4.4 */
#define RESET 0x00
@@ -127,57 +126,50 @@ int tenthdb2master(int db)
}
/* Silently enable / disable audio output */
-void audiohw_enable_output(bool enable)
+void audiohw_preinit(void)
{
- if (enable)
- {
- /* TODO: reset the I2S controller into known state */
- //i2s_reset();
+ wmcodec_write(RESET, 0x1ff); /* Reset */
- wmcodec_write(RESET, 0x1ff); /* Reset */
+ wmcodec_write(BIASCTL, 0x100); /* BIASCUT = 1 */
+ wmcodec_write(OUTCTRL, 0x6); /* Thermal shutdown */
- wmcodec_write(BIASCTL, 0x100); /* BIASCUT = 1 */
- wmcodec_write(OUTCTRL, 0x6); /* Thermal shutdown */
+ wmcodec_write(PWRMGMT1, 0x8); /* BIASEN = 1 */
- wmcodec_write(PWRMGMT1, 0x8); /* BIASEN = 1 */
+ /* Volume zero, mute all outputs */
+ wmcodec_write(LOUT1VOL, 0x140);
+ wmcodec_write(ROUT1VOL, 0x140);
+ wmcodec_write(LOUT2VOL, 0x140);
+ wmcodec_write(ROUT2VOL, 0x140);
+ wmcodec_write(OUT3MIX, 0x40);
+ wmcodec_write(OUT4MIX, 0x40);
- /* Volume zero, mute all outputs */
- wmcodec_write(LOUT1VOL, 0x140);
- wmcodec_write(ROUT1VOL, 0x140);
- wmcodec_write(LOUT2VOL, 0x140);
- wmcodec_write(ROUT2VOL, 0x140);
- wmcodec_write(OUT3MIX, 0x40);
- wmcodec_write(OUT4MIX, 0x40);
-
- /* DAC softmute, automute, 128OSR */
- wmcodec_write(DACCTRL, 0x4c);
+ /* DAC softmute, automute, 128OSR */
+ wmcodec_write(DACCTRL, 0x4c);
- wmcodec_write(OUT4ADC, 0x2); /* POBCTRL = 1 */
+ wmcodec_write(OUT4ADC, 0x2); /* POBCTRL = 1 */
- /* Enable output, DAC and mixer */
- wmcodec_write(PWRMGMT3, 0x6f);
- wmcodec_write(PWRMGMT2, 0x180);
- wmcodec_write(PWRMGMT1, 0xd);
- wmcodec_write(LOUTMIX, 0x1);
- wmcodec_write(ROUTMIX, 0x1);
+ /* Enable output, DAC and mixer */
+ wmcodec_write(PWRMGMT3, 0x6f);
+ wmcodec_write(PWRMGMT2, 0x180);
+ wmcodec_write(PWRMGMT1, 0xd);
+ wmcodec_write(LOUTMIX, 0x1);
+ wmcodec_write(ROUTMIX, 0x1);
- /* Disable clock since we're acting as slave to the SoC */
- wmcodec_write(CLKGEN, 0x0);
- wmcodec_write(AINTFCE, 0x10); /* 16-bit, I2S format */
+ /* Disable clock since we're acting as slave to the SoC */
+ wmcodec_write(CLKGEN, 0x0);
+ wmcodec_write(AINTFCE, 0x10); /* 16-bit, I2S format */
- wmcodec_write(LDACVOL, 0x1ff); /* Full DAC digital vol */
- wmcodec_write(RDACVOL, 0x1ff);
+ wmcodec_write(LDACVOL, 0x1ff); /* Full DAC digital vol */
+ wmcodec_write(RDACVOL, 0x1ff);
- wmcodec_write(OUT4ADC, 0x0); /* POBCTRL = 0 */
+ wmcodec_write(OUT4ADC, 0x0); /* POBCTRL = 0 */
+}
- sleep(HZ/2);
+void audiohw_postinit(void)
+{
+ sleep(HZ/2);
- audiohw_mute(0);
- }
- else
- {
- audiohw_mute(1);
- }
+ audiohw_mute(0);
}
void audiohw_set_headphone_vol(int vol_l, int vol_r)
@@ -256,9 +248,6 @@ void audiohw_enable_recording(bool source_mic)
{
(void)source_mic; /* We only have a line-in (I think) */
- /* TODO: reset the I2S controller into known state */
- //i2s_reset();
-
wmcodec_write(RESET, 0x1ff); /*Reset*/
wmcodec_write(PWRMGMT1, 0x2b);