summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Conrad <dconrad@fastmail.com>2021-08-09 19:22:52 -0500
committerSolomon Peachy <pizza@shaftnet.org>2021-08-12 10:07:49 +0000
commit6de6e1459de28bef919b869ee757474c615cb787 (patch)
treeecf10a64809863d1cc3626a3b92dec856b937c4e
parent235e41578be60135c8ad682e05440a5b9142ce69 (diff)
downloadrockbox-6de6e1459de28bef919b869ee757474c615cb787.tar.gz
rockbox-6de6e1459de28bef919b869ee757474c615cb787.zip
Eros Q Hosted: Apply DC Bias to PCM Data
Similar to the native port, the hosted port benefits from adding a -1 dc bias to the PCM data. This prevents almost all clicking artifacts. Change-Id: Ic6378716774b6d88df23c476e2ef54d49f33dc72
-rw-r--r--firmware/export/erosqlinux_codec.h2
-rw-r--r--firmware/target/hosted/pcm-alsa.c9
2 files changed, 9 insertions, 2 deletions
diff --git a/firmware/export/erosqlinux_codec.h b/firmware/export/erosqlinux_codec.h
index b6ab58fa74..2ed1ae11cf 100644
--- a/firmware/export/erosqlinux_codec.h
+++ b/firmware/export/erosqlinux_codec.h
@@ -3,6 +3,8 @@
3 3
4#define AUDIOHW_CAPS (LINEOUT_CAP) 4#define AUDIOHW_CAPS (LINEOUT_CAP)
5 5
6#define PCM_DC_OFFSET_VALUE -1
7
6AUDIOHW_SETTING(VOLUME, "dB", 0, 2, -74, 0, -40) 8AUDIOHW_SETTING(VOLUME, "dB", 0, 2, -74, 0, -40)
7 9
8//#define AUDIOHW_NEEDS_INITIAL_UNMUTE 10//#define AUDIOHW_NEEDS_INITIAL_UNMUTE
diff --git a/firmware/target/hosted/pcm-alsa.c b/firmware/target/hosted/pcm-alsa.c
index 13ebbbcbeb..68002d8158 100644
--- a/firmware/target/hosted/pcm-alsa.c
+++ b/firmware/target/hosted/pcm-alsa.c
@@ -68,6 +68,11 @@
68#warning "MIX_FRAME_SAMPLES <1024 may cause dropouts!" 68#warning "MIX_FRAME_SAMPLES <1024 may cause dropouts!"
69#endif 69#endif
70 70
71/* PCM_DC_OFFSET_VALUE is a workaround for eros q hardware quirk */
72#if !defined(PCM_DC_OFFSET_VALUE)
73# define PCM_DC_OFFSET_VALUE 0
74#endif
75
71static const snd_pcm_access_t access_ = SND_PCM_ACCESS_RW_INTERLEAVED; /* access mode */ 76static const snd_pcm_access_t access_ = SND_PCM_ACCESS_RW_INTERLEAVED; /* access mode */
72#if defined(HAVE_ALSA_32BIT) 77#if defined(HAVE_ALSA_32BIT)
73static const snd_pcm_format_t format = SND_PCM_FORMAT_S32_LE; /* sample format */ 78static const snd_pcm_format_t format = SND_PCM_FORMAT_S32_LE; /* sample format */
@@ -359,8 +364,8 @@ static bool copy_frames(bool first)
359 sample_t *sample_ptr = &frames[2*(period_size-frames_left)]; 364 sample_t *sample_ptr = &frames[2*(period_size-frames_left)];
360 for (int i = 0; i < nframes; i++) 365 for (int i = 0; i < nframes; i++)
361 { 366 {
362 *sample_ptr++ = *pcm_ptr++ * dig_vol_mult_l; 367 *sample_ptr++ = (*pcm_ptr++ * dig_vol_mult_l) + PCM_DC_OFFSET_VALUE;
363 *sample_ptr++ = *pcm_ptr++ * dig_vol_mult_r; 368 *sample_ptr++ = (*pcm_ptr++ * dig_vol_mult_r) + PCM_DC_OFFSET_VALUE;
364 } 369 }
365 } 370 }
366 else 371 else