mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 08:57:58 +00:00
401d1c4f5d
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
90 lines
1.8 KiB
C
90 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2012 Samsung Electronics
|
|
* Rajeshwari Shinde <rajeshwari.s@samsung.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <command.h>
|
|
#include <dm.h>
|
|
#include <fdtdec.h>
|
|
#include <sound.h>
|
|
#include <asm/global_data.h>
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
/* Initilaise sound subsystem */
|
|
static int do_init(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
char *const argv[])
|
|
{
|
|
struct udevice *dev;
|
|
int ret;
|
|
|
|
ret = uclass_first_device_err(UCLASS_SOUND, &dev);
|
|
if (!ret)
|
|
ret = sound_setup(dev);
|
|
if (ret) {
|
|
printf("Initialise Audio driver failed (ret=%d)\n", ret);
|
|
return CMD_RET_FAILURE;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* play sound from buffer */
|
|
static int do_play(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
char *const argv[])
|
|
{
|
|
struct udevice *dev;
|
|
int ret = 0;
|
|
int msec = 1000;
|
|
int freq = 400;
|
|
|
|
if (argc > 1)
|
|
msec = simple_strtoul(argv[1], NULL, 10);
|
|
if (argc > 2)
|
|
freq = simple_strtoul(argv[2], NULL, 10);
|
|
|
|
ret = uclass_first_device_err(UCLASS_SOUND, &dev);
|
|
if (!ret)
|
|
ret = sound_beep(dev, msec, freq);
|
|
if (ret) {
|
|
printf("Sound device failed to play (err=%d)\n", ret);
|
|
return CMD_RET_FAILURE;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct cmd_tbl cmd_sound_sub[] = {
|
|
U_BOOT_CMD_MKENT(init, 0, 1, do_init, "", ""),
|
|
U_BOOT_CMD_MKENT(play, 2, 1, do_play, "", ""),
|
|
};
|
|
|
|
/* process sound command */
|
|
static int do_sound(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
char *const argv[])
|
|
{
|
|
struct cmd_tbl *c;
|
|
|
|
if (argc < 1)
|
|
return CMD_RET_USAGE;
|
|
|
|
/* Strip off leading 'sound' command argument */
|
|
argc--;
|
|
argv++;
|
|
|
|
c = find_cmd_tbl(argv[0], &cmd_sound_sub[0], ARRAY_SIZE(cmd_sound_sub));
|
|
|
|
if (c)
|
|
return c->cmd(cmdtp, flag, argc, argv);
|
|
else
|
|
return CMD_RET_USAGE;
|
|
}
|
|
|
|
U_BOOT_CMD(
|
|
sound, 4, 1, do_sound,
|
|
"sound sub-system",
|
|
"init - initialise the sound driver\n"
|
|
"sound play [len] [freq] - play a sound for len ms at freq hz\n"
|
|
);
|