Commit 24151655 authored by Martin Kepplinger's avatar Martin Kepplinger
Browse files

hi846: improve start_streaming()

to be more self-contained and only return success if streaming indeed
successfully was turned on at the sensor. It's also the only place
that sets the "streaming" state to 1. This simplifies error handling.

Background to the register reading we're moving up so that enabling
streaming is the last operation:

Reading 0x0034 is purely done for debugging reasons. The register is not
documented in the DS but only mentioned once:

"If 0x0034[2] bit is disabled , Visible pixel width and height is 0."

I've never seen that bit be disabled.
parent cc989acb
Pipeline #67721 passed with stage
in 66 minutes and 4 seconds
......@@ -1079,6 +1079,20 @@ static int hi846_start_streaming(struct hi846 *hi846)
if (ret)
goto out;
/*
* Reading 0x0034 is purely done for debugging reasons: It is not
* documented in the DS but only mentioned once:
* "If 0x0034[2] bit is disabled , Visible pixel width and height is 0."
* So even though that sounds like we won't see anything, we don't
* know more about this, so in that case only inform the user but do
* nothing more.
*/
ret = hi846_read_reg(hi846, 0x0034, &val);
if (ret)
goto out;
if (!(val & BIT(2)))
dev_info(&client->dev, "visible pixel width and height is 0\n");
ret = hi846_write_reg(hi846, HI846_REG_MODE_SELECT,
HI846_MODE_STREAMING);
if (ret) {
......@@ -1088,14 +1102,7 @@ static int hi846_start_streaming(struct hi846 *hi846)
hi846->streaming = 1;
dev_dbg(&client->dev, "%s: STARTED\n", __func__);
ret = hi846_read_reg(hi846, 0x0034, &val);
if (ret)
goto out;
if (!(val & BIT(2)))
dev_info(&client->dev, "visible pixel width and height is 0\n");
dev_dbg(&client->dev, "%s: started streaming successfully\n", __func__);
out:
return ret;
}
......@@ -1223,8 +1230,6 @@ static int __maybe_unused hi846_resume(struct device *dev)
return 0;
error:
hi846_stop_streaming(hi846);
hi846->streaming = 0;
clk_disable_unprepare(hi846->clock);
error_regulator:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment