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>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
#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>
|
|
|
|
|
|
|
|
#include "stac9766.h"
|
|
|
|
|
2015-07-22 03:53:03 +08:00
|
|
|
#define STAC9766_VENDOR_ID 0x83847666
|
|
|
|
#define STAC9766_VENDOR_ID_MASK 0xffffffff
|
|
|
|
|
2009-05-24 07:13:07 +08:00
|
|
|
/*
|
|
|
|
* STAC9766 register cache
|
|
|
|
*/
|
|
|
|
static const u16 stac9766_reg[] = {
|
|
|
|
0x6A90, 0x8000, 0x8000, 0x8000, /* 6 */
|
|
|
|
0x0000, 0x0000, 0x8008, 0x8008, /* e */
|
|
|
|
0x8808, 0x8808, 0x8808, 0x8808, /* 16 */
|
|
|
|
0x8808, 0x0000, 0x8000, 0x0000, /* 1e */
|
|
|
|
0x0000, 0x0000, 0x0000, 0x000f, /* 26 */
|
|
|
|
0x0a05, 0x0400, 0xbb80, 0x0000, /* 2e */
|
|
|
|
0x0000, 0xbb80, 0x0000, 0x0000, /* 36 */
|
|
|
|
0x0000, 0x2000, 0x0000, 0x0100, /* 3e */
|
|
|
|
0x0000, 0x0000, 0x0080, 0x0000, /* 46 */
|
|
|
|
0x0000, 0x0000, 0x0003, 0xffff, /* 4e */
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, /* 56 */
|
|
|
|
0x4000, 0x0000, 0x0000, 0x0000, /* 5e */
|
2016-11-05 01:26:54 +08:00
|
|
|
0x1201, 0x0000, 0x0000, 0x0000, /* 66 */
|
|
|
|
0x0000, 0x0000, 0x0000, 0x1000, /* 6e */
|
2009-05-24 07:13:07 +08:00
|
|
|
0x0000, 0x0000, 0x0000, 0x0006, /* 76 */
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, /* 7e */
|
|
|
|
};
|
|
|
|
|
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),
|
|
|
|
};
|
|
|
|
|
2009-05-24 20:32:24 +08:00
|
|
|
static int stac9766_ac97_write(struct snd_soc_codec *codec, unsigned int reg,
|
|
|
|
unsigned int val)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2014-11-11 05:41:53 +08:00
|
|
|
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
|
2009-05-24 07:13:07 +08:00
|
|
|
u16 *cache = codec->reg_cache;
|
|
|
|
|
2009-07-13 08:20:10 +08:00
|
|
|
if (reg / 2 >= ARRAY_SIZE(stac9766_reg))
|
2009-05-24 07:13:07 +08:00
|
|
|
return -EIO;
|
|
|
|
|
2014-11-11 05:41:53 +08:00
|
|
|
soc_ac97_ops->write(ac97, reg, val);
|
2009-05-24 07:13:07 +08:00
|
|
|
cache[reg / 2] = val;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-24 20:32:24 +08:00
|
|
|
static unsigned int stac9766_ac97_read(struct snd_soc_codec *codec,
|
|
|
|
unsigned int reg)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2014-11-11 05:41:53 +08:00
|
|
|
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
|
2009-05-24 07:13:07 +08:00
|
|
|
u16 val = 0, *cache = codec->reg_cache;
|
|
|
|
|
2009-07-13 08:20:10 +08:00
|
|
|
if (reg / 2 >= ARRAY_SIZE(stac9766_reg))
|
2009-05-24 07:13:07 +08:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
if (reg == AC97_RESET || reg == AC97_GPIO_STATUS ||
|
|
|
|
reg == AC97_INT_PAGING || reg == AC97_VENDOR_ID1 ||
|
|
|
|
reg == AC97_VENDOR_ID2) {
|
|
|
|
|
2014-11-11 05:41:53 +08:00
|
|
|
val = soc_ac97_ops->read(ac97, reg);
|
2009-05-24 07:13:07 +08:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
return cache[reg / 2];
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
struct snd_soc_codec *codec = dai->codec;
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
|
|
unsigned short reg, vra;
|
|
|
|
|
|
|
|
vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS);
|
|
|
|
|
|
|
|
vra |= 0x1; /* enable variable rate audio */
|
2009-12-16 09:53:44 +08:00
|
|
|
vra &= ~0x4; /* disable SPDIF output */
|
2009-05-24 07:13:07 +08:00
|
|
|
|
|
|
|
stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra);
|
|
|
|
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
|
|
|
reg = AC97_PCM_FRONT_DAC_RATE;
|
|
|
|
else
|
|
|
|
reg = AC97_PCM_LR_ADC_RATE;
|
|
|
|
|
|
|
|
return stac9766_ac97_write(codec, reg, runtime->rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
struct snd_soc_codec *codec = dai->codec;
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
|
|
unsigned short reg, vra;
|
|
|
|
|
|
|
|
stac9766_ac97_write(codec, AC97_SPDIF, 0x2002);
|
|
|
|
|
|
|
|
vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS);
|
|
|
|
vra |= 0x5; /* Enable VRA and SPDIF out */
|
|
|
|
|
|
|
|
stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra);
|
|
|
|
|
|
|
|
reg = AC97_PCM_FRONT_DAC_RATE;
|
|
|
|
|
|
|
|
return stac9766_ac97_write(codec, reg, runtime->rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int stac9766_set_bias_level(struct snd_soc_codec *codec,
|
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 */
|
|
|
|
stac9766_ac97_write(codec, AC97_POWERDOWN, 0x0000);
|
|
|
|
break;
|
|
|
|
case SND_SOC_BIAS_OFF: /* Off, without power */
|
|
|
|
/* disable everything including AC link */
|
|
|
|
stac9766_ac97_write(codec, AC97_POWERDOWN, 0xffff);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
static int stac9766_codec_resume(struct snd_soc_codec *codec)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2014-11-11 05:41:53 +08:00
|
|
|
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
|
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
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
static int stac9766_codec_probe(struct snd_soc_codec *codec)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2014-11-11 05:41:53 +08:00
|
|
|
struct snd_ac97 *ac97;
|
2009-05-24 07:13:07 +08:00
|
|
|
|
2015-07-22 03:53:03 +08:00
|
|
|
ac97 = snd_soc_new_ac97_codec(codec, STAC9766_VENDOR_ID,
|
|
|
|
STAC9766_VENDOR_ID_MASK);
|
2014-11-11 05:41:53 +08:00
|
|
|
if (IS_ERR(ac97))
|
|
|
|
return PTR_ERR(ac97);
|
|
|
|
|
|
|
|
snd_soc_codec_set_drvdata(codec, ac97);
|
2009-05-24 07:13:07 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
static int stac9766_codec_remove(struct snd_soc_codec *codec)
|
2009-05-24 07:13:07 +08:00
|
|
|
{
|
2014-11-11 05:41:53 +08:00
|
|
|
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
|
|
|
|
|
|
|
|
snd_soc_free_ac97_codec(ac97);
|
2009-05-24 07:13:07 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
static struct snd_soc_codec_driver soc_codec_dev_stac9766 = {
|
2016-08-08 17:25:22 +08:00
|
|
|
.component_driver = {
|
|
|
|
.controls = stac9766_snd_ac97_controls,
|
|
|
|
.num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls),
|
|
|
|
},
|
2010-03-18 04:15:21 +08:00
|
|
|
.write = stac9766_ac97_write,
|
|
|
|
.read = stac9766_ac97_read,
|
|
|
|
.set_bias_level = stac9766_set_bias_level,
|
2014-10-20 16:56:39 +08:00
|
|
|
.suspend_bias_off = true,
|
2009-05-24 07:13:07 +08:00
|
|
|
.probe = stac9766_codec_probe,
|
|
|
|
.remove = stac9766_codec_remove,
|
|
|
|
.resume = stac9766_codec_resume,
|
2011-12-05 10:06:04 +08:00
|
|
|
.reg_cache_size = ARRAY_SIZE(stac9766_reg),
|
2010-03-18 04:15:21 +08:00
|
|
|
.reg_word_size = sizeof(u16),
|
|
|
|
.reg_cache_step = 2,
|
2010-11-22 08:20:54 +08:00
|
|
|
.reg_cache_default = stac9766_reg,
|
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
|
|
|
{
|
|
|
|
return snd_soc_register_codec(&pdev->dev,
|
|
|
|
&soc_codec_dev_stac9766, stac9766_dai, ARRAY_SIZE(stac9766_dai));
|
|
|
|
}
|
|
|
|
|
2012-12-07 22:26:37 +08:00
|
|
|
static int stac9766_remove(struct platform_device *pdev)
|
2010-03-18 04:15:21 +08:00
|
|
|
{
|
|
|
|
snd_soc_unregister_codec(&pdev->dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver stac9766_codec_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "stac9766-codec",
|
|
|
|
},
|
|
|
|
|
|
|
|
.probe = stac9766_probe,
|
2012-12-07 22:26:37 +08:00
|
|
|
.remove = stac9766_remove,
|
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");
|