Commit c0c88533fffdba4544043e6070ba322c8b79234a

Authored by Rajeshwari Shinde
Committed by Minkyu Kang
1 parent a2d8e0a717
Exists in master and in 55 other branches 8qm-imx_v2020.04_5.4.70_2.3.0, emb_lf_v2022.04, emb_lf_v2023.04, imx_v2015.04_4.1.15_1.0.0_ga, pitx_8mp_lf_v2020.04, smarc-8m-android-10.0.0_2.6.0, smarc-8m-android-11.0.0_2.0.0, smarc-8mp-android-11.0.0_2.0.0, smarc-emmc-imx_v2014.04_3.10.53_1.1.0_ga, smarc-emmc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx-l5.0.0_1.0.0-ga, smarc-imx6_v2018.03_4.14.98_2.0.0_ga, smarc-imx7_v2017.03_4.9.11_1.0.0_ga, smarc-imx7_v2018.03_4.14.98_2.0.0_ga, smarc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx_v2015.04_4.1.15_1.0.0_ga, smarc-imx_v2017.03_4.9.11_1.0.0_ga, smarc-imx_v2017.03_4.9.88_2.0.0_ga, smarc-imx_v2017.03_o8.1.0_1.3.0_8m, smarc-imx_v2018.03_4.14.78_1.0.0_ga, smarc-m6.0.1_2.1.0-ga, smarc-n7.1.2_2.0.0-ga, smarc-rel_imx_4.1.15_2.0.0_ga, smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8m-imx_v2019.04_4.19.35_1.1.0, smarc_8m_00d0-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2019.04_4.19.35_1.1.0, smarc_8mm-imx_v2020.04_5.4.24_2.1.0, smarc_8mp_lf_v2020.04, smarc_8mq-imx_v2020.04_5.4.24_2.1.0, smarc_8mq_lf_v2020.04, ti-u-boot-2015.07, u-boot-2013.01.y, v2013.10, v2013.10-smarct33, v2013.10-smartmen, v2014.01, v2014.04, v2014.04-smarct33, v2014.04-smarct33-emmc, v2014.04-smartmen, v2014.07, v2014.07-smarct33, v2014.07-smartmen, v2015.07-smarct33, v2015.07-smarct33-emmc, v2015.07-smarct4x, v2016.05-dlt, v2016.05-smarct3x, v2016.05-smarct3x-emmc, v2016.05-smarct4x, v2017.01-smarct3x, v2017.01-smarct3x-emmc, v2017.01-smarct4x

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 +);