linux/sound/soc/xilinx/xilinx-dp-pcm.c
<<
>>
Prefs
   1/*
   2 * Xilinx DisplayPort Sound PCM 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/device.h>
  19#include <linux/module.h>
  20#include <linux/platform_device.h>
  21
  22#include <sound/dmaengine_pcm.h>
  23#include <sound/pcm.h>
  24#include <sound/soc.h>
  25
  26static const struct snd_pcm_hardware xilinx_pcm_hw = {
  27        .info                   = SNDRV_PCM_INFO_MMAP |
  28                                  SNDRV_PCM_INFO_MMAP_VALID |
  29                                  SNDRV_PCM_INFO_INTERLEAVED |
  30                                  SNDRV_PCM_INFO_PAUSE |
  31                                  SNDRV_PCM_INFO_RESUME |
  32                                  SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
  33        .buffer_bytes_max       = 128 * 1024,
  34        .period_bytes_min       = 256,
  35        .period_bytes_max       = 1024 * 1024,
  36        .periods_min            = 2,
  37        .periods_max            = 256,
  38};
  39
  40static const struct snd_dmaengine_pcm_config xilinx_dmaengine_pcm_config = {
  41        .pcm_hardware = &xilinx_pcm_hw,
  42        .prealloc_buffer_size = 64 * 1024,
  43};
  44
  45static int xilinx_dp_pcm_probe(struct platform_device *pdev)
  46{
  47        int ret;
  48
  49        dev_set_name(&pdev->dev, pdev->dev.of_node->name);
  50        ret = devm_snd_dmaengine_pcm_register(&pdev->dev,
  51                                              &xilinx_dmaengine_pcm_config, 0);
  52        if (ret)
  53                return ret;
  54
  55        dev_info(&pdev->dev, "Xilinx DisplayPort Sound PCM probed\n");
  56
  57        return 0;
  58}
  59
  60static const struct of_device_id xilinx_dp_pcm_of_match[] = {
  61        { .compatible = "xlnx,dp-snd-pcm", },
  62        { /* end of table */ },
  63};
  64MODULE_DEVICE_TABLE(of, xilinx_dp_pcm_of_match);
  65
  66static struct platform_driver xilinx_dp_pcm_driver = {
  67        .driver = {
  68                .name           = "xilinx-dp-snd-pcm",
  69                .of_match_table = xilinx_dp_pcm_of_match,
  70        },
  71        .probe  = xilinx_dp_pcm_probe,
  72};
  73module_platform_driver(xilinx_dp_pcm_driver);
  74
  75MODULE_DESCRIPTION("Xilinx DisplayPort Sound PCM module");
  76MODULE_LICENSE("GPL v2");
  77