Skip to content

Commit

Permalink
Fix audio on Onda VX747
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21097 a1c6a512-1295-4272-9138-f99709370657
  • Loading branch information
mcuelenaere committed May 26, 2009
1 parent b3bc6ae commit 1c00289
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 112 deletions.
6 changes: 3 additions & 3 deletions firmware/export/config-ondavx747.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
/* Define this if you have the Jz4740 internal codec */
#define HAVE_JZ4740_CODEC

/* has no tone controls, so we use the software ones */
#define HAVE_SW_TONE_CONTROLS

/* define the bitmask of hardware sample rates */
#define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \
SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \
Expand All @@ -131,9 +134,6 @@

#define NEED_ADC_CLOSE 1

/* has no tone controls, so we use the software ones */
//#define HAVE_SW_TONE_CONTROLS

#define BATTERY_CAPACITY_DEFAULT 1250 /* default battery capacity */
#define BATTERY_CAPACITY_MIN 500 /* min. capacity selectable */
#define BATTERY_CAPACITY_MAX 2500 /* max. capacity selectable */
Expand Down
4 changes: 0 additions & 4 deletions firmware/export/jz4740-codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
#ifndef __JZ4740_CODEC_H_
#define __JZ4740_CODEC_H_

/* TODO */
#define VOLUME_MIN -730
#define VOLUME_MAX 60

int tenthdb2master(int db);
void audiohw_set_headphone_vol(int vol_l, int vol_r);

#endif /* __JZ4740_CODEC_H_ */
2 changes: 0 additions & 2 deletions firmware/export/jz4740.h
Original file line number Diff line number Diff line change
Expand Up @@ -1310,8 +1310,6 @@
#define ICDC_CDCCR2_MICBG(n) ((n & 0x3) << 4)
#define ICDC_CDCCR2_HPVOL(n) ((n & 0x3) << 0)

#define ICDC_CDCCR2_AINVOL_DB(n) ((n+34.5)/1.5)

#define ICDC_CDCCR2_SMPR_8 (0)
#define ICDC_CDCCR2_SMPR_11 (1)
#define ICDC_CDCCR2_SMPR_12 (2)
Expand Down
2 changes: 2 additions & 0 deletions firmware/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ static void set_prescaled_volume(void)

#elif defined(HAVE_TLV320) || defined(HAVE_WM8978) || defined(HAVE_WM8985)
audiohw_set_headphone_vol(tenthdb2master(l), tenthdb2master(r));
#elif defined(HAVE_JZ4740_CODEC)
audiohw_set_volume(current_volume);
#endif
}
#endif /* (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 */
Expand Down
93 changes: 48 additions & 45 deletions firmware/target/mips/ingenic_jz47xx/codec-jz4740.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/* TODO */
const struct sound_settings_info audiohw_settings[] = {
[SOUND_VOLUME] = {"dB", 0, 1, -73, 6, -20},
[SOUND_VOLUME] = {"dB", 0, 2, 0, 6, 0},
/* HAVE_SW_TONE_CONTROLS */
[SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
[SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
Expand Down Expand Up @@ -62,40 +62,39 @@ static void i2s_codec_init(void)
{
__cpm_start_aic1();
__cpm_start_aic2();

__aic_enable();

__i2s_internal_codec();
__i2s_as_slave();
__i2s_select_i2s();
__aic_select_i2s();

__aic_disable_byteswap();
__aic_disable_unsignadj();
__aic_disable_mono2stereo();

i2s_codec_reset();

//REG_ICDC_CDCCR2 = (ICDC_CDCCR2_AINVOL(ICDC_CDCCR2_AINVOL_DB(0)) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_48)

REG_ICDC_CDCCR1 &= ~(ICDC_CDCCR1_SUSPD | ICDC_CDCCR1_RST);

REG_ICDC_CDCCR2 = ( ICDC_CDCCR2_AINVOL(14) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_44)
| ICDC_CDCCR2_HPVOL(ICDC_CDCCR2_HPVOL_0));

REG_ICDC_CDCCR1 &= ~(ICDC_CDCCR1_SUSPD | ICDC_CDCCR1_RST);

mdelay(15);
REG_ICDC_CDCCR1 &= ~(ICDC_CDCCR1_PDVR | ICDC_CDCCR1_VRCGL | ICDC_CDCCR1_VRCGH);
REG_ICDC_CDCCR1 |= (ICDC_CDCCR1_EDAC | ICDC_CDCCR1_HPCG);

mdelay(600);
REG_ICDC_CDCCR1 &= ~(ICDC_CDCCR1_PDVRA | ICDC_CDCCR1_HPCG | ICDC_CDCCR1_PDHPM | ICDC_CDCCR1_PDHP);

mdelay(2);

/* CDCCR1.ELININ=0, CDCCR1.EMIC=0, CDCCR1.EADC=0, CDCCR1.SW1ON=0, CDCCR1.EDAC=1, CDCCR1.SW2ON=1, CDCCR1.HPMUTE=0 */
REG_ICDC_CDCCR1 = (REG_ICDC_CDCCR1 & ~(ICDC_CDCCR1_ELININ | ICDC_CDCCR1_EMIC | ICDC_CDCCR1_EADC |
ICDC_CDCCR1_SW1ON | ICDC_CDCCR1_HPMUTE)) | (ICDC_CDCCR1_EDAC
| ICDC_CDCCR1_SW2ON);

HP_on_off_flag = 1; /* HP is on */
}

Expand All @@ -111,7 +110,7 @@ static void i2s_codec_set_mic(unsigned short v) /* 0 <= v <= 100 */
REG_ICDC_CDCCR2 = ((REG_ICDC_CDCCR2 & ~(0x1f << 16)) | (codec_mic_gain << 16));
}

static void i2s_codec_set_bass(unsigned short v) /* 0 <= v <= 100 */
static void i2s_codec_set_base(unsigned short v) /* 0 <= v <= 100 */
{
v &= 0xff;

Expand Down Expand Up @@ -200,6 +199,7 @@ static unsigned short i2s_codec_get_volume(void)
return val;
}

static unsigned long HP_register_value;
static void HP_turn_on(void)
{
//see 1.3.4.1
Expand Down Expand Up @@ -261,11 +261,41 @@ static void HP_turn_off(void)
}
#endif

static void i2s_codec_set_samplerate(unsigned int rate)
void audiohw_mute(bool mute)
{
if(mute)
REG_ICDC_CDCCR1 |= ICDC_CDCCR1_HPMUTE;
else
REG_ICDC_CDCCR1 &= ~ICDC_CDCCR1_HPMUTE;
}

void audiohw_preinit(void)
{
}

void audiohw_postinit(void)
{
audiohw_mute(false);
//HP_turn_on();
}

void audiohw_init(void)
{
i2s_codec_init();
}

void audiohw_set_volume(int v)
{
/* 0 <= v <= 60 */
unsigned int codec_volume = v / 20;
REG_ICDC_CDCCR2 = (REG_ICDC_CDCCR2 & ~ICDC_CDCCR2_HPVOL(0x3)) | ICDC_CDCCR2_HPVOL(codec_volume);
}

void audiohw_set_frequency(int freq)
{
unsigned int speed;
switch (rate)

switch(freq)
{
case 8000:
speed = ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_8);
Expand Down Expand Up @@ -297,33 +327,6 @@ static void i2s_codec_set_samplerate(unsigned int rate)
default:
return;
}
REG_ICDC_CDCCR2 &= ~ICDC_CDCCR2_SMPR(0xF);
REG_ICDC_CDCCR2 |= speed;
}

void audiohw_mute(bool mute)
{
if(mute)
REG_ICDC_CDCCR1 |= ICDC_CDCCR1_HPMUTE;
else
REG_ICDC_CDCCR1 &= ~ICDC_CDCCR1_HPMUTE;
}

void audiohw_preinit(void)
{
}

void audiohw_postinit(void)
{
audiohw_mute(false);
}

void audiohw_init(void)
{
i2s_codec_init();
}

void audiohw_set_frequency(int freq)
{
i2s_codec_set_samplerate(freq);
REG_ICDC_CDCCR2 = (REG_ICDC_CDCCR2 & ~ICDC_CDCCR2_SMPR(0xF)) | speed;
}
Loading

0 comments on commit 1c00289

Please sign in to comment.