Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
diff --git a/firmware/target/arm/as3525/audio-as3525.c b/firmware/target/arm/as3525/audio-as3525.c index c56024f..570ff14 100644 #include "audiohw.h" #include "sound.h" +int audio_channels = 2; + void audio_set_output_source(int source) { (void)source; void audio_input_mux(int source, unsigned flags) case AUDIO_SRC_PLAYBACK: if (source != last_source) { + audio_channels = 2; #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN) audiohw_set_monitor(false); #endif void audio_input_mux(int source, unsigned flags) case AUDIO_SRC_MIC: /* recording only */ if (source != last_source) { + audio_channels = 1; audiohw_set_monitor(false); audiohw_enable_recording(true); /* source mic */ } void audio_input_mux(int source, unsigned flags) ) break; + audio_channels = 2; #ifdef HAVE_RECORDING last_recording = recording; diff --git a/firmware/target/arm/as3525/pcm-as3525.c b/firmware/target/arm/as3525/pcm-as3525.c index c649ace..d42b411 100644 void * pcm_dma_addr(void *addr) static int rec_locked = 0; static unsigned char *rec_dma_start_addr; -static size_t rec_dma_size; +static size_t rec_dma_size, rec_dma_transfer_size; static void rec_dma_callback(void); void pcm_rec_unlock(void) static void rec_dma_start(void) { - void* addr = rec_dma_start_addr; - size_t size = rec_dma_size; + rec_dma_transfer_size = rec_dma_size; /* We are limited to 8188 DMA transfers, and the recording core asks for * 8192 bytes. Avoid splitting 8192 bytes transfers in 8188 + 4 */ - if(size > 4096) - size = 4096; + if(rec_dma_transfer_size > 4096) + rec_dma_transfer_size = 4096; - rec_dma_size -= size; - rec_dma_start_addr += size; - - dma_enable_channel(1, (void*)I2SIN_DATA, addr, DMA_PERI_I2SIN, - DMAC_FLOWCTRL_DMAC_PERI_TO_MEM, false, true, size >> 2, DMA_S4, - rec_dma_callback); + dma_enable_channel(1, (void*)I2SIN_DATA, rec_dma_start_addr, DMA_PERI_I2SIN, + DMAC_FLOWCTRL_DMAC_PERI_TO_MEM, false, true, + rec_dma_transfer_size >> 2, DMA_S4, rec_dma_callback); } static void rec_dma_callback(void) { + rec_dma_size -= rec_dma_transfer_size; + rec_dma_start_addr += rec_dma_transfer_size; + +#if CONFIG_CPU == AS3525 + /* the 2nd channel is silent when recording microphone on as3525v1 */ + if(audio_channels == 1) + { + int16_t *sample = (int16_t*)rec_dma_start_addr; + size_t n_samples = rec_dma_transfer_size / 2; /* bytes -> samples */ + +#if 0 + do { + n_samples -= 2; + sample[n_samples + 1] = sample[n_samples]; + } while(n_samples); +#else + /* gcc 4.0.3 doesn't use pre/post indexing, let's save 1 cycle */ + int16_t tmp; + asm volatile ( + "1: ldrh %0, [%1, #-4]! \n" + " strh %0, [%1, #2] \n" + " subs %2, %2, #2 \n" + " bne 1b \n" + : "=r"(tmp), "+r"(sample), "+r"(n_samples) + : /* input */ + : "memory" + ); +#endif /* C / ASM */ + } +#endif /* CONFIG_CPU == AS3525 */ + if(!rec_dma_size) { register pcm_more_callback_type2 more_ready = pcm_callback_more_ready; |