[Galaxy Tab  Android Development] daniel.weck:
First of all, I needed SetCPU to detect the battery temperature on my overclocked Galaxy Tab (to switch profile when overheating), so I modified my home-brewed kernel with this small patch:

http://xdaforums.com/showthread.php?p=11454036#post11454036

This is fine, but on my JMI ROM (even with the correct /system/lib/hw/sensors.default.so library), applications like "SensorTest" were not displaying the temperature from the AK8973B sensor. I found a way to fix this.

Basically, I compiled this open-source driver (or alternatively, this one), which provides a custom sensors.default.so library and akmd service executable. The former is actually not needed, only the latter needs to be run on the Tab (because the standard /dev/akm8973_daemon device node is used, via ioctl to update the /dev/input values for compass, etc.).

First, I stopped the default /system/bin/akmd2 service. I then launched the custom akm daemon, which showed wrongly-calibrated values for the compass and orientation sensors (because I entered random digital and analog gain values), but the correct temperature was displayed (actually higher than the battery one !). I then stopped akmd, and re-launched akmd2...and magic: the temperature is now picked-up correctly ! :rolleyes:

Note that the gyroscope and accelerometer sensors are *not* affected these AKM modifications (they are effectively different hardware, with different drivers). The ambient light and proximity sensors are also different hardware (the latter isn't enabled on the Tab, by the way...I suspect we need to compile/install a driver for it).

I will do more testing with akmd and akmd2, and I will probably modify my init.rc to launch the service accordingly (in my custom initramfs).

I hope this helps.

Cheers, Dan

--- EDIT ---

Mhmmm, here's an interesting update:

There is no need to compile the open-source AKM daemon ! Instead, you just need to kill the /system/bin/akmd2 process, and restart it. :rolleyes:

Well, actually it's not that simple: it only really works when the temperature sensor is polled (for example, when the SensorTest or Elixir app is displaying current values). Oh, and the temperature sensor only spits-out results when the compass sensor is also polled at the same time ! :eek: (Elixir is useful to test this, because sensors can be selectively activated)

I tried to reverse-engineer the values coming out of /dev/input/event4 (which corresponds to the compass sensor, as shown by the getevent command). I used shell commands similar to that (note the automatic conversion from hexadecimal to decimal values):

getevent | grep "/dev/input/event4:" | sed 's/ffffff//g' | awk '{print $2 " " $3 " " ("0x"$4)+0 ">" $4}'

Unfortunately my time ran out before I could make sense out the stream of values.

By the way, here is the script I used to stop+restart the AKM daemon in init.d/ :

get_akmd_pid()
{
ps -w | grep akmd2 | grep -v grep | awk '{print $1}'
}

pid=`get_akmd_pid`
echo "Killing /system/bin/akmd2 (PID: ${pid}) ..."
kill -9 $pid
pid=`get_akmd_pid`
echo "Checking that /system/bin/akmd2 process has been terminated: now PID = [${pid}] (should be empty)"
echo "Restarting /system/bin/akmd2..."
/system/bin/akmd2 &
pid=`get_akmd_pid`
echo "Checking that /system/bin/akmd2 process has been restarted: now PID = [${pid}] (should NOT be empty)"