All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Zhang Jie <zhangjie14@huaqin.corp-partner.google.com>,
	Hans de Goede <johannes.goede@oss.qualcomm.com>,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	gwendal@chromium.org, swboyd@chromium.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org,
	"Joseph S. Barrera III" <joebar@chromium.org>
Subject: Re: [PATCH] iio: proximity: sx9324: Correct proximity channel resolution
Date: Wed, 19 Aug 2026 02:18:26 +0100	[thread overview]
Message-ID: <20260819021826.702ceeaf@jic23-huawei> (raw)
In-Reply-To: <aoQXPzFaMBpD2eC8@ashevche-desk.local>

On Tue, 18 Aug 2026 11:26:39 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Tue, Aug 18, 2026 at 03:28:03PM +0800, Zhang Jie wrote:
> > The proximity channels were previously defined with 12 realbits.
> > However, PROXDIFF is read from RegDiffMsb (0x65) and RegDiffLsb
> > (0x66). The SX9324 datasheet assigns bits 7:0 of each register to
> > PROXDIFF and documents it as a signed two's-complement value
> > (Revision 3, Section 8, Table 8, page 43). In contrast, RegOffsetMsb
> > explicitly marks bits 7:6 as reserved. Thus, PROXDIFF is a 16-bit
> > signed value.
> > 
> > With realbits = 12, sx_common_read_proximity() uses bit 11 as the
> > sign bit in sign_extend32(), causing samples outside the 12-bit
> > signed range to wrap into the [-2048, 2047] range.
> > 
> > Correct the realbits value to 16 to accurately reflect the hardware.  
> 
> > Tested on an SX9324-based device: a phase 0 DIFF readback of 0x7fff
> > was reported as -1 before this change and as 32767 afterward.  
> 
> Yeah, there seems only Chromebook devices (in ACPI world), MediaTek and
> Qualcomm (in DT world). Do we have anybody from Qualcomm to test this?
> 
> Hans, I think you (or somebody you might know at QCOMM) might be interested
> in this fix.

Looks like the actual dtsi blobs were all from google.
+CC Joseph on off chance still involved.

Applied the patch to the fixes-togreg branch of iio.git.
Note I'll rebase that on rc1 once available.

Jonathan

> 
> From the datasheet shared I see the same as described in this commit
> and since it was tested on real devices I'm quite sure this is the case.
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 
> > Fixes: 4c18a890dff8 ("iio:proximity:sx9324: Add SX9324 support")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Zhang Jie <zhangjie14@huaqin.corp-partner.google.com>
> > ---
> >  drivers/iio/proximity/sx9324.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c
> > index 36c45d101336..de6176fd8d47 100644
> > --- a/drivers/iio/proximity/sx9324.c
> > +++ b/drivers/iio/proximity/sx9324.c
> > @@ -223,7 +223,7 @@ static const struct iio_chan_spec_ext_info sx9324_channel_ext_info[] = {
> >  	.scan_index = idx,					 \
> >  	.scan_type = {						 \
> >  		.sign = 's',					 \
> > -		.realbits = 12,					 \
> > +		.realbits = 16,					 \
> >  		.storagebits = 16,				 \
> >  		.endianness = IIO_BE,				 \
> >  	},							 \  
> 


      reply	other threads:[~2026-08-19  1:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18  7:28 [PATCH] iio: proximity: sx9324: Correct proximity channel resolution Zhang Jie
2026-08-18  8:26 ` Andy Shevchenko
2026-08-19  1:18   ` Jonathan Cameron [this message]

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=20260819021826.702ceeaf@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gwendal@chromium.org \
    --cc=joebar@chromium.org \
    --cc=johannes.goede@oss.qualcomm.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=stable@vger.kernel.org \
    --cc=swboyd@chromium.org \
    --cc=zhangjie14@huaqin.corp-partner.google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.