diff options
author | Tom Rini <trini@konsulko.com> | 2022-12-06 10:07:01 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-12-06 10:07:01 -0500 |
commit | 14f2d087a3d6347ba0ff7a7e9aaff6955e53e7a8 (patch) | |
tree | bc4677f00c57b7ff42a0852a50d213266896e68a /drivers | |
parent | 1c470f32f74248ff4aa145bf033fb6524dc7fc2e (diff) | |
parent | 304bc9f437df51b4d982fe25fd0988350c8f5fc9 (diff) |
Merge tag 'sound-2023-01-rc4' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request for sound-2023-01-rc4
* Avoid endless loop and amend unit test
* Add man-page for the sound command
* Fix sandbox sound driver
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/sound/sandbox.c | 9 | ||||
-rw-r--r-- | drivers/sound/sound.c | 5 |
2 files changed, 13 insertions, 1 deletions
diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c index 4a2c87a84c..c6cbd81fdb 100644 --- a/drivers/sound/sandbox.c +++ b/drivers/sound/sandbox.c @@ -29,6 +29,7 @@ struct sandbox_i2s_priv { struct sandbox_sound_priv { int setup_called; /* Incremented when setup() method is called */ bool active; /* TX data is being sent */ + int count; /* Use to count the provided audio data */ int sum; /* Use to sum the provided audio data */ bool allow_beep; /* true to allow the start_beep() interface */ int frequency_hz; /* Beep frequency if active, else 0 */ @@ -68,6 +69,13 @@ int sandbox_get_sound_active(struct udevice *dev) return priv->active; } +int sandbox_get_sound_count(struct udevice *dev) +{ + struct sandbox_sound_priv *priv = dev_get_priv(dev); + + return priv->count; +} + int sandbox_get_sound_sum(struct udevice *dev) { struct sandbox_sound_priv *priv = dev_get_priv(dev); @@ -168,6 +176,7 @@ static int sandbox_sound_play(struct udevice *dev, void *data, uint data_size) for (i = 0; i < data_size; i++) priv->sum += ((uint8_t *)data)[i]; + priv->count += data_size; return i2s_tx_data(uc_priv->i2s, data, data_size); } diff --git a/drivers/sound/sound.c b/drivers/sound/sound.c index 041dfdccfe..c0fc50c99d 100644 --- a/drivers/sound/sound.c +++ b/drivers/sound/sound.c @@ -15,7 +15,10 @@ void sound_create_square_wave(uint sample_rate, unsigned short *data, int size, const int period = freq ? sample_rate / freq : 0; const int half = period / 2; - assert(freq); + if (!half) { + memset(data, 0, size); + return; + } /* Make sure we don't overflow our buffer */ if (size % 2) |