raspberrypi / picamera2

New libcamera based python library
BSD 2-Clause "Simplified" License
852 stars 180 forks source link

drm_preview: Updated to allow rendering to RP1 DSI/DPI/VEC, and SPI d… #1000

Closed 6by9 closed 4 months ago

6by9 commented 5 months ago

…isplays

vc4 supports overlay planes, scaling, and numerous pixel formats. RP1 and other DRM devices don't.

Handle falling back to the primary plane if there are no overlay planes. Changing the hard coded format is a bit of a hack. The format should really be found from those supported by the display.

davidplowman commented 5 months ago

Thanks for the PR! We normally target bug fixes at the "next" branch, but I can take care of that when applying it.

@ArtemKorr Are you able to try this branch and confirm that it works for you? Thanks!

davidplowman commented 5 months ago

Another thought... I wonder if set_overlay should check for overlay_plane being None (and then just returning). That way you could run code that uses overlays on other display devices, only you wouldn't get the overlay. Or perhaps it's better if it raises an error, at least you'd know what was happening. But then you might want to know that before you call it. Oh I don't know...!

davidplowman commented 5 months ago

Maybe leave this one with me. I'll check up on some of the questions I had, and take it from there. Thanks!

6by9 commented 5 months ago

Another thought... I wonder if set_overlay should check for overlay_plane being None (and then just returning). That way you could run code that uses overlays on other display devices, only you wouldn't get the overlay. Or perhaps it's better if it raises an error, at least you'd know what was happening. But then you might want to know that before you call it. Oh I don't know...!

Yes it does. I was nobbling the bits that stopped it running, not providing a full fix.

Maybe leave this one with me. I'll check up on some of the questions I had, and take it from there. Thanks!

Ta. It was proof of concept rather than fully polished (I don't do Python if I can help it!)

ArtemKorr commented 5 months ago

Thanks for the PR! We normally target bug fixes at the "next" branch, but I can take care of that when applying it.

@ArtemKorr Are you able to try this branch and confirm that it works for you? Thanks!

Oh yes, I'll be happy to try it one of these days

ArtemKorr commented 5 months ago

@davidplowman Finally, I got around to trying it (I tried the branch 6by9:patch-2 if I understood correctly what changes were meant). It didn't work for me if the frame does not match the screen exactly.. But when I made the image output the same size as the screen (704x432) and XR24, tried it like this,

import time

from picamera2 import Picamera2, Preview

picam2 = Picamera2()
picam2.start_preview(Preview.DRM, x=0, y=0, width=704, height=432)

preview_config = picam2.create_preview_configuration({"size": (704, 432),  "format": "BGR888"})
picam2.configure(preview_config)

picam2.start()
time.sleep(5)
davidplowman commented 5 months ago

@ArtemKorr Thanks for trying that. Yes, I think it's expected that you have to use the right format and image size, but so long as that works I think it's OK (or at least, as good as it will get). I'll post another version of this PR with just a couple of little tidies, and then merge it. Thanks again!

davidplowman commented 4 months ago

I've committed a patch which implements the changes here with a couple of tweaks as discussed. So I'll close this one now. Thanks to everyone for putting together and testing the necessary fixes!