picamera2 icon indicating copy to clipboard operation
picamera2 copied to clipboard

DRMPreview buffer format should be checked against display capabilities

Open 6by9 opened this issue 9 months ago • 5 comments

https://forums.raspberrypi.com/viewtopic.php?t=385297 and https://github.com/raspberrypi/picamera2/issues/995#issuecomment-2037464190

SPI displays typically only support RG16 or XR24 image formats. drm_preview.py ALWAYS tries creating a DumbFramebuffer of type XB24, which will fail on these displays. It also only uses this buffer when decoding MJPEG.

Can we get the supported image formats from DRM device and ask for that format?

6by9 avatar Mar 20 '25 15:03 6by9

Just chiming in... let me know if there's anything I can do to help test.

rbrian avatar Mar 20 '25 15:03 rbrian

Anyone know how you would find out what formats are supported? Once I have a card object, am I looking at connectors, crtcs, encoders, planes, properties... or something else? (I know nothing about DRM/KMS)

davidplowman avatar Mar 24 '25 14:03 davidplowman

You're looking for planes.

kmsprint will tell you the full list of formats supported for any currently active planes, which for VC4 will be a list of about 35 formats.

For simpler devices, it'll be fat fewer, eg RP1 DSI/DPI/VEC support:

  • 32bpp XR24, XB24, AR24, AB24
  • 24bpp RG24, BG24
  • 16bpp RG16.

SPI devices is often only RG16 (16bpp) or XR24 (32bpp).

Assuming that we are using the kmsxx Python files, then kmsxx gives you get_formats on a Plane - https://github.com/tomba/kmsxx/blob/master/kms%2B%2B/inc/kms%2B%2B/plane.h#L28 That appears to be called from the Python side at https://github.com/tomba/kmsxx/blob/master/py/pykms/pykmsbase.cpp#L112, so hopefully that is accessible to picamera2.

6by9 avatar Mar 24 '25 15:03 6by9

OK, I see lots of planes each with lots of formats. Presumably I'm looking for the XR24 or XB24 format in the list of formats, but is there a particular plane I should be using?

davidplowman avatar Mar 24 '25 16:03 davidplowman

Technically you should be looking at the formats supported on the plane you're going to use (either primary or overlay).

However on vc4 all planes are equal, so the formats supported on the first one will be common to all. Same will be true on RP1 or SPI displays in that there will only be one (primary) plane present.

6by9 avatar Mar 24 '25 16:03 6by9