diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-02-11 06:06:38 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-02-11 06:06:38 -0500 |
commit | 556d8b55d083ad487067680feaf179664172bd4e (patch) | |
tree | 36005d676bd1b7aeb4f3ff7dcda3f22bde051161 /sound/soc/soc-core.c | |
parent | f0f3214e8be1068121ba829fcd8c1c22b5bd6975 (diff) | |
parent | 8c2d6a9f9cfa59acfa63ee88e70d58f0ba3eaf21 (diff) |
Merge remote-tracking branch 'asoc/topic/of' into asoc-next
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 7365afbc5e18..8df1b3feaf2b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -4218,6 +4218,113 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
4218 | } | 4218 | } |
4219 | EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_routing); | 4219 | EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_routing); |
4220 | 4220 | ||
4221 | unsigned int snd_soc_of_parse_daifmt(struct device_node *np, | ||
4222 | const char *prefix) | ||
4223 | { | ||
4224 | int ret, i; | ||
4225 | char prop[128]; | ||
4226 | unsigned int format = 0; | ||
4227 | int bit, frame; | ||
4228 | const char *str; | ||
4229 | struct { | ||
4230 | char *name; | ||
4231 | unsigned int val; | ||
4232 | } of_fmt_table[] = { | ||
4233 | { "i2s", SND_SOC_DAIFMT_I2S }, | ||
4234 | { "right_j", SND_SOC_DAIFMT_RIGHT_J }, | ||
4235 | { "left_j", SND_SOC_DAIFMT_LEFT_J }, | ||
4236 | { "dsp_a", SND_SOC_DAIFMT_DSP_A }, | ||
4237 | { "dsp_b", SND_SOC_DAIFMT_DSP_B }, | ||
4238 | { "ac97", SND_SOC_DAIFMT_AC97 }, | ||
4239 | { "pdm", SND_SOC_DAIFMT_PDM}, | ||
4240 | { "msb", SND_SOC_DAIFMT_MSB }, | ||
4241 | { "lsb", SND_SOC_DAIFMT_LSB }, | ||
4242 | }; | ||
4243 | |||
4244 | if (!prefix) | ||
4245 | prefix = ""; | ||
4246 | |||
4247 | /* | ||
4248 | * check "[prefix]format = xxx" | ||
4249 | * SND_SOC_DAIFMT_FORMAT_MASK area | ||
4250 | */ | ||
4251 | snprintf(prop, sizeof(prop), "%sformat", prefix); | ||
4252 | ret = of_property_read_string(np, prop, &str); | ||
4253 | if (ret == 0) { | ||
4254 | for (i = 0; i < ARRAY_SIZE(of_fmt_table); i++) { | ||
4255 | if (strcmp(str, of_fmt_table[i].name) == 0) { | ||
4256 | format |= of_fmt_table[i].val; | ||
4257 | break; | ||
4258 | } | ||
4259 | } | ||
4260 | } | ||
4261 | |||
4262 | /* | ||
4263 | * check "[prefix]continuous-clock" | ||
4264 | * SND_SOC_DAIFMT_CLOCK_MASK area | ||
4265 | */ | ||
4266 | snprintf(prop, sizeof(prop), "%scontinuous-clock", prefix); | ||
4267 | if (of_get_property(np, prop, NULL)) | ||
4268 | format |= SND_SOC_DAIFMT_CONT; | ||
4269 | else | ||
4270 | format |= SND_SOC_DAIFMT_GATED; | ||
4271 | |||
4272 | /* | ||
4273 | * check "[prefix]bitclock-inversion" | ||
4274 | * check "[prefix]frame-inversion" | ||
4275 | * SND_SOC_DAIFMT_INV_MASK area | ||
4276 | */ | ||
4277 | snprintf(prop, sizeof(prop), "%sbitclock-inversion", prefix); | ||
4278 | bit = !!of_get_property(np, prop, NULL); | ||
4279 | |||
4280 | snprintf(prop, sizeof(prop), "%sframe-inversion", prefix); | ||
4281 | frame = !!of_get_property(np, prop, NULL); | ||
4282 | |||
4283 | switch ((bit << 4) + frame) { | ||
4284 | case 0x11: | ||
4285 | format |= SND_SOC_DAIFMT_IB_IF; | ||
4286 | break; | ||
4287 | case 0x10: | ||
4288 | format |= SND_SOC_DAIFMT_IB_NF; | ||
4289 | break; | ||
4290 | case 0x01: | ||
4291 | format |= SND_SOC_DAIFMT_NB_IF; | ||
4292 | break; | ||
4293 | default: | ||
4294 | /* SND_SOC_DAIFMT_NB_NF is default */ | ||
4295 | break; | ||
4296 | } | ||
4297 | |||
4298 | /* | ||
4299 | * check "[prefix]bitclock-master" | ||
4300 | * check "[prefix]frame-master" | ||
4301 | * SND_SOC_DAIFMT_MASTER_MASK area | ||
4302 | */ | ||
4303 | snprintf(prop, sizeof(prop), "%sbitclock-master", prefix); | ||
4304 | bit = !!of_get_property(np, prop, NULL); | ||
4305 | |||
4306 | snprintf(prop, sizeof(prop), "%sframe-master", prefix); | ||
4307 | frame = !!of_get_property(np, prop, NULL); | ||
4308 | |||
4309 | switch ((bit << 4) + frame) { | ||
4310 | case 0x11: | ||
4311 | format |= SND_SOC_DAIFMT_CBM_CFM; | ||
4312 | break; | ||
4313 | case 0x10: | ||
4314 | format |= SND_SOC_DAIFMT_CBM_CFS; | ||
4315 | break; | ||
4316 | case 0x01: | ||
4317 | format |= SND_SOC_DAIFMT_CBS_CFM; | ||
4318 | break; | ||
4319 | default: | ||
4320 | format |= SND_SOC_DAIFMT_CBS_CFS; | ||
4321 | break; | ||
4322 | } | ||
4323 | |||
4324 | return format; | ||
4325 | } | ||
4326 | EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt); | ||
4327 | |||
4221 | static int __init snd_soc_init(void) | 4328 | static int __init snd_soc_init(void) |
4222 | { | 4329 | { |
4223 | #ifdef CONFIG_DEBUG_FS | 4330 | #ifdef CONFIG_DEBUG_FS |