From patchwork Tue Dec 15 23:51:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrique de Moraes Holschuh X-Patchwork-Id: 68275 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBI4ixja005715 for ; Fri, 18 Dec 2009 04:45:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932929AbZLOXve (ORCPT ); Tue, 15 Dec 2009 18:51:34 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932878AbZLOXvd (ORCPT ); Tue, 15 Dec 2009 18:51:33 -0500 Received: from out1.smtp.messagingengine.com ([66.111.4.25]:44698 "EHLO out1.smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760883AbZLOXvX (ORCPT ); Tue, 15 Dec 2009 18:51:23 -0500 Received: from compute2.internal (compute2.internal [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id E43D4C6867; Tue, 15 Dec 2009 18:51:22 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute2.internal (MEProxy); Tue, 15 Dec 2009 18:51:22 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; s=smtpout; bh=kx5ZBzT5hKIKMRVVz2IFjSdB748=; b=fTbPgskwpYGhrDvkgo5s2d5LaX2fk//k5pQ+baZ2aUpi8Zk6uDUE3E3UElVzJPVJCwMkbCsR1OUynHmjgaLy0d8T6LuKfMWRwy31+zuP9yzIDPyEQFV46avjZ5aRqfaYb/4o04l5vx9aqTSZkAb9/YICDk+VWNVcsS0nzKB79Mg= X-Sasl-enc: XPfmdqC4Vs4Yl71RHuyjkTfz3QYcp1o+HSegk7379uGD 1260921082 Received: from khazad-dum.debian.net (unknown [201.82.165.62]) by mail.messagingengine.com (Postfix) with ESMTPSA id 543E34AF8F2; Tue, 15 Dec 2009 18:51:22 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by localhost.khazad-dum.debian.net (Postfix) with ESMTP id 938B72805F; Tue, 15 Dec 2009 21:51:20 -0200 (BRST) X-Virus-Scanned: Debian amavisd-new at khazad-dum.debian.net Received: from khazad-dum.debian.net ([127.0.0.1]) by localhost (khazad-dum.debian.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id hGxN2oZ1bQsR; Tue, 15 Dec 2009 21:51:17 -0200 (BRST) Received: by khazad-dum.debian.net (Postfix, from userid 1000) id 63F8E2823E; Tue, 15 Dec 2009 21:51:16 -0200 (BRST) From: Henrique de Moraes Holschuh To: Len Brown Cc: linux-acpi@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net, Henrique de Moraes Holschuh , Lorne Applebaum , Matthew Garrett Subject: [PATCH 5/8] thinkpad-acpi: disable volume control Date: Tue, 15 Dec 2009 21:51:10 -0200 Message-Id: <1260921073-7686-6-git-send-email-hmh@hmh.eng.br> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: <1260921073-7686-1-git-send-email-hmh@hmh.eng.br> References: <1260921073-7686-1-git-send-email-hmh@hmh.eng.br> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt index bd87682..6a58143 100644 --- a/Documentation/laptops/thinkpad-acpi.txt +++ b/Documentation/laptops/thinkpad-acpi.txt @@ -1097,6 +1097,18 @@ Volume control procfs: /proc/acpi/ibm/volume +NOTE: by default, the volume control interface operates in read-only +mode, as it is supposed to be used for on-screen-display purposes. +The read/write mode can be enabled through the use of the +"volume_control=1" module parameter. + +NOTE: distros are urged to not enable volume_control by default, this +should be done by the local admin only. The ThinkPad UI is for the +console audio control to be done through the volume keys only, and for +the desktop environment to just provide on-screen-display feedback. +Software volume control should be done only in the main AC97/HDA +mixer. + This feature allows volume control on ThinkPad models with a digital volume knob (when available, not all models have it), as well as mute/unmute control. The available commands are: @@ -1465,3 +1477,4 @@ Sysfs interface changelog: 0x020600: Marker for backlight change event support. 0x020700: Support for mute-only mixers. + Volume control in read-only mode by default. diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 4d909d5..2d74926 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -311,6 +311,7 @@ static struct { static struct { u16 hotkey_mask_ff:1; + u16 volume_ctrl_forbidden:1; } tp_warned; struct thinkpad_id_data { @@ -6434,6 +6435,7 @@ static enum tpacpi_volume_access_mode volume_mode = TPACPI_VOL_MODE_MAX; static enum tpacpi_volume_capabilities volume_capabilities; +static int volume_control_allowed; /* * Used to syncronize writers to TP_EC_AUDIO and @@ -6449,6 +6451,8 @@ static void tpacpi_volume_checkpoint_nvram(void) if (volume_mode != TPACPI_VOL_MODE_ECNVRAM) return; + if (!volume_control_allowed) + return; vdbg_printk(TPACPI_DBG_MIXER, "trying to checkpoint mixer state to NVRAM...\n"); @@ -6691,6 +6695,12 @@ static int __init volume_init(struct ibm_init_struct *iibm) "mute is supported, volume control is %s\n", str_supported(!tp_features.mixer_no_level_control)); + printk(TPACPI_INFO + "Console audio control enabled, mode: %s\n", + (volume_control_allowed) ? + "override (read/write)" : + "monitor (read only)"); + return 0; } @@ -6711,11 +6721,16 @@ static int volume_read(char *p) len += sprintf(p + len, "mute:\t\t%s\n", onoff(status, TP_EC_AUDIO_MUTESW)); - len += sprintf(p + len, "commands:\tunmute, mute\n"); - if (!tp_features.mixer_no_level_control) { - len += sprintf(p + len, "commands:\tup, down\n"); - len += sprintf(p + len, "commands:\tlevel " - " ( is 0-%d)\n", TP_EC_VOLUME_MAX); + if (volume_control_allowed) { + len += sprintf(p + len, "commands:\tunmute, mute\n"); + if (!tp_features.mixer_no_level_control) { + len += sprintf(p + len, + "commands:\tup, down\n"); + len += sprintf(p + len, + "commands:\tlevel " + " ( is 0-%d)\n", + TP_EC_VOLUME_MAX); + } } } @@ -6730,6 +6745,23 @@ static int volume_write(char *buf) char *cmd; int rc; + /* + * We do allow volume control at driver startup, so that the + * user can set initial state through the volume=... parameter hack. + */ + if (!volume_control_allowed && tpacpi_lifecycle != TPACPI_LIFE_INIT) { + if (unlikely(!tp_warned.volume_ctrl_forbidden)) { + tp_warned.volume_ctrl_forbidden = 1; + printk(TPACPI_NOTICE + "Console audio control in monitor mode, " + "changes are not allowed.\n"); + printk(TPACPI_NOTICE + "Use the volume_control=1 module parameter " + "to enable volume control\n"); + } + return -EPERM; + } + rc = volume_get_status(&s); if (rc < 0) return rc; @@ -8515,6 +8547,11 @@ MODULE_PARM_DESC(volume_capabilities, "Selects the mixer capabilites: " "0=auto, 1=volume and mute, 2=mute only"); +module_param_named(volume_control, volume_control_allowed, bool, 0444); +MODULE_PARM_DESC(volume_control, + "Enables software override for the console audio " + "control when true"); + #define TPACPI_PARAM(feature) \ module_param_call(feature, set_ibm_param, NULL, NULL, 0); \ MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command " \