1
0
Fork 0
forked from len0rd/rockbox

* make it louder - inspired by FS #6911

* disable some unneeded stuff -> save power
* remove some unneeded functions
* shadow registers, so we dont need to do so much i2c traffic



git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13150 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Christian Gmeiner 2007-04-14 00:49:35 +00:00
parent 17c93f9be0
commit ca6f4abcf1
2 changed files with 63 additions and 52 deletions

View file

@ -10,6 +10,7 @@
* Driver for AS3514 audio codec * Driver for AS3514 audio codec
* *
* Copyright (c) 2007 Daniel Ankers * Copyright (c) 2007 Daniel Ankers
* Copyright (c) 2007 Christian Gmeiner
* *
* All files in this archive are subject to the GNU General Public License. * All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement. * See the file COPYING in the source tree root for full license agreement.
@ -32,11 +33,29 @@
#include "buffer.h" #include "buffer.h"
#include "audio.h" #include "audio.h"
#include "backlight.h" #include "backlight.h"
#include "logf.h"
#include "as3514.h" #include "as3514.h"
#include "i2s.h" #include "i2s.h"
#include "i2c-pp.h" #include "i2c-pp.h"
/* Shadow registers */
int as3514_regs[0x1D];
/*
* little helper method to set register values.
* With the help of as3514_regs, we minimize i2c
* traffic.
*/
static void as3514_write(int reg, int value)
{
if (pp_i2c_send(AS3514_I2C_ADDR, reg, value) != 2)
{
DEBUGF("as3514 error reg=0x%x", reg);
}
as3514_regs[reg] = value;
}
/* convert tenth of dB volume to master volume register value */ /* convert tenth of dB volume to master volume register value */
int tenthdb2master(int db) int tenthdb2master(int db)
{ {
@ -73,7 +92,10 @@ void audiohw_reset(void);
/* /*
* Initialise the PP I2C and I2S. * Initialise the PP I2C and I2S.
*/ */
int audiohw_init(void) { int audiohw_init(void)
{
unsigned int i;
/* reset I2C */ /* reset I2C */
i2c_init(); i2c_init();
@ -100,11 +122,18 @@ int audiohw_init(void) {
i2s_reset(); i2s_reset();
/* Set ADC off, mixer on, DAC on, line out off, line in off, mic off */ /* Set ADC off, mixer on, DAC on, line out off, line in off, mic off */
pp_i2c_send(AS3514_I2C_ADDR, AUDIOSET1, 0x60); /* Turn on DAC and mixer */ as3514_write(AUDIOSET1, 0x60); /* Turn on DAC and mixer */
pp_i2c_send(AS3514_I2C_ADDR, PLLMODE, 0x04); as3514_write(AUDIOSET3, 0x5); /* Set HPCM off, ZCU off*/
pp_i2c_send(AS3514_I2C_ADDR, DAC_L, 0x50); /* DAC mute off, -16.5dB gain */ as3514_write(HPH_OUT_R, 0xc0 | 0x16); /* set vol and set speaker over-current to 0 */
pp_i2c_send(AS3514_I2C_ADDR, DAC_R, 0x10); /* DAC -16.5dB gain to prevent overloading as3514_write(HPH_OUT_L, 0x40 | 0x16); /* set default vol for headphone */
the headphone amp */ as3514_write(PLLMODE, 0x04);
/* read all reg values */
for (i = 0; i < sizeof(as3514_regs); i++)
{
as3514_regs[i] = i2c_readbyte(AS3514_I2C_ADDR, i);
}
return 0; return 0;
} }
@ -120,11 +149,11 @@ void audiohw_enable_output(bool enable)
/* reset the I2S controller into known state */ /* reset the I2S controller into known state */
i2s_reset(); i2s_reset();
pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_L, 0xc0); /* Mute on, power on */ as3514_write(HPH_OUT_L, 0xc0); /* Mute off, power on */
audiohw_mute(0); audiohw_mute(0);
} else { } else {
audiohw_mute(1); audiohw_mute(1);
pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_L, 0x80); /* Mute on, power off */ as3514_write(HPH_OUT_L, 0x80); /* Mute on, power off */
} }
} }
@ -132,16 +161,22 @@ int audiohw_set_master_vol(int vol_l, int vol_r)
{ {
vol_l &= 0x1f; vol_l &= 0x1f;
vol_r &= 0x1f; vol_r &= 0x1f;
pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_R, vol_r);
pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_L, 0x40 | vol_l); /* we are controling dac volume instead of headphone volume,
as the volume is bigger.
HDP: 1.07 dB gain
DAC: 6 dB gain
*/
as3514_write(DAC_R, vol_r);
as3514_write(DAC_L, 0x40 | vol_l);
return 0; return 0;
} }
int audiohw_set_lineout_vol(int vol_l, int vol_r) int audiohw_set_lineout_vol(int vol_l, int vol_r)
{ {
pp_i2c_send(AS3514_I2C_ADDR, LINE_OUT_R, vol_r); as3514_write(LINE_OUT_R, vol_r);
pp_i2c_send(AS3514_I2C_ADDR, LINE_OUT_L, 0x40 | vol_l); as3514_write(LINE_OUT_L, 0x40 | vol_l);
return 0; return 0;
} }
@ -154,27 +189,16 @@ int audiohw_set_mixer_vol(int channel1, int channel2)
return 0; return 0;
} }
/* We are using Linear bass control */
void audiohw_set_bass(int value)
{
(void)value;
}
void audiohw_set_treble(int value)
{
(void)value;
}
int audiohw_mute(int mute) int audiohw_mute(int mute)
{ {
int curr; int curr;
curr = i2c_readbyte(AS3514_I2C_ADDR, HPH_OUT_L); curr = as3514_regs[HPH_OUT_L];
if (mute) if (mute)
{ {
pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_L, curr | 0x80); as3514_write(HPH_OUT_L, curr | 0x80);
} else { } else {
pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_L, curr & ~(0x80)); as3514_write(HPH_OUT_L, curr & ~(0x80));
} }
return 0; return 0;
@ -183,47 +207,39 @@ int audiohw_mute(int mute)
/* Nice shutdown of WM8758 codec */ /* Nice shutdown of WM8758 codec */
void audiohw_close(void) void audiohw_close(void)
{ {
/* mute headphones */
audiohw_mute(1); audiohw_mute(1);
}
/* Change the order of the noise shaper, 5th order is recommended above 32kHz */ /* mute mixer */
void audiohw_set_nsorder(int order) as3514_write(AUDIOSET1, 0x0);
{
(void)order; /* turn off everything */
as3514_write(AUDIOSET1, 0x0);
} }
void audiohw_set_sample_rate(int sampling_control) void audiohw_set_sample_rate(int sampling_control)
{ {
(void)sampling_control; (void)sampling_control;
/* TODO: Implement this by adjusting the I2S Master clock */
} }
void audiohw_enable_recording(bool source_mic) void audiohw_enable_recording(bool source_mic)
{ {
(void)source_mic; (void)source_mic;
/* TODO */
} }
void audiohw_disable_recording(void) { void audiohw_disable_recording(void)
/* TODO */ {
int curr;
} }
void audiohw_set_recvol(int left, int right, int type) { void audiohw_set_recvol(int left, int right, int type)
{
(void)left; (void)left;
(void)right; (void)right;
(void)type; (void)type;
} }
void audiohw_set_monitor(int enable) { void audiohw_set_monitor(int enable)
{
(void)enable; (void)enable;
} }
void audiohw_set_equalizer_band(int band, int freq, int bw, int gain)
{
(void)band;
(void)freq;
(void)bw;
(void)gain;
}

View file

@ -31,11 +31,8 @@ extern void audiohw_enable_output(bool enable);
extern int audiohw_set_master_vol(int vol_l, int vol_r); extern int audiohw_set_master_vol(int vol_l, int vol_r);
extern int audiohw_set_lineout_vol(int vol_l, int vol_r); extern int audiohw_set_lineout_vol(int vol_l, int vol_r);
extern int audiohw_set_mixer_vol(int channel1, int channel2); extern int audiohw_set_mixer_vol(int channel1, int channel2);
extern void audiohw_set_bass(int value);
extern void audiohw_set_treble(int value);
extern int audiohw_mute(int mute); extern int audiohw_mute(int mute);
extern void audiohw_close(void); extern void audiohw_close(void);
extern void audiohw_set_nsorder(int order);
extern void audiohw_set_sample_rate(int sampling_control); extern void audiohw_set_sample_rate(int sampling_control);
extern void audiohw_enable_recording(bool source_mic); extern void audiohw_enable_recording(bool source_mic);
@ -43,8 +40,6 @@ extern void audiohw_disable_recording(void);
extern void audiohw_set_recvol(int left, int right, int type); extern void audiohw_set_recvol(int left, int right, int type);
extern void audiohw_set_monitor(int enable); extern void audiohw_set_monitor(int enable);
extern void audiohw_set_equalizer_band(int band, int freq, int bw, int gain);
/* Register Descriptions */ /* Register Descriptions */
#define LINE_OUT_R 0x00 #define LINE_OUT_R 0x00
#define LINE_OUT_L 0x01 #define LINE_OUT_L 0x01