From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755393AbcIFGjM (ORCPT ); Tue, 6 Sep 2016 02:39:12 -0400 Received: from down.free-electrons.com ([37.187.137.238]:34542 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751556AbcIFGjK (ORCPT ); Tue, 6 Sep 2016 02:39:10 -0400 Date: Tue, 6 Sep 2016 08:39:07 +0200 From: Maxime Ripard To: Danny Milosavljevic Cc: Mark Brown , Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alsa-devel@alsa-project.org, Jaroslav Kysela , Takashi Iwai , Liam Girdwood , linux-sunxi@googlegroups.com Subject: Re: [PATCH] ASoC: sun4i-codec: Distinguish sun4i from sun7i Message-ID: <20160906063907.GA9040@lukather> References: <20160905192404.13871-1-dannym@scratchpost.org> <20160905192404.13871-2-dannym@scratchpost.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline In-Reply-To: <20160905192404.13871-2-dannym@scratchpost.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Mon, Sep 05, 2016 at 09:24:04PM +0200, Danny Milosavljevic wrote: > ASoC: sun4i-codec: Distinguish sun4i from sun7i >=20 > Introduce mechanism to detect sun7i and provide a different regmap, codec > and different controls for it - different compared to sun4i Allwinner A10. >=20 > The controls will be extended in a forthcoming patch - it is necessary to > distinguish between sun4i and sun7i controls because the mic gains are in > different registers. >=20 > Renamed SUN4I_CODEC_AC_SYS_VERI to SUN7I_CODEC_AC_DAC_CAL and renamed > SUN4I_CODEC_AC_MIC_PHONE_CAL to SUN7I_CODEC_AC_MIC_PHONE_CAL because these > are actually not present on Allwinner A10. >=20 > Handle quirks by regmap config and codec and select the correct quirks > automatically. >=20 > Signed-off-by: Danny Milosavljevic > --- > sound/soc/sunxi/sun4i-codec.c | 66 +++++++++++++++++++++++++++++++++++--= ------ > 1 file changed, 54 insertions(+), 12 deletions(-) >=20 > diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c > index 0e19c50..8531c93 100644 > --- a/sound/soc/sunxi/sun4i-codec.c > +++ b/sound/soc/sunxi/sun4i-codec.c > @@ -96,8 +96,8 @@ > /* Other various ADC registers */ > #define SUN4I_CODEC_DAC_TXCNT (0x30) > #define SUN4I_CODEC_ADC_RXCNT (0x34) > -#define SUN4I_CODEC_AC_SYS_VERI (0x38) > -#define SUN4I_CODEC_AC_MIC_PHONE_CAL (0x3c) > +#define SUN7I_CODEC_AC_DAC_CAL (0x38) > +#define SUN7I_CODEC_AC_MIC_PHONE_CAL (0x3c) > =20 > struct sun4i_codec { > struct device *dev; > @@ -509,10 +509,17 @@ static const struct snd_kcontrol_new sun4i_codec_pa= _mute =3D > =20 > static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1); > =20 > -static const struct snd_kcontrol_new sun4i_codec_widgets[] =3D { > - SOC_SINGLE_TLV("Power Amplifier Volume", SUN4I_CODEC_DAC_ACTL, > - SUN4I_CODEC_DAC_ACTL_PA_VOL, 0x3F, 0, > - sun4i_codec_pa_volume_scale), > +#define SUN4I_COMMON_CODEC_CONTROLS \ > + SOC_SINGLE_TLV("Power Amplifier Volume", SUN4I_CODEC_DAC_ACTL,\ > + SUN4I_CODEC_DAC_ACTL_PA_VOL, 0x3F, 0,\ > + sun4i_codec_pa_volume_scale) > + > +static const struct snd_kcontrol_new sun4i_codec_controls[] =3D { > + SUN4I_COMMON_CODEC_CONTROLS, > +}; > + > +static const struct snd_kcontrol_new sun7i_codec_controls[] =3D { > + SUN4I_COMMON_CODEC_CONTROLS, > }; > =20 > static const struct snd_kcontrol_new sun4i_codec_left_mixer_controls[] = =3D { > @@ -629,8 +636,19 @@ static const struct snd_soc_dapm_route sun4i_codec_c= odec_dapm_routes[] =3D { > =20 > static struct snd_soc_codec_driver sun4i_codec_codec =3D { > .component_driver =3D { > - .controls =3D sun4i_codec_widgets, > - .num_controls =3D ARRAY_SIZE(sun4i_codec_widgets), > + .controls =3D sun4i_codec_controls, > + .num_controls =3D ARRAY_SIZE(sun4i_codec_controls), > + .dapm_widgets =3D sun4i_codec_codec_dapm_widgets, > + .num_dapm_widgets =3D ARRAY_SIZE(sun4i_codec_codec_dapm_widgets), > + .dapm_routes =3D sun4i_codec_codec_dapm_routes, > + .num_dapm_routes =3D ARRAY_SIZE(sun4i_codec_codec_dapm_routes), > + }, > +}; > + > +static struct snd_soc_codec_driver sun7i_codec_codec =3D { > + .component_driver =3D { > + .controls =3D sun7i_codec_controls, > + .num_controls =3D ARRAY_SIZE(sun7i_codec_controls), > .dapm_widgets =3D sun4i_codec_codec_dapm_widgets, > .num_dapm_widgets =3D ARRAY_SIZE(sun4i_codec_codec_dapm_widgets), > .dapm_routes =3D sun4i_codec_codec_dapm_routes, > @@ -682,12 +700,34 @@ static const struct regmap_config sun4i_codec_regma= p_config =3D { > .reg_bits =3D 32, > .reg_stride =3D 4, > .val_bits =3D 32, > - .max_register =3D SUN4I_CODEC_AC_MIC_PHONE_CAL, > + .max_register =3D SUN4I_CODEC_ADC_RXCNT, > +}; > + > +static const struct regmap_config sun7i_codec_regmap_config =3D { > + .reg_bits =3D 32, > + .reg_stride =3D 4, > + .val_bits =3D 32, > + .max_register =3D SUN7I_CODEC_AC_MIC_PHONE_CAL, > +}; > + > +struct sun4i_quirks { > + const struct snd_soc_codec_driver *codec; > + const struct regmap_config *regmap_config; > +}; > + > +static const struct sun4i_quirks sun4i_quirks =3D { > + .codec =3D &sun4i_codec_codec, > + .regmap_config =3D &sun4i_codec_regmap_config, > +}; > + > +static const struct sun4i_quirks sun7i_quirks =3D { > + .codec =3D &sun7i_codec_codec, > + .regmap_config =3D &sun7i_codec_regmap_config, > }; > =20 > static const struct of_device_id sun4i_codec_of_match[] =3D { > - { .compatible =3D "allwinner,sun4i-a10-codec" }, > - { .compatible =3D "allwinner,sun7i-a20-codec" }, > + { .compatible =3D "allwinner,sun4i-a10-codec", .data =3D &sun4i_quirks = }, > + { .compatible =3D "allwinner,sun7i-a20-codec", .data =3D &sun7i_quirks = }, > {} > }; > MODULE_DEVICE_TABLE(of, sun4i_codec_of_match); > @@ -760,6 +800,7 @@ static int sun4i_codec_probe(struct platform_device *= pdev) > { > struct snd_soc_card *card; > struct sun4i_codec *scodec; > + struct sun4i_quirks *quirks; > struct resource *res; > void __iomem *base; > int ret; > @@ -777,8 +818,9 @@ static int sun4i_codec_probe(struct platform_device *= pdev) > return PTR_ERR(base); > } > =20 > + quirks =3D of_device_get_match_data(&pdev->dev); > scodec->regmap =3D devm_regmap_init_mmio(&pdev->dev, base, > - &sun4i_codec_regmap_config); > + quirks->regmap_config); I think you also wanted to pass quirks->codec to snd_soc_register_codec? Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --9jxsPFA5p3P2qPhR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXzmSLAAoJEBx+YmzsjxAgZ5sP/Rt8r43HQ+jbUzQVsbPgqDBo OuU4bwcMYnmtv8WYllW0aBbNhX7MFrJ8CvsuQC40RHSfDs8ZPVpWXSwMba0s50pf bpXHiJBmusbF8G8raKz8/5rAQC4TNZCDeUGKfpog0g9ZwvJwJpiZgslcFYqUcPaP hx748Jp5/xYvIUt4r42oi9UoM+b3RjQvpjeNvRYUYlXxwsn9RP/EDNY4wFzP5KR1 RwiOb7Cgor4Q1PG4dMnhEObybgqJ70sjzTT1j7Zg557m2dyZXI1/rYBwxmshk1QQ V/+NZBzl7m87yLPaNURflyIc9qcdRucXdugB4HZym1xZdCV97I7NmZc39RKIVxJn 9Rc3LuohESTiQIDGnSR9YkRPli8VM3wbVWvkYje1jZkp67DtwcP99KZVxB6XWXKD EoWHa8Jw26R0VtQOB3uVYtKj6WUAuFxVd95kE1JcOpAk2MdmOyqRJ1w7kH9pSu5/ 09fszqgleGbi9ec01qOViK6xjp7ph5JOjO8xJpj4m70vQgDeKcuSbmcz8m7S8v0V v0qy9nBuQVxL0izKJ7PGFIg8KbSSkN1MwDj8axHlMlRVKNfUorlJ6phk9gj+iMi+ DDOadw243ISKoF68tP/N2MLKSqWdm7Z4+TF810hkCe2pwuSKhEYJglVRzeuDWQw8 IUj91RzO8+fPb/A47q+B =mJGQ -----END PGP SIGNATURE----- --9jxsPFA5p3P2qPhR--