Bug 5329 - (int-145212) Provide real accelerometer device (via /dev/input* devices) instead of forcing D-Bus
(int-145212)
: Provide real accelerometer device (via /dev/input* devices) instead of forcin...
Status: NEW
Product: Core
Kernel
: 5.0/(1.2009.41-10)
: All Maemo
: Low normal with 9 votes (vote)
: ---
Assigned To: unassigned
: linux-kernel-bugs
:
: performance
:
:
  Show dependency tree
 
Reported: 2009-10-12 15:20 UTC by luarvique
Modified: 2009-11-05 11:17 UTC (History)
2 users (show)

See Also:


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description luarvique (reporter) 2009-10-12 15:20:47 UTC
SOFTWARE VERSION:
1.2009.41-10

STEPS TO REPRODUCE THE PROBLEM:
Try using accelerometer API from an application

EXPECTED OUTCOME:
There is a /dev/accelerometer device that can be opened and repeatedly read,
with read() or ioctl(). It returns accelerometer data in binary format. The
accelerometer is powered down once all instances of the device are closed. It
is powered up when someone opens the device.

ACTUAL OUTCOME:
There are two APIs for accessing the accelerometer: the DBus and the SYSFS. The
first one requires the programmer to initialize and support DBus in his
application. The second one requires the programmer to repeatedly open/close
the file and parse character strings. Enabling/disabling the accelerometer is
now only possible via DBus call.

REPRODUCIBILITY:
always
Comment 1 Riku Voipio 2009-10-12 17:43:27 UTC
/dev/accelerometer would be BAD (tm) as it would not be standard linux API.

Instead it should be a input device like all the other lis3lv02 accelerometers
supported by linux.
Comment 2 luarvique (reporter) 2009-10-12 17:53:45 UTC
(In reply to comment #1)
> /dev/accelerometer would be BAD (tm) as it would not be standard linux API.
> Instead it should be a input device like all the other lis3lv02 accelerometers
> supported by linux.
If there is a standard device-based API already, I fully support using that
API.
Comment 3 Andre Klapper maemo.org 2009-10-12 21:49:38 UTC
So what is the exact proposal here if /dev/accelerometer is not good?
And what are good reasons for a developer to NOT use the existing D-Bus
interface?
Please elaborate - with real usecases it's way easier to convince people.
Comment 4 luarvique (reporter) 2009-10-12 22:18:46 UTC
(In reply to comment #3)
> So what is the exact proposal here if /dev/accelerometer is not good?
The current Linux support for accelerometers works via /dev/input* devices. For
details on this support, check out

/usr/include/linux/input.h

and the related documentation on the Net. Basically, there is a possibility to
return rotation events for all three axis. The accelerometer should generate
these events.

> And what are good reasons for a developer to NOT use the existing D-Bus
> interface?
> Please elaborate - with real usecases it's way easier to convince people.
The DBus interface requires you to initialize and support DBus API in your
software. Furthermore, using DBus costs more than opening and reading a simple
device file. Finally, you need separate DBus messages to actually read the
accelerometer and to indicate that you are using/not-using it.

As there is a simple, standard, and well known input events based API for
accelerometers in Linux, creating convoluted DBus-bound API makes no technical
sense.
Comment 5 luarvique (reporter) 2009-10-13 00:13:18 UTC
Additional justification for NOT using DBus, quoting from Maemo Development
Guide at 

http://maemo.org/maemo_release_documentation/maemo4.1.x/node16.html#SECTION001633100000000000000

"The D-BUS system bus should not be used for heavy messaging or regular
transfers of large amounts of data, because it slows down the communication of
other processes and requires extra processing power (and with it, electrical
power). For that purpose, using a Unix socket, pipe, shared memory or file
should be considered."
Comment 6 Riku Voipio 2009-10-13 10:51:28 UTC
(In reply to comment #3)
> So what is the exact proposal here if /dev/accelerometer is not good?
> And what are good reasons for a developer to NOT use the existing D-Bus
> interface?

1) Quering the orientation over dbus causes way too much latency. 
2) the dbus api is non-standard, requiring extra porting effort in case of
application already supports accelerometers.
Comment 7 Andre Klapper maemo.org 2009-10-13 12:55:47 UTC
(In reply to comment #4)
> As there is a simple, standard, and well known input events based API for
> accelerometers in Linux

Any URLs describing this/providing more info?
Comment 8 luarvique (reporter) 2009-10-13 14:50:05 UTC
(In reply to comment #7)
> (In reply to comment #4)
> > As there is a simple, standard, and well known input events based API for
> > accelerometers in Linux
> Any URLs describing this/providing more info?
Check input and joystick documents here:

http://www.mjmwired.net/kernel/Documentation/input

The accelerometer is basically a 3-axis analog joystick. Really adventurous may
consider adding proximity sensor, kickstand switch, and/or camera switch as
joystick "buttons".
Comment 9 pepitoe 2009-11-05 11:17:50 UTC
*** This bug has been confirmed by popular vote. ***