All of lore.kernel.org
 help / color / mirror / Atom feed
* Questions about ASoC driver implementation
@ 2015-08-12 14:01 Matt Campbell
  2015-08-12 15:14 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Campbell @ 2015-08-12 14:01 UTC (permalink / raw)
  To: alsa-devel

Hi All,

I'm diving into adding support for a new codec (AK4621) targeting IMX6 SoC
and as this is my first dive into ALSA driver code (and first deep dive in
to Linux driver development) I've come up with a few questions. I've done a
lot of digging in available documentation as well as reading a lot of code,
but some things remain unclear.

First, I'm a little confused with what appears to be inconsistent
terminology. The SoC overview.txt lists three types of component drivers:
codec, platform and machine. However, in the code there are four types of
snd_soc_register_* functions: card, platform, codec and component. From
looking at the underlying structs and how these are used in existing code
this is my best guess but please correct me if I'm wrong:

codec -> snd_soc_register_codec
machine -> snd_soc_register_card
platform -> snd_soc_register_component and snd_soc_register_platform? (not
sure about this, from what I can gather at some point there was an API
switch to using component rather than platforms for the DAIs)

My second question is around adding support for an amplifier external to
the codec. The amplifier is a PGA controlled over SPI. One possible way I
can see to adding this is to create a SPI based codec driver for the PGA
that exposes an ALSA control for the gain level and give it a dummy DAI
then add it to the card as an aux_dev. This feels a little kludgy as the
PGA isn't a perfect fit for the codec class.

Another option would be to have PGA driver separate from the ASoC
framework, add the controls for the gain level directly in the ASoC card
and put the glue code to interact with the device in the machine driver.
This feels somewhat better to me, but has two problems. First, I don't know
the best way to interact with the external PGA driver from the machine
driver. Second, this leaves the PGA driver outside of the ASoC framework,
If it was in ASoC it could be useful for others that come across this chip
when writing machine drivers.

Sorry for the long email, but there has been a bit of a learning curve up
front. I tried to do my best with documentation and code reading before
coming to the mailing list. I'll greatly appreciate any help the community
can offer and look forward to contributing to the ALSA project.

Best,
~Matt

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Questions about ASoC driver implementation
  2015-08-12 14:01 Questions about ASoC driver implementation Matt Campbell
@ 2015-08-12 15:14 ` Lars-Peter Clausen
  2015-08-12 16:56   ` Matt Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2015-08-12 15:14 UTC (permalink / raw)
  To: Matt Campbell, alsa-devel

Hi,


On 08/12/2015 04:01 PM, Matt Campbell wrote:
> Hi All,
> 
> I'm diving into adding support for a new codec (AK4621) targeting IMX6 SoC
> and as this is my first dive into ALSA driver code (and first deep dive in
> to Linux driver development) I've come up with a few questions. I've done a
> lot of digging in available documentation as well as reading a lot of code,
> but some things remain unclear.
> 
> First, I'm a little confused with what appears to be inconsistent
> terminology. The SoC overview.txt lists three types of component drivers:
> codec, platform and machine. However, in the code there are four types of
> snd_soc_register_* functions: card, platform, codec and component. From
> looking at the underlying structs and how these are used in existing code
> this is my best guess but please correct me if I'm wrong:
> 
> codec -> snd_soc_register_codec
> machine -> snd_soc_register_card
> platform -> snd_soc_register_component and snd_soc_register_platform? (not
> sure about this, from what I can gather at some point there was an API
> switch to using component rather than platforms for the DAIs)

There used to be a lot of similarity between platforms and CODECs and some
code duplication. snd_soc_component was introduced is a new common base
class for both CODEC and platform. It can also be used standalone if none of
the platform or CODEC specific functionality is need.

> 
> My second question is around adding support for an amplifier external to
> the codec. The amplifier is a PGA controlled over SPI. One possible way I
> can see to adding this is to create a SPI based codec driver for the PGA
> that exposes an ALSA control for the gain level and give it a dummy DAI
> then add it to the card as an aux_dev. This feels a little kludgy as the
> PGA isn't a perfect fit for the codec class.

You don't need to register a DAI with your CODEC it will work just fine
without. Although in this case you don't need any CODEC specific features so
the best is to just go with snd_soc_component. There are a few examples of
snd_soc_component based drivers for external analog amplifiers, e.g. max9768
or lm4857.

- Lars

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Questions about ASoC driver implementation
  2015-08-12 15:14 ` Lars-Peter Clausen
@ 2015-08-12 16:56   ` Matt Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Matt Campbell @ 2015-08-12 16:56 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: alsa-devel

Hi Lars,

Thanks for the information, that really clears things up for me! Having the
max9768 and lm4857 as examples should get me where I need to be.

~Matt

On Wed, Aug 12, 2015 at 11:14 AM, Lars-Peter Clausen <lars@metafoo.de>
wrote:

> Hi,
>
>
> On 08/12/2015 04:01 PM, Matt Campbell wrote:
> > Hi All,
> >
> > I'm diving into adding support for a new codec (AK4621) targeting IMX6
> SoC
> > and as this is my first dive into ALSA driver code (and first deep dive
> in
> > to Linux driver development) I've come up with a few questions. I've
> done a
> > lot of digging in available documentation as well as reading a lot of
> code,
> > but some things remain unclear.
> >
> > First, I'm a little confused with what appears to be inconsistent
> > terminology. The SoC overview.txt lists three types of component drivers:
> > codec, platform and machine. However, in the code there are four types of
> > snd_soc_register_* functions: card, platform, codec and component. From
> > looking at the underlying structs and how these are used in existing code
> > this is my best guess but please correct me if I'm wrong:
> >
> > codec -> snd_soc_register_codec
> > machine -> snd_soc_register_card
> > platform -> snd_soc_register_component and snd_soc_register_platform?
> (not
> > sure about this, from what I can gather at some point there was an API
> > switch to using component rather than platforms for the DAIs)
>
> There used to be a lot of similarity between platforms and CODECs and some
> code duplication. snd_soc_component was introduced is a new common base
> class for both CODEC and platform. It can also be used standalone if none
> of
> the platform or CODEC specific functionality is need.
>
> >
> > My second question is around adding support for an amplifier external to
> > the codec. The amplifier is a PGA controlled over SPI. One possible way I
> > can see to adding this is to create a SPI based codec driver for the PGA
> > that exposes an ALSA control for the gain level and give it a dummy DAI
> > then add it to the card as an aux_dev. This feels a little kludgy as the
> > PGA isn't a perfect fit for the codec class.
>
> You don't need to register a DAI with your CODEC it will work just fine
> without. Although in this case you don't need any CODEC specific features
> so
> the best is to just go with snd_soc_component. There are a few examples of
> snd_soc_component based drivers for external analog amplifiers, e.g.
> max9768
> or lm4857.
>
> - Lars
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-12 16:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-12 14:01 Questions about ASoC driver implementation Matt Campbell
2015-08-12 15:14 ` Lars-Peter Clausen
2015-08-12 16:56   ` Matt Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.