martin-ueding / thinkpad-scripts

Screen rotation, docking and other scripts for ThinkPad® X220 and X230 Tablet
Other
132 stars 23 forks source link

Modern i2c Sensor #123

Closed sonvirgo closed 7 years ago

sonvirgo commented 7 years ago

Hello guys Can you have some words for me in case I want to find the source code for i2c rotation sensor kernel driver? Ubuntu Gnome 16.04 kernel driver work out of box with my Yoga 500 15.

martin-ueding commented 7 years ago

You are looking for the kernel driver? I am not an expert in this. Perhaps you have to look into the kernel source code? If the driver is a mainline driver, it must be somewhere in the kernel source.

We do not have any driver code in this project, we just use existing programs and parse their text output.

sonvirgo commented 7 years ago

Thabk you any way. We try to dig in the kernel source but just for hid-multitouch modules, there are 1500 lines of code

martin-ueding commented 7 years ago

I think the Linux kernel has some 16 million lines of code. Navigating such a huge codebase is not easy, for my Master thesis I have like half a million lines 😄.

sonvirgo commented 7 years ago

Could you pls assist in the idea and join us i2c-rotation

martin-ueding commented 7 years ago

What idea? I still have not understood what you are trying to achieve. Also it seems that you target macOS?

sonvirgo commented 7 years ago

Yet, I am trying to port driver source to macOS then use a script fb-rotate to imitate the rotation. I don't know whare to start. How to get the data from hardware, where is the code. I have installed Ubuntu Unity, Fedora too, but only Ubuntu Gnome has auto-rotation function. So the code is far beyond the kernel driver, some part of it must lay in Gnome shell. I have no idea where to find.

martin-ueding commented 7 years ago

What do you mean with automatic rotation, by the way? Do you mean that it rotates when you physically rotate the display to the other side? Or are we talking about rotation with respect to gravity like Android and iOS devices have?

Then you are trying to install macOS on the Yoga?

I fear that I do not have the time to help you with your project, my master thesis is taking up all me software development time 😞.

sonvirgo commented 7 years ago

I don't quite understand the different between gravity sensitive rotation or display rotation. But it has been working like this in Windows: the screen will automatically switch to tablet mode when the Yoga is folded 360 degree. In this tablet mode, the screen will automatically rotate to vertically, horizontally, 90, 180, 270 degree whenever I physically rotate the display. In the Asphalt 8 games, on Windows, some kind of accelerator sensor is working so that I can driver a car just by swinging the tablet left and right, up and down without a keyboard or a mouse. In Ubuntu Gnome, screen will rotate automatically whenever I physically rotate the display like in Windows. I have tried Androidx86 6.0RC1 on the Yoga and the screen is automatically rotate according to the display's physical rotation too. And yet, I install macOS Sierra on the Yoga, multi-touch gesture work very well, except auto-rotation. OK, so based on your current knowledge, if you have any idea, please share with us, because not many people owned and interested in 2-in-1 device.

martin-ueding commented 7 years ago

I understand, you have some internal switch that is triggered fold the display around and a gravity sensor. Both must have some sort of driver. For Linux I know that with acpi_listen, Jim managed to find the event that is triggered on folding of the X220.

For the gravity sensor, I have no idea how that would work. I have no experience with hardware drivers and I have no experience with the internals of macOS either. I'm sorry, but I do not think I could be of any help.