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(struct cmd_tbl *cmdtp, int flag, int argc,
22 ret = uclass_first_device_err(UCLASS_SOUND, &dev);
24 ret = sound_setup(dev);
26 printf("Initialise Audio driver failed (ret=%d)\n", ret);
27 return CMD_RET_FAILURE;
33 /* play sound from buffer */
34 static int do_play(struct cmd_tbl *cmdtp, int flag, int argc,
43 msec = simple_strtoul(argv[1], NULL, 10);
45 freq = simple_strtoul(argv[2], NULL, 10);
47 ret = uclass_first_device_err(UCLASS_SOUND, &dev);
49 ret = sound_beep(dev, msec, freq);
51 printf("Sound device failed to play (err=%d)\n", ret);
52 return CMD_RET_FAILURE;
58 static struct cmd_tbl cmd_sound_sub[] = {
59 U_BOOT_CMD_MKENT(init, 0, 1, do_init, "", ""),
60 U_BOOT_CMD_MKENT(play, 2, 1, do_play, "", ""),
63 /* process sound command */
64 static int do_sound(struct cmd_tbl *cmdtp, int flag, int argc,
72 /* Strip off leading 'sound' command argument */
76 c = find_cmd_tbl(argv[0], &cmd_sound_sub[0], ARRAY_SIZE(cmd_sound_sub));
79 return c->cmd(cmdtp, flag, argc, argv);
85 sound, 4, 1, do_sound,
87 "init - initialise the sound driver\n"
88 "sound play [len] [freq] - play a sound for len ms at freq hz\n"