diff options
author | Tom Rini <trini@konsulko.com> | 2020-02-11 10:58:41 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-02-11 10:58:41 -0500 |
commit | 9a8942b53d57149754e0dfc975e0d92d1afd4087 (patch) | |
tree | de55e5352f3a8a79c413c0b8cb533428e5476841 /drivers/sound/sound-uclass.c | |
parent | ae347120eed8204b1fdf018ddf79131964e57016 (diff) | |
parent | 21d651fb29cf268b1a5f64d080e3d352ee32c87f (diff) |
Merge tag 'dm-pull-6feb20' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
sandbox conversion to SDL2
TPM TEE driver
Various minor sandbox video enhancements
New driver model core utility functions
Diffstat (limited to 'drivers/sound/sound-uclass.c')
-rw-r--r-- | drivers/sound/sound-uclass.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/sound/sound-uclass.c b/drivers/sound/sound-uclass.c index d49f29bcd5b..d9b3a38f18c 100644 --- a/drivers/sound/sound-uclass.c +++ b/drivers/sound/sound-uclass.c @@ -7,6 +7,7 @@ #include <common.h> #include <dm.h> #include <i2s.h> +#include <malloc.h> #include <sound.h> #define SOUND_BITS_IN_BYTE 8 @@ -31,6 +32,16 @@ int sound_play(struct udevice *dev, void *data, uint data_size) return ops->play(dev, data, data_size); } +int sound_stop_play(struct udevice *dev) +{ + struct sound_ops *ops = sound_get_ops(dev); + + if (!ops->play) + return -ENOSYS; + + return ops->stop_play(dev); +} + int sound_start_beep(struct udevice *dev, int frequency_hz) { struct sound_ops *ops = sound_get_ops(dev); @@ -87,16 +98,20 @@ int sound_beep(struct udevice *dev, int msecs, int frequency_hz) sound_create_square_wave(i2s_uc_priv->samplingrate, data, data_size, frequency_hz, i2s_uc_priv->channels); + ret = 0; while (msecs >= 1000) { ret = sound_play(dev, data, data_size); + if (ret) + break; msecs -= 1000; } - if (msecs) { + if (!ret && msecs) { unsigned long size = (data_size * msecs) / (sizeof(int) * 1000); ret = sound_play(dev, data, size); } + sound_stop_play(dev); free(data); |