Advertisement
Guest User

Untitled

a guest
Sep 7th, 2011
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. Kernel Diffs for sound/soc/omap3beagle.c
  2.  
  3. static int omap3beagle_hw_params(struct snd_pcm_substream *substream,
  4. struct snd_pcm_hw_params *params)
  5. {
  6. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  7. struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
  8. struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
  9. unsigned int fmt;
  10. int ret;
  11.  
  12. switch (params_channels(params)) {
  13. case 2: /* Stereo I2S mode */
  14. fmt = SND_SOC_DAIFMT_I2S |
  15. SND_SOC_DAIFMT_NB_NF |
  16. SND_SOC_DAIFMT_CBM_CFM;
  17. break;
  18. case 4: /* Four channel TDM mode */
  19. fmt = SND_SOC_DAIFMT_DSP_A |
  20. SND_SOC_DAIFMT_IB_NF |
  21. SND_SOC_DAIFMT_CBM_CFM;
  22. break;
  23. default:
  24. return -EINVAL;
  25. }
  26.  
  27. /* Set codec DAI configuration */
  28. ret = snd_soc_dai_set_fmt(codec_dai, fmt);
  29. if (ret < 0) {
  30. printk(KERN_ERR "can't set codec DAI configuration\n");
  31. return ret;
  32. }
  33.  
  34. /* Set cpu DAI configuration */
  35. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  36. if (ret < 0) {
  37. printk(KERN_ERR "can't set cpu DAI configuration\n");
  38. return ret;
  39. }
  40.  
  41. /* Vi har en extern MCLK, behövs denna? */
  42.  
  43. /* Set the codec system clock for DAC and ADC */
  44. ret = snd_soc_dai_set_sysclk(codec_dai, 0, 19200000,
  45. SND_SOC_CLOCK_IN);
  46. if (ret < 0) {
  47. printk(KERN_ERR "can't set codec system clock\n");
  48. return ret;
  49. }
  50.  
  51. return 0;
  52. }
  53.  
  54. static struct snd_soc_ops omap3beagle_ops = {
  55. .hw_params = omap3beagle_hw_params,
  56. };
  57.  
  58. static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
  59. SND_SOC_DAPM_HP("Headphone Jack", NULL),
  60. SND_SOC_DAPM_LINE("Line In", NULL),
  61. };
  62.  
  63. static const struct snd_soc_dapm_route audio_map[] = {
  64. /* Headphone connected to LLOUT, LROUT */
  65. {"Headphone Jack", NULL, "LLOUT"},
  66. {"Headphone Jack", NULL, "LROUT"},
  67.  
  68. /* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
  69. {"LINE1L", NULL, "Line In"},
  70. {"LINE2L", NULL, "Line In"},
  71. {"LINE1R", NULL, "Line In"},
  72. {"LINE2R", NULL, "Line In"},
  73. };
  74.  
  75. static int omap3beagle_aic3x_init(struct snd_soc_codec *codec)
  76. {
  77. /* Add beagle specific widgets */
  78. snd_soc_dapm_new_controls(codec, aic3x_dapm_widgets,
  79. ARRAY_SIZE(aic3x_dapm_widgets));
  80.  
  81. /* Set up beagle specific audio path audio_map */
  82. snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
  83.  
  84. /* not connected */
  85. snd_soc_dapm_disable_pin(codec, "MONO_LOUT");
  86. snd_soc_dapm_disable_pin(codec, "HPLCOM");
  87. snd_soc_dapm_disable_pin(codec, "HPRCOM");
  88. snd_soc_dapm_disable_pin(codec, "HPLOUT");
  89. snd_soc_dapm_disable_pin(codec, "HPROUT");
  90.  
  91. /* always connected */
  92. snd_soc_dapm_enable_pin(codec, "Headphone Jack");
  93. snd_soc_dapm_enable_pin(codec, "Line In");
  94.  
  95. snd_soc_dapm_sync(codec);
  96.  
  97. return 0;
  98. }
  99.  
  100. /* Digital audio interface glue - connects codec <--> CPU */
  101. static struct snd_soc_dai_link omap3beagle_dai = {
  102. .name = "TLV320AIC3X",
  103. .stream_name = "AIC3X",
  104. .cpu_dai = &omap_mcbsp_dai[0],
  105. .codec_dai = &aic3x_dai,
  106. .init = omap3beagle_aic3x_init,
  107. .ops = &omap3beagle_ops,
  108. };
  109.  
  110. /* Audio machine driver */
  111. static struct snd_soc_card snd_soc_omap3beagle = {
  112. .name = "omap3beagle",
  113. .platform = &omap_soc_platform,
  114. .dai_link = &omap3beagle_dai,
  115. .num_links = 1,
  116. };
  117.  
  118. static struct aic3x_setup_data aic3x_setup;
  119.  
  120. /* Audio subsystem */
  121. static struct snd_soc_device omap3beagle_snd_devdata = {
  122. .card = &snd_soc_omap3beagle,
  123. .codec_dev = &soc_codec_dev_aic3x,
  124. .codec_data = &aic3x_setup,
  125. };
  126.  
  127. static struct platform_device *omap3beagle_snd_device;
  128.  
  129. static int __init omap3beagle_soc_init(void)
  130. {
  131. int ret;
  132.  
  133. if (!machine_is_omap3_beagle()) {
  134. pr_debug("Not OMAP3 Beagle!\n");
  135. return -ENODEV;
  136. }
  137. pr_info("OMAP3 Beagle SoC init\n");
  138.  
  139. omap3beagle_snd_device = platform_device_alloc("soc-audio", -1);
  140. if (!omap3beagle_snd_device) {
  141. printk(KERN_ERR "Platform device allocation failed\n");
  142. return -ENOMEM;
  143. }
  144.  
  145. platform_set_drvdata(omap3beagle_snd_device, &omap3beagle_snd_devdata);
  146. omap3beagle_snd_devdata.dev = &omap3beagle_snd_device->dev;
  147. *(unsigned int *)omap3beagle_dai.cpu_dai->private_data = 2; /* McBSP3 */
  148.  
  149. ret = platform_device_add(omap3beagle_snd_device);
  150. if (ret)
  151. goto err1;
  152.  
  153. return 0;
  154.  
  155. err1:
  156. printk(KERN_ERR "Unable to add platform device\n");
  157. platform_device_put(omap3beagle_snd_device);
  158.  
  159. return ret;
  160. }
  161.  
  162. Kernel Diffs for arch/arm/mach-omap2/board-omap3beagle.c:
  163.  
  164. static struct i2c_board_info __initdata beagle_i2c1_boardinfo[] = {
  165. {
  166. I2C_BOARD_INFO("tlv320aic3x", 0x18),
  167. },
  168. {
  169. I2C_BOARD_INFO("twl4030", 0x48),
  170. .flags = I2C_CLIENT_WAKE,
  171. .irq = INT_34XX_SYS_NIRQ,
  172. .platform_data = &beagle_twldata,
  173. },
  174. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement