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

Get HDMI audio output working #138

Open
gardners opened this issue Nov 17, 2019 · 30 comments
Assignees
Labels
bug

Comments

@gardners
Copy link
Contributor

@gardners gardners commented Nov 17, 2019

Self-explanatory.

Depends on #114

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 17, 2019

Begun implementing this.

Using the hdmidebug target, I am able to play a tone, but it is being badly shaped, a the following images show:

Bildschirmfoto vom 2019-11-17 22-20-37
Bildschirmfoto vom 2019-11-17 22-19-29
Bildschirmfoto vom 2019-11-17 22-16-21

The waveform is smooth, just badly enveloped.

Changing the HDMI initialisation frequency in vga_hdmi doesn't change the ~4Hz pulse train, so it is not some HDMI setup thing.

That the waveform is smooth suggests to me that it probably isn't samples being missed, but its hard to know for sure.

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 18, 2019

New fascinating clue: HDMI video works with SPDIF audio enabled, only in NTSC mode: In PAL mode, the screen goes blank. SPDIF audio is still very broken up in NTSC mode, so something is still not right.

gardners added a commit that referenced this issue Nov 18, 2019
gardners added a commit that referenced this issue Nov 18, 2019
gardners added a commit that referenced this issue Nov 18, 2019
gardners added a commit that referenced this issue Nov 18, 2019
@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 18, 2019

Found this nice reference: https://www.av-iq.com/avcat/images/documents/pdfs/digaudiochannelstatusbits.pdf

There should be 192 sample PAIRS per sub-frame, not 192 samples, according to this. Reading more...

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 18, 2019

But that might be wrong, as with that, there is not even an HDMI image.
What might also be an issue is if the parity bit is 1, then we need the inverted preamble. It doesn't look like that ever actually gets sent.

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 18, 2019

Another source also indicates 192 x L+R pairs: http://www.hardwarebook.info/S/PDIF
But finding good source material seems to be hard...

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 18, 2019

Trying a different SPDIF implementation from OpenCores in case it solves the problem.

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 23, 2019

Wrote HDMI status debug utility that lets me see things like N and CTS values. This revealed that detected CTS was double the expected value, indicating we are generating samples at 88.2KHz, not 44.1KHz. Thus we need to double the value of N, and keep CTS the same.

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 23, 2019

Well, that didn't fix it. But being able to play with registers in real-time revealed some things:

  1. You have to turn HDMI audio TX off via reg $0A before you can change things like auto/manual CTS.
  2. Switching to auto CTS got HDMI audio working very nicely in NTSC! (commits follow)
@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 23, 2019

Now to figure out why PAL video still shuts down when audio is enabled...

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 23, 2019

Audio level is still WAY too high for HDMI audio. Mixer values need to be like $0707 or lower, so we are still at least 5 bits too loud. Also some static in the sound sometimes (e.g., in parts of the krakout music).

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 23, 2019

Static seems to be constant level, i.e., it sounds relatively louder if you reduce audio mixer gain, and quieter if you increase audio mixer gain.

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 23, 2019

Not audible when there is no sound playing. Is it some harmonic of SID to HDMI audio output?

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 23, 2019

For PAL mode, anything that ceases the audio stream restores video, including switching from SPDIF to another audio source, or telling the ADV7511 that the audio source uses external MCLK instead of recovered MCLK.

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 24, 2019

Have gone through all ADV7511 I2C main map registers and confirmed that everything looks right in PAL vs NTSC modes, but PAL mode still shows no video when SPDIF audio is enabled. Running out of ideas as to what could be the cause.

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 25, 2019

Found a possible cause: In PAL video data continues one raster line into the VSYNC period, which might be confusing the ADV7511. Trying to fix this now...

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 27, 2019

Some TVs/monitors have very broken audio, suggesting we aren't indicating the audio sample format correctly.

@gardners

This comment has been minimized.

Copy link
Contributor Author

@gardners gardners commented Nov 27, 2019

Varying I2C register 14 doesn't change it.
Is it bigendian/littleendian perhaps?
Or just 192khz audio sample rate?

gardners added a commit that referenced this issue Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.