Extensions to ov8865 driver
v2 cover Extensions to ov8865 driver
Hello all
This series extends the ov8865 driver with:
* Support for binding to ACPI enumerated devices.
* Support for a 19.2MHz clock in addition to existing 24MHz clock support
* Another v4l2_subdev_pad_ops callback
* 4 more V4L2 controls
* makes the driver supported by the cio2-bridge
There's also a little bit of tidying that I did along the way.
The series is tested on an MS Surface Go 2.
Thanks
Dan
Series changes since V2:
- Dropped a patch removing unused Macros from the driver.
Daniel Scally (12):
media: i2c: Add ACPI support to ov8865
media: i2c: Fix incorrect value in comment
media: i2c: Defer probe if not endpoint found
media: i2c: Support 19.2MHz input clock in ov8865
media: i2c: Add .get_selection() support to ov8865
media: i2c: Switch control to V4L2_CID_ANALOGUE_GAIN
media: i2c: Add vblank control to ov8865
media: i2c: Add hblank control to ov8865
media: i2c: cap exposure at height + vblank in ov8865
media: i2c: Add controls from fwnode to ov8865
media: i2c: Switch exposure control unit to lines
media: ipu3-cio2: Add INT347A to cio2-bridge
drivers/media/i2c/ov8865.c | 334 +++++++++++++++++---- drivers/media/pci/intel/ipu3/cio2-bridge.c | 2 + 2 files changed, 282 insertions(+), 54 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/12 media: i2c: Add ACPI support to ov8865
The ov8865 sensor is sometimes found on x86 platforms enumerated via ACPI. Add an ACPI match table to the driver so that it's probed on those platforms.
---
Changes in v2:
- Fix the new include to be mod_devicetable.h, not acpi.h (Andy)
drivers/media/i2c/ov8865.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/media/i2c/ov8865.c +8 -0
@@ -9,6 +9,7 @@#include <linux/delay.h> #include <linux/device.h> #include <linux/i2c.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/of_graph.h> #include <linux/pm_runtime.h>
@@ -2946,6 +2947,12 @@ static const struct dev_pm_ops ov8865_pm_ops = {SET_RUNTIME_PM_OPS (ov8865_suspend, ov8865_resume,NULL ) }; +static const struct acpi_device_id ov8865_acpi_match[] = { + {"INT347A" }, + {}, +}; +MODULE_DEVICE_TABLE (acpi, ov8865_acpi_match); +static const struct of_device_id ov8865_of_match[] = { { .compatible ="ovti,ov8865" }, { }
@@ -2956,6 +2963,7 @@ static struct i2c_driver ov8865_driver = { .driver = { .name = "ov8865", .of_match_table = ov8865_of_match, + .acpi_match_table = ov8865_acpi_match, .pm = &ov8865_pm_ops, }, .probe_new = ov8865_probe,
Signature · 1 line
2.25.1
Re: [PATCH v2 01/12] media: i2c: Add ACPI support to ov8865
Quoted 4 lines · Daniel Scally
The ov8865 sensor is sometimes found on x86 platforms enumerated via ACPI. Add an ACPI match table to the driver so that it's probed on those platforms.
...
drivers/media/i2c/ov8865.c static const struct dev_pm_ops ov8865_pm_ops = { · line 2952
Quoted 3 lines
drivers/media/i2c/ov8865.c +3
-0+static const struct acpi_device_id ov8865_acpi_match[] = { + {"INT347A" }, + {},
No comma for terminator entry.
Quoted 1 line
+};
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 2/12 media: i2c: Fix incorrect value in comment
In reply to Daniel ScallyThe PLL configuration defined here sets 72MHz (which is correct), not 80MHz. Correct the comment.
---
Changes in v2:
- None
drivers/media/i2c/ov8865.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov8865.c +1 -1
@@ -713,7 +713,7 @@ static const struct ov8865_pll2_config ov8865_pll2_config_native = {/* * EXTCLK = 24 MHz * DAC_CLK = 360 MHz -* SCLK = 80 MHz +* SCLK = 72 MHz */ static const struct ov8865_pll2_config ov8865_pll2_config_binning = {
Signature · 1 line
2.25.1
PATCH v2 3/12 media: i2c: Defer probe if not endpoint found
In reply to Daniel ScallyThe ov8865 driver is one of those that can be connected to a CIO2 device by the cio2-bridge code. This means that the absence of an endpoint for this device is not necessarily fatal, as one might be built by the cio2-bridge when it probes. Return -EPROBE_DEFER if no endpoint is found rather than a fatal error.
---
Changes in v2:
- None
drivers/media/i2c/ov8865.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/ov8865.c +2 -4
@@ -2796,10 +2796,8 @@ static int ov8865_probe(struct i2c_client *client)/* Graph Endpoint */ handle =fwnode_graph_get_next_endpoint (dev_fwnode (dev),NULL ); -if (!handle) { -dev_err (dev,"unable to find endpoint node\n" ); -return -EINVAL ; - } +if (!handle) +return -EPROBE_DEFER ; sensor->endpoint.bus_type =V4L2_MBUS_CSI2_DPHY ;
Signature · 1 line
2.25.1
PATCH v2 4/12 media: i2c: Support 19.2MHz input clock in ov8865
In reply to Daniel ScallyThe ov8865 driver as written expects a 24MHz input clock, but the sensor is sometimes found on x86 platforms with a 19.2MHz input clock supplied. Add a set of PLL configurations to the driver to support that rate too. As ACPI doesn't auto-configure the clock rate, check for a clock-frequency during probe and set that rate if one is found.
---
Changes in v2:
- Added an enum defining the possible frequency rates to index the array (Andy)
drivers/media/i2c/ov8865.c | 164 +++++++++++++++++++++++++++---------- 1 file changed, 121 insertions(+), 43 deletions(-)
drivers/media/i2c/ov8865.c +121 -43
@@ -21,10 +21,6 @@#include <media/v4l2-image-sizes.h> #include <media/v4l2-mediabus.h> -/* Clock rate */ - -#define OV8865_EXTCLK_RATE 24000000 -/* Register definitions */ /* System */
@@ -567,6 +563,19 @@ struct ov8865_sclk_config {unsigned int sclk_div; }; +/* Clock rate */ + +enum extclk_rate { +OV8865_19_2_MHZ , +OV8865_24_MHZ , +OV8865_NUM_SUPPORTED_RATES , +}; + +static const unsigned long supported_extclk_rates[] = { + [OV8865_19_2_MHZ ] =19200000 , + [OV8865_24_MHZ ] =24000000 , +}; +/* * General formulas for (array-centered) mode calculation: * - photo_array_width = 3296
@@ -665,6 +674,9 @@ struct ov8865_sensor {struct regulator *avdd;struct regulator *dvdd;struct regulator *dovdd; + +unsigned long extclk_rate; +enum extclk_rate extclk_rate_idx;struct clk *extclk;struct v4l2_fwnode_endpoint endpoint;
@@ -680,49 +692,83 @@ struct ov8865_sensor {/* Static definitions */ /* -* EXTCLK = 24 MHz * PHY_SCLK = 720 MHz * MIPI_PCLK = 90 MHz */ -static const struct ov8865_pll1_config ov8865_pll1_config_native = { - .pll_pre_div_half =1 , - .pll_pre_div =0 , - .pll_mul =30 , - .m_div =1 , - .mipi_div =3 , - .pclk_div =1 , - .sys_pre_div =1 , - .sys_div =2 , + +static const struct ov8865_pll1_config ov8865_pll1_configs_native[] = { + {/* 19.2 MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =2 , + .pll_mul =75 , + .m_div =1 , + .mipi_div =3 , + .pclk_div =1 , + .sys_pre_div =1 , + .sys_div =2 , + }, + {/* 24MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =0 , + .pll_mul =30 , + .m_div =1 , + .mipi_div =3 , + .pclk_div =1 , + .sys_pre_div =1 , + .sys_div =2 , + }, };/* -* EXTCLK = 24 MHz * DAC_CLK = 360 MHz * SCLK = 144 MHz */ -static const struct ov8865_pll2_config ov8865_pll2_config_native = { - .pll_pre_div_half =1 , - .pll_pre_div =0 , - .pll_mul =30 , - .dac_div =2 , - .sys_pre_div =5 , - .sys_div =0 , +static const struct ov8865_pll2_config ov8865_pll2_configs_native[] = { +/* 19.2MHz input clock */ + { + .pll_pre_div_half =1 , + .pll_pre_div =5 , + .pll_mul =75 , + .dac_div =1 , + .sys_pre_div =1 , + .sys_div =3 , + }, +/* 24MHz input clock */ + { + .pll_pre_div_half =1 , + .pll_pre_div =0 , + .pll_mul =30 , + .dac_div =2 , + .sys_pre_div =5 , + .sys_div =0 , + } };/* -* EXTCLK = 24 MHz * DAC_CLK = 360 MHz * SCLK = 72 MHz */ -static const struct ov8865_pll2_config ov8865_pll2_config_binning = { +static const struct ov8865_pll2_config ov8865_pll2_configs_binning[] = { +/* 19.2MHz input clock */ + { + .pll_pre_div_half =1 , + .pll_pre_div =2 , + .pll_mul =75 , + .dac_div =2 , + .sys_pre_div =10 , + .sys_div =0 , + }, +/* 24MHz input clock */ + { .pll_pre_div_half =1 , .pll_pre_div =0 , .pll_mul =30 , .dac_div =2 , .sys_pre_div =10 , .sys_div =0 , + } };static const struct ov8865_sclk_config ov8865_sclk_config_native = {
@@ -934,8 +980,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_native, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_native, .sclk_config = &ov8865_sclk_config_native,/* Registers */
@@ -990,8 +1036,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_native, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_native, .sclk_config = &ov8865_sclk_config_native,/* Registers */
@@ -1050,8 +1096,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_binning, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_binning, .sclk_config = &ov8865_sclk_config_native,/* Registers */
@@ -1116,8 +1162,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 90 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_binning, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_binning, .sclk_config = &ov8865_sclk_config_native,/* Registers */
@@ -1513,12 +1559,11 @@ static int ov8865_isp_configure(struct ov8865_sensor *sensor)static unsigned long ov8865_mode_pll1_rate (struct ov8865_sensor *sensor,const struct ov8865_mode *mode) { -const struct ov8865_pll1_config *config = mode->pll1_config; -unsigned long extclk_rate; +const struct ov8865_pll1_config *config;unsigned long pll1_rate; - extclk_rate =clk_get_rate (sensor->extclk); - pll1_rate = extclk_rate * config->pll_mul / config->pll_pre_div_half; + config = &mode->pll1_config[sensor->extclk_rate_idx]; + pll1_rate = sensor->extclk_rate * config->pll_mul / config->pll_pre_div_half;switch (config->pll_pre_div) {case 0 :
@@ -1552,10 +1597,12 @@ static int ov8865_mode_pll1_configure(struct ov8865_sensor *sensor, const struct ov8865_mode *mode, u32 mbus_code) { -const struct ov8865_pll1_config *config = mode->pll1_config; +const struct ov8865_pll1_config *config;u8 value;int ret; + config = &mode->pll1_config[sensor->extclk_rate_idx]; +switch (mbus_code) {case MEDIA_BUS_FMT_SBGGR10_1X10 : value =OV8865_MIPI_BIT_SEL (10 );
@@ -1622,9 +1669,11 @@ static int ov8865_mode_pll1_configure(struct ov8865_sensor *sensor,static int ov8865_mode_pll2_configure (struct ov8865_sensor *sensor,const struct ov8865_mode *mode) { -const struct ov8865_pll2_config *config = mode->pll2_config; +const struct ov8865_pll2_config *config;int ret; + config = &mode->pll2_config[sensor->extclk_rate_idx]; + ret =ov8865_write (sensor,OV8865_PLL_CTRL12_REG ,OV8865_PLL_CTRL12_PRE_DIV_HALF (config->pll_pre_div_half) |OV8865_PLL_CTRL12_DAC_DIV (config->dac_div));
@@ -2053,9 +2102,11 @@ static int ov8865_mode_configure(struct ov8865_sensor *sensor,static unsigned long ov8865_mode_mipi_clk_rate (struct ov8865_sensor *sensor,const struct ov8865_mode *mode) { -const struct ov8865_pll1_config *config = mode->pll1_config; +const struct ov8865_pll1_config *config;unsigned long pll1_rate; + config = &mode->pll1_config[sensor->extclk_rate_idx]; + pll1_rate =ov8865_mode_pll1_rate (sensor, mode);return pll1_rate / config->m_div /2 ;
@@ -2783,7 +2834,8 @@ static int ov8865_probe(struct i2c_client *client)struct ov8865_sensor *sensor;struct v4l2_subdev *subdev;struct media_pad *pad; -unsigned long rate; +unsigned int rate; +unsigned int i;int ret; sensor =devm_kzalloc (dev,sizeof (*sensor),GFP_KERNEL );
@@ -2858,13 +2910,39 @@ static int ov8865_probe(struct i2c_client *client) goto error_endpoint; } - rate =clk_get_rate (sensor->extclk); -if (rate !=OV8865_EXTCLK_RATE ) { -dev_err (dev,"clock rate %lu Hz is unsupported\n" , rate); +/* +* We could have either a 24MHz or 19.2MHz clock rate. Check for a +* clock-frequency property and if found, set that rate. This should +* cover ACPI case. If the system uses devicetree then the configured +* rate should already be set, so we'll have to check it. +*/ + + ret =fwnode_property_read_u32 (dev_fwnode (dev),"clock-frequency" , + &rate); +if (!ret) { + ret =clk_set_rate (sensor->extclk, rate); +if (ret) { +dev_err (dev,"failed to set clock rate\n" ); +return ret; + } + } + + sensor->extclk_rate =clk_get_rate (sensor->extclk); + +for (i =0 ; i <ARRAY_SIZE (supported_extclk_rates); i++) { +if (sensor->extclk_rate == supported_extclk_rates[i]) +break ; + } + +if (i ==ARRAY_SIZE (supported_extclk_rates)) { +dev_err (dev,"clock rate %lu Hz is unsupported\n" , + sensor->extclk_rate); ret = -EINVAL ; goto error_endpoint; } + sensor->extclk_rate_idx = i; +/* Subdev, entity and pad */ subdev = &sensor->subdev;
Signature · 1 line
2.25.1
Re: [PATCH v2 04/12] media: i2c: Support 19.2MHz input clock in ov8865
Quoted 6 lines · Daniel Scally
The ov8865 driver as written expects a 24MHz input clock, but the sensor is sometimes found on x86 platforms with a 19.2MHz input clock supplied. Add a set of PLL configurations to the driver to support that rate too. As ACPI doesn't auto-configure the clock rate, check for a clock-frequency during probe and set that rate if one is found.
...
drivers/media/i2c/ov8865.c struct ov8865_sclk_config { · line 571
Quoted 4 lines
drivers/media/i2c/ov8865.c +4
-0+enum extclk_rate { +OV8865_19_2_MHZ , +OV8865_24_MHZ , +OV8865_NUM_SUPPORTED_RATES ,
Same here, i.e. no comma,
If these are the only problems during review of v2, you can ignore them, they are not critical at all.
Quoted 1 line
+};
...
drivers/media/i2c/ov8865.c struct ov8865_sensor { · line 745
Quoted 11 lines
drivers/media/i2c/ov8865.c +10
-0+static const struct ov8865_pll2_config ov8865_pll2_configs_native[] = { +/* 24MHz input clock */ + { + .pll_pre_div_half =1 , + .pll_pre_div =0 , + .pll_mul =30 , + .dac_div =2 , + .sys_pre_div =5 , + .sys_div =0 , + }
+ comma.
Quoted 1 line
};
...
drivers/media/i2c/ov8865.c struct ov8865_sensor { · line 771
Quoted 9 lines
drivers/media/i2c/ov8865.c +3
-0+/* 24MHz input clock */ + { .pll_pre_div_half = 1, .pll_pre_div = 0, .pll_mul = 30, .dac_div = 2, .sys_pre_div = 10, .sys_div = 0, + }
Ditto.
...
drivers/media/i2c/ov8865.c static int ov8865_probe(struct i2c_client *client) · line 2916
Quoted 4 lines
drivers/media/i2c/ov8865.c +4
-0+/* +* We could have either a 24MHz or 19.2MHz clock rate. Check for a +* clock-frequency property and if found, set that rate. This should +* cover ACPI case. If the system uses devicetree then the configured
the ACPI case
drivers/media/i2c/ov8865.c static int ov8865_probe(struct i2c_client *client) · line 2945
Quoted 4 lines
drivers/media/i2c/ov8865.c +3
-0+* rate should already be set, so we'll have to check it. +*/ +
Redundant blank line.
drivers/media/i2c/ov8865.c static int ov8865_probe(struct i2c_client *client) · line 2922
Quoted 3 lines
drivers/media/i2c/ov8865.c +3
-0+ ret =fwnode_property_read_u32 (dev_fwnode (dev),"clock-frequency" , + &rate); +if (!ret) {
I'm wondering if something like
... rate = 0;
fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", &rate);
if (rate > 0) {can be used.
Quoted 6 lines
drivers/media/i2c/ov8865.c +6
-0+ ret =clk_set_rate (sensor->extclk, rate); +if (ret) { +dev_err (dev,"failed to set clock rate\n" ); +return ret; + } + }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 04/12] media: i2c: Support 19.2MHz input clock in ov8865
Hi Andy
Quoted 11 lines · Andy Shevchenko
drivers/media/i2c/ov8865.c static int ov8865_probe(struct i2c_client *client) · line 2922
Quoted 3 lines
drivers/media/i2c/ov8865.c +3
-0+ ret =fwnode_property_read_u32 (dev_fwnode (dev),"clock-frequency" , + &rate); +if (!ret) {I'm wondering if something like
... rate = 0;
fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", &rate); if (rate > 0) {can be used.
Should be fine, and I agree that it makes the point of the check more clear, thanks.
Sakari Ailus
maintainerRe: [PATCH v2 04/12] media: i2c: Support 19.2MHz input clock in ov8865
In reply to Daniel ScallyHi Daniel,
Thanks for the set.
Quoted 90 lines · Daniel Scally
The ov8865 driver as written expects a 24MHz input clock, but the sensor is sometimes found on x86 platforms with a 19.2MHz input clock supplied. Add a set of PLL configurations to the driver to support that rate too. As ACPI doesn't auto-configure the clock rate, check for a clock-frequency during probe and set that rate if one is found.
Signed-off-by Daniel Scally <[email protected]>---
Changes in v2:- Added an enum defining the possible frequency rates to index the array (Andy)
drivers/media/i2c/ov8865.c | 164 +++++++++++++++++++++++++++---------- 1 file changed, 121 insertions(+), 43 deletions(-)drivers/media/i2c/ov8865.c +28
-14@@ -21,10 +21,6 @@#include <media/v4l2-image-sizes.h> #include <media/v4l2-mediabus.h> -/* Clock rate */ - -#define OV8865_EXTCLK_RATE 24000000 -/* Register definitions */ /* System */ @@ -567,6 +563,19 @@ struct ov8865_sclk_config {unsigned int sclk_div; }; +/* Clock rate */ + +enum extclk_rate { +OV8865_19_2_MHZ , +OV8865_24_MHZ , +OV8865_NUM_SUPPORTED_RATES , +}; + +static const unsigned long supported_extclk_rates[] = { + [OV8865_19_2_MHZ ] =19200000 , + [OV8865_24_MHZ ] =24000000 , +}; +/* * General formulas for (array-centered) mode calculation: * - photo_array_width = 3296 @@ -665,6 +674,9 @@ struct ov8865_sensor {struct regulator *avdd;struct regulator *dvdd;struct regulator *dovdd; + +unsigned long extclk_rate; +enum extclk_rate extclk_rate_idx;struct clk *extclk;struct v4l2_fwnode_endpoint endpoint;@@ -680,49 +692,83 @@ struct ov8865_sensor {/* Static definitions */ /* -* EXTCLK = 24 MHz * PHY_SCLK = 720 MHz * MIPI_PCLK = 90 MHz */ -static const struct ov8865_pll1_config ov8865_pll1_config_native = { - .pll_pre_div_half =1 , - .pll_pre_div =0 , - .pll_mul =30 , - .m_div =1 , - .mipi_div =3 , - .pclk_div =1 , - .sys_pre_div =1 , - .sys_div =2 , + +static const struct ov8865_pll1_config ov8865_pll1_configs_native[] = { + {/* 19.2 MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =2 , + .pll_mul =75 , + .m_div =1 , + .mipi_div =3 , + .pclk_div =1 , + .sys_pre_div =1 , + .sys_div =2 , + },
drivers/media/i2c/ov8865.c struct ov8865_sensor { · line 719
Quoted 10 lines
drivers/media/i2c/ov8865.c +10
-0+ {/* 24MHz input clock */ + .pll_pre_div_half = 1, + .pll_pre_div = 0, + .pll_mul = 30, + .m_div = 1, + .mipi_div = 3, + .pclk_div = 1, + .sys_pre_div = 1, + .sys_div = 2, + },
Could you instead add a struct specific to the clock frequency with pointers to these? See e.g. the ov8856 driver how this could otherwise end up...
Quoted 218 lines
drivers/media/i2c/ov8865.c +83
-29};/* -* EXTCLK = 24 MHz * DAC_CLK = 360 MHz * SCLK = 144 MHz */ -static const struct ov8865_pll2_config ov8865_pll2_config_native = { - .pll_pre_div_half =1 , - .pll_pre_div =0 , - .pll_mul =30 , - .dac_div =2 , - .sys_pre_div =5 , - .sys_div =0 , +static const struct ov8865_pll2_config ov8865_pll2_configs_native[] = { +/* 19.2MHz input clock */ + { + .pll_pre_div_half =1 , + .pll_pre_div =5 , + .pll_mul =75 , + .dac_div =1 , + .sys_pre_div =1 , + .sys_div =3 , + }, +/* 24MHz input clock */ + { + .pll_pre_div_half =1 , + .pll_pre_div =0 , + .pll_mul =30 , + .dac_div =2 , + .sys_pre_div =5 , + .sys_div =0 , + } };/* -* EXTCLK = 24 MHz * DAC_CLK = 360 MHz * SCLK = 72 MHz */ -static const struct ov8865_pll2_config ov8865_pll2_config_binning = { +static const struct ov8865_pll2_config ov8865_pll2_configs_binning[] = { +/* 19.2MHz input clock */ + { + .pll_pre_div_half =1 , + .pll_pre_div =2 , + .pll_mul =75 , + .dac_div =2 , + .sys_pre_div =10 , + .sys_div =0 , + }, +/* 24MHz input clock */ + { .pll_pre_div_half =1 , .pll_pre_div =0 , .pll_mul =30 , .dac_div =2 , .sys_pre_div =10 , .sys_div =0 , + } };static const struct ov8865_sclk_config ov8865_sclk_config_native = {@@ -934,8 +980,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_native, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_native, .sclk_config = &ov8865_sclk_config_native,/* Registers */ @@ -990,8 +1036,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_native, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_native, .sclk_config = &ov8865_sclk_config_native,/* Registers */ @@ -1050,8 +1096,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_binning, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_binning, .sclk_config = &ov8865_sclk_config_native,/* Registers */ @@ -1116,8 +1162,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 90 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_binning, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_binning, .sclk_config = &ov8865_sclk_config_native,/* Registers */ @@ -1513,12 +1559,11 @@ static int ov8865_isp_configure(struct ov8865_sensor *sensor)static unsigned long ov8865_mode_pll1_rate (struct ov8865_sensor *sensor,const struct ov8865_mode *mode) { -const struct ov8865_pll1_config *config = mode->pll1_config; -unsigned long extclk_rate; +const struct ov8865_pll1_config *config;unsigned long pll1_rate; - extclk_rate =clk_get_rate (sensor->extclk); - pll1_rate = extclk_rate * config->pll_mul / config->pll_pre_div_half; + config = &mode->pll1_config[sensor->extclk_rate_idx]; + pll1_rate = sensor->extclk_rate * config->pll_mul / config->pll_pre_div_half;switch (config->pll_pre_div) {case 0 :@@ -1552,10 +1597,12 @@ static int ov8865_mode_pll1_configure(struct ov8865_sensor *sensor, const struct ov8865_mode *mode, u32 mbus_code) { -const struct ov8865_pll1_config *config = mode->pll1_config; +const struct ov8865_pll1_config *config;u8 value;int ret; + config = &mode->pll1_config[sensor->extclk_rate_idx]; +switch (mbus_code) {case MEDIA_BUS_FMT_SBGGR10_1X10 : value =OV8865_MIPI_BIT_SEL (10 );@@ -1622,9 +1669,11 @@ static int ov8865_mode_pll1_configure(struct ov8865_sensor *sensor,static int ov8865_mode_pll2_configure (struct ov8865_sensor *sensor,const struct ov8865_mode *mode) { -const struct ov8865_pll2_config *config = mode->pll2_config; +const struct ov8865_pll2_config *config;int ret; + config = &mode->pll2_config[sensor->extclk_rate_idx]; + ret =ov8865_write (sensor,OV8865_PLL_CTRL12_REG ,OV8865_PLL_CTRL12_PRE_DIV_HALF (config->pll_pre_div_half) |OV8865_PLL_CTRL12_DAC_DIV (config->dac_div));@@ -2053,9 +2102,11 @@ static int ov8865_mode_configure(struct ov8865_sensor *sensor,static unsigned long ov8865_mode_mipi_clk_rate (struct ov8865_sensor *sensor,const struct ov8865_mode *mode) { -const struct ov8865_pll1_config *config = mode->pll1_config; +const struct ov8865_pll1_config *config;unsigned long pll1_rate; + config = &mode->pll1_config[sensor->extclk_rate_idx]; + pll1_rate =ov8865_mode_pll1_rate (sensor, mode);return pll1_rate / config->m_div /2 ;@@ -2783,7 +2834,8 @@ static int ov8865_probe(struct i2c_client *client)struct ov8865_sensor *sensor;struct v4l2_subdev *subdev;struct media_pad *pad; -unsigned long rate; +unsigned int rate; +unsigned int i;int ret; sensor =devm_kzalloc (dev,sizeof (*sensor),GFP_KERNEL );@@ -2858,13 +2910,39 @@ static int ov8865_probe(struct i2c_client *client) goto error_endpoint; } - rate =clk_get_rate (sensor->extclk); -if (rate !=OV8865_EXTCLK_RATE ) { -dev_err (dev,"clock rate %lu Hz is unsupported\n" , rate); +/* +* We could have either a 24MHz or 19.2MHz clock rate. Check for a +* clock-frequency property and if found, set that rate. This should +* cover ACPI case. If the system uses devicetree then the configured +* rate should already be set, so we'll have to check it. +*/ + + ret =fwnode_property_read_u32 (dev_fwnode (dev),"clock-frequency" , + &rate); +if (!ret) { + ret =clk_set_rate (sensor->extclk, rate); +if (ret) { +dev_err (dev,"failed to set clock rate\n" ); +return ret; + } + } + + sensor->extclk_rate =clk_get_rate (sensor->extclk); + +for (i =0 ; i <ARRAY_SIZE (supported_extclk_rates); i++) { +if (sensor->extclk_rate == supported_extclk_rates[i]) +break ; + } + +if (i ==ARRAY_SIZE (supported_extclk_rates)) { +dev_err (dev,"clock rate %lu Hz is unsupported\n" , + sensor->extclk_rate); ret = -EINVAL ; goto error_endpoint; } + sensor->extclk_rate_idx = i; +/* Subdev, entity and pad */ subdev = &sensor->subdev;
Signature · 3 lines
Kind regards, Sakari Ailus
Re: [PATCH v2 04/12] media: i2c: Support 19.2MHz input clock in ov8865
Hi Sakari - thanks for all the comments
Quoted 100 lines · Sakari Ailus
Hi Daniel,
Thanks for the set.
Quoted 95 lines · Daniel Scally
The ov8865 driver as written expects a 24MHz input clock, but the sensor is sometimes found on x86 platforms with a 19.2MHz input clock supplied. Add a set of PLL configurations to the driver to support that rate too. As ACPI doesn't auto-configure the clock rate, check for a clock-frequency during probe and set that rate if one is found.
Signed-off-by Daniel Scally <[email protected]>---
Changes in v2:- Added an enum defining the possible frequency rates to index the array (Andy)
drivers/media/i2c/ov8865.c | 164 +++++++++++++++++++++++++++---------- 1 file changed, 121 insertions(+), 43 deletions(-)drivers/media/i2c/ov8865.c +33
-14@@ -21,10 +21,6 @@#include <media/v4l2-image-sizes.h> #include <media/v4l2-mediabus.h> -/* Clock rate */ - -#define OV8865_EXTCLK_RATE 24000000 -/* Register definitions */ /* System */ @@ -567,6 +563,19 @@ struct ov8865_sclk_config {unsigned int sclk_div; }; +/* Clock rate */ + +enum extclk_rate { +OV8865_19_2_MHZ , +OV8865_24_MHZ , +OV8865_NUM_SUPPORTED_RATES , +}; + +static const unsigned long supported_extclk_rates[] = { + [OV8865_19_2_MHZ ] =19200000 , + [OV8865_24_MHZ ] =24000000 , +}; +/* * General formulas for (array-centered) mode calculation: * - photo_array_width = 3296 @@ -665,6 +674,9 @@ struct ov8865_sensor {struct regulator *avdd;struct regulator *dvdd;struct regulator *dovdd; + +unsigned long extclk_rate; +enum extclk_rate extclk_rate_idx;struct clk *extclk;struct v4l2_fwnode_endpoint endpoint;@@ -680,49 +692,83 @@ struct ov8865_sensor {/* Static definitions */ /* -* EXTCLK = 24 MHz * PHY_SCLK = 720 MHz * MIPI_PCLK = 90 MHz */ -static const struct ov8865_pll1_config ov8865_pll1_config_native = { - .pll_pre_div_half =1 , - .pll_pre_div =0 , - .pll_mul =30 , - .m_div =1 , - .mipi_div =3 , - .pclk_div =1 , - .sys_pre_div =1 , - .sys_div =2 , + +static const struct ov8865_pll1_config ov8865_pll1_configs_native[] = { + {/* 19.2 MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =2 , + .pll_mul =75 , + .m_div =1 , + .mipi_div =3 , + .pclk_div =1 , + .sys_pre_div =1 , + .sys_div =2 , + }, + {/* 24MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =0 , + .pll_mul =30 , + .m_div =1 ,
Quoted 8 lines
drivers/media/i2c/ov8865.c struct ov8865_sensor { · line 709
Quoted 5 lines
drivers/media/i2c/ov8865.c +5
-0+ .mipi_div = 3, + .pclk_div = 1, + .sys_pre_div = 1, + .sys_div = 2, + },Could you instead add a struct specific to the clock frequency with pointers to these? See e.g. the ov8856 driver how this could otherwise end up...
You mean something like
static struct ov8865_pll_configs_19_2_mhz {
.pll1_config_native = &ov8865_pll1_config_native,
...
};
static struct ov8865_pll_configs_24_mhz {
.pll1_config_native = &ov8865_pll1_config_native,
...
};
or am I misunderstanding?
Quoted 219 lines
Quoted 219 lines
drivers/media/i2c/ov8865.c +83
-29};/* -* EXTCLK = 24 MHz * DAC_CLK = 360 MHz * SCLK = 144 MHz */ -static const struct ov8865_pll2_config ov8865_pll2_config_native = { - .pll_pre_div_half =1 , - .pll_pre_div =0 , - .pll_mul =30 , - .dac_div =2 , - .sys_pre_div =5 , - .sys_div =0 , +static const struct ov8865_pll2_config ov8865_pll2_configs_native[] = { +/* 19.2MHz input clock */ + { + .pll_pre_div_half =1 , + .pll_pre_div =5 , + .pll_mul =75 , + .dac_div =1 , + .sys_pre_div =1 , + .sys_div =3 , + }, +/* 24MHz input clock */ + { + .pll_pre_div_half =1 , + .pll_pre_div =0 , + .pll_mul =30 , + .dac_div =2 , + .sys_pre_div =5 , + .sys_div =0 , + } };/* -* EXTCLK = 24 MHz * DAC_CLK = 360 MHz * SCLK = 72 MHz */ -static const struct ov8865_pll2_config ov8865_pll2_config_binning = { +static const struct ov8865_pll2_config ov8865_pll2_configs_binning[] = { +/* 19.2MHz input clock */ + { + .pll_pre_div_half =1 , + .pll_pre_div =2 , + .pll_mul =75 , + .dac_div =2 , + .sys_pre_div =10 , + .sys_div =0 , + }, +/* 24MHz input clock */ + { .pll_pre_div_half =1 , .pll_pre_div =0 , .pll_mul =30 , .dac_div =2 , .sys_pre_div =10 , .sys_div =0 , + } };static const struct ov8865_sclk_config ov8865_sclk_config_native = {@@ -934,8 +980,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_native, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_native, .sclk_config = &ov8865_sclk_config_native,/* Registers */ @@ -990,8 +1036,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_native, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_native, .sclk_config = &ov8865_sclk_config_native,/* Registers */ @@ -1050,8 +1096,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_binning, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_binning, .sclk_config = &ov8865_sclk_config_native,/* Registers */ @@ -1116,8 +1162,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 90 },/* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_binning, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_binning, .sclk_config = &ov8865_sclk_config_native,/* Registers */ @@ -1513,12 +1559,11 @@ static int ov8865_isp_configure(struct ov8865_sensor *sensor)static unsigned long ov8865_mode_pll1_rate (struct ov8865_sensor *sensor,const struct ov8865_mode *mode) { -const struct ov8865_pll1_config *config = mode->pll1_config; -unsigned long extclk_rate; +const struct ov8865_pll1_config *config;unsigned long pll1_rate; - extclk_rate =clk_get_rate (sensor->extclk); - pll1_rate = extclk_rate * config->pll_mul / config->pll_pre_div_half; + config = &mode->pll1_config[sensor->extclk_rate_idx]; + pll1_rate = sensor->extclk_rate * config->pll_mul / config->pll_pre_div_half;switch (config->pll_pre_div) {case 0 :@@ -1552,10 +1597,12 @@ static int ov8865_mode_pll1_configure(struct ov8865_sensor *sensor, const struct ov8865_mode *mode, u32 mbus_code) { -const struct ov8865_pll1_config *config = mode->pll1_config; +const struct ov8865_pll1_config *config;u8 value;int ret; + config = &mode->pll1_config[sensor->extclk_rate_idx]; +switch (mbus_code) {case MEDIA_BUS_FMT_SBGGR10_1X10 : value =OV8865_MIPI_BIT_SEL (10 );@@ -1622,9 +1669,11 @@ static int ov8865_mode_pll1_configure(struct ov8865_sensor *sensor,static int ov8865_mode_pll2_configure (struct ov8865_sensor *sensor,const struct ov8865_mode *mode) { -const struct ov8865_pll2_config *config = mode->pll2_config; +const struct ov8865_pll2_config *config;int ret; + config = &mode->pll2_config[sensor->extclk_rate_idx]; + ret =ov8865_write (sensor,OV8865_PLL_CTRL12_REG ,OV8865_PLL_CTRL12_PRE_DIV_HALF (config->pll_pre_div_half) |OV8865_PLL_CTRL12_DAC_DIV (config->dac_div));@@ -2053,9 +2102,11 @@ static int ov8865_mode_configure(struct ov8865_sensor *sensor,static unsigned long ov8865_mode_mipi_clk_rate (struct ov8865_sensor *sensor,const struct ov8865_mode *mode) { -const struct ov8865_pll1_config *config = mode->pll1_config; +const struct ov8865_pll1_config *config;unsigned long pll1_rate; + config = &mode->pll1_config[sensor->extclk_rate_idx]; + pll1_rate =ov8865_mode_pll1_rate (sensor, mode);return pll1_rate / config->m_div /2 ;@@ -2783,7 +2834,8 @@ static int ov8865_probe(struct i2c_client *client)struct ov8865_sensor *sensor;struct v4l2_subdev *subdev;struct media_pad *pad; -unsigned long rate; +unsigned int rate; +unsigned int i;int ret; sensor =devm_kzalloc (dev,sizeof (*sensor),GFP_KERNEL );@@ -2858,13 +2910,39 @@ static int ov8865_probe(struct i2c_client *client) goto error_endpoint; } - rate =clk_get_rate (sensor->extclk); -if (rate !=OV8865_EXTCLK_RATE ) { -dev_err (dev,"clock rate %lu Hz is unsupported\n" , rate); +/* +* We could have either a 24MHz or 19.2MHz clock rate. Check for a +* clock-frequency property and if found, set that rate. This should +* cover ACPI case. If the system uses devicetree then the configured +* rate should already be set, so we'll have to check it. +*/ + + ret =fwnode_property_read_u32 (dev_fwnode (dev),"clock-frequency" , + &rate); +if (!ret) { + ret =clk_set_rate (sensor->extclk, rate); +if (ret) { +dev_err (dev,"failed to set clock rate\n" ); +return ret; + } + } + + sensor->extclk_rate =clk_get_rate (sensor->extclk); + +for (i =0 ; i <ARRAY_SIZE (supported_extclk_rates); i++) { +if (sensor->extclk_rate == supported_extclk_rates[i]) +break ; + } + +if (i ==ARRAY_SIZE (supported_extclk_rates)) { +dev_err (dev,"clock rate %lu Hz is unsupported\n" , + sensor->extclk_rate); ret = -EINVAL ; goto error_endpoint; } + sensor->extclk_rate_idx = i; +/* Subdev, entity and pad */ subdev = &sensor->subdev;
Sakari Ailus
maintainerRe: [PATCH v2 04/12] media: i2c: Support 19.2MHz input clock in ov8865
Quoted 1 line · Daniel Scally
Hi Sakari - thanks for all the comments
You're welcome!
Nice patches btw.
Quoted 127 lines · Sakari Ailus
Quoted 100 lines
Hi Daniel,
Thanks for the set.
Quoted 95 lines · Daniel Scally
The ov8865 driver as written expects a 24MHz input clock, but the sensor is sometimes found on x86 platforms with a 19.2MHz input clock supplied. Add a set of PLL configurations to the driver to support that rate too. As ACPI doesn't auto-configure the clock rate, check for a clock-frequency during probe and set that rate if one is found.
Signed-off-by Daniel Scally <[email protected]>---
Changes in v2:- Added an enum defining the possible frequency rates to index the array (Andy)
drivers/media/i2c/ov8865.c | 164 +++++++++++++++++++++++++++---------- 1 file changed, 121 insertions(+), 43 deletions(-)drivers/media/i2c/ov8865.c +33
-14@@ -21,10 +21,6 @@#include <media/v4l2-image-sizes.h> #include <media/v4l2-mediabus.h> -/* Clock rate */ - -#define OV8865_EXTCLK_RATE 24000000 -/* Register definitions */ /* System */ @@ -567,6 +563,19 @@ struct ov8865_sclk_config {unsigned int sclk_div; }; +/* Clock rate */ + +enum extclk_rate { +OV8865_19_2_MHZ , +OV8865_24_MHZ , +OV8865_NUM_SUPPORTED_RATES , +}; + +static const unsigned long supported_extclk_rates[] = { + [OV8865_19_2_MHZ ] =19200000 , + [OV8865_24_MHZ ] =24000000 , +}; +/* * General formulas for (array-centered) mode calculation: * - photo_array_width = 3296 @@ -665,6 +674,9 @@ struct ov8865_sensor {struct regulator *avdd;struct regulator *dvdd;struct regulator *dovdd; + +unsigned long extclk_rate; +enum extclk_rate extclk_rate_idx;struct clk *extclk;struct v4l2_fwnode_endpoint endpoint;@@ -680,49 +692,83 @@ struct ov8865_sensor {/* Static definitions */ /* -* EXTCLK = 24 MHz * PHY_SCLK = 720 MHz * MIPI_PCLK = 90 MHz */ -static const struct ov8865_pll1_config ov8865_pll1_config_native = { - .pll_pre_div_half =1 , - .pll_pre_div =0 , - .pll_mul =30 , - .m_div =1 , - .mipi_div =3 , - .pclk_div =1 , - .sys_pre_div =1 , - .sys_div =2 , + +static const struct ov8865_pll1_config ov8865_pll1_configs_native[] = { + {/* 19.2 MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =2 , + .pll_mul =75 , + .m_div =1 , + .mipi_div =3 , + .pclk_div =1 , + .sys_pre_div =1 , + .sys_div =2 , + }, + {/* 24MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =0 , + .pll_mul =30 , + .m_div =1 ,Quoted 8 lines
drivers/media/i2c/ov8865.c struct ov8865_sensor { · line 709
Quoted 5 lines
drivers/media/i2c/ov8865.c +5
-0+ .mipi_div = 3, + .pclk_div = 1, + .sys_pre_div = 1, + .sys_div = 2, + },Could you instead add a struct specific to the clock frequency with pointers to these? See e.g. the ov8856 driver how this could otherwise end up...
You mean something like
static struct
ov8865_pll_configs_19_2_mhz{.pll1_config_native =
&ov8865_pll1_config_native,...
};
static struct
ov8865_pll_configs_24_mhz{
Quoted 8 lines
.pll1_config_native =
&ov8865_pll1_config_native,...
};
or am I misunderstanding?
Yes, please --- ov8865_pll1_config_native above is thus the PLL configuration for the 24 MHz clock.
Signature · 1 line
Sakari Ailus
Re: [PATCH v2 04/12] media: i2c: Support 19.2MHz input clock in ov8865
Hi Sakari
Quoted 5 lines · Sakari Ailus
Quoted 1 line · Daniel Scally
Hi Sakari - thanks for all the comments
You're welcome!
Nice patches btw.
Thanks!
Quoted 128 lines
Quoted 128 lines · Sakari Ailus
Quoted 100 lines
Hi Daniel,
Thanks for the set.
Quoted 95 lines · Daniel Scally
The ov8865 driver as written expects a 24MHz input clock, but the sensor is sometimes found on x86 platforms with a 19.2MHz input clock supplied. Add a set of PLL configurations to the driver to support that rate too. As ACPI doesn't auto-configure the clock rate, check for a clock-frequency during probe and set that rate if one is found.
Signed-off-by Daniel Scally <[email protected]>---
Changes in v2:- Added an enum defining the possible frequency rates to index the array (Andy)
drivers/media/i2c/ov8865.c | 164 +++++++++++++++++++++++++++---------- 1 file changed, 121 insertions(+), 43 deletions(-)drivers/media/i2c/ov8865.c +33
-14@@ -21,10 +21,6 @@#include <media/v4l2-image-sizes.h> #include <media/v4l2-mediabus.h> -/* Clock rate */ - -#define OV8865_EXTCLK_RATE 24000000 -/* Register definitions */ /* System */ @@ -567,6 +563,19 @@ struct ov8865_sclk_config {unsigned int sclk_div; }; +/* Clock rate */ + +enum extclk_rate { +OV8865_19_2_MHZ , +OV8865_24_MHZ , +OV8865_NUM_SUPPORTED_RATES , +}; + +static const unsigned long supported_extclk_rates[] = { + [OV8865_19_2_MHZ ] =19200000 , + [OV8865_24_MHZ ] =24000000 , +}; +/* * General formulas for (array-centered) mode calculation: * - photo_array_width = 3296 @@ -665,6 +674,9 @@ struct ov8865_sensor {struct regulator *avdd;struct regulator *dvdd;struct regulator *dovdd; + +unsigned long extclk_rate; +enum extclk_rate extclk_rate_idx;struct clk *extclk;struct v4l2_fwnode_endpoint endpoint;@@ -680,49 +692,83 @@ struct ov8865_sensor {/* Static definitions */ /* -* EXTCLK = 24 MHz * PHY_SCLK = 720 MHz * MIPI_PCLK = 90 MHz */ -static const struct ov8865_pll1_config ov8865_pll1_config_native = { - .pll_pre_div_half =1 , - .pll_pre_div =0 , - .pll_mul =30 , - .m_div =1 , - .mipi_div =3 , - .pclk_div =1 , - .sys_pre_div =1 , - .sys_div =2 , + +static const struct ov8865_pll1_config ov8865_pll1_configs_native[] = { + {/* 19.2 MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =2 , + .pll_mul =75 , + .m_div =1 , + .mipi_div =3 , + .pclk_div =1 , + .sys_pre_div =1 , + .sys_div =2 , + }, + {/* 24MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =0 , + .pll_mul =30 , + .m_div =1 ,Quoted 8 lines
drivers/media/i2c/ov8865.c struct ov8865_sensor { · line 709
Quoted 5 lines
drivers/media/i2c/ov8865.c +5
-0+ .mipi_div = 3, + .pclk_div = 1, + .sys_pre_div = 1, + .sys_div = 2, + },Could you instead add a struct specific to the clock frequency with pointers to these? See e.g. the ov8856 driver how this could otherwise end up...I thin
You mean something like
static struct
ov8865_pll_configs_19_2_mhz{.pll1_config_native =
&ov8865_pll1_config_native,...
};
static struct
ov8865_pll_configs_24_mhz{.pll1_config_native =
&ov8865_pll1_config_native,
Quoted 8 lines
Quoted 6 lines
...
};
or am I misunderstanding?
Yes, please ---
ov8865_pll1_config_nativeabove is thus the PLL configuration for the 24 MHz clock.
I'm not sure about this actually. There's two versions of ov8865_pll2_config, native and binning, so it becomes something like this:
struct ov8865_pll_configs {
struct ov8865_pll1_config *pll1_config; struct ov8865_pll2_config *pll2_config_native; struct ov8865_pll2_config *pll2_config_binning; };
static struct ov8865_pll_configs ov8865_pll_configs_19_2mhz = { .pll1_config = &ov8865_pll1_config_native_19_2mhz, .pll2_config_native = &ov8865_pll2_config_native_19_2mhz, .pll2_config_binning = &ov8865_pll2_config_binning_19_2mhz, };
static struct ov8865_pll_configs ov8865_pll_configs_24mhz = { .pll1_config = &ov8865_pll1_config_native_24mhz, .pll2_config_native = &ov8865_pll2_config_native_24mhz, .pll2_config_binning = &ov8865_pll2_config_binning_24mhz, };
Now because a mode might use either the native or binning version of the pll2 configs, currently they're actually against the struct for a particular mode like so:
struct ov8865_mode ov8865_modes[] = {
{
<snip>
.pll1_config = &ov8865_pll1_config_native, .pll2_config = &ov8865_pll2_config_binning, .sclk_config = &ov8865_sclk_config_native,
}
};
The problem I'm having is that I can't really see a clean way to store against the _mode_ whether it should access .pll2_config_native or .pll2_config_binning, from the new struct ov8865_pll_configs. Do you have any ideas about a way to do that?
Sakari Ailus
maintainerRe: [PATCH v2 04/12] media: i2c: Support 19.2MHz input clock in ov8865
Hi Daniel,
Quoted 189 lines · Daniel Scally
Hi Sakari
Quoted 5 lines · Sakari Ailus
Quoted 1 line · Daniel Scally
Hi Sakari - thanks for all the comments
You're welcome!
Nice patches btw.
Thanks!
Quoted 128 lines
Quoted 128 lines · Sakari Ailus
Quoted 100 lines
Hi Daniel,
Thanks for the set.
Quoted 95 lines · Daniel Scally
The ov8865 driver as written expects a 24MHz input clock, but the sensor is sometimes found on x86 platforms with a 19.2MHz input clock supplied. Add a set of PLL configurations to the driver to support that rate too. As ACPI doesn't auto-configure the clock rate, check for a clock-frequency during probe and set that rate if one is found.
Signed-off-by Daniel Scally <[email protected]>---
Changes in v2:- Added an enum defining the possible frequency rates to index the array (Andy)
drivers/media/i2c/ov8865.c | 164 +++++++++++++++++++++++++++---------- 1 file changed, 121 insertions(+), 43 deletions(-)drivers/media/i2c/ov8865.c +33
-14@@ -21,10 +21,6 @@#include <media/v4l2-image-sizes.h> #include <media/v4l2-mediabus.h> -/* Clock rate */ - -#define OV8865_EXTCLK_RATE 24000000 -/* Register definitions */ /* System */ @@ -567,6 +563,19 @@ struct ov8865_sclk_config {unsigned int sclk_div; }; +/* Clock rate */ + +enum extclk_rate { +OV8865_19_2_MHZ , +OV8865_24_MHZ , +OV8865_NUM_SUPPORTED_RATES , +}; + +static const unsigned long supported_extclk_rates[] = { + [OV8865_19_2_MHZ ] =19200000 , + [OV8865_24_MHZ ] =24000000 , +}; +/* * General formulas for (array-centered) mode calculation: * - photo_array_width = 3296 @@ -665,6 +674,9 @@ struct ov8865_sensor {struct regulator *avdd;struct regulator *dvdd;struct regulator *dovdd; + +unsigned long extclk_rate; +enum extclk_rate extclk_rate_idx;struct clk *extclk;struct v4l2_fwnode_endpoint endpoint;@@ -680,49 +692,83 @@ struct ov8865_sensor {/* Static definitions */ /* -* EXTCLK = 24 MHz * PHY_SCLK = 720 MHz * MIPI_PCLK = 90 MHz */ -static const struct ov8865_pll1_config ov8865_pll1_config_native = { - .pll_pre_div_half =1 , - .pll_pre_div =0 , - .pll_mul =30 , - .m_div =1 , - .mipi_div =3 , - .pclk_div =1 , - .sys_pre_div =1 , - .sys_div =2 , + +static const struct ov8865_pll1_config ov8865_pll1_configs_native[] = { + {/* 19.2 MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =2 , + .pll_mul =75 , + .m_div =1 , + .mipi_div =3 , + .pclk_div =1 , + .sys_pre_div =1 , + .sys_div =2 , + }, + {/* 24MHz input clock */ + .pll_pre_div_half =1 , + .pll_pre_div =0 , + .pll_mul =30 , + .m_div =1 ,Quoted 8 lines
drivers/media/i2c/ov8865.c struct ov8865_sensor { · line 709
Quoted 5 lines
drivers/media/i2c/ov8865.c +5
-0+ .mipi_div = 3, + .pclk_div = 1, + .sys_pre_div = 1, + .sys_div = 2, + },Could you instead add a struct specific to the clock frequency with pointers to these? See e.g. the ov8856 driver how this could otherwise end up...I thin
You mean something like
static struct
ov8865_pll_configs_19_2_mhz{.pll1_config_native =
&ov8865_pll1_config_native,...
};
static struct
ov8865_pll_configs_24_mhz{.pll1_config_native =
&ov8865_pll1_config_native,Quoted 8 lines
Quoted 6 lines
...
};
or am I misunderstanding?
Yes, please ---
ov8865_pll1_config_nativeabove is thus the PLL configuration for the 24 MHz clock.I'm not sure about this actually. There's two versions of
ov8865_pll2_config, native and binning, so it becomes something like this:struct
ov8865_pll_configs{
structov8865_pll1_config*pll1_config; structov8865_pll2_config*pll2_config_native; structov8865_pll2_config*pll2_config_binning; };static struct
ov8865_pll_configsov8865_pll_configs_19_2mhz= { .pll1_config =&ov8865_pll1_config_native_19_2mhz, .pll2_config_native =&ov8865_pll2_config_native_19_2mhz, .pll2_config_binning =&ov8865_pll2_config_binning_19_2mhz, };static struct
ov8865_pll_configsov8865_pll_configs_24mhz= { .pll1_config =&ov8865_pll1_config_native_24mhz, .pll2_config_native =&ov8865_pll2_config_native_24mhz, .pll2_config_binning =&ov8865_pll2_config_binning_24mhz, };Now because a mode might use either the native or binning version of the pll2 configs, currently they're actually against the struct for a particular mode like so:
struct
ov8865_modeov8865_modes[] = {{
<snip>
.pll1_config =
&ov8865_pll1_config_native, .pll2_config =&ov8865_pll2_config_binning, .sclk_config =&ov8865_sclk_config_native,}
Quoted 7 lines
};
The problem I'm having is that I can't really see a clean way to store against the _mode_ whether it should access .pll2_config_native or .pll2_config_binning, from the new struct
ov8865_pll_configs. Do you have any ideas about a way to do that?
Ah, yes. I agree, that's where you'll need some code to pick the right one. So you could use a function pointer in the struct and give it the necessary arguments. I don't think it'd be overkill, things tend to develop over time. See e.g. the ov8856 driver as a (warning) example.
Signature · 3 lines
Kind regards, Sakari Ailus
PATCH v2 5/12 media: i2c: Add .get_selection() support to ov8865
In reply to Daniel ScallyThe ov8865 driver's v4l2_subdev_pad_ops currently does not include .get_selection() - add support for that callback.
---
Changes in v2:
- None
drivers/media/i2c/ov8865.c | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
drivers/media/i2c/ov8865.c +61 -0
@@ -450,6 +450,15 @@#define OV8865_PRE_CTRL0_PATTERN_COLOR_SQUARES 2#define OV8865_PRE_CTRL0_PATTERN_BLACK 3 +/* Pixel Array */ + +#define OV8865_NATIVE_WIDTH 3296 +#define OV8865_NATIVE_HEIGHT 2528 +#define OV8865_ACTIVE_START_TOP 32 +#define OV8865_ACTIVE_START_LEFT 80 +#define OV8865_ACTIVE_WIDTH 3264 +#define OV8865_ACTIVE_HEIGHT 2448 +/* Macros */ #define ov8865_subdev_sensor (s) \
@@ -2749,12 +2758,64 @@ static int ov8865_enum_frame_interval(struct v4l2_subdev *subdev,return 0 ; } +static void +__ov8865_get_pad_crop (struct ov8865_sensor *sensor, +struct v4l2_subdev_state *state,unsigned int pad, +enum v4l2_subdev_format_whence which,struct v4l2_rect *r) +{ +switch (which) { +case V4L2_SUBDEV_FORMAT_TRY : + *r = *v4l2_subdev_get_try_crop (&sensor->subdev, state, pad); +break ; +case V4L2_SUBDEV_FORMAT_ACTIVE : + r->height = sensor->state.mode->output_size_y; + r->width = sensor->state.mode->output_size_x; + r->top = (OV8865_NATIVE_HEIGHT - sensor->state.mode->output_size_y) /2 ; + r->left = (OV8865_NATIVE_WIDTH - sensor->state.mode->output_size_x) /2 ; +break ; + } +} + +static int ov8865_get_selection (struct v4l2_subdev *subdev, +struct v4l2_subdev_state *state, +struct v4l2_subdev_selection *sel) +{ +struct ov8865_sensor *sensor =ov8865_subdev_sensor (subdev); + +switch (sel->target) { +case V4L2_SEL_TGT_CROP : +mutex_lock (&sensor->mutex); +__ov8865_get_pad_crop (sensor, state, sel->pad, + sel->which, &sel->r); +mutex_unlock (&sensor->mutex); +break ; +case V4L2_SEL_TGT_NATIVE_SIZE : + sel->r.top =0 ; + sel->r.left =0 ; + sel->r.width =OV8865_NATIVE_WIDTH ; + sel->r.height =OV8865_NATIVE_HEIGHT ; +break ; +case V4L2_SEL_TGT_CROP_BOUNDS : +case V4L2_SEL_TGT_CROP_DEFAULT : + sel->r.top =OV8865_ACTIVE_START_TOP ; + sel->r.left =OV8865_ACTIVE_START_LEFT ; + sel->r.width =OV8865_ACTIVE_WIDTH ; + sel->r.height =OV8865_ACTIVE_HEIGHT ; +break ; +default : +return -EINVAL ; + } + +return 0 ; +} +static const struct v4l2_subdev_pad_ops ov8865_subdev_pad_ops = { .enum_mbus_code = ov8865_enum_mbus_code, .get_fmt = ov8865_get_fmt, .set_fmt = ov8865_set_fmt, .enum_frame_size = ov8865_enum_frame_size, .enum_frame_interval = ov8865_enum_frame_interval, + .get_selection = ov8865_get_selection, };static const struct v4l2_subdev_ops ov8865_subdev_ops = {
Signature · 1 line
2.25.1
Sakari Ailus
maintainerRe: [PATCH v2 05/12] media: i2c: Add .get_selection() support to ov8865
Hi Daniel,
Quoted 2 lines · Daniel Scally
The ov8865 driver's
v4l2_subdev_pad_opscurrently does not include .get_selection() - add support for that callback.
Could you use the same for .set_selection()? Even if it doesn't change anything.
Signature · 1 line
Sakari Ailus
Re: [PATCH v2 05/12] media: i2c: Add .get_selection() support to ov8865
Hi Sakari - sorry delayed reply
Quoted 7 lines · Sakari Ailus
Hi Daniel,
Quoted 2 lines · Daniel Scally
The ov8865 driver's
v4l2_subdev_pad_opscurrently does not include .get_selection() - add support for that callback.Could you use the same for .set_selection()? Even if it doesn't change anything.
You mean do the same? Or use the same function?
Sakari Ailus
maintainerRe: [PATCH v2 05/12] media: i2c: Add .get_selection() support to ov8865
Quoted 5 lines · Daniel Scally
Hi Sakari - sorry delayed reply
Quoted 2 lines · Sakari Ailus
Hi Daniel,
Quoted 8 lines
Quoted 5 lines · Daniel Scally
Quoted 2 lines
The ov8865 driver's
v4l2_subdev_pad_opscurrently does not include .get_selection() - add support for that callback.Could you use the same for .set_selection()? Even if it doesn't change anything.
You mean do the same? Or use the same function?
The same function. If the selection isn't changeable anyway, the functionality is the same for both.
Signature · 1 line
Sakari Ailus
Re: [PATCH v2 05/12] media: i2c: Add .get_selection() support to ov8865
Quoted 9 lines · Sakari Ailus
Quoted 8 lines · Daniel Scally
Hi Sakari - sorry delayed reply
Quoted 5 lines · Sakari Ailus
Hi Daniel,
Quoted 2 lines · Daniel Scally
The ov8865 driver's
v4l2_subdev_pad_opscurrently does not include .get_selection() - add support for that callback.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Could you use the same for .set_selection()? Even if it doesn't change anything.
You mean do the same? Or use the same function?
The same function. If the selection isn't changeable anyway, the functionality is the same for both.
Except that .s_selection() should return an error if you try to set the bounds or default rectangles.
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerRe: [PATCH v2 05/12] media: i2c: Add .get_selection() support to ov8865
Quoted 13 lines · Laurent Pinchart
Quoted 12 lines · Sakari Ailus
Quoted 11 lines · Daniel Scally
Hi Sakari - sorry delayed reply
Quoted 7 lines · Sakari Ailus
Hi Daniel,
Quoted 2 lines · Daniel Scally
The ov8865 driver's
v4l2_subdev_pad_opscurrently does not include .get_selection() - add support for that callback.Could you use the same for .set_selection()? Even if it doesn't change anything.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
You mean do the same? Or use the same function?
The same function. If the selection isn't changeable anyway, the functionality is the same for both.
Except that .s_selection() should return an error if you try to set the bounds or default rectangles.
That would make sense. But it's not documented. And in any case it should be implemented in the framework. :-)
Signature · 1 line
Sakari Ailus
PATCH v2 6/12 media: i2c: Switch control to V4L2_CID_ANALOGUE_GAIN
In reply to Daniel ScallyThe V4L2_CID_GAIN control for this driver configures registers that the datasheet specifies as analogue gain. Switch the control's ID to V4L2_CID_ANALOGUE_GAIN.
---
Changes in v2:
- None
drivers/media/i2c/ov8865.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/i2c/ov8865.c +4 -4
@@ -2143,7 +2143,7 @@ static int ov8865_exposure_configure(struct ov8865_sensor *sensor, u32 exposure)/* Gain */ -static int ov8865_gain_configure (struct ov8865_sensor *sensor,u32 gain) +static int ov8865_analog_gain_configure (struct ov8865_sensor *sensor,u32 gain) {int ret;
@@ -2453,8 +2453,8 @@ static int ov8865_s_ctrl(struct v4l2_ctrl *ctrl)if (ret)return ret;break ; -case V4L2_CID_GAIN : - ret =ov8865_gain_configure (sensor, ctrl->val); +case V4L2_CID_ANALOGUE_GAIN : + ret =ov8865_analog_gain_configure (sensor, ctrl->val);if (ret)return ret;break ;
@@ -2499,7 +2499,7 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)/* Gain */ -v4l2_ctrl_new_std (handler, ops,V4L2_CID_GAIN ,128 ,8191 ,128 ,128 ); +v4l2_ctrl_new_std (handler, ops,V4L2_CID_ANALOGUE_GAIN ,128 ,8191 ,128 ,128 );/* White Balance */
Signature · 1 line
2.25.1
Sakari Ailus
maintainerRe: [PATCH v2 06/12] media: i2c: Switch control to V4L2_CID_ANALOGUE_GAIN
Quoted 21 lines · Daniel Scally
drivers/media/i2c/ov8865.c +3
-3@@ -2143,7 +2143,7 @@ static int ov8865_exposure_configure(struct ov8865_sensor *sensor, u32 exposure)/* Gain */ -static int ov8865_gain_configure (struct ov8865_sensor *sensor,u32 gain) +static int ov8865_analog_gain_configure (struct ov8865_sensor *sensor,u32 gain) {int ret;@@ -2453,8 +2453,8 @@ static int ov8865_s_ctrl(struct v4l2_ctrl *ctrl)if (ret)return ret;break ; -case V4L2_CID_GAIN : - ret =ov8865_gain_configure (sensor, ctrl->val); +case V4L2_CID_ANALOGUE_GAIN : + ret =ov8865_analog_gain_configure (sensor, ctrl->val);if (ret)return ret;break ;
drivers/media/i2c/ov8865.c static int ov8865_ctrls_init(struct ov8865_sensor *sensor) · line 2502
Quoted 5 lines
drivers/media/i2c/ov8865.c +1
-1@@ -2499,7 +2499,7 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)/* Gain */ -v4l2_ctrl_new_std (handler, ops,V4L2_CID_GAIN ,128 ,8191 ,128 ,128 ); +v4l2_ctrl_new_std (handler, ops,V4L2_CID_ANALOGUE_GAIN ,128 ,8191 ,128 ,128 );
Over 80, please wrap.
Signature · 1 line
Sakari Ailus
PATCH v2 7/12 media: i2c: Add vblank control to ov8865
In reply to Daniel ScallyAdd a V4L2_CID_VBLANK control to the ov8865 driver.
---
Changes in v2:
- None
drivers/media/i2c/ov8865.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/media/i2c/ov8865.c +34 -0
@@ -183,6 +183,8 @@#define OV8865_VTS_H (v) (((v) & GENMASK(11, 8)) >> 8)#define OV8865_VTS_L_REG 0x380f#define OV8865_VTS_L (v) ((v) & GENMASK(7, 0)) +#define OV8865_TIMING_MAX_VTS 0xffff +#define OV8865_TIMING_MIN_VTS 0x04#define OV8865_OFFSET_X_H_REG 0x3810#define OV8865_OFFSET_X_H (v) (((v) & GENMASK(15, 8)) >> 8)#define OV8865_OFFSET_X_L_REG 0x3811
@@ -671,6 +673,7 @@ struct ov8865_state {struct ov8865_ctrls {struct v4l2_ctrl *link_freq;struct v4l2_ctrl *pixel_rate; +struct v4l2_ctrl *vblank;struct v4l2_ctrl_handler handler; };
@@ -2218,6 +2221,20 @@ static int ov8865_test_pattern_configure(struct ov8865_sensor *sensor, ov8865_test_pattern_bits[index]); } +/* Blanking */ + +static int ov8865_vts_configure (struct ov8865_sensor *sensor,u32 vblank) +{ +u16 vts = sensor->state.mode->output_size_y + vblank; +int ret; + + ret =ov8865_write (sensor,OV8865_VTS_H_REG ,OV8865_VTS_H (vts)); +if (ret) +return ret; + +return ov8865_write (sensor,OV8865_VTS_L_REG ,OV8865_VTS_L (vts)); +} +/* State */ static int ov8865_state_mipi_configure(struct ov8865_sensor *sensor,
@@ -2469,6 +2486,8 @@ static int ov8865_s_ctrl(struct v4l2_ctrl *ctrl)case V4L2_CID_TEST_PATTERN : index = (unsigned int )ctrl->val;return ov8865_test_pattern_configure (sensor, index); +case V4L2_CID_VBLANK : +return ov8865_vts_configure (sensor, ctrl->val);default :return -EINVAL ; }
@@ -2485,6 +2504,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)struct ov8865_ctrls *ctrls = &sensor->ctrls;struct v4l2_ctrl_handler *handler = &ctrls->handler;const struct v4l2_ctrl_ops *ops = &ov8865_ctrl_ops; +const struct ov8865_mode *mode = sensor->state.mode; +unsigned int vblank_max, vblank_def;int ret;v4l2_ctrl_handler_init (handler,32 );
@@ -2520,6 +2541,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)ARRAY_SIZE (ov8865_test_pattern_menu) -1 , 0, 0, ov8865_test_pattern_menu); +/* Blanking */ + vblank_max =OV8865_TIMING_MAX_VTS - mode->output_size_y; + vblank_def = mode->vts - mode->output_size_y; + ctrls->vblank =v4l2_ctrl_new_std (handler, ops,V4L2_CID_VBLANK , +OV8865_TIMING_MIN_VTS , vblank_max,1 , + vblank_def); +/* MIPI CSI-2 */ ctrls->link_freq =
@@ -2700,6 +2728,10 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev, sensor->state.mbus_code != mbus_code) ret =ov8865_state_configure (sensor, mode, mbus_code); +__v4l2_ctrl_modify_range (sensor->ctrls.vblank,OV8865_TIMING_MIN_VTS , +OV8865_TIMING_MAX_VTS - mode->output_size_y, +1 , mode->vts - mode->output_size_y); + complete:mutex_unlock (&sensor->mutex);
@@ -3025,6 +3057,8 @@ static int ov8865_probe(struct i2c_client *client)/* Sensor */ + sensor->state.mode = &ov8865_modes[0 ]; + ret =ov8865_ctrls_init (sensor);if (ret) goto error_mutex;
Signature · 1 line
2.25.1
PATCH v2 8/12 media: i2c: Add hblank control to ov8865
In reply to Daniel ScallyAdd a V4L2_CID_HBLANK control to the ov8865 driver. This is read only with timing control intended to be done via vblanking alone.
---
Changes in v2:
- None
drivers/media/i2c/ov8865.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/media/i2c/ov8865.c +14 -0
@@ -673,6 +673,7 @@ struct ov8865_state {struct ov8865_ctrls {struct v4l2_ctrl *link_freq;struct v4l2_ctrl *pixel_rate; +struct v4l2_ctrl *hblank;struct v4l2_ctrl *vblank;struct v4l2_ctrl_handler handler;
@@ -2506,6 +2507,7 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)const struct v4l2_ctrl_ops *ops = &ov8865_ctrl_ops;const struct ov8865_mode *mode = sensor->state.mode;unsigned int vblank_max, vblank_def; +unsigned int hblank;int ret;v4l2_ctrl_handler_init (handler,32 );
@@ -2542,6 +2544,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) 0, 0, ov8865_test_pattern_menu);/* Blanking */ + hblank = mode->hts < mode->output_size_x ?0 : mode->hts - mode->output_size_x; + ctrls->hblank =v4l2_ctrl_new_std (handler, ops,V4L2_CID_HBLANK , hblank, + hblank,1 , hblank); + +if (ctrls->hblank) + ctrls->hblank->flags |=V4L2_CTRL_FLAG_READ_ONLY ; + vblank_max =OV8865_TIMING_MAX_VTS - mode->output_size_y; vblank_def = mode->vts - mode->output_size_y; ctrls->vblank = v4l2_ctrl_new_std(handler, ops, V4L2_CID_VBLANK,
@@ -2688,6 +2697,7 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev,struct v4l2_mbus_framefmt *mbus_format = &format->format;const struct ov8865_mode *mode;u32 mbus_code =0 ; +unsigned int hblank;unsigned int index;int ret =0 ;
@@ -2732,6 +2742,10 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev,OV8865_TIMING_MAX_VTS - mode->output_size_y, 1, mode->vts - mode->output_size_y); + hblank = mode->hts < mode->output_size_x ?0 : mode->hts - mode->output_size_x; +__v4l2_ctrl_modify_range (sensor->ctrls.hblank, hblank, hblank,1 , + hblank); + complete:mutex_unlock (&sensor->mutex);
Signature · 1 line
2.25.1
Re: [PATCH v2 08/12] media: i2c: Add hblank control to ov8865
Quoted 3 lines · Daniel Scally
Add a
V4L2_CID_HBLANKcontrol to the ov8865 driver. This is read only with timing control intended to be done via vblanking alone.
...
Quoted 1 line
+ hblank =
mode->hts<mode->output_size_x? 0 :mode->hts-mode->output_size_x;
In both cases can be
hblank = max(mode->output_size_x, mode->hts) - mode->output_size_x;
or max_t() in case types are different (but in this case the code might be uglier).
drivers/media/i2c/ov8865.c static int ov8865_ctrls_init(struct ov8865_sensor *sensor) · line 2550
Quoted 4 lines
drivers/media/i2c/ov8865.c +3
-0+ ctrls->hblank =v4l2_ctrl_new_std (handler, ops,V4L2_CID_HBLANK , hblank, + hblank,1 , hblank); +
Redundant blank line (pun is not intended :).
Quoted 2 lines
drivers/media/i2c/ov8865.c +2
-0+if (ctrls->hblank) + ctrls->hblank->flags |=V4L2_CTRL_FLAG_READ_ONLY ;
...
Quoted 1 line
+ hblank =
mode->hts<mode->output_size_x? 0 :mode->hts-mode->output_size_x;
See above.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Sakari Ailus
maintainerRe: [PATCH v2 08/12] media: i2c: Add hblank control to ov8865
In reply to Daniel ScallyHi Daniel,
drivers/media/i2c/ov8865.c static int ov8865_ctrls_init(struct ov8865_sensor *sensor) · line 2547
Quoted 5 lines · Daniel Scally
drivers/media/i2c/ov8865.c +1
-0@@ -2542,6 +2544,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) 0, 0, ov8865_test_pattern_menu);/* Blanking */ + hblank = mode->hts < mode->output_size_x ?0 : mode->hts - mode->output_size_x;
Is the result in relation with the analogue crop size? Based on the above it wouldn't seem like that.
Quoted 9 lines
drivers/media/i2c/ov8865.c +6
-0+ ctrls->hblank =v4l2_ctrl_new_std (handler, ops,V4L2_CID_HBLANK , hblank, + hblank,1 , hblank); + +if (ctrls->hblank) + ctrls->hblank->flags |=V4L2_CTRL_FLAG_READ_ONLY ; + vblank_max =OV8865_TIMING_MAX_VTS - mode->output_size_y; vblank_def = mode->vts - mode->output_size_y; ctrls->vblank = v4l2_ctrl_new_std(handler, ops, V4L2_CID_VBLANK,
Signature · 1 line
Sakari Ailus
Re: [PATCH v2 08/12] media: i2c: Add hblank control to ov8865
Hi Sakari
Quoted 10 lines · Sakari Ailus
Hi Daniel,
drivers/media/i2c/ov8865.c static int ov8865_ctrls_init(struct ov8865_sensor *sensor) · line 2547
Quoted 5 lines · Daniel Scally
drivers/media/i2c/ov8865.c +1
-0@@ -2542,6 +2544,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) 0, 0, ov8865_test_pattern_menu);/* Blanking */ + hblank = mode->hts < mode->output_size_x ?0 : mode->hts - mode->output_size_x;Is the result in relation with the analogue crop size? Based on the above it wouldn't seem like that.
This was a weird one actually. My understanding was that HTS should always be >= the horizontal crop plus hblank...but that doesn't hold true for some of this driver's modes and nor does it hold true when running the camera in Windows (I checked the registers whilst running it). So I went with setting hblank to 0 if the mode's HTS exceeded the horizontal crop as the only way I could see to reconcile that.
Quoted 10 lines
Quoted 10 lines
drivers/media/i2c/ov8865.c +6
-0+ ctrls->hblank =v4l2_ctrl_new_std (handler, ops,V4L2_CID_HBLANK , hblank, + hblank,1 , hblank); + +if (ctrls->hblank) + ctrls->hblank->flags |=V4L2_CTRL_FLAG_READ_ONLY ; + vblank_max =OV8865_TIMING_MAX_VTS - mode->output_size_y; vblank_def = mode->vts - mode->output_size_y; ctrls->vblank = v4l2_ctrl_new_std(handler, ops, V4L2_CID_VBLANK,
Re: [PATCH v2 08/12] media: i2c: Add hblank control to ov8865
Hi Daniel,
Quoted 11 lines · Daniel Scally
Quoted 9 lines · Sakari Ailus
drivers/media/i2c/ov8865.c static int ov8865_ctrls_init(struct ov8865_sensor *sensor) · line 2547
Quoted 5 lines · Daniel Scally
drivers/media/i2c/ov8865.c +1
-0@@ -2542,6 +2544,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) 0, 0, ov8865_test_pattern_menu);/* Blanking */ + hblank = mode->hts < mode->output_size_x ?0 : mode->hts - mode->output_size_x;Is the result in relation with the analogue crop size? Based on the above it wouldn't seem like that.
Quoted 6 lines
This was a weird one actually. My understanding was that HTS should always be >= the horizontal crop plus hblank...but that doesn't hold true for some of this driver's modes and nor does it hold true when running the camera in Windows (I checked the registers whilst running it). So I went with setting hblank to 0 if the mode's HTS exceeded the horizontal crop as the only way I could see to reconcile that.
There's something very fishy here, HTS is, by definition, equal to the analog crop width plus the horizontal blanking. I suspect that the values in ov8865_modes are wrong.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/i2c/ov8865.c +6
-0+ ctrls->hblank =v4l2_ctrl_new_std (handler, ops,V4L2_CID_HBLANK , hblank, + hblank,1 , hblank); + +if (ctrls->hblank) + ctrls->hblank->flags |=V4L2_CTRL_FLAG_READ_ONLY ; + vblank_max =OV8865_TIMING_MAX_VTS - mode->output_size_y; vblank_def = mode->vts - mode->output_size_y; ctrls->vblank = v4l2_ctrl_new_std(handler, ops, V4L2_CID_VBLANK,
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 08/12] media: i2c: Add hblank control to ov8865
Hi Laurent
Quoted 18 lines · Laurent Pinchart
Hi Daniel,
Quoted 9 lines · Daniel Scally
Quoted 8 lines · Sakari Ailus
drivers/media/i2c/ov8865.c static int ov8865_ctrls_init(struct ov8865_sensor *sensor) · line 2547
Quoted 5 lines · Daniel Scally
drivers/media/i2c/ov8865.c +1
-0@@ -2542,6 +2544,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) 0, 0, ov8865_test_pattern_menu);/* Blanking */ + hblank = mode->hts < mode->output_size_x ?0 : mode->hts - mode->output_size_x;Is the result in relation with the analogue crop size? Based on the above it wouldn't seem like that.
Quoted 6 lines
This was a weird one actually. My understanding was that HTS should always be >= the horizontal crop plus hblank...but that doesn't hold true for some of this driver's modes and nor does it hold true when running the camera in Windows (I checked the registers whilst running it). So I went with setting hblank to 0 if the mode's HTS exceeded the horizontal crop as the only way I could see to reconcile that.
Quoted 3 lines
There's something very fishy here, HTS is, by definition, equal to the analog crop width plus the horizontal blanking. I suspect that the values in
ov8865_modesare wrong.
I thought that initially too but confirming that the same thing happened running windows switched me into "you're probably wrong" mode. If we're confident that the HTS is likely wrong though I can add an extra patch to bring those into lining with that definition.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/media/i2c/ov8865.c +6
-0+ ctrls->hblank =v4l2_ctrl_new_std (handler, ops,V4L2_CID_HBLANK , hblank, + hblank,1 , hblank); + +if (ctrls->hblank) + ctrls->hblank->flags |=V4L2_CTRL_FLAG_READ_ONLY ; + vblank_max =OV8865_TIMING_MAX_VTS - mode->output_size_y; vblank_def = mode->vts - mode->output_size_y; ctrls->vblank = v4l2_ctrl_new_std(handler, ops, V4L2_CID_VBLANK,
Re: [PATCH v2 08/12] media: i2c: Add hblank control to ov8865
Hi Daniel,
Quoted 20 lines · Daniel Scally
Quoted 19 lines · Laurent Pinchart
Quoted 17 lines · Daniel Scally
Quoted 9 lines · Sakari Ailus
drivers/media/i2c/ov8865.c static int ov8865_ctrls_init(struct ov8865_sensor *sensor) · line 2547
Quoted 5 lines · Daniel Scally
drivers/media/i2c/ov8865.c +1
-0@@ -2542,6 +2544,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) 0, 0, ov8865_test_pattern_menu);/* Blanking */ + hblank = mode->hts < mode->output_size_x ?0 : mode->hts - mode->output_size_x;Is the result in relation with the analogue crop size? Based on the above it wouldn't seem like that.
This was a weird one actually. My understanding was that HTS should always be >= the horizontal crop plus hblank...but that doesn't hold true for some of this driver's modes and nor does it hold true when running the camera in Windows (I checked the registers whilst running it). So I went with setting hblank to 0 if the mode's HTS exceeded the horizontal crop as the only way I could see to reconcile that.
Quoted 8 lines
Quoted 3 lines
There's something very fishy here, HTS is, by definition, equal to the analog crop width plus the horizontal blanking. I suspect that the values in
ov8865_modesare wrong.I thought that initially too but confirming that the same thing happened running windows switched me into "you're probably wrong" mode. If we're confident that the HTS is likely wrong though I can add an extra patch to bring those into lining with that definition.
I think it's worth investigating this. The hblank computed here is clearly incorrect, and would thus be useless for all practical purposes. As usual with OmniVision, the datasheet is also quite useless.
Paul, do you have any information about this ?
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/i2c/ov8865.c +6
-0+ ctrls->hblank =v4l2_ctrl_new_std (handler, ops,V4L2_CID_HBLANK , hblank, + hblank,1 , hblank); + +if (ctrls->hblank) + ctrls->hblank->flags |=V4L2_CTRL_FLAG_READ_ONLY ; + vblank_max =OV8865_TIMING_MAX_VTS - mode->output_size_y; vblank_def = mode->vts - mode->output_size_y; ctrls->vblank = v4l2_ctrl_new_std(handler, ops, V4L2_CID_VBLANK,
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 08/12] media: i2c: Add hblank control to ov8865
Hi Paul
Quoted 27 lines · Laurent Pinchart
Hi Daniel,
Quoted 17 lines · Daniel Scally
Quoted 16 lines · Laurent Pinchart
Quoted 15 lines · Daniel Scally
Quoted 8 lines · Sakari Ailus
drivers/media/i2c/ov8865.c static int ov8865_ctrls_init(struct ov8865_sensor *sensor) · line 2547
Quoted 5 lines · Daniel Scally
drivers/media/i2c/ov8865.c +1
-0@@ -2542,6 +2544,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) 0, 0, ov8865_test_pattern_menu);/* Blanking */ + hblank = mode->hts < mode->output_size_x ?0 : mode->hts - mode->output_size_x;Is the result in relation with the analogue crop size? Based on the above it wouldn't seem like that.
This was a weird one actually. My understanding was that HTS should always be >= the horizontal crop plus hblank...but that doesn't hold true for some of this driver's modes and nor does it hold true when running the camera in Windows (I checked the registers whilst running it). So I went with setting hblank to 0 if the mode's HTS exceeded the horizontal crop as the only way I could see to reconcile that.
Quoted 7 lines
Quoted 3 lines
There's something very fishy here, HTS is, by definition, equal to the analog crop width plus the horizontal blanking. I suspect that the values in
ov8865_modesare wrong.I thought that initially too but confirming that the same thing happened running windows switched me into "you're probably wrong" mode. If we're confident that the HTS is likely wrong though I can add an extra patch to bring those into lining with that definition.
Quoted 5 lines
I think it's worth investigating this. The hblank computed here is clearly incorrect, and would thus be useless for all practical purposes. As usual with OmniVision, the datasheet is also quite useless.
Paul, do you have any information about this ?
A gentle ping on this...I played around setting HTS / VTS values whilst the camera was running windows; and it behaves as you'd expect it to (raising/lowering the frame rate), so as far as I can tell the sensor itself isn't doing anything unusual...
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/i2c/ov8865.c +6
-0+ ctrls->hblank =v4l2_ctrl_new_std (handler, ops,V4L2_CID_HBLANK , hblank, + hblank,1 , hblank); + +if (ctrls->hblank) + ctrls->hblank->flags |=V4L2_CTRL_FLAG_READ_ONLY ; + vblank_max =OV8865_TIMING_MAX_VTS - mode->output_size_y; vblank_def = mode->vts - mode->output_size_y; ctrls->vblank = v4l2_ctrl_new_std(handler, ops, V4L2_CID_VBLANK,
Re: [PATCH v2 08/12] media: i2c: Add hblank control to ov8865
Hello all
Quoted 34 lines · Daniel Scally
Hi Paul
Quoted 31 lines · Laurent Pinchart
Hi Daniel,
Quoted 17 lines · Daniel Scally
Quoted 16 lines · Laurent Pinchart
Quoted 15 lines · Daniel Scally
Quoted 8 lines · Sakari Ailus
Review static int ov8865_ctrls_init(struct ov8865_sensor *sensor) · line 2547
Quoted 5 lines · Daniel Scally
(quoted diff) +1
-0@@ -2542,6 +2544,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) 0, 0, ov8865_test_pattern_menu); /* Blanking */ + hblank = mode->hts < mode->output_size_x ? 0 : mode->hts - mode->output_size_x;Is the result in relation with the analogue crop size? Based on the above it wouldn't seem like that.
This was a weird one actually. My understanding was that HTS should always be >= the horizontal crop plus hblank...but that doesn't hold true for some of this driver's modes and nor does it hold true when running the camera in Windows (I checked the registers whilst running it). So I went with setting hblank to 0 if the mode's HTS exceeded the horizontal crop as the only way I could see to reconcile that.
Quoted 7 lines
Quoted 3 lines
There's something very fishy here, HTS is, by definition, equal to the analog crop width plus the horizontal blanking. I suspect that the values in
ov8865_modesare wrong.I thought that initially too but confirming that the same thing happened running windows switched me into "you're probably wrong" mode. If we're confident that the HTS is likely wrong though I can add an extra patch to bring those into lining with that definition.
I think it's worth investigating this. The hblank computed here is clearly incorrect, and would thus be useless for all practical purposes. As usual with OmniVision, the datasheet is also quite useless.
Quoted 6 lines
Quoted 1 line
Paul, do you have any information about this ?
A gentle ping on this...I played around setting HTS / VTS values whilst the camera was running windows; and it behaves as you'd expect it to (raising/lowering the frame rate), so as far as I can tell the sensor itself isn't doing anything unusual...
So, looking at this again. The mode in question has:
.output_size_x = 3264
.hts = 1944
.output_size_y = 2448
.vts = 2470
.frame_interval = { 1, 30 }
And the driver sets a link frequency of 360MHz. That makes the pixel rate, depending on whether we're looking at 2 or 4 data lanes, either 144MHz or 288MHz. I think the HTS there is calculated so that the 2 lane configuration can make 30 FPS. Perhaps it would be better to default in the mode to the "ideal" 4-lane 30fps setting (by upping the .hts to 3888), but rather than hardcoding the frame interval there, calculate it for .g_frame_interval() based on the number of data lanes found in the bus (accepting that if we only have 2 it's going to be 15fps rather than 30, which doesn't seem unreasonable for that resolution)
PATCH v2 9/12 media: i2c: cap exposure at height + vblank in ov8865
In reply to Daniel ScallyExposure limits depend on the total height; when vblank is altered (and thus the total height is altered), change the exposure limits to reflect the new cap.
---
Changes in v2:
- None
drivers/media/i2c/ov8865.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/media/i2c/ov8865.c +22 -2
@@ -675,6 +675,7 @@ struct ov8865_ctrls {struct v4l2_ctrl *pixel_rate;struct v4l2_ctrl *hblank;struct v4l2_ctrl *vblank; +struct v4l2_ctrl *exposure;struct v4l2_ctrl_handler handler; };
@@ -2461,6 +2462,18 @@ static int ov8865_s_ctrl(struct v4l2_ctrl *ctrl)unsigned int index;int ret; +/* If VBLANK is altered we need to update exposure to compensate */ +if (ctrl->id ==V4L2_CID_VBLANK ) { +int exposure_max; + + exposure_max = sensor->state.mode->output_size_y + ctrl->val; +__v4l2_ctrl_modify_range (sensor->ctrls.exposure, + sensor->ctrls.exposure->minimum, + exposure_max, + sensor->ctrls.exposure->step, +min (sensor->ctrls.exposure->val, exposure_max)); + } +/* Wait for the sensor to be on before setting controls. */ if (pm_runtime_suspended (sensor->dev))return 0 ;
@@ -2517,8 +2530,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)/* Exposure */ -v4l2_ctrl_new_std (handler, ops,V4L2_CID_EXPOSURE ,16 ,1048575 ,16 , -512 ); + ctrls->exposure =v4l2_ctrl_new_std (handler, ops,V4L2_CID_EXPOSURE ,16 , +1048575 ,16 ,512 );/* Gain */
@@ -2699,6 +2712,7 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev,u32 mbus_code =0 ;unsigned int hblank;unsigned int index; +int exposure_max;int ret =0 ;mutex_lock (&sensor->mutex);
@@ -2746,6 +2760,12 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev,__v4l2_ctrl_modify_range (sensor->ctrls.hblank, hblank, hblank,1 , hblank); + exposure_max = mode->vts; +__v4l2_ctrl_modify_range (sensor->ctrls.exposure, + sensor->ctrls.exposure->minimum, exposure_max, + sensor->ctrls.exposure->step, +min (sensor->ctrls.exposure->val, exposure_max)); + complete:mutex_unlock (&sensor->mutex);
Signature · 1 line
2.25.1
Sakari Ailus
maintainerRe: [PATCH v2 09/12] media: i2c: cap exposure at height + vblank in ov8865
Hi Daniel,
Quoted 64 lines · Daniel Scally
Exposure limits depend on the total height; when vblank is altered (and thus the total height is altered), change the exposure limits to reflect the new cap.
Signed-off-by Daniel Scally <[email protected]>---
Changes in v2:- None
drivers/media/i2c/ov8865.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)drivers/media/i2c/ov8865.c +16
-2@@ -675,6 +675,7 @@ struct ov8865_ctrls {struct v4l2_ctrl *pixel_rate;struct v4l2_ctrl *hblank;struct v4l2_ctrl *vblank; +struct v4l2_ctrl *exposure;struct v4l2_ctrl_handler handler; };@@ -2461,6 +2462,18 @@ static int ov8865_s_ctrl(struct v4l2_ctrl *ctrl)unsigned int index;int ret; +/* If VBLANK is altered we need to update exposure to compensate */ +if (ctrl->id ==V4L2_CID_VBLANK ) { +int exposure_max; + + exposure_max = sensor->state.mode->output_size_y + ctrl->val; +__v4l2_ctrl_modify_range (sensor->ctrls.exposure, + sensor->ctrls.exposure->minimum, + exposure_max, + sensor->ctrls.exposure->step, +min (sensor->ctrls.exposure->val, exposure_max)); + } +/* Wait for the sensor to be on before setting controls. */ if (pm_runtime_suspended (sensor->dev))return 0 ;@@ -2517,8 +2530,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)/* Exposure */ -v4l2_ctrl_new_std (handler, ops,V4L2_CID_EXPOSURE ,16 ,1048575 ,16 , -512 ); + ctrls->exposure =v4l2_ctrl_new_std (handler, ops,V4L2_CID_EXPOSURE ,16 , +1048575 ,16 ,512 );/* Gain */ @@ -2699,6 +2712,7 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev,u32 mbus_code =0 ;unsigned int hblank;unsigned int index; +int exposure_max;int ret =0 ;mutex_lock (&sensor->mutex);
drivers/media/i2c/ov8865.c static int ov8865_set_fmt(struct v4l2_subdev *subdev, · line 2767
Quoted 8 lines
drivers/media/i2c/ov8865.c +5
-0@@ -2746,6 +2760,12 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev,__v4l2_ctrl_modify_range (sensor->ctrls.hblank, hblank, hblank,1 , hblank); + exposure_max = mode->vts; +__v4l2_ctrl_modify_range (sensor->ctrls.exposure, + sensor->ctrls.exposure->minimum, exposure_max, + sensor->ctrls.exposure->step, +min (sensor->ctrls.exposure->val, exposure_max));
Please wrap lines over 80 (unless there's a sound reason not to).
Quoted 4 lines
drivers/media/i2c/ov8865.c +1
-0+ complete:mutex_unlock (&sensor->mutex);
Signature · 1 line
Sakari Ailus
PATCH v2 10/12 media: i2c: Add controls from fwnode to ov8865
In reply to Daniel ScallyAdd V4L2_CID_CAMERA_ORIENTATION and V4L2_CID_CAMERA_SENSOR_ROTATION controls to the ov8865 driver by attempting to parse them from firmware.
---
Changes in v2:
- None
drivers/media/i2c/ov8865.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/media/i2c/ov8865.c +10 -0
@@ -2519,6 +2519,7 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)struct v4l2_ctrl_handler *handler = &ctrls->handler;const struct v4l2_ctrl_ops *ops = &ov8865_ctrl_ops;const struct ov8865_mode *mode = sensor->state.mode; +struct v4l2_fwnode_device_properties props;unsigned int vblank_max, vblank_def;unsigned int hblank;int ret;
@@ -2581,6 +2582,15 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)v4l2_ctrl_new_std (handler,NULL ,V4L2_CID_PIXEL_RATE ,1 ,INT_MAX ,1 ,1 ); +/* set properties from fwnode (e.g. rotation, orientation) */ + ret =v4l2_fwnode_device_parse (sensor->dev, &props); +if (ret) + goto error_ctrls; + + ret =v4l2_ctrl_new_fwnode_properties (handler, ops, &props); +if (ret) + goto error_ctrls; +if (handler->error) { ret = handler->error; goto error_ctrls;
Signature · 1 line
2.25.1
PATCH v2 11/12 media: i2c: Switch exposure control unit to lines
In reply to Daniel ScallyThe ov8865 driver currently has the unit of the V4L2_CID_EXPOSURE control as 1/16th of a line. This is what the sensor expects, but isn't very intuitive. Switch the control to be in units of a line and simply do the 16x multiplication before passing the value to the sensor.
The datasheet for this sensor gives minimum exposure as 2 lines, so take the opportunity to correct the lower bounds of the control.
---
Changes in v2:
- None
drivers/media/i2c/ov8865.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/i2c/ov8865.c +5 -2
@@ -2132,6 +2132,9 @@ static int ov8865_exposure_configure(struct ov8865_sensor *sensor, u32 exposure) {int ret; +/* The sensor stores exposure in units of 1/16th of a line */ + exposure *=16 ; + ret =ov8865_write (sensor,OV8865_EXPOSURE_CTRL_HH_REG ,OV8865_EXPOSURE_CTRL_HH (exposure));if (ret)
@@ -2531,8 +2534,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)/* Exposure */ - ctrls->exposure =v4l2_ctrl_new_std (handler, ops,V4L2_CID_EXPOSURE ,16 , -1048575 ,16 ,512 ); + ctrls->exposure =v4l2_ctrl_new_std (handler, ops,V4L2_CID_EXPOSURE ,2 , +65535 ,1 ,32 );/* Gain */
Signature · 1 line
2.25.1
PATCH v2 12/12 media: ipu3-cio2: Add INT347A to cio2-bridge
In reply to Daniel ScallyACPI _HID INT347A represents the OV8865 sensor, the driver for which can support the platforms that the cio2-bridge serves. Add it to the array of supported sensors so the bridge will connect the sensor to the CIO2 device.
---
Changes in V2:
- Ordered the list by ACPI _HID (Andy)
drivers/media/pci/intel/ipu3/cio2-bridge.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/pci/intel/ipu3/cio2-bridge.c +2 -0
@@ -22,6 +22,8 @@static const struct cio2_sensor_config cio2_supported_sensors[] = {/* Omnivision OV5693 */ CIO2_SENSOR_CONFIG ("INT33BE" ,0 ), +/* Omnivision OV8865 */ +CIO2_SENSOR_CONFIG ("INT347A" ,1 ,360000000 ),/* Omnivision OV2680 */ CIO2_SENSOR_CONFIG ("OVTI2680" ,0 ), };
Signature · 1 line
2.25.1
Re: [PATCH v2 12/12] media: ipu3-cio2: Add INT347A to cio2-bridge
Quoted 5 lines · Daniel Scally
ACPI
_HIDINT347A represents the OV8865 sensor, the driver for which can support the platforms that the cio2-bridge serves. Add it to the array of supported sensors so the bridge will connect the sensor to the CIO2 device.
Quoted 25 lines
Signed-off-by Daniel Scally <[email protected]>---
Changes in V2:- Ordered the list by ACPI
_HID(Andy)drivers/media/pci/intel/ipu3/cio2-bridge.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/pci/intel/ipu3/cio2-bridge.c +2
-1@@ -22,6 +22,8 @@static const struct cio2_sensor_config cio2_supported_sensors[] = {/* Omnivision OV5693 */ CIO2_SENSOR_CONFIG ("INT33BE" ,0 ), +/* Omnivision OV8865 */ +CIO2_SENSOR_CONFIG ("INT347A" ,1 ,360000000 ),/* Omnivision OV2680 */ CIO2_SENSOR_CONFIG ("OVTI2680" ,0 ), }; --2.25.1
Signature · 2 lines
With Best Regards, Andy Shevchenko