devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: m.silentcreek-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Cc: wens-jdAy2FN1RRM@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] touchscreen: sun4i-ts: Really fix A10 temperature reporting
Date: Tue, 23 Jun 2015 13:39:23 -0700 (PDT)	[thread overview]
Message-ID: <33d3fc39-c232-4022-b7fb-47de84735987@googlegroups.com> (raw)
In-Reply-To: <5589B78C.4080600-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 5178 bytes --]

Hi,

Am Dienstag, 23. Juni 2015 21:46:25 UTC+2 schrieb Hans de Goede:
> Hi,
> 
> On 06/23/2015 05:06 PM, m.silentcreek-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
> > Hi Hans,
> >
> > is it possible that this patch (and the parent commit "Input: sun4i-ts - allow controlling filter and sensitivity via DT") has quite an adversial effect on other boards than the ones tested?
> >
> > On my Lemaker Bananapi the temperature is now being reported as somwhere between -15°C to -10°C with the latest Kernel 4.1.0. These negative values are obviously way off. On Kernel 4.0.5 the temperature reading was usually around 40°C. While that might not have been accurate either, it was at least plausible.
> 
> The temperature curve for the A20 SoC was not changed, if it did change then
> you're using an old dtb file with a new kernel, you must always update your
> dtb file together with the kernel.

I always compile the dts that comes with the kernel tree from scratch. So this is up to date. I guess I have to dig in deeper then what caused that change. Any other hint where to look for?


> 
> 
> 
> >
> > Given that there is no Documentation and things seem quite board-specific, I really don't know how this could be improved, so I can merely report my observation.
> >
> > Kind regards,
> >
> > Timo
> >
> >
> > Am Montag, 9. März 2015 10:38:02 UTC+1 schrieb Hans de Goede:
> >> The commit titled:
> >> "touchscreen: sun4i-ts: A10 (sun4i) has a different temperature curve"
> >> contains a math error, the offset it uses is in degrees, but the actual code
> >> applies the offset before multiplying by stepsize :|
> >>
> >> Given that this is rather backwards (every math course ever thought applies
> >> the multiplication before the offset for linear functions), this commit
> >> fixes things by changing the code applying the offset to do the logical
> >> thing, adjusting the offset for the other models accordingly.
> >>
> >> This has been tested on an A10, A13, A20 and A31 to make sure everything really
> >> is correct now.
> >>
> >> Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> >> ---
> >> Note if possible this commit should be squashed into the original
> >> "touchscreen: sun4i-ts: A10 (sun4i) has a different temperature curve"
> >> commit as a fixup.
> >> ---
> >>   drivers/input/touchscreen/sun4i-ts.c | 14 +++++++-------
> >>   1 file changed, 7 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c
> >> index 66ccd5a..178d2ef 100644
> >> --- a/drivers/input/touchscreen/sun4i-ts.c
> >> +++ b/drivers/input/touchscreen/sun4i-ts.c
> >> @@ -193,7 +193,7 @@ static int sun4i_get_temp(const struct sun4i_ts_data *ts, long *temp)
> >>   	if (ts->temp_data == -1)
> >>   		return -EAGAIN;
> >>
> >> -	*temp = (ts->temp_data - ts->temp_offset) * ts->temp_step;
> >> +	*temp = ts->temp_data * ts->temp_step - ts->temp_offset;
> >>
> >>   	return 0;
> >>   }
> >> @@ -255,17 +255,17 @@ static int sun4i_ts_probe(struct platform_device *pdev)
> >>   	ts->ignore_fifo_data = true;
> >>   	ts->temp_data = -1;
> >>   	if (of_device_is_compatible(np, "allwinner,sun6i-a31-ts")) {
> >> -		/* Allwinner SDK has temperature = -271 + (value / 6) (C) */
> >> -		ts->temp_offset = 1626;
> >> +		/* Allwinner SDK has temperature (C) = (value / 6) - 271 */
> >> +		ts->temp_offset = 271000;
> >>   		ts->temp_step = 167;
> >>   	} else if (of_device_is_compatible(np, "allwinner,sun4i-a10-ts")) {
> >>   		/*
> >>   		 * The A10 temperature sensor has quite a wide spread, these
> >>   		 * parameters are based on the averaging of the calibration
> >>   		 * results of 4 completely different boards, with a spread of
> >> -		 * temp_step from 96 - 170 and temp_offset from 1758 - 3310.
> >> +		 * temp_step from 0.096 - 0.170 and temp_offset from 176 - 331.
> >>   		 */
> >> -		ts->temp_offset = 2570;
> >> +		ts->temp_offset = 257000;
> >>   		ts->temp_step = 133;
> >>   	} else {
> >>   		/*
> >> @@ -273,13 +273,13 @@ static int sun4i_ts_probe(struct platform_device *pdev)
> >>   		 * the temperature. The formula used here is from the AXP209,
> >>   		 * which is designed by X-Powers, an affiliate of Allwinner:
> >>   		 *
> >> -		 *     temperature = -144.7 + (value * 0.1)
> >> +		 *     temperature (C) = (value * 0.1) - 144.7
> >>   		 *
> >>   		 * Allwinner does not have any documentation whatsoever for
> >>   		 * this hardware. Moreover, it is claimed that the sensor
> >>   		 * is inaccurate and cannot work properly.
> >>   		 */
> >> -		ts->temp_offset = 1447;
> >> +		ts->temp_offset = 144700;
> >>   		ts->temp_step = 100;
> >>   	}
> >>
> >> --
> >> 2.3.1
> >
> 
> Regards,
> 
> Hans

Thanks,

Timo

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

  parent reply	other threads:[~2015-06-23 20:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09  9:37 [PATCH] touchscreen: sun4i-ts: Really fix A10 temperature reporting Hans de Goede
     [not found] ` <1425893870-28715-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-12 21:54   ` Dmitry Torokhov
2015-06-23 15:06   ` m.silentcreek-Re5JQEeQqe8AvxtiuMwx3w
2015-06-23 19:46     ` Hans de Goede
     [not found]       ` <5589B78C.4080600-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-23 19:54         ` Dmitry Torokhov
2015-06-24  7:16           ` Hans de Goede
     [not found]             ` <558A5966.9010908-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-24  7:28               ` Maxime Ripard
2015-06-24  7:31                 ` Hans de Goede
2015-06-24 11:59               ` Timo S.
2015-06-23 20:39         ` m.silentcreek-Re5JQEeQqe8AvxtiuMwx3w [this message]
2015-06-23 21:06         ` m.silentcreek-Re5JQEeQqe8AvxtiuMwx3w

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33d3fc39-c232-4022-b7fb-47de84735987@googlegroups.com \
    --to=m.silentcreek-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=wens-jdAy2FN1RRM@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).