David Henningsson wrote at Tuesday, August 23, 2011 10:54 PM:
On 2011-08-23 17:51, Stephen Warren wrote:
David Henningsson wrote at Tuesday, August 23, 2011 9:12 AM:
Since modern HDMI cards often have more than one output pin and thus input device, we need to know which one has actually been plugged in.
This patch adds a name hint that indicates which PCM device is connected to which pin.
To do that, the jack creation has been deferred to build_controls, i e, after the PCM devices have been created.
Would be great to have Stephen look through this patch quickly before it's committed.
Thanks for the review!
Structurally, I think this looks OK. The only question I have is the string format:
"HDMI/DP (pcm %d)", pcmdev
- Is there a 1:1 mapping between the internal pcmdev numbers and what
alsa-lib presents to clients?
That's very much up to the configuration in alsa-lib, but I would say that alsa-lib in general does that, and especially for HDA.
Thinking about ALSA device numbering, it's like "hw:1,3", so includes the card number too; should that be in the string?
The matchup against the card can be done both in sysfs, and using the card name, which is later prefixed to that string. The end result would be something like "HDA NVidia HDMI/DP (pcm 3)"
OK, so if the string that user-space sees already has the card name, that's probably enough in practice, although it still seems a little free-form.
One issue with the above string: There's no delimiter that user-space can use to extract just the card name from the whole string. Perhaps add a ":" at the start so there's a delimiter?
"HDA NVidia: HDMI/DP (pcm 3)" "HDA NVidia: pcm 3"
?
It's possible though, and somewhat simpler than matching against sysfs to add the card number as well.
- Would it be better to make the string completely generic - i.e. not
include "HDMI/DP", but rather something like "ALSA PCM %d", or even "ALSA PCM hw:%d,%d" so that the same format could be used for non-HDMI/ DP PCMs in the future?
That would probably be bad, as there would be no way to distinguish between e g "Headphone" and "Headphone 2".
Are those two different analog outputs from the same PCM device?
If so, I don't see a problem with having both those jack's input devices reporting the same PCM name; user-space will just see 2 matches and know that the PCM device is useful if either is plugged in.
If not, I'm afraid I don't have enough context to understand your comment.
This is a HDMI specific problem in general, as all analog outputs and inputs are at ,0 and SPDIF at ,1. (Although there might be exceptions, the "Independent HP" thing of the VIA drivers come to mind.)
Hmm. I don't see it as HDMI specific. If there's a random input device today that represents the analog output's jack detection, how does user- space know the input device is for analog (sub-device 0) at all? Isn't the exact same issue present for any kind of output; I don't how the ,0/,1/,3 numbering affects this. Sorry!
Up to now, I believe the string in the name has been pretty arbitrarily. E g, I have "Headphone" on one machine and "HP Out" on another. Should we try to establish a format where various parameters can be added, it might be good to try something like ",name=value". Should we add card as well, the result would be e g: "HDA NVidia HDMI/DP,card=2,pcm=3"
That sounds pretty sane to me.