From patchwork Tue Oct 23 06:57:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 12421 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 926A923EF8 for ; Tue, 23 Oct 2012 06:46:37 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 47069A184B2 for ; Tue, 23 Oct 2012 06:46:37 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so4657775iej.11 for ; Mon, 22 Oct 2012 23:46:37 -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=GGvD81hFkoZOdPrOXVALGDHZQF+XcyiuUxyyuH1djk0=; b=iG+AIBEthGviXC4OedOOGR5akYAvaWkx23qnkX7tzlMSJpteEfKjRzeQKFzlNlCoTO nOID9n7MCuHjmlToDAwWuFzZ1AmSkAhRxRSc0+HOsYaK9aEWaY8ok0YUhpkEI7nQjw7f kg9j5PAm7NVGLLXzaGZ2lsRhje625QTdBS8wrV1KhVFWfCK/vrklftpiYpv6v4ml7gFJ /S/jXYrFEUQyHpww6Uav49p2xb6/HOHWOWMPEC/yTPNWBUZdggp6/w9PZ76GYWWJYt6o 3eFUIQDCwM9xJUDIEvuR/RNSsIz2V+sAKUI398kvmAvVCYabqdU5ZpUGEmVEkw/LA63M s98g== Received: by 10.50.152.137 with SMTP id uy9mr11585359igb.62.1350974796894; Mon, 22 Oct 2012 23:46:36 -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 n20csp372156igt; Mon, 22 Oct 2012 23:46:36 -0700 (PDT) Received: by 10.66.72.35 with SMTP id a3mr32393044pav.66.1350974796111; Mon, 22 Oct 2012 23:46:36 -0700 (PDT) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id bf10si15990024pab.311.2012.10.22.23.46.35; Mon, 22 Oct 2012 23:46:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.25 as permitted sender) client-ip=203.254.224.25; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.25 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MCC00D8M2TICNT0@mailout2.samsung.com>; Tue, 23 Oct 2012 15:46:35 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 86.48.12699.A4D36805; Tue, 23 Oct 2012 15:46:35 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-41-50863d4a362e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id E5.48.12699.A4D36805; Tue, 23 Oct 2012 15:46:34 +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 <0MCC00CQ52Q0V720@mmp1.samsung.com>; Tue, 23 Oct 2012 15:46:34 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org Subject: [PATCH 3/9 V3] Sound: Add command for audio playback Date: Tue, 23 Oct 2012 12:27:23 +0530 Message-id: <1350975449-27816-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1350975449-27816-1-git-send-email-rajeshwari.s@samsung.com> References: <1350975449-27816-1-git-send-email-rajeshwari.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsWyRsSkTtfbti3AYMo3JouH62+yWEw5/IXF gcnjzrU9bAGMUVw2Kak5mWWpRfp2CVwZa25MZypokq34sfkzawPjOvEuRk4OCQETic2XV7NA 2GISF+6tZ+ti5OIQEljKKPFy127mLkYOsKITc2Ug4osYJZ41T2GFcCYySew9vx6sm03ASGLr yWmMILaIgITEr/6rYDazQIzE6/0/2EBsYQFbiV87T4LVswioSvz6MwHM5hXwkOhqPM0KcYWC xLGpX8FsTgFPibWHzrOAHCEEVLPvZClEq4DEt8mHWCBuk5XYdIAZ5BwJgdtsEgde3oJ6RlLi 4IobLBMYhRcwMqxiFE0tSC4oTkrPNdIrTswtLs1L10vOz93ECAzG0/+eSe9gXNVgcYhRgINR iYe3Y39rgBBrYllxZe4hRgkOZiUR3gartgAh3pTEyqrUovz4otKc1OJDjD5Al0xklhJNzgdG Sl5JvKGxibmpsamlkZGZqSkOYSVx3maPlAAhgfTEktTs1NSC1CKYcUwcnFINjOm+p7MbT25r f/hIukZjHfOH3F9/zh0RPZYu3NB2/TnDw++ue38uu9u7907+ockNnpbvrd0zJZm0zt8/H8kU vUTOtGnGJFergzavPk52aT6+sZpjxefgtX4W05+01mcsMVry4ueHvtolf4P2PfnNeMCv/fba 74/DUnfl7DbQcBafrL3H3OX2RWMlluKMREMt5qLiRABuOl07cwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeLIzCtJLcpLzFFi42I5/e+xgK6XbVuAwfH9xhYP199ksZhy+AuL A5PHnWt72AIYoxoYbTJSE1NSixRS85LzUzLz0m2VvIPjneNNzQwMdQ0tLcyVFPISc1NtlVx8 AnTdMnOAZisplCXmlAKFAhKLi5X07TBNCA1x07WAaYzQ9Q0JgusxMkADCWsYM9bcmM5U0CRb 8WPzZ9YGxnXiXYwcHBICJhIn5sp0MXICmWISF+6tZ+ti5OIQEljEKPGseQorhDORSWLv+fUs IFVsAkYSW09OYwSxRQQkJH71XwWzmQViJF7v/8EGYgsL2Er82nkSrJ5FQFXi158JYDavgIdE V+NpVohtChLHpn4FszkFPCXWHjrPAnKQEFDNvpOlExh5FzAyrGIUTS1ILihOSs810itOzC0u zUvXS87P3cQIDvVn0jsYVzVYHGIU4GBU4uHt2N8aIMSaWFZcmXuIUYKDWUmEt8GqLUCINyWx siq1KD++qDQntfgQow/QUROZpUST84FxmFcSb2hsYm5qbGppYmFiZolDWEmct9kjJUBIID2x JDU7NbUgtQhmHBMHp1QDo3OradSDsolrGOob7qdt03v5L1sh52e26eGPfd/M313bxl74R7h9 +6zCky+2vzAP2LbobMANUVmRdX/s/8jd9i6tjJYJ+r/j15s8jTqd3OuvA5cGpu6bNvO2Y2xl r7Ppur3btXp45aS76l6ftWY3PW3t27RHkzdEt/wb42d1gbobmdyNmp73lViKMxINtZiLihMB cgyrFqICAAA= X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQm3omY+x0A1T42N+QOEQMqk+qFABlZIwofgbm2/pYBvN8u21AtgOGN5CWG9OfwenI7oMT8u 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. 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 5442fbb..c0aa4a3 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" +);