Skip to content

drivers: video: hm01b0 and hm0360: How to handle data bus 1,4 or 8 bits #98112

@KurtE

Description

@KurtE

Summary

As I mentioned earlier in the two PRs to add the hm01b0 #94894 and hm0360 camera #94904.

Suppose I configure in the device tree to use an hm01b0 camera at resolution 324x324 to use the 8 bit
8 bit Grey format.

How many bytes will the drivers such as video_stm32_dcmi.c see from the camera per frame.

Sorry trick question: It depends on the HM01b0 property: data-bits, which can be 1, 4, or 8.

if set to 8, the answer is as expected: 324x324x1=104976 bytes

However if it is set to 4, which is needed to support the HM01b0 cameras sold by Arduino and
Arducam for the Arduino GIGA and the others with the 20 pin connector the actual number of bytes
returned from the camera is: 324x324x2=209952 bytes

And if you use the default value of 1, which I believe is used by the RPI Pico it is 324*324*8=839808 bytes

Currently the hardware like the DCMI on some of the STM32 boards has no knowledge of this camera
setting and for example if one uses the current default val frame of data. And each of these bytes will only have 1 actual
data bit contained in them.

Question is, How does DCMI (or other such hardware) discover how many data bits per pixel clock will be
returned by a camera? And how should this be handled?

For example on the video_stm32_dcmi code, what should it know about this? There are different options:
a) The code that determines the sizes of buffers needed, would find this information out and increase the
buffer size. The hardware code simply returns the data as returned by the camera and it is up to the
app code to deal with it.

b) Again the code somehow detects we are in one of these modes, and knows to receive the full buffer size
When the code like video_stm32_dcmi receives the buffer, and it currently memcpy it to another buffer
it could instead, compress back to 8 bits of data per byte. Note: This might imply that the camera buffer
might be a different size than the ones the applications use.

c) Some hardware drivers can handle 1 or 4 bits per pixel clock, and they simply need to have their setting
configured for it. like the RPI Pico code. Also some of the IMXRT code using FlexIO could be configured.

But in all of these cases, the first question is, how do the Hardware Video bus drivers know that the camera
is not returning 8 bits of data per clock?

Describe the solution you'd like

Not sure:
First part probably need a standard way to determine how many bits of data is returned by the camera
per pixel clock.

Then need to know if this can be handled transparently between the camera and the bus driver.
And then decide what to do with buffer sizes and who does the work to compress the data back.

Alternatives

Earlier when I was testing #94894 on an Arduino GIGA and Portenta H7, I hacked it up by adding a new pixel format:
VIDEO_PIX_FMT_GREY_4

Where if the app asked for it, the code to compute buffer sizes would say that it is 16 bits, which would compute
a buffer large enough and then the test sketch would rebuild the data.

Additional Context

No response

Metadata

Metadata

Labels

EnhancementChanges/Updates/Additions to existing featuresarea: VideoVideo subsystem

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions