linux/sound/soc/xilinx/xilinx-dp-card.c
<<
>>
Prefs
   1/*
   2 * Xilinx DisplayPort SoC Sound Card support
   3 *
   4 *  Copyright (C) 2015 Xilinx, Inc.
   5 *
   6 *  Author: Hyun Woo Kwon <hyunk@xilinx.com>
   7 *
   8 * This software is licensed under the terms of the GNU General Public
   9 * License version 2, as published by the Free Software Foundation, and
  10 * may be copied, distributed, and modified under those terms.
  11 *
  12 * This program is distributed in the hope that it will be useful,
  13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15 * GNU General Public License for more details.
  16 */
  17
  18#include <linux/module.h>
  19#include <linux/of.h>
  20#include <linux/platform_device.h>
  21
  22#include <sound/soc.h>
  23
  24static int xilinx_dp_startup(struct snd_pcm_substream *substream)
  25{
  26        struct snd_pcm_runtime *runtime = substream->runtime;
  27
  28        snd_pcm_hw_constraint_step(runtime, 0,
  29                                   SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 256);
  30        return 0;
  31}
  32
  33static const struct snd_soc_ops xilinx_dp_ops = {
  34        .startup        = xilinx_dp_startup,
  35};
  36
  37static struct snd_soc_dai_link xilinx_dp_dai_links[] = {
  38        {
  39                .name           = "xilinx-dp0",
  40                .codec_dai_name = "xilinx-dp-snd-codec-dai",
  41                .ops            = &xilinx_dp_ops,
  42        },
  43        {
  44                .name           = "xilinx-dp1",
  45                .codec_dai_name = "xilinx-dp-snd-codec-dai",
  46                .ops            = &xilinx_dp_ops,
  47        },
  48
  49};
  50
  51static struct snd_soc_card xilinx_dp_card = {
  52        .name           = "DisplayPort monitor",
  53        .owner          = THIS_MODULE,
  54        .dai_link       = xilinx_dp_dai_links,
  55        .num_links      = 2,
  56};
  57
  58static int xilinx_dp_probe(struct platform_device *pdev)
  59{
  60        struct snd_soc_card *card = &xilinx_dp_card;
  61        struct device_node *node = pdev->dev.of_node;
  62        struct device_node *codec, *pcm;
  63        int ret;
  64
  65        card->dev = &pdev->dev;
  66
  67        codec = of_parse_phandle(node, "xlnx,dp-snd-codec", 0);
  68        if (!codec)
  69                return -ENODEV;
  70
  71        pcm = of_parse_phandle(node, "xlnx,dp-snd-pcm", 0);
  72        if (!pcm)
  73                return -ENODEV;
  74        xilinx_dp_dai_links[0].platform_of_node = pcm;
  75        xilinx_dp_dai_links[0].cpu_of_node = codec;
  76        xilinx_dp_dai_links[0].codec_of_node = codec;
  77
  78        pcm = of_parse_phandle(node, "xlnx,dp-snd-pcm", 1);
  79        if (!pcm)
  80                return -ENODEV;
  81        xilinx_dp_dai_links[1].platform_of_node = pcm;
  82        xilinx_dp_dai_links[1].cpu_of_node = codec;
  83        xilinx_dp_dai_links[1].codec_of_node = codec;
  84
  85        ret = devm_snd_soc_register_card(&pdev->dev, card);
  86        if (ret)
  87                return ret;
  88
  89        dev_info(&pdev->dev, "Xilinx DisplayPort Sound Card probed\n");
  90
  91        return 0;
  92}
  93
  94static int xilinx_dp_remove(struct platform_device *pdev)
  95{
  96        return 0;
  97}
  98
  99static const struct of_device_id xilinx_dp_of_match[] = {
 100        { .compatible = "xlnx,dp-snd-card", },
 101        {},
 102};
 103MODULE_DEVICE_TABLE(of, xilinx_dp_of_match);
 104
 105static struct platform_driver xilinx_dp_aud_driver = {
 106        .driver = {
 107                .name           = "xilinx-dp-snd-card",
 108                .of_match_table = xilinx_dp_of_match,
 109                .pm             = &snd_soc_pm_ops,
 110        },
 111        .probe  = xilinx_dp_probe,
 112        .remove = xilinx_dp_remove,
 113};
 114module_platform_driver(xilinx_dp_aud_driver);
 115
 116MODULE_DESCRIPTION("Xilinx DisplayPort Sound Card module");
 117MODULE_LICENSE("GPL v2");
 118