Message ID | 20240409113310.303261-1-angelogioacchino.delregno@collabora.com |
---|---|
Headers | show |
Series | SoC: Cleanup MediaTek soundcard machine drivers | expand |
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> On 09/04/2024 13:32, AngeloGioacchino Del Regno wrote: > Add a common machine soundcard driver probe function that supports both > DSP and AFE-direct usecases and also provides a hook for legacy machine > soundcard driver probe mechanisms. > > Note that the hook is there because, even for legacy probe, a lot of the > actual code can still be commonized, hence still reducing duplication > for the legacy devicetree retrocompatibility cases. > > This common probe function deprecates all of the inconsistent previous > probe mechanisms and aims to settle all of the MediaTek card drivers on > consistent and common devicetree properties describing wanted DAIs, > device specific DAI configuration and DAI links to codecs found on > each device/board.
On 09/04/2024 13:32, AngeloGioacchino Del Regno wrote: > @@ -29,6 +30,13 @@ > #define RT1019_SPEAKER_AMP_PRESENT BIT(1) > #define MAX98390_SPEAKER_AMP_PRESENT BIT(2) > > +#define DUMB_CODEC_INIT BIT(0) > +#define MT6359_CODEC_INIT BIT(1) > +#define RT1011_CODEC_INIT BIT(2) > +#define RT1019_CODEC_INIT BIT(3) > +#define MAX98390_CODEC_INIT BIT(4) > +#define RT5682_CODEC_INIT BIT(5) > + Why are you using defines+single variable to track inited parts in the probe function but do it in the different way for legacy_probe using bool: is5682s, init6359 ? AFAII, both can use the same method with the defines above. > #define RT1011_CODEC_DAI "rt1011-aif" > #define RT1011_DEV0_NAME "rt1011.2-0038" > #define RT1011_DEV1_NAME "rt1011.2-0039"
On 09/04/2024 13:32, AngeloGioacchino Del Regno wrote: > @@ -1211,52 +1196,85 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) > if (dai_link->num_codecs && dai_link->codecs[0].dai_name && > strcmp(dai_link->codecs[0].dai_name, RT1015_CODEC_DAI) == 0) > dai_link->ops = &mt8192_rt1015_i2s_ops; > - > - if (!dai_link->platforms->name) > - dai_link->platforms->of_node = platform_node; > - } > - > - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); > - if (!priv) { > - ret = -ENOMEM; > - goto err_probe; > - } > - snd_soc_card_set_drvdata(card, priv); > - > - ret = mt8192_afe_gpio_init(&pdev->dev); > - if (ret) { > - dev_err_probe(&pdev->dev, ret, "%s init gpio error\n", __func__); I don't think __func__ is necessary. > - goto err_probe; > } > > - ret = devm_snd_soc_register_card(&pdev->dev, card); > - if (ret) > - dev_err_probe(&pdev->dev, ret, "%s snd_soc_register_card fail\n", __func__); I don't think __func__ is necessary. > - > -err_probe: > of_node_put(headset_codec); > err_headset_codec: > of_node_put(speaker_codec); > err_speaker_codec: > - of_node_put(platform_node); > -err_platform_node: > - of_node_put(hdmi_codec); > + if (hdmi_codec) > + of_node_put(hdmi_codec); > + > return ret; > } > > +static int mt8192_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card_data, bool legacy) > +{ > + struct mtk_platform_card_data *card_data = soc_card_data->card_data; > + struct snd_soc_card *card = card_data->card; > + int ret; > + > + if (legacy) { > + ret = mt8192_mt6359_legacy_probe(soc_card_data); > + if (ret) > + return ret; > + } else { > + struct snd_soc_dai_link *dai_link; > + int i; > + > + for_each_card_prelinks(card, i, dai_link) > + if (dai_link->num_codecs && dai_link->codecs[0].dai_name && > + strcmp(dai_link->codecs[0].dai_name, RT1015_CODEC_DAI) == 0) > + dai_link->ops = &mt8192_rt1015_i2s_ops; > + } > + > + ret = mt8192_afe_gpio_init(card->dev); > + if (ret) > + return dev_err_probe(card->dev, ret, "%s init gpio error\n", __func__); I don't think __func__ is necessary. > + > + return 0; > +} Beside that, Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> On 09/04/2024 13:32, AngeloGioacchino Del Regno wrote: > Add mtk_soundcard_pdata platform data for the MediaTek common sound card > probe mechanism, including a driver/soc-specific probe extension (used > for bits that cannot be commonized hence specific to this driver), and > change the probe function to mtk_soundcard_common_probe. > > This is also adding the possibility of specifying the links and routing > with the audio-routing property and (x)-dai-link nodes in device trees > to stop hardcoding machine specific links in the card driver assupported > by the common probe function, but support for legacy device trees is > retained with a legacy_probe function, which is used only in case the > new properties are not found.
Way better with common stuff ! :p Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> On 09/04/2024 13:33, AngeloGioacchino Del Regno wrote: > Add a const mtk_pcm_constraints_data struct array with all of the > (again, constant) constraints for all of the supported usecases, > remove the duplicated functions and call mtk_soundcard_startup() > instead in all of the .startup() callbacks.
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> On 09/04/2024 13:33, AngeloGioacchino Del Regno wrote: > Add a const mtk_pcm_constraints_data struct array with all of the > (again, constant) constraints for all of the supported usecases, > remove the duplicated functions and call mtk_soundcard_startup() > instead in all of the .startup() callbacks.