From patchwork Mon Jun 29 17:53:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Patrakov X-Patchwork-Id: 6690741 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B22759F1C1 for ; Mon, 29 Jun 2015 17:54:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1EDC20268 for ; Mon, 29 Jun 2015 17:54:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7CD9F20265 for ; Mon, 29 Jun 2015 17:54:26 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4A3722656FC; Mon, 29 Jun 2015 19:54:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 15517265529; Mon, 29 Jun 2015 19:54:17 +0200 (CEST) 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 D96C2265546; Mon, 29 Jun 2015 19:54:15 +0200 (CEST) Received: from mail-wg0-f54.google.com (mail-wg0-f54.google.com [74.125.82.54]) by alsa0.perex.cz (Postfix) with ESMTP id C803A2654CD for ; Mon, 29 Jun 2015 19:54:08 +0200 (CEST) Received: by wguu7 with SMTP id u7so147716077wgu.3 for ; Mon, 29 Jun 2015 10:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=fR+BSMHygB0W2neLlaxcFMBZ0H6/FAxZiht045BKO/4=; b=wKynIl2IB9c8+yX4iOKrtOt4FPXNx2g3V3xzApyiJ+O6w7S2/sZ1mSuw20zzCO5JFy ZJr5hfvQtmLA+tbVSjhm8V2y6KIdDavgPb+9EGehumSCkVFPEv+0Vn/N42Xbc69fnmqa rE4mH5QX9OJ8W3RCZhDBQIKnz+Oio8ydqX+GlWUZbvTTqJruxuVASkhlgFeLsu1zzJS+ JxntcHXQOunZ1a9q2lDuZb9UyEmvsf1+90Ui4VTLXZm4KGEaxXs0iycrKvXBDGY/v+F0 htzwLUNU7FRyxzeCaD7QM6PVDyxJJaUVPtTnXM0dFY+kFFEgIiinD3NwDPXEZqr1/PCq odMw== X-Received: by 10.180.210.234 with SMTP id mx10mr25126596wic.42.1435600448575; Mon, 29 Jun 2015 10:54:08 -0700 (PDT) Received: from localhost.localdomain (93-94-247-5.static.monzoon.net. [93.94.247.5]) by mx.google.com with ESMTPSA id ma15sm13215150wic.20.2015.06.29.10.54.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Jun 2015 10:54:07 -0700 (PDT) From: "Alexander E. Patrakov" To: alsa-devel@alsa-project.org Date: Mon, 29 Jun 2015 22:53:53 +0500 Message-Id: <1435600433-15873-1-git-send-email-patrakov@gmail.com> X-Mailer: git-send-email 2.4.4 Cc: tiwai@suse.de, "Alexander E. Patrakov" Subject: [alsa-devel] [PATCH lib v2] Replace unsafe characters with _ in card name 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Otherwise, they get misinterpreted as argument separators in USB-Audio PCM definitions, and thus prevent SPDIF blacklist entries from working. While at it, add my Logitec C910 webcam to the SPDIF blacklist. Signed-off-by: Alexander E. Patrakov --- v2: Fixed misplaced NULL check for tmp->u.string include/conf.h | 1 + src/conf.c | 32 ++++++++++++++++++++++++++++++++ src/conf/cards/USB-Audio.conf | 3 ++- src/confmisc.c | 2 +- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/conf.h b/include/conf.h index ff270f6..087c05d 100644 --- a/include/conf.h +++ b/include/conf.h @@ -126,6 +126,7 @@ int snd_config_imake_integer(snd_config_t **config, const char *key, const long int snd_config_imake_integer64(snd_config_t **config, const char *key, const long long value); int snd_config_imake_real(snd_config_t **config, const char *key, const double value); int snd_config_imake_string(snd_config_t **config, const char *key, const char *ascii); +int snd_config_imake_safe_string(snd_config_t **config, const char *key, const char *ascii); int snd_config_imake_pointer(snd_config_t **config, const char *key, const void *ptr); snd_config_type_t snd_config_get_type(const snd_config_t *config); diff --git a/src/conf.c b/src/conf.c index bb256e7..c6a83ee 100644 --- a/src/conf.c +++ b/src/conf.c @@ -2228,6 +2228,38 @@ int snd_config_imake_string(snd_config_t **config, const char *id, const char *v return 0; } +int snd_config_imake_safe_string(snd_config_t **config, const char *id, const char *value) +{ + int err; + snd_config_t *tmp; + char *c; + + err = snd_config_make(&tmp, id, SND_CONFIG_TYPE_STRING); + if (err < 0) + return err; + if (value) { + tmp->u.string = strdup(value); + if (!tmp->u.string) { + snd_config_delete(tmp); + return -ENOMEM; + } + + for (c = tmp->u.string; *c; c++) { + if (*c == ' ' || *c == '-' || *c == '_' || + (*c >= '0' && *c <= '9') || + (*c >= 'a' && *c <= 'z') || + (*c >= 'A' && *c <= 'Z')) + continue; + *c = '_'; + } + } else { + tmp->u.string = NULL; + } + *config = tmp; + return 0; +} + + /** * \brief Creates a pointer configuration node with the given initial value. * \param[out] config The function puts the handle to the new node at diff --git a/src/conf/cards/USB-Audio.conf b/src/conf/cards/USB-Audio.conf index 031bee0..e365f29 100644 --- a/src/conf/cards/USB-Audio.conf +++ b/src/conf/cards/USB-Audio.conf @@ -57,7 +57,8 @@ USB-Audio.pcm.iec958_device { "Scarlett 2i4 USB" 999 "Sennheiser USB headset" 999 "SWTOR Gaming Headset by Razer" 999 - "USB Device 0x46d:0x992" 999 + "USB Device 0x46d_0x821" 999 + "USB Device 0x46d_0x992" 999 } # Second iec958 device number, if any. diff --git a/src/confmisc.c b/src/confmisc.c index 1fb4f28..ae0275f 100644 --- a/src/confmisc.c +++ b/src/confmisc.c @@ -935,7 +935,7 @@ int snd_func_card_name(snd_config_t **dst, snd_config_t *root, } err = snd_config_get_id(src, &id); if (err >= 0) - err = snd_config_imake_string(dst, id, + err = snd_config_imake_safe_string(dst, id, snd_ctl_card_info_get_name(info)); __error: if (ctl)