Is this a good first patch for enabling screen rotation?

Brock York twunknown at gmail.com
Thu Jan 29 11:45:30 EST 2015


Hello 

This is my first patch and after speaking to a few kernel
devs at LCA2015 I thought I would ask here for some advice on
if I have followed the newbie guide correctly.

The patch is to get automatic screen rotation working on a
acer iconia w500 tablet.

The patch was made against linux-next branch next-20150129
and successfully built and ran.

Do you think this is a succificient patch to get accepted by the
platform-x86 maintainers? I used get_maintainer.pl and it suggested
the platform-x86 mailing list.

Thank you, any help is much appreciated.
Regards Brock York.

BEGIN PATCH BELOW------------
Subject: [PATCH] acer-wmi: Enable screen auto-rotation via udev

Emit udev event via kobject_uevent when accelerometer position
is updated. This is to allow userspace to grab the accelerometer
position and rotate the screen accordingly.

Swap the x and y values and negate the x value converting the
accelerometers coordinate system into the coordinate system
userspace udev expects.

Accelerometer		Expected
Coordinates		Coordinates
        x+		    y+
        ^		    ^
        |		    |
        |		    |
 y+<----/		    /---->x+
       /		   /
      z+		  z+

Screen Orientation
 ________
|        |
|        |
|________|

Tested on a Acer Iconia W500 tablet with Gnome 3

Signed-off-by: Brock York <twunknown at gmail.com>
---
 drivers/platform/x86/acer-wmi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 3ac29a1..d5678e4 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -1491,12 +1491,14 @@ static int acer_gsensor_event(void)
 		return -1;
 
 	input_report_abs(acer_wmi_accel_dev, ABS_X,
-		(s16)out_obj->package.elements[0].integer.value);
+		-(s16)out_obj->package.elements[1].integer.value);
 	input_report_abs(acer_wmi_accel_dev, ABS_Y,
-		(s16)out_obj->package.elements[1].integer.value);
+		(s16)out_obj->package.elements[0].integer.value);
 	input_report_abs(acer_wmi_accel_dev, ABS_Z,
 		(s16)out_obj->package.elements[2].integer.value);
 	input_sync(acer_wmi_accel_dev);
+
+	kobject_uevent(&acer_wmi_accel_dev->dev.kobj, KOBJ_CHANGE);
 	return 0;
 }
 
-- 
2.2.2




More information about the Kernelnewbies mailing list