Skip to content

Commit

Permalink
platform/x86: panasonic-laptop: Add write support to mute
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kenneth Chan authored and Hans de Goede committed Nov 10, 2020
1 parent 0085635 commit e3a9afb
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion drivers/platform/x86/panasonic-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e3a9afb

Please sign in to comment.