mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-10 21:55:10 -05:00
HD200 - add FM support.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25757 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4c03e9a6f0
commit
c740af20e7
4 changed files with 371 additions and 9 deletions
|
|
@ -149,6 +149,27 @@ static const struct button_mapping button_context_pitchscreen[] = {
|
||||||
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
|
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
|
||||||
}; /* button_context_pitchscreen */
|
}; /* button_context_pitchscreen */
|
||||||
|
|
||||||
|
static const struct button_mapping button_context_radio[] = {
|
||||||
|
{ ACTION_FM_MENU, BUTTON_SELECT | BUTTON_REPEAT, BUTTON_NONE },
|
||||||
|
{ ACTION_FM_PRESET, BUTTON_SELECT | BUTTON_REL, BUTTON_SELECT },
|
||||||
|
{ ACTION_FM_MODE, BUTTON_SELECT, BUTTON_NONE },
|
||||||
|
{ ACTION_FM_STOP, BUTTON_PLAY | BUTTON_REPEAT, BUTTON_PLAY },
|
||||||
|
{ ACTION_FM_EXIT, BUTTON_REC | BUTTON_REL, BUTTON_REC },
|
||||||
|
{ ACTION_FM_PLAY, BUTTON_PLAY | BUTTON_REL, BUTTON_PLAY },
|
||||||
|
{ ACTION_FM_QUICKSCREEN, BUTTON_REC|BUTTON_REPEAT, BUTTON_REC },
|
||||||
|
{ ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE },
|
||||||
|
{ ACTION_SETTINGS_INCREPEAT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
|
||||||
|
{ ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE },
|
||||||
|
{ ACTION_SETTINGS_DECREPEAT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
|
||||||
|
{ ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE },
|
||||||
|
{ ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
|
||||||
|
{ ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE },
|
||||||
|
{ ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
|
||||||
|
|
||||||
|
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
const struct button_mapping* get_context_mapping(int context)
|
const struct button_mapping* get_context_mapping(int context)
|
||||||
{
|
{
|
||||||
switch (context)
|
switch (context)
|
||||||
|
|
@ -157,7 +178,10 @@ const struct button_mapping* get_context_mapping(int context)
|
||||||
return button_context_standard;
|
return button_context_standard;
|
||||||
case CONTEXT_WPS:
|
case CONTEXT_WPS:
|
||||||
return button_context_wps;
|
return button_context_wps;
|
||||||
|
#if CONFIG_TUNER
|
||||||
|
case CONTEXT_FM:
|
||||||
|
return button_context_radio;
|
||||||
|
#endif
|
||||||
case CONTEXT_TREE:
|
case CONTEXT_TREE:
|
||||||
case CONTEXT_LIST:
|
case CONTEXT_LIST:
|
||||||
case CONTEXT_MAINMENU:
|
case CONTEXT_MAINMENU:
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,18 @@ static int adaptivebass2hw(int value)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_WM8750)
|
||||||
|
static int recvol2hw(int value)
|
||||||
|
{
|
||||||
|
/* convert tenth of dB of input volume (-172...300) to input register value */
|
||||||
|
/* +30dB to -17.25 0.75dB step 6 bits */
|
||||||
|
/* 111111 == +30dB (0x3f) */
|
||||||
|
/* 010111 == 0dB (0x17) */
|
||||||
|
/* 000000 == -17.25dB */
|
||||||
|
|
||||||
|
return (3*(value/10 - 0x17))/4;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
static void audiohw_mute(bool mute)
|
static void audiohw_mute(bool mute)
|
||||||
{
|
{
|
||||||
/* Mute: Set DACMU = 1 to soft-mute the audio DACs. */
|
/* Mute: Set DACMU = 1 to soft-mute the audio DACs. */
|
||||||
|
|
@ -268,3 +280,166 @@ void audiohw_set_frequency(int fsel)
|
||||||
wmcodec_write(CLOCKING, srctrl_table[fsel]);
|
wmcodec_write(CLOCKING, srctrl_table[fsel]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_WM8750)
|
||||||
|
void audiohw_set_recsrc(int source, bool recording)
|
||||||
|
{
|
||||||
|
/* INPUT1 - FM radio
|
||||||
|
* INPUT2 - Line-in
|
||||||
|
* INPUT3 - MIC
|
||||||
|
*
|
||||||
|
* if recording == false we use analog bypass from input
|
||||||
|
* turn off ADC, PGA to save power
|
||||||
|
* turn on output buffer(s)
|
||||||
|
*
|
||||||
|
* if recording == true we route input signal to PGA
|
||||||
|
* and monitoring picks up signal after PGA in analog domain
|
||||||
|
* turn on ADC, PGA, DAC, output buffer(s)
|
||||||
|
*/
|
||||||
|
|
||||||
|
switch(source)
|
||||||
|
{
|
||||||
|
case AUDIO_SRC_PLAYBACK:
|
||||||
|
/* mute PGA, disable all audio paths but DAC and output stage*/
|
||||||
|
wmcodec_write(LINVOL, LINVOL_LINMUTE | LINVOL_LINVOL(23)); /* 0dB */
|
||||||
|
wmcodec_write(RINVOL, RINVOL_RINMUTE | RINVOL_RINVOL(23)); /* 0dB */
|
||||||
|
wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K);
|
||||||
|
wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
|
||||||
|
PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1);
|
||||||
|
|
||||||
|
/* route DAC signal to output mixer */
|
||||||
|
wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO);
|
||||||
|
wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO);
|
||||||
|
|
||||||
|
/* unmute DAC */
|
||||||
|
audiohw_mute(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_SRC_FMRADIO:
|
||||||
|
if(recording)
|
||||||
|
{
|
||||||
|
/* Set input volume to PGA */
|
||||||
|
wmcodec_write(LINVOL, LINVOL_LINVOL(23));
|
||||||
|
wmcodec_write(RINVOL, RINVOL_RINVOL(23));
|
||||||
|
|
||||||
|
/* Turn on PGA and ADC */
|
||||||
|
wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K |
|
||||||
|
PWRMGMT1_AINL | PWRMGMT1_AINR |
|
||||||
|
PWRMGMT1_ADCL | PWRMGMT1_ADCR);
|
||||||
|
|
||||||
|
/* Setup input source for PGA as INPUT1
|
||||||
|
* MICBOOST disabled
|
||||||
|
*/
|
||||||
|
wmcodec_write(ADCL, ADCL_LINSEL_LINPUT1 | ADCL_LMICBOOST_DISABLED);
|
||||||
|
wmcodec_write(ADCR, ADCR_RINSEL_RINPUT1 | ADCR_RMICBOOST_DISABLED);
|
||||||
|
|
||||||
|
/* setup output digital data
|
||||||
|
* default is LADC -> LDATA, RADC -> RDATA
|
||||||
|
* so we don't touch this
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* power up DAC and output stage */
|
||||||
|
wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
|
||||||
|
PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1);
|
||||||
|
|
||||||
|
/* analog monitor */
|
||||||
|
wmcodec_write(LEFTMIX1, LEFTMIX1_LMIXSEL_ADCLIN |
|
||||||
|
LEFTMIX1_LD2LO);
|
||||||
|
wmcodec_write(RIGHTMIX2, RIGHTMIX2_RMIXSEL_ADCRIN |
|
||||||
|
RIGHTMIX2_RD2RO);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
/* turn off ADC, PGA */
|
||||||
|
wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K);
|
||||||
|
|
||||||
|
/* turn on DAC and output stage */
|
||||||
|
wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
|
||||||
|
PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1);
|
||||||
|
|
||||||
|
/* setup monitor mode by routing input signal to outmix
|
||||||
|
* at 0dB volume
|
||||||
|
*/
|
||||||
|
wmcodec_write(LEFTMIX1, LEFTMIX1_LI2LO | LEFTMIX1_LMIXSEL_LINPUT1 |
|
||||||
|
LEFTMIX1_LI2LOVOL(0x20) | LEFTMIX1_LD2LO);
|
||||||
|
wmcodec_write(RIGHTMIX2, RIGHTMIX2_RI2RO | RIGHTMIX2_RMIXSEL_RINPUT1 |
|
||||||
|
RIGHTMIX2_RI2ROVOL(0x20) | RIGHTMIX2_RD2RO);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_SRC_LINEIN:
|
||||||
|
/* Set input volume to PGA */
|
||||||
|
wmcodec_write(LINVOL, LINVOL_LINVOL(23));
|
||||||
|
wmcodec_write(RINVOL, RINVOL_RINVOL(23));
|
||||||
|
|
||||||
|
/* Turn on PGA, ADC, DAC */
|
||||||
|
wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K |
|
||||||
|
PWRMGMT1_AINL | PWRMGMT1_AINR |
|
||||||
|
PWRMGMT1_ADCL | PWRMGMT1_ADCR);
|
||||||
|
|
||||||
|
/* turn on DAC and output stage */
|
||||||
|
wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
|
||||||
|
PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1);
|
||||||
|
|
||||||
|
/* Setup input source for PGA as INPUT2
|
||||||
|
* MICBOOST disabled
|
||||||
|
*/
|
||||||
|
wmcodec_write(ADCL, ADCL_LINSEL_LINPUT2 | ADCL_LMICBOOST_DISABLED);
|
||||||
|
wmcodec_write(ADCR, ADCR_RINSEL_RINPUT2 | ADCR_RMICBOOST_DISABLED);
|
||||||
|
|
||||||
|
/* setup output digital data
|
||||||
|
* default is LADC -> LDATA, RADC -> RDATA
|
||||||
|
* so we don't touch this
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* digital monitor */
|
||||||
|
wmcodec_write(LEFTMIX1, LEFTMIX1_LMIXSEL_ADCLIN |
|
||||||
|
LEFTMIX1_LD2LO);
|
||||||
|
wmcodec_write(RIGHTMIX2, RIGHTMIX2_RMIXSEL_ADCRIN |
|
||||||
|
RIGHTMIX2_RD2RO);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_SRC_MIC:
|
||||||
|
/* Set input volume to PGA */
|
||||||
|
wmcodec_write(LINVOL, LINVOL_LINVOL(23));
|
||||||
|
wmcodec_write(RINVOL, RINVOL_RINVOL(23));
|
||||||
|
|
||||||
|
/* Turn on PGA and ADC, turn off DAC */
|
||||||
|
wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K |
|
||||||
|
PWRMGMT1_AINL | PWRMGMT1_AINR |
|
||||||
|
PWRMGMT1_ADCL | PWRMGMT1_ADCR);
|
||||||
|
|
||||||
|
/* turn on DAC and output stage */
|
||||||
|
wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
|
||||||
|
PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1);
|
||||||
|
|
||||||
|
/* Setup input source for PGA as INPUT3
|
||||||
|
* MICBOOST disabled
|
||||||
|
*/
|
||||||
|
wmcodec_write(ADCL, ADCL_LINSEL_LINPUT3 | ADCL_LMICBOOST_DISABLED);
|
||||||
|
wmcodec_write(ADCR, ADCR_RINSEL_RINPUT3 | ADCR_RMICBOOST_DISABLED);
|
||||||
|
|
||||||
|
/* setup output digital data
|
||||||
|
* default is LADC -> LDATA, RADC -> RDATA
|
||||||
|
* so we don't touch this
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* analog monitor */
|
||||||
|
wmcodec_write(LEFTMIX1, LEFTMIX1_LMIXSEL_ADCLIN |
|
||||||
|
LEFTMIX1_LD2LO);
|
||||||
|
wmcodec_write(RIGHTMIX2, RIGHTMIX2_RMIXSEL_ADCRIN |
|
||||||
|
RIGHTMIX2_RD2RO);
|
||||||
|
break;
|
||||||
|
|
||||||
|
} /* switch(source) */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup PGA gain */
|
||||||
|
void audiohw_set_recvol(int left, int right, int type)
|
||||||
|
{
|
||||||
|
(void)type;
|
||||||
|
wmcodec_write(LINVOL, LINVOL_LINVOL(recvol2hw(left)));
|
||||||
|
wmcodec_write(RINVOL, RINVOL_RINVOL(recvol2hw(right)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,28 @@ extern int tenthdb2master(int db);
|
||||||
|
|
||||||
extern void audiohw_set_master_vol(int vol_l, int vol_r);
|
extern void audiohw_set_master_vol(int vol_l, int vol_r);
|
||||||
extern void audiohw_set_lineout_vol(int vol_l, int vol_r);
|
extern void audiohw_set_lineout_vol(int vol_l, int vol_r);
|
||||||
|
#if defined(HAVE_WM8750)
|
||||||
|
void audiohw_set_recsrc(int source, bool recording);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Register addresses and bits */
|
/* Register addresses and bits */
|
||||||
#define OUTPUT_MUTED 0x2f
|
#define OUTPUT_MUTED 0x2f
|
||||||
#define OUTPUT_0DB 0x79
|
#define OUTPUT_0DB 0x79
|
||||||
|
|
||||||
|
#if defined(HAVE_WM8750)
|
||||||
|
#define LINVOL 0x00
|
||||||
|
#define LINVOL_LINVOL(x) ((x) & 0x3f)
|
||||||
|
#define LINVOL_LIZC (1 << 6)
|
||||||
|
#define LINVOL_LINMUTE (1 << 7)
|
||||||
|
#define LINVOL_LIVU (1 << 8)
|
||||||
|
|
||||||
|
#define RINVOL 0x01
|
||||||
|
#define RINVOL_RINVOL(x) ((x) & 0x3f)
|
||||||
|
#define RINVOL_RIZC (1 << 6)
|
||||||
|
#define RINVOL_RINMUTE (1 << 7)
|
||||||
|
#define RINVOL_RIVU (1 << 8)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LOUT1 0x02
|
#define LOUT1 0x02
|
||||||
#define LOUT1_LOUT1VOL_MASK (0x07f << 0)
|
#define LOUT1_LOUT1VOL_MASK (0x07f << 0)
|
||||||
#define LOUT1_LOUT1VOL(x) ((x) & 0x7f)
|
#define LOUT1_LOUT1VOL(x) ((x) & 0x7f)
|
||||||
|
|
@ -98,7 +115,7 @@ extern void audiohw_set_lineout_vol(int vol_l, int vol_r);
|
||||||
#define RESET 0x0f
|
#define RESET 0x0f
|
||||||
#define RESET_RESET 0x000
|
#define RESET_RESET 0x000
|
||||||
|
|
||||||
/* WM8750 only */
|
#if defined(HAVE_WM8750)
|
||||||
#define ENHANCE_3D 0x10
|
#define ENHANCE_3D 0x10
|
||||||
#define ENHANCE_3D_3DEN (1 << 0)
|
#define ENHANCE_3D_3DEN (1 << 0)
|
||||||
#define ENHANCE_3D_DEPTH(x) (((x) & 0xf) << 1)
|
#define ENHANCE_3D_DEPTH(x) (((x) & 0xf) << 1)
|
||||||
|
|
@ -107,6 +124,30 @@ extern void audiohw_set_lineout_vol(int vol_l, int vol_r);
|
||||||
#define ENHANCE_3D_MODE3D_PLAYBACK (1 << 7)
|
#define ENHANCE_3D_MODE3D_PLAYBACK (1 << 7)
|
||||||
#define ENHANCE_3D_MODE3D_RECORD (0 << 7)
|
#define ENHANCE_3D_MODE3D_RECORD (0 << 7)
|
||||||
|
|
||||||
|
#define ALC1 0x11
|
||||||
|
#define ALC1_ALCL(x) ((x) & (0x0f))
|
||||||
|
#define ALC1_MAXGAIN(x) ((x) & (0x07 << 4))
|
||||||
|
#define ALC1_ALCSEL_DISABLED (0 << 7)
|
||||||
|
#define ALC1_ALCSEL_RIGHT (1 << 7)
|
||||||
|
#define ALC1_ALCSEL_LEFT (2 << 7)
|
||||||
|
#define ALC1_ALCSEL_STEREO (3 << 7)
|
||||||
|
|
||||||
|
#define ALC2 0x12
|
||||||
|
#define ALC2_HLD(x) ((x) & 0x0f)
|
||||||
|
#define ALC2_ALCZC (1 << 7)
|
||||||
|
|
||||||
|
#define ALC3 0x13
|
||||||
|
#define ALC3_ATK(x) ((x) & 0x0f)
|
||||||
|
#define ALC3_DCY(x) ((x) & (0x0f << 4))
|
||||||
|
|
||||||
|
#define NGAT 0x14
|
||||||
|
#define NGAT_NGAT (1 << 0)
|
||||||
|
#define NGAT_NGG_CONST (0 << 1)
|
||||||
|
#define NGAT_NGG_MUTEADC (1 << 1)
|
||||||
|
#define NGAT_NGG(x) ((x) & (0x3 << 1))
|
||||||
|
#define NGAT_NGTH(x) ((x) & (0x1f << 3))
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ADDITIONAL1 0x17
|
#define ADDITIONAL1 0x17
|
||||||
#define ADDITIONAL1_TOEN (1 << 0)
|
#define ADDITIONAL1_TOEN (1 << 0)
|
||||||
#define ADDITIONAL1_DACINV (1 << 1)
|
#define ADDITIONAL1_DACINV (1 << 1)
|
||||||
|
|
@ -136,6 +177,13 @@ extern void audiohw_set_lineout_vol(int vol_l, int vol_r);
|
||||||
|
|
||||||
#define PWRMGMT1 0x19
|
#define PWRMGMT1 0x19
|
||||||
#define PWRMGMT1_DIGENB (1 << 0)
|
#define PWRMGMT1_DIGENB (1 << 0)
|
||||||
|
#if defined(HAVE_WM8750)
|
||||||
|
#define PWRMGMT1_MICBIAS (1 << 1)
|
||||||
|
#define PWRMGMT1_ADCR (1 << 2)
|
||||||
|
#define PWRMGMT1_ADCL (1 << 3)
|
||||||
|
#define PWRMGMT1_AINR (1 << 4)
|
||||||
|
#define PWRMGMT1_AINL (1 << 5)
|
||||||
|
#endif
|
||||||
#define PWRMGMT1_VREF (1 << 6)
|
#define PWRMGMT1_VREF (1 << 6)
|
||||||
#define PWRMGMT1_VMIDSEL_DISABLED (0 << 7)
|
#define PWRMGMT1_VMIDSEL_DISABLED (0 << 7)
|
||||||
#define PWRMGMT1_VMIDSEL_50K (1 << 7)
|
#define PWRMGMT1_VMIDSEL_50K (1 << 7)
|
||||||
|
|
@ -158,7 +206,48 @@ extern void audiohw_set_lineout_vol(int vol_l, int vol_r);
|
||||||
#define ADDITIONAL3_HPFLREN (1 << 5)
|
#define ADDITIONAL3_HPFLREN (1 << 5)
|
||||||
#define ADDITIONAL3_VROI (1 << 6)
|
#define ADDITIONAL3_VROI (1 << 6)
|
||||||
|
|
||||||
|
#if defined(HAVE_WM8750)
|
||||||
|
#define ADCIM 0x1f
|
||||||
|
#define ADCIM_LDCM (1 << 4)
|
||||||
|
#define ADCIM_RDCM (1 << 5)
|
||||||
|
#define ADCIM_MONOMIX_STEREO (0 << 6)
|
||||||
|
#define ADCIM_MONOMIX_AMONOL (1 << 6)
|
||||||
|
#define ADCIM_MONOMIX_AMONOR (2 << 6)
|
||||||
|
#define ADCIM_MONOMIX_DMONO (3 << 6)
|
||||||
|
#define ADCIM_MONOMIX(x) ((x) & (0x3 << 6))
|
||||||
|
#define ADCIM_DS (1 << 8)
|
||||||
|
|
||||||
|
#define ADCL 0x20
|
||||||
|
#define ADCL_LMICBOOST_DISABLED (0 << 4)
|
||||||
|
#define ADCL_LMICBOOST_13DB (1 << 4)
|
||||||
|
#define ADCL_LMICBOOST_20DB (2 << 4)
|
||||||
|
#define ADCL_LMICBOOST_29DB (3 << 4)
|
||||||
|
#define ADCL_LMICBOOST(x) ((x) & (0x3 << 7))
|
||||||
|
#define ADCL_LINSEL_LINPUT1 (0 << 6)
|
||||||
|
#define ADCL_LINSEL_LINPUT2 (1 << 6)
|
||||||
|
#define ADCL_LINSEL_LINPUT3 (2 << 6)
|
||||||
|
#define ADCL_LINSEL_DIFF (3 << 6)
|
||||||
|
|
||||||
|
#define ADCR 0x21
|
||||||
|
#define ADCR_RMICBOOST_DISABLED (0 << 4)
|
||||||
|
#define ADCR_RMICBOOST_13DB (1 << 4)
|
||||||
|
#define ADCR_RMICBOOST_20DB (2 << 4)
|
||||||
|
#define ADCR_RMICBOOST_29DB (3 << 4)
|
||||||
|
#define ADCR_RMICBOOST(x) ((x) & (0x3 << 7))
|
||||||
|
#define ADCR_RINSEL_RINPUT1 (0 << 6)
|
||||||
|
#define ADCR_RINSEL_RINPUT2 (1 << 6)
|
||||||
|
#define ADCR_RINSEL_RINPUT3 (2 << 6)
|
||||||
|
#define ADCR_RINSEL_DIFF (3 << 6)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LEFTMIX1 0x22
|
#define LEFTMIX1 0x22
|
||||||
|
#if defined(HAVE_WM8750)
|
||||||
|
#define LEFTMIX1_LMIXSEL_LINPUT1 (0 << 0)
|
||||||
|
#define LEFTMIX1_LMIXSEL_LINPUT2 (1 << 0)
|
||||||
|
#define LEFTMIX1_LMIXSEL_LINPUT3 (2 << 0)
|
||||||
|
#define LEFTMIX1_LMIXSEL_ADCLIN (3 << 0)
|
||||||
|
#define LEFTMIX1_LMIXSEL_DIFF (4 << 0)
|
||||||
|
#endif
|
||||||
#define LEFTMIX1_LI2LO_DEFAULT (5 << 4)
|
#define LEFTMIX1_LI2LO_DEFAULT (5 << 4)
|
||||||
#define LEFTMIX1_LI2LOVOL(x) ((x) & (0x7 << 4))
|
#define LEFTMIX1_LI2LOVOL(x) ((x) & (0x7 << 4))
|
||||||
#define LEFTMIX1_LI2LO (1 << 7)
|
#define LEFTMIX1_LI2LO (1 << 7)
|
||||||
|
|
@ -167,16 +256,39 @@ extern void audiohw_set_lineout_vol(int vol_l, int vol_r);
|
||||||
#define LEFTMIX2 0x23
|
#define LEFTMIX2 0x23
|
||||||
#define LEFTMIX2_MI2LO_DEFAULT (5 << 4)
|
#define LEFTMIX2_MI2LO_DEFAULT (5 << 4)
|
||||||
#define LEFTMIX2_MI2LOVOL(x) ((x) & (0x7 << 4))
|
#define LEFTMIX2_MI2LOVOL(x) ((x) & (0x7 << 4))
|
||||||
|
#if defined(HAVE_WM8750)
|
||||||
|
#define LEFTMIX2_RI2LO (1 << 7)
|
||||||
|
#elif defined(HAVE_WM8751)
|
||||||
#define LEFTMIX2_MI2LO (1 << 7)
|
#define LEFTMIX2_MI2LO (1 << 7)
|
||||||
|
#endif
|
||||||
#define LEFTMIX2_RD2LO (1 << 8)
|
#define LEFTMIX2_RD2LO (1 << 8)
|
||||||
|
|
||||||
#define RIGHTMIX1 0x24
|
#define RIGHTMIX1 0x24
|
||||||
|
#if defined(HAVE_WM8750)
|
||||||
|
#define RIGHTMIX1_RMIXSEL_RINPUT1 (0 << 0)
|
||||||
|
#define RIGHTMIX1_RMIXSEL_RINPUT2 (1 << 0)
|
||||||
|
#define RIGHTMIX1_RMIXSEL_RINPUT3 (2 << 0)
|
||||||
|
#define RIGHTMIX1_RMIXSEL_ADCRIN (3 << 0)
|
||||||
|
#define RIGHTMIX1_RMIXSEL_DIFF (4 << 0)
|
||||||
|
#define RIGHTMIX1_LI2RO_DEFAULT (5 << 4)
|
||||||
|
#define RIGHTMIX1_LI2ROVOL(x) ((x) & (0x7 << 4))
|
||||||
|
#define RIGHTMIX1_LI2RO (1 << 7)
|
||||||
|
#define RIGHTMIX1_LD2RO (1 << 8)
|
||||||
|
#elif defined(HAVE_WM8751)
|
||||||
#define RIGHTMIX1_MI2RO_DEFAULT (5 << 4)
|
#define RIGHTMIX1_MI2RO_DEFAULT (5 << 4)
|
||||||
#define RIGHTMIX1_MI2ROVOL(x) ((x) & (0x7 << 4))
|
#define RIGHTMIX1_MI2ROVOL(x) ((x) & (0x7 << 4))
|
||||||
#define RIGHTMIX1_MI2RO (1 << 7)
|
#define RIGHTMIX1_MI2RO (1 << 7)
|
||||||
#define RIGHTMIX1_LD2RO (1 << 8)
|
#define RIGHTMIX1_LD2RO (1 << 8)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define RIGHTMIX2 0x25
|
#define RIGHTMIX2 0x25
|
||||||
|
#if defined(HAVE_WM8750)
|
||||||
|
#define RIGHTMIX2_RMIXSEL_RINPUT1 (0 << 0)
|
||||||
|
#define RIGHTMIX2_RMIXSEL_RINPUT2 (1 << 0)
|
||||||
|
#define RIGHTMIX2_RMIXSEL_RINPUT3 (2 << 0)
|
||||||
|
#define RIGHTMIX2_RMIXSEL_ADCRIN (3 << 0)
|
||||||
|
#define RIGHTMIX2_RMIXSEL_DIFF (4 << 0)
|
||||||
|
#endif
|
||||||
#define RIGHTMIX2_RI2RO_DEFAULT (5 << 4)
|
#define RIGHTMIX2_RI2RO_DEFAULT (5 << 4)
|
||||||
#define RIGHTMIX2_RI2ROVOL(x) ((x) & (0x7 << 4))
|
#define RIGHTMIX2_RI2ROVOL(x) ((x) & (0x7 << 4))
|
||||||
#define RIGHTMIX2_RI2RO (1 << 7)
|
#define RIGHTMIX2_RI2RO (1 << 7)
|
||||||
|
|
|
||||||
|
|
@ -23,27 +23,78 @@
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
|
static inline void enable_mclk(bool enable)
|
||||||
|
{
|
||||||
|
if(enable)
|
||||||
|
and_l(~(1<<10), &GPIO1_FUNCTION);
|
||||||
|
else
|
||||||
|
or_l((1<<10), &GPIO1_FUNCTION);
|
||||||
|
}
|
||||||
|
|
||||||
void audio_set_output_source(int source)
|
void audio_set_output_source(int source)
|
||||||
{
|
{
|
||||||
|
static const unsigned char txsrc_select[AUDIO_NUM_SOURCES+1] =
|
||||||
|
{
|
||||||
|
[AUDIO_SRC_PLAYBACK+1] = 3, /* PDOR3 */
|
||||||
|
[AUDIO_SRC_MIC+1] = 4, /* IIS1 RcvData */
|
||||||
|
[AUDIO_SRC_LINEIN+1] = 4, /* IIS1 RcvData */
|
||||||
|
[AUDIO_SRC_FMRADIO+1] = 4, /* IIS1 RcvData */
|
||||||
|
};
|
||||||
|
|
||||||
(void)source;
|
|
||||||
int level = set_irq_level(DMA_IRQ_LEVEL);
|
int level = set_irq_level(DMA_IRQ_LEVEL);
|
||||||
|
|
||||||
/* PDOR3 */
|
if ((unsigned)source >= AUDIO_NUM_SOURCES)
|
||||||
IIS2CONFIG = (IIS2CONFIG & ~(7 << 8)) | (3 << 8);
|
source = AUDIO_SRC_PLAYBACK;
|
||||||
|
|
||||||
|
IIS2CONFIG = (IIS2CONFIG & ~(7 << 8)) | (txsrc_select[source+1] << 8);
|
||||||
|
|
||||||
restore_irq(level);
|
restore_irq(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_input_mux(int source, unsigned flags)
|
void audio_input_mux(int source, unsigned flags)
|
||||||
{
|
{
|
||||||
(void)source;
|
/* Prevent pops from unneeded switching */
|
||||||
(void)flags;
|
static int last_source = AUDIO_SRC_PLAYBACK;
|
||||||
|
bool recording = flags & SRCF_RECORDING;
|
||||||
|
static bool last_recording = false;
|
||||||
|
|
||||||
switch(source)
|
switch(source)
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
|
/* playback - no recording */
|
||||||
|
source = AUDIO_SRC_PLAYBACK;
|
||||||
|
|
||||||
|
case AUDIO_SRC_PLAYBACK:
|
||||||
|
if (source != last_source)
|
||||||
|
{
|
||||||
|
audiohw_set_recsrc(source,false);
|
||||||
|
coldfire_set_dataincontrol(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUDIO_SRC_MIC:
|
||||||
|
case AUDIO_SRC_LINEIN:
|
||||||
|
/* recording only */
|
||||||
|
if (source != last_source)
|
||||||
|
{
|
||||||
|
audiohw_set_recsrc(source,true);
|
||||||
|
/* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
|
||||||
|
coldfire_set_dataincontrol((3 << 14) | (4 << 3));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case AUDIO_SRC_FMRADIO:
|
case AUDIO_SRC_FMRADIO:
|
||||||
break;
|
if (source == last_source && recording == last_recording)
|
||||||
|
break;
|
||||||
|
|
||||||
|
last_recording = recording;
|
||||||
|
|
||||||
|
/* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
|
||||||
|
coldfire_set_dataincontrol(recording ?
|
||||||
|
((3 << 14) | (4 << 3)) : 0);
|
||||||
|
audiohw_set_recsrc(source, recording);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
/* empty stub */
|
|
||||||
|
last_source = source;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue