Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea53bf77 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown
Browse files

ASoC: Add snd_soc_kcontrol_codec() helper function



For CODEC controls snd_kcontrol_chip() currently returns a pointer to the
CODEC that registered the control. With the upcoming consolidation of
platform and CODEC controls this will change. Prepare for this by introducing
the snd_soc_kcontrol_codec() helper function that will hide the implementation
details of how the CODEC for a control can be obtained. This will allow us to
change this easily in the future.

The patch also updates all CODEC drivers to use the new helper function.

Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Acked-by: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent c9eaa447
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -1228,6 +1228,20 @@ static inline bool snd_soc_codec_is_active(struct snd_soc_codec *codec)
	return snd_soc_component_is_active(&codec->component);
	return snd_soc_component_is_active(&codec->component);
}
}


/**
 * snd_soc_kcontrol_codec() - Returns the CODEC that registered the control
 * @kcontrol: The control for which to get the CODEC
 *
 * Note: This function will only work correctly if the control has been
 * registered with snd_soc_add_codec_controls() or via table based setup of
 * snd_soc_codec_driver. Otherwise the behavior is undefined.
 */
static inline struct snd_soc_codec *snd_soc_kcontrol_codec(
	struct snd_kcontrol *kcontrol)
{
	return snd_kcontrol_chip(kcontrol);
}

int snd_soc_util_init(void);
int snd_soc_util_init(void);
void snd_soc_util_exit(void);
void snd_soc_util_exit(void);


+4 −4
Original line number Original line Diff line number Diff line
@@ -276,7 +276,7 @@ static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol,
{
{
	struct soc_mixer_control *mc =
	struct soc_mixer_control *mc =
		(struct soc_mixer_control *)kcontrol->private_value;
		(struct soc_mixer_control *)kcontrol->private_value;
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	unsigned int reg = mc->reg;
	unsigned int reg = mc->reg;
	unsigned int reg2 = mc->rreg;
	unsigned int reg2 = mc->rreg;
	int val[2], val2[2], i;
	int val[2], val2[2], i;
@@ -300,7 +300,7 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol,
{
{
	struct soc_mixer_control *mc =
	struct soc_mixer_control *mc =
		(struct soc_mixer_control *)kcontrol->private_value;
		(struct soc_mixer_control *)kcontrol->private_value;
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	unsigned int reg = mc->reg;
	unsigned int reg = mc->reg;
	unsigned int reg2 = mc->rreg;
	unsigned int reg2 = mc->rreg;
	int err;
	int err;
@@ -333,7 +333,7 @@ static int snd_soc_get_volsw_2r_out(struct snd_kcontrol *kcontrol,
{
{
	struct soc_mixer_control *mc =
	struct soc_mixer_control *mc =
		(struct soc_mixer_control *)kcontrol->private_value;
		(struct soc_mixer_control *)kcontrol->private_value;
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	unsigned int reg = mc->reg;
	unsigned int reg = mc->reg;
	unsigned int reg2 = mc->rreg;
	unsigned int reg2 = mc->rreg;
	unsigned int shift = mc->shift;
	unsigned int shift = mc->shift;
@@ -353,7 +353,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol,
{
{
	struct soc_mixer_control *mc =
	struct soc_mixer_control *mc =
		(struct soc_mixer_control *)kcontrol->private_value;
		(struct soc_mixer_control *)kcontrol->private_value;
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	unsigned int reg = mc->reg;
	unsigned int reg = mc->reg;
	unsigned int reg2 = mc->rreg;
	unsigned int reg2 = mc->rreg;
	unsigned int shift = mc->shift;
	unsigned int shift = mc->shift;
+6 −6
Original line number Original line Diff line number Diff line
@@ -1139,7 +1139,7 @@ static void anc_configure(struct snd_soc_codec *codec,
static int sid_status_control_get(struct snd_kcontrol *kcontrol,
static int sid_status_control_get(struct snd_kcontrol *kcontrol,
		struct snd_ctl_elem_value *ucontrol)
		struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
	struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);


	mutex_lock(&codec->mutex);
	mutex_lock(&codec->mutex);
@@ -1153,7 +1153,7 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol,
static int sid_status_control_put(struct snd_kcontrol *kcontrol,
static int sid_status_control_put(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
				struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
	struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
	unsigned int param, sidconf, val;
	unsigned int param, sidconf, val;
	int status = 1;
	int status = 1;
@@ -1208,7 +1208,7 @@ out:
static int anc_status_control_get(struct snd_kcontrol *kcontrol,
static int anc_status_control_get(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
				struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
	struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);


	mutex_lock(&codec->mutex);
	mutex_lock(&codec->mutex);
@@ -1221,7 +1221,7 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol,
static int anc_status_control_put(struct snd_kcontrol *kcontrol,
static int anc_status_control_put(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
				struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
	struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
	struct device *dev = codec->dev;
	struct device *dev = codec->dev;
	bool apply_fir, apply_iir;
	bool apply_fir, apply_iir;
@@ -1306,7 +1306,7 @@ static int filter_control_info(struct snd_kcontrol *kcontrol,
static int filter_control_get(struct snd_kcontrol *kcontrol,
static int filter_control_get(struct snd_kcontrol *kcontrol,
			struct snd_ctl_elem_value *ucontrol)
			struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct filter_control *fc =
	struct filter_control *fc =
			(struct filter_control *)kcontrol->private_value;
			(struct filter_control *)kcontrol->private_value;
	unsigned int i;
	unsigned int i;
@@ -1322,7 +1322,7 @@ static int filter_control_get(struct snd_kcontrol *kcontrol,
static int filter_control_put(struct snd_kcontrol *kcontrol,
static int filter_control_put(struct snd_kcontrol *kcontrol,
		struct snd_ctl_elem_value *ucontrol)
		struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct filter_control *fc =
	struct filter_control *fc =
			(struct filter_control *)kcontrol->private_value;
			(struct filter_control *)kcontrol->private_value;
	unsigned int i;
	unsigned int i;
+2 −2
Original line number Original line Diff line number Diff line
@@ -315,7 +315,7 @@ static int adav80x_set_deemph(struct snd_soc_codec *codec)
static int adav80x_put_deemph(struct snd_kcontrol *kcontrol,
static int adav80x_put_deemph(struct snd_kcontrol *kcontrol,
		struct snd_ctl_elem_value *ucontrol)
		struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
	struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
	unsigned int deemph = ucontrol->value.enumerated.item[0];
	unsigned int deemph = ucontrol->value.enumerated.item[0];


@@ -330,7 +330,7 @@ static int adav80x_put_deemph(struct snd_kcontrol *kcontrol,
static int adav80x_get_deemph(struct snd_kcontrol *kcontrol,
static int adav80x_get_deemph(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
				struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
	struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);


	ucontrol->value.enumerated.item[0] = adav80x->deemph;
	ucontrol->value.enumerated.item[0] = adav80x->deemph;
+2 −2
Original line number Original line Diff line number Diff line
@@ -74,7 +74,7 @@ static int ak4641_set_deemph(struct snd_soc_codec *codec)
static int ak4641_put_deemph(struct snd_kcontrol *kcontrol,
static int ak4641_put_deemph(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
				struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec);
	struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec);
	int deemph = ucontrol->value.enumerated.item[0];
	int deemph = ucontrol->value.enumerated.item[0];


@@ -89,7 +89,7 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol,
static int ak4641_get_deemph(struct snd_kcontrol *kcontrol,
static int ak4641_get_deemph(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
				struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec);
	struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec);


	ucontrol->value.enumerated.item[0] = ak4641->deemph;
	ucontrol->value.enumerated.item[0] = ak4641->deemph;
Loading