1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Samsung Electronics
4 * Rajeshwari Shinde <rajeshwari.s@samsung.com>
12 #include <asm/global_data.h>
14 DECLARE_GLOBAL_DATA_PTR;
16 /* Initilaise sound subsystem */
17 static int do_init(struct cmd_tbl *cmdtp, int flag, int argc,
23 ret = uclass_first_device_err(UCLASS_SOUND, &dev);
25 ret = sound_setup(dev);
27 printf("Initialise Audio driver failed (ret=%d)\n", ret);
28 return CMD_RET_FAILURE;
34 /* play sound from buffer */
35 static int do_play(struct cmd_tbl *cmdtp, int flag, int argc,
44 ret = uclass_first_device_err(UCLASS_SOUND, &dev);
49 while (argc || first) {
52 msec = dectoul(argv[0], NULL);
57 freq = dectoul(argv[0], NULL);
61 ret = sound_beep(dev, msec, freq);
68 printf("Sound device failed to play (err=%d)\n", ret);
69 return CMD_RET_FAILURE;
72 static struct cmd_tbl cmd_sound_sub[] = {
73 U_BOOT_CMD_MKENT(init, 0, 1, do_init, "", ""),
74 U_BOOT_CMD_MKENT(play, INT_MAX, 1, do_play, "", ""),
77 /* process sound command */
78 static int do_sound(struct cmd_tbl *cmdtp, int flag, int argc,
86 /* Strip off leading 'sound' command argument */
90 c = find_cmd_tbl(argv[0], &cmd_sound_sub[0], ARRAY_SIZE(cmd_sound_sub));
93 return c->cmd(cmdtp, flag, argc, argv);
99 sound, INT_MAX, 1, do_sound,
101 "init - initialise the sound driver\n"
102 "sound play [[[-q|-s] len [freq]] ...] - play sounds\n"
103 " len - duration in ms\n"
104 " freq - frequency in Hz\n"