音频驱动之machine


  1 /*
  2  * smdk_wm9713.c  --  SoC audio for SMDK
  3  *
  4  * Copyright 2010 Samsung Electronics Co. Ltd.
  5  * Author: Jaswinder Singh Brar <jassi.brar@samsung.com>
  6  *
  7  * This program is free software; you can redistribute it and/or
  8  * modify it under the terms of the GNU General Public License as
  9  * published by the Free Software Foundation; either version 2 of the
 10  * License, or (at your option) any later version.
 11  *
 12  */
 13 
 14 #include <linux/module.h>
 15 #include <sound/soc.h>
 16 
 17 static struct snd_soc_card smdk;
 18 
 19 /*
 20  * Default CFG switch settings to use this driver:
 21  *
 22  *   SMDK6410: Set CFG1 1-3 On, CFG2 1-4 Off
 23  *   SMDKC100: Set CFG6 1-3 On, CFG7 1   On
 24  *   SMDKC110: Set CFGB10 1-2 Off, CFGB12 1-3 On
 25  *   SMDKV210: Set CFGB10 1-2 Off, CFGB12 1-3 On
 26  *   SMDKV310: Set CFG2 1-2 Off, CFG4 All On, CFG7 All Off, CFG8 1-On
 27  */
 28 
 29 /*
 30  Playback (HeadPhone):-
 31     $ amixer sset 'Headphone' unmute
 32     $ amixer sset 'Right Headphone Out Mux' 'Headphone'
 33     $ amixer sset 'Left Headphone Out Mux' 'Headphone'
 34     $ amixer sset 'Right HP Mixer PCM' unmute
 35     $ amixer sset 'Left HP Mixer PCM' unmute
 36 
 37  Capture (LineIn):-
 38     $ amixer sset 'Right Capture Source' 'Line'
 39     $ amixer sset 'Left Capture Source' 'Line'
 40 */
 41 
 42 static struct snd_soc_dai_link smdk_dai = {
 43     .name = "AC97",
 44     .stream_name = "AC97 PCM",
 45     .platform_name = "samsung-audio",
 46     .cpu_dai_name = "samsung-ac97",
 47     .codec_dai_name = "wm9713-hifi",
 48     .codec_name = "wm9713-codec",
 49 };
 50 
 51 static struct snd_soc_card smdk = {
 52     .name = "SMDK WM9713",
 53     .dai_link = &smdk_dai,
 54     .num_links = 1,
 55 };
 56 
 57 static struct platform_device *smdk_snd_wm9713_device;
 58 static struct platform_device *smdk_snd_ac97_device;
 59 
 60 static int __init smdk_init(void)
 61 {
 62     int ret;
 63 
 64     smdk_snd_wm9713_device = platform_device_alloc("wm9713-codec", -1);
 65     if (!smdk_snd_wm9713_device)
 66         return -ENOMEM;
 67 
 68     ret = platform_device_add(smdk_snd_wm9713_device);
 69     if (ret)
 70         goto err1;
 71 
 72     smdk_snd_ac97_device = platform_device_alloc("soc-audio", -1);
 73     if (!smdk_snd_ac97_device) {
 74         ret = -ENOMEM;
 75         goto err2;
 76     }
 77 
 78     platform_set_drvdata(smdk_snd_ac97_device, &smdk);
 79 
 80     ret = platform_device_add(smdk_snd_ac97_device);
 81     if (ret)
 82         goto err3;
 83 
 84     return 0;
 85 
 86 err3:
 87     platform_device_put(smdk_snd_ac97_device);
 88 err2:
 89     platform_device_del(smdk_snd_wm9713_device);
 90 err1:
 91     platform_device_put(smdk_snd_wm9713_device);
 92     return ret;
 93 }
 94 
 95 static void __exit smdk_exit(void)
 96 {
 97     platform_device_unregister(smdk_snd_ac97_device);
 98     platform_device_unregister(smdk_snd_wm9713_device);
 99 }
100 
101 module_init(smdk_init);
102 module_exit(smdk_exit);
103 
104 /* Module information */
105 MODULE_AUTHOR("Jaswinder Singh Brar, jassi.brar@samsung.com");
106 MODULE_DESCRIPTION("ALSA SoC SMDK+WM9713");
107 MODULE_LICENSE("GPL");

 


 

 

posted on 2014-06-21 21:58  pipita209  阅读(172)  评论(0)    收藏  举报

导航