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>
This commit is contained in:
Mattia Dongili 2012-06-09 13:18:11 +09:00 committed by Matthew Garrett
parent 15aa5c7546
commit 014fc8fbec

View file

@ -1010,6 +1010,7 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
struct sony_backlight_props { struct sony_backlight_props {
struct backlight_device *dev; struct backlight_device *dev;
int handle; int handle;
int cmd_base;
u8 offset; u8 offset;
u8 maxlvl; u8 maxlvl;
}; };
@ -1037,7 +1038,7 @@ static int sony_nc_get_brightness_ng(struct backlight_device *bd)
struct sony_backlight_props *sdev = struct sony_backlight_props *sdev =
(struct sony_backlight_props *)bl_get_data(bd); (struct sony_backlight_props *)bl_get_data(bd);
sony_call_snc_handle(sdev->handle, 0x0200, &result); sony_call_snc_handle(sdev->handle, sdev->cmd_base + 0x100, &result);
return (result & 0xff) - sdev->offset; return (result & 0xff) - sdev->offset;
} }
@ -1049,7 +1050,8 @@ static int sony_nc_update_status_ng(struct backlight_device *bd)
(struct sony_backlight_props *)bl_get_data(bd); (struct sony_backlight_props *)bl_get_data(bd);
value = bd->props.brightness + sdev->offset; value = bd->props.brightness + sdev->offset;
if (sony_call_snc_handle(sdev->handle, 0x0100 | (value << 16), &result)) if (sony_call_snc_handle(sdev->handle, sdev->cmd_base | (value << 0x10),
&result))
return -EIO; return -EIO;
return value; return value;
@ -2496,6 +2498,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
{ {
u64 offset; u64 offset;
int i; int i;
int lvl_table_len = 0;
u8 min = 0xff, max = 0x00; u8 min = 0xff, max = 0x00;
unsigned char buffer[32] = { 0 }; unsigned char buffer[32] = { 0 };
@ -2515,11 +2518,21 @@ static void sony_nc_backlight_ng_read_limits(int handle,
if (i < 0) if (i < 0)
return; return;
switch (handle) {
case 0x012f:
case 0x0137:
lvl_table_len = 9;
break;
case 0x143:
lvl_table_len = 16;
break;
}
/* the buffer lists brightness levels available, brightness levels are /* the buffer lists brightness levels available, brightness levels are
* from position 0 to 8 in the array, other values are used by ALS * from position 0 to 8 in the array, other values are used by ALS
* control. * control.
*/ */
for (i = 0; i < 9 && i < ARRAY_SIZE(buffer); i++) { for (i = 0; i < lvl_table_len && i < ARRAY_SIZE(buffer); i++) {
dprintk("Brightness level: %d\n", buffer[i]); dprintk("Brightness level: %d\n", buffer[i]);
@ -2546,14 +2559,22 @@ static void sony_nc_backlight_setup(void)
if (sony_find_snc_handle(0x12f) != -1) { if (sony_find_snc_handle(0x12f) != -1) {
ops = &sony_backlight_ng_ops; ops = &sony_backlight_ng_ops;
sony_bl_props.cmd_base = 0x0100;
sony_nc_backlight_ng_read_limits(0x12f, &sony_bl_props); sony_nc_backlight_ng_read_limits(0x12f, &sony_bl_props);
max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
} else if (sony_find_snc_handle(0x137) != -1) { } else if (sony_find_snc_handle(0x137) != -1) {
ops = &sony_backlight_ng_ops; ops = &sony_backlight_ng_ops;
sony_bl_props.cmd_base = 0x0100;
sony_nc_backlight_ng_read_limits(0x137, &sony_bl_props); sony_nc_backlight_ng_read_limits(0x137, &sony_bl_props);
max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
} else if (sony_find_snc_handle(0x143) != -1) {
ops = &sony_backlight_ng_ops;
sony_bl_props.cmd_base = 0x3000;
sony_nc_backlight_ng_read_limits(0x143, &sony_bl_props);
max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
} else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
&unused))) { &unused))) {
ops = &sony_backlight_ops; ops = &sony_backlight_ops;