Lines Matching +full:merge +full:- +full:mute
1 // SPDX-License-Identifier: GPL-2.0-only
4 * (C) 2004 Hiroshi Miura <miura@da-cha.org>
8 * (C) 2006-2008 Harald Welte <laforge@gnumonks.org>
10 * derived from toshiba_acpi.c, Copyright (C) 2002-2004 John Belmonte
12 *---------------------------------------------------------------------------
16 * -v0.98 add platform devices for firmware brightness registers
19 * add write support to mute
25 * -v0.97 add support for cdpower hardware switch
26 * -v0.96 merge Lucina's enhancement
28 * - add support for optical driver power in
32 * -v0.95 rename driver from drivers/acpi/pcc_acpi.c to
33 * drivers/misc/panasonic-laptop.c
36 * -v0.94 replace /proc interface with device attributes
40 * -v0.92 merge with 2.6.26-rc6 input API changes
48 * -v0.91 merge with 2.6.24-rc6 ACPI changes
50 * Nov.04, 2006 Hiroshi Miura <miura@da-cha.org>
51 * -v0.9 remove warning about section reference.
54 * merge dbronaugh's enhancement
56 * - Added screen brightness setting interface
60 * May.29, 2006 Hiroshi Miura <miura@da-cha.org>
61 * -v0.8.4 follow to change keyinput structure
62 * thanks Fabian Yamaguchi <fabs@cs.tu-berlin.de>,
66 * Oct.02, 2004 Hiroshi Miura <miura@da-cha.org>
67 * -v0.8.2 merge code of YOKOTA Hiroshi
72 * Sep.15, 2004 Hiroshi Miura <miura@da-cha.org>
73 * -v0.8 Generate key input event on input subsystem.
77 * Sep.10, 2004 Hiroshi Miura <miura@da-cha.org>
78 * -v0.7 Change proc interface functions using seq_file
81 * Aug.28, 2004 Hiroshi Miura <miura@da-cha.org>
82 * -v0.6.4 Fix a silly error with status checking
84 * Aug.25, 2004 Hiroshi Miura <miura@da-cha.org>
85 * -v0.6.3 replace read_acpi_int by standard function
92 * -v0.6.2 Add check on ACPI data (num_sifr)
94 * Fixed an off-by-one error in memory allocation
97 * -v0.6.1 Fix a silly error with status checking
100 * - v0.6 Correct brightness controls to reflect reality
104 * Aug.10, 2004 Hiroshi Miura <miura@da-cha.org>
105 * - v0.5 support LCD brightness control
108 * Jul.25, 2004 Hiroshi Miura <miura@da-cha.org>
109 * - v0.4 first post version
112 * Jul.24, 2004 Hiroshi Miura <miura@da-cha.org>
113 * - v0.3 get proper status of hotkey
115 * Jul.22, 2004 Hiroshi Miura <miura@da-cha.org>
116 * - v0.2 add HotKey handler
118 * Jul.17, 2004 Hiroshi Miura <miura@da-cha.org>
119 * - v0.1 start from toshiba_acpi driver written by John Belmonte
128 #include <linux/input/sparse-keymap.h>
139 MODULE_AUTHOR("Hiroshi Miura <miura@da-cha.org>");
166 /* LCD_TYPEs: 0 = Normal, 1 = Semi-transparent
235 int mute; member
247 * On some Panasonic models the volume up / down / mute keys send duplicate
265 case 0x20: /* e0 20 / e0 a0, Volume Mute press / release */ in panasonic_i8042_filter()
272 * with the next non-filtered byte. in panasonic_i8042_filter()
297 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SSET, in acpi_pcc_write_sset()
300 return (status == AE_OK) ? 0 : -EIO; in acpi_pcc_write_sset()
308 status = acpi_evaluate_integer(device->handle, METHOD_HKEY_SQTY, in acpi_pcc_get_sqty()
314 return -EINVAL; in acpi_pcc_get_sqty()
325 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SINF, NULL, in acpi_pcc_retrieve_biosdata()
333 if (!hkey || (hkey->type != ACPI_TYPE_PACKAGE)) { in acpi_pcc_retrieve_biosdata()
339 if (pcc->num_sifr < hkey->package.count) { in acpi_pcc_retrieve_biosdata()
340 pr_err("SQTY reports bad SINF length SQTY: %lu SINF-pkg-count: %u\n", in acpi_pcc_retrieve_biosdata()
341 pcc->num_sifr, hkey->package.count); in acpi_pcc_retrieve_biosdata()
346 for (i = 0; i < hkey->package.count; i++) { in acpi_pcc_retrieve_biosdata()
347 union acpi_object *element = &(hkey->package.elements[i]); in acpi_pcc_retrieve_biosdata()
348 if (likely(element->type == ACPI_TYPE_INTEGER)) { in acpi_pcc_retrieve_biosdata()
349 pcc->sinf[i] = element->integer.value; in acpi_pcc_retrieve_biosdata()
353 pcc->sinf[hkey->package.count] = -1; in acpi_pcc_retrieve_biosdata()
372 return -EIO; in bl_get()
374 return pcc->sinf[SINF_AC_CUR_BRIGHT]; in bl_get()
380 int bright = bd->props.brightness; in bl_set_status()
384 return -EIO; in bl_set_status()
386 if (bright < pcc->sinf[SINF_AC_MIN_BRIGHT]) in bl_set_status()
387 bright = pcc->sinf[SINF_AC_MIN_BRIGHT]; in bl_set_status()
389 if (bright < pcc->sinf[SINF_DC_MIN_BRIGHT]) in bl_set_status()
390 bright = pcc->sinf[SINF_DC_MIN_BRIGHT]; in bl_set_status()
392 if (bright < pcc->sinf[SINF_AC_MIN_BRIGHT] || in bl_set_status()
393 bright > pcc->sinf[SINF_AC_MAX_BRIGHT]) in bl_set_status()
394 return -EINVAL; in bl_set_status()
441 result = -EIO; in get_optd_power_state()
452 result = -EIO; in get_optd_power_state()
481 result = -EIO; in set_optd_power_state()
488 result = -EIO; in set_optd_power_state()
492 result = -EINVAL; in set_optd_power_state()
510 return -EIO; in numbatt_show()
512 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_NUM_BATTERIES]); in numbatt_show()
522 return -EIO; in lcdtype_show()
524 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_LCD_TYPE]); in lcdtype_show()
534 return -EIO; in mute_show()
536 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_MUTE]); in mute_show()
551 pcc->mute = val; in mute_store()
564 return -EIO; in sticky_key_show()
566 return sysfs_emit(buf, "%u\n", pcc->sticky_key); in sticky_key_show()
581 pcc->sticky_key = val; in sticky_key_store()
595 return -EIO; in eco_mode_show()
597 switch (pcc->sinf[SINF_ECO_MODE]) { in eco_mode_show()
605 return -EIO; in eco_mode_show()
634 pcc->sinf[SINF_ECO_MODE] = 0; in eco_mode_store()
635 pcc->eco_mode = 0; in eco_mode_store()
639 pcc->sinf[SINF_ECO_MODE] = 1; in eco_mode_store()
640 pcc->eco_mode = 1; in eco_mode_store()
651 return -EINVAL; in eco_mode_store()
664 return -EIO; in ac_brightness_show()
666 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_AC_CUR_BRIGHT]); in ac_brightness_show()
681 pcc->ac_brightness = val; in ac_brightness_store()
694 return -EIO; in dc_brightness_show()
696 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_DC_CUR_BRIGHT]); in dc_brightness_show()
711 pcc->dc_brightness = val; in dc_brightness_store()
724 return -EIO; in current_brightness_show()
726 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_CUR_BRIGHT]); in current_brightness_show()
742 pcc->current_brightness = val; in current_brightness_store()
773 static DEVICE_ATTR_RW(mute);
788 return (pcc->num_sifr > SINF_MUTE) ? attr->mode : 0; in pcc_sysfs_is_visible()
791 return (pcc->num_sifr > SINF_ECO_MODE) ? attr->mode : 0; in pcc_sysfs_is_visible()
794 return (pcc->num_sifr > SINF_CUR_BRIGHT) ? attr->mode : 0; in pcc_sysfs_is_visible()
796 return attr->mode; in pcc_sysfs_is_visible()
824 struct input_dev *hotk_input_dev = pcc->input_dev; in acpi_pcc_generate_keyinput()
830 rc = acpi_evaluate_integer(pcc->handle, METHOD_HKEY_QUERY, in acpi_pcc_generate_keyinput()
850 * Don't report brightness key-presses if they are also reported in acpi_pcc_generate_keyinput()
896 return -ENODEV; in pcc_register_optd_notifier()
925 return -ENOMEM; in acpi_pcc_init_input()
927 input_dev->name = ACPI_PCC_DRIVER_NAME; in acpi_pcc_init_input()
928 input_dev->phys = ACPI_PCC_INPUT_PHYS; in acpi_pcc_init_input()
929 input_dev->id.bustype = BUS_HOST; in acpi_pcc_init_input()
930 input_dev->id.vendor = 0x0001; in acpi_pcc_init_input()
931 input_dev->id.product = 0x0001; in acpi_pcc_init_input()
932 input_dev->id.version = 0x0100; in acpi_pcc_init_input()
946 pcc->input_dev = input_dev; in acpi_pcc_init_input()
962 return -EINVAL; in acpi_pcc_hotkey_resume()
966 return -EINVAL; in acpi_pcc_hotkey_resume()
968 if (pcc->num_sifr > SINF_MUTE) in acpi_pcc_hotkey_resume()
969 acpi_pcc_write_sset(pcc, SINF_MUTE, pcc->mute); in acpi_pcc_hotkey_resume()
970 if (pcc->num_sifr > SINF_ECO_MODE) in acpi_pcc_hotkey_resume()
971 acpi_pcc_write_sset(pcc, SINF_ECO_MODE, pcc->eco_mode); in acpi_pcc_hotkey_resume()
972 acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, pcc->sticky_key); in acpi_pcc_hotkey_resume()
973 acpi_pcc_write_sset(pcc, SINF_AC_CUR_BRIGHT, pcc->ac_brightness); in acpi_pcc_hotkey_resume()
974 acpi_pcc_write_sset(pcc, SINF_DC_CUR_BRIGHT, pcc->dc_brightness); in acpi_pcc_hotkey_resume()
975 if (pcc->num_sifr > SINF_CUR_BRIGHT) in acpi_pcc_hotkey_resume()
976 acpi_pcc_write_sset(pcc, SINF_CUR_BRIGHT, pcc->current_brightness); in acpi_pcc_hotkey_resume()
989 return -EINVAL; in acpi_pcc_hotkey_add()
994 * pcc->sinf is expected to at least have the AC+DC brightness entries. in acpi_pcc_hotkey_add()
998 pr_err("num_sifr %d out of range %d - 255\n", num_sifr, SINF_DC_CUR_BRIGHT + 1); in acpi_pcc_hotkey_add()
999 return -ENODEV; in acpi_pcc_hotkey_add()
1003 * Some DSDT-s have an off-by-one bug where the SINF package count is in acpi_pcc_hotkey_add()
1011 return -ENOMEM; in acpi_pcc_hotkey_add()
1014 pcc->sinf = kcalloc(num_sifr + 1, sizeof(u32), GFP_KERNEL); in acpi_pcc_hotkey_add()
1015 if (!pcc->sinf) { in acpi_pcc_hotkey_add()
1016 result = -ENOMEM; in acpi_pcc_hotkey_add()
1020 pcc->device = device; in acpi_pcc_hotkey_add()
1021 pcc->handle = device->handle; in acpi_pcc_hotkey_add()
1022 pcc->num_sifr = num_sifr; in acpi_pcc_hotkey_add()
1023 device->driver_data = pcc; in acpi_pcc_hotkey_add()
1034 result = -EIO; in acpi_pcc_hotkey_add()
1043 props.max_brightness = pcc->sinf[SINF_AC_MAX_BRIGHT]; in acpi_pcc_hotkey_add()
1045 pcc->backlight = backlight_device_register("panasonic", NULL, pcc, in acpi_pcc_hotkey_add()
1047 if (IS_ERR(pcc->backlight)) { in acpi_pcc_hotkey_add()
1048 result = PTR_ERR(pcc->backlight); in acpi_pcc_hotkey_add()
1053 pcc->backlight->props.brightness = pcc->sinf[SINF_AC_CUR_BRIGHT]; in acpi_pcc_hotkey_add()
1058 pcc->sticky_key = 0; in acpi_pcc_hotkey_add()
1060 pcc->ac_brightness = pcc->sinf[SINF_AC_CUR_BRIGHT]; in acpi_pcc_hotkey_add()
1061 pcc->dc_brightness = pcc->sinf[SINF_DC_CUR_BRIGHT]; in acpi_pcc_hotkey_add()
1062 if (pcc->num_sifr > SINF_MUTE) in acpi_pcc_hotkey_add()
1063 pcc->mute = pcc->sinf[SINF_MUTE]; in acpi_pcc_hotkey_add()
1064 if (pcc->num_sifr > SINF_ECO_MODE) in acpi_pcc_hotkey_add()
1065 pcc->eco_mode = pcc->sinf[SINF_ECO_MODE]; in acpi_pcc_hotkey_add()
1066 if (pcc->num_sifr > SINF_CUR_BRIGHT) in acpi_pcc_hotkey_add()
1067 pcc->current_brightness = pcc->sinf[SINF_CUR_BRIGHT]; in acpi_pcc_hotkey_add()
1070 result = sysfs_create_group(&device->dev.kobj, &pcc_attr_group); in acpi_pcc_hotkey_add()
1076 pcc->platform = platform_device_register_simple("panasonic", in acpi_pcc_hotkey_add()
1078 if (IS_ERR(pcc->platform)) { in acpi_pcc_hotkey_add()
1079 result = PTR_ERR(pcc->platform); in acpi_pcc_hotkey_add()
1082 result = device_create_file(&pcc->platform->dev, in acpi_pcc_hotkey_add()
1088 pcc->platform = NULL; in acpi_pcc_hotkey_add()
1095 platform_device_unregister(pcc->platform); in acpi_pcc_hotkey_add()
1097 backlight_device_unregister(pcc->backlight); in acpi_pcc_hotkey_add()
1099 input_unregister_device(pcc->input_dev); in acpi_pcc_hotkey_add()
1101 kfree(pcc->sinf); in acpi_pcc_hotkey_add()
1117 if (pcc->platform) { in acpi_pcc_hotkey_remove()
1118 device_remove_file(&pcc->platform->dev, &dev_attr_cdpower); in acpi_pcc_hotkey_remove()
1119 platform_device_unregister(pcc->platform); in acpi_pcc_hotkey_remove()
1123 sysfs_remove_group(&device->dev.kobj, &pcc_attr_group); in acpi_pcc_hotkey_remove()
1125 backlight_device_unregister(pcc->backlight); in acpi_pcc_hotkey_remove()
1127 input_unregister_device(pcc->input_dev); in acpi_pcc_hotkey_remove()
1129 kfree(pcc->sinf); in acpi_pcc_hotkey_remove()