lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250526121034.GF17743@pendragon.ideasonboard.com>
Date: Mon, 26 May 2025 14:10:34 +0200
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Mathis Foerst <mathis.foerst@...com>
Cc: linux-kernel@...r.kernel.org,
	Mauro Carvalho Chehab <mchehab@...nel.org>,
	Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Sakari Ailus <sakari.ailus@...ux.intel.com>,
	Steve Longerbeam <slongerbeam@...il.com>,
	Philipp Zabel <p.zabel@...gutronix.de>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Shawn Guo <shawnguo@...nel.org>,
	Sascha Hauer <s.hauer@...gutronix.de>,
	Pengutronix Kernel Team <kernel@...gutronix.de>,
	Fabio Estevam <festevam@...il.com>, linux-media@...r.kernel.org,
	devicetree@...r.kernel.org, linux-staging@...ts.linux.dev,
	imx@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
	manuel.traut@...com, mathis.foerst@...hlke.com
Subject: Re: [PATCH v6 4/7] media: mt9m114: Apply horizontal / vertical flip
 while streaming

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@...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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ