Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * ALSA SoC SPDIF DIR (Digital Interface Reciever) driver
0004  *
0005  * Based on ALSA SoC SPDIF DIT driver
0006  *
0007  *  This driver is used by controllers which can operate in DIR (SPDI/F) where
0008  *  no codec is needed.  This file provides stub codec that can be used
0009  *  in these configurations. SPEAr SPDIF IN Audio controller uses this driver.
0010  *
0011  * Author:      Vipin Kumar,  <vipin.kumar@st.com>
0012  * Copyright:   (C) 2012  ST Microelectronics
0013  */
0014 
0015 #include <linux/module.h>
0016 #include <linux/moduleparam.h>
0017 #include <linux/slab.h>
0018 #include <sound/soc.h>
0019 #include <sound/pcm.h>
0020 #include <sound/initval.h>
0021 #include <linux/of.h>
0022 
0023 static const struct snd_soc_dapm_widget dir_widgets[] = {
0024     SND_SOC_DAPM_INPUT("spdif-in"),
0025 };
0026 
0027 static const struct snd_soc_dapm_route dir_routes[] = {
0028     { "Capture", NULL, "spdif-in" },
0029 };
0030 
0031 #define STUB_RATES  SNDRV_PCM_RATE_8000_192000
0032 #define STUB_FORMATS    (SNDRV_PCM_FMTBIT_S16_LE | \
0033             SNDRV_PCM_FMTBIT_S20_3LE | \
0034             SNDRV_PCM_FMTBIT_S24_LE  | \
0035             SNDRV_PCM_FMTBIT_S32_LE | \
0036             SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
0037 
0038 static struct snd_soc_component_driver soc_codec_spdif_dir = {
0039     .dapm_widgets       = dir_widgets,
0040     .num_dapm_widgets   = ARRAY_SIZE(dir_widgets),
0041     .dapm_routes        = dir_routes,
0042     .num_dapm_routes    = ARRAY_SIZE(dir_routes),
0043     .idle_bias_on       = 1,
0044     .use_pmdown_time    = 1,
0045     .endianness     = 1,
0046 };
0047 
0048 static struct snd_soc_dai_driver dir_stub_dai = {
0049     .name       = "dir-hifi",
0050     .capture    = {
0051         .stream_name    = "Capture",
0052         .channels_min   = 1,
0053         .channels_max   = 384,
0054         .rates      = STUB_RATES,
0055         .formats    = STUB_FORMATS,
0056     },
0057 };
0058 
0059 static int spdif_dir_probe(struct platform_device *pdev)
0060 {
0061     return devm_snd_soc_register_component(&pdev->dev,
0062             &soc_codec_spdif_dir,
0063             &dir_stub_dai, 1);
0064 }
0065 
0066 #ifdef CONFIG_OF
0067 static const struct of_device_id spdif_dir_dt_ids[] = {
0068     { .compatible = "linux,spdif-dir", },
0069     { }
0070 };
0071 MODULE_DEVICE_TABLE(of, spdif_dir_dt_ids);
0072 #endif
0073 
0074 static struct platform_driver spdif_dir_driver = {
0075     .probe      = spdif_dir_probe,
0076     .driver     = {
0077         .name   = "spdif-dir",
0078         .of_match_table = of_match_ptr(spdif_dir_dt_ids),
0079     },
0080 };
0081 
0082 module_platform_driver(spdif_dir_driver);
0083 
0084 MODULE_DESCRIPTION("ASoC SPDIF DIR driver");
0085 MODULE_AUTHOR("Vipin Kumar <vipin.kumar@st.com>");
0086 MODULE_LICENSE("GPL");