I'm working on a custom driver for an embedded device that should manage an audio card with multiple codecs. Each codec can be hotplugged or removed because is placed on an external display that extends an i2cbus.
I used the orginal fsl/imx-card.c driver as a starting point and my device tree looks like this:
sound_card: sound { compatible = "display-audio-card"; model = "disp-audio"; pri-dai-link { link-name = "disp-codec-1"; format = "dsp_b"; dai-tdm-slot-num = <4>; dai-tdm-slot-width = <32>; dai-tdm-slot-tx-mask = <1 1 1 1 0 0 0 0>; fsl,mclk-equal-bclk; cpu { sound-dai = <&esai0>; }; codec { sound-dai = <&speaker_dac_1>, <&speaker_dac_2>; }; }; };
The first issue I encountered was that if both of the codecs were not present at the system start the snd_soc_of_get_dai_link_codecs was returning probe_defer, so I made an internal customization to set one of the two codecs to dummy and continuing registering the card that works as required. Now the problem I am facing is when I have both displays connected and when I unplug one of them all the card gets unregistered instead of the single codec. I tried implementing the codec_i2c_remove where I removed the component from the component list
snd_soc_component_remove(component); list_del(&component->list); devm_kfree(dev, component->name);
and this did not unregistered the card, but something is odd. So I tried to replace the component with a dummy codec to be transparent but without success
There is some other architecture instead of imx-card that I can use to implement the feature? I remember firsly I tried with audio-graph-card but without success.