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

PSPi6 with RPi CM4 - Only left channel audio is output from both speakers #30

Open
Skylark13 opened this issue Sep 13, 2024 · 14 comments
Open

Comments

@Skylark13
Copy link

Hello, thanks a lot for this great project! I had fun building it, and it works really well for a lot of different emulators. I have a problem with mine though, and I could use some help identifying the exact cause.

Both speakers, and both sides of headphones if those are connected, output the left channel audio only. The right channel audio is not being output at all.

This was apparent when I ran some Amiga demos (since the Amiga has 100% stereo separation) and some instruments in the music were just not audible at all. But I also found an MP3 to test stereo, which plays a voice first in the center (both channels), then left only, then right only. When played on my PSPi6 it sounds the same when playing center and left (the sound would come out of both speakers in both cases), then would just be totally silent when playing the right side audio.

http://www.aoakley.com/articles/stereo-test.mp3

I think this is not a software issue with the OS being used, because I tested this in two different ones (Batocera using the menu music, and RetroPie using Kodi) and it did the same thing in both.

Just to let you know, I found this issue on the Batocera github: batocera-linux/batocera.linux#7447 . It describes the same issue happening on a Steam Deck and says it was fixed, then another issue was opened for a later version saying it came back. But I don't think this is the same issue because it would happen only in Batocera, not RetroPie as well, I think. Surely both OSes, which are pretty different at their core, wouldn't have exactly the same bug? (I got the link to the stereo testing MP3 file from that issue)

So I'm thinking this could be a hardware issue, perhaps a solder bridge somewhere. I have some soldering and basic electronics knowledge (can check continuity and voltages for example) but what makes this harder to diagnose is that it's pretty hard to run the PSPi when it's disassembled so the board is accessible. But it could be done if needed.

What do you think? Is there any guidance you could give to help me figure out what is wrong? Or even better, have you ever seen this issue and know of a fix already?

Thanks in advance.

@othermod
Copy link
Owner

othermod commented Sep 27, 2024

Hey @Skylark13, sorry for the late reply. The issue is due to the fact that the CM4 carrier only uses mono audio. The LCD takes up all the other pins, so I had to design it that way. The left and right channels are supposed to combine so that nothing is lost, but I assume that isn't working in some things.

@Skylark13
Copy link
Author

Hmm, ok that's unfortunate... Is this mentioned somewhere in the documentation I would have missed? It seems like some info that would be important to know when deciding what type of Raspberry Pi to choose.

I have 2 options from here:

  1. Keep my CM4 knowing left and right should be combined, and debug why the right channel is not being mixed with the left one. I was looking at the schematics on OSHWLab trying to figure out the routing. I assume what I have to look at is the carrier board, the channels should be combined at that point and be sent to the main board already combined? If you can point me in the right direction I'd be interested. (assuming it's a hardware issue and not a software one, correct me if I'm wrong)
  2. If I want stereo I would need to change my CM4 for something else, is the best choice Raspberry Pi Zero 2W? That would be the easiest but incur extra cost. From the https://github.com/othermod/PSPi-Version-6/wiki/Compatibility page I gather the Zero 2W is a bit less powerful than the CM4, so I'd be missing out on some games in the upper end of the spectrum like some PS1 games and PSP emulation, is that right?

Just want to make sure I understand the tradeoffs well enough.

Thanks!

@othermod
Copy link
Owner

It the same for any Pi currently. All only route a mono channel. The choice was between video quality and stereo, and the general consensus was that video quality took priority. I'm working on a different carrier board (that I plan to also work with other CM4-style boards), and I expect will have high quality video and stereo audio. Will be a while though, as I'm waiting for the CM5 to be released or at least sampled to people.

To clarify, I built the PSPi 6 to be ready for stereo audio. It does have independent audio channels that are filtered and amplified. The limitation is with the Pi boards.

@othermod
Copy link
Owner

othermod commented Sep 27, 2024

To answer the other part of the question, the audio channels should be combined in software and sent through the mono channel. That appears to not be working correctly. My board will take that merged mono channel and send it to both speakers.

When two independent audio channels are available, my board will output the independent audio channels. They just arent available on the Pi when using DPI video

@Skylark13
Copy link
Author

the audio channels should be combined in software and sent through the mono channel.

Where does this happen in the software? Is it done in a modification of the OS that you do specifically for the PSPi6? Because I am hearing the same audio coming out of both speakers, so the board side seems to work, but the audio that comes out is only the left channel, so it's the combining in software that doesn't work.

The OSes I tried were from the Community OS Images section (I tried RetroPie 4.8 and Batocera 39, perhaps those don't have the required modification and I would need to use one of those you did?

@othermod
Copy link
Owner

othermod commented Sep 27, 2024

I set mono audio using an overlay in config.txt.
https://github.com/othermod/PSPi-Version-6/blob/main/rpi/configs/cm4.txt#L30C1

It's possible that some programs don't adhere to it, and Linux may need some additional configuration to force it. I'm pretty good with hardware design and c coding, but not quite as knowledgeable about Linux structure and configuration

@Skylark13
Copy link
Author

I tested in both Kodi and the Amiga emulator (I think both Batocera and RetroPie use fsuae by default) and reproduced the issue in both. I don't know much about this either but I can probably try to troubleshoot it.

Thanks! I'll let you know if I find something, but for now I'll close this issue since it's as intended.

@othermod
Copy link
Owner

I'll create a bug list and add this to it. Maybe can get some more assistance on it.

@Skylark13
Copy link
Author

Sorry to still post to this closed issue, but I think there's really something that doesn't work as you intended.

Here is a video in which I'm running alsamixer from ssh, while the batocera menu music is playing. You can see that when I lower just the left channel volume, all audio goes away. When I lower just the right channel volume, nothing changes.

https://drive.google.com/file/d/1HfaDSr8wGxI0eRXY8Q_zO98Go8Fk_4pc/view

I checked and the configuration seems to be correct (according to what you mentioned earlier in this thread):

  • /boot/config.txt has the following lines:
[board-type=0x14]
include cm4.txt
  • And /boot/cm4.txt has the following lines:
dtoverlay=audiocm4

So I should be hearing both left and right channels from both speakers, and lowering only one side in alsamixer should not change anything to the audio I hear unless I lower both...

I read somewhere that what we want could also be accomplished by using directives in asound.conf to have alsa mirror the channels like this:

# mono
pcm.!default {
	type route
	slave.pcm "hw:0,0"
	ttable {
		0.1 1
		0.0 1
		1.0 1
		1.1 1
	}
}

But I don't know how to make this change, if I add /etc/asound.conf the file just disappears the next time I restart the PSPi6.

@Skylark13
Copy link
Author

Hi @othermod , happy new year!

I've been fiddling with this a bit more. I had it working at one point but I can't remember what I changed, and a reboot brought me back to non-working again :(

From what I've read, .asoundrc in the home directory should be the last alsa config file applied. I tried using this config in that file, editing "hw:N" for "hw:0" of course, and doing alsactl init to restart alsa, but it had no effect. To see if my file was even getting used, I tried setting all channels to 0 (the last digit to 0 on each line in the ttable) thinking after alsactl init I should not hear any sound, but again it had no effect, I could still hear sound with the same problem.

And again for some reason the .asoundrc file disappeared after a reboot. It looks like ~ is /userdata/system for the root user in batocera, so its contents should survive reboots...

I wonder, what is the source for https://github.com/othermod/PSPi-Version-6/blob/main/rpi/overlays/audiocm4.dtbo ? There is no corresponding .dts file in the repo, only "oldaudiocm4.dts". I'd like to see how that's configured. I also saw another user had a "mono.dtbo" file for a pi zero (see #7) but I don't know if that's a fix for a related problem, or if it's related. I asked to see the source for that too in the issue.

Thanks again.

@Skylark13 Skylark13 reopened this Jan 6, 2025
@othermod
Copy link
Owner

@Skylark13
https://github.com/raspberrypi/linux/blob/rpi-6.6.y/arch/arm/boot/dts/overlays/audremap-overlay.dts
That is the source, with one small change here
https://github.com/raspberrypi/linux/blob/rpi-6.6.y/arch/arm/boot/dts/overlays/audremap-overlay.dts#L10
to specify a single GPIO 45 instead of two

I've tried so many things to make it merge the 2 channels into a single one in the driver, but had no luck. The best I can do is force it to be either just left or just right that is piped in. The merging still has to be done in the OS. I think the hardware is capable of it, but can't find any use of it in the Raspberry Pi Linux GitHub.

@Skylark13
Copy link
Author

Thanks for the pointer. I think the right way would be to make the alsa config have the desired effect, and have it stick, somehow. I'll continue to look in that direction.

@othermod
Copy link
Owner

Yep I agree that alsa is probably the way to go, but that only works in retropie and raspberry pi os. Ones like Lakka and Batocera have their own way to do it, and don't allow you to easily modify the filesystem.

I'm going to reach out to the raspberry pi developers and ask whether they have a way to implement this at a lower level

@Skylark13
Copy link
Author

I like Batocera so that's a shame doing it through alsa won't work for that.

OK, let me know (and if there's a thread I can follow please post the link here). I'd love to keep abreast of any progress (I can even help testing if it can help).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants