* [PATCH 0/4] sony-laptop for 3.8
@ 2012-12-20 22:21 Mattia Dongili
2012-12-20 22:21 ` [PATCH 1/4] sony-laptop: fully enable SNY controlled modems Mattia Dongili
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Mattia Dongili @ 2012-12-20 22:21 UTC (permalink / raw)
To: Matthew Garrett; +Cc: platform-driver-x86, Mattia Dongili
Hi Matthew,
here's a few patches I would like to include in 3.8. First two are
resubmissions of bug fixes sent previously (please use this version), the
others add some functionality for recent vaios.
Mattia Dongili (4):
sony-laptop: fully enable SNY controlled modems
sony-laptop: fix SNC buffer calls when SN06 returns Integers
sony-laptop: allow reading the status of gfx switch
sony-laptop: support basic functions for handle 0x14B and 0x14C
drivers/platform/x86/sony-laptop.c | 158 ++++++++++++++++++++++++++++++++----
1 file changed, 141 insertions(+), 17 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] sony-laptop: fully enable SNY controlled modems
2012-12-20 22:21 [PATCH 0/4] sony-laptop for 3.8 Mattia Dongili
@ 2012-12-20 22:21 ` Mattia Dongili
2012-12-20 22:21 ` [PATCH 2/4] sony-laptop: fix SNC buffer calls when SN06 returns Integers Mattia Dongili
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Mattia Dongili @ 2012-12-20 22:21 UTC (permalink / raw)
To: Matthew Garrett; +Cc: platform-driver-x86, Mattia Dongili
The call to handlers 0x124 and 0x135 (rfkill control) seems to take a
bitmask to control various states of the device. For our rfkill we need
a fully on/off. SVZ1311Z9R/X's LTE modem needs more bits up.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=47751
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
drivers/platform/x86/sony-laptop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index daaddec..b0e1180 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1533,7 +1533,7 @@ static int sony_nc_rfkill_set(void *data, bool blocked)
int argument = sony_rfkill_address[(long) data] + 0x100;
if (!blocked)
- argument |= 0x030000;
+ argument |= 0x070000;
return sony_call_snc_handle(sony_rfkill_handle, argument, &result);
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] sony-laptop: fix SNC buffer calls when SN06 returns Integers
2012-12-20 22:21 [PATCH 0/4] sony-laptop for 3.8 Mattia Dongili
2012-12-20 22:21 ` [PATCH 1/4] sony-laptop: fully enable SNY controlled modems Mattia Dongili
@ 2012-12-20 22:21 ` Mattia Dongili
2012-12-20 22:21 ` [PATCH 3/4] sony-laptop: allow reading the status of gfx switch Mattia Dongili
2012-12-20 22:21 ` [PATCH 4/4] sony-laptop: support basic functions for handle 0x14B and 0x14C Mattia Dongili
3 siblings, 0 replies; 5+ messages in thread
From: Mattia Dongili @ 2012-12-20 22:21 UTC (permalink / raw)
To: Matthew Garrett
Cc: platform-driver-x86, Mattia Dongili, stable, Fabrizio Narni,
mus.svz
SN06 in some cases returns an Integer instead of a buffer. While the
code handling the return value was trying to cope with the difference,
the memcpy call was not making any difference between the two types of
acpi_object union. This regression was introduced in 3.5.
While there also rework the return value logic to improve readability.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=48671
Cc: <stable@vger.kernel.org>
Cc: Fabrizio Narni <shibotto@gmail.com>
Cc: <mus.svz@gmail.com>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
drivers/platform/x86/sony-laptop.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index b0e1180..0fe987f 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -786,28 +786,29 @@ static int sony_nc_int_call(acpi_handle handle, char *name, int *value,
static int sony_nc_buffer_call(acpi_handle handle, char *name, u64 *value,
void *buffer, size_t buflen)
{
+ int ret = 0;
size_t len = len;
union acpi_object *object = __call_snc_method(handle, name, value);
if (!object)
return -EINVAL;
- if (object->type == ACPI_TYPE_BUFFER)
+ if (object->type == ACPI_TYPE_BUFFER) {
len = MIN(buflen, object->buffer.length);
+ memcpy(buffer, object->buffer.pointer, len);
- else if (object->type == ACPI_TYPE_INTEGER)
+ } else if (object->type == ACPI_TYPE_INTEGER) {
len = MIN(buflen, sizeof(object->integer.value));
+ memcpy(buffer, &object->integer.value, len);
- else {
+ } else {
pr_warn("Invalid acpi_object: expected 0x%x got 0x%x\n",
ACPI_TYPE_BUFFER, object->type);
- kfree(object);
- return -EINVAL;
+ ret = -EINVAL;
}
- memcpy(buffer, object->buffer.pointer, len);
kfree(object);
- return 0;
+ return ret;
}
struct sony_nc_handles {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] sony-laptop: allow reading the status of gfx switch
2012-12-20 22:21 [PATCH 0/4] sony-laptop for 3.8 Mattia Dongili
2012-12-20 22:21 ` [PATCH 1/4] sony-laptop: fully enable SNY controlled modems Mattia Dongili
2012-12-20 22:21 ` [PATCH 2/4] sony-laptop: fix SNC buffer calls when SN06 returns Integers Mattia Dongili
@ 2012-12-20 22:21 ` Mattia Dongili
2012-12-20 22:21 ` [PATCH 4/4] sony-laptop: support basic functions for handle 0x14B and 0x14C Mattia Dongili
3 siblings, 0 replies; 5+ messages in thread
From: Mattia Dongili @ 2012-12-20 22:21 UTC (permalink / raw)
To: Matthew Garrett; +Cc: platform-driver-x86, Mattia Dongili
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
drivers/platform/x86/sony-laptop.c | 121 +++++++++++++++++++++++++++++++++---
1 file changed, 112 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 0fe987f..385835d 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -158,6 +158,11 @@ static void sony_nc_thermal_cleanup(struct platform_device *pd);
static int sony_nc_lid_resume_setup(struct platform_device *pd);
static void sony_nc_lid_resume_cleanup(struct platform_device *pd);
+static int sony_nc_gfx_switch_setup(struct platform_device *pd,
+ unsigned int handle);
+static void sony_nc_gfx_switch_cleanup(struct platform_device *pd);
+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);
@@ -1241,17 +1246,13 @@ static void sony_nc_notify(struct acpi_device *device, u32 event)
/* Hybrid GFX switching */
sony_call_snc_handle(handle, 0x0000, &result);
dprintk("GFX switch event received (reason: %s)\n",
- (result & 0x01) ?
- "switch change" : "unknown");
-
- /* verify the switch state
- * 1: discrete GFX
- * 0: integrated GFX
- */
- sony_call_snc_handle(handle, 0x0100, &result);
+ (result == 0x1) ? "switch change" :
+ (result == 0x2) ? "output switch" :
+ (result == 0x3) ? "output switch" :
+ "");
ev_type = GFX_SWITCH;
- real_ev = result & 0xff;
+ real_ev = __sony_nc_gfx_switch_status_get();
break;
default:
@@ -1350,6 +1351,13 @@ static void sony_nc_function_setup(struct acpi_device *device,
pr_err("couldn't set up thermal profile function (%d)\n",
result);
break;
+ case 0x0128:
+ case 0x0146:
+ result = sony_nc_gfx_switch_setup(pf_device, handle);
+ if (result)
+ pr_err("couldn't set up GFX Switch status (%d)\n",
+ result);
+ break;
case 0x0131:
result = sony_nc_highspeed_charging_setup(pf_device);
if (result)
@@ -1414,6 +1422,10 @@ static void sony_nc_function_cleanup(struct platform_device *pd)
case 0x0122:
sony_nc_thermal_cleanup(pd);
break;
+ case 0x0128:
+ case 0x0146:
+ sony_nc_gfx_switch_cleanup(pd);
+ break;
case 0x0131:
sony_nc_highspeed_charging_cleanup(pd);
break;
@@ -2355,6 +2367,97 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
}
}
+/* GFX Switch position */
+enum gfx_switch {
+ SPEED,
+ STAMINA,
+ AUTO
+};
+struct snc_gfx_switch_control {
+ struct device_attribute attr;
+ unsigned int handle;
+};
+static struct snc_gfx_switch_control *gfxs_ctl;
+
+/* returns 0 for speed, 1 for stamina */
+static int __sony_nc_gfx_switch_status_get(void)
+{
+ unsigned int result;
+
+ if (sony_call_snc_handle(gfxs_ctl->handle, 0x0100, &result))
+ return -EIO;
+
+ switch (gfxs_ctl->handle) {
+ case 0x0146:
+ /* 1: discrete GFX (speed)
+ * 0: integrated GFX (stamina)
+ */
+ return result & 0x1 ? SPEED : STAMINA;
+ break;
+ case 0x0128:
+ /* it's a more elaborated bitmask, for now:
+ * 2: integrated GFX (stamina)
+ * 0: discrete GFX (speed)
+ */
+ dprintk("GFX Status: 0x%x\n", result);
+ return result & 0x80 ? AUTO :
+ result & 0x02 ? STAMINA : SPEED;
+ break;
+ }
+ return -EINVAL;
+}
+
+static ssize_t sony_nc_gfx_switch_status_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buffer)
+{
+ int pos = __sony_nc_gfx_switch_status_get();
+
+ if (pos < 0)
+ return pos;
+
+ return snprintf(buffer, PAGE_SIZE, "%s\n", pos ? "speed" : "stamina");
+}
+
+static int sony_nc_gfx_switch_setup(struct platform_device *pd,
+ unsigned int handle)
+{
+ unsigned int result;
+
+ gfxs_ctl = kzalloc(sizeof(struct snc_gfx_switch_control), GFP_KERNEL);
+ if (!gfxs_ctl)
+ return -ENOMEM;
+
+ gfxs_ctl->handle = handle;
+
+ sysfs_attr_init(&gfxs_ctl->attr.attr);
+ gfxs_ctl->attr.attr.name = "gfx_switch_status";
+ gfxs_ctl->attr.attr.mode = S_IRUGO;
+ gfxs_ctl->attr.show = sony_nc_gfx_switch_status_show;
+
+ result = device_create_file(&pd->dev, &gfxs_ctl->attr);
+ if (result)
+ goto gfxerror;
+
+ return 0;
+
+gfxerror:
+ kfree(gfxs_ctl);
+ gfxs_ctl = NULL;
+
+ return result;
+}
+
+static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
+{
+ if (gfxs_ctl) {
+ device_remove_file(&pd->dev, &gfxs_ctl->attr);
+
+ kfree(gfxs_ctl);
+ gfxs_ctl = NULL;
+ }
+}
+
/* High speed charging function */
static struct device_attribute *hsc_handle;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] sony-laptop: support basic functions for handle 0x14B and 0x14C
2012-12-20 22:21 [PATCH 0/4] sony-laptop for 3.8 Mattia Dongili
` (2 preceding siblings ...)
2012-12-20 22:21 ` [PATCH 3/4] sony-laptop: allow reading the status of gfx switch Mattia Dongili
@ 2012-12-20 22:21 ` Mattia Dongili
3 siblings, 0 replies; 5+ messages in thread
From: Mattia Dongili @ 2012-12-20 22:21 UTC (permalink / raw)
To: Matthew Garrett; +Cc: platform-driver-x86, Mattia Dongili
Z series and other recent models have 0x14? for lid and keyboard
backlight.
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
drivers/platform/x86/sony-laptop.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 385835d..075f998 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1373,6 +1373,8 @@ static void sony_nc_function_setup(struct acpi_device *device,
break;
case 0x0137:
case 0x0143:
+ case 0x014b:
+ case 0x014c:
result = sony_nc_kbd_backlight_setup(pf_device, handle);
if (result)
pr_err("couldn't set up keyboard backlight function (%d)\n",
@@ -1435,6 +1437,8 @@ static void sony_nc_function_cleanup(struct platform_device *pd)
break;
case 0x0137:
case 0x0143:
+ case 0x014b:
+ case 0x014c:
sony_nc_kbd_backlight_cleanup(pd);
break;
default:
@@ -1479,6 +1483,8 @@ static void sony_nc_function_resume(void)
break;
case 0x0137:
case 0x0143:
+ case 0x014b:
+ case 0x014c:
sony_nc_kbd_backlight_resume();
break;
default:
@@ -2636,6 +2642,8 @@ static void sony_nc_backlight_ng_read_limits(int handle,
lvl_table_len = 9;
break;
case 0x143:
+ case 0x14b:
+ case 0x14c:
lvl_table_len = 16;
break;
}
@@ -2687,6 +2695,18 @@ static void sony_nc_backlight_setup(void)
sony_nc_backlight_ng_read_limits(0x143, &sony_bl_props);
max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
+ } else if (sony_find_snc_handle(0x14b) >= 0) {
+ ops = &sony_backlight_ng_ops;
+ sony_bl_props.cmd_base = 0x3000;
+ sony_nc_backlight_ng_read_limits(0x14b, &sony_bl_props);
+ max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
+
+ } else if (sony_find_snc_handle(0x14c) >= 0) {
+ ops = &sony_backlight_ng_ops;
+ sony_bl_props.cmd_base = 0x3000;
+ sony_nc_backlight_ng_read_limits(0x14c, &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",
&unused))) {
ops = &sony_backlight_ops;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-12-20 22:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-20 22:21 [PATCH 0/4] sony-laptop for 3.8 Mattia Dongili
2012-12-20 22:21 ` [PATCH 1/4] sony-laptop: fully enable SNY controlled modems Mattia Dongili
2012-12-20 22:21 ` [PATCH 2/4] sony-laptop: fix SNC buffer calls when SN06 returns Integers Mattia Dongili
2012-12-20 22:21 ` [PATCH 3/4] sony-laptop: allow reading the status of gfx switch Mattia Dongili
2012-12-20 22:21 ` [PATCH 4/4] sony-laptop: support basic functions for handle 0x14B and 0x14C Mattia Dongili
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.