From 39ffde2d72f34f1ea98d5e9bc25913728ad98037 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 19 Oct 2020 02:21:05 +0200 Subject: [PATCH] Some ES1371 fixes. --- src/sound/snd_audiopci.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/sound/snd_audiopci.c b/src/sound/snd_audiopci.c index e070e1dc5..7cec733a8 100644 --- a/src/sound/snd_audiopci.c +++ b/src/sound/snd_audiopci.c @@ -79,6 +79,7 @@ typedef struct { int64_t dac_latch, dac_time; int master_vol_l, master_vol_r; + int cd_vol_l, cd_vol_r; int card; @@ -592,7 +593,7 @@ static void es1371_outl(uint16_t port, uint32_t val, void *p) if (!(val & CODEC_READ)) { // audiopci_log("Write codec %02x %04x\n", (val >> 16) & 0x7f, val & 0xffff); - if ((((val >> 16) & 0x7f) != 0x7c) || (((val >> 16) & 0x7f) != 0x7e)) + if ((((val >> 16) & 0x7f) != 0x7c) && (((val >> 16) & 0x7f) != 0x7e)) es1371->codec_regs[(val >> 16) & 0x7f] = val & 0xffff; switch ((val >> 16) & 0x7f) { @@ -611,6 +612,15 @@ static void es1371_outl(uint16_t port, uint32_t val, void *p) es1371->master_vol_r = codec_attn[0x1f - (val & 0x1f)]; } break; + case 0x12: /*CD volume*/ + if (val & 0x8000) + es1371->cd_vol_l = es1371->cd_vol_r = 0; + else + { + es1371->cd_vol_l = codec_attn[0x1f - ((val >> 8) & 0x1f)]; + es1371->cd_vol_r = codec_attn[0x1f - (val & 0x1f)]; + } + break; } } break; @@ -1268,15 +1278,10 @@ static void es1371_filter_cd_audio(int channel, float *buffer, void *p) { es1371_t *es1371 = (es1371_t *)p; int32_t c; - int32_t volume, val = (int32_t) (uint32_t) es1371->codec_regs[0x12]; + int cd = channel ? es1371->cd_vol_r : es1371->cd_vol_l; int master = channel ? es1371->master_vol_r : es1371->master_vol_l; - if (val & 0x8000) - volume = 0; - else - volume = channel ? codec_attn[0x1f - (val & 0x1f)] : codec_attn[0x1f - ((val >> 8) & 0x1f)]; - - c = (((int32_t) buffer) * volume) >> 15; + c = (((int32_t) *buffer) * cd) >> 15; c = (c * master) >> 15; *buffer = (float) c;