Linux Media Controller development
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Maurizio Casciano <mauriziocasciano7@gmail.com>
Cc: linux-media@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Bingbu Cao <bingbu.cao@amd.com>,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	Nicholas Roth <nicholas@rothemail.net>,
	Andy Shevchenko <andy@kernel.org>,
	Hans de Goede <hansg@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jose Maria Martin <jmmartinf@hotmail.com>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/8] media: atomisp: support the Yoga Book OV2740 link
Date: Thu, 27 Aug 2026 17:26:36 +0300	[thread overview]
Message-ID: <apBJHHhAPowUs8Kj@ashevche-desk.local> (raw)
In-Reply-To: <20260826132256.3343451-6-mauriziocasciano7@gmail.com>

On Wed, Aug 26, 2026 at 03:22:53PM +0200, Maurizio Casciano wrote:
> The YB1-X91L firmware does not describe the complete camera link. Its
> front OV2740 uses two CSI-2 lanes at a 288 MHz link frequency and sends
> a 1932x1092 BGGR transport frame with 12 pixels of horizontal and
> vertical padding around the 1920x1080 image.
> 
> Allow the AtomISP bridge to provide per-sensor link frequencies and
> padding, add the matching OV2740 mode, and derive ISP2401 D-PHY timing
> from the sensor link-frequency control.
> 
> The register values are hardware configuration facts checked against
> the Lenovo YB1-X91L configuration and physical captures; no proprietary
> driver code or tuning binary is included.
> 
> Tested on a Lenovo Yoga Book YB1-X91L with continuous front-camera raw
> capture.

...

>  #define OV2740_LINK_FREQ_360MHZ		360000000ULL
> +#define OV2740_LINK_FREQ_288MHZ		288000000ULL
>  #define OV2740_LINK_FREQ_180MHZ		180000000ULL

At some point would be good to use HZ_PER_MHZ multiplier from units.h.

...

> struct ov2740_mode {

>  	/* Link frequency needed for this resolution */
>  	u32 link_freq_index;
>  
> +	/* Optional common settings applied before the mode-specific settings */
> +	const struct ov2740_reg_list init_reg_list;
> +
>  	/* Sensor register settings for this resolution */
>  	const struct ov2740_reg_list reg_list;
> +
> +	/* Bayer order produced by this mode */
> +	u32 code;

Check with `pahole`.

>  };

...

> +++ b/drivers/media/pci/intel/ipu-bridge.c
> @@ -520,11 +520,16 @@ static void ipu_bridge_create_fwnode_properties(
>  					sensor->prop_names.remote_endpoint,
>  					sensor->local_ref);
>  
> -	if (cfg->nr_link_freqs > 0)
> -		sensor->ep_properties[3] = PROPERTY_ENTRY_U64_ARRAY_LEN(
> -			sensor->prop_names.link_frequencies,
> -			cfg->link_freqs,
> -			cfg->nr_link_freqs);
> +	if (sensor->nr_link_freqs > 0)
> +		sensor->ep_properties[3] =
> +			PROPERTY_ENTRY_U64_ARRAY_LEN(names->link_frequencies,
> +						     sensor->link_freqs,
> +						     sensor->nr_link_freqs);
> +	else if (cfg->nr_link_freqs > 0)
> +		sensor->ep_properties[3] =
> +			PROPERTY_ENTRY_U64_ARRAY_LEN(names->link_frequencies,
> +						     cfg->link_freqs,
> +						     cfg->nr_link_freqs);

Why do we need this? The sensors are listed in the supported ones in the IPU
bridge code. Also, if required, some data can be altered by using driver_data
field in ACPI ID table.

...

> +++ b/drivers/staging/media/atomisp/pci/atomisp_csi2.h

>  int atomisp_csi2_bridge_init(struct atomisp_device *isp);
>  int atomisp_csi2_bridge_parse_firmware(struct atomisp_device *isp);
> +bool atomisp_csi2_get_sensor_padding(struct device *dev, u32 *padding_w,
> +				     u32 *padding_h);

Better to split logically.

bool atomisp_csi2_get_sensor_padding(struct device *dev,
				     u32 *padding_w, u32 *padding_h);

>  void atomisp_csi2_configure(struct atomisp_sub_device *asd);

...

> +bool atomisp_csi2_get_sensor_padding(struct device *dev, u32 *padding_w,
> +				     u32 *padding_h)
> +{

Ditto.

> +	struct acpi_device *adev = ACPI_COMPANION(dev);

Split the assignment. The current way is prone to subtle mistakes in the
future.

> +	bool override = false;
> +	char *str_val;
> +	unsigned int val;

Try to use reversed xmas tree order.

> +	*padding_w = pad_w;
> +	*padding_h = pad_h;

	adev = ACPI_COMPANION(dev);

> +	if (!adev)
> +		return false;
> +
> +	str_val = gmin_cfg_get(adev, "CsiPaddingWidth");
> +	if (str_val) {
> +		if (!kstrtouint(str_val, 0, &val) && val <= 64 && !(val & 1)) {
> +			*padding_w = val;
> +			override = true;
> +		} else {
> +			acpi_handle_warn(adev->handle,
> +					 "%s: Invalid CSI padding width %s\n",
> +					 dev_name(dev), str_val);
> +		}
> +		kfree(str_val);
> +	}
> +
> +	str_val = gmin_cfg_get(adev, "CsiPaddingHeight");
> +	if (str_val) {
> +		if (!kstrtouint(str_val, 0, &val) && val <= 64 && !(val & 1)) {
> +			*padding_h = val;
> +			override = true;
> +		} else {
> +			acpi_handle_warn(adev->handle,
> +					 "%s: Invalid CSI padding height %s\n",
> +					 dev_name(dev), str_val);
> +		}
> +		kfree(str_val);
> +	}

This is dup of the code, please create a helper to deduplicate these.
Also, what's wrong with gmin_cfg_get_int()?

> +	return override;
> +}

...

>  {
>  	const struct acpi_device_id *id;
> +	char *link_freq_str;
> +	unsigned long long link_freq;

Reversed xmas tree order.

>  	int ret, clock_num;
>  	bool vcm = false;
>  	int lanes = 1;

...

> +	link_freq_str = gmin_cfg_get(adev, "CsiLinkFreq");
> +	if (link_freq_str) {
> +		ret = kstrtoull(link_freq_str, 0, &link_freq);
> +		kfree(link_freq_str);
> +		if (ret || !link_freq) {
> +			acpi_handle_err(adev->handle,
> +					"%s: Invalid CSI link frequency\n",
> +					dev_name(&adev->dev));
> +			return ret ?: -EINVAL;
> +		}

gmin_cfg_get_int()

> +		sensor->link_freqs[0] = link_freq;
> +		sensor->nr_link_freqs = 1;
> +	}

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-08-27 14:26 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 13:22 [PATCH 0/8] media: Add Lenovo Yoga Book YB1-X91 camera support Maurizio Casciano
2026-08-26 13:22 ` [PATCH 1/8] media: ov8858: support 19.2 MHz clock and CHT gain setup Maurizio Casciano
2026-08-27  9:40   ` Andy Shevchenko
2026-08-27 11:59     ` Sakari Ailus
2026-08-27 18:19     ` Maurizio Casciano
2026-08-26 13:22 ` [PATCH 2/8] media: i2c: Add Yoga Book camera ACPI IDs Maurizio Casciano
2026-08-27  9:58   ` Andy Shevchenko
2026-08-27 12:14     ` Sakari Ailus
2026-08-27 12:46       ` Andy Shevchenko
2026-08-27 18:19     ` Maurizio Casciano
2026-08-27 23:18     ` Maurizio Casciano
2026-08-27 12:13   ` Sakari Ailus
2026-08-26 13:22 ` [PATCH 3/8] media: intel: ipu-bridge: Add Yoga Book camera sensors Maurizio Casciano
2026-08-26 13:22 ` [PATCH 4/8] media: atomisp: Add Yoga Book camera configuration Maurizio Casciano
2026-08-26 13:22 ` [PATCH 5/8] media: atomisp: support the Yoga Book OV2740 link Maurizio Casciano
2026-08-27 14:26   ` Andy Shevchenko [this message]
2026-08-27 23:18     ` Maurizio Casciano
2026-08-26 13:22 ` [PATCH 6/8] media: ov2740: add manual white balance controls Maurizio Casciano
2026-08-27  3:13   ` Cao, Bingbu
2026-08-27 18:19     ` Maurizio Casciano
2026-08-27 14:32   ` Andy Shevchenko
2026-08-26 13:22 ` [PATCH 7/8] media: atomisp: allow opt-in raw Bayer capture Maurizio Casciano
2026-08-27 14:43   ` Andy Shevchenko
2026-08-26 13:22 ` [PATCH 8/8] media: i2c: Add WV517S lens actuator driver Maurizio Casciano
2026-08-27 12:30   ` Sakari Ailus
2026-08-27 18:19     ` Maurizio Casciano
2026-08-27 18:17 ` [PATCH v2 00/11] media: Add Lenovo Yoga Book YB1-X91 camera support Maurizio Casciano
2026-08-27 18:17   ` [PATCH v2 01/11] media: ov8858: Extract digital gain programming Maurizio Casciano
2026-08-27 18:17   ` [PATCH v2 02/11] media: ov8858: support 19.2 MHz clock and CHT gain setup Maurizio Casciano
2026-08-27 19:46     ` Andy Shevchenko
2026-08-27 23:18       ` Maurizio Casciano
2026-08-28  7:28       ` Sakari Ailus
2026-08-28  7:48         ` Andy Shevchenko
2026-08-27 18:17   ` [PATCH v2 03/11] media: ov2740: Use C99 initializers for ACPI IDs Maurizio Casciano
2026-08-27 19:47     ` Andy Shevchenko
2026-08-27 18:17   ` [PATCH v2 04/11] media: ov2740: Add OVTI2740 ACPI ID Maurizio Casciano
2026-08-27 18:17   ` [PATCH v2 05/11] media: ov8858: Add INT3477 " Maurizio Casciano
2026-08-28 11:21     ` Sakari Ailus
2026-08-28 13:24       ` Andy Shevchenko
2026-08-28 13:31         ` Andy Shevchenko
2026-08-27 18:17   ` [PATCH v2 06/11] media: intel: ipu-bridge: Add Yoga Book camera sensors Maurizio Casciano
2026-08-27 18:17   ` [PATCH v2 07/11] media: atomisp: Add Yoga Book camera configuration Maurizio Casciano
2026-08-27 18:17   ` [PATCH v2 08/11] media: atomisp: support the Yoga Book OV2740 link Maurizio Casciano
2026-08-27 19:57     ` Andy Shevchenko
2026-08-28 11:37     ` Sakari Ailus
2026-08-28 11:42     ` Sakari Ailus
2026-08-27 18:17   ` [PATCH v2 09/11] media: ov2740: add manual white balance controls Maurizio Casciano
2026-08-27 20:03     ` Andy Shevchenko
2026-08-27 18:17   ` [PATCH v2 10/11] media: atomisp: allow raw Bayer capture Maurizio Casciano
2026-08-27 20:24     ` Andy Shevchenko
2026-08-27 18:17   ` [PATCH v2 11/11] media: i2c: Add WV517S lens actuator driver Maurizio Casciano
2026-08-27 20:31     ` Andy Shevchenko
2026-08-27 18:58   ` [PATCH v2 00/11] media: Add Lenovo Yoga Book YB1-X91 camera support Andy Shevchenko

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=apBJHHhAPowUs8Kj@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=bingbu.cao@amd.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hansg@kernel.org \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=jmmartinf@hotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mauriziocasciano7@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=nicholas@rothemail.net \
    --cc=sakari.ailus@linux.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