Re: [alsa-devel] [PATCH 1/3] ALSA SoC: Add OpenFirmware helper for matching bus and codec drivers

2008-07-04 Thread Timur Tabi


On Jul 3, 2008, at 12:33 PM, Grant Likely wrote:


Yes, but you hadn't written these functions when I wrote this helper.
:-P.  I believe ASoC v2 makes all this stuff unnecessary, but I'm
waiting for v2 to hit mainline before I port forward.


FYI, it took me about a month to port my drivers to ASoC V2.  I had  
more work than most people because I addressed issues that others  
drivers didn't.  For instance, my CS4270 driver is the only codec  
driver in V2 that supports multiple instances of itself.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [alsa-devel] [PATCH 1/3] ALSA SoC: Add OpenFirmware helper for matching bus and codec drivers

2008-07-03 Thread Grant Likely
On Wed, Jul 02, 2008 at 11:27:17AM -0400, Jon Smirl wrote:
 On 7/1/08, Grant Likely [EMAIL PROTECTED] wrote:
   +static struct of_snd_soc_device *
   +of_snd_soc_get_device(struct device_node *codec_node)
   +{
   +   struct of_snd_soc_device *of_soc;
   +
   +   list_for_each_entry(of_soc, of_snd_soc_device_list, list) {
   +   if (of_soc-codec_node == codec_node)
   +   return of_soc;
   +   }
   +
   +   of_soc = kzalloc(sizeof(struct of_snd_soc_device), GFP_KERNEL);
   +   if (!of_soc)
   +   return NULL;
   +
   +   /* Initialize the structure and add it to the global list */
   +   of_soc-codec_node = codec_node;
   +   of_soc-id = of_snd_soc_next_index++;
   +   of_soc-machine.dai_link = of_soc-dai_link;
   +   of_soc-machine.num_links = 1;
   +   of_soc-device.machine = of_soc-machine;
   +   of_soc-dai_link.ops = of_snd_soc_ops;
   +   list_add(of_soc-list, of_snd_soc_device_list);
   +
   +   return of_soc;
   +}
 
 Isn't this performing the same basic function as this code (except for
 spi)? Should this list be maintained in alsa or should there be an
 equivalent for searching the spi bus? If you follow the link to the
 codec node and get it's parent you know which bus to search. But it
 might be simpler to just search the buses sequentially for the node.
 
 static int of_dev_node_match(struct device *dev, void *data)
 {
 return dev-archdata.of_node == data;
 }
 
 struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
 {
   struct device *dev;
   
   dev = bus_find_device(i2c_bus_type, NULL, node,
of_dev_node_match);
   if (!dev)
   return NULL;
   
   return to_i2c_client(dev);
 }
 EXPORT_SYMBOL(of_find_i2c_device_by_node);

Yes, but you hadn't written these functions when I wrote this helper.
:-P.  I believe ASoC v2 makes all this stuff unnecessary, but I'm
waiting for v2 to hit mainline before I port forward.

g.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [alsa-devel] [PATCH 1/3] ALSA SoC: Add OpenFirmware helper for matching bus and codec drivers

2008-07-02 Thread Takashi Iwai
At Tue, 01 Jul 2008 17:53:30 -0600,
Grant Likely wrote:
 diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
 index 18f28ac..c5736e5 100644
 --- a/sound/soc/Kconfig
 +++ b/sound/soc/Kconfig
 @@ -23,6 +23,12 @@ config SND_SOC
 This ASoC audio support can also be built as a module.  If so, the 
 module
 will be called snd-soc-core.
  
 +config SND_SOC_OF
 + tristate OF helpers for SoC audio support
 + depends on SND_SOC
 + ---help---
 +   Add support for OpenFirmware device tree descriptions of sound device
 +

This is a helper module and not necessarily manually selectable.
Better to make the other driver selecting this.


 diff --git a/sound/soc/soc-of.c b/sound/soc/soc-of.c
 new file mode 100644
 index 000..9694979
 --- /dev/null
 +++ b/sound/soc/soc-of.c
(snip)
 +DEFINE_MUTEX(of_snd_soc_mutex);
 +LIST_HEAD(of_snd_soc_device_list);

Missing static.


Takashi
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [alsa-devel] [PATCH 1/3] ALSA SoC: Add OpenFirmware helper for matching bus and codec drivers

2008-07-02 Thread Jon Smirl
On 7/1/08, Grant Likely [EMAIL PROTECTED] wrote:
 From: Grant Likely [EMAIL PROTECTED]

  Simple utility layer for creating ASoC machine instances based on data
  in the OpenFirmware device tree.  OF aware platform drivers and codec
  drivers register themselves with this framework and the framework
  automatically instantiates a machine driver.

  This is most likely temporary glue code to work around limitations in
  the ASoC v1 framework.  I expect ASoC v2 won't need this.
  ---

   sound/soc/Kconfig  |6 ++
   sound/soc/Makefile |1
   sound/soc/soc-of.c |  171 
 
   3 files changed, 178 insertions(+), 0 deletions(-)

  diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
  index 18f28ac..c5736e5 100644
  --- a/sound/soc/Kconfig
  +++ b/sound/soc/Kconfig
  @@ -23,6 +23,12 @@ config SND_SOC
   This ASoC audio support can also be built as a module.  If so, the 
 module
   will be called snd-soc-core.

  +config SND_SOC_OF
  +   tristate OF helpers for SoC audio support
  +   depends on SND_SOC
  +   ---help---
  + Add support for OpenFirmware device tree descriptions of sound 
 device
  +
   # All the supported Soc's
   source sound/soc/at91/Kconfig
   source sound/soc/pxa/Kconfig
  diff --git a/sound/soc/Makefile b/sound/soc/Makefile
  index 782db21..191c2e5 100644
  --- a/sound/soc/Makefile
  +++ b/sound/soc/Makefile
  @@ -2,3 +2,4 @@ snd-soc-core-objs := soc-core.o soc-dapm.o

   obj-$(CONFIG_SND_SOC)  += snd-soc-core.o
   obj-$(CONFIG_SND_SOC)  += codecs/ at91/ pxa/ s3c24xx/ sh/ fsl/ davinci/ 
 omap/
  +obj-$(CONFIG_SND_SOC_OF)   += soc-of.o
  diff --git a/sound/soc/soc-of.c b/sound/soc/soc-of.c
  new file mode 100644
  index 000..9694979
  --- /dev/null
  +++ b/sound/soc/soc-of.c
  @@ -0,0 +1,171 @@
  +/*
  + * OF helpers for ALSA SoC Layer
  + *
  + * Copyright (C) 2008, Secret Lab Technologies Ltd.
  + */
  +
  +#include linux/module.h
  +#include linux/moduleparam.h
  +#include linux/init.h
  +#include linux/delay.h
  +#include linux/pm.h
  +#include linux/bitops.h
  +#include linux/platform_device.h
  +#include linux/of.h
  +#include sound/core.h
  +#include sound/pcm.h
  +#include sound/pcm_params.h
  +#include sound/soc.h
  +#include sound/soc-of.h
  +#include sound/initval.h
  +
  +MODULE_AUTHOR(Grant Likely [EMAIL PROTECTED]);
  +MODULE_LICENSE(GPL);
  +MODULE_DESCRIPTION(ALSA SoC OpenFirmware bindings);
  +
  +DEFINE_MUTEX(of_snd_soc_mutex);
  +LIST_HEAD(of_snd_soc_device_list);
  +static int of_snd_soc_next_index;
  +
  +struct of_snd_soc_device {
  +   int id;
  +   struct list_head list;
  +   struct snd_soc_device device;
  +   struct snd_soc_machine machine;
  +   struct snd_soc_dai_link dai_link;
  +   struct platform_device *pdev;
  +   struct device_node *platform_node;
  +   struct device_node *codec_node;
  +};
  +
  +static struct snd_soc_ops of_snd_soc_ops = {
  +};
  +
  +static struct of_snd_soc_device *
  +of_snd_soc_get_device(struct device_node *codec_node)
  +{
  +   struct of_snd_soc_device *of_soc;
  +
  +   list_for_each_entry(of_soc, of_snd_soc_device_list, list) {
  +   if (of_soc-codec_node == codec_node)
  +   return of_soc;
  +   }
  +
  +   of_soc = kzalloc(sizeof(struct of_snd_soc_device), GFP_KERNEL);
  +   if (!of_soc)
  +   return NULL;
  +
  +   /* Initialize the structure and add it to the global list */
  +   of_soc-codec_node = codec_node;
  +   of_soc-id = of_snd_soc_next_index++;
  +   of_soc-machine.dai_link = of_soc-dai_link;
  +   of_soc-machine.num_links = 1;
  +   of_soc-device.machine = of_soc-machine;
  +   of_soc-dai_link.ops = of_snd_soc_ops;
  +   list_add(of_soc-list, of_snd_soc_device_list);
  +
  +   return of_soc;
  +}

Isn't this performing the same basic function as this code (except for
spi)? Should this list be maintained in alsa or should there be an
equivalent for searching the spi bus? If you follow the link to the
codec node and get it's parent you know which bus to search. But it
might be simpler to just search the buses sequentially for the node.

static int of_dev_node_match(struct device *dev, void *data)
{
return dev-archdata.of_node == data;
}

struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
{
struct device *dev;

dev = bus_find_device(i2c_bus_type, NULL, node,
 of_dev_node_match);
if (!dev)
return NULL;

return to_i2c_client(dev);
}
EXPORT_SYMBOL(of_find_i2c_device_by_node);



  +
  +static void of_snd_soc_register_device(struct of_snd_soc_device *of_soc)
  +{
  +   struct platform_device *pdev;
  +   int rc;
  +
  +   /* Only register the device if both the codec and platform have
  +* been registered */
  +   if 

Re: [alsa-devel] [PATCH 1/3] ALSA SoC: Add OpenFirmware helper for matching bus and codec drivers

2008-07-02 Thread Grant Likely
On Wed, Jul 02, 2008 at 11:50:43AM +0200, Takashi Iwai wrote:
 At Tue, 01 Jul 2008 17:53:30 -0600,
 Grant Likely wrote:
  diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
  index 18f28ac..c5736e5 100644
  --- a/sound/soc/Kconfig
  +++ b/sound/soc/Kconfig
  @@ -23,6 +23,12 @@ config SND_SOC
This ASoC audio support can also be built as a module.  If so, the 
  module
will be called snd-soc-core.
   
  +config SND_SOC_OF
  +   tristate OF helpers for SoC audio support
  +   depends on SND_SOC
  +   ---help---
  + Add support for OpenFirmware device tree descriptions of sound device
  +
 
 This is a helper module and not necessarily manually selectable.
 Better to make the other driver selecting this.

Yes, you're right.  I hadn't put too much thought into the Kconfig stuff
for this patch because, at the moment, I'm viewing this as a temporary
solution until ASoCv2 is merged.

Which raises another question: Liam and Mark, what is your opinion on
merging this driver?  Is it something that you would merge with the v1
API and then rework it when v2 is merged?  Or would you rather it be
kept out until v2 is ready?  I haven't even looked at the v2 API yet, so
I don't know how much rework is involved.

Cheers,
g.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [alsa-devel] [PATCH 1/3] ALSA SoC: Add OpenFirmware helper for matching bus and codec drivers

2008-07-02 Thread Liam Girdwood
On Wed, 2008-07-02 at 09:48 -0600, Grant Likely wrote:
 On Wed, Jul 02, 2008 at 11:50:43AM +0200, Takashi Iwai wrote:
  
  This is a helper module and not necessarily manually selectable.
  Better to make the other driver selecting this.
 
 Yes, you're right.  I hadn't put too much thought into the Kconfig stuff
 for this patch because, at the moment, I'm viewing this as a temporary
 solution until ASoCv2 is merged.
 
 Which raises another question: Liam and Mark, what is your opinion on
 merging this driver?  Is it something that you would merge with the v1
 API and then rework it when v2 is merged?  Or would you rather it be
 kept out until v2 is ready?  I haven't even looked at the v2 API yet, so
 I don't know how much rework is involved.
 

I'm happy with this atm for v1. We can then rework for V2.

Liam


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev