Lines Matching +full:capture +full:- +full:channels

1 // SPDX-License-Identifier: GPL-2.0
32 u32 channels; member
44 return -EINVAL; in xlnx_i2s_set_sclkout_div()
46 drv_data->sysclk = 0; in xlnx_i2s_set_sclkout_div()
48 writel(div, drv_data->base + I2S_I2STIM_OFFSET); in xlnx_i2s_set_sclkout_div()
58 drv_data->sysclk = freq; in xlnx_i2s_set_sysclk()
62 if (drv_data->is_32bit_lrclk) in xlnx_i2s_set_sysclk()
65 bits_per_sample = drv_data->data_width; in xlnx_i2s_set_sysclk()
67 drv_data->ratnum.num = freq / (bits_per_sample * drv_data->channels) / 2; in xlnx_i2s_set_sysclk()
68 drv_data->ratnum.den_step = 1; in xlnx_i2s_set_sysclk()
69 drv_data->ratnum.den_min = 1; in xlnx_i2s_set_sysclk()
70 drv_data->ratnum.den_max = 255; in xlnx_i2s_set_sysclk()
71 drv_data->rate_constraints.rats = &drv_data->ratnum; in xlnx_i2s_set_sysclk()
72 drv_data->rate_constraints.nrats = 1; in xlnx_i2s_set_sysclk()
82 if (drv_data->sysclk) in xlnx_i2s_startup()
83 return snd_pcm_hw_constraint_ratnums(substream->runtime, 0, in xlnx_i2s_startup()
85 &drv_data->rate_constraints); in xlnx_i2s_startup()
97 if (drv_data->sysclk) { in xlnx_i2s_hw_params()
100 if (drv_data->is_32bit_lrclk) in xlnx_i2s_hw_params()
103 bits_per_sample = drv_data->data_width; in xlnx_i2s_hw_params()
106 sclk_div = drv_data->sysclk / sclk / 2; in xlnx_i2s_hw_params()
108 if ((drv_data->sysclk % sclk != 0) || in xlnx_i2s_hw_params()
110 dev_warn(i2s_dai->dev, "invalid SCLK divisor for sysclk %u and sclk %u\n", in xlnx_i2s_hw_params()
111 drv_data->sysclk, sclk); in xlnx_i2s_hw_params()
112 return -EINVAL; in xlnx_i2s_hw_params()
114 writel(sclk_div, drv_data->base + I2S_I2STIM_OFFSET); in xlnx_i2s_hw_params()
120 reg_off = I2S_CH0_OFFSET + ((chan_id - 1) * 4); in xlnx_i2s_hw_params()
121 writel(chan_id, drv_data->base + reg_off); in xlnx_i2s_hw_params()
122 chan_id--; in xlnx_i2s_hw_params()
137 writel(I2S_CORE_CTRL_ENABLE, drv_data->base + I2S_CORE_CTRL_OFFSET); in xlnx_i2s_trigger()
142 writel(0, drv_data->base + I2S_CORE_CTRL_OFFSET); in xlnx_i2s_trigger()
145 return -EINVAL; in xlnx_i2s_trigger()
165 { .compatible = "xlnx,i2s-transmitter-1.0", },
166 { .compatible = "xlnx,i2s-receiver-1.0", },
176 struct device *dev = &pdev->dev; in xlnx_i2s_probe()
177 struct device_node *node = dev->of_node; in xlnx_i2s_probe()
179 drv_data = devm_kzalloc(&pdev->dev, sizeof(*drv_data), GFP_KERNEL); in xlnx_i2s_probe()
181 return -ENOMEM; in xlnx_i2s_probe()
183 drv_data->base = devm_platform_ioremap_resource(pdev, 0); in xlnx_i2s_probe()
184 if (IS_ERR(drv_data->base)) in xlnx_i2s_probe()
185 return PTR_ERR(drv_data->base); in xlnx_i2s_probe()
187 ret = of_property_read_u32(node, "xlnx,num-channels", &drv_data->channels); in xlnx_i2s_probe()
189 dev_err(dev, "cannot get supported channels\n"); in xlnx_i2s_probe()
192 drv_data->channels *= 2; in xlnx_i2s_probe()
194 ret = of_property_read_u32(node, "xlnx,dwidth", &drv_data->data_width); in xlnx_i2s_probe()
199 switch (drv_data->data_width) { in xlnx_i2s_probe()
207 return -EINVAL; in xlnx_i2s_probe()
210 if (of_device_is_compatible(node, "xlnx,i2s-transmitter-1.0")) { in xlnx_i2s_probe()
211 drv_data->dai_drv.name = "xlnx_i2s_playback"; in xlnx_i2s_probe()
212 drv_data->dai_drv.playback.stream_name = "Playback"; in xlnx_i2s_probe()
213 drv_data->dai_drv.playback.formats = format; in xlnx_i2s_probe()
214 drv_data->dai_drv.playback.channels_min = drv_data->channels; in xlnx_i2s_probe()
215 drv_data->dai_drv.playback.channels_max = drv_data->channels; in xlnx_i2s_probe()
216 drv_data->dai_drv.playback.rates = SNDRV_PCM_RATE_8000_192000; in xlnx_i2s_probe()
217 drv_data->dai_drv.ops = &xlnx_i2s_dai_ops; in xlnx_i2s_probe()
218 } else if (of_device_is_compatible(node, "xlnx,i2s-receiver-1.0")) { in xlnx_i2s_probe()
219 drv_data->dai_drv.name = "xlnx_i2s_capture"; in xlnx_i2s_probe()
220 drv_data->dai_drv.capture.stream_name = "Capture"; in xlnx_i2s_probe()
221 drv_data->dai_drv.capture.formats = format; in xlnx_i2s_probe()
222 drv_data->dai_drv.capture.channels_min = drv_data->channels; in xlnx_i2s_probe()
223 drv_data->dai_drv.capture.channels_max = drv_data->channels; in xlnx_i2s_probe()
224 drv_data->dai_drv.capture.rates = SNDRV_PCM_RATE_8000_192000; in xlnx_i2s_probe()
225 drv_data->dai_drv.ops = &xlnx_i2s_dai_ops; in xlnx_i2s_probe()
227 return -ENODEV; in xlnx_i2s_probe()
229 drv_data->is_32bit_lrclk = readl(drv_data->base + I2S_CORE_CTRL_OFFSET) & in xlnx_i2s_probe()
232 dev_set_drvdata(&pdev->dev, drv_data); in xlnx_i2s_probe()
234 ret = devm_snd_soc_register_component(&pdev->dev, &xlnx_i2s_component, in xlnx_i2s_probe()
235 &drv_data->dai_drv, 1); in xlnx_i2s_probe()
237 dev_err(&pdev->dev, "i2s component registration failed\n"); in xlnx_i2s_probe()
241 dev_info(&pdev->dev, "%s DAI registered\n", drv_data->dai_drv.name); in xlnx_i2s_probe()