Skip to contentSkip to conversation

lis3lv02d: add axes knowledge of HP Pavilion dv5 models

PATCH Superseded Giuseppe Bilotta 5 participants 27 messages Feb 7, 2009 – Feb 10, 2009 3 messages not in the archive Hardware monitoring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lis3lv02d: add axes knowledge of HP Pavilion dv5 models

Add support for HP Pavlion dv5 models, whose sensor has an inverted x axis.

---
My HP Pavilion dv5 has an inverted x axis of the accelerometer, so this patch marks the inversion for all the dv5. I can include the full dmidecode output if this is deemed necessary.

With the laptop standing still on my desk jstest reports X and Y values fluctuating from -8k to +8k (more or less). I assume this is normal?

 drivers/hwmon/hp_accel.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/hwmon/hp_accel.c +1 -0
index abf4dfc..5a379bd 100644
@@ -179,6 +179,7 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = {
 	AXIS_DMI_MATCH("NC673x", "HP Compaq 673", xy_rotated_left_usd),
 	AXIS_DMI_MATCH("NC651xx", "HP Compaq 651", xy_rotated_right),
 	AXIS_DMI_MATCH("NC671xx", "HP Compaq 671", xy_swap_yz_inverted),
+	AXIS_DMI_MATCH("HPDV5", "HP Pavilion dv5", x_inverted),
 	{ NULL, }
 /* Laptop models without axis info (yet):
  * "NC6910" "HP Compaq 6910"
Signature · 1 line
1.6.1.399.g0d272
Acked-by on v1 1/1
#1 lore raw

Giuseppe Bilotta schreef:

Quoted 4 lines

Add support for HP Pavlion dv5 models, whose sensor has an inverted x axis.

Looks good.
Andrew, would you mind queuing it?

Quoted 7 lines

---
My HP Pavilion dv5 has an inverted x axis of the accelerometer, so this patch marks the inversion for all the dv5. I can include the full dmidecode output if this is deemed necessary.

With the laptop standing still on my desk jstest reports X and Y values fluctuating from -8k to +8k (more or less). I assume this is normal?

What does "k" stands for? If that's the unit of the joystick output:
yes, that's perfectly normal, just some noise/vibration. If that's 1000, it's far too much to be normal.

Eric

#2 lore raw
Quoted 14 lines · Éric Piel

Giuseppe Bilotta schreef:

Quoted 4 lines

Add support for HP Pavlion dv5 models, whose sensor has an inverted x axis.

Looks good.
Andrew, would you mind queuing it?

Quoted 5 lines

---
My HP Pavilion dv5 has an inverted x axis of the accelerometer, so this patch marks the inversion for all the dv5. I can include the full dmidecode output if this is deemed necessary.

Quoted 5 lines
Quoted 2 lines

With the laptop standing still on my desk jstest reports X and Y values fluctuating from -8k to +8k (more or less). I assume this is normal?

What does "k" stands for? If that's the unit of the joystick output:
yes, that's perfectly normal, just some noise/vibration. If that's 1000, it's far too much to be normal.

k is for thousands. I thought it could have been normal because someone (Pavel?) mentioned the disk park script trigged even if he was just walking around, so I just assumed the sensor to be extremely sensible. OTOH the maximum range of the sensor, as reported by jstest, seems to be -32k to +32k, and 8k is about one forth of it. Considering sometimes the fluctuations even peak to 12k, there might be something else at play here. Any suggestions on helping debug the issue are welcome.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#3 lore raw
Quoted 17 lines · Éric Piel
Quoted 16 lines

Giuseppe Bilotta schreef:

Quoted 4 lines

Add support for HP Pavlion dv5 models, whose sensor has an inverted x axis.

Looks good.
Andrew, would you mind queuing it?

Quoted 7 lines

---
My HP Pavilion dv5 has an inverted x axis of the accelerometer, so this patch marks the inversion for all the dv5. I can include the full dmidecode output if this is deemed necessary.

With the laptop standing still on my desk jstest reports X and Y values fluctuating from -8k to +8k (more or less). I assume this is normal?

Quoted 7 lines
Quoted 3 lines

What does "k" stands for? If that's the unit of the joystick output:
yes, that's perfectly normal, just some noise/vibration. If that's 1000, it's far too much to be normal.

k is for thousands. I thought it could have been normal because someone (Pavel?) mentioned the disk park script trigged even if he was just walking around, so I just assumed the sensor to be extremely

I believe that it is designed to trigger at walking.

Quoted 5 lines

sensible. OTOH the maximum range of the sensor, as reported by jstest, seems to be -32k to +32k, and 8k is about one forth of it. Considering sometimes the fluctuations even peak to 12k, there might be something else at play here. Any suggestions on helping debug the issue are welcome.

Ok, at my machine it fluctuates around 1K when sitting on the desk, and maximum range is about 13-15K. So your values seem little too noisy.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#4 lore raw

2009/2/9 Pavel Machek <[email protected]>:

Quoted 2 lines

Ok, at my machine it fluctuates around 1K when sitting on the desk, and maximum range is about 13-15K. So your values seem little too noisy.

I suspected as much. Do you think this is a hardware problem, or something that can be worked around in software? Or maybe I just leave in a very shaky neighborohood (although there's little or no car traffic around here) ...

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#5 lore raw
Quoted 8 lines

2009/2/9 Pavel Machek <[email protected]>:

Quoted 2 lines

Ok, at my machine it fluctuates around 1K when sitting on the desk, and maximum range is about 13-15K. So your values seem little too noisy.

I suspected as much. Do you think this is a hardware problem, or something that can be worked around in software? Or maybe I just leave in a very shaky neighborohood (although there's little or no car traffic around here) ...

I'd say that the driver is way too new to suspect hardware problems. Could you try the new version from -mm? It does very minimum setup, as recommended by HP...
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw
Quoted 4 lines · Pavel Machek
Quoted 4 lines

2009/2/9 Pavel Machek <[email protected]>:

Quoted 2 lines

Ok, at my machine it fluctuates around 1K when sitting on the desk, and maximum range is about 13-15K. So your values seem little too noisy.

Quoted 8 lines
Quoted 4 lines

I suspected as much. Do you think this is a hardware problem, or something that can be worked around in software? Or maybe I just leave in a very shaky neighborohood (although there's little or no car traffic around here) ...

I'd say that the driver is way too new to suspect hardware problems. Could you try the new version from -mm? It does very minimum setup, as recommended by HP...

I can try, but I have never worked with the -mm tree, so I don't even know where to get it. Is there a webpage or archived email I can read to understand how to get and build the -mm tree? Is it git-tracked? Or can I just get your patches for -mm and apply them on top of the current git?

I will try this patch
http://lkml.indiana.edu/hypermail/linux/kernel/0901.2/00164.html in the mean time, in case that's the patch which is in -mm.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#8 lore raw
Quoted 7 lines
Quoted 3 lines · Giuseppe Bilotta

I will try this patch
http://lkml.indiana.edu/hypermail/linux/kernel/0901.2/00164.html in the mean time, in case that's the patch which is in -mm.

With that patch I still get the same range of fluctuations.

Yeah, that patch. Not sure what to do next... you could grab lis3 manual and see if you can setup chip by hand to get better results...

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#9 lore raw
Quoted 3 lines · Pavel Machek

Yeah, that patch. Not sure what to do next... you could grab lis3 manual and see if you can setup chip by hand to get better results...

As Eric pointed out, it looks definitely like an endianness problem, although there are a few strange things which are happening at the same time. Is the lis3 manual available online somewhere, or can I request it to the mfgr?

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#10 lore raw

Giuseppe Bilotta schreef:

Quoted 8 lines · Pavel Machek
Quoted 2 lines

Yeah, that patch. Not sure what to do next... you could grab lis3 manual and see if you can setup chip by hand to get better results...

As Eric pointed out, it looks definitely like an endianness problem, although there are a few strange things which are happening at the same time. Is the lis3 manual available online somewhere, or can I request it to the mfgr?

It's freely available at the original manufacturer website:
http://www.st.com/stonline/products/literature/ds/11115.htm

Eric

#11 lore raw
In reply to Giuseppe Bilotta
Quoted 9 lines · Giuseppe Bilotta
Quoted 3 lines · Pavel Machek

Yeah, that patch. Not sure what to do next... you could grab lis3 manual and see if you can setup chip by hand to get better results...

As Eric pointed out, it looks definitely like an endianness problem, although there are a few strange things which are happening at the same time. Is the lis3 manual available online somewhere, or can I request it to the mfgr?

'k, found it on the STMicroelectronics website. Reading the doc about LIS3LV02DL I see that WHO_AM_I should return 3Ah, but my sensor returns 3Bh. I'll see if I find the correct datasheet for this one instead, it might have info about the differences.

One thing that I noticed is that (modulo axis inversion) I'm able to use the sensor correctly if I set the thing to only use the high byte, totally discarding the lower byte:

	return *((s8*)(&hi));

Maybe this sensor needs a different setup to return 12 instead of 8 bits of information.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#12 lore raw

Giuseppe Bilotta schreef:

Quoted 10 lines
Quoted 7 lines · Giuseppe Bilotta
Quoted 2 lines · Pavel Machek

Yeah, that patch. Not sure what to do next... you could grab lis3 manual and see if you can setup chip by hand to get better results...

As Eric pointed out, it looks definitely like an endianness problem, although there are a few strange things which are happening at the same time. Is the lis3 manual available online somewhere, or can I request it to the mfgr?

Quoted 4 lines

'k, found it on the STMicroelectronics website. Reading the doc about LIS3LV02DL I see that WHO_AM_I should return 3Ah, but my sensor returns 3Bh. I'll see if I find the correct datasheet for this one instead, it might have info about the differences.

Yeah, we accept also 3Bh for the who_am_i (see in hp_accel.c). The reporter who had a laptop with such chip never reported any problem and I didn't pay attention enough to notice those chips have only 8bits precision.

Quoted 6 lines

One thing that I noticed is that (modulo axis inversion) I'm able to use the sensor correctly if I set the thing to only use the high byte, totally discarding the lower byte:

	return *((s8*)(&hi));

Maybe this sensor needs a different setup to return 12 instead of 8 bits of information.

So you probably have a lis202dl (which has only two axes of 8bits each) or a LIS302DL (3 axes of 8 bits):
http://www.st.com/stonline/products/literature/ds/13624/lis202dl.htm
http://www.st.com/stonline/products/literature/ds/12726/lis302dl.htm

Unfortunately, the WHO_AM_I register returns 3Bh in both cases. I'd tend to imagine it's a three axes chip, but you can confirm that by just checking if Z has any meaningful value. You can then modify lis3lv02d_read_16() to only return the byte as low byte and the high byte as FFh if the high bit of the value is set (because I guess they are signed integers). You also have to change MDPS_MAX_VAL to 128, to get things completely right.

Once we have this sorted, we should add a flag to know if the current device is 8 bits or 12 bits, depending on the value of who_am_i. This would allow the driver to work fine with both type of chip.

Eric

#13 lore raw
In reply to Giuseppe Bilotta
Quoted 17 lines · On Tue, 10 Feb 2009 23:48:14 +0100 Giuseppe Bilotta…
Quoted 9 lines · Giuseppe Bilotta
Quoted 3 lines · Pavel Machek

Yeah, that patch. Not sure what to do next... you could grab lis3 manual and see if you can setup chip by hand to get better results...

As Eric pointed out, it looks definitely like an endianness problem, although there are a few strange things which are happening at the same time. Is the lis3 manual available online somewhere, or can I request it to the mfgr?

'k, found it on the STMicroelectronics website. Reading the doc about LIS3LV02DL I see that WHO_AM_I should return 3Ah, but my sensor returns 3Bh. I'll see if I find the correct datasheet for this one instead, it might have info about the differences.

Quoted 7 lines

One thing that I noticed is that (modulo axis inversion) I'm able to use the sensor correctly if I set the thing to only use the high byte, totally discarding the lower byte:

	return *((s8*)(&hi));

Maybe this sensor needs a different setup to return 12 instead of 8 bits of information.

I've lost the plot here. I still intend to merge lis3lv02d-add-axes-knowledge-of-hp-pavilion-dv5-models.patch into 2.6.29. Someone please stop me if that is wrong.

#14 lore raw

Andrew Morton schreef:

Quoted 25 lines
Quoted 14 lines · On Tue, 10 Feb 2009 23:48:14 +0100 Giuseppe Bilotta…
Quoted 7 lines · Giuseppe Bilotta
Quoted 2 lines · Pavel Machek

Yeah, that patch. Not sure what to do next... you could grab lis3 manual and see if you can setup chip by hand to get better results...

As Eric pointed out, it looks definitely like an endianness problem, although there are a few strange things which are happening at the same time. Is the lis3 manual available online somewhere, or can I request it to the mfgr?

'k, found it on the STMicroelectronics website. Reading the doc about LIS3LV02DL I see that WHO_AM_I should return 3Ah, but my sensor returns 3Bh. I'll see if I find the correct datasheet for this one instead, it might have info about the differences.

Quoted 7 lines

One thing that I noticed is that (modulo axis inversion) I'm able to use the sensor correctly if I set the thing to only use the high byte, totally discarding the lower byte:

	return *((s8*)(&hi));

Maybe this sensor needs a different setup to return 12 instead of 8 bits of information.

Quoted 3 lines

I've lost the plot here. I still intend to merge lis3lv02d-add-axes-knowledge-of-hp-pavilion-dv5-models.patch into 2.6.29. Someone please stop me if that is wrong.

Hi Andrew,
No, let's wait to get things settle down. You can discard the current patch. I think we should manage to get it working eventually, but the patch will be much bigger...

Eric

#15 lore raw
In reply to Giuseppe Bilotta

Giuseppe Bilotta schreef:

Quoted 10 lines
Quoted 7 lines · Giuseppe Bilotta
Quoted 2 lines · Pavel Machek

Yeah, that patch. Not sure what to do next... you could grab lis3 manual and see if you can setup chip by hand to get better results...

As Eric pointed out, it looks definitely like an endianness problem, although there are a few strange things which are happening at the same time. Is the lis3 manual available online somewhere, or can I request it to the mfgr?

Quoted 4 lines

'k, found it on the STMicroelectronics website. Reading the doc about LIS3LV02DL I see that WHO_AM_I should return 3Ah, but my sensor returns 3Bh. I'll see if I find the correct datasheet for this one instead, it might have info about the differences.

Ah, yes, that would explain a lots of things! Your chip is 8bits! The original reporter had not reported anything and I didn't pay attention to this "little" detail when comparing the specs.

Quoted 6 lines

One thing that I noticed is that (modulo axis inversion) I'm able to use the sensor correctly if I set the thing to only use the high byte, totally discarding the lower byte:

	return *((s8*)(&hi));

Maybe this sensor needs a different setup to return 12 instead of 8 bits of information.

So you either have the lis302dl or the lis202dl (2 axes only):
http://www.st.com/stonline/products/literature/ds/12726/lis302dl.htm
http://www.st.com/stonline/products/literature/ds/13624/lis202dl.htm

I'd guess you have the one with 3 axes as all the axes had changing values. More optimistically I'll imagine that no HP laptop has the 2D chip, which unfortunately share the same who_am_i value.

So to get it working you need to change the lis3lv02d_read_16() function to only read the low byte and put the high byte to FFh if the high bit (80h) is set (I guess it's a signed integer). Then for completeness you need to put MDPS_MAX_VAL to 128.

Does it work?

Once this is verified, you should add a flag in the driver for the device to know whether it's 8bits or 12bits. This would be set at initialization according to the who_am_i value.

Eric

A message that is not in the archive (sent off-list or not yet received): [email protected]

#17 lore raw

Palatis Tseng schreef:

Quoted 11 lines

Éric Piel 提到:

Quoted 7 lines
Quoted 2 lines

With the laptop standing still on my desk jstest reports X and Y values fluctuating from -8k to +8k (more or less). I assume this is normal?

What does "k" stands for? If that's the unit of the joystick output:
yes, that's perfectly normal, just some noise/vibration. If that's 1000, it's far too much to be normal.

Eric

"k" is for kilo, which means 1000.
I verified this and found out that i've made a mistake. following the steps in

:
No problem, the patch from Giuseppe will get the axex fine :-)

However, could you let use know if you too, on your laptop, have huge fluctuations even when the laptop is not moving? Could you give an idea of the minimum and maximum values of each axis when the laptop is set normally on the desk without touching it?

Thanks,
Eric

A message that is not in the archive (sent off-list or not yet received): [email protected]

#19 lore raw

(putting back the cc's, please keep them when answering)

Palatis Tseng schreef:

Quoted 20 lines

Éric Piel 提到:

Quoted 9 lines

No problem, the patch from Giuseppe will get the axex fine :-)

However, could you let use know if you too, on your laptop, have huge fluctuations even when the laptop is not moving? Could you give an idea of the minimum and maximum values of each axis when the laptop is set normally on the desk without touching it?

Thanks,
Eric

I took a look at the patch but my axis on dv5 is Y_inverted (instead of X_inverted.) i patched my lis3lv02d.c and added:

=== cut here ===
AXIS_DMI_MATCH("HPDV5", "HP Pavilion dv5", y_inverted),
=== cut here ===

and neverball worked just correct with it so i'm kinda sure my patch about the axis should be correct.

Quoted 8 lines

i've also tested with x_inverted, but whenever i evaluate the left side of my notebook the ball goes to the left side too which is not real-world behavier.

mine is a HP Pavilion dv5 1003ax with AMD PUMA platform. `dmidecode | grep "Product Name" says:
(under "System Information"...)
Product Name: HP Pavilion dv5 Notebook PC

Giuseppe,
Palatis mentions that on his laptop the sensor is actually y_inverted. Could you check your laptop? In particular it would be nice if you could
describe the values for the four positions defined in the documentation
file. BTW, what is the exact version of your laptop? Is it the same as Palatis?

Palatis, could you let us know if you also have a lot of "noise" in the values. That is, if when using jstest /dev/input/js0 you see big changes in the values. Is it like on Giuseppe's laptop of around 8000?

Moreover I'm wondering if this could be an error on LSB/MSB ordering. Maybe looking at the raw values (cat /sys/devices/platform/lis3lv02d/position) would give more insight...

See you,
Eric

#20 lore raw
Quoted 31 lines · Éric Piel

(putting back the cc's, please keep them when answering)

Palatis Tseng schreef:

Quoted 20 lines

Éric Piel 提到:

Quoted 9 lines

No problem, the patch from Giuseppe will get the axex fine :-)

However, could you let use know if you too, on your laptop, have huge fluctuations even when the laptop is not moving? Could you give an idea of the minimum and maximum values of each axis when the laptop is set normally on the desk without touching it?

Thanks,
Eric

I took a look at the patch but my axis on dv5 is Y_inverted (instead of X_inverted.) i patched my lis3lv02d.c and added:

=== cut here ===
AXIS_DMI_MATCH("HPDV5", "HP Pavilion dv5", y_inverted),
=== cut here ===

and neverball worked just correct with it so i'm kinda sure my patch about the axis should be correct.

Quoted 8 lines

i've also tested with x_inverted, but whenever i evaluate the left side of my notebook the ball goes to the left side too which is not real-world behavier.

mine is a HP Pavilion dv5 1003ax with AMD PUMA platform. `dmidecode | grep "Product Name" says:
(under "System Information"...)
Product Name: HP Pavilion dv5 Notebook PC

Quoted 6 lines

Giuseppe,
Palatis mentions that on his laptop the sensor is actually y_inverted. Could you check your laptop? In particular it would be nice if you could
describe the values for the four positions defined in the documentation
file. BTW, what is the exact version of your laptop? Is it the same as Palatis?

With my patch applied:

Left raised: 0 -> 32k
Right raised: 0 -> -32k

Front raised: 1 -> -32k
back raised: 1 -> 32k

Upside down: 2 -> 32k

So it seems that my model inverts the Z axis too, I'll have to fix that. However, this last test is tricky because unless the laptop is completely upside down the Z axis can go from -32k to +32k with just a couple of degrees (around the 90°)

I'll update my patch to invert the X and Z axis for my model.

Quoted 7 lines

Palatis, could you let us know if you also have a lot of "noise" in the values. That is, if when using jstest /dev/input/js0 you see big changes in the values. Is it like on Giuseppe's laptop of around 8000?

Moreover I'm wondering if this could be an error on LSB/MSB ordering. Maybe looking at the raw values (cat /sys/devices/platform/lis3lv02d/position) would give more insight...

amd64 architecture here. Laptop flat:

oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,256,14592)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(0,256,14848)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,256,14848)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,0,14336)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,512,14336)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(256,256,14592)

Left edge raised:

oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(5120,512,13312)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(5632,512,13312)

You might be onto something.

The dmi for my Pavilion is:

Handle 0x0001, DMI type 1, 27 bytes
System Information
Manufacturer: Hewlett-Packard
Product Name: HP Pavilion dv5 Notebook PC
Version: F.09
Serial Number: (x-ed out)
UUID: (x-ed out)
Wake-up Type: Power Switch
SKU Number: (x-ed out)
Family: 103C_5335KV

So it might be that different pavilions have different sensors?

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#21 lore raw

Giuseppe Bilotta schreef:
:

Quoted 9 lines

With my patch applied:

Left raised: 0 -> 32k
Right raised: 0 -> -32k

Front raised: 1 -> -32k
back raised: 1 -> 32k

Quoted 8 lines

Upside down: 2 -> 32k

So it seems that my model inverts the Z axis too, I'll have to fix that. However, this last test is tricky because unless the laptop is completely upside down the Z axis can go from -32k to +32k with just a couple of degrees (around the 90°)

I'll update my patch to invert the X and Z axis for my model.

Let's have a look at this once the "big noise" problem is fixed, because for now it's rather impossible to deduce anything meaningful.

Andrew, could you drop the patch in the mean time?

Quoted 24 lines
Quoted 8 lines

Palatis, could you let us know if you also have a lot of "noise" in the values. That is, if when using jstest /dev/input/js0 you see big changes in the values. Is it like on Giuseppe's laptop of around 8000?

Moreover I'm wondering if this could be an error on LSB/MSB ordering. Maybe looking at the raw values (cat /sys/devices/platform/lis3lv02d/position) would give more insight...

amd64 architecture here. Laptop flat:

oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,256,14592)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(0,256,14848)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,256,14848)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,0,14336)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,512,14336)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(256,256,14592)
Quoted 7 lines

Left edge raised:

oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(5120,512,13312)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(5632,512,13312)

You might be onto something.

Yes, beautiful! All are multiples of 2⁸, so much a sign of MSB/LSB inversion! And the good news is that the device just happens to have a register to set the endianess: CTRL2/BLE . For now, in the driver, we expect the device to be little endian (which is the default according to the manual). So at initialization we could force the endianess and see if that fix the problem.

Can you try something like this in lis3lv02d_poweron():

	adev.read(handle, CTRL_REG2, &val);
	val |= CTRL2_BDU | CTRL2_IEN;
+	val &= ~CTRL2_BLE;
	adev.write(handle, CTRL_REG2, val);

Eric

begin:vcard
fn;quoted-printable:=C3=89ric Piel n;quoted-printable:Piel;=C3=89ric
org:Technical University of Delft;Software Engineering Research Group adr:HB 08.080;;Mekelweg 4;Delft;;2628 CD;The Netherlands email;internet:[email protected]
tel;work:+31 15 278 6338
tel;cell:+31 6 2437 9135
x-mozilla-html:FALSE
url:http://pieleric.free.fr
version:2.1
end:vcard

#22 lore raw
Quoted 28 lines · Éric Piel

Giuseppe Bilotta schreef:

Quoted 13 lines
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,256,14592)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(0,256,14848)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,256,14848)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,0,14336)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(-256,512,14336)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(256,256,14592)
Quoted 7 lines

Left edge raised:

oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(5120,512,13312)
oblomov@oblomov:~$ cat /sys/devices/platform/lis3lv02d/position
(5632,512,13312)

You might be onto something.

Yes, beautiful! All are multiples of 2⁸, so much a sign of MSB/LSB inversion! And the good news is that the device just happens to have a register to set the endianess: CTRL2/BLE . For now, in the driver, we expect the device to be little endian (which is the default according to the manual). So at initialization we could force the endianess and see if that fix the problem.

Quoted 5 lines

Can you try something like this in lis3lv02d_poweron():

       adev.read(handle, CTRL_REG2, &val);
       val |= CTRL2_BDU | CTRL2_IEN;
+       val &= ~CTRL2_BLE;
       adev.write(handle, CTRL_REG2, val);

I reverted both my patch and the 'minimal init' patch from Pavel, then added this line. However, it seems to change nothing. Even using CTRL2_BLE instead of its negation doesn't seem to change much: same fluctuations, and cat'ing the sysfs file still gives 256, 512 etc.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#23 lore raw
Quoted 4 lines · Giuseppe Bilotta

I reverted both my patch and the 'minimal init' patch from Pavel, then added this line. However, it seems to change nothing. Even using CTRL2_BLE instead of its negation doesn't seem to change much: same fluctuations, and cat'ing the sysfs file still gives 256, 512 etc.

Discard this, I'm an idiot and I'm not doing the testing properly. BRB.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#24 lore raw
In reply to Éric Piel
Quoted 5 lines · Éric Piel

Can you try something like this in lis3lv02d_poweron():

       adev.read(handle, CTRL_REG2, &val);
       val |= CTRL2_BDU | CTRL2_IEN;
+       val &= ~CTRL2_BLE;
       adev.write(handle, CTRL_REG2, val);

Ok, this is getting crazier and crazier. Apparently, setting the CTRL2_BLE bit this way makes no difference, and so does setting it with val |= (i.e. enabling it): in both cases, if I debug lis3lv02d_read_16 I always get 0 in the lower byte and something in the upper byte.

By forcefully swapping lo and hi I actually get very little fluctuations in the Y and Z axes (so small that jstest doesn't detect them), but I still get huge (4k) fluctuations in the X axis:
apparently, this axis has very small SIGNED fluctuations around the 0, which translate to fluctuations between 255 and 1

Now, the lo/hi thing might be solved some other way (e.g. by checking the BLE bit and relying on its setting instead of trying to force it, and then swapping hi and lo as needed). But how do we solve the SIGNEDNESS of lo ?

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#25 lore raw
Quoted 7 lines · Giuseppe Bilotta
Quoted 5 lines · Éric Piel

Can you try something like this in lis3lv02d_poweron():

       adev.read(handle, CTRL_REG2, &val);
       val |= CTRL2_BDU | CTRL2_IEN;
+       val &= ~CTRL2_BLE;
       adev.write(handle, CTRL_REG2, val);
Quoted 5 lines

Ok, this is getting crazier and crazier. Apparently, setting the CTRL2_BLE bit this way makes no difference, and so does setting it with val |= (i.e. enabling it): in both cases, if I debug lis3lv02d_read_16 I always get 0 in the lower byte and something in the upper byte.

To be precise, these are the result I get with some additional debug info, with and without setting BLE.

Setting BLE on init:

[ 2891.428798] lis3lv02d: BLE: 0
[ 2891.452567] lis3lv02d: BLE: 32
[ 2891.476800] lis3lv02d: lo: 0 hi: 1
[ 2891.500616] lis3lv02d: lo: 0 hi: 3
[ 2891.524799] lis3lv02d: lo: 0 hi: 57

Resetting BLE on init:

[ 3006.661279] lis3lv02d: BLE: 0
[ 3006.684574] lis3lv02d: BLE: 0
[ 3006.709107] lis3lv02d: lo: 0 hi: 254
[ 3006.733144] lis3lv02d: lo: 0 hi: 2
[ 3006.757286] lis3lv02d: lo: 0 hi: 56

So it looks like (1) the BLE register is ignored (at least in my sensor) and (2) it actually defaults to LE anyway.

Signature · 1 line
Giuseppe "Oblomov" Bilotta
#26 lore raw
In reply to Giuseppe Bilotta
Quoted 11 lines

Add support for HP Pavlion dv5 models, whose sensor has an inverted x axis.

---
My HP Pavilion dv5 has an inverted x axis of the accelerometer, so this patch marks the inversion for all the dv5. I can include the full dmidecode output if this is deemed necessary.

With the laptop standing still on my desk jstest reports X and Y values fluctuating from -8k to +8k (more or less). I assume this is normal?

Well, on hp2140 it fluctuates 1000+-500 or so... But Z axis is still significantly different.

How much is 7 while in "steady state" for you?
Pavel

Quoted 15 lines
 drivers/hwmon/hp_accel.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/hwmon/hp_accel.c +1 -0
index abf4dfc..5a379bd 100644
@@ -179,6 +179,7 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = {
 	AXIS_DMI_MATCH("NC673x", "HP Compaq 673", xy_rotated_left_usd),
 	AXIS_DMI_MATCH("NC651xx", "HP Compaq 651", xy_rotated_right),
 	AXIS_DMI_MATCH("NC671xx", "HP Compaq 671", xy_swap_yz_inverted),
+	AXIS_DMI_MATCH("HPDV5", "HP Pavilion dv5", x_inverted),
 	{ NULL, }
 /* Laptop models without axis info (yet):
  * "NC6910" "HP Compaq 6910"
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#27 lore raw
Quoted 9 lines · Pavel Machek
Quoted 9 lines

Add support for HP Pavlion dv5 models, whose sensor has an inverted x axis.

---
My HP Pavilion dv5 has an inverted x axis of the accelerometer, so this patch marks the inversion for all the dv5. I can include the full dmidecode output if this is deemed necessary.

Quoted 8 lines
Quoted 2 lines

With the laptop standing still on my desk jstest reports X and Y values fluctuating from -8k to +8k (more or less). I assume this is normal?

Well, on hp2140 it fluctuates 1000+-500 or so... But Z axis is still significantly different.

How much is 7 while in "steady state" for you?
Pavel

Assuming 7 here means Z, the Z axis fluctuates in the + range. All three axis seem to hold to 4k most of the time (+ or - for X and Y, only + for Z), with not infrequent peaks of 8k (+ or - for X and Y, only + for Z), and seldom peaks at around 12k. Z seems to peak to 12k more often, I only rarely manage to see X or Y peaking so high.

Signature · 1 line
Giuseppe "Oblomov" Bilotta

A message that is not in the archive (sent off-list or not yet received): [email protected]

#29 lore raw
Quoted 5 lines · Jaswinder Singh Rajput
Quoted 3 lines · Giuseppe Bilotta

Add support for HP Pavlion dv5 models, whose sensor has an inverted x axis.

How can I test this patch on HP dv5-1002us laptop.

lspnp (run by root, most likely) should show a device HPQ0004. If it's present you have the sensor. I also have a big horrible sticker on my palm rest advertising the protectsmart feature.

(Please use Reply-All)

Signature · 1 line
Giuseppe "Oblomov" Bilotta