Hi,
Changes in v5:
- Fixed issues reported by dt_binding_check
- Use /schemas/graph.yaml#/$defs/port-base instead of
/schemas/graph.yaml#/properties/port since we have additional
endpoint properties
- Update commit message
Changes in v4:
- Add two missing BIT macro conversions
- Switch to dt-bindings yaml schema before applying changes
- Drop explicit pclk-sample property documentation patch since it is
documented in the referenced video-interface schema now. (I hope that
is correct)
Changes in v3:
- Dropped 1/5 media: mt9p031: Add support for 8 bit and 10 bit formats
- Dropped 3/5 media: mt9p031: Implement [gs]_register debug calls
- Added reviewed-by from Laurent Pinchart to
media: mt9p031: Read back the real clock rate
- Dropped unnecessary register reads in
media: mt9p031: Fix corrupted frame after restarting
- Changed sorting of register bits from MSB to LSB
- Added patch to switch to BIT macro
- Added two additional dt-bindings patches to add missing properties
documentation
Christian Hemp (2):
media: mt9p031: Make pixel clock polarity configurable by DT
media: mt9p031: Add support for 8 bit and 10 bit formats
Dirk Bender (1):
media: mt9p031: Fix corrupted frame after restarting stream
Stefan Riedmueller (3):
media: mt9p031: Use BIT macro
media: dt-bindings: mt9p031: Convert bindings to yaml
media: dt-bindings: mt9p031: Add missing required properties
.../bindings/media/i2c/aptina,mt9p031.yaml | 97 ++++++++++++++
.../devicetree/bindings/media/i2c/mt9p031.txt | 40 ------
MAINTAINERS | 1 +
drivers/media/i2c/Kconfig | 1 +
drivers/media/i2c/mt9p031.c | 121 ++++++++++++++----
include/media/i2c/mt9p031.h | 1 +
6 files changed, 196 insertions(+), 65 deletions(-)
create mode 100644 Documentation/devicetree/bindings/media/i2c/aptina,mt9p031.yaml
delete mode 100644 Documentation/devicetree/bindings/media/i2c/mt9p031.txt
--
2.25.1
From: Dirk Bender <[email protected]>
To prevent corrupted frames after starting and stopping the sensor its
datasheet specifies a specific pause sequence to follow:
Stopping:
Set Pause_Restart Bit -> Set Restart Bit -> Set Chip_Enable Off
Restarting:
Set Chip_Enable On -> Clear Pause_Restart Bit
The Restart Bit is cleared automatically and must not be cleared
manually as this would cause undefined behavior.
Signed-off-by: Dirk Bender <[email protected]>
Signed-off-by: Stefan Riedmueller <[email protected]>
---
drivers/media/i2c/mt9p031.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index ea90aff576ba..ee2777059682 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -79,7 +79,9 @@
#define MT9P031_PIXEL_CLOCK_INVERT (1 << 15)
#define MT9P031_PIXEL_CLOCK_SHIFT(n) ((n) << 8)
#define MT9P031_PIXEL_CLOCK_DIVIDE(n) ((n) << 0)
-#define MT9P031_FRAME_RESTART 0x0b
+#define MT9P031_RESTART 0x0b
+#define MT9P031_FRAME_PAUSE_RESTART (1 << 1)
+#define MT9P031_FRAME_RESTART (1 << 0)
#define MT9P031_SHUTTER_DELAY 0x0c
#define MT9P031_RST 0x0d
#define MT9P031_RST_ENABLE 1
@@ -456,9 +458,23 @@ static int mt9p031_set_params(struct mt9p031 *mt9p031)
static int mt9p031_s_stream(struct v4l2_subdev *subdev, int enable)
{
struct mt9p031 *mt9p031 = to_mt9p031(subdev);
+ struct i2c_client *client = v4l2_get_subdevdata(subdev);
+ int val;
int ret;
if (!enable) {
+ /* enable pause restart */
+ val = MT9P031_FRAME_PAUSE_RESTART;
+ ret = mt9p031_write(client, MT9P031_RESTART, val);
+ if (ret < 0)
+ return ret;
+
+ /* enable restart + keep pause restart set */
+ val |= MT9P031_FRAME_RESTART;
+ ret = mt9p031_write(client, MT9P031_RESTART, val);
+ if (ret < 0)
+ return ret;
+
/* Stop sensor readout */
ret = mt9p031_set_output_control(mt9p031,
MT9P031_OUTPUT_CONTROL_CEN, 0);
@@ -478,6 +494,16 @@ static int mt9p031_s_stream(struct v4l2_subdev *subdev, int enable)
if (ret < 0)
return ret;
+ /*
+ * - clear pause restart
+ * - don't clear restart as clearing restart manually can cause
+ * undefined behavior
+ */
+ val = MT9P031_FRAME_RESTART;
+ ret = mt9p031_write(client, MT9P031_RESTART, val);
+ if (ret < 0)
+ return ret;
+
return mt9p031_pll_enable(mt9p031);
}
--
2.25.1