sony-laptop changes for 3.15
Subsystems (2)
Mattia Dongili
maintainercover sony-laptop changes for 3.15
Hi Matthew,
could you please apply these patches?
There's a bunch of new functions made available for newer vaios (Pros mainly) and a fix for keyboard backlight settings.
There's more to come, specifically a much bigger ALS support patch.
Thanks
Javier Achirica (7):
sony-laptop: add support as Fn+1 as a hot key
sony-laptop: Add support for lid resume settings on Vaio Pro
sony-laptop: add panel_id function
sony-laptop: add usb charge function
sony-laptop: add fan speed regulation function
sony-laptop: add hibernate on low battery function
sony-laptop: adjust keyboard backlight values for off/auto/on
drivers/platform/x86/sony-laptop.c | 463 +++++++++++++++++++++++++++++++++---- 1 file changed, 412 insertions(+), 51 deletions(-)
Signature · 1 line
1.9.rc1
Mattia Dongili
maintainerPATCH 1/7 sony-laptop: add support as Fn+1 as a hot key
From: Javier Achirica <[email protected]>
--- drivers/platform/x86/sony-laptop.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/platform/x86/sony-laptop.c +2 -0
@@ -1122,6 +1122,8 @@ static struct sony_nc_event sony_100_events[] = { { 0x25, SONYPI_EVENT_ANYBUTTON_RELEASED }, { 0xa6, SONYPI_EVENT_HELP_PRESSED }, { 0x26, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0xa8, SONYPI_EVENT_FNKEY_1 }, + { 0x28, SONYPI_EVENT_ANYBUTTON_RELEASED }, { 0, 0 }, };
Signature · 1 line
1.9.rc1
Mattia Dongili
maintainerPATCH 2/7 sony-laptop: Add support for lid resume settings on Vaio Pro
In reply to Mattia DongiliFrom: Javier Achirica <[email protected]>
Vaio Pro uses a different handle and doesn't support all the options as other models (only S5 setting v/s S3/4/5).
Minor code rework to generalize functions by Mattia Dongili.
--- drivers/platform/x86/sony-laptop.c | 110 +++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 48 deletions(-)
drivers/platform/x86/sony-laptop.c +62 -48
@@ -152,7 +152,8 @@ static void sony_nc_battery_care_cleanup(struct platform_device *pd);static int sony_nc_thermal_setup (struct platform_device *pd);static void sony_nc_thermal_cleanup (struct platform_device *pd); -static int sony_nc_lid_resume_setup (struct platform_device *pd); +static int sony_nc_lid_resume_setup (struct platform_device *pd, +unsigned int handle);static void sony_nc_lid_resume_cleanup (struct platform_device *pd); static int sony_nc_gfx_switch_setup(struct platform_device *pd,
@@ -1341,7 +1342,8 @@ static void sony_nc_function_setup(struct acpi_device *device, result);break ;case 0x0119 : - result =sony_nc_lid_resume_setup (pf_device); +case 0x015D : + result =sony_nc_lid_resume_setup (pf_device, handle);if (result)pr_err ("couldn't set up lid resume function (%d)\n" , result);
@@ -1422,6 +1424,7 @@ static void sony_nc_function_cleanup(struct platform_device *pd)sony_nc_battery_care_cleanup (pd);break ;case 0x0119 : +case 0x015D :sony_nc_lid_resume_cleanup (pd);break ;case 0x0122 :
@@ -2223,9 +2226,14 @@ static void sony_nc_thermal_resume(void)#endif /* resume on LID open */ +#define LID_RESUME_S5 0 +#define LID_RESUME_S4 1 +#define LID_RESUME_S3 2 +#define LID_RESUME_MAX 3struct snc_lid_resume_control { -struct device_attribute attrs[3 ]; +struct device_attribute attrs[LID_RESUME_MAX ];unsigned int status; +int handle; };static struct snc_lid_resume_control *lid_ctl;
@@ -2233,8 +2241,9 @@ static ssize_t sony_nc_lid_resume_store(struct device *dev,struct device_attribute *attr, const char *buffer, size_t count) { - unsigned int result, pos; + unsigned int result;unsigned long value; +unsigned int pos =LID_RESUME_S5 ;if (count >31 )return -EINVAL ;
@@ -2247,21 +2256,21 @@ static ssize_t sony_nc_lid_resume_store(struct device *dev,* +--------------+ * 2 1 0 */ -if (strcmp (attr->attr.name,"lid_resume_S3" ) ==0 ) - pos =2 ; -else if (strcmp (attr->attr.name,"lid_resume_S4" ) ==0 ) - pos =1 ; -else if (strcmp (attr->attr.name,"lid_resume_S5" ) ==0 ) - pos =0 ; -else -return -EINVAL ; +while (pos <LID_RESUME_MAX ) { +if (&lid_ctl->attrs[pos].attr == &attr->attr) +break ; + pos++; + } +if (pos ==LID_RESUME_MAX ) +return -EINVAL ;if (value) value = lid_ctl->status | (1 << pos);else value = lid_ctl->status & ~(1 << pos); -if (sony_call_snc_handle (0x0119 , value <<0x10 |0x0100 , &result)) +if (sony_call_snc_handle (lid_ctl->handle, value <<0x10 |0x0100 , + &result))return -EIO ; lid_ctl->status = value;
@@ -2270,29 +2279,27 @@ static ssize_t sony_nc_lid_resume_store(struct device *dev, }static ssize_t sony_nc_lid_resume_show (struct device *dev, -struct device_attribute *attr,char *buffer) +struct device_attribute *attr, +char *buffer) { -unsigned int pos; - -if (strcmp (attr->attr.name,"lid_resume_S3" ) ==0 ) - pos =2 ; -else if (strcmp (attr->attr.name,"lid_resume_S4" ) ==0 ) - pos =1 ; -else if (strcmp (attr->attr.name,"lid_resume_S5" ) ==0 ) - pos =0 ; -else -return -EINVAL ; - -return snprintf (buffer,PAGE_SIZE ,"%d\n" , - (lid_ctl->status >> pos) &0x01 ); +unsigned int pos =LID_RESUME_S5 ; + +while (pos <LID_RESUME_MAX ) { +if (&lid_ctl->attrs[pos].attr == &attr->attr) +return snprintf (buffer,PAGE_SIZE ,"%d\n" , + (lid_ctl->status >> pos) &0x01 ); + pos++; + } +return -EINVAL ; } -static int sony_nc_lid_resume_setup (struct platform_device *pd) +static int sony_nc_lid_resume_setup (struct platform_device *pd, +unsigned int handle) {unsigned int result;int i; -if (sony_call_snc_handle (0x0119 ,0x0000 , &result)) +if (sony_call_snc_handle (handle,0x0000 , &result))return -EIO ; lid_ctl =kzalloc (sizeof (struct snc_lid_resume_control ),GFP_KERNEL );
@@ -2300,26 +2307,29 @@ static int sony_nc_lid_resume_setup(struct platform_device *pd)return -ENOMEM ; lid_ctl->status = result &0x7 ; + lid_ctl->handle = handle;sysfs_attr_init (&lid_ctl->attrs[0 ].attr); - lid_ctl->attrs[0 ].attr.name ="lid_resume_S3" ; - lid_ctl->attrs[0 ].attr.mode =S_IRUGO |S_IWUSR ; - lid_ctl->attrs[0 ].show = sony_nc_lid_resume_show; - lid_ctl->attrs[0 ].store = sony_nc_lid_resume_store; - -sysfs_attr_init (&lid_ctl->attrs[1 ].attr); - lid_ctl->attrs[1 ].attr.name ="lid_resume_S4" ; - lid_ctl->attrs[1 ].attr.mode =S_IRUGO |S_IWUSR ; - lid_ctl->attrs[1 ].show = sony_nc_lid_resume_show; - lid_ctl->attrs[1 ].store = sony_nc_lid_resume_store; - -sysfs_attr_init (&lid_ctl->attrs[2 ].attr); - lid_ctl->attrs[2 ].attr.name ="lid_resume_S5" ; - lid_ctl->attrs[2 ].attr.mode =S_IRUGO |S_IWUSR ; - lid_ctl->attrs[2 ].show = sony_nc_lid_resume_show; - lid_ctl->attrs[2 ].store = sony_nc_lid_resume_store; - -for (i =0 ; i <3 ; i++) { + lid_ctl->attrs[LID_RESUME_S5 ].attr.name ="lid_resume_S5" ; + lid_ctl->attrs[LID_RESUME_S5 ].attr.mode =S_IRUGO |S_IWUSR ; + lid_ctl->attrs[LID_RESUME_S5 ].show = sony_nc_lid_resume_show; + lid_ctl->attrs[LID_RESUME_S5 ].store = sony_nc_lid_resume_store; + +if (handle ==0x0119 ) { +sysfs_attr_init (&lid_ctl->attrs[1 ].attr); + lid_ctl->attrs[LID_RESUME_S4 ].attr.name ="lid_resume_S4" ; + lid_ctl->attrs[LID_RESUME_S4 ].attr.mode =S_IRUGO |S_IWUSR ; + lid_ctl->attrs[LID_RESUME_S4 ].show = sony_nc_lid_resume_show; + lid_ctl->attrs[LID_RESUME_S4 ].store = sony_nc_lid_resume_store; + +sysfs_attr_init (&lid_ctl->attrs[2 ].attr); + lid_ctl->attrs[LID_RESUME_S3 ].attr.name ="lid_resume_S3" ; + lid_ctl->attrs[LID_RESUME_S3 ].attr.mode =S_IRUGO |S_IWUSR ; + lid_ctl->attrs[LID_RESUME_S3 ].show = sony_nc_lid_resume_show; + lid_ctl->attrs[LID_RESUME_S3 ].store = sony_nc_lid_resume_store; + } +for (i =0 ; i <LID_RESUME_MAX && + lid_ctl->attrs[LID_RESUME_S3 ].attr.name; i++) { result =device_create_file (&pd->dev, &lid_ctl->attrs[i]);if (result) goto liderror;
@@ -2342,8 +2352,12 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)int i;if (lid_ctl) { -for (i =0 ; i <3 ; i++) +for (i =0 ; i <LID_RESUME_MAX ; i++) { +if (!lid_ctl->attrs[i].attr.name) +break ; +device_remove_file (&pd->dev, &lid_ctl->attrs[i]); + }kfree (lid_ctl); lid_ctl =NULL ;
Signature · 1 line
1.9.rc1
Mattia Dongili
maintainerPATCH 3/7 sony-laptop: add panel_id function
In reply to Mattia DongiliFrom: Javier Achirica <[email protected]>
--- drivers/platform/x86/sony-laptop.c | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
drivers/platform/x86/sony-laptop.c +59 -0
@@ -164,6 +164,9 @@ static int __sony_nc_gfx_switch_status_get(void);static int sony_nc_highspeed_charging_setup (struct platform_device *pd);static void sony_nc_highspeed_charging_cleanup (struct platform_device *pd); +static int sony_nc_panelid_setup (struct platform_device *pd); +static void sony_nc_panelid_cleanup (struct platform_device *pd); +static int sony_nc_touchpad_setup (struct platform_device *pd,unsigned int handle);static void sony_nc_touchpad_cleanup (struct platform_device *pd);
@@ -1385,6 +1388,12 @@ static void sony_nc_function_setup(struct acpi_device *device,pr_err ("couldn't set up keyboard backlight function (%d)\n" , result);break ; +case 0x011D : + result =sony_nc_panelid_setup (pf_device); +if (result) +pr_err ("couldn't set up panel ID function (%d)\n" , + result); +break ;default :continue ; }
@@ -1449,6 +1458,9 @@ static void sony_nc_function_cleanup(struct platform_device *pd)case 0x0163 :sony_nc_kbd_backlight_cleanup (pd, handle);break ; +case 0x011D : +sony_nc_panelid_cleanup (pd); +break ;default :continue ; }
@@ -2540,6 +2552,53 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd) } } +/* Panel ID function */ +static struct device_attribute *panel_handle; + +static ssize_t sony_nc_panelid_show (struct device *dev, +struct device_attribute *attr,char *buffer) +{ +unsigned int result; + +if (sony_call_snc_handle (0x011D ,0x0000 , &result)) +return -EIO ; + +return snprintf (buffer,PAGE_SIZE ,"%d\n" , result); +} + +static int sony_nc_panelid_setup (struct platform_device *pd) +{ +unsigned int result; + + panel_handle =kzalloc (sizeof (struct device_attribute ),GFP_KERNEL ); +if (!panel_handle) +return -ENOMEM ; + +sysfs_attr_init (&panel_handle->attr); + panel_handle->attr.name ="panel_id" ; + panel_handle->attr.mode =S_IRUGO ; + panel_handle->show = sony_nc_panelid_show; + panel_handle->store =NULL ; + + result =device_create_file (&pd->dev, panel_handle); +if (result) { +kfree (panel_handle); + panel_handle =NULL ; +return result; + } + +return 0 ; +} + +static void sony_nc_panelid_cleanup (struct platform_device *pd) +{ +if (panel_handle) { +device_remove_file (&pd->dev, panel_handle); +kfree (panel_handle); + panel_handle =NULL ; + } +} +/* Touchpad enable/disable */ struct touchpad_control {struct device_attribute attr;
Signature · 1 line
1.9.rc1
Mattia Dongili
maintainerPATCH 4/7 sony-laptop: add usb charge function
In reply to Mattia DongiliFrom: Javier Achirica <[email protected]>
Allows to specify if the USB socket should charge attached devices while the laptop is suspended to ram.
--- drivers/platform/x86/sony-laptop.c | 86 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)
drivers/platform/x86/sony-laptop.c +86 -0
@@ -164,6 +164,9 @@ static int __sony_nc_gfx_switch_status_get(void);static int sony_nc_highspeed_charging_setup (struct platform_device *pd);static void sony_nc_highspeed_charging_cleanup (struct platform_device *pd); +static int sony_nc_usb_charge_setup (struct platform_device *pd); +static void sony_nc_usb_charge_cleanup (struct platform_device *pd); +static int sony_nc_panelid_setup (struct platform_device *pd);static void sony_nc_panelid_cleanup (struct platform_device *pd);
@@ -1388,6 +1391,12 @@ static void sony_nc_function_setup(struct acpi_device *device,pr_err ("couldn't set up keyboard backlight function (%d)\n" , result);break ; +case 0x0155 : + result =sony_nc_usb_charge_setup (pf_device); +if (result) +pr_err ("couldn't set up USB charge support (%d)\n" , + result); +break ;case 0x011D : result =sony_nc_panelid_setup (pf_device);if (result)
@@ -1458,6 +1467,9 @@ static void sony_nc_function_cleanup(struct platform_device *pd)case 0x0163 :sony_nc_kbd_backlight_cleanup (pd, handle);break ; +case 0x0155 : +sony_nc_usb_charge_cleanup (pd); +break ;case 0x011D :sony_nc_panelid_cleanup (pd);break ;
@@ -2552,6 +2564,80 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd) } } +/* USB charge function */ +static struct device_attribute *uc_handle; + +static ssize_t sony_nc_usb_charge_store (struct device *dev, +struct device_attribute *attr, +const char *buffer,size_t count) +{ +unsigned int result; +unsigned long value; + +if (count >31 ) +return -EINVAL ; + +if (kstrtoul (buffer,10 , &value) || value >1 ) +return -EINVAL ; + +if (sony_call_snc_handle (0x0155 , value <<0x10 |0x0100 , &result)) +return -EIO ; + +return count; +} + +static ssize_t sony_nc_usb_charge_show (struct device *dev, +struct device_attribute *attr,char *buffer) +{ +unsigned int result; + +if (sony_call_snc_handle (0x0155 ,0x0000 , &result)) +return -EIO ; + +return snprintf (buffer,PAGE_SIZE ,"%d\n" , result &0x01 ); +} + +static int sony_nc_usb_charge_setup (struct platform_device *pd) +{ +unsigned int result; + +if (sony_call_snc_handle (0x0155 ,0x0000 , &result) || !(result &0x01 )) { +/* some models advertise the handle but have no implementation +* for it +*/ +pr_info ("No USB Charge capability found\n" ); +return 0 ; + } + + uc_handle =kzalloc (sizeof (struct device_attribute ),GFP_KERNEL ); +if (!uc_handle) +return -ENOMEM ; + +sysfs_attr_init (&uc_handle->attr); + uc_handle->attr.name ="usb_charge" ; + uc_handle->attr.mode =S_IRUGO |S_IWUSR ; + uc_handle->show = sony_nc_usb_charge_show; + uc_handle->store = sony_nc_usb_charge_store; + + result =device_create_file (&pd->dev, uc_handle); +if (result) { +kfree (uc_handle); + uc_handle =NULL ; +return result; + } + +return 0 ; +} + +static void sony_nc_usb_charge_cleanup (struct platform_device *pd) +{ +if (uc_handle) { +device_remove_file (&pd->dev, uc_handle); +kfree (uc_handle); + uc_handle =NULL ; + } +} +/* Panel ID function */ static struct device_attribute *panel_handle;
Signature · 1 line
1.9.rc1
Mattia Dongili
maintainerPATCH 5/7 sony-laptop: add fan speed regulation function
In reply to Mattia DongiliFrom: Javier Achirica <[email protected]>
Rework error exit logic by Mattia Dongili.
--- drivers/platform/x86/sony-laptop.c | 119 +++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+)
drivers/platform/x86/sony-laptop.c +119 -0
@@ -164,6 +164,9 @@ static int __sony_nc_gfx_switch_status_get(void);static int sony_nc_highspeed_charging_setup (struct platform_device *pd);static void sony_nc_highspeed_charging_cleanup (struct platform_device *pd); +static int sony_nc_fanspeed_setup (struct platform_device *pd); +static void sony_nc_fanspeed_cleanup (struct platform_device *pd); +static int sony_nc_usb_charge_setup (struct platform_device *pd);static void sony_nc_usb_charge_cleanup (struct platform_device *pd);
@@ -1391,6 +1394,12 @@ static void sony_nc_function_setup(struct acpi_device *device,pr_err ("couldn't set up keyboard backlight function (%d)\n" , result);break ; +case 0x0149 : + result =sony_nc_fanspeed_setup (pf_device); +if (result) +pr_err ("couldn't set up fan speed function (%d)\n" , + result); +break ;case 0x0155 : result =sony_nc_usb_charge_setup (pf_device);if (result)
@@ -1467,6 +1476,9 @@ static void sony_nc_function_cleanup(struct platform_device *pd)case 0x0163 :sony_nc_kbd_backlight_cleanup (pd, handle);break ; +case 0x0149 : +sony_nc_fanspeed_cleanup (pd); +break ;case 0x0155 :sony_nc_usb_charge_cleanup (pd);break ;
@@ -2564,6 +2576,113 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd) } } +/* fan speed function */ +static struct device_attribute *fan_handle, *hsf_handle; + +static ssize_t sony_nc_hsfan_store (struct device *dev, +struct device_attribute *attr, +const char *buffer,size_t count) +{ +unsigned int result; +unsigned long value; + +if (count >31 ) +return -EINVAL ; + +if (kstrtoul (buffer,10 , &value) || value >1 ) +return -EINVAL ; + +if (sony_call_snc_handle (0x0149 , value <<0x10 |0x0200 , &result)) +return -EIO ; + +return count; +} + +static ssize_t sony_nc_hsfan_show (struct device *dev, +struct device_attribute *attr,char *buffer) +{ +unsigned int result; + +if (sony_call_snc_handle (0x0149 ,0x0100 , &result)) +return -EIO ; + +return snprintf (buffer,PAGE_SIZE ,"%d\n" , result &0x01 ); +} + +static ssize_t sony_nc_fanspeed_show (struct device *dev, +struct device_attribute *attr,char *buffer) +{ +unsigned int result; + +if (sony_call_snc_handle (0x0149 ,0x0300 , &result)) +return -EIO ; + +return snprintf (buffer,PAGE_SIZE ,"%d\n" , result &0xff ); +} + +static int sony_nc_fanspeed_setup (struct platform_device *pd) +{ +unsigned int result; + + fan_handle =kzalloc (sizeof (struct device_attribute ),GFP_KERNEL ); +if (!fan_handle) +return -ENOMEM ; + + hsf_handle =kzalloc (sizeof (struct device_attribute ),GFP_KERNEL ); +if (!hsf_handle) { + result = -ENOMEM ; + goto out_hsf_handle_alloc; + } + +sysfs_attr_init (&fan_handle->attr); + fan_handle->attr.name ="fanspeed" ; + fan_handle->attr.mode =S_IRUGO ; + fan_handle->show = sony_nc_fanspeed_show; + fan_handle->store =NULL ; + +sysfs_attr_init (&hsf_handle->attr); + hsf_handle->attr.name ="fan_forced" ; + hsf_handle->attr.mode =S_IRUGO |S_IWUSR ; + hsf_handle->show = sony_nc_hsfan_show; + hsf_handle->store = sony_nc_hsfan_store; + + result =device_create_file (&pd->dev, fan_handle); +if (result) + goto out_fan_handle; + + result =device_create_file (&pd->dev, hsf_handle); +if (result) + goto out_hsf_handle; + +return 0 ; + +out_hsf_handle: +device_remove_file (&pd->dev, fan_handle); + +out_fan_handle: +kfree (hsf_handle); + hsf_handle =NULL ; + +out_hsf_handle_alloc: +kfree (fan_handle); + fan_handle =NULL ; +return result; +} + +static void sony_nc_fanspeed_cleanup (struct platform_device *pd) +{ +if (fan_handle) { +device_remove_file (&pd->dev, fan_handle); +kfree (fan_handle); + fan_handle =NULL ; + } +if (hsf_handle) { +device_remove_file (&pd->dev, hsf_handle); +kfree (hsf_handle); + hsf_handle =NULL ; + } +} +/* USB charge function */ static struct device_attribute *uc_handle;
Signature · 1 line
1.9.rc1
Mattia Dongili
maintainerPATCH 6/7 sony-laptop: add hibernate on low battery function
In reply to Mattia DongiliFrom: Javier Achirica <[email protected]>
--- drivers/platform/x86/sony-laptop.c | 78 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)
drivers/platform/x86/sony-laptop.c +78 -0
@@ -164,6 +164,9 @@ static int __sony_nc_gfx_switch_status_get(void);static int sony_nc_highspeed_charging_setup (struct platform_device *pd);static void sony_nc_highspeed_charging_cleanup (struct platform_device *pd); +static int sony_nc_lowbatt_setup (struct platform_device *pd); +static void sony_nc_lowbatt_cleanup (struct platform_device *pd); +static int sony_nc_fanspeed_setup (struct platform_device *pd);static void sony_nc_fanspeed_cleanup (struct platform_device *pd);
@@ -1394,6 +1397,12 @@ static void sony_nc_function_setup(struct acpi_device *device,pr_err ("couldn't set up keyboard backlight function (%d)\n" , result);break ; +case 0x0121 : + result =sony_nc_lowbatt_setup (pf_device); +if (result) +pr_err ("couldn't set up low battery function (%d)\n" , + result); +break ;case 0x0149 : result =sony_nc_fanspeed_setup (pf_device);if (result)
@@ -1476,6 +1485,9 @@ static void sony_nc_function_cleanup(struct platform_device *pd)case 0x0163 :sony_nc_kbd_backlight_cleanup (pd, handle);break ; +case 0x0121 : +sony_nc_lowbatt_cleanup (pd); +break ;case 0x0149 :sony_nc_fanspeed_cleanup (pd);break ;
@@ -2576,6 +2588,72 @@ static void sony_nc_highspeed_charging_cleanup(struct platform_device *pd) } } +/* low battery function */ +static struct device_attribute *lowbatt_handle; + +static ssize_t sony_nc_lowbatt_store (struct device *dev, +struct device_attribute *attr, +const char *buffer,size_t count) +{ +unsigned int result; +unsigned long value; + +if (count >31 ) +return -EINVAL ; + +if (kstrtoul (buffer,10 , &value) || value >1 ) +return -EINVAL ; + +if (sony_call_snc_handle (0x0121 , value <<8 , &result)) +return -EIO ; + +return count; +} + +static ssize_t sony_nc_lowbatt_show (struct device *dev, +struct device_attribute *attr,char *buffer) +{ +unsigned int result; + +if (sony_call_snc_handle (0x0121 ,0x0200 , &result)) +return -EIO ; + +return snprintf (buffer,PAGE_SIZE ,"%d\n" , result &1 ); +} + +static int sony_nc_lowbatt_setup (struct platform_device *pd) +{ +unsigned int result; + + lowbatt_handle =kzalloc (sizeof (struct device_attribute ),GFP_KERNEL ); +if (!lowbatt_handle) +return -ENOMEM ; + +sysfs_attr_init (&lowbatt_handle->attr); + lowbatt_handle->attr.name ="lowbatt_hibernate" ; + lowbatt_handle->attr.mode =S_IRUGO |S_IWUSR ; + lowbatt_handle->show = sony_nc_lowbatt_show; + lowbatt_handle->store = sony_nc_lowbatt_store; + + result =device_create_file (&pd->dev, lowbatt_handle); +if (result) { +kfree (lowbatt_handle); + lowbatt_handle =NULL ; +return result; + } + +return 0 ; +} + +static void sony_nc_lowbatt_cleanup (struct platform_device *pd) +{ +if (lowbatt_handle) { +device_remove_file (&pd->dev, lowbatt_handle); +kfree (lowbatt_handle); + lowbatt_handle =NULL ; + } +} +/* fan speed function */ static struct device_attribute *fan_handle, *hsf_handle;
Signature · 1 line
1.9.rc1
Mattia Dongili
maintainerPATCH 7/7 sony-laptop: adjust keyboard backlight values for off/auto/on
In reply to Mattia DongiliFrom: Javier Achirica <[email protected]>
Keyboard backlight can be always off, use some automatic trigger (activity and light sensor), always on.
The behaviour of the driver changes whereby previously when passed 1 it tried to turn on backlight immediately now it does nothing. This is however a bug fix since (a) it makes little sense to turn on the backlight when control is automatic and (b) this behaviour is consistent with what the windows driver does.
--- drivers/platform/x86/sony-laptop.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/platform/x86/sony-laptop.c +7 -4
@@ -129,7 +129,8 @@ static int kbd_backlight = -1;module_param (kbd_backlight, int,0444 );MODULE_PARM_DESC (kbd_backlight,"set this to 0 to disable keyboard backlight, " -"1 to enable it (default: no change from current value)" ); +"1 to enable it with automatic control and 2 to have it always " +"on (default: no change from current value)" );static int kbd_backlight_timeout =-1 ;module_param (kbd_backlight_timeout, int,0444 );
@@ -1772,7 +1773,7 @@ static ssize_t __sony_nc_kbd_backlight_mode_set(u8 value) {int result; -if (value >1 ) +if (value >2 )return -EINVAL ; if (sony_call_snc_handle(kbdbl_ctl->handle,
@@ -1780,8 +1781,10 @@ static ssize_t __sony_nc_kbd_backlight_mode_set(u8 value)return -EIO ;/* Try to turn the light on/off immediately */ -sony_call_snc_handle (kbdbl_ctl->handle, - (value <<0x10 ) | (kbdbl_ctl->base +0x100 ), &result); +if (value !=1 ) +sony_call_snc_handle (kbdbl_ctl->handle, + (value <<0x0f ) | (kbdbl_ctl->base +0x100 ), + &result); kbdbl_ctl->mode = value;
Signature · 1 line
1.9.rc1