1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Samsung Electronics
4 * Rajeshwari Shinde <rajeshwari.s@samsung.com>
13 DECLARE_GLOBAL_DATA_PTR
;
15 /* Initilaise sound subsystem */
16 static int do_init(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *const argv
[])
21 ret
= uclass_first_device_err(UCLASS_SOUND
, &dev
);
23 ret
= sound_setup(dev
);
25 printf("Initialise Audio driver failed (ret=%d)\n", ret
);
26 return CMD_RET_FAILURE
;
32 /* play sound from buffer */
33 static int do_play(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *const argv
[])
41 msec
= simple_strtoul(argv
[1], NULL
, 10);
43 freq
= simple_strtoul(argv
[2], NULL
, 10);
45 ret
= uclass_first_device_err(UCLASS_SOUND
, &dev
);
47 ret
= sound_beep(dev
, msec
, freq
);
49 printf("Sound device failed to play (err=%d)\n", ret
);
50 return CMD_RET_FAILURE
;
56 static cmd_tbl_t cmd_sound_sub
[] = {
57 U_BOOT_CMD_MKENT(init
, 0, 1, do_init
, "", ""),
58 U_BOOT_CMD_MKENT(play
, 2, 1, do_play
, "", ""),
61 /* process sound command */
62 static int do_sound(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *const argv
[])
69 /* Strip off leading 'sound' command argument */
73 c
= find_cmd_tbl(argv
[0], &cmd_sound_sub
[0], ARRAY_SIZE(cmd_sound_sub
));
76 return c
->cmd(cmdtp
, flag
, argc
, argv
);
82 sound
, 4, 1, do_sound
,
84 "init - initialise the sound driver\n"
85 "sound play [len] [freq] - play a sound for len ms at freq hz\n"