From patchwork Fri Oct 26 05:49:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 12531 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8431723E01 for ; Fri, 26 Oct 2012 05:47:33 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 0AEBEA1917A for ; Fri, 26 Oct 2012 05:47:32 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so1868146iag.11 for ; Thu, 25 Oct 2012 22:47:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:x-auditid :from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :dlp-filter:x-mtr:x-brightmail-tracker:x-brightmail-tracker :x-cfilter-loop:x-gm-message-state; bh=zBK730e4BtfbzGl9ohdiw0tPCetIh0T5wiGALoJ0uJM=; b=eReX3+Tl8UPxA3/rR0bRzCzV9U29wTPd0ayAdAY9H2FiIWySp7ihyGIC6zEfC0Bi/U g+b1ibKtc2HbfjJ08URdUgGTrH9Mfj4mqTvakNH/WK4O/zusnKT2f7qDpCjwaZZSq8NA YWHc7kcqDRkV092DVwH9fkcLeWAmC202+fI73VOWEFfC81ZisNzxvTbnXTGqoWLpvaBI TaSi8uVpneaCycUYcWD3qnLoTPQbyyZKCYiKr4q5r34MRFPrCDSM7c4pM8e26o7Ef9EI 4zoRe5PrvOK1Y5XZjgP+eNRMTkDxxgnSn6GejmzXI2sOVC5sfeTKZ1OelakJDTMnltWr L2DA== Received: by 10.50.46.226 with SMTP id y2mr958655igm.62.1351230452435; Thu, 25 Oct 2012 22:47:32 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp191348igt; Thu, 25 Oct 2012 22:47:32 -0700 (PDT) Received: by 10.68.191.1 with SMTP id gu1mr48941212pbc.150.1351230451754; Thu, 25 Oct 2012 22:47:31 -0700 (PDT) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id h2si809982pay.48.2012.10.25.22.47.31; Thu, 25 Oct 2012 22:47:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.33 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MCH00M6MK2R1990@mailout3.samsung.com>; Fri, 26 Oct 2012 14:47:30 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.126]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 1D.A8.01231.2F32A805; Fri, 26 Oct 2012 14:47:30 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-99-508a23f2da7e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 8C.A8.01231.2F32A805; Fri, 26 Oct 2012 14:47:30 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MCH0021JJY1HB30@mmp1.samsung.com>; Fri, 26 Oct 2012 14:47:30 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, alim.akhtar@samsung.com, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org Subject: [PATCH 3/9 V4] Sound: Add command for audio playback Date: Fri, 26 Oct 2012 11:19:24 +0530 Message-id: <1351230570-21597-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1351230570-21597-1-git-send-email-rajeshwari.s@samsung.com> References: <1351230570-21597-1-git-send-email-rajeshwari.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsWyRsSkTveTcleAQdNCHYuH62+yWEw5/IXF gcnjzrU9bAGMUVw2Kak5mWWpRfp2CVwZrQ/mMxUcka3YvOkNSwPjE/EuRk4OCQETie+Pexkh bDGJC/fWs3UxcnEICSxllPi18ygLTNHOCUuZIRKLGCWm9HyAqprIJLH2zxewdjYBI4mtJ6eB 2SICEhK/+q8C2RwczAKlElMm5oGYwgK2EtPXiYBUsAioSnQ9vsQMYvMKeEgcmXaKCWKXgsSx qV9ZQWxOAU+JS39+gsWFgGoWn9vLBNErIPFt8iEWkJESArISmw6AnSYhcJ1N4u3bR2wQcyQl Dq64wTKBUXgBI8MqRtHUguSC4qT0XEO94sTc4tK8dL3k/NxNjMBgPP3vmdQOxpUNFocYBTgY lXh4I1I6A4RYE8uKK3MPMUpwMCuJ8O6eChTiTUmsrEotyo8vKs1JLT7E6AN0yURmKdHkfGCk 5JXEGxqbmJsam1oaGZmZmuIQVhLnbfZICRASSE8sSc1OTS1ILYIZx8TBKdXA2M/YUmxhm/bK sWrhjNnry1UvXgzTnfM8wHnv3oR9SjP62SXuq7KsKUvd/FrCaO/8I6Gmp91qV7jXT508+ejv tov965bXxR/54/pgZXEK3+Wz2/b5NO68OkOOnUXj6wG5adO/MtaKG0dtSLjFqbBiQvhCpiC+ LRy7z7xsYPj6IKlGm1fT3nSOiRJLcUaioRZzUXEiAEVfd/pzAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeLIzCtJLcpLzFFi42I5/e+xgO4n5a4Agwd/pC0err/JYjHl8BcW ByaPO9f2sAUwRjUw2mSkJqakFimk5iXnp2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qbaKrn4 BOi6ZeYAzVZSKEvMKQUKBSQWFyvp22GaEBripmsB0xih6xsSBNdjZIAGEtYwZrQ+mM9UcES2 YvOmNywNjE/Euxg5OSQETCR2TljKDGGLSVy4t56ti5GLQ0hgEaPElJ4PUM5EJom1f74wglSx CRhJbD05DcwWEZCQ+NV/Fcjm4GAWKJWYMjEPxBQWsJWYvk4EpIJFQFWi6/ElsPm8Ah4SR6ad YoLYpSBxbOpXVhCbU8BT4tKfn2BxIaCaxef2Mk1g5F3AyLCKUTS1ILmgOCk911CvODG3uDQv XS85P3cTIzjUn0ntYFzZYHGIUYCDUYmHNyKlM0CINbGsuDL3EKMEB7OSCO/uqUAh3pTEyqrU ovz4otKc1OJDjD5AV01klhJNzgfGYV5JvKGxibmpsamliYWJmSUOYSVx3maPlAAhgfTEktTs 1NSC1CKYcUwcnFINjIW2JVr679rNpf59Fbj05Z3AxZ1PtCWtXxQuO8za6r6j8ObvczMkSxme 1Fo1VagvCwt/lK2nIb3j/jm+/YdOWyj4KmSLfn68+mvXpT/rhNhOzSu7qFD1ZNL1co3sT3s7 jj1zD/ykdy1z/d8CoY05gXxaYXXsS1Z3C7wIXnfIN+q7rIv7ZNW5/EosxRmJhlrMRcWJAMAe iAqiAgAA X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQm/9TfUBHv9rtFdOF7cluouozZy0mIIgNs3aT6DNrlhIVR69Z4k0LPjXy+ZFUeZh3MgRbpR 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 Acked-by: Simon Glass --- Changes in V2: - None Changes in V3: - Incorporated comments from Simon Glass. Changes in V4: - None common/Makefile | 1 + common/cmd_sound.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 0 deletions(-) create mode 100644 common/cmd_sound.c diff --git a/common/Makefile b/common/Makefile index fdfead7..3f9f001 100644 --- a/common/Makefile +++ b/common/Makefile @@ -74,6 +74,7 @@ COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o COBJS-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o COBJS-$(CONFIG_CMD_DATE) += cmd_date.o +COBJS-$(CONFIG_CMD_SOUND) += cmd_sound.o ifdef CONFIG_4xx COBJS-$(CONFIG_CMD_SETGETDCR) += cmd_dcr.o endif diff --git a/common/cmd_sound.c b/common/cmd_sound.c new file mode 100644 index 0000000..459d1eb --- /dev/null +++ b/common/cmd_sound.c @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * Rajeshwari Shinde + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/* Initilaise sound subsystem */ +static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + int ret; + + ret = sound_init(); + if (ret) { + printf("Initialise Audio driver failed\n"); + return CMD_RET_FAILURE; + } + + return 0; +} + +/* play sound from buffer */ +static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + 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 = sound_play(msec, freq); + if (ret) { + printf("play failed"); + return CMD_RET_FAILURE; + } + + return 0; +} + +static cmd_tbl_t 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(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + cmd_tbl_t *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" +);