media: i2c: alvium: Accelerated alvium_set_power
Subsystems (2)
PATCH 1/1 media: i2c: alvium: Accelerated alvium_set_power
From: Martin Hecht <[email protected]>
Now alvium_set_power tests if Alvium is up and running already instead of waiting for the period of a full reboot. This safes about 7 seconds delay for each connected and already booted camera especially when using multiple Alvium cameras.
--- drivers/media/i2c/alvium-csi2.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/media/i2c/alvium-csi2.c +19 -2
@@ -2367,6 +2367,9 @@ static int alvium_get_dt_data(struct alvium_dev *alvium)static int alvium_set_power (struct alvium_dev *alvium,bool on) {int ret; +int alvium_boot_time_timout =7000 ; +const int alvium_poll_interval =500 ; +u64 val =0 ;if (!on)return regulator_disable (alvium->reg_vcc);
@@ -2375,8 +2378,22 @@ static int alvium_set_power(struct alvium_dev *alvium, bool on)if (ret)return ret; -/* alvium boot time 7s */ -msleep (7000 ); +/* alvium boot time is less than 7s, but eventually it's already on */ +do { +alvium_read (alvium,REG_BCRM_HEARTBEAT_RW , &val, &ret); +if (ret >=0 ) +break ; + +msleep (alvium_poll_interval); + alvium_boot_time_timout -= alvium_poll_interval; + }while (alvium_boot_time_timout >0 ); + +if (ret <0 ) +return ret; + +if (alvium_boot_time_timout <=0 ) +return -ETIMEDOUT ; +return 0 ; }
Signature · 1 line
2.43.0
Hi Martin,
Thanks for the patch.
Quoted 31 lines · On Tue, May 13, 2025 at 04:10:20PM +0200, [email protected] wrote:
From: Martin Hecht <[email protected]>
Now
alvium_set_powertests if Alvium is up and running already instead of waiting for the period of a full reboot. This safes about 7 seconds delay for each connected and already booted camera especially when using multiple Alvium cameras.Signed-off-by Martin Hecht <[email protected]>--- drivers/media/i2c/alvium-csi2.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)drivers/media/i2c/alvium-csi2.c +3
-1@@ -2367,6 +2367,9 @@ static int alvium_get_dt_data(struct alvium_dev *alvium)static int alvium_set_power (struct alvium_dev *alvium,bool on) {int ret; +int alvium_boot_time_timout =7000 ; +const int alvium_poll_interval =500 ; +u64 val =0 ;if (!on)return regulator_disable (alvium->reg_vcc);@@ -2375,8 +2378,22 @@ static int alvium_set_power(struct alvium_dev *alvium, bool on)if (ret)return ret; -/* alvium boot time 7s */
drivers/media/i2c/alvium-csi2.c static int alvium_set_power(struct alvium_dev *alvium, bool on) · line 2389
Quoted 10 lines
drivers/media/i2c/alvium-csi2.c +9
-1-msleep (7000 ); +/* alvium boot time is less than 7s, but eventually it's already on */ +do { +alvium_read (alvium,REG_BCRM_HEARTBEAT_RW , &val, &ret); +if (ret >=0 ) +break ; + +msleep (alvium_poll_interval); + alvium_boot_time_timout -= alvium_poll_interval; + }while (alvium_boot_time_timout >0 );
Please use read_poll_timeout() for this.
Quoted 10 lines
drivers/media/i2c/alvium-csi2.c +7
-0+ +if (ret <0 ) +return ret; + +if (alvium_boot_time_timout <=0 ) +return -ETIMEDOUT ; +return 0 ; }
Signature · 3 lines
Regards, Sakari Ailus