Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi-Config | RPi: Add modern RPi camera module support #5127

Open
isarrider opened this issue Jan 2, 2022 · 36 comments
Open

DietPi-Config | RPi: Add modern RPi camera module support #5127

isarrider opened this issue Jan 2, 2022 · 36 comments

Comments

@isarrider
Copy link

isarrider commented Jan 2, 2022

Hi,

just as a hint for other users,
in my Octoprint as docker container setup,
the webcam only works, if I include
camera_auto_detect=1
in the config.txt on my Pi4

Maybe put it right above the
start_x=1

BR,
Alex

@isarrider isarrider changed the title Include Include camera_auto_detect=1 in config.txt Jan 2, 2022
@MichaIng MichaIng added this to the v8.0 milestone Jan 2, 2022
@MichaIng
Copy link
Owner

MichaIng commented Jan 2, 2022

Many thanks for your report.

Indeed I recognised this. Basically start_x=1 is to enable the legacy firmware based camera features, when the legacy non-GL display driver or fake KMS is used. When full KMS is used camera_auto_detect=1 is the correct way to enable the camera module, making use of generic libcamera and V4L2 libraries, as far as I understand. start_x is then not required.

We can toggle the correct setting based on display driver:

  • When enabling the camera module option, setting camera_auto_detect=1 or start_x=1 based on whether full KMS is used or not.
  • When switching between fake KMS/full KMS/legacy and the camera module is enabled, switch between camera_auto_detect=1 and start_x=1 accordingly.

Just to be sure, can you verify that you have full KMS enabled?

grep 'vc4-.*-v3d' /boot/config.txt

@isarrider
Copy link
Author

it seems my statement wasnt right afterall...
after a reboot - the cam only works with start_x=1,
I had to set #camera_auto_detect=1...
But now the picture also became messed up...
z-rex_21m_0 2mm_240C_PETG aw_20220103104730 mp4_snapshot_00 00 608

@isarrider
Copy link
Author

Ill investigate further...
(also some peops think its related to bullseye: https://issueexplorer.com/issue/raspberrypi/linux/4697)

@isarrider
Copy link
Author

ok, it seems my env variables didnt work out...
situation now is:
start_x=1
#camera_auto_detect=1
(and docker run -d --restart -v octoprint:/octoprint --device /dev/ttyUSB0:/dev/ttyUSB0 --device /dev/video0:/dev/video0 -e ENABLE_MJPG_STREAMER=true -e "MJPG_STREAMER_INPUT=-r 800x600 -f 15 -y" -p 80:80 --name octoprint octoprint/octoprint)
works now...
sry for the confusion...

@MichaIng
Copy link
Owner

MichaIng commented Jan 3, 2022

Can you check with the suggested command whether KMS is enabled or not? As said, as far as I understood, camera_auto_detect=1 works only with full KMS enabled, while start_x=1 works only with legacy or fake KMS driver.

@isarrider
Copy link
Author

grep 'vc4-.*-v3d' /boot/config.txt throw nth out...

@MichaIng
Copy link
Owner

MichaIng commented Jan 3, 2022

Okay, then you do not have KMS enabled and it makes sense that start_x=1 must be used instead of camera_auto_detect=1. You could test to switch:

sed -i 's/^[[:blank:]]*start_x=.*$/#start_x=0/' /boot/config.txt
G_CONFIG_INJECT 'dtoverlay=vc4-f?kms-v3d' 'dtoverlay=vc4-kms-v3d' /boot/config.txt
G_CONFIG_INJECT 'camera_auto_detect=' 'camera_auto_detect=1' /boot/config.txt
reboot

@isarrider
Copy link
Author

doesnt boot anymore after these 4 cmds...

@MichaIng
Copy link
Owner

MichaIng commented Jan 3, 2022

?? Are you sure that it is not just the screen which stays blank for a while? It is basically impossible to break boot with those changes, even invalid entries are gracefully ignored. But when during boot it is switched from framebuffer output to KMS, the screen blanks for a while (some seconds). We also got reports where the monitor stood in energy savings mode for some reason. So check SSH.

@isarrider
Copy link
Author

I am using it always per ssh...

@isarrider
Copy link
Author

changed it back > boots

@MichaIng
Copy link
Owner

MichaIng commented Jan 3, 2022

Mysterious, it is actually impossible that those commands have this effect, even with typos inside. Only if somehow KMS triggers a bit of additional power usage at some boot stage or so.

Ah, if I remember correctly in the one case where the screen stood blank, commenting the gpu_mem_* settings solved it, hence reducing GPU memory back to default. The KMS driver does not use this anymore but the system memory via CMA instead. Not sure how/why increased GPU memory causes this, as long as there is sufficient system memory, but probably it as well has a side effect in your case. Puhh, this makes our implementation more complicated as I'm not sure whether with KMS there is still a reason/use case where increased GPU memory may be needed 🤔.

@isarrider
Copy link
Author

I have set it to 128MB (the GPU mem)
tmr I can do additional tests...

@MichaIng
Copy link
Owner

MichaIng commented Jan 3, 2022

Jep, with start_x=1, 128 MiB is added automatically, also required to cover full legacy camera support, but the new implementation doesn't require it. Since I have no other explanation why the system wouldn't boot, when you find time, would be worth a test.

@isarrider
Copy link
Author

ok, it seems it is somehow related with the Pi4 being powered by the 3D-Printer...
When I power it with an external Powerplug, it comes up...
Ill dig into it a bit more...

@isarrider
Copy link
Author

Ok, it cannot load the webcam with dtoverlay=vc4-kms-v3d
Ill go back to my old "legacy" setup...

@MichaIng MichaIng modified the milestones: v8.0, v8.1 Jan 6, 2022
@MichaIng MichaIng modified the milestones: v8.1, v8.2 Feb 1, 2022
@MichaIng MichaIng changed the title Include camera_auto_detect=1 in config.txt DietPi-Config | RPi: Add modern RPi camera module support Feb 1, 2022
@isarrider
Copy link
Author

@isarrider
Copy link
Author

as info...

@isarrider
Copy link
Author

Ill test on the weekend a bit more...

@isarrider
Copy link
Author

@MichaIng MichaIng added this to the v8.24 milestone Oct 21, 2023
@MichaIng MichaIng modified the milestones: v8.24, v8.25 Nov 19, 2023
@MichaIng MichaIng modified the milestones: v8.25, v9.0 Dec 20, 2023
@MichaIng MichaIng modified the milestones: v9.0, v9.1 Jan 20, 2024
@MichaIng MichaIng modified the milestones: v9.1, v9.2 Feb 20, 2024
@MichaIng MichaIng modified the milestones: v9.2, v9.3 Mar 17, 2024
@MichaIng MichaIng modified the milestones: v9.3, v9.4 Apr 16, 2024
@MichaIng MichaIng modified the milestones: v9.4, v9.5 May 13, 2024
@MichaIng MichaIng modified the milestones: v9.5, v9.6 Jun 10, 2024
@MichaIng MichaIng modified the milestones: v9.6, v9.7 Jul 10, 2024
@MichaIng MichaIng modified the milestones: v9.7, v9.8 Aug 26, 2024
@MichaIng MichaIng modified the milestones: v9.8, v9.9 Oct 18, 2024
@MichaIng MichaIng modified the milestones: v9.9, v9.10 Dec 25, 2024
@MichaIng MichaIng modified the milestones: v9.10, v9.11 Feb 9, 2025
@MichaIng MichaIng modified the milestones: v9.11, v9.12 Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants