@@ -391,6 +391,7 @@ struct mt9m114 {
unsigned int pixrate;
bool streaming;
+ bool config_change_pending;
/* Pixel Array */
struct {
@@ -776,14 +777,7 @@ static int mt9m114_initialize(struct mt9m114 *sensor)
if (ret < 0)
return ret;
- ret = mt9m114_set_state(sensor, MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE);
- if (ret < 0)
- return ret;
-
- ret = mt9m114_set_state(sensor, MT9M114_SYS_STATE_ENTER_SUSPEND);
- if (ret < 0)
- return ret;
-
+ sensor->config_change_pending = true;
return 0;
}
@@ -958,6 +952,7 @@ static int mt9m114_start_streaming(struct mt9m114 *sensor,
if (ret)
goto error;
+ sensor->config_change_pending = false;
sensor->streaming = true;
return 0;
@@ -2251,6 +2246,14 @@ static int __maybe_unused mt9m114_runtime_suspend(struct device *dev)
struct v4l2_subdev *sd = dev_get_drvdata(dev);
struct mt9m114 *sensor = ifp_to_mt9m114(sd);
+ if (sensor->config_change_pending) {
+ /* mt9m114_set_state() prints errors itself, no need to check */
+ mt9m114_set_state(sensor,
+ MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE);
+ mt9m114_set_state(sensor,
+ MT9M114_SYS_STATE_ENTER_SUSPEND);
+ }
+
mt9m114_power_off(sensor);
return 0;
Drop the start-, stop-streaming sequence from initialize. When streaming is started with a runtime-suspended sensor, mt9m114_start_streaming() will runtime-resume the sensor which calls mt9m114_initialize() immediately followed by calling mt9m114_set_state(ENTER_CONFIG_CHANGE). This results in the following state changes in quick succession: mt9m114_set_state(ENTER_CONFIG_CHANGE) -> transitions to STREAMING mt9m114_set_state(ENTER_SUSPEND) -> transitions to SUSPENDED mt9m114_set_state(ENTER_CONFIG_CHANGE) -> transitions to STREAMING these quick state changes confuses the CSI receiver on atomisp devices causing streaming to not work. Drop the state changes from mt9m114_initialize() so that only a single mt9m114_set_state(ENTER_CONFIG_CHANGE) call is made when streaming is started with a runtime-suspend sensor. This means that the sensor may have config changes pending when mt9m114_runtime_suspend() gets called the first time after mt9m114_probe(), when streaming was not started within the 1 second runtime-pm timeout. Keep track of this and do the ENTER_CONFIG_CHANGE + ENTER suspend from mt9m114_runtime_suspend() if necessary. Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- drivers/media/i2c/mt9m114.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)