public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <johannes.goede@oss.qualcomm.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Kate Hsuan <hpa@redhat.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	Serin Yeh <serin.yeh@intel.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] media: i2c: imx471: Add Sony IMX471 image sensor driver
Date: Tue, 21 Apr 2026 11:47:12 +0200	[thread overview]
Message-ID: <07115433-dcfb-40a9-952a-5f841ee93947@oss.qualcomm.com> (raw)
In-Reply-To: <aec9Pzr_ZUD0zBcK@kekkonen.localdomain>

Hi Sakari, Kate,

On 21-Apr-26 11:02, Sakari Ailus wrote:
> Hi Hans,
> 
> On Fri, Apr 17, 2026 at 12:16:11PM +0200, Hans de Goede wrote:

...

>>> +
>>> +		cci_update_bits(sensor->regmap, IMX471_REG_ORIENTATION,
>>> +				flip_bit, val, &ret);
>>> +
>>> +		return ret;
>>> +	}
>>> +
>>> +	/* vflip */
>>> +	cci_update_bits(sensor->regmap, IMX471_REG_ORIENTATION,
>>> +			flip_bit, val, &ret);
>>> +	if (ret)
>>> +		return ret;
>>
>> Hmm, I wonder if the problem here is you doing 2 subsequent
>> cci_update_bits(). If the flip control registered is double-buffered
>> and the new value is latched as the actual value on the start
>> of the next frame; and this is combined with reading back
>> reading the active value, not the last written value then
>> the first time you do this the setting of the hflip bit will
>> be overwritten by the second cci_update_bits.
>>
>> I think it would be better to do something similar to what
>> imx219.c and replace these 2 cci_update_bits() calls with:
>>
>>         cci_write(imx471->regmap, IMX471_REG_ORIENTATION,
>>                   imx471->hflip->val | imx471->vflip->val << 1, &ret);
>>
>> I believe this should work here too.
>>
>>
>>> +
>>> +	cci_write(sensor->regmap, IMX471_REG_V_WIN_OFFSET,
>>> +		  value ? 0xe0 : 0xeb, &ret);
>>> +	if (ret)
>>> +		return ret;
>>> +
>>> +	cci_update_bits(sensor->regmap, IMX471_REG_H_WIN_OFFSET, 1,
>>> +			value ? 0x01 : 0x00, &ret);
>>
>> No need for cci_update_bits() here, the register is always
>> initialized to 0xc8 so this can just use hardcoded values
>> like the V_WIN_OFFSET path:
>>
>> 	cci_write(sensor->regmap, IMX471_REG_H_WIN_OFFSET,
>> 		  value ? 0xc9 : 0xc8, &ret);
>>
>>> +	return ret;
>>
>> Updating both offsets here is wrong when hflip != vflip, you
>> should only update V_WIN_OFFSET when changing vflip and
>> H_WIN_OFFSET when changing hflip.
> 
> The cropping configuration should reflect the values on the sensor's pixel
> array and should not be affected by flipping. At least the crop window
> needs to be adjusted accordingly by the driver. Is there a need to change
> flipping while streaming?

Ah, that is a very valid question, no I don't think we do need to
set them while streaming.

Kate if you cannot get the start_x / start_y coordinate changes
when changing flipping to work to get a stable bayer output
pattern, then another way to fix this is to only allow changing
the flip controls while not streaming and return -EBUSY otherwise.

This can then be combined with reporting a flip-ctrl dependend
bayer-order so that userspace sees the right bayer-order after
flipping is applied as long as userspace reads the subdev format
after setting the controls (which libcamera does I believe).

For an example of an imx driver which reports a different
bayer order depending in flipping see: imx214.c and
the imx214_get_format_code() helper, a call to which should
be used to replace any hardcoded mbus-formats in the driver.

Regards,

Hans






  reply	other threads:[~2026-04-21  9:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17  8:32 [PATCH 0/2] Add Sony IMX471 camera sensor driver Kate Hsuan
2026-04-17  8:32 ` [PATCH 1/2] media: ipu-bridge: Add DMI information of Lenovo X9 to the image upside-down list Kate Hsuan
2026-04-17 10:37   ` Hans de Goede
2026-04-20  7:40     ` Kate Hsuan
2026-04-17  8:32 ` [PATCH 2/2] media: i2c: imx471: Add Sony IMX471 image sensor driver Kate Hsuan
2026-04-17 10:16   ` Hans de Goede
2026-04-20  4:05     ` Kate Hsuan
2026-04-20  6:48     ` Yeh, Serin
2026-04-20  7:23     ` Yeh, Serin
2026-04-20  8:59       ` Hans de Goede
2026-04-21  9:26       ` Sakari Ailus
2026-04-21  9:02     ` Sakari Ailus
2026-04-21  9:47       ` Hans de Goede [this message]
2026-04-21 20:05         ` Sakari Ailus
2026-04-28  3:08           ` Kate Hsuan
2026-04-28  8:49             ` Sakari Ailus
2026-04-21  9:23   ` Sakari Ailus
2026-04-28  4:05     ` Kate Hsuan

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=07115433-dcfb-40a9-952a-5f841ee93947@oss.qualcomm.com \
    --to=johannes.goede@oss.qualcomm.com \
    --cc=hpa@redhat.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=serin.yeh@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox