summaryrefslogtreecommitdiff
path: root/cmd/sound.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/sound.c')
-rw-r--r--cmd/sound.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/cmd/sound.c b/cmd/sound.c
index d1cbc14f8d..638f29df21 100644
--- a/cmd/sound.c
+++ b/cmd/sound.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <command.h>
+#include <dm.h>
#include <fdtdec.h>
#include <sound.h>
@@ -14,11 +15,14 @@ DECLARE_GLOBAL_DATA_PTR;
/* Initilaise sound subsystem */
static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
+ struct udevice *dev;
int ret;
- ret = sound_init(gd->fdt_blob);
+ ret = uclass_first_device_err(UCLASS_SOUND, &dev);
+ if (!ret)
+ ret = sound_setup(dev);
if (ret) {
- printf("Initialise Audio driver failed\n");
+ printf("Initialise Audio driver failed (ret=%d)\n", ret);
return CMD_RET_FAILURE;
}
@@ -28,6 +32,7 @@ static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
/* play sound from buffer */
static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
+ struct udevice *dev;
int ret = 0;
int msec = 1000;
int freq = 400;
@@ -37,9 +42,11 @@ static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
if (argc > 2)
freq = simple_strtoul(argv[2], NULL, 10);
- ret = sound_play(msec, freq);
+ ret = uclass_first_device_err(UCLASS_SOUND, &dev);
+ if (!ret)
+ ret = sound_beep(dev, msec, freq);
if (ret) {
- printf("play failed");
+ printf("Sound device failed to play (err=%d)\n", ret);
return CMD_RET_FAILURE;
}