summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/panasonic-laptop.c
diff options
context:
space:
mode:
authorKenneth Chan <kenneth.t.chan@gmail.com>2020-08-21 21:14:30 +0300
committerHans de Goede <hdegoede@redhat.com>2020-11-10 16:49:49 +0300
commite3a9afbbc309c51421d9beb3390ba42522fa6afe (patch)
treefe7fe80c616482bef473c4082e994b57ce960080 /drivers/platform/x86/panasonic-laptop.c
parent008563513348a5ab0324fb8976172fe56c939450 (diff)
downloadlinux-e3a9afbbc309c51421d9beb3390ba42522fa6afe.tar.xz
platform/x86: panasonic-laptop: Add write support to mute
Add write support to the mute platform device Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com> Link: https://lore.kernel.org/r/20200821181433.17653-7-kenneth.t.chan@gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform/x86/panasonic-laptop.c')
-rw-r--r--drivers/platform/x86/panasonic-laptop.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index c77292588a8a..3b0294ee9d3e 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -13,6 +13,7 @@
*
* ChangeLog:
* Aug.18, 2020 Kenneth Chan <kenneth.t.chan@gmail.com>
+ * add write support to mute
* fix sticky_key init bug
* fix naming of platform files for consistency with other
* modules
@@ -220,6 +221,7 @@ struct pcc_acpi {
acpi_handle handle;
unsigned long num_sifr;
int sticky_key;
+ int mute;
u32 *sinf;
struct acpi_device *device;
struct input_dev *input_dev;
@@ -483,6 +485,24 @@ static ssize_t mute_show(struct device *dev, struct device_attribute *attr,
return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_MUTE]);
}
+static ssize_t mute_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct acpi_device *acpi = to_acpi_device(dev);
+ struct pcc_acpi *pcc = acpi_driver_data(acpi);
+ int err, val;
+
+ err = kstrtoint(buf, 0, &val);
+ if (err)
+ return err;
+ if (val == 0 || val == 1) {
+ acpi_pcc_write_sset(pcc, SINF_MUTE, val);
+ pcc->mute = val;
+ }
+
+ return count;
+}
+
static ssize_t sticky_key_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -533,7 +553,7 @@ static ssize_t cdpower_store(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR_RO(numbatt);
static DEVICE_ATTR_RO(lcdtype);
-static DEVICE_ATTR_RO(mute);
+static DEVICE_ATTR_RW(mute);
static DEVICE_ATTR_RW(sticky_key);
static DEVICE_ATTR_RW(cdpower);
@@ -690,6 +710,7 @@ static int acpi_pcc_hotkey_resume(struct device *dev)
if (!pcc)
return -EINVAL;
+ acpi_pcc_write_sset(pcc, SINF_MUTE, pcc->mute);
acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, pcc->sticky_key);
return 0;
@@ -760,6 +781,8 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, 0);
pcc->sticky_key = 0;
+ pcc->mute = pcc->sinf[SINF_MUTE];
+
/* add sysfs attributes */
result = sysfs_create_group(&device->dev.kobj, &pcc_attr_group);
if (result)