Message ID | 20240313072516.241106-35-sakari.ailus@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Generic line based metadata support, internal pads | expand |
On 3/13/24 08:25, Sakari Ailus wrote: > With enable_streams and disable_streams, the driver for a device where > streams are not independently started and stopped needs to maintain state > information on streams that have been requested to be started. Do that > now. > > In the future, a helper function in the framework is a desirable way to do > this instead. > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Julien Massot <julien.massot@collabora.com> > --- > drivers/media/i2c/ov2740.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c > index 44c6724a102c..df57f0096e98 100644 > --- a/drivers/media/i2c/ov2740.c > +++ b/drivers/media/i2c/ov2740.c > @@ -539,6 +539,9 @@ struct ov2740 { > > /* True if the device has been identified */ > bool identified; > + > + /* Track streaming state */ > + u8 streaming; > }; > > static inline struct ov2740 *to_ov2740(struct v4l2_subdev *subdev) > @@ -929,6 +932,11 @@ static int ov2740_enable_streams(struct v4l2_subdev *sd, > int link_freq_index; > int ret; > > + if (ov2740->streaming) { > + ov2740->streaming |= streams_mask; > + return 0; > + } > + > ret = pm_runtime_resume_and_get(&client->dev); > if (ret < 0) > return ret; > @@ -975,6 +983,8 @@ static int ov2740_enable_streams(struct v4l2_subdev *sd, > goto out_pm_put; > } > > + ov2740->streaming |= streams_mask; > + > return 0; > > out_pm_put: > @@ -991,6 +1001,10 @@ static int ov2740_disable_streams(struct v4l2_subdev *sd, > struct ov2740 *ov2740 = to_ov2740(sd); > int ret; > > + ov2740->streaming &= ~streams_mask; > + if (ov2740->streaming) > + return 0; > + > ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1, > OV2740_MODE_STANDBY); >
Hi Sakari, Thank you for the patch. On Wed, Mar 13, 2024 at 09:25:12AM +0200, Sakari Ailus wrote: > With enable_streams and disable_streams, the driver for a device where > streams are not independently started and stopped needs to maintain state > information on streams that have been requested to be started. Do that > now. > > In the future, a helper function in the framework is a desirable way to do > this instead. > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> > --- > drivers/media/i2c/ov2740.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c > index 44c6724a102c..df57f0096e98 100644 > --- a/drivers/media/i2c/ov2740.c > +++ b/drivers/media/i2c/ov2740.c > @@ -539,6 +539,9 @@ struct ov2740 { > > /* True if the device has been identified */ > bool identified; > + > + /* Track streaming state */ > + u8 streaming; > }; > > static inline struct ov2740 *to_ov2740(struct v4l2_subdev *subdev) > @@ -929,6 +932,11 @@ static int ov2740_enable_streams(struct v4l2_subdev *sd, > int link_freq_index; > int ret; > > + if (ov2740->streaming) { > + ov2740->streaming |= streams_mask; > + return 0; > + } > + > ret = pm_runtime_resume_and_get(&client->dev); > if (ret < 0) > return ret; > @@ -975,6 +983,8 @@ static int ov2740_enable_streams(struct v4l2_subdev *sd, > goto out_pm_put; > } > > + ov2740->streaming |= streams_mask; > + > return 0; > > out_pm_put: > @@ -991,6 +1001,10 @@ static int ov2740_disable_streams(struct v4l2_subdev *sd, > struct ov2740 *ov2740 = to_ov2740(sd); > int ret; > > + ov2740->streaming &= ~streams_mask; > + if (ov2740->streaming) > + return 0; > + > ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1, > OV2740_MODE_STANDBY); >
diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index 44c6724a102c..df57f0096e98 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -539,6 +539,9 @@ struct ov2740 { /* True if the device has been identified */ bool identified; + + /* Track streaming state */ + u8 streaming; }; static inline struct ov2740 *to_ov2740(struct v4l2_subdev *subdev) @@ -929,6 +932,11 @@ static int ov2740_enable_streams(struct v4l2_subdev *sd, int link_freq_index; int ret; + if (ov2740->streaming) { + ov2740->streaming |= streams_mask; + return 0; + } + ret = pm_runtime_resume_and_get(&client->dev); if (ret < 0) return ret; @@ -975,6 +983,8 @@ static int ov2740_enable_streams(struct v4l2_subdev *sd, goto out_pm_put; } + ov2740->streaming |= streams_mask; + return 0; out_pm_put: @@ -991,6 +1001,10 @@ static int ov2740_disable_streams(struct v4l2_subdev *sd, struct ov2740 *ov2740 = to_ov2740(sd); int ret; + ov2740->streaming &= ~streams_mask; + if (ov2740->streaming) + return 0; + ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1, OV2740_MODE_STANDBY);
With enable_streams and disable_streams, the driver for a device where streams are not independently started and stopped needs to maintain state information on streams that have been requested to be started. Do that now. In the future, a helper function in the framework is a desirable way to do this instead. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/i2c/ov2740.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)