ErosQ New Revision HW volume

Add HW volume control via ES9018K2M, and reorganize
eros_qn_codec.c/.h, audiohw-erosqnative.c.

This automatically detects the presence of the new DAC and
uses its hardware volume scaling. If not present, use same
SWVOL we have been using so far.

Add debug menu readout of SWVOL/I2C result.

Break out es9018k2m stuff into its own file so that
maybe it can be useful to other ports.

Note that we may need to get smarter about detecting the DAC
type if/when another model emerges.

Change-Id: I586a1cf7f150dd6b4e221157859825952840af56
This commit is contained in:
Dana Conrad 2023-11-21 19:28:51 -06:00 committed by Aidan MacDonald
parent 161c861153
commit a3fe07ff12
12 changed files with 308 additions and 52 deletions

View file

@ -26,56 +26,30 @@
#include "audiohw.h"
#include "settings.h"
#include "pcm_sw_volume.h"
#include "gpio-x1000.h"
static long int vol_l_hw = 0;
static long int vol_r_hw = 0;
static long int vol_l_hw = PCM5102A_VOLUME_MIN;
static long int vol_r_hw = PCM5102A_VOLUME_MIN;
int es9018k2m_present_flag = 0;
/* internal: Switch the output sink. 0 - headphones, 1 - line out */
void audiohw_switch_output(int select);
void dac_set_outputs(void)
void eros_qn_set_outputs(void)
{
audiohw_set_volume(vol_l_hw, vol_r_hw);
}
/* this makes less sense here than it does in the audiohw-*.c file,
* but we need access to settings.h */
void audiohw_set_volume(int vol_l, int vol_r)
void eros_qn_set_last_vol(long int vol_l, long int vol_r)
{
int l, r;
vol_l_hw = vol_l;
vol_r_hw = vol_r;
l = vol_l;
r = vol_r;
#if (defined(HAVE_HEADPHONE_DETECTION) && defined(HAVE_LINEOUT_DETECTION))
/* make sure headphones aren't present - don't want to
* blow out our eardrums cranking it to full */
if (lineout_inserted() && !headphones_inserted())
{
audiohw_switch_output(1);
l = r = global_settings.volume_limit * 10;
}
else
{
audiohw_switch_output(0);
l = vol_l;
r = vol_r;
}
#endif
l = l <= PCM5102A_VOLUME_MIN ? PCM_MUTE_LEVEL : (l / 20);
r = r <= PCM5102A_VOLUME_MIN ? PCM_MUTE_LEVEL : (r / 20);
pcm_set_master_volume(l, r);
}
void audiohw_switch_output(int select)
int eros_qn_get_volume_limit(void)
{
return (global_settings.volume_limit * 10);
}
void eros_qn_switch_output(int select)
{
if (select == 0)
{
@ -85,4 +59,4 @@ void audiohw_switch_output(int select)
{
gpio_set_level(GPIO_STEREOSW_SEL, 1);
}
}
}