Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4453779ybz; Tue, 28 Apr 2020 11:33:45 -0700 (PDT) X-Google-Smtp-Source: APiQypKIJhizZvIkMgzNkfGuviLtiPmT5KAsuTxcqV2AaZhruz/KXncQw3dESw1+qy0EhU/Cp9Vs X-Received: by 2002:a17:906:af94:: with SMTP id mj20mr25045589ejb.347.1588098824989; Tue, 28 Apr 2020 11:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588098824; cv=none; d=google.com; s=arc-20160816; b=E5FqNxXRMnLsCFq34T/v3O2OfHhvu0L4uQkH2RGSjv4dTh1zF99t0blNviRCSYQ0h/ hldq2Wy1Dc+HWTi2gTL7ClVZyrScxcM36uWH4vVV1dSXh9yh0JakTdYO8qcqf+nuHHd9 /al2eQnIjzWETiJ5sLNPeyYI+UM4JyKb6H668q8BwOmPhGNvv1tAVkpImfzn1Oauihmb YVlPX0LC6/OaQZ1uLBfec0IVf0eWB05ELYP5jf34s6PxY9QzIn8OlIPKZHyHFY5NQuq1 50exl7a1Mj1v88nSX0qnMH0p4aAxiClacWomW2xVpodAHveq3l+tAq0OtJr+HGFDWEXb fRWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1GU2fw0K+8vVJqfOtj0ygwFdUEZ+GL+aRp71me3sov0=; b=bk7XTHhm8Gq97DcQMAZ1YmnxOYn/qfmDZFowuJFViSakphMEzBVFQm26ShkG8/kf+a WrjyNZ1adUBnRml3swYTFTHR+xNRdXs3HE55UXChudf8KMDJxOgULqQCoYrPtUoUqreK OrZNJdoSlPSGO1yPqjV37MLQ03xYMij9sVQhrIne7/NPQxJV5Qkzixiqa9VjxLZl4oF6 ewgi16uBq/JaVb06Ds2Oa20nwxWij7l4pvX6dEvDDhyrCu9n75SSCV6NlPlBr9nXkLn8 cZMMkfSAl6F/n2+aTBupOszEuvsvZce5TyjwqBRZnlkQmVP0FP4skID0/wHg6m54n3w0 jxDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zXhLYJtC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si2328507ejt.165.2020.04.28.11.33.21; Tue, 28 Apr 2020 11:33:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zXhLYJtC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729565AbgD1Sav (ORCPT + 99 others); Tue, 28 Apr 2020 14:30:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:45878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729535AbgD1Saq (ORCPT ); Tue, 28 Apr 2020 14:30:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 18C2A20B80; Tue, 28 Apr 2020 18:30:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588098646; bh=CBhCMpziAppXItF9FpbPkmAKYIWo0j2lUiz36AW80zc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zXhLYJtCIzBdiyFAs8E3SuJxBH8CMogS+FkstXxXJOonUTUWJ6tocEhzsFsq5BNlj g/IKzwd0nKcGU2ybYCk30bMEfL+ndMUpJT4fpaxIXn1MeYF9TiE78sUUMl6ROV4rdE BoMtSfEAWpqXWQt7BTJeT9lv7tpoSXdHZtbmXStI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Sasha Levin Subject: [PATCH 5.6 078/167] ALSA: usb-audio: Add connector notifier delegation Date: Tue, 28 Apr 2020 20:24:14 +0200 Message-Id: <20200428182234.826106188@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182225.451225420@linuxfoundation.org> References: <20200428182225.451225420@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai [ Upstream commit fef66ae73a611e84c8b4b74ff6f805ec5f113477 ] It turned out that ALC1220-VB USB-audio device gives the interrupt event to some PCM terminals while those don't allow the connector state request but only the actual I/O terminals return the request. The recent commit 7dc3c5a0172e ("ALSA: usb-audio: Don't create jack controls for PCM terminals") excluded those phantom terminals, so those events are ignored, too. My first thought was that this could be easily deduced from the associated terminals, but some of them have even no associate terminal ID, hence it's not too trivial to figure out. Since the number of such terminals are small and limited, this patch implements another quirk table for the simple mapping of the connectors. It's not really scalable, but let's hope that there will be not many such funky devices in future. Fixes: 7dc3c5a0172e ("ALSA: usb-audio: Don't create jack controls for PCM terminals") BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206873 Link: https://lore.kernel.org/r/20200422113320.26664-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/usb/mixer.c | 25 +++++++++++++++++++++++++ sound/usb/mixer.h | 10 ++++++++++ sound/usb/mixer_maps.c | 13 +++++++++++++ 3 files changed, 48 insertions(+) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 05f64fe0b0bbe..7a2961ad60de0 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -3096,6 +3096,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) if (map->id == state.chip->usb_id) { state.map = map->map; state.selector_map = map->selector_map; + mixer->connector_map = map->connector_map; mixer->ignore_ctl_error |= map->ignore_ctl_error; break; } @@ -3177,10 +3178,32 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) return 0; } +static int delegate_notify(struct usb_mixer_interface *mixer, int unitid, + u8 *control, u8 *channel) +{ + const struct usbmix_connector_map *map = mixer->connector_map; + + if (!map) + return unitid; + + for (; map->id; map++) { + if (map->id == unitid) { + if (control && map->control) + *control = map->control; + if (channel && map->channel) + *channel = map->channel; + return map->delegated_id; + } + } + return unitid; +} + void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid) { struct usb_mixer_elem_list *list; + unitid = delegate_notify(mixer, unitid, NULL, NULL); + for_each_mixer_elem(list, mixer, unitid) { struct usb_mixer_elem_info *info = mixer_elem_list_to_info(list); @@ -3250,6 +3273,8 @@ static void snd_usb_mixer_interrupt_v2(struct usb_mixer_interface *mixer, return; } + unitid = delegate_notify(mixer, unitid, &control, &channel); + for_each_mixer_elem(list, mixer, unitid) count++; diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h index 65d6d08c96f53..41ec9dc4139bb 100644 --- a/sound/usb/mixer.h +++ b/sound/usb/mixer.h @@ -6,6 +6,13 @@ struct media_mixer_ctl; +struct usbmix_connector_map { + u8 id; + u8 delegated_id; + u8 control; + u8 channel; +}; + struct usb_mixer_interface { struct snd_usb_audio *chip; struct usb_host_interface *hostif; @@ -18,6 +25,9 @@ struct usb_mixer_interface { /* the usb audio specification version this interface complies to */ int protocol; + /* optional connector delegation map */ + const struct usbmix_connector_map *connector_map; + /* Sound Blaster remote control stuff */ const struct rc_config *rc_cfg; u32 rc_code; diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c index fb2c4a992951b..0260c750e1569 100644 --- a/sound/usb/mixer_maps.c +++ b/sound/usb/mixer_maps.c @@ -27,6 +27,7 @@ struct usbmix_ctl_map { u32 id; const struct usbmix_name_map *map; const struct usbmix_selector_map *selector_map; + const struct usbmix_connector_map *connector_map; int ignore_ctl_error; }; @@ -387,6 +388,15 @@ static const struct usbmix_name_map trx40_mobo_map[] = { {} }; +static const struct usbmix_connector_map trx40_mobo_connector_map[] = { + { 10, 16 }, /* (Back) Speaker */ + { 11, 17 }, /* Front Headphone */ + { 13, 7 }, /* Line */ + { 14, 8 }, /* Mic */ + { 15, 9 }, /* Front Mic */ + {} +}; + /* * Control map entries */ @@ -519,6 +529,7 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = { { /* Gigabyte TRX40 Aorus Pro WiFi */ .id = USB_ID(0x0414, 0xa002), .map = trx40_mobo_map, + .connector_map = trx40_mobo_connector_map, }, { /* ASUS ROG Zenith II */ .id = USB_ID(0x0b05, 0x1916), @@ -531,10 +542,12 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = { { /* MSI TRX40 Creator */ .id = USB_ID(0x0db0, 0x0d64), .map = trx40_mobo_map, + .connector_map = trx40_mobo_connector_map, }, { /* MSI TRX40 */ .id = USB_ID(0x0db0, 0x543d), .map = trx40_mobo_map, + .connector_map = trx40_mobo_connector_map, }, { 0 } /* terminator */ }; -- 2.20.1