18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * ALSA SoC SPDIF DIR (Digital Interface Reciever) driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Based on ALSA SoC SPDIF DIT driver 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * This driver is used by controllers which can operate in DIR (SPDI/F) where 88c2ecf20Sopenharmony_ci * no codec is needed. This file provides stub codec that can be used 98c2ecf20Sopenharmony_ci * in these configurations. SPEAr SPDIF IN Audio controller uses this driver. 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * Author: Vipin Kumar, <vipin.kumar@st.com> 128c2ecf20Sopenharmony_ci * Copyright: (C) 2012 ST Microelectronics 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <linux/module.h> 168c2ecf20Sopenharmony_ci#include <linux/moduleparam.h> 178c2ecf20Sopenharmony_ci#include <linux/slab.h> 188c2ecf20Sopenharmony_ci#include <sound/soc.h> 198c2ecf20Sopenharmony_ci#include <sound/pcm.h> 208c2ecf20Sopenharmony_ci#include <sound/initval.h> 218c2ecf20Sopenharmony_ci#include <linux/of.h> 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget dir_widgets[] = { 248c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("spdif-in"), 258c2ecf20Sopenharmony_ci}; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route dir_routes[] = { 288c2ecf20Sopenharmony_ci { "Capture", NULL, "spdif-in" }, 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define STUB_RATES SNDRV_PCM_RATE_8000_192000 328c2ecf20Sopenharmony_ci#define STUB_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ 338c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S20_3LE | \ 348c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE | \ 358c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE | \ 368c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistatic struct snd_soc_component_driver soc_codec_spdif_dir = { 398c2ecf20Sopenharmony_ci .dapm_widgets = dir_widgets, 408c2ecf20Sopenharmony_ci .num_dapm_widgets = ARRAY_SIZE(dir_widgets), 418c2ecf20Sopenharmony_ci .dapm_routes = dir_routes, 428c2ecf20Sopenharmony_ci .num_dapm_routes = ARRAY_SIZE(dir_routes), 438c2ecf20Sopenharmony_ci .idle_bias_on = 1, 448c2ecf20Sopenharmony_ci .use_pmdown_time = 1, 458c2ecf20Sopenharmony_ci .endianness = 1, 468c2ecf20Sopenharmony_ci .non_legacy_dai_naming = 1, 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver dir_stub_dai = { 508c2ecf20Sopenharmony_ci .name = "dir-hifi", 518c2ecf20Sopenharmony_ci .capture = { 528c2ecf20Sopenharmony_ci .stream_name = "Capture", 538c2ecf20Sopenharmony_ci .channels_min = 1, 548c2ecf20Sopenharmony_ci .channels_max = 384, 558c2ecf20Sopenharmony_ci .rates = STUB_RATES, 568c2ecf20Sopenharmony_ci .formats = STUB_FORMATS, 578c2ecf20Sopenharmony_ci }, 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic int spdif_dir_probe(struct platform_device *pdev) 618c2ecf20Sopenharmony_ci{ 628c2ecf20Sopenharmony_ci return devm_snd_soc_register_component(&pdev->dev, 638c2ecf20Sopenharmony_ci &soc_codec_spdif_dir, 648c2ecf20Sopenharmony_ci &dir_stub_dai, 1); 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#ifdef CONFIG_OF 688c2ecf20Sopenharmony_cistatic const struct of_device_id spdif_dir_dt_ids[] = { 698c2ecf20Sopenharmony_ci { .compatible = "linux,spdif-dir", }, 708c2ecf20Sopenharmony_ci { } 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, spdif_dir_dt_ids); 738c2ecf20Sopenharmony_ci#endif 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistatic struct platform_driver spdif_dir_driver = { 768c2ecf20Sopenharmony_ci .probe = spdif_dir_probe, 778c2ecf20Sopenharmony_ci .driver = { 788c2ecf20Sopenharmony_ci .name = "spdif-dir", 798c2ecf20Sopenharmony_ci .of_match_table = of_match_ptr(spdif_dir_dt_ids), 808c2ecf20Sopenharmony_ci }, 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cimodule_platform_driver(spdif_dir_driver); 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("ASoC SPDIF DIR driver"); 868c2ecf20Sopenharmony_ciMODULE_AUTHOR("Vipin Kumar <vipin.kumar@st.com>"); 878c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 88