2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2009-05-24 07:13:07 +08:00
|
|
|
/*
|
|
|
|
* stac9766.c -- ALSA SoC STAC9766 codec support
|
|
|
|
*
|
|
|
|
* Copyright 2009 Jon Smirl, Digispeaker
|
|
|
|
* Author: Jon Smirl <jonsmirl@gmail.com>
|
|
|
|
*
|
|
|
|
* Features:-
|
|
|
|
*
|
|
|
|
* o Support for AC97 Codec, S/PDIF
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2009-05-24 07:13:07 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/device.h>
|
2016-11-05 01:26:56 +08:00
|
|
|
#include <linux/regmap.h>
|
2009-05-24 07:13:07 +08:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/ac97_codec.h>
|
|
|
|
#include <sound/initval.h>
|
|
|
|
#include <sound/pcm_params.h>
|
|
|
|
#include <sound/soc.h>
|
|
|
|
#include <sound/tlv.h>
|
|
|
|
|
2015-07-22 03:53:03 +08:00
|
|
|
#define STAC9766_VENDOR_ID 0x83847666
|
|
|
|
#define STAC9766_VENDOR_ID_MASK 0xffffffff
|
|
|
|
|
2016-11-05 01:26:55 +08:00
|
|
|
#define AC97_STAC_DA_CONTROL 0x6A
|
|
|
|
#define AC97_STAC_ANALOG_SPECIAL 0x6E
|
|
|
|
#define AC97_STAC_STEREO_MIC 0x78
|
|
|
|
|
2016-11-05 01:26:56 +08:00
|
|
|
static const struct reg_default stac9766_reg_defaults[] = {
|
|
|
|
{ 0x02, 0x8000 },
|
|
|
|
{ 0x04, 0x8000 },
|
|
|
|
{ 0x06, 0x8000 },
|
|
|
|
{ 0x0a, 0x0000 },
|
|
|
|
{ 0x0c, 0x8008 },
|
|
|
|
{ 0x0e, 0x8008 },
|
|
|
|
{ 0x10, 0x8808 },
|
|
|
|
{ 0x12, 0x8808 },
|
|
|
|
{ 0x14, 0x8808 },
|
|
|
|
{ 0x16, 0x8808 },
|
|
|
|
{ 0x18, 0x8808 },
|
|
|
|
{ 0x1a, 0x0000 },
|
|
|
|
{ 0x1c, 0x8000 },
|
|
|
|
{ 0x20, 0x0000 },
|
|
|
|
{ 0x22, 0x0000 },
|
|
|
|
{ 0x28, 0x0a05 },
|
|
|
|
{ 0x2c, 0xbb80 },
|
|
|
|
{ 0x32, 0xbb80 },
|
|
|
|
{ 0x3a, 0x2000 },
|
|
|
|
{ 0x3e, 0x0100 },
|
|
|
|
{ 0x4c, 0x0300 },
|
|
|
|
{ 0x4e, 0xffff },
|
|
|
|
{ 0x50, 0x0000 },
|
|
|
|
{ 0x52, 0x0000 },
|
|
|
|
{ 0x54, 0x0000 },
|
|
|
|
{ 0x6a, 0x0000 },
|
|
|
|
{ 0x6e, 0x1000 },
|
|
|
|
{ 0x72, 0x0000 },
|
|
|
|
{ 0x78, 0x0000 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct regmap_config stac9766_regmap_config = {
|
|
|
|
.reg_bits = 16,
|
|
|
|
.reg_stride = 2,
|
|
|
|
.val_bits = 16,
|
|
|
|
.max_register = 0x78,
|
2023-07-13 02:44:30 +08:00
|
|
|
.cache_type = REGCACHE_MAPLE,
|
2016-11-05 01:26:56 +08:00
|
|
|
|
|
|
|
.volatile_reg = regmap_ac97_default_volatile,
|
|
|
|
|
|
|
|
.reg_defaults = stac9766_reg_defaults,
|
|
|
|
.num_reg_defaults = ARRAY_SIZE(stac9766_reg_defaults),
|
2009-05-24 07:13:07 +08:00
|
|
|
};
|
|
|
|
|
2009-05-24 20:32:24 +08:00
|
|
|
static const char *stac9766_record_mux[] = {"Mic", "CD", "Video", "AUX",
|
|
|
|
"Line", "Stereo Mix", "Mono Mix", "Phone"};
|
2009-05-24 07:13:07 +08:00
|
|
|
static const char *stac9766_mono_mux[] = {"Mix", "Mic"};
|
|
|
|
static const char *stac9766_mic_mux[] = {"Mic1", "Mic2"};
|
|
|
|
static const char *stac9766_SPDIF_mux[] = {"PCM", "ADC Record"};
|
|
|
|
static const char *stac9766_popbypass_mux[] = {"Normal", "Bypass Mixer"};
|
2009-05-24 20:32:24 +08:00
|
|
|
static const char *stac9766_record_all_mux[] = {"All analog",
|
|
|
|
"Analog plus DAC"};
|
2009-05-24 07:13:07 +08:00
|
|
|
static const char *stac9766_boost1[] = {"0dB", "10dB"};
|
|
|
|
static const char *stac9766_boost2[] = {"0dB", "20dB"};
|
|
|
|
static const char *stac9766_stereo_mic[] = {"Off", "On"};
|
|
|
|
|
2014-02-18 17:26:27 +08:00
|
|
|
static SOC_ENUM_DOUBLE_DECL(stac9766_record_enum,
|
|
|
|
AC97_REC_SEL, 8, 0, stac9766_record_mux);
|
|
|
|
static SOC_ENUM_SINGLE_DECL(stac9766_mono_enum,
|
|
|
|
AC97_GENERAL_PURPOSE, 9, stac9766_mono_mux);
|
|
|
|
static SOC_ENUM_SINGLE_DECL(stac9766_mic_enum,
|
|
|
|
AC97_GENERAL_PURPOSE, 8, stac9766_mic_mux);
|
|
|
|
static SOC_ENUM_SINGLE_DECL(stac9766_SPDIF_enum,
|
|
|
|
AC97_STAC_DA_CONTROL, 1, stac9766_SPDIF_mux);
|
|
|
|
static SOC_ENUM_SINGLE_DECL(stac9766_popbypass_enum,
|
|
|
|
AC97_GENERAL_PURPOSE, 15, stac9766_popbypass_mux);
|
|
|
|
static SOC_ENUM_SINGLE_DECL(stac9766_record_all_enum,
|
|
|
|
AC97_STAC_ANALOG_SPECIAL, 12,
|
|
|
|
stac9766_record_all_mux);
|
|
|
|
static SOC_ENUM_SINGLE_DECL(stac9766_boost1_enum,
|
|
|
|
AC97_MIC, 6, stac9766_boost1); /* 0/10dB */
|
|
|
|
static SOC_ENUM_SINGLE_DECL(stac9766_boost2_enum,
|
|
|
|
AC97_STAC_ANALOG_SPECIAL, 2, stac9766_boost2); /* 0/20dB */
|
|
|
|
static SOC_ENUM_SINGLE_DECL(stac9766_stereo_mic_enum,
|
|
|
|
AC97_STAC_STEREO_MIC, 2, stac9766_stereo_mic);
|
2009-05-24 07:13:07 +08:00
|
|
|
|
ASoC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR()
As long as reading datasheet of STAC9766/9767, this driver includes wrong
usage of DECLARE_TLV_DB_LINEAR().
In "8.1.2. Master Volume Registers", attenuation of lineout volumes is
represented in 5 bits by -1.5 dB/step from 0 to -46.5 dB. Thus,
'master_tlv' should be dB step representation.
In "8.1.14. Record Gain", gain of volumes is represented in 4 bits by
1.5 dB/step from 0 to 22.5 dB. Thus, 'record_tlv' should be dB step
representation.
In "8.1.5. PC BEEP Volume", attenuation of volume is represented in 4 bits
by -3 dB/step from 0 to 45 dB. Thus, 'beep_tlv' should be dB step
representation.
In "8.1.7. Stereo or Mic Volume" and so on, gain of volumes is represented
in 5 bits by -1.5 dB from 12 to -34.5 dB. Thus, 'mix_tlv' should be dB
step representation.
Totally, current implementation includes misuse of TLV-related macro.
This commit replaces usage of DECLARE_TLV_DB_LINEAR() with
SNDRV_CTL_TLVD_DECLARE_DB_SCALE(), to give proper information to
applications in user land.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Mark Brown <broonie@kernel.org>
2016-09-27 07:25:29 +08:00
|
|
|
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(master_tlv, -4650, 150, 0);
|
|
|
|
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(record_tlv, 0, 150, 0);
|
|
|
|
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(beep_tlv, -4500, 300, 0);
|
|
|
|
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(mix_tlv, -3450, 150, 0);
|
2009-05-24 07:13:07 +08:00
|
|
|
|
|
|
|
static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = {
|
|
|
|
SOC_DOUBLE_TLV("Speaker Volume", AC97_MASTER, 8, 0, 31, 1, master_tlv),
|
|
|
|
SOC_SINGLE("Speaker Switch", AC97_MASTER, 15, 1, 1),
|
2009-05-24 20:32:24 +08:00
|
|
|
SOC_DOUBLE_TLV("Headphone Volume", AC97_HEADPHONE, 8, 0, 31, 1,
|
|
|
|
master_tlv),
|
2009-05-24 07:13:07 +08:00
|
|
|
SOC_SINGLE("Headphone Switch", AC97_HEADPHONE, 15, 1, 1),
|
2009-05-24 20:32:24 +08:00
|
|
|
SOC_SINGLE_TLV("Mono Out Volume", AC97_MASTER_MONO, 0, 31, 1,
|
|
|
|
master_tlv),
|
2009-05-24 07:13:07 +08:00
|
|
|
SOC_SINGLE("Mono Out Switch", AC97_MASTER_MONO, 15, 1, 1),
|
|
|
|
|
|
|
|
SOC_DOUBLE_TLV("Record Volume", AC97_REC_GAIN, 8, 0, 15, 0, record_tlv),
|
|
|
|
SOC_SINGLE("Record Switch", AC97_REC_GAIN, 15, 1, 1),
|
|
|
|
|
|
|
|
|
|
|
|
SOC_SINGLE_TLV("Beep Volume", AC97_PC_BEEP, 1, 15, 1, beep_tlv),
|
|
|
|
SOC_SINGLE("Beep Switch", AC97_PC_BEEP, 15, 1, 1),
|
|
|
|
SOC_SINGLE("Beep Frequency", AC97_PC_BEEP, 5, 127, 1),
|
|
|
|
SOC_SINGLE_TLV("Phone Volume", AC97_PHONE, 0, 31, 1, mix_tlv),
|
|
|
|
SOC_SINGLE("Phone Switch", AC97_PHONE, 15, 1, 1),
|
|
|
|
|
|
|
|
SOC_ENUM("Mic Boost1", stac9766_boost1_enum),
|
|
|
|
SOC_ENUM("Mic Boost2", stac9766_boost2_enum),
|
|
|
|
SOC_SINGLE_TLV("Mic Volume", AC97_MIC, 0, 31, 1, mix_tlv),
|
|
|
|
SOC_SINGLE("Mic Switch", AC97_MIC, 15, 1, 1),
|
|
|
|
SOC_ENUM("Stereo Mic", stac9766_stereo_mic_enum),
|
|
|
|
|
|
|
|
SOC_DOUBLE_TLV("Line Volume", AC97_LINE, 8, 0, 31, 1, mix_tlv),
|
|
|
|
SOC_SINGLE("Line Switch", AC97_LINE, 15, 1, 1),
|
|
|
|
SOC_DOUBLE_TLV("CD Volume", AC97_CD, 8, 0, 31, 1, mix_tlv),
|
|
|
|
SOC_SINGLE("CD Switch", AC97_CD, 15, 1, 1),
|
|
|
|
SOC_DOUBLE_TLV("AUX Volume", AC97_AUX, 8, 0, 31, 1, mix_tlv),
|
|
|
|
SOC_SINGLE("AUX Switch", AC97_AUX, 15, 1, 1),
|
|
|
|
SOC_DOUBLE_TLV("Video Volume", AC97_VIDEO, 8, 0, 31, 1, mix_tlv),
|
|
|
|
SOC_SINGLE("Video Switch", AC97_VIDEO, 15, 1, 1),
|
|
|
|
|
|
|
|
SOC_DOUBLE_TLV("DAC Volume", AC97_PCM, 8, 0, 31, 1, mix_tlv),
|
|
|
|
SOC_SINGLE("DAC Switch", AC97_PCM, 15, 1, 1),
|
|
|
|
SOC_SINGLE("Loopback Test Switch", AC97_GENERAL_PURPOSE, 7, 1, 0),
|
|
|
|
SOC_SINGLE("3D Volume", AC97_3D_CONTROL, 3, 2, 1),
|
|
|
|
SOC_SINGLE("3D Switch", AC97_GENERAL_PURPOSE, 13, 1, 0),
|
|
|
|
|
|
|
|
SOC_ENUM("SPDIF Mux", stac9766_SPDIF_enum),
|
|
|
|
SOC_ENUM("Mic1/2 Mux", stac9766_mic_enum),
|
|
|
|
SOC_ENUM("Record All Mux", stac9766_record_all_enum),
|
|
|
|
SOC_ENUM("Record Mux", stac9766_record_enum),
|
|
|
|
SOC_ENUM("Mono Mux", stac9766_mono_enum),
|
|
|
|
SOC_ENUM("Pop Bypass Mux", stac9766_popbypass_enum),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int ac97_analog_prepare(struct snd_pcm_substream *substream,
|
2009-05-24 20:32:24 +08:00
|
|
|
struct snd_soc_dai *dai)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2018-01-29 12:38:18 +08:00
|
|
|
struct snd_soc_component *component = dai->component;
|
2009-05-24 07:13:07 +08:00
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2016-11-05 01:26:57 +08:00
|
|
|
unsigned short reg;
|
2009-05-24 07:13:07 +08:00
|
|
|
|
2016-11-05 01:26:57 +08:00
|
|
|
/* enable variable rate audio, disable SPDIF output */
|
2018-01-29 12:38:18 +08:00
|
|
|
snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x5, 0x1);
|
2009-05-24 07:13:07 +08:00
|
|
|
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
|
|
|
reg = AC97_PCM_FRONT_DAC_RATE;
|
|
|
|
else
|
|
|
|
reg = AC97_PCM_LR_ADC_RATE;
|
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
return snd_soc_component_write(component, reg, runtime->rate);
|
2009-05-24 07:13:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ac97_digital_prepare(struct snd_pcm_substream *substream,
|
2009-05-24 20:32:24 +08:00
|
|
|
struct snd_soc_dai *dai)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2018-01-29 12:38:18 +08:00
|
|
|
struct snd_soc_component *component = dai->component;
|
2009-05-24 07:13:07 +08:00
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2016-11-05 01:26:57 +08:00
|
|
|
unsigned short reg;
|
2009-05-24 07:13:07 +08:00
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
snd_soc_component_write(component, AC97_SPDIF, 0x2002);
|
2009-05-24 07:13:07 +08:00
|
|
|
|
2016-11-05 01:26:57 +08:00
|
|
|
/* Enable VRA and SPDIF out */
|
2018-01-29 12:38:18 +08:00
|
|
|
snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x5, 0x5);
|
2009-05-24 07:13:07 +08:00
|
|
|
|
|
|
|
reg = AC97_PCM_FRONT_DAC_RATE;
|
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
return snd_soc_component_write(component, reg, runtime->rate);
|
2009-05-24 07:13:07 +08:00
|
|
|
}
|
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
static int stac9766_set_bias_level(struct snd_soc_component *component,
|
2009-05-24 20:32:24 +08:00
|
|
|
enum snd_soc_bias_level level)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
|
|
|
switch (level) {
|
|
|
|
case SND_SOC_BIAS_ON: /* full On */
|
|
|
|
case SND_SOC_BIAS_PREPARE: /* partial On */
|
|
|
|
case SND_SOC_BIAS_STANDBY: /* Off, with power */
|
2018-01-29 12:38:18 +08:00
|
|
|
snd_soc_component_write(component, AC97_POWERDOWN, 0x0000);
|
2009-05-24 07:13:07 +08:00
|
|
|
break;
|
|
|
|
case SND_SOC_BIAS_OFF: /* Off, without power */
|
|
|
|
/* disable everything including AC link */
|
2018-01-29 12:38:18 +08:00
|
|
|
snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
|
2009-05-24 07:13:07 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
static int stac9766_component_resume(struct snd_soc_component *component)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2018-01-29 12:38:18 +08:00
|
|
|
struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
|
2009-05-24 07:13:07 +08:00
|
|
|
|
2015-07-22 03:53:03 +08:00
|
|
|
return snd_ac97_reset(ac97, true, STAC9766_VENDOR_ID,
|
|
|
|
STAC9766_VENDOR_ID_MASK);
|
2009-05-24 07:13:07 +08:00
|
|
|
}
|
|
|
|
|
2011-11-23 18:40:40 +08:00
|
|
|
static const struct snd_soc_dai_ops stac9766_dai_ops_analog = {
|
2009-05-24 07:13:07 +08:00
|
|
|
.prepare = ac97_analog_prepare,
|
|
|
|
};
|
|
|
|
|
2011-11-23 18:40:40 +08:00
|
|
|
static const struct snd_soc_dai_ops stac9766_dai_ops_digital = {
|
2009-05-24 07:13:07 +08:00
|
|
|
.prepare = ac97_digital_prepare,
|
|
|
|
};
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
static struct snd_soc_dai_driver stac9766_dai[] = {
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2010-03-18 04:15:21 +08:00
|
|
|
.name = "stac9766-hifi-analog",
|
2009-05-24 07:13:07 +08:00
|
|
|
|
|
|
|
/* stream cababilities */
|
|
|
|
.playback = {
|
|
|
|
.stream_name = "stac9766 analog",
|
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 2,
|
|
|
|
.rates = SNDRV_PCM_RATE_8000_48000,
|
|
|
|
.formats = SND_SOC_STD_AC97_FMTS,
|
|
|
|
},
|
|
|
|
.capture = {
|
|
|
|
.stream_name = "stac9766 analog",
|
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 2,
|
|
|
|
.rates = SNDRV_PCM_RATE_8000_48000,
|
|
|
|
.formats = SND_SOC_STD_AC97_FMTS,
|
|
|
|
},
|
|
|
|
/* alsa ops */
|
|
|
|
.ops = &stac9766_dai_ops_analog,
|
|
|
|
},
|
|
|
|
{
|
2010-03-18 04:15:21 +08:00
|
|
|
.name = "stac9766-hifi-IEC958",
|
2009-05-24 07:13:07 +08:00
|
|
|
|
|
|
|
/* stream cababilities */
|
|
|
|
.playback = {
|
|
|
|
.stream_name = "stac9766 IEC958",
|
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 2,
|
|
|
|
.rates = SNDRV_PCM_RATE_32000 | \
|
|
|
|
SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
|
2015-05-24 00:32:29 +08:00
|
|
|
.formats = SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE,
|
2009-05-24 07:13:07 +08:00
|
|
|
},
|
|
|
|
/* alsa ops */
|
|
|
|
.ops = &stac9766_dai_ops_digital,
|
2009-05-24 20:32:24 +08:00
|
|
|
}
|
|
|
|
};
|
2009-05-24 07:13:07 +08:00
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
static int stac9766_component_probe(struct snd_soc_component *component)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2014-11-11 05:41:53 +08:00
|
|
|
struct snd_ac97 *ac97;
|
2016-11-05 01:26:56 +08:00
|
|
|
struct regmap *regmap;
|
|
|
|
int ret;
|
2009-05-24 07:13:07 +08:00
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
ac97 = snd_soc_new_ac97_component(component, STAC9766_VENDOR_ID,
|
2015-07-22 03:53:03 +08:00
|
|
|
STAC9766_VENDOR_ID_MASK);
|
2014-11-11 05:41:53 +08:00
|
|
|
if (IS_ERR(ac97))
|
|
|
|
return PTR_ERR(ac97);
|
|
|
|
|
2016-11-05 01:26:56 +08:00
|
|
|
regmap = regmap_init_ac97(ac97, &stac9766_regmap_config);
|
|
|
|
if (IS_ERR(regmap)) {
|
|
|
|
ret = PTR_ERR(regmap);
|
|
|
|
goto err_free_ac97;
|
|
|
|
}
|
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
snd_soc_component_init_regmap(component, regmap);
|
|
|
|
snd_soc_component_set_drvdata(component, ac97);
|
2009-05-24 07:13:07 +08:00
|
|
|
|
|
|
|
return 0;
|
2016-11-05 01:26:56 +08:00
|
|
|
err_free_ac97:
|
2018-01-29 12:38:18 +08:00
|
|
|
snd_soc_free_ac97_component(ac97);
|
2016-11-05 01:26:56 +08:00
|
|
|
return ret;
|
2009-05-24 07:13:07 +08:00
|
|
|
}
|
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
static void stac9766_component_remove(struct snd_soc_component *component)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2018-01-29 12:38:18 +08:00
|
|
|
struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
|
2014-11-11 05:41:53 +08:00
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
snd_soc_component_exit_regmap(component);
|
|
|
|
snd_soc_free_ac97_component(ac97);
|
2009-05-24 07:13:07 +08:00
|
|
|
}
|
|
|
|
|
2018-01-29 12:38:18 +08:00
|
|
|
static const struct snd_soc_component_driver soc_component_dev_stac9766 = {
|
|
|
|
.controls = stac9766_snd_ac97_controls,
|
|
|
|
.num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls),
|
|
|
|
.set_bias_level = stac9766_set_bias_level,
|
|
|
|
.probe = stac9766_component_probe,
|
|
|
|
.remove = stac9766_component_remove,
|
|
|
|
.resume = stac9766_component_resume,
|
|
|
|
.suspend_bias_off = 1,
|
|
|
|
.idle_bias_on = 1,
|
|
|
|
.use_pmdown_time = 1,
|
|
|
|
.endianness = 1,
|
2010-03-18 04:15:21 +08:00
|
|
|
};
|
|
|
|
|
2012-12-07 22:26:37 +08:00
|
|
|
static int stac9766_probe(struct platform_device *pdev)
|
2010-03-18 04:15:21 +08:00
|
|
|
{
|
2018-01-29 12:38:18 +08:00
|
|
|
return devm_snd_soc_register_component(&pdev->dev,
|
|
|
|
&soc_component_dev_stac9766, stac9766_dai, ARRAY_SIZE(stac9766_dai));
|
2010-03-18 04:15:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver stac9766_codec_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "stac9766-codec",
|
|
|
|
},
|
|
|
|
|
|
|
|
.probe = stac9766_probe,
|
2009-05-24 07:13:07 +08:00
|
|
|
};
|
2010-03-18 04:15:21 +08:00
|
|
|
|
2011-11-24 06:52:08 +08:00
|
|
|
module_platform_driver(stac9766_codec_driver);
|
2009-05-24 07:13:07 +08:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("ASoC stac9766 driver");
|
|
|
|
MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>");
|
|
|
|
MODULE_LICENSE("GPL");
|