Blame view
sound/soc/samsung/jive_wm8750.c
4.24 KB
5033f43c6 ASoC: Samsung: Re... |
1 |
/* sound/soc/samsung/jive_wm8750.c |
3093e48c4 ASoC: Add JIVE au... |
2 3 4 5 6 7 8 9 10 11 12 |
* * Copyright 2007,2008 Simtec Electronics * * Based on sound/soc/pxa/spitz.c * Copyright 2005 Wolfson Microelectronics PLC. * Copyright 2005 Openedhand Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ |
3093e48c4 ASoC: Add JIVE au... |
13 |
#include <sound/soc.h> |
3093e48c4 ASoC: Add JIVE au... |
14 15 |
#include <asm/mach-types.h> |
3093e48c4 ASoC: Add JIVE au... |
16 |
#include "s3c2412-i2s.h" |
3093e48c4 ASoC: Add JIVE au... |
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#include "../codecs/wm8750.h" static const struct snd_soc_dapm_route audio_map[] = { { "Headphone Jack", NULL, "LOUT1" }, { "Headphone Jack", NULL, "ROUT1" }, { "Internal Speaker", NULL, "LOUT2" }, { "Internal Speaker", NULL, "ROUT2" }, { "LINPUT1", NULL, "Line Input" }, { "RINPUT1", NULL, "Line Input" }, }; static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_SPK("Internal Speaker", NULL), SND_SOC_DAPM_LINE("Line In", NULL), }; |
3093e48c4 ASoC: Add JIVE au... |
33 34 35 36 |
static int jive_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; |
f0fba2ad1 ASoC: multi-compo... |
37 38 |
struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
dc85447b1 ASoC: Split s3c24... |
39 |
struct s3c_i2sv2_rate_calc div; |
3093e48c4 ASoC: Add JIVE au... |
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
unsigned int clk = 0; int ret = 0; switch (params_rate(params)) { case 8000: case 16000: case 48000: case 96000: clk = 12288000; break; case 11025: case 22050: case 44100: clk = 11289600; break; } |
01c4cad4f ASoC: Fix jive_wm... |
56 |
s3c_i2sv2_iis_calc_rate(&div, NULL, params_rate(params), |
572824278 ASoC: S3C: I2Sv2:... |
57 |
s3c_i2sv2_get_clock(cpu_dai)); |
3093e48c4 ASoC: Add JIVE au... |
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
/* set codec DAI configuration */ ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); if (ret < 0) return ret; /* set cpu DAI configuration */ ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); if (ret < 0) return ret; /* set the codec system clock for DAC and ADC */ ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk, SND_SOC_CLOCK_IN); if (ret < 0) return ret; ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_RCLK, div.fs_div); if (ret < 0) return ret; ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_PRESCALER, div.clk_div - 1); if (ret < 0) return ret; return 0; } static struct snd_soc_ops jive_ops = { |
3093e48c4 ASoC: Add JIVE au... |
92 93 |
.hw_params = jive_hw_params, }; |
f0fba2ad1 ASoC: multi-compo... |
94 |
static int jive_wm8750_init(struct snd_soc_pcm_runtime *rtd) |
3093e48c4 ASoC: Add JIVE au... |
95 |
{ |
f0fba2ad1 ASoC: multi-compo... |
96 |
struct snd_soc_codec *codec = rtd->codec; |
ce6120cca ASoC: Decouple DA... |
97 |
struct snd_soc_dapm_context *dapm = &codec->dapm; |
3093e48c4 ASoC: Add JIVE au... |
98 99 100 |
int err; /* These endpoints are not being used. */ |
ce6120cca ASoC: Decouple DA... |
101 102 103 104 105 106 |
snd_soc_dapm_nc_pin(dapm, "LINPUT2"); snd_soc_dapm_nc_pin(dapm, "RINPUT2"); snd_soc_dapm_nc_pin(dapm, "LINPUT3"); snd_soc_dapm_nc_pin(dapm, "RINPUT3"); snd_soc_dapm_nc_pin(dapm, "OUT3"); snd_soc_dapm_nc_pin(dapm, "MONO"); |
3093e48c4 ASoC: Add JIVE au... |
107 108 |
/* Add jive specific widgets */ |
ce6120cca ASoC: Decouple DA... |
109 |
err = snd_soc_dapm_new_controls(dapm, wm8750_dapm_widgets, |
3093e48c4 ASoC: Add JIVE au... |
110 111 112 113 114 115 116 |
ARRAY_SIZE(wm8750_dapm_widgets)); if (err) { printk(KERN_ERR "%s: failed to add widgets (%d) ", __func__, err); return err; } |
ce6120cca ASoC: Decouple DA... |
117 118 |
snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); snd_soc_dapm_sync(dapm); |
3093e48c4 ASoC: Add JIVE au... |
119 120 121 122 123 124 125 |
return 0; } static struct snd_soc_dai_link jive_dai = { .name = "wm8750", .stream_name = "WM8750", |
f0fba2ad1 ASoC: multi-compo... |
126 127 |
.cpu_dai_name = "s3c2412-i2s", .codec_dai_name = "wm8750-hifi", |
58bb40721 ASoC: Samsung: Re... |
128 |
.platform_name = "samsung-audio", |
667805044 ASoC: Fix binding... |
129 |
.codec_name = "wm8750-codec.0-001a", |
3093e48c4 ASoC: Add JIVE au... |
130 131 132 133 134 |
.init = jive_wm8750_init, .ops = &jive_ops, }; /* jive audio machine driver */ |
01c4cad4f ASoC: Fix jive_wm... |
135 |
static struct snd_soc_card snd_soc_machine_jive = { |
3093e48c4 ASoC: Add JIVE au... |
136 137 138 139 |
.name = "Jive", .dai_link = &jive_dai, .num_links = 1, }; |
3093e48c4 ASoC: Add JIVE au... |
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
static struct platform_device *jive_snd_device; static int __init jive_init(void) { int ret; if (!machine_is_jive()) return 0; printk("JIVE WM8750 Audio support "); jive_snd_device = platform_device_alloc("soc-audio", -1); if (!jive_snd_device) return -ENOMEM; |
f0fba2ad1 ASoC: multi-compo... |
155 |
platform_set_drvdata(jive_snd_device, &snd_soc_machine_jive); |
3093e48c4 ASoC: Add JIVE au... |
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
ret = platform_device_add(jive_snd_device); if (ret) platform_device_put(jive_snd_device); return ret; } static void __exit jive_exit(void) { platform_device_unregister(jive_snd_device); } module_init(jive_init); module_exit(jive_exit); MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); MODULE_DESCRIPTION("ALSA SoC Jive Audio support"); MODULE_LICENSE("GPL"); |