From patchwork Tue Nov 8 08:11:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 9416923 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6533E60585 for ; Tue, 8 Nov 2016 09:00:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53F0B28AE1 for ; Tue, 8 Nov 2016 09:00:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4557128C8B; Tue, 8 Nov 2016 09:00:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DB2A28AE1 for ; Tue, 8 Nov 2016 09:00:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A72DC266F18; Tue, 8 Nov 2016 10:00:11 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2D176266F0E; Tue, 8 Nov 2016 09:57:53 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C4DE0266EFF; Tue, 8 Nov 2016 09:13:21 +0100 (CET) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by alsa0.perex.cz (Postfix) with ESMTP id C3933266EFD for ; Tue, 8 Nov 2016 09:13:13 +0100 (CET) Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id uA88AvEC022136; Tue, 8 Nov 2016 09:13:13 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 26h5e9s6tw-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 08 Nov 2016 09:13:13 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9364231; Tue, 8 Nov 2016 08:13:12 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 79173256F; Tue, 8 Nov 2016 08:13:12 +0000 (GMT) Received: from localhost (10.201.23.162) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 8 Nov 2016 09:13:12 +0100 From: Arnaud Pouliquen To: Takashi Sakamoto , , Charles Keepax , Vinod Koul Date: Tue, 8 Nov 2016 09:11:15 +0100 Message-ID: <1478592675-23092-5-git-send-email-arnaud.pouliquen@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1478592675-23092-1-git-send-email-arnaud.pouliquen@st.com> References: <1478592675-23092-1-git-send-email-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.162] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-08_03:, , signatures=0 Cc: Takashi Iwai , broonie@kernel.org, lgirdwood@gmail.com Subject: [alsa-devel] [RFC 4/4 ] iecset: allow to select control with device and sub-device numbers. X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP ASoc implementation force the index to 0. In case of multi devices that export the iec control, we need device and subdevice fields to differentiate and address the different controls. This patch extends "-D" option to be able to address control using PCM device/sub-device id. Signed-off-by: Arnaud Pouliquen --- iecset/iecset.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/iecset/iecset.c b/iecset/iecset.c index 92a93e8..8d7a800 100644 --- a/iecset/iecset.c +++ b/iecset/iecset.c @@ -89,6 +89,8 @@ static void usage(void) printf("Usage: iecset [options] [cmd arg...]\n"); printf("Options:\n"); printf(" -D device specifies the control device to use\n"); + printf(" for \"-Dhw:X,Y,Z\" Only control device X is mandatory\n"); + printf(" the device(Y) and subdevice(Z) are optinal (default = 0)\n"); printf(" -c card specifies the card number to use (equiv. with -Dhw:#)\n"); printf(" -n number specifies the control index number (default = 0)\n"); printf(" -x dump the dump the AESx hex code for IEC958 PCM parameters\n"); @@ -99,6 +101,15 @@ static void usage(void) } } +static int parse_device(char *parms, int *ctl_dev, int *dev, int *sdev) +{ + + if (strncmp(parms, "hw", 2)) + return 1; + sscanf(parms,"hw:%d,%d,%d",ctl_dev, dev, sdev); + + return 0; +} /* * parse iecset commands @@ -312,6 +323,7 @@ int main(int argc, char **argv) const char *dev = "default"; const char *spdif_str = SND_CTL_NAME_IEC958("", PLAYBACK, DEFAULT); int spdif_index = -1; + int cdev, spdif_dev = -1, spdif_sdev = -1; snd_ctl_t *ctl; snd_ctl_elem_list_t *clist; snd_ctl_elem_id_t *cid; @@ -330,7 +342,11 @@ int main(int argc, char **argv) while ((c = getopt(argc, argv, "D:c:n:xhi")) != -1) { switch (c) { case 'D': - dev = optarg; + if (parse_device(optarg, &cdev, &spdif_dev, &spdif_sdev)) + dev = optarg; + else + sprintf(tmpname, "hw:%d", cdev); + dev = tmpname; break; case 'c': i = atoi(optarg); @@ -376,15 +392,19 @@ int main(int argc, char **argv) } controls = snd_ctl_elem_list_get_used(clist); - for (cidx = 0; cidx < controls; cidx++) { - if (!strcmp(snd_ctl_elem_list_get_name(clist, cidx), spdif_str)) - if (spdif_index < 0 || - snd_ctl_elem_list_get_index(clist, cidx) == spdif_index) + for (cidx = 0; cidx < controls; cidx++) + if (!strcmp(snd_ctl_elem_list_get_name(clist, cidx), spdif_str)) { + if ((spdif_index < 0 || + snd_ctl_elem_list_get_index(clist, cidx) == spdif_index) && + (spdif_dev < 0 || + snd_ctl_elem_list_get_device(clist, cidx) == spdif_dev) && + (spdif_sdev < 0 || + snd_ctl_elem_list_get_subdevice(clist, cidx) == spdif_sdev)) break; } if (cidx >= controls) { - fprintf(stderr, "control \"%s\" (index %d) not found\n", - spdif_str, spdif_index); + fprintf(stderr, "control \"%s\" (index %d, device %d, subdevice %d) not found\n", + spdif_str, spdif_index, spdif_dev, spdif_sdev); return 1; }