Commit 4ec7e204 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/tda7419', 'asoc/topic/tfa9879',...

Merge remote-tracking branches 'asoc/topic/tda7419', 'asoc/topic/tfa9879', 'asoc/topic/tlv320aic23', 'asoc/topic/tlv320aic26' and 'asoc/topic/tlv320aic31xx' into asoc-next
TDA7419 audio processor
This device supports I2C only.
Required properties:
- compatible : "st,tda7419"
- reg : the I2C address of the device.
- vdd-supply : a regulator spec for the common power supply (8-10V)
Optional properties:
- st,mute-gpios : a GPIO spec for the MUTE pin.
Pins on the device (for linking into audio routes):
* SE3L
* SE3R
* SE2L
* SE2R
* SE1L
* SE1R
* DIFFL
* DIFFR
* MIX
* OUTLF
* OUTRF
* OUTLR
* OUTRR
* OUTSW
Example:
ap: tda7419@44 {
compatible = "st,tda7419";
reg = <0x44>;
vdd-supply = <&vdd_9v0_reg>;
};
......@@ -156,6 +156,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TAS571X if I2C
select SND_SOC_TAS5720 if I2C
select SND_SOC_TAS6424 if I2C
select SND_SOC_TDA7419 if I2C
select SND_SOC_TFA9879 if I2C
select SND_SOC_TLV320AIC23_I2C if I2C
select SND_SOC_TLV320AIC23_SPI if SPI_MASTER
......@@ -948,6 +949,11 @@ config SND_SOC_TAS6424
Enable support for Texas Instruments TAS6424 high-efficiency
digital input quad-channel Class-D audio power amplifiers.
config SND_SOC_TDA7419
tristate "ST TDA7419 audio processor"
depends on I2C
select REGMAP_I2C
config SND_SOC_TFA9879
tristate "NXP Semiconductors TFA9879 amplifier"
depends on I2C
......
......@@ -167,6 +167,7 @@ snd-soc-tas5086-objs := tas5086.o
snd-soc-tas571x-objs := tas571x.o
snd-soc-tas5720-objs := tas5720.o
snd-soc-tas6424-objs := tas6424.o
snd-soc-tda7419-objs := tda7419.o
snd-soc-tfa9879-objs := tfa9879.o
snd-soc-tlv320aic23-objs := tlv320aic23.o
snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o
......@@ -418,6 +419,7 @@ obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o
obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o
obj-$(CONFIG_SND_SOC_TAS5720) += snd-soc-tas5720.o
obj-$(CONFIG_SND_SOC_TAS6424) += snd-soc-tas6424.o
obj-$(CONFIG_SND_SOC_TDA7419) += snd-soc-tda7419.o
obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o
obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o
obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o
......
/*
* TDA7419 audio processor driver
*
* Copyright 2018 Konsulko Group
*
* Author: Matt Porter <mporter@konsulko.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.
*/
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <sound/core.h>
#include <sound/control.h>
#include <sound/soc.h>
#include <sound/tlv.h>
#define TDA7419_MAIN_SRC_REG 0x00
#define TDA7419_LOUDNESS_REG 0x01
#define TDA7419_MUTE_CLK_REG 0x02
#define TDA7419_VOLUME_REG 0x03
#define TDA7419_TREBLE_REG 0x04
#define TDA7419_MIDDLE_REG 0x05
#define TDA7419_BASS_REG 0x06
#define TDA7419_SECOND_SRC_REG 0x07
#define TDA7419_SUB_MID_BASS_REG 0x08
#define TDA7419_MIXING_GAIN_REG 0x09
#define TDA7419_ATTENUATOR_LF_REG 0x0a
#define TDA7419_ATTENUATOR_RF_REG 0x0b
#define TDA7419_ATTENUATOR_LR_REG 0x0c
#define TDA7419_ATTENUATOR_RR_REG 0x0d
#define TDA7419_MIXING_LEVEL_REG 0x0e
#define TDA7419_ATTENUATOR_SUB_REG 0x0f
#define TDA7419_SA_CLK_AC_REG 0x10
#define TDA7419_TESTING_REG 0x11
#define TDA7419_MAIN_SRC_SEL 0
#define TDA7419_MAIN_SRC_GAIN 3
#define TDA7419_MAIN_SRC_AUTOZERO 7
#define TDA7419_LOUDNESS_ATTEN 0
#define TDA7419_LOUDNESS_CENTER_FREQ 4
#define TDA7419_LOUDNESS_BOOST 6
#define TDA7419_LOUDNESS_SOFT_STEP 7
#define TDA7419_VOLUME_SOFT_STEP 7
#define TDA7419_SOFT_MUTE 0
#define TDA7419_MUTE_INFLUENCE 1
#define TDA7419_SOFT_MUTE_TIME 2
#define TDA7419_SOFT_STEP_TIME 4
#define TDA7419_CLK_FAST_MODE 7
#define TDA7419_TREBLE_CENTER_FREQ 5
#define TDA7419_REF_OUT_SELECT 7
#define TDA7419_MIDDLE_Q_FACTOR 5
#define TDA7419_MIDDLE_SOFT_STEP 7
#define TDA7419_BASS_Q_FACTOR 5
#define TDA7419_BASS_SOFT_STEP 7
#define TDA7419_SECOND_SRC_SEL 0
#define TDA7419_SECOND_SRC_GAIN 3
#define TDA7419_REAR_SPKR_SRC 7
#define TDA7419_SUB_CUT_OFF_FREQ 0
#define TDA7419_MIDDLE_CENTER_FREQ 2
#define TDA7419_BASS_CENTER_FREQ 4
#define TDA7419_BASS_DC_MODE 6
#define TDA7419_SMOOTHING_FILTER 7
#define TDA7419_MIX_LF 0
#define TDA7419_MIX_RF 1
#define TDA7419_MIX_ENABLE 2
#define TDA7419_SUB_ENABLE 3
#define TDA7419_HPF_GAIN 4
#define TDA7419_SA_Q_FACTOR 0
#define TDA7419_RESET_MODE 1
#define TDA7419_SA_SOURCE 2
#define TDA7419_SA_RUN 3
#define TDA7419_RESET 4
#define TDA7419_CLK_SOURCE 5
#define TDA7419_COUPLING_MODE 6
struct tda7419_data {
struct regmap *regmap;
};
static bool tda7419_readable_reg(struct device *dev, unsigned int reg)
{
return false;
}
static const struct reg_default tda7419_regmap_defaults[] = {
{ TDA7419_MAIN_SRC_REG, 0xfe },
{ TDA7419_LOUDNESS_REG, 0xfe },
{ TDA7419_MUTE_CLK_REG, 0xfe },
{ TDA7419_VOLUME_REG, 0xfe },
{ TDA7419_TREBLE_REG, 0xfe },
{ TDA7419_MIDDLE_REG, 0xfe },
{ TDA7419_BASS_REG, 0xfe },
{ TDA7419_SECOND_SRC_REG, 0xfe },
{ TDA7419_SUB_MID_BASS_REG, 0xfe },
{ TDA7419_MIXING_GAIN_REG, 0xfe },
{ TDA7419_ATTENUATOR_LF_REG, 0xfe },
{ TDA7419_ATTENUATOR_RF_REG, 0xfe },
{ TDA7419_ATTENUATOR_LR_REG, 0xfe },
{ TDA7419_ATTENUATOR_RR_REG, 0xfe },
{ TDA7419_MIXING_LEVEL_REG, 0xfe },
{ TDA7419_ATTENUATOR_SUB_REG, 0xfe },
{ TDA7419_SA_CLK_AC_REG, 0xfe },
{ TDA7419_TESTING_REG, 0xfe },
};
static const struct regmap_config tda7419_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = TDA7419_TESTING_REG,
.cache_type = REGCACHE_RBTREE,
.readable_reg = tda7419_readable_reg,
.reg_defaults = tda7419_regmap_defaults,
.num_reg_defaults = ARRAY_SIZE(tda7419_regmap_defaults),
};
struct tda7419_vol_control {
int min, max;
unsigned int reg, rreg, mask, thresh;
unsigned int invert:1;
};
static inline bool tda7419_vol_is_stereo(struct tda7419_vol_control *tvc)
{
if (tvc->reg == tvc->rreg)
return 0;
return 1;
}
static int tda7419_vol_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
struct tda7419_vol_control *tvc =
(struct tda7419_vol_control *)kcontrol->private_value;
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = tda7419_vol_is_stereo(tvc) ? 2 : 1;
uinfo->value.integer.min = tvc->min;
uinfo->value.integer.max = tvc->max;
return 0;
}
static inline int tda7419_vol_get_value(int val, unsigned int mask,
int min, int thresh,
unsigned int invert)
{
val &= mask;
if (val < thresh) {
if (invert)
val = 0 - val;
} else if (val > thresh) {
if (invert)
val = val - thresh;
else
val = thresh - val;
}
if (val < min)
val = min;
return val;
}
static int tda7419_vol_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct tda7419_vol_control *tvc =
(struct tda7419_vol_control *)kcontrol->private_value;
unsigned int reg = tvc->reg;
unsigned int rreg = tvc->rreg;
unsigned int mask = tvc->mask;
int min = tvc->min;
int thresh = tvc->thresh;
unsigned int invert = tvc->invert;
int val;
int ret;
ret = snd_soc_component_read(component, reg, &val);
if (ret < 0)
return ret;
ucontrol->value.integer.value[0] =
tda7419_vol_get_value(val, mask, min, thresh, invert);
if (tda7419_vol_is_stereo(tvc)) {
ret = snd_soc_component_read(component, rreg, &val);
if (ret < 0)
return ret;
ucontrol->value.integer.value[1] =
tda7419_vol_get_value(val, mask, min, thresh, invert);
}
return 0;
}
static inline int tda7419_vol_put_value(int val, int thresh,
unsigned int invert)
{
if (val < 0) {
if (invert)
val = abs(val);
else
val = thresh - val;
} else if ((val > 0) && invert) {
val += thresh;
}
return val;
}
static int tda7419_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component =
snd_kcontrol_chip(kcontrol);
struct tda7419_vol_control *tvc =
(struct tda7419_vol_control *)kcontrol->private_value;
unsigned int reg = tvc->reg;
unsigned int rreg = tvc->rreg;
unsigned int mask = tvc->mask;
int thresh = tvc->thresh;
unsigned int invert = tvc->invert;
int val;
int ret;
val = tda7419_vol_put_value(ucontrol->value.integer.value[0],
thresh, invert);
ret = snd_soc_component_update_bits(component, reg,
mask, val);
if (ret < 0)
return ret;
if (tda7419_vol_is_stereo(tvc)) {
val = tda7419_vol_put_value(ucontrol->value.integer.value[1],
thresh, invert);
ret = snd_soc_component_update_bits(component, rreg,
mask, val);
}
return ret;
}
#define TDA7419_SINGLE_VALUE(xreg, xmask, xmin, xmax, xthresh, xinvert) \
((unsigned long)&(struct tda7419_vol_control) \
{.reg = xreg, .rreg = xreg, .mask = xmask, .min = xmin, \
.max = xmax, .thresh = xthresh, .invert = xinvert})
#define TDA7419_DOUBLE_R_VALUE(xregl, xregr, xmask, xmin, xmax, xthresh, \
xinvert) \
((unsigned long)&(struct tda7419_vol_control) \
{.reg = xregl, .rreg = xregr, .mask = xmask, .min = xmin, \
.max = xmax, .thresh = xthresh, .invert = xinvert})
#define TDA7419_SINGLE_TLV(xname, xreg, xmask, xmin, xmax, xthresh, \
xinvert, xtlv_array) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
SNDRV_CTL_ELEM_ACCESS_READWRITE, \
.tlv.p = (xtlv_array), \
.info = tda7419_vol_info, \
.get = tda7419_vol_get, \
.put = tda7419_vol_put, \
.private_value = TDA7419_SINGLE_VALUE(xreg, xmask, xmin, \
xmax, xthresh, xinvert), \
}
#define TDA7419_DOUBLE_R_TLV(xname, xregl, xregr, xmask, xmin, xmax, \
xthresh, xinvert, xtlv_array) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
.name = xname, \
.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
SNDRV_CTL_ELEM_ACCESS_READWRITE, \
.tlv.p = (xtlv_array), \
.info = tda7419_vol_info, \
.get = tda7419_vol_get, \
.put = tda7419_vol_put, \
.private_value = TDA7419_DOUBLE_R_VALUE(xregl, xregr, xmask, \
xmin, xmax, xthresh, \
xinvert), \
}
static const char * const enum_src_sel[] = {
"QD", "SE1", "SE2", "SE3", "SE", "Mute", "Mute", "Mute"};
static SOC_ENUM_SINGLE_DECL(soc_enum_main_src_sel,
TDA7419_MAIN_SRC_REG, TDA7419_MAIN_SRC_SEL, enum_src_sel);
static const struct snd_kcontrol_new soc_mux_main_src_sel =
SOC_DAPM_ENUM("Main Source Select", soc_enum_main_src_sel);
static DECLARE_TLV_DB_SCALE(tlv_src_gain, 0, 100, 0);
static DECLARE_TLV_DB_SCALE(tlv_loudness_atten, -1500, 100, 0);
static const char * const enum_loudness_center_freq[] = {
"Flat", "400 Hz", "800 Hz", "2400 Hz"};
static SOC_ENUM_SINGLE_DECL(soc_enum_loudness_center_freq,
TDA7419_LOUDNESS_REG, TDA7419_LOUDNESS_CENTER_FREQ,
enum_loudness_center_freq);
static const char * const enum_mute_influence[] = {
"Pin and IIC", "IIC"};
static SOC_ENUM_SINGLE_DECL(soc_enum_mute_influence,
TDA7419_MUTE_CLK_REG, TDA7419_MUTE_INFLUENCE, enum_mute_influence);
static const char * const enum_soft_mute_time[] = {
"0.48 ms", "0.96 ms", "123 ms", "123 ms"};
static SOC_ENUM_SINGLE_DECL(soc_enum_soft_mute_time,
TDA7419_MUTE_CLK_REG, TDA7419_SOFT_MUTE_TIME, enum_soft_mute_time);
static const char * const enum_soft_step_time[] = {
"0.160 ms", "0.321 ms", "0.642 ms", "1.28 ms",
"2.56 ms", "5.12 ms", "10.24 ms", "20.48 ms"};
static SOC_ENUM_SINGLE_DECL(soc_enum_soft_step_time,
TDA7419_MUTE_CLK_REG, TDA7419_SOFT_STEP_TIME, enum_soft_step_time);
static DECLARE_TLV_DB_SCALE(tlv_volume, -8000, 100, 1);
static const char * const enum_treble_center_freq[] = {
"10.0 kHz", "12.5 kHz", "15.0 kHz", "17.5 kHz"};
static DECLARE_TLV_DB_SCALE(tlv_filter, -1500, 100, 0);
static SOC_ENUM_SINGLE_DECL(soc_enum_treble_center_freq,
TDA7419_TREBLE_REG, TDA7419_TREBLE_CENTER_FREQ,
enum_treble_center_freq);
static const char * const enum_ref_out_select[] = {
"External Vref (4 V)", "Internal Vref (3.3 V)"};
static SOC_ENUM_SINGLE_DECL(soc_enum_ref_out_select,
TDA7419_TREBLE_REG, TDA7419_REF_OUT_SELECT, enum_ref_out_select);
static const char * const enum_middle_q_factor[] = {
"0.5", "0.75", "1.0", "1.25"};
static SOC_ENUM_SINGLE_DECL(soc_enum_middle_q_factor,
TDA7419_MIDDLE_REG, TDA7419_MIDDLE_Q_FACTOR, enum_middle_q_factor);
static const char * const enum_bass_q_factor[] = {
"1.0", "1.25", "1.5", "2.0"};
static SOC_ENUM_SINGLE_DECL(soc_enum_bass_q_factor,
TDA7419_BASS_REG, TDA7419_BASS_Q_FACTOR, enum_bass_q_factor);
static SOC_ENUM_SINGLE_DECL(soc_enum_second_src_sel,
TDA7419_SECOND_SRC_REG, TDA7419_SECOND_SRC_SEL, enum_src_sel);
static const struct snd_kcontrol_new soc_mux_second_src_sel =
SOC_DAPM_ENUM("Second Source Select", soc_enum_second_src_sel);
static const char * const enum_rear_spkr_src[] = {
"Main", "Second"};
static SOC_ENUM_SINGLE_DECL(soc_enum_rear_spkr_src,
TDA7419_SECOND_SRC_REG, TDA7419_REAR_SPKR_SRC, enum_rear_spkr_src);
static const struct snd_kcontrol_new soc_mux_rear_spkr_src =
SOC_DAPM_ENUM("Rear Speaker Source", soc_enum_rear_spkr_src);
static const char * const enum_sub_cut_off_freq[] = {
"Flat", "80 Hz", "120 Hz", "160 Hz"};
static SOC_ENUM_SINGLE_DECL(soc_enum_sub_cut_off_freq,
TDA7419_SUB_MID_BASS_REG, TDA7419_SUB_CUT_OFF_FREQ,
enum_sub_cut_off_freq);
static const char * const enum_middle_center_freq[] = {
"500 Hz", "1000 Hz", "1500 Hz", "2500 Hz"};
static SOC_ENUM_SINGLE_DECL(soc_enum_middle_center_freq,
TDA7419_SUB_MID_BASS_REG, TDA7419_MIDDLE_CENTER_FREQ,
enum_middle_center_freq);
static const char * const enum_bass_center_freq[] = {
"60 Hz", "80 Hz", "100 Hz", "200 Hz"};
static SOC_ENUM_SINGLE_DECL(soc_enum_bass_center_freq,
TDA7419_SUB_MID_BASS_REG, TDA7419_BASS_CENTER_FREQ,
enum_bass_center_freq);
static const char * const enum_sa_q_factor[] = {
"3.5", "1.75" };
static SOC_ENUM_SINGLE_DECL(soc_enum_sa_q_factor,
TDA7419_SA_CLK_AC_REG, TDA7419_SA_Q_FACTOR, enum_sa_q_factor);
static const char * const enum_reset_mode[] = {
"IIC", "Auto" };
static SOC_ENUM_SINGLE_DECL(soc_enum_reset_mode,
TDA7419_SA_CLK_AC_REG, TDA7419_RESET_MODE, enum_reset_mode);
static const char * const enum_sa_src[] = {
"Bass", "In Gain" };
static SOC_ENUM_SINGLE_DECL(soc_enum_sa_src,
TDA7419_SA_CLK_AC_REG, TDA7419_SA_SOURCE, enum_sa_src);
static const char * const enum_clk_src[] = {
"Internal", "External" };
static SOC_ENUM_SINGLE_DECL(soc_enum_clk_src,
TDA7419_SA_CLK_AC_REG, TDA7419_CLK_SOURCE, enum_clk_src);
static const char * const enum_coupling_mode[] = {
"DC Coupling (without HPF)", "AC Coupling after In Gain",
"DC Coupling (with HPF)", "AC Coupling after Bass" };
static SOC_ENUM_SINGLE_DECL(soc_enum_coupling_mode,
TDA7419_SA_CLK_AC_REG, TDA7419_COUPLING_MODE, enum_coupling_mode);
/* ASoC Controls */
static struct snd_kcontrol_new tda7419_controls[] = {
SOC_SINGLE_TLV("Main Source Capture Volume", TDA7419_MAIN_SRC_REG,
TDA7419_MAIN_SRC_GAIN, 15, 0, tlv_src_gain),
SOC_SINGLE("Main Source AutoZero Switch", TDA7419_MAIN_SRC_REG,
TDA7419_MAIN_SRC_AUTOZERO, 1, 1),
SOC_SINGLE_TLV("Loudness Playback Volume", TDA7419_LOUDNESS_REG,
TDA7419_LOUDNESS_ATTEN, 15, 1, tlv_loudness_atten),
SOC_ENUM("Loudness Center Frequency", soc_enum_loudness_center_freq),
SOC_SINGLE("Loudness High Boost Switch", TDA7419_LOUDNESS_REG,
TDA7419_LOUDNESS_BOOST, 1, 1),
SOC_SINGLE("Loudness Soft Step Switch", TDA7419_LOUDNESS_REG,
TDA7419_LOUDNESS_SOFT_STEP, 1, 1),
SOC_SINGLE("Soft Mute Switch", TDA7419_MUTE_CLK_REG, TDA7419_SOFT_MUTE, 1, 1),
SOC_ENUM("Mute Influence", soc_enum_mute_influence),
SOC_ENUM("Soft Mute Time", soc_enum_soft_mute_time),
SOC_ENUM("Soft Step Time", soc_enum_soft_step_time),
SOC_SINGLE("Clock Fast Mode Switch", TDA7419_MUTE_CLK_REG,
TDA7419_CLK_FAST_MODE, 1, 1),
TDA7419_SINGLE_TLV("Master Playback Volume", TDA7419_VOLUME_REG,
0x7f, -80, 15, 0x10, 0, tlv_volume),
SOC_SINGLE("Volume Soft Step Switch", TDA7419_VOLUME_REG,
TDA7419_VOLUME_SOFT_STEP, 1, 1),
TDA7419_SINGLE_TLV("Treble Playback Volume", TDA7419_TREBLE_REG,
0x1f, -15, 15, 0x10, 1, tlv_filter),
SOC_ENUM("Treble Center Frequency", soc_enum_treble_center_freq),
SOC_ENUM("Reference Output Select", soc_enum_ref_out_select),
TDA7419_SINGLE_TLV("Middle Playback Volume", TDA7419_MIDDLE_REG,
0x1f, -15, 15, 0x10, 1, tlv_filter),
SOC_ENUM("Middle Q Factor", soc_enum_middle_q_factor),
SOC_SINGLE("Middle Soft Step Switch", TDA7419_MIDDLE_REG,
TDA7419_MIDDLE_SOFT_STEP, 1, 1),
TDA7419_SINGLE_TLV("Bass Playback Volume", TDA7419_BASS_REG,
0x1f, -15, 15, 0x10, 1, tlv_filter),
SOC_ENUM("Bass Q Factor", soc_enum_bass_q_factor),
SOC_SINGLE("Bass Soft Step Switch", TDA7419_BASS_REG,
TDA7419_BASS_SOFT_STEP, 1, 1),
SOC_SINGLE_TLV("Second Source Capture Volume", TDA7419_SECOND_SRC_REG,
TDA7419_SECOND_SRC_GAIN, 15, 0, tlv_src_gain),
SOC_ENUM("Subwoofer Cut-off Frequency", soc_enum_sub_cut_off_freq),
SOC_ENUM("Middle Center Frequency", soc_enum_middle_center_freq),
SOC_ENUM("Bass Center Frequency", soc_enum_bass_center_freq),
SOC_SINGLE("Bass DC Mode Switch", TDA7419_SUB_MID_BASS_REG,
TDA7419_BASS_DC_MODE, 1, 1),
SOC_SINGLE("Smoothing Filter Switch", TDA7419_SUB_MID_BASS_REG,
TDA7419_SMOOTHING_FILTER, 1, 1),
TDA7419_DOUBLE_R_TLV("Front Speaker Playback Volume", TDA7419_ATTENUATOR_LF_REG,
TDA7419_ATTENUATOR_RF_REG, 0x7f, -80, 15, 0x10, 0,
tlv_volume),
SOC_SINGLE("Left Front Soft Step Switch", TDA7419_ATTENUATOR_LF_REG,
TDA7419_VOLUME_SOFT_STEP, 1, 1),
SOC_SINGLE("Right Front Soft Step Switch", TDA7419_ATTENUATOR_RF_REG,
TDA7419_VOLUME_SOFT_STEP, 1, 1),
TDA7419_DOUBLE_R_TLV("Rear Speaker Playback Volume", TDA7419_ATTENUATOR_LR_REG,
TDA7419_ATTENUATOR_RR_REG, 0x7f, -80, 15, 0x10, 0,
tlv_volume),
SOC_SINGLE("Left Rear Soft Step Switch", TDA7419_ATTENUATOR_LR_REG,
TDA7419_VOLUME_SOFT_STEP, 1, 1),
SOC_SINGLE("Right Rear Soft Step Switch", TDA7419_ATTENUATOR_RR_REG,
TDA7419_VOLUME_SOFT_STEP, 1, 1),
TDA7419_SINGLE_TLV("Mixing Capture Volume", TDA7419_MIXING_LEVEL_REG,
0x7f, -80, 15, 0x10, 0, tlv_volume),
SOC_SINGLE("Mixing Level Soft Step Switch", TDA7419_MIXING_LEVEL_REG,
TDA7419_VOLUME_SOFT_STEP, 1, 1),
TDA7419_SINGLE_TLV("Subwoofer Playback Volume", TDA7419_ATTENUATOR_SUB_REG,
0x7f, -80, 15, 0x10, 0, tlv_volume),
SOC_SINGLE("Subwoofer Soft Step Switch", TDA7419_ATTENUATOR_SUB_REG,
TDA7419_VOLUME_SOFT_STEP, 1, 1),
SOC_ENUM("Spectrum Analyzer Q Factor", soc_enum_sa_q_factor),
SOC_ENUM("Spectrum Analyzer Reset Mode", soc_enum_reset_mode),
SOC_ENUM("Spectrum Analyzer Source", soc_enum_sa_src),
SOC_SINGLE("Spectrum Analyzer Run Switch", TDA7419_SA_CLK_AC_REG,
TDA7419_SA_RUN, 1, 1),
SOC_SINGLE("Spectrum Analyzer Reset Switch", TDA7419_SA_CLK_AC_REG,
TDA7419_RESET, 1, 1),
SOC_ENUM("Clock Source", soc_enum_clk_src),
SOC_ENUM("Coupling Mode", soc_enum_coupling_mode),
};
static const struct snd_kcontrol_new soc_mixer_lf_output_controls[] = {
SOC_DAPM_SINGLE("Mix to LF Speaker Switch",
TDA7419_MIXING_GAIN_REG,
TDA7419_MIX_LF, 1, 1),
};
static const struct snd_kcontrol_new soc_mixer_rf_output_controls[] = {
SOC_DAPM_SINGLE("Mix to RF Speaker Switch",
TDA7419_MIXING_GAIN_REG,
TDA7419_MIX_RF, 1, 1),
};
static const struct snd_kcontrol_new soc_mix_enable_switch_controls[] = {
SOC_DAPM_SINGLE("Switch", TDA7419_MIXING_GAIN_REG,
TDA7419_MIX_ENABLE, 1, 1),
};
static const struct snd_kcontrol_new soc_sub_enable_switch_controls[] = {
SOC_DAPM_SINGLE("Switch", TDA7419_MIXING_GAIN_REG,
TDA7419_MIX_ENABLE, 1, 1),
};
static const struct snd_soc_dapm_widget tda7419_dapm_widgets[] = {
SND_SOC_DAPM_INPUT("SE3L"),
SND_SOC_DAPM_INPUT("SE3R"),
SND_SOC_DAPM_INPUT("SE2L"),
SND_SOC_DAPM_INPUT("SE2R"),
SND_SOC_DAPM_INPUT("SE1L"),
SND_SOC_DAPM_INPUT("SE1R"),
SND_SOC_DAPM_INPUT("DIFFL"),
SND_SOC_DAPM_INPUT("DIFFR"),
SND_SOC_DAPM_INPUT("MIX"),
SND_SOC_DAPM_MUX("Main Source Select", SND_SOC_NOPM,
0, 0, &soc_mux_main_src_sel),
SND_SOC_DAPM_MUX("Second Source Select", SND_SOC_NOPM,
0, 0, &soc_mux_second_src_sel),
SND_SOC_DAPM_MUX("Rear Speaker Source", SND_SOC_NOPM,
0, 0, &soc_mux_rear_spkr_src),
SND_SOC_DAPM_SWITCH("Mix Enable", SND_SOC_NOPM,
0, 0, &soc_mix_enable_switch_controls[0]),
SND_SOC_DAPM_MIXER_NAMED_CTL("LF Output Mixer", SND_SOC_NOPM,
0, 0, &soc_mixer_lf_output_controls[0],
ARRAY_SIZE(soc_mixer_lf_output_controls)),
SND_SOC_DAPM_MIXER_NAMED_CTL("RF Output Mixer", SND_SOC_NOPM,
0, 0, &soc_mixer_rf_output_controls[0],
ARRAY_SIZE(soc_mixer_rf_output_controls)),
SND_SOC_DAPM_SWITCH("Subwoofer Enable",
SND_SOC_NOPM, 0, 0,
&soc_sub_enable_switch_controls[0]),
SND_SOC_DAPM_OUTPUT("OUTLF"),
SND_SOC_DAPM_OUTPUT("OUTRF"),
SND_SOC_DAPM_OUTPUT("OUTLR"),
SND_SOC_DAPM_OUTPUT("OUTRR"),
SND_SOC_DAPM_OUTPUT("OUTSW"),
};
static const struct snd_soc_dapm_route tda7419_dapm_routes[] = {
{"Main Source Select", "SE3", "SE3L"},
{"Main Source Select", "SE3", "SE3R"},
{"Main Source Select", "SE2", "SE2L"},
{"Main Source Select", "SE2", "SE2R"},
{"Main Source Select", "SE1", "SE1L"},
{"Main Source Select", "SE1", "SE1R"},
{"Main Source Select", "SE", "DIFFL"},
{"Main Source Select", "SE", "DIFFR"},
{"Main Source Select", "QD", "DIFFL"},
{"Main Source Select", "QD", "DIFFR"},
{"Second Source Select", "SE3", "SE3L"},
{"Second Source Select", "SE3", "SE3R"},
{"Second Source Select", "SE2", "SE2L"},
{"Second Source Select", "SE2", "SE2R"},
{"Second Source Select", "SE1", "SE1L"},
{"Second Source Select", "SE1", "SE1R"},
{"Second Source Select", "SE", "DIFFL"},
{"Second Source Select", "SE", "DIFFR"},
{"Second Source Select", "QD", "DIFFL"},
{"Second Source Select", "QD", "DIFFR"},
{"Rear Speaker Source", "Main", "Main Source Select"},
{"Rear Speaker Source", "Second", "Second Source Select"},
{"Subwoofer Enable", "Switch", "Main Source Select"},
{"Mix Enable", "Switch", "MIX"},
{"LF Output Mixer", NULL, "Main Source Select"},
{"LF Output Mixer", "Mix to LF Speaker Switch", "Mix Enable"},
{"RF Output Mixer", NULL, "Main Source Select"},
{"RF Output Mixer", "Mix to RF Speaker Switch", "Mix Enable"},
{"OUTLF", NULL, "LF Output Mixer"},
{"OUTRF", NULL, "RF Output Mixer"},
{"OUTLR", NULL, "Rear Speaker Source"},
{"OUTRR", NULL, "Rear Speaker Source"},
{"OUTSW", NULL, "Subwoofer Enable"},
};
static const struct snd_soc_component_driver tda7419_component_driver = {
.name = "tda7419",
.controls = tda7419_controls,
.num_controls = ARRAY_SIZE(tda7419_controls),
.dapm_widgets = tda7419_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tda7419_dapm_widgets),
.dapm_routes = tda7419_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(tda7419_dapm_routes),
};
static int tda7419_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct tda7419_data *tda7419;
int i, ret;
tda7419 = devm_kzalloc(&i2c->dev,
sizeof(struct tda7419_data),
GFP_KERNEL);
if (tda7419 == NULL)
return -ENOMEM;
i2c_set_clientdata(i2c, tda7419);
tda7419->regmap = devm_regmap_init_i2c(i2c, &tda7419_regmap_config);
if (IS_ERR(tda7419->regmap)) {
ret = PTR_ERR(tda7419->regmap);
dev_err(&i2c->dev, "error initializing regmap: %d\n",
ret);
return ret;
}
/*
* Reset registers to power-on defaults. The part does not provide a
* soft-reset function and the registers are not readable. This ensures
* that the cache matches register contents even if the registers have
* been previously initialized and not power cycled before probe.
*/
for (i = 0; i < ARRAY_SIZE(tda7419_regmap_defaults); i++)
regmap_write(tda7419->regmap,
tda7419_regmap_defaults[i].reg,
tda7419_regmap_defaults[i].def);
ret = devm_snd_soc_register_component(&i2c->dev,
&tda7419_component_driver, NULL, 0);
if (ret < 0) {
dev_err(&i2c->dev, "error registering component: %d\n",
ret);
}
return ret;
}
static const struct i2c_device_id tda7419_i2c_id[] = {
{ "tda7419", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, tda7419_i2c_id);
static const struct of_device_id tda7419_of_match[] = {
{ .compatible = "st,tda7419" },
{ },
};
static struct i2c_driver tda7419_driver = {
.driver = {
.name = "tda7419",
.of_match_table = tda7419_of_match,
},
.probe = tda7419_probe,
.id_table = tda7419_i2c_id,
};
module_i2c_driver(tda7419_driver);
MODULE_AUTHOR("Matt Porter <mporter@konsulko.com>");
MODULE_DESCRIPTION("TDA7419 audio processor driver");
MODULE_LICENSE("GPL");
......@@ -30,8 +30,8 @@ static int tfa9879_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct tfa9879_priv *tfa9879 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *component = dai->component;
struct tfa9879_priv *tfa9879 = snd_soc_component_get_drvdata(component);
int fs;
int i2s_set = 0;
......@@ -88,11 +88,11 @@ static int tfa9879_hw_params(struct snd_pcm_substream *substream,
}
if (tfa9879->lsb_justified)
snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1,
snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1,
TFA9879_I2S_SET_MASK,
i2s_set << TFA9879_I2S_SET_SHIFT);
snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1,
snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1,
TFA9879_I2S_FS_MASK,
fs << TFA9879_I2S_FS_SHIFT);
return 0;
......@@ -100,9 +100,9 @@ static int tfa9879_hw_params(struct snd_pcm_substream *substream,
static int tfa9879_digital_mute(struct snd_soc_dai *dai, int mute)
{
struct snd_soc_codec *codec = dai->codec;
struct snd_soc_component *component = dai->component;
snd_soc_update_bits(codec, TFA9879_MISC_CONTROL,
snd_soc_component_update_bits(component, TFA9879_MISC_CONTROL,
TFA9879_S_MUTE_MASK,
!!mute << TFA9879_S_MUTE_SHIFT);
......@@ -111,8 +111,8 @@ static int tfa9879_digital_mute(struct snd_soc_dai *dai, int mute)
static int tfa9879_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
struct snd_soc_codec *codec = dai->codec;
struct tfa9879_priv *tfa9879 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *component = dai->component;
struct tfa9879_priv *tfa9879 = snd_soc_component_get_drvdata(component);
int i2s_set;
int sck_pol;
......@@ -151,10 +151,10 @@ static int tfa9879_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
return -EINVAL;
}
snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1,
snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1,
TFA9879_SCK_POL_MASK,
sck_pol << TFA9879_SCK_POL_SHIFT);
snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1,
snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1,
TFA9879_I2S_SET_MASK,
i2s_set << TFA9879_I2S_SET_SHIFT);
return 0;
......@@ -230,15 +230,17 @@ static const struct snd_soc_dapm_route tfa9879_dapm_routes[] = {
{ "DAC", NULL, "POWER" },
};
static const struct snd_soc_codec_driver tfa9879_codec = {
.component_driver = {
.controls = tfa9879_controls,
.num_controls = ARRAY_SIZE(tfa9879_controls),
.dapm_widgets = tfa9879_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tfa9879_dapm_widgets),
.dapm_routes = tfa9879_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(tfa9879_dapm_routes),
},
static const struct snd_soc_component_driver tfa9879_component = {
.controls = tfa9879_controls,
.num_controls = ARRAY_SIZE(tfa9879_controls),
.dapm_widgets = tfa9879_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tfa9879_dapm_widgets),
.dapm_routes = tfa9879_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(tfa9879_dapm_routes),
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
};
static const struct regmap_config tfa9879_regmap = {
......@@ -295,17 +297,10 @@ static int tfa9879_i2c_probe(struct i2c_client *i2c,
regmap_write(tfa9879->regmap,
tfa9879_regs[i].reg, tfa9879_regs[i].def);
return snd_soc_register_codec(&i2c->dev, &tfa9879_codec,
return devm_snd_soc_register_component(&i2c->dev, &tfa9879_component,
&tfa9879_dai, 1);
}
static int tfa9879_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id tfa9879_i2c_id[] = {
{ "tfa9879", 0 },
{ }
......@@ -324,7 +319,6 @@ static struct i2c_driver tfa9879_i2c_driver = {
.of_match_table = tfa9879_of_match,
},
.probe = tfa9879_i2c_probe,
.remove = tfa9879_i2c_remove,
.id_table = tfa9879_i2c_id,
};
......
......@@ -31,12 +31,6 @@ static int tlv320aic23_i2c_probe(struct i2c_client *i2c,
return tlv320aic23_probe(&i2c->dev, regmap);
}
static int tlv320aic23_i2c_remove(struct i2c_client *i2c)
{
snd_soc_unregister_codec(&i2c->dev);
return 0;
}
static const struct i2c_device_id tlv320aic23_id[] = {
{"tlv320aic23", 0},
{}
......@@ -56,7 +50,6 @@ static struct i2c_driver tlv320aic23_i2c_driver = {
.of_match_table = of_match_ptr(tlv320aic23_of_match),
},
.probe = tlv320aic23_i2c_probe,
.remove = tlv320aic23_i2c_remove,
.id_table = tlv320aic23_id,
};
......
......@@ -34,18 +34,11 @@ static int aic23_spi_probe(struct spi_device *spi)
return tlv320aic23_probe(&spi->dev, regmap);
}
static int aic23_spi_remove(struct spi_device *spi)
{
snd_soc_unregister_codec(&spi->dev);
return 0;
}
static struct spi_driver aic23_spi = {
.driver = {
.name = "tlv320aic23",
},
.probe = aic23_spi_probe,
.remove = aic23_spi_remove,
};
module_spi_driver(aic23_spi);
......
......@@ -82,7 +82,7 @@ static const DECLARE_TLV_DB_SCALE(sidetone_vol_tlv, -1800, 300, 0);
static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
u16 val, reg;
val = (ucontrol->value.integer.value[0] & 0x07);
......@@ -96,8 +96,8 @@ static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol,
*/
val = (val >= 4) ? 4 : (3 - val);
reg = snd_soc_read(codec, TLV320AIC23_ANLG) & (~0x1C0);
snd_soc_write(codec, TLV320AIC23_ANLG, reg | (val << 6));
reg = snd_soc_component_read32(component, TLV320AIC23_ANLG) & (~0x1C0);
snd_soc_component_write(component, TLV320AIC23_ANLG, reg | (val << 6));
return 0;
}
......@@ -105,10 +105,10 @@ static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol,
static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
u16 val;
val = snd_soc_read(codec, TLV320AIC23_ANLG) & (0x1C0);
val = snd_soc_component_read32(component, TLV320AIC23_ANLG) & (0x1C0);
val = val >> 6;
val = (val >= 4) ? 4 : (3 - val);
ucontrol->value.integer.value[0] = val;
......@@ -296,10 +296,10 @@ static int find_rate(int mclk, u32 need_adc, u32 need_dac)
}
#ifdef DEBUG
static void get_current_sample_rates(struct snd_soc_codec *codec, int mclk,
static void get_current_sample_rates(struct snd_soc_component *component, int mclk,
u32 *sample_rate_adc, u32 *sample_rate_dac)
{
int src = snd_soc_read(codec, TLV320AIC23_SRATE);
int src = snd_soc_component_read32(component, TLV320AIC23_SRATE);
int sr = (src >> 2) & 0x0f;
int val = (mclk / bosr_usb_divisor_table[src & 3]);
int adc = (val * sr_adc_mult_table[sr]) / SR_MULT;
......@@ -313,7 +313,7 @@ static void get_current_sample_rates(struct snd_soc_codec *codec, int mclk,
}
#endif
static int set_sample_rate_control(struct snd_soc_codec *codec, int mclk,
static int set_sample_rate_control(struct snd_soc_component *component, int mclk,
u32 sample_rate_adc, u32 sample_rate_dac)
{
/* Search for the right sample rate */
......@@ -323,11 +323,11 @@ static int set_sample_rate_control(struct snd_soc_codec *codec, int mclk,
__func__, sample_rate_adc, sample_rate_dac);
return -EINVAL;
}
snd_soc_write(codec, TLV320AIC23_SRATE, data);
snd_soc_component_write(component, TLV320AIC23_SRATE, data);
#ifdef DEBUG
{
u32 adc, dac;
get_current_sample_rates(codec, mclk, &adc, &dac);
get_current_sample_rates(component, mclk, &adc, &dac);
printk(KERN_DEBUG "actual samplerate = %u,%u reg=%x\n",
adc, dac, data);
}
......@@ -339,10 +339,10 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct snd_soc_component *component = dai->component;
u16 iface_reg;
int ret;
struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec);
struct aic23 *aic23 = snd_soc_component_get_drvdata(component);
u32 sample_rate_adc = aic23->requested_adc;
u32 sample_rate_dac = aic23->requested_dac;
u32 sample_rate = params_rate(params);
......@@ -356,12 +356,12 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream,
if (!sample_rate_dac)
sample_rate_dac = sample_rate;
}
ret = set_sample_rate_control(codec, aic23->mclk, sample_rate_adc,
ret = set_sample_rate_control(component, aic23->mclk, sample_rate_adc,
sample_rate_dac);
if (ret < 0)
return ret;
iface_reg = snd_soc_read(codec, TLV320AIC23_DIGT_FMT) & ~(0x03 << 2);
iface_reg = snd_soc_component_read32(component, TLV320AIC23_DIGT_FMT) & ~(0x03 << 2);
switch (params_width(params)) {
case 16:
......@@ -376,7 +376,7 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream,
iface_reg |= (0x03 << 2);
break;
}
snd_soc_write(codec, TLV320AIC23_DIGT_FMT, iface_reg);
snd_soc_component_write(component, TLV320AIC23_DIGT_FMT, iface_reg);
return 0;
}
......@@ -384,10 +384,10 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream,
static int tlv320aic23_pcm_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct snd_soc_component *component = dai->component;
/* set active */
snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0001);
snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x0001);
return 0;
}
......@@ -395,13 +395,13 @@ static int tlv320aic23_pcm_prepare(struct snd_pcm_substream *substream,
static void tlv320aic23_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *component = dai->component;
struct aic23 *aic23 = snd_soc_component_get_drvdata(component);
/* deactivate */
if (!snd_soc_codec_is_active(codec)) {
if (!snd_soc_component_is_active(component)) {
udelay(50);
snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0);
snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x0);
}
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
aic23->requested_dac = 0;
......@@ -411,17 +411,17 @@ static void tlv320aic23_shutdown(struct snd_pcm_substream *substream,
static int tlv320aic23_mute(struct snd_soc_dai *dai, int mute)
{
struct snd_soc_codec *codec = dai->codec;
struct snd_soc_component *component = dai->component;
u16 reg;
reg = snd_soc_read(codec, TLV320AIC23_DIGT);
reg = snd_soc_component_read32(component, TLV320AIC23_DIGT);
if (mute)
reg |= TLV320AIC23_DACM_MUTE;
else
reg &= ~TLV320AIC23_DACM_MUTE;
snd_soc_write(codec, TLV320AIC23_DIGT, reg);
snd_soc_component_write(component, TLV320AIC23_DIGT, reg);
return 0;
}
......@@ -429,10 +429,10 @@ static int tlv320aic23_mute(struct snd_soc_dai *dai, int mute)
static int tlv320aic23_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt)
{
struct snd_soc_codec *codec = codec_dai->codec;
struct snd_soc_component *component = codec_dai->component;
u16 iface_reg;
iface_reg = snd_soc_read(codec, TLV320AIC23_DIGT_FMT) & (~0x03);
iface_reg = snd_soc_component_read32(component, TLV320AIC23_DIGT_FMT) & (~0x03);
/* set master/slave audio interface */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
......@@ -468,7 +468,7 @@ static int tlv320aic23_set_dai_fmt(struct snd_soc_dai *codec_dai,
}
snd_soc_write(codec, TLV320AIC23_DIGT_FMT, iface_reg);
snd_soc_component_write(component, TLV320AIC23_DIGT_FMT, iface_reg);
return 0;
}
......@@ -481,29 +481,29 @@ static int tlv320aic23_set_dai_sysclk(struct snd_soc_dai *codec_dai,
return 0;
}
static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec,
static int tlv320aic23_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{
u16 reg = snd_soc_read(codec, TLV320AIC23_PWR) & 0x17f;
u16 reg = snd_soc_component_read32(component, TLV320AIC23_PWR) & 0x17f;
switch (level) {
case SND_SOC_BIAS_ON:
/* vref/mid, osc on, dac unmute */
reg &= ~(TLV320AIC23_DEVICE_PWR_OFF | TLV320AIC23_OSC_OFF | \
TLV320AIC23_DAC_OFF);
snd_soc_write(codec, TLV320AIC23_PWR, reg);
snd_soc_component_write(component, TLV320AIC23_PWR, reg);
break;
case SND_SOC_BIAS_PREPARE:
break;
case SND_SOC_BIAS_STANDBY:
/* everything off except vref/vmid, */
snd_soc_write(codec, TLV320AIC23_PWR,
snd_soc_component_write(component, TLV320AIC23_PWR,
reg | TLV320AIC23_CLK_OFF);
break;
case SND_SOC_BIAS_OFF:
/* everything off, dac mute, inactive */
snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0);
snd_soc_write(codec, TLV320AIC23_PWR, 0x1ff);
snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x0);
snd_soc_component_write(component, TLV320AIC23_PWR, 0x1ff);
break;
}
return 0;
......@@ -539,58 +539,59 @@ static struct snd_soc_dai_driver tlv320aic23_dai = {
.ops = &tlv320aic23_dai_ops,
};
static int tlv320aic23_resume(struct snd_soc_codec *codec)
static int tlv320aic23_resume(struct snd_soc_component *component)
{
struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec);
struct aic23 *aic23 = snd_soc_component_get_drvdata(component);
regcache_mark_dirty(aic23->regmap);
regcache_sync(aic23->regmap);
return 0;
}
static int tlv320aic23_codec_probe(struct snd_soc_codec *codec)
static int tlv320aic23_component_probe(struct snd_soc_component *component)
{
/* Reset codec */
snd_soc_write(codec, TLV320AIC23_RESET, 0);
snd_soc_component_write(component, TLV320AIC23_RESET, 0);
snd_soc_write(codec, TLV320AIC23_DIGT, TLV320AIC23_DEEMP_44K);
snd_soc_component_write(component, TLV320AIC23_DIGT, TLV320AIC23_DEEMP_44K);
/* Unmute input */
snd_soc_update_bits(codec, TLV320AIC23_LINVOL,
snd_soc_component_update_bits(component, TLV320AIC23_LINVOL,
TLV320AIC23_LIM_MUTED, TLV320AIC23_LRS_ENABLED);
snd_soc_update_bits(codec, TLV320AIC23_RINVOL,
snd_soc_component_update_bits(component, TLV320AIC23_RINVOL,
TLV320AIC23_LIM_MUTED, TLV320AIC23_LRS_ENABLED);
snd_soc_update_bits(codec, TLV320AIC23_ANLG,
snd_soc_component_update_bits(component, TLV320AIC23_ANLG,
TLV320AIC23_BYPASS_ON | TLV320AIC23_MICM_MUTED,
0);
/* Default output volume */
snd_soc_write(codec, TLV320AIC23_LCHNVOL,
snd_soc_component_write(component, TLV320AIC23_LCHNVOL,
TLV320AIC23_DEFAULT_OUT_VOL & TLV320AIC23_OUT_VOL_MASK);
snd_soc_write(codec, TLV320AIC23_RCHNVOL,
snd_soc_component_write(component, TLV320AIC23_RCHNVOL,
TLV320AIC23_DEFAULT_OUT_VOL & TLV320AIC23_OUT_VOL_MASK);
snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x1);
snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x1);
return 0;
}
static const struct snd_soc_codec_driver soc_codec_dev_tlv320aic23 = {
.probe = tlv320aic23_codec_probe,
.resume = tlv320aic23_resume,
.set_bias_level = tlv320aic23_set_bias_level,
.suspend_bias_off = true,
.component_driver = {
.controls = tlv320aic23_snd_controls,
.num_controls = ARRAY_SIZE(tlv320aic23_snd_controls),
.dapm_widgets = tlv320aic23_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets),
.dapm_routes = tlv320aic23_intercon,
.num_dapm_routes = ARRAY_SIZE(tlv320aic23_intercon),
},
static const struct snd_soc_component_driver soc_component_dev_tlv320aic23 = {
.probe = tlv320aic23_component_probe,
.resume = tlv320aic23_resume,
.set_bias_level = tlv320aic23_set_bias_level,
.controls = tlv320aic23_snd_controls,
.num_controls = ARRAY_SIZE(tlv320aic23_snd_controls),
.dapm_widgets = tlv320aic23_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets),
.dapm_routes = tlv320aic23_intercon,
.num_dapm_routes = ARRAY_SIZE(tlv320aic23_intercon),
.suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
};
int tlv320aic23_probe(struct device *dev, struct regmap *regmap)
......@@ -608,7 +609,8 @@ int tlv320aic23_probe(struct device *dev, struct regmap *regmap)
dev_set_drvdata(dev, aic23);
return snd_soc_register_codec(dev, &soc_codec_dev_tlv320aic23,
return devm_snd_soc_register_component(dev,
&soc_component_dev_tlv320aic23,
&tlv320aic23_dai, 1);
}
EXPORT_SYMBOL(tlv320aic23_probe);
......
......@@ -30,7 +30,7 @@ MODULE_LICENSE("GPL");
struct aic26 {
struct spi_device *spi;
struct regmap *regmap;
struct snd_soc_codec *codec;
struct snd_soc_component *component;
int master;
int datfm;
int mclk;
......@@ -64,8 +64,8 @@ static int aic26_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *component = dai->component;
struct aic26 *aic26 = snd_soc_component_get_drvdata(component);
int fsref, divisor, wlen, pval, jval, dval, qval;
u16 reg;
......@@ -112,20 +112,20 @@ static int aic26_hw_params(struct snd_pcm_substream *substream,
dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval);
qval = 0;
reg = 0x8000 | qval << 11 | pval << 8 | jval << 2;
snd_soc_write(codec, AIC26_REG_PLL_PROG1, reg);
snd_soc_component_write(component, AIC26_REG_PLL_PROG1, reg);
reg = dval << 2;
snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg);
snd_soc_component_write(component, AIC26_REG_PLL_PROG2, reg);
/* Audio Control 3 (master mode, fsref rate) */
if (aic26->master)
reg = 0x0800;
if (fsref == 48000)
reg = 0x2000;
snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL3, 0xf800, reg);
snd_soc_component_update_bits(component, AIC26_REG_AUDIO_CTRL3, 0xf800, reg);
/* Audio Control 1 (FSref divisor) */
reg = wlen | aic26->datfm | (divisor << 3) | divisor;
snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL1, 0xfff, reg);
snd_soc_component_update_bits(component, AIC26_REG_AUDIO_CTRL1, 0xfff, reg);
return 0;
}
......@@ -135,8 +135,8 @@ static int aic26_hw_params(struct snd_pcm_substream *substream,
*/
static int aic26_mute(struct snd_soc_dai *dai, int mute)
{
struct snd_soc_codec *codec = dai->codec;
struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *component = dai->component;
struct aic26 *aic26 = snd_soc_component_get_drvdata(component);
u16 reg;
dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n",
......@@ -146,7 +146,7 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute)
reg = 0x8080;
else
reg = 0;
snd_soc_update_bits(codec, AIC26_REG_DAC_GAIN, 0x8000, reg);
snd_soc_component_update_bits(component, AIC26_REG_DAC_GAIN, 0x8000, reg);
return 0;
}
......@@ -154,8 +154,8 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute)
static int aic26_set_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{
struct snd_soc_codec *codec = codec_dai->codec;
struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *component = codec_dai->component;
struct aic26 *aic26 = snd_soc_component_get_drvdata(component);
dev_dbg(&aic26->spi->dev, "aic26_set_sysclk(dai=%p, clk_id==%i,"
" freq=%i, dir=%i)\n",
......@@ -171,8 +171,8 @@ static int aic26_set_sysclk(struct snd_soc_dai *codec_dai,
static int aic26_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{
struct snd_soc_codec *codec = codec_dai->codec;
struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *component = codec_dai->component;
struct aic26 *aic26 = snd_soc_component_get_drvdata(component);
dev_dbg(&aic26->spi->dev, "aic26_set_fmt(dai=%p, fmt==%i)\n",
codec_dai, fmt);
......@@ -265,7 +265,7 @@ static ssize_t aic26_keyclick_show(struct device *dev,
struct aic26 *aic26 = dev_get_drvdata(dev);
int val, amp, freq, len;
val = snd_soc_read(aic26->codec, AIC26_REG_AUDIO_CTRL2);
val = snd_soc_component_read32(aic26->component, AIC26_REG_AUDIO_CTRL2);
amp = (val >> 12) & 0x7;
freq = (125 << ((val >> 8) & 0x7)) >> 1;
len = 2 * (1 + ((val >> 4) & 0xf));
......@@ -280,7 +280,7 @@ static ssize_t aic26_keyclick_set(struct device *dev,
{
struct aic26 *aic26 = dev_get_drvdata(dev);
snd_soc_update_bits(aic26->codec, AIC26_REG_AUDIO_CTRL2,
snd_soc_component_update_bits(aic26->component, AIC26_REG_AUDIO_CTRL2,
0x8000, 0x800);
return count;
......@@ -291,44 +291,46 @@ static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set);
/* ---------------------------------------------------------------------
* SoC CODEC portion of driver: probe and release routines
*/
static int aic26_probe(struct snd_soc_codec *codec)
static int aic26_probe(struct snd_soc_component *component)
{
struct aic26 *aic26 = dev_get_drvdata(codec->dev);
struct aic26 *aic26 = dev_get_drvdata(component->dev);
int ret, reg;
aic26->codec = codec;
aic26->component = component;
/* Reset the codec to power on defaults */
snd_soc_write(codec, AIC26_REG_RESET, 0xBB00);
snd_soc_component_write(component, AIC26_REG_RESET, 0xBB00);
/* Power up CODEC */
snd_soc_write(codec, AIC26_REG_POWER_CTRL, 0);
snd_soc_component_write(component, AIC26_REG_POWER_CTRL, 0);
/* Audio Control 3 (master mode, fsref rate) */
reg = snd_soc_read(codec, AIC26_REG_AUDIO_CTRL3);
reg = snd_soc_component_read32(component, AIC26_REG_AUDIO_CTRL3);
reg &= ~0xf800;
reg |= 0x0800; /* set master mode */
snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg);
snd_soc_component_write(component, AIC26_REG_AUDIO_CTRL3, reg);
/* Register the sysfs files for debugging */
/* Create SysFS files */
ret = device_create_file(codec->dev, &dev_attr_keyclick);
ret = device_create_file(component->dev, &dev_attr_keyclick);
if (ret)
dev_info(codec->dev, "error creating sysfs files\n");
dev_info(component->dev, "error creating sysfs files\n");
return 0;
}
static const struct snd_soc_codec_driver aic26_soc_codec_dev = {
.probe = aic26_probe,
.component_driver = {
.controls = aic26_snd_controls,
.num_controls = ARRAY_SIZE(aic26_snd_controls),
.dapm_widgets = tlv320aic26_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets),
.dapm_routes = tlv320aic26_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes),
},
static const struct snd_soc_component_driver aic26_soc_component_dev = {
.probe = aic26_probe,
.controls = aic26_snd_controls,
.num_controls = ARRAY_SIZE(aic26_snd_controls),
.dapm_widgets = tlv320aic26_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets),
.dapm_routes = tlv320aic26_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes),
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
};
static const struct regmap_config aic26_regmap = {
......@@ -361,23 +363,16 @@ static int aic26_spi_probe(struct spi_device *spi)
dev_set_drvdata(&spi->dev, aic26);
aic26->master = 1;
ret = snd_soc_register_codec(&spi->dev,
&aic26_soc_codec_dev, &aic26_dai, 1);
ret = devm_snd_soc_register_component(&spi->dev,
&aic26_soc_component_dev, &aic26_dai, 1);
return ret;
}
static int aic26_spi_remove(struct spi_device *spi)
{
snd_soc_unregister_codec(&spi->dev);
return 0;
}
static struct spi_driver aic26_spi = {
.driver = {
.name = "tlv320aic26-codec",
},
.probe = aic26_spi_probe,
.remove = aic26_spi_remove,
};
module_spi_driver(aic26_spi);
......@@ -153,7 +153,7 @@ struct aic31xx_disable_nb {
};
struct aic31xx_priv {
struct snd_soc_codec *codec;
struct snd_soc_component *component;
u8 i2c_regs_status;
struct device *dev;
struct regmap *regmap;
......@@ -166,6 +166,7 @@ struct aic31xx_priv {
unsigned int sysclk;
u8 p_div;
int rate_div_line;
bool master_dapm_route_applied;
};
struct aic31xx_rate_divs {
......@@ -348,8 +349,8 @@ static int aic31xx_wait_bits(struct aic31xx_priv *aic31xx, unsigned int reg,
static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
unsigned int reg = AIC31XX_DACFLAG1;
unsigned int mask;
......@@ -377,7 +378,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w,
reg = AIC31XX_ADCFLAG;
break;
default:
dev_err(codec->dev, "Unknown widget '%s' calling %s\n",
dev_err(component->dev, "Unknown widget '%s' calling %s\n",
w->name, __func__);
return -EINVAL;
}
......@@ -388,7 +389,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w,
case SND_SOC_DAPM_POST_PMD:
return aic31xx_wait_bits(aic31xx, reg, mask, 0, 5000, 100);
default:
dev_dbg(codec->dev,
dev_dbg(component->dev,
"Unhandled dapm widget event %d from %s\n",
event, w->name);
}
......@@ -444,30 +445,30 @@ static const struct snd_kcontrol_new aic31xx_dapm_spr_switch =
static int mic_bias_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
switch (event) {
case SND_SOC_DAPM_POST_PMU:
/* change mic bias voltage to user defined */
snd_soc_update_bits(codec, AIC31XX_MICBIAS,
snd_soc_component_update_bits(component, AIC31XX_MICBIAS,
AIC31XX_MICBIAS_MASK,
aic31xx->micbias_vg <<
AIC31XX_MICBIAS_SHIFT);
dev_dbg(codec->dev, "%s: turned on\n", __func__);
dev_dbg(component->dev, "%s: turned on\n", __func__);
break;
case SND_SOC_DAPM_PRE_PMD:
/* turn mic bias off */
snd_soc_update_bits(codec, AIC31XX_MICBIAS,
snd_soc_component_update_bits(component, AIC31XX_MICBIAS,
AIC31XX_MICBIAS_MASK, 0);
dev_dbg(codec->dev, "%s: turned off\n", __func__);
dev_dbg(component->dev, "%s: turned off\n", __func__);
break;
}
return 0;
}
static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = {
SND_SOC_DAPM_AIF_IN("DAC IN", "DAC Playback", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("AIF IN", "Playback", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_MUX("DAC Left Input",
SND_SOC_NOPM, 0, 0, &ldac_in_control),
......@@ -500,6 +501,10 @@ static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = {
SND_SOC_DAPM_SUPPLY("MICBIAS", SND_SOC_NOPM, 0, 0, mic_bias_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
/* Keep BCLK/WCLK enabled even if DAC/ADC is powered down */
SND_SOC_DAPM_SUPPLY("Activate I2S clocks", AIC31XX_IFACE2, 2, 0,
NULL, 0),
/* Outputs */
SND_SOC_DAPM_OUTPUT("HPL"),
SND_SOC_DAPM_OUTPUT("HPR"),
......@@ -552,6 +557,8 @@ static const struct snd_soc_dapm_widget aic31xx_dapm_widgets[] = {
SND_SOC_DAPM_MIXER("Output Right", SND_SOC_NOPM, 0, 0,
aic31xx_right_output_switches,
ARRAY_SIZE(aic31xx_right_output_switches)),
SND_SOC_DAPM_AIF_OUT("AIF OUT", "Capture", 0, SND_SOC_NOPM, 0, 0),
};
static const struct snd_soc_dapm_widget aic311x_dapm_widgets[] = {
......@@ -583,12 +590,12 @@ static const struct snd_soc_dapm_widget aic310x_dapm_widgets[] = {
static const struct snd_soc_dapm_route
common31xx_audio_map[] = {
/* DAC Input Routing */
{"DAC Left Input", "Left Data", "DAC IN"},
{"DAC Left Input", "Right Data", "DAC IN"},
{"DAC Left Input", "Mono", "DAC IN"},
{"DAC Right Input", "Left Data", "DAC IN"},
{"DAC Right Input", "Right Data", "DAC IN"},
{"DAC Right Input", "Mono", "DAC IN"},
{"DAC Left Input", "Left Data", "AIF IN"},
{"DAC Left Input", "Right Data", "AIF IN"},
{"DAC Left Input", "Mono", "AIF IN"},
{"DAC Right Input", "Left Data", "AIF IN"},
{"DAC Right Input", "Right Data", "AIF IN"},
{"DAC Right Input", "Mono", "AIF IN"},
{"DAC Left", NULL, "DAC Left Input"},
{"DAC Right", NULL, "DAC Right Input"},
......@@ -639,6 +646,8 @@ aic31xx_audio_map[] = {
{"ADC", NULL, "MIC_GAIN_CTL"},
{"AIF OUT", NULL, "ADC"},
/* Left Output */
{"Output Left", "From Left DAC", "DAC Left"},
{"Output Left", "From MIC1LP", "MIC1LP"},
......@@ -670,34 +679,61 @@ aic310x_audio_map[] = {
{"SPK", NULL, "SPK ClassD"},
};
static int aic31xx_add_controls(struct snd_soc_codec *codec)
/*
* Always connected DAPM routes for codec clock master modes.
* If the codec is the master on the I2S bus, we need to power up components
* to have valid DAC_CLK.
*
* In order to have the I2S clocks on the bus either the DACs/ADC need to be
* enabled, or the P0/R29/D2 (Keep bclk/wclk in power down) need to be set.
*
* Otherwise the codec will not generate clocks on the bus.
*/
static const struct snd_soc_dapm_route
common31xx_cm_audio_map[] = {
{"HPL", NULL, "AIF IN"},
{"HPR", NULL, "AIF IN"},
{"AIF IN", NULL, "Activate I2S clocks"},
};
static const struct snd_soc_dapm_route
aic31xx_cm_audio_map[] = {
{"AIF OUT", NULL, "MIC1LP"},
{"AIF OUT", NULL, "MIC1RP"},
{"AIF OUT", NULL, "MIC1LM"},
{"AIF OUT", NULL, "Activate I2S clocks"},
};
static int aic31xx_add_controls(struct snd_soc_component *component)
{
int ret = 0;
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
if (!(aic31xx->codec_type & DAC31XX_BIT))
ret = snd_soc_add_codec_controls(
codec, aic31xx_snd_controls,
ret = snd_soc_add_component_controls(
component, aic31xx_snd_controls,
ARRAY_SIZE(aic31xx_snd_controls));
if (ret)
return ret;
if (aic31xx->codec_type & AIC31XX_STEREO_CLASS_D_BIT)
ret = snd_soc_add_codec_controls(
codec, aic311x_snd_controls,
ret = snd_soc_add_component_controls(
component, aic311x_snd_controls,
ARRAY_SIZE(aic311x_snd_controls));
else
ret = snd_soc_add_codec_controls(
codec, aic310x_snd_controls,
ret = snd_soc_add_component_controls(
component, aic310x_snd_controls,
ARRAY_SIZE(aic310x_snd_controls));
return ret;
}
static int aic31xx_add_widgets(struct snd_soc_codec *codec)
static int aic31xx_add_widgets(struct snd_soc_component *component)
{
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
int ret = 0;
if (aic31xx->codec_type & DAC31XX_BIT) {
......@@ -751,10 +787,10 @@ static int aic31xx_add_widgets(struct snd_soc_codec *codec)
return 0;
}
static int aic31xx_setup_pll(struct snd_soc_codec *codec,
static int aic31xx_setup_pll(struct snd_soc_component *component,
struct snd_pcm_hw_params *params)
{
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
int bclk_score = snd_soc_params_to_frame_size(params);
int mclk_p;
int bclk_n = 0;
......@@ -762,15 +798,15 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec,
int i;
if (!aic31xx->sysclk || !aic31xx->p_div) {
dev_err(codec->dev, "Master clock not supplied\n");
dev_err(component->dev, "Master clock not supplied\n");
return -EINVAL;
}
mclk_p = aic31xx->sysclk / aic31xx->p_div;
/* Use PLL as CODEC_CLKIN and DAC_CLK as BDIV_CLKIN */
snd_soc_update_bits(codec, AIC31XX_CLKMUX,
snd_soc_component_update_bits(component, AIC31XX_CLKMUX,
AIC31XX_CODEC_CLKIN_MASK, AIC31XX_CODEC_CLKIN_PLL);
snd_soc_update_bits(codec, AIC31XX_IFACE2,
snd_soc_component_update_bits(component, AIC31XX_IFACE2,
AIC31XX_BDIVCLK_MASK, AIC31XX_DAC2BCLK);
for (i = 0; i < ARRAY_SIZE(aic31xx_divs); i++) {
......@@ -789,14 +825,14 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec,
}
if (match == -1) {
dev_err(codec->dev,
dev_err(component->dev,
"%s: Sample rate (%u) and format not supported\n",
__func__, params_rate(params));
/* See bellow for details how fix this. */
return -EINVAL;
}
if (bclk_score != 0) {
dev_warn(codec->dev, "Can not produce exact bitclock");
dev_warn(component->dev, "Can not produce exact bitclock");
/* This is fine if using dsp format, but if using i2s
there may be trouble. To fix the issue edit the
aic31xx_divs table for your mclk and sample
......@@ -808,39 +844,39 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec,
i = match;
/* PLL configuration */
snd_soc_update_bits(codec, AIC31XX_PLLPR, AIC31XX_PLL_MASK,
snd_soc_component_update_bits(component, AIC31XX_PLLPR, AIC31XX_PLL_MASK,
(aic31xx->p_div << 4) | 0x01);
snd_soc_write(codec, AIC31XX_PLLJ, aic31xx_divs[i].pll_j);
snd_soc_component_write(component, AIC31XX_PLLJ, aic31xx_divs[i].pll_j);
snd_soc_write(codec, AIC31XX_PLLDMSB,
snd_soc_component_write(component, AIC31XX_PLLDMSB,
aic31xx_divs[i].pll_d >> 8);
snd_soc_write(codec, AIC31XX_PLLDLSB,
snd_soc_component_write(component, AIC31XX_PLLDLSB,
aic31xx_divs[i].pll_d & 0xff);
/* DAC dividers configuration */
snd_soc_update_bits(codec, AIC31XX_NDAC, AIC31XX_PLL_MASK,
snd_soc_component_update_bits(component, AIC31XX_NDAC, AIC31XX_PLL_MASK,
aic31xx_divs[i].ndac);
snd_soc_update_bits(codec, AIC31XX_MDAC, AIC31XX_PLL_MASK,
snd_soc_component_update_bits(component, AIC31XX_MDAC, AIC31XX_PLL_MASK,
aic31xx_divs[i].mdac);
snd_soc_write(codec, AIC31XX_DOSRMSB, aic31xx_divs[i].dosr >> 8);
snd_soc_write(codec, AIC31XX_DOSRLSB, aic31xx_divs[i].dosr & 0xff);
snd_soc_component_write(component, AIC31XX_DOSRMSB, aic31xx_divs[i].dosr >> 8);
snd_soc_component_write(component, AIC31XX_DOSRLSB, aic31xx_divs[i].dosr & 0xff);
/* ADC dividers configuration. Write reset value 1 if not used. */
snd_soc_update_bits(codec, AIC31XX_NADC, AIC31XX_PLL_MASK,
snd_soc_component_update_bits(component, AIC31XX_NADC, AIC31XX_PLL_MASK,
aic31xx_divs[i].nadc ? aic31xx_divs[i].nadc : 1);
snd_soc_update_bits(codec, AIC31XX_MADC, AIC31XX_PLL_MASK,
snd_soc_component_update_bits(component, AIC31XX_MADC, AIC31XX_PLL_MASK,
aic31xx_divs[i].madc ? aic31xx_divs[i].madc : 1);
snd_soc_write(codec, AIC31XX_AOSR, aic31xx_divs[i].aosr);
snd_soc_component_write(component, AIC31XX_AOSR, aic31xx_divs[i].aosr);
/* Bit clock divider configuration. */
snd_soc_update_bits(codec, AIC31XX_BCLKN,
snd_soc_component_update_bits(component, AIC31XX_BCLKN,
AIC31XX_PLL_MASK, bclk_n);
aic31xx->rate_div_line = i;
dev_dbg(codec->dev,
dev_dbg(component->dev,
"pll %d.%04d/%d dosr %d n %d m %d aosr %d n %d m %d bclk_n %d\n",
aic31xx_divs[i].pll_j,
aic31xx_divs[i].pll_d,
......@@ -861,10 +897,10 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct snd_soc_component *component = dai->component;
u8 data = 0;
dev_dbg(codec->dev, "## %s: width %d rate %d\n",
dev_dbg(component->dev, "## %s: width %d rate %d\n",
__func__, params_width(params),
params_rate(params));
......@@ -884,43 +920,90 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream,
AIC31XX_IFACE1_DATALEN_SHIFT);
break;
default:
dev_err(codec->dev, "%s: Unsupported width %d\n",
dev_err(component->dev, "%s: Unsupported width %d\n",
__func__, params_width(params));
return -EINVAL;
}
snd_soc_update_bits(codec, AIC31XX_IFACE1,
snd_soc_component_update_bits(component, AIC31XX_IFACE1,
AIC31XX_IFACE1_DATALEN_MASK,
data);
return aic31xx_setup_pll(codec, params);
return aic31xx_setup_pll(component, params);
}
static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute)
{
struct snd_soc_codec *codec = codec_dai->codec;
struct snd_soc_component *component = codec_dai->component;
if (mute) {
snd_soc_update_bits(codec, AIC31XX_DACMUTE,
snd_soc_component_update_bits(component, AIC31XX_DACMUTE,
AIC31XX_DACMUTE_MASK,
AIC31XX_DACMUTE_MASK);
} else {
snd_soc_update_bits(codec, AIC31XX_DACMUTE,
snd_soc_component_update_bits(component, AIC31XX_DACMUTE,
AIC31XX_DACMUTE_MASK, 0x0);
}
return 0;
}
static int aic31xx_clock_master_routes(struct snd_soc_component *component,
unsigned int fmt)
{
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
int ret;
fmt &= SND_SOC_DAIFMT_MASTER_MASK;
if (fmt == SND_SOC_DAIFMT_CBS_CFS &&
aic31xx->master_dapm_route_applied) {
/*
* Remove the DAPM route(s) for codec clock master modes,
* if applied
*/
ret = snd_soc_dapm_del_routes(dapm, common31xx_cm_audio_map,
ARRAY_SIZE(common31xx_cm_audio_map));
if (!ret && !(aic31xx->codec_type & DAC31XX_BIT))
ret = snd_soc_dapm_del_routes(dapm,
aic31xx_cm_audio_map,
ARRAY_SIZE(aic31xx_cm_audio_map));
if (ret)
return ret;
aic31xx->master_dapm_route_applied = false;
} else if (fmt != SND_SOC_DAIFMT_CBS_CFS &&
!aic31xx->master_dapm_route_applied) {
/*
* Add the needed DAPM route(s) for codec clock master modes,
* if it is not done already
*/
ret = snd_soc_dapm_add_routes(dapm, common31xx_cm_audio_map,
ARRAY_SIZE(common31xx_cm_audio_map));
if (!ret && !(aic31xx->codec_type & DAC31XX_BIT))
ret = snd_soc_dapm_add_routes(dapm,
aic31xx_cm_audio_map,
ARRAY_SIZE(aic31xx_cm_audio_map));
if (ret)
return ret;
aic31xx->master_dapm_route_applied = true;
}
return 0;
}
static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt)
{
struct snd_soc_codec *codec = codec_dai->codec;
struct snd_soc_component *component = codec_dai->component;
u8 iface_reg1 = 0;
u8 iface_reg2 = 0;
u8 dsp_a_val = 0;
dev_dbg(codec->dev, "## %s: fmt = 0x%x\n", __func__, fmt);
dev_dbg(component->dev, "## %s: fmt = 0x%x\n", __func__, fmt);
/* set master/slave audio interface */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
......@@ -936,7 +1019,7 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai,
case SND_SOC_DAIFMT_CBS_CFS:
break;
default:
dev_err(codec->dev, "Invalid DAI master/slave interface\n");
dev_err(component->dev, "Invalid DAI master/slave interface\n");
return -EINVAL;
}
......@@ -948,7 +1031,7 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai,
iface_reg2 |= AIC31XX_BCLKINV_MASK;
break;
default:
dev_err(codec->dev, "Invalid DAI clock signal polarity\n");
dev_err(component->dev, "Invalid DAI clock signal polarity\n");
return -EINVAL;
}
......@@ -977,32 +1060,32 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai,
AIC31XX_IFACE1_DATATYPE_SHIFT);
break;
default:
dev_err(codec->dev, "Invalid DAI interface format\n");
dev_err(component->dev, "Invalid DAI interface format\n");
return -EINVAL;
}
snd_soc_update_bits(codec, AIC31XX_IFACE1,
snd_soc_component_update_bits(component, AIC31XX_IFACE1,
AIC31XX_IFACE1_DATATYPE_MASK |
AIC31XX_IFACE1_MASTER_MASK,
iface_reg1);
snd_soc_update_bits(codec, AIC31XX_DATA_OFFSET,
snd_soc_component_update_bits(component, AIC31XX_DATA_OFFSET,
AIC31XX_DATA_OFFSET_MASK,
dsp_a_val);
snd_soc_update_bits(codec, AIC31XX_IFACE2,
snd_soc_component_update_bits(component, AIC31XX_IFACE2,
AIC31XX_BCLKINV_MASK,
iface_reg2);
return 0;
return aic31xx_clock_master_routes(component, fmt);
}
static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{
struct snd_soc_codec *codec = codec_dai->codec;
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct snd_soc_component *component = codec_dai->component;
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
int i;
dev_dbg(codec->dev, "## %s: clk_id = %d, freq = %d, dir = %d\n",
dev_dbg(component->dev, "## %s: clk_id = %d, freq = %d, dir = %d\n",
__func__, clk_id, freq, dir);
for (i = 1; i < 8; i++)
......@@ -1025,7 +1108,7 @@ static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
}
/* set clock on MCLK, BCLK, or GPIO1 as PLL input */
snd_soc_update_bits(codec, AIC31XX_CLKMUX, AIC31XX_PLL_CLKIN_MASK,
snd_soc_component_update_bits(component, AIC31XX_CLKMUX, AIC31XX_PLL_CLKIN_MASK,
clk_id << AIC31XX_PLL_CLKIN_SHIFT);
aic31xx->sysclk = freq;
......@@ -1071,42 +1154,42 @@ static int aic31xx_reset(struct aic31xx_priv *aic31xx)
return ret;
}
static void aic31xx_clk_on(struct snd_soc_codec *codec)
static void aic31xx_clk_on(struct snd_soc_component *component)
{
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
u8 mask = AIC31XX_PM_MASK;
u8 on = AIC31XX_PM_MASK;
dev_dbg(codec->dev, "codec clock -> on (rate %d)\n",
dev_dbg(component->dev, "codec clock -> on (rate %d)\n",
aic31xx_divs[aic31xx->rate_div_line].rate);
snd_soc_update_bits(codec, AIC31XX_PLLPR, mask, on);
snd_soc_component_update_bits(component, AIC31XX_PLLPR, mask, on);
mdelay(10);
snd_soc_update_bits(codec, AIC31XX_NDAC, mask, on);
snd_soc_update_bits(codec, AIC31XX_MDAC, mask, on);
snd_soc_component_update_bits(component, AIC31XX_NDAC, mask, on);
snd_soc_component_update_bits(component, AIC31XX_MDAC, mask, on);
if (aic31xx_divs[aic31xx->rate_div_line].nadc)
snd_soc_update_bits(codec, AIC31XX_NADC, mask, on);
snd_soc_component_update_bits(component, AIC31XX_NADC, mask, on);
if (aic31xx_divs[aic31xx->rate_div_line].madc)
snd_soc_update_bits(codec, AIC31XX_MADC, mask, on);
snd_soc_update_bits(codec, AIC31XX_BCLKN, mask, on);
snd_soc_component_update_bits(component, AIC31XX_MADC, mask, on);
snd_soc_component_update_bits(component, AIC31XX_BCLKN, mask, on);
}
static void aic31xx_clk_off(struct snd_soc_codec *codec)
static void aic31xx_clk_off(struct snd_soc_component *component)
{
u8 mask = AIC31XX_PM_MASK;
u8 off = 0;
dev_dbg(codec->dev, "codec clock -> off\n");
snd_soc_update_bits(codec, AIC31XX_BCLKN, mask, off);
snd_soc_update_bits(codec, AIC31XX_MADC, mask, off);
snd_soc_update_bits(codec, AIC31XX_NADC, mask, off);
snd_soc_update_bits(codec, AIC31XX_MDAC, mask, off);
snd_soc_update_bits(codec, AIC31XX_NDAC, mask, off);
snd_soc_update_bits(codec, AIC31XX_PLLPR, mask, off);
dev_dbg(component->dev, "codec clock -> off\n");
snd_soc_component_update_bits(component, AIC31XX_BCLKN, mask, off);
snd_soc_component_update_bits(component, AIC31XX_MADC, mask, off);
snd_soc_component_update_bits(component, AIC31XX_NADC, mask, off);
snd_soc_component_update_bits(component, AIC31XX_MDAC, mask, off);
snd_soc_component_update_bits(component, AIC31XX_NDAC, mask, off);
snd_soc_component_update_bits(component, AIC31XX_PLLPR, mask, off);
}
static int aic31xx_power_on(struct snd_soc_codec *codec)
static int aic31xx_power_on(struct snd_soc_component *component)
{
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
int ret;
ret = regulator_bulk_enable(ARRAY_SIZE(aic31xx->supplies),
......@@ -1123,7 +1206,7 @@ static int aic31xx_power_on(struct snd_soc_codec *codec)
ret = regcache_sync(aic31xx->regmap);
if (ret) {
dev_err(codec->dev,
dev_err(component->dev,
"Failed to restore cache: %d\n", ret);
regcache_cache_only(aic31xx->regmap, true);
regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies),
......@@ -1134,57 +1217,57 @@ static int aic31xx_power_on(struct snd_soc_codec *codec)
return 0;
}
static void aic31xx_power_off(struct snd_soc_codec *codec)
static void aic31xx_power_off(struct snd_soc_component *component)
{
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
regcache_cache_only(aic31xx->regmap, true);
regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies),
aic31xx->supplies);
}
static int aic31xx_set_bias_level(struct snd_soc_codec *codec,
static int aic31xx_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{
dev_dbg(codec->dev, "## %s: %d -> %d\n", __func__,
snd_soc_codec_get_bias_level(codec), level);
dev_dbg(component->dev, "## %s: %d -> %d\n", __func__,
snd_soc_component_get_bias_level(component), level);
switch (level) {
case SND_SOC_BIAS_ON:
break;
case SND_SOC_BIAS_PREPARE:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY)
aic31xx_clk_on(codec);
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY)
aic31xx_clk_on(component);
break;
case SND_SOC_BIAS_STANDBY:
switch (snd_soc_codec_get_bias_level(codec)) {
switch (snd_soc_component_get_bias_level(component)) {
case SND_SOC_BIAS_OFF:
aic31xx_power_on(codec);
aic31xx_power_on(component);
break;
case SND_SOC_BIAS_PREPARE:
aic31xx_clk_off(codec);
aic31xx_clk_off(component);
break;
default:
BUG();
}
break;
case SND_SOC_BIAS_OFF:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY)
aic31xx_power_off(codec);
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY)
aic31xx_power_off(component);
break;
}
return 0;
}
static int aic31xx_codec_probe(struct snd_soc_codec *codec)
static int aic31xx_codec_probe(struct snd_soc_component *component)
{
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
int i, ret;
dev_dbg(aic31xx->dev, "## %s\n", __func__);
aic31xx->codec = codec;
aic31xx->component = component;
for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) {
aic31xx->disable_nb[i].nb.notifier_call =
......@@ -1193,7 +1276,7 @@ static int aic31xx_codec_probe(struct snd_soc_codec *codec)
ret = regulator_register_notifier(aic31xx->supplies[i].consumer,
&aic31xx->disable_nb[i].nb);
if (ret) {
dev_err(codec->dev,
dev_err(component->dev,
"Failed to request regulator notifier: %d\n",
ret);
return ret;
......@@ -1203,43 +1286,42 @@ static int aic31xx_codec_probe(struct snd_soc_codec *codec)
regcache_cache_only(aic31xx->regmap, true);
regcache_mark_dirty(aic31xx->regmap);
ret = aic31xx_add_controls(codec);
ret = aic31xx_add_controls(component);
if (ret)
return ret;
ret = aic31xx_add_widgets(codec);
ret = aic31xx_add_widgets(component);
if (ret)
return ret;
return 0;
}
static int aic31xx_codec_remove(struct snd_soc_codec *codec)
static void aic31xx_codec_remove(struct snd_soc_component *component)
{
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component);
int i;
for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++)
regulator_unregister_notifier(aic31xx->supplies[i].consumer,
&aic31xx->disable_nb[i].nb);
return 0;
}
static const struct snd_soc_codec_driver soc_codec_driver_aic31xx = {
static const struct snd_soc_component_driver soc_codec_driver_aic31xx = {
.probe = aic31xx_codec_probe,
.remove = aic31xx_codec_remove,
.set_bias_level = aic31xx_set_bias_level,
.suspend_bias_off = true,
.component_driver = {
.controls = common31xx_snd_controls,
.num_controls = ARRAY_SIZE(common31xx_snd_controls),
.dapm_widgets = common31xx_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(common31xx_dapm_widgets),
.dapm_routes = common31xx_audio_map,
.num_dapm_routes = ARRAY_SIZE(common31xx_audio_map),
},
.controls = common31xx_snd_controls,
.num_controls = ARRAY_SIZE(common31xx_snd_controls),
.dapm_widgets = common31xx_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(common31xx_dapm_widgets),
.dapm_routes = common31xx_audio_map,
.num_dapm_routes = ARRAY_SIZE(common31xx_audio_map),
.suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
};
static const struct snd_soc_dai_ops aic31xx_dai_ops = {
......@@ -1375,23 +1457,17 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c,
}
if (aic31xx->codec_type & DAC31XX_BIT)
return snd_soc_register_codec(&i2c->dev,
return devm_snd_soc_register_component(&i2c->dev,
&soc_codec_driver_aic31xx,
dac31xx_dai_driver,
ARRAY_SIZE(dac31xx_dai_driver));
else
return snd_soc_register_codec(&i2c->dev,
return devm_snd_soc_register_component(&i2c->dev,
&soc_codec_driver_aic31xx,
aic31xx_dai_driver,
ARRAY_SIZE(aic31xx_dai_driver));
}
static int aic31xx_i2c_remove(struct i2c_client *i2c)
{
snd_soc_unregister_codec(&i2c->dev);
return 0;
}
static const struct i2c_device_id aic31xx_i2c_id[] = {
{ "tlv320aic310x", AIC3100 },
{ "tlv320aic311x", AIC3110 },
......@@ -1412,7 +1488,6 @@ static struct i2c_driver aic31xx_i2c_driver = {
.acpi_match_table = ACPI_PTR(aic31xx_acpi_match),
},
.probe = aic31xx_i2c_probe,
.remove = aic31xx_i2c_remove,
.id_table = aic31xx_i2c_id,
};
module_i2c_driver(aic31xx_i2c_driver);
......
......@@ -160,6 +160,7 @@ struct aic31xx_pdata {
#define AIC31XX_DACMOD2BCLK 0x01
#define AIC31XX_ADC2BCLK 0x02
#define AIC31XX_ADCMOD2BCLK 0x03
#define AIC31XX_KEEP_I2SCLK BIT(2)
/* AIC31XX_ADCFLAG */
#define AIC31XX_ADCPWRSTATUS_MASK BIT(6)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment