aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMattia Dongili <malattia@linux.it>2012-06-09 00:18:11 -0400
committerMatthew Garrett <mjg@redhat.com>2012-06-26 14:43:16 -0400
commit014fc8fbece33d42e2aa92d289fffa213a159321 (patch)
tree2bc1f05abc586bd5d3b961f52c545390e767d161 /drivers
parent15aa5c75468a103cdee1a0e0ec26aad979bf71a5 (diff)
sony-laptop: add lid backlight support for handle 0x143
Signed-off-by: Mattia Dongili <malattia@linux.it> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/platform/x86/sony-laptop.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index f045e3e59cd6..a94e13fe1f42 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1010,6 +1010,7 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
1010struct sony_backlight_props { 1010struct sony_backlight_props {
1011 struct backlight_device *dev; 1011 struct backlight_device *dev;
1012 int handle; 1012 int handle;
1013 int cmd_base;
1013 u8 offset; 1014 u8 offset;
1014 u8 maxlvl; 1015 u8 maxlvl;
1015}; 1016};
@@ -1037,7 +1038,7 @@ static int sony_nc_get_brightness_ng(struct backlight_device *bd)
1037 struct sony_backlight_props *sdev = 1038 struct sony_backlight_props *sdev =
1038 (struct sony_backlight_props *)bl_get_data(bd); 1039 (struct sony_backlight_props *)bl_get_data(bd);
1039 1040
1040 sony_call_snc_handle(sdev->handle, 0x0200, &result); 1041 sony_call_snc_handle(sdev->handle, sdev->cmd_base + 0x100, &result);
1041 1042
1042 return (result & 0xff) - sdev->offset; 1043 return (result & 0xff) - sdev->offset;
1043} 1044}
@@ -1049,7 +1050,8 @@ static int sony_nc_update_status_ng(struct backlight_device *bd)
1049 (struct sony_backlight_props *)bl_get_data(bd); 1050 (struct sony_backlight_props *)bl_get_data(bd);
1050 1051
1051 value = bd->props.brightness + sdev->offset; 1052 value = bd->props.brightness + sdev->offset;
1052 if (sony_call_snc_handle(sdev->handle, 0x0100 | (value << 16), &result)) 1053 if (sony_call_snc_handle(sdev->handle, sdev->cmd_base | (value << 0x10),
1054 &result))
1053 return -EIO; 1055 return -EIO;
1054 1056
1055 return value; 1057 return value;
@@ -2496,6 +2498,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
2496{ 2498{
2497 u64 offset; 2499 u64 offset;
2498 int i; 2500 int i;
2501 int lvl_table_len = 0;
2499 u8 min = 0xff, max = 0x00; 2502 u8 min = 0xff, max = 0x00;
2500 unsigned char buffer[32] = { 0 }; 2503 unsigned char buffer[32] = { 0 };
2501 2504
@@ -2515,11 +2518,21 @@ static void sony_nc_backlight_ng_read_limits(int handle,
2515 if (i < 0) 2518 if (i < 0)
2516 return; 2519 return;
2517 2520
2521 switch (handle) {
2522 case 0x012f:
2523 case 0x0137:
2524 lvl_table_len = 9;
2525 break;
2526 case 0x143:
2527 lvl_table_len = 16;
2528 break;
2529 }
2530
2518 /* the buffer lists brightness levels available, brightness levels are 2531 /* the buffer lists brightness levels available, brightness levels are
2519 * from position 0 to 8 in the array, other values are used by ALS 2532 * from position 0 to 8 in the array, other values are used by ALS
2520 * control. 2533 * control.
2521 */ 2534 */
2522 for (i = 0; i < 9 && i < ARRAY_SIZE(buffer); i++) { 2535 for (i = 0; i < lvl_table_len && i < ARRAY_SIZE(buffer); i++) {
2523 2536
2524 dprintk("Brightness level: %d\n", buffer[i]); 2537 dprintk("Brightness level: %d\n", buffer[i]);
2525 2538
@@ -2546,14 +2559,22 @@ static void sony_nc_backlight_setup(void)
2546 2559
2547 if (sony_find_snc_handle(0x12f) != -1) { 2560 if (sony_find_snc_handle(0x12f) != -1) {
2548 ops = &sony_backlight_ng_ops; 2561 ops = &sony_backlight_ng_ops;
2562 sony_bl_props.cmd_base = 0x0100;
2549 sony_nc_backlight_ng_read_limits(0x12f, &sony_bl_props); 2563 sony_nc_backlight_ng_read_limits(0x12f, &sony_bl_props);
2550 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; 2564 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
2551 2565
2552 } else if (sony_find_snc_handle(0x137) != -1) { 2566 } else if (sony_find_snc_handle(0x137) != -1) {
2553 ops = &sony_backlight_ng_ops; 2567 ops = &sony_backlight_ng_ops;
2568 sony_bl_props.cmd_base = 0x0100;
2554 sony_nc_backlight_ng_read_limits(0x137, &sony_bl_props); 2569 sony_nc_backlight_ng_read_limits(0x137, &sony_bl_props);
2555 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; 2570 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
2556 2571
2572 } else if (sony_find_snc_handle(0x143) != -1) {
2573 ops = &sony_backlight_ng_ops;
2574 sony_bl_props.cmd_base = 0x3000;
2575 sony_nc_backlight_ng_read_limits(0x143, &sony_bl_props);
2576 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
2577
2557 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", 2578 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
2558 &unused))) { 2579 &unused))) {
2559 ops = &sony_backlight_ops; 2580 ops = &sony_backlight_ops;