From patchwork Wed Sep 23 02:40:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Yau X-Patchwork-Id: 7247031 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3CBB8BEEC1 for ; Wed, 23 Sep 2015 02:41:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5307020595 for ; Wed, 23 Sep 2015 02:41:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id EF2E32046F for ; Wed, 23 Sep 2015 02:41:06 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 371B42651B4; Wed, 23 Sep 2015 04:40:59 +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=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 0AF7F265158; Wed, 23 Sep 2015 04:40:56 +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 3AED5265132; Wed, 23 Sep 2015 04:40:54 +0200 (CEST) Received: from mail-ob0-f169.google.com (mail-ob0-f169.google.com [209.85.214.169]) by alsa0.perex.cz (Postfix) with ESMTP id 36CE7265132 for ; Wed, 23 Sep 2015 04:40:47 +0200 (CEST) Received: by obbbh8 with SMTP id bh8so23274051obb.0 for ; Tue, 22 Sep 2015 19:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=MREQcxOQv+G9UZGGcAuupipvYfy4pI69GCKJzSV+Xfg=; b=b+vnjQ7/x218vz6x0X88LITWIGbAm2HwwnDOw18OP7sc+eFomMsA84HjomMjmwe0N5 092lOcRg1Kcw6sQWRpiSkzBhPMbN0C+s7BDH/AiaviNPju5CZwBQmqdpCUGBuqe1vg5U +ZPZYnzuT0y7UaqXBcGZElNdWSzu4P2jWOxWF2MS4+TdKk3o0HMIF33TTkf03jLY/KKx YDY0nxcSrfUTgVRlxf09CyLed7PmkOxDRJpxxeQ3s2ABQwggz0YbFsF+HDhqa+dJ1PHr yhag51aWOtcgPw5f93NyIme0f9ztfE2ozSTmh9nEbJXdp8Vz/KibCYafjPQKxeuwl0rf 45Kw== MIME-Version: 1.0 X-Received: by 10.60.99.7 with SMTP id em7mr17164133oeb.63.1442976045911; Tue, 22 Sep 2015 19:40:45 -0700 (PDT) Received: by 10.202.209.22 with HTTP; Tue, 22 Sep 2015 19:40:45 -0700 (PDT) Date: Wed, 23 Sep 2015 10:40:45 +0800 Message-ID: From: Raymond Yau To: ALSA Development Mailing List , tiwai@suse.de, arthurborsboom@gmail.com X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Subject: [alsa-devel] [PATCH v2- ALSA 1/3] HDA - Allow hda_jack_tbl to use another nid for pin sense 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 - add sense_nid to __snd_hda_jack_add_kctl for pin sense - update slave pin sense when master pin sense change - enable unsolicited event when widcap support UNSOL Signed-off-by: Raymond Yau diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index 366efbf..d81d65f 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -19,6 +19,7 @@ #include "hda_local.h" #include "hda_auto_parser.h" #include "hda_jack.h" +#include "hda_generic.h" /** * is_jack_detectable - Check whether the given pin is jack-detectable @@ -157,7 +158,14 @@ static void jack_detect_update(struct hda_codec *codec, if (jack->phantom_jack) jack->pin_sense = AC_PINSENSE_PRESENCE; else - jack->pin_sense = read_pin_sense(codec, jack->nid); + jack->pin_sense = read_pin_sense(codec, + jack->sense_nid ? jack->sense_nid : jack->nid); + + if (jack->slave_nid) { + struct hda_jack_tbl *slave = snd_hda_jack_tbl_get(codec, + jack->slave_nid); + slave->pin_sense = jack->pin_sense; + } /* A gating jack indicates the jack is invalid if gating is unplugged */ if (jack->gating_jack && !snd_hda_jack_detect(codec, jack->gating_jack)) @@ -269,11 +277,13 @@ snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid, jack->jack_detect = 1; if (codec->jackpoll_interval > 0) return callback; /* No unsol if we're polling instead */ - err = snd_hda_codec_write_cache(codec, nid, 0, + if (is_jack_detectable(codec, nid)) { + err = snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | jack->tag); - if (err < 0) - return ERR_PTR(err); + if (err < 0) + return ERR_PTR(err); + } return callback; } EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable_callback); @@ -384,7 +394,7 @@ static void hda_free_jack_priv(struct snd_jack *jack) * will have the given name and index. */ static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, - const char *name, bool phantom_jack) + const char *name, bool phantom_jack, hda_nid_t sense_nid) { struct hda_jack_tbl *jack; int err, state, type; @@ -403,6 +413,7 @@ static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, jack->phantom_jack = !!phantom_jack; jack->type = type; + jack->sense_nid = sense_nid; jack->jack->private_data = jack; jack->jack->private_free = hda_free_jack_priv; state = snd_hda_jack_detect(codec, nid); @@ -422,7 +433,7 @@ static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, const char *name) { - return __snd_hda_jack_add_kctl(codec, nid, name, false); + return __snd_hda_jack_add_kctl(codec, nid, name, false, nid); } EXPORT_SYMBOL_GPL(snd_hda_jack_add_kctl); @@ -451,7 +462,7 @@ static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid, if (phantom_jack) /* Example final name: "Internal Mic Phantom Jack" */ strncat(name, " Phantom", sizeof(name) - strlen(name) - 1); - err = __snd_hda_jack_add_kctl(codec, nid, name, phantom_jack); + err = __snd_hda_jack_add_kctl(codec, nid, name, phantom_jack, nid); if (err < 0) return err; diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h index 387d309..ef3d162 100644 --- a/sound/pci/hda/hda_jack.h +++ b/sound/pci/hda/hda_jack.h @@ -41,6 +41,8 @@ struct hda_jack_tbl { hda_nid_t gated_jack; /* gated is dependent on this jack */ int type; struct snd_jack *jack; + hda_nid_t sense_nid; + hda_nid_t slave_nid; }; struct hda_jack_tbl *