f0fba2ad1b
This patch extends the ASoC API to allow sound cards to have more than one CODEC and more than one platform DMA controller. This is achieved by dividing some current ASoC structures that contain both driver data and device data into structures that only either contain device data or driver data. i.e. struct snd_soc_codec ---> struct snd_soc_codec (device data) +-> struct snd_soc_codec_driver (driver data) struct snd_soc_platform ---> struct snd_soc_platform (device data) +-> struct snd_soc_platform_driver (driver data) struct snd_soc_dai ---> struct snd_soc_dai (device data) +-> struct snd_soc_dai_driver (driver data) struct snd_soc_device ---> deleted This now allows ASoC to be more tightly aligned with the Linux driver model and also means that every ASoC codec, platform and (platform) DAI is a kernel device. ASoC component private data is now stored as device private data. The ASoC sound card struct snd_soc_card has also been updated to store lists of it's components rather than a pointer to a codec and platform. The PCM runtime struct soc_pcm_runtime now has pointers to all its components. This patch adds DAPM support for ASoC multi-component and removes struct snd_soc_socdev from DAPM core. All DAPM calls are now made on a card, codec or runtime PCM level basis rather than using snd_soc_socdev. Other notable multi-component changes:- * Stream operations now de-reference less structures. * close_delayed work() now runs on a DAI basis rather than looping all DAIs in a card. * PM suspend()/resume() operations can now handle N CODECs and Platforms per sound card. * Added soc_bind_dai_link() to bind the component devices to the sound card. * Added soc_dai_link_probe() and soc_dai_link_remove() to probe and remove DAI link components. * sysfs entries can now be registered per component per card. * snd_soc_new_pcms() functionailty rolled into dai_link_probe(). * snd_soc_register_codec() now does all the codec list and mutex init. This patch changes the probe() and remove() of the CODEC drivers as follows:- o Make CODEC driver a platform driver o Moved all struct snd_soc_codec list, mutex, etc initialiasation to core. o Removed all static codec pointers (drivers now support > 1 codec dev) o snd_soc_register_pcms() now done by core. o snd_soc_register_dai() folded into snd_soc_register_codec(). CS4270 portions: Acked-by: Timur Tabi <timur@freescale.com> Some TLV320aic23 and Cirrus platform fixes. Signed-off-by: Ryan Mallon <ryan@bluewatersys.com> TI CODEC and OMAP fixes Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Jarkko Nikula <jhnikula@gmail.com> Samsung platform and misc fixes :- Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Jassi Brar <jassi.brar@samsung.com> Signed-off-by: Seungwhan Youn <sw.youn@samsung.com> MPC8610 and PPC fixes. Signed-off-by: Timur Tabi <timur@freescale.com> i.MX fixes and some core fixes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> J4740 platform fixes:- Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> CC: Tony Lindgren <tony@atomide.com> CC: Nicolas Ferre <nicolas.ferre@atmel.com> CC: Kevin Hilman <khilman@deeprootsystems.com> CC: Sascha Hauer <s.hauer@pengutronix.de> CC: Atsushi Nemoto <anemo@mba.ocn.ne.jp> CC: Kuninori Morimoto <morimoto.kuninori@renesas.com> CC: Daniel Gloeckner <dg@emlix.com> CC: Manuel Lauss <mano@roarinelk.homelinux.net> CC: Mike Frysinger <vapier.adi@gmail.com> CC: Arnaud Patard <apatard@mandriva.com> CC: Wan ZongShun <mcuos.com@gmail.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
274 lines
6.5 KiB
C
274 lines
6.5 KiB
C
/*
|
|
* omap-mcpdm.c -- OMAP ALSA SoC DAI driver using McPDM port
|
|
*
|
|
* Copyright (C) 2009 Texas Instruments
|
|
*
|
|
* Author: Misael Lopez Cruz <x0052729@ti.com>
|
|
* Contact: Jorge Eduardo Candelaria <x0107209@ti.com>
|
|
* Margarita Olaya <magi.olaya@ti.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* version 2 as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
* 02110-1301 USA
|
|
*
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <linux/device.h>
|
|
#include <sound/core.h>
|
|
#include <sound/pcm.h>
|
|
#include <sound/pcm_params.h>
|
|
#include <sound/initval.h>
|
|
#include <sound/soc.h>
|
|
|
|
#include <plat/control.h>
|
|
#include <plat/dma.h>
|
|
#include <plat/mcbsp.h>
|
|
#include "mcpdm.h"
|
|
#include "omap-pcm.h"
|
|
|
|
struct omap_mcpdm_data {
|
|
struct omap_mcpdm_link *links;
|
|
int active;
|
|
};
|
|
|
|
static struct omap_mcpdm_link omap_mcpdm_links[] = {
|
|
/* downlink */
|
|
{
|
|
.irq_mask = MCPDM_DN_IRQ_EMPTY | MCPDM_DN_IRQ_FULL,
|
|
.threshold = 1,
|
|
.format = PDMOUTFORMAT_LJUST,
|
|
},
|
|
/* uplink */
|
|
{
|
|
.irq_mask = MCPDM_UP_IRQ_EMPTY | MCPDM_UP_IRQ_FULL,
|
|
.threshold = 1,
|
|
.format = PDMOUTFORMAT_LJUST,
|
|
},
|
|
};
|
|
|
|
static struct omap_mcpdm_data mcpdm_data = {
|
|
.links = omap_mcpdm_links,
|
|
.active = 0,
|
|
};
|
|
|
|
/*
|
|
* Stream DMA parameters
|
|
*/
|
|
static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = {
|
|
{
|
|
.name = "Audio playback",
|
|
.dma_req = OMAP44XX_DMA_MCPDM_DL,
|
|
.data_type = OMAP_DMA_DATA_TYPE_S32,
|
|
.sync_mode = OMAP_DMA_SYNC_PACKET,
|
|
.packet_size = 16,
|
|
.port_addr = OMAP44XX_MCPDM_L3_BASE + MCPDM_DN_DATA,
|
|
},
|
|
{
|
|
.name = "Audio capture",
|
|
.dma_req = OMAP44XX_DMA_MCPDM_UP,
|
|
.data_type = OMAP_DMA_DATA_TYPE_S32,
|
|
.sync_mode = OMAP_DMA_SYNC_PACKET,
|
|
.packet_size = 16,
|
|
.port_addr = OMAP44XX_MCPDM_L3_BASE + MCPDM_UP_DATA,
|
|
},
|
|
};
|
|
|
|
static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream,
|
|
struct snd_soc_dai *dai)
|
|
{
|
|
int err = 0;
|
|
|
|
if (!dai->active)
|
|
err = omap_mcpdm_request();
|
|
|
|
return err;
|
|
}
|
|
|
|
static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream,
|
|
struct snd_soc_dai *dai)
|
|
{
|
|
if (!dai->active)
|
|
omap_mcpdm_free();
|
|
}
|
|
|
|
static int omap_mcpdm_dai_trigger(struct snd_pcm_substream *substream, int cmd,
|
|
struct snd_soc_dai *dai)
|
|
{
|
|
struct omap_mcpdm_data *mcpdm_priv = snd_soc_dai_get_drvdata(dai);
|
|
int stream = substream->stream;
|
|
int err = 0;
|
|
|
|
switch (cmd) {
|
|
case SNDRV_PCM_TRIGGER_START:
|
|
case SNDRV_PCM_TRIGGER_RESUME:
|
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
|
if (!mcpdm_priv->active++)
|
|
omap_mcpdm_start(stream);
|
|
break;
|
|
|
|
case SNDRV_PCM_TRIGGER_STOP:
|
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
|
if (!--mcpdm_priv->active)
|
|
omap_mcpdm_stop(stream);
|
|
break;
|
|
default:
|
|
err = -EINVAL;
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *params,
|
|
struct snd_soc_dai *dai)
|
|
{
|
|
struct omap_mcpdm_data *mcpdm_priv = snd_soc_dai_get_drvdata(dai);
|
|
struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links;
|
|
int stream = substream->stream;
|
|
int channels, err, link_mask = 0;
|
|
|
|
snd_soc_dai_set_dma_data(dai, substream,
|
|
&omap_mcpdm_dai_dma_params[stream]);
|
|
|
|
channels = params_channels(params);
|
|
switch (channels) {
|
|
case 4:
|
|
if (stream == SNDRV_PCM_STREAM_CAPTURE)
|
|
/* up to 2 channels for capture */
|
|
return -EINVAL;
|
|
link_mask |= 1 << 3;
|
|
case 3:
|
|
if (stream == SNDRV_PCM_STREAM_CAPTURE)
|
|
/* up to 2 channels for capture */
|
|
return -EINVAL;
|
|
link_mask |= 1 << 2;
|
|
case 2:
|
|
link_mask |= 1 << 1;
|
|
case 1:
|
|
link_mask |= 1 << 0;
|
|
break;
|
|
default:
|
|
/* unsupported number of channels */
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
|
mcpdm_links[stream].channels = link_mask << 3;
|
|
err = omap_mcpdm_playback_open(&mcpdm_links[stream]);
|
|
} else {
|
|
mcpdm_links[stream].channels = link_mask << 0;
|
|
err = omap_mcpdm_capture_open(&mcpdm_links[stream]);
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
static int omap_mcpdm_dai_hw_free(struct snd_pcm_substream *substream,
|
|
struct snd_soc_dai *dai)
|
|
{
|
|
struct omap_mcpdm_data *mcpdm_priv = snd_soc_dai_get_drvdata(dai);
|
|
struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links;
|
|
int stream = substream->stream;
|
|
int err;
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
|
err = omap_mcpdm_playback_close(&mcpdm_links[stream]);
|
|
else
|
|
err = omap_mcpdm_capture_close(&mcpdm_links[stream]);
|
|
|
|
return err;
|
|
}
|
|
|
|
static struct snd_soc_dai_ops omap_mcpdm_dai_ops = {
|
|
.startup = omap_mcpdm_dai_startup,
|
|
.shutdown = omap_mcpdm_dai_shutdown,
|
|
.trigger = omap_mcpdm_dai_trigger,
|
|
.hw_params = omap_mcpdm_dai_hw_params,
|
|
.hw_free = omap_mcpdm_dai_hw_free,
|
|
};
|
|
|
|
#define OMAP_MCPDM_RATES (SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
|
|
#define OMAP_MCPDM_FORMATS (SNDRV_PCM_FMTBIT_S32_LE)
|
|
|
|
static int omap_mcpdm_dai_probe(struct snd_soc_dai *dai)
|
|
{
|
|
snd_soc_dai_set_drvdata(dai, &mcpdm_data);
|
|
return 0;
|
|
}
|
|
|
|
static struct snd_soc_dai_driver omap_mcpdm_dai = {
|
|
.probe = omap_mcpdm_dai_probe,
|
|
.playback = {
|
|
.channels_min = 1,
|
|
.channels_max = 4,
|
|
.rates = OMAP_MCPDM_RATES,
|
|
.formats = OMAP_MCPDM_FORMATS,
|
|
},
|
|
.capture = {
|
|
.channels_min = 1,
|
|
.channels_max = 2,
|
|
.rates = OMAP_MCPDM_RATES,
|
|
.formats = OMAP_MCPDM_FORMATS,
|
|
},
|
|
.ops = &omap_mcpdm_dai_ops,
|
|
};
|
|
|
|
static __devinit int asoc_mcpdm_probe(struct platform_device *pdev)
|
|
{
|
|
int ret;
|
|
|
|
ret = omap_mcpdm_probe(pdev);
|
|
if (ret < 0)
|
|
return ret;
|
|
ret = snd_soc_register_dai(&pdev->dev, &omap_mcpdm_dai);
|
|
if (ret < 0)
|
|
omap_mcpdm_remove(pdev);
|
|
return ret;
|
|
}
|
|
|
|
static int __devexit asoc_mcpdm_remove(struct platform_device *pdev)
|
|
{
|
|
snd_soc_unregister_dai(&pdev->dev);
|
|
omap_mcpdm_remove(pdev);
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver asoc_mcpdm_driver = {
|
|
.driver = {
|
|
.name = "omap-mcpdm-dai",
|
|
.owner = THIS_MODULE,
|
|
},
|
|
|
|
.probe = asoc_mcpdm_probe,
|
|
.remove = __devexit_p(asoc_mcpdm_remove),
|
|
};
|
|
|
|
static int __init snd_omap_mcpdm_init(void)
|
|
{
|
|
return platform_driver_register(&asoc_mcpdm_driver);
|
|
}
|
|
module_init(snd_omap_mcpdm_init);
|
|
|
|
static void __exit snd_omap_mcpdm_exit(void)
|
|
{
|
|
platform_driver_unregister(&asoc_mcpdm_driver);
|
|
}
|
|
module_exit(snd_omap_mcpdm_exit);
|
|
|
|
MODULE_AUTHOR("Misael Lopez Cruz <x0052729@ti.com>");
|
|
MODULE_DESCRIPTION("OMAP PDM SoC Interface");
|
|
MODULE_LICENSE("GPL");
|