1
0
Fork 0
forked from len0rd/rockbox

add more registers for the tsc2100

hopefully working volume control, mute definatly works.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17259 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2008-04-27 13:43:05 +00:00
parent 8d7bd0a940
commit d20d9dd6e4
4 changed files with 174 additions and 12 deletions

View file

@ -255,6 +255,7 @@ drivers/m5636.c
/* Other Random Hardware */
#ifdef HAVE_TSC2100
drivers/tsc2100.c
drivers/audio/tsc2100.c
#endif
/* CPU Specific - By class then particular chip if applicable */

View file

@ -0,0 +1,141 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Driver for TSC2100 audio codec
*
* Copyright (c) 2008 Jonathan Gordon
*
* 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.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "cpu.h"
#include "debug.h"
#include "system.h"
#include "audio.h"
#include "audiohw.h"
#include "tsc2100.h"
const struct sound_settings_info audiohw_settings[] = {
[SOUND_VOLUME] = {"dB", 0, 1, -63, 0, -25},
#if 0
/* HAVE_SW_TONE_CONTROLS */
[SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
[SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
[SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
[SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
[SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
[SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 39, 23},
[SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 31, 23},
[SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 31, 23},
#endif
};
static bool is_muted = false;
/* convert tenth of dB volume to master volume register value */
int tenthdb2master(int db)
{
/* 0 to -63.0dB in 1dB steps, tsc2100 can goto -63.5 in 0.5dB steps */
if (db < VOLUME_MIN) {
return 0x0;
} else if (db >= VOLUME_MAX) {
return 0x1f;
} else {
return((db-VOLUME_MIN)/10); /* VOLUME_MIN is negative */
}
}
int sound_val2phys(int setting, int value)
{
int result;
switch(setting)
{
#if 0
case SOUND_LEFT_GAIN:
case SOUND_RIGHT_GAIN:
case SOUND_MIC_GAIN:
result = (value - 23) * 15;
break;
#endif
default:
result = value;
break;
}
return result;
}
void audiohw_init(void)
{
short val = tsc2100_readreg(TSAC4_PAGE, TSAC4_ADDRESS);
/* disable DAC PGA soft-stepping */
val |= TSAC4_DASTDP;
tsc2100_writereg(TSAC4_PAGE, TSAC4_ADDRESS, val);
}
void audiohw_postinit(void)
{
}
/* Silently enable / disable audio output */
void audiohw_enable_output(bool enable)
{
if (enable) {
audiohw_mute(0);
} else {
audiohw_mute(1);
}
}
void audiohw_set_master_vol(int vol_l, int vol_r)
{
short vol = (vol_l<<14)|(vol_r);
if (is_muted)
vol |= (1<<15)|(1<<7);
tsc2100_writereg(TSDACGAIN_PAGE, TSDACGAIN_ADDRESS, vol);
}
void audiohw_set_lineout_vol(int vol_l, int vol_r)
{
audiohw_set_lineout_vol(vol_l, vol_r);
}
void audiohw_mute(bool mute)
{
short vol = tsc2100_readreg(TSDACGAIN_PAGE, TSDACGAIN_ADDRESS);
/* left mute bit == 1<<15
right mute bit == 1<<7
*/
if (mute)
{
vol |= (1<<15)|(1<<7);
} else
{
vol &= ~((1<<15)|(1<<7));
}
is_muted = mute;
tsc2100_writereg(TSDACGAIN_PAGE, TSDACGAIN_ADDRESS, vol);
}
void audiohw_close(void)
{
/* mute headphones */
audiohw_mute(true);
}
void audiohw_set_sample_rate(int sampling_control)
{
(void)sampling_control;
}

View file

@ -45,6 +45,8 @@
#include "as3514.h"
#elif defined(HAVE_MAS35XX)
#include "mas35xx.h"
#elif defined(HAVE_TSC2100)
#include "tsc2100.h"
#endif
enum {

View file

@ -73,6 +73,8 @@ void tsc2100_writereg(int page, int address, short value);
/* ts codec dac gain control */
#define TSDACGAIN_PAGE 2
#define TSDACGAIN_ADDRESS 0x02
#define VOLUME_MAX 0
#define VOLUME_MIN -630
/* ts audio control 1*/
#define TSAC1_PAGE 2
@ -105,6 +107,22 @@ void tsc2100_writereg(int page, int address, short value);
/* ts audio control 4 */
#define TSAC4_PAGE 2
#define TSAC4_ADDRESS 0x1d
#define TSAC4_ASTDP (1<<15)
#define TSAC4_DASTDP (1<<14)
#define TSAC4_ASSTDP (1<<13)
#define TSAC4_DSTDP (1<<12)
#define TSAC4_RESERVEDD11 (1<<11)
#define TSAC4_AGC_HYST_MASK 0x0c00
#define TSAC4_AGC_HYST_SHIFT 10
#define TSAC4_SHCKT_DIS (1<<8)
#define TSAC4_SHCKT_PD (1<<7)
#define TSAC4_SHCKT_FLAG (1<<6)
#define TSAC4_DAC_POP_RED (1<<5)
#define TSAC4_DAC_POP_RED_SET1 (1<<4)
#define TSAC4_DAC_POP_RED_SET2_MASK 0x000c
#define TSAC4_DAC_POP_RED_SET2_SHIFT 3
#define TSAC4_PGID_MASK 0x0003
#define TSAC4_PGID_SHIFT 0
/* ts audio control 5 */
#define TSAC5_PAGE 2