astefanutti / kms-glsl

CLI that runs OpenGL fragment shaders using the DRM/KMS Linux kernel subsystem
https://ttt.io/glsl-raspberry-pi
MIT License
87 stars 14 forks source link

Composite video on Pi4? #7

Closed veneering closed 1 year ago

veneering commented 1 year ago

Sorry if this is a naive question, but I get the error “failed to initialize legacy DRM” when I try running the program through composite. I can get the program to run on HDMI with the modifier “-d /dev/dri/card1” and without, it returns “unable to get DRM resources”. Enabling/disabling vc4-kms-v3d also doesn’t change anything for composite. I’m guessing there is some difference in how the composite video is processed that makes this impossible because I can’t find a program that can do that on Pi4. the goal is to make a shader player that I can manipulate for live visuals and use in an analog setup.

Thanks for your contributions to make OpenGL more usable for the Pi :)

astefanutti commented 1 year ago

I'm not familiar with composite output on the RPi 4. Are you using the 3.5mm jack to output video? Could you please provide your /boot/config.txt, and also the output of ls /sys/class/drm?

I wonder whether / how this kind of output is supported by KMS / DRM.

I've stumbled upon a couple of discussions that mentions it:

But I would need to dig into it.

veneering commented 1 year ago

I tried every combination with kms, fkms, and vc4-kms-v3d-pi4, and without any of them in dtoverlay and none work. I'm wondering if this is something that can be solved with a different kernel? I really have no idea...

Here's my config.txt and the files in /sys/class/drm config.txt Capture

astefanutti commented 1 year ago

I tried every combination with kms, fkms, and vc4-kms-v3d-pi4, and without any of them in dtoverlay and none work. I'm wondering if this is something that can be solved with a different kernel? I really have no idea...

Right, probably worth trying with the most recent kernel version, if not already.

Here's my config.txt and the files in /sys/class/drm config.txt Capture

The config looks good. The key would be to understand if/how the composite output materialises as a DRM connector...

veneering commented 1 year ago

Got this to work on a fresh flash with dtoverlay=vc4-fkms-v3d,composite. I could’ve sworn I tried that before. I tried recreating the issue by changing other parameters but it seems like the only thing that reproduces the “failed to initialize legacy DRM” is when I use “vc4-kms-v3d”. Thanks for the help. Now to try to use i2c to pass potentiometer inputs as uniforms to the shaders…

astefanutti commented 1 year ago

Got this to work on a fresh flash with dtoverlay=vc4-fkms-v3d,composite. I could’ve sworn I tried that before. I tried recreating the issue by changing other parameters but it seems like the only thing that reproduces the “failed to initialize legacy DRM” is when I use “vc4-kms-v3d”.

Thanks for the feedback, glad to hear it works! Out of curiosity, what DRM device is used in that case?

Thanks for the help. Now to try to use i2c to pass potentiometer inputs as uniforms to the shaders…

Adding inputs is something I really want to add, but I still need to research what could be the best approach(es). I'd be very interested to hear from your work!