From nobody Fri Oct 18 08:29:19 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 --- 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