From nobody Fri May 17 08:25:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694933973539229.88384727153698; Sat, 16 Sep 2023 23:59:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhljZ-0006qB-UU; Sun, 17 Sep 2023 02:58:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljX-0006ph-Uu; Sun, 17 Sep 2023 02:58:19 -0400 Received: from mailout05.t-online.de ([194.25.134.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljW-0004y4-9i; Sun, 17 Sep 2023 02:58:19 -0400 Received: from fwd86.aul.t-online.de (fwd86.aul.t-online.de [10.223.144.112]) by mailout05.t-online.de (Postfix) with SMTP id 7A5204338; Sun, 17 Sep 2023 08:58:14 +0200 (CEST) Received: from linpower.localnet ([79.208.31.89]) by fwd86.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qhljR-2zr8Sn0; Sun, 17 Sep 2023 08:58:14 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 9512020027A; Sun, 17 Sep 2023 08:58:13 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , qemu-devel@nongnu.org, qemu-stable@nongnu.org Subject: [PATCH 1/8] hw/audio/es1370: reset current sample counter Date: Sun, 17 Sep 2023 08:58:06 +0200 Message-Id: <20230917065813.6692-1-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1694933894-0592EEBC-39B5DE82/0/0 CLEAN NORMAL X-TOI-MSGID: 906388a9-a312-4720-b4b8-98d2ef9832a8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.82; envelope-from=volker.ruemelin@t-online.de; helo=mailout05.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1694933974448100001 Reset the current sample counter when writing the Channel Sample Count Register. The Linux ens1370 driver and the AROS sb128 driver expect the current sample counter counts down from sample count to 0 after a write to the Channel Sample Count Register. Currently the current sample counter starts from 0 after a reset or the last count when the counter was stopped. The current sample counter is used to raise an interrupt whenever a complete buffer was transferred. When the counter starts with a value lower than the reload value, the interrupt triggeres before the buffer was completly transferred. This may lead to corrupted audio streams. Tested-by: Rene Engel Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: BALATON Zoltan --- hw/audio/es1370.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 4f738a0ad8..9a8e29c39c 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -502,7 +502,7 @@ static void es1370_write(void *opaque, hwaddr addr, uin= t64_t val, unsigned size) case ES1370_REG_DAC2_SCOUNT: case ES1370_REG_ADC_SCOUNT: d +=3D (addr - ES1370_REG_DAC1_SCOUNT) >> 2; - d->scount =3D (val & 0xffff) | (d->scount & ~0xffff); + d->scount =3D (val & 0xffff) << 16 | (val & 0xffff); ldebug ("chan %td CURR_SAMP_CT %d, SAMP_CT %d\n", d - &s->chan[0], val >> 16, (val & 0xffff)); break; --=20 2.35.3 From nobody Fri May 17 08:25:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694933992708106.35938923553101; Sat, 16 Sep 2023 23:59:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhlje-0006rD-GU; Sun, 17 Sep 2023 02:58:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljd-0006qn-5m for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:25 -0400 Received: from mailout05.t-online.de ([194.25.134.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljb-00051D-Dc for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:24 -0400 Received: from fwd82.aul.t-online.de (fwd82.aul.t-online.de [10.223.144.108]) by mailout05.t-online.de (Postfix) with SMTP id CB211433B; Sun, 17 Sep 2023 08:58:21 +0200 (CEST) Received: from linpower.localnet ([79.208.31.89]) by fwd82.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qhljU-1K09FR0; Sun, 17 Sep 2023 08:58:16 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 9757020027E; Sun, 17 Sep 2023 08:58:13 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , qemu-devel@nongnu.org Subject: [PATCH 2/8] hw/audio/es1370: replace bit-rotted code with tracepoints Date: Sun, 17 Sep 2023 08:58:07 +0200 Message-Id: <20230917065813.6692-2-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1694933896-39D2CD37-B8CEA4AB/0/0 CLEAN NORMAL X-TOI-MSGID: 70c2fda6-fe8a-4607-9076-a3b4cbf18308 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.82; envelope-from=volker.ruemelin@t-online.de; helo=mailout05.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1694933993614100005 It seems that nobody has enabled the debug code of the ES1370 device for a long time. Since then, the code has bit-rotted. Replace the bit-rotten code with tracepoints. Tested-by: Rene Engel Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: BALATON Zoltan --- hw/audio/es1370.c | 55 ++++++++++++++----------------------------- hw/audio/trace-events | 10 ++++++++ 2 files changed, 28 insertions(+), 37 deletions(-) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 9a8e29c39c..0b9fdc8f41 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -34,6 +34,7 @@ #include "qemu/module.h" #include "sysemu/dma.h" #include "qom/object.h" +#include "trace.h" =20 /* Missing stuff: SCTRL_P[12](END|ST)INC @@ -166,8 +167,6 @@ static void es1370_adc_callback (void *opaque, int avai= l); =20 #ifdef DEBUG_ES1370 =20 -#define ldebug(...) AUD_log ("es1370", __VA_ARGS__) - static void print_ctl (uint32_t val) { char buf[1024]; @@ -239,7 +238,6 @@ static void print_sctl (uint32_t val) ); } #else -#define ldebug(...) #define print_ctl(...) #define print_sctl(...) #endif @@ -411,12 +409,9 @@ static void es1370_update_voices (ES1370State *s, uint= 32_t ctl, uint32_t sctl) =20 if ((old_fmt !=3D new_fmt) || (old_freq !=3D new_freq)) { d->shift =3D (new_fmt & 1) + (new_fmt >> 1); - ldebug ("channel %zu, freq =3D %d, nchannels %d, fmt %d, shift= %d\n", - i, - new_freq, - 1 << (new_fmt & 1), - (new_fmt & 2) ? AUDIO_FORMAT_S16 : AUDIO_FORMAT_U8, - d->shift); + trace_es1370_stream_format(i, new_freq, + new_fmt & 2 ? "s16" : "u8", new_fmt & 1 ? "stereo" : "mono= ", + d->shift); if (new_freq) { struct audsettings as; =20 @@ -503,8 +498,8 @@ static void es1370_write(void *opaque, hwaddr addr, uin= t64_t val, unsigned size) case ES1370_REG_ADC_SCOUNT: d +=3D (addr - ES1370_REG_DAC1_SCOUNT) >> 2; d->scount =3D (val & 0xffff) << 16 | (val & 0xffff); - ldebug ("chan %td CURR_SAMP_CT %d, SAMP_CT %d\n", - d - &s->chan[0], val >> 16, (val & 0xffff)); + trace_es1370_sample_count_wr(d - &s->chan[0], + d->scount >> 16, d->scount & 0xffff); break; =20 case ES1370_REG_ADC_FRAMEADR: @@ -515,7 +510,7 @@ static void es1370_write(void *opaque, hwaddr addr, uin= t64_t val, unsigned size) d +=3D (addr - ES1370_REG_DAC1_FRAMEADR) >> 3; frameadr: d->frame_addr =3D val; - ldebug ("chan %td frame address %#x\n", d - &s->chan[0], val); + trace_es1370_frame_address_wr(d - &s->chan[0], d->frame_addr); break; =20 case ES1370_REG_PHANTOM_FRAMECNT: @@ -534,8 +529,8 @@ static void es1370_write(void *opaque, hwaddr addr, uin= t64_t val, unsigned size) framecnt: d->frame_cnt =3D val; d->leftover =3D 0; - ldebug ("chan %td frame count %d, buffer size %d\n", - d - &s->chan[0], val >> 16, val & 0xffff); + trace_es1370_frame_count_wr(d - &s->chan[0], + d->frame_cnt >> 16, d->frame_cnt & 0xffff); break; =20 default: @@ -573,17 +568,9 @@ static uint64_t es1370_read(void *opaque, hwaddr addr,= unsigned size) case ES1370_REG_DAC2_SCOUNT: case ES1370_REG_ADC_SCOUNT: d +=3D (addr - ES1370_REG_DAC1_SCOUNT) >> 2; + trace_es1370_sample_count_rd(d - &s->chan[0], + d->scount >> 16, d->scount & 0xffff); val =3D d->scount; -#ifdef DEBUG_ES1370 - { - uint32_t curr_count =3D d->scount >> 16; - uint32_t count =3D d->scount & 0xffff; - - curr_count <<=3D d->shift; - count <<=3D d->shift; - dolog ("read scount curr %d, total %d\n", curr_count, count); - } -#endif break; =20 case ES1370_REG_ADC_FRAMECNT: @@ -593,17 +580,9 @@ static uint64_t es1370_read(void *opaque, hwaddr addr,= unsigned size) case ES1370_REG_DAC2_FRAMECNT: d +=3D (addr - ES1370_REG_DAC1_FRAMECNT) >> 3; framecnt: + trace_es1370_frame_count_rd(d - &s->chan[0], + d->frame_cnt >> 16, d->frame_cnt & 0xffff); val =3D d->frame_cnt; -#ifdef DEBUG_ES1370 - { - uint32_t size =3D ((d->frame_cnt & 0xffff) + 1) << 2; - uint32_t curr =3D ((d->frame_cnt >> 16) + 1) << 2; - if (curr > size) { - dolog ("read framecnt curr %d, size %d %d\n", curr, size, - curr > size); - } - } -#endif break; =20 case ES1370_REG_ADC_FRAMEADR: @@ -613,6 +592,7 @@ static uint64_t es1370_read(void *opaque, hwaddr addr, = unsigned size) case ES1370_REG_DAC2_FRAMEADR: d +=3D (addr - ES1370_REG_DAC1_FRAMEADR) >> 3; frameadr: + trace_es1370_frame_address_rd(d - &s->chan[0], d->frame_addr); val =3D d->frame_addr; break; =20 @@ -689,9 +669,6 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, if (csc_bytes =3D=3D transferred) { *irq =3D 1; d->scount =3D sc | (sc << 16); - ldebug ("sc =3D %d, rate =3D %f\n", - (sc + 1) << d->shift, - (sc + 1) / (double) 44100); } else { *irq =3D 0; @@ -713,6 +690,10 @@ static void es1370_transfer_audio (ES1370State *s, str= uct chan *d, int loop_sel, } =20 d->leftover =3D (transferred + d->leftover) & 3; + trace_es1370_transfer_audio(index, + d->frame_cnt >> 16, d->frame_cnt & 0xffff, + d->scount >> 16, d->scount & 0xffff, + d->leftover, *irq); } =20 static void es1370_run_channel (ES1370State *s, size_t chan, int free_or_a= vail) diff --git a/hw/audio/trace-events b/hw/audio/trace-events index 4dec48a4fd..00f9e45158 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -6,6 +6,16 @@ cs4231_mem_readl_reg(uint32_t reg, uint32_t ret) "read reg= %d: 0x%08x" cs4231_mem_writel_reg(uint32_t reg, uint32_t old, uint32_t val) "write reg= %d: 0x%08x -> 0x%08x" cs4231_mem_writel_dreg(uint32_t reg, uint32_t old, uint32_t val) "write dr= eg %d: 0x%02x -> 0x%02x" =20 +# es1370.c +es1370_frame_address_rd(int ch, uint32_t addr) "ch=3D%d addr=3D0x%08x" +es1370_frame_address_wr(int ch, uint32_t addr) "ch=3D%d addr=3D0x%08x" +es1370_frame_count_rd(int ch, uint32_t curr, uint32_t size) "ch=3D%d CURR_= CT=3D%u BUF_SIZE=3D%u" +es1370_frame_count_wr(int ch, uint32_t curr, uint32_t size) "ch=3D%d CURR_= CT=3D%u BUF_SIZE=3D%u" +es1370_sample_count_rd(int ch, uint32_t curr, uint32_t num) "ch=3D%d CURR_= SAMP_CT=3D%u SAMP_CT=3D%u" +es1370_sample_count_wr(int ch, uint32_t curr, uint32_t num) "ch=3D%d CURR_= SAMP_CT=3D%u SAMP_CT=3D%u" +es1370_stream_format(int ch, uint32_t freq, const char *fmt, const char *m= ode, uint32_t shift) "ch=3D%d fmt=3D%u:%s:%s shift=3D%u" +es1370_transfer_audio(int ch, uint32_t f_curr, uint32_t f_size, uint32_t s= _curr, uint32_t s_num, uint32_t leftover, int irq) "ch=3D%d CURR_CT=3D%u BU= F_SIZE=3D%u CURR_SAMP_CT=3D%u SAMP_CT=3D%u leftover=3D%u irq=3D%d" + # hda-codec.c hda_audio_running(const char *stream, int nr, bool running) "st %s, nr %d,= run %d" hda_audio_format(const char *stream, int chan, const char *fmt, int freq) = "st %s, %d x %s @ %d Hz" --=20 2.35.3 From nobody Fri May 17 08:25:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694933992008515.0318709486423; Sat, 16 Sep 2023 23:59:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhljj-0006tu-9Q; Sun, 17 Sep 2023 02:58:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljf-0006t4-Gv for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:27 -0400 Received: from mailout01.t-online.de ([194.25.134.80]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljc-00051J-CL for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:26 -0400 Received: from fwd82.aul.t-online.de (fwd82.aul.t-online.de [10.223.144.108]) by mailout01.t-online.de (Postfix) with SMTP id E1F39173A0; Sun, 17 Sep 2023 08:58:21 +0200 (CEST) Received: from linpower.localnet ([79.208.31.89]) by fwd82.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qhljW-1XNDhh0; Sun, 17 Sep 2023 08:58:18 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 9A3E02002DE; Sun, 17 Sep 2023 08:58:13 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , qemu-devel@nongnu.org Subject: [PATCH 3/8] hw/audio/es1370: remove unused dolog macro Date: Sun, 17 Sep 2023 08:58:08 +0200 Message-Id: <20230917065813.6692-3-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1694933898-39D2CD37-D2638B6E/0/0 CLEAN NORMAL X-TOI-MSGID: a893b9f3-15d1-4dad-9947-88f108abcb73 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.80; envelope-from=volker.ruemelin@t-online.de; helo=mailout01.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1694933992746100001 The dolog macro is unused. Remove the macro and use the now unused ES1370_VERBOSE macro to replace its inverse ES1370_SILENT macro. Tested-by: Rene Engel Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: BALATON Zoltan --- hw/audio/es1370.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 0b9fdc8f41..f66feb5bb0 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -24,7 +24,6 @@ =20 /* #define DEBUG_ES1370 */ /* #define VERBOSE_ES1370 */ -#define SILENT_ES1370 =20 #include "qemu/osdep.h" #include "hw/audio/soundhw.h" @@ -243,12 +242,6 @@ static void print_sctl (uint32_t val) #endif =20 #ifdef VERBOSE_ES1370 -#define dolog(...) AUD_log ("es1370", __VA_ARGS__) -#else -#define dolog(...) -#endif - -#ifndef SILENT_ES1370 #define lwarn(...) AUD_log ("es1370: warning", __VA_ARGS__) #else #define lwarn(...) --=20 2.35.3 From nobody Fri May 17 08:25:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694933989557446.51955124076017; Sat, 16 Sep 2023 23:59:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhljj-0006uN-R0; Sun, 17 Sep 2023 02:58:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljf-0006t3-Fy for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:27 -0400 Received: from mailout01.t-online.de ([194.25.134.80]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljd-00051C-2Y for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:26 -0400 Received: from fwd76.aul.t-online.de (fwd76.aul.t-online.de [10.223.144.102]) by mailout01.t-online.de (Postfix) with SMTP id D395F35709; Sun, 17 Sep 2023 08:58:21 +0200 (CEST) Received: from linpower.localnet ([79.208.31.89]) by fwd76.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qhljZ-3qw7mr0; Sun, 17 Sep 2023 08:58:21 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 9D61B200205; Sun, 17 Sep 2023 08:58:13 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , qemu-devel@nongnu.org Subject: [PATCH 4/8] hw/audio/es1370: remove #ifdef ES1370_DEBUG to avoid bit rot Date: Sun, 17 Sep 2023 08:58:09 +0200 Message-Id: <20230917065813.6692-4-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1694933901-27FFE5E3-3EE6DCB5/0/0 CLEAN NORMAL X-TOI-MSGID: e290478b-d9c4-4b85-bb40-567dc2f93ca7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.80; envelope-from=volker.ruemelin@t-online.de; helo=mailout01.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1694933990415100001 Replace the #ifdef ES1370_DEBUG code with code that the compiler can optimize away to avoid bit rot. While at it, replace strcat() with pstrcat(). Tested-by: Rene Engel Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: BALATON Zoltan --- hw/audio/es1370.c | 135 +++++++++++++++++++++++----------------------- 1 file changed, 66 insertions(+), 69 deletions(-) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index f66feb5bb0..839689bcb3 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ =20 -/* #define DEBUG_ES1370 */ +#define DEBUG_ES1370 0 /* #define VERBOSE_ES1370 */ =20 #include "qemu/osdep.h" @@ -30,6 +30,7 @@ #include "audio/audio.h" #include "hw/pci/pci_device.h" #include "migration/vmstate.h" +#include "qemu/cutils.h" #include "qemu/module.h" #include "sysemu/dma.h" #include "qom/object.h" @@ -164,82 +165,78 @@ static void es1370_dac1_callback (void *opaque, int f= ree); static void es1370_dac2_callback (void *opaque, int free); static void es1370_adc_callback (void *opaque, int avail); =20 -#ifdef DEBUG_ES1370 - -static void print_ctl (uint32_t val) +static void print_ctl(uint32_t val) { - char buf[1024]; - - buf[0] =3D '\0'; -#define a(n) if (val & CTRL_##n) strcat (buf, " "#n) - a (ADC_STOP); - a (XCTL1); - a (OPEN); - a (MSFMTSEL); - a (M_SBB); - a (DAC_SYNC); - a (CCB_INTRM); - a (M_CB); - a (XCTL0); - a (BREQ); - a (DAC1_EN); - a (DAC2_EN); - a (ADC_EN); - a (UART_EN); - a (JYSTK_EN); - a (CDC_EN); - a (SERR_DIS); + if (DEBUG_ES1370) { + char buf[1024]; + + buf[0] =3D '\0'; +#define a(n) if (val & CTRL_##n) pstrcat(buf, sizeof(buf), " "#n) + a(ADC_STOP); + a(XCTL1); + a(OPEN); + a(MSFMTSEL); + a(M_SBB); + a(DAC_SYNC); + a(CCB_INTRM); + a(M_CB); + a(XCTL0); + a(BREQ); + a(DAC1_EN); + a(DAC2_EN); + a(ADC_EN); + a(UART_EN); + a(JYSTK_EN); + a(CDC_EN); + a(SERR_DIS); #undef a - AUD_log ("es1370", "ctl - PCLKDIV %d(DAC2 freq %d), freq %d,%s\n", - (val & CTRL_PCLKDIV) >> CTRL_SH_PCLKDIV, - DAC2_DIVTOSR ((val & CTRL_PCLKDIV) >> CTRL_SH_PCLKDIV), - dac1_samplerate[(val & CTRL_WTSRSEL) >> CTRL_SH_WTSRSEL], - buf); + AUD_log("es1370", "ctl - PCLKDIV %d(DAC2 freq %d), freq %d,%s\n", + (val & CTRL_PCLKDIV) >> CTRL_SH_PCLKDIV, + DAC2_DIVTOSR((val & CTRL_PCLKDIV) >> CTRL_SH_PCLKDIV), + dac1_samplerate[(val & CTRL_WTSRSEL) >> CTRL_SH_WTSRSEL], + buf); + } } =20 -static void print_sctl (uint32_t val) +static void print_sctl(uint32_t val) { - static const char *fmt_names[] =3D {"8M", "8S", "16M", "16S"}; - char buf[1024]; - - buf[0] =3D '\0'; - -#define a(n) if (val & SCTRL_##n) strcat (buf, " "#n) -#define b(n) if (!(val & SCTRL_##n)) strcat (buf, " "#n) - b (R1LOOPSEL); - b (P2LOOPSEL); - b (P1LOOPSEL); - a (P2PAUSE); - a (P1PAUSE); - a (R1INTEN); - a (P2INTEN); - a (P1INTEN); - a (P1SCTRLD); - a (P2DACSEN); - if (buf[0]) { - strcat (buf, "\n "); - } - else { - buf[0] =3D ' '; - buf[1] =3D '\0'; - } + if (DEBUG_ES1370) { + static const char *fmt_names[] =3D {"8M", "8S", "16M", "16S"}; + char buf[1024]; + + buf[0] =3D '\0'; + +#define a(n) if (val & SCTRL_##n) pstrcat(buf, sizeof(buf), " "#n) +#define b(n) if (!(val & SCTRL_##n)) pstrcat(buf, sizeof(buf), " "#n) + b(R1LOOPSEL); + b(P2LOOPSEL); + b(P1LOOPSEL); + a(P2PAUSE); + a(P1PAUSE); + a(R1INTEN); + a(P2INTEN); + a(P1INTEN); + a(P1SCTRLD); + a(P2DACSEN); + if (buf[0]) { + pstrcat(buf, sizeof(buf), "\n "); + } else { + buf[0] =3D ' '; + buf[1] =3D '\0'; + } #undef b #undef a - AUD_log ("es1370", - "%s" - "p2_end_inc %d, p2_st_inc %d, r1_fmt %s, p2_fmt %s, p1_fmt %s= \n", - buf, - (val & SCTRL_P2ENDINC) >> SCTRL_SH_P2ENDINC, - (val & SCTRL_P2STINC) >> SCTRL_SH_P2STINC, - fmt_names [(val >> SCTRL_SH_R1FMT) & 3], - fmt_names [(val >> SCTRL_SH_P2FMT) & 3], - fmt_names [(val >> SCTRL_SH_P1FMT) & 3] - ); + AUD_log("es1370", + "%s p2_end_inc %d, p2_st_inc %d," + " r1_fmt %s, p2_fmt %s, p1_fmt %s\n", + buf, + (val & SCTRL_P2ENDINC) >> SCTRL_SH_P2ENDINC, + (val & SCTRL_P2STINC) >> SCTRL_SH_P2STINC, + fmt_names[(val >> SCTRL_SH_R1FMT) & 3], + fmt_names[(val >> SCTRL_SH_P2FMT) & 3], + fmt_names[(val >> SCTRL_SH_P1FMT) & 3]); + } } -#else -#define print_ctl(...) -#define print_sctl(...) -#endif =20 #ifdef VERBOSE_ES1370 #define lwarn(...) AUD_log ("es1370: warning", __VA_ARGS__) --=20 2.35.3 From nobody Fri May 17 08:25:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694933947221879.3962978161873; Sat, 16 Sep 2023 23:59:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhljh-0006tZ-JZ; Sun, 17 Sep 2023 02:58:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljf-0006tG-P9 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:27 -0400 Received: from mailout05.t-online.de ([194.25.134.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljd-00051i-9c for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:27 -0400 Received: from fwd86.aul.t-online.de (fwd86.aul.t-online.de [10.223.144.112]) by mailout05.t-online.de (Postfix) with SMTP id D3D7824592; Sun, 17 Sep 2023 08:58:23 +0200 (CEST) Received: from linpower.localnet ([79.208.31.89]) by fwd86.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qhljb-3yMzkv0; Sun, 17 Sep 2023 08:58:23 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id A05FB200206; Sun, 17 Sep 2023 08:58:13 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , qemu-devel@nongnu.org Subject: [PATCH 5/8] hw/audio/es1370: remove #ifdef ES1370_VERBOSE to avoid bit rot Date: Sun, 17 Sep 2023 08:58:10 +0200 Message-Id: <20230917065813.6692-5-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1694933903-0592EEBC-B24C16C2/0/0 CLEAN NORMAL X-TOI-MSGID: 9609e484-8de7-44a1-8e60-a73e49094292 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.82; envelope-from=volker.ruemelin@t-online.de; helo=mailout05.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1694933948138100001 Replace the #ifdef ES1370_VERBOSE code with code that the compiler can optimize away to avoid bit rot and fix the already rotten code. Tested-by: Rene Engel Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: BALATON Zoltan --- hw/audio/es1370.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 839689bcb3..e1ca6a4cd5 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -23,7 +23,7 @@ */ =20 #define DEBUG_ES1370 0 -/* #define VERBOSE_ES1370 */ +#define VERBOSE_ES1370 0 =20 #include "qemu/osdep.h" #include "hw/audio/soundhw.h" @@ -238,11 +238,12 @@ static void print_sctl(uint32_t val) } } =20 -#ifdef VERBOSE_ES1370 -#define lwarn(...) AUD_log ("es1370: warning", __VA_ARGS__) -#else -#define lwarn(...) -#endif +#define lwarn(...) \ +do { \ + if (VERBOSE_ES1370) { \ + AUD_log("es1370: warning", __VA_ARGS__); \ + } \ +} while (0) =20 #define TYPE_ES1370 "ES1370" OBJECT_DECLARE_SIMPLE_TYPE(ES1370State, ES1370) @@ -504,10 +505,10 @@ static void es1370_write(void *opaque, hwaddr addr, u= int64_t val, unsigned size) break; =20 case ES1370_REG_PHANTOM_FRAMECNT: - lwarn ("writing to phantom frame count %#x\n", val); + lwarn("writing to phantom frame count 0x%" PRIx64 "\n", val); break; case ES1370_REG_PHANTOM_FRAMEADR: - lwarn ("writing to phantom frame address %#x\n", val); + lwarn("writing to phantom frame address 0x%" PRIx64 "\n", val); break; =20 case ES1370_REG_ADC_FRAMECNT: @@ -524,7 +525,7 @@ static void es1370_write(void *opaque, hwaddr addr, uin= t64_t val, unsigned size) break; =20 default: - lwarn ("writel %#x <- %#x\n", addr, val); + lwarn("writel 0x%" PRIx64 " <- 0x%" PRIx64 "\n", addr, val); break; } } @@ -588,16 +589,16 @@ static uint64_t es1370_read(void *opaque, hwaddr addr= , unsigned size) =20 case ES1370_REG_PHANTOM_FRAMECNT: val =3D ~0U; - lwarn ("reading from phantom frame count\n"); + lwarn("reading from phantom frame count\n"); break; case ES1370_REG_PHANTOM_FRAMEADR: val =3D ~0U; - lwarn ("reading from phantom frame address\n"); + lwarn("reading from phantom frame address\n"); break; =20 default: val =3D ~0U; - lwarn ("readl %#x -> %#x\n", addr, val); + lwarn("readl 0x%" PRIx64 " -> 0x%x\n", addr, val); break; } return val; --=20 2.35.3 From nobody Fri May 17 08:25:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16949339808171002.1423252617697; Sat, 16 Sep 2023 23:59:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhljl-0006uw-E1; Sun, 17 Sep 2023 02:58:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljj-0006uF-DX for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:31 -0400 Received: from mailout05.t-online.de ([194.25.134.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljg-00052Q-UY for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:31 -0400 Received: from fwd86.aul.t-online.de (fwd86.aul.t-online.de [10.223.144.112]) by mailout05.t-online.de (Postfix) with SMTP id EFC9C143F8; Sun, 17 Sep 2023 08:58:26 +0200 (CEST) Received: from linpower.localnet ([79.208.31.89]) by fwd86.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qhljd-4E4Qt70; Sun, 17 Sep 2023 08:58:26 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id A32B7200207; Sun, 17 Sep 2023 08:58:13 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , qemu-devel@nongnu.org Subject: [PATCH 6/8] hw/audio/es1370: block structure coding style fixes Date: Sun, 17 Sep 2023 08:58:11 +0200 Message-Id: <20230917065813.6692-6-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1694933906-F77E4EBC-299B1698/0/0 CLEAN NORMAL X-TOI-MSGID: bb812899-75bc-4e23-afbf-8b72bd9506bd Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.82; envelope-from=volker.ruemelin@t-online.de; helo=mailout05.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1694933981968100001 Change the block structure according to the QEMU Coding Style documentation. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: BALATON Zoltan --- hw/audio/es1370.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index e1ca6a4cd5..86a869d4da 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -309,8 +309,7 @@ static void es1370_update_status (ES1370State *s, uint3= 2_t new_status) =20 if (level) { s->status =3D new_status | STAT_INTR; - } - else { + } else { s->status =3D new_status & ~STAT_INTR; } pci_set_irq(&s->dev, !!level); @@ -333,8 +332,7 @@ static void es1370_reset (ES1370State *s) if (i =3D=3D ADC_CHANNEL) { AUD_close_in (&s->card, s->adc_voice); s->adc_voice =3D NULL; - } - else { + } else { AUD_close_out (&s->card, s->dac_voice[i]); s->dac_voice[i] =3D NULL; } @@ -421,8 +419,7 @@ static void es1370_update_voices (ES1370State *s, uint3= 2_t ctl, uint32_t sctl) es1370_adc_callback, &as ); - } - else { + } else { s->dac_voice[i] =3D AUD_open_out ( &s->card, @@ -442,8 +439,7 @@ static void es1370_update_voices (ES1370State *s, uint3= 2_t ctl, uint32_t sctl) =20 if (i =3D=3D ADC_CHANNEL) { AUD_set_active_in (s->adc_voice, on); - } - else { + } else { AUD_set_active_out (s->dac_voice[i], on); } } @@ -456,8 +452,9 @@ static void es1370_update_voices (ES1370State *s, uint3= 2_t ctl, uint32_t sctl) static inline uint32_t es1370_fixup (ES1370State *s, uint32_t addr) { addr &=3D 0xff; - if (addr >=3D 0x30 && addr <=3D 0x3f) + if (addr >=3D 0x30 && addr <=3D 0x3f) { addr |=3D s->mempage << 8; + } return addr; } =20 @@ -630,8 +627,9 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, =20 to_copy =3D MIN ((size_t) temp, sizeof (tmpbuf)); acquired =3D AUD_read (s->adc_voice, tmpbuf, to_copy); - if (!acquired) + if (!acquired) { break; + } =20 pci_dma_write (&s->dev, addr, tmpbuf, acquired); =20 @@ -639,8 +637,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, addr +=3D acquired; transferred +=3D acquired; } - } - else { + } else { SWVoiceOut *voice =3D s->dac_voice[index]; =20 while (temp > 0) { @@ -649,8 +646,9 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, to_copy =3D MIN ((size_t) temp, sizeof (tmpbuf)); pci_dma_read (&s->dev, addr, tmpbuf, to_copy); copied =3D AUD_write (voice, tmpbuf, to_copy); - if (!copied) + if (!copied) { break; + } temp -=3D copied; addr +=3D copied; transferred +=3D copied; @@ -660,8 +658,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, if (csc_bytes =3D=3D transferred) { *irq =3D 1; d->scount =3D sc | (sc << 16); - } - else { + } else { *irq =3D 0; d->scount =3D sc | (((csc_bytes - transferred - 1) >> d->shift) <<= 16); } @@ -672,12 +669,12 @@ static void es1370_transfer_audio (ES1370State *s, st= ruct chan *d, int loop_sel, /* Bah, how stupid is that having a 0 represent true value? i just spent few hours on this shit */ AUD_log ("es1370: warning", "non looping mode\n"); - } - else { + } else { d->frame_cnt =3D size; =20 - if ((uint32_t) cnt <=3D d->frame_cnt) + if ((uint32_t) cnt <=3D d->frame_cnt) { d->frame_cnt |=3D cnt << 16; + } } =20 d->leftover =3D (transferred + d->leftover) & 3; @@ -778,8 +775,7 @@ static int es1370_post_load (void *opaque, int version_= id) AUD_close_in (&s->card, s->adc_voice); s->adc_voice =3D NULL; } - } - else { + } else { if (s->dac_voice[i]) { AUD_close_out (&s->card, s->dac_voice[i]); s->dac_voice[i] =3D NULL; --=20 2.35.3 From nobody Fri May 17 08:25:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694933947331711.1054159177676; Sat, 16 Sep 2023 23:59:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhljq-0006w0-O1; Sun, 17 Sep 2023 02:58:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljo-0006vG-QH for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:36 -0400 Received: from mailout02.t-online.de ([194.25.134.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljn-000556-1B for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:36 -0400 Received: from fwd72.aul.t-online.de (fwd72.aul.t-online.de [10.223.144.98]) by mailout02.t-online.de (Postfix) with SMTP id 0CBDA3ADF; Sun, 17 Sep 2023 08:58:33 +0200 (CEST) Received: from linpower.localnet ([79.208.31.89]) by fwd72.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qhljg-0lLi8P0; Sun, 17 Sep 2023 08:58:28 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id A6431200208; Sun, 17 Sep 2023 08:58:13 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , qemu-devel@nongnu.org Subject: [PATCH 7/8] hw/audio/es1370: change variable type and name Date: Sun, 17 Sep 2023 08:58:12 +0200 Message-Id: <20230917065813.6692-7-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1694933908-737FD980-9081658E/0/0 CLEAN NORMAL X-TOI-MSGID: 1a6b1dad-2f6c-4764-bcb0-06b4c47d892f Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.17; envelope-from=volker.ruemelin@t-online.de; helo=mailout02.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1694933948172100003 Change the type of the variable temp to size_t to avoid a type cast. While at it, rename the variable name to to_transfer. This improves the readability of the code. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: BALATON Zoltan --- hw/audio/es1370.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 86a869d4da..6d2aff57f2 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -605,6 +605,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, int max, int *irq) { uint8_t tmpbuf[4096]; + size_t to_transfer; uint32_t addr =3D d->frame_addr; int sc =3D d->scount & 0xffff; int csc =3D d->scount >> 16; @@ -616,16 +617,16 @@ static void es1370_transfer_audio (ES1370State *s, st= ruct chan *d, int loop_sel, } int left =3D ((size - cnt + 1) << 2) + d->leftover; int transferred =3D 0; - int temp =3D MIN (max, MIN (left, csc_bytes)); int index =3D d - &s->chan[0]; =20 + to_transfer =3D MIN(max, MIN(left, csc_bytes)); addr +=3D (cnt << 2) + d->leftover; =20 if (index =3D=3D ADC_CHANNEL) { - while (temp > 0) { + while (to_transfer > 0) { int acquired, to_copy; =20 - to_copy =3D MIN ((size_t) temp, sizeof (tmpbuf)); + to_copy =3D MIN(to_transfer, sizeof(tmpbuf)); acquired =3D AUD_read (s->adc_voice, tmpbuf, to_copy); if (!acquired) { break; @@ -633,23 +634,23 @@ static void es1370_transfer_audio (ES1370State *s, st= ruct chan *d, int loop_sel, =20 pci_dma_write (&s->dev, addr, tmpbuf, acquired); =20 - temp -=3D acquired; + to_transfer -=3D acquired; addr +=3D acquired; transferred +=3D acquired; } } else { SWVoiceOut *voice =3D s->dac_voice[index]; =20 - while (temp > 0) { + while (to_transfer > 0) { int copied, to_copy; =20 - to_copy =3D MIN ((size_t) temp, sizeof (tmpbuf)); + to_copy =3D MIN(to_transfer, sizeof(tmpbuf)); pci_dma_read (&s->dev, addr, tmpbuf, to_copy); copied =3D AUD_write (voice, tmpbuf, to_copy); if (!copied) { break; } - temp -=3D copied; + to_transfer -=3D copied; addr +=3D copied; transferred +=3D copied; } --=20 2.35.3 From nobody Fri May 17 08:25:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694933967612628.1585876666056; Sat, 16 Sep 2023 23:59:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhljq-0006vh-4s; Sun, 17 Sep 2023 02:58:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljn-0006v8-QU for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:35 -0400 Received: from mailout01.t-online.de ([194.25.134.80]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhljm-000552-49 for qemu-devel@nongnu.org; Sun, 17 Sep 2023 02:58:35 -0400 Received: from fwd89.aul.t-online.de (fwd89.aul.t-online.de [10.223.144.115]) by mailout01.t-online.de (Postfix) with SMTP id 5D1CA10125; Sun, 17 Sep 2023 08:58:32 +0200 (CEST) Received: from linpower.localnet ([79.208.31.89]) by fwd89.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qhlji-2mKRIP0; Sun, 17 Sep 2023 08:58:30 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id A924E200209; Sun, 17 Sep 2023 08:58:13 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , qemu-devel@nongnu.org Subject: [PATCH 8/8] hw/audio/es1370: trace lost interrupts Date: Sun, 17 Sep 2023 08:58:13 +0200 Message-Id: <20230917065813.6692-8-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1694933910-BF7E49BF-B142A45C/0/0 CLEAN NORMAL X-TOI-MSGID: 99bbe9f7-0738-44ab-ad2b-b42ac29d903b Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.80; envelope-from=volker.ruemelin@t-online.de; helo=mailout01.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1694933967800100001 It turns out that there are drivers which assume that interrupts can't be lost. E.g. the AROS sb128 driver is such a driver. Add a lost interrupt tracepoint to debug this kind of issues. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: BALATON Zoltan --- hw/audio/es1370.c | 14 ++++++++++---- hw/audio/trace-events | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 6d2aff57f2..4966f72ae6 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -602,7 +602,7 @@ static uint64_t es1370_read(void *opaque, hwaddr addr, = unsigned size) } =20 static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loo= p_sel, - int max, int *irq) + int max, bool *irq) { uint8_t tmpbuf[4096]; size_t to_transfer; @@ -657,10 +657,13 @@ static void es1370_transfer_audio (ES1370State *s, st= ruct chan *d, int loop_sel, } =20 if (csc_bytes =3D=3D transferred) { - *irq =3D 1; + if (*irq) { + trace_es1370_lost_interrupt(index); + } + *irq =3D true; d->scount =3D sc | (sc << 16); } else { - *irq =3D 0; + *irq =3D false; d->scount =3D sc | (((csc_bytes - transferred - 1) >> d->shift) <<= 16); } =20 @@ -688,7 +691,8 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, static void es1370_run_channel (ES1370State *s, size_t chan, int free_or_a= vail) { uint32_t new_status =3D s->status; - int max_bytes, irq; + int max_bytes; + bool irq; struct chan *d =3D &s->chan[chan]; const struct chan_bits *b =3D &es1370_chan_bits[chan]; =20 @@ -702,6 +706,8 @@ static void es1370_run_channel (ES1370State *s, size_t = chan, int free_or_avail) return; } =20 + irq =3D s->sctl & b->sctl_inten && s->status & b->stat_int; + es1370_transfer_audio (s, d, b->sctl_loopsel, max_bytes, &irq); =20 if (irq) { diff --git a/hw/audio/trace-events b/hw/audio/trace-events index 00f9e45158..ccbc8dabd5 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -11,10 +11,11 @@ es1370_frame_address_rd(int ch, uint32_t addr) "ch=3D%d= addr=3D0x%08x" es1370_frame_address_wr(int ch, uint32_t addr) "ch=3D%d addr=3D0x%08x" es1370_frame_count_rd(int ch, uint32_t curr, uint32_t size) "ch=3D%d CURR_= CT=3D%u BUF_SIZE=3D%u" es1370_frame_count_wr(int ch, uint32_t curr, uint32_t size) "ch=3D%d CURR_= CT=3D%u BUF_SIZE=3D%u" +es1370_lost_interrupt(int ch) "ch=3D%d lost interrupt" es1370_sample_count_rd(int ch, uint32_t curr, uint32_t num) "ch=3D%d CURR_= SAMP_CT=3D%u SAMP_CT=3D%u" es1370_sample_count_wr(int ch, uint32_t curr, uint32_t num) "ch=3D%d CURR_= SAMP_CT=3D%u SAMP_CT=3D%u" es1370_stream_format(int ch, uint32_t freq, const char *fmt, const char *m= ode, uint32_t shift) "ch=3D%d fmt=3D%u:%s:%s shift=3D%u" -es1370_transfer_audio(int ch, uint32_t f_curr, uint32_t f_size, uint32_t s= _curr, uint32_t s_num, uint32_t leftover, int irq) "ch=3D%d CURR_CT=3D%u BU= F_SIZE=3D%u CURR_SAMP_CT=3D%u SAMP_CT=3D%u leftover=3D%u irq=3D%d" +es1370_transfer_audio(int ch, uint32_t f_curr, uint32_t f_size, uint32_t s= _curr, uint32_t s_num, uint32_t leftover, bool irq) "ch=3D%d CURR_CT=3D%u B= UF_SIZE=3D%u CURR_SAMP_CT=3D%u SAMP_CT=3D%u leftover=3D%u irq=3D%d" =20 # hda-codec.c hda_audio_running(const char *stream, int nr, bool running) "st %s, nr %d,= run %d" --=20 2.35.3