Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1 | /* |
| 2 | * soc-core.c -- ALSA SoC Audio Layer |
| 3 | * |
| 4 | * Copyright 2005 Wolfson Microelectronics PLC. |
Liam Girdwood | 0664d88 | 2006-12-18 14:39:02 +0100 | [diff] [blame] | 5 | * Copyright 2005 Openedhand Ltd. |
| 6 | * |
Liam Girdwood | d331124 | 2008-10-12 13:17:36 +0100 | [diff] [blame] | 7 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
Liam Girdwood | 0664d88 | 2006-12-18 14:39:02 +0100 | [diff] [blame] | 8 | * with code, comments and ideas from :- |
| 9 | * Richard Purdie <richard@openedhand.com> |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify it |
| 12 | * under the terms of the GNU General Public License as published by the |
| 13 | * Free Software Foundation; either version 2 of the License, or (at your |
| 14 | * option) any later version. |
| 15 | * |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 16 | * TODO: |
| 17 | * o Add hw rules to enforce rates, etc. |
| 18 | * o More testing with other codecs/machines. |
| 19 | * o Add more codecs and platforms to ensure good API coverage. |
| 20 | * o Support TDM on PCM and I2S |
| 21 | */ |
| 22 | |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/moduleparam.h> |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/delay.h> |
| 27 | #include <linux/pm.h> |
| 28 | #include <linux/bitops.h> |
Troy Kisky | 12ef193 | 2008-10-13 17:42:14 -0700 | [diff] [blame] | 29 | #include <linux/debugfs.h> |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 30 | #include <linux/platform_device.h> |
Marek Vasut | 474828a | 2009-07-22 13:01:03 +0200 | [diff] [blame] | 31 | #include <sound/ac97_codec.h> |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 32 | #include <sound/core.h> |
| 33 | #include <sound/pcm.h> |
| 34 | #include <sound/pcm_params.h> |
| 35 | #include <sound/soc.h> |
| 36 | #include <sound/soc-dapm.h> |
| 37 | #include <sound/initval.h> |
| 38 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 39 | static DEFINE_MUTEX(pcm_mutex); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 40 | static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq); |
| 41 | |
Mark Brown | 384c89e | 2008-12-03 17:34:03 +0000 | [diff] [blame] | 42 | #ifdef CONFIG_DEBUG_FS |
| 43 | static struct dentry *debugfs_root; |
| 44 | #endif |
| 45 | |
Mark Brown | c5af3a2 | 2008-11-28 13:29:45 +0000 | [diff] [blame] | 46 | static DEFINE_MUTEX(client_mutex); |
| 47 | static LIST_HEAD(card_list); |
Mark Brown | 9115171 | 2008-11-30 23:31:24 +0000 | [diff] [blame] | 48 | static LIST_HEAD(dai_list); |
Mark Brown | 12a48a8c | 2008-12-03 19:40:30 +0000 | [diff] [blame] | 49 | static LIST_HEAD(platform_list); |
Mark Brown | 0d0cf00 | 2008-12-10 14:32:45 +0000 | [diff] [blame] | 50 | static LIST_HEAD(codec_list); |
Mark Brown | c5af3a2 | 2008-11-28 13:29:45 +0000 | [diff] [blame] | 51 | |
| 52 | static int snd_soc_register_card(struct snd_soc_card *card); |
| 53 | static int snd_soc_unregister_card(struct snd_soc_card *card); |
| 54 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 55 | /* |
| 56 | * This is a timeout to do a DAPM powerdown after a stream is closed(). |
| 57 | * It can be used to eliminate pops between different playback streams, e.g. |
| 58 | * between two audio tracks. |
| 59 | */ |
| 60 | static int pmdown_time = 5000; |
| 61 | module_param(pmdown_time, int, 0); |
| 62 | MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)"); |
| 63 | |
Liam Girdwood | 965ac42 | 2007-01-31 14:14:57 +0100 | [diff] [blame] | 64 | /* |
| 65 | * This function forces any delayed work to be queued and run. |
| 66 | */ |
| 67 | static int run_delayed_work(struct delayed_work *dwork) |
| 68 | { |
| 69 | int ret; |
| 70 | |
| 71 | /* cancel any work waiting to be queued. */ |
| 72 | ret = cancel_delayed_work(dwork); |
| 73 | |
| 74 | /* if there was any work waiting then we run it now and |
| 75 | * wait for it's completion */ |
| 76 | if (ret) { |
| 77 | schedule_delayed_work(dwork, 0); |
| 78 | flush_scheduled_work(); |
| 79 | } |
| 80 | return ret; |
| 81 | } |
| 82 | |
Mark Brown | 2624d5f | 2009-11-03 21:56:13 +0000 | [diff] [blame] | 83 | /* codec register dump */ |
| 84 | static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf) |
| 85 | { |
| 86 | int i, step = 1, count = 0; |
| 87 | |
| 88 | if (!codec->reg_cache_size) |
| 89 | return 0; |
| 90 | |
| 91 | if (codec->reg_cache_step) |
| 92 | step = codec->reg_cache_step; |
| 93 | |
| 94 | count += sprintf(buf, "%s registers\n", codec->name); |
| 95 | for (i = 0; i < codec->reg_cache_size; i += step) { |
| 96 | if (codec->readable_register && !codec->readable_register(i)) |
| 97 | continue; |
| 98 | |
| 99 | count += sprintf(buf + count, "%2x: ", i); |
| 100 | if (count >= PAGE_SIZE - 1) |
| 101 | break; |
| 102 | |
| 103 | if (codec->display_register) |
| 104 | count += codec->display_register(codec, buf + count, |
| 105 | PAGE_SIZE - count, i); |
| 106 | else |
| 107 | count += snprintf(buf + count, PAGE_SIZE - count, |
| 108 | "%4x", codec->read(codec, i)); |
| 109 | |
| 110 | if (count >= PAGE_SIZE - 1) |
| 111 | break; |
| 112 | |
| 113 | count += snprintf(buf + count, PAGE_SIZE - count, "\n"); |
| 114 | if (count >= PAGE_SIZE - 1) |
| 115 | break; |
| 116 | } |
| 117 | |
| 118 | /* Truncate count; min() would cause a warning */ |
| 119 | if (count >= PAGE_SIZE) |
| 120 | count = PAGE_SIZE - 1; |
| 121 | |
| 122 | return count; |
| 123 | } |
| 124 | static ssize_t codec_reg_show(struct device *dev, |
| 125 | struct device_attribute *attr, char *buf) |
| 126 | { |
| 127 | struct snd_soc_device *devdata = dev_get_drvdata(dev); |
| 128 | return soc_codec_reg_show(devdata->card->codec, buf); |
| 129 | } |
| 130 | |
| 131 | static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL); |
| 132 | |
Mark Brown | dbe2140 | 2010-02-12 11:37:24 +0000 | [diff] [blame] | 133 | static ssize_t pmdown_time_show(struct device *dev, |
| 134 | struct device_attribute *attr, char *buf) |
| 135 | { |
| 136 | struct snd_soc_device *socdev = dev_get_drvdata(dev); |
| 137 | struct snd_soc_card *card = socdev->card; |
| 138 | |
Mark Brown | 6c5f1fe | 2010-02-17 14:30:44 +0000 | [diff] [blame] | 139 | return sprintf(buf, "%ld\n", card->pmdown_time); |
Mark Brown | dbe2140 | 2010-02-12 11:37:24 +0000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | static ssize_t pmdown_time_set(struct device *dev, |
| 143 | struct device_attribute *attr, |
| 144 | const char *buf, size_t count) |
| 145 | { |
| 146 | struct snd_soc_device *socdev = dev_get_drvdata(dev); |
| 147 | struct snd_soc_card *card = socdev->card; |
| 148 | |
| 149 | strict_strtol(buf, 10, &card->pmdown_time); |
| 150 | |
| 151 | return count; |
| 152 | } |
| 153 | |
| 154 | static DEVICE_ATTR(pmdown_time, 0644, pmdown_time_show, pmdown_time_set); |
| 155 | |
Mark Brown | 2624d5f | 2009-11-03 21:56:13 +0000 | [diff] [blame] | 156 | #ifdef CONFIG_DEBUG_FS |
| 157 | static int codec_reg_open_file(struct inode *inode, struct file *file) |
| 158 | { |
| 159 | file->private_data = inode->i_private; |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf, |
| 164 | size_t count, loff_t *ppos) |
| 165 | { |
| 166 | ssize_t ret; |
| 167 | struct snd_soc_codec *codec = file->private_data; |
| 168 | char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 169 | if (!buf) |
| 170 | return -ENOMEM; |
| 171 | ret = soc_codec_reg_show(codec, buf); |
| 172 | if (ret >= 0) |
| 173 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); |
| 174 | kfree(buf); |
| 175 | return ret; |
| 176 | } |
| 177 | |
| 178 | static ssize_t codec_reg_write_file(struct file *file, |
| 179 | const char __user *user_buf, size_t count, loff_t *ppos) |
| 180 | { |
| 181 | char buf[32]; |
| 182 | int buf_size; |
| 183 | char *start = buf; |
| 184 | unsigned long reg, value; |
| 185 | int step = 1; |
| 186 | struct snd_soc_codec *codec = file->private_data; |
| 187 | |
| 188 | buf_size = min(count, (sizeof(buf)-1)); |
| 189 | if (copy_from_user(buf, user_buf, buf_size)) |
| 190 | return -EFAULT; |
| 191 | buf[buf_size] = 0; |
| 192 | |
| 193 | if (codec->reg_cache_step) |
| 194 | step = codec->reg_cache_step; |
| 195 | |
| 196 | while (*start == ' ') |
| 197 | start++; |
| 198 | reg = simple_strtoul(start, &start, 16); |
| 199 | if ((reg >= codec->reg_cache_size) || (reg % step)) |
| 200 | return -EINVAL; |
| 201 | while (*start == ' ') |
| 202 | start++; |
| 203 | if (strict_strtoul(start, 16, &value)) |
| 204 | return -EINVAL; |
| 205 | codec->write(codec, reg, value); |
| 206 | return buf_size; |
| 207 | } |
| 208 | |
| 209 | static const struct file_operations codec_reg_fops = { |
| 210 | .open = codec_reg_open_file, |
| 211 | .read = codec_reg_read_file, |
| 212 | .write = codec_reg_write_file, |
| 213 | }; |
| 214 | |
| 215 | static void soc_init_codec_debugfs(struct snd_soc_codec *codec) |
| 216 | { |
| 217 | char codec_root[128]; |
| 218 | |
| 219 | if (codec->dev) |
| 220 | snprintf(codec_root, sizeof(codec_root), |
| 221 | "%s.%s", codec->name, dev_name(codec->dev)); |
| 222 | else |
| 223 | snprintf(codec_root, sizeof(codec_root), |
| 224 | "%s", codec->name); |
| 225 | |
| 226 | codec->debugfs_codec_root = debugfs_create_dir(codec_root, |
| 227 | debugfs_root); |
| 228 | if (!codec->debugfs_codec_root) { |
| 229 | printk(KERN_WARNING |
| 230 | "ASoC: Failed to create codec debugfs directory\n"); |
| 231 | return; |
| 232 | } |
| 233 | |
| 234 | codec->debugfs_reg = debugfs_create_file("codec_reg", 0644, |
| 235 | codec->debugfs_codec_root, |
| 236 | codec, &codec_reg_fops); |
| 237 | if (!codec->debugfs_reg) |
| 238 | printk(KERN_WARNING |
| 239 | "ASoC: Failed to create codec register debugfs file\n"); |
| 240 | |
| 241 | codec->debugfs_pop_time = debugfs_create_u32("dapm_pop_time", 0744, |
| 242 | codec->debugfs_codec_root, |
| 243 | &codec->pop_time); |
| 244 | if (!codec->debugfs_pop_time) |
| 245 | printk(KERN_WARNING |
| 246 | "Failed to create pop time debugfs file\n"); |
| 247 | |
| 248 | codec->debugfs_dapm = debugfs_create_dir("dapm", |
| 249 | codec->debugfs_codec_root); |
| 250 | if (!codec->debugfs_dapm) |
| 251 | printk(KERN_WARNING |
| 252 | "Failed to create DAPM debugfs directory\n"); |
| 253 | |
| 254 | snd_soc_dapm_debugfs_init(codec); |
| 255 | } |
| 256 | |
| 257 | static void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec) |
| 258 | { |
| 259 | debugfs_remove_recursive(codec->debugfs_codec_root); |
| 260 | } |
| 261 | |
| 262 | #else |
| 263 | |
| 264 | static inline void soc_init_codec_debugfs(struct snd_soc_codec *codec) |
| 265 | { |
| 266 | } |
| 267 | |
| 268 | static inline void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec) |
| 269 | { |
| 270 | } |
| 271 | #endif |
| 272 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 273 | #ifdef CONFIG_SND_SOC_AC97_BUS |
| 274 | /* unregister ac97 codec */ |
| 275 | static int soc_ac97_dev_unregister(struct snd_soc_codec *codec) |
| 276 | { |
| 277 | if (codec->ac97->dev.bus) |
| 278 | device_unregister(&codec->ac97->dev); |
| 279 | return 0; |
| 280 | } |
| 281 | |
| 282 | /* stop no dev release warning */ |
| 283 | static void soc_ac97_device_release(struct device *dev){} |
| 284 | |
| 285 | /* register ac97 codec to bus */ |
| 286 | static int soc_ac97_dev_register(struct snd_soc_codec *codec) |
| 287 | { |
| 288 | int err; |
| 289 | |
| 290 | codec->ac97->dev.bus = &ac97_bus_type; |
Mark Brown | 4ac5c61 | 2009-04-01 19:35:01 +0100 | [diff] [blame] | 291 | codec->ac97->dev.parent = codec->card->dev; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 292 | codec->ac97->dev.release = soc_ac97_device_release; |
| 293 | |
Kay Sievers | bb072bf | 2008-11-02 03:50:35 +0100 | [diff] [blame] | 294 | dev_set_name(&codec->ac97->dev, "%d-%d:%s", |
| 295 | codec->card->number, 0, codec->name); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 296 | err = device_register(&codec->ac97->dev); |
| 297 | if (err < 0) { |
| 298 | snd_printk(KERN_ERR "Can't register ac97 bus\n"); |
| 299 | codec->ac97->dev.bus = NULL; |
| 300 | return err; |
| 301 | } |
| 302 | return 0; |
| 303 | } |
| 304 | #endif |
| 305 | |
Mark Brown | 06f409d | 2009-04-07 18:10:13 +0100 | [diff] [blame] | 306 | static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream) |
| 307 | { |
| 308 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 309 | struct snd_soc_device *socdev = rtd->socdev; |
| 310 | struct snd_soc_card *card = socdev->card; |
| 311 | struct snd_soc_dai_link *machine = rtd->dai; |
| 312 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
| 313 | struct snd_soc_dai *codec_dai = machine->codec_dai; |
| 314 | int ret; |
| 315 | |
| 316 | if (codec_dai->symmetric_rates || cpu_dai->symmetric_rates || |
| 317 | machine->symmetric_rates) { |
Peter Ujfalusi | 5083145 | 2010-03-03 15:08:04 +0200 | [diff] [blame] | 318 | dev_dbg(card->dev, "Symmetry forces %dHz rate\n", |
Mark Brown | 06f409d | 2009-04-07 18:10:13 +0100 | [diff] [blame] | 319 | machine->rate); |
| 320 | |
| 321 | ret = snd_pcm_hw_constraint_minmax(substream->runtime, |
| 322 | SNDRV_PCM_HW_PARAM_RATE, |
| 323 | machine->rate, |
| 324 | machine->rate); |
| 325 | if (ret < 0) { |
| 326 | dev_err(card->dev, |
| 327 | "Unable to apply rate symmetry constraint: %d\n", ret); |
| 328 | return ret; |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | return 0; |
| 333 | } |
| 334 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 335 | /* |
| 336 | * Called by ALSA when a PCM substream is opened, the runtime->hw record is |
| 337 | * then initialized and any private data can be allocated. This also calls |
| 338 | * startup for the cpu DAI, platform, machine and codec DAI. |
| 339 | */ |
| 340 | static int soc_pcm_open(struct snd_pcm_substream *substream) |
| 341 | { |
| 342 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 343 | struct snd_soc_device *socdev = rtd->socdev; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 344 | struct snd_soc_card *card = socdev->card; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 345 | struct snd_pcm_runtime *runtime = substream->runtime; |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 346 | struct snd_soc_dai_link *machine = rtd->dai; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 347 | struct snd_soc_platform *platform = card->platform; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 348 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
| 349 | struct snd_soc_dai *codec_dai = machine->codec_dai; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 350 | int ret = 0; |
| 351 | |
| 352 | mutex_lock(&pcm_mutex); |
| 353 | |
| 354 | /* startup the audio subsystem */ |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 355 | if (cpu_dai->ops->startup) { |
| 356 | ret = cpu_dai->ops->startup(substream, cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 357 | if (ret < 0) { |
| 358 | printk(KERN_ERR "asoc: can't open interface %s\n", |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 359 | cpu_dai->name); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 360 | goto out; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | if (platform->pcm_ops->open) { |
| 365 | ret = platform->pcm_ops->open(substream); |
| 366 | if (ret < 0) { |
| 367 | printk(KERN_ERR "asoc: can't open platform %s\n", platform->name); |
| 368 | goto platform_err; |
| 369 | } |
| 370 | } |
| 371 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 372 | if (codec_dai->ops->startup) { |
| 373 | ret = codec_dai->ops->startup(substream, codec_dai); |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 374 | if (ret < 0) { |
| 375 | printk(KERN_ERR "asoc: can't open codec %s\n", |
| 376 | codec_dai->name); |
| 377 | goto codec_dai_err; |
| 378 | } |
| 379 | } |
| 380 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 381 | if (machine->ops && machine->ops->startup) { |
| 382 | ret = machine->ops->startup(substream); |
| 383 | if (ret < 0) { |
| 384 | printk(KERN_ERR "asoc: %s startup failed\n", machine->name); |
| 385 | goto machine_err; |
| 386 | } |
| 387 | } |
| 388 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 389 | /* Check that the codec and cpu DAI's are compatible */ |
| 390 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 391 | runtime->hw.rate_min = |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 392 | max(codec_dai->playback.rate_min, |
| 393 | cpu_dai->playback.rate_min); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 394 | runtime->hw.rate_max = |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 395 | min(codec_dai->playback.rate_max, |
| 396 | cpu_dai->playback.rate_max); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 397 | runtime->hw.channels_min = |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 398 | max(codec_dai->playback.channels_min, |
| 399 | cpu_dai->playback.channels_min); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 400 | runtime->hw.channels_max = |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 401 | min(codec_dai->playback.channels_max, |
| 402 | cpu_dai->playback.channels_max); |
| 403 | runtime->hw.formats = |
| 404 | codec_dai->playback.formats & cpu_dai->playback.formats; |
| 405 | runtime->hw.rates = |
| 406 | codec_dai->playback.rates & cpu_dai->playback.rates; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 407 | } else { |
| 408 | runtime->hw.rate_min = |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 409 | max(codec_dai->capture.rate_min, |
| 410 | cpu_dai->capture.rate_min); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 411 | runtime->hw.rate_max = |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 412 | min(codec_dai->capture.rate_max, |
| 413 | cpu_dai->capture.rate_max); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 414 | runtime->hw.channels_min = |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 415 | max(codec_dai->capture.channels_min, |
| 416 | cpu_dai->capture.channels_min); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 417 | runtime->hw.channels_max = |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 418 | min(codec_dai->capture.channels_max, |
| 419 | cpu_dai->capture.channels_max); |
| 420 | runtime->hw.formats = |
| 421 | codec_dai->capture.formats & cpu_dai->capture.formats; |
| 422 | runtime->hw.rates = |
| 423 | codec_dai->capture.rates & cpu_dai->capture.rates; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | snd_pcm_limit_hw_rates(runtime); |
| 427 | if (!runtime->hw.rates) { |
| 428 | printk(KERN_ERR "asoc: %s <-> %s No matching rates\n", |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 429 | codec_dai->name, cpu_dai->name); |
Jassi Brar | bb1c047 | 2010-02-25 11:24:53 +0900 | [diff] [blame] | 430 | goto config_err; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 431 | } |
| 432 | if (!runtime->hw.formats) { |
| 433 | printk(KERN_ERR "asoc: %s <-> %s No matching formats\n", |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 434 | codec_dai->name, cpu_dai->name); |
Jassi Brar | bb1c047 | 2010-02-25 11:24:53 +0900 | [diff] [blame] | 435 | goto config_err; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 436 | } |
| 437 | if (!runtime->hw.channels_min || !runtime->hw.channels_max) { |
| 438 | printk(KERN_ERR "asoc: %s <-> %s No matching channels\n", |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 439 | codec_dai->name, cpu_dai->name); |
Jassi Brar | bb1c047 | 2010-02-25 11:24:53 +0900 | [diff] [blame] | 440 | goto config_err; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 441 | } |
| 442 | |
Mark Brown | 06f409d | 2009-04-07 18:10:13 +0100 | [diff] [blame] | 443 | /* Symmetry only applies if we've already got an active stream. */ |
| 444 | if (cpu_dai->active || codec_dai->active) { |
| 445 | ret = soc_pcm_apply_symmetry(substream); |
| 446 | if (ret != 0) |
Jassi Brar | bb1c047 | 2010-02-25 11:24:53 +0900 | [diff] [blame] | 447 | goto config_err; |
Mark Brown | 06f409d | 2009-04-07 18:10:13 +0100 | [diff] [blame] | 448 | } |
| 449 | |
Mark Brown | f24368c | 2008-10-21 21:45:08 +0100 | [diff] [blame] | 450 | pr_debug("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name); |
| 451 | pr_debug("asoc: rate mask 0x%x\n", runtime->hw.rates); |
| 452 | pr_debug("asoc: min ch %d max ch %d\n", runtime->hw.channels_min, |
| 453 | runtime->hw.channels_max); |
| 454 | pr_debug("asoc: min rate %d max rate %d\n", runtime->hw.rate_min, |
| 455 | runtime->hw.rate_max); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 456 | |
Jassi Brar | 14dc573 | 2010-02-26 09:12:32 +0900 | [diff] [blame] | 457 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 458 | cpu_dai->playback.active++; |
| 459 | codec_dai->playback.active++; |
| 460 | } else { |
| 461 | cpu_dai->capture.active++; |
| 462 | codec_dai->capture.active++; |
| 463 | } |
| 464 | cpu_dai->active++; |
| 465 | codec_dai->active++; |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 466 | card->codec->active++; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 467 | mutex_unlock(&pcm_mutex); |
| 468 | return 0; |
| 469 | |
Jassi Brar | bb1c047 | 2010-02-25 11:24:53 +0900 | [diff] [blame] | 470 | config_err: |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 471 | if (machine->ops && machine->ops->shutdown) |
| 472 | machine->ops->shutdown(substream); |
| 473 | |
Jassi Brar | bb1c047 | 2010-02-25 11:24:53 +0900 | [diff] [blame] | 474 | machine_err: |
| 475 | if (codec_dai->ops->shutdown) |
| 476 | codec_dai->ops->shutdown(substream, codec_dai); |
| 477 | |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 478 | codec_dai_err: |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 479 | if (platform->pcm_ops->close) |
| 480 | platform->pcm_ops->close(substream); |
| 481 | |
| 482 | platform_err: |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 483 | if (cpu_dai->ops->shutdown) |
| 484 | cpu_dai->ops->shutdown(substream, cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 485 | out: |
| 486 | mutex_unlock(&pcm_mutex); |
| 487 | return ret; |
| 488 | } |
| 489 | |
| 490 | /* |
Robert P. J. Day | 3a4fa0a | 2007-10-19 23:10:43 +0200 | [diff] [blame] | 491 | * Power down the audio subsystem pmdown_time msecs after close is called. |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 492 | * This is to ensure there are no pops or clicks in between any music tracks |
| 493 | * due to DAPM power cycling. |
| 494 | */ |
Andrew Morton | 4484bb2 | 2006-12-15 09:30:07 +0100 | [diff] [blame] | 495 | static void close_delayed_work(struct work_struct *work) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 496 | { |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 497 | struct snd_soc_card *card = container_of(work, struct snd_soc_card, |
| 498 | delayed_work.work); |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 499 | struct snd_soc_codec *codec = card->codec; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 500 | struct snd_soc_dai *codec_dai; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 501 | int i; |
| 502 | |
| 503 | mutex_lock(&pcm_mutex); |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 504 | for (i = 0; i < codec->num_dai; i++) { |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 505 | codec_dai = &codec->dai[i]; |
| 506 | |
Mark Brown | f24368c | 2008-10-21 21:45:08 +0100 | [diff] [blame] | 507 | pr_debug("pop wq checking: %s status: %s waiting: %s\n", |
| 508 | codec_dai->playback.stream_name, |
| 509 | codec_dai->playback.active ? "active" : "inactive", |
| 510 | codec_dai->pop_wait ? "yes" : "no"); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 511 | |
| 512 | /* are we waiting on this codec DAI stream */ |
| 513 | if (codec_dai->pop_wait == 1) { |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 514 | codec_dai->pop_wait = 0; |
Liam Girdwood | 0b4d221 | 2008-01-10 14:36:20 +0100 | [diff] [blame] | 515 | snd_soc_dapm_stream_event(codec, |
| 516 | codec_dai->playback.stream_name, |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 517 | SND_SOC_DAPM_STREAM_STOP); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 518 | } |
| 519 | } |
| 520 | mutex_unlock(&pcm_mutex); |
| 521 | } |
| 522 | |
| 523 | /* |
| 524 | * Called by ALSA when a PCM substream is closed. Private data can be |
| 525 | * freed here. The cpu DAI, codec DAI, machine and platform are also |
| 526 | * shutdown. |
| 527 | */ |
| 528 | static int soc_codec_close(struct snd_pcm_substream *substream) |
| 529 | { |
| 530 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 531 | struct snd_soc_device *socdev = rtd->socdev; |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 532 | struct snd_soc_card *card = socdev->card; |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 533 | struct snd_soc_dai_link *machine = rtd->dai; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 534 | struct snd_soc_platform *platform = card->platform; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 535 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
| 536 | struct snd_soc_dai *codec_dai = machine->codec_dai; |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 537 | struct snd_soc_codec *codec = card->codec; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 538 | |
| 539 | mutex_lock(&pcm_mutex); |
| 540 | |
Jassi Brar | 14dc573 | 2010-02-26 09:12:32 +0900 | [diff] [blame] | 541 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 542 | cpu_dai->playback.active--; |
| 543 | codec_dai->playback.active--; |
| 544 | } else { |
| 545 | cpu_dai->capture.active--; |
| 546 | codec_dai->capture.active--; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 547 | } |
Jassi Brar | 14dc573 | 2010-02-26 09:12:32 +0900 | [diff] [blame] | 548 | |
| 549 | cpu_dai->active--; |
| 550 | codec_dai->active--; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 551 | codec->active--; |
| 552 | |
Mark Brown | 6010b2d | 2008-09-06 18:33:24 +0100 | [diff] [blame] | 553 | /* Muting the DAC suppresses artifacts caused during digital |
| 554 | * shutdown, for example from stopping clocks. |
| 555 | */ |
| 556 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 557 | snd_soc_dai_digital_mute(codec_dai, 1); |
| 558 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 559 | if (cpu_dai->ops->shutdown) |
| 560 | cpu_dai->ops->shutdown(substream, cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 561 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 562 | if (codec_dai->ops->shutdown) |
| 563 | codec_dai->ops->shutdown(substream, codec_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 564 | |
| 565 | if (machine->ops && machine->ops->shutdown) |
| 566 | machine->ops->shutdown(substream); |
| 567 | |
| 568 | if (platform->pcm_ops->close) |
| 569 | platform->pcm_ops->close(substream); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 570 | |
| 571 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 572 | /* start delayed pop wq here for playback streams */ |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 573 | codec_dai->pop_wait = 1; |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 574 | schedule_delayed_work(&card->delayed_work, |
Mark Brown | 96dd362 | 2010-02-12 11:05:44 +0000 | [diff] [blame] | 575 | msecs_to_jiffies(card->pmdown_time)); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 576 | } else { |
| 577 | /* capture streams can be powered down now */ |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 578 | snd_soc_dapm_stream_event(codec, |
Liam Girdwood | 0b4d221 | 2008-01-10 14:36:20 +0100 | [diff] [blame] | 579 | codec_dai->capture.stream_name, |
| 580 | SND_SOC_DAPM_STREAM_STOP); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | mutex_unlock(&pcm_mutex); |
| 584 | return 0; |
| 585 | } |
| 586 | |
| 587 | /* |
| 588 | * Called by ALSA when the PCM substream is prepared, can set format, sample |
| 589 | * rate, etc. This function is non atomic and can be called multiple times, |
| 590 | * it can refer to the runtime info. |
| 591 | */ |
| 592 | static int soc_pcm_prepare(struct snd_pcm_substream *substream) |
| 593 | { |
| 594 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 595 | struct snd_soc_device *socdev = rtd->socdev; |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 596 | struct snd_soc_card *card = socdev->card; |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 597 | struct snd_soc_dai_link *machine = rtd->dai; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 598 | struct snd_soc_platform *platform = card->platform; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 599 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
| 600 | struct snd_soc_dai *codec_dai = machine->codec_dai; |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 601 | struct snd_soc_codec *codec = card->codec; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 602 | int ret = 0; |
| 603 | |
| 604 | mutex_lock(&pcm_mutex); |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 605 | |
| 606 | if (machine->ops && machine->ops->prepare) { |
| 607 | ret = machine->ops->prepare(substream); |
| 608 | if (ret < 0) { |
| 609 | printk(KERN_ERR "asoc: machine prepare error\n"); |
| 610 | goto out; |
| 611 | } |
| 612 | } |
| 613 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 614 | if (platform->pcm_ops->prepare) { |
| 615 | ret = platform->pcm_ops->prepare(substream); |
Liam Girdwood | a71a468 | 2006-10-19 20:35:56 +0200 | [diff] [blame] | 616 | if (ret < 0) { |
| 617 | printk(KERN_ERR "asoc: platform prepare error\n"); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 618 | goto out; |
Liam Girdwood | a71a468 | 2006-10-19 20:35:56 +0200 | [diff] [blame] | 619 | } |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 620 | } |
| 621 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 622 | if (codec_dai->ops->prepare) { |
| 623 | ret = codec_dai->ops->prepare(substream, codec_dai); |
Liam Girdwood | a71a468 | 2006-10-19 20:35:56 +0200 | [diff] [blame] | 624 | if (ret < 0) { |
| 625 | printk(KERN_ERR "asoc: codec DAI prepare error\n"); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 626 | goto out; |
Liam Girdwood | a71a468 | 2006-10-19 20:35:56 +0200 | [diff] [blame] | 627 | } |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 628 | } |
| 629 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 630 | if (cpu_dai->ops->prepare) { |
| 631 | ret = cpu_dai->ops->prepare(substream, cpu_dai); |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 632 | if (ret < 0) { |
| 633 | printk(KERN_ERR "asoc: cpu DAI prepare error\n"); |
| 634 | goto out; |
| 635 | } |
| 636 | } |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 637 | |
Mark Brown | d45f621 | 2008-10-14 13:58:36 +0100 | [diff] [blame] | 638 | /* cancel any delayed stream shutdown that is pending */ |
| 639 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && |
| 640 | codec_dai->pop_wait) { |
| 641 | codec_dai->pop_wait = 0; |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 642 | cancel_delayed_work(&card->delayed_work); |
Mark Brown | d45f621 | 2008-10-14 13:58:36 +0100 | [diff] [blame] | 643 | } |
| 644 | |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 645 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 646 | snd_soc_dapm_stream_event(codec, |
| 647 | codec_dai->playback.stream_name, |
| 648 | SND_SOC_DAPM_STREAM_START); |
| 649 | else |
| 650 | snd_soc_dapm_stream_event(codec, |
| 651 | codec_dai->capture.stream_name, |
| 652 | SND_SOC_DAPM_STREAM_START); |
Mark Brown | d45f621 | 2008-10-14 13:58:36 +0100 | [diff] [blame] | 653 | |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 654 | snd_soc_dai_digital_mute(codec_dai, 0); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 655 | |
| 656 | out: |
| 657 | mutex_unlock(&pcm_mutex); |
| 658 | return ret; |
| 659 | } |
| 660 | |
| 661 | /* |
| 662 | * Called by ALSA when the hardware params are set by application. This |
| 663 | * function can also be called multiple times and can allocate buffers |
| 664 | * (using snd_pcm_lib_* ). It's non-atomic. |
| 665 | */ |
| 666 | static int soc_pcm_hw_params(struct snd_pcm_substream *substream, |
| 667 | struct snd_pcm_hw_params *params) |
| 668 | { |
| 669 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 670 | struct snd_soc_device *socdev = rtd->socdev; |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 671 | struct snd_soc_dai_link *machine = rtd->dai; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 672 | struct snd_soc_card *card = socdev->card; |
| 673 | struct snd_soc_platform *platform = card->platform; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 674 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
| 675 | struct snd_soc_dai *codec_dai = machine->codec_dai; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 676 | int ret = 0; |
| 677 | |
| 678 | mutex_lock(&pcm_mutex); |
| 679 | |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 680 | if (machine->ops && machine->ops->hw_params) { |
| 681 | ret = machine->ops->hw_params(substream, params); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 682 | if (ret < 0) { |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 683 | printk(KERN_ERR "asoc: machine hw_params failed\n"); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 684 | goto out; |
| 685 | } |
| 686 | } |
| 687 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 688 | if (codec_dai->ops->hw_params) { |
| 689 | ret = codec_dai->ops->hw_params(substream, params, codec_dai); |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 690 | if (ret < 0) { |
| 691 | printk(KERN_ERR "asoc: can't set codec %s hw params\n", |
| 692 | codec_dai->name); |
| 693 | goto codec_err; |
| 694 | } |
| 695 | } |
| 696 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 697 | if (cpu_dai->ops->hw_params) { |
| 698 | ret = cpu_dai->ops->hw_params(substream, params, cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 699 | if (ret < 0) { |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 700 | printk(KERN_ERR "asoc: interface %s hw params failed\n", |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 701 | cpu_dai->name); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 702 | goto interface_err; |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | if (platform->pcm_ops->hw_params) { |
| 707 | ret = platform->pcm_ops->hw_params(substream, params); |
| 708 | if (ret < 0) { |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 709 | printk(KERN_ERR "asoc: platform %s hw params failed\n", |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 710 | platform->name); |
| 711 | goto platform_err; |
| 712 | } |
| 713 | } |
| 714 | |
Mark Brown | 06f409d | 2009-04-07 18:10:13 +0100 | [diff] [blame] | 715 | machine->rate = params_rate(params); |
| 716 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 717 | out: |
| 718 | mutex_unlock(&pcm_mutex); |
| 719 | return ret; |
| 720 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 721 | platform_err: |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 722 | if (cpu_dai->ops->hw_free) |
| 723 | cpu_dai->ops->hw_free(substream, cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 724 | |
| 725 | interface_err: |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 726 | if (codec_dai->ops->hw_free) |
| 727 | codec_dai->ops->hw_free(substream, codec_dai); |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 728 | |
| 729 | codec_err: |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 730 | if (machine->ops && machine->ops->hw_free) |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 731 | machine->ops->hw_free(substream); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 732 | |
| 733 | mutex_unlock(&pcm_mutex); |
| 734 | return ret; |
| 735 | } |
| 736 | |
| 737 | /* |
| 738 | * Free's resources allocated by hw_params, can be called multiple times |
| 739 | */ |
| 740 | static int soc_pcm_hw_free(struct snd_pcm_substream *substream) |
| 741 | { |
| 742 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 743 | struct snd_soc_device *socdev = rtd->socdev; |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 744 | struct snd_soc_dai_link *machine = rtd->dai; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 745 | struct snd_soc_card *card = socdev->card; |
| 746 | struct snd_soc_platform *platform = card->platform; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 747 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
| 748 | struct snd_soc_dai *codec_dai = machine->codec_dai; |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 749 | struct snd_soc_codec *codec = card->codec; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 750 | |
| 751 | mutex_lock(&pcm_mutex); |
| 752 | |
| 753 | /* apply codec digital mute */ |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 754 | if (!codec->active) |
| 755 | snd_soc_dai_digital_mute(codec_dai, 1); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 756 | |
| 757 | /* free any machine hw params */ |
| 758 | if (machine->ops && machine->ops->hw_free) |
| 759 | machine->ops->hw_free(substream); |
| 760 | |
| 761 | /* free any DMA resources */ |
| 762 | if (platform->pcm_ops->hw_free) |
| 763 | platform->pcm_ops->hw_free(substream); |
| 764 | |
| 765 | /* now free hw params for the DAI's */ |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 766 | if (codec_dai->ops->hw_free) |
| 767 | codec_dai->ops->hw_free(substream, codec_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 768 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 769 | if (cpu_dai->ops->hw_free) |
| 770 | cpu_dai->ops->hw_free(substream, cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 771 | |
| 772 | mutex_unlock(&pcm_mutex); |
| 773 | return 0; |
| 774 | } |
| 775 | |
| 776 | static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
| 777 | { |
| 778 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 779 | struct snd_soc_device *socdev = rtd->socdev; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 780 | struct snd_soc_card *card= socdev->card; |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 781 | struct snd_soc_dai_link *machine = rtd->dai; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 782 | struct snd_soc_platform *platform = card->platform; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 783 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
| 784 | struct snd_soc_dai *codec_dai = machine->codec_dai; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 785 | int ret; |
| 786 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 787 | if (codec_dai->ops->trigger) { |
| 788 | ret = codec_dai->ops->trigger(substream, cmd, codec_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 789 | if (ret < 0) |
| 790 | return ret; |
| 791 | } |
| 792 | |
| 793 | if (platform->pcm_ops->trigger) { |
| 794 | ret = platform->pcm_ops->trigger(substream, cmd); |
| 795 | if (ret < 0) |
| 796 | return ret; |
| 797 | } |
| 798 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 799 | if (cpu_dai->ops->trigger) { |
| 800 | ret = cpu_dai->ops->trigger(substream, cmd, cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 801 | if (ret < 0) |
| 802 | return ret; |
| 803 | } |
| 804 | return 0; |
| 805 | } |
| 806 | |
Peter Ujfalusi | 377b6f6 | 2010-03-03 15:08:06 +0200 | [diff] [blame] | 807 | /* |
| 808 | * soc level wrapper for pointer callback |
Peter Ujfalusi | 258020d | 2010-03-03 15:08:07 +0200 | [diff] [blame] | 809 | * If cpu_dai, codec_dai, platform driver has the delay callback, than |
| 810 | * the runtime->delay will be updated accordingly. |
Peter Ujfalusi | 377b6f6 | 2010-03-03 15:08:06 +0200 | [diff] [blame] | 811 | */ |
| 812 | static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) |
| 813 | { |
| 814 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 815 | struct snd_soc_device *socdev = rtd->socdev; |
| 816 | struct snd_soc_card *card = socdev->card; |
| 817 | struct snd_soc_platform *platform = card->platform; |
Peter Ujfalusi | 258020d | 2010-03-03 15:08:07 +0200 | [diff] [blame] | 818 | struct snd_soc_dai_link *machine = rtd->dai; |
| 819 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; |
| 820 | struct snd_soc_dai *codec_dai = machine->codec_dai; |
| 821 | struct snd_pcm_runtime *runtime = substream->runtime; |
Peter Ujfalusi | 377b6f6 | 2010-03-03 15:08:06 +0200 | [diff] [blame] | 822 | snd_pcm_uframes_t offset = 0; |
Peter Ujfalusi | 258020d | 2010-03-03 15:08:07 +0200 | [diff] [blame] | 823 | snd_pcm_sframes_t delay = 0; |
Peter Ujfalusi | 377b6f6 | 2010-03-03 15:08:06 +0200 | [diff] [blame] | 824 | |
| 825 | if (platform->pcm_ops->pointer) |
| 826 | offset = platform->pcm_ops->pointer(substream); |
| 827 | |
Peter Ujfalusi | 258020d | 2010-03-03 15:08:07 +0200 | [diff] [blame] | 828 | if (cpu_dai->ops->delay) |
| 829 | delay += cpu_dai->ops->delay(substream, cpu_dai); |
| 830 | |
| 831 | if (codec_dai->ops->delay) |
| 832 | delay += codec_dai->ops->delay(substream, codec_dai); |
| 833 | |
| 834 | if (platform->delay) |
| 835 | delay += platform->delay(substream, codec_dai); |
| 836 | |
| 837 | runtime->delay = delay; |
| 838 | |
Peter Ujfalusi | 377b6f6 | 2010-03-03 15:08:06 +0200 | [diff] [blame] | 839 | return offset; |
| 840 | } |
| 841 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 842 | /* ASoC PCM operations */ |
| 843 | static struct snd_pcm_ops soc_pcm_ops = { |
| 844 | .open = soc_pcm_open, |
| 845 | .close = soc_codec_close, |
| 846 | .hw_params = soc_pcm_hw_params, |
| 847 | .hw_free = soc_pcm_hw_free, |
| 848 | .prepare = soc_pcm_prepare, |
| 849 | .trigger = soc_pcm_trigger, |
Peter Ujfalusi | 377b6f6 | 2010-03-03 15:08:06 +0200 | [diff] [blame] | 850 | .pointer = soc_pcm_pointer, |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 851 | }; |
| 852 | |
| 853 | #ifdef CONFIG_PM |
| 854 | /* powers down audio subsystem for suspend */ |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 855 | static int soc_suspend(struct device *dev) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 856 | { |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 857 | struct platform_device *pdev = to_platform_device(dev); |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 858 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 859 | struct snd_soc_card *card = socdev->card; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 860 | struct snd_soc_platform *platform = card->platform; |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 861 | struct snd_soc_codec_device *codec_dev = socdev->codec_dev; |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 862 | struct snd_soc_codec *codec = card->codec; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 863 | int i; |
| 864 | |
Daniel Mack | e3509ff | 2009-06-03 17:44:49 +0200 | [diff] [blame] | 865 | /* If the initialization of this soc device failed, there is no codec |
| 866 | * associated with it. Just bail out in this case. |
| 867 | */ |
| 868 | if (!codec) |
| 869 | return 0; |
| 870 | |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 871 | /* Due to the resume being scheduled into a workqueue we could |
| 872 | * suspend before that's finished - wait for it to complete. |
| 873 | */ |
| 874 | snd_power_lock(codec->card); |
| 875 | snd_power_wait(codec->card, SNDRV_CTL_POWER_D0); |
| 876 | snd_power_unlock(codec->card); |
| 877 | |
| 878 | /* we're going to block userspace touching us until resume completes */ |
| 879 | snd_power_change_state(codec->card, SNDRV_CTL_POWER_D3hot); |
| 880 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 881 | /* mute any active DAC's */ |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 882 | for (i = 0; i < card->num_links; i++) { |
| 883 | struct snd_soc_dai *dai = card->dai_link[i].codec_dai; |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 884 | if (dai->ops->digital_mute && dai->playback.active) |
| 885 | dai->ops->digital_mute(dai, 1); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 886 | } |
| 887 | |
Liam Girdwood | 4ccab3e | 2008-01-10 14:39:01 +0100 | [diff] [blame] | 888 | /* suspend all pcms */ |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 889 | for (i = 0; i < card->num_links; i++) |
| 890 | snd_pcm_suspend_all(card->dai_link[i].pcm); |
Liam Girdwood | 4ccab3e | 2008-01-10 14:39:01 +0100 | [diff] [blame] | 891 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 892 | if (card->suspend_pre) |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 893 | card->suspend_pre(pdev, PMSG_SUSPEND); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 894 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 895 | for (i = 0; i < card->num_links; i++) { |
| 896 | struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai; |
Mark Brown | 3ba9e10a | 2008-11-24 18:01:05 +0000 | [diff] [blame] | 897 | if (cpu_dai->suspend && !cpu_dai->ac97_control) |
Mark Brown | dc7d7b8 | 2008-12-03 18:21:52 +0000 | [diff] [blame] | 898 | cpu_dai->suspend(cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 899 | if (platform->suspend) |
jassi brar | d273ebe | 2010-02-22 15:58:04 +0900 | [diff] [blame] | 900 | platform->suspend(&card->dai_link[i]); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | /* close any waiting streams and save state */ |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 904 | run_delayed_work(&card->delayed_work); |
Mark Brown | 0be9898 | 2008-05-19 12:31:28 +0200 | [diff] [blame] | 905 | codec->suspend_bias_level = codec->bias_level; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 906 | |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 907 | for (i = 0; i < codec->num_dai; i++) { |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 908 | char *stream = codec->dai[i].playback.stream_name; |
| 909 | if (stream != NULL) |
| 910 | snd_soc_dapm_stream_event(codec, stream, |
| 911 | SND_SOC_DAPM_STREAM_SUSPEND); |
| 912 | stream = codec->dai[i].capture.stream_name; |
| 913 | if (stream != NULL) |
| 914 | snd_soc_dapm_stream_event(codec, stream, |
| 915 | SND_SOC_DAPM_STREAM_SUSPEND); |
| 916 | } |
| 917 | |
| 918 | if (codec_dev->suspend) |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 919 | codec_dev->suspend(pdev, PMSG_SUSPEND); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 920 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 921 | for (i = 0; i < card->num_links; i++) { |
| 922 | struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai; |
Mark Brown | 3ba9e10a | 2008-11-24 18:01:05 +0000 | [diff] [blame] | 923 | if (cpu_dai->suspend && cpu_dai->ac97_control) |
Mark Brown | dc7d7b8 | 2008-12-03 18:21:52 +0000 | [diff] [blame] | 924 | cpu_dai->suspend(cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 925 | } |
| 926 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 927 | if (card->suspend_post) |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 928 | card->suspend_post(pdev, PMSG_SUSPEND); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 929 | |
| 930 | return 0; |
| 931 | } |
| 932 | |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 933 | /* deferred resume work, so resume can complete before we finished |
| 934 | * setting our codec back up, which can be very slow on I2C |
| 935 | */ |
| 936 | static void soc_resume_deferred(struct work_struct *work) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 937 | { |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 938 | struct snd_soc_card *card = container_of(work, |
| 939 | struct snd_soc_card, |
| 940 | deferred_resume_work); |
| 941 | struct snd_soc_device *socdev = card->socdev; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 942 | struct snd_soc_platform *platform = card->platform; |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 943 | struct snd_soc_codec_device *codec_dev = socdev->codec_dev; |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 944 | struct snd_soc_codec *codec = card->codec; |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 945 | struct platform_device *pdev = to_platform_device(socdev->dev); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 946 | int i; |
| 947 | |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 948 | /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time, |
| 949 | * so userspace apps are blocked from touching us |
| 950 | */ |
| 951 | |
Mark Brown | fde22f2 | 2008-11-24 18:08:18 +0000 | [diff] [blame] | 952 | dev_dbg(socdev->dev, "starting resume work\n"); |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 953 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 954 | if (card->resume_pre) |
| 955 | card->resume_pre(pdev); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 956 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 957 | for (i = 0; i < card->num_links; i++) { |
| 958 | struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai; |
Mark Brown | 3ba9e10a | 2008-11-24 18:01:05 +0000 | [diff] [blame] | 959 | if (cpu_dai->resume && cpu_dai->ac97_control) |
Mark Brown | dc7d7b8 | 2008-12-03 18:21:52 +0000 | [diff] [blame] | 960 | cpu_dai->resume(cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | if (codec_dev->resume) |
| 964 | codec_dev->resume(pdev); |
| 965 | |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 966 | for (i = 0; i < codec->num_dai; i++) { |
| 967 | char *stream = codec->dai[i].playback.stream_name; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 968 | if (stream != NULL) |
| 969 | snd_soc_dapm_stream_event(codec, stream, |
| 970 | SND_SOC_DAPM_STREAM_RESUME); |
| 971 | stream = codec->dai[i].capture.stream_name; |
| 972 | if (stream != NULL) |
| 973 | snd_soc_dapm_stream_event(codec, stream, |
| 974 | SND_SOC_DAPM_STREAM_RESUME); |
| 975 | } |
| 976 | |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 977 | /* unmute any active DACs */ |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 978 | for (i = 0; i < card->num_links; i++) { |
| 979 | struct snd_soc_dai *dai = card->dai_link[i].codec_dai; |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 980 | if (dai->ops->digital_mute && dai->playback.active) |
| 981 | dai->ops->digital_mute(dai, 0); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 982 | } |
| 983 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 984 | for (i = 0; i < card->num_links; i++) { |
| 985 | struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai; |
Mark Brown | 3ba9e10a | 2008-11-24 18:01:05 +0000 | [diff] [blame] | 986 | if (cpu_dai->resume && !cpu_dai->ac97_control) |
Mark Brown | dc7d7b8 | 2008-12-03 18:21:52 +0000 | [diff] [blame] | 987 | cpu_dai->resume(cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 988 | if (platform->resume) |
jassi brar | d273ebe | 2010-02-22 15:58:04 +0900 | [diff] [blame] | 989 | platform->resume(&card->dai_link[i]); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 990 | } |
| 991 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 992 | if (card->resume_post) |
| 993 | card->resume_post(pdev); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 994 | |
Mark Brown | fde22f2 | 2008-11-24 18:08:18 +0000 | [diff] [blame] | 995 | dev_dbg(socdev->dev, "resume work completed\n"); |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 996 | |
| 997 | /* userspace can access us now we are back as we were before */ |
| 998 | snd_power_change_state(codec->card, SNDRV_CTL_POWER_D0); |
| 999 | } |
| 1000 | |
| 1001 | /* powers up audio subsystem after a suspend */ |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 1002 | static int soc_resume(struct device *dev) |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 1003 | { |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 1004 | struct platform_device *pdev = to_platform_device(dev); |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 1005 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 1006 | struct snd_soc_card *card = socdev->card; |
Mark Brown | 64ab9ba | 2009-03-31 11:27:03 +0100 | [diff] [blame] | 1007 | struct snd_soc_dai *cpu_dai = card->dai_link[0].cpu_dai; |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 1008 | |
Peter Ujfalusi | b9dd94a | 2010-02-22 13:27:13 +0200 | [diff] [blame] | 1009 | /* If the initialization of this soc device failed, there is no codec |
| 1010 | * associated with it. Just bail out in this case. |
| 1011 | */ |
| 1012 | if (!card->codec) |
| 1013 | return 0; |
| 1014 | |
Mark Brown | 64ab9ba | 2009-03-31 11:27:03 +0100 | [diff] [blame] | 1015 | /* AC97 devices might have other drivers hanging off them so |
| 1016 | * need to resume immediately. Other drivers don't have that |
| 1017 | * problem and may take a substantial amount of time to resume |
| 1018 | * due to I/O costs and anti-pop so handle them out of line. |
| 1019 | */ |
| 1020 | if (cpu_dai->ac97_control) { |
| 1021 | dev_dbg(socdev->dev, "Resuming AC97 immediately\n"); |
| 1022 | soc_resume_deferred(&card->deferred_resume_work); |
| 1023 | } else { |
| 1024 | dev_dbg(socdev->dev, "Scheduling resume work\n"); |
| 1025 | if (!schedule_work(&card->deferred_resume_work)) |
| 1026 | dev_err(socdev->dev, "resume work item may be lost\n"); |
| 1027 | } |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 1028 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1029 | return 0; |
| 1030 | } |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1031 | #else |
| 1032 | #define soc_suspend NULL |
| 1033 | #define soc_resume NULL |
| 1034 | #endif |
| 1035 | |
Barry Song | 02a06d3 | 2009-10-16 18:13:38 +0800 | [diff] [blame] | 1036 | static struct snd_soc_dai_ops null_dai_ops = { |
| 1037 | }; |
| 1038 | |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1039 | static void snd_soc_instantiate_card(struct snd_soc_card *card) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1040 | { |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1041 | struct platform_device *pdev = container_of(card->dev, |
| 1042 | struct platform_device, |
| 1043 | dev); |
| 1044 | struct snd_soc_codec_device *codec_dev = card->socdev->codec_dev; |
Mark Brown | fe3e78e | 2009-11-03 22:13:13 +0000 | [diff] [blame] | 1045 | struct snd_soc_codec *codec; |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1046 | struct snd_soc_platform *platform; |
| 1047 | struct snd_soc_dai *dai; |
Mark Brown | 6b05eda | 2008-12-08 19:26:48 +0000 | [diff] [blame] | 1048 | int i, found, ret, ac97; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1049 | |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1050 | if (card->instantiated) |
| 1051 | return; |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 1052 | |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1053 | found = 0; |
| 1054 | list_for_each_entry(platform, &platform_list, list) |
| 1055 | if (card->platform == platform) { |
| 1056 | found = 1; |
| 1057 | break; |
| 1058 | } |
| 1059 | if (!found) { |
| 1060 | dev_dbg(card->dev, "Platform %s not registered\n", |
| 1061 | card->platform->name); |
| 1062 | return; |
Mark Brown | c5af3a2 | 2008-11-28 13:29:45 +0000 | [diff] [blame] | 1063 | } |
| 1064 | |
Mark Brown | 6b05eda | 2008-12-08 19:26:48 +0000 | [diff] [blame] | 1065 | ac97 = 0; |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1066 | for (i = 0; i < card->num_links; i++) { |
| 1067 | found = 0; |
| 1068 | list_for_each_entry(dai, &dai_list, list) |
| 1069 | if (card->dai_link[i].cpu_dai == dai) { |
| 1070 | found = 1; |
| 1071 | break; |
| 1072 | } |
| 1073 | if (!found) { |
| 1074 | dev_dbg(card->dev, "DAI %s not registered\n", |
| 1075 | card->dai_link[i].cpu_dai->name); |
| 1076 | return; |
| 1077 | } |
Mark Brown | 6b05eda | 2008-12-08 19:26:48 +0000 | [diff] [blame] | 1078 | |
| 1079 | if (card->dai_link[i].cpu_dai->ac97_control) |
| 1080 | ac97 = 1; |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1081 | } |
| 1082 | |
Barry Song | 02a06d3 | 2009-10-16 18:13:38 +0800 | [diff] [blame] | 1083 | for (i = 0; i < card->num_links; i++) { |
| 1084 | if (!card->dai_link[i].codec_dai->ops) |
| 1085 | card->dai_link[i].codec_dai->ops = &null_dai_ops; |
| 1086 | } |
| 1087 | |
Mark Brown | 6b05eda | 2008-12-08 19:26:48 +0000 | [diff] [blame] | 1088 | /* If we have AC97 in the system then don't wait for the |
| 1089 | * codec. This will need revisiting if we have to handle |
| 1090 | * systems with mixed AC97 and non-AC97 parts. Only check for |
| 1091 | * DAIs currently; we can't do this per link since some AC97 |
| 1092 | * codecs have non-AC97 DAIs. |
| 1093 | */ |
| 1094 | if (!ac97) |
| 1095 | for (i = 0; i < card->num_links; i++) { |
| 1096 | found = 0; |
| 1097 | list_for_each_entry(dai, &dai_list, list) |
| 1098 | if (card->dai_link[i].codec_dai == dai) { |
| 1099 | found = 1; |
| 1100 | break; |
| 1101 | } |
| 1102 | if (!found) { |
| 1103 | dev_dbg(card->dev, "DAI %s not registered\n", |
| 1104 | card->dai_link[i].codec_dai->name); |
| 1105 | return; |
| 1106 | } |
| 1107 | } |
| 1108 | |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1109 | /* Note that we do not current check for codec components */ |
| 1110 | |
| 1111 | dev_dbg(card->dev, "All components present, instantiating\n"); |
| 1112 | |
| 1113 | /* Found everything, bring it up */ |
Mark Brown | 96dd362 | 2010-02-12 11:05:44 +0000 | [diff] [blame] | 1114 | card->pmdown_time = pmdown_time; |
| 1115 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 1116 | if (card->probe) { |
| 1117 | ret = card->probe(pdev); |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 1118 | if (ret < 0) |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1119 | return; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1120 | } |
| 1121 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 1122 | for (i = 0; i < card->num_links; i++) { |
| 1123 | struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1124 | if (cpu_dai->probe) { |
Mark Brown | bdb9287 | 2008-06-11 13:47:10 +0100 | [diff] [blame] | 1125 | ret = cpu_dai->probe(pdev, cpu_dai); |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 1126 | if (ret < 0) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1127 | goto cpu_dai_err; |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | if (codec_dev->probe) { |
| 1132 | ret = codec_dev->probe(pdev); |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 1133 | if (ret < 0) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1134 | goto cpu_dai_err; |
| 1135 | } |
Mark Brown | fe3e78e | 2009-11-03 22:13:13 +0000 | [diff] [blame] | 1136 | codec = card->codec; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1137 | |
| 1138 | if (platform->probe) { |
| 1139 | ret = platform->probe(pdev); |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 1140 | if (ret < 0) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1141 | goto platform_err; |
| 1142 | } |
| 1143 | |
| 1144 | /* DAPM stream work */ |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 1145 | INIT_DELAYED_WORK(&card->delayed_work, close_delayed_work); |
Randy Dunlap | 1301a96 | 2008-06-17 19:19:34 +0100 | [diff] [blame] | 1146 | #ifdef CONFIG_PM |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 1147 | /* deferred resume work */ |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 1148 | INIT_WORK(&card->deferred_resume_work, soc_resume_deferred); |
Randy Dunlap | 1301a96 | 2008-06-17 19:19:34 +0100 | [diff] [blame] | 1149 | #endif |
Andy Green | 6ed2597 | 2008-06-13 16:24:05 +0100 | [diff] [blame] | 1150 | |
Mark Brown | fe3e78e | 2009-11-03 22:13:13 +0000 | [diff] [blame] | 1151 | for (i = 0; i < card->num_links; i++) { |
| 1152 | if (card->dai_link[i].init) { |
| 1153 | ret = card->dai_link[i].init(codec); |
| 1154 | if (ret < 0) { |
| 1155 | printk(KERN_ERR "asoc: failed to init %s\n", |
| 1156 | card->dai_link[i].stream_name); |
| 1157 | continue; |
| 1158 | } |
| 1159 | } |
Barry Song | f773205 | 2009-11-12 12:01:47 +0800 | [diff] [blame] | 1160 | if (card->dai_link[i].codec_dai->ac97_control) |
Mark Brown | fe3e78e | 2009-11-03 22:13:13 +0000 | [diff] [blame] | 1161 | ac97 = 1; |
Mark Brown | fe3e78e | 2009-11-03 22:13:13 +0000 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | snprintf(codec->card->shortname, sizeof(codec->card->shortname), |
| 1165 | "%s", card->name); |
| 1166 | snprintf(codec->card->longname, sizeof(codec->card->longname), |
| 1167 | "%s (%s)", card->name, codec->name); |
| 1168 | |
| 1169 | /* Make sure all DAPM widgets are instantiated */ |
| 1170 | snd_soc_dapm_new_widgets(codec); |
| 1171 | |
| 1172 | ret = snd_card_register(codec->card); |
| 1173 | if (ret < 0) { |
| 1174 | printk(KERN_ERR "asoc: failed to register soundcard for %s\n", |
| 1175 | codec->name); |
| 1176 | goto card_err; |
| 1177 | } |
| 1178 | |
| 1179 | mutex_lock(&codec->mutex); |
| 1180 | #ifdef CONFIG_SND_SOC_AC97_BUS |
| 1181 | /* Only instantiate AC97 if not already done by the adaptor |
| 1182 | * for the generic AC97 subsystem. |
| 1183 | */ |
| 1184 | if (ac97 && strcmp(codec->name, "AC97") != 0) { |
| 1185 | ret = soc_ac97_dev_register(codec); |
| 1186 | if (ret < 0) { |
| 1187 | printk(KERN_ERR "asoc: AC97 device register failed\n"); |
| 1188 | snd_card_free(codec->card); |
| 1189 | mutex_unlock(&codec->mutex); |
| 1190 | goto card_err; |
| 1191 | } |
| 1192 | } |
| 1193 | #endif |
| 1194 | |
| 1195 | ret = snd_soc_dapm_sys_add(card->socdev->dev); |
| 1196 | if (ret < 0) |
| 1197 | printk(KERN_WARNING "asoc: failed to add dapm sysfs entries\n"); |
| 1198 | |
Mark Brown | dbe2140 | 2010-02-12 11:37:24 +0000 | [diff] [blame] | 1199 | ret = device_create_file(card->socdev->dev, &dev_attr_pmdown_time); |
| 1200 | if (ret < 0) |
| 1201 | printk(KERN_WARNING "asoc: failed to add pmdown_time sysfs\n"); |
| 1202 | |
Mark Brown | fe3e78e | 2009-11-03 22:13:13 +0000 | [diff] [blame] | 1203 | ret = device_create_file(card->socdev->dev, &dev_attr_codec_reg); |
| 1204 | if (ret < 0) |
| 1205 | printk(KERN_WARNING "asoc: failed to add codec sysfs files\n"); |
| 1206 | |
| 1207 | soc_init_codec_debugfs(codec); |
| 1208 | mutex_unlock(&codec->mutex); |
| 1209 | |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1210 | card->instantiated = 1; |
| 1211 | |
| 1212 | return; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1213 | |
Mark Brown | fe3e78e | 2009-11-03 22:13:13 +0000 | [diff] [blame] | 1214 | card_err: |
| 1215 | if (platform->remove) |
| 1216 | platform->remove(pdev); |
| 1217 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1218 | platform_err: |
| 1219 | if (codec_dev->remove) |
| 1220 | codec_dev->remove(pdev); |
| 1221 | |
| 1222 | cpu_dai_err: |
Liam Girdwood | 18b9b3d | 2007-01-30 17:18:45 +0100 | [diff] [blame] | 1223 | for (i--; i >= 0; i--) { |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 1224 | struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1225 | if (cpu_dai->remove) |
Mark Brown | bdb9287 | 2008-06-11 13:47:10 +0100 | [diff] [blame] | 1226 | cpu_dai->remove(pdev, cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1227 | } |
| 1228 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 1229 | if (card->remove) |
| 1230 | card->remove(pdev); |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1231 | } |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1232 | |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 1233 | /* |
| 1234 | * Attempt to initialise any uninitalised cards. Must be called with |
| 1235 | * client_mutex. |
| 1236 | */ |
| 1237 | static void snd_soc_instantiate_cards(void) |
| 1238 | { |
| 1239 | struct snd_soc_card *card; |
| 1240 | list_for_each_entry(card, &card_list, list) |
| 1241 | snd_soc_instantiate_card(card); |
| 1242 | } |
| 1243 | |
| 1244 | /* probes a new socdev */ |
| 1245 | static int soc_probe(struct platform_device *pdev) |
| 1246 | { |
| 1247 | int ret = 0; |
| 1248 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
| 1249 | struct snd_soc_card *card = socdev->card; |
| 1250 | |
| 1251 | /* Bodge while we push things out of socdev */ |
| 1252 | card->socdev = socdev; |
| 1253 | |
| 1254 | /* Bodge while we unpick instantiation */ |
| 1255 | card->dev = &pdev->dev; |
| 1256 | ret = snd_soc_register_card(card); |
| 1257 | if (ret != 0) { |
| 1258 | dev_err(&pdev->dev, "Failed to register card\n"); |
| 1259 | return ret; |
| 1260 | } |
| 1261 | |
| 1262 | return 0; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | /* removes a socdev */ |
| 1266 | static int soc_remove(struct platform_device *pdev) |
| 1267 | { |
| 1268 | int i; |
| 1269 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 1270 | struct snd_soc_card *card = socdev->card; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 1271 | struct snd_soc_platform *platform = card->platform; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1272 | struct snd_soc_codec_device *codec_dev = socdev->codec_dev; |
| 1273 | |
Mike Rapoport | 914dc18 | 2009-05-11 13:04:55 +0300 | [diff] [blame] | 1274 | if (!card->instantiated) |
| 1275 | return 0; |
| 1276 | |
Mark Brown | 6308419 | 2008-12-02 15:08:03 +0000 | [diff] [blame] | 1277 | run_delayed_work(&card->delayed_work); |
Liam Girdwood | 965ac42 | 2007-01-31 14:14:57 +0100 | [diff] [blame] | 1278 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1279 | if (platform->remove) |
| 1280 | platform->remove(pdev); |
| 1281 | |
| 1282 | if (codec_dev->remove) |
| 1283 | codec_dev->remove(pdev); |
| 1284 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 1285 | for (i = 0; i < card->num_links; i++) { |
| 1286 | struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1287 | if (cpu_dai->remove) |
Mark Brown | bdb9287 | 2008-06-11 13:47:10 +0100 | [diff] [blame] | 1288 | cpu_dai->remove(pdev, cpu_dai); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1289 | } |
| 1290 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 1291 | if (card->remove) |
| 1292 | card->remove(pdev); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1293 | |
Mark Brown | c5af3a2 | 2008-11-28 13:29:45 +0000 | [diff] [blame] | 1294 | snd_soc_unregister_card(card); |
| 1295 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1296 | return 0; |
| 1297 | } |
| 1298 | |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 1299 | static int soc_poweroff(struct device *dev) |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 1300 | { |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 1301 | struct platform_device *pdev = to_platform_device(dev); |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 1302 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
| 1303 | struct snd_soc_card *card = socdev->card; |
| 1304 | |
| 1305 | if (!card->instantiated) |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 1306 | return 0; |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 1307 | |
| 1308 | /* Flush out pmdown_time work - we actually do want to run it |
| 1309 | * now, we're shutting down so no imminent restart. */ |
| 1310 | run_delayed_work(&card->delayed_work); |
| 1311 | |
| 1312 | snd_soc_dapm_shutdown(socdev); |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 1313 | |
| 1314 | return 0; |
Mark Brown | 5173747 | 2009-06-22 13:16:51 +0100 | [diff] [blame] | 1315 | } |
| 1316 | |
Alexey Dobriyan | 4714521 | 2009-12-14 18:00:08 -0800 | [diff] [blame] | 1317 | static const struct dev_pm_ops soc_pm_ops = { |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 1318 | .suspend = soc_suspend, |
| 1319 | .resume = soc_resume, |
| 1320 | .poweroff = soc_poweroff, |
| 1321 | }; |
| 1322 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1323 | /* ASoC platform driver */ |
| 1324 | static struct platform_driver soc_driver = { |
| 1325 | .driver = { |
| 1326 | .name = "soc-audio", |
Kay Sievers | 8b45a20 | 2008-04-14 13:33:36 +0200 | [diff] [blame] | 1327 | .owner = THIS_MODULE, |
Mark Brown | 416356f | 2009-06-30 19:05:15 +0100 | [diff] [blame] | 1328 | .pm = &soc_pm_ops, |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1329 | }, |
| 1330 | .probe = soc_probe, |
| 1331 | .remove = soc_remove, |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1332 | }; |
| 1333 | |
| 1334 | /* create a new pcm */ |
| 1335 | static int soc_new_pcm(struct snd_soc_device *socdev, |
| 1336 | struct snd_soc_dai_link *dai_link, int num) |
| 1337 | { |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 1338 | struct snd_soc_card *card = socdev->card; |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 1339 | struct snd_soc_codec *codec = card->codec; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 1340 | struct snd_soc_platform *platform = card->platform; |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 1341 | struct snd_soc_dai *codec_dai = dai_link->codec_dai; |
| 1342 | struct snd_soc_dai *cpu_dai = dai_link->cpu_dai; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1343 | struct snd_soc_pcm_runtime *rtd; |
| 1344 | struct snd_pcm *pcm; |
| 1345 | char new_name[64]; |
| 1346 | int ret = 0, playback = 0, capture = 0; |
| 1347 | |
| 1348 | rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL); |
| 1349 | if (rtd == NULL) |
| 1350 | return -ENOMEM; |
Liam Girdwood | cb666e5 | 2007-02-02 17:13:49 +0100 | [diff] [blame] | 1351 | |
| 1352 | rtd->dai = dai_link; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1353 | rtd->socdev = socdev; |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 1354 | codec_dai->codec = card->codec; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1355 | |
| 1356 | /* check client and interface hw capabilities */ |
Mark Brown | 40ca114 | 2009-12-24 13:44:28 +0000 | [diff] [blame] | 1357 | snprintf(new_name, sizeof(new_name), "%s %s-%d", |
| 1358 | dai_link->stream_name, codec_dai->name, num); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1359 | |
| 1360 | if (codec_dai->playback.channels_min) |
| 1361 | playback = 1; |
| 1362 | if (codec_dai->capture.channels_min) |
| 1363 | capture = 1; |
| 1364 | |
| 1365 | ret = snd_pcm_new(codec->card, new_name, codec->pcm_devs++, playback, |
| 1366 | capture, &pcm); |
| 1367 | if (ret < 0) { |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 1368 | printk(KERN_ERR "asoc: can't create pcm for codec %s\n", |
| 1369 | codec->name); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1370 | kfree(rtd); |
| 1371 | return ret; |
| 1372 | } |
| 1373 | |
Liam Girdwood | 4ccab3e | 2008-01-10 14:39:01 +0100 | [diff] [blame] | 1374 | dai_link->pcm = pcm; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1375 | pcm->private_data = rtd; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 1376 | soc_pcm_ops.mmap = platform->pcm_ops->mmap; |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 1377 | soc_pcm_ops.ioctl = platform->pcm_ops->ioctl; |
| 1378 | soc_pcm_ops.copy = platform->pcm_ops->copy; |
| 1379 | soc_pcm_ops.silence = platform->pcm_ops->silence; |
| 1380 | soc_pcm_ops.ack = platform->pcm_ops->ack; |
| 1381 | soc_pcm_ops.page = platform->pcm_ops->page; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1382 | |
| 1383 | if (playback) |
| 1384 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops); |
| 1385 | |
| 1386 | if (capture) |
| 1387 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops); |
| 1388 | |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 1389 | ret = platform->pcm_new(codec->card, codec_dai, pcm); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1390 | if (ret < 0) { |
| 1391 | printk(KERN_ERR "asoc: platform pcm constructor failed\n"); |
| 1392 | kfree(rtd); |
| 1393 | return ret; |
| 1394 | } |
| 1395 | |
Mark Brown | 87689d5 | 2008-12-02 16:01:14 +0000 | [diff] [blame] | 1396 | pcm->private_free = platform->pcm_free; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1397 | printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name, |
| 1398 | cpu_dai->name); |
| 1399 | return ret; |
| 1400 | } |
| 1401 | |
Mark Brown | 096e49d | 2009-07-05 15:12:22 +0100 | [diff] [blame] | 1402 | /** |
| 1403 | * snd_soc_codec_volatile_register: Report if a register is volatile. |
| 1404 | * |
| 1405 | * @codec: CODEC to query. |
| 1406 | * @reg: Register to query. |
| 1407 | * |
| 1408 | * Boolean function indiciating if a CODEC register is volatile. |
| 1409 | */ |
| 1410 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg) |
| 1411 | { |
| 1412 | if (codec->volatile_register) |
| 1413 | return codec->volatile_register(reg); |
| 1414 | else |
| 1415 | return 0; |
| 1416 | } |
| 1417 | EXPORT_SYMBOL_GPL(snd_soc_codec_volatile_register); |
| 1418 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1419 | /** |
| 1420 | * snd_soc_new_ac97_codec - initailise AC97 device |
| 1421 | * @codec: audio codec |
| 1422 | * @ops: AC97 bus operations |
| 1423 | * @num: AC97 codec number |
| 1424 | * |
| 1425 | * Initialises AC97 codec resources for use by ad-hoc devices only. |
| 1426 | */ |
| 1427 | int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, |
| 1428 | struct snd_ac97_bus_ops *ops, int num) |
| 1429 | { |
| 1430 | mutex_lock(&codec->mutex); |
| 1431 | |
| 1432 | codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); |
| 1433 | if (codec->ac97 == NULL) { |
| 1434 | mutex_unlock(&codec->mutex); |
| 1435 | return -ENOMEM; |
| 1436 | } |
| 1437 | |
| 1438 | codec->ac97->bus = kzalloc(sizeof(struct snd_ac97_bus), GFP_KERNEL); |
| 1439 | if (codec->ac97->bus == NULL) { |
| 1440 | kfree(codec->ac97); |
| 1441 | codec->ac97 = NULL; |
| 1442 | mutex_unlock(&codec->mutex); |
| 1443 | return -ENOMEM; |
| 1444 | } |
| 1445 | |
| 1446 | codec->ac97->bus->ops = ops; |
| 1447 | codec->ac97->num = num; |
Mark Brown | 2718625 | 2010-01-28 12:36:29 +0000 | [diff] [blame] | 1448 | codec->dev = &codec->ac97->dev; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1449 | mutex_unlock(&codec->mutex); |
| 1450 | return 0; |
| 1451 | } |
| 1452 | EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec); |
| 1453 | |
| 1454 | /** |
| 1455 | * snd_soc_free_ac97_codec - free AC97 codec device |
| 1456 | * @codec: audio codec |
| 1457 | * |
| 1458 | * Frees AC97 codec device resources. |
| 1459 | */ |
| 1460 | void snd_soc_free_ac97_codec(struct snd_soc_codec *codec) |
| 1461 | { |
| 1462 | mutex_lock(&codec->mutex); |
| 1463 | kfree(codec->ac97->bus); |
| 1464 | kfree(codec->ac97); |
| 1465 | codec->ac97 = NULL; |
| 1466 | mutex_unlock(&codec->mutex); |
| 1467 | } |
| 1468 | EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); |
| 1469 | |
| 1470 | /** |
| 1471 | * snd_soc_update_bits - update codec register bits |
| 1472 | * @codec: audio codec |
| 1473 | * @reg: codec register |
| 1474 | * @mask: register mask |
| 1475 | * @value: new value |
| 1476 | * |
| 1477 | * Writes new register value. |
| 1478 | * |
| 1479 | * Returns 1 for change else 0. |
| 1480 | */ |
| 1481 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 1482 | unsigned int mask, unsigned int value) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1483 | { |
| 1484 | int change; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 1485 | unsigned int old, new; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1486 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1487 | old = snd_soc_read(codec, reg); |
| 1488 | new = (old & ~mask) | value; |
| 1489 | change = old != new; |
| 1490 | if (change) |
| 1491 | snd_soc_write(codec, reg, new); |
| 1492 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1493 | return change; |
| 1494 | } |
| 1495 | EXPORT_SYMBOL_GPL(snd_soc_update_bits); |
| 1496 | |
| 1497 | /** |
Eero Nurkkala | 6c508c6 | 2009-10-30 13:34:03 +0200 | [diff] [blame] | 1498 | * snd_soc_update_bits_locked - update codec register bits |
| 1499 | * @codec: audio codec |
| 1500 | * @reg: codec register |
| 1501 | * @mask: register mask |
| 1502 | * @value: new value |
| 1503 | * |
| 1504 | * Writes new register value, and takes the codec mutex. |
| 1505 | * |
| 1506 | * Returns 1 for change else 0. |
| 1507 | */ |
Mark Brown | dd1b3d5 | 2009-12-04 14:22:03 +0000 | [diff] [blame] | 1508 | int snd_soc_update_bits_locked(struct snd_soc_codec *codec, |
| 1509 | unsigned short reg, unsigned int mask, |
| 1510 | unsigned int value) |
Eero Nurkkala | 6c508c6 | 2009-10-30 13:34:03 +0200 | [diff] [blame] | 1511 | { |
| 1512 | int change; |
| 1513 | |
| 1514 | mutex_lock(&codec->mutex); |
| 1515 | change = snd_soc_update_bits(codec, reg, mask, value); |
| 1516 | mutex_unlock(&codec->mutex); |
| 1517 | |
| 1518 | return change; |
| 1519 | } |
Mark Brown | dd1b3d5 | 2009-12-04 14:22:03 +0000 | [diff] [blame] | 1520 | EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked); |
Eero Nurkkala | 6c508c6 | 2009-10-30 13:34:03 +0200 | [diff] [blame] | 1521 | |
| 1522 | /** |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1523 | * snd_soc_test_bits - test register for change |
| 1524 | * @codec: audio codec |
| 1525 | * @reg: codec register |
| 1526 | * @mask: register mask |
| 1527 | * @value: new value |
| 1528 | * |
| 1529 | * Tests a register with a new value and checks if the new value is |
| 1530 | * different from the old value. |
| 1531 | * |
| 1532 | * Returns 1 for change else 0. |
| 1533 | */ |
| 1534 | int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 1535 | unsigned int mask, unsigned int value) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1536 | { |
| 1537 | int change; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 1538 | unsigned int old, new; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1539 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1540 | old = snd_soc_read(codec, reg); |
| 1541 | new = (old & ~mask) | value; |
| 1542 | change = old != new; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1543 | |
| 1544 | return change; |
| 1545 | } |
| 1546 | EXPORT_SYMBOL_GPL(snd_soc_test_bits); |
| 1547 | |
| 1548 | /** |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1549 | * snd_soc_new_pcms - create new sound card and pcms |
| 1550 | * @socdev: the SoC audio device |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 1551 | * @idx: ALSA card index |
| 1552 | * @xid: card identification |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1553 | * |
| 1554 | * Create a new sound card based upon the codec and interface pcms. |
| 1555 | * |
| 1556 | * Returns 0 for success, else error. |
| 1557 | */ |
Liam Girdwood | bc7320c | 2007-02-01 12:26:07 +0100 | [diff] [blame] | 1558 | int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1559 | { |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 1560 | struct snd_soc_card *card = socdev->card; |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 1561 | struct snd_soc_codec *codec = card->codec; |
Takashi Iwai | bd7dd77 | 2008-12-28 16:45:02 +0100 | [diff] [blame] | 1562 | int ret, i; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1563 | |
| 1564 | mutex_lock(&codec->mutex); |
| 1565 | |
| 1566 | /* register a sound card */ |
Takashi Iwai | bd7dd77 | 2008-12-28 16:45:02 +0100 | [diff] [blame] | 1567 | ret = snd_card_create(idx, xid, codec->owner, 0, &codec->card); |
| 1568 | if (ret < 0) { |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1569 | printk(KERN_ERR "asoc: can't create sound card for codec %s\n", |
| 1570 | codec->name); |
| 1571 | mutex_unlock(&codec->mutex); |
Takashi Iwai | bd7dd77 | 2008-12-28 16:45:02 +0100 | [diff] [blame] | 1572 | return ret; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1573 | } |
| 1574 | |
Mark Brown | 452c5ea | 2009-05-17 21:41:23 +0100 | [diff] [blame] | 1575 | codec->socdev = socdev; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1576 | codec->card->dev = socdev->dev; |
| 1577 | codec->card->private_data = codec; |
| 1578 | strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver)); |
| 1579 | |
| 1580 | /* create the pcms */ |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 1581 | for (i = 0; i < card->num_links; i++) { |
| 1582 | ret = soc_new_pcm(socdev, &card->dai_link[i], i); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1583 | if (ret < 0) { |
| 1584 | printk(KERN_ERR "asoc: can't create pcm %s\n", |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 1585 | card->dai_link[i].stream_name); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1586 | mutex_unlock(&codec->mutex); |
| 1587 | return ret; |
| 1588 | } |
Barry Song | f773205 | 2009-11-12 12:01:47 +0800 | [diff] [blame] | 1589 | if (card->dai_link[i].codec_dai->ac97_control) { |
| 1590 | snd_ac97_dev_add_pdata(codec->ac97, |
| 1591 | card->dai_link[i].cpu_dai->ac97_pdata); |
| 1592 | } |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1593 | } |
| 1594 | |
| 1595 | mutex_unlock(&codec->mutex); |
| 1596 | return ret; |
| 1597 | } |
| 1598 | EXPORT_SYMBOL_GPL(snd_soc_new_pcms); |
| 1599 | |
| 1600 | /** |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1601 | * snd_soc_free_pcms - free sound card and pcms |
| 1602 | * @socdev: the SoC audio device |
| 1603 | * |
| 1604 | * Frees sound card and pcms associated with the socdev. |
| 1605 | * Also unregister the codec if it is an AC97 device. |
| 1606 | */ |
| 1607 | void snd_soc_free_pcms(struct snd_soc_device *socdev) |
| 1608 | { |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 1609 | struct snd_soc_codec *codec = socdev->card->codec; |
Liam Girdwood | a68660e | 2007-05-10 19:27:27 +0200 | [diff] [blame] | 1610 | #ifdef CONFIG_SND_SOC_AC97_BUS |
Liam Girdwood | 3c4b266 | 2008-07-07 16:07:17 +0100 | [diff] [blame] | 1611 | struct snd_soc_dai *codec_dai; |
Liam Girdwood | a68660e | 2007-05-10 19:27:27 +0200 | [diff] [blame] | 1612 | int i; |
| 1613 | #endif |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1614 | |
| 1615 | mutex_lock(&codec->mutex); |
Mark Brown | 6627a65 | 2009-01-23 22:55:23 +0000 | [diff] [blame] | 1616 | soc_cleanup_codec_debugfs(codec); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1617 | #ifdef CONFIG_SND_SOC_AC97_BUS |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 1618 | for (i = 0; i < codec->num_dai; i++) { |
Liam Girdwood | a68660e | 2007-05-10 19:27:27 +0200 | [diff] [blame] | 1619 | codec_dai = &codec->dai[i]; |
Atsushi Nemoto | d2314e0 | 2009-03-16 23:26:20 +0900 | [diff] [blame] | 1620 | if (codec_dai->ac97_control && codec->ac97 && |
| 1621 | strcmp(codec->name, "AC97") != 0) { |
Liam Girdwood | a68660e | 2007-05-10 19:27:27 +0200 | [diff] [blame] | 1622 | soc_ac97_dev_unregister(codec); |
| 1623 | goto free_card; |
| 1624 | } |
| 1625 | } |
| 1626 | free_card: |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1627 | #endif |
| 1628 | |
| 1629 | if (codec->card) |
| 1630 | snd_card_free(codec->card); |
| 1631 | device_remove_file(socdev->dev, &dev_attr_codec_reg); |
| 1632 | mutex_unlock(&codec->mutex); |
| 1633 | } |
| 1634 | EXPORT_SYMBOL_GPL(snd_soc_free_pcms); |
| 1635 | |
| 1636 | /** |
| 1637 | * snd_soc_set_runtime_hwparams - set the runtime hardware parameters |
| 1638 | * @substream: the pcm substream |
| 1639 | * @hw: the hardware parameters |
| 1640 | * |
| 1641 | * Sets the substream runtime hardware parameters. |
| 1642 | */ |
| 1643 | int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, |
| 1644 | const struct snd_pcm_hardware *hw) |
| 1645 | { |
| 1646 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 1647 | runtime->hw.info = hw->info; |
| 1648 | runtime->hw.formats = hw->formats; |
| 1649 | runtime->hw.period_bytes_min = hw->period_bytes_min; |
| 1650 | runtime->hw.period_bytes_max = hw->period_bytes_max; |
| 1651 | runtime->hw.periods_min = hw->periods_min; |
| 1652 | runtime->hw.periods_max = hw->periods_max; |
| 1653 | runtime->hw.buffer_bytes_max = hw->buffer_bytes_max; |
| 1654 | runtime->hw.fifo_size = hw->fifo_size; |
| 1655 | return 0; |
| 1656 | } |
| 1657 | EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams); |
| 1658 | |
| 1659 | /** |
| 1660 | * snd_soc_cnew - create new control |
| 1661 | * @_template: control template |
| 1662 | * @data: control private data |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 1663 | * @long_name: control long name |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1664 | * |
| 1665 | * Create a new mixer control from a template control. |
| 1666 | * |
| 1667 | * Returns 0 for success, else error. |
| 1668 | */ |
| 1669 | struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, |
| 1670 | void *data, char *long_name) |
| 1671 | { |
| 1672 | struct snd_kcontrol_new template; |
| 1673 | |
| 1674 | memcpy(&template, _template, sizeof(template)); |
| 1675 | if (long_name) |
| 1676 | template.name = long_name; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1677 | template.index = 0; |
| 1678 | |
| 1679 | return snd_ctl_new1(&template, data); |
| 1680 | } |
| 1681 | EXPORT_SYMBOL_GPL(snd_soc_cnew); |
| 1682 | |
| 1683 | /** |
Ian Molton | 3e8e195 | 2009-01-09 00:23:21 +0000 | [diff] [blame] | 1684 | * snd_soc_add_controls - add an array of controls to a codec. |
| 1685 | * Convienience function to add a list of controls. Many codecs were |
| 1686 | * duplicating this code. |
| 1687 | * |
| 1688 | * @codec: codec to add controls to |
| 1689 | * @controls: array of controls to add |
| 1690 | * @num_controls: number of elements in the array |
| 1691 | * |
| 1692 | * Return 0 for success, else error. |
| 1693 | */ |
| 1694 | int snd_soc_add_controls(struct snd_soc_codec *codec, |
| 1695 | const struct snd_kcontrol_new *controls, int num_controls) |
| 1696 | { |
| 1697 | struct snd_card *card = codec->card; |
| 1698 | int err, i; |
| 1699 | |
| 1700 | for (i = 0; i < num_controls; i++) { |
| 1701 | const struct snd_kcontrol_new *control = &controls[i]; |
| 1702 | err = snd_ctl_add(card, snd_soc_cnew(control, codec, NULL)); |
| 1703 | if (err < 0) { |
| 1704 | dev_err(codec->dev, "%s: Failed to add %s\n", |
| 1705 | codec->name, control->name); |
| 1706 | return err; |
| 1707 | } |
| 1708 | } |
| 1709 | |
| 1710 | return 0; |
| 1711 | } |
| 1712 | EXPORT_SYMBOL_GPL(snd_soc_add_controls); |
| 1713 | |
| 1714 | /** |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1715 | * snd_soc_info_enum_double - enumerated double mixer info callback |
| 1716 | * @kcontrol: mixer control |
| 1717 | * @uinfo: control element information |
| 1718 | * |
| 1719 | * Callback to provide information about a double enumerated |
| 1720 | * mixer control. |
| 1721 | * |
| 1722 | * Returns 0 for success. |
| 1723 | */ |
| 1724 | int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, |
| 1725 | struct snd_ctl_elem_info *uinfo) |
| 1726 | { |
| 1727 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
| 1728 | |
| 1729 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1730 | uinfo->count = e->shift_l == e->shift_r ? 1 : 2; |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1731 | uinfo->value.enumerated.items = e->max; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1732 | |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1733 | if (uinfo->value.enumerated.item > e->max - 1) |
| 1734 | uinfo->value.enumerated.item = e->max - 1; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1735 | strcpy(uinfo->value.enumerated.name, |
| 1736 | e->texts[uinfo->value.enumerated.item]); |
| 1737 | return 0; |
| 1738 | } |
| 1739 | EXPORT_SYMBOL_GPL(snd_soc_info_enum_double); |
| 1740 | |
| 1741 | /** |
| 1742 | * snd_soc_get_enum_double - enumerated double mixer get callback |
| 1743 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 1744 | * @ucontrol: control element information |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1745 | * |
| 1746 | * Callback to get the value of a double enumerated mixer. |
| 1747 | * |
| 1748 | * Returns 0 for success. |
| 1749 | */ |
| 1750 | int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol, |
| 1751 | struct snd_ctl_elem_value *ucontrol) |
| 1752 | { |
| 1753 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1754 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 1755 | unsigned int val, bitmask; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1756 | |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1757 | for (bitmask = 1; bitmask < e->max; bitmask <<= 1) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1758 | ; |
| 1759 | val = snd_soc_read(codec, e->reg); |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 1760 | ucontrol->value.enumerated.item[0] |
| 1761 | = (val >> e->shift_l) & (bitmask - 1); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1762 | if (e->shift_l != e->shift_r) |
| 1763 | ucontrol->value.enumerated.item[1] = |
| 1764 | (val >> e->shift_r) & (bitmask - 1); |
| 1765 | |
| 1766 | return 0; |
| 1767 | } |
| 1768 | EXPORT_SYMBOL_GPL(snd_soc_get_enum_double); |
| 1769 | |
| 1770 | /** |
| 1771 | * snd_soc_put_enum_double - enumerated double mixer put callback |
| 1772 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 1773 | * @ucontrol: control element information |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1774 | * |
| 1775 | * Callback to set the value of a double enumerated mixer. |
| 1776 | * |
| 1777 | * Returns 0 for success. |
| 1778 | */ |
| 1779 | int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, |
| 1780 | struct snd_ctl_elem_value *ucontrol) |
| 1781 | { |
| 1782 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1783 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 1784 | unsigned int val; |
| 1785 | unsigned int mask, bitmask; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1786 | |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1787 | for (bitmask = 1; bitmask < e->max; bitmask <<= 1) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1788 | ; |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1789 | if (ucontrol->value.enumerated.item[0] > e->max - 1) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1790 | return -EINVAL; |
| 1791 | val = ucontrol->value.enumerated.item[0] << e->shift_l; |
| 1792 | mask = (bitmask - 1) << e->shift_l; |
| 1793 | if (e->shift_l != e->shift_r) { |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1794 | if (ucontrol->value.enumerated.item[1] > e->max - 1) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1795 | return -EINVAL; |
| 1796 | val |= ucontrol->value.enumerated.item[1] << e->shift_r; |
| 1797 | mask |= (bitmask - 1) << e->shift_r; |
| 1798 | } |
| 1799 | |
Eero Nurkkala | 6c508c6 | 2009-10-30 13:34:03 +0200 | [diff] [blame] | 1800 | return snd_soc_update_bits_locked(codec, e->reg, mask, val); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1801 | } |
| 1802 | EXPORT_SYMBOL_GPL(snd_soc_put_enum_double); |
| 1803 | |
| 1804 | /** |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 1805 | * snd_soc_get_value_enum_double - semi enumerated double mixer get callback |
| 1806 | * @kcontrol: mixer control |
| 1807 | * @ucontrol: control element information |
| 1808 | * |
| 1809 | * Callback to get the value of a double semi enumerated mixer. |
| 1810 | * |
| 1811 | * Semi enumerated mixer: the enumerated items are referred as values. Can be |
| 1812 | * used for handling bitfield coded enumeration for example. |
| 1813 | * |
| 1814 | * Returns 0 for success. |
| 1815 | */ |
| 1816 | int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol, |
| 1817 | struct snd_ctl_elem_value *ucontrol) |
| 1818 | { |
| 1819 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
Peter Ujfalusi | 7415555 | 2009-01-08 13:34:29 +0200 | [diff] [blame] | 1820 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 1821 | unsigned int reg_val, val, mux; |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 1822 | |
| 1823 | reg_val = snd_soc_read(codec, e->reg); |
| 1824 | val = (reg_val >> e->shift_l) & e->mask; |
| 1825 | for (mux = 0; mux < e->max; mux++) { |
| 1826 | if (val == e->values[mux]) |
| 1827 | break; |
| 1828 | } |
| 1829 | ucontrol->value.enumerated.item[0] = mux; |
| 1830 | if (e->shift_l != e->shift_r) { |
| 1831 | val = (reg_val >> e->shift_r) & e->mask; |
| 1832 | for (mux = 0; mux < e->max; mux++) { |
| 1833 | if (val == e->values[mux]) |
| 1834 | break; |
| 1835 | } |
| 1836 | ucontrol->value.enumerated.item[1] = mux; |
| 1837 | } |
| 1838 | |
| 1839 | return 0; |
| 1840 | } |
| 1841 | EXPORT_SYMBOL_GPL(snd_soc_get_value_enum_double); |
| 1842 | |
| 1843 | /** |
| 1844 | * snd_soc_put_value_enum_double - semi enumerated double mixer put callback |
| 1845 | * @kcontrol: mixer control |
| 1846 | * @ucontrol: control element information |
| 1847 | * |
| 1848 | * Callback to set the value of a double semi enumerated mixer. |
| 1849 | * |
| 1850 | * Semi enumerated mixer: the enumerated items are referred as values. Can be |
| 1851 | * used for handling bitfield coded enumeration for example. |
| 1852 | * |
| 1853 | * Returns 0 for success. |
| 1854 | */ |
| 1855 | int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol, |
| 1856 | struct snd_ctl_elem_value *ucontrol) |
| 1857 | { |
| 1858 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
Peter Ujfalusi | 7415555 | 2009-01-08 13:34:29 +0200 | [diff] [blame] | 1859 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 1860 | unsigned int val; |
| 1861 | unsigned int mask; |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 1862 | |
| 1863 | if (ucontrol->value.enumerated.item[0] > e->max - 1) |
| 1864 | return -EINVAL; |
| 1865 | val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l; |
| 1866 | mask = e->mask << e->shift_l; |
| 1867 | if (e->shift_l != e->shift_r) { |
| 1868 | if (ucontrol->value.enumerated.item[1] > e->max - 1) |
| 1869 | return -EINVAL; |
| 1870 | val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r; |
| 1871 | mask |= e->mask << e->shift_r; |
| 1872 | } |
| 1873 | |
Eero Nurkkala | 6c508c6 | 2009-10-30 13:34:03 +0200 | [diff] [blame] | 1874 | return snd_soc_update_bits_locked(codec, e->reg, mask, val); |
Peter Ujfalusi | 2e72f8e | 2009-01-05 09:54:57 +0200 | [diff] [blame] | 1875 | } |
| 1876 | EXPORT_SYMBOL_GPL(snd_soc_put_value_enum_double); |
| 1877 | |
| 1878 | /** |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1879 | * snd_soc_info_enum_ext - external enumerated single mixer info callback |
| 1880 | * @kcontrol: mixer control |
| 1881 | * @uinfo: control element information |
| 1882 | * |
| 1883 | * Callback to provide information about an external enumerated |
| 1884 | * single mixer. |
| 1885 | * |
| 1886 | * Returns 0 for success. |
| 1887 | */ |
| 1888 | int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, |
| 1889 | struct snd_ctl_elem_info *uinfo) |
| 1890 | { |
| 1891 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
| 1892 | |
| 1893 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 1894 | uinfo->count = 1; |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1895 | uinfo->value.enumerated.items = e->max; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1896 | |
Jon Smirl | f8ba0b7 | 2008-07-29 11:42:27 +0100 | [diff] [blame] | 1897 | if (uinfo->value.enumerated.item > e->max - 1) |
| 1898 | uinfo->value.enumerated.item = e->max - 1; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1899 | strcpy(uinfo->value.enumerated.name, |
| 1900 | e->texts[uinfo->value.enumerated.item]); |
| 1901 | return 0; |
| 1902 | } |
| 1903 | EXPORT_SYMBOL_GPL(snd_soc_info_enum_ext); |
| 1904 | |
| 1905 | /** |
| 1906 | * snd_soc_info_volsw_ext - external single mixer info callback |
| 1907 | * @kcontrol: mixer control |
| 1908 | * @uinfo: control element information |
| 1909 | * |
| 1910 | * Callback to provide information about a single external mixer control. |
| 1911 | * |
| 1912 | * Returns 0 for success. |
| 1913 | */ |
| 1914 | int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, |
| 1915 | struct snd_ctl_elem_info *uinfo) |
| 1916 | { |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 1917 | int max = kcontrol->private_value; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1918 | |
Mark Brown | fd5dfad | 2009-04-15 21:37:46 +0100 | [diff] [blame] | 1919 | if (max == 1 && !strstr(kcontrol->id.name, " Volume")) |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 1920 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 1921 | else |
| 1922 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
| 1923 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1924 | uinfo->count = 1; |
| 1925 | uinfo->value.integer.min = 0; |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 1926 | uinfo->value.integer.max = max; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1927 | return 0; |
| 1928 | } |
| 1929 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext); |
| 1930 | |
| 1931 | /** |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1932 | * snd_soc_info_volsw - single mixer info callback |
| 1933 | * @kcontrol: mixer control |
| 1934 | * @uinfo: control element information |
| 1935 | * |
| 1936 | * Callback to provide information about a single mixer control. |
| 1937 | * |
| 1938 | * Returns 0 for success. |
| 1939 | */ |
| 1940 | int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, |
| 1941 | struct snd_ctl_elem_info *uinfo) |
| 1942 | { |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 1943 | struct soc_mixer_control *mc = |
| 1944 | (struct soc_mixer_control *)kcontrol->private_value; |
| 1945 | int max = mc->max; |
Mark Brown | 762b8df | 2008-10-30 12:37:08 +0000 | [diff] [blame] | 1946 | unsigned int shift = mc->shift; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 1947 | unsigned int rshift = mc->rshift; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1948 | |
Mark Brown | fd5dfad | 2009-04-15 21:37:46 +0100 | [diff] [blame] | 1949 | if (max == 1 && !strstr(kcontrol->id.name, " Volume")) |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 1950 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 1951 | else |
| 1952 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
| 1953 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1954 | uinfo->count = shift == rshift ? 1 : 2; |
| 1955 | uinfo->value.integer.min = 0; |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 1956 | uinfo->value.integer.max = max; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1957 | return 0; |
| 1958 | } |
| 1959 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw); |
| 1960 | |
| 1961 | /** |
| 1962 | * snd_soc_get_volsw - single mixer get callback |
| 1963 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 1964 | * @ucontrol: control element information |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1965 | * |
| 1966 | * Callback to get the value of a single mixer control. |
| 1967 | * |
| 1968 | * Returns 0 for success. |
| 1969 | */ |
| 1970 | int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, |
| 1971 | struct snd_ctl_elem_value *ucontrol) |
| 1972 | { |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 1973 | struct soc_mixer_control *mc = |
| 1974 | (struct soc_mixer_control *)kcontrol->private_value; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1975 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 1976 | unsigned int reg = mc->reg; |
| 1977 | unsigned int shift = mc->shift; |
| 1978 | unsigned int rshift = mc->rshift; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 1979 | int max = mc->max; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 1980 | unsigned int mask = (1 << fls(max)) - 1; |
| 1981 | unsigned int invert = mc->invert; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1982 | |
| 1983 | ucontrol->value.integer.value[0] = |
| 1984 | (snd_soc_read(codec, reg) >> shift) & mask; |
| 1985 | if (shift != rshift) |
| 1986 | ucontrol->value.integer.value[1] = |
| 1987 | (snd_soc_read(codec, reg) >> rshift) & mask; |
| 1988 | if (invert) { |
| 1989 | ucontrol->value.integer.value[0] = |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 1990 | max - ucontrol->value.integer.value[0]; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1991 | if (shift != rshift) |
| 1992 | ucontrol->value.integer.value[1] = |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 1993 | max - ucontrol->value.integer.value[1]; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 1994 | } |
| 1995 | |
| 1996 | return 0; |
| 1997 | } |
| 1998 | EXPORT_SYMBOL_GPL(snd_soc_get_volsw); |
| 1999 | |
| 2000 | /** |
| 2001 | * snd_soc_put_volsw - single mixer put callback |
| 2002 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2003 | * @ucontrol: control element information |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2004 | * |
| 2005 | * Callback to set the value of a single mixer control. |
| 2006 | * |
| 2007 | * Returns 0 for success. |
| 2008 | */ |
| 2009 | int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, |
| 2010 | struct snd_ctl_elem_value *ucontrol) |
| 2011 | { |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2012 | struct soc_mixer_control *mc = |
| 2013 | (struct soc_mixer_control *)kcontrol->private_value; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2014 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 2015 | unsigned int reg = mc->reg; |
| 2016 | unsigned int shift = mc->shift; |
| 2017 | unsigned int rshift = mc->rshift; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2018 | int max = mc->max; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 2019 | unsigned int mask = (1 << fls(max)) - 1; |
| 2020 | unsigned int invert = mc->invert; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 2021 | unsigned int val, val2, val_mask; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2022 | |
| 2023 | val = (ucontrol->value.integer.value[0] & mask); |
| 2024 | if (invert) |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 2025 | val = max - val; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2026 | val_mask = mask << shift; |
| 2027 | val = val << shift; |
| 2028 | if (shift != rshift) { |
| 2029 | val2 = (ucontrol->value.integer.value[1] & mask); |
| 2030 | if (invert) |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 2031 | val2 = max - val2; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2032 | val_mask |= mask << rshift; |
| 2033 | val |= val2 << rshift; |
| 2034 | } |
Eero Nurkkala | 6c508c6 | 2009-10-30 13:34:03 +0200 | [diff] [blame] | 2035 | return snd_soc_update_bits_locked(codec, reg, val_mask, val); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2036 | } |
| 2037 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw); |
| 2038 | |
| 2039 | /** |
| 2040 | * snd_soc_info_volsw_2r - double mixer info callback |
| 2041 | * @kcontrol: mixer control |
| 2042 | * @uinfo: control element information |
| 2043 | * |
| 2044 | * Callback to provide information about a double mixer control that |
| 2045 | * spans 2 codec registers. |
| 2046 | * |
| 2047 | * Returns 0 for success. |
| 2048 | */ |
| 2049 | int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol, |
| 2050 | struct snd_ctl_elem_info *uinfo) |
| 2051 | { |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2052 | struct soc_mixer_control *mc = |
| 2053 | (struct soc_mixer_control *)kcontrol->private_value; |
| 2054 | int max = mc->max; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2055 | |
Mark Brown | fd5dfad | 2009-04-15 21:37:46 +0100 | [diff] [blame] | 2056 | if (max == 1 && !strstr(kcontrol->id.name, " Volume")) |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 2057 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 2058 | else |
| 2059 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
| 2060 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2061 | uinfo->count = 2; |
| 2062 | uinfo->value.integer.min = 0; |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 2063 | uinfo->value.integer.max = max; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2064 | return 0; |
| 2065 | } |
| 2066 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r); |
| 2067 | |
| 2068 | /** |
| 2069 | * snd_soc_get_volsw_2r - double mixer get callback |
| 2070 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2071 | * @ucontrol: control element information |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2072 | * |
| 2073 | * Callback to get the value of a double mixer control that spans 2 registers. |
| 2074 | * |
| 2075 | * Returns 0 for success. |
| 2076 | */ |
| 2077 | int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol, |
| 2078 | struct snd_ctl_elem_value *ucontrol) |
| 2079 | { |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2080 | struct soc_mixer_control *mc = |
| 2081 | (struct soc_mixer_control *)kcontrol->private_value; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2082 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 2083 | unsigned int reg = mc->reg; |
| 2084 | unsigned int reg2 = mc->rreg; |
| 2085 | unsigned int shift = mc->shift; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2086 | int max = mc->max; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 2087 | unsigned int mask = (1 << fls(max)) - 1; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 2088 | unsigned int invert = mc->invert; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2089 | |
| 2090 | ucontrol->value.integer.value[0] = |
| 2091 | (snd_soc_read(codec, reg) >> shift) & mask; |
| 2092 | ucontrol->value.integer.value[1] = |
| 2093 | (snd_soc_read(codec, reg2) >> shift) & mask; |
| 2094 | if (invert) { |
| 2095 | ucontrol->value.integer.value[0] = |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 2096 | max - ucontrol->value.integer.value[0]; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2097 | ucontrol->value.integer.value[1] = |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 2098 | max - ucontrol->value.integer.value[1]; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2099 | } |
| 2100 | |
| 2101 | return 0; |
| 2102 | } |
| 2103 | EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r); |
| 2104 | |
| 2105 | /** |
| 2106 | * snd_soc_put_volsw_2r - double mixer set callback |
| 2107 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2108 | * @ucontrol: control element information |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2109 | * |
| 2110 | * Callback to set the value of a double mixer control that spans 2 registers. |
| 2111 | * |
| 2112 | * Returns 0 for success. |
| 2113 | */ |
| 2114 | int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, |
| 2115 | struct snd_ctl_elem_value *ucontrol) |
| 2116 | { |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2117 | struct soc_mixer_control *mc = |
| 2118 | (struct soc_mixer_control *)kcontrol->private_value; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2119 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 2120 | unsigned int reg = mc->reg; |
| 2121 | unsigned int reg2 = mc->rreg; |
| 2122 | unsigned int shift = mc->shift; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2123 | int max = mc->max; |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 2124 | unsigned int mask = (1 << fls(max)) - 1; |
| 2125 | unsigned int invert = mc->invert; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2126 | int err; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 2127 | unsigned int val, val2, val_mask; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2128 | |
| 2129 | val_mask = mask << shift; |
| 2130 | val = (ucontrol->value.integer.value[0] & mask); |
| 2131 | val2 = (ucontrol->value.integer.value[1] & mask); |
| 2132 | |
| 2133 | if (invert) { |
Philipp Zabel | a7a4ac8 | 2008-01-10 14:37:42 +0100 | [diff] [blame] | 2134 | val = max - val; |
| 2135 | val2 = max - val2; |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2136 | } |
| 2137 | |
| 2138 | val = val << shift; |
| 2139 | val2 = val2 << shift; |
| 2140 | |
Eero Nurkkala | 6c508c6 | 2009-10-30 13:34:03 +0200 | [diff] [blame] | 2141 | err = snd_soc_update_bits_locked(codec, reg, val_mask, val); |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 2142 | if (err < 0) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2143 | return err; |
| 2144 | |
Eero Nurkkala | 6c508c6 | 2009-10-30 13:34:03 +0200 | [diff] [blame] | 2145 | err = snd_soc_update_bits_locked(codec, reg2, val_mask, val2); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2146 | return err; |
| 2147 | } |
| 2148 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r); |
| 2149 | |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 2150 | /** |
| 2151 | * snd_soc_info_volsw_s8 - signed mixer info callback |
| 2152 | * @kcontrol: mixer control |
| 2153 | * @uinfo: control element information |
| 2154 | * |
| 2155 | * Callback to provide information about a signed mixer control. |
| 2156 | * |
| 2157 | * Returns 0 for success. |
| 2158 | */ |
| 2159 | int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, |
| 2160 | struct snd_ctl_elem_info *uinfo) |
| 2161 | { |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2162 | struct soc_mixer_control *mc = |
| 2163 | (struct soc_mixer_control *)kcontrol->private_value; |
| 2164 | int max = mc->max; |
| 2165 | int min = mc->min; |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 2166 | |
| 2167 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
| 2168 | uinfo->count = 2; |
| 2169 | uinfo->value.integer.min = 0; |
| 2170 | uinfo->value.integer.max = max-min; |
| 2171 | return 0; |
| 2172 | } |
| 2173 | EXPORT_SYMBOL_GPL(snd_soc_info_volsw_s8); |
| 2174 | |
| 2175 | /** |
| 2176 | * snd_soc_get_volsw_s8 - signed mixer get callback |
| 2177 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2178 | * @ucontrol: control element information |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 2179 | * |
| 2180 | * Callback to get the value of a signed mixer control. |
| 2181 | * |
| 2182 | * Returns 0 for success. |
| 2183 | */ |
| 2184 | int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, |
| 2185 | struct snd_ctl_elem_value *ucontrol) |
| 2186 | { |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2187 | struct soc_mixer_control *mc = |
| 2188 | (struct soc_mixer_control *)kcontrol->private_value; |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 2189 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 2190 | unsigned int reg = mc->reg; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2191 | int min = mc->min; |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 2192 | int val = snd_soc_read(codec, reg); |
| 2193 | |
| 2194 | ucontrol->value.integer.value[0] = |
| 2195 | ((signed char)(val & 0xff))-min; |
| 2196 | ucontrol->value.integer.value[1] = |
| 2197 | ((signed char)((val >> 8) & 0xff))-min; |
| 2198 | return 0; |
| 2199 | } |
| 2200 | EXPORT_SYMBOL_GPL(snd_soc_get_volsw_s8); |
| 2201 | |
| 2202 | /** |
| 2203 | * snd_soc_put_volsw_sgn - signed mixer put callback |
| 2204 | * @kcontrol: mixer control |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2205 | * @ucontrol: control element information |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 2206 | * |
| 2207 | * Callback to set the value of a signed mixer control. |
| 2208 | * |
| 2209 | * Returns 0 for success. |
| 2210 | */ |
| 2211 | int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, |
| 2212 | struct snd_ctl_elem_value *ucontrol) |
| 2213 | { |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2214 | struct soc_mixer_control *mc = |
| 2215 | (struct soc_mixer_control *)kcontrol->private_value; |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 2216 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
Jon Smirl | 815ecf8d | 2008-07-29 10:22:24 -0400 | [diff] [blame] | 2217 | unsigned int reg = mc->reg; |
Jon Smirl | 4eaa981 | 2008-07-29 11:42:26 +0100 | [diff] [blame] | 2218 | int min = mc->min; |
Daniel Ribeiro | 46f5822 | 2009-06-07 02:49:11 -0300 | [diff] [blame] | 2219 | unsigned int val; |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 2220 | |
| 2221 | val = (ucontrol->value.integer.value[0]+min) & 0xff; |
| 2222 | val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8; |
| 2223 | |
Eero Nurkkala | 6c508c6 | 2009-10-30 13:34:03 +0200 | [diff] [blame] | 2224 | return snd_soc_update_bits_locked(codec, reg, 0xffff, val); |
Mark Brown | e13ac2e | 2008-05-28 17:58:05 +0100 | [diff] [blame] | 2225 | } |
| 2226 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8); |
| 2227 | |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2228 | /** |
| 2229 | * snd_soc_dai_set_sysclk - configure DAI system or master clock. |
| 2230 | * @dai: DAI |
| 2231 | * @clk_id: DAI specific clock ID |
| 2232 | * @freq: new clock frequency in Hz |
| 2233 | * @dir: new clock direction - input/output. |
| 2234 | * |
| 2235 | * Configures the DAI master (MCLK) or system (SYSCLK) clocking. |
| 2236 | */ |
| 2237 | int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, |
| 2238 | unsigned int freq, int dir) |
| 2239 | { |
Mark Brown | 3f1a4d8 | 2009-04-15 21:35:26 +0100 | [diff] [blame] | 2240 | if (dai->ops && dai->ops->set_sysclk) |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 2241 | return dai->ops->set_sysclk(dai, clk_id, freq, dir); |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2242 | else |
| 2243 | return -EINVAL; |
| 2244 | } |
| 2245 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk); |
| 2246 | |
| 2247 | /** |
| 2248 | * snd_soc_dai_set_clkdiv - configure DAI clock dividers. |
| 2249 | * @dai: DAI |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2250 | * @div_id: DAI specific clock divider ID |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2251 | * @div: new clock divisor. |
| 2252 | * |
| 2253 | * Configures the clock dividers. This is used to derive the best DAI bit and |
| 2254 | * frame clocks from the system or master clock. It's best to set the DAI bit |
| 2255 | * and frame clocks as low as possible to save system power. |
| 2256 | */ |
| 2257 | int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, |
| 2258 | int div_id, int div) |
| 2259 | { |
Mark Brown | 3f1a4d8 | 2009-04-15 21:35:26 +0100 | [diff] [blame] | 2260 | if (dai->ops && dai->ops->set_clkdiv) |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 2261 | return dai->ops->set_clkdiv(dai, div_id, div); |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2262 | else |
| 2263 | return -EINVAL; |
| 2264 | } |
| 2265 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv); |
| 2266 | |
| 2267 | /** |
| 2268 | * snd_soc_dai_set_pll - configure DAI PLL. |
| 2269 | * @dai: DAI |
| 2270 | * @pll_id: DAI specific PLL ID |
Mark Brown | 8548803 | 2009-09-05 18:52:16 +0100 | [diff] [blame] | 2271 | * @source: DAI specific source for the PLL |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2272 | * @freq_in: PLL input clock frequency in Hz |
| 2273 | * @freq_out: requested PLL output clock frequency in Hz |
| 2274 | * |
| 2275 | * Configures and enables PLL to generate output clock based on input clock. |
| 2276 | */ |
Mark Brown | 8548803 | 2009-09-05 18:52:16 +0100 | [diff] [blame] | 2277 | int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source, |
| 2278 | unsigned int freq_in, unsigned int freq_out) |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2279 | { |
Mark Brown | 3f1a4d8 | 2009-04-15 21:35:26 +0100 | [diff] [blame] | 2280 | if (dai->ops && dai->ops->set_pll) |
Mark Brown | 8548803 | 2009-09-05 18:52:16 +0100 | [diff] [blame] | 2281 | return dai->ops->set_pll(dai, pll_id, source, |
| 2282 | freq_in, freq_out); |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2283 | else |
| 2284 | return -EINVAL; |
| 2285 | } |
| 2286 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll); |
| 2287 | |
| 2288 | /** |
| 2289 | * snd_soc_dai_set_fmt - configure DAI hardware audio format. |
| 2290 | * @dai: DAI |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2291 | * @fmt: SND_SOC_DAIFMT_ format value. |
| 2292 | * |
| 2293 | * Configures the DAI hardware format and clocking. |
| 2294 | */ |
| 2295 | int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
| 2296 | { |
Mark Brown | 3f1a4d8 | 2009-04-15 21:35:26 +0100 | [diff] [blame] | 2297 | if (dai->ops && dai->ops->set_fmt) |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 2298 | return dai->ops->set_fmt(dai, fmt); |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2299 | else |
| 2300 | return -EINVAL; |
| 2301 | } |
| 2302 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt); |
| 2303 | |
| 2304 | /** |
| 2305 | * snd_soc_dai_set_tdm_slot - configure DAI TDM. |
| 2306 | * @dai: DAI |
Daniel Ribeiro | a5479e3 | 2009-06-15 21:44:31 -0300 | [diff] [blame] | 2307 | * @tx_mask: bitmask representing active TX slots. |
| 2308 | * @rx_mask: bitmask representing active RX slots. |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2309 | * @slots: Number of slots in use. |
Daniel Ribeiro | a5479e3 | 2009-06-15 21:44:31 -0300 | [diff] [blame] | 2310 | * @slot_width: Width in bits for each slot. |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2311 | * |
| 2312 | * Configures a DAI for TDM operation. Both mask and slots are codec and DAI |
| 2313 | * specific. |
| 2314 | */ |
| 2315 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, |
Daniel Ribeiro | a5479e3 | 2009-06-15 21:44:31 -0300 | [diff] [blame] | 2316 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2317 | { |
Mark Brown | 3f1a4d8 | 2009-04-15 21:35:26 +0100 | [diff] [blame] | 2318 | if (dai->ops && dai->ops->set_tdm_slot) |
Daniel Ribeiro | a5479e3 | 2009-06-15 21:44:31 -0300 | [diff] [blame] | 2319 | return dai->ops->set_tdm_slot(dai, tx_mask, rx_mask, |
| 2320 | slots, slot_width); |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2321 | else |
| 2322 | return -EINVAL; |
| 2323 | } |
| 2324 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot); |
| 2325 | |
| 2326 | /** |
Barry Song | 472df3c | 2009-09-12 01:16:29 +0800 | [diff] [blame] | 2327 | * snd_soc_dai_set_channel_map - configure DAI audio channel map |
| 2328 | * @dai: DAI |
| 2329 | * @tx_num: how many TX channels |
| 2330 | * @tx_slot: pointer to an array which imply the TX slot number channel |
| 2331 | * 0~num-1 uses |
| 2332 | * @rx_num: how many RX channels |
| 2333 | * @rx_slot: pointer to an array which imply the RX slot number channel |
| 2334 | * 0~num-1 uses |
| 2335 | * |
| 2336 | * configure the relationship between channel number and TDM slot number. |
| 2337 | */ |
| 2338 | int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai, |
| 2339 | unsigned int tx_num, unsigned int *tx_slot, |
| 2340 | unsigned int rx_num, unsigned int *rx_slot) |
| 2341 | { |
| 2342 | if (dai->ops && dai->ops->set_channel_map) |
| 2343 | return dai->ops->set_channel_map(dai, tx_num, tx_slot, |
| 2344 | rx_num, rx_slot); |
| 2345 | else |
| 2346 | return -EINVAL; |
| 2347 | } |
| 2348 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_channel_map); |
| 2349 | |
| 2350 | /** |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2351 | * snd_soc_dai_set_tristate - configure DAI system or master clock. |
| 2352 | * @dai: DAI |
| 2353 | * @tristate: tristate enable |
| 2354 | * |
| 2355 | * Tristates the DAI so that others can use it. |
| 2356 | */ |
| 2357 | int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate) |
| 2358 | { |
Mark Brown | 3f1a4d8 | 2009-04-15 21:35:26 +0100 | [diff] [blame] | 2359 | if (dai->ops && dai->ops->set_tristate) |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 2360 | return dai->ops->set_tristate(dai, tristate); |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2361 | else |
| 2362 | return -EINVAL; |
| 2363 | } |
| 2364 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate); |
| 2365 | |
| 2366 | /** |
| 2367 | * snd_soc_dai_digital_mute - configure DAI system or master clock. |
| 2368 | * @dai: DAI |
| 2369 | * @mute: mute enable |
| 2370 | * |
| 2371 | * Mutes the DAI DAC. |
| 2372 | */ |
| 2373 | int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute) |
| 2374 | { |
Mark Brown | 3f1a4d8 | 2009-04-15 21:35:26 +0100 | [diff] [blame] | 2375 | if (dai->ops && dai->ops->digital_mute) |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 2376 | return dai->ops->digital_mute(dai, mute); |
Liam Girdwood | 8c6529d | 2008-07-08 13:19:13 +0100 | [diff] [blame] | 2377 | else |
| 2378 | return -EINVAL; |
| 2379 | } |
| 2380 | EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute); |
| 2381 | |
Mark Brown | c5af3a2 | 2008-11-28 13:29:45 +0000 | [diff] [blame] | 2382 | /** |
| 2383 | * snd_soc_register_card - Register a card with the ASoC core |
| 2384 | * |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2385 | * @card: Card to register |
Mark Brown | c5af3a2 | 2008-11-28 13:29:45 +0000 | [diff] [blame] | 2386 | * |
| 2387 | * Note that currently this is an internal only function: it will be |
| 2388 | * exposed to machine drivers after further backporting of ASoC v2 |
| 2389 | * registration APIs. |
| 2390 | */ |
| 2391 | static int snd_soc_register_card(struct snd_soc_card *card) |
| 2392 | { |
| 2393 | if (!card->name || !card->dev) |
| 2394 | return -EINVAL; |
| 2395 | |
| 2396 | INIT_LIST_HEAD(&card->list); |
| 2397 | card->instantiated = 0; |
| 2398 | |
| 2399 | mutex_lock(&client_mutex); |
| 2400 | list_add(&card->list, &card_list); |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 2401 | snd_soc_instantiate_cards(); |
Mark Brown | c5af3a2 | 2008-11-28 13:29:45 +0000 | [diff] [blame] | 2402 | mutex_unlock(&client_mutex); |
| 2403 | |
| 2404 | dev_dbg(card->dev, "Registered card '%s'\n", card->name); |
| 2405 | |
| 2406 | return 0; |
| 2407 | } |
| 2408 | |
| 2409 | /** |
| 2410 | * snd_soc_unregister_card - Unregister a card with the ASoC core |
| 2411 | * |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2412 | * @card: Card to unregister |
Mark Brown | c5af3a2 | 2008-11-28 13:29:45 +0000 | [diff] [blame] | 2413 | * |
| 2414 | * Note that currently this is an internal only function: it will be |
| 2415 | * exposed to machine drivers after further backporting of ASoC v2 |
| 2416 | * registration APIs. |
| 2417 | */ |
| 2418 | static int snd_soc_unregister_card(struct snd_soc_card *card) |
| 2419 | { |
| 2420 | mutex_lock(&client_mutex); |
| 2421 | list_del(&card->list); |
| 2422 | mutex_unlock(&client_mutex); |
| 2423 | |
| 2424 | dev_dbg(card->dev, "Unregistered card '%s'\n", card->name); |
| 2425 | |
| 2426 | return 0; |
| 2427 | } |
| 2428 | |
Mark Brown | 9115171 | 2008-11-30 23:31:24 +0000 | [diff] [blame] | 2429 | /** |
| 2430 | * snd_soc_register_dai - Register a DAI with the ASoC core |
| 2431 | * |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2432 | * @dai: DAI to register |
Mark Brown | 9115171 | 2008-11-30 23:31:24 +0000 | [diff] [blame] | 2433 | */ |
| 2434 | int snd_soc_register_dai(struct snd_soc_dai *dai) |
| 2435 | { |
| 2436 | if (!dai->name) |
| 2437 | return -EINVAL; |
| 2438 | |
| 2439 | /* The device should become mandatory over time */ |
| 2440 | if (!dai->dev) |
| 2441 | printk(KERN_WARNING "No device for DAI %s\n", dai->name); |
| 2442 | |
Eric Miao | 6335d05 | 2009-03-03 09:41:00 +0800 | [diff] [blame] | 2443 | if (!dai->ops) |
| 2444 | dai->ops = &null_dai_ops; |
| 2445 | |
Mark Brown | 9115171 | 2008-11-30 23:31:24 +0000 | [diff] [blame] | 2446 | INIT_LIST_HEAD(&dai->list); |
| 2447 | |
| 2448 | mutex_lock(&client_mutex); |
| 2449 | list_add(&dai->list, &dai_list); |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 2450 | snd_soc_instantiate_cards(); |
Mark Brown | 9115171 | 2008-11-30 23:31:24 +0000 | [diff] [blame] | 2451 | mutex_unlock(&client_mutex); |
| 2452 | |
| 2453 | pr_debug("Registered DAI '%s'\n", dai->name); |
| 2454 | |
| 2455 | return 0; |
| 2456 | } |
| 2457 | EXPORT_SYMBOL_GPL(snd_soc_register_dai); |
| 2458 | |
| 2459 | /** |
| 2460 | * snd_soc_unregister_dai - Unregister a DAI from the ASoC core |
| 2461 | * |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2462 | * @dai: DAI to unregister |
Mark Brown | 9115171 | 2008-11-30 23:31:24 +0000 | [diff] [blame] | 2463 | */ |
| 2464 | void snd_soc_unregister_dai(struct snd_soc_dai *dai) |
| 2465 | { |
| 2466 | mutex_lock(&client_mutex); |
| 2467 | list_del(&dai->list); |
| 2468 | mutex_unlock(&client_mutex); |
| 2469 | |
| 2470 | pr_debug("Unregistered DAI '%s'\n", dai->name); |
| 2471 | } |
| 2472 | EXPORT_SYMBOL_GPL(snd_soc_unregister_dai); |
| 2473 | |
| 2474 | /** |
| 2475 | * snd_soc_register_dais - Register multiple DAIs with the ASoC core |
| 2476 | * |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2477 | * @dai: Array of DAIs to register |
| 2478 | * @count: Number of DAIs |
Mark Brown | 9115171 | 2008-11-30 23:31:24 +0000 | [diff] [blame] | 2479 | */ |
| 2480 | int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count) |
| 2481 | { |
| 2482 | int i, ret; |
| 2483 | |
| 2484 | for (i = 0; i < count; i++) { |
| 2485 | ret = snd_soc_register_dai(&dai[i]); |
| 2486 | if (ret != 0) |
| 2487 | goto err; |
| 2488 | } |
| 2489 | |
| 2490 | return 0; |
| 2491 | |
| 2492 | err: |
| 2493 | for (i--; i >= 0; i--) |
| 2494 | snd_soc_unregister_dai(&dai[i]); |
| 2495 | |
| 2496 | return ret; |
| 2497 | } |
| 2498 | EXPORT_SYMBOL_GPL(snd_soc_register_dais); |
| 2499 | |
| 2500 | /** |
| 2501 | * snd_soc_unregister_dais - Unregister multiple DAIs from the ASoC core |
| 2502 | * |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2503 | * @dai: Array of DAIs to unregister |
| 2504 | * @count: Number of DAIs |
Mark Brown | 9115171 | 2008-11-30 23:31:24 +0000 | [diff] [blame] | 2505 | */ |
| 2506 | void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count) |
| 2507 | { |
| 2508 | int i; |
| 2509 | |
| 2510 | for (i = 0; i < count; i++) |
| 2511 | snd_soc_unregister_dai(&dai[i]); |
| 2512 | } |
| 2513 | EXPORT_SYMBOL_GPL(snd_soc_unregister_dais); |
| 2514 | |
Mark Brown | 12a48a8c | 2008-12-03 19:40:30 +0000 | [diff] [blame] | 2515 | /** |
| 2516 | * snd_soc_register_platform - Register a platform with the ASoC core |
| 2517 | * |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2518 | * @platform: platform to register |
Mark Brown | 12a48a8c | 2008-12-03 19:40:30 +0000 | [diff] [blame] | 2519 | */ |
| 2520 | int snd_soc_register_platform(struct snd_soc_platform *platform) |
| 2521 | { |
| 2522 | if (!platform->name) |
| 2523 | return -EINVAL; |
| 2524 | |
| 2525 | INIT_LIST_HEAD(&platform->list); |
| 2526 | |
| 2527 | mutex_lock(&client_mutex); |
| 2528 | list_add(&platform->list, &platform_list); |
Mark Brown | 435c5e2 | 2008-12-04 15:32:53 +0000 | [diff] [blame] | 2529 | snd_soc_instantiate_cards(); |
Mark Brown | 12a48a8c | 2008-12-03 19:40:30 +0000 | [diff] [blame] | 2530 | mutex_unlock(&client_mutex); |
| 2531 | |
| 2532 | pr_debug("Registered platform '%s'\n", platform->name); |
| 2533 | |
| 2534 | return 0; |
| 2535 | } |
| 2536 | EXPORT_SYMBOL_GPL(snd_soc_register_platform); |
| 2537 | |
| 2538 | /** |
| 2539 | * snd_soc_unregister_platform - Unregister a platform from the ASoC core |
| 2540 | * |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2541 | * @platform: platform to unregister |
Mark Brown | 12a48a8c | 2008-12-03 19:40:30 +0000 | [diff] [blame] | 2542 | */ |
| 2543 | void snd_soc_unregister_platform(struct snd_soc_platform *platform) |
| 2544 | { |
| 2545 | mutex_lock(&client_mutex); |
| 2546 | list_del(&platform->list); |
| 2547 | mutex_unlock(&client_mutex); |
| 2548 | |
| 2549 | pr_debug("Unregistered platform '%s'\n", platform->name); |
| 2550 | } |
| 2551 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); |
| 2552 | |
Mark Brown | 151ab22 | 2009-05-09 16:22:58 +0100 | [diff] [blame] | 2553 | static u64 codec_format_map[] = { |
| 2554 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE, |
| 2555 | SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE, |
| 2556 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE, |
| 2557 | SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_U24_BE, |
| 2558 | SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE, |
| 2559 | SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE, |
| 2560 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3BE, |
| 2561 | SNDRV_PCM_FMTBIT_U24_3LE | SNDRV_PCM_FMTBIT_U24_3BE, |
| 2562 | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE, |
| 2563 | SNDRV_PCM_FMTBIT_U20_3LE | SNDRV_PCM_FMTBIT_U20_3BE, |
| 2564 | SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE, |
| 2565 | SNDRV_PCM_FMTBIT_U18_3LE | SNDRV_PCM_FMTBIT_U18_3BE, |
| 2566 | SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE, |
| 2567 | SNDRV_PCM_FMTBIT_FLOAT64_LE | SNDRV_PCM_FMTBIT_FLOAT64_BE, |
| 2568 | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE |
| 2569 | | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE, |
| 2570 | }; |
| 2571 | |
| 2572 | /* Fix up the DAI formats for endianness: codecs don't actually see |
| 2573 | * the endianness of the data but we're using the CPU format |
| 2574 | * definitions which do need to include endianness so we ensure that |
| 2575 | * codec DAIs always have both big and little endian variants set. |
| 2576 | */ |
| 2577 | static void fixup_codec_formats(struct snd_soc_pcm_stream *stream) |
| 2578 | { |
| 2579 | int i; |
| 2580 | |
| 2581 | for (i = 0; i < ARRAY_SIZE(codec_format_map); i++) |
| 2582 | if (stream->formats & codec_format_map[i]) |
| 2583 | stream->formats |= codec_format_map[i]; |
| 2584 | } |
| 2585 | |
Mark Brown | 0d0cf00 | 2008-12-10 14:32:45 +0000 | [diff] [blame] | 2586 | /** |
| 2587 | * snd_soc_register_codec - Register a codec with the ASoC core |
| 2588 | * |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2589 | * @codec: codec to register |
Mark Brown | 0d0cf00 | 2008-12-10 14:32:45 +0000 | [diff] [blame] | 2590 | */ |
| 2591 | int snd_soc_register_codec(struct snd_soc_codec *codec) |
| 2592 | { |
Mark Brown | 151ab22 | 2009-05-09 16:22:58 +0100 | [diff] [blame] | 2593 | int i; |
| 2594 | |
Mark Brown | 0d0cf00 | 2008-12-10 14:32:45 +0000 | [diff] [blame] | 2595 | if (!codec->name) |
| 2596 | return -EINVAL; |
| 2597 | |
| 2598 | /* The device should become mandatory over time */ |
| 2599 | if (!codec->dev) |
| 2600 | printk(KERN_WARNING "No device for codec %s\n", codec->name); |
| 2601 | |
| 2602 | INIT_LIST_HEAD(&codec->list); |
| 2603 | |
Mark Brown | 151ab22 | 2009-05-09 16:22:58 +0100 | [diff] [blame] | 2604 | for (i = 0; i < codec->num_dai; i++) { |
| 2605 | fixup_codec_formats(&codec->dai[i].playback); |
| 2606 | fixup_codec_formats(&codec->dai[i].capture); |
| 2607 | } |
| 2608 | |
Mark Brown | 0d0cf00 | 2008-12-10 14:32:45 +0000 | [diff] [blame] | 2609 | mutex_lock(&client_mutex); |
| 2610 | list_add(&codec->list, &codec_list); |
| 2611 | snd_soc_instantiate_cards(); |
| 2612 | mutex_unlock(&client_mutex); |
| 2613 | |
| 2614 | pr_debug("Registered codec '%s'\n", codec->name); |
| 2615 | |
| 2616 | return 0; |
| 2617 | } |
| 2618 | EXPORT_SYMBOL_GPL(snd_soc_register_codec); |
| 2619 | |
| 2620 | /** |
| 2621 | * snd_soc_unregister_codec - Unregister a codec from the ASoC core |
| 2622 | * |
Mark Brown | ac11a2b | 2009-01-01 12:18:17 +0000 | [diff] [blame] | 2623 | * @codec: codec to unregister |
Mark Brown | 0d0cf00 | 2008-12-10 14:32:45 +0000 | [diff] [blame] | 2624 | */ |
| 2625 | void snd_soc_unregister_codec(struct snd_soc_codec *codec) |
| 2626 | { |
| 2627 | mutex_lock(&client_mutex); |
| 2628 | list_del(&codec->list); |
| 2629 | mutex_unlock(&client_mutex); |
| 2630 | |
| 2631 | pr_debug("Unregistered codec '%s'\n", codec->name); |
| 2632 | } |
| 2633 | EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); |
| 2634 | |
Takashi Iwai | c9b3a40 | 2008-12-10 07:47:22 +0100 | [diff] [blame] | 2635 | static int __init snd_soc_init(void) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2636 | { |
Mark Brown | 384c89e | 2008-12-03 17:34:03 +0000 | [diff] [blame] | 2637 | #ifdef CONFIG_DEBUG_FS |
| 2638 | debugfs_root = debugfs_create_dir("asoc", NULL); |
| 2639 | if (IS_ERR(debugfs_root) || !debugfs_root) { |
| 2640 | printk(KERN_WARNING |
| 2641 | "ASoC: Failed to create debugfs directory\n"); |
| 2642 | debugfs_root = NULL; |
| 2643 | } |
| 2644 | #endif |
| 2645 | |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2646 | return platform_driver_register(&soc_driver); |
| 2647 | } |
| 2648 | |
Mark Brown | 7d8c16a | 2008-11-30 22:11:24 +0000 | [diff] [blame] | 2649 | static void __exit snd_soc_exit(void) |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2650 | { |
Mark Brown | 384c89e | 2008-12-03 17:34:03 +0000 | [diff] [blame] | 2651 | #ifdef CONFIG_DEBUG_FS |
| 2652 | debugfs_remove_recursive(debugfs_root); |
| 2653 | #endif |
Mark Brown | 3ff3f64 | 2008-05-19 12:32:25 +0200 | [diff] [blame] | 2654 | platform_driver_unregister(&soc_driver); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2655 | } |
| 2656 | |
| 2657 | module_init(snd_soc_init); |
| 2658 | module_exit(snd_soc_exit); |
| 2659 | |
| 2660 | /* Module information */ |
Liam Girdwood | d331124 | 2008-10-12 13:17:36 +0100 | [diff] [blame] | 2661 | MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk"); |
Frank Mandarino | db2a416 | 2006-10-06 18:31:09 +0200 | [diff] [blame] | 2662 | MODULE_DESCRIPTION("ALSA SoC Core"); |
| 2663 | MODULE_LICENSE("GPL"); |
Kay Sievers | 8b45a20 | 2008-04-14 13:33:36 +0200 | [diff] [blame] | 2664 | MODULE_ALIAS("platform:soc-audio"); |