ASoC SST: add mid machine driver
RFC 3/4 ASoC SST: add mid machine driver
From: Vinod Koul <[email protected]>
This patch adds the mic machine driver
The mid machine driver glues the msic and mid_platfrom driver to form the asoc sound driver
--- sound/soc/mid-x86/mid_machine.c | 168 +++++++++++++++++++++++++++++++++ sound/soc/mid-x86/mid_machine.h | 63 ++++++++++++ sound/soc/mid-x86/mid_machine_pvt.c | 81 ++++++++++++++++ sound/soc/mid-x86/mid_machine_table.h | 154 ++++++++++++++++++++++++++++++ 4 files changed, 466 insertions(+), 0 deletions(-) create mode 100644 sound/soc/mid-x86/mid_machine.c create mode 100644 sound/soc/mid-x86/mid_machine.h create mode 100644 sound/soc/mid-x86/mid_machine_pvt.c create mode 100644 sound/soc/mid-x86/mid_machine_table.h
sound/soc/mid-x86/mid_machine.c new file +168 -0
@@ -0,0 +1,168 @@ +/* +* mid_machine.c - Intel MID Machine driver +* +* Copyright (C) 2010 Intel Corp +* Author: Harsha Priya <[email protected]> +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; version 2 of the License. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* +* +*/ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/device.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/initval.h> +#include <sound/soc.h> +#include <sound/intel_sst.h> +#include "../codecs/msic.h" +#include "mid_platform.h" +#include "mid_machine.h" +#include "mid_machine_table.h" + + +static struct platform_device *mid_platform_device, + *mid_codec_device, + *mid_soc_device; + +struct mid_dev_data platform_drv_data; +struct snd_soc_card soc_dev_data; + + +int __devinit snd_intelmid_mc_probe (struct platform_device *pdev) +{ +int ret_val =0 , i; +struct codec_id_info *codec; +const struct platform_device_id *id =platform_get_device_id (pdev); +unsigned int cpu_id, codec_id; + +pr_debug ("snd_intelmid_mc_probe called\n" ); + + codec = (void *)id->driver_data; +if (codec ==NULL ) { +pr_err ("driver data received as null\n" ); +return 0 ; + } + + codec_id =get_codec_id (codec); + cpu_id = codec->cpu_id; +pr_debug ("**codec id = %d \t ***cpu id = %d\n" , codec_id, cpu_id); + +for (i =0 ; i <ARRAY_SIZE (machine_table); i++) { +struct platform_codec_map mc = machine_table[i]; +if (mc.cpu_id == cpu_id && mc.codec_id == codec_id) { + platform_drv_data.dai = mc.cpu_dai; + platform_drv_data.num_dais = mc.cpu_num_dais; + ret_val =create_device (&mid_platform_device, + mc.platform_name, &platform_drv_data); +if (ret_val) +return ret_val; + + ret_val =create_device (&mid_codec_device, + mc.codec_name,NULL ); +if (ret_val) + goto unreg_platform; + + soc_dev_data.name = mc.soc_name; + soc_dev_data.dai_link = mc.dai_link; + soc_dev_data.num_links = mc.num_dai_links; +/*soc_dev_data.codec_dev = mc.codec_dev;*/ + ret_val =create_device (&mid_soc_device, +"soc-audio" , &soc_dev_data); +if (ret_val) + goto unreg_codec; + } + + } +if (i >ARRAY_SIZE (machine_table)) { +pr_err ("no platform and codec found to be registered\n" ); +return -1 ; + } +pr_debug ("successfully exited probe\n" ); +return ret_val; +unreg_codec: +platform_device_unregister (mid_codec_device); +unreg_platform: +platform_device_unregister (mid_platform_device); +return ret_val; +} + +static int snd_intelmid_remove (struct platform_device *pdev) +{ +const struct platform_device_id *id =platform_get_device_id (pdev); +struct codec_id_info *codec; +int i; +unsigned int cpu_id, codec_id; + +pr_debug ("snd_intelmid_remove called\n" ); + + codec = (void *)id->driver_data; +if (codec ==NULL ) { +pr_err ("driver data received as null\n" ); +return 0 ; + } + codec_id =get_codec_id (codec); + cpu_id = codec->cpu_id; +pr_debug ("**codec id = %d \t ***cpu id = %d\n" , codec_id, cpu_id); + +for (i =0 ; i <ARRAY_SIZE (machine_table); i++) { +struct platform_codec_map mc = machine_table[i]; +if (mc.cpu_id == cpu_id && mc.codec_id == codec_id) { +platform_device_unregister (mid_soc_device); +platform_device_unregister (mid_platform_device); +platform_device_unregister (mid_codec_device); +platform_set_drvdata (pdev,NULL ); + } + } +return 0 ; +} + + +static struct platform_driver snd_intelmid_mc_driver = { + .driver = { + .owner =THIS_MODULE , + .name ="mid_sound_card" , + }, + .id_table = snd_intelmid_ids, + .probe = snd_intelmid_mc_probe, + .remove =__devexit_p (snd_intelmid_remove), +}; + +static int __init intelmidmc_soc_init (void ) +{ +pr_debug ("intelmidmc_soc_init called\n" ); + +return platform_driver_register (&snd_intelmid_mc_driver); +} +module_init (intelmidmc_soc_init); + +static void __exit intelmidmc_soc_exit(void) +{ +pr_debug ("intelmidmc_soc_exit called\n" ); +platform_driver_unregister (&snd_intelmid_mc_driver); +} +module_exit (intelmidmc_soc_exit); + +MODULE_DESCRIPTION ("ASoC Intel(R) MACHINE driver" ); +MODULE_AUTHOR ("Harsha Priya" ); +MODULE_LICENSE ("GPL v2" ); + +
sound/soc/mid-x86/mid_machine.h new file +63 -0
63 lines not on this page · raw message
sound/soc/mid-x86/mid_machine_pvt.c new file +81 -0
81 lines not on this page · raw message
sound/soc/mid-x86/mid_machine_table.h new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Quoted 4 lines · Vinod
From: Vinod Koul <[email protected]>
This patch adds the mic machine driver
The mid machine driver glues the msic andmid_platfromdriver to form the asoc sound driver
A machine driver should be for a particular machine, describing how the various components have been connected on that particular machine. This looks like you're trying to do a single machine driver for all systems.
Probably this should have some sort of name indicating that it's for use with systems that are trying to do something using the BIOS scheme you've got for these systems; I'd expect that if the systems get much traction in the market you'll also end up with systems implementing regular ASoC machine drivers too.
sound/soc/mid-x86/mid_machine.h line 36
Quoted 8 lines
sound/soc/mid-x86/mid_machine.h new file +8
-0+#define MONO 1 +#define STEREO 2 +#define MAX_CAP 5 +#define DRIVER_NAME_MFLD "msic_audio" +#define DRIVER_NAME_MRST "pmic_audio" +#define CPU_CHIP_LINCROFT 1/* System running lincroft */ +#define CPU_CHIP_PENWELL 2/* System running penwell */ +#define MSIC_CODEC 3
Here and through most of the rest of the driver you need to namespace stuff more.
Quoted 10 lines · Mark Brown
Quoted 4 lines · Vinod
From: Vinod Koul <[email protected]>
This patch adds the mic machine driver
The mid machine driver glues the msic andmid_platfromdriver to form theasoc sound driver
A machine driver should be for a particular machine, describing how the various components have been connected on that particular machine. This looks like you're trying to do a single machine driver for all systems.
Yes that is the intention, that's why a table.
At least currently we plan to use single machine driver for two platforms and having 4 codecs. For now most of the code is reuse in machine driver so would make sense to have common driver.
Quoted 5 lines
Probably this should have some sort of name indicating that it's for use with systems that are trying to do something using the BIOS scheme you've got for these systems; I'd expect that if the systems get much traction in the market you'll also end up with systems implementing regular ASoC machine drivers too.
Yes I am also divided on which approach to take
~Vinod