Facebook
From Eratic Plover, 1 Year ago, written in C.
This paste is a reply to Untitled from Whipped Leech - view diff
Embed
Download Paste or View Raw
Hits: 164
  1. / {
  2.         sound: sound {
  3.                 compatible = "simple-audio-card";
  4.  
  5.                 simple-audio-card,name = "Odroid-XU4";
  6.                 simple-audio-card,widgets =
  7.                         "Headphone", "Headphone Jack";
  8.                 simple-audio-card,routing =
  9.                         "Headphone Jack", "HPL",
  10.                         "Headphone Jack", "HPR";
  11.  
  12.                 simple-audio-card,format = "i2s";
  13.                 simple-audio-card,bitclock-master = <&link0_codec>;
  14.                 simple-audio-card,frame-master = <&link0_codec>;
  15.  
  16.                 simple-audio-card,cpu {
  17.                         sound-dai = <&i2s0 0>;
  18.                         system-clock-frequency = <19200000>;
  19.                 };
  20.  
  21.                 link0_codec: simple-audio-card,codec {
  22.                         sound-dai = <&cs4344>;
  23.                         clocks = <&i2s0 CLK_I2S_CDCLK>;
  24.                 };
  25.         };
  26.  
  27.         cs4344: cs4344@10 {
  28.                 compatible = "cirrus,cs4344";
  29.                 clocks = <&i2s0 CLK_I2S_CDCLK>;
  30.                 clock-names = "mclk";
  31.                 #sound-dai-cells = <0>;
  32.                 status = "okay";
  33.         };
  34.  
  35. };
  36.  
  37.  
  38.  
  39.  
  40. ==============================================
  41.  
  42. CODEC PART:
  43.  
  44.  
  45. #include <linux/init.h>
  46. #include <linux/slab.h>
  47. #include <linux/module.h>
  48. #include <linux/kernel.h>
  49. #include <linux/device.h>
  50. #include <sound/core.h>
  51. #include <sound/pcm.h>
  52. #include <sound/ac97_codec.h>
  53. #include <sound/initval.h>
  54. #include <sound/soc.h>
  55.  
  56. #include "cs4344.h"
  57.  
  58. static const struct snd_soc_dapm_widget cs4344_dapm_widgets[] = {
  59.     SND_SOC_DAPM_OUTPUT("HPL"),
  60.     SND_SOC_DAPM_OUTPUT("HPR"),
  61. };
  62.  
  63. static const struct snd_soc_dapm_route cs4344_dapm_routes[] = {
  64.     { "HPL", NULL, "Playback" },
  65.     { "HPR", NULL, "Playback" },
  66. };
  67.  
  68. static struct snd_soc_dai_driver cs4344_dai = {
  69.     .name = "cs4344",
  70.     .playback = {
  71.         .stream_name = "Playback",
  72.         .channels_min = 1,
  73.         .channels_max = 2,
  74.         .rates= SNDRV_PCM_RATE_8000  | SNDRV_PCM_RATE_11025 | \
  75.                 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \
  76.                 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | \
  77.                 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000,
  78.         .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
  79.     },
  80. };
  81.  
  82. static struct snd_soc_codec_driver soc_codec_dev_cs4344 = {
  83.     .dapm_widgets = cs4344_dapm_widgets,
  84.     .num_dapm_widgets = ARRAY_SIZE(cs4344_dapm_widgets),
  85.     .dapm_routes = cs4344_dapm_routes,
  86.     .num_dapm_routes = ARRAY_SIZE(cs4344_dapm_routes),
  87. };
  88.  
  89. static int cs4344_probe(struct platform_device *pdev){
  90.     printk ("****** probe cs4344 ******\n");
  91.     return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_cs4344, &cs4344_dai, 1);
  92. }
  93.  
  94. static int cs4344_remove(struct platform_device *pdev){
  95.     printk ("****** remove cs4344 ******\n");
  96.     snd_soc_unregister_codec(&pdev->dev);
  97.     return 0;
  98. }
  99.  
  100. static const struct of_device_id cs4344_of_match[] = {
  101.     { .compatible = "cirrus,cs4344", },
  102.     { }
  103. };
  104.  
  105. MODULE_DEVICE_TABLE(of, cs4344_of_match);
  106.  
  107. static struct platform_driver cs4344_codec_driver = {
  108.     .driver = {
  109.         .name = "cs4344",
  110.         .of_match_table = of_match_ptr(cs4344_of_match),
  111.     },
  112.     .probe = cs4344_probe,
  113.     .remove = cs4344_remove,
  114. };
  115.  
  116. module_platform_driver(cs4344_codec_driver);
  117.  
  118. MODULE_DESCRIPTION("ASoC cs4344 driver");
  119. MODULE_AUTHOR("xyz");
  120. MODULE_LICENSE("GPL");
  121. MODULE_ALIAS("platform:cs4344");
  122.  
  123.  
  124.