Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

echoplayer: add PCM debug menu

Display DMA error counters and the SAI underrun counter
in the debug menu.

Change-Id: I235bfcb0fa965d87c30deeb300535141eda5f974

authored by

Aidan MacDonald and committed by
Solomon Peachy
84fa5389 5c1ae511

+84
+57
firmware/target/arm/stm32/debug-stm32h7.c
··· 86 86 return simplelist_show_list(&info); 87 87 } 88 88 89 + #if defined(ECHO_R1) 90 + extern volatile int pcm_sai_xrun_count; 91 + extern volatile int pcm_dma_teif_count; 92 + extern volatile int pcm_dma_dmeif_count; 93 + extern volatile int pcm_dma_feif_count; 94 + 95 + struct pcmdebug_counter 96 + { 97 + const char *name; 98 + volatile int *value; 99 + }; 100 + 101 + static const struct pcmdebug_counter pcmdebug_counters[] = 102 + { 103 + {"SAI xrun count", &pcm_sai_xrun_count}, 104 + {"DMA TEIF count", &pcm_dma_teif_count}, 105 + {"DMA DMEIF count", &pcm_dma_dmeif_count}, 106 + {"DMA FEIF count", &pcm_dma_feif_count}, 107 + }; 108 + 109 + static int pcmdebug_menu_action_cb(int action, struct gui_synclist *lists) 110 + { 111 + if (action == ACTION_STD_OK) 112 + { 113 + int item = gui_synclist_get_sel_pos(lists); 114 + const struct pcmdebug_counter *counter = &pcmdebug_counters[item]; 115 + 116 + *counter->value = 0; 117 + action = ACTION_REDRAW; 118 + } 119 + 120 + if (action == ACTION_NONE) 121 + action = ACTION_REDRAW; 122 + 123 + return action; 124 + } 125 + 126 + static const char *pcmdebug_menu_get_name(int item, void *data, char *buf, size_t bufsz) 127 + { 128 + const struct pcmdebug_counter *counter = &pcmdebug_counters[item]; 129 + (void)data; 130 + 131 + snprintf(buf, bufsz, "%s: %d", counter->name, *counter->value); 132 + return buf; 133 + } 134 + 135 + static bool pcm_debug_menu(void) 136 + { 137 + struct simplelist_info info; 138 + simplelist_info_init(&info, "PCM debug", ARRAYLEN(pcmdebug_counters), NULL); 139 + info.action_callback = pcmdebug_menu_action_cb; 140 + info.get_name = pcmdebug_menu_get_name; 141 + return simplelist_show_list(&info); 142 + } 143 + #endif 144 + 89 145 /* Menu definition */ 90 146 static const struct { 91 147 const char *name; 92 148 bool (*function) (void); 93 149 } menuitems[] = { 150 + {"PCM debug", pcm_debug_menu}, 94 151 {"SWD/JTAG", swd_menu}, 95 152 }; 96 153
+27
firmware/target/arm/stm32/echoplayer/pcm-echoplayer.c
··· 65 65 66 66 static int pcm_last_freq = -1; 67 67 68 + volatile int pcm_sai_xrun_count; 69 + volatile int pcm_dma_teif_count; 70 + volatile int pcm_dma_dmeif_count; 71 + volatile int pcm_dma_feif_count; 72 + 68 73 static void play_dma_start(const void *addr, size_t size) 69 74 { 70 75 commit_dcache_range(addr, size); ··· 151 156 SLOTSZ_V(DATASZ), /* slot size = data size */ 152 157 FBOFF(0)); /* no bit offset in slot */ 153 158 159 + /* Enable xrun error interrupt */ 160 + reg_writelf(sai1a, SAI_SUBBLOCK_IM, OVRUDR(1)); 161 + 154 162 /* Enable interrupts in NVIC */ 155 163 nvic_enable_irq(NVIC_IRQN_DMA1_STR0); 164 + nvic_enable_irq(NVIC_IRQN_SAI1); 156 165 } 157 166 158 167 struct div_settings ··· 326 335 const void *addr; 327 336 size_t size; 328 337 338 + if (reg_vreadf(lisr, DMA_LISR, TEIF0)) 339 + pcm_dma_teif_count++; 340 + 341 + if (reg_vreadf(lisr, DMA_LISR, DMEIF0)) 342 + pcm_dma_dmeif_count++; 343 + 344 + if (reg_vreadf(lisr, DMA_LISR, FEIF0)) 345 + pcm_dma_feif_count++; 346 + 329 347 if (reg_vreadf(lisr, DMA_LISR, TEIF0) || 330 348 reg_vreadf(lisr, DMA_LISR, DMEIF0) || 331 349 reg_vreadf(lisr, DMA_LISR, FEIF0)) ··· 352 370 panicf("%s: %08lx", __func__, lisr); 353 371 } 354 372 } 373 + 374 + void sai1_irq_handler(void) 375 + { 376 + if (reg_readlf(sai1a, SAI_SUBBLOCK_SR, OVRUDR)) 377 + { 378 + reg_assignlf(sai1a, SAI_SUBBLOCK_CLRFR, OVRUDR(1)); 379 + pcm_sai_xrun_count++; 380 + } 381 + }