[alsa-devel] [PATCH v14 2/8] ASoC: sun4i-codec: Add Mic1 Boost Volume, Mic2 Boost Volume

Maxime Ripard maxime.ripard at bootlin.com
Mon May 14 16:05:30 CEST 2018


On Sat, May 05, 2018 at 09:05:13AM +0200, Danny Milosavljevic wrote:
> Hi Maxime,
> 
> On Thu, 3 May 2018 16:33:19 +0200
> Maxime Ripard <maxime.ripard at bootlin.com> wrote:
> 
> > > +struct sun4i_codec_quirks {
> > > +	const struct regmap_config *regmap_config;
> > > +	const struct snd_soc_component_driver *codec;
> > > +	struct snd_soc_card * (*create_card)(struct device *dev);
> > > +	struct reg_field reg_adc_fifoc;	/* used for regmap_field */
> > > +	unsigned int reg_dac_txdata;	/* TX FIFO offset for DMA config */
> > > +	unsigned int reg_adc_rxdata;	/* RX FIFO offset for DMA config */
> > > +	bool has_reset;
> > > +	const struct snd_kcontrol_new *controls;
> > > +	unsigned int num_controls;
> > > +};
> > > +
> > > +static int sun4i_codec_component_driver_probe(struct snd_soc_component *codec)
> > > +{
> > > +	const struct sun4i_codec_quirks *quirks;
> > > +
> > > +	quirks = of_device_get_match_data(codec->dev);
> > > +	return snd_soc_add_component_controls(codec,
> > > +					      quirks->controls,
> > > +					      quirks->num_controls);  
> > 
> > Why not just extending the sun4i_codec_controls to add it, and create
> > a duplicate one for the A20?
> 
> Because sun4i_codec_controls has five controls shared between A10 and A20,
> and only two not shared.
>
> And if we extended sun4i_codec_controls, we'd also have to duplicate
> sun4i_codec_codec in order to use sun4i_codec_controls vs. sun7i_codec_controls,
> which really contains exactly the same data otherwise.

What I don't really like is that with this patch we have two variants
of the same mechanism: one to add the controls that are mostly shared,
and one to add the controls that are not shared, without any clear
definition of when you should add a new control to one list or the
other.

So far, we had one mechanism, it was easy to understand and to know
what to do about it. And the code was simple as well.

> The quirks here are just for two controls, Mic1 Boost Volume and
> Mic2 Boost Volume, and there not even for the names or anything -
> just for some reason the register moved away.
> 
> The simplest way was to add it to the quirks - which already have a
> variant selection etc.

Actually, I think that having to do add a new control explicitly to an
A10 and an A20 list is a feature if the two controls set aren't
exactly the same. It makes you explicitly think about what you're
doing, and hopefully double check if it is actually shared or not,
instead of exposing a control because one didn't pay attention that it
was shared.

Chen-Yu, any opinion on this?

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20180514/56573f41/attachment-0001.sig>


More information about the Alsa-devel mailing list