public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Mathis Foerst <mathis.foerst@mt.com>
Cc: linux-kernel@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Steve Longerbeam <slongerbeam@gmail.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	linux-staging@lists.linux.dev, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org, manuel.traut@mt.com,
	mathis.foerst@zuehlke.com
Subject: Re: [PATCH v6 4/7] media: mt9m114: Apply horizontal / vertical flip while streaming
Date: Mon, 26 May 2025 14:10:34 +0200	[thread overview]
Message-ID: <20250526121034.GF17743@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20250522143512.112043-5-mathis.foerst@mt.com>

Hi Mathis,

Thank you for the patch.

On Thu, May 22, 2025 at 04:35:08PM +0200, Mathis Foerst wrote:
> The current implementation does not apply changes to the V4L2 controls
> HFLIP & VFLIP of the sensor immediately if the sensor is in streaming
> state. The user has to stop and restart the stream for the changes to be
> applied.

This is by design. Changing horizontal or vertical flip will cause a
shift in the bayer pattern, which would require reconfiguring the
downstream devices in the pipeline atomically. This affects raw data
capture.

> Issue a CONFIG_CHANGE when the V4L2 controls HFLIP or VFLIP are set if the
> sensor is in streaming state to apply the change immediately.
> 
> Signed-off-by: Mathis Foerst <mathis.foerst@mt.com>
> ---
>  drivers/media/i2c/mt9m114.c | 43 +++++++++++++++++++++++++------------
>  1 file changed, 29 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c
> index 6c80c6926aef..7d39978835fe 100644
> --- a/drivers/media/i2c/mt9m114.c
> +++ b/drivers/media/i2c/mt9m114.c
> @@ -399,6 +399,11 @@ struct mt9m114 {
>  		struct v4l2_ctrl *gain;
>  		struct v4l2_ctrl *hblank;
>  		struct v4l2_ctrl *vblank;
> +		struct {
> +			/* horizonal / vertical flip cluster */
> +			struct v4l2_ctrl *hflip;
> +			struct v4l2_ctrl *vflip;
> +		};
>  	} pa;
>  
>  	/* Image Flow Processor */
> @@ -1059,6 +1064,7 @@ static int mt9m114_pa_s_ctrl(struct v4l2_ctrl *ctrl)
>  	struct v4l2_subdev_state *state;
>  	int ret = 0;
>  	u64 mask;
> +	u64 val;
>  
>  	/* V4L2 controls values are applied only when power is up. */
>  	if (!pm_runtime_get_if_in_use(&sensor->client->dev))
> @@ -1095,17 +1101,25 @@ static int mt9m114_pa_s_ctrl(struct v4l2_ctrl *ctrl)
>  		break;
>  
>  	case V4L2_CID_HFLIP:
> -		mask = MT9M114_CAM_SENSOR_CONTROL_HORZ_MIRROR_EN;
> +		mask = MT9M114_CAM_SENSOR_CONTROL_HORZ_MIRROR_EN |
> +		       MT9M114_CAM_SENSOR_CONTROL_VERT_FLIP_EN;
> +		val = (sensor->pa.hflip->val ?
> +		       MT9M114_CAM_SENSOR_CONTROL_HORZ_MIRROR_EN : 0) &
> +		      (sensor->pa.vflip->val ?
> +		       MT9M114_CAM_SENSOR_CONTROL_VERT_FLIP_EN : 0);
>  		ret = cci_update_bits(sensor->regmap,
>  				      MT9M114_CAM_SENSOR_CONTROL_READ_MODE,
> -				      mask, ctrl->val ? mask : 0, NULL);
> -		break;
> +				      mask, val, NULL);
> +		/*
> +		 * A Config-Change needs to be issued for the change to take
> +		 * effect. If we're not streaming ignore this, the change will
> +		 * be applied when the stream is started.
> +		 */
> +		if (ret || !sensor->streaming)
> +			break;
>  
> -	case V4L2_CID_VFLIP:
> -		mask = MT9M114_CAM_SENSOR_CONTROL_VERT_FLIP_EN;
> -		ret = cci_update_bits(sensor->regmap,
> -				      MT9M114_CAM_SENSOR_CONTROL_READ_MODE,
> -				      mask, ctrl->val ? mask : 0, NULL);
> +		ret = mt9m114_set_state(sensor,
> +					MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE);
>  		break;
>  
>  	default:
> @@ -1406,12 +1420,13 @@ static int mt9m114_pa_init(struct mt9m114 *sensor)
>  			  sensor->pixrate, sensor->pixrate, 1,
>  			  sensor->pixrate);
>  
> -	v4l2_ctrl_new_std(hdl, &mt9m114_pa_ctrl_ops,
> -			  V4L2_CID_HFLIP,
> -			  0, 1, 1, 0);
> -	v4l2_ctrl_new_std(hdl, &mt9m114_pa_ctrl_ops,
> -			  V4L2_CID_VFLIP,
> -			  0, 1, 1, 0);
> +	sensor->pa.hflip = v4l2_ctrl_new_std(hdl, &mt9m114_pa_ctrl_ops,
> +					     V4L2_CID_HFLIP,
> +					     0, 1, 1, 0);
> +	sensor->pa.vflip = v4l2_ctrl_new_std(hdl, &mt9m114_pa_ctrl_ops,
> +					     V4L2_CID_VFLIP,
> +					     0, 1, 1, 0);
> +	v4l2_ctrl_cluster(2, &sensor->pa.hflip);
>  
>  	if (hdl->error) {
>  		ret = hdl->error;

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2025-05-26 12:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-22 14:35 [PATCH v6 0/7] MT9M114 driver bugfix and improvements Mathis Foerst
2025-05-22 14:35 ` [PATCH v6 1/7] media: dt-bindings: mt9m114: Add slew-rate DT-binding Mathis Foerst
2025-05-22 14:35 ` [PATCH v6 2/7] media: mt9m114: Bypass PLL if required Mathis Foerst
2025-05-22 14:35 ` [PATCH v6 3/7] media: mt9m114: Factor out mt9m114_configure_pa Mathis Foerst
2025-05-22 14:35 ` [PATCH v6 4/7] media: mt9m114: Apply horizontal / vertical flip while streaming Mathis Foerst
2025-05-26 12:10   ` Laurent Pinchart [this message]
2025-05-22 14:35 ` [PATCH v6 5/7] media: mt9m114: Allow set_selection " Mathis Foerst
2025-05-26  8:46   ` Sakari Ailus
2025-05-26 12:13   ` Laurent Pinchart
2025-05-22 14:35 ` [PATCH v6 6/7] media: mt9m114: Fix deadlock in get_frame_interval/set_frame_interval Mathis Foerst
2025-05-22 14:35 ` [PATCH v6 7/7] media: mt9m114: Set pad-slew-rate Mathis Foerst
2025-05-27  6:36   ` Sakari Ailus
2025-05-26 12:15 ` [PATCH v6 0/7] MT9M114 driver bugfix and improvements Laurent Pinchart
2025-05-27  6:37   ` Sakari Ailus

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=20250526121034.GF17743@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=manuel.traut@mt.com \
    --cc=mathis.foerst@mt.com \
    --cc=mathis.foerst@zuehlke.com \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sakari.ailus@linux.intel.com \
    --cc=shawnguo@kernel.org \
    --cc=slongerbeam@gmail.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