ASoC: wm_adsp: Expand firmware loading search options
authorSimon Trimmer <simont@opensource.cirrus.com>
Thu, 3 Mar 2022 15:50:16 +0000 (15:50 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 7 Mar 2022 13:14:57 +0000 (13:14 +0000)
commitb6b62d942bbc4d926bcf3799ea3bcaeb105fd04f
treeff2b506c0d528314f651fc061c970120e23c64b0
parent405afed8a728f23cfaa02f75bbc8bdd6b7322123
ASoC: wm_adsp: Expand firmware loading search options

The parts supported by this driver can have product-specific
firmware and tunings files. Typically these have been used on
embedded systems where the manufacturer is responsible for
installing the correct product-specific firmware files into
/lib/firmware. However, the linux-firmware repository places all
available firmwares into /lib/firmware and it is up to the driver to
select the correct product-specific firmware from that directory.

For example a product containing four smart amplifiers may provide
firmware specific for that product and each of the amplifiers may
have coefficient files containing tunings for their placement in the
mechanical design.

This change extends firmware (wmfw) and coefficient (bin) filenames
to be of the general form:

<cirrus/>part-dspN-fwtype<-system_name<-asoc_component_prefix>>.type

Where the cirrus subdirectory, system_name and asoc_component_prefix
are optional.

New files will be placed in the cirrus subdirectory to avoid
polluting the main /lib/firmware/ location. The generic name must be
searched in /lib/firmware before /lib/firmware/cirrus so that a
generic file in the new location does not override existing
product-specific files in the legacy location.

The search order for firmware files is:
  - cirrus/part-dspN-fwtype-system_name-asoc_component_prefix.wmfw
  - cirrus/part-dspN-fwtype-system_name.wmfw
  - part-dspN-fwtype.wmfw
  - cirrus/part-dspN-fwtype.wmfw

- Qualifications are added to the filename so that rightwards is more
  specific.
- The system_name is provided by the codec driver.
- The asoc_component_prefix is used to identify tunings for individual
  parts because it would already exist to disambiguate the controls
  and it makes it obvious which firmware file applies to which device.

The optional coefficient file must have the same filename
construction as the discovered wmfw except:
  - where the wmfw has only system_name then the bin file can
    optionally include the asoc_component_prefix. This is to allow a
    common wmfw for all amps but separate tunings per amp.

Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220303155016.122125-1-simont@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wm_adsp.c
sound/soc/codecs/wm_adsp.h