Lines Matching +full:imx +full:- +full:audio +full:- +full:card
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright 2017-2020 NXP
8 #include <sound/hdmi-codec.h>
12 * struct cpu_priv - CPU private data
25 struct snd_soc_card card; member
36 struct imx_hdmi_data *data = snd_soc_card_get_drvdata(rtd->card); in imx_hdmi_hw_params()
37 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in imx_hdmi_hw_params()
39 struct snd_soc_card *card = rtd->card; in imx_hdmi_hw_params() local
40 struct device *dev = card->dev; in imx_hdmi_hw_params()
41 u32 slot_width = data->cpu_priv.slot_width; in imx_hdmi_hw_params()
45 ret = snd_soc_dai_set_sysclk(cpu_dai, data->cpu_priv.sysclk_id[tx], in imx_hdmi_hw_params()
48 if (ret && ret != -ENOTSUPP) { in imx_hdmi_hw_params()
54 if (ret && ret != -ENOTSUPP) { in imx_hdmi_hw_params()
72 struct snd_soc_card *card = rtd->card; in imx_hdmi_init() local
74 struct snd_soc_component *component = codec_dai->component; in imx_hdmi_init()
75 struct imx_hdmi_data *data = snd_soc_card_get_drvdata(card); in imx_hdmi_init()
78 data->hdmi_jack_pin.pin = "HDMI Jack"; in imx_hdmi_init()
79 data->hdmi_jack_pin.mask = SND_JACK_LINEOUT; in imx_hdmi_init()
81 ret = snd_soc_card_jack_new_pins(card, "HDMI Jack", SND_JACK_LINEOUT, in imx_hdmi_init()
82 &data->hdmi_jack, in imx_hdmi_init()
83 &data->hdmi_jack_pin, 1); in imx_hdmi_init()
85 dev_err(card->dev, "Can't new HDMI Jack %d\n", ret); in imx_hdmi_init()
89 ret = snd_soc_component_set_jack(component, &data->hdmi_jack, NULL); in imx_hdmi_init()
90 if (ret && ret != -ENOTSUPP) { in imx_hdmi_init()
91 dev_err(card->dev, "Can't set HDMI Jack %d\n", ret); in imx_hdmi_init()
100 struct device_node *np = pdev->dev.of_node; in imx_hdmi_probe()
101 bool hdmi_out = of_property_read_bool(np, "hdmi-out"); in imx_hdmi_probe()
102 bool hdmi_in = of_property_read_bool(np, "hdmi-in"); in imx_hdmi_probe()
109 dlc = devm_kzalloc(&pdev->dev, 3 * sizeof(*dlc), GFP_KERNEL); in imx_hdmi_probe()
111 return -ENOMEM; in imx_hdmi_probe()
113 cpu_np = of_parse_phandle(np, "audio-cpu", 0); in imx_hdmi_probe()
115 dev_err(&pdev->dev, "cpu dai phandle missing or invalid\n"); in imx_hdmi_probe()
116 ret = -EINVAL; in imx_hdmi_probe()
122 dev_err(&pdev->dev, "failed to find SAI platform device\n"); in imx_hdmi_probe()
123 ret = -EINVAL; in imx_hdmi_probe()
127 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in imx_hdmi_probe()
129 ret = -ENOMEM; in imx_hdmi_probe()
130 put_device(&cpu_pdev->dev); in imx_hdmi_probe()
134 data->dai.cpus = &dlc[0]; in imx_hdmi_probe()
135 data->dai.num_cpus = 1; in imx_hdmi_probe()
136 data->dai.platforms = &dlc[1]; in imx_hdmi_probe()
137 data->dai.num_platforms = 1; in imx_hdmi_probe()
138 data->dai.codecs = &dlc[2]; in imx_hdmi_probe()
139 data->dai.num_codecs = 1; in imx_hdmi_probe()
141 data->dai.name = "i.MX HDMI"; in imx_hdmi_probe()
142 data->dai.stream_name = "i.MX HDMI"; in imx_hdmi_probe()
143 data->dai.cpus->dai_name = dev_name(&cpu_pdev->dev); in imx_hdmi_probe()
144 data->dai.platforms->of_node = cpu_np; in imx_hdmi_probe()
145 data->dai.ops = &imx_hdmi_ops; in imx_hdmi_probe()
146 data->dai.playback_only = true; in imx_hdmi_probe()
147 data->dai.capture_only = false; in imx_hdmi_probe()
148 data->dai.init = imx_hdmi_init; in imx_hdmi_probe()
150 put_device(&cpu_pdev->dev); in imx_hdmi_probe()
153 data->cpu_priv.sysclk_id[1] = FSL_SAI_CLK_MAST1; in imx_hdmi_probe()
154 data->cpu_priv.sysclk_id[0] = FSL_SAI_CLK_MAST1; in imx_hdmi_probe()
157 if (of_device_is_compatible(np, "fsl,imx-audio-sii902x")) { in imx_hdmi_probe()
158 data->dai_fmt = SND_SOC_DAIFMT_LEFT_J; in imx_hdmi_probe()
159 data->cpu_priv.slot_width = 24; in imx_hdmi_probe()
161 data->dai_fmt = SND_SOC_DAIFMT_I2S; in imx_hdmi_probe()
162 data->cpu_priv.slot_width = 32; in imx_hdmi_probe()
166 dev_err(&pdev->dev, "Invalid HDMI DAI link\n"); in imx_hdmi_probe()
167 ret = -EINVAL; in imx_hdmi_probe()
172 data->dai.playback_only = true; in imx_hdmi_probe()
173 data->dai.capture_only = false; in imx_hdmi_probe()
174 data->dai.codecs->dai_name = "i2s-hifi"; in imx_hdmi_probe()
175 data->dai.codecs->name = "hdmi-audio-codec.1"; in imx_hdmi_probe()
176 data->dai.dai_fmt = data->dai_fmt | in imx_hdmi_probe()
182 data->dai.playback_only = false; in imx_hdmi_probe()
183 data->dai.capture_only = true; in imx_hdmi_probe()
184 data->dai.codecs->dai_name = "i2s-hifi"; in imx_hdmi_probe()
185 data->dai.codecs->name = "hdmi-audio-codec.2"; in imx_hdmi_probe()
186 data->dai.dai_fmt = data->dai_fmt | in imx_hdmi_probe()
191 data->card.dapm_widgets = imx_hdmi_widgets; in imx_hdmi_probe()
192 data->card.num_dapm_widgets = ARRAY_SIZE(imx_hdmi_widgets); in imx_hdmi_probe()
193 data->card.dev = &pdev->dev; in imx_hdmi_probe()
194 data->card.owner = THIS_MODULE; in imx_hdmi_probe()
195 ret = snd_soc_of_parse_card_name(&data->card, "model"); in imx_hdmi_probe()
199 data->card.num_links = 1; in imx_hdmi_probe()
200 data->card.dai_link = &data->dai; in imx_hdmi_probe()
202 snd_soc_card_set_drvdata(&data->card, data); in imx_hdmi_probe()
203 ret = devm_snd_soc_register_card(&pdev->dev, &data->card); in imx_hdmi_probe()
205 dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n"); in imx_hdmi_probe()
216 { .compatible = "fsl,imx-audio-hdmi", },
217 { .compatible = "fsl,imx-audio-sii902x", },
224 .name = "imx-hdmi",
233 MODULE_DESCRIPTION("Freescale i.MX hdmi audio ASoC machine driver");
235 MODULE_ALIAS("platform:imx-hdmi");