<p><br>
>><br>
>> It looks like in the future the ALSA drivers for some Intel hardware<br>
>> will dynamically create a new PCM device when a DisplayPort monitor is<br>
>> plugged in. This is being discussed in this thread (part of the thread<br>
>> is also cross-posted to pulseaudio-discuss):<br>
>> <a href="http://thread.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/62703/focus=63002">http://thread.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/62703/focus=63002</a><br>
>><br>
><br>
> No objections to the plan below, but some nitpicks.<br>
><br>
><br>
>><br>
>> PulseAudio doesn't currently support dynamic PCM devices, so work is<br>
>> needed to add that support. I may work on that, or it may be someone<br>
>> else from Intel. I'll describe here what code changes I think we should<br>
>> make. That serves two purposes: to get feedback about the plan before<br>
>> any code gets written, and to help with the implementation work if<br>
>> someone else than me is going to write the code.<br>
>><br>
>> This is a long mail, but I'm sure I still didn't think of every issue<br>
>> that will arise when implementing this...<br>
>><br>
>><br>
>> Event: monitor gets plugged in<br>
>> ------------------------------<br>
>><br>
>> The first thing that happens should be that PulseAudio gets a wakeup<br>
>> from the alsa mixer, when a new ELD control for the monitor is added.<br>
>> This is important, because the mixer should be ready when PulseAudio<br>
>> starts to use the new PCM device. It's up to the driver developer to do<br>
>> this right. This wakeup can be ignored, so no code changes are needed in<br>
>> PulseAudio to handle this.<br>
>><br>
>> The second thing that happens is that udev notifies PulseAudio about a<br>
>> new PCM device. Interfacing with udev is done in<br>
>> src/modules/module-udev-detect.c. Currently PulseAudio only cares about<br>
>> new and removed cards, so module-udev-detect has to be modified to also<br>
>> keep track of what PCM devices each card has, so that new devices can be<br>
>> noticed.<br>
><br>
><br>
> I am not sure whether this "wakeup from alsa mixer first, from udev second" ordering is something that can be relied on. But a "ELD control exists when udev notifies us" requirement looks sensible.<br>
><br>
><br>
>><br>
>> When module-udev-detect sees a new PCM device, it needs to notify<br>
>> module-alsa-card about it. module-udev-detect's only interface with<br>
>> module-alsa-card is pa_module, which is not useful for adding the<br>
>> notification. I think we should move the bulk of the code in<br>
>> module-alsa-card.c to a new class: pa_alsa_card. module-udev-detect<br>
>> would then create pa_alsa_card objects instead of loading<br>
>> module-alsa-card instances. module-alsa-card would still exist as a<br>
>> wrapper around pa_alsa_card, but the module would not be used by<br>
>> module-udev-detect. With pa_alsa_card in place, we can add a<br>
>> pa_alsa_card_pcm_added() function to its API.<br>
><br>
><br>
> OK.<br>
><br>
><br>
>> pa_alsa_card should be defined in src/modules/alsa/alsa-card.[ch] and<br>
>> included in the <a href="http://libalsa-util.la">libalsa-util.la</a> helper library.<br>
>><br>
>> When moving the code from module-alsa-card to pa_alsa_card, some changes<br>
>> to the sink and source error handling is needed. Currently, if something<br>
>> fails in the IO thread of an alsa sink or source, the sink/source<br>
>> unloads the module that owns the sink/source (see the end of<br>
>> thread_func() in alsa-sink.c and alsa-source.c). Now the owner module of<br>
>> alsa sinks and sources becomes module-udev-detect, and we certainly<br>
>> don't want to unload that if a single sink or source fails. The<br>
>> sink/source should notify the pa_alsa_card object of the failure (new<br>
>> functions pa_alsa_card_sink_failed() and pa_alsa_card_source_failed()),<br>
>> and pa_alsa_card should free the failed pa_alsa_sink or pa_alsa_source<br>
>> object.<br>
><br>
><br>
> The case of manually-loaded module-alsa-sink is not described here, but should be.<br>
><br>
><br>
>> Let's get back to the pa_alsa_card_pcm_added() function. What should it<br>
>> do? We shouldn't support dynamic PCMs for arbitrary hw PCMs, because<br>
>> that's not compatible with relying on logical device names like "front",<br>
>> "surround51" etc. At this point we only need to support dynamic PCMs<br>
>> that are dedicated to hotplugged HDMI/DisplayPort/Thunderbolt devices.<br>
>> The current proposal to detect such PCMs is to add a new HDMI class to<br>
>> snd_pcm_class_t, which can be queried with snd_pcm_info_get_class().<br>
>><br>
>> Currently when opening HDMI devices, we use "hdmi:x,y" as the device<br>
>> string, where x is the card index and y is the device index. The device<br>
>> index may be different than the hw device index, but the mapping between<br>
>> "hdmi:x,y" to "hw:x,z" is static. The mapping can be different with<br>
>> different drivers, AFAIK. We currently blindly try all device indexes<br>
>> from 0 to 7 when probing the card. Takashi Iwai told that such behaviour<br>
>> won't be compatible with drivers that create dynamic PCMs for HDMI. I<br>
>> guess the reason is that the dynamically allocated hw device indexes can<br>
>> (and usually do) fall outside the index range that is used in "hdmi:x,y".<br>
>><br>
>> Since the new HDMI PCM class is new, old kernels and old alsa-lib won't<br>
>> use that class even with PCMs that are actually dedicated to HDMI. We<br>
>> need to tell apart drivers that use the new HDMI PCM class and drivers<br>
>> that don't. With drivers that never use the HDMI class, we should keep<br>
>> using the "hdmi:x,y" device strings. With drivers that use the HDMI<br>
>> class, we should use "hdmi:CARD=x,SYSDEV=z", where z is the hw device<br>
>> index (the SYSDEV parameter doesn't currently exist, so alsa-lib needs<br>
>> to be updated to support it). How do we tell the two kinds of drivers<br>
>> apart? The current proposal is to add a version field to the PCM info.<br>
>> Version 0 would mean that the driver is unaware of the HDMI PCM class,<br>
>> and version 1 would mean that the driver will set the PCM class to HDMI<br>
>> when appropriate.<br>
>><br>
>> I assume that the PCM info version will be provided separately for each<br>
>> PCM device, but I expect the version to be always the same for every<br>
>> device that belongs to the same card. We definitely need to make the<br>
>> decision between the two models at the card level in any case, because<br>
>> we can't really mix the "hdmi:x,y" model with the "hdmi:CARD=x,SYSDEV=z"<br>
>> model within the same card. When probing a new card, we should check the<br>
>> PCM info version of the first device that we probe, and choose the HDMI<br>
>> model for the card based on that. If the first device has PCM info<br>
>> version 0, then we won't support dynamic HDMI devices for that card,<br>
>> even if subsequent devices would somehow have version 1.<br>
>><br>
>> The "mapping" concept in our alsa-mixer code corresponds to the PCM<br>
>> devices. What mappings exist is configured in<br>
>> src/modules/alsa/mixer/profile-sets/default.conf. We have many HDMI<br>
>> entries, here are a couple of examples:<br>
>><br>
>> [Mapping hdmi-stereo]<br>
>> description = Digital Stereo (HDMI)<br>
>> device-strings = hdmi:%f<br>
>> paths-output = hdmi-output-0<br>
>> channel-map = left,right<br>
>> priority = 4<br>
>> direction = output<br>
>><br>
>> [Mapping hdmi-stereo-extra1]<br>
>> description = Digital Stereo (HDMI 2)<br>
>> device-strings = hdmi:%f,1<br>
>> paths-output = hdmi-output-1<br>
>> channel-map = left,right<br>
>> priority = 2<br>
>> direction = output<br>
>><br>
>> The "device-strings" option doesn't suit the HDMI case very well, if we<br>
>> sometimes have to use "hdmi:x,y" and sometimes "hdmi:CARD=x,SYSDEV=z".<br>
>> Also, the path configuration files assume a particular mapping from<br>
>> "hdmi:x,y" to "hw:x,z" when dealing with ELD information and jack<br>
>> detection, and that assumed mapping is incorrect with dynamic HDMI<br>
>> devices. (This assumption probably also means that our HDMI ELD and jack<br>
>> detection functionality is currently broken on non-HDA cards.)<br>
>><br>
>> I propose that we add a new boolean option for mappings, which would<br>
>> indicate that the mapping represents more than one PCM device, and that<br>
>> the PCM and mixer handling is performed according to the complex HDMI<br>
>> specific rules that I've explained above. The option name could be e.g.<br>
>> "dynamic-hdmi". When "dynamic-hdmi" is be set for a mapping, the<br>
>> "description", "device-strings", "paths-output" and "direction" options<br>
>> in the configuration file would be ignored, and the appropriate values<br>
>> for those would be hardcoded. That would allow us to shorten<br>
>> default.conf quite a bit, and also remove all the hdmi-output-N.conf<br>
>> path files (the generated paths would be hardcoded too).<br>
>><br>
>> All that hardcoding isn't nice from flexibility point of view, but I<br>
>> don't think the lost flexibility is very important in this case. I<br>
>> believe that any alternative solution that would keep everything in the<br>
>> configuration files would introduce a significant amount of complexity<br>
>> to deal with the variance in the "hdmi:x,y" -> "hw:x,z" mapping (and I'm<br>
>> not sure it's even possible to have non-HDA-specific ELD information and<br>
>> jack detection support with the old-style "hdmi:x,y" device strings,<br>
>> since we don't have a reliable method to figure out what hw PCM device<br>
>> index y corresponds to).<br>
>><br>
>> In case of dynamic HDMI mappings, the HDMI profiles need to become<br>
>> dynamic too. So, if a profile definition in a configuration file<br>
>> references a mapping that has the "dynamic-hdmi" flag set, that profile<br>
>> definition will then represent multiple profiles, one for each HDMI<br>
>> device. I'm not sure how to deal with the "description" option. Should<br>
>> it be ignored, or should we append a number to the description when<br>
>> there are multiple HDMI devices? When profiles are autogenerated (which<br>
>> is the common case), then the existing profile description logic should<br>
>> work fine.<br>
>><br>
>> So, when pa_alsa_card_pcm_added() sees that a new HDMI PCM device<br>
>> appeared, it should create a new mapping for the device, a new path for<br>
>> the mapping, and a new profile containing the mapping. Then<br>
>> pa_alsa_card_pcm_added() needs to call pa_card_add_profile(), and<br>
>> hopefully it will just work.<br>
>><br>
>><br>
>> Event: monitor gets unplugged<br>
>> -----------------------------<br>
>><br>
>> When a monitor gets unplugged, module-udev-detect gets a notified, and<br>
>> it should figure out that a PCM device has disappeared. It should then<br>
>> call pa_alsa_card_pcm_removed(), which is a new function that needs to<br>
>> be implemented.<br>
><br>
><br>
> Again, the case of manually loaded module-alsa-sink is not considered.<br>
><br>
><br>
>><br>
>> pa_alsa_card_pcm_removed() should mirror pa_alsa_card_pcm_added(), just<br>
>> undoing the things that _added() did, in reverse order. So, first it<br>
>> should call pa_card_remove_profile(). That function doesn't exist<br>
>> currently, so it needs to be implemented. Next<br>
>> pa_alsa_card_pcm_removed() should free the pa_alsa_profile,<br>
>> pa_alsa_mapping and pa_alsa_path objects corresponding to the removed<br>
>> device. I think that's it for pa_alsa_card_pcm_removed().<br>
>><br>
>> If the profile that is being removed is active, pa_card_remove_profile()<br>
>> should change the card profile to something else. I suppose it should<br>
>> use the same logic as what pa_card_new() uses when choosing the default<br>
>> profile.<br>
>><br>
><br>
> What else is missing is the big picture of the available multi-monitor use cases.<br>
><br>
> Currently, if one has a card with multiple HDMI outputs, one can use audio from one monitor at a time, using profiles. I.e. there are no profiles like "HDMI Digital Stereo Output + HDMI 3 Digital Surround Output" (with the possibility to move individual streams between monitors), presumably due to the combinatorial explosion. Will this limitation be lifted?</p>
<p>><br>
> Also, AFAIR, there was a discussion of a possibility to send the same PCM stream to two monitors. How would that work?</p>
<p><a href="http://www.intel.com/support/graphics/sb/CS-031040.htm">http://www.intel.com/support/graphics/sb/CS-031040.htm</a></p>
<p>The multi display monitors can be configured by graphic driver in clone mode or extended display mode </p>
<p>Are there hardware limitation (e.g. bandwidth ) which limit the highest sample rate and 32bits cannot be used by multi monitors at same time ?</p>
<p>Are there any different in primary display , second display and third display ?</p>
<p>Will th power off/on of the monitor in the middle of dasiy chain affect the other displays of the dasiy chain ?</p>
<p><a href="http://www.intel.com/support/graphics/sb/CS-033714.htm">http://www.intel.com/support/graphics/sb/CS-033714.htm</a></p>
<p>How do pulseaudio/driver know multi displays are in clone node or independent display mode ?<br>
</p>