1
0
Fork 0
forked from len0rd/rockbox

iPod 3G - initial (completely untested) attempt at audio support

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8847 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2006-02-26 15:59:46 +00:00
parent 4b9fbd1687
commit 2f76763d73
7 changed files with 184 additions and 96 deletions

View file

@ -180,7 +180,7 @@ drivers/uda1380.c
drivers/wm8975.c drivers/wm8975.c
#elif defined(HAVE_WM8758) && !defined(SIMULATOR) #elif defined(HAVE_WM8758) && !defined(SIMULATOR)
drivers/wm8758.c drivers/wm8758.c
#elif defined(HAVE_WM8731L) && !defined(SIMULATOR) #elif defined(HAVE_WM8731) && !defined(SIMULATOR)
drivers/wm8731l.c drivers/wm8731l.c
#elif defined(HAVE_TLV320) && !defined(SIMULATOR) #elif defined(HAVE_TLV320) && !defined(SIMULATOR)
drivers/tlv320.c drivers/tlv320.c

View file

@ -41,40 +41,46 @@
#include "wm8731l.h" #include "wm8731l.h"
#include "pcf50605.h" #include "pcf50605.h"
void wm8731l_reset(void);
#define IPOD_PCM_LEVEL 0x65 /* -6dB */ #define IPOD_PCM_LEVEL 0x65 /* -6dB */
#define RESET (0x0f<<1) #define LINVOL 0x00
#define PWRMGMT1 (0x19<<1) #define RINVOL 0x01
#define PWRMGMT2 (0x1a<<1) #define LOUTVOL 0x02
#define AINTFCE (0x07<<1) #define ROUTVOL 0x03
#define LOUT1VOL (0x02<<1) #define DACCTRL 0x05
#define ROUT1VOL (0x03<<1) #define PWRMGMT 0x06
#define LOUT2VOL (0x28<<1) #define AINTFCE 0x07
#define ROUT2VOL (0x29<<1) #define SAMPCTRL 0x08
#define ACTIVECTRL 0x09
#define RESET 0x0f
int wm8731l_mute(int mute) void wm8731_write(int reg, int data)
{
ipod_i2c_send(0x1a, (reg<<1) | ((data&0x100)>>8),data&0xff);
}
int wmcodec_mute(int mute)
{ {
if (mute) if (mute)
{ {
/* Set DACMU = 1 to soft-mute the audio DACs. */ /* Set DACMU = 1 to soft-mute the audio DACs. */
ipod_i2c_send(0x1a, 0xa, 0x8); wm8731_write(DACCTRL, 0x8);
} else { } else {
/* Set DACMU = 0 to soft-un-mute the audio DACs. */ /* Set DACMU = 0 to soft-un-mute the audio DACs. */
ipod_i2c_send(0x1a, 0xa, 0x0); wm8731_write(DACCTRL, 0x0);
} }
return 0; return 0;
} }
/** From ipodLinux **/ /** From ipodLinux **/
static void codec_set_active(int active) static void codec_set_active(int active)
{ {
/* set active to 0x0 or 0x1 */ /* set active to 0x0 or 0x1 */
if (active) { if (active) {
ipod_i2c_send(0x1a, 0x12, 0x01); wm8731_write(ACTIVECTRL, 0x01);
} else { } else {
ipod_i2c_send(0x1a, 0x12, 0x00); wm8731_write(ACTIVECTRL, 0x00);
} }
} }
@ -102,7 +108,7 @@ static void i2s_reset(void)
* Initialise the WM8975 for playback via headphone and line out. * Initialise the WM8975 for playback via headphone and line out.
* Note, I'm using the WM8750 datasheet as its apparently close. * Note, I'm using the WM8750 datasheet as its apparently close.
*/ */
int wm8731l_init(void) { int wmcodec_init(void) {
/* reset I2C */ /* reset I2C */
i2c_init(); i2c_init();
@ -134,64 +140,61 @@ int wm8731l_init(void) {
} }
/* Silently enable / disable audio output */ /* Silently enable / disable audio output */
void wm8731l_enable_output(bool enable) void wmcodec_enable_output(bool enable)
{ {
if (enable) if (enable)
{ {
/* reset the I2S controller into known state */ /* reset the I2S controller into known state */
i2s_reset(); i2s_reset();
ipod_i2c_send(0x1a, 0x1e, 0x0); /*Reset*/ wm8731_write(RESET, 0x0); /*Reset*/
codec_set_active(0x0); codec_set_active(0x0);
/* DACSEL=1 */ /* DACSEL=1 */
/* BYPASS=1 */ /* BYPASS=1 */
ipod_i2c_send(0x1a, 0x8, 0x18); wm8731_write(0x4, 0x18);
/* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */ /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */
ipod_i2c_send(0x1a, 0xc, 0x67); wm8731_write(PWRMGMT, 0x67);
/* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */ /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
/* IWL=00(16 bit) FORMAT=10(I2S format) */ /* IWL=00(16 bit) FORMAT=10(I2S format) */
ipod_i2c_send(0x1a, 0xe, 0x42); wm8731_write(AINTFCE, 0x42);
wm8731l_set_sample_rate(WM8731L_44100HZ); wmcodec_set_sample_rate(WM8731L_44100HZ);
/* set the volume to -6dB */ /* set the volume to -6dB */
ipod_i2c_send(0x1a, 0x4, IPOD_PCM_LEVEL); wm8731_write(LOUTVOL, IPOD_PCM_LEVEL);
ipod_i2c_send(0x1a, 0x6 | 0x1, IPOD_PCM_LEVEL); wm8731_write(ROUTVOL, 0x100 | IPOD_PCM_LEVEL);
/* ACTIVE=1 */ /* ACTIVE=1 */
codec_set_active(1); codec_set_active(1);
/* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */ /* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */
ipod_i2c_send(0x1a, 0xa, 0x0); wm8731_write(DACCTRL, 0x0);
wm8731l_mute(0); wmcodec_mute(0);
} else { } else {
wm8731l_mute(1); wmcodec_mute(1);
} }
} }
int wm8731l_set_master_vol(int vol_l, int vol_r) int wmcodec_set_master_vol(int vol_l, int vol_r)
{ {
/* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
/* 1111111 == +6dB */ /* 1111111 == +6dB */
/* 1111001 == 0dB */ /* 1111001 == 0dB */
/* 0110000 == -73dB */ /* 0110000 == -73dB */
/* 0101111 == mute (0x2f) */ /* 0101111 == mute (0x2f) */
if (vol_l == vol_r) {
ipod_i2c_send(0x1a, 0x4 | 0x1, vol_l); wm8731_write(LOUTVOL, vol_l);
} else { wm8731_write(ROUTVOL, vol_r);
ipod_i2c_send(0x1a, 0x4, vol_l);
ipod_i2c_send(0x1a, 0x6, vol_r);
}
return 0; return 0;
} }
int wm8975_set_mixer_vol(int channel1, int channel2) int wmcodec_set_mixer_vol(int channel1, int channel2)
{ {
(void)channel1; (void)channel1;
(void)channel2; (void)channel2;
@ -199,70 +202,69 @@ int wm8975_set_mixer_vol(int channel1, int channel2)
return 0; return 0;
} }
void wm8731l_set_bass(int value) void wmcodec_set_bass(int value)
{ {
(void)value; (void)value;
} }
void wm8731l_set_treble(int value) void wmcodec_set_treble(int value)
{ {
(void)value; (void)value;
} }
/* Nice shutdown of WM8975 codec */ /* Nice shutdown of WM8731 codec */
void wm8731l_close(void) void wmcodec_close(void)
{ {
/* set DACMU=1 DEEMPH=0 */ /* set DACMU=1 DEEMPH=0 */
ipod_i2c_send(0x1a, 0xa, 0x8); wm8731_write(DACCTRL, 0x8);
/* ACTIVE=0 */ /* ACTIVE=0 */
codec_set_active(0x0); codec_set_active(0x0);
/* line in mute left & right*/ /* line in mute left & right*/
ipod_i2c_send(0x1a, 0x0 | 0x1, 0x80); wm8731_write(LINVOL, 0x100 | 0x80);
/* set DACSEL=0, MUTEMIC=1 */ /* set DACSEL=0, MUTEMIC=1 */
ipod_i2c_send(0x1a, 0x8, 0x2); wm8731_write(0x4, 0x2);
/* set POWEROFF=0 OUTPD=0 DACPD=1 */ /* set POWEROFF=0 OUTPD=0 DACPD=1 */
ipod_i2c_send(0x1a, 0xc, 0x6f); wm8731_write(PWRMGMT, 0x6f);
/* set POWEROFF=1 OUTPD=1 DACPD=1 */ /* set POWEROFF=1 OUTPD=1 DACPD=1 */
ipod_i2c_send(0x1a, 0xc, 0xff); wm8731_write(PWRMGMT, 0xff);
} }
/* Change the order of the noise shaper, 5th order is recommended above 32kHz */ /* Change the order of the noise shaper, 5th order is recommended above 32kHz */
void wm8731l_set_nsorder(int order) void wmcodec_set_nsorder(int order)
{ {
(void)order; (void)order;
} }
/* */ void wmcodec_set_sample_rate(int sampling_control)
void wm8731l_set_sample_rate(int sampling_control)
{ {
codec_set_active(0x0); codec_set_active(0x0);
ipod_i2c_send(0x1a, 0x10, sampling_control); wm8731_write(SAMPCTRL, sampling_control);
codec_set_active(0x1); codec_set_active(0x1);
} }
void wm8731l_enable_recording(bool source_mic) void wmcodec_enable_recording(bool source_mic)
{ {
(void)source_mic; (void)source_mic;
} }
void wm8731l_disable_recording(void) void wmcodec_disable_recording(void)
{ {
} }
void wm8731l_set_recvol(int left, int right, int type) void wmcodec_set_recvol(int left, int right, int type)
{ {
(void)left; (void)left;
(void)right; (void)right;
(void)type; (void)type;
} }
void wm8731l_set_monitor(int enable) void wmcodec_set_monitor(int enable)
{ {
(void)enable; (void)enable;
} }

View file

@ -41,7 +41,7 @@
#define PLUGIN_BUFFER_SIZE 0x80000 #define PLUGIN_BUFFER_SIZE 0x80000
/* Define this if you have the WM8731L audio codec */ /* Define this if you have the WM8731L audio codec */
#define HAVE_WM8731L #define HAVE_WM8731
/* Define this for LCD backlight available */ /* Define this for LCD backlight available */
#define CONFIG_BACKLIGHT BL_IPOD3G /* port controlled */ #define CONFIG_BACKLIGHT BL_IPOD3G /* port controlled */

View file

@ -20,31 +20,25 @@
#ifndef _WM8731L_H #ifndef _WM8731L_H
#define _WM8731L_H #define _WM8731L_H
extern void wm8731l_reset(void); extern void wmcodec_reset(void);
extern int wm8731l_init(void); extern int wmcodec_init(void);
extern void wm8731l_enable_output(bool enable); extern void wmcodec_enable_output(bool enable);
extern int wm8731l_set_master_vol(int vol_l, int vol_r); extern int wmcodec_set_master_vol(int vol_l, int vol_r);
extern int wm8731l_set_mixer_vol(int channel1, int channel2); extern int wmcodec_set_mixer_vol(int channel1, int channel2);
extern void wm8731l_set_bass(int value); extern void wmcodec_set_bass(int value);
extern void wm8731l_set_treble(int value); extern void wmcodec_set_treble(int value);
extern int wm8731l_mute(int mute); extern int wmcodec_mute(int mute);
extern void wm8731l_close(void); extern void wmcodec_close(void);
extern void wm8731l_set_nsorder(int order); extern void wmcodec_set_nsorder(int order);
extern void wm8731l_set_sample_rate(int sampling_control); extern void wmcodec_set_sample_rate(int sampling_control);
extern void wm8731l_enable_recording(bool source_mic); extern void wmcodec_enable_recording(bool source_mic);
extern void wm8731l_disable_recording(void); extern void wmcodec_disable_recording(void);
extern void wm8731l_set_recvol(int left, int right, int type); extern void wmcodec_set_recvol(int left, int right, int type);
extern void wm8731l_set_monitor(int enable); extern void wmcodec_set_monitor(int enable);
/* Register settings for the supported samplerates: */ /* Register settings for the supported samplerates: */
#define WM8731L_8000HZ 0x4d #define WM8731L_8000HZ 0x4d
/*
IpodLinux don't seem to support those sampling rate with the wm8731L chip
#define WM8975_16000HZ 0x55
#define WM8975_22050HZ 0x77
#define WM8975_24000HZ 0x79
*/
#define WM8731L_32000HZ 0x59 #define WM8731L_32000HZ 0x59
#define WM8731L_44100HZ 0x63 #define WM8731L_44100HZ 0x63
#define WM8731L_48000HZ 0x41 #define WM8731L_48000HZ 0x41

View file

@ -31,7 +31,7 @@
#include "wm8758.h" #include "wm8758.h"
#elif defined(HAVE_TLV320) #elif defined(HAVE_TLV320)
#include "tlv320.h" #include "tlv320.h"
#elif defined(HAVE_WM8731L) #elif defined(HAVE_WM8731)
#include "wm8731l.h" #include "wm8731l.h"
#endif #endif
#include "system.h" #include "system.h"
@ -314,13 +314,17 @@ void pcm_init(void)
dma_stop(); dma_stop();
} }
#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) #elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
/* We need to unify this code with the uda1380 code as much as possible, but /* We need to unify this code with the uda1380 code as much as possible, but
we will keep it separate during early development. we will keep it separate during early development.
*/ */
#if CONFIG_CPU == PP5020
#define FIFO_FREE_COUNT ((IISFIFO_CFG & 0x3f0000) >> 16) #define FIFO_FREE_COUNT ((IISFIFO_CFG & 0x3f0000) >> 16)
#elif CONFIG_CPU == PP5002
#define FIFO_FREE_COUNT ((IISFIFO_CFG & 0x7800000) >> 23)
#endif
static bool pcm_playing; static bool pcm_playing;
static bool pcm_paused; static bool pcm_paused;
@ -329,6 +333,8 @@ static int pcm_freq = 0x6; /* 44.1 is default */
unsigned short* p IBSS_ATTR; unsigned short* p IBSS_ATTR;
long p_size IBSS_ATTR; long p_size IBSS_ATTR;
#define PP5002_DMA_OUT_MASK (1 << DMA_OUT_IRQ)
static void dma_start(const void *addr, size_t size) static void dma_start(const void *addr, size_t size)
{ {
p=(unsigned short*)addr; p=(unsigned short*)addr;
@ -336,22 +342,36 @@ static void dma_start(const void *addr, size_t size)
pcm_playing = true; pcm_playing = true;
#if CONFIG_CPU == PP5020
/* setup I2S interrupt for FIQ */ /* setup I2S interrupt for FIQ */
outl(inl(0x6000402c) | I2S_MASK, 0x6000402c); outl(inl(0x6000402c) | I2S_MASK, 0x6000402c);
outl(I2S_MASK, 0x60004024); outl(I2S_MASK, 0x60004024);
#else
/* setup I2S interrupt for FIQ */
outl(inl(0xcf00103c) | PP5002_DMA_OUT_MASK, 0xcf00103c);
outl(PP5002_DMA_OUT_MASK, 0xcf001034);
#endif
/* Clear the FIQ disable bit in cpsr_c */ /* Clear the FIQ disable bit in cpsr_c */
enable_fiq(); enable_fiq();
/* Enable playback FIFO */ /* Enable playback FIFO */
#if CONFIG_CPU == PP5020
IISCONFIG |= 0x20000000; IISCONFIG |= 0x20000000;
#elif CONFIG_CPU == PP5002
IISCONFIG |= 0x4;
#endif
/* Fill the FIFO - we assume there are enough bytes in the pcm buffer to /* Fill the FIFO - we assume there are enough bytes in the pcm buffer to
fill the 32-byte FIFO. */ fill the 32-byte FIFO. */
while (p_size > 0) { while (p_size > 0) {
if (FIFO_FREE_COUNT < 2) { if (FIFO_FREE_COUNT < 2) {
/* Enable interrupt */ /* Enable interrupt */
#if CONFIG_CPU == PP5020
IISCONFIG |= 0x2; IISCONFIG |= 0x2;
#elif CONFIG_CPU == PP5002
IISFIFO_CFG &= ~(1<<9);
#endif
return; return;
} }
@ -366,12 +386,23 @@ static void dma_stop(void)
{ {
pcm_playing = false; pcm_playing = false;
#if CONFIG_CPU == PP5020
/* Disable playback FIFO */ /* Disable playback FIFO */
IISCONFIG &= ~0x20000000; IISCONFIG &= ~0x20000000;
/* Disable the interrupt */ /* Disable the interrupt */
IISCONFIG &= ~0x2; IISCONFIG &= ~0x2;
#elif CONFIG_CPU == PP5002
/* Disable playback FIFO */
IISCONFIG &= ~0x4;
/* Disable the interrupt */
IISFIFO_CFG &= ~(1<<9);
#endif
disable_fiq(); disable_fiq();
pcm_paused = false; pcm_paused = false;
@ -438,14 +469,22 @@ void pcm_play_pause(bool play)
enable_fiq(); enable_fiq();
/* Enable playback FIFO */ /* Enable playback FIFO */
#if CONFIG_CPU == PP5020
IISCONFIG |= 0x20000000; IISCONFIG |= 0x20000000;
#elif CONFIG_CPU == PP5002
IISCONFIG |= 0x4;
#endif
/* Fill the FIFO - we assume there are enough bytes in the /* Fill the FIFO - we assume there are enough bytes in the
pcm buffer to fill the 32-byte FIFO. */ pcm buffer to fill the 32-byte FIFO. */
while (p_size > 0) { while (p_size > 0) {
if (FIFO_FREE_COUNT < 2) { if (FIFO_FREE_COUNT < 2) {
/* Enable interrupt */ /* Enable interrupt */
#if CONFIG_CPU == PP5020
IISCONFIG |= 0x2; IISCONFIG |= 0x2;
#elif CONFIG_CPU == PP5002
IISFIFO_CFG &= ~(1<<9);
#endif
return; return;
} }
@ -473,12 +512,23 @@ void pcm_play_pause(bool play)
{ {
logf("pause"); logf("pause");
#if CONFIG_CPU == PP5020
/* Disable the interrupt */ /* Disable the interrupt */
IISCONFIG &= ~0x2; IISCONFIG &= ~0x2;
/* Disable playback FIFO */ /* Disable playback FIFO */
IISCONFIG &= ~0x20000000; IISCONFIG &= ~0x20000000;
#elif CONFIG_CPU == PP5002
/* Disable the interrupt */
IISFIFO_CFG &= ~(1<<9);
/* Disable playback FIFO */
IISCONFIG &= ~0x4;
#endif
disable_fiq(); disable_fiq();
} }
pcm_paused = !play; pcm_paused = !play;
@ -500,7 +550,7 @@ bool pcm_is_playing(void)
actually needs to do so when calling callback_for_more. C version is still actually needs to do so when calling callback_for_more. C version is still
included below for reference. included below for reference.
*/ */
#if 1 #if CONFIG_CPU == PP5020
void fiq(void) ICODE_ATTR __attribute__((naked)); void fiq(void) ICODE_ATTR __attribute__((naked));
void fiq(void) void fiq(void)
{ {
@ -579,13 +629,22 @@ void fiq(void) ICODE_ATTR __attribute__ ((interrupt ("FIQ")));
void fiq(void) void fiq(void)
{ {
/* Clear interrupt */ /* Clear interrupt */
#if CONFIG_CPU == PP5020
IISCONFIG &= ~0x2; IISCONFIG &= ~0x2;
#elif CONFIG_CPU == PP5002
inl(0xcf001040);
IISFIFO_CFG &= ~(1<<9);
#endif
do { do {
while (p_size) { while (p_size) {
if (FIFO_FREE_COUNT < 2) { if (FIFO_FREE_COUNT < 2) {
/* Enable interrupt */ /* Enable interrupt */
#if CONFIG_CPU == PP5020
IISCONFIG |= 0x2; IISCONFIG |= 0x2;
#elif CONFIG_CPU == PP5002
IISFIFO_CFG &= ~(1<<9);
#endif
return; return;
} }
@ -625,9 +684,9 @@ void pcm_init(void)
dma_stop(); dma_stop();
} }
#elif (CONFIG_CPU == PNX0101) || (CONFIG_CPU == PP5002) #elif (CONFIG_CPU == PNX0101)
/* TODO: Implement for iFP7xx and iPod 3G /* TODO: Implement for iFP7xx
For now, just implement some dummy functions. For now, just implement some dummy functions.
*/ */
@ -686,7 +745,7 @@ size_t pcm_get_bytes_waiting(void)
#endif #endif
#if (CONFIG_CPU != PNX0101) && (CONFIG_CPU != PP5002) #if (CONFIG_CPU != PNX0101)
/* /*
* This function goes directly into the DMA buffer to calculate the left and * This function goes directly into the DMA buffer to calculate the left and
* right peak values. To avoid missing peaks it tries to look forward two full * right peak values. To avoid missing peaks it tries to look forward two full
@ -704,12 +763,9 @@ void pcm_calculate_peaks(int *left, int *right)
#ifdef HAVE_UDA1380 #ifdef HAVE_UDA1380
long samples = (BCR0 & 0xffffff) / 4; long samples = (BCR0 & 0xffffff) / 4;
short *addr = (short *) (SAR0 & ~3); short *addr = (short *) (SAR0 & ~3);
#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) #elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
long samples = p_size / 4; long samples = p_size / 4;
short *addr = p; short *addr = p;
#elif defined(HAVE_WM8731L)
long samples = next_size / 4;
short *addr = (short *)next_start;
#elif defined(HAVE_TLV320) #elif defined(HAVE_TLV320)
long samples = 4; /* TODO X5 */ long samples = 4; /* TODO X5 */
short *addr = NULL; short *addr = NULL;

View file

@ -30,6 +30,8 @@
#include "wm8975.h" #include "wm8975.h"
#elif defined(HAVE_WM8758) #elif defined(HAVE_WM8758)
#include "wm8758.h" #include "wm8758.h"
#elif defined(HAVE_WM8731)
#include "wm8731l.h"
#elif defined(HAVE_TLV320) #elif defined(HAVE_TLV320)
#include "tlv320.h" #include "tlv320.h"
#endif #endif
@ -77,6 +79,10 @@ static const struct sound_settings_info sound_settings_table[] = {
[SOUND_VOLUME] = {"dB", 0, 1, -57, 6, -25, sound_set_volume}, [SOUND_VOLUME] = {"dB", 0, 1, -57, 6, -25, sound_set_volume},
[SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass}, [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass},
[SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble}, [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble},
#elif defined(HAVE_WM8731)
[SOUND_VOLUME] = {"dB", 0, 1, -73, 6, -25, sound_set_volume},
[SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass},
[SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble},
#else /* MAS3507D */ #else /* MAS3507D */
[SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18, sound_set_volume}, [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18, sound_set_volume},
[SOUND_BASS] = {"dB", 0, 1, -15, 15, 7, sound_set_bass}, [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7, sound_set_bass},
@ -350,10 +356,44 @@ static int tenthdb2mixer(int db)
return -db * 2 / 5; return -db * 2 / 5;
} }
#elif defined(HAVE_WM8731)
/* volume/balance/treble/bass interdependency */
#define VOLUME_MIN -730
#define VOLUME_MAX 60
/* convert tenth of dB volume (-730..60) to master volume register value */
static int tenthdb2master(int db)
{
/* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
/* 1111111 == +6dB (0x7f) */
/* 1111001 == 0dB (0x79) */
/* 0110000 == -73dB (0x30 */
/* 0101111 == mute (0x2f) */
if (db <= -570) {
return 0x0;
} else {
return((db/10)+57);
}
}
/* convert tenth of dB volume (-780..0) to mixer volume register value */
static int tenthdb2mixer(int db)
{
if (db < -660) /* 1.5 dB steps */
return (2640 - db) / 15;
else if (db < -600) /* 0.75 dB steps */
return (990 - db) * 2 / 15;
else if (db < -460) /* 0.5 dB steps */
return (460 - db) / 5;
else /* 0.25 dB steps */
return -db * 2 / 5;
}
#endif #endif
#if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \ #if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \
defined HAVE_WM8975 || defined HAVE_WM8758 defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_WM8731)
/* volume/balance/treble/bass interdependency main part */ /* volume/balance/treble/bass interdependency main part */
#define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN) #define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
@ -383,7 +423,7 @@ static void set_prescaled_volume(void)
mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]); mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]);
#elif defined(HAVE_UDA1380) #elif defined(HAVE_UDA1380)
uda1380_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale)); uda1380_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale));
#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) #elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
wmcodec_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale)); wmcodec_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale));
#endif #endif
@ -409,7 +449,7 @@ static void set_prescaled_volume(void)
dac_volume(tenthdb2reg(l), tenthdb2reg(r), false); dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
#elif defined(HAVE_UDA1380) #elif defined(HAVE_UDA1380)
uda1380_set_master_vol(tenthdb2master(l), tenthdb2master(r)); uda1380_set_master_vol(tenthdb2master(l), tenthdb2master(r));
#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) #elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
wmcodec_set_master_vol(tenthdb2master(l), tenthdb2master(r)); wmcodec_set_master_vol(tenthdb2master(l), tenthdb2master(r));
#endif #endif
} }
@ -511,7 +551,7 @@ void sound_set_volume(int value)
unsigned tmp = ((unsigned)(value + 115) & 0xff) << 8; unsigned tmp = ((unsigned)(value + 115) & 0xff) << 8;
mas_codec_writereg(0x10, tmp); mas_codec_writereg(0x10, tmp);
#elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \ #elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \
defined HAVE_WM8975 || defined HAVE_WM8758 defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731
current_volume = value * 10; /* tenth of dB */ current_volume = value * 10; /* tenth of dB */
set_prescaled_volume(); set_prescaled_volume();
#elif CONFIG_CPU == PNX0101 #elif CONFIG_CPU == PNX0101
@ -528,7 +568,7 @@ void sound_set_balance(int value)
unsigned tmp = ((unsigned)(value * 127 / 100) & 0xff) << 8; unsigned tmp = ((unsigned)(value * 127 / 100) & 0xff) << 8;
mas_codec_writereg(0x11, tmp); mas_codec_writereg(0x11, tmp);
#elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380 || \ #elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380 || \
defined HAVE_WM8975 || defined HAVE_WM8758 defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731
current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */ current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */
set_prescaled_volume(); set_prescaled_volume();
#elif CONFIG_CPU == PNX0101 #elif CONFIG_CPU == PNX0101
@ -552,7 +592,7 @@ void sound_set_bass(int value)
uda1380_set_bass(value >> 1); uda1380_set_bass(value >> 1);
current_bass = value * 10; current_bass = value * 10;
set_prescaled_volume(); set_prescaled_volume();
#elif defined HAVE_WM8975 || defined HAVE_WM8758 #elif defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731
current_bass = value * 10; current_bass = value * 10;
wmcodec_set_bass(value); wmcodec_set_bass(value);
set_prescaled_volume(); set_prescaled_volume();
@ -577,7 +617,7 @@ void sound_set_treble(int value)
uda1380_set_treble(value >> 1); uda1380_set_treble(value >> 1);
current_treble = value * 10; current_treble = value * 10;
set_prescaled_volume(); set_prescaled_volume();
#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) #elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731)
wmcodec_set_treble(value); wmcodec_set_treble(value);
current_treble = value * 10; current_treble = value * 10;
set_prescaled_volume(); set_prescaled_volume();

View file

@ -1237,10 +1237,6 @@ void irq(void)
TIMER1(); TIMER1();
} }
void fiq(void)
{
/** TODO: implement this function **/
}
#endif #endif
/* TODO: The following two function have been lifted straight from IPL, and /* TODO: The following two function have been lifted straight from IPL, and