Unverified Commit 795dd8d3 authored by Mark Brown's avatar Mark Brown
Browse files

Clean up usage of the endianness flag

Merge series from Charles Keepax <ckeepax@opensource.cirrus.com>:

Before componentisation any part registered as a CODEC would have
automatically supported both little and big endian, ie. the core
would duplicate any supported LE or BE PCM format to support the other
endian as well. As componentisation removed the distinction between
CODEC drivers and platform drivers, a flag was added to specify
if this behaviour is required for a particular component. However,
as most systems tend to use little endian the absence of the flag
is rarely noticed. Also the naming of the flag "endianness" is a
little unobvious as to if it should be applied to a particular
component.

This series adds a comment to better explain the meaning of the
flag and then tidys up the usage of the flag. A couple of uses
of the flag are removed where is has been used inappropriately
on the CPU side of the DAI link, this is clearly not valid in the
cases it has been used, and I suspect never would be valid. Then
some redundant formats are removed, since they would be covered by
existing endianness flags. And finally a bunch of devices that are
missing the flag have it added.

It is worth noting that since componenisation there are now a couple
of cases where it is not entire clear to me that the flag should
be applied to all CODECs as it was before. In those cases I haven't
updated the driver to add the flag and they are outlined here:

1) Build into the AP CODECs, these are actual silicon inside the main
processor and they typically receive audio directly from an internal
bus. It is not obvious to me that these can happily ignore endian. On
the CODEC side these include: jz4725b.c, jz4760.c, jz4770.c,
rk3328_codec.c, lpass-va-macro.c, lpass-rx-macro.c, lpass-tx-macro.c,
lpass-wsa-macro.c. There are also some examples of this scattered
around the various platform support directories in sound/soc.

2) Devices behind non-audio buses, SPI just moves bits and doesn't
really define an endian for audio data on the bus. Thus it seems the
CODEC probably can care about the endian. The only devices that fall
into this group (mostly for AoV) are: rt5514-spi.c, rt5677-spi.c,
cros_ec_codec.c (only the AoV).

3) CODECs with no DAIs, these could specify the flag and plenty of
them do; CODECs from the initial conversion to componentisation. But
the flag makes no difference here since there is nothing for it to
apply to. This includes purely analogue CODECs: aw8738.c, ssm2305.c,
tpa6130a2.c, tda7419.c, max9759.c, max9768.c, max9877.c, lm4857.c,
simple-mux.c, simple-amplifier.c. And devices that only do jack
detection: ts3a227e.c, mt6359-accdet.c.

If there are any opinions on adding the flag to any of those three
groups they would be greatfully received. But I am leaning towards
leaving 1,2 without endianness flags since it feels inappropriate,
and removing the endian flag from devices in catagory 3 that already
have it. Assuming no one objects to that I will do a follow up
series for that.
parents d491db14 e2d61f62
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -169,6 +169,15 @@ struct snd_soc_component_driver {
	unsigned int idle_bias_on:1;
	unsigned int suspend_bias_off:1;
	unsigned int use_pmdown_time:1; /* care pmdown_time at stop */
	/*
	 * Indicates that the component does not care about the endianness of
	 * PCM audio data and the core will ensure that both LE and BE variants
	 * of each used format are present. Typically this is because the
	 * component sits behind a bus that abstracts away the endian of the
	 * original data, ie. one for which the transmission endian is defined
	 * (I2S/SLIMbus/SoundWire), or the concept of endian doesn't exist (PDM,
	 * analogue).
	 */
	unsigned int endianness:1;
	unsigned int non_legacy_dai_naming:1;

+0 −1
Original line number Diff line number Diff line
@@ -458,7 +458,6 @@ static const struct snd_soc_component_driver atmel_classd_cpu_dai_component = {
	.num_controls		= ARRAY_SIZE(atmel_classd_snd_controls),
	.idle_bias_on		= 1,
	.use_pmdown_time	= 1,
	.endianness		= 1,
};

/* ASoC sound card */
+0 −1
Original line number Diff line number Diff line
@@ -481,7 +481,6 @@ static const struct snd_soc_component_driver atmel_pdmic_cpu_dai_component = {
	.num_controls		= ARRAY_SIZE(atmel_pdmic_snd_controls),
	.idle_bias_on		= 1,
	.use_pmdown_time	= 1,
	.endianness		= 1,
};

/* ASoC sound card */
+1 −0
Original line number Diff line number Diff line
@@ -859,6 +859,7 @@ static const struct snd_soc_component_driver adau1372_driver = {
	.num_dapm_widgets = ARRAY_SIZE(adau1372_dapm_widgets),
	.dapm_routes = adau1372_dapm_routes,
	.num_dapm_routes = ARRAY_SIZE(adau1372_dapm_routes),
	.endianness = 1,
};

static const struct snd_soc_dai_ops adau1372_dai_ops = {
+4 −3
Original line number Diff line number Diff line
@@ -232,11 +232,11 @@ static int i2s_rx_hw_params(struct snd_pcm_substream *substream,
	if (params_rate(params) != 48000)
		return -EINVAL;

	switch (params_format(params)) {
	case SNDRV_PCM_FORMAT_S16_LE:
	switch (params_width(params)) {
	case 16:
		depth = EC_CODEC_I2S_RX_SAMPLE_DEPTH_16;
		break;
	case SNDRV_PCM_FORMAT_S24_LE:
	case 24:
		depth = EC_CODEC_I2S_RX_SAMPLE_DEPTH_24;
		break;
	default:
@@ -387,6 +387,7 @@ static const struct snd_soc_component_driver i2s_rx_component_driver = {
	.num_dapm_widgets	= ARRAY_SIZE(i2s_rx_dapm_widgets),
	.dapm_routes		= i2s_rx_dapm_routes,
	.num_dapm_routes	= ARRAY_SIZE(i2s_rx_dapm_routes),
	.endianness		= 1,
};

static void *wov_map_shm(struct cros_ec_codec_priv *priv,
Loading