2019-05-29 17:57:50 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2010-08-20 03:32:46 -06:00
|
|
|
/*
|
|
|
|
* ALSA SoC WL1273 codec driver
|
|
|
|
*
|
|
|
|
* Author: Matti Aaltonen, <matti.j.aaltonen@nokia.com>
|
|
|
|
*
|
2011-03-01 06:10:37 -07:00
|
|
|
* Copyright: (C) 2010, 2011 Nokia Corporation
|
2010-08-20 03:32:46 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/mfd/wl1273-core.h>
|
|
|
|
#include <linux/slab.h>
|
2011-07-15 10:38:28 -06:00
|
|
|
#include <linux/module.h>
|
2010-08-20 03:32:46 -06:00
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/pcm_params.h>
|
2010-11-21 10:48:46 -07:00
|
|
|
#include <sound/soc.h>
|
2010-08-20 03:32:46 -06:00
|
|
|
#include <sound/initval.h>
|
|
|
|
|
|
|
|
#include "wl1273.h"
|
|
|
|
|
|
|
|
enum wl1273_mode { WL1273_MODE_BT, WL1273_MODE_FM_RX, WL1273_MODE_FM_TX };
|
|
|
|
|
|
|
|
/* codec private data */
|
|
|
|
struct wl1273_priv {
|
|
|
|
enum wl1273_mode mode;
|
|
|
|
struct wl1273_core *core;
|
|
|
|
unsigned int channels;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int snd_wl1273_fm_set_i2s_mode(struct wl1273_core *core,
|
|
|
|
int rate, int width)
|
|
|
|
{
|
2011-01-13 06:22:45 -07:00
|
|
|
struct device *dev = &core->client->dev;
|
2010-08-20 03:32:46 -06:00
|
|
|
int r = 0;
|
|
|
|
u16 mode;
|
|
|
|
|
|
|
|
dev_dbg(dev, "rate: %d\n", rate);
|
|
|
|
dev_dbg(dev, "width: %d\n", width);
|
|
|
|
|
|
|
|
mutex_lock(&core->lock);
|
|
|
|
|
|
|
|
mode = core->i2s_mode & ~WL1273_IS2_WIDTH & ~WL1273_IS2_RATE;
|
|
|
|
|
|
|
|
switch (rate) {
|
|
|
|
case 48000:
|
|
|
|
mode |= WL1273_IS2_RATE_48K;
|
|
|
|
break;
|
|
|
|
case 44100:
|
|
|
|
mode |= WL1273_IS2_RATE_44_1K;
|
|
|
|
break;
|
|
|
|
case 32000:
|
|
|
|
mode |= WL1273_IS2_RATE_32K;
|
|
|
|
break;
|
|
|
|
case 22050:
|
|
|
|
mode |= WL1273_IS2_RATE_22_05K;
|
|
|
|
break;
|
|
|
|
case 16000:
|
|
|
|
mode |= WL1273_IS2_RATE_16K;
|
|
|
|
break;
|
|
|
|
case 12000:
|
|
|
|
mode |= WL1273_IS2_RATE_12K;
|
|
|
|
break;
|
|
|
|
case 11025:
|
|
|
|
mode |= WL1273_IS2_RATE_11_025;
|
|
|
|
break;
|
|
|
|
case 8000:
|
|
|
|
mode |= WL1273_IS2_RATE_8K;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dev_err(dev, "Sampling rate: %d not supported\n", rate);
|
|
|
|
r = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (width) {
|
|
|
|
case 16:
|
|
|
|
mode |= WL1273_IS2_WIDTH_32;
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
mode |= WL1273_IS2_WIDTH_40;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
mode |= WL1273_IS2_WIDTH_48;
|
|
|
|
break;
|
|
|
|
case 25:
|
|
|
|
mode |= WL1273_IS2_WIDTH_50;
|
|
|
|
break;
|
|
|
|
case 30:
|
|
|
|
mode |= WL1273_IS2_WIDTH_60;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
mode |= WL1273_IS2_WIDTH_64;
|
|
|
|
break;
|
|
|
|
case 40:
|
|
|
|
mode |= WL1273_IS2_WIDTH_80;
|
|
|
|
break;
|
|
|
|
case 48:
|
|
|
|
mode |= WL1273_IS2_WIDTH_96;
|
|
|
|
break;
|
|
|
|
case 64:
|
|
|
|
mode |= WL1273_IS2_WIDTH_128;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dev_err(dev, "Data width: %d not supported\n", width);
|
|
|
|
r = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_dbg(dev, "WL1273_I2S_DEF_MODE: 0x%04x\n", WL1273_I2S_DEF_MODE);
|
|
|
|
dev_dbg(dev, "core->i2s_mode: 0x%04x\n", core->i2s_mode);
|
|
|
|
dev_dbg(dev, "mode: 0x%04x\n", mode);
|
|
|
|
|
|
|
|
if (core->i2s_mode != mode) {
|
2011-01-13 06:22:45 -07:00
|
|
|
r = core->write(core, WL1273_I2S_MODE_CONFIG_SET, mode);
|
2010-08-20 03:32:46 -06:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
core->i2s_mode = mode;
|
2011-01-13 06:22:45 -07:00
|
|
|
r = core->write(core, WL1273_AUDIO_ENABLE,
|
|
|
|
WL1273_AUDIO_ENABLE_I2S);
|
2010-08-20 03:32:46 -06:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
mutex_unlock(&core->lock);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_wl1273_fm_set_channel_number(struct wl1273_core *core,
|
|
|
|
int channel_number)
|
|
|
|
{
|
2011-01-13 06:22:45 -07:00
|
|
|
struct device *dev = &core->client->dev;
|
2010-08-20 03:32:46 -06:00
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
dev_dbg(dev, "%s\n", __func__);
|
|
|
|
|
|
|
|
mutex_lock(&core->lock);
|
|
|
|
|
|
|
|
if (core->channel_number == channel_number)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (channel_number == 1 && core->mode == WL1273_MODE_RX)
|
2011-01-13 06:22:45 -07:00
|
|
|
r = core->write(core, WL1273_MOST_MODE_SET, WL1273_RX_MONO);
|
2010-08-20 03:32:46 -06:00
|
|
|
else if (channel_number == 1 && core->mode == WL1273_MODE_TX)
|
2011-01-13 06:22:45 -07:00
|
|
|
r = core->write(core, WL1273_MONO_SET, WL1273_TX_MONO);
|
2010-08-20 03:32:46 -06:00
|
|
|
else if (channel_number == 2 && core->mode == WL1273_MODE_RX)
|
2011-01-13 06:22:45 -07:00
|
|
|
r = core->write(core, WL1273_MOST_MODE_SET, WL1273_RX_STEREO);
|
2010-08-20 03:32:46 -06:00
|
|
|
else if (channel_number == 2 && core->mode == WL1273_MODE_TX)
|
2011-01-13 06:22:45 -07:00
|
|
|
r = core->write(core, WL1273_MONO_SET, WL1273_TX_STEREO);
|
2010-08-20 03:32:46 -06:00
|
|
|
else
|
|
|
|
r = -EINVAL;
|
|
|
|
out:
|
|
|
|
mutex_unlock(&core->lock);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_wl1273_get_audio_route(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
|
struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
2016-02-29 10:08:04 -07:00
|
|
|
ucontrol->value.enumerated.item[0] = wl1273->mode;
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-03-01 06:10:37 -07:00
|
|
|
/*
|
|
|
|
* TODO: Implement the audio routing in the driver. Now this control
|
|
|
|
* only indicates the setting that has been done elsewhere (in the user
|
|
|
|
* space).
|
|
|
|
*/
|
|
|
|
static const char * const wl1273_audio_route[] = { "Bt", "FmRx", "FmTx" };
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
static int snd_wl1273_set_audio_route(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
|
struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
2016-02-29 10:08:04 -07:00
|
|
|
if (wl1273->mode == ucontrol->value.enumerated.item[0])
|
2010-09-10 01:41:30 -06:00
|
|
|
return 0;
|
|
|
|
|
2010-08-20 03:32:46 -06:00
|
|
|
/* Do not allow changes while stream is running */
|
2018-01-28 21:36:21 -07:00
|
|
|
if (snd_soc_component_is_active(component))
|
2010-08-20 03:32:46 -06:00
|
|
|
return -EPERM;
|
|
|
|
|
2016-02-29 10:08:04 -07:00
|
|
|
if (ucontrol->value.enumerated.item[0] >= ARRAY_SIZE(wl1273_audio_route))
|
2010-08-20 03:32:46 -06:00
|
|
|
return -EINVAL;
|
|
|
|
|
2016-02-29 10:08:04 -07:00
|
|
|
wl1273->mode = ucontrol->value.enumerated.item[0];
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-02-18 02:33:06 -07:00
|
|
|
static SOC_ENUM_SINGLE_EXT_DECL(wl1273_enum, wl1273_audio_route);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
|
struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
dev_dbg(component->dev, "%s: enter.\n", __func__);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
2016-02-29 10:08:04 -07:00
|
|
|
ucontrol->value.enumerated.item[0] = wl1273->core->audio_mode;
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_wl1273_fm_audio_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
|
struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component);
|
2010-08-20 03:32:46 -06:00
|
|
|
int val, r = 0;
|
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
dev_dbg(component->dev, "%s: enter.\n", __func__);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
2016-02-29 10:08:04 -07:00
|
|
|
val = ucontrol->value.enumerated.item[0];
|
2010-08-20 03:32:46 -06:00
|
|
|
if (wl1273->core->audio_mode == val)
|
|
|
|
return 0;
|
|
|
|
|
2011-01-13 06:22:45 -07:00
|
|
|
r = wl1273->core->set_audio(wl1273->core, val);
|
2010-08-20 03:32:46 -06:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-03-01 06:10:37 -07:00
|
|
|
static const char * const wl1273_audio_strings[] = { "Digital", "Analog" };
|
2010-08-20 03:32:46 -06:00
|
|
|
|
2014-02-18 02:33:06 -07:00
|
|
|
static SOC_ENUM_SINGLE_EXT_DECL(wl1273_audio_enum, wl1273_audio_strings);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
|
struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
dev_dbg(component->dev, "%s: enter.\n", __func__);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
ucontrol->value.integer.value[0] = wl1273->core->volume;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_wl1273_fm_volume_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
|
|
|
struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component);
|
2010-08-20 03:32:46 -06:00
|
|
|
int r;
|
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
dev_dbg(component->dev, "%s: enter.\n", __func__);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
2011-01-13 06:22:45 -07:00
|
|
|
r = wl1273->core->set_volume(wl1273->core,
|
|
|
|
ucontrol->value.integer.value[0]);
|
2010-08-20 03:32:46 -06:00
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct snd_kcontrol_new wl1273_controls[] = {
|
|
|
|
SOC_ENUM_EXT("Codec Mode", wl1273_enum,
|
|
|
|
snd_wl1273_get_audio_route, snd_wl1273_set_audio_route),
|
|
|
|
SOC_ENUM_EXT("Audio Switch", wl1273_audio_enum,
|
|
|
|
snd_wl1273_fm_audio_get, snd_wl1273_fm_audio_put),
|
|
|
|
SOC_SINGLE_EXT("Volume", 0, 0, WL1273_MAX_VOLUME, 0,
|
|
|
|
snd_wl1273_fm_volume_get, snd_wl1273_fm_volume_put),
|
|
|
|
};
|
|
|
|
|
2013-08-18 11:25:53 -06:00
|
|
|
static const struct snd_soc_dapm_widget wl1273_dapm_widgets[] = {
|
|
|
|
SND_SOC_DAPM_INPUT("RX"),
|
|
|
|
|
|
|
|
SND_SOC_DAPM_OUTPUT("TX"),
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_route wl1273_dapm_routes[] = {
|
|
|
|
{ "Capture", NULL, "RX" },
|
|
|
|
|
|
|
|
{ "TX", NULL, "Playback" },
|
|
|
|
};
|
|
|
|
|
2010-08-20 03:32:46 -06:00
|
|
|
static int wl1273_startup(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_soc_dai *dai)
|
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
struct snd_soc_component *component = dai->component;
|
|
|
|
struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
switch (wl1273->mode) {
|
|
|
|
case WL1273_MODE_BT:
|
2015-10-18 07:39:25 -06:00
|
|
|
snd_pcm_hw_constraint_single(substream->runtime,
|
|
|
|
SNDRV_PCM_HW_PARAM_RATE, 8000);
|
|
|
|
snd_pcm_hw_constraint_single(substream->runtime,
|
|
|
|
SNDRV_PCM_HW_PARAM_CHANNELS, 1);
|
2010-08-20 03:32:46 -06:00
|
|
|
break;
|
|
|
|
case WL1273_MODE_FM_RX:
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
|
|
|
pr_err("Cannot play in RX mode.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WL1273_MODE_FM_TX:
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
|
|
|
|
pr_err("Cannot capture in TX mode.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wl1273_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *params,
|
|
|
|
struct snd_soc_dai *dai)
|
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(dai->component);
|
2010-08-20 03:32:46 -06:00
|
|
|
struct wl1273_core *core = wl1273->core;
|
|
|
|
unsigned int rate, width, r;
|
|
|
|
|
2014-07-31 05:49:36 -06:00
|
|
|
if (params_width(params) != 16) {
|
|
|
|
dev_err(dai->dev, "%d bits/sample not supported\n",
|
|
|
|
params_width(params));
|
2010-08-20 03:32:46 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rate = params_rate(params);
|
|
|
|
width = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min;
|
|
|
|
|
|
|
|
if (wl1273->mode == WL1273_MODE_BT) {
|
|
|
|
if (rate != 8000) {
|
|
|
|
pr_err("Rate %d not supported.\n", params_rate(params));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params_channels(params) != 1) {
|
|
|
|
pr_err("Only mono supported.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wl1273->mode == WL1273_MODE_FM_TX &&
|
|
|
|
substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
|
|
|
|
pr_err("Only playback supported with TX.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wl1273->mode == WL1273_MODE_FM_RX &&
|
|
|
|
substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
|
|
|
pr_err("Only capture supported with RX.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wl1273->mode != WL1273_MODE_FM_RX &&
|
|
|
|
wl1273->mode != WL1273_MODE_FM_TX) {
|
|
|
|
pr_err("Unexpected mode: %d.\n", wl1273->mode);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = snd_wl1273_fm_set_i2s_mode(core, rate, width);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
wl1273->channels = params_channels(params);
|
|
|
|
r = snd_wl1273_fm_set_channel_number(core, wl1273->channels);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-23 03:40:40 -07:00
|
|
|
static const struct snd_soc_dai_ops wl1273_dai_ops = {
|
2010-08-20 03:32:46 -06:00
|
|
|
.startup = wl1273_startup,
|
|
|
|
.hw_params = wl1273_hw_params,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct snd_soc_dai_driver wl1273_dai = {
|
|
|
|
.name = "wl1273-fm",
|
|
|
|
.playback = {
|
|
|
|
.stream_name = "Playback",
|
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 2,
|
|
|
|
.rates = SNDRV_PCM_RATE_8000_48000,
|
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE},
|
|
|
|
.capture = {
|
|
|
|
.stream_name = "Capture",
|
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 2,
|
|
|
|
.rates = SNDRV_PCM_RATE_8000_48000,
|
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE},
|
|
|
|
.ops = &wl1273_dai_ops,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Audio interface format for the soc_card driver */
|
2018-01-28 21:36:21 -07:00
|
|
|
int wl1273_get_format(struct snd_soc_component *component, unsigned int *fmt)
|
2010-08-20 03:32:46 -06:00
|
|
|
{
|
|
|
|
struct wl1273_priv *wl1273;
|
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
if (component == NULL || fmt == NULL)
|
2010-08-20 03:32:46 -06:00
|
|
|
return -EINVAL;
|
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
wl1273 = snd_soc_component_get_drvdata(component);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
switch (wl1273->mode) {
|
|
|
|
case WL1273_MODE_FM_RX:
|
|
|
|
case WL1273_MODE_FM_TX:
|
|
|
|
*fmt = SND_SOC_DAIFMT_I2S |
|
|
|
|
SND_SOC_DAIFMT_NB_NF |
|
|
|
|
SND_SOC_DAIFMT_CBM_CFM;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case WL1273_MODE_BT:
|
|
|
|
*fmt = SND_SOC_DAIFMT_DSP_A |
|
|
|
|
SND_SOC_DAIFMT_IB_NF |
|
|
|
|
SND_SOC_DAIFMT_CBM_CFM;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wl1273_get_format);
|
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
static int wl1273_probe(struct snd_soc_component *component)
|
2010-08-20 03:32:46 -06:00
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
struct wl1273_core **core = component->dev->platform_data;
|
2010-08-20 03:32:46 -06:00
|
|
|
struct wl1273_priv *wl1273;
|
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
dev_dbg(component->dev, "%s.\n", __func__);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
if (!core) {
|
2018-01-28 21:36:21 -07:00
|
|
|
dev_err(component->dev, "Platform data is missing.\n");
|
2010-08-20 03:32:46 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl1273 = kzalloc(sizeof(struct wl1273_priv), GFP_KERNEL);
|
2014-06-20 03:59:04 -06:00
|
|
|
if (!wl1273)
|
2010-08-20 03:32:46 -06:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
wl1273->mode = WL1273_MODE_BT;
|
|
|
|
wl1273->core = *core;
|
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
snd_soc_component_set_drvdata(component, wl1273);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
2014-11-05 02:46:33 -07:00
|
|
|
return 0;
|
2010-08-20 03:32:46 -06:00
|
|
|
}
|
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
static void wl1273_remove(struct snd_soc_component *component)
|
2010-08-20 03:32:46 -06:00
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
dev_dbg(component->dev, "%s\n", __func__);
|
2010-08-20 03:32:46 -06:00
|
|
|
kfree(wl1273);
|
|
|
|
}
|
|
|
|
|
2018-01-28 21:36:21 -07:00
|
|
|
static const struct snd_soc_component_driver soc_component_dev_wl1273 = {
|
|
|
|
.probe = wl1273_probe,
|
|
|
|
.remove = wl1273_remove,
|
|
|
|
.controls = wl1273_controls,
|
|
|
|
.num_controls = ARRAY_SIZE(wl1273_controls),
|
|
|
|
.dapm_widgets = wl1273_dapm_widgets,
|
|
|
|
.num_dapm_widgets = ARRAY_SIZE(wl1273_dapm_widgets),
|
|
|
|
.dapm_routes = wl1273_dapm_routes,
|
|
|
|
.num_dapm_routes = ARRAY_SIZE(wl1273_dapm_routes),
|
|
|
|
.idle_bias_on = 1,
|
|
|
|
.use_pmdown_time = 1,
|
|
|
|
.endianness = 1,
|
|
|
|
.non_legacy_dai_naming = 1,
|
2010-08-20 03:32:46 -06:00
|
|
|
};
|
|
|
|
|
2012-12-07 07:26:37 -07:00
|
|
|
static int wl1273_platform_probe(struct platform_device *pdev)
|
2010-08-20 03:32:46 -06:00
|
|
|
{
|
2018-01-28 21:36:21 -07:00
|
|
|
return devm_snd_soc_register_component(&pdev->dev,
|
|
|
|
&soc_component_dev_wl1273,
|
2010-08-20 03:32:46 -06:00
|
|
|
&wl1273_dai, 1);
|
|
|
|
}
|
|
|
|
|
2012-12-07 07:26:37 -07:00
|
|
|
static int wl1273_platform_remove(struct platform_device *pdev)
|
2010-08-20 03:32:46 -06:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_ALIAS("platform:wl1273-codec");
|
|
|
|
|
|
|
|
static struct platform_driver wl1273_platform_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "wl1273-codec",
|
|
|
|
},
|
|
|
|
.probe = wl1273_platform_probe,
|
2012-12-07 07:26:37 -07:00
|
|
|
.remove = wl1273_platform_remove,
|
2010-08-20 03:32:46 -06:00
|
|
|
};
|
|
|
|
|
2011-11-23 15:52:08 -07:00
|
|
|
module_platform_driver(wl1273_platform_driver);
|
2010-08-20 03:32:46 -06:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Matti Aaltonen <matti.j.aaltonen@nokia.com>");
|
|
|
|
MODULE_DESCRIPTION("ASoC WL1273 codec driver");
|
|
|
|
MODULE_LICENSE("GPL");
|