[alsa-devel] link between HDMI ELD and PCM devices
Hi, I've been trying for some time to expose the HDMI ELD information in a new control. The problem I am facing with the HDMI/HDA code is that the ELD is linked to an output pin, and I can't find an elegant way to link this output pin with a PCM device number to be used by my control. For a single output, I could hard-code something but it would probably not work with multiple monitors handled by recent hardware. There is some existing code such as pin_nid_to_pin_index() in patch_hdmi.c, but I can't figure out what this pin_idx is, and how to find the related PCM device number. Any suggestions? Thanks, -Pierre
Pierre-Louis Bossart wrote at Tuesday, September 20, 2011 5:13 PM:
Hi, I've been trying for some time to expose the HDMI ELD information in a new control. The problem I am facing with the HDMI/HDA code is that the ELD is linked to an output pin, and I can't find an elegant way to link this output pin with a PCM device number to be used by my control. For a single output, I could hard-code something but it would probably not work with multiple monitors handled by recent hardware. There is some existing code such as pin_nid_to_pin_index() in patch_hdmi.c, but I can't figure out what this pin_idx is, and how to find the related PCM device number. Any suggestions?
That function simply returns the index into the array spec->pins[] that refers to that pin NID.
Judging by hinfo_to_pin_index() (e.g. used near the start ofhdmi_pcm_open), that same index is valid for spec->pcm_rec[] too, which I assume will give you access to what you want, possibly through the .stream[0] field.
There is some existing code such as pin_nid_to_pin_index() in patch_hdmi.c, but I can't figure out what this pin_idx is, and how to find the related PCM device number. Any suggestions?
That function simply returns the index into the array spec->pins[] that refers to that pin NID.
Judging by hinfo_to_pin_index() (e.g. used near the start ofhdmi_pcm_open), that same index is valid for spec->pcm_rec[] too, which I assume will give you access to what you want, possibly through the .stream[0] field.
Looks like the device number is assigned in hda_codec.c and there's no hooks to create the ELD control then... Instead of creating a PCM_IFACE control, it's probably simpler to create a MIXER control in the build_pcms routines, using the same name for the control and the device, eg:
amixer -c0 controls
numid=1,iface=MIXER,name='ELD HDMI 0'
aplay -l
card 0: Intel [HDA Intel], device 3: HDMI 0 [HDMI 0]
That looks simple enough for apps to figure out which ELD control to use? Feedback welcome. -Pierre
On 09/21/2011 02:58 AM, Pierre-Louis Bossart wrote:
There is some existing code such as pin_nid_to_pin_index() in patch_hdmi.c, but I can't figure out what this pin_idx is, and how to find the related PCM device number. Any suggestions?
That function simply returns the index into the array spec->pins[] that refers to that pin NID.
Judging by hinfo_to_pin_index() (e.g. used near the start ofhdmi_pcm_open), that same index is valid for spec->pcm_rec[] too, which I assume will give you access to what you want, possibly through the .stream[0] field.
Looks like the device number is assigned in hda_codec.c and there's no hooks to create the ELD control then... Instead of creating a PCM_IFACE control, it's probably simpler to create a MIXER control in the build_pcms routines, using the same name for the control and the device, eg:
amixer -c0 controls
numid=1,iface=MIXER,name='ELD HDMI 0'
aplay -l
card 0: Intel [HDA Intel], device 3: HDMI 0 [HDMI 0]
That looks simple enough for apps to figure out which ELD control to use? Feedback welcome.
This won't work - in the case of several HDMI codecs (common with NVidia) there will be more than one "HDMI 0".
The solution is to actually find the device number out, like this:
struct hdmi_spec *spec = codec->spec; int pcmdev = spec->pcm_rec[pin_idx].device;
(This must be run after build_pcms, e g in build_controls.)
At Wed, 21 Sep 2011 08:44:15 +0200, David Henningsson wrote:
On 09/21/2011 02:58 AM, Pierre-Louis Bossart wrote:
There is some existing code such as pin_nid_to_pin_index() in patch_hdmi.c, but I can't figure out what this pin_idx is, and how to find the related PCM device number. Any suggestions?
That function simply returns the index into the array spec->pins[] that refers to that pin NID.
Judging by hinfo_to_pin_index() (e.g. used near the start ofhdmi_pcm_open), that same index is valid for spec->pcm_rec[] too, which I assume will give you access to what you want, possibly through the .stream[0] field.
Looks like the device number is assigned in hda_codec.c and there's no hooks to create the ELD control then... Instead of creating a PCM_IFACE control, it's probably simpler to create a MIXER control in the build_pcms routines, using the same name for the control and the device, eg:
amixer -c0 controls
numid=1,iface=MIXER,name='ELD HDMI 0'
aplay -l
card 0: Intel [HDA Intel], device 3: HDMI 0 [HDMI 0]
That looks simple enough for apps to figure out which ELD control to use? Feedback welcome.
This won't work - in the case of several HDMI codecs (common with NVidia) there will be more than one "HDMI 0".
The solution is to actually find the device number out, like this:
struct hdmi_spec *spec = codec->spec; int pcmdev = spec->pcm_rec[pin_idx].device;
(This must be run after build_pcms, e g in build_controls.)
Yes, currently a device-number assignment is somehow tricky, as it's assigned semi-dynamically. But the method above David mentioned should work.
thanks,
Takashi
This won't work - in the case of several HDMI codecs (common with NVidia) there will be more than one "HDMI 0".
No, the code doesn't use a constant, it's assigned in the same way as the device name. You would have HDMI 0, HDMI 1..4. I don't have this kind of hardware, it'd be good if someone could verify that the name is indeed dynamic.
The solution is to actually find the device number out, like this:
struct hdmi_spec *spec = codec->spec; int pcmdev = spec->pcm_rec[pin_idx].device;
That's what I wanted initially, but this device field is not used/initialized, and like I said the device assignment comes after the pin sensing and all the ELD handling -Pierre
participants (4)
-
David Henningsson
-
Pierre-Louis Bossart
-
Stephen Warren
-
Takashi Iwai