Path: blob/master/sound/soc/blackfin/bf5xx-ad1836.c
10817 views
/*1* File: sound/soc/blackfin/bf5xx-ad1836.c2* Author: Barry Song <[email protected]>3*4* Created: Aug 4 20095* Description: Board driver for ad1836 sound chip6*7* Bugs: Enter bugs at http://blackfin.uclinux.org/8*9* This program is free software; you can redistribute it and/or modify10* it under the terms of the GNU General Public License as published by11* the Free Software Foundation; either version 2 of the License, or12* (at your option) any later version.13*14*/1516#include <linux/module.h>17#include <linux/moduleparam.h>18#include <linux/device.h>19#include <sound/core.h>20#include <sound/pcm.h>21#include <sound/soc.h>22#include <sound/pcm_params.h>2324#include <asm/blackfin.h>25#include <asm/cacheflush.h>26#include <asm/irq.h>27#include <asm/dma.h>28#include <asm/portmux.h>2930#include "../codecs/ad1836.h"3132#include "bf5xx-tdm-pcm.h"33#include "bf5xx-tdm.h"3435static struct snd_soc_card bf5xx_ad1836;3637static int bf5xx_ad1836_hw_params(struct snd_pcm_substream *substream,38struct snd_pcm_hw_params *params)39{40struct snd_soc_pcm_runtime *rtd = substream->private_data;41struct snd_soc_dai *cpu_dai = rtd->cpu_dai;42struct snd_soc_dai *codec_dai = rtd->codec_dai;43unsigned int channel_map[] = {0, 4, 1, 5, 2, 6, 3, 7};44int ret = 0;45/* set cpu DAI configuration */46ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A |47SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM);48if (ret < 0)49return ret;5051/* set codec DAI configuration */52ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A |53SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM);54if (ret < 0)55return ret;5657/* set cpu DAI channel mapping */58ret = snd_soc_dai_set_channel_map(cpu_dai, ARRAY_SIZE(channel_map),59channel_map, ARRAY_SIZE(channel_map), channel_map);60if (ret < 0)61return ret;6263return 0;64}6566static struct snd_soc_ops bf5xx_ad1836_ops = {67.hw_params = bf5xx_ad1836_hw_params,68};6970static struct snd_soc_dai_link bf5xx_ad1836_dai[] = {71{72.name = "ad1836",73.stream_name = "AD1836",74.cpu_dai_name = "bfin-tdm.0",75.codec_dai_name = "ad1836-hifi",76.platform_name = "bfin-tdm-pcm-audio",77.codec_name = "spi0.4",78.ops = &bf5xx_ad1836_ops,79},80{81.name = "ad1836",82.stream_name = "AD1836",83.cpu_dai_name = "bfin-tdm.1",84.codec_dai_name = "ad1836-hifi",85.platform_name = "bfin-tdm-pcm-audio",86.codec_name = "spi0.4",87.ops = &bf5xx_ad1836_ops,88},89};9091static struct snd_soc_card bf5xx_ad1836 = {92.name = "bfin-ad1836",93.dai_link = &bf5xx_ad1836_dai[CONFIG_SND_BF5XX_SPORT_NUM],94.num_links = 1,95};9697static struct platform_device *bfxx_ad1836_snd_device;9899static int __init bf5xx_ad1836_init(void)100{101int ret;102103bfxx_ad1836_snd_device = platform_device_alloc("soc-audio", -1);104if (!bfxx_ad1836_snd_device)105return -ENOMEM;106107platform_set_drvdata(bfxx_ad1836_snd_device, &bf5xx_ad1836);108ret = platform_device_add(bfxx_ad1836_snd_device);109110if (ret)111platform_device_put(bfxx_ad1836_snd_device);112113return ret;114}115116static void __exit bf5xx_ad1836_exit(void)117{118platform_device_unregister(bfxx_ad1836_snd_device);119}120121module_init(bf5xx_ad1836_init);122module_exit(bf5xx_ad1836_exit);123124/* Module information */125MODULE_AUTHOR("Barry Song");126MODULE_DESCRIPTION("ALSA SoC AD1836 board driver");127MODULE_LICENSE("GPL");128129130131