From patchwork Mon May 3 20:03:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 96548 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o43JxEG4025550 for ; Mon, 3 May 2010 19:59:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756529Ab0ECT7z (ORCPT ); Mon, 3 May 2010 15:59:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35335 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756254Ab0ECT7y (ORCPT ); Mon, 3 May 2010 15:59:54 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o43Jxk27012646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 3 May 2010 15:59:46 -0400 Received: from cavan.codon.org.uk (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o43JxiMO014411 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Mon, 3 May 2010 15:59:45 -0400 Received: from lan-nat-pool-bos.redhat.com ([66.187.234.200] helo=localhost.localdomain) by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1O91np-0004Pj-7q; Mon, 03 May 2010 20:59:41 +0100 From: Matthew Garrett To: linux-acpi@vger.kernel.org Cc: ibm-acpi@hmh.eng.br, ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, Matthew Garrett Subject: [PATCH 2/2] thinkpad_acpi: Hook volume events Date: Mon, 3 May 2010 16:03:00 -0400 Message-Id: <1272916980-11835-2-git-send-email-mjg@redhat.com> In-Reply-To: <1272916980-11835-1-git-send-email-mjg@redhat.com> References: <1272916980-11835-1-git-send-email-mjg@redhat.com> X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 66.187.234.200 X-SA-Exim-Mail-From: mjg@redhat.com X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 03 May 2010 19:59:56 +0000 (UTC) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 63290b3..c8c4f2b 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3083,6 +3083,15 @@ static const struct tpacpi_quirk tpacpi_hotkey_qtable[] __initconst = { TPACPI_Q_IBM('1', 'D', TPACPI_HK_Q_INIMASK), /* X22, X23, X24 */ }; +static void volume_alsa_notify_change(void); +static int volume_check_status(void); + +static void cmos_notifier(void *context) +{ + if (volume_check_status()) + volume_alsa_notify_change(); +} + static int __init hotkey_init(struct ibm_init_struct *iibm) { /* Requirements for changing the default keymaps: @@ -4939,11 +4948,16 @@ static int __init cmos_init(struct ibm_init_struct *iibm) if (res) return res; + if (cmos_handle) + acpi_install_method_handler(cmos_handle, cmos_notifier, + iibm->data); + return (cmos_handle)? 0 : 1; } static void cmos_exit(void) { + acpi_remove_method_handler(cmos_handle, cmos_notifier); device_remove_file(&tpacpi_pdev->dev, &dev_attr_cmos_command); } @@ -6458,6 +6472,7 @@ static enum tpacpi_volume_access_mode volume_mode = static enum tpacpi_volume_capabilities volume_capabilities; static int volume_control_allowed; +static u8 volume_state; /* * Used to syncronize writers to TP_EC_AUDIO and @@ -6544,6 +6559,21 @@ static int volume_set_status(const u8 status) return volume_set_status_ec(status); } +static int volume_check_status() +{ + u8 new_state; + int ret = 0; + + volume_get_status(&new_state); + + if (new_state != volume_state) { + ret = 1; + volume_state = new_state; + } + + return ret; +} + /* returns < 0 on error, 0 on no change, 1 on change */ static int __volume_set_mute_ec(const bool mute) { @@ -6931,6 +6961,8 @@ static int __init volume_init(struct ibm_init_struct *iibm) return rc; } + volume_get_status(&volume_state); + printk(TPACPI_INFO "Console audio control enabled, mode: %s\n", (volume_control_allowed) ?