recording on Samsung YH-820/YH-92x

Change-Id: I6eac4cf6c16a322910ad17bfbf3105e330cd0e36
Reviewed-on: http://gerrit.rockbox.org/815
Reviewed-by: Szymon Dziok <b0hoon@o2.pl>
Tested: Szymon Dziok <b0hoon@o2.pl>
This commit is contained in:
Sebastian Leonhardt 2014-05-30 00:26:27 +02:00 committed by Szymon Dziok
parent 5237b36a85
commit 53efa59e12
6 changed files with 118 additions and 16 deletions

View file

@ -253,17 +253,14 @@ static const struct button_mapping button_context_pitchscreen[] = {
static const struct button_mapping button_context_recscreen[] = { static const struct button_mapping button_context_recscreen[] = {
{ ACTION_REC_PAUSE, BUTTON_PLAY|BUTTON_REL, BUTTON_NONE }, { ACTION_REC_PAUSE, BUTTON_PLAY|BUTTON_REL, BUTTON_NONE },
#ifdef SAMSUNG_YH820 { ACTION_REC_NEWFILE, BUTTON_FFWD|BUTTON_REL, BUTTON_NONE },
/* the yh-820 has a rec button */
{ ACTION_REC_NEWFILE, BUTTON_REC, BUTTON_NONE }, { ACTION_STD_MENU, BUTTON_REC, BUTTON_NONE },
#else { ACTION_STD_MENU, BUTTON_REW|BUTTON_REPEAT, BUTTON_REW },
/* the yh-920 & yh-925 have a rec switch */ { ACTION_STD_CANCEL, BUTTON_REW|BUTTON_REL, BUTTON_NONE },
{ ACTION_REC_NEWFILE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
#endif
{ ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE },
{ ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_SETTINGS_INCREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE }, { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE },
{ ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_SETTINGS_DECREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },

View file

@ -223,22 +223,116 @@ void audiohw_set_frequency(int fsel)
#if defined(HAVE_RECORDING) #if defined(HAVE_RECORDING)
void audiohw_enable_recording(bool source_mic) void audiohw_enable_recording(bool source_mic)
{ {
(void)source_mic; if (source_mic)
{
/* enable mic power supply */
#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
/* additionally select external mic */
akc_set(AK4537_MIC, MPWRE | MSEL);
#else
akc_set(AK4537_MIC, MPWRI);
#endif
/* mic out is connected to line1 input */
akc_clear(AK4537_PM3, INL | INR);
/* route ALC output to ADC input */
akc_set(AK4537_MIC, MICAD);
/* set ALC (automatic level control) to manual mode */
akc_clear(AK4537_ALC1, ALC1);
/* set gain control to 'dependent' (left&right at the same time) */
akc_clear(AK4537_MIC, IPGAC);
/* power up mic preamp, left channel ADC and line in */
akc_set(AK4537_PM1, PMMICL | PMIPGL | PMADL);
/* power up right channel ADC and line in */
akc_set(AK4537_PM3, PMADR | PMIPGR);
}
else
{
/* disable mic power supply */
#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
akc_clear(AK4537_MIC, MPWRE);
#else
akc_clear(AK4537_MIC, MPWRI);
#endif
/* disable mic preamp */
akc_clear(AK4537_PM1, PMMICL);
/* Select line1 input */
akc_clear(AK4537_PM3, INL | INR);
/* route ALC output to ADC input */
akc_set(AK4537_MIC, MICAD);
/* set ALC (automatic level control) to manual mode */
akc_clear(AK4537_ALC1, ALC1);
/* set gain control to independent left & right gain */
akc_set(AK4537_MIC, IPGAC);
/* power up left channel input and ADC */
akc_set(AK4537_PM1, PMADL | PMIPGL);
/* power up right channel input and ADC */
akc_set(AK4537_PM3, PMADR | PMIPGR);
}
} }
void audiohw_disable_recording(void) void audiohw_disable_recording(void)
{ {
/* disable mic power supply */
#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
akc_clear(AK4537_MIC, MPWRE);
#else
akc_clear(AK4537_MIC, MPWRI);
#endif
/* power down ADC, mic preamp and line amp */
akc_clear(AK4537_PM1, PMADL | PMMICL | PMIPGL);
akc_clear(AK4537_PM3, PMADR | PMMICR | PMIPGR);
} }
void audiohw_set_recvol(int left, int right, int type) void audiohw_set_recvol(int left, int right, int type)
{ {
(void)left; switch (type)
(void)right; {
(void)type; case AUDIO_GAIN_MIC:
/* the mic preamp has a fixed gain of +15 dB. There's an additional
* activatable +20dB mic gain stage. The signal is then routed to
* the Line1 input, where you find the line attenuator with a range
* from -23.5 to +12dB, so we have a total gain range of -8.0 .. +47dB.
* NOTE: the datasheet state's different attenuator levels for mic and
* line input, but that's not precise. The +15dB difference result only
* from the mic stage.
* NOTE2: the mic is connected to the line1 input (via mic preamp),
* so if a line signal is present, you will always record a mixup.
*/
/* If gain is > 20 dB we use the additional gain stage */
if (left > 20) {
akc_set(AK4537_MIC, MGAIN);
left -= 20;
}
else {
akc_clear(AK4537_MIC, MGAIN);
}
/* the remains is done by the line input amp */
left = (left+8)*2;
akc_write(AK4537_IPGAL, left);
break;
case AUDIO_GAIN_LINEIN:
/* convert dB to register value */
left = (left+23)*2+1;
right = (right+23)*2+1;
akc_write(AK4537_IPGAL, left);
akc_write(AK4537_IPGAR, right);
break;
default:
return;
}
} }
void audiohw_set_monitor(bool enable) void audiohw_set_monitor(bool enable)
{ {
(void)enable; if (enable)
/* mix input signal to headphone output */
akc_set(AK4537_SIGSEL2, MICL);
else
akc_clear(AK4537_SIGSEL2, MICL);
} }
#endif /* HAVE_RECORDING */ #endif /* HAVE_RECORDING */

View file

@ -22,8 +22,19 @@
#ifndef _AK4537_H #ifndef _AK4537_H
#define _AK4537_H #define _AK4537_H
#define AUDIOHW_CAPS (LIN_GAIN_CAP | MIC_GAIN_CAP)
/* Volume goes from -127.0 ... 0 dB in 0.5 dB increments */ /* Volume goes from -127.0 ... 0 dB in 0.5 dB increments */
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -128, 0, -25) AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -128, 0, -25)
#ifdef HAVE_RECORDING
/* line input: -23 .. +12dB */
AUDIOHW_SETTING(LEFT_GAIN, "dB", 0, 1, -23, 12, 0)
AUDIOHW_SETTING(RIGHT_GAIN, "dB", 0, 1, -23, 12, 0)
/* mic gain: +15dB fixed +20dB switchable mic preamp gain
and the line stage of -23..+12dB make a total range of -8..+47dB */
AUDIOHW_SETTING(MIC_GAIN, "dB", 0, 1, -8, 47, 20)
#endif /* HAVE_RECORDING */
#define AKC_NUM_REGS 0x11 #define AKC_NUM_REGS 0x11

View file

@ -7,7 +7,7 @@
#define MODEL_NAME "Samsung YH-820" #define MODEL_NAME "Samsung YH-820"
/* define this if you have recording possibility */ /* define this if you have recording possibility */
/* todo #define HAVE_RECORDING */ #define HAVE_RECORDING
/* Define bitmask of input sources - recordable bitmask can be defined /* Define bitmask of input sources - recordable bitmask can be defined
explicitly if different */ explicitly if different */

View file

@ -7,7 +7,7 @@
#define MODEL_NAME "Samsung YH-920" #define MODEL_NAME "Samsung YH-920"
/* define this if you have recording possibility */ /* define this if you have recording possibility */
/* todo #define HAVE_RECORDING */ #define HAVE_RECORDING
/* Define bitmask of input sources - recordable bitmask can be defined /* Define bitmask of input sources - recordable bitmask can be defined
explicitly if different */ explicitly if different */

View file

@ -7,7 +7,7 @@
#define MODEL_NAME "Samsung YH-925" #define MODEL_NAME "Samsung YH-925"
/* define this if you have recording possibility */ /* define this if you have recording possibility */
/* todo #define HAVE_RECORDING */ #define HAVE_RECORDING
/* Define bitmask of input sources - recordable bitmask can be defined /* Define bitmask of input sources - recordable bitmask can be defined
explicitly if different */ explicitly if different */