Root/sound/soc/jz4740/jz4740-pcm.c

Source at commit 654fa4606ec498505bac64ceb8c5ccffb18da55d created 10 years 7 months ago.
By Lars-Peter Clausen, ASoC: jz4740: Use the generic dmaengine PCM driver
1/*
2 * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * You should have received a copy of the GNU General Public License along
10 * with this program; if not, write to the Free Software Foundation, Inc.,
11 * 675 Mass Ave, Cambridge, MA 02139, USA.
12 *
13 */
14
15#include <linux/init.h>
16#include <linux/interrupt.h>
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20#include <linux/slab.h>
21
22#include <sound/dmaengine_pcm.h>
23
24static const struct snd_pcm_hardware jz4740_pcm_hardware = {
25    .info = SNDRV_PCM_INFO_MMAP |
26        SNDRV_PCM_INFO_MMAP_VALID |
27        SNDRV_PCM_INFO_INTERLEAVED |
28        SNDRV_PCM_INFO_BLOCK_TRANSFER,
29    .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8,
30    .period_bytes_min = 16,
31    .period_bytes_max = 2 * PAGE_SIZE,
32    .periods_min = 2,
33    .periods_max = 128,
34    .buffer_bytes_max = 128 * 2 * PAGE_SIZE,
35    .fifo_size = 32,
36};
37
38static const struct snd_dmaengine_pcm_config jz4740_dmaengine_pcm_config = {
39    .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
40    .pcm_hardware = &jz4740_pcm_hardware,
41    .prealloc_buffer_size = 256 * PAGE_SIZE,
42};
43
44static int jz4740_pcm_probe(struct platform_device *pdev)
45{
46    return snd_dmaengine_pcm_register(&pdev->dev, &jz4740_dmaengine_pcm_config,
47        SND_DMAENGINE_PCM_FLAG_COMPAT);
48}
49
50static int jz4740_pcm_remove(struct platform_device *pdev)
51{
52    snd_dmaengine_pcm_unregister(&pdev->dev);
53    return 0;
54}
55
56static struct platform_driver jz4740_pcm_driver = {
57    .probe = jz4740_pcm_probe,
58    .remove = jz4740_pcm_remove,
59    .driver = {
60        .name = "jz4740-pcm-audio",
61        .owner = THIS_MODULE,
62    },
63};
64
65module_platform_driver(jz4740_pcm_driver);
66
67MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
68MODULE_DESCRIPTION("Ingenic SoC JZ4740 PCM driver");
69MODULE_LICENSE("GPL");
70

Archive Download this file



interactive