Would be still great if you could the above commands (I replaced the rmmod/modprobe with a reboot), i.e. if those remove the HDMI card from aplay -l in your case.
This is why the dedicated onboard menu entries exist and should work. A cleaner solution would be to have a 2 stage system: First enable/disable audio devices, reboot to apply the change, then select one among the enabled sound devices. But this makes it more complicated, hence for now we have those menu entries which do both. This is a special RPi thing since on other SBCs one cannot disable sound devices like on RPi, including all the USB/HAT device tree overlays.
Just to see what would happen, went in and manually created the file (did not exist) and entered the listed data (Using sudo). Rebooted, saw no differences in the audio problems. speaker-test from the command line give normal expected audio. Cinnamon Speaker app with the rpi builtin audio headphone jack selected gives no audio out when running the speaker test option.
Did some more checking and found that raspian lite and dietpi are both running the same versions of of Linux and Cinnamon.
Decided to build CubicSDR so I could check the audio from my RSP-1A sdr. Good audio on both the raspian and dietpi machines. The Cinnamon sound app shows CubicSDR running on both Raspian and Dietpi. But the Cinnamon sound app on the dietpi machine (actually same computer, just dirfferent SSD’s) will not put out audio on the speaker test option.
So it would appear that something in the bakground files/scripts etc is causing the test problem.
At this point in time I will probably drop this topic as the main reason I was trying to find out what was happening with the Cinnamon sound app was that I needed audio for CubicSDR/RSP-1A. But now that I know CubicSDR audio is good…
Depends on the DietPi and RPi OS Image. Which one you compared? Theoreticlly DietPi using exactly same package source and kernel because DietPi is not an own OS. It’s a set of bash script on top of a Debian base image.
Used the cinnamon system info app tor Linux version & Cinnamon version.
Same versions listed on both “machines” (Different ssd for each OS same computer)
Did the revised script you suggested and got the proper results in /etc/modprobe.
But as I had decided to do a complete fresh reinstall of dietpi and redo the setup steps as I had been making lots of changes to fix various problems and thought there might be something corrupted in the origional dietpi install. It appeared that that was the main problem as after the new run thru of initial setup and dietpi-config I was able to get the audio selection to work properly (at least for the #2 choice (rpi headphone jack)) and with a usb speaker using the hw choice near for the bottom of the list. Went back to the #2 choice and after each reboot (headphone and usb speaker) I had good command line audio using the speaker-test command. Looks like the only real problem I have found in the dietpi-config setup is that if you select the hw choice for rpi headphone near the bottom of the list it turns the rpi onboard audio off, defeating the whole choice of using the hw choice.
The only real problem I have left with audio is in the cinnamon desktop sound app the test speaker options has no audio out. But that is a minor problem for me as the reason I needed audio was so I could use CubicSDR with my RSP-1a sdr. As it works fine at this time the speaker test problem can be ignored. But I do know that that option works properly in the Raspian Bullseye lite install I have on another ssd. Same RPI-4B just a different ssd. Both the Linux and Cinnamon versions are the same on the Raspian lite and the dietpi systems.
And did it have the expected result on aplay -l output so that there is no card 1 anymore but only card 0 being the “Headphones” analogue device?
You mean without applying the modprobe.d rule and with a HDMI screen attached, aplay -l shows the above intended output, also after a reboot? It should still show HDMI as card 0 (if a screen is attached) and hence not work, as the nodes changed with the device tree overlay we currently use do not exist anymore.
This is intended and the reason I want to fully fix the onboard selections at the top of the list. The auto-detection is just a fallback, meant to be used for external sound cards which are not supported by the hardcoded options above.
I do not have a hdmi screen so cannot test anything that way (DVI-D with adapter to hdmi cable).
Yes cinnamon sound app speaker test did work as I normally run a t est of the speakers after a Cinnamon desktop install. Though I was just seeing how things would work as a primary system for my Ham Shack. But as I was having problems getting synaptic to work properly I stopped testing dietpi. Then when the next dietpi version update came out I did a new install using the latest iso. But ran into audio problems (which appeared to start working from the command line after tried a few suggestions for a possible fix). Then decided to start with a fresh install to see if the many changes I had made were really needed to fix the problem. With the fresh install (downloaded the latest iso again) audio from the command line seemed to be working normally except for the hw option we have talked about before. But at no time since I went with the latest version of dietpi have I been able to get the Cinnamon sound app speaker test to give any audio out. The sound app shows the proper aodio output options (i.e. hdmi/displayport – built in audio and analog output built in audio). Plus if I connect a usb speaker (identified as CD002) the sound app shows the proper entries for it along with built in audio entries. In fact just selecting the usb speaker in the sound app lets the speaker-test program work through the usb speaker. Selecting the built in audio option in the sound app puts the speaker-test audio out through the rpi headphone jack as expected. Just no audio using the sound app speaker test for either speaker.
But the HDMI audio device did show up: No audio from RPI 4B Headphone jack - #24 by Gale
This is all what matters (should break the onboard analogue audio selection) and hence I am interested in whether these are still there or not, and whether adding the modprobe.d config finally disables them.
The desktop speaker testing app is a secondary issue to have a look at when the sound card selection itself works as expected.
I ran your script and verified that everyting was in modprobe.d. Rebooted and aplay -l still shows the hdmi entries. Did a quick check and found the following in /boot/config.txt: dtoverlay=dietpi-disable_hdmi_audio.
Not sure how long it has been there but still showing the hdmi audio entries in both aplay -l and the cinnamon sound app.
One thing I did see was that when I selected my usb speaker in dietpi-config audio it did shut down the onboard rpi audio chip AND the hdmi audio entrys were no longer in aplay -l or in the cinnimon audio app.
What I didn’t know: kernel command-line arguments apply as well to non-builtin kernel modules.
And they do override module options set via /etc/modprobe.d configs.
When having onboard audio enabled (/boot/config.txtdtparam=audio=on), the bootloader/firmware adds snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1 to the kernel command-line, as it does with options for framebuffer sizes, CMA etc. These override/break my attempt to disable HDMI audio via /etc/modprobe.d/dietpi-disable_rpi_hdmi_audio.conf.
The solution however is to override those kernel command-line options again.
rm /etc/modprobe.d/dietpi-disable_rpi_hdmi_audio.conf
sed -i '/root=/s/$/ snd_bcm2835.enable_hdmi=0/' /boot/cmdline.txt
reboot
That seems to have fixed the problem. Changed my audio selection to my usb speaker, rebooted and ran aplay -l. No hdmi audio listed.
Changed audio selection back to rpi headphones, rebooted and ran aplay -l.
No hdmi audio listed.
Speaker test worked fine for both of the selected outputs. Now the get the cinnamon speaker test to work properly.
Thank you for your help in figuring the major problem out and finding out a fix.