Commit c0c88533fffdba4544043e6070ba322c8b79234a

Authored by Rajeshwari Shinde
Committed by Minkyu Kang
1 parent a2d8e0a717

Sound: Add command for audio playback

This patch adds command to test audio playback.
sound init - Initialises the audio subsystem (i2s and wm8994 codec)
sound play - Plays predefined the audio data when specified length
and frequency.

Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>

Showing 2 changed files with 97 additions and 0 deletions Side-by-side Diff

... ... @@ -75,6 +75,7 @@
75 75 COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o
76 76 COBJS-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o
77 77 COBJS-$(CONFIG_CMD_DATE) += cmd_date.o
  78 +COBJS-$(CONFIG_CMD_SOUND) += cmd_sound.o
78 79 ifdef CONFIG_4xx
79 80 COBJS-$(CONFIG_CMD_SETGETDCR) += cmd_dcr.o
80 81 endif
  1 +/*
  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 +
  29 +DECLARE_GLOBAL_DATA_PTR;
  30 +
  31 +/* Initilaise sound subsystem */
  32 +static 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 */
  46 +static 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 +
  66 +static 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 */
  72 +static 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 +
  91 +U_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 +);