Re: [PATCH v4 4/5] toshiba_acpi: Support new keyboard backlight type

2014-09-15 Thread Darren Hart
On Fri, Sep 12, 2014 at 06:50:36PM -0600, Azael Avalos wrote:
> Newer Toshiba models now come with a new (and different) keyboard
> backlight implementation with three modes of operation: TIMER,
> ON and OFF, and the LED is now controlled internally by the firmware.
> 
> This patch adds support for that type of backlight, changing the
> existing code to accomodate the new implementation.
> 
> The timeout value range is now 1-60 seconds, and the accepted
> modes are now: 1 (FN-Z), 2 (AUTO or TIMER), 8 (ON) and 10 (OFF),
> this adds two new entries kbd_type and available_kbd_modes,
> the first shows the keyboard type and the latter shows the
> supported modes depending on the keyboard type.
> 
> Signed-off-by: Azael Avalos 
> ---
> Changes since v3:
> Fixed typos on patch description
> Dropped changes to toshiba_kbd_bl_mode_show and simply added the new mode mask
>  drivers/platform/x86/toshiba_acpi.c | 188 
> ++--
>  1 file changed, 156 insertions(+), 32 deletions(-)

Queued, thanks Azael.

-- 
Darren Hart
Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 4/5] toshiba_acpi: Support new keyboard backlight type

2014-09-15 Thread Darren Hart
On Fri, Sep 12, 2014 at 06:50:36PM -0600, Azael Avalos wrote:
 Newer Toshiba models now come with a new (and different) keyboard
 backlight implementation with three modes of operation: TIMER,
 ON and OFF, and the LED is now controlled internally by the firmware.
 
 This patch adds support for that type of backlight, changing the
 existing code to accomodate the new implementation.
 
 The timeout value range is now 1-60 seconds, and the accepted
 modes are now: 1 (FN-Z), 2 (AUTO or TIMER), 8 (ON) and 10 (OFF),
 this adds two new entries kbd_type and available_kbd_modes,
 the first shows the keyboard type and the latter shows the
 supported modes depending on the keyboard type.
 
 Signed-off-by: Azael Avalos coproscef...@gmail.com
 ---
 Changes since v3:
 Fixed typos on patch description
 Dropped changes to toshiba_kbd_bl_mode_show and simply added the new mode mask
  drivers/platform/x86/toshiba_acpi.c | 188 
 ++--
  1 file changed, 156 insertions(+), 32 deletions(-)

Queued, thanks Azael.

-- 
Darren Hart
Intel Open Source Technology Center
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 4/5] toshiba_acpi: Support new keyboard backlight type

2014-09-12 Thread Azael Avalos
Newer Toshiba models now come with a new (and different) keyboard
backlight implementation with three modes of operation: TIMER,
ON and OFF, and the LED is now controlled internally by the firmware.

This patch adds support for that type of backlight, changing the
existing code to accomodate the new implementation.

The timeout value range is now 1-60 seconds, and the accepted
modes are now: 1 (FN-Z), 2 (AUTO or TIMER), 8 (ON) and 10 (OFF),
this adds two new entries kbd_type and available_kbd_modes,
the first shows the keyboard type and the latter shows the
supported modes depending on the keyboard type.

Signed-off-by: Azael Avalos 
---
Changes since v3:
Fixed typos on patch description
Dropped changes to toshiba_kbd_bl_mode_show and simply added the new mode mask
 drivers/platform/x86/toshiba_acpi.c | 188 ++--
 1 file changed, 156 insertions(+), 32 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c 
b/drivers/platform/x86/toshiba_acpi.c
index 2a84652..edd8f3d 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -138,8 +138,12 @@ MODULE_LICENSE("GPL");
 #define HCI_WIRELESS_BT_PRESENT0x0f
 #define HCI_WIRELESS_BT_ATTACH 0x40
 #define HCI_WIRELESS_BT_POWER  0x80
+#define SCI_KBD_MODE_MASK  0x1f
 #define SCI_KBD_MODE_FNZ   0x1
 #define SCI_KBD_MODE_AUTO  0x2
+#define SCI_KBD_MODE_ON0x8
+#define SCI_KBD_MODE_OFF   0x10
+#define SCI_KBD_TIME_MAX   0x3c001a
 
 struct toshiba_acpi_dev {
struct acpi_device *acpi_dev;
@@ -155,6 +159,7 @@ struct toshiba_acpi_dev {
int force_fan;
int last_key_event;
int key_event_valid;
+   int kbd_type;
int kbd_mode;
int kbd_time;
 
@@ -495,6 +500,42 @@ static enum led_brightness toshiba_illumination_get(struct 
led_classdev *cdev)
 }
 
 /* KBD Illumination */
+static int toshiba_kbd_illum_available(struct toshiba_acpi_dev *dev)
+{
+   u32 in[HCI_WORDS] = { SCI_GET, SCI_KBD_ILLUM_STATUS, 0, 0, 0, 0 };
+   u32 out[HCI_WORDS];
+   acpi_status status;
+
+   if (!sci_open(dev))
+   return 0;
+
+   status = hci_raw(dev, in, out);
+   sci_close(dev);
+   if (ACPI_FAILURE(status) || out[0] == SCI_INPUT_DATA_ERROR) {
+   pr_err("ACPI call to query kbd illumination support failed\n");
+   return 0;
+   } else if (out[0] == HCI_NOT_SUPPORTED) {
+   pr_info("Keyboard illumination not available\n");
+   return 0;
+   }
+
+   /* Check for keyboard backlight timeout max value,
+* previous kbd backlight implementation set this to
+* 0x3c0003, and now the new implementation set this
+* to 0x3c001a, use this to distinguish between them
+*/
+   if (out[3] == SCI_KBD_TIME_MAX)
+   dev->kbd_type = 2;
+   else
+   dev->kbd_type = 1;
+   /* Get the current keyboard backlight mode */
+   dev->kbd_mode = out[2] & SCI_KBD_MODE_MASK;
+   /* Get the current time (1-60 seconds) */
+   dev->kbd_time = out[2] >> HCI_MISC_SHIFT;
+
+   return 1;
+}
+
 static int toshiba_kbd_illum_status_set(struct toshiba_acpi_dev *dev, u32 time)
 {
u32 result;
@@ -1254,6 +1295,62 @@ static const struct backlight_ops toshiba_backlight_data 
= {
 /*
  * Sysfs files
  */
+static ssize_t toshiba_kbd_bl_mode_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count);
+static ssize_t toshiba_kbd_bl_mode_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf);
+static ssize_t toshiba_kbd_type_show(struct device *dev,
+struct device_attribute *attr,
+char *buf);
+static ssize_t toshiba_available_kbd_modes_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf);
+static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count);
+static ssize_t toshiba_kbd_bl_timeout_show(struct device *dev,
+  struct device_attribute *attr,
+  char *buf);
+static ssize_t toshiba_touchpad_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
+static ssize_t toshiba_touchpad_show(struct device *dev,
+struct device_attribute *attr,
+char *buf);
+static 

[PATCH v4 4/5] toshiba_acpi: Support new keyboard backlight type

2014-09-12 Thread Azael Avalos
Newer Toshiba models now come with a new (and different) keyboard
backlight implementation with three modes of operation: TIMER,
ON and OFF, and the LED is now controlled internally by the firmware.

This patch adds support for that type of backlight, changing the
existing code to accomodate the new implementation.

The timeout value range is now 1-60 seconds, and the accepted
modes are now: 1 (FN-Z), 2 (AUTO or TIMER), 8 (ON) and 10 (OFF),
this adds two new entries kbd_type and available_kbd_modes,
the first shows the keyboard type and the latter shows the
supported modes depending on the keyboard type.

Signed-off-by: Azael Avalos coproscef...@gmail.com
---
Changes since v3:
Fixed typos on patch description
Dropped changes to toshiba_kbd_bl_mode_show and simply added the new mode mask
 drivers/platform/x86/toshiba_acpi.c | 188 ++--
 1 file changed, 156 insertions(+), 32 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c 
b/drivers/platform/x86/toshiba_acpi.c
index 2a84652..edd8f3d 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -138,8 +138,12 @@ MODULE_LICENSE(GPL);
 #define HCI_WIRELESS_BT_PRESENT0x0f
 #define HCI_WIRELESS_BT_ATTACH 0x40
 #define HCI_WIRELESS_BT_POWER  0x80
+#define SCI_KBD_MODE_MASK  0x1f
 #define SCI_KBD_MODE_FNZ   0x1
 #define SCI_KBD_MODE_AUTO  0x2
+#define SCI_KBD_MODE_ON0x8
+#define SCI_KBD_MODE_OFF   0x10
+#define SCI_KBD_TIME_MAX   0x3c001a
 
 struct toshiba_acpi_dev {
struct acpi_device *acpi_dev;
@@ -155,6 +159,7 @@ struct toshiba_acpi_dev {
int force_fan;
int last_key_event;
int key_event_valid;
+   int kbd_type;
int kbd_mode;
int kbd_time;
 
@@ -495,6 +500,42 @@ static enum led_brightness toshiba_illumination_get(struct 
led_classdev *cdev)
 }
 
 /* KBD Illumination */
+static int toshiba_kbd_illum_available(struct toshiba_acpi_dev *dev)
+{
+   u32 in[HCI_WORDS] = { SCI_GET, SCI_KBD_ILLUM_STATUS, 0, 0, 0, 0 };
+   u32 out[HCI_WORDS];
+   acpi_status status;
+
+   if (!sci_open(dev))
+   return 0;
+
+   status = hci_raw(dev, in, out);
+   sci_close(dev);
+   if (ACPI_FAILURE(status) || out[0] == SCI_INPUT_DATA_ERROR) {
+   pr_err(ACPI call to query kbd illumination support failed\n);
+   return 0;
+   } else if (out[0] == HCI_NOT_SUPPORTED) {
+   pr_info(Keyboard illumination not available\n);
+   return 0;
+   }
+
+   /* Check for keyboard backlight timeout max value,
+* previous kbd backlight implementation set this to
+* 0x3c0003, and now the new implementation set this
+* to 0x3c001a, use this to distinguish between them
+*/
+   if (out[3] == SCI_KBD_TIME_MAX)
+   dev-kbd_type = 2;
+   else
+   dev-kbd_type = 1;
+   /* Get the current keyboard backlight mode */
+   dev-kbd_mode = out[2]  SCI_KBD_MODE_MASK;
+   /* Get the current time (1-60 seconds) */
+   dev-kbd_time = out[2]  HCI_MISC_SHIFT;
+
+   return 1;
+}
+
 static int toshiba_kbd_illum_status_set(struct toshiba_acpi_dev *dev, u32 time)
 {
u32 result;
@@ -1254,6 +1295,62 @@ static const struct backlight_ops toshiba_backlight_data 
= {
 /*
  * Sysfs files
  */
+static ssize_t toshiba_kbd_bl_mode_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count);
+static ssize_t toshiba_kbd_bl_mode_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf);
+static ssize_t toshiba_kbd_type_show(struct device *dev,
+struct device_attribute *attr,
+char *buf);
+static ssize_t toshiba_available_kbd_modes_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf);
+static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count);
+static ssize_t toshiba_kbd_bl_timeout_show(struct device *dev,
+  struct device_attribute *attr,
+  char *buf);
+static ssize_t toshiba_touchpad_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
+static ssize_t toshiba_touchpad_show(struct device *dev,
+struct device_attribute *attr,
+char *buf);