On 3月23日, 下午1時53分, Chinmay S <[email protected]> wrote:
> Hi Chih-Wei
> The Sensor-HAL is used as a means to abstract the kernel/hardware level
> details.
> *sensors_control_open* lies in the control path of sensor HAL.
> It is called by the sensor-service which runs as part of system_server.
> * sensors_data_open* lies in the data path of sensor HAL.
> It is called by every instance of sensor manager.
> When any apk registers for sensor data, a copy of  sensors.so (HAL)
> is attached to the process belonging to the apk.

OK, now I see.

Any document says that?

> NOTE: Even though it is a single file, there will be multiple instances of
> sensors.so
> during runtime. One for the sensor-service & one each for every app using
> sensor.
> Hence use of global variables to pass data between various functions
> ( _open, _activate, _poll etc. ) WILL fail.
> Can you tell me what you are trying to achieve?

Well, just tried to understand how sensor HAL works
exactly and avoid bugs in my libsensors.

The problem is the documents for sensor HAL
are so few and poor. The only one I found is
http://source.android.com/porting/sensors.html
but it's almost the same as sensors.h,
which doesn't say the details.

So what I can do is just read the code.
I have referred to the qemu sensors
(sdk/emulator/sensors/sensors_qemu.c)
and htc libsensors
(device/htc/passion-common/libsensors/sensors.c).
But I still don't understand many details.

Back to my problem.
As you said, my data_poll is called by multiple instances
so I saw these in the logcat

03-23 13:48:35.311 D/KbdSensor( 1871): data_poll: dev=0x82ddfb8 fd=29
03-23 13:48:36.311 D/KbdSensor( 1531): data_poll: dev=0x85c5e30 fd=77
03-23 13:48:36.311 D/KbdSensor( 1871): data_poll: dev=0x82ddfb8 fd=29
03-23 13:48:38.311 D/KbdSensor( 1871): data_poll: dev=0x82ddfb8 fd=29
03-23 13:48:38.311 D/KbdSensor( 1531): data_poll: dev=0x85c5e30 fd=77
03-23 13:48:42.321 D/KbdSensor( 1531): data_poll: dev=0x85c5e30 fd=77
03-23 13:48:42.321 D/KbdSensor( 1871): data_poll: dev=0x82ddfb8 fd=29

That means at least two instances tried to access
my sensor device (/dev/input/eventX).
That seems a conflict to me.
Should I use a mutex lock in the data_poll?
(but I don't see such a lock in the qemu or htc sensors)

Besides, when will control__activate and control__wake
be used? I saw in htc libsensor, control__wake
open the sensor devices and then close them.
Very confused...

Oh, I forgot to say I'm working on froyo.
(I know in GB or HC the sensor interfaces have changed
a lot. OMG...)

-- 
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting

Reply via email to