Skip to content

Commit 8098801

Browse files
committed
fw/drivers/mic: add QEMU microphone driver
Signed-off-by: Joshua Jun <lets@throw.rocks>
1 parent 071a5a5 commit 8098801

13 files changed

Lines changed: 198 additions & 0 deletions

File tree

boards/qemu_emery/defconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ CONFIG_TEMPERATURE_STUB=y
4141

4242
CONFIG_CPUMODE=y
4343
CONFIG_CPUMODE_STUB=y
44+
45+
CONFIG_MIC=y
46+
CONFIG_MIC_QEMU=y

boards/qemu_flint/defconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ CONFIG_TEMPERATURE_STUB=y
3535

3636
CONFIG_CPUMODE=y
3737
CONFIG_CPUMODE_STUB=y
38+
39+
CONFIG_MIC=y
40+
CONFIG_MIC_QEMU=y

boards/qemu_gabbro/defconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ CONFIG_TEMPERATURE_STUB=y
3838

3939
CONFIG_CPUMODE=y
4040
CONFIG_CPUMODE_STUB=y
41+
42+
CONFIG_MIC=y
43+
CONFIG_MIC_QEMU=y

src/fw/board/boards/board_qemu_emery.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "drivers/uart/qemu.h"
88
#include "drivers/qemu/qemu_audio.h"
99
#include "drivers/led_controller.h"
10+
#include "drivers/mic/qemu/mic_definitions.h"
1011

1112
static UARTDeviceState s_dbg_uart_state = {};
1213

@@ -80,6 +81,14 @@ static struct AudioDevice AUDIO_DEVICE = {
8081
};
8182
AudioDevice *const AUDIO = (AudioDevice *)&AUDIO_DEVICE;
8283

84+
// Microphone (QEMU stub — feeds silence on a timer)
85+
static MicDeviceState s_mic_state;
86+
static MicDevice MIC_DEVICE = {
87+
.state = &s_mic_state,
88+
.channels = 1,
89+
};
90+
MicDevice * const MIC = &MIC_DEVICE;
91+
8392
// IRQ handler trampolines
8493
IRQ_MAP(UART2, uart_irq_handler, DBG_UART);
8594
IRQ_MAP(UART1, uart_irq_handler, QEMU_UART);

src/fw/board/boards/board_qemu_emery.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
extern UARTDevice * const DBG_UART;
1010
extern UARTDevice * const QEMU_UART;
1111
extern DisplayDevice *const DISPLAY;
12+
extern MicDevice * const MIC;
1213
extern const BoardConfigActuator BOARD_CONFIG_VIBE;
1314
extern const BoardConfigPower BOARD_CONFIG_POWER;
1415
extern const BoardConfig BOARD_CONFIG;

src/fw/board/boards/board_qemu_flint.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// UART device for debug serial
77
#include "drivers/uart/qemu.h"
88
#include "drivers/qemu/qemu_audio.h"
9+
#include "drivers/mic/qemu/mic_definitions.h"
910

1011
static UARTDeviceState s_dbg_uart_state = {};
1112

@@ -78,6 +79,14 @@ static struct AudioDevice AUDIO_DEVICE = {
7879
};
7980
AudioDevice *const AUDIO = (AudioDevice *)&AUDIO_DEVICE;
8081

82+
// Microphone (QEMU stub — feeds silence on a timer)
83+
static MicDeviceState s_mic_state;
84+
static MicDevice MIC_DEVICE = {
85+
.state = &s_mic_state,
86+
.channels = 1,
87+
};
88+
MicDevice * const MIC = &MIC_DEVICE;
89+
8190
// IRQ handler trampolines
8291
IRQ_MAP(UART2, uart_irq_handler, DBG_UART);
8392
IRQ_MAP(UART1, uart_irq_handler, QEMU_UART);

src/fw/board/boards/board_qemu_flint.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
extern UARTDevice * const DBG_UART;
1010
extern UARTDevice * const QEMU_UART;
1111
extern DisplayDevice *const DISPLAY;
12+
extern MicDevice * const MIC;
1213
extern const BoardConfigActuator BOARD_CONFIG_VIBE;
1314
extern const BoardConfigPower BOARD_CONFIG_POWER;
1415
extern const BoardConfig BOARD_CONFIG;

src/fw/board/boards/board_qemu_gabbro.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
// UART device for debug serial
77
#include "drivers/uart/qemu.h"
8+
#include "drivers/mic/qemu/mic_definitions.h"
89

910
static UARTDeviceState s_dbg_uart_state = {};
1011

@@ -68,6 +69,14 @@ const BoardConfigButton BOARD_CONFIG_BUTTON = {
6869
.timer_irqn = TIMER0_IRQn,
6970
};
7071

72+
// Microphone (QEMU stub — feeds silence on a timer)
73+
static MicDeviceState s_mic_state;
74+
static MicDevice MIC_DEVICE = {
75+
.state = &s_mic_state,
76+
.channels = 1,
77+
};
78+
MicDevice * const MIC = &MIC_DEVICE;
79+
7180
// IRQ handler trampolines
7281
IRQ_MAP(UART2, uart_irq_handler, DBG_UART);
7382
IRQ_MAP(UART1, uart_irq_handler, QEMU_UART);

src/fw/board/boards/board_qemu_gabbro.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
extern UARTDevice * const DBG_UART;
1010
extern UARTDevice * const QEMU_UART;
1111
extern DisplayDevice *const DISPLAY;
12+
extern MicDevice * const MIC;
1213
extern const BoardConfigActuator BOARD_CONFIG_VIBE;
1314
extern const BoardConfigPower BOARD_CONFIG_POWER;
1415
extern const BoardConfig BOARD_CONFIG;

src/fw/drivers/mic/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,12 @@ config MIC_STM32F4_PDM
2828
help
2929
Support for the ST STM32F4 PDM microphone interface.
3030

31+
config MIC_QEMU
32+
bool "QEMU stub"
33+
help
34+
Software-only microphone stub for QEMU. Delivers silence at
35+
MIC_SAMPLE_RATE so the voice service can run end-to-end against
36+
`pebble transcribe`, which ignores audio frames and replies with
37+
a canned transcription on a timer.
38+
3139
endif # MIC

0 commit comments

Comments
 (0)