media: Add Lenovo Yoga Book YB1-X91 camera support
Subsystems (7)
v4 cover media: Add Lenovo Yoga Book YB1-X91 camera support
The Lenovo Yoga Book YB1-X91L exposes an OV2740 front sensor and an OV8858 rear sensor through the Cherry Trail AtomISP. Its firmware does not provide enough information for the existing sensor and IPU bridge drivers to construct the complete camera links.
Add the ACPI IDs and bridge data, describe both AtomISP camera links, support the Yoga Book sensor clocks and modes, expose raw Bayer capture, add per-channel white-balance controls, and add the WV517S rear-camera lens actuator.
Raw capture is selected through the normal V4L2 raw pixel formats. There is no module parameter or separate private ABI. Raw formats expose the complete sensor transport frame required by the ISP2401 copy pipeline; selecting a smaller crop remains a userspace decision.
Changes since v3:
- use ACPI_PTR() for the new OV8858 ACPI match table;
- split the Yoga Book OV2740 link support into sensor, IPU bridge, AtomISP timing and device-specific frequency patches;
- reuse the existing OV2740 1932x1092 mode register list and SGRBG10 Bayer order for the 288 MHz link frequency;
- carry per-sensor link frequencies through the IPU bridge and use v4l2_get_link_freq() with s64 arithmetic for AtomISP D-PHY timing;
- remove the sensor-specific kernel padding override: raw capture exposes the full transport frame and userspace owns the centered crop;
- keep struct v4l2_area for the existing AtomISP padding interface without adding per-sensor padding state; and
- add review links to the commits that address the requested changes.
v3:
https://lore.kernel.org/linux-media/[email protected]/
The tablet DSDT contains the sensor objects requested during review:
Device (CA11)
{
Name (_HID, "INT3477")
Name (_CID, "OVTI8858")
Name (_DDN, "OV8858")
}
Device (CA01)
{
Name (_HID, "OVTI2740")
Name (_CID, "OVTI2740")
Name (_DDN, "OV2740")
}Pahole reports struct ov2740_mode as 64 bytes, exactly one cacheline, with no holes or padding. Struct ov8858 is 792 bytes, naturally aligned to 8 bytes, with 4 bytes of tail padding. Struct ipu_sensor is 2096 bytes in v4, reduced from 2104 bytes during review.
All fifteen patches pass strict checkpatch. The touched Media objects at the exact v4 tip pass W=1 and sparse v0.6.5-rc1. A clean 20-job full kernel package build containing the patch-equivalent v4 series completed successfully.
Runtime testing used a Lenovo Yoga Book YB1-X91L booted with 7.2.0-yogabook-20260828-163827 from integration commit 907805589733fd2e9112118314ac811361afdcd2. Both sensors, AtomISP and WV517S bound. The OV2740 exposed its full 1932x1092 SGRBG10 transport and completed three consecutive direct raw captures at approximately 30 fps. The camera userspace consumed that interface with a centered 1920x1080 crop, and the rear OV8858 preview consumed its SBGGR10 transport.
The 1280x720 YUYV rear endpoint completed a bounded 90-frame capture, then switched automatically to a bounded 150-frame front capture. Both physical camera images and front/rear switching were tested successfully in Cheese. Speakers, microphone, Halo keyboard haptics and pen mode were also retested on the same integrated kernel without regressions.
With Best Regards,
Maurizio Casciano
Maurizio Casciano (15):
media: ov8858: Extract digital gain programming
media: ov8858: support 19.2 MHz clock and CHT gain setup
media: ov2740: Use C99 initializers for ACPI IDs
media: ov2740: Add OVTI2740 ACPI ID
media: ov8858: Add INT3477 ACPI ID
media: intel: ipu-bridge: Add Yoga Book camera sensors
media: atomisp: Add Yoga Book camera configuration
media: ov2740: support 288 MHz link frequency
media: intel: ipu-bridge: allow sensor-specific link frequencies
media: atomisp: derive CSI-2 timing from sensor link frequency
media: atomisp: provide Yoga Book OV2740 link frequency
media: ov2740: add manual white balance controls
media: atomisp: Use struct v4l2_area for padding
media: atomisp: allow raw Bayer capture
media: i2c: Add WV517S lens actuator driver
MAINTAINERS | 1 + drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov2740.c | 116 +++++++--- drivers/media/i2c/ov8858.c | 167 ++++++++++++-- drivers/media/i2c/wv517s.c | 206 ++++++++++++++++++ drivers/media/pci/intel/ipu-bridge.c | 19 +- .../staging/media/atomisp/pci/atomisp_cmd.c | 64 ++++-- .../staging/media/atomisp/pci/atomisp_cmd.h | 6 +- .../staging/media/atomisp/pci/atomisp_csi2.c | 20 +- .../media/atomisp/pci/atomisp_csi2_bridge.c | 30 ++- .../staging/media/atomisp/pci/atomisp_ioctl.c | 33 ++- include/media/ipu-bridge.h | 2 + 13 files changed, 578 insertions(+), 98 deletions(-) create mode 100644 drivers/media/i2c/wv517s.c
base-commit: 73e3f0710014fe6d4ed98cfc02292f6121db7558
Signature · 1 line
2.53.0
PATCH v4 1/15 media: ov8858: Extract digital gain programming
Move the existing packed digital-gain register programming into a helper so clock-specific gain handling can be added separately.
--- drivers/media/i2c/ov8858.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/media/i2c/ov8858.c +18 -12
@@ -1523,6 +1523,23 @@ static int ov8858_enable_test_pattern(struct ov8858 *ov8858, u32 pattern)return ov8858_write (ov8858,OV8858_REG_TEST_PATTERN , val,NULL ); } +static int ov8858_set_long_digital_gain (struct ov8858 *ov8858,u32 gain) +{ +u16 long_gain; + +/* +* Digital gain is assembled as: +* 0x350a[7:0] = dgain[13:6] +* 0x350b[5:0] = dgain[5:0] +* Reassemble the control value to write it in one go. +*/ + long_gain = (gain &OV8858_LONG_DIGIGAIN_L_MASK ) | + ((gain &OV8858_LONG_DIGIGAIN_H_MASK ) << +OV8858_LONG_DIGIGAIN_H_SHIFT ); + +return ov8858_write (ov8858,OV8858_REG_LONG_DIGIGAIN , long_gain,NULL ); +} +static int ov8858_set_ctrl (struct v4l2_ctrl *ctrl) { struct ov8858 *ov8858 = container_of(ctrl->handler,
@@ -1531,7 +1548,6 @@ static int ov8858_set_ctrl(struct v4l2_ctrl *ctrl)struct i2c_client *client =v4l2_get_subdevdata (&ov8858->subdev);struct v4l2_mbus_framefmt *format;struct v4l2_subdev_state *state; -u16 digi_gain;s64 max_exp;int ret;
@@ -1570,17 +1586,7 @@ static int ov8858_set_ctrl(struct v4l2_ctrl *ctrl) ctrl->val, NULL);break ;case V4L2_CID_DIGITAL_GAIN : -/* -* Digital gain is assembled as: -* 0x350a[7:0] = dgain[13:6] -* 0x350b[5:0] = dgain[5:0] -* Reassemble the control value to write it in one go. -*/ - digi_gain = (ctrl->val &OV8858_LONG_DIGIGAIN_L_MASK ) - | ((ctrl->val &OV8858_LONG_DIGIGAIN_H_MASK ) << -OV8858_LONG_DIGIGAIN_H_SHIFT ); - ret =ov8858_write (ov8858,OV8858_REG_LONG_DIGIGAIN , - digi_gain,NULL ); + ret =ov8858_set_long_digital_gain (ov8858, ctrl->val);break ;case V4L2_CID_VBLANK : ret = ov8858_write(ov8858, OV8858_REG_VTS,
Signature · 1 line
2.53.0
PATCH v4 2/15 media: ov8858: support 19.2 MHz clock and CHT gain setup
In reply to Maurizio CascianoThe Yoga Book drives its OV8858 from a 19.2 MHz platform clock, while the existing mode tables program the sensor PLL for 24 MHz. Reusing those settings produces incorrect internal and CSI-2 clocks.
Accept both input rates and use the actual rate for the reset delay. For 19.2 MHz, apply the Cherry Trail MRD PLL and black-level settings after the generic mode table.
The 19.2 MHz platform uses the per-channel manual white-balance registers for digital gain. Program registers 0x5032, 0x5034 and 0x5036 and expose their 1x-to-4x range, while retaining the existing long-exposure gain block for 24 MHz systems.
The manual white-balance register definitions and programming follow the GPL-2.0 Intel OV5670 driver, so retain its 2017 Intel copyright notice in this file. No proprietary source or tuning binary is included.
Tested on the Lenovo Yoga Book YB1-X91L OV8858 with full-range test bars and real 10-bit Bayer frames.
--- drivers/media/i2c/ov8858.c | 133 +++++++++++++++++++++++++++++++++---- 1 file changed, 120 insertions(+), 13 deletions(-)
drivers/media/i2c/ov8858.c +120 -13
@@ -3,10 +3,9 @@* Copyright (C) 2023 Jacopo Mondi <[email protected]> * Copyright (C) 2022 Nicholas Roth <[email protected]> * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd. +* Copyright (c) 2017 Intel Corporation. */ -#include <linux/unaligned.h> -#include <linux/clk.h> #include <linux/delay.h> #include <linux/device.h>
@@ -18,6 +17,8 @@#include <linux/property.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> +#include <linux/unaligned.h> +#include <linux/units.h> #include <media/media-entity.h> #include <media/v4l2-async.h>
@@ -28,8 +29,9 @@#include <media/v4l2-mediabus.h> #include <media/v4l2-subdev.h> -#define OV8858_LINK_FREQ 360000000U -#define OV8858_XVCLK_FREQ 24000000 +#define OV8858_LINK_FREQ (360 * HZ_PER_MHZ) +#define OV8858_XVCLK_FREQ_19_2MHZ (192 * HZ_PER_MHZ / 10) +#define OV8858_XVCLK_FREQ_24MHZ (24 * HZ_PER_MHZ)#define OV8858_REG_SIZE_SHIFT 16#define OV8858_REG_ADDR_MASK 0xffff
@@ -59,6 +61,14 @@#define OV8858_LONG_GAIN_STEP 1#define OV8858_LONG_GAIN_DEFAULT 0x80 +#define OV8858_REG_MWB_RED_GAIN OV8858_REG_16BIT(0x5032) +#define OV8858_REG_MWB_GREEN_GAIN OV8858_REG_16BIT(0x5034) +#define OV8858_REG_MWB_BLUE_GAIN OV8858_REG_16BIT(0x5036) +#define OV8858_MWB_GAIN_MIN 0x400 +#define OV8858_MWB_GAIN_MAX 0xfff +#define OV8858_MWB_GAIN_STEP 1 +#define OV8858_MWB_GAIN_DEFAULT 0x400 +#define OV8858_REG_LONG_DIGIGAIN OV8858_REG_16BIT(0x350a)#define OV8858_LONG_DIGIGAIN_H_MASK 0x3fc0#define OV8858_LONG_DIGIGAIN_L_MASK 0x3f
@@ -93,6 +103,33 @@ struct regval_modes {const struct regval *mode_4lanes; }; +struct ov8858_gain_range { +u32 min; +u32 max; +u32 step; +u32 def; +}; + +enum ov8858_xvclk_index { +OV8858_XVCLK_24MHZ , +OV8858_XVCLK_19_2MHZ , +}; + +static const struct ov8858_gain_range ov8858_digital_gain_ranges[] = { + [OV8858_XVCLK_24MHZ ] = { + .min =OV8858_LONG_DIGIGAIN_MIN , + .max =OV8858_LONG_DIGIGAIN_MAX , + .step =OV8858_LONG_DIGIGAIN_STEP , + .def =OV8858_LONG_DIGIGAIN_DEFAULT , + }, + [OV8858_XVCLK_19_2MHZ ] = { + .min =OV8858_MWB_GAIN_MIN , + .max =OV8858_MWB_GAIN_MAX , + .step =OV8858_MWB_GAIN_STEP , + .def =OV8858_MWB_GAIN_DEFAULT , + }, +}; +struct ov8858_mode {u32 width;u32 height;
@@ -104,6 +141,7 @@ struct ov8858_mode {struct ov8858 {struct clk *xvclk; +unsigned long xvclk_rate;struct gpio_desc *reset_gpio;struct gpio_desc *pwdn_gpio;struct regulator_bulk_data supplies[ARRAY_SIZE (ov8858_supply_names)];
@@ -121,6 +159,41 @@ struct ov8858 {unsigned int num_lanes; }; +/* +* Cherry Trail MRD production settings for a 19.2 MHz input and 360 MHz +* CSI-2 link. Apply these after the otherwise reusable 24 MHz mode table. +* +* Besides the corrected sensor/MIPI PLL divisors, keep the final common +* black-level settings here. The per-mode tables retain their resolution +* dependent black-column anchors and window sizes. +*/ +static const struct regval ov8858_cht_mrd_19_2mhz[] = { + {0x0300 ,0x00 }, + {0x0302 ,0x27 }, + {0x0303 ,0x00 }, + {0x0304 ,0x03 }, + {0x030b ,0x00 }, + {0x030d ,0x27 }, + {0x030e ,0x00 }, + {0x030f ,0x04 }, + {0x0312 ,0x01 }, + {0x031e ,0x0c }, + {0x3f08 ,0x08 }, + {0x400a ,0x01 }, + {0x400d ,0x10 }, + {0x4011 ,0x20 }, + {0x403e ,0x08 }, + {0x4040 ,0x07 }, + {0x4041 ,0xc6 }, + {0x4202 ,0x00 }, + {0x4500 ,0x58 }, + {0x470b ,0x28 }, + {0x4837 ,0x15 }, + {0x58f4 ,0x32 }, + {0x58f8 ,0x3d }, + {REG_NULL ,0x00 }, +}; +static inline struct ov8858 *sd_to_ov8858 (struct v4l2_subdev *sd) { return container_of(sd, struct ov8858, subdev);
@@ -1345,6 +1418,13 @@ static int ov8858_start_stream(struct ov8858 *ov8858,if (ret)return ret; +/* The mode tables contain PLL settings for a 24 MHz input clock. */ +if (ov8858->xvclk_rate ==OV8858_XVCLK_FREQ_19_2MHZ ) { + ret =ov8858_write_array (ov8858, ov8858_cht_mrd_19_2mhz); +if (ret) +return ret; + } +/* 200 usec max to let PLL stabilize. */ fsleep (200 );
@@ -1537,7 +1617,23 @@ static int ov8858_set_long_digital_gain(struct ov8858 *ov8858, u32 gain) ((gain &OV8858_LONG_DIGIGAIN_H_MASK ) <<OV8858_LONG_DIGIGAIN_H_SHIFT ); -return ov8858_write (ov8858,OV8858_REG_LONG_DIGIGAIN , long_gain,NULL ); +return ov8858_write (ov8858,OV8858_REG_LONG_DIGIGAIN , + long_gain,NULL ); +} + +static int ov8858_set_mwb_digital_gain (struct ov8858 *ov8858,u32 gain) +{ +int ret; + + ret =ov8858_write (ov8858,OV8858_REG_MWB_RED_GAIN , gain,NULL ); +if (ret) +return ret; + + ret =ov8858_write (ov8858,OV8858_REG_MWB_GREEN_GAIN , gain,NULL ); +if (ret) +return ret; + +return ov8858_write (ov8858,OV8858_REG_MWB_BLUE_GAIN , gain,NULL ); }static int ov8858_set_ctrl (struct v4l2_ctrl *ctrl)
@@ -1586,7 +1682,10 @@ static int ov8858_set_ctrl(struct v4l2_ctrl *ctrl) ctrl->val, NULL);break ;case V4L2_CID_DIGITAL_GAIN : - ret =ov8858_set_long_digital_gain (ov8858, ctrl->val); +if (ov8858->xvclk_rate ==OV8858_XVCLK_FREQ_19_2MHZ ) + ret =ov8858_set_mwb_digital_gain (ov8858, ctrl->val); +else + ret =ov8858_set_long_digital_gain (ov8858, ctrl->val);break ;case V4L2_CID_VBLANK : ret = ov8858_write(ov8858, OV8858_REG_VTS,
@@ -1622,9 +1721,6 @@ static int ov8858_power_on(struct ov8858 *ov8858)unsigned long delay_us;int ret; -if (clk_get_rate (ov8858->xvclk) !=OV8858_XVCLK_FREQ ) -dev_warn (dev,"xvclk mismatched, modes are based on 24MHz\n" ); - ret =clk_prepare_enable (ov8858->xvclk);if (ret <0 ) {dev_err (dev,"Failed to enable xvclk\n" );
@@ -1643,7 +1739,7 @@ static int ov8858_power_on(struct ov8858 *ov8858)* transaction, but a double sleep between the release of gpios * helps with sporadic failures observed at probe time. */ - delay_us =DIV_ROUND_UP (8192 ,OV8858_XVCLK_FREQ /1000 /1000 ); + delay_us =DIV_ROUND_UP (8192 , ov8858->xvclk_rate /HZ_PER_MHZ );gpiod_set_value_cansleep (ov8858->reset_gpio,0 );fsleep (delay_us);
@@ -1701,9 +1797,11 @@ static int ov8858_init_ctrls(struct ov8858 *ov8858) {struct i2c_client *client =v4l2_get_subdevdata (&ov8858->subdev);struct v4l2_ctrl_handler *handler = &ov8858->ctrl_handler; +const struct ov8858_gain_range *digital_gain_range;const struct ov8858_mode *mode = &ov8858_modes[0 ];struct v4l2_fwnode_device_properties props;s64 exposure_max, vblank_def; +unsigned int xvclk_index;unsigned int pixel_rate;struct v4l2_ctrl *ctrl;u32 h_blank;
@@ -1746,10 +1844,12 @@ static int ov8858_init_ctrls(struct ov8858 *ov8858)OV8858_LONG_GAIN_MIN ,OV8858_LONG_GAIN_MAX , OV8858_LONG_GAIN_STEP, OV8858_LONG_GAIN_DEFAULT); + xvclk_index = ov8858->xvclk_rate ==OV8858_XVCLK_FREQ_19_2MHZ ? +OV8858_XVCLK_19_2MHZ :OV8858_XVCLK_24MHZ ; + digital_gain_range = &ov8858_digital_gain_ranges[xvclk_index];v4l2_ctrl_new_std (handler, &ov8858_ctrl_ops,V4L2_CID_DIGITAL_GAIN , -OV8858_LONG_DIGIGAIN_MIN ,OV8858_LONG_DIGIGAIN_MAX , -OV8858_LONG_DIGIGAIN_STEP , -OV8858_LONG_DIGIGAIN_DEFAULT ); + digital_gain_range->min, digital_gain_range->max, + digital_gain_range->step, digital_gain_range->def); v4l2_ctrl_new_std_menu_items(handler, &ov8858_ctrl_ops, V4L2_CID_TEST_PATTERN,
@@ -1887,6 +1987,13 @@ static int ov8858_probe(struct i2c_client *client)return dev_err_probe (dev,PTR_ERR (ov8858->xvclk),"Failed to get xvclk\n" ); + ov8858->xvclk_rate =clk_get_rate (ov8858->xvclk); +if (ov8858->xvclk_rate !=OV8858_XVCLK_FREQ_19_2MHZ && + ov8858->xvclk_rate !=OV8858_XVCLK_FREQ_24MHZ ) +return dev_err_probe (dev, -EINVAL , +"Unsupported xvclk rate %lu Hz\n" , + ov8858->xvclk_rate); + ov8858->reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (ov8858->reset_gpio))
Signature · 1 line
2.53.0
PATCH v4 3/15 media: ov2740: Use C99 initializers for ACPI IDs
In reply to Maurizio CascianoUse designated initializers and the standard empty sentinel style before adding firmware IDs.
--- drivers/media/i2c/ov2740.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/i2c/ov2740.c +2 -3
@@ -1461,10 +1461,9 @@ static DEFINE_RUNTIME_DEV_PM_OPS(ov2740_pm_ops, ov2740_suspend, ov2740_resume, NULL);static const struct acpi_device_id ov2740_acpi_ids[] = { - {"INT3474" }, - {} + { .id ="INT3474" }, + { } }; -MODULE_DEVICE_TABLE (acpi, ov2740_acpi_ids);static struct i2c_driver ov2740_i2c_driver = {
Signature · 1 line
2.53.0
PATCH v4 4/15 media: ov2740: Add OVTI2740 ACPI ID
In reply to Maurizio CascianoFirmware may enumerate OV2740 image sensors using the OVTI2740 ACPI ID. Add it to the existing ACPI match table.
--- drivers/media/i2c/ov2740.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/ov2740.c +1 -0
@@ -1462,6 +1462,7 @@ static DEFINE_RUNTIME_DEV_PM_OPS(ov2740_pm_ops, ov2740_suspend, ov2740_resume,static const struct acpi_device_id ov2740_acpi_ids[] = { { .id ="INT3474" }, + { .id ="OVTI2740" }, { } };MODULE_DEVICE_TABLE (acpi, ov2740_acpi_ids);
Signature · 1 line
2.53.0
PATCH v4 5/15 media: ov8858: Add INT3477 ACPI ID
In reply to Maurizio CascianoFirmware may use INT3477 as the ACPI hardware ID for an OV8858 image sensor. Add an ACPI match table for that ID.
--- drivers/media/i2c/ov8858.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/media/i2c/ov8858.c +8 -0
@@ -6,6 +6,7 @@* Copyright (c) 2017 Intel Corporation. */ +#include <linux/acpi.h> #include <linux/clk.h> #include <linux/delay.h> #include <linux/device.h>
@@ -2088,6 +2089,12 @@ static void ov8858_remove(struct i2c_client *client)pm_runtime_set_suspended (&client->dev); } +static const struct acpi_device_id ov8858_acpi_match[] = { + { .id ="INT3477" }, + { } +}; +MODULE_DEVICE_TABLE (acpi, ov8858_acpi_match); +static const struct of_device_id ov8858_of_match[] = { { .compatible ="ovti,ov8858" }, {/* sentinel */ },
@@ -2098,6 +2105,7 @@ static struct i2c_driver ov8858_i2c_driver = { .driver = { .name = "ov8858", .pm = &ov8858_pm_ops, + .acpi_match_table = ACPI_PTR(ov8858_acpi_match), .of_match_table = ov8858_of_match, }, .probe = ov8858_probe,
Signature · 1 line
2.53.0
PATCH v4 6/15 media: intel: ipu-bridge: Add Yoga Book camera sensors
In reply to Maurizio CascianoThe Yoga Book YB1-X91 uses INT3477 for its OV8858 rear sensor and OVTI2740 for its OV2740 front sensor. Add link frequencies consumed by the sensor drivers when the IPU bridge constructs software endpoints.
This supplies endpoint data only; it does not establish that either sensor can stream on the Yoga Book hardware.
--- drivers/media/pci/intel/ipu-bridge.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/pci/intel/ipu-bridge.c +4 -0
@@ -65,6 +65,8 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = {IPU_SENSOR_CONFIG ("INT33F0" ,1 ,384000000 ),/* Omnivision OV2740 */ IPU_SENSOR_CONFIG ("INT3474" ,1 ,180000000 ), +/* Omnivision OV8858 */ +IPU_SENSOR_CONFIG ("INT3477" ,1 ,360000000 ),/* Omnivision OV5670 */ IPU_SENSOR_CONFIG("INT3479", 1, 422400000),/* Omnivision OV8865 */
@@ -93,6 +95,8 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = {IPU_SENSOR_CONFIG ("OVTIDB10" ,1 ,560000000 ),/* Omnivision OV2680 */ IPU_SENSOR_CONFIG ("OVTI2680" ,1 ,331200000 ), +/* Omnivision OV2740 */ +IPU_SENSOR_CONFIG ("OVTI2740" ,1 ,360000000 ),/* Omnivision OV5675 */ IPU_SENSOR_CONFIG("OVTI5675", 1, 450000000),/* Omnivision OV8856 */
Signature · 1 line
2.53.0
PATCH v4 7/15 media: atomisp: Add Yoga Book camera configuration
In reply to Maurizio CascianoThe Yoga Book YB1-X91 firmware lacks usable AtomISP configuration for both cameras. Rear INT3477 OV8858 uses four CSI-2 lanes and a WV517S actuator, while the front OVTI2740 firmware reports the wrong lane count.
Add the rear sensor configuration and a DMI-scoped two-lane override for OVTI2740:00. Add the front sensor configuration separately once its link frequency can be supplied at the same time.
--- .../media/atomisp/pci/atomisp_csi2_bridge.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c +18 -1
@@ -74,6 +74,12 @@ static struct gmin_cfg_var lenovo_ideapad_miix_310_vars[] = { {} }; +static struct gmin_cfg_var lenovo_yogabook_x91_vars[] = { +/* The vendor driver and sensor modes use two CSI data lanes. */ + {"OVTI2740:00" ,"CsiLanes" ,"2" }, + {} +}; +static struct gmin_cfg_var xiaomi_mipad2_vars[] = {/* _DSM contains the wrong CsiPort for the front facing OV5693 sensor */ {"INT33BE:00" ,"CsiPort" ,"0" },
@@ -83,6 +89,14 @@ static struct gmin_cfg_var xiaomi_mipad2_vars[] = { };static const struct dmi_system_id gmin_cfg_dmi_overrides[] = { + { +/* Lenovo Yoga Book X91L */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Lenovo YB1-X91L" ), + }, + .driver_data = lenovo_yogabook_x91_vars, + }, {/* Lenovo Ideapad Miix 310 */ .matches = {
@@ -359,7 +373,10 @@ static const struct acpi_device_id atomisp_sensor_configs[] = {* the sensor fails to start streaming when instantiating * an i2c-client for the VCM, so it is disabled for now. */ - ATOMISP_SENSOR_CONFIG("INT33BE", 2, false), /* OV5693 */ +/* OV5693 */ + ATOMISP_SENSOR_CONFIG("INT33BE", 2, false), + /* OV8858 */ + ATOMISP_SENSOR_CONFIG("INT3477", 4, true), {} };
Signature · 1 line
2.53.0
PATCH v4 8/15 media: ov2740: support 288 MHz link frequency
In reply to Maurizio CascianoThe Lenovo Yoga Book YB1-X91 front camera uses two CSI-2 lanes at a 288 MHz link frequency. Add the matching PLL configuration and mode timing.
Reuse the existing 1932x1092 crop and mode register list so the Bayer order remains SGRBG across link frequencies. Cropping the CSI-2 receiver output to a smaller processed frame is a userspace pipeline decision.
--- drivers/media/i2c/ov2740.c | 45 +++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-)
drivers/media/i2c/ov2740.c +42 -3
@@ -12,14 +12,16 @@#include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/unaligned.h> +#include <linux/units.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-fwnode.h> -#define OV2740_LINK_FREQ_360MHZ 360000000ULL -#define OV2740_LINK_FREQ_180MHZ 180000000ULL +#define OV2740_LINK_FREQ_360MHZ (360 * HZ_PER_MHZ) +#define OV2740_LINK_FREQ_288MHZ (288 * HZ_PER_MHZ) +#define OV2740_LINK_FREQ_180MHZ (180 * HZ_PER_MHZ)#define OV2740_SCLK 72000000LL -#define OV2740_MCLK 19200000 +#define OV2740_MCLK (192 * HZ_PER_MHZ / 10)#define OV2740_DATA_LANES 2#define OV2740_RGB_DEPTH 10
@@ -91,6 +93,7 @@ struct nvm_data {enum {OV2740_LINK_FREQ_360MHZ_INDEX , +OV2740_LINK_FREQ_288MHZ_INDEX ,OV2740_LINK_FREQ_180MHZ_INDEX , };
@@ -142,6 +145,14 @@ static const struct ov2740_reg mipi_data_rate_720mbps[] = { {0x0312, 0x11}, }; +static const struct ov2740_reg mipi_data_rate_576mbps[] = { + {0x0302 ,0x1e }, + {0x0303 ,0x00 }, + {0x030d ,0x1e }, + {0x030e ,0x02 }, + {0x0312 ,0x01 }, +}; +static const struct ov2740_reg mipi_data_rate_360mbps[] = { {0x0302 ,0x4b }, {0x0303, 0x01},
@@ -468,6 +479,7 @@ static const char * const ov2740_test_pattern_menu[] = {static const s64 link_freq_menu_items[] = {OV2740_LINK_FREQ_360MHZ , +OV2740_LINK_FREQ_288MHZ ,OV2740_LINK_FREQ_180MHZ , };
@@ -478,6 +490,12 @@ static const struct ov2740_link_freq_config link_freq_configs[] = { .regs = mipi_data_rate_720mbps, } }, + [OV2740_LINK_FREQ_288MHZ_INDEX] = { + .reg_list = { + .num_of_regs = ARRAY_SIZE(mipi_data_rate_576mbps), + .regs = mipi_data_rate_576mbps, + } + }, [OV2740_LINK_FREQ_180MHZ_INDEX] = { .reg_list = { .num_of_regs = ARRAY_SIZE(mipi_data_rate_360mbps),
@@ -502,6 +520,22 @@ static const struct ov2740_mode supported_modes_360mhz[] = { }, }; +static const struct ov2740_mode supported_modes_288mhz[] = { + { + .width =1932 , + .height =1092 , + .hts =2160 , + .vts_min =1776 , + .vts_def =1776 , + .vts_max =32767 , + .reg_list = { + .num_of_regs =ARRAY_SIZE (mode_1932x1092_regs_360mhz), + .regs = mode_1932x1092_regs_360mhz, + }, + .link_freq_index =OV2740_LINK_FREQ_288MHZ_INDEX , + }, +}; +static const struct ov2740_mode supported_modes_180mhz[] = { { .width =1932 ,
@@ -1178,6 +1212,11 @@ static int ov2740_check_hwcfg(struct ov2740 *ov2740) ov2740->supported_modes_count =ARRAY_SIZE (supported_modes_360mhz);break ; +case OV2740_LINK_FREQ_288MHZ_INDEX : + ov2740->supported_modes = supported_modes_288mhz; + ov2740->supported_modes_count = +ARRAY_SIZE (supported_modes_288mhz); +break ;case OV2740_LINK_FREQ_180MHZ_INDEX : ov2740->supported_modes = supported_modes_180mhz; ov2740->supported_modes_count =
Signature · 1 line
2.53.0
PATCH v4 9/15 media: intel: ipu-bridge: allow sensor-specific link frequencies
In reply to Maurizio CascianoA bridge-specific firmware parser may have more accurate link-frequency information than the generic ACPI hardware-ID table. Let it store link frequencies in the per-sensor bridge data and prefer those values when constructing the endpoint software node.
Existing bridges continue to use the hardware-ID table when no sensor-specific frequencies are supplied.
--- drivers/media/pci/intel/ipu-bridge.c | 15 ++++++++++----- include/media/ipu-bridge.h | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-)
drivers/media/pci/intel/ipu-bridge.c +10 -5
@@ -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); sensor->ipu_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN( sensor->prop_names.data_lanes,
include/media/ipu-bridge.h +2 -0
@@ -135,10 +135,12 @@ struct ipu_sensor {u8 link;u8 lanes; +u8 nr_link_freqs;u32 mclkspeed;u32 rotation;enum v4l2_fwnode_orientation orientation;const char *vcm_type; +u64 link_freqs[MAX_NUM_LINK_FREQS ];struct ipu_property_names prop_names;struct property_entry ep_properties[5 ];
Signature · 1 line
2.53.0
PATCH v4 10/15 media: atomisp: derive CSI-2 timing from sensor link frequency
In reply to Maurizio CascianoThe ISP2401 CSI-2 receiver timing depends on the sensor link frequency. Query it through v4l2_get_link_freq() instead of reading a 32-bit control value directly.
Keep the frequency as s64 throughout the calculation so valid link frequencies do not require an arbitrary S32_MAX limit. Fall back to the existing default timings when the frequency query fails.
--- .../staging/media/atomisp/pci/atomisp_csi2.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_csi2.c +13 -7
@@ -5,6 +5,7 @@* Copyright (c) 2010 Intel Corporation. All Rights Reserved. */ +#include <media/v4l2-common.h> #include <media/v4l2-event.h> #include <media/v4l2-mediabus.h> #include "atomisp_cmd.h"
@@ -209,7 +210,7 @@ int atomisp_mipi_csi2_register_entities(struct atomisp_mipi_csi2_device *csi2,static const int LIMIT_SHIFT =6 ;/* Limit numeric range into 31 bits */ static int -atomisp_csi2_configure_calc (const short int coeffs[2 ],int mipi_freq,int def) +atomisp_csi2_configure_calc (const short int coeffs[2 ],s64 mipi_freq,int def) {/* Delay counter accuracy, 1/0.0625 for ANN/CHT, 1/0.125 for BXT */ static const int accinv =16 ;/* 1 / COUNT_ACC */
@@ -288,18 +289,18 @@ static void atomisp_csi2_configure_isp2401(struct atomisp_sub_device *asd)int dat_termen;int dat_settle; -struct v4l2_control ctrl;struct atomisp_device *isp = asd->isp; -int mipi_freq =0 ; +struct v4l2_subdev *sensor; +s64 mipi_freq;enum atomisp_camera_port port;int n; port = isp->inputs[asd->input_curr].port; - ctrl.id =V4L2_CID_LINK_FREQ ; -if (v4l2_g_ctrl - (isp->inputs[asd->input_curr].sensor->ctrl_handler, &ctrl) ==0 ) - mipi_freq = ctrl.value; + sensor = isp->inputs[asd->input_curr].sensor; + mipi_freq =v4l2_get_link_freq (&sensor->entity.pads[0 ],0 ,0 ); +if (mipi_freq <0 ) + mipi_freq =0 ; clk_termen =atomisp_csi2_configure_calc (coeff_clk_termen, mipi_freq,TERMEN_DEFAULT );
@@ -310,6 +311,11 @@ static void atomisp_csi2_configure_isp2401(struct atomisp_sub_device *asd) dat_settle =atomisp_csi2_configure_calc (coeff_dat_settle, mipi_freq,SETTLE_DEFAULT ); +dev_dbg (isp->dev, +"CSI port %u link frequency %lld Hz, clk timing %d/%d, data timing %d/%d\n" , + port, mipi_freq, clk_termen, clk_settle, + dat_termen, dat_settle); +for (n =0 ; n < csi2_port_lanes[port] +1 ; n++) {hrt_address base = csi2_port_base[port] + csi2_lane_base[n];
Signature · 1 line
2.53.0
PATCH v4 11/15 media: atomisp: provide Yoga Book OV2740 link frequency
In reply to Maurizio CascianoThe Lenovo Yoga Book YB1-X91 firmware does not describe the front OV2740 link frequency. Extend the AtomISP sensor configuration with an optional frequency and assign the 288 MHz Yoga Book value while adding its ACPI ID.
Pass the value through the IPU bridge per-sensor endpoint data so the OV2740 driver selects its matching mode and the AtomISP CSI-2 receiver derives the correct D-PHY timing.
--- .../media/atomisp/pci/atomisp_csi2_bridge.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c +12 -3
@@ -15,6 +15,7 @@#include <linux/dmi.h> #include <linux/platform_data/x86/int3472.h> #include <linux/property.h> +#include <linux/units.h> #include <media/ipu-bridge.h> #include <media/v4l2-fwnode.h>
@@ -43,14 +44,16 @@ static const guid_t vcm_dsm_guid = 0x9f, 0x48, 0xa9, 0xc3, 0xb5, 0xda, 0x78, 0x9f);struct atomisp_sensor_config { +u64 link_freq;int lanes;bool vcm; }; -#define ATOMISP_SENSOR_CONFIG (_HID, _LANES, _VCM) \ +#define ATOMISP_SENSOR_CONFIG (_HID, _LANES, _VCM, _LINK_FREQ) \ { \ .id = _HID, \ .driver_data = (long)&((const struct atomisp_sensor_config) { \ + .link_freq = _LINK_FREQ, \ .lanes = _LANES, \ .vcm = _VCM, \ }) \
@@ -374,9 +377,11 @@ static const struct acpi_device_id atomisp_sensor_configs[] = {* an i2c-client for the VCM, so it is disabled for now. */ /* OV5693 */ - ATOMISP_SENSOR_CONFIG("INT33BE", 2, false), +ATOMISP_SENSOR_CONFIG ("INT33BE" ,2 , false,0 ),/* OV8858 */ - ATOMISP_SENSOR_CONFIG("INT3477", 4, true), +ATOMISP_SENSOR_CONFIG ("INT3477" ,4 , true,0 ), +/* OV2740 */ + ATOMISP_SENSOR_CONFIG("OVTI2740", 2, false, 288 * HZ_PER_MHZ), {} };
@@ -395,6 +400,10 @@ static int atomisp_csi2_parse_sensor_fwnode(struct acpi_device *adev, lanes = cfg->lanes; vcm = cfg->vcm; +if (cfg->link_freq) { + sensor->link_freqs[0 ] = cfg->link_freq; + sensor->nr_link_freqs =1 ; + } }/*
Signature · 1 line
2.53.0
PATCH v4 12/15 media: ov2740: add manual white balance controls
In reply to Maurizio CascianoThe sensor has separate red, green and blue manual white-balance gain registers, but the driver currently writes the same digital-gain value to all three channels. This prevents userspace from correcting the strong color cast of raw Bayer capture.
Expose red- and blue-balance controls relative to the digital gain, update all three channels under group hold, and always release and launch the group even when a channel write fails.
Tested on the Yoga Book OV2740 with live gain changes and continuous raw capture.
--- drivers/media/i2c/ov2740.c | 65 ++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 20 deletions(-)
drivers/media/i2c/ov2740.c +45 -20
@@ -565,6 +565,9 @@ struct ov2740 {struct v4l2_ctrl *vblank;struct v4l2_ctrl *hblank;struct v4l2_ctrl *exposure; +struct v4l2_ctrl *digital_gain; +struct v4l2_ctrl *red_balance; +struct v4l2_ctrl *blue_balance;/* GPIOs, clocks, regulators */ struct gpio_desc *reset_gpio;
@@ -694,35 +697,41 @@ static int ov2740_identify_module(struct ov2740 *ov2740)return 0 ; } -static int ov2740_update_digital_gain (struct ov2740 *ov2740,u32 d_gain) +static int ov2740_update_mwb_gains (struct ov2740 *ov2740) { -int ret; +u32 d_gain = ov2740->digital_gain->val; +u32 blue_gain, red_gain; +int end_ret, launch_ret, ret; ret =ov2740_write_reg (ov2740,OV2740_REG_GROUP_ACCESS ,1 ,OV2740_GROUP_HOLD_START );if (ret)return ret; - ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_R_GAIN ,2 , d_gain); +/* Balance controls use 1024 as unity relative to the digital gain. */ + red_gain =DIV_ROUND_CLOSEST (d_gain * ov2740->red_balance->val, +OV2740_DGTL_GAIN_DEFAULT ); + red_gain =min (red_gain,OV2740_DGTL_GAIN_MAX ); + ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_R_GAIN ,2 , red_gain);if (ret) -return ret; + goto release_group; ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_G_GAIN ,2 , d_gain);if (ret) -return ret; + goto release_group; - ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_B_GAIN ,2 , d_gain); -if (ret) -return ret; + blue_gain =DIV_ROUND_CLOSEST (d_gain * ov2740->blue_balance->val, +OV2740_DGTL_GAIN_DEFAULT ); + blue_gain =min (blue_gain,OV2740_DGTL_GAIN_MAX ); + ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_B_GAIN ,2 , blue_gain); - ret =ov2740_write_reg (ov2740,OV2740_REG_GROUP_ACCESS ,1 , -OV2740_GROUP_HOLD_END ); -if (ret) -return ret; +release_group: + end_ret =ov2740_write_reg (ov2740,OV2740_REG_GROUP_ACCESS ,1 , +OV2740_GROUP_HOLD_END ); + launch_ret =ov2740_write_reg (ov2740,OV2740_REG_GROUP_ACCESS ,1 , +OV2740_GROUP_HOLD_LAUNCH ); - ret =ov2740_write_reg (ov2740,OV2740_REG_GROUP_ACCESS ,1 , -OV2740_GROUP_HOLD_LAUNCH ); -return ret; +return ret ?: end_ret ?: launch_ret; }static int ov2740_test_pattern (struct ov2740 *ov2740,u32 pattern)
@@ -763,7 +772,9 @@ static int ov2740_set_ctrl(struct v4l2_ctrl *ctrl)break ;case V4L2_CID_DIGITAL_GAIN : - ret =ov2740_update_digital_gain (ov2740, ctrl->val); +case V4L2_CID_RED_BALANCE : +case V4L2_CID_BLUE_BALANCE : + ret =ov2740_update_mwb_gains (ov2740);break ;case V4L2_CID_EXPOSURE :
@@ -804,7 +815,7 @@ static int ov2740_init_controls(struct ov2740 *ov2740)int ret; ctrl_hdlr = &ov2740->ctrl_handler; - ret =v4l2_ctrl_handler_init (ctrl_hdlr,10 ); + ret =v4l2_ctrl_handler_init (ctrl_hdlr,12 );if (ret)return ret;
@@ -839,9 +850,23 @@ static int ov2740_init_controls(struct ov2740 *ov2740)v4l2_ctrl_new_std (ctrl_hdlr, &ov2740_ctrl_ops,V4L2_CID_ANALOGUE_GAIN ,OV2740_ANAL_GAIN_MIN ,OV2740_ANAL_GAIN_MAX ,OV2740_ANAL_GAIN_STEP ,OV2740_ANAL_GAIN_MIN ); -v4l2_ctrl_new_std (ctrl_hdlr, &ov2740_ctrl_ops,V4L2_CID_DIGITAL_GAIN , -OV2740_DGTL_GAIN_MIN ,OV2740_DGTL_GAIN_MAX , -OV2740_DGTL_GAIN_STEP ,OV2740_DGTL_GAIN_DEFAULT ); + ov2740->digital_gain = +v4l2_ctrl_new_std (ctrl_hdlr, &ov2740_ctrl_ops, +V4L2_CID_DIGITAL_GAIN , +OV2740_DGTL_GAIN_MIN ,OV2740_DGTL_GAIN_MAX , +OV2740_DGTL_GAIN_STEP , +OV2740_DGTL_GAIN_DEFAULT ); + ov2740->red_balance = +v4l2_ctrl_new_std (ctrl_hdlr, &ov2740_ctrl_ops, +V4L2_CID_RED_BALANCE , +1 ,OV2740_DGTL_GAIN_MAX ,1 , +OV2740_DGTL_GAIN_DEFAULT ); + ov2740->blue_balance = +v4l2_ctrl_new_std (ctrl_hdlr, &ov2740_ctrl_ops, +V4L2_CID_BLUE_BALANCE , +1 ,OV2740_DGTL_GAIN_MAX ,1 , +OV2740_DGTL_GAIN_DEFAULT ); +v4l2_ctrl_cluster (3 , &ov2740->digital_gain); exposure_max = ov2740->cur_mode->vts_def -OV2740_EXPOSURE_MAX_MARGIN ; ov2740->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops, V4L2_CID_EXPOSURE,
Signature · 1 line
2.53.0
PATCH v4 13/15 media: atomisp: Use struct v4l2_area for padding
In reply to Maurizio CascianoThe padding helper passes width and height as four separate scalar arguments even though they form two logical dimensions.
Pass the requested size and returned padding as struct v4l2_area values. This makes the dimensions explicit and simplifies all three callers.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 51 +++++++++++-------- .../staging/media/atomisp/pci/atomisp_cmd.h | 6 +-- .../staging/media/atomisp/pci/atomisp_ioctl.c | 14 +++-- 3 files changed, 42 insertions(+), 29 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +30 -21
@@ -3562,9 +3562,9 @@ static void atomisp_fill_pix_format(struct v4l2_pix_format *f, f->xfer_func =V4L2_XFER_FUNC_709 ; } -/* Get sensor padding values for the non padded width x height resolution */ -void atomisp_get_padding (struct atomisp_device *isp,u32 width,u32 height, -u32 *padding_w,u32 *padding_h) +/* Get sensor padding values for the non-padded size */ +void atomisp_get_padding (struct atomisp_device *isp,struct v4l2_area size, +struct v4l2_area *pad) {struct atomisp_input_subdev *input = &isp->inputs[isp->asd.input_curr];struct v4l2_rect native_rect = input->native_rect;
@@ -3574,22 +3574,23 @@ void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height,struct v4l2_mbus_framefmt *sink;if (!input->crop_support) { - *padding_w = pad_w; - *padding_h = pad_h; + pad->width = pad_w; + pad->height = pad_h;return ; } - width =min (width, input->active_rect.width); - height =min (height, input->active_rect.height); + size.width =min (size.width, input->active_rect.width); + size.height =min (size.height, input->active_rect.height); -if (input->binning_support && width <= (input->active_rect.width /2 ) && - height <= (input->active_rect.height /2 )) { +if (input->binning_support && + size.width <= (input->active_rect.width /2 ) && + size.height <= (input->active_rect.height /2 )) { native_rect.width /=2 ; native_rect.height /=2 ; } - *padding_w =min_t (u32, (native_rect.width - width) & ~1 , pad_w); - *padding_h =min_t (u32, (native_rect.height - height) & ~1 , pad_h); + pad->width =min_t (u32, (native_rect.width - size.width) & ~1 , pad_w); + pad->height =min_t (u32, (native_rect.height - size.height) & ~1 , pad_h);/* The below minimum padding requirements are for BYT / ISP2400 only */ if (IS_ISP2401 )
@@ -3617,8 +3618,8 @@ void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height, min_pad_h +=2 ; apply_min_padding: - *padding_w =max_t (u32, *padding_w, min_pad_w); - *padding_h =max_t (u32, *padding_h, min_pad_h); + pad->width =max_t (u32, pad->width, min_pad_w); + pad->height =max_t (u32, pad->height, min_pad_h); }int atomisp_s_sensor_power (struct atomisp_device *isp,unsigned int input,bool on)
@@ -3800,7 +3801,8 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,const struct atomisp_format_bridge *fmt, *snr_fmt;struct atomisp_sub_device *asd = &isp->asd;struct v4l2_mbus_framefmt ffmt = { }; -u32 padding_w, padding_h; +struct v4l2_area padding; +struct v4l2_area size;int ret; fmt =atomisp_get_format_bridge (f->pixelformat);
@@ -3827,10 +3829,12 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,* resolution + padding. Add padding here and remove it again after * the set_fmt call, like atomisp_set_fmt_to_snr() does. */ -atomisp_get_padding (isp, f->width, f->height, &padding_w, &padding_h); + size.width = f->width; + size.height = f->height; +atomisp_get_padding (isp, size, &padding);v4l2_fill_mbus_format (&ffmt, f, fmt->mbus_code); - ffmt.width += padding_w; - ffmt.height += padding_h; + ffmt.width += padding.width; + ffmt.height += padding.height;dev_dbg (isp->dev,"try_mbus_fmt: try %ux%u\n" , ffmt.width, ffmt.height);
@@ -3847,8 +3851,8 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,return -EINVAL ; } - f->width = ffmt.width - padding_w; - f->height = ffmt.height - padding_h; + f->width = ffmt.width - padding.width; + f->height = ffmt.height - padding.height;/* * If the format is jpeg or custom RAW, then the width and height will
@@ -4334,6 +4338,8 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)const struct atomisp_format_bridge *format_bridge;const struct atomisp_format_bridge *snr_format_bridge;struct ia_css_frame_info output_info; +struct v4l2_area padding; +struct v4l2_area size;unsigned int dvs_env_w =0 , dvs_env_h =0 ;struct v4l2_mbus_framefmt isp_source_fmt = {0 };struct v4l2_rect isp_sink_crop;
@@ -4366,8 +4372,11 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f) ATOMISP_SUBDEV_PAD_SOURCE, &isp_source_fmt);if (atomisp_subdev_format_conversion (asd)) { -atomisp_get_padding (isp, f->fmt.pix.width, f->fmt.pix.height, - &asd->sink_pad_padding_w, &asd->sink_pad_padding_h); + size.width = f->fmt.pix.width; + size.height = f->fmt.pix.height; +atomisp_get_padding (isp, size, &padding); + asd->sink_pad_padding_w = padding.width; + asd->sink_pad_padding_h = padding.height; }else { asd->sink_pad_padding_w =0 ; asd->sink_pad_padding_h =0 ;
drivers/staging/media/atomisp/pci/atomisp_cmd.h +3 -3
@@ -225,9 +225,9 @@ int atomisp_makeup_css_parameters(struct atomisp_sub_device *asd,int atomisp_compare_grid (struct atomisp_sub_device *asd,struct atomisp_grid_info *atomgrid); -/* Get sensor padding values for the non padded width x height resolution */ -void atomisp_get_padding (struct atomisp_device *isp,u32 width,u32 height, -u32 *padding_w,u32 *padding_h); +/* Get sensor padding values for the non-padded size */ +void atomisp_get_padding (struct atomisp_device *isp,struct v4l2_area size, +struct v4l2_area *pad);/* Set sensor power (no-op if already on/off) */ int atomisp_s_sensor_power (struct atomisp_device *isp,unsigned int input,bool on);
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +9 -5
@@ -470,15 +470,19 @@ static int atomisp_enum_framesizes_crop_inner(struct atomisp_device *isp, { 800, 600 }, { 640, 480 }, }; -u32 padding_w, padding_h;int i;for (i =0 ; i <ARRAY_SIZE (frame_sizes); i++) { -atomisp_get_padding (isp, frame_sizes[i].width, frame_sizes[i].height, - &padding_w, &padding_h); +struct v4l2_area size = { + .width = frame_sizes[i].width, + .height = frame_sizes[i].height, + }; +struct v4l2_area padding; -if ((frame_sizes[i].width + padding_w) > native->width || - (frame_sizes[i].height + padding_h) > native->height) +atomisp_get_padding (isp, size, &padding); + +if ((frame_sizes[i].width + padding.width) > native->width || + (frame_sizes[i].height + padding.height) > native->height)continue ;/*
Signature · 1 line
2.53.0
PATCH v4 14/15 media: atomisp: allow raw Bayer capture
In reply to Maurizio CascianoAtomISP currently rejects all raw formats and silently substitutes YUV420. This prevents userspace camera processing stacks from obtaining unprocessed sensor frames.
Enumerate only the raw format matching the sensor media-bus code and reconcile raw requests with the code selected by the sensor. Userspace opts in by selecting that raw V4L2 pixel format with VIDIOC_S_FMT.
Raw formats expose the full sensor transport frame so ISP2401 can use its copy pipeline. Processed formats retain the existing global padding behavior; selecting a smaller receiver crop remains a userspace pipeline decision.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 19 +++++++++++++------ .../staging/media/atomisp/pci/atomisp_ioctl.c | 19 ++++++++++++++++--- 2 files changed, 29 insertions(+), 9 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +13 -6
@@ -3572,7 +3572,6 @@ void atomisp_get_padding(struct atomisp_device *isp, struct v4l2_area size,u32 min_pad_w =ISP2400_MIN_PAD_W ;u32 min_pad_h =ISP2400_MIN_PAD_H ;struct v4l2_mbus_framefmt *sink; -if (!input->crop_support) { pad->width = pad_w; pad->height = pad_h;
@@ -3806,8 +3805,7 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,int ret; fmt =atomisp_get_format_bridge (f->pixelformat); -/* Currently, raw formats are broken!!! */ -if (!fmt || fmt->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW ) { +if (!fmt) { f->pixelformat =V4L2_PIX_FMT_YUV420 ; fmt =atomisp_get_format_bridge (f->pixelformat);
@@ -3829,9 +3827,13 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,* resolution + padding. Add padding here and remove it again after * the set_fmt call, like atomisp_set_fmt_to_snr() does. */ - size.width = f->width; - size.height = f->height; -atomisp_get_padding (isp, size, &padding); +if (fmt->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW ) { + padding = (struct v4l2_area ) { }; + }else { + size.width = f->width; + size.height = f->height; +atomisp_get_padding (isp, size, &padding); + }v4l2_fill_mbus_format (&ffmt, f, fmt->mbus_code); ffmt.width += padding.width; ffmt.height += padding.height;
@@ -3850,6 +3852,11 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, ffmt.code);return -EINVAL ; } +if (fmt->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW && + fmt->mbus_code != snr_fmt->mbus_code) { + fmt = snr_fmt; + f->pixelformat = fmt->pixelformat; + } f->width = ffmt.width - padding.width; f->height = ffmt.height - padding.height;
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +16 -3
@@ -540,12 +540,21 @@ static int atomisp_enum_framesizes(struct file *file, void *priv, .which = V4L2_SUBDEV_FORMAT_ACTIVE, .code = input->code, }; +const struct atomisp_format_bridge *format;struct v4l2_subdev_state *act_sd_state; +struct v4l2_area padding = { + .width = pad_w, + .height = pad_h, + };int ret;if (!input->sensor)return -EINVAL ; + format =atomisp_get_format_bridge (fsize->pixel_format); +if (!format) +return -EINVAL ; +if (input->crop_support)return atomisp_enum_framesizes_crop (isp, fsize);
@@ -557,9 +566,12 @@ static int atomisp_enum_framesizes(struct file *file, void *priv,if (ret)return ret; +if (format->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW ) + padding = (struct v4l2_area ) { }; + fsize->type =V4L2_FRMSIZE_TYPE_DISCRETE ; - fsize->discrete.width = fse.max_width - pad_w; - fsize->discrete.height = fse.max_height - pad_h; + fsize->discrete.width = fse.max_width - padding.width; + fsize->discrete.height = fse.max_height - padding.height;return 0 ; }
@@ -633,7 +645,8 @@ static int atomisp_enum_fmt_cap(struct file *file, void *fh,* * FIXME: fix the pipeline to allow sensor format too. */ -if (format->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW ) +if (format->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW && + format->mbus_code != code.code)continue ;/* Found a match. Now let's pick f->index'th one. */
Signature · 1 line
2.53.0
PATCH v4 15/15 media: i2c: Add WV517S lens actuator driver
In reply to Maurizio CascianoThe Lenovo Yoga Book YB1-X91 rear camera contains a WV517S voice-coil actuator. Add a V4L2 lens subdevice exposing the standard 10-bit FOCUS_ABSOLUTE control and the device ringing-control mode.
Use regmap for register access and tie control updates to runtime PM so the IPU bridge sensor link keeps shared power resources active. Propagate PM acquisition failures and restore the drive mode and controls after resume.
The register addresses and drive-mode value are derived from Intel's GPL-2.0 WV517 driver. Retain the Intel copyright notice and document the 2026 copyright for this V4L2/regmap implementation.
--- MAINTAINERS | 1 + drivers/media/i2c/Kconfig | 11 ++ drivers/media/i2c/Makefile | 1 + drivers/media/i2c/wv517s.c | 206 +++++++++++++++++++++++++++++++++++++ 4 files changed, 219 insertions(+) create mode 100644 drivers/media/i2c/wv517s.c
MAINTAINERS +1 -0
@@ -28555,6 +28555,7 @@ S: Maintained F: drivers/media/i2c/ak* F: drivers/media/i2c/dw* F: drivers/media/i2c/lm* +F: drivers/media/i2c/wv517s.c V4L2 CAMERA SENSOR DRIVERS M: Sakari Ailus <[email protected]>
drivers/media/i2c/Kconfig +11 -0
@@ -949,6 +949,17 @@ config VIDEO_DW9807_VCM capability. This is designed for linear control of voice coil motors, controlled via I2C serial interface. +config VIDEO_WV517S + tristate "WV517S lens voice coil support" + select REGMAP_I2C + help + This is a driver for the WV517S camera lens voice coil. The driver + supports 10-bit focus control and exposes the actuator through the + standard V4L2 lens sub-device interface. + + To compile this driver as a module, choose M here: the module will be + called wv517s. + endif menu "Flash devices"
drivers/media/i2c/Makefile +1 -0
@@ -173,4 +173,5 @@ obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o obj-$(CONFIG_VIDEO_WM8739) += wm8739.o obj-$(CONFIG_VIDEO_WM8775) += wm8775.o +obj-$(CONFIG_VIDEO_WV517S) += wv517s.o obj-$(CONFIG_VIDEO_INTEL_CVS) += cvs/
drivers/media/i2c/wv517s.c new file +206 -0
206 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v4 01/15] media: ov8858: Extract digital gain programming
In reply to Maurizio CascianoQuoted 2 lines · Maurizio Casciano
Move the existing packed digital-gain register programming into a helper so clock-specific gain handling can be added separately.
My comment was ignored, I am not sure why...
...
drivers/media/i2c/ov8858.c static int ov8858_enable_test_pattern(struct ov8858 *ov8858, u32 pattern) · line 1533
Quoted 8 lines
drivers/media/i2c/ov8858.c +8
-0+static int ov8858_set_long_digital_gain (struct ov8858 *ov8858,u32 gain) +{ +u16 long_gain; + +/* +* Digital gain is assembled as: +* 0x350a[7:0] = dgain[13:6] +* 0x350b[5:0] = dgain[5:0]
This comment most likely has a typo as I pointed out earlier.
Quoted 8 lines
drivers/media/i2c/ov8858.c +8
-0+* Reassemble the control value to write it in one go. +*/ + long_gain = (gain &OV8858_LONG_DIGIGAIN_L_MASK ) | + ((gain &OV8858_LONG_DIGIGAIN_H_MASK ) << +OV8858_LONG_DIGIGAIN_H_SHIFT ); + +return ov8858_write (ov8858,OV8858_REG_LONG_DIGIGAIN , long_gain,NULL ); +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 02/15] media: ov8858: support 19.2 MHz clock and CHT gain setup
In reply to Maurizio CascianoQuoted 19 lines · Maurizio Casciano
The Yoga Book drives its OV8858 from a 19.2 MHz platform clock, while the existing mode tables program the sensor PLL for 24 MHz. Reusing those settings produces incorrect internal and CSI-2 clocks.
Accept both input rates and use the actual rate for the reset delay. For 19.2 MHz, apply the Cherry Trail MRD PLL and black-level settings after the generic mode table.
The 19.2 MHz platform uses the per-channel manual white-balance registers for digital gain. Program registers
0x5032,0x5034and0x5036and expose their 1x-to-4x range, while retaining the existing long-exposure gain block for 24 MHz systems.The manual white-balance register definitions and programming follow the GPL-2.0 Intel OV5670 driver, so retain its 2017 Intel copyright notice in this file. No proprietary source or tuning binary is included.
Tested on the Lenovo Yoga Book YB1-X91L OV8858 with full-range test bars and real 10-bit Bayer frames.
...
drivers/media/i2c/ov8858.c line 34
Quoted 5 lines
drivers/media/i2c/ov8858.c +3
-2-#define OV8858_LINK_FREQ 360000000U -#define OV8858_XVCLK_FREQ 24000000 +#define OV8858_LINK_FREQ (360 * HZ_PER_MHZ) +#define OV8858_XVCLK_FREQ_19_2MHZ (192 * HZ_PER_MHZ / 10) +#define OV8858_XVCLK_FREQ_24MHZ (24 * HZ_PER_MHZ)
I believe the idea was not to touch these. Again I haven't seen the reply on why both comments (Sakari's and mine) were ignored.
...
drivers/media/i2c/ov8858.c static int ov8858_set_long_digital_gain(struct ov8858 *ov8858, u32 gain) · line 1621
Quoted 3 lines
drivers/media/i2c/ov8858.c +2
-1-return ov8858_write (ov8858,OV8858_REG_LONG_DIGIGAIN , long_gain,NULL ); +return ov8858_write (ov8858,OV8858_REG_LONG_DIGIGAIN , + long_gain,NULL );
Stray change.
...
I stopped here, Please, give a full reply to *each* of the comments you disagree with.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 04/15] media: ov2740: Add OVTI2740 ACPI ID
In reply to Maurizio CascianoQuoted 2 lines · Maurizio Casciano
Firmware may enumerate OV2740 image sensors using the OVTI2740 ACPI ID. Add it to the existing ACPI match table.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 05/15] media: ov8858: Add INT3477 ACPI ID
In reply to Maurizio CascianoQuoted 2 lines · Maurizio Casciano
Firmware may use INT3477 as the ACPI hardware ID for an OV8858 image sensor. Add an ACPI match table for that ID.
No tag here from me because I strongly disagree on usage of ACPI_PTR(). But I'm not a media maintainer :-)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 06/15] media: intel: ipu-bridge: Add Yoga Book camera sensors
In reply to Maurizio CascianoQuoted 6 lines · Maurizio Casciano
The Yoga Book YB1-X91 uses INT3477 for its OV8858 rear sensor and OVTI2740 for its OV2740 front sensor. Add link frequencies consumed by the sensor drivers when the IPU bridge constructs software endpoints.
This supplies endpoint data only; it does not establish that either sensor can stream on the Yoga Book hardware.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 07/15] media: atomisp: Add Yoga Book camera configuration
In reply to Maurizio CascianoQuoted 8 lines · Maurizio Casciano
The Yoga Book YB1-X91 firmware lacks usable AtomISP configuration for both cameras. Rear INT3477 OV8858 uses four CSI-2 lanes and a WV517S actuator, while the front OVTI2740 firmware reports the wrong lane count.
Add the rear sensor configuration and a DMI-scoped two-lane override for OVTI2740:00. Add the front sensor configuration separately once its link frequency can be supplied at the same time.
...
Quoted 1 line
What is this for?
...
With the stray Link tag dropped you may add my
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 08/15] media: ov2740: support 288 MHz link frequency
In reply to Maurizio CascianoQuoted 11 lines · Maurizio Casciano
The Lenovo Yoga Book YB1-X91 front camera uses two CSI-2 lanes at a 288 MHz link frequency. Add the matching PLL configuration and mode timing.
Reuse the existing 1932x1092 crop and mode register list so the Bayer order remains SGRBG across link frequencies. Cropping the CSI-2 receiver output to a smaller processed frame is a userspace pipeline decision.
No, you shouldn't add these tags. You can refer to the URLs in a free form in the comment block, and not in the commit message.
Quoted 2 lines
Assisted-by Codex:gpt-5.6-sol sparse---
Comment block is here.
...
drivers/media/i2c/ov2740.c line 24
Quoted 3 lines
#define
OV2740_SCLK72000000LLdrivers/media/i2c/ov2740.c +1
-1-#define OV2740_MCLK 19200000 +#define OV2740_MCLK (192 * HZ_PER_MHZ / 10)
720 is left untouched so should this.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 10 lines · Maurizio Casciano
The Lenovo Yoga Book YB1-X91L exposes an OV2740 front sensor and an OV8858 rear sensor through the Cherry Trail AtomISP. Its firmware does not provide enough information for the existing sensor and IPU bridge drivers to construct the complete camera links.
Add the ACPI IDs and bridge data, describe both AtomISP camera links, support the Yoga Book sensor clocks and modes, expose raw Bayer capture, add per-channel white-balance controls, and add the WV517S rear-camera lens actuator.
Quoted 4 lines
Raw capture is selected through the normal V4L2 raw pixel formats. There is no module parameter or separate private ABI. Raw formats expose the complete sensor transport frame required by the ISP2401 copy pipeline; selecting a smaller crop remains a userspace decision.
Please, try to avoid using AI blindly. Think about the code it generates. Sometimes it's a puke.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 09/15] media: intel: ipu-bridge: allow sensor-specific link frequencies
In reply to Maurizio CascianoQuoted 7 lines · Maurizio Casciano
A bridge-specific firmware parser may have more accurate link-frequency information than the generic ACPI hardware-ID table. Let it store link frequencies in the per-sensor bridge data and prefer those values when constructing the endpoint software node.
Existing bridges continue to use the hardware-ID table when no sensor-specific frequencies are supplied.
...
Quoted 1 line
Drop this.
...
Quoted 1 line
struct
ipu_sensor{
We need to use common sense, AI sometimes produces a crap.
include/media/ipu-bridge.h struct ipu_sensor { · line 143
Quoted 8 lines
include/media/ipu-bridge.h +2
-0u8 link;u8 lanes; +u8 nr_link_freqs;u32 mclkspeed;u32 rotation;enum v4l2_fwnode_orientation orientation;const char *vcm_type; +u64 link_freqs[MAX_NUM_LINK_FREQS ];
I would orginise it as
u64 link_freqs[MAX_NUM_LINK_FREQS]; u8 nr_link_freqs;
// blank line here
u8 link; u8 lanes; u32 mclkspeed; u32 rotation; enum v4l2_fwnode_orientation orientation; const char *vcm_type;
Quoted 2 lines
include/media/ipu-bridge.h +0
-0struct ipu_property_names prop_names;struct property_entry ep_properties[5 ];
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 10/15] media: atomisp: derive CSI-2 timing from sensor link frequency
In reply to Maurizio CascianoQuoted 7 lines · Maurizio Casciano
The ISP2401 CSI-2 receiver timing depends on the sensor link frequency. Query it through
v4l2_get_link_freq()instead of reading a 32-bit control value directly.Keep the frequency as s64 throughout the calculation so valid link frequencies do not require an arbitrary
S32_MAXlimit. Fall back to the existing default timings when the frequency query fails.
...
Quoted 1 line
Drop this.
...
drivers/staging/media/atomisp/pci/atomisp_csi2.c static void atomisp_csi2_configure_isp2401(struct atomisp_sub_device *asd) · line 294
Quoted 10 lines
static void
atomisp_csi2_configure_isp2401(struct atomisp_sub_device *asd)drivers/staging/media/atomisp/pci/atomisp_csi2.c +2
-2int dat_termen;int dat_settle; -struct v4l2_control ctrl;struct atomisp_device *isp = asd->isp; -int mipi_freq =0 ; +struct v4l2_subdev *sensor; +s64 mipi_freq;
Move it one line below, ...
Quoted 1 line
enum
atomisp_camera_portport;
...to here.
Quoted 1 line
int n;
...
Otherwise LGTM,
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 11/15] media: atomisp: provide Yoga Book OV2740 link frequency
In reply to Maurizio CascianoQuoted 8 lines · Maurizio Casciano
The Lenovo Yoga Book YB1-X91 firmware does not describe the front OV2740 link frequency. Extend the AtomISP sensor configuration with an optional frequency and assign the 288 MHz Yoga Book value while adding its ACPI ID.
Pass the value through the IPU bridge per-sensor endpoint data so the OV2740 driver selects its matching mode and the AtomISP CSI-2 receiver derives the correct D-PHY timing.
...
Quoted 1 line
Drop this.
...
Otherwise, if we are okay with this data to be attached here, it looks good.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 12/15] media: ov2740: add manual white balance controls
In reply to Maurizio CascianoQuoted 9 lines · Maurizio Casciano
The sensor has separate red, green and blue manual white-balance gain registers, but the driver currently writes the same digital-gain value to all three channels. This prevents userspace from correcting the strong color cast of raw Bayer capture.
Expose red- and blue-balance controls relative to the digital gain, update all three channels under group hold,
and always release and launch the group even when a channel write fails.
This part can be split to a separate change explaining "why?". What's wrong if we don't do this (as it's currently done in the original code)?
Quoted 2 lines
Tested on the Yoga Book OV2740 with live gain changes and continuous raw capture.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 13/15] media: atomisp: Use struct v4l2_area for padding
In reply to Maurizio CascianoQuoted 7 lines · Maurizio Casciano
The padding helper passes width and height as four separate scalar arguments even though they form two logical dimensions.
Pass the requested size and returned padding as struct
v4l2_areavalues. This makes the dimensions explicit and simplifies all three callers.Suggested-by Andy Shevchenko <[email protected]>
This is fine...
Quoted 1 line
...but drop this one. No need to have it in the commit message even if there is an accompanying Suggested-by tag.
...
Quoted 14 lines
int atomisp_try_fmt(struct
atomisp_device*isp, structv4l2_pix_format*f,(quoted diff) +2
-1const struct atomisp_format_bridge *fmt, *snr_fmt; struct atomisp_sub_device *asd = &isp->asd; struct v4l2_mbus_framefmt ffmt = { }; - u32 padding_w, padding_h; + struct v4l2_area padding; + struct v4l2_area size; int ret; fmt = atomisp_get_format_bridge(f->pixelformat); * resolution + padding. Add padding here and remove it again after * the set_fmt call, like atomisp_set_fmt_to_snr() does.
Review
Quoted 10 lines
(quoted diff) +5
-3*/ - atomisp_get_padding(isp, f->width, f->height, &padding_w, &padding_h); + size.width = f->width; + size.height = f->height; + atomisp_get_padding(isp, size, &padding); v4l2_fill_mbus_format(&ffmt, f, fmt->mbus_code); - ffmt.width += padding_w; - ffmt.height += padding_h; + ffmt.width += padding.width; + ffmt.height += padding.height;
Add a wrapper that takes struct v4l2_pix_format
static inline void atomisp_get_pix_padding(struct atomisp_device *isp,
struct v4l2_pix_format *f, struct v4l2_area *pad)
{
struct v4l2_area size = { .width = f->width, .height = f->height };
atomisp_get_padding(isp, size, pad);
}So it will become here as
atomisp_get_pix_padding(isp, f, &padding);
...
drivers/staging/media/atomisp/pci/atomisp_cmd.c int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f) · line 4379
Quoted 8 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +5
-2if (atomisp_subdev_format_conversion (asd)) { -atomisp_get_padding (isp, f->fmt.pix.width, f->fmt.pix.height, - &asd->sink_pad_padding_w, &asd->sink_pad_padding_h); + size.width = f->fmt.pix.width; + size.height = f->fmt.pix.height; +atomisp_get_padding (isp, size, &padding); + asd->sink_pad_padding_w = padding.width; + asd->sink_pad_padding_h = padding.height;
And respectively here
atomisp_get_pix_padding(isp, &f->fmt.pix, &padding);
drivers/staging/media/atomisp/pci/atomisp_cmd.c int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f) · line 4382
Quoted 3 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +0
-0}else { asd->sink_pad_padding_w =0 ; asd->sink_pad_padding_h =0 ;
Looking at this, I would also replace these two in asd to be struct v4l2_area. There are only three users.
With that this becomes
if (atomisp_subdev_format_conversion(asd))
atomisp_get_pix_padding(isp, &f->fmt.pix, &asd->sink_pad_padding);
else
asd->sink_pad_padding = {};...
Quoted 5 lines
static int atomisp_enum_framesizes_crop_inner(struct
atomisp_device*isp,drivers/staging/media/atomisp/pci/atomisp_ioctl.c +0
-0{ 800, 600 }, { 640, 480 }, };
drivers/staging/media/atomisp/pci/atomisp_ioctl.c static int atomisp_enum_framesizes_crop_inner(struct atomisp_device *isp, · line 479
Quoted 10 lines
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +4
-3-u32 padding_w, padding_h;int i;for (i =0 ; i <ARRAY_SIZE (frame_sizes); i++) { -atomisp_get_padding (isp, frame_sizes[i].width, frame_sizes[i].height, - &padding_w, &padding_h); +struct v4l2_area size = { + .width = frame_sizes[i].width, + .height = frame_sizes[i].height, + };
Just convert frame_sizes to be of struct v4l2_area type.
drivers/staging/media/atomisp/pci/atomisp_ioctl.c static int atomisp_enum_framesizes_crop_inner(struct atomisp_device *isp, · line 486
Quoted 9 lines
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +5
-2+struct v4l2_area padding; -if ((frame_sizes[i].width + padding_w) > native->width || - (frame_sizes[i].height + padding_h) > native->height) +atomisp_get_padding (isp, size, &padding); + +if ((frame_sizes[i].width + padding.width) > native->width || + (frame_sizes[i].height + padding.height) > native->height)continue ;
Then only fsize->discrete = frame_sizes[i]; will require the member-to-member assignment.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 14/15] media: atomisp: allow raw Bayer capture
In reply to Maurizio CascianoQuoted 12 lines · Maurizio Casciano
AtomISP currently rejects all raw formats and silently substitutes YUV420. This prevents userspace camera processing stacks from obtaining unprocessed sensor frames.
Enumerate only the raw format matching the sensor media-bus code and reconcile raw requests with the code selected by the sensor. Userspace opts in by selecting that raw V4L2 pixel format with
VIDIOC_S_FMT.Raw formats expose the full sensor transport frame so ISP2401 can use its copy pipeline. Processed formats retain the existing global padding behavior; selecting a smaller receiver crop remains a userspace pipeline decision.
...
Quoted 2 lines
Drop these.
...
drivers/staging/media/atomisp/pci/atomisp_cmd.c void atomisp_get_padding(struct atomisp_device *isp, struct v4l2_area size, · line 3577
Quoted 9 lines
void atomisp_get_padding(struct
atomisp_device*isp, structv4l2_areasize,drivers/staging/media/atomisp/pci/atomisp_cmd.c +0
-1u32 min_pad_w =ISP2400_MIN_PAD_W ;u32 min_pad_h =ISP2400_MIN_PAD_H ;struct v4l2_mbus_framefmt *sink; -if (!input->crop_support) { pad->width = pad_w; pad->height = pad_h;
Stray change.
...
drivers/staging/media/atomisp/pci/atomisp_cmd.c int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, · line 3836
Quoted 10 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +7
-3- size.width = f->width; - size.height = f->height; -atomisp_get_padding (isp, size, &padding); +if (fmt->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW ) { + padding = (struct v4l2_area ) { }; + }else { + size.width = f->width; + size.height = f->height; +atomisp_get_padding (isp, size, &padding); + }
Compound literal is not needed here. With the previous suggestions this becomes
if (fmt->sh_fmt == IA_CSS_FRAME_FORMAT_RAW)
padding = {};
else
atomisp_get_padding(isp, f, &padding);...
drivers/staging/media/atomisp/pci/atomisp_cmd.c int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, · line 3854
Quoted 3 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +0
-0ffmt.code);return -EINVAL ; }
Not enough context, but I assume a blank line is good to have here.
Quoted 5 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +5
-0+if (fmt->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW && + fmt->mbus_code != snr_fmt->mbus_code) { + fmt = snr_fmt; + f->pixelformat = fmt->pixelformat; + }
...
drivers/staging/media/atomisp/pci/atomisp_ioctl.c static int atomisp_enum_framesizes(struct file *file, void *priv, · line 570
Quoted 2 lines
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +2
-0+if (format->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW ) + padding = (struct v4l2_area ) { };
padding = {};should suffice.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 05/15] media: ov8858: Add INT3477 ACPI ID
In reply to Andy ShevchenkoHi Andy, Sakari,
Thank you. The use of ACPI_PTR() in v4 was intentional and followed Sakari's explicit request in the v2 review:
"Please use ACPI_PTR() for this one."
That review also referred to:
https://lore.kernel.org/linux-media/[email protected]/T/#t
Andy subsequently noted that the last patch in that related series was controversial and had been NAKed. I should have called out this conflict explicitly when sending v4 instead of leaving the rationale undocumented.
For v5 I have retained ACPI_PTR() for now. Removing it unilaterally would discard an explicit media-maintainer request, while keeping it without clarification would ignore Andy's objection and would not earn his review tag.
Could you please confirm which form you want for v5 while the related ACPI_PTR() work is unresolved?
.acpi_match_table = ACPI_PTR(ov8858_acpi_match),
or:
.acpi_match_table = ov8858_acpi_match,
I will use the agreed form and will not send v5 until this point is settled.
With Best Regards,
Maurizio Casciano
Re: [PATCH v4 05/15] media: ov8858: Add INT3477 ACPI ID
Quoted 23 lines · On Mon, Aug 31, 2026 at 01:12:41PM +0000, [email protected] wrote:
Hi Andy, Sakari,
Thank you. The use of
ACPI_PTR()in v4 was intentional and followed Sakari's explicit request in the v2 review:"Please use
ACPI_PTR()for this one."That review also referred to:
https://lore.kernel.org/linux-media/[email protected]/T/#t
Andy subsequently noted that the last patch in that related series was controversial and had been NAKed. I should have called out this conflict explicitly when sending v4 instead of leaving the rationale undocumented.
For v5 I have retained
ACPI_PTR()for now. Removing it unilaterally would discard an explicit media-maintainer request, while keeping it without clarification would ignore Andy's objection and would not earn his review tag.Could you please confirm which form you want for v5 while the related
ACPI_PTR()work is unresolved?
Quoted 8 lines
.acpi_match_table =
ACPI_PTR(ov8858_acpi_match),or:
.acpi_match_table =
ov8858_acpi_match,I will use the agreed form and will not send v5 until this point is settled.
Sakari is media maintainer, do how he says.
Signature · 2 lines
With Best Regards, Andy Shevchenko
v5 cover media: Add Lenovo Yoga Book YB1-X91 camera support
In reply to Maurizio CascianoThe Lenovo Yoga Book YB1-X91L exposes an OV2740 front sensor and an OV8858 rear sensor through the Cherry Trail AtomISP. Its firmware does not provide enough information for the existing sensor and IPU bridge drivers to construct the complete camera links.
Add the ACPI IDs and bridge data, describe both AtomISP camera links, support the Yoga Book sensor clocks and modes, expose raw Bayer capture, add per-channel white-balance controls, and add the WV517S rear-camera lens actuator.
Raw capture is selected through the normal V4L2 raw pixel formats. There is no module parameter or separate private ABI. Raw formats expose the complete sensor transport frame required by the ISP2401 copy pipeline; selecting a smaller crop remains a userspace decision.
Changes since v4:
- retain the HZ_PER_MHZ conversions requested during review, including the canonical 24 MHz OV8858 clock constant;
- retain ACPI_PTR() for the OV8858 match table as Sakari requested; Andy subsequently confirmed that Sakari's media-maintainer guidance should decide this point;
- add Andy's Reviewed-by tags to the unchanged patches he accepted;
- move the existing OV2740 group-hold error-unwinding correction into a separate preparatory patch before the white-balance controls;
- complete the AtomISP struct v4l2_area conversion for persistent sink padding, padding helpers, frame-size tables and all callers;
- keep the OV8858 digital-gain extraction a pure refactoring, preserving the original register packing and explanatory comment;
- use the existing OV8858_XVCLK_FREQ name for 24 MHz and keep a distinct constant only for 19.2 MHz; and
- standardize the Assisted-by trailers without changing authorship or Signed-off-by certification.
v4:
https://lore.kernel.org/linux-media/[email protected]/
The tablet DSDT contains the sensor objects requested during review:
Device (CA11)
{
Name (_HID, "INT3477")
Name (_CID, "OVTI8858")
Name (_DDN, "OV8858")
}
Device (CA01)
{
Name (_HID, "OVTI2740")
Name (_CID, "OVTI2740")
Name (_DDN, "OV2740")
}All sixteen patches pass strict checkpatch. Integration commit 780663f0af3b contains the exact v5 media series and passed olddefconfig, focused W=1 C=2 CHECK=sparse builds, and a full x86_64 Debian package build. The full build log contains no warning in a touched file.
Runtime testing used a Lenovo Yoga Book YB1-X91L booted with 7.2.0-yogabook-20260831-153058. OV2740, OV8858, WV517S and AtomISP bound, and AtomISP reported two connected cameras. Processed front and rear streams completed and actual switching was confirmed through distinct BA10/GRBG and BG10/BGGR sensor paths.
Direct raw capture produced five complete OV2740 BA10 frames (22,364,160 bytes) and five complete OV8858 BG10 frames (20,377,600 bytes). The OV2740 red/blue balance controls were set to 1200/1300, read back and exercised during a five-frame raw capture, then restored to 1024/1024. WV517S focus was set to 448 during rear raw streaming and restored to 300.
During rear streaming, OV8858 and AtomISP were runtime active while OV2740 remained suspended; all returned to runtime suspended after idle. A 15-second s2idle cycle with RTC wake resumed successfully on the same kernel. Front processed capture, SOF playback/capture, and both DRV2604 force-feedback devices were rechecked after resume without regression.
With Best Regards,
Maurizio Casciano
Maurizio Casciano (16):
media: ov8858: Extract digital gain programming
media: ov8858: support 19.2 MHz clock and CHT gain setup
media: ov2740: Use C99 initializers for ACPI IDs
media: ov2740: Add OVTI2740 ACPI ID
media: ov8858: Add INT3477 ACPI ID
media: intel: ipu-bridge: Add Yoga Book camera sensors
media: atomisp: Add Yoga Book camera configuration
media: ov2740: support 288 MHz link frequency
media: intel: ipu-bridge: allow sensor-specific link frequencies
media: atomisp: derive CSI-2 timing from sensor link frequency
media: atomisp: provide Yoga Book OV2740 link frequency
media: ov2740: release group hold after gain write errors
media: ov2740: add manual white balance controls
media: atomisp: Use struct v4l2_area for padding
media: atomisp: allow raw Bayer capture
media: i2c: Add WV517S lens actuator driver
MAINTAINERS | 1 + drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov2740.c | 114 +++++++--- drivers/media/i2c/ov8858.c | 166 ++++++++++++-- drivers/media/i2c/wv517s.c | 206 ++++++++++++++++++ drivers/media/pci/intel/ipu-bridge.c | 19 +- .../staging/media/atomisp/pci/atomisp_cmd.c | 80 ++++--- .../staging/media/atomisp/pci/atomisp_cmd.h | 6 +- .../staging/media/atomisp/pci/atomisp_csi2.c | 20 +- .../media/atomisp/pci/atomisp_csi2_bridge.c | 30 ++- .../staging/media/atomisp/pci/atomisp_ioctl.c | 34 ++- .../media/atomisp/pci/atomisp_subdev.c | 4 +- .../media/atomisp/pci/atomisp_subdev.h | 3 +- include/media/ipu-bridge.h | 3 + 15 files changed, 588 insertions(+), 110 deletions(-) create mode 100644 drivers/media/i2c/wv517s.c
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 1/16 media: ov8858: Extract digital gain programming
Move the existing packed digital-gain register programming into a helper so clock-specific gain handling can be added separately.
This is a pure refactoring: preserve both the register packing and the explanatory comment without changing the bytes written to the sensor.
--- drivers/media/i2c/ov8858.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/media/i2c/ov8858.c +18 -12
@@ -1523,6 +1523,23 @@ static int ov8858_enable_test_pattern(struct ov8858 *ov8858, u32 pattern)return ov8858_write (ov8858,OV8858_REG_TEST_PATTERN , val,NULL ); } +static int ov8858_set_long_digital_gain (struct ov8858 *ov8858,u32 gain) +{ +u16 long_gain; + +/* +* Digital gain is assembled as: +* 0x350a[7:0] = dgain[13:6] +* 0x350b[5:0] = dgain[5:0] +* Reassemble the control value to write it in one go. +*/ + long_gain = (gain &OV8858_LONG_DIGIGAIN_L_MASK ) | + ((gain &OV8858_LONG_DIGIGAIN_H_MASK ) << +OV8858_LONG_DIGIGAIN_H_SHIFT ); + +return ov8858_write (ov8858,OV8858_REG_LONG_DIGIGAIN , long_gain,NULL ); +} +static int ov8858_set_ctrl (struct v4l2_ctrl *ctrl) { struct ov8858 *ov8858 = container_of(ctrl->handler,
@@ -1531,7 +1548,6 @@ static int ov8858_set_ctrl(struct v4l2_ctrl *ctrl)struct i2c_client *client =v4l2_get_subdevdata (&ov8858->subdev);struct v4l2_mbus_framefmt *format;struct v4l2_subdev_state *state; -u16 digi_gain;s64 max_exp;int ret;
@@ -1570,17 +1586,7 @@ static int ov8858_set_ctrl(struct v4l2_ctrl *ctrl) ctrl->val, NULL);break ;case V4L2_CID_DIGITAL_GAIN : -/* -* Digital gain is assembled as: -* 0x350a[7:0] = dgain[13:6] -* 0x350b[5:0] = dgain[5:0] -* Reassemble the control value to write it in one go. -*/ - digi_gain = (ctrl->val &OV8858_LONG_DIGIGAIN_L_MASK ) - | ((ctrl->val &OV8858_LONG_DIGIGAIN_H_MASK ) << -OV8858_LONG_DIGIGAIN_H_SHIFT ); - ret =ov8858_write (ov8858,OV8858_REG_LONG_DIGIGAIN , - digi_gain,NULL ); + ret =ov8858_set_long_digital_gain (ov8858, ctrl->val);break ;case V4L2_CID_VBLANK : ret = ov8858_write(ov8858, OV8858_REG_VTS,
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 2/16 media: ov8858: support 19.2 MHz clock and CHT gain setup
In reply to Maurizio CascianoThe Yoga Book drives its OV8858 from a 19.2 MHz platform clock, while the existing mode tables program the sensor PLL for 24 MHz. Reusing those settings produces incorrect internal and CSI-2 clocks.
Accept both input rates and use the actual rate for the reset delay. For 19.2 MHz, apply the Cherry Trail MRD PLL and black-level settings after the generic mode table.
The 19.2 MHz platform uses the per-channel manual white-balance registers for digital gain. Program registers 0x5032, 0x5034 and 0x5036 and expose their 1x-to-4x range, while retaining the existing long-exposure gain block for 24 MHz systems.
The manual white-balance register definitions and programming follow the GPL-2.0 Intel OV5670 driver, so retain its 2017 Intel copyright notice in this file. No proprietary source or tuning binary is included.
Tested on the Lenovo Yoga Book YB1-X91L OV8858 with full-range test bars and real 10-bit Bayer frames.
--- drivers/media/i2c/ov8858.c | 130 +++++++++++++++++++++++++++++++++---- 1 file changed, 118 insertions(+), 12 deletions(-)
drivers/media/i2c/ov8858.c +118 -12
@@ -3,10 +3,9 @@* Copyright (C) 2023 Jacopo Mondi <[email protected]> * Copyright (C) 2022 Nicholas Roth <[email protected]> * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd. +* Copyright (c) 2017 Intel Corporation. */ -#include <linux/unaligned.h> -#include <linux/clk.h> #include <linux/delay.h> #include <linux/device.h>
@@ -18,6 +17,8 @@#include <linux/property.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> +#include <linux/unaligned.h> +#include <linux/units.h> #include <media/media-entity.h> #include <media/v4l2-async.h>
@@ -28,8 +29,9 @@#include <media/v4l2-mediabus.h> #include <media/v4l2-subdev.h> -#define OV8858_LINK_FREQ 360000000U -#define OV8858_XVCLK_FREQ 24000000 +#define OV8858_LINK_FREQ (360 * HZ_PER_MHZ) +#define OV8858_XVCLK_FREQ (24 * HZ_PER_MHZ) +#define OV8858_XVCLK_FREQ_19_2MHZ (192 * HZ_PER_MHZ / 10)#define OV8858_REG_SIZE_SHIFT 16#define OV8858_REG_ADDR_MASK 0xffff
@@ -59,6 +61,14 @@#define OV8858_LONG_GAIN_STEP 1#define OV8858_LONG_GAIN_DEFAULT 0x80 +#define OV8858_REG_MWB_RED_GAIN OV8858_REG_16BIT(0x5032) +#define OV8858_REG_MWB_GREEN_GAIN OV8858_REG_16BIT(0x5034) +#define OV8858_REG_MWB_BLUE_GAIN OV8858_REG_16BIT(0x5036) +#define OV8858_MWB_GAIN_MIN 0x400 +#define OV8858_MWB_GAIN_MAX 0xfff +#define OV8858_MWB_GAIN_STEP 1 +#define OV8858_MWB_GAIN_DEFAULT 0x400 +#define OV8858_REG_LONG_DIGIGAIN OV8858_REG_16BIT(0x350a)#define OV8858_LONG_DIGIGAIN_H_MASK 0x3fc0#define OV8858_LONG_DIGIGAIN_L_MASK 0x3f
@@ -93,6 +103,33 @@ struct regval_modes {const struct regval *mode_4lanes; }; +struct ov8858_gain_range { +u32 min; +u32 max; +u32 step; +u32 def; +}; + +enum ov8858_xvclk_index { +OV8858_XVCLK_24MHZ , +OV8858_XVCLK_19_2MHZ , +}; + +static const struct ov8858_gain_range ov8858_digital_gain_ranges[] = { + [OV8858_XVCLK_24MHZ ] = { + .min =OV8858_LONG_DIGIGAIN_MIN , + .max =OV8858_LONG_DIGIGAIN_MAX , + .step =OV8858_LONG_DIGIGAIN_STEP , + .def =OV8858_LONG_DIGIGAIN_DEFAULT , + }, + [OV8858_XVCLK_19_2MHZ ] = { + .min =OV8858_MWB_GAIN_MIN , + .max =OV8858_MWB_GAIN_MAX , + .step =OV8858_MWB_GAIN_STEP , + .def =OV8858_MWB_GAIN_DEFAULT , + }, +}; +struct ov8858_mode {u32 width;u32 height;
@@ -104,6 +141,7 @@ struct ov8858_mode {struct ov8858 {struct clk *xvclk; +unsigned long xvclk_rate;struct gpio_desc *reset_gpio;struct gpio_desc *pwdn_gpio;struct regulator_bulk_data supplies[ARRAY_SIZE (ov8858_supply_names)];
@@ -121,6 +159,41 @@ struct ov8858 {unsigned int num_lanes; }; +/* +* Cherry Trail MRD production settings for a 19.2 MHz input and 360 MHz +* CSI-2 link. Apply these after the otherwise reusable 24 MHz mode table. +* +* Besides the corrected sensor/MIPI PLL divisors, keep the final common +* black-level settings here. The per-mode tables retain their resolution +* dependent black-column anchors and window sizes. +*/ +static const struct regval ov8858_cht_mrd_19_2mhz[] = { + {0x0300 ,0x00 }, + {0x0302 ,0x27 }, + {0x0303 ,0x00 }, + {0x0304 ,0x03 }, + {0x030b ,0x00 }, + {0x030d ,0x27 }, + {0x030e ,0x00 }, + {0x030f ,0x04 }, + {0x0312 ,0x01 }, + {0x031e ,0x0c }, + {0x3f08 ,0x08 }, + {0x400a ,0x01 }, + {0x400d ,0x10 }, + {0x4011 ,0x20 }, + {0x403e ,0x08 }, + {0x4040 ,0x07 }, + {0x4041 ,0xc6 }, + {0x4202 ,0x00 }, + {0x4500 ,0x58 }, + {0x470b ,0x28 }, + {0x4837 ,0x15 }, + {0x58f4 ,0x32 }, + {0x58f8 ,0x3d }, + {REG_NULL ,0x00 }, +}; +static inline struct ov8858 *sd_to_ov8858 (struct v4l2_subdev *sd) { return container_of(sd, struct ov8858, subdev);
@@ -1345,6 +1418,13 @@ static int ov8858_start_stream(struct ov8858 *ov8858,if (ret)return ret; +/* The mode tables contain PLL settings for a 24 MHz input clock. */ +if (ov8858->xvclk_rate ==OV8858_XVCLK_FREQ_19_2MHZ ) { + ret =ov8858_write_array (ov8858, ov8858_cht_mrd_19_2mhz); +if (ret) +return ret; + } +/* 200 usec max to let PLL stabilize. */ fsleep (200 );
@@ -1540,6 +1620,21 @@ static int ov8858_set_long_digital_gain(struct ov8858 *ov8858, u32 gain)return ov8858_write (ov8858,OV8858_REG_LONG_DIGIGAIN , long_gain,NULL ); } +static int ov8858_set_mwb_digital_gain (struct ov8858 *ov8858,u32 gain) +{ +int ret; + + ret =ov8858_write (ov8858,OV8858_REG_MWB_RED_GAIN , gain,NULL ); +if (ret) +return ret; + + ret =ov8858_write (ov8858,OV8858_REG_MWB_GREEN_GAIN , gain,NULL ); +if (ret) +return ret; + +return ov8858_write (ov8858,OV8858_REG_MWB_BLUE_GAIN , gain,NULL ); +} +static int ov8858_set_ctrl (struct v4l2_ctrl *ctrl) { struct ov8858 *ov8858 = container_of(ctrl->handler,
@@ -1586,7 +1681,10 @@ static int ov8858_set_ctrl(struct v4l2_ctrl *ctrl) ctrl->val, NULL);break ;case V4L2_CID_DIGITAL_GAIN : - ret =ov8858_set_long_digital_gain (ov8858, ctrl->val); +if (ov8858->xvclk_rate ==OV8858_XVCLK_FREQ_19_2MHZ ) + ret =ov8858_set_mwb_digital_gain (ov8858, ctrl->val); +else + ret =ov8858_set_long_digital_gain (ov8858, ctrl->val);break ;case V4L2_CID_VBLANK : ret = ov8858_write(ov8858, OV8858_REG_VTS,
@@ -1622,9 +1720,6 @@ static int ov8858_power_on(struct ov8858 *ov8858)unsigned long delay_us;int ret; -if (clk_get_rate (ov8858->xvclk) !=OV8858_XVCLK_FREQ ) -dev_warn (dev,"xvclk mismatched, modes are based on 24MHz\n" ); - ret =clk_prepare_enable (ov8858->xvclk);if (ret <0 ) {dev_err (dev,"Failed to enable xvclk\n" );
@@ -1643,7 +1738,7 @@ static int ov8858_power_on(struct ov8858 *ov8858)* transaction, but a double sleep between the release of gpios * helps with sporadic failures observed at probe time. */ - delay_us =DIV_ROUND_UP (8192 ,OV8858_XVCLK_FREQ /1000 /1000 ); + delay_us =DIV_ROUND_UP (8192 , ov8858->xvclk_rate /HZ_PER_MHZ );gpiod_set_value_cansleep (ov8858->reset_gpio,0 );fsleep (delay_us);
@@ -1701,9 +1796,11 @@ static int ov8858_init_ctrls(struct ov8858 *ov8858) {struct i2c_client *client =v4l2_get_subdevdata (&ov8858->subdev);struct v4l2_ctrl_handler *handler = &ov8858->ctrl_handler; +const struct ov8858_gain_range *digital_gain_range;const struct ov8858_mode *mode = &ov8858_modes[0 ];struct v4l2_fwnode_device_properties props;s64 exposure_max, vblank_def; +unsigned int xvclk_index;unsigned int pixel_rate;struct v4l2_ctrl *ctrl;u32 h_blank;
@@ -1746,10 +1843,12 @@ static int ov8858_init_ctrls(struct ov8858 *ov8858)OV8858_LONG_GAIN_MIN ,OV8858_LONG_GAIN_MAX , OV8858_LONG_GAIN_STEP, OV8858_LONG_GAIN_DEFAULT); + xvclk_index = ov8858->xvclk_rate ==OV8858_XVCLK_FREQ_19_2MHZ ? +OV8858_XVCLK_19_2MHZ :OV8858_XVCLK_24MHZ ; + digital_gain_range = &ov8858_digital_gain_ranges[xvclk_index];v4l2_ctrl_new_std (handler, &ov8858_ctrl_ops,V4L2_CID_DIGITAL_GAIN , -OV8858_LONG_DIGIGAIN_MIN ,OV8858_LONG_DIGIGAIN_MAX , -OV8858_LONG_DIGIGAIN_STEP , -OV8858_LONG_DIGIGAIN_DEFAULT ); + digital_gain_range->min, digital_gain_range->max, + digital_gain_range->step, digital_gain_range->def); v4l2_ctrl_new_std_menu_items(handler, &ov8858_ctrl_ops, V4L2_CID_TEST_PATTERN,
@@ -1887,6 +1986,13 @@ static int ov8858_probe(struct i2c_client *client)return dev_err_probe (dev,PTR_ERR (ov8858->xvclk),"Failed to get xvclk\n" ); + ov8858->xvclk_rate =clk_get_rate (ov8858->xvclk); +if (ov8858->xvclk_rate !=OV8858_XVCLK_FREQ_19_2MHZ && + ov8858->xvclk_rate !=OV8858_XVCLK_FREQ ) +return dev_err_probe (dev, -EINVAL , +"Unsupported xvclk rate %lu Hz\n" , + ov8858->xvclk_rate); + ov8858->reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (ov8858->reset_gpio))
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 3/16 media: ov2740: Use C99 initializers for ACPI IDs
In reply to Maurizio CascianoUse designated initializers and the standard empty sentinel style before adding firmware IDs.
--- drivers/media/i2c/ov2740.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/i2c/ov2740.c +2 -3
@@ -1461,10 +1461,9 @@ static DEFINE_RUNTIME_DEV_PM_OPS(ov2740_pm_ops, ov2740_suspend, ov2740_resume, NULL);static const struct acpi_device_id ov2740_acpi_ids[] = { - {"INT3474" }, - {} + { .id ="INT3474" }, + { } }; -MODULE_DEVICE_TABLE (acpi, ov2740_acpi_ids);static struct i2c_driver ov2740_i2c_driver = {
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 4/16 media: ov2740: Add OVTI2740 ACPI ID
In reply to Maurizio CascianoFirmware may enumerate OV2740 image sensors using the OVTI2740 ACPI ID. Add it to the existing ACPI match table.
--- drivers/media/i2c/ov2740.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/ov2740.c +1 -0
@@ -1462,6 +1462,7 @@ static DEFINE_RUNTIME_DEV_PM_OPS(ov2740_pm_ops, ov2740_suspend, ov2740_resume,static const struct acpi_device_id ov2740_acpi_ids[] = { { .id ="INT3474" }, + { .id ="OVTI2740" }, { } };MODULE_DEVICE_TABLE (acpi, ov2740_acpi_ids);
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 5/16 media: ov8858: Add INT3477 ACPI ID
In reply to Maurizio CascianoFirmware may use INT3477 as the ACPI hardware ID for an OV8858 image sensor. Add an ACPI match table for that ID.
--- drivers/media/i2c/ov8858.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/media/i2c/ov8858.c +8 -0
@@ -6,6 +6,7 @@* Copyright (c) 2017 Intel Corporation. */ +#include <linux/acpi.h> #include <linux/clk.h> #include <linux/delay.h> #include <linux/device.h>
@@ -2087,6 +2088,12 @@ static void ov8858_remove(struct i2c_client *client)pm_runtime_set_suspended (&client->dev); } +static const struct acpi_device_id ov8858_acpi_match[] = { + { .id ="INT3477" }, + { } +}; +MODULE_DEVICE_TABLE (acpi, ov8858_acpi_match); +static const struct of_device_id ov8858_of_match[] = { { .compatible ="ovti,ov8858" }, {/* sentinel */ },
@@ -2097,6 +2104,7 @@ static struct i2c_driver ov8858_i2c_driver = { .driver = { .name = "ov8858", .pm = &ov8858_pm_ops, + .acpi_match_table = ACPI_PTR(ov8858_acpi_match), .of_match_table = ov8858_of_match, }, .probe = ov8858_probe,
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 6/16 media: intel: ipu-bridge: Add Yoga Book camera sensors
In reply to Maurizio CascianoThe Yoga Book YB1-X91 uses INT3477 for its OV8858 rear sensor and OVTI2740 for its OV2740 front sensor. Add link frequencies consumed by the sensor drivers when the IPU bridge constructs software endpoints.
This supplies endpoint data only; it does not establish that either sensor can stream on the Yoga Book hardware.
--- drivers/media/pci/intel/ipu-bridge.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/pci/intel/ipu-bridge.c +4 -0
@@ -65,6 +65,8 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = {IPU_SENSOR_CONFIG ("INT33F0" ,1 ,384000000 ),/* Omnivision OV2740 */ IPU_SENSOR_CONFIG ("INT3474" ,1 ,180000000 ), +/* Omnivision OV8858 */ +IPU_SENSOR_CONFIG ("INT3477" ,1 ,360000000 ),/* Omnivision OV5670 */ IPU_SENSOR_CONFIG("INT3479", 1, 422400000),/* Omnivision OV8865 */
@@ -93,6 +95,8 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = {IPU_SENSOR_CONFIG ("OVTIDB10" ,1 ,560000000 ),/* Omnivision OV2680 */ IPU_SENSOR_CONFIG ("OVTI2680" ,1 ,331200000 ), +/* Omnivision OV2740 */ +IPU_SENSOR_CONFIG ("OVTI2740" ,1 ,360000000 ),/* Omnivision OV5675 */ IPU_SENSOR_CONFIG("OVTI5675", 1, 450000000),/* Omnivision OV8856 */
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 7/16 media: atomisp: Add Yoga Book camera configuration
In reply to Maurizio CascianoThe Yoga Book YB1-X91 firmware lacks usable AtomISP configuration for both cameras. Rear INT3477 OV8858 uses four CSI-2 lanes and a WV517S actuator, while the front OVTI2740 firmware reports the wrong lane count.
Add the rear sensor configuration and a DMI-scoped two-lane override for OVTI2740:00. Add the front sensor configuration separately once its link frequency can be supplied at the same time.
--- .../media/atomisp/pci/atomisp_csi2_bridge.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c +18 -1
@@ -74,6 +74,12 @@ static struct gmin_cfg_var lenovo_ideapad_miix_310_vars[] = { {} }; +static struct gmin_cfg_var lenovo_yogabook_x91_vars[] = { +/* The vendor driver and sensor modes use two CSI data lanes. */ + {"OVTI2740:00" ,"CsiLanes" ,"2" }, + {} +}; +static struct gmin_cfg_var xiaomi_mipad2_vars[] = {/* _DSM contains the wrong CsiPort for the front facing OV5693 sensor */ {"INT33BE:00" ,"CsiPort" ,"0" },
@@ -83,6 +89,14 @@ static struct gmin_cfg_var xiaomi_mipad2_vars[] = { };static const struct dmi_system_id gmin_cfg_dmi_overrides[] = { + { +/* Lenovo Yoga Book X91L */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Lenovo YB1-X91L" ), + }, + .driver_data = lenovo_yogabook_x91_vars, + }, {/* Lenovo Ideapad Miix 310 */ .matches = {
@@ -359,7 +373,10 @@ static const struct acpi_device_id atomisp_sensor_configs[] = {* the sensor fails to start streaming when instantiating * an i2c-client for the VCM, so it is disabled for now. */ - ATOMISP_SENSOR_CONFIG("INT33BE", 2, false), /* OV5693 */ +/* OV5693 */ + ATOMISP_SENSOR_CONFIG("INT33BE", 2, false), + /* OV8858 */ + ATOMISP_SENSOR_CONFIG("INT3477", 4, true), {} };
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 8/16 media: ov2740: support 288 MHz link frequency
In reply to Maurizio CascianoThe Lenovo Yoga Book YB1-X91 front camera uses two CSI-2 lanes at a 288 MHz link frequency. Add the matching PLL configuration and mode timing.
Reuse the existing 1932x1092 crop and mode register list so the Bayer order remains SGRBG across link frequencies. Cropping the CSI-2 receiver output to a smaller processed frame is a userspace pipeline decision.
--- drivers/media/i2c/ov2740.c | 43 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-)
drivers/media/i2c/ov2740.c +41 -2
@@ -12,12 +12,14 @@#include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/unaligned.h> +#include <linux/units.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <media/v4l2-fwnode.h> -#define OV2740_LINK_FREQ_360MHZ 360000000ULL -#define OV2740_LINK_FREQ_180MHZ 180000000ULL +#define OV2740_LINK_FREQ_360MHZ (360 * HZ_PER_MHZ) +#define OV2740_LINK_FREQ_288MHZ (288 * HZ_PER_MHZ) +#define OV2740_LINK_FREQ_180MHZ (180 * HZ_PER_MHZ)#define OV2740_SCLK 72000000LL#define OV2740_MCLK 19200000#define OV2740_DATA_LANES 2
@@ -91,6 +93,7 @@ struct nvm_data {enum {OV2740_LINK_FREQ_360MHZ_INDEX , +OV2740_LINK_FREQ_288MHZ_INDEX ,OV2740_LINK_FREQ_180MHZ_INDEX , };
@@ -142,6 +145,14 @@ static const struct ov2740_reg mipi_data_rate_720mbps[] = { {0x0312, 0x11}, }; +static const struct ov2740_reg mipi_data_rate_576mbps[] = { + {0x0302 ,0x1e }, + {0x0303 ,0x00 }, + {0x030d ,0x1e }, + {0x030e ,0x02 }, + {0x0312 ,0x01 }, +}; +static const struct ov2740_reg mipi_data_rate_360mbps[] = { {0x0302 ,0x4b }, {0x0303, 0x01},
@@ -468,6 +479,7 @@ static const char * const ov2740_test_pattern_menu[] = {static const s64 link_freq_menu_items[] = {OV2740_LINK_FREQ_360MHZ , +OV2740_LINK_FREQ_288MHZ ,OV2740_LINK_FREQ_180MHZ , };
@@ -478,6 +490,12 @@ static const struct ov2740_link_freq_config link_freq_configs[] = { .regs = mipi_data_rate_720mbps, } }, + [OV2740_LINK_FREQ_288MHZ_INDEX] = { + .reg_list = { + .num_of_regs = ARRAY_SIZE(mipi_data_rate_576mbps), + .regs = mipi_data_rate_576mbps, + } + }, [OV2740_LINK_FREQ_180MHZ_INDEX] = { .reg_list = { .num_of_regs = ARRAY_SIZE(mipi_data_rate_360mbps),
@@ -502,6 +520,22 @@ static const struct ov2740_mode supported_modes_360mhz[] = { }, }; +static const struct ov2740_mode supported_modes_288mhz[] = { + { + .width =1932 , + .height =1092 , + .hts =2160 , + .vts_min =1776 , + .vts_def =1776 , + .vts_max =32767 , + .reg_list = { + .num_of_regs =ARRAY_SIZE (mode_1932x1092_regs_360mhz), + .regs = mode_1932x1092_regs_360mhz, + }, + .link_freq_index =OV2740_LINK_FREQ_288MHZ_INDEX , + }, +}; +static const struct ov2740_mode supported_modes_180mhz[] = { { .width =1932 ,
@@ -1178,6 +1212,11 @@ static int ov2740_check_hwcfg(struct ov2740 *ov2740) ov2740->supported_modes_count =ARRAY_SIZE (supported_modes_360mhz);break ; +case OV2740_LINK_FREQ_288MHZ_INDEX : + ov2740->supported_modes = supported_modes_288mhz; + ov2740->supported_modes_count = +ARRAY_SIZE (supported_modes_288mhz); +break ;case OV2740_LINK_FREQ_180MHZ_INDEX : ov2740->supported_modes = supported_modes_180mhz; ov2740->supported_modes_count =
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 9/16 media: intel: ipu-bridge: allow sensor-specific link frequencies
In reply to Maurizio CascianoA bridge-specific firmware parser may have more accurate link-frequency information than the generic ACPI hardware-ID table. Let it store link frequencies in the per-sensor bridge data and prefer those values when constructing the endpoint software node.
Existing bridges continue to use the hardware-ID table when no sensor-specific frequencies are supplied.
--- drivers/media/pci/intel/ipu-bridge.c | 15 ++++++++++----- include/media/ipu-bridge.h | 3 +++ 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/media/pci/intel/ipu-bridge.c +10 -5
@@ -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); sensor->ipu_properties[0] = PROPERTY_ENTRY_U32_ARRAY_LEN( sensor->prop_names.data_lanes,
include/media/ipu-bridge.h +3 -0
@@ -133,6 +133,9 @@ struct ipu_sensor {struct software_node swnodes[SWNODE_COUNT ];struct ipu_node_names node_names; +u64 link_freqs[MAX_NUM_LINK_FREQS ]; +u8 nr_link_freqs; +u8 link;u8 lanes;u32 mclkspeed;
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 10/16 media: atomisp: derive CSI-2 timing from sensor link frequency
In reply to Maurizio CascianoThe ISP2401 CSI-2 receiver timing depends on the sensor link frequency. Query it through v4l2_get_link_freq() instead of reading a 32-bit control value directly.
Keep the frequency as s64 throughout the calculation so valid link frequencies do not require an arbitrary S32_MAX limit. Fall back to the existing default timings when the frequency query fails.
--- .../staging/media/atomisp/pci/atomisp_csi2.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_csi2.c +13 -7
@@ -5,6 +5,7 @@* Copyright (c) 2010 Intel Corporation. All Rights Reserved. */ +#include <media/v4l2-common.h> #include <media/v4l2-event.h> #include <media/v4l2-mediabus.h> #include "atomisp_cmd.h"
@@ -209,7 +210,7 @@ int atomisp_mipi_csi2_register_entities(struct atomisp_mipi_csi2_device *csi2,static const int LIMIT_SHIFT =6 ;/* Limit numeric range into 31 bits */ static int -atomisp_csi2_configure_calc (const short int coeffs[2 ],int mipi_freq,int def) +atomisp_csi2_configure_calc (const short int coeffs[2 ],s64 mipi_freq,int def) {/* Delay counter accuracy, 1/0.0625 for ANN/CHT, 1/0.125 for BXT */ static const int accinv =16 ;/* 1 / COUNT_ACC */
@@ -288,18 +289,18 @@ static void atomisp_csi2_configure_isp2401(struct atomisp_sub_device *asd)int dat_termen;int dat_settle; -struct v4l2_control ctrl;struct atomisp_device *isp = asd->isp; -int mipi_freq =0 ;enum atomisp_camera_port port; +struct v4l2_subdev *sensor; +s64 mipi_freq;int n; port = isp->inputs[asd->input_curr].port; - ctrl.id =V4L2_CID_LINK_FREQ ; -if (v4l2_g_ctrl - (isp->inputs[asd->input_curr].sensor->ctrl_handler, &ctrl) ==0 ) - mipi_freq = ctrl.value; + sensor = isp->inputs[asd->input_curr].sensor; + mipi_freq =v4l2_get_link_freq (&sensor->entity.pads[0 ],0 ,0 ); +if (mipi_freq <0 ) + mipi_freq =0 ; clk_termen =atomisp_csi2_configure_calc (coeff_clk_termen, mipi_freq,TERMEN_DEFAULT );
@@ -310,6 +311,11 @@ static void atomisp_csi2_configure_isp2401(struct atomisp_sub_device *asd) dat_settle =atomisp_csi2_configure_calc (coeff_dat_settle, mipi_freq,SETTLE_DEFAULT ); +dev_dbg (isp->dev, +"CSI port %u link frequency %lld Hz, clk timing %d/%d, data timing %d/%d\n" , + port, mipi_freq, clk_termen, clk_settle, + dat_termen, dat_settle); +for (n =0 ; n < csi2_port_lanes[port] +1 ; n++) {hrt_address base = csi2_port_base[port] + csi2_lane_base[n];
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 11/16 media: atomisp: provide Yoga Book OV2740 link frequency
In reply to Maurizio CascianoThe Lenovo Yoga Book YB1-X91 firmware does not describe the front OV2740 link frequency. Extend the AtomISP sensor configuration with an optional frequency and assign the 288 MHz Yoga Book value while adding its ACPI ID.
Pass the value through the IPU bridge per-sensor endpoint data so the OV2740 driver selects its matching mode and the AtomISP CSI-2 receiver derives the correct D-PHY timing.
--- .../media/atomisp/pci/atomisp_csi2_bridge.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c +12 -3
@@ -15,6 +15,7 @@#include <linux/dmi.h> #include <linux/platform_data/x86/int3472.h> #include <linux/property.h> +#include <linux/units.h> #include <media/ipu-bridge.h> #include <media/v4l2-fwnode.h>
@@ -43,14 +44,16 @@ static const guid_t vcm_dsm_guid = 0x9f, 0x48, 0xa9, 0xc3, 0xb5, 0xda, 0x78, 0x9f);struct atomisp_sensor_config { +u64 link_freq;int lanes;bool vcm; }; -#define ATOMISP_SENSOR_CONFIG (_HID, _LANES, _VCM) \ +#define ATOMISP_SENSOR_CONFIG (_HID, _LANES, _VCM, _LINK_FREQ) \ { \ .id = _HID, \ .driver_data = (long)&((const struct atomisp_sensor_config) { \ + .link_freq = _LINK_FREQ, \ .lanes = _LANES, \ .vcm = _VCM, \ }) \
@@ -374,9 +377,11 @@ static const struct acpi_device_id atomisp_sensor_configs[] = {* an i2c-client for the VCM, so it is disabled for now. */ /* OV5693 */ - ATOMISP_SENSOR_CONFIG("INT33BE", 2, false), +ATOMISP_SENSOR_CONFIG ("INT33BE" ,2 , false,0 ),/* OV8858 */ - ATOMISP_SENSOR_CONFIG("INT3477", 4, true), +ATOMISP_SENSOR_CONFIG ("INT3477" ,4 , true,0 ), +/* OV2740 */ + ATOMISP_SENSOR_CONFIG("OVTI2740", 2, false, 288 * HZ_PER_MHZ), {} };
@@ -395,6 +400,10 @@ static int atomisp_csi2_parse_sensor_fwnode(struct acpi_device *adev, lanes = cfg->lanes; vcm = cfg->vcm; +if (cfg->link_freq) { + sensor->link_freqs[0 ] = cfg->link_freq; + sensor->nr_link_freqs =1 ; + } }/*
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 12/16 media: ov2740: release group hold after gain write errors
In reply to Maurizio CascianoDigital-gain updates start a register group before writing the red, green and blue gains. The current error paths return immediately when one of those writes fails, leaving the group open and never issuing its end and launch commands. Later control updates can then be accumulated in an unfinished group instead of taking effect.
Once group hold has started, always attempt both commands needed to end and launch the group. Preserve the first gain-write error; report an end or launch error only when all gain writes succeeded.
--- drivers/media/i2c/ov2740.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/media/i2c/ov2740.c +9 -12
@@ -696,7 +696,7 @@ static int ov2740_identify_module(struct ov2740 *ov2740)static int ov2740_update_digital_gain (struct ov2740 *ov2740,u32 d_gain) { -int ret; +int end_ret, launch_ret, ret; ret =ov2740_write_reg (ov2740,OV2740_REG_GROUP_ACCESS ,1 ,OV2740_GROUP_HOLD_START );
@@ -705,24 +705,21 @@ static int ov2740_update_digital_gain(struct ov2740 *ov2740, u32 d_gain) ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_R_GAIN ,2 , d_gain);if (ret) -return ret; + goto release_group; ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_G_GAIN ,2 , d_gain);if (ret) -return ret; + goto release_group; ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_B_GAIN ,2 , d_gain); -if (ret) -return ret; - ret =ov2740_write_reg (ov2740,OV2740_REG_GROUP_ACCESS ,1 , -OV2740_GROUP_HOLD_END ); -if (ret) -return ret; +release_group: + end_ret =ov2740_write_reg (ov2740,OV2740_REG_GROUP_ACCESS ,1 , +OV2740_GROUP_HOLD_END ); + launch_ret =ov2740_write_reg (ov2740,OV2740_REG_GROUP_ACCESS ,1 , +OV2740_GROUP_HOLD_LAUNCH ); - ret =ov2740_write_reg (ov2740,OV2740_REG_GROUP_ACCESS ,1 , -OV2740_GROUP_HOLD_LAUNCH ); -return ret; +return ret ?: end_ret ?: launch_ret; }static int ov2740_test_pattern (struct ov2740 *ov2740,u32 pattern)
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 13/16 media: ov2740: add manual white balance controls
In reply to Maurizio CascianoThe sensor has separate red, green and blue manual white-balance gain registers, but the driver currently writes the same digital-gain value to all three channels. This prevents userspace from correcting the strong color cast of raw Bayer capture.
Expose red- and blue-balance controls relative to the digital gain and update all three channels under group hold.
Tested on the Yoga Book OV2740 with live gain changes and continuous raw capture.
--- drivers/media/i2c/ov2740.c | 44 +++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-)
drivers/media/i2c/ov2740.c +36 -8
@@ -565,6 +565,9 @@ struct ov2740 {struct v4l2_ctrl *vblank;struct v4l2_ctrl *hblank;struct v4l2_ctrl *exposure; +struct v4l2_ctrl *digital_gain; +struct v4l2_ctrl *red_balance; +struct v4l2_ctrl *blue_balance;/* GPIOs, clocks, regulators */ struct gpio_desc *reset_gpio;
@@ -694,8 +697,10 @@ static int ov2740_identify_module(struct ov2740 *ov2740)return 0 ; } -static int ov2740_update_digital_gain (struct ov2740 *ov2740,u32 d_gain) +static int ov2740_update_mwb_gains (struct ov2740 *ov2740) { +u32 d_gain = ov2740->digital_gain->val; +u32 blue_gain, red_gain;int end_ret, launch_ret, ret; ret = ov2740_write_reg(ov2740, OV2740_REG_GROUP_ACCESS, 1,
@@ -703,7 +708,11 @@ static int ov2740_update_digital_gain(struct ov2740 *ov2740, u32 d_gain)if (ret)return ret; - ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_R_GAIN ,2 , d_gain); +/* Balance controls use 1024 as unity relative to the digital gain. */ + red_gain =DIV_ROUND_CLOSEST (d_gain * ov2740->red_balance->val, +OV2740_DGTL_GAIN_DEFAULT ); + red_gain =min (red_gain,OV2740_DGTL_GAIN_MAX ); + ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_R_GAIN ,2 , red_gain);if (ret) goto release_group;
@@ -711,7 +720,10 @@ static int ov2740_update_digital_gain(struct ov2740 *ov2740, u32 d_gain)if (ret) goto release_group; - ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_B_GAIN ,2 , d_gain); + blue_gain =DIV_ROUND_CLOSEST (d_gain * ov2740->blue_balance->val, +OV2740_DGTL_GAIN_DEFAULT ); + blue_gain =min (blue_gain,OV2740_DGTL_GAIN_MAX ); + ret =ov2740_write_reg (ov2740,OV2740_REG_MWB_B_GAIN ,2 , blue_gain); release_group: end_ret = ov2740_write_reg(ov2740, OV2740_REG_GROUP_ACCESS, 1,
@@ -760,7 +772,9 @@ static int ov2740_set_ctrl(struct v4l2_ctrl *ctrl)break ;case V4L2_CID_DIGITAL_GAIN : - ret =ov2740_update_digital_gain (ov2740, ctrl->val); +case V4L2_CID_RED_BALANCE : +case V4L2_CID_BLUE_BALANCE : + ret =ov2740_update_mwb_gains (ov2740);break ;case V4L2_CID_EXPOSURE :
@@ -801,7 +815,7 @@ static int ov2740_init_controls(struct ov2740 *ov2740)int ret; ctrl_hdlr = &ov2740->ctrl_handler; - ret =v4l2_ctrl_handler_init (ctrl_hdlr,10 ); + ret =v4l2_ctrl_handler_init (ctrl_hdlr,12 );if (ret)return ret;
@@ -836,9 +850,23 @@ static int ov2740_init_controls(struct ov2740 *ov2740)v4l2_ctrl_new_std (ctrl_hdlr, &ov2740_ctrl_ops,V4L2_CID_ANALOGUE_GAIN ,OV2740_ANAL_GAIN_MIN ,OV2740_ANAL_GAIN_MAX ,OV2740_ANAL_GAIN_STEP ,OV2740_ANAL_GAIN_MIN ); -v4l2_ctrl_new_std (ctrl_hdlr, &ov2740_ctrl_ops,V4L2_CID_DIGITAL_GAIN , -OV2740_DGTL_GAIN_MIN ,OV2740_DGTL_GAIN_MAX , -OV2740_DGTL_GAIN_STEP ,OV2740_DGTL_GAIN_DEFAULT ); + ov2740->digital_gain = +v4l2_ctrl_new_std (ctrl_hdlr, &ov2740_ctrl_ops, +V4L2_CID_DIGITAL_GAIN , +OV2740_DGTL_GAIN_MIN ,OV2740_DGTL_GAIN_MAX , +OV2740_DGTL_GAIN_STEP , +OV2740_DGTL_GAIN_DEFAULT ); + ov2740->red_balance = +v4l2_ctrl_new_std (ctrl_hdlr, &ov2740_ctrl_ops, +V4L2_CID_RED_BALANCE , +1 ,OV2740_DGTL_GAIN_MAX ,1 , +OV2740_DGTL_GAIN_DEFAULT ); + ov2740->blue_balance = +v4l2_ctrl_new_std (ctrl_hdlr, &ov2740_ctrl_ops, +V4L2_CID_BLUE_BALANCE , +1 ,OV2740_DGTL_GAIN_MAX ,1 , +OV2740_DGTL_GAIN_DEFAULT ); +v4l2_ctrl_cluster (3 , &ov2740->digital_gain); exposure_max = ov2740->cur_mode->vts_def -OV2740_EXPOSURE_MAX_MARGIN ; ov2740->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops, V4L2_CID_EXPOSURE,
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 14/16 media: atomisp: Use struct v4l2_area for padding
In reply to Maurizio CascianoThe padding helper passes width and height as four separate scalar arguments even though they form two logical dimensions.
Pass the requested size and returned padding as struct v4l2_area values. This makes the dimensions explicit and simplifies all three callers.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 68 +++++++++++-------- .../staging/media/atomisp/pci/atomisp_cmd.h | 6 +- .../staging/media/atomisp/pci/atomisp_ioctl.c | 15 ++-- .../media/atomisp/pci/atomisp_subdev.c | 4 +- .../media/atomisp/pci/atomisp_subdev.h | 3 +- 5 files changed, 53 insertions(+), 43 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +39 -29
@@ -3562,9 +3562,9 @@ static void atomisp_fill_pix_format(struct v4l2_pix_format *f, f->xfer_func =V4L2_XFER_FUNC_709 ; } -/* Get sensor padding values for the non padded width x height resolution */ -void atomisp_get_padding (struct atomisp_device *isp,u32 width,u32 height, -u32 *padding_w,u32 *padding_h) +/* Get sensor padding values for the non-padded size */ +void atomisp_get_padding (struct atomisp_device *isp,struct v4l2_area size, +struct v4l2_area *pad) {struct atomisp_input_subdev *input = &isp->inputs[isp->asd.input_curr];struct v4l2_rect native_rect = input->native_rect;
@@ -3574,22 +3574,23 @@ void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height,struct v4l2_mbus_framefmt *sink;if (!input->crop_support) { - *padding_w = pad_w; - *padding_h = pad_h; + pad->width = pad_w; + pad->height = pad_h;return ; } - width =min (width, input->active_rect.width); - height =min (height, input->active_rect.height); + size.width =min (size.width, input->active_rect.width); + size.height =min (size.height, input->active_rect.height); -if (input->binning_support && width <= (input->active_rect.width /2 ) && - height <= (input->active_rect.height /2 )) { +if (input->binning_support && + size.width <= (input->active_rect.width /2 ) && + size.height <= (input->active_rect.height /2 )) { native_rect.width /=2 ; native_rect.height /=2 ; } - *padding_w =min_t (u32, (native_rect.width - width) & ~1 , pad_w); - *padding_h =min_t (u32, (native_rect.height - height) & ~1 , pad_h); + pad->width =min_t (u32, (native_rect.width - size.width) & ~1 , pad_w); + pad->height =min_t (u32, (native_rect.height - size.height) & ~1 , pad_h);/* The below minimum padding requirements are for BYT / ISP2400 only */ if (IS_ISP2401 )
@@ -3617,8 +3618,18 @@ void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height, min_pad_h +=2 ; apply_min_padding: - *padding_w =max_t (u32, *padding_w, min_pad_w); - *padding_h =max_t (u32, *padding_h, min_pad_h); + pad->width =max_t (u32, pad->width, min_pad_w); + pad->height =max_t (u32, pad->height, min_pad_h); +} + +static inline void +atomisp_get_pix_padding (struct atomisp_device *isp, +struct v4l2_pix_format *f, +struct v4l2_area *pad) +{ +struct v4l2_area size = { .width = f->width, .height = f->height }; + +atomisp_get_padding (isp, size, pad); }int atomisp_s_sensor_power (struct atomisp_device *isp,unsigned int input,bool on)
@@ -3800,7 +3811,7 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,const struct atomisp_format_bridge *fmt, *snr_fmt;struct atomisp_sub_device *asd = &isp->asd;struct v4l2_mbus_framefmt ffmt = { }; -u32 padding_w, padding_h; +struct v4l2_area padding;int ret; fmt =atomisp_get_format_bridge (f->pixelformat);
@@ -3827,10 +3838,10 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,* resolution + padding. Add padding here and remove it again after * the set_fmt call, like atomisp_set_fmt_to_snr() does. */ -atomisp_get_padding (isp, f->width, f->height, &padding_w, &padding_h); +atomisp_get_pix_padding (isp, f, &padding);v4l2_fill_mbus_format (&ffmt, f, fmt->mbus_code); - ffmt.width += padding_w; - ffmt.height += padding_h; + ffmt.width += padding.width; + ffmt.height += padding.height;dev_dbg (isp->dev,"try_mbus_fmt: try %ux%u\n" , ffmt.width, ffmt.height);
@@ -3847,8 +3858,8 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,return -EINVAL ; } - f->width = ffmt.width - padding_w; - f->height = ffmt.height - padding_h; + f->width = ffmt.width - padding.width; + f->height = ffmt.height - padding.height;/* * If the format is jpeg or custom RAW, then the width and height will
@@ -4268,11 +4279,12 @@ static int atomisp_set_fmt_to_snr(struct video_device *vdev, const struct v4l2_preturn -EINVAL ;v4l2_fill_mbus_format (&ffmt, f, format->mbus_code); - ffmt.height += asd->sink_pad_padding_h + dvs_env_h; - ffmt.width += asd->sink_pad_padding_w + dvs_env_w; + ffmt.height += asd->sink_pad_padding.height + dvs_env_h; + ffmt.width += asd->sink_pad_padding.width + dvs_env_w;dev_dbg (isp->dev,"s_mbus_fmt: ask %ux%u (padding %ux%u, dvs %ux%u)\n" , - ffmt.width, ffmt.height, asd->sink_pad_padding_w, asd->sink_pad_padding_h, + ffmt.width, ffmt.height, asd->sink_pad_padding.width, + asd->sink_pad_padding.height, dvs_env_w, dvs_env_h);__atomisp_init_stream_info (ATOMISP_INPUT_STREAM_GENERAL , stream_info);
@@ -4365,13 +4377,11 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)V4L2_SUBDEV_FORMAT_ACTIVE , ATOMISP_SUBDEV_PAD_SOURCE, &isp_source_fmt); -if (atomisp_subdev_format_conversion (asd)) { -atomisp_get_padding (isp, f->fmt.pix.width, f->fmt.pix.height, - &asd->sink_pad_padding_w, &asd->sink_pad_padding_h); - }else { - asd->sink_pad_padding_w =0 ; - asd->sink_pad_padding_h =0 ; - } +if (atomisp_subdev_format_conversion (asd)) +atomisp_get_pix_padding (isp, &f->fmt.pix, + &asd->sink_pad_padding); +else + asd->sink_pad_padding = (struct v4l2_area ) { };atomisp_get_dis_envelop (asd, f->fmt.pix.width, f->fmt.pix.height, &dvs_env_w, &dvs_env_h);
drivers/staging/media/atomisp/pci/atomisp_cmd.h +3 -3
@@ -225,9 +225,9 @@ int atomisp_makeup_css_parameters(struct atomisp_sub_device *asd,int atomisp_compare_grid (struct atomisp_sub_device *asd,struct atomisp_grid_info *atomgrid); -/* Get sensor padding values for the non padded width x height resolution */ -void atomisp_get_padding (struct atomisp_device *isp,u32 width,u32 height, -u32 *padding_w,u32 *padding_h); +/* Get sensor padding values for the non-padded size */ +void atomisp_get_padding (struct atomisp_device *isp,struct v4l2_area size, +struct v4l2_area *pad);/* Set sensor power (no-op if already on/off) */ int atomisp_s_sensor_power (struct atomisp_device *isp,unsigned int input,bool on);
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +8 -7
@@ -457,7 +457,7 @@ static int atomisp_enum_framesizes_crop_inner(struct atomisp_device *isp, const struct v4l2_rect *native, int *valid_sizes) { -static const struct v4l2_frmsize_discrete frame_sizes[] = { +static const struct v4l2_area frame_sizes[] = { {1920 ,1440 }, {1920 ,1200 }, {1920 ,1080 },
@@ -470,15 +470,15 @@ static int atomisp_enum_framesizes_crop_inner(struct atomisp_device *isp, { 800, 600 }, { 640, 480 }, }; -u32 padding_w, padding_h;int i;for (i =0 ; i <ARRAY_SIZE (frame_sizes); i++) { -atomisp_get_padding (isp, frame_sizes[i].width, frame_sizes[i].height, - &padding_w, &padding_h); +struct v4l2_area padding; -if ((frame_sizes[i].width + padding_w) > native->width || - (frame_sizes[i].height + padding_h) > native->height) +atomisp_get_padding (isp, frame_sizes[i], &padding); + +if ((frame_sizes[i].width + padding.width) > native->width || + (frame_sizes[i].height + padding.height) > native->height)continue ;/*
@@ -491,7 +491,8 @@ static int atomisp_enum_framesizes_crop_inner(struct atomisp_device *isp,if (*valid_sizes == fsize->index) { fsize->type =V4L2_FRMSIZE_TYPE_DISCRETE ; - fsize->discrete = frame_sizes[i]; + fsize->discrete.width = frame_sizes[i].width; + fsize->discrete.height = frame_sizes[i].height;return 0 ; }
drivers/staging/media/atomisp/pci/atomisp_subdev.c +2 -2
@@ -326,8 +326,8 @@ int atomisp_subdev_set_selection(struct v4l2_subdev *sd,if (atomisp_subdev_format_conversion (isp_sd) && crop[pad]->width && crop[pad]->height) { - crop[pad]->width -= isp_sd->sink_pad_padding_w; - crop[pad]->height -= isp_sd->sink_pad_padding_h; + crop[pad]->width -= isp_sd->sink_pad_padding.width; + crop[pad]->height -= isp_sd->sink_pad_padding.height; } if (isp_sd->params.video_dis_en &&
drivers/staging/media/atomisp/pci/atomisp_subdev.h +1 -2
@@ -214,8 +214,7 @@ struct atomisp_sub_device {struct media_pad pads[ATOMISP_SUBDEV_PADS_NUM ];struct atomisp_pad_format fmt[ATOMISP_SUBDEV_PADS_NUM ];/* Padding for currently set sink-pad fmt */ -u32 sink_pad_padding_w; -u32 sink_pad_padding_h; +struct v4l2_area sink_pad_padding;unsigned int output;struct atomisp_video_pipe video_out;
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 15/16 media: atomisp: allow raw Bayer capture
In reply to Maurizio CascianoAtomISP currently rejects all raw formats and silently substitutes YUV420. This prevents userspace camera processing stacks from obtaining unprocessed sensor frames.
Enumerate only the raw format matching the sensor media-bus code and reconcile raw requests with the code selected by the sensor. Userspace opts in by selecting that raw V4L2 pixel format with VIDIOC_S_FMT.
Raw formats expose the full sensor transport frame so ISP2401 can use its copy pipeline. Processed formats retain the existing global padding behavior; selecting a smaller receiver crop remains a userspace pipeline decision.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 14 +++++++++++--- .../staging/media/atomisp/pci/atomisp_ioctl.c | 19 ++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +11 -3
@@ -3815,8 +3815,7 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,int ret; fmt =atomisp_get_format_bridge (f->pixelformat); -/* Currently, raw formats are broken!!! */ -if (!fmt || fmt->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW ) { +if (!fmt) { f->pixelformat =V4L2_PIX_FMT_YUV420 ; fmt =atomisp_get_format_bridge (f->pixelformat);
@@ -3838,7 +3837,10 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,* resolution + padding. Add padding here and remove it again after * the set_fmt call, like atomisp_set_fmt_to_snr() does. */ -atomisp_get_pix_padding (isp, f, &padding); +if (fmt->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW ) + padding = (struct v4l2_area ) { }; +else +atomisp_get_pix_padding (isp, f, &padding);v4l2_fill_mbus_format (&ffmt, f, fmt->mbus_code); ffmt.width += padding.width; ffmt.height += padding.height;
@@ -3858,6 +3860,12 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,return -EINVAL ; } +if (fmt->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW && + fmt->mbus_code != snr_fmt->mbus_code) { + fmt = snr_fmt; + f->pixelformat = fmt->pixelformat; + } + f->width = ffmt.width - padding.width; f->height = ffmt.height - padding.height;
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +16 -3
@@ -537,12 +537,21 @@ static int atomisp_enum_framesizes(struct file *file, void *priv, .which = V4L2_SUBDEV_FORMAT_ACTIVE, .code = input->code, }; +const struct atomisp_format_bridge *format;struct v4l2_subdev_state *act_sd_state; +struct v4l2_area padding = { + .width = pad_w, + .height = pad_h, + };int ret;if (!input->sensor)return -EINVAL ; + format =atomisp_get_format_bridge (fsize->pixel_format); +if (!format) +return -EINVAL ; +if (input->crop_support)return atomisp_enum_framesizes_crop (isp, fsize);
@@ -554,9 +563,12 @@ static int atomisp_enum_framesizes(struct file *file, void *priv,if (ret)return ret; +if (format->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW ) + padding = (struct v4l2_area ) { }; + fsize->type =V4L2_FRMSIZE_TYPE_DISCRETE ; - fsize->discrete.width = fse.max_width - pad_w; - fsize->discrete.height = fse.max_height - pad_h; + fsize->discrete.width = fse.max_width - padding.width; + fsize->discrete.height = fse.max_height - padding.height;return 0 ; }
@@ -630,7 +642,8 @@ static int atomisp_enum_fmt_cap(struct file *file, void *fh,* * FIXME: fix the pipeline to allow sensor format too. */ -if (format->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW ) +if (format->sh_fmt ==IA_CSS_FRAME_FORMAT_RAW && + format->mbus_code != code.code)continue ;/* Found a match. Now let's pick f->index'th one. */
Signature · 2 lines
With Best Regards, Maurizio Casciano
PATCH v5 16/16 media: i2c: Add WV517S lens actuator driver
In reply to Maurizio CascianoThe Lenovo Yoga Book YB1-X91 rear camera contains a WV517S voice-coil actuator. Add a V4L2 lens subdevice exposing the standard 10-bit FOCUS_ABSOLUTE control and the device ringing-control mode.
Use regmap for register access and tie control updates to runtime PM so the IPU bridge sensor link keeps shared power resources active. Propagate PM acquisition failures and restore the drive mode and controls after resume.
The register addresses and drive-mode value are derived from Intel's GPL-2.0 WV517 driver. Retain the Intel copyright notice and document the 2026 copyright for this V4L2/regmap implementation.
--- MAINTAINERS | 1 + drivers/media/i2c/Kconfig | 11 ++ drivers/media/i2c/Makefile | 1 + drivers/media/i2c/wv517s.c | 206 +++++++++++++++++++++++++++++++++++++ 4 files changed, 219 insertions(+) create mode 100644 drivers/media/i2c/wv517s.c
MAINTAINERS +1 -0
@@ -28555,6 +28555,7 @@ S: Maintained F: drivers/media/i2c/ak* F: drivers/media/i2c/dw* F: drivers/media/i2c/lm* +F: drivers/media/i2c/wv517s.c V4L2 CAMERA SENSOR DRIVERS M: Sakari Ailus <[email protected]>
drivers/media/i2c/Kconfig +11 -0
@@ -949,6 +949,17 @@ config VIDEO_DW9807_VCM capability. This is designed for linear control of voice coil motors, controlled via I2C serial interface. +config VIDEO_WV517S + tristate "WV517S lens voice coil support" + select REGMAP_I2C + help + This is a driver for the WV517S camera lens voice coil. The driver + supports 10-bit focus control and exposes the actuator through the + standard V4L2 lens sub-device interface. + + To compile this driver as a module, choose M here: the module will be + called wv517s. + endif menu "Flash devices"
drivers/media/i2c/Makefile +1 -0
@@ -173,4 +173,5 @@ obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o obj-$(CONFIG_VIDEO_WM8739) += wm8739.o obj-$(CONFIG_VIDEO_WM8775) += wm8775.o +obj-$(CONFIG_VIDEO_WV517S) += wv517s.o obj-$(CONFIG_VIDEO_INTEL_CVS) += cvs/
drivers/media/i2c/wv517s.c new file +206 -0
206 lines not on this page · raw message
Signature · 2 lines
With Best Regards, Maurizio Casciano
Re: [PATCH v5 04/16] media: ov2740: Add OVTI2740 ACPI ID
In reply to Maurizio CascianoQuoted 2 lines · Maurizio Casciano
Firmware may enumerate OV2740 image sensors using the OVTI2740 ACPI ID. Add it to the existing ACPI match table.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 02/16] media: ov8858: support 19.2 MHz clock and CHT gain setup
In reply to Maurizio CascianoQuoted 19 lines · Maurizio Casciano
The Yoga Book drives its OV8858 from a 19.2 MHz platform clock, while the existing mode tables program the sensor PLL for 24 MHz. Reusing those settings produces incorrect internal and CSI-2 clocks.
Accept both input rates and use the actual rate for the reset delay. For 19.2 MHz, apply the Cherry Trail MRD PLL and black-level settings after the generic mode table.
The 19.2 MHz platform uses the per-channel manual white-balance registers for digital gain. Program registers
0x5032,0x5034and0x5036and expose their 1x-to-4x range, while retaining the existing long-exposure gain block for 24 MHz systems.The manual white-balance register definitions and programming follow the GPL-2.0 Intel OV5670 driver, so retain its 2017 Intel copyright notice in this file. No proprietary source or tuning binary is included.
Tested on the Lenovo Yoga Book YB1-X91L OV8858 with full-range test bars and real 10-bit Bayer frames.
...
drivers/media/i2c/ov8858.c line 34
Quoted 5 lines
drivers/media/i2c/ov8858.c +3
-2-#define OV8858_LINK_FREQ 360000000U -#define OV8858_XVCLK_FREQ 24000000 +#define OV8858_LINK_FREQ (360 * HZ_PER_MHZ) +#define OV8858_XVCLK_FREQ (24 * HZ_PER_MHZ) +#define OV8858_XVCLK_FREQ_19_2MHZ (192 * HZ_PER_MHZ / 10)
No. I told you already few times this...
In the given context of the change I expect to see either all in plain numbers
#define OV8858_LINK_FREQ 360000000U
#define OV8858_XVCLK_FREQ_24MHz 24000000
#define OV8858_XVCLK_FREQ_19_2MHz 19200000
or only first one converted
#define OV8858_LINK_FREQ (360 * HZ_PER_MHZ)
#define OV8858_XVCLK_FREQ_24MHz 24000000
#define OV8858_XVCLK_FREQ_19_2MHz 19200000
And better to name XVCLK definitions less ambiguous.
(Also read this https://gruhn.me/blog/2026-08-03/)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 09/16] media: intel: ipu-bridge: allow sensor-specific link frequencies
In reply to Maurizio CascianoQuoted 7 lines · Maurizio Casciano
A bridge-specific firmware parser may have more accurate link-frequency information than the generic ACPI hardware-ID table. Let it store link frequencies in the per-sensor bridge data and prefer those values when constructing the endpoint software node.
Existing bridges continue to use the hardware-ID table when no sensor-specific frequencies are supplied.
with the same caveat: assuming this approach is confirmed to be the right one.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 01/16] media: ov8858: Extract digital gain programming
In reply to Maurizio CascianoQuoted 5 lines · Maurizio Casciano
Move the existing packed digital-gain register programming into a helper so clock-specific gain handling can be added separately.
This is a pure refactoring: preserve both the register packing and the explanatory comment without changing the bytes written to the sensor.
Consider adding a change to fix the comment.
Signature · 2 lines
With Best Regards, Andy Shevchenko