blob: 459d1ebaf2cc00ea61974c0d7675115199b5eb2b [file] [log] [blame]
Rajeshwari Shinde805adac2012-10-25 19:49:24 +00001/*
2 * Copyright (C) 2012 Samsung Electronics
3 * Rajeshwari Shinde <rajeshwari.s@samsung.com>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <command.h>
26#include <fdtdec.h>
27#include <sound.h>
28
29DECLARE_GLOBAL_DATA_PTR;
30
31/* Initilaise sound subsystem */
32static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
33{
34 int ret;
35
36 ret = sound_init();
37 if (ret) {
38 printf("Initialise Audio driver failed\n");
39 return CMD_RET_FAILURE;
40 }
41
42 return 0;
43}
44
45/* play sound from buffer */
46static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
47{
48 int ret = 0;
49 int msec = 1000;
50 int freq = 400;
51
52 if (argc > 1)
53 msec = simple_strtoul(argv[1], NULL, 10);
54 if (argc > 2)
55 freq = simple_strtoul(argv[2], NULL, 10);
56
57 ret = sound_play(msec, freq);
58 if (ret) {
59 printf("play failed");
60 return CMD_RET_FAILURE;
61 }
62
63 return 0;
64}
65
66static cmd_tbl_t cmd_sound_sub[] = {
67 U_BOOT_CMD_MKENT(init, 0, 1, do_init, "", ""),
68 U_BOOT_CMD_MKENT(play, 2, 1, do_play, "", ""),
69};
70
71/* process sound command */
72static int do_sound(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
73{
74 cmd_tbl_t *c;
75
76 if (argc < 1)
77 return CMD_RET_USAGE;
78
79 /* Strip off leading 'sound' command argument */
80 argc--;
81 argv++;
82
83 c = find_cmd_tbl(argv[0], &cmd_sound_sub[0], ARRAY_SIZE(cmd_sound_sub));
84
85 if (c)
86 return c->cmd(cmdtp, flag, argc, argv);
87 else
88 return CMD_RET_USAGE;
89}
90
91U_BOOT_CMD(
92 sound, 4, 1, do_sound,
93 "sound sub-system",
94 "init - initialise the sound driver\n"
95 "sound play [len] [freq] - play a sound for len ms at freq hz\n"
96);