Lines Matching full:pcc

53  * 			add /proc/acpi/pcc/brightness interface for HAL access
163 #define ACPI_PCC_CLASS "pcc"
295 static int acpi_pcc_write_sset(struct pcc_acpi *pcc, int func, int val) in acpi_pcc_write_sset() argument
309 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SSET, in acpi_pcc_write_sset()
330 static int acpi_pcc_retrieve_biosdata(struct pcc_acpi *pcc) in acpi_pcc_retrieve_biosdata() argument
337 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SINF, NULL, in acpi_pcc_retrieve_biosdata()
351 if (pcc->num_sifr < hkey->package.count) { in acpi_pcc_retrieve_biosdata()
353 pcc->num_sifr, hkey->package.count); in acpi_pcc_retrieve_biosdata()
361 pcc->sinf[i] = element->integer.value; in acpi_pcc_retrieve_biosdata()
365 pcc->sinf[hkey->package.count] = -1; in acpi_pcc_retrieve_biosdata()
381 struct pcc_acpi *pcc = bl_get_data(bd); in bl_get() local
383 if (!acpi_pcc_retrieve_biosdata(pcc)) in bl_get()
386 return pcc->sinf[SINF_AC_CUR_BRIGHT]; in bl_get()
391 struct pcc_acpi *pcc = bl_get_data(bd); in bl_set_status() local
395 if (!acpi_pcc_retrieve_biosdata(pcc)) in bl_set_status()
398 if (bright < pcc->sinf[SINF_AC_MIN_BRIGHT]) in bl_set_status()
399 bright = pcc->sinf[SINF_AC_MIN_BRIGHT]; in bl_set_status()
401 if (bright < pcc->sinf[SINF_DC_MIN_BRIGHT]) in bl_set_status()
402 bright = pcc->sinf[SINF_DC_MIN_BRIGHT]; in bl_set_status()
404 if (bright < pcc->sinf[SINF_AC_MIN_BRIGHT] || in bl_set_status()
405 bright > pcc->sinf[SINF_AC_MAX_BRIGHT]) in bl_set_status()
408 rc = acpi_pcc_write_sset(pcc, SINF_AC_CUR_BRIGHT, bright); in bl_set_status()
412 return acpi_pcc_write_sset(pcc, SINF_DC_CUR_BRIGHT, bright); in bl_set_status()
519 struct pcc_acpi *pcc = acpi_driver_data(acpi); in numbatt_show() local
521 if (!acpi_pcc_retrieve_biosdata(pcc)) in numbatt_show()
524 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_NUM_BATTERIES]); in numbatt_show()
531 struct pcc_acpi *pcc = acpi_driver_data(acpi); in lcdtype_show() local
533 if (!acpi_pcc_retrieve_biosdata(pcc)) in lcdtype_show()
536 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_LCD_TYPE]); in lcdtype_show()
543 struct pcc_acpi *pcc = acpi_driver_data(acpi); in mute_show() local
545 if (!acpi_pcc_retrieve_biosdata(pcc)) in mute_show()
548 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_MUTE]); in mute_show()
555 struct pcc_acpi *pcc = acpi_driver_data(acpi); in mute_store() local
562 acpi_pcc_write_sset(pcc, SINF_MUTE, val); in mute_store()
563 pcc->mute = val; in mute_store()
573 struct pcc_acpi *pcc = acpi_driver_data(acpi); in sticky_key_show() local
575 if (!acpi_pcc_retrieve_biosdata(pcc)) in sticky_key_show()
578 return sysfs_emit(buf, "%u\n", pcc->sticky_key); in sticky_key_show()
585 struct pcc_acpi *pcc = acpi_driver_data(acpi); in sticky_key_store() local
592 acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, val); in sticky_key_store()
593 pcc->sticky_key = val; in sticky_key_store()
603 struct pcc_acpi *pcc = acpi_driver_data(acpi); in eco_mode_show() local
606 if (!acpi_pcc_retrieve_biosdata(pcc)) in eco_mode_show()
609 switch (pcc->sinf[SINF_ECO_MODE]) { in eco_mode_show()
627 struct pcc_acpi *pcc = acpi_driver_data(acpi); in eco_mode_store() local
647 pcc->sinf[SINF_ECO_MODE] = 0; in eco_mode_store()
648 pcc->eco_mode = 0; in eco_mode_store()
652 pcc->sinf[SINF_ECO_MODE] = 1; in eco_mode_store()
653 pcc->eco_mode = 1; in eco_mode_store()
674 struct pcc_acpi *pcc = acpi_driver_data(acpi); in ac_brightness_show() local
676 if (!acpi_pcc_retrieve_biosdata(pcc)) in ac_brightness_show()
679 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_AC_CUR_BRIGHT]); in ac_brightness_show()
686 struct pcc_acpi *pcc = acpi_driver_data(acpi); in ac_brightness_store() local
693 acpi_pcc_write_sset(pcc, SINF_AC_CUR_BRIGHT, val); in ac_brightness_store()
694 pcc->ac_brightness = val; in ac_brightness_store()
704 struct pcc_acpi *pcc = acpi_driver_data(acpi); in dc_brightness_show() local
706 if (!acpi_pcc_retrieve_biosdata(pcc)) in dc_brightness_show()
709 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_DC_CUR_BRIGHT]); in dc_brightness_show()
716 struct pcc_acpi *pcc = acpi_driver_data(acpi); in dc_brightness_store() local
723 acpi_pcc_write_sset(pcc, SINF_DC_CUR_BRIGHT, val); in dc_brightness_store()
724 pcc->dc_brightness = val; in dc_brightness_store()
734 struct pcc_acpi *pcc = acpi_driver_data(acpi); in current_brightness_show() local
736 if (!acpi_pcc_retrieve_biosdata(pcc)) in current_brightness_show()
739 return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_CUR_BRIGHT]); in current_brightness_show()
746 struct pcc_acpi *pcc = acpi_driver_data(acpi); in current_brightness_store() local
754 err = acpi_pcc_write_sset(pcc, SINF_CUR_BRIGHT, val); in current_brightness_store()
755 pcc->current_brightness = val; in current_brightness_store()
793 struct pcc_acpi *pcc = acpi_driver_data(acpi); in pcc_sysfs_is_visible() local
796 return (pcc->num_sifr > SINF_MUTE) ? attr->mode : 0; in pcc_sysfs_is_visible()
799 return (pcc->num_sifr > SINF_ECO_MODE) ? attr->mode : 0; in pcc_sysfs_is_visible()
802 return (pcc->num_sifr > SINF_CUR_BRIGHT) ? attr->mode : 0; in pcc_sysfs_is_visible()
830 static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc) in acpi_pcc_generate_keyinput() argument
832 struct input_dev *hotk_input_dev = pcc->input_dev; in acpi_pcc_generate_keyinput()
838 rc = acpi_evaluate_integer(pcc->handle, METHOD_HKEY_QUERY, in acpi_pcc_generate_keyinput()
870 struct pcc_acpi *pcc = acpi_driver_data(device); in acpi_pcc_hotkey_notify() local
874 acpi_pcc_generate_keyinput(pcc); in acpi_pcc_hotkey_notify()
890 static int pcc_register_optd_notifier(struct pcc_acpi *pcc, char *node) in pcc_register_optd_notifier() argument
900 pcc_optd_notify, pcc); in pcc_register_optd_notifier()
909 static void pcc_unregister_optd_notifier(struct pcc_acpi *pcc, char *node) in pcc_unregister_optd_notifier() argument
926 static int acpi_pcc_init_input(struct pcc_acpi *pcc) in acpi_pcc_init_input() argument
954 pcc->input_dev = input_dev; in acpi_pcc_init_input()
967 struct pcc_acpi *pcc; in acpi_pcc_hotkey_resume() local
972 pcc = acpi_driver_data(to_acpi_device(dev)); in acpi_pcc_hotkey_resume()
973 if (!pcc) in acpi_pcc_hotkey_resume()
976 if (pcc->num_sifr > SINF_MUTE) in acpi_pcc_hotkey_resume()
977 acpi_pcc_write_sset(pcc, SINF_MUTE, pcc->mute); in acpi_pcc_hotkey_resume()
978 if (pcc->num_sifr > SINF_ECO_MODE) in acpi_pcc_hotkey_resume()
979 acpi_pcc_write_sset(pcc, SINF_ECO_MODE, pcc->eco_mode); in acpi_pcc_hotkey_resume()
980 acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, pcc->sticky_key); in acpi_pcc_hotkey_resume()
981 acpi_pcc_write_sset(pcc, SINF_AC_CUR_BRIGHT, pcc->ac_brightness); in acpi_pcc_hotkey_resume()
982 acpi_pcc_write_sset(pcc, SINF_DC_CUR_BRIGHT, pcc->dc_brightness); in acpi_pcc_hotkey_resume()
983 if (pcc->num_sifr > SINF_CUR_BRIGHT) in acpi_pcc_hotkey_resume()
984 acpi_pcc_write_sset(pcc, SINF_CUR_BRIGHT, pcc->current_brightness); in acpi_pcc_hotkey_resume()
993 struct pcc_acpi *pcc; in acpi_pcc_hotkey_add() local
1002 * pcc->sinf is expected to at least have the AC+DC brightness entries. in acpi_pcc_hotkey_add()
1016 pcc = kzalloc(sizeof(struct pcc_acpi), GFP_KERNEL); in acpi_pcc_hotkey_add()
1017 if (!pcc) { in acpi_pcc_hotkey_add()
1018 pr_err("Couldn't allocate mem for pcc"); in acpi_pcc_hotkey_add()
1022 pcc->sinf = kcalloc(num_sifr + 1, sizeof(u32), GFP_KERNEL); in acpi_pcc_hotkey_add()
1023 if (!pcc->sinf) { in acpi_pcc_hotkey_add()
1028 pcc->device = device; in acpi_pcc_hotkey_add()
1029 pcc->handle = device->handle; in acpi_pcc_hotkey_add()
1030 pcc->num_sifr = num_sifr; in acpi_pcc_hotkey_add()
1031 device->driver_data = pcc; in acpi_pcc_hotkey_add()
1035 result = acpi_pcc_init_input(pcc); in acpi_pcc_hotkey_add()
1041 if (!acpi_pcc_retrieve_biosdata(pcc)) { in acpi_pcc_hotkey_add()
1051 props.max_brightness = pcc->sinf[SINF_AC_MAX_BRIGHT]; in acpi_pcc_hotkey_add()
1053 pcc->backlight = backlight_device_register("panasonic", NULL, pcc, in acpi_pcc_hotkey_add()
1055 if (IS_ERR(pcc->backlight)) { in acpi_pcc_hotkey_add()
1056 result = PTR_ERR(pcc->backlight); in acpi_pcc_hotkey_add()
1061 pcc->backlight->props.brightness = pcc->sinf[SINF_AC_CUR_BRIGHT]; in acpi_pcc_hotkey_add()
1065 acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, 0); in acpi_pcc_hotkey_add()
1066 pcc->sticky_key = 0; in acpi_pcc_hotkey_add()
1068 pcc->ac_brightness = pcc->sinf[SINF_AC_CUR_BRIGHT]; in acpi_pcc_hotkey_add()
1069 pcc->dc_brightness = pcc->sinf[SINF_DC_CUR_BRIGHT]; in acpi_pcc_hotkey_add()
1070 if (pcc->num_sifr > SINF_MUTE) in acpi_pcc_hotkey_add()
1071 pcc->mute = pcc->sinf[SINF_MUTE]; in acpi_pcc_hotkey_add()
1072 if (pcc->num_sifr > SINF_ECO_MODE) in acpi_pcc_hotkey_add()
1073 pcc->eco_mode = pcc->sinf[SINF_ECO_MODE]; in acpi_pcc_hotkey_add()
1074 if (pcc->num_sifr > SINF_CUR_BRIGHT) in acpi_pcc_hotkey_add()
1075 pcc->current_brightness = pcc->sinf[SINF_CUR_BRIGHT]; in acpi_pcc_hotkey_add()
1084 pcc->platform = platform_device_register_simple("panasonic", in acpi_pcc_hotkey_add()
1086 if (IS_ERR(pcc->platform)) { in acpi_pcc_hotkey_add()
1087 result = PTR_ERR(pcc->platform); in acpi_pcc_hotkey_add()
1090 result = device_create_file(&pcc->platform->dev, in acpi_pcc_hotkey_add()
1092 pcc_register_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD"); in acpi_pcc_hotkey_add()
1096 pcc->platform = NULL; in acpi_pcc_hotkey_add()
1103 platform_device_unregister(pcc->platform); in acpi_pcc_hotkey_add()
1105 backlight_device_unregister(pcc->backlight); in acpi_pcc_hotkey_add()
1107 input_unregister_device(pcc->input_dev); in acpi_pcc_hotkey_add()
1109 kfree(pcc->sinf); in acpi_pcc_hotkey_add()
1111 kfree(pcc); in acpi_pcc_hotkey_add()
1118 struct pcc_acpi *pcc = acpi_driver_data(device); in acpi_pcc_hotkey_remove() local
1120 if (!device || !pcc) in acpi_pcc_hotkey_remove()
1125 if (pcc->platform) { in acpi_pcc_hotkey_remove()
1126 device_remove_file(&pcc->platform->dev, &dev_attr_cdpower); in acpi_pcc_hotkey_remove()
1127 platform_device_unregister(pcc->platform); in acpi_pcc_hotkey_remove()
1129 pcc_unregister_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD"); in acpi_pcc_hotkey_remove()
1133 backlight_device_unregister(pcc->backlight); in acpi_pcc_hotkey_remove()
1135 input_unregister_device(pcc->input_dev); in acpi_pcc_hotkey_remove()
1137 kfree(pcc->sinf); in acpi_pcc_hotkey_remove()
1138 kfree(pcc); in acpi_pcc_hotkey_remove()