Lines Matching +full:iec +full:- +full:60958

1 // SPDX-License-Identifier: GPL-2.0-only
3 * omap-hdmi-audio.c -- OMAP4+ DSS HDMI audio support library
5 * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com
20 #include <sound/omap-hdmi-audio.h>
22 #include "sdma-pcm.h"
24 #define DRV_NAME "omap-hdmi-audio"
33 struct snd_aes_iec958 iec; member
43 struct snd_soc_pcm_runtime *rtd = ss->private_data; in card_drvdata_substream()
45 return snd_soc_card_get_drvdata(rtd->card); in card_drvdata_substream()
52 mutex_lock(&ad->current_stream_lock); in hdmi_dai_abort()
53 if (ad->current_stream && ad->current_stream->runtime && in hdmi_dai_abort()
54 snd_pcm_running(ad->current_stream)) { in hdmi_dai_abort()
56 snd_pcm_stream_lock_irq(ad->current_stream); in hdmi_dai_abort()
57 snd_pcm_stop(ad->current_stream, SNDRV_PCM_STATE_DISCONNECTED); in hdmi_dai_abort()
58 snd_pcm_stream_unlock_irq(ad->current_stream); in hdmi_dai_abort()
60 mutex_unlock(&ad->current_stream_lock); in hdmi_dai_abort()
70 * Largest packet size we use is 32 32-bit words = 128 bytes in hdmi_dai_startup()
72 ret = snd_pcm_hw_constraint_step(substream->runtime, 0, in hdmi_dai_startup()
75 dev_err(dai->dev, "Could not apply period constraint: %d\n", in hdmi_dai_startup()
79 ret = snd_pcm_hw_constraint_step(substream->runtime, 0, in hdmi_dai_startup()
82 dev_err(dai->dev, "Could not apply buffer constraint: %d\n", in hdmi_dai_startup()
87 snd_soc_dai_set_dma_data(dai, substream, &ad->dma_data); in hdmi_dai_startup()
89 mutex_lock(&ad->current_stream_lock); in hdmi_dai_startup()
90 ad->current_stream = substream; in hdmi_dai_startup()
91 mutex_unlock(&ad->current_stream_lock); in hdmi_dai_startup()
93 ret = ad->ops->audio_startup(ad->dssdev, hdmi_dai_abort); in hdmi_dai_startup()
96 mutex_lock(&ad->current_stream_lock); in hdmi_dai_startup()
97 ad->current_stream = NULL; in hdmi_dai_startup()
98 mutex_unlock(&ad->current_stream_lock); in hdmi_dai_startup()
109 struct snd_aes_iec958 *iec = &ad->iec; in hdmi_dai_hw_params() local
110 struct snd_cea_861_aud_if *cea = &ad->cea; in hdmi_dai_hw_params()
112 WARN_ON(ad->current_stream != substream); in hdmi_dai_hw_params()
116 ad->dma_data.maxburst = 16; in hdmi_dai_hw_params()
119 ad->dma_data.maxburst = 32; in hdmi_dai_hw_params()
122 dev_err(dai->dev, "format not supported!\n"); in hdmi_dai_hw_params()
123 return -EINVAL; in hdmi_dai_hw_params()
126 ad->dss_audio.iec = iec; in hdmi_dai_hw_params()
127 ad->dss_audio.cea = cea; in hdmi_dai_hw_params()
129 * fill the IEC-60958 channel status word in hdmi_dai_hw_params()
132 memset(iec->status, 0, sizeof(iec->status)); in hdmi_dai_hw_params()
134 /* specify IEC-60958-3 (commercial use) */ in hdmi_dai_hw_params()
135 iec->status[0] &= ~IEC958_AES0_PROFESSIONAL; in hdmi_dai_hw_params()
138 iec->status[0] &= ~IEC958_AES0_NONAUDIO; in hdmi_dai_hw_params()
140 iec->status[0] |= IEC958_AES0_CON_NOT_COPYRIGHT; in hdmi_dai_hw_params()
142 iec->status[0] |= IEC958_AES0_CON_EMPHASIS_NONE; in hdmi_dai_hw_params()
144 iec->status[1] = IEC958_AES1_CON_GENERAL; in hdmi_dai_hw_params()
146 iec->status[2] |= IEC958_AES2_CON_SOURCE_UNSPEC; in hdmi_dai_hw_params()
148 iec->status[2] |= IEC958_AES2_CON_CHANNEL_UNSPEC; in hdmi_dai_hw_params()
152 iec->status[3] |= IEC958_AES3_CON_FS_32000; in hdmi_dai_hw_params()
155 iec->status[3] |= IEC958_AES3_CON_FS_44100; in hdmi_dai_hw_params()
158 iec->status[3] |= IEC958_AES3_CON_FS_48000; in hdmi_dai_hw_params()
161 iec->status[3] |= IEC958_AES3_CON_FS_88200; in hdmi_dai_hw_params()
164 iec->status[3] |= IEC958_AES3_CON_FS_96000; in hdmi_dai_hw_params()
167 iec->status[3] |= IEC958_AES3_CON_FS_176400; in hdmi_dai_hw_params()
170 iec->status[3] |= IEC958_AES3_CON_FS_192000; in hdmi_dai_hw_params()
173 dev_err(dai->dev, "rate not supported!\n"); in hdmi_dai_hw_params()
174 return -EINVAL; in hdmi_dai_hw_params()
178 iec->status[3] |= IEC958_AES3_CON_CLOCK_1000PPM; in hdmi_dai_hw_params()
187 iec->status[4] |= IEC958_AES4_CON_WORDLEN_20_16; in hdmi_dai_hw_params()
188 iec->status[4] &= ~IEC958_AES4_CON_MAX_WORDLEN_24; in hdmi_dai_hw_params()
191 iec->status[4] |= IEC958_AES4_CON_WORDLEN_24_20; in hdmi_dai_hw_params()
192 iec->status[4] |= IEC958_AES4_CON_MAX_WORDLEN_24; in hdmi_dai_hw_params()
195 dev_err(dai->dev, "format not supported!\n"); in hdmi_dai_hw_params()
196 return -EINVAL; in hdmi_dai_hw_params()
200 * Fill the CEA-861 audio infoframe (see spec for details) in hdmi_dai_hw_params()
203 cea->db1_ct_cc = (params_channels(params) - 1) in hdmi_dai_hw_params()
205 cea->db1_ct_cc |= CEA861_AUDIO_INFOFRAME_DB1CT_FROM_STREAM; in hdmi_dai_hw_params()
207 cea->db2_sf_ss = CEA861_AUDIO_INFOFRAME_DB2SF_FROM_STREAM; in hdmi_dai_hw_params()
208 cea->db2_sf_ss |= CEA861_AUDIO_INFOFRAME_DB2SS_FROM_STREAM; in hdmi_dai_hw_params()
210 cea->db3 = 0; /* not used, all zeros */ in hdmi_dai_hw_params()
213 cea->db4_ca = 0x0; in hdmi_dai_hw_params()
215 cea->db4_ca = 0xb; in hdmi_dai_hw_params()
217 cea->db4_ca = 0x13; in hdmi_dai_hw_params()
219 if (cea->db4_ca == 0x00) in hdmi_dai_hw_params()
220 cea->db5_dminh_lsv = CEA861_AUDIO_INFOFRAME_DB5_DM_INH_PERMITTED; in hdmi_dai_hw_params()
222 cea->db5_dminh_lsv = CEA861_AUDIO_INFOFRAME_DB5_DM_INH_PROHIBITED; in hdmi_dai_hw_params()
225 cea->db5_dminh_lsv |= (0 & CEA861_AUDIO_INFOFRAME_DB5_LSV); in hdmi_dai_hw_params()
227 return ad->ops->audio_config(ad->dssdev, &ad->dss_audio); in hdmi_dai_hw_params()
236 WARN_ON(ad->current_stream != substream); in hdmi_dai_trigger()
242 err = ad->ops->audio_start(ad->dssdev); in hdmi_dai_trigger()
247 ad->ops->audio_stop(ad->dssdev); in hdmi_dai_trigger()
250 err = -EINVAL; in hdmi_dai_trigger()
260 WARN_ON(ad->current_stream != substream); in hdmi_dai_shutdown()
262 ad->ops->audio_shutdown(ad->dssdev); in hdmi_dai_shutdown()
264 mutex_lock(&ad->current_stream_lock); in hdmi_dai_shutdown()
265 ad->current_stream = NULL; in hdmi_dai_shutdown()
266 mutex_unlock(&ad->current_stream_lock); in hdmi_dai_shutdown()
281 .name = "omap5-hdmi-dai",
295 .name = "omap4-hdmi-dai",
310 struct omap_hdmi_audio_pdata *ha = pdev->dev.platform_data; in omap_hdmi_audio_probe()
311 struct device *dev = &pdev->dev; in omap_hdmi_audio_probe()
320 return -EINVAL; in omap_hdmi_audio_probe()
325 return -ENOMEM; in omap_hdmi_audio_probe()
326 ad->dssdev = ha->dev; in omap_hdmi_audio_probe()
327 ad->ops = ha->ops; in omap_hdmi_audio_probe()
328 ad->dma_data.addr = ha->audio_dma_addr; in omap_hdmi_audio_probe()
329 ad->dma_data.filter_data = "audio_tx"; in omap_hdmi_audio_probe()
330 ad->dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in omap_hdmi_audio_probe()
331 mutex_init(&ad->current_stream_lock); in omap_hdmi_audio_probe()
333 switch (ha->version) { in omap_hdmi_audio_probe()
341 return -EINVAL; in omap_hdmi_audio_probe()
343 ret = devm_snd_soc_register_component(ad->dssdev, &omap_hdmi_component, in omap_hdmi_audio_probe()
348 ret = sdma_pcm_platform_register(ad->dssdev, "audio_tx", NULL); in omap_hdmi_audio_probe()
354 return -ENOMEM; in omap_hdmi_audio_probe()
356 card->name = devm_kasprintf(dev, GFP_KERNEL, in omap_hdmi_audio_probe()
357 "HDMI %s", dev_name(ad->dssdev)); in omap_hdmi_audio_probe()
358 if (!card->name) in omap_hdmi_audio_probe()
359 return -ENOMEM; in omap_hdmi_audio_probe()
361 card->owner = THIS_MODULE; in omap_hdmi_audio_probe()
362 card->dai_link = in omap_hdmi_audio_probe()
363 devm_kzalloc(dev, sizeof(*(card->dai_link)), GFP_KERNEL); in omap_hdmi_audio_probe()
364 if (!card->dai_link) in omap_hdmi_audio_probe()
365 return -ENOMEM; in omap_hdmi_audio_probe()
369 return -ENOMEM; in omap_hdmi_audio_probe()
370 card->dai_link->cpus = &compnent[0]; in omap_hdmi_audio_probe()
371 card->dai_link->num_cpus = 1; in omap_hdmi_audio_probe()
372 card->dai_link->codecs = &compnent[1]; in omap_hdmi_audio_probe()
373 card->dai_link->num_codecs = 1; in omap_hdmi_audio_probe()
374 card->dai_link->platforms = &compnent[2]; in omap_hdmi_audio_probe()
375 card->dai_link->num_platforms = 1; in omap_hdmi_audio_probe()
377 card->dai_link->name = card->name; in omap_hdmi_audio_probe()
378 card->dai_link->stream_name = card->name; in omap_hdmi_audio_probe()
379 card->dai_link->cpus->dai_name = dev_name(ad->dssdev); in omap_hdmi_audio_probe()
380 card->dai_link->platforms->name = dev_name(ad->dssdev); in omap_hdmi_audio_probe()
381 card->dai_link->codecs->name = "snd-soc-dummy"; in omap_hdmi_audio_probe()
382 card->dai_link->codecs->dai_name = "snd-soc-dummy-dai"; in omap_hdmi_audio_probe()
383 card->num_links = 1; in omap_hdmi_audio_probe()
384 card->dev = dev; in omap_hdmi_audio_probe()
392 ad->card = card; in omap_hdmi_audio_probe()
404 snd_soc_unregister_card(ad->card); in omap_hdmi_audio_remove()