mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-09 23:53:28 -04:00
YP-CP3: recording from the microphone and FM radio
- config: HAVE_RECORDING, sources microphone and FM, 8-48 kHz - wm8751.c: the YP-CP3's own audiohw_set_recsrc(). The rk27xx cannot send received samples straight back out, so what is heard of an input goes through the codec's analog bypass - the input PGA into the output mixers: the radio always, the microphone never. As in the original firmware, the radio passes the PGA at +12 dB when only listened to, and the microphone - mono, on RINPUT2 - gets +13 dB boost and is recorded by the right ADC onto both channels (the original firmware's noise gate is left out). The HD300's version assumes the microphone on INPUT3 and headphones on OUT1, and switches OUT2 - the YP-CP3's headphones - off. - wm8751.c: the playback-only FM monitor added for the YP-CP3 goes; the radio is routed by audiohw_set_recsrc() now, as on the HD300 - wm8751.h: DATSEL, which ADC feeds each channel of the output data Only partly tested on hardware: FM radio still plays, and the recording screen's peak meter follows the microphone. Not yet tested: a recorded file played back, recording FM, recording gain range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Change-Id: I3c25f4333f765d98dddc2fd722c111f8493bbe77
This commit is contained in:
parent
3fbf975ecc
commit
3689292b28
3 changed files with 76 additions and 39 deletions
|
|
@ -427,43 +427,6 @@ void audiohw_set_depth_3d(int val)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_WM8750) && defined(HAVE_FMRADIO_IN) && !defined(HAVE_RECORDING)
|
||||
/* The FM tuner, on LINPUT1/RINPUT1, played through the analog bypass into
|
||||
* the output mixers - for a target that plays the radio but cannot record
|
||||
* it. As on the YP-CP3's original firmware, the signal goes through the
|
||||
* input PGA at +12 dB, which the tuner's low line level needs. The DAC
|
||||
* stays in the mix. */
|
||||
void audiohw_set_monitor(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
wmcodec_set_masked(ADCL, ADCL_LINSEL_LINPUT1, ADCL_LINSEL_MASK);
|
||||
wmcodec_set_masked(ADCR, ADCR_RINSEL_RINPUT1, ADCR_RINSEL_MASK);
|
||||
wmcodec_set_reg(LINVOL, LINVOL_LIZC | LINVOL_LINVOL(0x27));
|
||||
wmcodec_set_reg(RINVOL, RINVOL_RIVU | RINVOL_RIZC |
|
||||
RINVOL_RINVOL(0x27));
|
||||
wmcodec_set_bits(PWRMGMT1, PWRMGMT1_AINL | PWRMGMT1_AINR);
|
||||
|
||||
wmcodec_set_masked(LEFTMIX1, LEFTMIX1_LMIXSEL_ADCLIN |
|
||||
LEFTMIX1_LI2LOVOL(0x20),
|
||||
0x7 | LEFTMIX1_LI2LOVOL_MASK);
|
||||
wmcodec_set_bits(LEFTMIX1, LEFTMIX1_LI2LO);
|
||||
wmcodec_set_masked(RIGHTMIX1, RIGHTMIX1_RMIXSEL_ADCRIN, 0x7);
|
||||
wmcodec_set_masked(RIGHTMIX2, RIGHTMIX2_RI2ROVOL(0x20),
|
||||
RIGHTMIX2_RI2ROVOL_MASK);
|
||||
wmcodec_set_bits(RIGHTMIX2, RIGHTMIX2_RI2RO);
|
||||
}
|
||||
else
|
||||
{
|
||||
wmcodec_clear_bits(LEFTMIX1, LEFTMIX1_LI2LO);
|
||||
wmcodec_clear_bits(RIGHTMIX2, RIGHTMIX2_RI2RO);
|
||||
wmcodec_set_bits(LINVOL, LINVOL_LINMUTE);
|
||||
wmcodec_set_bits(RINVOL, RINVOL_RIVU | RINVOL_RINMUTE);
|
||||
wmcodec_clear_bits(PWRMGMT1, PWRMGMT1_AINL | PWRMGMT1_AINR);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RECORDING
|
||||
#if 0
|
||||
static void audiohw_set_ngat(int ngath, int type, bool enable)
|
||||
|
|
@ -502,6 +465,70 @@ static void audiohw_set_alc(unsigned char level, /* signal level at ADC */
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(SAMSUNG_YPCP3)
|
||||
/* Samsung YP-CP3: the FM tuner on LINPUT1/RINPUT1, the microphone - mono -
|
||||
* on RINPUT2, the headphones on OUT2. The rk27xx cannot send received
|
||||
* samples straight back out, so what is heard of an input goes through the
|
||||
* codec's analog bypass, the input PGA into the output mixers: the radio
|
||||
* always, the microphone never. As in the original firmware, the radio
|
||||
* passes the PGA at +12 dB when only listened to, and the microphone gets
|
||||
* +13 dB of boost and is recorded by the right ADC onto both channels.
|
||||
* While recording, the gain setting drives the PGA. */
|
||||
void audiohw_set_recsrc(int source, bool recording)
|
||||
{
|
||||
audiohw_mute(true);
|
||||
|
||||
/* inputs off */
|
||||
wmcodec_clear_bits(LEFTMIX1, LEFTMIX1_LI2LO);
|
||||
wmcodec_clear_bits(RIGHTMIX2, RIGHTMIX2_RI2RO);
|
||||
wmcodec_clear_bits(PWRMGMT1, PWRMGMT1_AINL | PWRMGMT1_AINR |
|
||||
PWRMGMT1_ADCL | PWRMGMT1_ADCR);
|
||||
wmcodec_set_masked(ADCR, ADCR_RMICBOOST_DISABLED, 0x3 << 4);
|
||||
wmcodec_set_masked(ADDITIONAL1, ADDITIONAL1_DATSEL_LR,
|
||||
ADDITIONAL1_DATSEL_MASK);
|
||||
|
||||
switch (source)
|
||||
{
|
||||
case AUDIO_SRC_FMRADIO:
|
||||
wmcodec_set_masked(ADCL, ADCL_LINSEL_LINPUT1, ADCL_LINSEL_MASK);
|
||||
wmcodec_set_masked(ADCR, ADCR_RINSEL_RINPUT1, ADCR_RINSEL_MASK);
|
||||
wmcodec_set_bits(PWRMGMT1, PWRMGMT1_AINL | PWRMGMT1_AINR);
|
||||
if (recording)
|
||||
{
|
||||
wmcodec_set_bits(PWRMGMT1, PWRMGMT1_ADCL | PWRMGMT1_ADCR);
|
||||
}
|
||||
else
|
||||
{
|
||||
wmcodec_set_reg(LINVOL, LINVOL_LIZC | LINVOL_LINVOL(0x27));
|
||||
wmcodec_set_reg(RINVOL, RINVOL_RIVU | RINVOL_RIZC |
|
||||
RINVOL_RINVOL(0x27));
|
||||
}
|
||||
|
||||
wmcodec_set_masked(LEFTMIX1, LEFTMIX1_LMIXSEL_ADCLIN |
|
||||
LEFTMIX1_LI2LOVOL(0x20),
|
||||
0x7 | LEFTMIX1_LI2LOVOL_MASK);
|
||||
wmcodec_set_bits(LEFTMIX1, LEFTMIX1_LI2LO);
|
||||
wmcodec_set_masked(RIGHTMIX1, RIGHTMIX1_RMIXSEL_ADCRIN, 0x7);
|
||||
wmcodec_set_masked(RIGHTMIX2, RIGHTMIX2_RI2ROVOL(0x20),
|
||||
RIGHTMIX2_RI2ROVOL_MASK);
|
||||
wmcodec_set_bits(RIGHTMIX2, RIGHTMIX2_RI2RO);
|
||||
break;
|
||||
|
||||
case AUDIO_SRC_MIC:
|
||||
wmcodec_set_masked(ADCR, ADCR_RINSEL_RINPUT2 | ADCR_RMICBOOST_13DB,
|
||||
ADCR_RINSEL_MASK | (0x3 << 4));
|
||||
wmcodec_set_bits(PWRMGMT1, PWRMGMT1_AINR | PWRMGMT1_ADCR);
|
||||
wmcodec_set_masked(ADDITIONAL1, ADDITIONAL1_DATSEL_RR,
|
||||
ADDITIONAL1_DATSEL_MASK);
|
||||
break;
|
||||
|
||||
default: /* playback */
|
||||
break;
|
||||
}
|
||||
|
||||
audiohw_mute(false);
|
||||
}
|
||||
#else /* !SAMSUNG_YPCP3 */
|
||||
void audiohw_set_recsrc(int source, bool recording)
|
||||
{
|
||||
/* INPUT1 - FM radio
|
||||
|
|
@ -674,6 +701,7 @@ void audiohw_set_recsrc(int source, bool recording)
|
|||
#endif
|
||||
} /* switch(source) */
|
||||
}
|
||||
#endif /* SAMSUNG_YPCP3 */
|
||||
|
||||
static int digital_gain2hw(int value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#define MODEL_NAME "Samsung YP-CP3"
|
||||
|
||||
/* define this if you have recording possibility */
|
||||
/* #define HAVE_RECORDING */
|
||||
#define HAVE_RECORDING
|
||||
|
||||
/* define the bitmask of hardware sample rates */
|
||||
#define HW_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11 \
|
||||
|
|
@ -115,7 +115,8 @@
|
|||
#define HAVE_RDS_CAP
|
||||
#define CONFIG_RDS (RDS_CFG_POLL | RDS_CFG_PROCESS)
|
||||
#define CONFIG_RDS_POLL_TICKS 4
|
||||
#define INPUT_SRC_CAPS SRC_CAP_FMRADIO
|
||||
/* inputs: the microphone (mono, on RINPUT2) and the tuner */
|
||||
#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO)
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define HAVE_BACKLIGHT
|
||||
|
|
|
|||
|
|
@ -183,6 +183,14 @@ AUDIOHW_SETTING(TREBLE_CUTOFF, "kHz", 0, 4, 4, 8, 4)
|
|||
#define ADDITIONAL1 0x17
|
||||
#define ADDITIONAL1_TOEN (1 << 0)
|
||||
#define ADDITIONAL1_DACINV (1 << 1)
|
||||
#if defined(HAVE_WM8750)
|
||||
/* which ADC feeds the left and right channels of the output data */
|
||||
#define ADDITIONAL1_DATSEL_LR (0 << 2)
|
||||
#define ADDITIONAL1_DATSEL_LL (1 << 2)
|
||||
#define ADDITIONAL1_DATSEL_RR (2 << 2)
|
||||
#define ADDITIONAL1_DATSEL_RL (3 << 2)
|
||||
#define ADDITIONAL1_DATSEL_MASK (3 << 2)
|
||||
#endif
|
||||
#define ADDITIONAL1_DMONOMIX_LLRR (0 << 4)
|
||||
#define ADDITIONAL1_DMONOMIX_ML0R (1 << 4)
|
||||
#define ADDITIONAL1_DMONOMIX_0LMR (2 << 4)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue