summaryrefslogtreecommitdiff
path: root/drivers/sound
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-02-03 07:36:06 -0700
committerSimon Glass <sjg@chromium.org>2020-02-05 19:33:46 -0700
commit3062cd17af35b691582230c382dd125625d3b7ca (patch)
tree2fda0d01ece1da65ea3e0dd0d7790e2129aaa064 /drivers/sound
parent3ff6fe5fab11a99d4b3ec94a8a4a238d6f96f5ba (diff)
downloadu-boot-3062cd17af35b691582230c382dd125625d3b7ca.tar.gz
sound: Add a new stop_play() method
At present there is no positive indication that U-Boot has finished sending sound data. This means that it is not possible to power down an audio codec, for example. Add a new method that is called once all sound data has been sent. Add a new method for this, called when the sound_play() call is done. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/sound')
-rw-r--r--drivers/sound/sandbox.c21
-rw-r--r--drivers/sound/sound-uclass.c11
2 files changed, 31 insertions, 1 deletions
diff --git a/drivers/sound/sandbox.c b/drivers/sound/sandbox.c
index 363c687baf..9034a8385a 100644
--- a/drivers/sound/sandbox.c
+++ b/drivers/sound/sandbox.c
@@ -26,7 +26,8 @@ struct sandbox_i2s_priv {
};
struct sandbox_sound_priv {
- int setup_called;
+ int setup_called; /* Incremented when setup() method is called */
+ bool active; /* TX data is being sent */
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 */
@@ -59,6 +60,13 @@ int sandbox_get_setup_called(struct udevice *dev)
return priv->setup_called;
}
+int sandbox_get_sound_active(struct udevice *dev)
+{
+ struct sandbox_sound_priv *priv = dev_get_priv(dev);
+
+ return priv->active;
+}
+
int sandbox_get_sound_sum(struct udevice *dev)
{
struct sandbox_sound_priv *priv = dev_get_priv(dev);
@@ -163,6 +171,16 @@ static int sandbox_sound_play(struct udevice *dev, void *data, uint data_size)
return i2s_tx_data(uc_priv->i2s, data, data_size);
}
+static int sandbox_sound_stop_play(struct udevice *dev)
+{
+ struct sandbox_sound_priv *priv = dev_get_priv(dev);
+
+ sandbox_sdl_sound_stop();
+ priv->active = false;
+
+ return 0;
+}
+
int sandbox_sound_start_beep(struct udevice *dev, int frequency_hz)
{
struct sandbox_sound_priv *priv = dev_get_priv(dev);
@@ -228,6 +246,7 @@ U_BOOT_DRIVER(sandbox_i2s) = {
static const struct sound_ops sandbox_sound_ops = {
.setup = sandbox_sound_setup,
.play = sandbox_sound_play,
+ .stop_play = sandbox_sound_stop_play,
.start_beep = sandbox_sound_start_beep,
.stop_beep = sandbox_sound_stop_beep,
};
diff --git a/drivers/sound/sound-uclass.c b/drivers/sound/sound-uclass.c
index d49f29bcd5..c213472d60 100644
--- a/drivers/sound/sound-uclass.c
+++ b/drivers/sound/sound-uclass.c
@@ -31,6 +31,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);
@@ -97,6 +107,7 @@ int sound_beep(struct udevice *dev, int msecs, int frequency_hz)
ret = sound_play(dev, data, size);
}
+ sound_stop_play(dev);
free(data);