Closed ArtemKorr closed 6 months ago
Hi, thanks for the report. I don't have the right hardware to do any work on this, but am happy to do my best to help if we can establish what it is that needs fixing. Can I assume you have checked out the latest version of Picamera2, and have added your local version to your PYTHONPATH?
If you run the most basic example
from picamera2 import Picamera2
picam2 = Picamera2()
picam2.start(show_preview=True)
can you say exactly where it is going wrong, and what the immediate cause of the error is? Thanks!
Hello. thanks for the answer. I use picamera2 0.3.16 I tried the most basic example that you sent me and got this
It is important that this does not work only if you combine the output. For example, if I take an HDMI converter then RCA, then since Linux works with HDMI for DRM output, then there are no problems
If I try to call the same code by connecting the keyboard (before this I ran the code via ssh), then looking at the analog screen. then I get the same thing. Most likely it doesn’t matter, but just for fun I wanted to try it
Presumably your application is using one of the 32bpp "XRGB8888"
type of output formats, which would translate into something like pykms.PixelFormat.XRGB8888
, and this is being rejected. Do you know what kind of pixel format this display will accept, one of the 24bpp ones perhaps?
Also https://github.com/raspberrypi/rpicam-apps/blob/70894c0c46855955442284aba9dedb66d8d4bfbf/preview/drm_preview.cpp#L90 I also tried to run this code in C++ but I get “No suitable enabled connector found” due to the fact that count_connectors turns out to be empty
Presumably your application is using one of the 32bpp
"XRGB8888"
type of output formats, which would translate into something likepykms.PixelFormat.XRGB8888
, and this is being rejected. Do you know what kind of pixel format this display will accept, one of the 24bpp ones perhaps?
Well, this display works with what the analog output gives it. in this case pal.
I run kmsprint and here output
OK, this is totally beyond my understanding (I know basically nothing about DRM or KMS). @6by9 Does any of this mean anything to you?
We previously talked about this and this is what he wrote to me. https://github.com/raspberrypi/linux/issues/5948#issuecomment-1942096270
I tried changing the format in drm_preview.py from AB24 to XB24, but still failed
OK, this is totally beyond my understanding (I know basically nothing about DRM or KMS). @6by9 Does any of this mean anything to you?
As discussed previously, Picamera2 (and rpicam-apps) are assuming they're running against vc4 as the DRM renderer, and hence have a wide choice of formats, scaling, and planes.
RP1 for DSI, DPI, and VEC (and also most SPI displays) only have a single primary plane, and only support XRGB8888, XBGR8888, RGB888, BGR888, and RGB565 formats. Asking for any other format or requiring an overlay plane will fail.
Picamera2 and rpicam-apps need to fall back to using the primary plane in the absence of a suitable overlay plane, and ensure that their pixel format choice is supported by the DRM device.
Thanks for that!
@ArtemKorr Sounds like either of the 24bpp or 32bpp formats should work then. Do you you want to try replacing reserve_overlay_plane
(the line where it falls over), with reserve_plane
. Also, just a few lines below that, delete the half dozen or so lines that refer to overlay_plane
. Lets see if that works.
Ok, if I understood you correctly, I tried to make the changes you say. I attached the file in a zip archive. now that line has passed, but it breaks below
also I use type Primary
here
self.plane = self.resman.reserve_plane(crtc=self.crtc,type= pykms.PlaneType.Primary,format=fmt)
It 's only one combination which worked
Hmm, so it seems to be failing to create a pykms.DmabufFramebuffer
. I assume you've tried a different format or two. Perhaps this kind of display doesn't support dmabufs? It would be nice if there was a way to know that. Maybe we need to allocate a pykms.DumbFramebuffer
instead and copy the image into that (though it will involve lots of pixel copying...)?
@6by9 Does the above sound plausible, do you think?
It should be happy to import a dmabuf. RP1 has an iommu, so should be able to import any buffer. Is the buffer the same geometry as the display? DSI has no scaler, so it needs to be full screen and 1:1.
If we have a simple way to reproduce this, then I can have a look and see why DRM is unhappy.
OK, that's interesting. I don't have any means of reproducing this behaviour, unfortunately. @ArtemKorr Can you check your image dimensions match the display exactly?
The previous time I tried it didn’t match. The image is 1280 x 720, I took it from the camera. And the display is 704/432, respectively.
OK. When I set the photo size to be the same as my display (704*432) I don’t get any errors.. But I don’t see the image on the screen either Can you help, maybe my code that I modified has problems
I guess you're sure that the image actually does contain something? (Perhaps you are able to save it as a JPEG and view it somewhere else?)
This is a live stream from a camera... but the camera is working. shoots, so the images must contain something exactly
Ok I found a bug in myself. I decided to remove the frame size by default. Now everything works thanks for support!
Great glad it's working! I'd like to get these changes packaged into a PR that can be merged into our code base, so that in future this will "just work" for everyone, and you won't need special code edits of your own.
Would you be able to commit your changes and post your tree to a Github fork of Picamera2? Then I can tidy them up a bit and make sure I haven't broken anything else. Then I'll create a PR which can be merged. I'd be extremely grateful if you'd have a moment to test that PR before I finally merge it. Would that be OK? Thanks very much for your help with this issue.
Of course I can. But everything I did was commented out as you told me. As I understand it, the overlay needs to be removed completely because it cannot be supported in such formats (AR24 and other). And I don’t quite understand what the preview file should be called. Like preview_composite_pi5? . Just on Rpi4, when I tried it, because of the fkms, everything worked and the overlay beat.
Well, I'll make up a PR in the next day or so, and maybe you could give it a try just to check that I've fixed your issue correctly. That would be great!
FKMS is deprecated.
vc4-kms-v3d when rendering through vc4 (the composition hardware for HDMI, DSI, DPI, and VEC on Pi0-4, and for HDMI on Pi5) allows lots of options that currently picamera2 assumes are present.
With the RP1 outputs, or with other random DRM drivers (eg SPI displays, DisplayLink USB devices, etc), those features aren't available. Picamera2 needs to handle these situations properly.
It also really wants a mechanism for passing in dev_path
when creating the card, so you can choose which display device to render to (https://github.com/tomba/pykms/blob/master/kms/card.py#L24)
Largely the PR is to make sure that nothing gets missed out from what works for you. I'm trying to get it working on an SPI display at present, but with limited success.
I've succeeded in getting picamera2 to render to an SPI display (yes the refresh rate sucks!), but it does require jumping through a few hoops in the configuration as well as fixing up drm_preview. Changes pushed to #1000
I still had to configure things manually in my stream config. It feels like at least the pixel format should be extracted from the preview renderer.
from picamera2 import Picamera2, Preview
picam2 = Picamera2()
picam2.start_preview(Preview.DRM, width=480, height=320)
preview_config = picam2.create_preview_configuration({"format": "XRGB8888","size": (480, 320)})
picam2.configure(preview_config)
picam2.start()
Please only report one bug per issue! I'm attempting to display the output of the Picamera2 on a DRM (Direct Rendering Manager) preview window and then output it to analog video. However, when I launch the application, I encounter the following error: I previously inquired about this issue in the repository responsible for the kernel. https://github.com/raspberrypi/linux/issues/5948#issuecomment-1941545899
Could you advise on how to resolve this issue and what I might be doing wrong in this scenario? Describe the bug I'm having trouble seeing the DRM (Direct Rendering Manager) preview on an RPI5 when using the composite video output. Hardware : I'm using Raspberry Pi 5 Console Output, Screenshots If applicable, any console output or screenshots that show the problem and associated error messages.
Additional context
uname -a `Linux raspberrypi 6.6.22-v8-16k+ #1747 SMP PREEMPT Wed Mar 27 17:06:56 GMT 2024 aarch64 GNU/Linux vcgencmd version