diff options
Diffstat (limited to 'sound')
180 files changed, 20652 insertions, 3990 deletions
diff --git a/sound/aoa/fabrics/layout.c b/sound/aoa/fabrics/layout.c index fbf5c933baa4..586965f9605f 100644 --- a/sound/aoa/fabrics/layout.c +++ b/sound/aoa/fabrics/layout.c | |||
@@ -1037,7 +1037,7 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev) | |||
1037 | } | 1037 | } |
1038 | ldev->selfptr_headphone.ptr = ldev; | 1038 | ldev->selfptr_headphone.ptr = ldev; |
1039 | ldev->selfptr_lineout.ptr = ldev; | 1039 | ldev->selfptr_lineout.ptr = ldev; |
1040 | sdev->ofdev.dev.driver_data = ldev; | 1040 | dev_set_drvdata(&sdev->ofdev.dev, ldev); |
1041 | list_add(&ldev->list, &layouts_list); | 1041 | list_add(&ldev->list, &layouts_list); |
1042 | layouts_list_items++; | 1042 | layouts_list_items++; |
1043 | 1043 | ||
@@ -1081,7 +1081,7 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev) | |||
1081 | 1081 | ||
1082 | static int aoa_fabric_layout_remove(struct soundbus_dev *sdev) | 1082 | static int aoa_fabric_layout_remove(struct soundbus_dev *sdev) |
1083 | { | 1083 | { |
1084 | struct layout_dev *ldev = sdev->ofdev.dev.driver_data; | 1084 | struct layout_dev *ldev = dev_get_drvdata(&sdev->ofdev.dev); |
1085 | int i; | 1085 | int i; |
1086 | 1086 | ||
1087 | for (i=0; i<MAX_CODECS_PER_BUS; i++) { | 1087 | for (i=0; i<MAX_CODECS_PER_BUS; i++) { |
@@ -1114,7 +1114,7 @@ static int aoa_fabric_layout_remove(struct soundbus_dev *sdev) | |||
1114 | #ifdef CONFIG_PM | 1114 | #ifdef CONFIG_PM |
1115 | static int aoa_fabric_layout_suspend(struct soundbus_dev *sdev, pm_message_t state) | 1115 | static int aoa_fabric_layout_suspend(struct soundbus_dev *sdev, pm_message_t state) |
1116 | { | 1116 | { |
1117 | struct layout_dev *ldev = sdev->ofdev.dev.driver_data; | 1117 | struct layout_dev *ldev = dev_get_drvdata(&sdev->ofdev.dev); |
1118 | 1118 | ||
1119 | if (ldev->gpio.methods && ldev->gpio.methods->all_amps_off) | 1119 | if (ldev->gpio.methods && ldev->gpio.methods->all_amps_off) |
1120 | ldev->gpio.methods->all_amps_off(&ldev->gpio); | 1120 | ldev->gpio.methods->all_amps_off(&ldev->gpio); |
@@ -1124,7 +1124,7 @@ static int aoa_fabric_layout_suspend(struct soundbus_dev *sdev, pm_message_t sta | |||
1124 | 1124 | ||
1125 | static int aoa_fabric_layout_resume(struct soundbus_dev *sdev) | 1125 | static int aoa_fabric_layout_resume(struct soundbus_dev *sdev) |
1126 | { | 1126 | { |
1127 | struct layout_dev *ldev = sdev->ofdev.dev.driver_data; | 1127 | struct layout_dev *ldev = dev_get_drvdata(&sdev->ofdev.dev); |
1128 | 1128 | ||
1129 | if (ldev->gpio.methods && ldev->gpio.methods->all_amps_off) | 1129 | if (ldev->gpio.methods && ldev->gpio.methods->all_amps_off) |
1130 | ldev->gpio.methods->all_amps_restore(&ldev->gpio); | 1130 | ldev->gpio.methods->all_amps_restore(&ldev->gpio); |
diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c index 418c84c99d69..4e3b819d4993 100644 --- a/sound/aoa/soundbus/i2sbus/core.c +++ b/sound/aoa/soundbus/i2sbus/core.c | |||
@@ -358,14 +358,14 @@ static int i2sbus_probe(struct macio_dev* dev, const struct of_device_id *match) | |||
358 | return -ENODEV; | 358 | return -ENODEV; |
359 | } | 359 | } |
360 | 360 | ||
361 | dev->ofdev.dev.driver_data = control; | 361 | dev_set_drvdata(&dev->ofdev.dev, control); |
362 | 362 | ||
363 | return 0; | 363 | return 0; |
364 | } | 364 | } |
365 | 365 | ||
366 | static int i2sbus_remove(struct macio_dev* dev) | 366 | static int i2sbus_remove(struct macio_dev* dev) |
367 | { | 367 | { |
368 | struct i2sbus_control *control = dev->ofdev.dev.driver_data; | 368 | struct i2sbus_control *control = dev_get_drvdata(&dev->ofdev.dev); |
369 | struct i2sbus_dev *i2sdev, *tmp; | 369 | struct i2sbus_dev *i2sdev, *tmp; |
370 | 370 | ||
371 | list_for_each_entry_safe(i2sdev, tmp, &control->list, item) | 371 | list_for_each_entry_safe(i2sdev, tmp, &control->list, item) |
@@ -377,7 +377,7 @@ static int i2sbus_remove(struct macio_dev* dev) | |||
377 | #ifdef CONFIG_PM | 377 | #ifdef CONFIG_PM |
378 | static int i2sbus_suspend(struct macio_dev* dev, pm_message_t state) | 378 | static int i2sbus_suspend(struct macio_dev* dev, pm_message_t state) |
379 | { | 379 | { |
380 | struct i2sbus_control *control = dev->ofdev.dev.driver_data; | 380 | struct i2sbus_control *control = dev_get_drvdata(&dev->ofdev.dev); |
381 | struct codec_info_item *cii; | 381 | struct codec_info_item *cii; |
382 | struct i2sbus_dev* i2sdev; | 382 | struct i2sbus_dev* i2sdev; |
383 | int err, ret = 0; | 383 | int err, ret = 0; |
@@ -407,7 +407,7 @@ static int i2sbus_suspend(struct macio_dev* dev, pm_message_t state) | |||
407 | 407 | ||
408 | static int i2sbus_resume(struct macio_dev* dev) | 408 | static int i2sbus_resume(struct macio_dev* dev) |
409 | { | 409 | { |
410 | struct i2sbus_control *control = dev->ofdev.dev.driver_data; | 410 | struct i2sbus_control *control = dev_get_drvdata(&dev->ofdev.dev); |
411 | struct codec_info_item *cii; | 411 | struct codec_info_item *cii; |
412 | struct i2sbus_dev* i2sdev; | 412 | struct i2sbus_dev* i2sdev; |
413 | int err, ret = 0; | 413 | int err, ret = 0; |
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 7fbd68fab944..5c48e36038f2 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c | |||
@@ -1074,7 +1074,7 @@ static unsigned int __devinit aaci_size_fifo(struct aaci *aaci) | |||
1074 | return i; | 1074 | return i; |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | static int __devinit aaci_probe(struct amba_device *dev, void *id) | 1077 | static int __devinit aaci_probe(struct amba_device *dev, struct amba_id *id) |
1078 | { | 1078 | { |
1079 | struct aaci *aaci; | 1079 | struct aaci *aaci; |
1080 | int ret, i; | 1080 | int ret, i; |
diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c index a2c12d105c9a..6fdca97186e7 100644 --- a/sound/arm/pxa2xx-ac97-lib.c +++ b/sound/arm/pxa2xx-ac97-lib.c | |||
@@ -65,7 +65,7 @@ static void set_resetgpio_mode(int resetgpio_action) | |||
65 | switch (resetgpio_action) { | 65 | switch (resetgpio_action) { |
66 | case RESETGPIO_NORMAL_ALTFUNC: | 66 | case RESETGPIO_NORMAL_ALTFUNC: |
67 | if (reset_gpio == 113) | 67 | if (reset_gpio == 113) |
68 | mode = 113 | GPIO_OUT | GPIO_DFLT_LOW; | 68 | mode = 113 | GPIO_ALT_FN_2_OUT; |
69 | if (reset_gpio == 95) | 69 | if (reset_gpio == 95) |
70 | mode = 95 | GPIO_ALT_FN_1_OUT; | 70 | mode = 95 | GPIO_ALT_FN_1_OUT; |
71 | break; | 71 | break; |
diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 7bbdda041a99..6061fb5f4e1c 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig | |||
@@ -205,3 +205,5 @@ config SND_PCM_XRUN_DEBUG | |||
205 | 205 | ||
206 | config SND_VMASTER | 206 | config SND_VMASTER |
207 | bool | 207 | bool |
208 | |||
209 | source "sound/core/seq/Kconfig" | ||
diff --git a/sound/core/init.c b/sound/core/init.c index fd56afe846ed..d5d40d78c409 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -152,15 +152,8 @@ int snd_card_create(int idx, const char *xid, | |||
152 | card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL); | 152 | card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL); |
153 | if (!card) | 153 | if (!card) |
154 | return -ENOMEM; | 154 | return -ENOMEM; |
155 | if (xid) { | 155 | if (xid) |
156 | if (!snd_info_check_reserved_words(xid)) { | ||
157 | snd_printk(KERN_ERR | ||
158 | "given id string '%s' is reserved.\n", xid); | ||
159 | err = -EBUSY; | ||
160 | goto __error; | ||
161 | } | ||
162 | strlcpy(card->id, xid, sizeof(card->id)); | 156 | strlcpy(card->id, xid, sizeof(card->id)); |
163 | } | ||
164 | err = 0; | 157 | err = 0; |
165 | mutex_lock(&snd_card_mutex); | 158 | mutex_lock(&snd_card_mutex); |
166 | if (idx < 0) { | 159 | if (idx < 0) { |
@@ -483,22 +476,28 @@ int snd_card_free(struct snd_card *card) | |||
483 | 476 | ||
484 | EXPORT_SYMBOL(snd_card_free); | 477 | EXPORT_SYMBOL(snd_card_free); |
485 | 478 | ||
486 | static void choose_default_id(struct snd_card *card) | 479 | static void snd_card_set_id_no_lock(struct snd_card *card, const char *nid) |
487 | { | 480 | { |
488 | int i, len, idx_flag = 0, loops = SNDRV_CARDS; | 481 | int i, len, idx_flag = 0, loops = SNDRV_CARDS; |
489 | char *id, *spos; | 482 | const char *spos, *src; |
483 | char *id; | ||
490 | 484 | ||
491 | id = spos = card->shortname; | 485 | if (nid == NULL) { |
492 | while (*id != '\0') { | 486 | id = card->shortname; |
493 | if (*id == ' ') | 487 | spos = src = id; |
494 | spos = id + 1; | 488 | while (*id != '\0') { |
495 | id++; | 489 | if (*id == ' ') |
490 | spos = id + 1; | ||
491 | id++; | ||
492 | } | ||
493 | } else { | ||
494 | spos = src = nid; | ||
496 | } | 495 | } |
497 | id = card->id; | 496 | id = card->id; |
498 | while (*spos != '\0' && !isalnum(*spos)) | 497 | while (*spos != '\0' && !isalnum(*spos)) |
499 | spos++; | 498 | spos++; |
500 | if (isdigit(*spos)) | 499 | if (isdigit(*spos)) |
501 | *id++ = isalpha(card->shortname[0]) ? card->shortname[0] : 'D'; | 500 | *id++ = isalpha(src[0]) ? src[0] : 'D'; |
502 | while (*spos != '\0' && (size_t)(id - card->id) < sizeof(card->id) - 1) { | 501 | while (*spos != '\0' && (size_t)(id - card->id) < sizeof(card->id) - 1) { |
503 | if (isalnum(*spos)) | 502 | if (isalnum(*spos)) |
504 | *id++ = *spos; | 503 | *id++ = *spos; |
@@ -513,7 +512,7 @@ static void choose_default_id(struct snd_card *card) | |||
513 | 512 | ||
514 | while (1) { | 513 | while (1) { |
515 | if (loops-- == 0) { | 514 | if (loops-- == 0) { |
516 | snd_printk(KERN_ERR "unable to choose default card id (%s)\n", id); | 515 | snd_printk(KERN_ERR "unable to set card id (%s)\n", id); |
517 | strcpy(card->id, card->proc_root->name); | 516 | strcpy(card->id, card->proc_root->name); |
518 | return; | 517 | return; |
519 | } | 518 | } |
@@ -539,14 +538,33 @@ static void choose_default_id(struct snd_card *card) | |||
539 | spos = id + len - 2; | 538 | spos = id + len - 2; |
540 | if ((size_t)len <= sizeof(card->id) - 2) | 539 | if ((size_t)len <= sizeof(card->id) - 2) |
541 | spos++; | 540 | spos++; |
542 | *spos++ = '_'; | 541 | *(char *)spos++ = '_'; |
543 | *spos++ = '1'; | 542 | *(char *)spos++ = '1'; |
544 | *spos++ = '\0'; | 543 | *(char *)spos++ = '\0'; |
545 | idx_flag++; | 544 | idx_flag++; |
546 | } | 545 | } |
547 | } | 546 | } |
548 | } | 547 | } |
549 | 548 | ||
549 | /** | ||
550 | * snd_card_set_id - set card identification name | ||
551 | * @card: soundcard structure | ||
552 | * @nid: new identification string | ||
553 | * | ||
554 | * This function sets the card identification and checks for name | ||
555 | * collisions. | ||
556 | */ | ||
557 | void snd_card_set_id(struct snd_card *card, const char *nid) | ||
558 | { | ||
559 | /* check if user specified own card->id */ | ||
560 | if (card->id[0] != '\0') | ||
561 | return; | ||
562 | mutex_lock(&snd_card_mutex); | ||
563 | snd_card_set_id_no_lock(card, nid); | ||
564 | mutex_unlock(&snd_card_mutex); | ||
565 | } | ||
566 | EXPORT_SYMBOL(snd_card_set_id); | ||
567 | |||
550 | #ifndef CONFIG_SYSFS_DEPRECATED | 568 | #ifndef CONFIG_SYSFS_DEPRECATED |
551 | static ssize_t | 569 | static ssize_t |
552 | card_id_show_attr(struct device *dev, | 570 | card_id_show_attr(struct device *dev, |
@@ -640,8 +658,7 @@ int snd_card_register(struct snd_card *card) | |||
640 | mutex_unlock(&snd_card_mutex); | 658 | mutex_unlock(&snd_card_mutex); |
641 | return 0; | 659 | return 0; |
642 | } | 660 | } |
643 | if (card->id[0] == '\0') | 661 | snd_card_set_id_no_lock(card, card->id[0] == '\0' ? NULL : card->id); |
644 | choose_default_id(card); | ||
645 | snd_cards[card->number] = card; | 662 | snd_cards[card->number] = card; |
646 | mutex_unlock(&snd_card_mutex); | 663 | mutex_unlock(&snd_card_mutex); |
647 | init_info_for_card(card); | 664 | init_info_for_card(card); |
diff --git a/sound/core/jack.c b/sound/core/jack.c index d54d1a05fe65..f705eec7372a 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c | |||
@@ -63,7 +63,7 @@ static int snd_jack_dev_register(struct snd_device *device) | |||
63 | 63 | ||
64 | /* Default to the sound card device. */ | 64 | /* Default to the sound card device. */ |
65 | if (!jack->input_dev->dev.parent) | 65 | if (!jack->input_dev->dev.parent) |
66 | jack->input_dev->dev.parent = card->dev; | 66 | jack->input_dev->dev.parent = snd_card_get_device_link(card); |
67 | 67 | ||
68 | err = input_register_device(jack->input_dev); | 68 | err = input_register_device(jack->input_dev); |
69 | if (err == 0) | 69 | if (err == 0) |
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index dda000b9684c..dbe406b82591 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/time.h> | 31 | #include <linux/time.h> |
32 | #include <linux/vmalloc.h> | 32 | #include <linux/vmalloc.h> |
33 | #include <linux/moduleparam.h> | 33 | #include <linux/moduleparam.h> |
34 | #include <linux/math64.h> | ||
34 | #include <linux/string.h> | 35 | #include <linux/string.h> |
35 | #include <sound/core.h> | 36 | #include <sound/core.h> |
36 | #include <sound/minors.h> | 37 | #include <sound/minors.h> |
@@ -617,9 +618,7 @@ static long snd_pcm_oss_bytes(struct snd_pcm_substream *substream, long frames) | |||
617 | #else | 618 | #else |
618 | { | 619 | { |
619 | u64 bsize = (u64)runtime->oss.buffer_bytes * (u64)bytes; | 620 | u64 bsize = (u64)runtime->oss.buffer_bytes * (u64)bytes; |
620 | u32 rem; | 621 | return div_u64(bsize, buffer_size); |
621 | div64_32(&bsize, buffer_size, &rem); | ||
622 | return (long)bsize; | ||
623 | } | 622 | } |
624 | #endif | 623 | #endif |
625 | } | 624 | } |
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index a2a792c18c40..333e4dd29450 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/time.h> | 24 | #include <linux/time.h> |
25 | #include <linux/math64.h> | ||
25 | #include <sound/core.h> | 26 | #include <sound/core.h> |
26 | #include <sound/control.h> | 27 | #include <sound/control.h> |
27 | #include <sound/info.h> | 28 | #include <sound/info.h> |
@@ -126,24 +127,37 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram | |||
126 | } | 127 | } |
127 | 128 | ||
128 | #ifdef CONFIG_SND_PCM_XRUN_DEBUG | 129 | #ifdef CONFIG_SND_PCM_XRUN_DEBUG |
129 | #define xrun_debug(substream) ((substream)->pstr->xrun_debug) | 130 | #define xrun_debug(substream, mask) ((substream)->pstr->xrun_debug & (mask)) |
130 | #else | 131 | #else |
131 | #define xrun_debug(substream) 0 | 132 | #define xrun_debug(substream, mask) 0 |
132 | #endif | 133 | #endif |
133 | 134 | ||
134 | #define dump_stack_on_xrun(substream) do { \ | 135 | #define dump_stack_on_xrun(substream) do { \ |
135 | if (xrun_debug(substream) > 1) \ | 136 | if (xrun_debug(substream, 2)) \ |
136 | dump_stack(); \ | 137 | dump_stack(); \ |
137 | } while (0) | 138 | } while (0) |
138 | 139 | ||
140 | static void pcm_debug_name(struct snd_pcm_substream *substream, | ||
141 | char *name, size_t len) | ||
142 | { | ||
143 | snprintf(name, len, "pcmC%dD%d%c:%d", | ||
144 | substream->pcm->card->number, | ||
145 | substream->pcm->device, | ||
146 | substream->stream ? 'c' : 'p', | ||
147 | substream->number); | ||
148 | } | ||
149 | |||
139 | static void xrun(struct snd_pcm_substream *substream) | 150 | static void xrun(struct snd_pcm_substream *substream) |
140 | { | 151 | { |
152 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
153 | |||
154 | if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) | ||
155 | snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); | ||
141 | snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); | 156 | snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); |
142 | if (xrun_debug(substream)) { | 157 | if (xrun_debug(substream, 1)) { |
143 | snd_printd(KERN_DEBUG "XRUN: pcmC%dD%d%c\n", | 158 | char name[16]; |
144 | substream->pcm->card->number, | 159 | pcm_debug_name(substream, name, sizeof(name)); |
145 | substream->pcm->device, | 160 | snd_printd(KERN_DEBUG "XRUN: %s\n", name); |
146 | substream->stream ? 'c' : 'p'); | ||
147 | dump_stack_on_xrun(substream); | 161 | dump_stack_on_xrun(substream); |
148 | } | 162 | } |
149 | } | 163 | } |
@@ -154,16 +168,16 @@ snd_pcm_update_hw_ptr_pos(struct snd_pcm_substream *substream, | |||
154 | { | 168 | { |
155 | snd_pcm_uframes_t pos; | 169 | snd_pcm_uframes_t pos; |
156 | 170 | ||
157 | if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) | ||
158 | snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); | ||
159 | pos = substream->ops->pointer(substream); | 171 | pos = substream->ops->pointer(substream); |
160 | if (pos == SNDRV_PCM_POS_XRUN) | 172 | if (pos == SNDRV_PCM_POS_XRUN) |
161 | return pos; /* XRUN */ | 173 | return pos; /* XRUN */ |
162 | if (pos >= runtime->buffer_size) { | 174 | if (pos >= runtime->buffer_size) { |
163 | if (printk_ratelimit()) { | 175 | if (printk_ratelimit()) { |
164 | snd_printd(KERN_ERR "BUG: stream = %i, pos = 0x%lx, " | 176 | char name[16]; |
177 | pcm_debug_name(substream, name, sizeof(name)); | ||
178 | snd_printd(KERN_ERR "BUG: %s, pos = 0x%lx, " | ||
165 | "buffer size = 0x%lx, period size = 0x%lx\n", | 179 | "buffer size = 0x%lx, period size = 0x%lx\n", |
166 | substream->stream, pos, runtime->buffer_size, | 180 | name, pos, runtime->buffer_size, |
167 | runtime->period_size); | 181 | runtime->period_size); |
168 | } | 182 | } |
169 | pos = 0; | 183 | pos = 0; |
@@ -197,7 +211,7 @@ static int snd_pcm_update_hw_ptr_post(struct snd_pcm_substream *substream, | |||
197 | 211 | ||
198 | #define hw_ptr_error(substream, fmt, args...) \ | 212 | #define hw_ptr_error(substream, fmt, args...) \ |
199 | do { \ | 213 | do { \ |
200 | if (xrun_debug(substream)) { \ | 214 | if (xrun_debug(substream, 1)) { \ |
201 | if (printk_ratelimit()) { \ | 215 | if (printk_ratelimit()) { \ |
202 | snd_printd("PCM: " fmt, ##args); \ | 216 | snd_printd("PCM: " fmt, ##args); \ |
203 | } \ | 217 | } \ |
@@ -249,6 +263,11 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | |||
249 | new_hw_ptr = hw_base + pos; | 263 | new_hw_ptr = hw_base + pos; |
250 | } | 264 | } |
251 | } | 265 | } |
266 | |||
267 | /* Do jiffies check only in xrun_debug mode */ | ||
268 | if (!xrun_debug(substream, 4)) | ||
269 | goto no_jiffies_check; | ||
270 | |||
252 | /* Skip the jiffies check for hardwares with BATCH flag. | 271 | /* Skip the jiffies check for hardwares with BATCH flag. |
253 | * Such hardware usually just increases the position at each IRQ, | 272 | * Such hardware usually just increases the position at each IRQ, |
254 | * thus it can't give any strange position. | 273 | * thus it can't give any strange position. |
@@ -256,6 +275,9 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | |||
256 | if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) | 275 | if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) |
257 | goto no_jiffies_check; | 276 | goto no_jiffies_check; |
258 | hdelta = new_hw_ptr - old_hw_ptr; | 277 | hdelta = new_hw_ptr - old_hw_ptr; |
278 | if (hdelta < runtime->delay) | ||
279 | goto no_jiffies_check; | ||
280 | hdelta -= runtime->delay; | ||
259 | jdelta = jiffies - runtime->hw_ptr_jiffies; | 281 | jdelta = jiffies - runtime->hw_ptr_jiffies; |
260 | if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { | 282 | if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { |
261 | delta = jdelta / | 283 | delta = jdelta / |
@@ -289,14 +311,20 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | |||
289 | hw_ptr_interrupt = | 311 | hw_ptr_interrupt = |
290 | new_hw_ptr - new_hw_ptr % runtime->period_size; | 312 | new_hw_ptr - new_hw_ptr % runtime->period_size; |
291 | } | 313 | } |
314 | runtime->hw_ptr_interrupt = hw_ptr_interrupt; | ||
315 | |||
292 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && | 316 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && |
293 | runtime->silence_size > 0) | 317 | runtime->silence_size > 0) |
294 | snd_pcm_playback_silence(substream, new_hw_ptr); | 318 | snd_pcm_playback_silence(substream, new_hw_ptr); |
295 | 319 | ||
320 | if (runtime->status->hw_ptr == new_hw_ptr) | ||
321 | return 0; | ||
322 | |||
296 | runtime->hw_ptr_base = hw_base; | 323 | runtime->hw_ptr_base = hw_base; |
297 | runtime->status->hw_ptr = new_hw_ptr; | 324 | runtime->status->hw_ptr = new_hw_ptr; |
298 | runtime->hw_ptr_jiffies = jiffies; | 325 | runtime->hw_ptr_jiffies = jiffies; |
299 | runtime->hw_ptr_interrupt = hw_ptr_interrupt; | 326 | if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) |
327 | snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); | ||
300 | 328 | ||
301 | return snd_pcm_update_hw_ptr_post(substream, runtime); | 329 | return snd_pcm_update_hw_ptr_post(substream, runtime); |
302 | } | 330 | } |
@@ -336,6 +364,12 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) | |||
336 | hw_base = 0; | 364 | hw_base = 0; |
337 | new_hw_ptr = hw_base + pos; | 365 | new_hw_ptr = hw_base + pos; |
338 | } | 366 | } |
367 | /* Do jiffies check only in xrun_debug mode */ | ||
368 | if (!xrun_debug(substream, 4)) | ||
369 | goto no_jiffies_check; | ||
370 | if (delta < runtime->delay) | ||
371 | goto no_jiffies_check; | ||
372 | delta -= runtime->delay; | ||
339 | if (((delta * HZ) / runtime->rate) > jdelta + HZ/100) { | 373 | if (((delta * HZ) / runtime->rate) > jdelta + HZ/100) { |
340 | hw_ptr_error(substream, | 374 | hw_ptr_error(substream, |
341 | "hw_ptr skipping! " | 375 | "hw_ptr skipping! " |
@@ -345,13 +379,19 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) | |||
345 | ((delta * HZ) / runtime->rate)); | 379 | ((delta * HZ) / runtime->rate)); |
346 | return 0; | 380 | return 0; |
347 | } | 381 | } |
382 | no_jiffies_check: | ||
348 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && | 383 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && |
349 | runtime->silence_size > 0) | 384 | runtime->silence_size > 0) |
350 | snd_pcm_playback_silence(substream, new_hw_ptr); | 385 | snd_pcm_playback_silence(substream, new_hw_ptr); |
351 | 386 | ||
387 | if (runtime->status->hw_ptr == new_hw_ptr) | ||
388 | return 0; | ||
389 | |||
352 | runtime->hw_ptr_base = hw_base; | 390 | runtime->hw_ptr_base = hw_base; |
353 | runtime->status->hw_ptr = new_hw_ptr; | 391 | runtime->status->hw_ptr = new_hw_ptr; |
354 | runtime->hw_ptr_jiffies = jiffies; | 392 | runtime->hw_ptr_jiffies = jiffies; |
393 | if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) | ||
394 | snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); | ||
355 | 395 | ||
356 | return snd_pcm_update_hw_ptr_post(substream, runtime); | 396 | return snd_pcm_update_hw_ptr_post(substream, runtime); |
357 | } | 397 | } |
@@ -445,7 +485,7 @@ static inline unsigned int muldiv32(unsigned int a, unsigned int b, | |||
445 | *r = 0; | 485 | *r = 0; |
446 | return UINT_MAX; | 486 | return UINT_MAX; |
447 | } | 487 | } |
448 | div64_32(&n, c, r); | 488 | n = div_u64_rem(n, c, r); |
449 | if (n >= UINT_MAX) { | 489 | if (n >= UINT_MAX) { |
450 | *r = 0; | 490 | *r = 0; |
451 | return UINT_MAX; | 491 | return UINT_MAX; |
@@ -1478,7 +1518,6 @@ static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, | |||
1478 | runtime->status->hw_ptr %= runtime->buffer_size; | 1518 | runtime->status->hw_ptr %= runtime->buffer_size; |
1479 | else | 1519 | else |
1480 | runtime->status->hw_ptr = 0; | 1520 | runtime->status->hw_ptr = 0; |
1481 | runtime->hw_ptr_jiffies = jiffies; | ||
1482 | snd_pcm_stream_unlock_irqrestore(substream, flags); | 1521 | snd_pcm_stream_unlock_irqrestore(substream, flags); |
1483 | return 0; | 1522 | return 0; |
1484 | } | 1523 | } |
@@ -1518,6 +1557,23 @@ static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream, | |||
1518 | return 0; | 1557 | return 0; |
1519 | } | 1558 | } |
1520 | 1559 | ||
1560 | static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream, | ||
1561 | void *arg) | ||
1562 | { | ||
1563 | struct snd_pcm_hw_params *params = arg; | ||
1564 | snd_pcm_format_t format; | ||
1565 | int channels, width; | ||
1566 | |||
1567 | params->fifo_size = substream->runtime->hw.fifo_size; | ||
1568 | if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { | ||
1569 | format = params_format(params); | ||
1570 | channels = params_channels(params); | ||
1571 | width = snd_pcm_format_physical_width(format); | ||
1572 | params->fifo_size /= width * channels; | ||
1573 | } | ||
1574 | return 0; | ||
1575 | } | ||
1576 | |||
1521 | /** | 1577 | /** |
1522 | * snd_pcm_lib_ioctl - a generic PCM ioctl callback | 1578 | * snd_pcm_lib_ioctl - a generic PCM ioctl callback |
1523 | * @substream: the pcm substream instance | 1579 | * @substream: the pcm substream instance |
@@ -1539,6 +1595,8 @@ int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, | |||
1539 | return snd_pcm_lib_ioctl_reset(substream, arg); | 1595 | return snd_pcm_lib_ioctl_reset(substream, arg); |
1540 | case SNDRV_PCM_IOCTL1_CHANNEL_INFO: | 1596 | case SNDRV_PCM_IOCTL1_CHANNEL_INFO: |
1541 | return snd_pcm_lib_ioctl_channel_info(substream, arg); | 1597 | return snd_pcm_lib_ioctl_channel_info(substream, arg); |
1598 | case SNDRV_PCM_IOCTL1_FIFO_SIZE: | ||
1599 | return snd_pcm_lib_ioctl_fifo_size(substream, arg); | ||
1542 | } | 1600 | } |
1543 | return -ENXIO; | 1601 | return -ENXIO; |
1544 | } | 1602 | } |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index fc6f98e257df..84da3ba17c86 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -312,9 +312,18 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream, | |||
312 | 312 | ||
313 | hw = &substream->runtime->hw; | 313 | hw = &substream->runtime->hw; |
314 | if (!params->info) | 314 | if (!params->info) |
315 | params->info = hw->info; | 315 | params->info = hw->info & ~SNDRV_PCM_INFO_FIFO_IN_FRAMES; |
316 | if (!params->fifo_size) | 316 | if (!params->fifo_size) { |
317 | params->fifo_size = hw->fifo_size; | 317 | if (snd_mask_min(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT]) == |
318 | snd_mask_max(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT]) && | ||
319 | snd_mask_min(¶ms->masks[SNDRV_PCM_HW_PARAM_CHANNELS]) == | ||
320 | snd_mask_max(¶ms->masks[SNDRV_PCM_HW_PARAM_CHANNELS])) { | ||
321 | changed = substream->ops->ioctl(substream, | ||
322 | SNDRV_PCM_IOCTL1_FIFO_SIZE, params); | ||
323 | if (params < 0) | ||
324 | return changed; | ||
325 | } | ||
326 | } | ||
318 | params->rmask = 0; | 327 | params->rmask = 0; |
319 | return 0; | 328 | return 0; |
320 | } | 329 | } |
@@ -587,14 +596,15 @@ int snd_pcm_status(struct snd_pcm_substream *substream, | |||
587 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 596 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
588 | status->avail = snd_pcm_playback_avail(runtime); | 597 | status->avail = snd_pcm_playback_avail(runtime); |
589 | if (runtime->status->state == SNDRV_PCM_STATE_RUNNING || | 598 | if (runtime->status->state == SNDRV_PCM_STATE_RUNNING || |
590 | runtime->status->state == SNDRV_PCM_STATE_DRAINING) | 599 | runtime->status->state == SNDRV_PCM_STATE_DRAINING) { |
591 | status->delay = runtime->buffer_size - status->avail; | 600 | status->delay = runtime->buffer_size - status->avail; |
592 | else | 601 | status->delay += runtime->delay; |
602 | } else | ||
593 | status->delay = 0; | 603 | status->delay = 0; |
594 | } else { | 604 | } else { |
595 | status->avail = snd_pcm_capture_avail(runtime); | 605 | status->avail = snd_pcm_capture_avail(runtime); |
596 | if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) | 606 | if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) |
597 | status->delay = status->avail; | 607 | status->delay = status->avail + runtime->delay; |
598 | else | 608 | else |
599 | status->delay = 0; | 609 | status->delay = 0; |
600 | } | 610 | } |
@@ -848,6 +858,7 @@ static void snd_pcm_post_start(struct snd_pcm_substream *substream, int state) | |||
848 | { | 858 | { |
849 | struct snd_pcm_runtime *runtime = substream->runtime; | 859 | struct snd_pcm_runtime *runtime = substream->runtime; |
850 | snd_pcm_trigger_tstamp(substream); | 860 | snd_pcm_trigger_tstamp(substream); |
861 | runtime->hw_ptr_jiffies = jiffies; | ||
851 | runtime->status->state = state; | 862 | runtime->status->state = state; |
852 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && | 863 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && |
853 | runtime->silence_size > 0) | 864 | runtime->silence_size > 0) |
@@ -961,6 +972,11 @@ static int snd_pcm_do_pause(struct snd_pcm_substream *substream, int push) | |||
961 | { | 972 | { |
962 | if (substream->runtime->trigger_master != substream) | 973 | if (substream->runtime->trigger_master != substream) |
963 | return 0; | 974 | return 0; |
975 | /* The jiffies check in snd_pcm_update_hw_ptr*() is done by | ||
976 | * a delta betwen the current jiffies, this gives a large enough | ||
977 | * delta, effectively to skip the check once. | ||
978 | */ | ||
979 | substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; | ||
964 | return substream->ops->trigger(substream, | 980 | return substream->ops->trigger(substream, |
965 | push ? SNDRV_PCM_TRIGGER_PAUSE_PUSH : | 981 | push ? SNDRV_PCM_TRIGGER_PAUSE_PUSH : |
966 | SNDRV_PCM_TRIGGER_PAUSE_RELEASE); | 982 | SNDRV_PCM_TRIGGER_PAUSE_RELEASE); |
@@ -2404,6 +2420,7 @@ static int snd_pcm_delay(struct snd_pcm_substream *substream, | |||
2404 | n = snd_pcm_playback_hw_avail(runtime); | 2420 | n = snd_pcm_playback_hw_avail(runtime); |
2405 | else | 2421 | else |
2406 | n = snd_pcm_capture_avail(runtime); | 2422 | n = snd_pcm_capture_avail(runtime); |
2423 | n += runtime->delay; | ||
2407 | break; | 2424 | break; |
2408 | case SNDRV_PCM_STATE_XRUN: | 2425 | case SNDRV_PCM_STATE_XRUN: |
2409 | err = -EPIPE; | 2426 | err = -EPIPE; |
diff --git a/sound/core/seq/Kconfig b/sound/core/seq/Kconfig new file mode 100644 index 000000000000..b851fd890a89 --- /dev/null +++ b/sound/core/seq/Kconfig | |||
@@ -0,0 +1,16 @@ | |||
1 | # define SND_XXX_SEQ to min(SND_SEQUENCER,SND_XXX) | ||
2 | |||
3 | config SND_RAWMIDI_SEQ | ||
4 | def_tristate SND_SEQUENCER && SND_RAWMIDI | ||
5 | |||
6 | config SND_OPL3_LIB_SEQ | ||
7 | def_tristate SND_SEQUENCER && SND_OPL3_LIB | ||
8 | |||
9 | config SND_OPL4_LIB_SEQ | ||
10 | def_tristate SND_SEQUENCER && SND_OPL4_LIB | ||
11 | |||
12 | config SND_SBAWE_SEQ | ||
13 | def_tristate SND_SEQUENCER && SND_SBAWE | ||
14 | |||
15 | config SND_EMU10K1_SEQ | ||
16 | def_tristate SND_SEQUENCER && SND_EMU10K1 | ||
diff --git a/sound/core/seq/Makefile b/sound/core/seq/Makefile index 069593717fba..1bcb360330e5 100644 --- a/sound/core/seq/Makefile +++ b/sound/core/seq/Makefile | |||
@@ -17,14 +17,6 @@ snd-seq-midi-event-objs := seq_midi_event.o | |||
17 | snd-seq-dummy-objs := seq_dummy.o | 17 | snd-seq-dummy-objs := seq_dummy.o |
18 | snd-seq-virmidi-objs := seq_virmidi.o | 18 | snd-seq-virmidi-objs := seq_virmidi.o |
19 | 19 | ||
20 | # | ||
21 | # this function returns: | ||
22 | # "m" - CONFIG_SND_SEQUENCER is m | ||
23 | # <empty string> - CONFIG_SND_SEQUENCER is undefined | ||
24 | # otherwise parameter #1 value | ||
25 | # | ||
26 | sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1))) | ||
27 | |||
28 | obj-$(CONFIG_SND_SEQUENCER) += snd-seq.o snd-seq-device.o | 20 | obj-$(CONFIG_SND_SEQUENCER) += snd-seq.o snd-seq-device.o |
29 | ifeq ($(CONFIG_SND_SEQUENCER_OSS),y) | 21 | ifeq ($(CONFIG_SND_SEQUENCER_OSS),y) |
30 | obj-$(CONFIG_SND_SEQUENCER) += snd-seq-midi-event.o | 22 | obj-$(CONFIG_SND_SEQUENCER) += snd-seq-midi-event.o |
@@ -33,8 +25,8 @@ obj-$(CONFIG_SND_SEQ_DUMMY) += snd-seq-dummy.o | |||
33 | 25 | ||
34 | # Toplevel Module Dependency | 26 | # Toplevel Module Dependency |
35 | obj-$(CONFIG_SND_VIRMIDI) += snd-seq-virmidi.o snd-seq-midi-event.o | 27 | obj-$(CONFIG_SND_VIRMIDI) += snd-seq-virmidi.o snd-seq-midi-event.o |
36 | obj-$(call sequencer,$(CONFIG_SND_RAWMIDI)) += snd-seq-midi.o snd-seq-midi-event.o | 28 | obj-$(CONFIG_SND_RAWMIDI_SEQ) += snd-seq-midi.o snd-seq-midi-event.o |
37 | obj-$(call sequencer,$(CONFIG_SND_OPL3_LIB)) += snd-seq-midi-event.o snd-seq-midi-emul.o | 29 | obj-$(CONFIG_SND_OPL3_LIB_SEQ) += snd-seq-midi-event.o snd-seq-midi-emul.o |
38 | obj-$(call sequencer,$(CONFIG_SND_OPL4_LIB)) += snd-seq-midi-event.o snd-seq-midi-emul.o | 30 | obj-$(CONFIG_SND_OPL4_LIB_SEQ) += snd-seq-midi-event.o snd-seq-midi-emul.o |
39 | obj-$(call sequencer,$(CONFIG_SND_SBAWE)) += snd-seq-midi-emul.o snd-seq-virmidi.o | 31 | obj-$(CONFIG_SND_SBAWE_SEQ) += snd-seq-midi-emul.o snd-seq-virmidi.o |
40 | obj-$(call sequencer,$(CONFIG_SND_EMU10K1)) += snd-seq-midi-emul.o snd-seq-virmidi.o | 32 | obj-$(CONFIG_SND_EMU10K1_SEQ) += snd-seq-midi-emul.o snd-seq-virmidi.o |
diff --git a/sound/drivers/opl3/Makefile b/sound/drivers/opl3/Makefile index 19767a6a5c54..7f2c2a10c4e5 100644 --- a/sound/drivers/opl3/Makefile +++ b/sound/drivers/opl3/Makefile | |||
@@ -7,14 +7,6 @@ snd-opl3-lib-objs := opl3_lib.o opl3_synth.o | |||
7 | snd-opl3-synth-y := opl3_seq.o opl3_midi.o opl3_drums.o | 7 | snd-opl3-synth-y := opl3_seq.o opl3_midi.o opl3_drums.o |
8 | snd-opl3-synth-$(CONFIG_SND_SEQUENCER_OSS) += opl3_oss.o | 8 | snd-opl3-synth-$(CONFIG_SND_SEQUENCER_OSS) += opl3_oss.o |
9 | 9 | ||
10 | # | ||
11 | # this function returns: | ||
12 | # "m" - CONFIG_SND_SEQUENCER is m | ||
13 | # <empty string> - CONFIG_SND_SEQUENCER is undefined | ||
14 | # otherwise parameter #1 value | ||
15 | # | ||
16 | sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1))) | ||
17 | |||
18 | obj-$(CONFIG_SND_OPL3_LIB) += snd-opl3-lib.o | 10 | obj-$(CONFIG_SND_OPL3_LIB) += snd-opl3-lib.o |
19 | obj-$(CONFIG_SND_OPL4_LIB) += snd-opl3-lib.o | 11 | obj-$(CONFIG_SND_OPL4_LIB) += snd-opl3-lib.o |
20 | obj-$(call sequencer,$(CONFIG_SND_OPL3_LIB)) += snd-opl3-synth.o | 12 | obj-$(CONFIG_SND_OPL3_LIB_SEQ) += snd-opl3-synth.o |
diff --git a/sound/drivers/opl4/Makefile b/sound/drivers/opl4/Makefile index d178b39ffa60..b94009b0b19f 100644 --- a/sound/drivers/opl4/Makefile +++ b/sound/drivers/opl4/Makefile | |||
@@ -6,13 +6,5 @@ | |||
6 | snd-opl4-lib-objs := opl4_lib.o opl4_mixer.o opl4_proc.o | 6 | snd-opl4-lib-objs := opl4_lib.o opl4_mixer.o opl4_proc.o |
7 | snd-opl4-synth-objs := opl4_seq.o opl4_synth.o yrw801.o | 7 | snd-opl4-synth-objs := opl4_seq.o opl4_synth.o yrw801.o |
8 | 8 | ||
9 | # | ||
10 | # this function returns: | ||
11 | # "m" - CONFIG_SND_SEQUENCER is m | ||
12 | # <empty string> - CONFIG_SND_SEQUENCER is undefined | ||
13 | # otherwise parameter #1 value | ||
14 | # | ||
15 | sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1))) | ||
16 | |||
17 | obj-$(CONFIG_SND_OPL4_LIB) += snd-opl4-lib.o | 9 | obj-$(CONFIG_SND_OPL4_LIB) += snd-opl4-lib.o |
18 | obj-$(call sequencer,$(CONFIG_SND_OPL4_LIB)) += snd-opl4-synth.o | 10 | obj-$(CONFIG_SND_OPL4_LIB_SEQ) += snd-opl4-synth.o |
diff --git a/sound/drivers/pcsp/pcsp_mixer.c b/sound/drivers/pcsp/pcsp_mixer.c index caeb0f57fcca..199b03377142 100644 --- a/sound/drivers/pcsp/pcsp_mixer.c +++ b/sound/drivers/pcsp/pcsp_mixer.c | |||
@@ -50,8 +50,8 @@ static int pcsp_treble_info(struct snd_kcontrol *kcontrol, | |||
50 | uinfo->value.enumerated.items = chip->max_treble + 1; | 50 | uinfo->value.enumerated.items = chip->max_treble + 1; |
51 | if (uinfo->value.enumerated.item > chip->max_treble) | 51 | if (uinfo->value.enumerated.item > chip->max_treble) |
52 | uinfo->value.enumerated.item = chip->max_treble; | 52 | uinfo->value.enumerated.item = chip->max_treble; |
53 | sprintf(uinfo->value.enumerated.name, "%d", | 53 | sprintf(uinfo->value.enumerated.name, "%lu", |
54 | PCSP_CALC_RATE(uinfo->value.enumerated.item)); | 54 | (unsigned long)PCSP_CALC_RATE(uinfo->value.enumerated.item)); |
55 | return 0; | 55 | return 0; |
56 | } | 56 | } |
57 | 57 | ||
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index b2b6d50c9425..a25fb7b1f441 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c | |||
@@ -963,16 +963,11 @@ static int __devinit snd_serial_probe(struct platform_device *devptr) | |||
963 | if (err < 0) | 963 | if (err < 0) |
964 | goto _err; | 964 | goto _err; |
965 | 965 | ||
966 | sprintf(card->longname, "%s at 0x%lx, irq %d speed %d div %d outs %d ins %d adaptor %s droponfull %d", | 966 | sprintf(card->longname, "%s [%s] at %#lx, irq %d", |
967 | card->shortname, | 967 | card->shortname, |
968 | uart->base, | ||
969 | uart->irq, | ||
970 | uart->speed, | ||
971 | (int)uart->divisor, | ||
972 | outs[dev], | ||
973 | ins[dev], | ||
974 | adaptor_names[uart->adaptor], | 968 | adaptor_names[uart->adaptor], |
975 | uart->drop_on_full); | 969 | uart->base, |
970 | uart->irq); | ||
976 | 971 | ||
977 | snd_card_set_dev(card, &devptr->dev); | 972 | snd_card_set_dev(card, &devptr->dev); |
978 | 973 | ||
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index c6942a4de99b..51a7e3777e17 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig | |||
@@ -177,15 +177,18 @@ config SND_ES18XX | |||
177 | will be called snd-es18xx. | 177 | will be called snd-es18xx. |
178 | 178 | ||
179 | config SND_SC6000 | 179 | config SND_SC6000 |
180 | tristate "Gallant SC-6000, Audio Excel DSP 16" | 180 | tristate "Gallant SC-6000/6600/7000 and Audio Excel DSP 16" |
181 | depends on HAS_IOPORT | 181 | depends on HAS_IOPORT |
182 | select SND_WSS_LIB | 182 | select SND_WSS_LIB |
183 | select SND_OPL3_LIB | 183 | select SND_OPL3_LIB |
184 | select SND_MPU401_UART | 184 | select SND_MPU401_UART |
185 | help | 185 | help |
186 | Say Y here to include support for Gallant SC-6000 card and clones: | 186 | Say Y here to include support for Gallant SC-6000, SC-6600, SC-7000 |
187 | cards and clones: | ||
187 | Audio Excel DSP 16 and Zoltrix AV302. | 188 | Audio Excel DSP 16 and Zoltrix AV302. |
188 | 189 | ||
190 | These cards are based on CompuMedia ASC-9308 or ASC-9408 chips. | ||
191 | |||
189 | To compile this driver as a module, choose M here: the module | 192 | To compile this driver as a module, choose M here: the module |
190 | will be called snd-sc6000. | 193 | will be called snd-sc6000. |
191 | 194 | ||
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 442b081cafb7..07df201ed8fa 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c | |||
@@ -193,7 +193,7 @@ static int __devexit snd_es1688_remove(struct device *dev, unsigned int n) | |||
193 | static struct isa_driver snd_es1688_driver = { | 193 | static struct isa_driver snd_es1688_driver = { |
194 | .match = snd_es1688_match, | 194 | .match = snd_es1688_match, |
195 | .probe = snd_es1688_probe, | 195 | .probe = snd_es1688_probe, |
196 | .remove = snd_es1688_remove, | 196 | .remove = __devexit_p(snd_es1688_remove), |
197 | #if 0 /* FIXME */ | 197 | #if 0 /* FIXME */ |
198 | .suspend = snd_es1688_suspend, | 198 | .suspend = snd_es1688_suspend, |
199 | .resume = snd_es1688_resume, | 199 | .resume = snd_es1688_resume, |
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 180a8dea6bd9..65e4b18581a6 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c | |||
@@ -348,7 +348,7 @@ static int __devexit snd_gusextreme_remove(struct device *dev, unsigned int n) | |||
348 | static struct isa_driver snd_gusextreme_driver = { | 348 | static struct isa_driver snd_gusextreme_driver = { |
349 | .match = snd_gusextreme_match, | 349 | .match = snd_gusextreme_match, |
350 | .probe = snd_gusextreme_probe, | 350 | .probe = snd_gusextreme_probe, |
351 | .remove = snd_gusextreme_remove, | 351 | .remove = __devexit_p(snd_gusextreme_remove), |
352 | #if 0 /* FIXME */ | 352 | #if 0 /* FIXME */ |
353 | .suspend = snd_gusextreme_suspend, | 353 | .suspend = snd_gusextreme_suspend, |
354 | .resume = snd_gusextreme_resume, | 354 | .resume = snd_gusextreme_resume, |
diff --git a/sound/isa/sb/Makefile b/sound/isa/sb/Makefile index 1098a56b2f4b..faeffceb01b7 100644 --- a/sound/isa/sb/Makefile +++ b/sound/isa/sb/Makefile | |||
@@ -13,14 +13,6 @@ snd-sbawe-objs := sbawe.o emu8000.o | |||
13 | snd-emu8000-synth-objs := emu8000_synth.o emu8000_callback.o emu8000_patch.o emu8000_pcm.o | 13 | snd-emu8000-synth-objs := emu8000_synth.o emu8000_callback.o emu8000_patch.o emu8000_pcm.o |
14 | snd-es968-objs := es968.o | 14 | snd-es968-objs := es968.o |
15 | 15 | ||
16 | # | ||
17 | # this function returns: | ||
18 | # "m" - CONFIG_SND_SEQUENCER is m | ||
19 | # <empty string> - CONFIG_SND_SEQUENCER is undefined | ||
20 | # otherwise parameter #1 value | ||
21 | # | ||
22 | sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1))) | ||
23 | |||
24 | # Toplevel Module Dependency | 16 | # Toplevel Module Dependency |
25 | obj-$(CONFIG_SND_SB_COMMON) += snd-sb-common.o | 17 | obj-$(CONFIG_SND_SB_COMMON) += snd-sb-common.o |
26 | obj-$(CONFIG_SND_SB16_DSP) += snd-sb16-dsp.o | 18 | obj-$(CONFIG_SND_SB16_DSP) += snd-sb16-dsp.o |
@@ -33,4 +25,4 @@ ifeq ($(CONFIG_SND_SB16_CSP),y) | |||
33 | obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o | 25 | obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o |
34 | obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o | 26 | obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o |
35 | endif | 27 | endif |
36 | obj-$(call sequencer,$(CONFIG_SND_SBAWE)) += snd-emu8000-synth.o | 28 | obj-$(CONFIG_SND_SBAWE_SEQ) += snd-emu8000-synth.o |
diff --git a/sound/isa/sc6000.c b/sound/isa/sc6000.c index 782010608ef4..9a8bbf6dd62a 100644 --- a/sound/isa/sc6000.c +++ b/sound/isa/sc6000.c | |||
@@ -2,6 +2,8 @@ | |||
2 | * Driver for Gallant SC-6000 soundcard. This card is also known as | 2 | * Driver for Gallant SC-6000 soundcard. This card is also known as |
3 | * Audio Excel DSP 16 or Zoltrix AV302. | 3 | * Audio Excel DSP 16 or Zoltrix AV302. |
4 | * These cards use CompuMedia ASC-9308 chip + AD1848 codec. | 4 | * These cards use CompuMedia ASC-9308 chip + AD1848 codec. |
5 | * SC-6600 and SC-7000 cards are also supported. They are based on | ||
6 | * CompuMedia ASC-9408 chip and CS4231 codec. | ||
5 | * | 7 | * |
6 | * Copyright (C) 2007 Krzysztof Helt <krzysztof.h1@wp.pl> | 8 | * Copyright (C) 2007 Krzysztof Helt <krzysztof.h1@wp.pl> |
7 | * | 9 | * |
@@ -54,6 +56,7 @@ static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | |||
54 | /* 0x300, 0x310, 0x320, 0x330 */ | 56 | /* 0x300, 0x310, 0x320, 0x330 */ |
55 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5, 7, 9, 10, 0 */ | 57 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5, 7, 9, 10, 0 */ |
56 | static int dma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0, 1, 3 */ | 58 | static int dma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0, 1, 3 */ |
59 | static bool joystick[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = false }; | ||
57 | 60 | ||
58 | module_param_array(index, int, NULL, 0444); | 61 | module_param_array(index, int, NULL, 0444); |
59 | MODULE_PARM_DESC(index, "Index value for sc-6000 based soundcard."); | 62 | MODULE_PARM_DESC(index, "Index value for sc-6000 based soundcard."); |
@@ -73,6 +76,8 @@ module_param_array(mpu_irq, int, NULL, 0444); | |||
73 | MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for sc-6000 driver."); | 76 | MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for sc-6000 driver."); |
74 | module_param_array(dma, int, NULL, 0444); | 77 | module_param_array(dma, int, NULL, 0444); |
75 | MODULE_PARM_DESC(dma, "DMA # for sc-6000 driver."); | 78 | MODULE_PARM_DESC(dma, "DMA # for sc-6000 driver."); |
79 | module_param_array(joystick, bool, NULL, 0444); | ||
80 | MODULE_PARM_DESC(joystick, "Enable gameport."); | ||
76 | 81 | ||
77 | /* | 82 | /* |
78 | * Commands of SC6000's DSP (SBPRO+special). | 83 | * Commands of SC6000's DSP (SBPRO+special). |
@@ -191,7 +196,7 @@ static __devinit unsigned char sc6000_mpu_irq_to_softcfg(int mpu_irq) | |||
191 | return val; | 196 | return val; |
192 | } | 197 | } |
193 | 198 | ||
194 | static __devinit int sc6000_wait_data(char __iomem *vport) | 199 | static int sc6000_wait_data(char __iomem *vport) |
195 | { | 200 | { |
196 | int loop = 1000; | 201 | int loop = 1000; |
197 | unsigned char val = 0; | 202 | unsigned char val = 0; |
@@ -206,7 +211,7 @@ static __devinit int sc6000_wait_data(char __iomem *vport) | |||
206 | return -EAGAIN; | 211 | return -EAGAIN; |
207 | } | 212 | } |
208 | 213 | ||
209 | static __devinit int sc6000_read(char __iomem *vport) | 214 | static int sc6000_read(char __iomem *vport) |
210 | { | 215 | { |
211 | if (sc6000_wait_data(vport)) | 216 | if (sc6000_wait_data(vport)) |
212 | return -EBUSY; | 217 | return -EBUSY; |
@@ -215,7 +220,7 @@ static __devinit int sc6000_read(char __iomem *vport) | |||
215 | 220 | ||
216 | } | 221 | } |
217 | 222 | ||
218 | static __devinit int sc6000_write(char __iomem *vport, int cmd) | 223 | static int sc6000_write(char __iomem *vport, int cmd) |
219 | { | 224 | { |
220 | unsigned char val; | 225 | unsigned char val; |
221 | int loop = 500000; | 226 | int loop = 500000; |
@@ -276,8 +281,33 @@ static int __devinit sc6000_dsp_reset(char __iomem *vport) | |||
276 | } | 281 | } |
277 | 282 | ||
278 | /* detection and initialization */ | 283 | /* detection and initialization */ |
279 | static int __devinit sc6000_cfg_write(char __iomem *vport, | 284 | static int __devinit sc6000_hw_cfg_write(char __iomem *vport, const int *cfg) |
280 | unsigned char softcfg) | 285 | { |
286 | if (sc6000_write(vport, COMMAND_6C) < 0) { | ||
287 | snd_printk(KERN_WARNING "CMD 0x%x: failed!\n", COMMAND_6C); | ||
288 | return -EIO; | ||
289 | } | ||
290 | if (sc6000_write(vport, COMMAND_5C) < 0) { | ||
291 | snd_printk(KERN_ERR "CMD 0x%x: failed!\n", COMMAND_5C); | ||
292 | return -EIO; | ||
293 | } | ||
294 | if (sc6000_write(vport, cfg[0]) < 0) { | ||
295 | snd_printk(KERN_ERR "DATA 0x%x: failed!\n", cfg[0]); | ||
296 | return -EIO; | ||
297 | } | ||
298 | if (sc6000_write(vport, cfg[1]) < 0) { | ||
299 | snd_printk(KERN_ERR "DATA 0x%x: failed!\n", cfg[1]); | ||
300 | return -EIO; | ||
301 | } | ||
302 | if (sc6000_write(vport, COMMAND_C5) < 0) { | ||
303 | snd_printk(KERN_ERR "CMD 0x%x: failed!\n", COMMAND_C5); | ||
304 | return -EIO; | ||
305 | } | ||
306 | |||
307 | return 0; | ||
308 | } | ||
309 | |||
310 | static int sc6000_cfg_write(char __iomem *vport, unsigned char softcfg) | ||
281 | { | 311 | { |
282 | 312 | ||
283 | if (sc6000_write(vport, WRITE_MDIRQ_CFG)) { | 313 | if (sc6000_write(vport, WRITE_MDIRQ_CFG)) { |
@@ -291,7 +321,7 @@ static int __devinit sc6000_cfg_write(char __iomem *vport, | |||
291 | return 0; | 321 | return 0; |
292 | } | 322 | } |
293 | 323 | ||
294 | static int __devinit sc6000_setup_board(char __iomem *vport, int config) | 324 | static int sc6000_setup_board(char __iomem *vport, int config) |
295 | { | 325 | { |
296 | int loop = 10; | 326 | int loop = 10; |
297 | 327 | ||
@@ -334,16 +364,39 @@ static int __devinit sc6000_init_mss(char __iomem *vport, int config, | |||
334 | return 0; | 364 | return 0; |
335 | } | 365 | } |
336 | 366 | ||
337 | static int __devinit sc6000_init_board(char __iomem *vport, int irq, int dma, | 367 | static void __devinit sc6000_hw_cfg_encode(char __iomem *vport, int *cfg, |
338 | char __iomem *vmss_port, int mpu_irq) | 368 | long xport, long xmpu, |
369 | long xmss_port, int joystick) | ||
370 | { | ||
371 | cfg[0] = 0; | ||
372 | cfg[1] = 0; | ||
373 | if (xport == 0x240) | ||
374 | cfg[0] |= 1; | ||
375 | if (xmpu != SNDRV_AUTO_PORT) { | ||
376 | cfg[0] |= (xmpu & 0x30) >> 2; | ||
377 | cfg[1] |= 0x20; | ||
378 | } | ||
379 | if (xmss_port == 0xe80) | ||
380 | cfg[0] |= 0x10; | ||
381 | cfg[0] |= 0x40; /* always set */ | ||
382 | if (!joystick) | ||
383 | cfg[0] |= 0x02; | ||
384 | cfg[1] |= 0x80; /* enable WSS system */ | ||
385 | cfg[1] &= ~0x40; /* disable IDE */ | ||
386 | snd_printd("hw cfg %x, %x\n", cfg[0], cfg[1]); | ||
387 | } | ||
388 | |||
389 | static int __devinit sc6000_init_board(char __iomem *vport, | ||
390 | char __iomem *vmss_port, int dev) | ||
339 | { | 391 | { |
340 | char answer[15]; | 392 | char answer[15]; |
341 | char version[2]; | 393 | char version[2]; |
342 | int mss_config = sc6000_irq_to_softcfg(irq) | | 394 | int mss_config = sc6000_irq_to_softcfg(irq[dev]) | |
343 | sc6000_dma_to_softcfg(dma); | 395 | sc6000_dma_to_softcfg(dma[dev]); |
344 | int config = mss_config | | 396 | int config = mss_config | |
345 | sc6000_mpu_irq_to_softcfg(mpu_irq); | 397 | sc6000_mpu_irq_to_softcfg(mpu_irq[dev]); |
346 | int err; | 398 | int err; |
399 | int old = 0; | ||
347 | 400 | ||
348 | err = sc6000_dsp_reset(vport); | 401 | err = sc6000_dsp_reset(vport); |
349 | if (err < 0) { | 402 | if (err < 0) { |
@@ -360,7 +413,6 @@ static int __devinit sc6000_init_board(char __iomem *vport, int irq, int dma, | |||
360 | /* | 413 | /* |
361 | * My SC-6000 card return "SC-6000" in DSPCopyright, so | 414 | * My SC-6000 card return "SC-6000" in DSPCopyright, so |
362 | * if we have something different, we have to be warned. | 415 | * if we have something different, we have to be warned. |
363 | * Mine returns "SC-6000A " - KH | ||
364 | */ | 416 | */ |
365 | if (strncmp("SC-6000", answer, 7)) | 417 | if (strncmp("SC-6000", answer, 7)) |
366 | snd_printk(KERN_WARNING "Warning: non SC-6000 audio card!\n"); | 418 | snd_printk(KERN_WARNING "Warning: non SC-6000 audio card!\n"); |
@@ -372,13 +424,32 @@ static int __devinit sc6000_init_board(char __iomem *vport, int irq, int dma, | |||
372 | printk(KERN_INFO PFX "Detected model: %s, DSP version %d.%d\n", | 424 | printk(KERN_INFO PFX "Detected model: %s, DSP version %d.%d\n", |
373 | answer, version[0], version[1]); | 425 | answer, version[0], version[1]); |
374 | 426 | ||
375 | /* | 427 | /* set configuration */ |
376 | * 0x0A == (IRQ 7, DMA 1, MIRQ 0) | 428 | sc6000_write(vport, COMMAND_5C); |
377 | */ | 429 | if (sc6000_read(vport) < 0) |
378 | err = sc6000_cfg_write(vport, 0x0a); | 430 | old = 1; |
431 | |||
432 | if (!old) { | ||
433 | int cfg[2]; | ||
434 | sc6000_hw_cfg_encode(vport, &cfg[0], port[dev], mpu_port[dev], | ||
435 | mss_port[dev], joystick[dev]); | ||
436 | if (sc6000_hw_cfg_write(vport, cfg) < 0) { | ||
437 | snd_printk(KERN_ERR "sc6000_hw_cfg_write: failed!\n"); | ||
438 | return -EIO; | ||
439 | } | ||
440 | } | ||
441 | err = sc6000_setup_board(vport, config); | ||
379 | if (err < 0) { | 442 | if (err < 0) { |
380 | snd_printk(KERN_ERR "sc6000_cfg_write: failed!\n"); | 443 | snd_printk(KERN_ERR "sc6000_setup_board: failed!\n"); |
381 | return -EFAULT; | 444 | return -ENODEV; |
445 | } | ||
446 | |||
447 | sc6000_dsp_reset(vport); | ||
448 | |||
449 | if (!old) { | ||
450 | sc6000_write(vport, COMMAND_60); | ||
451 | sc6000_write(vport, 0x02); | ||
452 | sc6000_dsp_reset(vport); | ||
382 | } | 453 | } |
383 | 454 | ||
384 | err = sc6000_setup_board(vport, config); | 455 | err = sc6000_setup_board(vport, config); |
@@ -386,10 +457,9 @@ static int __devinit sc6000_init_board(char __iomem *vport, int irq, int dma, | |||
386 | snd_printk(KERN_ERR "sc6000_setup_board: failed!\n"); | 457 | snd_printk(KERN_ERR "sc6000_setup_board: failed!\n"); |
387 | return -ENODEV; | 458 | return -ENODEV; |
388 | } | 459 | } |
389 | |||
390 | err = sc6000_init_mss(vport, config, vmss_port, mss_config); | 460 | err = sc6000_init_mss(vport, config, vmss_port, mss_config); |
391 | if (err < 0) { | 461 | if (err < 0) { |
392 | snd_printk(KERN_ERR "Can not initialize " | 462 | snd_printk(KERN_ERR "Cannot initialize " |
393 | "Microsoft Sound System mode.\n"); | 463 | "Microsoft Sound System mode.\n"); |
394 | return -ENODEV; | 464 | return -ENODEV; |
395 | } | 465 | } |
@@ -485,14 +555,16 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev) | |||
485 | struct snd_card *card; | 555 | struct snd_card *card; |
486 | struct snd_wss *chip; | 556 | struct snd_wss *chip; |
487 | struct snd_opl3 *opl3; | 557 | struct snd_opl3 *opl3; |
488 | char __iomem *vport; | 558 | char __iomem **vport; |
489 | char __iomem *vmss_port; | 559 | char __iomem *vmss_port; |
490 | 560 | ||
491 | 561 | ||
492 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); | 562 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, sizeof(vport), |
563 | &card); | ||
493 | if (err < 0) | 564 | if (err < 0) |
494 | return err; | 565 | return err; |
495 | 566 | ||
567 | vport = card->private_data; | ||
496 | if (xirq == SNDRV_AUTO_IRQ) { | 568 | if (xirq == SNDRV_AUTO_IRQ) { |
497 | xirq = snd_legacy_find_free_irq(possible_irqs); | 569 | xirq = snd_legacy_find_free_irq(possible_irqs); |
498 | if (xirq < 0) { | 570 | if (xirq < 0) { |
@@ -517,8 +589,8 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev) | |||
517 | err = -EBUSY; | 589 | err = -EBUSY; |
518 | goto err_exit; | 590 | goto err_exit; |
519 | } | 591 | } |
520 | vport = devm_ioport_map(devptr, port[dev], 0x10); | 592 | *vport = devm_ioport_map(devptr, port[dev], 0x10); |
521 | if (!vport) { | 593 | if (*vport == NULL) { |
522 | snd_printk(KERN_ERR PFX | 594 | snd_printk(KERN_ERR PFX |
523 | "I/O port cannot be iomaped.\n"); | 595 | "I/O port cannot be iomaped.\n"); |
524 | err = -EBUSY; | 596 | err = -EBUSY; |
@@ -533,7 +605,7 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev) | |||
533 | goto err_unmap1; | 605 | goto err_unmap1; |
534 | } | 606 | } |
535 | vmss_port = devm_ioport_map(devptr, mss_port[dev], 4); | 607 | vmss_port = devm_ioport_map(devptr, mss_port[dev], 4); |
536 | if (!vport) { | 608 | if (!vmss_port) { |
537 | snd_printk(KERN_ERR PFX | 609 | snd_printk(KERN_ERR PFX |
538 | "MSS port I/O cannot be iomaped.\n"); | 610 | "MSS port I/O cannot be iomaped.\n"); |
539 | err = -EBUSY; | 611 | err = -EBUSY; |
@@ -544,7 +616,7 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev) | |||
544 | port[dev], xirq, xdma, | 616 | port[dev], xirq, xdma, |
545 | mpu_irq[dev] == SNDRV_AUTO_IRQ ? 0 : mpu_irq[dev]); | 617 | mpu_irq[dev] == SNDRV_AUTO_IRQ ? 0 : mpu_irq[dev]); |
546 | 618 | ||
547 | err = sc6000_init_board(vport, xirq, xdma, vmss_port, mpu_irq[dev]); | 619 | err = sc6000_init_board(*vport, vmss_port, dev); |
548 | if (err < 0) | 620 | if (err < 0) |
549 | goto err_unmap2; | 621 | goto err_unmap2; |
550 | 622 | ||
@@ -552,7 +624,6 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev) | |||
552 | WSS_HW_DETECT, 0, &chip); | 624 | WSS_HW_DETECT, 0, &chip); |
553 | if (err < 0) | 625 | if (err < 0) |
554 | goto err_unmap2; | 626 | goto err_unmap2; |
555 | card->private_data = chip; | ||
556 | 627 | ||
557 | err = snd_wss_pcm(chip, 0, NULL); | 628 | err = snd_wss_pcm(chip, 0, NULL); |
558 | if (err < 0) { | 629 | if (err < 0) { |
@@ -608,6 +679,7 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev) | |||
608 | return 0; | 679 | return 0; |
609 | 680 | ||
610 | err_unmap2: | 681 | err_unmap2: |
682 | sc6000_setup_board(*vport, 0); | ||
611 | release_region(mss_port[dev], 4); | 683 | release_region(mss_port[dev], 4); |
612 | err_unmap1: | 684 | err_unmap1: |
613 | release_region(port[dev], 0x10); | 685 | release_region(port[dev], 0x10); |
@@ -618,11 +690,17 @@ err_exit: | |||
618 | 690 | ||
619 | static int __devexit snd_sc6000_remove(struct device *devptr, unsigned int dev) | 691 | static int __devexit snd_sc6000_remove(struct device *devptr, unsigned int dev) |
620 | { | 692 | { |
693 | struct snd_card *card = dev_get_drvdata(devptr); | ||
694 | char __iomem **vport = card->private_data; | ||
695 | |||
696 | if (sc6000_setup_board(*vport, 0) < 0) | ||
697 | snd_printk(KERN_WARNING "sc6000_setup_board failed on exit!\n"); | ||
698 | |||
621 | release_region(port[dev], 0x10); | 699 | release_region(port[dev], 0x10); |
622 | release_region(mss_port[dev], 4); | 700 | release_region(mss_port[dev], 4); |
623 | 701 | ||
624 | snd_card_free(dev_get_drvdata(devptr)); | ||
625 | dev_set_drvdata(devptr, NULL); | 702 | dev_set_drvdata(devptr, NULL); |
703 | snd_card_free(card); | ||
626 | return 0; | 704 | return 0; |
627 | } | 705 | } |
628 | 706 | ||
diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 66f3b48ceafc..e497525bc11b 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c | |||
@@ -619,8 +619,7 @@ static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream, | |||
619 | /* hw_free callback */ | 619 | /* hw_free callback */ |
620 | static int snd_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream) | 620 | static int snd_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream) |
621 | { | 621 | { |
622 | if (substream->runtime->dma_area) | 622 | vfree(substream->runtime->dma_area); |
623 | vfree(substream->runtime->dma_area); | ||
624 | substream->runtime->dma_area = NULL; | 623 | substream->runtime->dma_area = NULL; |
625 | return 0; | 624 | return 0; |
626 | } | 625 | } |
diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index 6055fd6d3b38..e924492df21d 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c | |||
@@ -935,7 +935,7 @@ snd_harmony_create(struct snd_card *card, | |||
935 | h->iobase = ioremap_nocache(padev->hpa.start, HARMONY_SIZE); | 935 | h->iobase = ioremap_nocache(padev->hpa.start, HARMONY_SIZE); |
936 | if (h->iobase == NULL) { | 936 | if (h->iobase == NULL) { |
937 | printk(KERN_ERR PFX "unable to remap hpa 0x%lx\n", | 937 | printk(KERN_ERR PFX "unable to remap hpa 0x%lx\n", |
938 | padev->hpa.start); | 938 | (unsigned long)padev->hpa.start); |
939 | err = -EBUSY; | 939 | err = -EBUSY; |
940 | goto free_and_ret; | 940 | goto free_and_ret; |
941 | } | 941 | } |
@@ -1020,7 +1020,7 @@ static struct parisc_driver snd_harmony_driver = { | |||
1020 | .name = "harmony", | 1020 | .name = "harmony", |
1021 | .id_table = snd_harmony_devtable, | 1021 | .id_table = snd_harmony_devtable, |
1022 | .probe = snd_harmony_probe, | 1022 | .probe = snd_harmony_probe, |
1023 | .remove = snd_harmony_remove, | 1023 | .remove = __devexit_p(snd_harmony_remove), |
1024 | }; | 1024 | }; |
1025 | 1025 | ||
1026 | static int __init | 1026 | static int __init |
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 3a7640feaf92..748f6b7d90b7 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig | |||
@@ -542,6 +542,9 @@ config SND_HDSP | |||
542 | To compile this driver as a module, choose M here: the module | 542 | To compile this driver as a module, choose M here: the module |
543 | will be called snd-hdsp. | 543 | will be called snd-hdsp. |
544 | 544 | ||
545 | comment "Don't forget to add built-in firmwares for HDSP driver" | ||
546 | depends on SND_HDSP=y | ||
547 | |||
545 | config SND_HDSPM | 548 | config SND_HDSPM |
546 | tristate "RME Hammerfall DSP MADI" | 549 | tristate "RME Hammerfall DSP MADI" |
547 | select SND_HWDEP | 550 | select SND_HWDEP |
@@ -632,6 +635,16 @@ config SND_KORG1212 | |||
632 | To compile this driver as a module, choose M here: the module | 635 | To compile this driver as a module, choose M here: the module |
633 | will be called snd-korg1212. | 636 | will be called snd-korg1212. |
634 | 637 | ||
638 | config SND_LX6464ES | ||
639 | tristate "Digigram LX6464ES" | ||
640 | select SND_PCM | ||
641 | help | ||
642 | Say Y here to include support for Digigram LX6464ES boards. | ||
643 | |||
644 | To compile this driver as a module, choose M here: the module | ||
645 | will be called snd-lx6464es. | ||
646 | |||
647 | |||
635 | config SND_MAESTRO3 | 648 | config SND_MAESTRO3 |
636 | tristate "ESS Allegro/Maestro3" | 649 | tristate "ESS Allegro/Maestro3" |
637 | select SND_AC97_CODEC | 650 | select SND_AC97_CODEC |
@@ -774,8 +787,8 @@ config SND_VIRTUOSO | |||
774 | select SND_OXYGEN_LIB | 787 | select SND_OXYGEN_LIB |
775 | help | 788 | help |
776 | Say Y here to include support for sound cards based on the | 789 | Say Y here to include support for sound cards based on the |
777 | Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, and | 790 | Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, |
778 | Essence STX. | 791 | Essence ST (Deluxe), and Essence STX. |
779 | Support for the HDAV1.3 (Deluxe) is very experimental. | 792 | Support for the HDAV1.3 (Deluxe) is very experimental. |
780 | 793 | ||
781 | To compile this driver as a module, choose M here: the module | 794 | To compile this driver as a module, choose M here: the module |
diff --git a/sound/pci/Makefile b/sound/pci/Makefile index 6a1281ec01e3..ecfc609d2b9f 100644 --- a/sound/pci/Makefile +++ b/sound/pci/Makefile | |||
@@ -63,6 +63,7 @@ obj-$(CONFIG_SND) += \ | |||
63 | ca0106/ \ | 63 | ca0106/ \ |
64 | cs46xx/ \ | 64 | cs46xx/ \ |
65 | cs5535audio/ \ | 65 | cs5535audio/ \ |
66 | lx6464es/ \ | ||
66 | echoaudio/ \ | 67 | echoaudio/ \ |
67 | emu10k1/ \ | 68 | emu10k1/ \ |
68 | hda/ \ | 69 | hda/ \ |
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 81bc93e5f1e3..7337abdbe4e3 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c | |||
@@ -958,10 +958,13 @@ static int patch_sigmatel_stac9708_3d(struct snd_ac97 * ac97) | |||
958 | } | 958 | } |
959 | 959 | ||
960 | static const struct snd_kcontrol_new snd_ac97_sigmatel_4speaker = | 960 | static const struct snd_kcontrol_new snd_ac97_sigmatel_4speaker = |
961 | AC97_SINGLE("Sigmatel 4-Speaker Stereo Playback Switch", AC97_SIGMATEL_DAC2INVERT, 2, 1, 0); | 961 | AC97_SINGLE("Sigmatel 4-Speaker Stereo Playback Switch", |
962 | AC97_SIGMATEL_DAC2INVERT, 2, 1, 0); | ||
962 | 963 | ||
964 | /* "Sigmatel " removed due to excessive name length: */ | ||
963 | static const struct snd_kcontrol_new snd_ac97_sigmatel_phaseinvert = | 965 | static const struct snd_kcontrol_new snd_ac97_sigmatel_phaseinvert = |
964 | AC97_SINGLE("Sigmatel Surround Phase Inversion Playback Switch", AC97_SIGMATEL_DAC2INVERT, 3, 1, 0); | 966 | AC97_SINGLE("Surround Phase Inversion Playback Switch", |
967 | AC97_SIGMATEL_DAC2INVERT, 3, 1, 0); | ||
965 | 968 | ||
966 | static const struct snd_kcontrol_new snd_ac97_sigmatel_controls[] = { | 969 | static const struct snd_kcontrol_new snd_ac97_sigmatel_controls[] = { |
967 | AC97_SINGLE("Sigmatel DAC 6dB Attenuate", AC97_SIGMATEL_ANALOG, 1, 1, 0), | 970 | AC97_SINGLE("Sigmatel DAC 6dB Attenuate", AC97_SIGMATEL_ANALOG, 1, 1, 0), |
diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c index 3906f5afe27a..23f49f356e0f 100644 --- a/sound/pci/au88x0/au88x0_core.c +++ b/sound/pci/au88x0/au88x0_core.c | |||
@@ -1255,8 +1255,8 @@ static int inline vortex_adbdma_getlinearpos(vortex_t * vortex, int adbdma) | |||
1255 | int temp; | 1255 | int temp; |
1256 | 1256 | ||
1257 | temp = hwread(vortex->mmio, VORTEX_ADBDMA_STAT + (adbdma << 2)); | 1257 | temp = hwread(vortex->mmio, VORTEX_ADBDMA_STAT + (adbdma << 2)); |
1258 | temp = (dma->period_virt * dma->period_bytes) + (temp & POS_MASK); | 1258 | temp = (dma->period_virt * dma->period_bytes) + (temp & (dma->period_bytes - 1)); |
1259 | return (temp); | 1259 | return temp; |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | static void vortex_adbdma_startfifo(vortex_t * vortex, int adbdma) | 1262 | static void vortex_adbdma_startfifo(vortex_t * vortex, int adbdma) |
@@ -1504,8 +1504,7 @@ static int inline vortex_wtdma_getlinearpos(vortex_t * vortex, int wtdma) | |||
1504 | int temp; | 1504 | int temp; |
1505 | 1505 | ||
1506 | temp = hwread(vortex->mmio, VORTEX_WTDMA_STAT + (wtdma << 2)); | 1506 | temp = hwread(vortex->mmio, VORTEX_WTDMA_STAT + (wtdma << 2)); |
1507 | //temp = (temp & POS_MASK) + (((temp>>WT_SUBBUF_SHIFT) & WT_SUBBUF_MASK)*(dma->cfg0&POS_MASK)); | 1507 | temp = (dma->period_virt * dma->period_bytes) + (temp & (dma->period_bytes - 1)); |
1508 | temp = (temp & POS_MASK) + ((dma->period_virt) * (dma->period_bytes)); | ||
1509 | return temp; | 1508 | return temp; |
1510 | } | 1509 | } |
1511 | 1510 | ||
@@ -2441,7 +2440,8 @@ static irqreturn_t vortex_interrupt(int irq, void *dev_id) | |||
2441 | spin_lock(&vortex->lock); | 2440 | spin_lock(&vortex->lock); |
2442 | for (i = 0; i < NR_ADB; i++) { | 2441 | for (i = 0; i < NR_ADB; i++) { |
2443 | if (vortex->dma_adb[i].fifo_status == FIFO_START) { | 2442 | if (vortex->dma_adb[i].fifo_status == FIFO_START) { |
2444 | if (vortex_adbdma_bufshift(vortex, i)) ; | 2443 | if (!vortex_adbdma_bufshift(vortex, i)) |
2444 | continue; | ||
2445 | spin_unlock(&vortex->lock); | 2445 | spin_unlock(&vortex->lock); |
2446 | snd_pcm_period_elapsed(vortex->dma_adb[i]. | 2446 | snd_pcm_period_elapsed(vortex->dma_adb[i]. |
2447 | substream); | 2447 | substream); |
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index ce3f2e90f4d7..24585c6c6d01 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c | |||
@@ -810,6 +810,8 @@ static struct pci_device_id snd_bt87x_ids[] = { | |||
810 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x107d, 0x6606, GENERIC), | 810 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x107d, 0x6606, GENERIC), |
811 | /* Voodoo TV 200 */ | 811 | /* Voodoo TV 200 */ |
812 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x121a, 0x3000, GENERIC), | 812 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x121a, 0x3000, GENERIC), |
813 | /* Askey Computer Corp. MagicTView'99 */ | ||
814 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x144f, 0x3000, GENERIC), | ||
813 | /* AVerMedia Studio No. 103, 203, ...? */ | 815 | /* AVerMedia Studio No. 103, 203, ...? */ |
814 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x1461, 0x0003, AVPHONE98), | 816 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x1461, 0x0003, AVPHONE98), |
815 | /* Prolink PixelView PV-M4900 */ | 817 | /* Prolink PixelView PV-M4900 */ |
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index bfac30f7929f..57b992a5c057 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c | |||
@@ -1319,7 +1319,6 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device) | |||
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | pcm->info_flags = 0; | 1321 | pcm->info_flags = 0; |
1322 | pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; | ||
1323 | strcpy(pcm->name, "CA0106"); | 1322 | strcpy(pcm->name, "CA0106"); |
1324 | 1323 | ||
1325 | for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; | 1324 | for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; |
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index ad2888705d2a..c8c6f437f5b3 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c | |||
@@ -739,7 +739,7 @@ static int __devinit rename_ctl(struct snd_card *card, const char *src, const ch | |||
739 | } while (0) | 739 | } while (0) |
740 | 740 | ||
741 | static __devinitdata | 741 | static __devinitdata |
742 | DECLARE_TLV_DB_SCALE(snd_ca0106_master_db_scale, -6375, 50, 1); | 742 | DECLARE_TLV_DB_SCALE(snd_ca0106_master_db_scale, -6375, 25, 1); |
743 | 743 | ||
744 | static char *slave_vols[] __devinitdata = { | 744 | static char *slave_vols[] __devinitdata = { |
745 | "Analog Front Playback Volume", | 745 | "Analog Front Playback Volume", |
@@ -800,7 +800,7 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) | |||
800 | "Capture Volume", | 800 | "Capture Volume", |
801 | "External Amplifier", | 801 | "External Amplifier", |
802 | "Sigmatel 4-Speaker Stereo Playback Switch", | 802 | "Sigmatel 4-Speaker Stereo Playback Switch", |
803 | "Sigmatel Surround Phase Inversion Playback ", | 803 | "Surround Phase Inversion Playback Switch", |
804 | NULL | 804 | NULL |
805 | }; | 805 | }; |
806 | static char *ca0106_rename_ctls[] = { | 806 | static char *ca0106_rename_ctls[] = { |
@@ -841,6 +841,9 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) | |||
841 | snd_ca0106_master_db_scale); | 841 | snd_ca0106_master_db_scale); |
842 | if (!vmaster) | 842 | if (!vmaster) |
843 | return -ENOMEM; | 843 | return -ENOMEM; |
844 | err = snd_ctl_add(card, vmaster); | ||
845 | if (err < 0) | ||
846 | return err; | ||
844 | add_slaves(card, vmaster, slave_vols); | 847 | add_slaves(card, vmaster, slave_vols); |
845 | 848 | ||
846 | if (emu->details->spi_dac == 1) { | 849 | if (emu->details->spi_dac == 1) { |
@@ -848,8 +851,13 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) | |||
848 | NULL); | 851 | NULL); |
849 | if (!vmaster) | 852 | if (!vmaster) |
850 | return -ENOMEM; | 853 | return -ENOMEM; |
854 | err = snd_ctl_add(card, vmaster); | ||
855 | if (err < 0) | ||
856 | return err; | ||
851 | add_slaves(card, vmaster, slave_sws); | 857 | add_slaves(card, vmaster, slave_sws); |
852 | } | 858 | } |
859 | |||
860 | strcpy(card->mixername, "CA0106"); | ||
853 | return 0; | 861 | return 0; |
854 | } | 862 | } |
855 | 863 | ||
diff --git a/sound/pci/emu10k1/Makefile b/sound/pci/emu10k1/Makefile index cf2d5636d8be..fc5591e7777e 100644 --- a/sound/pci/emu10k1/Makefile +++ b/sound/pci/emu10k1/Makefile | |||
@@ -9,15 +9,7 @@ snd-emu10k1-objs := emu10k1.o emu10k1_main.o \ | |||
9 | snd-emu10k1-synth-objs := emu10k1_synth.o emu10k1_callback.o emu10k1_patch.o | 9 | snd-emu10k1-synth-objs := emu10k1_synth.o emu10k1_callback.o emu10k1_patch.o |
10 | snd-emu10k1x-objs := emu10k1x.o | 10 | snd-emu10k1x-objs := emu10k1x.o |
11 | 11 | ||
12 | # | ||
13 | # this function returns: | ||
14 | # "m" - CONFIG_SND_SEQUENCER is m | ||
15 | # <empty string> - CONFIG_SND_SEQUENCER is undefined | ||
16 | # otherwise parameter #1 value | ||
17 | # | ||
18 | sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1))) | ||
19 | |||
20 | # Toplevel Module Dependency | 12 | # Toplevel Module Dependency |
21 | obj-$(CONFIG_SND_EMU10K1) += snd-emu10k1.o | 13 | obj-$(CONFIG_SND_EMU10K1) += snd-emu10k1.o |
22 | obj-$(call sequencer,$(CONFIG_SND_EMU10K1)) += snd-emu10k1-synth.o | 14 | obj-$(CONFIG_SND_EMU10K1_SEQ) += snd-emu10k1-synth.o |
23 | obj-$(CONFIG_SND_EMU10K1X) += snd-emu10k1x.o | 15 | obj-$(CONFIG_SND_EMU10K1X) += snd-emu10k1x.o |
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 1970f0e70f37..4d3ad793e98f 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c | |||
@@ -858,7 +858,6 @@ static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct s | |||
858 | } | 858 | } |
859 | 859 | ||
860 | pcm->info_flags = 0; | 860 | pcm->info_flags = 0; |
861 | pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; | ||
862 | switch(device) { | 861 | switch(device) { |
863 | case 0: | 862 | case 0: |
864 | strcpy(pcm->name, "EMU10K1X Front"); | 863 | strcpy(pcm->name, "EMU10K1X Front"); |
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 78f62fd404c2..55b83ef73c63 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c | |||
@@ -1736,7 +1736,7 @@ static struct snd_pcm_hardware snd_emu10k1_fx8010_playback = | |||
1736 | .buffer_bytes_max = (128*1024), | 1736 | .buffer_bytes_max = (128*1024), |
1737 | .period_bytes_min = 1024, | 1737 | .period_bytes_min = 1024, |
1738 | .period_bytes_max = (128*1024), | 1738 | .period_bytes_max = (128*1024), |
1739 | .periods_min = 1, | 1739 | .periods_min = 2, |
1740 | .periods_max = 1024, | 1740 | .periods_max = 1024, |
1741 | .fifo_size = 0, | 1741 | .fifo_size = 0, |
1742 | }; | 1742 | }; |
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index eb2a19b894a0..c710150d5065 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig | |||
@@ -139,6 +139,19 @@ config SND_HDA_CODEC_CONEXANT | |||
139 | snd-hda-codec-conexant. | 139 | snd-hda-codec-conexant. |
140 | This module is automatically loaded at probing. | 140 | This module is automatically loaded at probing. |
141 | 141 | ||
142 | config SND_HDA_CODEC_CA0110 | ||
143 | bool "Build Creative CA0110-IBG codec support" | ||
144 | depends on SND_HDA_INTEL | ||
145 | default y | ||
146 | help | ||
147 | Say Y here to include Creative CA0110-IBG codec support in | ||
148 | snd-hda-intel driver, found on some Creative X-Fi cards. | ||
149 | |||
150 | When the HD-audio driver is built as a module, the codec | ||
151 | support code is also built as another module, | ||
152 | snd-hda-codec-ca0110. | ||
153 | This module is automatically loaded at probing. | ||
154 | |||
142 | config SND_HDA_CODEC_CMEDIA | 155 | config SND_HDA_CODEC_CMEDIA |
143 | bool "Build C-Media HD-audio codec support" | 156 | bool "Build C-Media HD-audio codec support" |
144 | default y | 157 | default y |
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile index 50f9d0967251..e3081d4586cc 100644 --- a/sound/pci/hda/Makefile +++ b/sound/pci/hda/Makefile | |||
@@ -13,6 +13,7 @@ snd-hda-codec-analog-objs := patch_analog.o | |||
13 | snd-hda-codec-idt-objs := patch_sigmatel.o | 13 | snd-hda-codec-idt-objs := patch_sigmatel.o |
14 | snd-hda-codec-si3054-objs := patch_si3054.o | 14 | snd-hda-codec-si3054-objs := patch_si3054.o |
15 | snd-hda-codec-atihdmi-objs := patch_atihdmi.o | 15 | snd-hda-codec-atihdmi-objs := patch_atihdmi.o |
16 | snd-hda-codec-ca0110-objs := patch_ca0110.o | ||
16 | snd-hda-codec-conexant-objs := patch_conexant.o | 17 | snd-hda-codec-conexant-objs := patch_conexant.o |
17 | snd-hda-codec-via-objs := patch_via.o | 18 | snd-hda-codec-via-objs := patch_via.o |
18 | snd-hda-codec-nvhdmi-objs := patch_nvhdmi.o | 19 | snd-hda-codec-nvhdmi-objs := patch_nvhdmi.o |
@@ -40,6 +41,9 @@ endif | |||
40 | ifdef CONFIG_SND_HDA_CODEC_ATIHDMI | 41 | ifdef CONFIG_SND_HDA_CODEC_ATIHDMI |
41 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-atihdmi.o | 42 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-atihdmi.o |
42 | endif | 43 | endif |
44 | ifdef CONFIG_SND_HDA_CODEC_CA0110 | ||
45 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-ca0110.o | ||
46 | endif | ||
43 | ifdef CONFIG_SND_HDA_CODEC_CONEXANT | 47 | ifdef CONFIG_SND_HDA_CODEC_CONEXANT |
44 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-conexant.o | 48 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-conexant.o |
45 | endif | 49 | endif |
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index 4de5bacd3929..29272f2e95a0 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
@@ -45,6 +45,46 @@ static void snd_hda_generate_beep(struct work_struct *work) | |||
45 | AC_VERB_SET_BEEP_CONTROL, beep->tone); | 45 | AC_VERB_SET_BEEP_CONTROL, beep->tone); |
46 | } | 46 | } |
47 | 47 | ||
48 | /* (non-standard) Linear beep tone calculation for IDT/STAC codecs | ||
49 | * | ||
50 | * The tone frequency of beep generator on IDT/STAC codecs is | ||
51 | * defined from the 8bit tone parameter, in Hz, | ||
52 | * freq = 48000 * (257 - tone) / 1024 | ||
53 | * that is from 12kHz to 93.75kHz in step of 46.875 hz | ||
54 | */ | ||
55 | static int beep_linear_tone(struct hda_beep *beep, int hz) | ||
56 | { | ||
57 | hz *= 1000; /* fixed point */ | ||
58 | hz = hz - DIGBEEP_HZ_MIN; | ||
59 | if (hz < 0) | ||
60 | hz = 0; /* turn off PC beep*/ | ||
61 | else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN)) | ||
62 | hz = 0xff; | ||
63 | else { | ||
64 | hz /= DIGBEEP_HZ_STEP; | ||
65 | hz++; | ||
66 | } | ||
67 | return hz; | ||
68 | } | ||
69 | |||
70 | /* HD-audio standard beep tone parameter calculation | ||
71 | * | ||
72 | * The tone frequency in Hz is calculated as | ||
73 | * freq = 48000 / (tone * 4) | ||
74 | * from 47Hz to 12kHz | ||
75 | */ | ||
76 | static int beep_standard_tone(struct hda_beep *beep, int hz) | ||
77 | { | ||
78 | if (hz <= 0) | ||
79 | return 0; /* disabled */ | ||
80 | hz = 12000 / hz; | ||
81 | if (hz > 0xff) | ||
82 | return 0xff; | ||
83 | if (hz <= 0) | ||
84 | return 1; | ||
85 | return hz; | ||
86 | } | ||
87 | |||
48 | static int snd_hda_beep_event(struct input_dev *dev, unsigned int type, | 88 | static int snd_hda_beep_event(struct input_dev *dev, unsigned int type, |
49 | unsigned int code, int hz) | 89 | unsigned int code, int hz) |
50 | { | 90 | { |
@@ -55,21 +95,14 @@ static int snd_hda_beep_event(struct input_dev *dev, unsigned int type, | |||
55 | if (hz) | 95 | if (hz) |
56 | hz = 1000; | 96 | hz = 1000; |
57 | case SND_TONE: | 97 | case SND_TONE: |
58 | hz *= 1000; /* fixed point */ | 98 | if (beep->linear_tone) |
59 | hz = hz - DIGBEEP_HZ_MIN; | 99 | beep->tone = beep_linear_tone(beep, hz); |
60 | if (hz < 0) | 100 | else |
61 | hz = 0; /* turn off PC beep*/ | 101 | beep->tone = beep_standard_tone(beep, hz); |
62 | else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN)) | ||
63 | hz = 0xff; | ||
64 | else { | ||
65 | hz /= DIGBEEP_HZ_STEP; | ||
66 | hz++; | ||
67 | } | ||
68 | break; | 102 | break; |
69 | default: | 103 | default: |
70 | return -1; | 104 | return -1; |
71 | } | 105 | } |
72 | beep->tone = hz; | ||
73 | 106 | ||
74 | /* schedule beep event */ | 107 | /* schedule beep event */ |
75 | schedule_work(&beep->beep_work); | 108 | schedule_work(&beep->beep_work); |
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h index 51bf6a5daf39..0c3de787c717 100644 --- a/sound/pci/hda/hda_beep.h +++ b/sound/pci/hda/hda_beep.h | |||
@@ -30,8 +30,9 @@ struct hda_beep { | |||
30 | struct hda_codec *codec; | 30 | struct hda_codec *codec; |
31 | char phys[32]; | 31 | char phys[32]; |
32 | int tone; | 32 | int tone; |
33 | int nid; | 33 | hda_nid_t nid; |
34 | int enabled; | 34 | unsigned int enabled:1; |
35 | unsigned int linear_tone:1; /* linear tone for IDT/STAC codec */ | ||
35 | struct work_struct beep_work; /* scheduled task for beep event */ | 36 | struct work_struct beep_work; /* scheduled task for beep event */ |
36 | }; | 37 | }; |
37 | 38 | ||
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 8820faf6c9d8..562403a23488 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -48,6 +48,7 @@ static struct hda_vendor_id hda_vendor_ids[] = { | |||
48 | { 0x1095, "Silicon Image" }, | 48 | { 0x1095, "Silicon Image" }, |
49 | { 0x10de, "Nvidia" }, | 49 | { 0x10de, "Nvidia" }, |
50 | { 0x10ec, "Realtek" }, | 50 | { 0x10ec, "Realtek" }, |
51 | { 0x1102, "Creative" }, | ||
51 | { 0x1106, "VIA" }, | 52 | { 0x1106, "VIA" }, |
52 | { 0x111d, "IDT" }, | 53 | { 0x111d, "IDT" }, |
53 | { 0x11c1, "LSI" }, | 54 | { 0x11c1, "LSI" }, |
@@ -157,6 +158,39 @@ make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, | |||
157 | return val; | 158 | return val; |
158 | } | 159 | } |
159 | 160 | ||
161 | /* | ||
162 | * Send and receive a verb | ||
163 | */ | ||
164 | static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd, | ||
165 | unsigned int *res) | ||
166 | { | ||
167 | struct hda_bus *bus = codec->bus; | ||
168 | int err; | ||
169 | |||
170 | if (res) | ||
171 | *res = -1; | ||
172 | again: | ||
173 | snd_hda_power_up(codec); | ||
174 | mutex_lock(&bus->cmd_mutex); | ||
175 | err = bus->ops.command(bus, cmd); | ||
176 | if (!err && res) | ||
177 | *res = bus->ops.get_response(bus); | ||
178 | mutex_unlock(&bus->cmd_mutex); | ||
179 | snd_hda_power_down(codec); | ||
180 | if (res && *res == -1 && bus->rirb_error) { | ||
181 | if (bus->response_reset) { | ||
182 | snd_printd("hda_codec: resetting BUS due to " | ||
183 | "fatal communication error\n"); | ||
184 | bus->ops.bus_reset(bus); | ||
185 | } | ||
186 | goto again; | ||
187 | } | ||
188 | /* clear reset-flag when the communication gets recovered */ | ||
189 | if (!err) | ||
190 | bus->response_reset = 0; | ||
191 | return err; | ||
192 | } | ||
193 | |||
160 | /** | 194 | /** |
161 | * snd_hda_codec_read - send a command and get the response | 195 | * snd_hda_codec_read - send a command and get the response |
162 | * @codec: the HDA codec | 196 | * @codec: the HDA codec |
@@ -173,18 +207,9 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, | |||
173 | int direct, | 207 | int direct, |
174 | unsigned int verb, unsigned int parm) | 208 | unsigned int verb, unsigned int parm) |
175 | { | 209 | { |
176 | struct hda_bus *bus = codec->bus; | 210 | unsigned cmd = make_codec_cmd(codec, nid, direct, verb, parm); |
177 | unsigned int res; | 211 | unsigned int res; |
178 | 212 | codec_exec_verb(codec, cmd, &res); | |
179 | res = make_codec_cmd(codec, nid, direct, verb, parm); | ||
180 | snd_hda_power_up(codec); | ||
181 | mutex_lock(&bus->cmd_mutex); | ||
182 | if (!bus->ops.command(bus, res)) | ||
183 | res = bus->ops.get_response(bus); | ||
184 | else | ||
185 | res = (unsigned int)-1; | ||
186 | mutex_unlock(&bus->cmd_mutex); | ||
187 | snd_hda_power_down(codec); | ||
188 | return res; | 213 | return res; |
189 | } | 214 | } |
190 | EXPORT_SYMBOL_HDA(snd_hda_codec_read); | 215 | EXPORT_SYMBOL_HDA(snd_hda_codec_read); |
@@ -204,17 +229,10 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_read); | |||
204 | int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct, | 229 | int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct, |
205 | unsigned int verb, unsigned int parm) | 230 | unsigned int verb, unsigned int parm) |
206 | { | 231 | { |
207 | struct hda_bus *bus = codec->bus; | 232 | unsigned int cmd = make_codec_cmd(codec, nid, direct, verb, parm); |
208 | unsigned int res; | 233 | unsigned int res; |
209 | int err; | 234 | return codec_exec_verb(codec, cmd, |
210 | 235 | codec->bus->sync_write ? &res : NULL); | |
211 | res = make_codec_cmd(codec, nid, direct, verb, parm); | ||
212 | snd_hda_power_up(codec); | ||
213 | mutex_lock(&bus->cmd_mutex); | ||
214 | err = bus->ops.command(bus, res); | ||
215 | mutex_unlock(&bus->cmd_mutex); | ||
216 | snd_hda_power_down(codec); | ||
217 | return err; | ||
218 | } | 236 | } |
219 | EXPORT_SYMBOL_HDA(snd_hda_codec_write); | 237 | EXPORT_SYMBOL_HDA(snd_hda_codec_write); |
220 | 238 | ||
@@ -613,7 +631,10 @@ static int get_codec_name(struct hda_codec *codec) | |||
613 | const struct hda_vendor_id *c; | 631 | const struct hda_vendor_id *c; |
614 | const char *vendor = NULL; | 632 | const char *vendor = NULL; |
615 | u16 vendor_id = codec->vendor_id >> 16; | 633 | u16 vendor_id = codec->vendor_id >> 16; |
616 | char tmp[16], name[32]; | 634 | char tmp[16]; |
635 | |||
636 | if (codec->vendor_name) | ||
637 | goto get_chip_name; | ||
617 | 638 | ||
618 | for (c = hda_vendor_ids; c->id; c++) { | 639 | for (c = hda_vendor_ids; c->id; c++) { |
619 | if (c->id == vendor_id) { | 640 | if (c->id == vendor_id) { |
@@ -625,14 +646,21 @@ static int get_codec_name(struct hda_codec *codec) | |||
625 | sprintf(tmp, "Generic %04x", vendor_id); | 646 | sprintf(tmp, "Generic %04x", vendor_id); |
626 | vendor = tmp; | 647 | vendor = tmp; |
627 | } | 648 | } |
649 | codec->vendor_name = kstrdup(vendor, GFP_KERNEL); | ||
650 | if (!codec->vendor_name) | ||
651 | return -ENOMEM; | ||
652 | |||
653 | get_chip_name: | ||
654 | if (codec->chip_name) | ||
655 | return 0; | ||
656 | |||
628 | if (codec->preset && codec->preset->name) | 657 | if (codec->preset && codec->preset->name) |
629 | snprintf(name, sizeof(name), "%s %s", vendor, | 658 | codec->chip_name = kstrdup(codec->preset->name, GFP_KERNEL); |
630 | codec->preset->name); | 659 | else { |
631 | else | 660 | sprintf(tmp, "ID %x", codec->vendor_id & 0xffff); |
632 | snprintf(name, sizeof(name), "%s ID %x", vendor, | 661 | codec->chip_name = kstrdup(tmp, GFP_KERNEL); |
633 | codec->vendor_id & 0xffff); | 662 | } |
634 | codec->name = kstrdup(name, GFP_KERNEL); | 663 | if (!codec->chip_name) |
635 | if (!codec->name) | ||
636 | return -ENOMEM; | 664 | return -ENOMEM; |
637 | return 0; | 665 | return 0; |
638 | } | 666 | } |
@@ -838,7 +866,8 @@ static void snd_hda_codec_free(struct hda_codec *codec) | |||
838 | module_put(codec->owner); | 866 | module_put(codec->owner); |
839 | free_hda_cache(&codec->amp_cache); | 867 | free_hda_cache(&codec->amp_cache); |
840 | free_hda_cache(&codec->cmd_cache); | 868 | free_hda_cache(&codec->cmd_cache); |
841 | kfree(codec->name); | 869 | kfree(codec->vendor_name); |
870 | kfree(codec->chip_name); | ||
842 | kfree(codec->modelname); | 871 | kfree(codec->modelname); |
843 | kfree(codec->wcaps); | 872 | kfree(codec->wcaps); |
844 | kfree(codec); | 873 | kfree(codec); |
@@ -979,15 +1008,16 @@ int snd_hda_codec_configure(struct hda_codec *codec) | |||
979 | int err; | 1008 | int err; |
980 | 1009 | ||
981 | codec->preset = find_codec_preset(codec); | 1010 | codec->preset = find_codec_preset(codec); |
982 | if (!codec->name) { | 1011 | if (!codec->vendor_name || !codec->chip_name) { |
983 | err = get_codec_name(codec); | 1012 | err = get_codec_name(codec); |
984 | if (err < 0) | 1013 | if (err < 0) |
985 | return err; | 1014 | return err; |
986 | } | 1015 | } |
987 | /* audio codec should override the mixer name */ | 1016 | /* audio codec should override the mixer name */ |
988 | if (codec->afg || !*codec->bus->card->mixername) | 1017 | if (codec->afg || !*codec->bus->card->mixername) |
989 | strlcpy(codec->bus->card->mixername, codec->name, | 1018 | snprintf(codec->bus->card->mixername, |
990 | sizeof(codec->bus->card->mixername)); | 1019 | sizeof(codec->bus->card->mixername), |
1020 | "%s %s", codec->vendor_name, codec->chip_name); | ||
991 | 1021 | ||
992 | if (is_generic_config(codec)) { | 1022 | if (is_generic_config(codec)) { |
993 | err = snd_hda_parse_generic_codec(codec); | 1023 | err = snd_hda_parse_generic_codec(codec); |
@@ -1055,6 +1085,8 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream); | |||
1055 | /* FIXME: more better hash key? */ | 1085 | /* FIXME: more better hash key? */ |
1056 | #define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) | 1086 | #define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) |
1057 | #define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24)) | 1087 | #define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24)) |
1088 | #define HDA_HASH_PARPCM_KEY(nid) (u32)((nid) + (0x03 << 24)) | ||
1089 | #define HDA_HASH_PARSTR_KEY(nid) (u32)((nid) + (0x04 << 24)) | ||
1058 | #define INFO_AMP_CAPS (1<<0) | 1090 | #define INFO_AMP_CAPS (1<<0) |
1059 | #define INFO_AMP_VOL(ch) (1 << (1 + (ch))) | 1091 | #define INFO_AMP_VOL(ch) (1 << (1 + (ch))) |
1060 | 1092 | ||
@@ -1145,19 +1177,32 @@ int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, | |||
1145 | } | 1177 | } |
1146 | EXPORT_SYMBOL_HDA(snd_hda_override_amp_caps); | 1178 | EXPORT_SYMBOL_HDA(snd_hda_override_amp_caps); |
1147 | 1179 | ||
1148 | u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid) | 1180 | static unsigned int |
1181 | query_caps_hash(struct hda_codec *codec, hda_nid_t nid, u32 key, | ||
1182 | unsigned int (*func)(struct hda_codec *, hda_nid_t)) | ||
1149 | { | 1183 | { |
1150 | struct hda_amp_info *info; | 1184 | struct hda_amp_info *info; |
1151 | 1185 | ||
1152 | info = get_alloc_amp_hash(codec, HDA_HASH_PINCAP_KEY(nid)); | 1186 | info = get_alloc_amp_hash(codec, key); |
1153 | if (!info) | 1187 | if (!info) |
1154 | return 0; | 1188 | return 0; |
1155 | if (!info->head.val) { | 1189 | if (!info->head.val) { |
1156 | info->amp_caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | ||
1157 | info->head.val |= INFO_AMP_CAPS; | 1190 | info->head.val |= INFO_AMP_CAPS; |
1191 | info->amp_caps = func(codec, nid); | ||
1158 | } | 1192 | } |
1159 | return info->amp_caps; | 1193 | return info->amp_caps; |
1160 | } | 1194 | } |
1195 | |||
1196 | static unsigned int read_pin_cap(struct hda_codec *codec, hda_nid_t nid) | ||
1197 | { | ||
1198 | return snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | ||
1199 | } | ||
1200 | |||
1201 | u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid) | ||
1202 | { | ||
1203 | return query_caps_hash(codec, nid, HDA_HASH_PINCAP_KEY(nid), | ||
1204 | read_pin_cap); | ||
1205 | } | ||
1161 | EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); | 1206 | EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); |
1162 | 1207 | ||
1163 | /* | 1208 | /* |
@@ -1432,6 +1477,8 @@ _snd_hda_find_mixer_ctl(struct hda_codec *codec, | |||
1432 | memset(&id, 0, sizeof(id)); | 1477 | memset(&id, 0, sizeof(id)); |
1433 | id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | 1478 | id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
1434 | id.index = idx; | 1479 | id.index = idx; |
1480 | if (snd_BUG_ON(strlen(name) >= sizeof(id.name))) | ||
1481 | return NULL; | ||
1435 | strcpy(id.name, name); | 1482 | strcpy(id.name, name); |
1436 | return snd_ctl_find_id(codec->bus->card, &id); | 1483 | return snd_ctl_find_id(codec->bus->card, &id); |
1437 | } | 1484 | } |
@@ -2242,28 +2289,22 @@ EXPORT_SYMBOL_HDA(snd_hda_create_spdif_in_ctls); | |||
2242 | int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid, | 2289 | int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid, |
2243 | int direct, unsigned int verb, unsigned int parm) | 2290 | int direct, unsigned int verb, unsigned int parm) |
2244 | { | 2291 | { |
2245 | struct hda_bus *bus = codec->bus; | 2292 | int err = snd_hda_codec_write(codec, nid, direct, verb, parm); |
2246 | unsigned int res; | 2293 | struct hda_cache_head *c; |
2247 | int err; | 2294 | u32 key; |
2248 | 2295 | ||
2249 | res = make_codec_cmd(codec, nid, direct, verb, parm); | 2296 | if (err < 0) |
2250 | snd_hda_power_up(codec); | 2297 | return err; |
2251 | mutex_lock(&bus->cmd_mutex); | 2298 | /* parm may contain the verb stuff for get/set amp */ |
2252 | err = bus->ops.command(bus, res); | 2299 | verb = verb | (parm >> 8); |
2253 | if (!err) { | 2300 | parm &= 0xff; |
2254 | struct hda_cache_head *c; | 2301 | key = build_cmd_cache_key(nid, verb); |
2255 | u32 key; | 2302 | mutex_lock(&codec->bus->cmd_mutex); |
2256 | /* parm may contain the verb stuff for get/set amp */ | 2303 | c = get_alloc_hash(&codec->cmd_cache, key); |
2257 | verb = verb | (parm >> 8); | 2304 | if (c) |
2258 | parm &= 0xff; | 2305 | c->val = parm; |
2259 | key = build_cmd_cache_key(nid, verb); | 2306 | mutex_unlock(&codec->bus->cmd_mutex); |
2260 | c = get_alloc_hash(&codec->cmd_cache, key); | 2307 | return 0; |
2261 | if (c) | ||
2262 | c->val = parm; | ||
2263 | } | ||
2264 | mutex_unlock(&bus->cmd_mutex); | ||
2265 | snd_hda_power_down(codec); | ||
2266 | return err; | ||
2267 | } | 2308 | } |
2268 | EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache); | 2309 | EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache); |
2269 | 2310 | ||
@@ -2321,7 +2362,8 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
2321 | if (wcaps & AC_WCAP_POWER) { | 2362 | if (wcaps & AC_WCAP_POWER) { |
2322 | unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> | 2363 | unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> |
2323 | AC_WCAP_TYPE_SHIFT; | 2364 | AC_WCAP_TYPE_SHIFT; |
2324 | if (wid_type == AC_WID_PIN) { | 2365 | if (power_state == AC_PWRST_D3 && |
2366 | wid_type == AC_WID_PIN) { | ||
2325 | unsigned int pincap; | 2367 | unsigned int pincap; |
2326 | /* | 2368 | /* |
2327 | * don't power down the widget if it controls | 2369 | * don't power down the widget if it controls |
@@ -2333,7 +2375,7 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
2333 | nid, 0, | 2375 | nid, 0, |
2334 | AC_VERB_GET_EAPD_BTLENABLE, 0); | 2376 | AC_VERB_GET_EAPD_BTLENABLE, 0); |
2335 | eapd &= 0x02; | 2377 | eapd &= 0x02; |
2336 | if (power_state == AC_PWRST_D3 && eapd) | 2378 | if (eapd) |
2337 | continue; | 2379 | continue; |
2338 | } | 2380 | } |
2339 | } | 2381 | } |
@@ -2544,6 +2586,41 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate, | |||
2544 | } | 2586 | } |
2545 | EXPORT_SYMBOL_HDA(snd_hda_calc_stream_format); | 2587 | EXPORT_SYMBOL_HDA(snd_hda_calc_stream_format); |
2546 | 2588 | ||
2589 | static unsigned int get_pcm_param(struct hda_codec *codec, hda_nid_t nid) | ||
2590 | { | ||
2591 | unsigned int val = 0; | ||
2592 | if (nid != codec->afg && | ||
2593 | (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) | ||
2594 | val = snd_hda_param_read(codec, nid, AC_PAR_PCM); | ||
2595 | if (!val || val == -1) | ||
2596 | val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); | ||
2597 | if (!val || val == -1) | ||
2598 | return 0; | ||
2599 | return val; | ||
2600 | } | ||
2601 | |||
2602 | static unsigned int query_pcm_param(struct hda_codec *codec, hda_nid_t nid) | ||
2603 | { | ||
2604 | return query_caps_hash(codec, nid, HDA_HASH_PARPCM_KEY(nid), | ||
2605 | get_pcm_param); | ||
2606 | } | ||
2607 | |||
2608 | static unsigned int get_stream_param(struct hda_codec *codec, hda_nid_t nid) | ||
2609 | { | ||
2610 | unsigned int streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); | ||
2611 | if (!streams || streams == -1) | ||
2612 | streams = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); | ||
2613 | if (!streams || streams == -1) | ||
2614 | return 0; | ||
2615 | return streams; | ||
2616 | } | ||
2617 | |||
2618 | static unsigned int query_stream_param(struct hda_codec *codec, hda_nid_t nid) | ||
2619 | { | ||
2620 | return query_caps_hash(codec, nid, HDA_HASH_PARSTR_KEY(nid), | ||
2621 | get_stream_param); | ||
2622 | } | ||
2623 | |||
2547 | /** | 2624 | /** |
2548 | * snd_hda_query_supported_pcm - query the supported PCM rates and formats | 2625 | * snd_hda_query_supported_pcm - query the supported PCM rates and formats |
2549 | * @codec: the HDA codec | 2626 | * @codec: the HDA codec |
@@ -2562,15 +2639,8 @@ static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, | |||
2562 | { | 2639 | { |
2563 | unsigned int i, val, wcaps; | 2640 | unsigned int i, val, wcaps; |
2564 | 2641 | ||
2565 | val = 0; | ||
2566 | wcaps = get_wcaps(codec, nid); | 2642 | wcaps = get_wcaps(codec, nid); |
2567 | if (nid != codec->afg && (wcaps & AC_WCAP_FORMAT_OVRD)) { | 2643 | val = query_pcm_param(codec, nid); |
2568 | val = snd_hda_param_read(codec, nid, AC_PAR_PCM); | ||
2569 | if (val == -1) | ||
2570 | return -EIO; | ||
2571 | } | ||
2572 | if (!val) | ||
2573 | val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); | ||
2574 | 2644 | ||
2575 | if (ratesp) { | 2645 | if (ratesp) { |
2576 | u32 rates = 0; | 2646 | u32 rates = 0; |
@@ -2592,15 +2662,9 @@ static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, | |||
2592 | u64 formats = 0; | 2662 | u64 formats = 0; |
2593 | unsigned int streams, bps; | 2663 | unsigned int streams, bps; |
2594 | 2664 | ||
2595 | streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); | 2665 | streams = query_stream_param(codec, nid); |
2596 | if (streams == -1) | 2666 | if (!streams) |
2597 | return -EIO; | 2667 | return -EIO; |
2598 | if (!streams) { | ||
2599 | streams = snd_hda_param_read(codec, codec->afg, | ||
2600 | AC_PAR_STREAM); | ||
2601 | if (streams == -1) | ||
2602 | return -EIO; | ||
2603 | } | ||
2604 | 2668 | ||
2605 | bps = 0; | 2669 | bps = 0; |
2606 | if (streams & AC_SUPFMT_PCM) { | 2670 | if (streams & AC_SUPFMT_PCM) { |
@@ -2674,17 +2738,9 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid, | |||
2674 | int i; | 2738 | int i; |
2675 | unsigned int val = 0, rate, stream; | 2739 | unsigned int val = 0, rate, stream; |
2676 | 2740 | ||
2677 | if (nid != codec->afg && | 2741 | val = query_pcm_param(codec, nid); |
2678 | (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) { | 2742 | if (!val) |
2679 | val = snd_hda_param_read(codec, nid, AC_PAR_PCM); | 2743 | return 0; |
2680 | if (val == -1) | ||
2681 | return 0; | ||
2682 | } | ||
2683 | if (!val) { | ||
2684 | val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); | ||
2685 | if (val == -1) | ||
2686 | return 0; | ||
2687 | } | ||
2688 | 2744 | ||
2689 | rate = format & 0xff00; | 2745 | rate = format & 0xff00; |
2690 | for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++) | 2746 | for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++) |
@@ -2696,12 +2752,8 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid, | |||
2696 | if (i >= AC_PAR_PCM_RATE_BITS) | 2752 | if (i >= AC_PAR_PCM_RATE_BITS) |
2697 | return 0; | 2753 | return 0; |
2698 | 2754 | ||
2699 | stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM); | 2755 | stream = query_stream_param(codec, nid); |
2700 | if (stream == -1) | 2756 | if (!stream) |
2701 | return 0; | ||
2702 | if (!stream && nid != codec->afg) | ||
2703 | stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); | ||
2704 | if (!stream || stream == -1) | ||
2705 | return 0; | 2757 | return 0; |
2706 | 2758 | ||
2707 | if (stream & AC_SUPFMT_PCM) { | 2759 | if (stream & AC_SUPFMT_PCM) { |
@@ -3835,11 +3887,10 @@ EXPORT_SYMBOL_HDA(auto_pin_cfg_labels); | |||
3835 | /** | 3887 | /** |
3836 | * snd_hda_suspend - suspend the codecs | 3888 | * snd_hda_suspend - suspend the codecs |
3837 | * @bus: the HDA bus | 3889 | * @bus: the HDA bus |
3838 | * @state: suspsend state | ||
3839 | * | 3890 | * |
3840 | * Returns 0 if successful. | 3891 | * Returns 0 if successful. |
3841 | */ | 3892 | */ |
3842 | int snd_hda_suspend(struct hda_bus *bus, pm_message_t state) | 3893 | int snd_hda_suspend(struct hda_bus *bus) |
3843 | { | 3894 | { |
3844 | struct hda_codec *codec; | 3895 | struct hda_codec *codec; |
3845 | 3896 | ||
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 2fdecf4b0eb6..cad79efaabc9 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -574,6 +574,8 @@ struct hda_bus_ops { | |||
574 | /* attach a PCM stream */ | 574 | /* attach a PCM stream */ |
575 | int (*attach_pcm)(struct hda_bus *bus, struct hda_codec *codec, | 575 | int (*attach_pcm)(struct hda_bus *bus, struct hda_codec *codec, |
576 | struct hda_pcm *pcm); | 576 | struct hda_pcm *pcm); |
577 | /* reset bus for retry verb */ | ||
578 | void (*bus_reset)(struct hda_bus *bus); | ||
577 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 579 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
578 | /* notify power-up/down from codec to controller */ | 580 | /* notify power-up/down from codec to controller */ |
579 | void (*pm_notify)(struct hda_bus *bus); | 581 | void (*pm_notify)(struct hda_bus *bus); |
@@ -622,7 +624,13 @@ struct hda_bus { | |||
622 | 624 | ||
623 | /* misc op flags */ | 625 | /* misc op flags */ |
624 | unsigned int needs_damn_long_delay :1; | 626 | unsigned int needs_damn_long_delay :1; |
627 | unsigned int allow_bus_reset:1; /* allow bus reset at fatal error */ | ||
628 | unsigned int sync_write:1; /* sync after verb write */ | ||
629 | /* status for codec/controller */ | ||
625 | unsigned int shutdown :1; /* being unloaded */ | 630 | unsigned int shutdown :1; /* being unloaded */ |
631 | unsigned int rirb_error:1; /* error in codec communication */ | ||
632 | unsigned int response_reset:1; /* controller was reset */ | ||
633 | unsigned int in_reset:1; /* during reset operation */ | ||
626 | }; | 634 | }; |
627 | 635 | ||
628 | /* | 636 | /* |
@@ -747,7 +755,8 @@ struct hda_codec { | |||
747 | /* detected preset */ | 755 | /* detected preset */ |
748 | const struct hda_codec_preset *preset; | 756 | const struct hda_codec_preset *preset; |
749 | struct module *owner; | 757 | struct module *owner; |
750 | const char *name; /* codec name */ | 758 | const char *vendor_name; /* codec vendor name */ |
759 | const char *chip_name; /* codec chip name */ | ||
751 | const char *modelname; /* model name for preset */ | 760 | const char *modelname; /* model name for preset */ |
752 | 761 | ||
753 | /* set by patch */ | 762 | /* set by patch */ |
@@ -905,7 +914,7 @@ void snd_hda_get_codec_name(struct hda_codec *codec, char *name, int namelen); | |||
905 | * power management | 914 | * power management |
906 | */ | 915 | */ |
907 | #ifdef CONFIG_PM | 916 | #ifdef CONFIG_PM |
908 | int snd_hda_suspend(struct hda_bus *bus, pm_message_t state); | 917 | int snd_hda_suspend(struct hda_bus *bus); |
909 | int snd_hda_resume(struct hda_bus *bus); | 918 | int snd_hda_resume(struct hda_bus *bus); |
910 | #endif | 919 | #endif |
911 | 920 | ||
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index 1c57505c2874..6812fbe80fa4 100644 --- a/sound/pci/hda/hda_hwdep.c +++ b/sound/pci/hda/hda_hwdep.c | |||
@@ -242,7 +242,8 @@ CODEC_INFO_SHOW(subsystem_id); | |||
242 | CODEC_INFO_SHOW(revision_id); | 242 | CODEC_INFO_SHOW(revision_id); |
243 | CODEC_INFO_SHOW(afg); | 243 | CODEC_INFO_SHOW(afg); |
244 | CODEC_INFO_SHOW(mfg); | 244 | CODEC_INFO_SHOW(mfg); |
245 | CODEC_INFO_STR_SHOW(name); | 245 | CODEC_INFO_STR_SHOW(vendor_name); |
246 | CODEC_INFO_STR_SHOW(chip_name); | ||
246 | CODEC_INFO_STR_SHOW(modelname); | 247 | CODEC_INFO_STR_SHOW(modelname); |
247 | 248 | ||
248 | #define CODEC_INFO_STORE(type) \ | 249 | #define CODEC_INFO_STORE(type) \ |
@@ -275,7 +276,8 @@ static ssize_t type##_store(struct device *dev, \ | |||
275 | CODEC_INFO_STORE(vendor_id); | 276 | CODEC_INFO_STORE(vendor_id); |
276 | CODEC_INFO_STORE(subsystem_id); | 277 | CODEC_INFO_STORE(subsystem_id); |
277 | CODEC_INFO_STORE(revision_id); | 278 | CODEC_INFO_STORE(revision_id); |
278 | CODEC_INFO_STR_STORE(name); | 279 | CODEC_INFO_STR_STORE(vendor_name); |
280 | CODEC_INFO_STR_STORE(chip_name); | ||
279 | CODEC_INFO_STR_STORE(modelname); | 281 | CODEC_INFO_STR_STORE(modelname); |
280 | 282 | ||
281 | #define CODEC_ACTION_STORE(type) \ | 283 | #define CODEC_ACTION_STORE(type) \ |
@@ -499,7 +501,8 @@ static struct device_attribute codec_attrs[] = { | |||
499 | CODEC_ATTR_RW(revision_id), | 501 | CODEC_ATTR_RW(revision_id), |
500 | CODEC_ATTR_RO(afg), | 502 | CODEC_ATTR_RO(afg), |
501 | CODEC_ATTR_RO(mfg), | 503 | CODEC_ATTR_RO(mfg), |
502 | CODEC_ATTR_RW(name), | 504 | CODEC_ATTR_RW(vendor_name), |
505 | CODEC_ATTR_RW(chip_name), | ||
503 | CODEC_ATTR_RW(modelname), | 506 | CODEC_ATTR_RW(modelname), |
504 | CODEC_ATTR_RW(init_verbs), | 507 | CODEC_ATTR_RW(init_verbs), |
505 | CODEC_ATTR_RW(hints), | 508 | CODEC_ATTR_RW(hints), |
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 21e99cfa8c49..4e9ea7080270 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -128,21 +128,33 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," | |||
128 | "{ULI, M5461}}"); | 128 | "{ULI, M5461}}"); |
129 | MODULE_DESCRIPTION("Intel HDA driver"); | 129 | MODULE_DESCRIPTION("Intel HDA driver"); |
130 | 130 | ||
131 | #ifdef CONFIG_SND_VERBOSE_PRINTK | ||
132 | #define SFX /* nop */ | ||
133 | #else | ||
131 | #define SFX "hda-intel: " | 134 | #define SFX "hda-intel: " |
132 | 135 | #endif | |
133 | 136 | ||
134 | /* | 137 | /* |
135 | * registers | 138 | * registers |
136 | */ | 139 | */ |
137 | #define ICH6_REG_GCAP 0x00 | 140 | #define ICH6_REG_GCAP 0x00 |
141 | #define ICH6_GCAP_64OK (1 << 0) /* 64bit address support */ | ||
142 | #define ICH6_GCAP_NSDO (3 << 1) /* # of serial data out signals */ | ||
143 | #define ICH6_GCAP_BSS (31 << 3) /* # of bidirectional streams */ | ||
144 | #define ICH6_GCAP_ISS (15 << 8) /* # of input streams */ | ||
145 | #define ICH6_GCAP_OSS (15 << 12) /* # of output streams */ | ||
138 | #define ICH6_REG_VMIN 0x02 | 146 | #define ICH6_REG_VMIN 0x02 |
139 | #define ICH6_REG_VMAJ 0x03 | 147 | #define ICH6_REG_VMAJ 0x03 |
140 | #define ICH6_REG_OUTPAY 0x04 | 148 | #define ICH6_REG_OUTPAY 0x04 |
141 | #define ICH6_REG_INPAY 0x06 | 149 | #define ICH6_REG_INPAY 0x06 |
142 | #define ICH6_REG_GCTL 0x08 | 150 | #define ICH6_REG_GCTL 0x08 |
151 | #define ICH6_GCTL_RESET (1 << 0) /* controller reset */ | ||
152 | #define ICH6_GCTL_FCNTRL (1 << 1) /* flush control */ | ||
153 | #define ICH6_GCTL_UNSOL (1 << 8) /* accept unsol. response enable */ | ||
143 | #define ICH6_REG_WAKEEN 0x0c | 154 | #define ICH6_REG_WAKEEN 0x0c |
144 | #define ICH6_REG_STATESTS 0x0e | 155 | #define ICH6_REG_STATESTS 0x0e |
145 | #define ICH6_REG_GSTS 0x10 | 156 | #define ICH6_REG_GSTS 0x10 |
157 | #define ICH6_GSTS_FSTS (1 << 1) /* flush status */ | ||
146 | #define ICH6_REG_INTCTL 0x20 | 158 | #define ICH6_REG_INTCTL 0x20 |
147 | #define ICH6_REG_INTSTS 0x24 | 159 | #define ICH6_REG_INTSTS 0x24 |
148 | #define ICH6_REG_WALCLK 0x30 | 160 | #define ICH6_REG_WALCLK 0x30 |
@@ -150,17 +162,27 @@ MODULE_DESCRIPTION("Intel HDA driver"); | |||
150 | #define ICH6_REG_CORBLBASE 0x40 | 162 | #define ICH6_REG_CORBLBASE 0x40 |
151 | #define ICH6_REG_CORBUBASE 0x44 | 163 | #define ICH6_REG_CORBUBASE 0x44 |
152 | #define ICH6_REG_CORBWP 0x48 | 164 | #define ICH6_REG_CORBWP 0x48 |
153 | #define ICH6_REG_CORBRP 0x4A | 165 | #define ICH6_REG_CORBRP 0x4a |
166 | #define ICH6_CORBRP_RST (1 << 15) /* read pointer reset */ | ||
154 | #define ICH6_REG_CORBCTL 0x4c | 167 | #define ICH6_REG_CORBCTL 0x4c |
168 | #define ICH6_CORBCTL_RUN (1 << 1) /* enable DMA */ | ||
169 | #define ICH6_CORBCTL_CMEIE (1 << 0) /* enable memory error irq */ | ||
155 | #define ICH6_REG_CORBSTS 0x4d | 170 | #define ICH6_REG_CORBSTS 0x4d |
171 | #define ICH6_CORBSTS_CMEI (1 << 0) /* memory error indication */ | ||
156 | #define ICH6_REG_CORBSIZE 0x4e | 172 | #define ICH6_REG_CORBSIZE 0x4e |
157 | 173 | ||
158 | #define ICH6_REG_RIRBLBASE 0x50 | 174 | #define ICH6_REG_RIRBLBASE 0x50 |
159 | #define ICH6_REG_RIRBUBASE 0x54 | 175 | #define ICH6_REG_RIRBUBASE 0x54 |
160 | #define ICH6_REG_RIRBWP 0x58 | 176 | #define ICH6_REG_RIRBWP 0x58 |
177 | #define ICH6_RIRBWP_RST (1 << 15) /* write pointer reset */ | ||
161 | #define ICH6_REG_RINTCNT 0x5a | 178 | #define ICH6_REG_RINTCNT 0x5a |
162 | #define ICH6_REG_RIRBCTL 0x5c | 179 | #define ICH6_REG_RIRBCTL 0x5c |
180 | #define ICH6_RBCTL_IRQ_EN (1 << 0) /* enable IRQ */ | ||
181 | #define ICH6_RBCTL_DMA_EN (1 << 1) /* enable DMA */ | ||
182 | #define ICH6_RBCTL_OVERRUN_EN (1 << 2) /* enable overrun irq */ | ||
163 | #define ICH6_REG_RIRBSTS 0x5d | 183 | #define ICH6_REG_RIRBSTS 0x5d |
184 | #define ICH6_RBSTS_IRQ (1 << 0) /* response irq */ | ||
185 | #define ICH6_RBSTS_OVERRUN (1 << 2) /* overrun irq */ | ||
164 | #define ICH6_REG_RIRBSIZE 0x5e | 186 | #define ICH6_REG_RIRBSIZE 0x5e |
165 | 187 | ||
166 | #define ICH6_REG_IC 0x60 | 188 | #define ICH6_REG_IC 0x60 |
@@ -257,16 +279,6 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; | |||
257 | #define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */ | 279 | #define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */ |
258 | #define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */ | 280 | #define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */ |
259 | 281 | ||
260 | /* GCTL unsolicited response enable bit */ | ||
261 | #define ICH6_GCTL_UREN (1<<8) | ||
262 | |||
263 | /* GCTL reset bit */ | ||
264 | #define ICH6_GCTL_RESET (1<<0) | ||
265 | |||
266 | /* CORB/RIRB control, read/write pointer */ | ||
267 | #define ICH6_RBCTL_DMA_EN 0x02 /* enable DMA */ | ||
268 | #define ICH6_RBCTL_IRQ_EN 0x01 /* enable IRQ */ | ||
269 | #define ICH6_RBRWP_CLR 0x8000 /* read/write pointer clear */ | ||
270 | /* below are so far hardcoded - should read registers in future */ | 282 | /* below are so far hardcoded - should read registers in future */ |
271 | #define ICH6_MAX_CORB_ENTRIES 256 | 283 | #define ICH6_MAX_CORB_ENTRIES 256 |
272 | #define ICH6_MAX_RIRB_ENTRIES 256 | 284 | #define ICH6_MAX_RIRB_ENTRIES 256 |
@@ -512,25 +524,25 @@ static void azx_init_cmd_io(struct azx *chip) | |||
512 | /* set the corb write pointer to 0 */ | 524 | /* set the corb write pointer to 0 */ |
513 | azx_writew(chip, CORBWP, 0); | 525 | azx_writew(chip, CORBWP, 0); |
514 | /* reset the corb hw read pointer */ | 526 | /* reset the corb hw read pointer */ |
515 | azx_writew(chip, CORBRP, ICH6_RBRWP_CLR); | 527 | azx_writew(chip, CORBRP, ICH6_CORBRP_RST); |
516 | /* enable corb dma */ | 528 | /* enable corb dma */ |
517 | azx_writeb(chip, CORBCTL, ICH6_RBCTL_DMA_EN); | 529 | azx_writeb(chip, CORBCTL, ICH6_CORBCTL_RUN); |
518 | 530 | ||
519 | /* RIRB set up */ | 531 | /* RIRB set up */ |
520 | chip->rirb.addr = chip->rb.addr + 2048; | 532 | chip->rirb.addr = chip->rb.addr + 2048; |
521 | chip->rirb.buf = (u32 *)(chip->rb.area + 2048); | 533 | chip->rirb.buf = (u32 *)(chip->rb.area + 2048); |
534 | chip->rirb.wp = chip->rirb.rp = chip->rirb.cmds = 0; | ||
522 | azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr); | 535 | azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr); |
523 | azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr)); | 536 | azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr)); |
524 | 537 | ||
525 | /* set the rirb size to 256 entries (ULI requires explicitly) */ | 538 | /* set the rirb size to 256 entries (ULI requires explicitly) */ |
526 | azx_writeb(chip, RIRBSIZE, 0x02); | 539 | azx_writeb(chip, RIRBSIZE, 0x02); |
527 | /* reset the rirb hw write pointer */ | 540 | /* reset the rirb hw write pointer */ |
528 | azx_writew(chip, RIRBWP, ICH6_RBRWP_CLR); | 541 | azx_writew(chip, RIRBWP, ICH6_RIRBWP_RST); |
529 | /* set N=1, get RIRB response interrupt for new entry */ | 542 | /* set N=1, get RIRB response interrupt for new entry */ |
530 | azx_writew(chip, RINTCNT, 1); | 543 | azx_writew(chip, RINTCNT, 1); |
531 | /* enable rirb dma and response irq */ | 544 | /* enable rirb dma and response irq */ |
532 | azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); | 545 | azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); |
533 | chip->rirb.rp = chip->rirb.cmds = 0; | ||
534 | } | 546 | } |
535 | 547 | ||
536 | static void azx_free_cmd_io(struct azx *chip) | 548 | static void azx_free_cmd_io(struct azx *chip) |
@@ -606,6 +618,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) | |||
606 | } | 618 | } |
607 | if (!chip->rirb.cmds) { | 619 | if (!chip->rirb.cmds) { |
608 | smp_rmb(); | 620 | smp_rmb(); |
621 | bus->rirb_error = 0; | ||
609 | return chip->rirb.res; /* the last value */ | 622 | return chip->rirb.res; /* the last value */ |
610 | } | 623 | } |
611 | if (time_after(jiffies, timeout)) | 624 | if (time_after(jiffies, timeout)) |
@@ -619,19 +632,21 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) | |||
619 | } | 632 | } |
620 | 633 | ||
621 | if (chip->msi) { | 634 | if (chip->msi) { |
622 | snd_printk(KERN_WARNING "hda_intel: No response from codec, " | 635 | snd_printk(KERN_WARNING SFX "No response from codec, " |
623 | "disabling MSI: last cmd=0x%08x\n", chip->last_cmd); | 636 | "disabling MSI: last cmd=0x%08x\n", chip->last_cmd); |
624 | free_irq(chip->irq, chip); | 637 | free_irq(chip->irq, chip); |
625 | chip->irq = -1; | 638 | chip->irq = -1; |
626 | pci_disable_msi(chip->pci); | 639 | pci_disable_msi(chip->pci); |
627 | chip->msi = 0; | 640 | chip->msi = 0; |
628 | if (azx_acquire_irq(chip, 1) < 0) | 641 | if (azx_acquire_irq(chip, 1) < 0) { |
642 | bus->rirb_error = 1; | ||
629 | return -1; | 643 | return -1; |
644 | } | ||
630 | goto again; | 645 | goto again; |
631 | } | 646 | } |
632 | 647 | ||
633 | if (!chip->polling_mode) { | 648 | if (!chip->polling_mode) { |
634 | snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, " | 649 | snd_printk(KERN_WARNING SFX "azx_get_response timeout, " |
635 | "switching to polling mode: last cmd=0x%08x\n", | 650 | "switching to polling mode: last cmd=0x%08x\n", |
636 | chip->last_cmd); | 651 | chip->last_cmd); |
637 | chip->polling_mode = 1; | 652 | chip->polling_mode = 1; |
@@ -646,14 +661,23 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) | |||
646 | return -1; | 661 | return -1; |
647 | } | 662 | } |
648 | 663 | ||
664 | /* a fatal communication error; need either to reset or to fallback | ||
665 | * to the single_cmd mode | ||
666 | */ | ||
667 | bus->rirb_error = 1; | ||
668 | if (bus->allow_bus_reset && !bus->response_reset && !bus->in_reset) { | ||
669 | bus->response_reset = 1; | ||
670 | return -1; /* give a chance to retry */ | ||
671 | } | ||
672 | |||
649 | snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " | 673 | snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " |
650 | "switching to single_cmd mode: last cmd=0x%08x\n", | 674 | "switching to single_cmd mode: last cmd=0x%08x\n", |
651 | chip->last_cmd); | 675 | chip->last_cmd); |
652 | chip->rirb.rp = azx_readb(chip, RIRBWP); | ||
653 | chip->rirb.cmds = 0; | ||
654 | /* switch to single_cmd mode */ | ||
655 | chip->single_cmd = 1; | 676 | chip->single_cmd = 1; |
677 | bus->response_reset = 0; | ||
678 | /* re-initialize CORB/RIRB */ | ||
656 | azx_free_cmd_io(chip); | 679 | azx_free_cmd_io(chip); |
680 | azx_init_cmd_io(chip); | ||
657 | return -1; | 681 | return -1; |
658 | } | 682 | } |
659 | 683 | ||
@@ -667,12 +691,34 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) | |||
667 | * I left the codes, however, for debugging/testing purposes. | 691 | * I left the codes, however, for debugging/testing purposes. |
668 | */ | 692 | */ |
669 | 693 | ||
694 | /* receive a response */ | ||
695 | static int azx_single_wait_for_response(struct azx *chip) | ||
696 | { | ||
697 | int timeout = 50; | ||
698 | |||
699 | while (timeout--) { | ||
700 | /* check IRV busy bit */ | ||
701 | if (azx_readw(chip, IRS) & ICH6_IRS_VALID) { | ||
702 | /* reuse rirb.res as the response return value */ | ||
703 | chip->rirb.res = azx_readl(chip, IR); | ||
704 | return 0; | ||
705 | } | ||
706 | udelay(1); | ||
707 | } | ||
708 | if (printk_ratelimit()) | ||
709 | snd_printd(SFX "get_response timeout: IRS=0x%x\n", | ||
710 | azx_readw(chip, IRS)); | ||
711 | chip->rirb.res = -1; | ||
712 | return -EIO; | ||
713 | } | ||
714 | |||
670 | /* send a command */ | 715 | /* send a command */ |
671 | static int azx_single_send_cmd(struct hda_bus *bus, u32 val) | 716 | static int azx_single_send_cmd(struct hda_bus *bus, u32 val) |
672 | { | 717 | { |
673 | struct azx *chip = bus->private_data; | 718 | struct azx *chip = bus->private_data; |
674 | int timeout = 50; | 719 | int timeout = 50; |
675 | 720 | ||
721 | bus->rirb_error = 0; | ||
676 | while (timeout--) { | 722 | while (timeout--) { |
677 | /* check ICB busy bit */ | 723 | /* check ICB busy bit */ |
678 | if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) { | 724 | if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) { |
@@ -682,7 +728,7 @@ static int azx_single_send_cmd(struct hda_bus *bus, u32 val) | |||
682 | azx_writel(chip, IC, val); | 728 | azx_writel(chip, IC, val); |
683 | azx_writew(chip, IRS, azx_readw(chip, IRS) | | 729 | azx_writew(chip, IRS, azx_readw(chip, IRS) | |
684 | ICH6_IRS_BUSY); | 730 | ICH6_IRS_BUSY); |
685 | return 0; | 731 | return azx_single_wait_for_response(chip); |
686 | } | 732 | } |
687 | udelay(1); | 733 | udelay(1); |
688 | } | 734 | } |
@@ -696,18 +742,7 @@ static int azx_single_send_cmd(struct hda_bus *bus, u32 val) | |||
696 | static unsigned int azx_single_get_response(struct hda_bus *bus) | 742 | static unsigned int azx_single_get_response(struct hda_bus *bus) |
697 | { | 743 | { |
698 | struct azx *chip = bus->private_data; | 744 | struct azx *chip = bus->private_data; |
699 | int timeout = 50; | 745 | return chip->rirb.res; |
700 | |||
701 | while (timeout--) { | ||
702 | /* check IRV busy bit */ | ||
703 | if (azx_readw(chip, IRS) & ICH6_IRS_VALID) | ||
704 | return azx_readl(chip, IR); | ||
705 | udelay(1); | ||
706 | } | ||
707 | if (printk_ratelimit()) | ||
708 | snd_printd(SFX "get_response timeout: IRS=0x%x\n", | ||
709 | azx_readw(chip, IRS)); | ||
710 | return (unsigned int)-1; | ||
711 | } | 746 | } |
712 | 747 | ||
713 | /* | 748 | /* |
@@ -775,17 +810,17 @@ static int azx_reset(struct azx *chip) | |||
775 | 810 | ||
776 | /* check to see if controller is ready */ | 811 | /* check to see if controller is ready */ |
777 | if (!azx_readb(chip, GCTL)) { | 812 | if (!azx_readb(chip, GCTL)) { |
778 | snd_printd("azx_reset: controller not ready!\n"); | 813 | snd_printd(SFX "azx_reset: controller not ready!\n"); |
779 | return -EBUSY; | 814 | return -EBUSY; |
780 | } | 815 | } |
781 | 816 | ||
782 | /* Accept unsolicited responses */ | 817 | /* Accept unsolicited responses */ |
783 | azx_writel(chip, GCTL, azx_readl(chip, GCTL) | ICH6_GCTL_UREN); | 818 | azx_writel(chip, GCTL, azx_readl(chip, GCTL) | ICH6_GCTL_UNSOL); |
784 | 819 | ||
785 | /* detect codecs */ | 820 | /* detect codecs */ |
786 | if (!chip->codec_mask) { | 821 | if (!chip->codec_mask) { |
787 | chip->codec_mask = azx_readw(chip, STATESTS); | 822 | chip->codec_mask = azx_readw(chip, STATESTS); |
788 | snd_printdd("codec_mask = 0x%x\n", chip->codec_mask); | 823 | snd_printdd(SFX "codec_mask = 0x%x\n", chip->codec_mask); |
789 | } | 824 | } |
790 | 825 | ||
791 | return 0; | 826 | return 0; |
@@ -895,8 +930,7 @@ static void azx_init_chip(struct azx *chip) | |||
895 | azx_int_enable(chip); | 930 | azx_int_enable(chip); |
896 | 931 | ||
897 | /* initialize the codec command I/O */ | 932 | /* initialize the codec command I/O */ |
898 | if (!chip->single_cmd) | 933 | azx_init_cmd_io(chip); |
899 | azx_init_cmd_io(chip); | ||
900 | 934 | ||
901 | /* program the position buffer */ | 935 | /* program the position buffer */ |
902 | azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); | 936 | azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); |
@@ -953,12 +987,12 @@ static void azx_init_pci(struct azx *chip) | |||
953 | case AZX_DRIVER_SCH: | 987 | case AZX_DRIVER_SCH: |
954 | pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); | 988 | pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); |
955 | if (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) { | 989 | if (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) { |
956 | pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, \ | 990 | pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, |
957 | snoop & (~INTEL_SCH_HDA_DEVC_NOSNOOP)); | 991 | snoop & (~INTEL_SCH_HDA_DEVC_NOSNOOP)); |
958 | pci_read_config_word(chip->pci, | 992 | pci_read_config_word(chip->pci, |
959 | INTEL_SCH_HDA_DEVC, &snoop); | 993 | INTEL_SCH_HDA_DEVC, &snoop); |
960 | snd_printdd("HDA snoop disabled, enabling ... %s\n",\ | 994 | snd_printdd(SFX "HDA snoop disabled, enabling ... %s\n", |
961 | (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) \ | 995 | (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) |
962 | ? "Failed" : "OK"); | 996 | ? "Failed" : "OK"); |
963 | } | 997 | } |
964 | break; | 998 | break; |
@@ -1012,7 +1046,7 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) | |||
1012 | /* clear rirb int */ | 1046 | /* clear rirb int */ |
1013 | status = azx_readb(chip, RIRBSTS); | 1047 | status = azx_readb(chip, RIRBSTS); |
1014 | if (status & RIRB_INT_MASK) { | 1048 | if (status & RIRB_INT_MASK) { |
1015 | if (!chip->single_cmd && (status & RIRB_INT_RESPONSE)) | 1049 | if (status & RIRB_INT_RESPONSE) |
1016 | azx_update_rirb(chip); | 1050 | azx_update_rirb(chip); |
1017 | azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); | 1051 | azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); |
1018 | } | 1052 | } |
@@ -1098,7 +1132,7 @@ static int azx_setup_periods(struct azx *chip, | |||
1098 | pos_align; | 1132 | pos_align; |
1099 | pos_adj = frames_to_bytes(runtime, pos_adj); | 1133 | pos_adj = frames_to_bytes(runtime, pos_adj); |
1100 | if (pos_adj >= period_bytes) { | 1134 | if (pos_adj >= period_bytes) { |
1101 | snd_printk(KERN_WARNING "Too big adjustment %d\n", | 1135 | snd_printk(KERN_WARNING SFX "Too big adjustment %d\n", |
1102 | bdl_pos_adj[chip->dev_index]); | 1136 | bdl_pos_adj[chip->dev_index]); |
1103 | pos_adj = 0; | 1137 | pos_adj = 0; |
1104 | } else { | 1138 | } else { |
@@ -1122,7 +1156,7 @@ static int azx_setup_periods(struct azx *chip, | |||
1122 | return 0; | 1156 | return 0; |
1123 | 1157 | ||
1124 | error: | 1158 | error: |
1125 | snd_printk(KERN_ERR "Too many BDL entries: buffer=%d, period=%d\n", | 1159 | snd_printk(KERN_ERR SFX "Too many BDL entries: buffer=%d, period=%d\n", |
1126 | azx_dev->bufsize, period_bytes); | 1160 | azx_dev->bufsize, period_bytes); |
1127 | return -EINVAL; | 1161 | return -EINVAL; |
1128 | } | 1162 | } |
@@ -1215,7 +1249,7 @@ static int probe_codec(struct azx *chip, int addr) | |||
1215 | chip->probing = 0; | 1249 | chip->probing = 0; |
1216 | if (res == -1) | 1250 | if (res == -1) |
1217 | return -EIO; | 1251 | return -EIO; |
1218 | snd_printdd("hda_intel: codec #%d probed OK\n", addr); | 1252 | snd_printdd(SFX "codec #%d probed OK\n", addr); |
1219 | return 0; | 1253 | return 0; |
1220 | } | 1254 | } |
1221 | 1255 | ||
@@ -1223,6 +1257,26 @@ static int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec, | |||
1223 | struct hda_pcm *cpcm); | 1257 | struct hda_pcm *cpcm); |
1224 | static void azx_stop_chip(struct azx *chip); | 1258 | static void azx_stop_chip(struct azx *chip); |
1225 | 1259 | ||
1260 | static void azx_bus_reset(struct hda_bus *bus) | ||
1261 | { | ||
1262 | struct azx *chip = bus->private_data; | ||
1263 | |||
1264 | bus->in_reset = 1; | ||
1265 | azx_stop_chip(chip); | ||
1266 | azx_init_chip(chip); | ||
1267 | #ifdef CONFIG_PM | ||
1268 | if (chip->initialized) { | ||
1269 | int i; | ||
1270 | |||
1271 | for (i = 0; i < AZX_MAX_PCMS; i++) | ||
1272 | snd_pcm_suspend_all(chip->pcm[i]); | ||
1273 | snd_hda_suspend(chip->bus); | ||
1274 | snd_hda_resume(chip->bus); | ||
1275 | } | ||
1276 | #endif | ||
1277 | bus->in_reset = 0; | ||
1278 | } | ||
1279 | |||
1226 | /* | 1280 | /* |
1227 | * Codec initialization | 1281 | * Codec initialization |
1228 | */ | 1282 | */ |
@@ -1246,6 +1300,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model, | |||
1246 | bus_temp.ops.command = azx_send_cmd; | 1300 | bus_temp.ops.command = azx_send_cmd; |
1247 | bus_temp.ops.get_response = azx_get_response; | 1301 | bus_temp.ops.get_response = azx_get_response; |
1248 | bus_temp.ops.attach_pcm = azx_attach_pcm_stream; | 1302 | bus_temp.ops.attach_pcm = azx_attach_pcm_stream; |
1303 | bus_temp.ops.bus_reset = azx_bus_reset; | ||
1249 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 1304 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
1250 | bus_temp.power_save = &power_save; | 1305 | bus_temp.power_save = &power_save; |
1251 | bus_temp.ops.pm_notify = azx_power_notify; | 1306 | bus_temp.ops.pm_notify = azx_power_notify; |
@@ -1270,8 +1325,8 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model, | |||
1270 | /* Some BIOSen give you wrong codec addresses | 1325 | /* Some BIOSen give you wrong codec addresses |
1271 | * that don't exist | 1326 | * that don't exist |
1272 | */ | 1327 | */ |
1273 | snd_printk(KERN_WARNING | 1328 | snd_printk(KERN_WARNING SFX |
1274 | "hda_intel: Codec #%d probe error; " | 1329 | "Codec #%d probe error; " |
1275 | "disabling it...\n", c); | 1330 | "disabling it...\n", c); |
1276 | chip->codec_mask &= ~(1 << c); | 1331 | chip->codec_mask &= ~(1 << c); |
1277 | /* More badly, accessing to a non-existing | 1332 | /* More badly, accessing to a non-existing |
@@ -1487,7 +1542,7 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) | |||
1487 | bufsize = snd_pcm_lib_buffer_bytes(substream); | 1542 | bufsize = snd_pcm_lib_buffer_bytes(substream); |
1488 | period_bytes = snd_pcm_lib_period_bytes(substream); | 1543 | period_bytes = snd_pcm_lib_period_bytes(substream); |
1489 | 1544 | ||
1490 | snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n", | 1545 | snd_printdd(SFX "azx_pcm_prepare: bufsize=0x%x, format=0x%x\n", |
1491 | bufsize, format_val); | 1546 | bufsize, format_val); |
1492 | 1547 | ||
1493 | if (bufsize != azx_dev->bufsize || | 1548 | if (bufsize != azx_dev->bufsize || |
@@ -1830,7 +1885,7 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec, | |||
1830 | &pcm); | 1885 | &pcm); |
1831 | if (err < 0) | 1886 | if (err < 0) |
1832 | return err; | 1887 | return err; |
1833 | strcpy(pcm->name, cpcm->name); | 1888 | strlcpy(pcm->name, cpcm->name, sizeof(pcm->name)); |
1834 | apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); | 1889 | apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); |
1835 | if (apcm == NULL) | 1890 | if (apcm == NULL) |
1836 | return -ENOMEM; | 1891 | return -ENOMEM; |
@@ -1973,7 +2028,7 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state) | |||
1973 | for (i = 0; i < AZX_MAX_PCMS; i++) | 2028 | for (i = 0; i < AZX_MAX_PCMS; i++) |
1974 | snd_pcm_suspend_all(chip->pcm[i]); | 2029 | snd_pcm_suspend_all(chip->pcm[i]); |
1975 | if (chip->initialized) | 2030 | if (chip->initialized) |
1976 | snd_hda_suspend(chip->bus, state); | 2031 | snd_hda_suspend(chip->bus); |
1977 | azx_stop_chip(chip); | 2032 | azx_stop_chip(chip); |
1978 | if (chip->irq >= 0) { | 2033 | if (chip->irq >= 0) { |
1979 | free_irq(chip->irq, chip); | 2034 | free_irq(chip->irq, chip); |
@@ -2141,6 +2196,7 @@ static struct snd_pci_quirk probe_mask_list[] __devinitdata = { | |||
2141 | /* including bogus ALC268 in slot#2 that conflicts with ALC888 */ | 2196 | /* including bogus ALC268 in slot#2 that conflicts with ALC888 */ |
2142 | SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01), | 2197 | SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01), |
2143 | /* forced codec slots */ | 2198 | /* forced codec slots */ |
2199 | SND_PCI_QUIRK(0x1043, 0x1262, "ASUS W5Fm", 0x103), | ||
2144 | SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103), | 2200 | SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103), |
2145 | {} | 2201 | {} |
2146 | }; | 2202 | }; |
@@ -2264,14 +2320,14 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
2264 | synchronize_irq(chip->irq); | 2320 | synchronize_irq(chip->irq); |
2265 | 2321 | ||
2266 | gcap = azx_readw(chip, GCAP); | 2322 | gcap = azx_readw(chip, GCAP); |
2267 | snd_printdd("chipset global capabilities = 0x%x\n", gcap); | 2323 | snd_printdd(SFX "chipset global capabilities = 0x%x\n", gcap); |
2268 | 2324 | ||
2269 | /* ATI chips seems buggy about 64bit DMA addresses */ | 2325 | /* ATI chips seems buggy about 64bit DMA addresses */ |
2270 | if (chip->driver_type == AZX_DRIVER_ATI) | 2326 | if (chip->driver_type == AZX_DRIVER_ATI) |
2271 | gcap &= ~0x01; | 2327 | gcap &= ~ICH6_GCAP_64OK; |
2272 | 2328 | ||
2273 | /* allow 64bit DMA address if supported by H/W */ | 2329 | /* allow 64bit DMA address if supported by H/W */ |
2274 | if ((gcap & 0x01) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) | 2330 | if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) |
2275 | pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64)); | 2331 | pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64)); |
2276 | else { | 2332 | else { |
2277 | pci_set_dma_mask(pci, DMA_BIT_MASK(32)); | 2333 | pci_set_dma_mask(pci, DMA_BIT_MASK(32)); |
@@ -2308,7 +2364,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
2308 | chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), | 2364 | chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), |
2309 | GFP_KERNEL); | 2365 | GFP_KERNEL); |
2310 | if (!chip->azx_dev) { | 2366 | if (!chip->azx_dev) { |
2311 | snd_printk(KERN_ERR "cannot malloc azx_dev\n"); | 2367 | snd_printk(KERN_ERR SFX "cannot malloc azx_dev\n"); |
2312 | goto errout; | 2368 | goto errout; |
2313 | } | 2369 | } |
2314 | 2370 | ||
@@ -2331,11 +2387,9 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
2331 | goto errout; | 2387 | goto errout; |
2332 | } | 2388 | } |
2333 | /* allocate CORB/RIRB */ | 2389 | /* allocate CORB/RIRB */ |
2334 | if (!chip->single_cmd) { | 2390 | err = azx_alloc_cmd_io(chip); |
2335 | err = azx_alloc_cmd_io(chip); | 2391 | if (err < 0) |
2336 | if (err < 0) | 2392 | goto errout; |
2337 | goto errout; | ||
2338 | } | ||
2339 | 2393 | ||
2340 | /* initialize streams */ | 2394 | /* initialize streams */ |
2341 | azx_init_stream(chip); | 2395 | azx_init_stream(chip); |
@@ -2358,9 +2412,11 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
2358 | } | 2412 | } |
2359 | 2413 | ||
2360 | strcpy(card->driver, "HDA-Intel"); | 2414 | strcpy(card->driver, "HDA-Intel"); |
2361 | strcpy(card->shortname, driver_short_names[chip->driver_type]); | 2415 | strlcpy(card->shortname, driver_short_names[chip->driver_type], |
2362 | sprintf(card->longname, "%s at 0x%lx irq %i", | 2416 | sizeof(card->shortname)); |
2363 | card->shortname, chip->addr, chip->irq); | 2417 | snprintf(card->longname, sizeof(card->longname), |
2418 | "%s at 0x%lx irq %i", | ||
2419 | card->shortname, chip->addr, chip->irq); | ||
2364 | 2420 | ||
2365 | *rchip = chip; | 2421 | *rchip = chip; |
2366 | return 0; | 2422 | return 0; |
@@ -2513,6 +2569,20 @@ static struct pci_device_id azx_ids[] = { | |||
2513 | { PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA }, | 2569 | { PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA }, |
2514 | /* Teradici */ | 2570 | /* Teradici */ |
2515 | { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, | 2571 | { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, |
2572 | /* Creative X-Fi (CA0110-IBG) */ | ||
2573 | #if !defined(CONFIG_SND_CTXFI) && !defined(CONFIG_SND_CTXFI_MODULE) | ||
2574 | /* the following entry conflicts with snd-ctxfi driver, | ||
2575 | * as ctxfi driver mutates from HD-audio to native mode with | ||
2576 | * a special command sequence. | ||
2577 | */ | ||
2578 | { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_ANY_ID), | ||
2579 | .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, | ||
2580 | .class_mask = 0xffffff, | ||
2581 | .driver_data = AZX_DRIVER_GENERIC }, | ||
2582 | #else | ||
2583 | /* this entry seems still valid -- i.e. without emu20kx chip */ | ||
2584 | { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_GENERIC }, | ||
2585 | #endif | ||
2516 | /* AMD Generic, PCI class code and Vendor ID for HD Audio */ | 2586 | /* AMD Generic, PCI class code and Vendor ID for HD Audio */ |
2517 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID), | 2587 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID), |
2518 | .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, | 2588 | .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, |
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 93d7499350c6..418c5d1badaa 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c | |||
@@ -466,8 +466,12 @@ static void print_codec_info(struct snd_info_entry *entry, | |||
466 | hda_nid_t nid; | 466 | hda_nid_t nid; |
467 | int i, nodes; | 467 | int i, nodes; |
468 | 468 | ||
469 | snd_iprintf(buffer, "Codec: %s\n", | 469 | snd_iprintf(buffer, "Codec: "); |
470 | codec->name ? codec->name : "Not Set"); | 470 | if (codec->vendor_name && codec->chip_name) |
471 | snd_iprintf(buffer, "%s %s\n", | ||
472 | codec->vendor_name, codec->chip_name); | ||
473 | else | ||
474 | snd_iprintf(buffer, "Not Set\n"); | ||
471 | snd_iprintf(buffer, "Address: %d\n", codec->addr); | 475 | snd_iprintf(buffer, "Address: %d\n", codec->addr); |
472 | snd_iprintf(buffer, "Function Id: 0x%x\n", codec->function_id); | 476 | snd_iprintf(buffer, "Function Id: 0x%x\n", codec->function_id); |
473 | snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id); | 477 | snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id); |
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c new file mode 100644 index 000000000000..392d108c3558 --- /dev/null +++ b/sound/pci/hda/patch_ca0110.c | |||
@@ -0,0 +1,573 @@ | |||
1 | /* | ||
2 | * HD audio interface patch for Creative X-Fi CA0110-IBG chip | ||
3 | * | ||
4 | * Copyright (c) 2008 Takashi Iwai <tiwai@suse.de> | ||
5 | * | ||
6 | * This driver is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This driver is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <linux/init.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/slab.h> | ||
24 | #include <linux/pci.h> | ||
25 | #include <sound/core.h> | ||
26 | #include "hda_codec.h" | ||
27 | #include "hda_local.h" | ||
28 | |||
29 | /* | ||
30 | */ | ||
31 | |||
32 | struct ca0110_spec { | ||
33 | struct auto_pin_cfg autocfg; | ||
34 | struct hda_multi_out multiout; | ||
35 | hda_nid_t out_pins[AUTO_CFG_MAX_OUTS]; | ||
36 | hda_nid_t dacs[AUTO_CFG_MAX_OUTS]; | ||
37 | hda_nid_t hp_dac; | ||
38 | hda_nid_t input_pins[AUTO_PIN_LAST]; | ||
39 | hda_nid_t adcs[AUTO_PIN_LAST]; | ||
40 | hda_nid_t dig_out; | ||
41 | hda_nid_t dig_in; | ||
42 | unsigned int num_inputs; | ||
43 | const char *input_labels[AUTO_PIN_LAST]; | ||
44 | struct hda_pcm pcm_rec[2]; /* PCM information */ | ||
45 | }; | ||
46 | |||
47 | /* | ||
48 | * PCM callbacks | ||
49 | */ | ||
50 | static int ca0110_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
51 | struct hda_codec *codec, | ||
52 | struct snd_pcm_substream *substream) | ||
53 | { | ||
54 | struct ca0110_spec *spec = codec->spec; | ||
55 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, | ||
56 | hinfo); | ||
57 | } | ||
58 | |||
59 | static int ca0110_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
60 | struct hda_codec *codec, | ||
61 | unsigned int stream_tag, | ||
62 | unsigned int format, | ||
63 | struct snd_pcm_substream *substream) | ||
64 | { | ||
65 | struct ca0110_spec *spec = codec->spec; | ||
66 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, | ||
67 | stream_tag, format, substream); | ||
68 | } | ||
69 | |||
70 | static int ca0110_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
71 | struct hda_codec *codec, | ||
72 | struct snd_pcm_substream *substream) | ||
73 | { | ||
74 | struct ca0110_spec *spec = codec->spec; | ||
75 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | * Digital out | ||
80 | */ | ||
81 | static int ca0110_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
82 | struct hda_codec *codec, | ||
83 | struct snd_pcm_substream *substream) | ||
84 | { | ||
85 | struct ca0110_spec *spec = codec->spec; | ||
86 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | ||
87 | } | ||
88 | |||
89 | static int ca0110_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | ||
90 | struct hda_codec *codec, | ||
91 | struct snd_pcm_substream *substream) | ||
92 | { | ||
93 | struct ca0110_spec *spec = codec->spec; | ||
94 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | ||
95 | } | ||
96 | |||
97 | static int ca0110_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
98 | struct hda_codec *codec, | ||
99 | unsigned int stream_tag, | ||
100 | unsigned int format, | ||
101 | struct snd_pcm_substream *substream) | ||
102 | { | ||
103 | struct ca0110_spec *spec = codec->spec; | ||
104 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, | ||
105 | format, substream); | ||
106 | } | ||
107 | |||
108 | /* | ||
109 | * Analog capture | ||
110 | */ | ||
111 | static int ca0110_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
112 | struct hda_codec *codec, | ||
113 | unsigned int stream_tag, | ||
114 | unsigned int format, | ||
115 | struct snd_pcm_substream *substream) | ||
116 | { | ||
117 | struct ca0110_spec *spec = codec->spec; | ||
118 | |||
119 | snd_hda_codec_setup_stream(codec, spec->adcs[substream->number], | ||
120 | stream_tag, 0, format); | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static int ca0110_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
125 | struct hda_codec *codec, | ||
126 | struct snd_pcm_substream *substream) | ||
127 | { | ||
128 | struct ca0110_spec *spec = codec->spec; | ||
129 | |||
130 | snd_hda_codec_cleanup_stream(codec, spec->adcs[substream->number]); | ||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | /* | ||
135 | */ | ||
136 | |||
137 | static char *dirstr[2] = { "Playback", "Capture" }; | ||
138 | |||
139 | static int _add_switch(struct hda_codec *codec, hda_nid_t nid, const char *pfx, | ||
140 | int chan, int dir) | ||
141 | { | ||
142 | char namestr[44]; | ||
143 | int type = dir ? HDA_INPUT : HDA_OUTPUT; | ||
144 | struct snd_kcontrol_new knew = | ||
145 | HDA_CODEC_MUTE_MONO(namestr, nid, chan, 0, type); | ||
146 | sprintf(namestr, "%s %s Switch", pfx, dirstr[dir]); | ||
147 | return snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec)); | ||
148 | } | ||
149 | |||
150 | static int _add_volume(struct hda_codec *codec, hda_nid_t nid, const char *pfx, | ||
151 | int chan, int dir) | ||
152 | { | ||
153 | char namestr[44]; | ||
154 | int type = dir ? HDA_INPUT : HDA_OUTPUT; | ||
155 | struct snd_kcontrol_new knew = | ||
156 | HDA_CODEC_VOLUME_MONO(namestr, nid, chan, 0, type); | ||
157 | sprintf(namestr, "%s %s Volume", pfx, dirstr[dir]); | ||
158 | return snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec)); | ||
159 | } | ||
160 | |||
161 | #define add_out_switch(codec, nid, pfx) _add_switch(codec, nid, pfx, 3, 0) | ||
162 | #define add_out_volume(codec, nid, pfx) _add_volume(codec, nid, pfx, 3, 0) | ||
163 | #define add_in_switch(codec, nid, pfx) _add_switch(codec, nid, pfx, 3, 1) | ||
164 | #define add_in_volume(codec, nid, pfx) _add_volume(codec, nid, pfx, 3, 1) | ||
165 | #define add_mono_switch(codec, nid, pfx, chan) \ | ||
166 | _add_switch(codec, nid, pfx, chan, 0) | ||
167 | #define add_mono_volume(codec, nid, pfx, chan) \ | ||
168 | _add_volume(codec, nid, pfx, chan, 0) | ||
169 | |||
170 | static int ca0110_build_controls(struct hda_codec *codec) | ||
171 | { | ||
172 | struct ca0110_spec *spec = codec->spec; | ||
173 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
174 | static char *prefix[AUTO_CFG_MAX_OUTS] = { | ||
175 | "Front", "Surround", NULL, "Side", "Multi" | ||
176 | }; | ||
177 | hda_nid_t mutenid; | ||
178 | int i, err; | ||
179 | |||
180 | for (i = 0; i < spec->multiout.num_dacs; i++) { | ||
181 | if (get_wcaps(codec, spec->out_pins[i]) & AC_WCAP_OUT_AMP) | ||
182 | mutenid = spec->out_pins[i]; | ||
183 | else | ||
184 | mutenid = spec->multiout.dac_nids[i]; | ||
185 | if (!prefix[i]) { | ||
186 | err = add_mono_switch(codec, mutenid, | ||
187 | "Center", 1); | ||
188 | if (err < 0) | ||
189 | return err; | ||
190 | err = add_mono_switch(codec, mutenid, | ||
191 | "LFE", 1); | ||
192 | if (err < 0) | ||
193 | return err; | ||
194 | err = add_mono_volume(codec, spec->multiout.dac_nids[i], | ||
195 | "Center", 1); | ||
196 | if (err < 0) | ||
197 | return err; | ||
198 | err = add_mono_volume(codec, spec->multiout.dac_nids[i], | ||
199 | "LFE", 1); | ||
200 | if (err < 0) | ||
201 | return err; | ||
202 | } else { | ||
203 | err = add_out_switch(codec, mutenid, | ||
204 | prefix[i]); | ||
205 | if (err < 0) | ||
206 | return err; | ||
207 | err = add_out_volume(codec, spec->multiout.dac_nids[i], | ||
208 | prefix[i]); | ||
209 | if (err < 0) | ||
210 | return err; | ||
211 | } | ||
212 | } | ||
213 | if (cfg->hp_outs) { | ||
214 | if (get_wcaps(codec, cfg->hp_pins[0]) & AC_WCAP_OUT_AMP) | ||
215 | mutenid = cfg->hp_pins[0]; | ||
216 | else | ||
217 | mutenid = spec->multiout.dac_nids[i]; | ||
218 | |||
219 | err = add_out_switch(codec, mutenid, "Headphone"); | ||
220 | if (err < 0) | ||
221 | return err; | ||
222 | if (spec->hp_dac) { | ||
223 | err = add_out_volume(codec, spec->hp_dac, "Headphone"); | ||
224 | if (err < 0) | ||
225 | return err; | ||
226 | } | ||
227 | } | ||
228 | for (i = 0; i < spec->num_inputs; i++) { | ||
229 | const char *label = spec->input_labels[i]; | ||
230 | if (get_wcaps(codec, spec->input_pins[i]) & AC_WCAP_IN_AMP) | ||
231 | mutenid = spec->input_pins[i]; | ||
232 | else | ||
233 | mutenid = spec->adcs[i]; | ||
234 | err = add_in_switch(codec, mutenid, label); | ||
235 | if (err < 0) | ||
236 | return err; | ||
237 | err = add_in_volume(codec, spec->adcs[i], label); | ||
238 | if (err < 0) | ||
239 | return err; | ||
240 | } | ||
241 | |||
242 | if (spec->dig_out) { | ||
243 | err = snd_hda_create_spdif_out_ctls(codec, spec->dig_out); | ||
244 | if (err < 0) | ||
245 | return err; | ||
246 | err = snd_hda_create_spdif_share_sw(codec, &spec->multiout); | ||
247 | if (err < 0) | ||
248 | return err; | ||
249 | spec->multiout.share_spdif = 1; | ||
250 | } | ||
251 | if (spec->dig_in) { | ||
252 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in); | ||
253 | if (err < 0) | ||
254 | return err; | ||
255 | err = add_in_volume(codec, spec->dig_in, "IEC958"); | ||
256 | } | ||
257 | return 0; | ||
258 | } | ||
259 | |||
260 | /* | ||
261 | */ | ||
262 | static struct hda_pcm_stream ca0110_pcm_analog_playback = { | ||
263 | .substreams = 1, | ||
264 | .channels_min = 2, | ||
265 | .channels_max = 8, | ||
266 | .ops = { | ||
267 | .open = ca0110_playback_pcm_open, | ||
268 | .prepare = ca0110_playback_pcm_prepare, | ||
269 | .cleanup = ca0110_playback_pcm_cleanup | ||
270 | }, | ||
271 | }; | ||
272 | |||
273 | static struct hda_pcm_stream ca0110_pcm_analog_capture = { | ||
274 | .substreams = 1, | ||
275 | .channels_min = 2, | ||
276 | .channels_max = 2, | ||
277 | .ops = { | ||
278 | .prepare = ca0110_capture_pcm_prepare, | ||
279 | .cleanup = ca0110_capture_pcm_cleanup | ||
280 | }, | ||
281 | }; | ||
282 | |||
283 | static struct hda_pcm_stream ca0110_pcm_digital_playback = { | ||
284 | .substreams = 1, | ||
285 | .channels_min = 2, | ||
286 | .channels_max = 2, | ||
287 | .ops = { | ||
288 | .open = ca0110_dig_playback_pcm_open, | ||
289 | .close = ca0110_dig_playback_pcm_close, | ||
290 | .prepare = ca0110_dig_playback_pcm_prepare | ||
291 | }, | ||
292 | }; | ||
293 | |||
294 | static struct hda_pcm_stream ca0110_pcm_digital_capture = { | ||
295 | .substreams = 1, | ||
296 | .channels_min = 2, | ||
297 | .channels_max = 2, | ||
298 | }; | ||
299 | |||
300 | static int ca0110_build_pcms(struct hda_codec *codec) | ||
301 | { | ||
302 | struct ca0110_spec *spec = codec->spec; | ||
303 | struct hda_pcm *info = spec->pcm_rec; | ||
304 | |||
305 | codec->pcm_info = info; | ||
306 | codec->num_pcms = 0; | ||
307 | |||
308 | info->name = "CA0110 Analog"; | ||
309 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ca0110_pcm_analog_playback; | ||
310 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->dacs[0]; | ||
311 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = | ||
312 | spec->multiout.max_channels; | ||
313 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = ca0110_pcm_analog_capture; | ||
314 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_inputs; | ||
315 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adcs[0]; | ||
316 | codec->num_pcms++; | ||
317 | |||
318 | if (!spec->dig_out && !spec->dig_in) | ||
319 | return 0; | ||
320 | |||
321 | info++; | ||
322 | info->name = "CA0110 Digital"; | ||
323 | info->pcm_type = HDA_PCM_TYPE_SPDIF; | ||
324 | if (spec->dig_out) { | ||
325 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | ||
326 | ca0110_pcm_digital_playback; | ||
327 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->dig_out; | ||
328 | } | ||
329 | if (spec->dig_in) { | ||
330 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | ||
331 | ca0110_pcm_digital_capture; | ||
332 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in; | ||
333 | } | ||
334 | codec->num_pcms++; | ||
335 | |||
336 | return 0; | ||
337 | } | ||
338 | |||
339 | static void init_output(struct hda_codec *codec, hda_nid_t pin, hda_nid_t dac) | ||
340 | { | ||
341 | if (pin) { | ||
342 | snd_hda_codec_write(codec, pin, 0, | ||
343 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | ||
344 | if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) | ||
345 | snd_hda_codec_write(codec, pin, 0, | ||
346 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
347 | AMP_OUT_UNMUTE); | ||
348 | } | ||
349 | if (dac) | ||
350 | snd_hda_codec_write(codec, dac, 0, | ||
351 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO); | ||
352 | } | ||
353 | |||
354 | static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) | ||
355 | { | ||
356 | if (pin) { | ||
357 | snd_hda_codec_write(codec, pin, 0, | ||
358 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80); | ||
359 | if (get_wcaps(codec, pin) & AC_WCAP_IN_AMP) | ||
360 | snd_hda_codec_write(codec, pin, 0, | ||
361 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
362 | AMP_IN_UNMUTE(0)); | ||
363 | } | ||
364 | if (adc) | ||
365 | snd_hda_codec_write(codec, adc, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
366 | AMP_IN_UNMUTE(0)); | ||
367 | } | ||
368 | |||
369 | static int ca0110_init(struct hda_codec *codec) | ||
370 | { | ||
371 | struct ca0110_spec *spec = codec->spec; | ||
372 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
373 | int i; | ||
374 | |||
375 | for (i = 0; i < spec->multiout.num_dacs; i++) | ||
376 | init_output(codec, spec->out_pins[i], | ||
377 | spec->multiout.dac_nids[i]); | ||
378 | init_output(codec, cfg->hp_pins[0], spec->hp_dac); | ||
379 | init_output(codec, cfg->dig_out_pins[0], spec->dig_out); | ||
380 | |||
381 | for (i = 0; i < spec->num_inputs; i++) | ||
382 | init_input(codec, spec->input_pins[i], spec->adcs[i]); | ||
383 | init_input(codec, cfg->dig_in_pin, spec->dig_in); | ||
384 | return 0; | ||
385 | } | ||
386 | |||
387 | static void ca0110_free(struct hda_codec *codec) | ||
388 | { | ||
389 | kfree(codec->spec); | ||
390 | } | ||
391 | |||
392 | static struct hda_codec_ops ca0110_patch_ops = { | ||
393 | .build_controls = ca0110_build_controls, | ||
394 | .build_pcms = ca0110_build_pcms, | ||
395 | .init = ca0110_init, | ||
396 | .free = ca0110_free, | ||
397 | }; | ||
398 | |||
399 | |||
400 | static void parse_line_outs(struct hda_codec *codec) | ||
401 | { | ||
402 | struct ca0110_spec *spec = codec->spec; | ||
403 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
404 | int i, n; | ||
405 | unsigned int def_conf; | ||
406 | hda_nid_t nid; | ||
407 | |||
408 | n = 0; | ||
409 | for (i = 0; i < cfg->line_outs; i++) { | ||
410 | nid = cfg->line_out_pins[i]; | ||
411 | def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
412 | if (!def_conf) | ||
413 | continue; /* invalid pin */ | ||
414 | if (snd_hda_get_connections(codec, nid, &spec->dacs[i], 1) != 1) | ||
415 | continue; | ||
416 | spec->out_pins[n++] = nid; | ||
417 | } | ||
418 | spec->multiout.dac_nids = spec->dacs; | ||
419 | spec->multiout.num_dacs = n; | ||
420 | spec->multiout.max_channels = n * 2; | ||
421 | } | ||
422 | |||
423 | static void parse_hp_out(struct hda_codec *codec) | ||
424 | { | ||
425 | struct ca0110_spec *spec = codec->spec; | ||
426 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
427 | int i; | ||
428 | unsigned int def_conf; | ||
429 | hda_nid_t nid, dac; | ||
430 | |||
431 | if (!cfg->hp_outs) | ||
432 | return; | ||
433 | nid = cfg->hp_pins[0]; | ||
434 | def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
435 | if (!def_conf) { | ||
436 | cfg->hp_outs = 0; | ||
437 | return; | ||
438 | } | ||
439 | if (snd_hda_get_connections(codec, nid, &dac, 1) != 1) | ||
440 | return; | ||
441 | |||
442 | for (i = 0; i < cfg->line_outs; i++) | ||
443 | if (dac == spec->dacs[i]) | ||
444 | break; | ||
445 | if (i >= cfg->line_outs) { | ||
446 | spec->hp_dac = dac; | ||
447 | spec->multiout.hp_nid = dac; | ||
448 | } | ||
449 | } | ||
450 | |||
451 | static void parse_input(struct hda_codec *codec) | ||
452 | { | ||
453 | struct ca0110_spec *spec = codec->spec; | ||
454 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
455 | hda_nid_t nid, pin; | ||
456 | int n, i, j; | ||
457 | |||
458 | n = 0; | ||
459 | nid = codec->start_nid; | ||
460 | for (i = 0; i < codec->num_nodes; i++, nid++) { | ||
461 | unsigned int wcaps = get_wcaps(codec, nid); | ||
462 | unsigned int type = (wcaps & AC_WCAP_TYPE) >> | ||
463 | AC_WCAP_TYPE_SHIFT; | ||
464 | if (type != AC_WID_AUD_IN) | ||
465 | continue; | ||
466 | if (snd_hda_get_connections(codec, nid, &pin, 1) != 1) | ||
467 | continue; | ||
468 | if (pin == cfg->dig_in_pin) { | ||
469 | spec->dig_in = nid; | ||
470 | continue; | ||
471 | } | ||
472 | for (j = 0; j < AUTO_PIN_LAST; j++) | ||
473 | if (cfg->input_pins[j] == pin) | ||
474 | break; | ||
475 | if (j >= AUTO_PIN_LAST) | ||
476 | continue; | ||
477 | spec->input_pins[n] = pin; | ||
478 | spec->input_labels[n] = auto_pin_cfg_labels[j]; | ||
479 | spec->adcs[n] = nid; | ||
480 | n++; | ||
481 | } | ||
482 | spec->num_inputs = n; | ||
483 | } | ||
484 | |||
485 | static void parse_digital(struct hda_codec *codec) | ||
486 | { | ||
487 | struct ca0110_spec *spec = codec->spec; | ||
488 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
489 | |||
490 | if (cfg->dig_outs && | ||
491 | snd_hda_get_connections(codec, cfg->dig_out_pins[0], | ||
492 | &spec->dig_out, 1) == 1) | ||
493 | spec->multiout.dig_out_nid = cfg->dig_out_pins[0]; | ||
494 | } | ||
495 | |||
496 | static int ca0110_parse_auto_config(struct hda_codec *codec) | ||
497 | { | ||
498 | struct ca0110_spec *spec = codec->spec; | ||
499 | int err; | ||
500 | |||
501 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); | ||
502 | if (err < 0) | ||
503 | return err; | ||
504 | |||
505 | parse_line_outs(codec); | ||
506 | parse_hp_out(codec); | ||
507 | parse_digital(codec); | ||
508 | parse_input(codec); | ||
509 | return 0; | ||
510 | } | ||
511 | |||
512 | |||
513 | int patch_ca0110(struct hda_codec *codec) | ||
514 | { | ||
515 | struct ca0110_spec *spec; | ||
516 | int err; | ||
517 | |||
518 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
519 | if (!spec) | ||
520 | return -ENOMEM; | ||
521 | codec->spec = spec; | ||
522 | |||
523 | codec->bus->needs_damn_long_delay = 1; | ||
524 | |||
525 | err = ca0110_parse_auto_config(codec); | ||
526 | if (err < 0) | ||
527 | goto error; | ||
528 | |||
529 | codec->patch_ops = ca0110_patch_ops; | ||
530 | |||
531 | return 0; | ||
532 | |||
533 | error: | ||
534 | kfree(codec->spec); | ||
535 | codec->spec = NULL; | ||
536 | return err; | ||
537 | } | ||
538 | |||
539 | |||
540 | /* | ||
541 | * patch entries | ||
542 | */ | ||
543 | static struct hda_codec_preset snd_hda_preset_ca0110[] = { | ||
544 | { .id = 0x1102000a, .name = "CA0110-IBG", .patch = patch_ca0110 }, | ||
545 | { .id = 0x1102000b, .name = "CA0110-IBG", .patch = patch_ca0110 }, | ||
546 | { .id = 0x1102000d, .name = "SB0880 X-Fi", .patch = patch_ca0110 }, | ||
547 | {} /* terminator */ | ||
548 | }; | ||
549 | |||
550 | MODULE_ALIAS("snd-hda-codec-id:1102000a"); | ||
551 | MODULE_ALIAS("snd-hda-codec-id:1102000b"); | ||
552 | MODULE_ALIAS("snd-hda-codec-id:1102000d"); | ||
553 | |||
554 | MODULE_LICENSE("GPL"); | ||
555 | MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec"); | ||
556 | |||
557 | static struct hda_codec_preset_list ca0110_list = { | ||
558 | .preset = snd_hda_preset_ca0110, | ||
559 | .owner = THIS_MODULE, | ||
560 | }; | ||
561 | |||
562 | static int __init patch_ca0110_init(void) | ||
563 | { | ||
564 | return snd_hda_add_codec_preset(&ca0110_list); | ||
565 | } | ||
566 | |||
567 | static void __exit patch_ca0110_exit(void) | ||
568 | { | ||
569 | snd_hda_delete_codec_preset(&ca0110_list); | ||
570 | } | ||
571 | |||
572 | module_init(patch_ca0110_init) | ||
573 | module_exit(patch_ca0110_exit) | ||
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 56ce19e68cb5..4fcbe21829ab 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -1848,6 +1848,7 @@ static const char *cxt5051_models[CXT5051_MODELS] = { | |||
1848 | 1848 | ||
1849 | static struct snd_pci_quirk cxt5051_cfg_tbl[] = { | 1849 | static struct snd_pci_quirk cxt5051_cfg_tbl[] = { |
1850 | SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), | 1850 | SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), |
1851 | SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), | ||
1851 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", | 1852 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
1852 | CXT5051_LAPTOP), | 1853 | CXT5051_LAPTOP), |
1853 | SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), | 1854 | SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), |
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index d57d8132a06e..f5792e2eea82 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c | |||
@@ -35,9 +35,28 @@ struct nvhdmi_spec { | |||
35 | struct hda_pcm pcm_rec; | 35 | struct hda_pcm pcm_rec; |
36 | }; | 36 | }; |
37 | 37 | ||
38 | #define Nv_VERB_SET_Channel_Allocation 0xF79 | ||
39 | #define Nv_VERB_SET_Info_Frame_Checksum 0xF7A | ||
40 | #define Nv_VERB_SET_Audio_Protection_On 0xF98 | ||
41 | #define Nv_VERB_SET_Audio_Protection_Off 0xF99 | ||
42 | |||
43 | #define Nv_Master_Convert_nid 0x04 | ||
44 | #define Nv_Master_Pin_nid 0x05 | ||
45 | |||
46 | static hda_nid_t nvhdmi_convert_nids[4] = { | ||
47 | /*front, rear, clfe, rear_surr */ | ||
48 | 0x6, 0x8, 0xa, 0xc, | ||
49 | }; | ||
50 | |||
38 | static struct hda_verb nvhdmi_basic_init[] = { | 51 | static struct hda_verb nvhdmi_basic_init[] = { |
52 | /* set audio protect on */ | ||
53 | { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1}, | ||
39 | /* enable digital output on pin widget */ | 54 | /* enable digital output on pin widget */ |
40 | { 0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | 55 | { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, |
56 | { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, | ||
57 | { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, | ||
58 | { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, | ||
59 | { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, | ||
41 | {} /* terminator */ | 60 | {} /* terminator */ |
42 | }; | 61 | }; |
43 | 62 | ||
@@ -66,48 +85,205 @@ static int nvhdmi_init(struct hda_codec *codec) | |||
66 | * Digital out | 85 | * Digital out |
67 | */ | 86 | */ |
68 | static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | 87 | static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
69 | struct hda_codec *codec, | 88 | struct hda_codec *codec, |
70 | struct snd_pcm_substream *substream) | 89 | struct snd_pcm_substream *substream) |
71 | { | 90 | { |
72 | struct nvhdmi_spec *spec = codec->spec; | 91 | struct nvhdmi_spec *spec = codec->spec; |
73 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | 92 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
74 | } | 93 | } |
75 | 94 | ||
76 | static int nvhdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | 95 | static int nvhdmi_dig_playback_pcm_close_8ch(struct hda_pcm_stream *hinfo, |
77 | struct hda_codec *codec, | 96 | struct hda_codec *codec, |
78 | struct snd_pcm_substream *substream) | 97 | struct snd_pcm_substream *substream) |
79 | { | 98 | { |
80 | struct nvhdmi_spec *spec = codec->spec; | 99 | struct nvhdmi_spec *spec = codec->spec; |
100 | int i; | ||
101 | |||
102 | snd_hda_codec_write(codec, Nv_Master_Convert_nid, | ||
103 | 0, AC_VERB_SET_CHANNEL_STREAMID, 0); | ||
104 | for (i = 0; i < 4; i++) { | ||
105 | /* set the stream id */ | ||
106 | snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0, | ||
107 | AC_VERB_SET_CHANNEL_STREAMID, 0); | ||
108 | /* set the stream format */ | ||
109 | snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0, | ||
110 | AC_VERB_SET_STREAM_FORMAT, 0); | ||
111 | } | ||
112 | |||
81 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | 113 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
82 | } | 114 | } |
83 | 115 | ||
84 | static int nvhdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | 116 | static int nvhdmi_dig_playback_pcm_close_2ch(struct hda_pcm_stream *hinfo, |
85 | struct hda_codec *codec, | 117 | struct hda_codec *codec, |
86 | unsigned int stream_tag, | 118 | struct snd_pcm_substream *substream) |
87 | unsigned int format, | 119 | { |
88 | struct snd_pcm_substream *substream) | 120 | struct nvhdmi_spec *spec = codec->spec; |
121 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | ||
122 | } | ||
123 | |||
124 | static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, | ||
125 | struct hda_codec *codec, | ||
126 | unsigned int stream_tag, | ||
127 | unsigned int format, | ||
128 | struct snd_pcm_substream *substream) | ||
129 | { | ||
130 | int chs; | ||
131 | unsigned int dataDCC1, dataDCC2, chan, chanmask, channel_id; | ||
132 | int i; | ||
133 | |||
134 | mutex_lock(&codec->spdif_mutex); | ||
135 | |||
136 | chs = substream->runtime->channels; | ||
137 | chan = chs ? (chs - 1) : 1; | ||
138 | |||
139 | switch (chs) { | ||
140 | default: | ||
141 | case 0: | ||
142 | case 2: | ||
143 | chanmask = 0x00; | ||
144 | break; | ||
145 | case 4: | ||
146 | chanmask = 0x08; | ||
147 | break; | ||
148 | case 6: | ||
149 | chanmask = 0x0b; | ||
150 | break; | ||
151 | case 8: | ||
152 | chanmask = 0x13; | ||
153 | break; | ||
154 | } | ||
155 | dataDCC1 = AC_DIG1_ENABLE | AC_DIG1_COPYRIGHT; | ||
156 | dataDCC2 = 0x2; | ||
157 | |||
158 | /* set the Audio InforFrame Channel Allocation */ | ||
159 | snd_hda_codec_write(codec, 0x1, 0, | ||
160 | Nv_VERB_SET_Channel_Allocation, chanmask); | ||
161 | |||
162 | /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ | ||
163 | if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) | ||
164 | snd_hda_codec_write(codec, | ||
165 | Nv_Master_Convert_nid, | ||
166 | 0, | ||
167 | AC_VERB_SET_DIGI_CONVERT_1, | ||
168 | codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); | ||
169 | |||
170 | /* set the stream id */ | ||
171 | snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0, | ||
172 | AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); | ||
173 | |||
174 | /* set the stream format */ | ||
175 | snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0, | ||
176 | AC_VERB_SET_STREAM_FORMAT, format); | ||
177 | |||
178 | /* turn on again (if needed) */ | ||
179 | /* enable and set the channel status audio/data flag */ | ||
180 | if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) { | ||
181 | snd_hda_codec_write(codec, | ||
182 | Nv_Master_Convert_nid, | ||
183 | 0, | ||
184 | AC_VERB_SET_DIGI_CONVERT_1, | ||
185 | codec->spdif_ctls & 0xff); | ||
186 | snd_hda_codec_write(codec, | ||
187 | Nv_Master_Convert_nid, | ||
188 | 0, | ||
189 | AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); | ||
190 | } | ||
191 | |||
192 | for (i = 0; i < 4; i++) { | ||
193 | if (chs == 2) | ||
194 | channel_id = 0; | ||
195 | else | ||
196 | channel_id = i * 2; | ||
197 | |||
198 | /* turn off SPDIF once; | ||
199 | *otherwise the IEC958 bits won't be updated | ||
200 | */ | ||
201 | if (codec->spdif_status_reset && | ||
202 | (codec->spdif_ctls & AC_DIG1_ENABLE)) | ||
203 | snd_hda_codec_write(codec, | ||
204 | nvhdmi_convert_nids[i], | ||
205 | 0, | ||
206 | AC_VERB_SET_DIGI_CONVERT_1, | ||
207 | codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); | ||
208 | /* set the stream id */ | ||
209 | snd_hda_codec_write(codec, | ||
210 | nvhdmi_convert_nids[i], | ||
211 | 0, | ||
212 | AC_VERB_SET_CHANNEL_STREAMID, | ||
213 | (stream_tag << 4) | channel_id); | ||
214 | /* set the stream format */ | ||
215 | snd_hda_codec_write(codec, | ||
216 | nvhdmi_convert_nids[i], | ||
217 | 0, | ||
218 | AC_VERB_SET_STREAM_FORMAT, | ||
219 | format); | ||
220 | /* turn on again (if needed) */ | ||
221 | /* enable and set the channel status audio/data flag */ | ||
222 | if (codec->spdif_status_reset && | ||
223 | (codec->spdif_ctls & AC_DIG1_ENABLE)) { | ||
224 | snd_hda_codec_write(codec, | ||
225 | nvhdmi_convert_nids[i], | ||
226 | 0, | ||
227 | AC_VERB_SET_DIGI_CONVERT_1, | ||
228 | codec->spdif_ctls & 0xff); | ||
229 | snd_hda_codec_write(codec, | ||
230 | nvhdmi_convert_nids[i], | ||
231 | 0, | ||
232 | AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | /* set the Audio Info Frame Checksum */ | ||
237 | snd_hda_codec_write(codec, 0x1, 0, | ||
238 | Nv_VERB_SET_Info_Frame_Checksum, | ||
239 | (0x71 - chan - chanmask)); | ||
240 | |||
241 | mutex_unlock(&codec->spdif_mutex); | ||
242 | return 0; | ||
243 | } | ||
244 | |||
245 | static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream *hinfo, | ||
246 | struct hda_codec *codec, | ||
247 | unsigned int stream_tag, | ||
248 | unsigned int format, | ||
249 | struct snd_pcm_substream *substream) | ||
89 | { | 250 | { |
90 | struct nvhdmi_spec *spec = codec->spec; | 251 | struct nvhdmi_spec *spec = codec->spec; |
91 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, | 252 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, |
92 | format, substream); | 253 | format, substream); |
93 | } | 254 | } |
94 | 255 | ||
95 | static struct hda_pcm_stream nvhdmi_pcm_digital_playback = { | 256 | static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch = { |
257 | .substreams = 1, | ||
258 | .channels_min = 2, | ||
259 | .channels_max = 8, | ||
260 | .nid = Nv_Master_Convert_nid, | ||
261 | .rates = SNDRV_PCM_RATE_48000, | ||
262 | .maxbps = 16, | ||
263 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
264 | .ops = { | ||
265 | .open = nvhdmi_dig_playback_pcm_open, | ||
266 | .close = nvhdmi_dig_playback_pcm_close_8ch, | ||
267 | .prepare = nvhdmi_dig_playback_pcm_prepare_8ch | ||
268 | }, | ||
269 | }; | ||
270 | |||
271 | static struct hda_pcm_stream nvhdmi_pcm_digital_playback_2ch = { | ||
96 | .substreams = 1, | 272 | .substreams = 1, |
97 | .channels_min = 2, | 273 | .channels_min = 2, |
98 | .channels_max = 2, | 274 | .channels_max = 2, |
99 | .nid = 0x4, /* NID to query formats and rates and setup streams */ | 275 | .nid = Nv_Master_Convert_nid, |
100 | .rates = SNDRV_PCM_RATE_48000, | 276 | .rates = SNDRV_PCM_RATE_48000, |
101 | .maxbps = 16, | 277 | .maxbps = 16, |
102 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 278 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
103 | .ops = { | 279 | .ops = { |
104 | .open = nvhdmi_dig_playback_pcm_open, | 280 | .open = nvhdmi_dig_playback_pcm_open, |
105 | .close = nvhdmi_dig_playback_pcm_close, | 281 | .close = nvhdmi_dig_playback_pcm_close_2ch, |
106 | .prepare = nvhdmi_dig_playback_pcm_prepare | 282 | .prepare = nvhdmi_dig_playback_pcm_prepare_2ch |
107 | }, | 283 | }, |
108 | }; | 284 | }; |
109 | 285 | ||
110 | static int nvhdmi_build_pcms(struct hda_codec *codec) | 286 | static int nvhdmi_build_pcms_8ch(struct hda_codec *codec) |
111 | { | 287 | { |
112 | struct nvhdmi_spec *spec = codec->spec; | 288 | struct nvhdmi_spec *spec = codec->spec; |
113 | struct hda_pcm *info = &spec->pcm_rec; | 289 | struct hda_pcm *info = &spec->pcm_rec; |
@@ -117,7 +293,24 @@ static int nvhdmi_build_pcms(struct hda_codec *codec) | |||
117 | 293 | ||
118 | info->name = "NVIDIA HDMI"; | 294 | info->name = "NVIDIA HDMI"; |
119 | info->pcm_type = HDA_PCM_TYPE_HDMI; | 295 | info->pcm_type = HDA_PCM_TYPE_HDMI; |
120 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = nvhdmi_pcm_digital_playback; | 296 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] |
297 | = nvhdmi_pcm_digital_playback_8ch; | ||
298 | |||
299 | return 0; | ||
300 | } | ||
301 | |||
302 | static int nvhdmi_build_pcms_2ch(struct hda_codec *codec) | ||
303 | { | ||
304 | struct nvhdmi_spec *spec = codec->spec; | ||
305 | struct hda_pcm *info = &spec->pcm_rec; | ||
306 | |||
307 | codec->num_pcms = 1; | ||
308 | codec->pcm_info = info; | ||
309 | |||
310 | info->name = "NVIDIA HDMI"; | ||
311 | info->pcm_type = HDA_PCM_TYPE_HDMI; | ||
312 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] | ||
313 | = nvhdmi_pcm_digital_playback_2ch; | ||
121 | 314 | ||
122 | return 0; | 315 | return 0; |
123 | } | 316 | } |
@@ -127,14 +320,40 @@ static void nvhdmi_free(struct hda_codec *codec) | |||
127 | kfree(codec->spec); | 320 | kfree(codec->spec); |
128 | } | 321 | } |
129 | 322 | ||
130 | static struct hda_codec_ops nvhdmi_patch_ops = { | 323 | static struct hda_codec_ops nvhdmi_patch_ops_8ch = { |
324 | .build_controls = nvhdmi_build_controls, | ||
325 | .build_pcms = nvhdmi_build_pcms_8ch, | ||
326 | .init = nvhdmi_init, | ||
327 | .free = nvhdmi_free, | ||
328 | }; | ||
329 | |||
330 | static struct hda_codec_ops nvhdmi_patch_ops_2ch = { | ||
131 | .build_controls = nvhdmi_build_controls, | 331 | .build_controls = nvhdmi_build_controls, |
132 | .build_pcms = nvhdmi_build_pcms, | 332 | .build_pcms = nvhdmi_build_pcms_2ch, |
133 | .init = nvhdmi_init, | 333 | .init = nvhdmi_init, |
134 | .free = nvhdmi_free, | 334 | .free = nvhdmi_free, |
135 | }; | 335 | }; |
136 | 336 | ||
137 | static int patch_nvhdmi(struct hda_codec *codec) | 337 | static int patch_nvhdmi_8ch(struct hda_codec *codec) |
338 | { | ||
339 | struct nvhdmi_spec *spec; | ||
340 | |||
341 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
342 | if (spec == NULL) | ||
343 | return -ENOMEM; | ||
344 | |||
345 | codec->spec = spec; | ||
346 | |||
347 | spec->multiout.num_dacs = 0; /* no analog */ | ||
348 | spec->multiout.max_channels = 8; | ||
349 | spec->multiout.dig_out_nid = Nv_Master_Convert_nid; | ||
350 | |||
351 | codec->patch_ops = nvhdmi_patch_ops_8ch; | ||
352 | |||
353 | return 0; | ||
354 | } | ||
355 | |||
356 | static int patch_nvhdmi_2ch(struct hda_codec *codec) | ||
138 | { | 357 | { |
139 | struct nvhdmi_spec *spec; | 358 | struct nvhdmi_spec *spec; |
140 | 359 | ||
@@ -144,13 +363,11 @@ static int patch_nvhdmi(struct hda_codec *codec) | |||
144 | 363 | ||
145 | codec->spec = spec; | 364 | codec->spec = spec; |
146 | 365 | ||
147 | spec->multiout.num_dacs = 0; /* no analog */ | 366 | spec->multiout.num_dacs = 0; /* no analog */ |
148 | spec->multiout.max_channels = 2; | 367 | spec->multiout.max_channels = 2; |
149 | spec->multiout.dig_out_nid = 0x4; /* NID for copying analog to digital, | 368 | spec->multiout.dig_out_nid = Nv_Master_Convert_nid; |
150 | * seems to be unused in pure-digital | ||
151 | * case. */ | ||
152 | 369 | ||
153 | codec->patch_ops = nvhdmi_patch_ops; | 370 | codec->patch_ops = nvhdmi_patch_ops_2ch; |
154 | 371 | ||
155 | return 0; | 372 | return 0; |
156 | } | 373 | } |
@@ -159,11 +376,11 @@ static int patch_nvhdmi(struct hda_codec *codec) | |||
159 | * patch entries | 376 | * patch entries |
160 | */ | 377 | */ |
161 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { | 378 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { |
162 | { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi }, | 379 | { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, |
163 | { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi }, | 380 | { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, |
164 | { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi }, | 381 | { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch }, |
165 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi }, | 382 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, |
166 | { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi }, | 383 | { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, |
167 | {} /* terminator */ | 384 | {} /* terminator */ |
168 | }; | 385 | }; |
169 | 386 | ||
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index b8a0d3e79272..337d2a59c67e 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -190,6 +190,7 @@ enum { | |||
190 | ALC663_ASUS_MODE6, | 190 | ALC663_ASUS_MODE6, |
191 | ALC272_DELL, | 191 | ALC272_DELL, |
192 | ALC272_DELL_ZM1, | 192 | ALC272_DELL_ZM1, |
193 | ALC272_SAMSUNG_NC10, | ||
193 | ALC662_AUTO, | 194 | ALC662_AUTO, |
194 | ALC662_MODEL_LAST, | 195 | ALC662_MODEL_LAST, |
195 | }; | 196 | }; |
@@ -205,6 +206,7 @@ enum { | |||
205 | ALC882_ASUS_A7M, | 206 | ALC882_ASUS_A7M, |
206 | ALC885_MACPRO, | 207 | ALC885_MACPRO, |
207 | ALC885_MBP3, | 208 | ALC885_MBP3, |
209 | ALC885_MB5, | ||
208 | ALC885_IMAC24, | 210 | ALC885_IMAC24, |
209 | ALC882_AUTO, | 211 | ALC882_AUTO, |
210 | ALC882_MODEL_LAST, | 212 | ALC882_MODEL_LAST, |
@@ -218,9 +220,11 @@ enum { | |||
218 | ALC883_6ST_DIG, | 220 | ALC883_6ST_DIG, |
219 | ALC883_TARGA_DIG, | 221 | ALC883_TARGA_DIG, |
220 | ALC883_TARGA_2ch_DIG, | 222 | ALC883_TARGA_2ch_DIG, |
223 | ALC883_TARGA_8ch_DIG, | ||
221 | ALC883_ACER, | 224 | ALC883_ACER, |
222 | ALC883_ACER_ASPIRE, | 225 | ALC883_ACER_ASPIRE, |
223 | ALC888_ACER_ASPIRE_4930G, | 226 | ALC888_ACER_ASPIRE_4930G, |
227 | ALC888_ACER_ASPIRE_8930G, | ||
224 | ALC883_MEDION, | 228 | ALC883_MEDION, |
225 | ALC883_MEDION_MD2, | 229 | ALC883_MEDION_MD2, |
226 | ALC883_LAPTOP_EAPD, | 230 | ALC883_LAPTOP_EAPD, |
@@ -238,7 +242,9 @@ enum { | |||
238 | ALC883_3ST_6ch_INTEL, | 242 | ALC883_3ST_6ch_INTEL, |
239 | ALC888_ASUS_M90V, | 243 | ALC888_ASUS_M90V, |
240 | ALC888_ASUS_EEE1601, | 244 | ALC888_ASUS_EEE1601, |
245 | ALC889A_MB31, | ||
241 | ALC1200_ASUS_P5Q, | 246 | ALC1200_ASUS_P5Q, |
247 | ALC883_SONY_VAIO_TT, | ||
242 | ALC883_AUTO, | 248 | ALC883_AUTO, |
243 | ALC883_MODEL_LAST, | 249 | ALC883_MODEL_LAST, |
244 | }; | 250 | }; |
@@ -253,6 +259,15 @@ enum { | |||
253 | /* for GPIO Poll */ | 259 | /* for GPIO Poll */ |
254 | #define GPIO_MASK 0x03 | 260 | #define GPIO_MASK 0x03 |
255 | 261 | ||
262 | /* extra amp-initialization sequence types */ | ||
263 | enum { | ||
264 | ALC_INIT_NONE, | ||
265 | ALC_INIT_DEFAULT, | ||
266 | ALC_INIT_GPIO1, | ||
267 | ALC_INIT_GPIO2, | ||
268 | ALC_INIT_GPIO3, | ||
269 | }; | ||
270 | |||
256 | struct alc_spec { | 271 | struct alc_spec { |
257 | /* codec parameterization */ | 272 | /* codec parameterization */ |
258 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ | 273 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
@@ -266,13 +281,13 @@ struct alc_spec { | |||
266 | */ | 281 | */ |
267 | unsigned int num_init_verbs; | 282 | unsigned int num_init_verbs; |
268 | 283 | ||
269 | char *stream_name_analog; /* analog PCM stream */ | 284 | char stream_name_analog[16]; /* analog PCM stream */ |
270 | struct hda_pcm_stream *stream_analog_playback; | 285 | struct hda_pcm_stream *stream_analog_playback; |
271 | struct hda_pcm_stream *stream_analog_capture; | 286 | struct hda_pcm_stream *stream_analog_capture; |
272 | struct hda_pcm_stream *stream_analog_alt_playback; | 287 | struct hda_pcm_stream *stream_analog_alt_playback; |
273 | struct hda_pcm_stream *stream_analog_alt_capture; | 288 | struct hda_pcm_stream *stream_analog_alt_capture; |
274 | 289 | ||
275 | char *stream_name_digital; /* digital PCM stream */ | 290 | char stream_name_digital[16]; /* digital PCM stream */ |
276 | struct hda_pcm_stream *stream_digital_playback; | 291 | struct hda_pcm_stream *stream_digital_playback; |
277 | struct hda_pcm_stream *stream_digital_capture; | 292 | struct hda_pcm_stream *stream_digital_capture; |
278 | 293 | ||
@@ -301,6 +316,8 @@ struct alc_spec { | |||
301 | const struct hda_channel_mode *channel_mode; | 316 | const struct hda_channel_mode *channel_mode; |
302 | int num_channel_mode; | 317 | int num_channel_mode; |
303 | int need_dac_fix; | 318 | int need_dac_fix; |
319 | int const_channel_count; | ||
320 | int ext_channel_count; | ||
304 | 321 | ||
305 | /* PCM information */ | 322 | /* PCM information */ |
306 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ | 323 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
@@ -322,6 +339,7 @@ struct alc_spec { | |||
322 | 339 | ||
323 | /* other flags */ | 340 | /* other flags */ |
324 | unsigned int no_analog :1; /* digital I/O only */ | 341 | unsigned int no_analog :1; /* digital I/O only */ |
342 | int init_amp; | ||
325 | 343 | ||
326 | /* for virtual master */ | 344 | /* for virtual master */ |
327 | hda_nid_t vmaster_nid; | 345 | hda_nid_t vmaster_nid; |
@@ -355,6 +373,7 @@ struct alc_config_preset { | |||
355 | unsigned int num_channel_mode; | 373 | unsigned int num_channel_mode; |
356 | const struct hda_channel_mode *channel_mode; | 374 | const struct hda_channel_mode *channel_mode; |
357 | int need_dac_fix; | 375 | int need_dac_fix; |
376 | int const_channel_count; | ||
358 | unsigned int num_mux_defs; | 377 | unsigned int num_mux_defs; |
359 | const struct hda_input_mux *input_mux; | 378 | const struct hda_input_mux *input_mux; |
360 | void (*unsol_event)(struct hda_codec *, unsigned int); | 379 | void (*unsol_event)(struct hda_codec *, unsigned int); |
@@ -449,7 +468,7 @@ static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, | |||
449 | struct alc_spec *spec = codec->spec; | 468 | struct alc_spec *spec = codec->spec; |
450 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, | 469 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
451 | spec->num_channel_mode, | 470 | spec->num_channel_mode, |
452 | spec->multiout.max_channels); | 471 | spec->ext_channel_count); |
453 | } | 472 | } |
454 | 473 | ||
455 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, | 474 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
@@ -459,9 +478,12 @@ static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, | |||
459 | struct alc_spec *spec = codec->spec; | 478 | struct alc_spec *spec = codec->spec; |
460 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, | 479 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
461 | spec->num_channel_mode, | 480 | spec->num_channel_mode, |
462 | &spec->multiout.max_channels); | 481 | &spec->ext_channel_count); |
463 | if (err >= 0 && spec->need_dac_fix) | 482 | if (err >= 0 && !spec->const_channel_count) { |
464 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; | 483 | spec->multiout.max_channels = spec->ext_channel_count; |
484 | if (spec->need_dac_fix) | ||
485 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; | ||
486 | } | ||
465 | return err; | 487 | return err; |
466 | } | 488 | } |
467 | 489 | ||
@@ -776,6 +798,12 @@ static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, | |||
776 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; | 798 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
777 | if (pincap & AC_PINCAP_VREF_80) | 799 | if (pincap & AC_PINCAP_VREF_80) |
778 | val = PIN_VREF80; | 800 | val = PIN_VREF80; |
801 | else if (pincap & AC_PINCAP_VREF_50) | ||
802 | val = PIN_VREF50; | ||
803 | else if (pincap & AC_PINCAP_VREF_100) | ||
804 | val = PIN_VREF100; | ||
805 | else if (pincap & AC_PINCAP_VREF_GRD) | ||
806 | val = PIN_VREFGRD; | ||
779 | } | 807 | } |
780 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); | 808 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
781 | } | 809 | } |
@@ -835,8 +863,13 @@ static void setup_preset(struct alc_spec *spec, | |||
835 | spec->channel_mode = preset->channel_mode; | 863 | spec->channel_mode = preset->channel_mode; |
836 | spec->num_channel_mode = preset->num_channel_mode; | 864 | spec->num_channel_mode = preset->num_channel_mode; |
837 | spec->need_dac_fix = preset->need_dac_fix; | 865 | spec->need_dac_fix = preset->need_dac_fix; |
866 | spec->const_channel_count = preset->const_channel_count; | ||
838 | 867 | ||
839 | spec->multiout.max_channels = spec->channel_mode[0].channels; | 868 | if (preset->const_channel_count) |
869 | spec->multiout.max_channels = preset->const_channel_count; | ||
870 | else | ||
871 | spec->multiout.max_channels = spec->channel_mode[0].channels; | ||
872 | spec->ext_channel_count = spec->channel_mode[0].channels; | ||
840 | 873 | ||
841 | spec->multiout.num_dacs = preset->num_dacs; | 874 | spec->multiout.num_dacs = preset->num_dacs; |
842 | spec->multiout.dac_nids = preset->dac_nids; | 875 | spec->multiout.dac_nids = preset->dac_nids; |
@@ -915,20 +948,26 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |||
915 | alc_fix_pll(codec); | 948 | alc_fix_pll(codec); |
916 | } | 949 | } |
917 | 950 | ||
918 | static void alc_sku_automute(struct hda_codec *codec) | 951 | static void alc_automute_pin(struct hda_codec *codec) |
919 | { | 952 | { |
920 | struct alc_spec *spec = codec->spec; | 953 | struct alc_spec *spec = codec->spec; |
921 | unsigned int present; | 954 | unsigned int present; |
922 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | 955 | unsigned int nid = spec->autocfg.hp_pins[0]; |
923 | unsigned int sp_nid = spec->autocfg.speaker_pins[0]; | 956 | int i; |
924 | 957 | ||
925 | /* need to execute and sync at first */ | 958 | /* need to execute and sync at first */ |
926 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | 959 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); |
927 | present = snd_hda_codec_read(codec, hp_nid, 0, | 960 | present = snd_hda_codec_read(codec, nid, 0, |
928 | AC_VERB_GET_PIN_SENSE, 0); | 961 | AC_VERB_GET_PIN_SENSE, 0); |
929 | spec->jack_present = (present & 0x80000000) != 0; | 962 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; |
930 | snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 963 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { |
931 | spec->jack_present ? 0 : PIN_OUT); | 964 | nid = spec->autocfg.speaker_pins[i]; |
965 | if (!nid) | ||
966 | break; | ||
967 | snd_hda_codec_write(codec, nid, 0, | ||
968 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
969 | spec->jack_present ? 0 : PIN_OUT); | ||
970 | } | ||
932 | } | 971 | } |
933 | 972 | ||
934 | #if 0 /* it's broken in some acses -- temporarily disabled */ | 973 | #if 0 /* it's broken in some acses -- temporarily disabled */ |
@@ -963,16 +1002,19 @@ static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |||
963 | res >>= 28; | 1002 | res >>= 28; |
964 | else | 1003 | else |
965 | res >>= 26; | 1004 | res >>= 26; |
966 | if (res == ALC880_HP_EVENT) | 1005 | switch (res) { |
967 | alc_sku_automute(codec); | 1006 | case ALC880_HP_EVENT: |
968 | 1007 | alc_automute_pin(codec); | |
969 | if (res == ALC880_MIC_EVENT) | 1008 | break; |
1009 | case ALC880_MIC_EVENT: | ||
970 | alc_mic_automute(codec); | 1010 | alc_mic_automute(codec); |
1011 | break; | ||
1012 | } | ||
971 | } | 1013 | } |
972 | 1014 | ||
973 | static void alc_inithook(struct hda_codec *codec) | 1015 | static void alc_inithook(struct hda_codec *codec) |
974 | { | 1016 | { |
975 | alc_sku_automute(codec); | 1017 | alc_automute_pin(codec); |
976 | alc_mic_automute(codec); | 1018 | alc_mic_automute(codec); |
977 | } | 1019 | } |
978 | 1020 | ||
@@ -994,69 +1036,21 @@ static void alc888_coef_init(struct hda_codec *codec) | |||
994 | AC_VERB_SET_PROC_COEF, 0x3030); | 1036 | AC_VERB_SET_PROC_COEF, 0x3030); |
995 | } | 1037 | } |
996 | 1038 | ||
997 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. | 1039 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
998 | * 31 ~ 16 : Manufacture ID | ||
999 | * 15 ~ 8 : SKU ID | ||
1000 | * 7 ~ 0 : Assembly ID | ||
1001 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | ||
1002 | */ | ||
1003 | static void alc_subsystem_id(struct hda_codec *codec, | ||
1004 | unsigned int porta, unsigned int porte, | ||
1005 | unsigned int portd) | ||
1006 | { | 1040 | { |
1007 | unsigned int ass, tmp, i; | 1041 | unsigned int tmp; |
1008 | unsigned nid; | ||
1009 | struct alc_spec *spec = codec->spec; | ||
1010 | |||
1011 | ass = codec->subsystem_id & 0xffff; | ||
1012 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | ||
1013 | goto do_sku; | ||
1014 | |||
1015 | /* | ||
1016 | * 31~30 : port conetcivity | ||
1017 | * 29~21 : reserve | ||
1018 | * 20 : PCBEEP input | ||
1019 | * 19~16 : Check sum (15:1) | ||
1020 | * 15~1 : Custom | ||
1021 | * 0 : override | ||
1022 | */ | ||
1023 | nid = 0x1d; | ||
1024 | if (codec->vendor_id == 0x10ec0260) | ||
1025 | nid = 0x17; | ||
1026 | ass = snd_hda_codec_get_pincfg(codec, nid); | ||
1027 | if (!(ass & 1) && !(ass & 0x100000)) | ||
1028 | return; | ||
1029 | if ((ass >> 30) != 1) /* no physical connection */ | ||
1030 | return; | ||
1031 | 1042 | ||
1032 | /* check sum */ | 1043 | switch (type) { |
1033 | tmp = 0; | 1044 | case ALC_INIT_GPIO1: |
1034 | for (i = 1; i < 16; i++) { | ||
1035 | if ((ass >> i) & 1) | ||
1036 | tmp++; | ||
1037 | } | ||
1038 | if (((ass >> 16) & 0xf) != tmp) | ||
1039 | return; | ||
1040 | do_sku: | ||
1041 | /* | ||
1042 | * 0 : override | ||
1043 | * 1 : Swap Jack | ||
1044 | * 2 : 0 --> Desktop, 1 --> Laptop | ||
1045 | * 3~5 : External Amplifier control | ||
1046 | * 7~6 : Reserved | ||
1047 | */ | ||
1048 | tmp = (ass & 0x38) >> 3; /* external Amp control */ | ||
1049 | switch (tmp) { | ||
1050 | case 1: | ||
1051 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | 1045 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
1052 | break; | 1046 | break; |
1053 | case 3: | 1047 | case ALC_INIT_GPIO2: |
1054 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | 1048 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
1055 | break; | 1049 | break; |
1056 | case 7: | 1050 | case ALC_INIT_GPIO3: |
1057 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | 1051 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
1058 | break; | 1052 | break; |
1059 | case 5: /* set EAPD output high */ | 1053 | case ALC_INIT_DEFAULT: |
1060 | switch (codec->vendor_id) { | 1054 | switch (codec->vendor_id) { |
1061 | case 0x10ec0260: | 1055 | case 0x10ec0260: |
1062 | snd_hda_codec_write(codec, 0x0f, 0, | 1056 | snd_hda_codec_write(codec, 0x0f, 0, |
@@ -1110,7 +1104,7 @@ do_sku: | |||
1110 | tmp | 0x2010); | 1104 | tmp | 0x2010); |
1111 | break; | 1105 | break; |
1112 | case 0x10ec0888: | 1106 | case 0x10ec0888: |
1113 | /*alc888_coef_init(codec);*/ /* called in alc_init() */ | 1107 | alc888_coef_init(codec); |
1114 | break; | 1108 | break; |
1115 | case 0x10ec0267: | 1109 | case 0x10ec0267: |
1116 | case 0x10ec0268: | 1110 | case 0x10ec0268: |
@@ -1125,7 +1119,107 @@ do_sku: | |||
1125 | tmp | 0x3000); | 1119 | tmp | 0x3000); |
1126 | break; | 1120 | break; |
1127 | } | 1121 | } |
1128 | default: | 1122 | break; |
1123 | } | ||
1124 | } | ||
1125 | |||
1126 | static void alc_init_auto_hp(struct hda_codec *codec) | ||
1127 | { | ||
1128 | struct alc_spec *spec = codec->spec; | ||
1129 | |||
1130 | if (!spec->autocfg.hp_pins[0]) | ||
1131 | return; | ||
1132 | |||
1133 | if (!spec->autocfg.speaker_pins[0]) { | ||
1134 | if (spec->autocfg.line_out_pins[0] && | ||
1135 | spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
1136 | spec->autocfg.speaker_pins[0] = | ||
1137 | spec->autocfg.line_out_pins[0]; | ||
1138 | else | ||
1139 | return; | ||
1140 | } | ||
1141 | |||
1142 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", | ||
1143 | spec->autocfg.hp_pins[0]); | ||
1144 | snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0, | ||
1145 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
1146 | AC_USRSP_EN | ALC880_HP_EVENT); | ||
1147 | spec->unsol_event = alc_sku_unsol_event; | ||
1148 | } | ||
1149 | |||
1150 | /* check subsystem ID and set up device-specific initialization; | ||
1151 | * return 1 if initialized, 0 if invalid SSID | ||
1152 | */ | ||
1153 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. | ||
1154 | * 31 ~ 16 : Manufacture ID | ||
1155 | * 15 ~ 8 : SKU ID | ||
1156 | * 7 ~ 0 : Assembly ID | ||
1157 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | ||
1158 | */ | ||
1159 | static int alc_subsystem_id(struct hda_codec *codec, | ||
1160 | hda_nid_t porta, hda_nid_t porte, | ||
1161 | hda_nid_t portd) | ||
1162 | { | ||
1163 | unsigned int ass, tmp, i; | ||
1164 | unsigned nid; | ||
1165 | struct alc_spec *spec = codec->spec; | ||
1166 | |||
1167 | ass = codec->subsystem_id & 0xffff; | ||
1168 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | ||
1169 | goto do_sku; | ||
1170 | |||
1171 | /* invalid SSID, check the special NID pin defcfg instead */ | ||
1172 | /* | ||
1173 | * 31~30 : port conetcivity | ||
1174 | * 29~21 : reserve | ||
1175 | * 20 : PCBEEP input | ||
1176 | * 19~16 : Check sum (15:1) | ||
1177 | * 15~1 : Custom | ||
1178 | * 0 : override | ||
1179 | */ | ||
1180 | nid = 0x1d; | ||
1181 | if (codec->vendor_id == 0x10ec0260) | ||
1182 | nid = 0x17; | ||
1183 | ass = snd_hda_codec_get_pincfg(codec, nid); | ||
1184 | snd_printd("realtek: No valid SSID, " | ||
1185 | "checking pincfg 0x%08x for NID 0x%x\n", | ||
1186 | ass, nid); | ||
1187 | if (!(ass & 1) && !(ass & 0x100000)) | ||
1188 | return 0; | ||
1189 | if ((ass >> 30) != 1) /* no physical connection */ | ||
1190 | return 0; | ||
1191 | |||
1192 | /* check sum */ | ||
1193 | tmp = 0; | ||
1194 | for (i = 1; i < 16; i++) { | ||
1195 | if ((ass >> i) & 1) | ||
1196 | tmp++; | ||
1197 | } | ||
1198 | if (((ass >> 16) & 0xf) != tmp) | ||
1199 | return 0; | ||
1200 | do_sku: | ||
1201 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", | ||
1202 | ass & 0xffff, codec->vendor_id); | ||
1203 | /* | ||
1204 | * 0 : override | ||
1205 | * 1 : Swap Jack | ||
1206 | * 2 : 0 --> Desktop, 1 --> Laptop | ||
1207 | * 3~5 : External Amplifier control | ||
1208 | * 7~6 : Reserved | ||
1209 | */ | ||
1210 | tmp = (ass & 0x38) >> 3; /* external Amp control */ | ||
1211 | switch (tmp) { | ||
1212 | case 1: | ||
1213 | spec->init_amp = ALC_INIT_GPIO1; | ||
1214 | break; | ||
1215 | case 3: | ||
1216 | spec->init_amp = ALC_INIT_GPIO2; | ||
1217 | break; | ||
1218 | case 7: | ||
1219 | spec->init_amp = ALC_INIT_GPIO3; | ||
1220 | break; | ||
1221 | case 5: | ||
1222 | spec->init_amp = ALC_INIT_DEFAULT; | ||
1129 | break; | 1223 | break; |
1130 | } | 1224 | } |
1131 | 1225 | ||
@@ -1133,7 +1227,7 @@ do_sku: | |||
1133 | * when the external headphone out jack is plugged" | 1227 | * when the external headphone out jack is plugged" |
1134 | */ | 1228 | */ |
1135 | if (!(ass & 0x8000)) | 1229 | if (!(ass & 0x8000)) |
1136 | return; | 1230 | return 1; |
1137 | /* | 1231 | /* |
1138 | * 10~8 : Jack location | 1232 | * 10~8 : Jack location |
1139 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered | 1233 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
@@ -1141,14 +1235,6 @@ do_sku: | |||
1141 | * 15 : 1 --> enable the function "Mute internal speaker | 1235 | * 15 : 1 --> enable the function "Mute internal speaker |
1142 | * when the external headphone out jack is plugged" | 1236 | * when the external headphone out jack is plugged" |
1143 | */ | 1237 | */ |
1144 | if (!spec->autocfg.speaker_pins[0]) { | ||
1145 | if (spec->autocfg.line_out_pins[0]) | ||
1146 | spec->autocfg.speaker_pins[0] = | ||
1147 | spec->autocfg.line_out_pins[0]; | ||
1148 | else | ||
1149 | return; | ||
1150 | } | ||
1151 | |||
1152 | if (!spec->autocfg.hp_pins[0]) { | 1238 | if (!spec->autocfg.hp_pins[0]) { |
1153 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ | 1239 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
1154 | if (tmp == 0) | 1240 | if (tmp == 0) |
@@ -1158,23 +1244,23 @@ do_sku: | |||
1158 | else if (tmp == 2) | 1244 | else if (tmp == 2) |
1159 | spec->autocfg.hp_pins[0] = portd; | 1245 | spec->autocfg.hp_pins[0] = portd; |
1160 | else | 1246 | else |
1161 | return; | 1247 | return 1; |
1162 | } | 1248 | } |
1163 | if (spec->autocfg.hp_pins[0]) | ||
1164 | snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, | ||
1165 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
1166 | AC_USRSP_EN | ALC880_HP_EVENT); | ||
1167 | 1249 | ||
1168 | #if 0 /* it's broken in some acses -- temporarily disabled */ | 1250 | alc_init_auto_hp(codec); |
1169 | if (spec->autocfg.input_pins[AUTO_PIN_MIC] && | 1251 | return 1; |
1170 | spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]) | 1252 | } |
1171 | snd_hda_codec_write(codec, | ||
1172 | spec->autocfg.input_pins[AUTO_PIN_MIC], 0, | ||
1173 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
1174 | AC_USRSP_EN | ALC880_MIC_EVENT); | ||
1175 | #endif /* disabled */ | ||
1176 | 1253 | ||
1177 | spec->unsol_event = alc_sku_unsol_event; | 1254 | static void alc_ssid_check(struct hda_codec *codec, |
1255 | hda_nid_t porta, hda_nid_t porte, hda_nid_t portd) | ||
1256 | { | ||
1257 | if (!alc_subsystem_id(codec, porta, porte, portd)) { | ||
1258 | struct alc_spec *spec = codec->spec; | ||
1259 | snd_printd("realtek: " | ||
1260 | "Enable default setup for auto mode as fallback\n"); | ||
1261 | spec->init_amp = ALC_INIT_DEFAULT; | ||
1262 | alc_init_auto_hp(codec); | ||
1263 | } | ||
1178 | } | 1264 | } |
1179 | 1265 | ||
1180 | /* | 1266 | /* |
@@ -1309,32 +1395,58 @@ static struct hda_verb alc888_fujitsu_xa3530_verbs[] = { | |||
1309 | {} | 1395 | {} |
1310 | }; | 1396 | }; |
1311 | 1397 | ||
1312 | static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec) | 1398 | static void alc_automute_amp(struct hda_codec *codec) |
1313 | { | 1399 | { |
1314 | unsigned int present; | 1400 | struct alc_spec *spec = codec->spec; |
1315 | unsigned int bits; | 1401 | unsigned int val, mute; |
1316 | /* Line out presence */ | 1402 | hda_nid_t nid; |
1317 | present = snd_hda_codec_read(codec, 0x17, 0, | 1403 | int i; |
1318 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 1404 | |
1319 | /* HP out presence */ | 1405 | spec->jack_present = 0; |
1320 | present = present || snd_hda_codec_read(codec, 0x1b, 0, | 1406 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) { |
1321 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 1407 | nid = spec->autocfg.hp_pins[i]; |
1322 | bits = present ? HDA_AMP_MUTE : 0; | 1408 | if (!nid) |
1409 | break; | ||
1410 | val = snd_hda_codec_read(codec, nid, 0, | ||
1411 | AC_VERB_GET_PIN_SENSE, 0); | ||
1412 | if (val & AC_PINSENSE_PRESENCE) { | ||
1413 | spec->jack_present = 1; | ||
1414 | break; | ||
1415 | } | ||
1416 | } | ||
1417 | |||
1418 | mute = spec->jack_present ? HDA_AMP_MUTE : 0; | ||
1323 | /* Toggle internal speakers muting */ | 1419 | /* Toggle internal speakers muting */ |
1324 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 1420 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { |
1325 | HDA_AMP_MUTE, bits); | 1421 | nid = spec->autocfg.speaker_pins[i]; |
1326 | /* Toggle internal bass muting */ | 1422 | if (!nid) |
1327 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 1423 | break; |
1328 | HDA_AMP_MUTE, bits); | 1424 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
1425 | HDA_AMP_MUTE, mute); | ||
1426 | } | ||
1329 | } | 1427 | } |
1330 | 1428 | ||
1331 | static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec, | 1429 | static void alc_automute_amp_unsol_event(struct hda_codec *codec, |
1332 | unsigned int res) | 1430 | unsigned int res) |
1333 | { | 1431 | { |
1334 | if (res >> 26 == ALC880_HP_EVENT) | 1432 | if (codec->vendor_id == 0x10ec0880) |
1335 | alc888_fujitsu_xa3530_automute(codec); | 1433 | res >>= 28; |
1434 | else | ||
1435 | res >>= 26; | ||
1436 | if (res == ALC880_HP_EVENT) | ||
1437 | alc_automute_amp(codec); | ||
1336 | } | 1438 | } |
1337 | 1439 | ||
1440 | static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec) | ||
1441 | { | ||
1442 | struct alc_spec *spec = codec->spec; | ||
1443 | |||
1444 | spec->autocfg.hp_pins[0] = 0x17; /* line-out */ | ||
1445 | spec->autocfg.hp_pins[1] = 0x1b; /* hp */ | ||
1446 | spec->autocfg.speaker_pins[0] = 0x14; /* speaker */ | ||
1447 | spec->autocfg.speaker_pins[1] = 0x15; /* bass */ | ||
1448 | alc_automute_amp(codec); | ||
1449 | } | ||
1338 | 1450 | ||
1339 | /* | 1451 | /* |
1340 | * ALC888 Acer Aspire 4930G model | 1452 | * ALC888 Acer Aspire 4930G model |
@@ -1358,6 +1470,59 @@ static struct hda_verb alc888_acer_aspire_4930g_verbs[] = { | |||
1358 | { } | 1470 | { } |
1359 | }; | 1471 | }; |
1360 | 1472 | ||
1473 | /* | ||
1474 | * ALC889 Acer Aspire 8930G model | ||
1475 | */ | ||
1476 | |||
1477 | static struct hda_verb alc889_acer_aspire_8930g_verbs[] = { | ||
1478 | /* Front Mic: set to PIN_IN (empty by default) */ | ||
1479 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
1480 | /* Unselect Front Mic by default in input mixer 3 */ | ||
1481 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)}, | ||
1482 | /* Enable unsolicited event for HP jack */ | ||
1483 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | ||
1484 | /* Connect Internal Front to Front */ | ||
1485 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
1486 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1487 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
1488 | /* Connect Internal Rear to Rear */ | ||
1489 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
1490 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1491 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
1492 | /* Connect Internal CLFE to CLFE */ | ||
1493 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
1494 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1495 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
1496 | /* Connect HP out to Front */ | ||
1497 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP}, | ||
1498 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1499 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
1500 | /* Enable all DACs */ | ||
1501 | /* DAC DISABLE/MUTE 1? */ | ||
1502 | /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */ | ||
1503 | {0x20, AC_VERB_SET_COEF_INDEX, 0x03}, | ||
1504 | {0x20, AC_VERB_SET_PROC_COEF, 0x0000}, | ||
1505 | /* DAC DISABLE/MUTE 2? */ | ||
1506 | /* some bit here disables the other DACs. Init=0x4900 */ | ||
1507 | {0x20, AC_VERB_SET_COEF_INDEX, 0x08}, | ||
1508 | {0x20, AC_VERB_SET_PROC_COEF, 0x0000}, | ||
1509 | /* Enable amplifiers */ | ||
1510 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | ||
1511 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | ||
1512 | /* DMIC fix | ||
1513 | * This laptop has a stereo digital microphone. The mics are only 1cm apart | ||
1514 | * which makes the stereo useless. However, either the mic or the ALC889 | ||
1515 | * makes the signal become a difference/sum signal instead of standard | ||
1516 | * stereo, which is annoying. So instead we flip this bit which makes the | ||
1517 | * codec replicate the sum signal to both channels, turning it into a | ||
1518 | * normal mono mic. | ||
1519 | */ | ||
1520 | /* DMIC_CONTROL? Init value = 0x0001 */ | ||
1521 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0b}, | ||
1522 | {0x20, AC_VERB_SET_PROC_COEF, 0x0003}, | ||
1523 | { } | ||
1524 | }; | ||
1525 | |||
1361 | static struct hda_input_mux alc888_2_capture_sources[2] = { | 1526 | static struct hda_input_mux alc888_2_capture_sources[2] = { |
1362 | /* Front mic only available on one ADC */ | 1527 | /* Front mic only available on one ADC */ |
1363 | { | 1528 | { |
@@ -1379,6 +1544,38 @@ static struct hda_input_mux alc888_2_capture_sources[2] = { | |||
1379 | } | 1544 | } |
1380 | }; | 1545 | }; |
1381 | 1546 | ||
1547 | static struct hda_input_mux alc889_capture_sources[3] = { | ||
1548 | /* Digital mic only available on first "ADC" */ | ||
1549 | { | ||
1550 | .num_items = 5, | ||
1551 | .items = { | ||
1552 | { "Mic", 0x0 }, | ||
1553 | { "Line", 0x2 }, | ||
1554 | { "CD", 0x4 }, | ||
1555 | { "Front Mic", 0xb }, | ||
1556 | { "Input Mix", 0xa }, | ||
1557 | }, | ||
1558 | }, | ||
1559 | { | ||
1560 | .num_items = 4, | ||
1561 | .items = { | ||
1562 | { "Mic", 0x0 }, | ||
1563 | { "Line", 0x2 }, | ||
1564 | { "CD", 0x4 }, | ||
1565 | { "Input Mix", 0xa }, | ||
1566 | }, | ||
1567 | }, | ||
1568 | { | ||
1569 | .num_items = 4, | ||
1570 | .items = { | ||
1571 | { "Mic", 0x0 }, | ||
1572 | { "Line", 0x2 }, | ||
1573 | { "CD", 0x4 }, | ||
1574 | { "Input Mix", 0xa }, | ||
1575 | }, | ||
1576 | } | ||
1577 | }; | ||
1578 | |||
1382 | static struct snd_kcontrol_new alc888_base_mixer[] = { | 1579 | static struct snd_kcontrol_new alc888_base_mixer[] = { |
1383 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 1580 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1384 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | 1581 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
@@ -1401,22 +1598,24 @@ static struct snd_kcontrol_new alc888_base_mixer[] = { | |||
1401 | { } /* end */ | 1598 | { } /* end */ |
1402 | }; | 1599 | }; |
1403 | 1600 | ||
1404 | static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec) | 1601 | static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec) |
1405 | { | 1602 | { |
1406 | unsigned int present; | 1603 | struct alc_spec *spec = codec->spec; |
1407 | unsigned int bits; | 1604 | |
1408 | present = snd_hda_codec_read(codec, 0x15, 0, | 1605 | spec->autocfg.hp_pins[0] = 0x15; |
1409 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 1606 | spec->autocfg.speaker_pins[0] = 0x14; |
1410 | bits = present ? HDA_AMP_MUTE : 0; | 1607 | alc_automute_amp(codec); |
1411 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
1412 | HDA_AMP_MUTE, bits); | ||
1413 | } | 1608 | } |
1414 | 1609 | ||
1415 | static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec, | 1610 | static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec) |
1416 | unsigned int res) | ||
1417 | { | 1611 | { |
1418 | if (res >> 26 == ALC880_HP_EVENT) | 1612 | struct alc_spec *spec = codec->spec; |
1419 | alc888_acer_aspire_4930g_automute(codec); | 1613 | |
1614 | spec->autocfg.hp_pins[0] = 0x15; | ||
1615 | spec->autocfg.speaker_pins[0] = 0x14; | ||
1616 | spec->autocfg.speaker_pins[1] = 0x16; | ||
1617 | spec->autocfg.speaker_pins[2] = 0x1b; | ||
1618 | alc_automute_amp(codec); | ||
1420 | } | 1619 | } |
1421 | 1620 | ||
1422 | /* | 1621 | /* |
@@ -2384,21 +2583,6 @@ static struct hda_verb alc880_beep_init_verbs[] = { | |||
2384 | { } | 2583 | { } |
2385 | }; | 2584 | }; |
2386 | 2585 | ||
2387 | /* toggle speaker-output according to the hp-jack state */ | ||
2388 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) | ||
2389 | { | ||
2390 | unsigned int present; | ||
2391 | unsigned char bits; | ||
2392 | |||
2393 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
2394 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2395 | bits = present ? HDA_AMP_MUTE : 0; | ||
2396 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
2397 | HDA_AMP_MUTE, bits); | ||
2398 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
2399 | HDA_AMP_MUTE, bits); | ||
2400 | } | ||
2401 | |||
2402 | /* auto-toggle front mic */ | 2586 | /* auto-toggle front mic */ |
2403 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | 2587 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) |
2404 | { | 2588 | { |
@@ -2411,9 +2595,14 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |||
2411 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | 2595 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); |
2412 | } | 2596 | } |
2413 | 2597 | ||
2414 | static void alc880_uniwill_automute(struct hda_codec *codec) | 2598 | static void alc880_uniwill_init_hook(struct hda_codec *codec) |
2415 | { | 2599 | { |
2416 | alc880_uniwill_hp_automute(codec); | 2600 | struct alc_spec *spec = codec->spec; |
2601 | |||
2602 | spec->autocfg.hp_pins[0] = 0x14; | ||
2603 | spec->autocfg.speaker_pins[0] = 0x15; | ||
2604 | spec->autocfg.speaker_pins[0] = 0x16; | ||
2605 | alc_automute_amp(codec); | ||
2417 | alc880_uniwill_mic_automute(codec); | 2606 | alc880_uniwill_mic_automute(codec); |
2418 | } | 2607 | } |
2419 | 2608 | ||
@@ -2424,24 +2613,22 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |||
2424 | * definition. 4bit tag is placed at 28 bit! | 2613 | * definition. 4bit tag is placed at 28 bit! |
2425 | */ | 2614 | */ |
2426 | switch (res >> 28) { | 2615 | switch (res >> 28) { |
2427 | case ALC880_HP_EVENT: | ||
2428 | alc880_uniwill_hp_automute(codec); | ||
2429 | break; | ||
2430 | case ALC880_MIC_EVENT: | 2616 | case ALC880_MIC_EVENT: |
2431 | alc880_uniwill_mic_automute(codec); | 2617 | alc880_uniwill_mic_automute(codec); |
2432 | break; | 2618 | break; |
2619 | default: | ||
2620 | alc_automute_amp_unsol_event(codec, res); | ||
2621 | break; | ||
2433 | } | 2622 | } |
2434 | } | 2623 | } |
2435 | 2624 | ||
2436 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | 2625 | static void alc880_uniwill_p53_init_hook(struct hda_codec *codec) |
2437 | { | 2626 | { |
2438 | unsigned int present; | 2627 | struct alc_spec *spec = codec->spec; |
2439 | unsigned char bits; | ||
2440 | 2628 | ||
2441 | present = snd_hda_codec_read(codec, 0x14, 0, | 2629 | spec->autocfg.hp_pins[0] = 0x14; |
2442 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 2630 | spec->autocfg.speaker_pins[0] = 0x15; |
2443 | bits = present ? HDA_AMP_MUTE : 0; | 2631 | alc_automute_amp(codec); |
2444 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits); | ||
2445 | } | 2632 | } |
2446 | 2633 | ||
2447 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | 2634 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) |
@@ -2463,10 +2650,10 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, | |||
2463 | /* Looks like the unsol event is incompatible with the standard | 2650 | /* Looks like the unsol event is incompatible with the standard |
2464 | * definition. 4bit tag is placed at 28 bit! | 2651 | * definition. 4bit tag is placed at 28 bit! |
2465 | */ | 2652 | */ |
2466 | if ((res >> 28) == ALC880_HP_EVENT) | ||
2467 | alc880_uniwill_p53_hp_automute(codec); | ||
2468 | if ((res >> 28) == ALC880_DCVOL_EVENT) | 2653 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
2469 | alc880_uniwill_p53_dcvol_automute(codec); | 2654 | alc880_uniwill_p53_dcvol_automute(codec); |
2655 | else | ||
2656 | alc_automute_amp_unsol_event(codec, res); | ||
2470 | } | 2657 | } |
2471 | 2658 | ||
2472 | /* | 2659 | /* |
@@ -2536,6 +2723,7 @@ static struct hda_verb alc880_pin_asus_init_verbs[] = { | |||
2536 | /* Enable GPIO mask and set output */ | 2723 | /* Enable GPIO mask and set output */ |
2537 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs | 2724 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
2538 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | 2725 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs |
2726 | #define alc880_gpio3_init_verbs alc_gpio3_init_verbs | ||
2539 | 2727 | ||
2540 | /* Clevo m520g init */ | 2728 | /* Clevo m520g init */ |
2541 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | 2729 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { |
@@ -2698,30 +2886,18 @@ static struct hda_verb alc880_lg_init_verbs[] = { | |||
2698 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | 2886 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
2699 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 2887 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2700 | /* jack sense */ | 2888 | /* jack sense */ |
2701 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | 2889 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
2702 | { } | 2890 | { } |
2703 | }; | 2891 | }; |
2704 | 2892 | ||
2705 | /* toggle speaker-output according to the hp-jack state */ | 2893 | /* toggle speaker-output according to the hp-jack state */ |
2706 | static void alc880_lg_automute(struct hda_codec *codec) | 2894 | static void alc880_lg_init_hook(struct hda_codec *codec) |
2707 | { | 2895 | { |
2708 | unsigned int present; | 2896 | struct alc_spec *spec = codec->spec; |
2709 | unsigned char bits; | ||
2710 | |||
2711 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
2712 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2713 | bits = present ? HDA_AMP_MUTE : 0; | ||
2714 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | ||
2715 | HDA_AMP_MUTE, bits); | ||
2716 | } | ||
2717 | 2897 | ||
2718 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | 2898 | spec->autocfg.hp_pins[0] = 0x1b; |
2719 | { | 2899 | spec->autocfg.speaker_pins[0] = 0x17; |
2720 | /* Looks like the unsol event is incompatible with the standard | 2900 | alc_automute_amp(codec); |
2721 | * definition. 4bit tag is placed at 28 bit! | ||
2722 | */ | ||
2723 | if ((res >> 28) == 0x01) | ||
2724 | alc880_lg_automute(codec); | ||
2725 | } | 2901 | } |
2726 | 2902 | ||
2727 | /* | 2903 | /* |
@@ -2795,30 +2971,18 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = { | |||
2795 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 2971 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2796 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 2972 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2797 | /* jack sense */ | 2973 | /* jack sense */ |
2798 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | 2974 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
2799 | { } | 2975 | { } |
2800 | }; | 2976 | }; |
2801 | 2977 | ||
2802 | /* toggle speaker-output according to the hp-jack state */ | 2978 | /* toggle speaker-output according to the hp-jack state */ |
2803 | static void alc880_lg_lw_automute(struct hda_codec *codec) | 2979 | static void alc880_lg_lw_init_hook(struct hda_codec *codec) |
2804 | { | 2980 | { |
2805 | unsigned int present; | 2981 | struct alc_spec *spec = codec->spec; |
2806 | unsigned char bits; | ||
2807 | 2982 | ||
2808 | present = snd_hda_codec_read(codec, 0x1b, 0, | 2983 | spec->autocfg.hp_pins[0] = 0x1b; |
2809 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 2984 | spec->autocfg.speaker_pins[0] = 0x14; |
2810 | bits = present ? HDA_AMP_MUTE : 0; | 2985 | alc_automute_amp(codec); |
2811 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
2812 | HDA_AMP_MUTE, bits); | ||
2813 | } | ||
2814 | |||
2815 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | ||
2816 | { | ||
2817 | /* Looks like the unsol event is incompatible with the standard | ||
2818 | * definition. 4bit tag is placed at 28 bit! | ||
2819 | */ | ||
2820 | if ((res >> 28) == 0x01) | ||
2821 | alc880_lg_lw_automute(codec); | ||
2822 | } | 2986 | } |
2823 | 2987 | ||
2824 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { | 2988 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { |
@@ -2865,16 +3029,10 @@ static struct hda_verb alc880_medion_rim_init_verbs[] = { | |||
2865 | /* toggle speaker-output according to the hp-jack state */ | 3029 | /* toggle speaker-output according to the hp-jack state */ |
2866 | static void alc880_medion_rim_automute(struct hda_codec *codec) | 3030 | static void alc880_medion_rim_automute(struct hda_codec *codec) |
2867 | { | 3031 | { |
2868 | unsigned int present; | 3032 | struct alc_spec *spec = codec->spec; |
2869 | unsigned char bits; | 3033 | alc_automute_amp(codec); |
2870 | 3034 | /* toggle EAPD */ | |
2871 | present = snd_hda_codec_read(codec, 0x14, 0, | 3035 | if (spec->jack_present) |
2872 | AC_VERB_GET_PIN_SENSE, 0) | ||
2873 | & AC_PINSENSE_PRESENCE; | ||
2874 | bits = present ? HDA_AMP_MUTE : 0; | ||
2875 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | ||
2876 | HDA_AMP_MUTE, bits); | ||
2877 | if (present) | ||
2878 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); | 3036 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); |
2879 | else | 3037 | else |
2880 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); | 3038 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); |
@@ -2890,6 +3048,15 @@ static void alc880_medion_rim_unsol_event(struct hda_codec *codec, | |||
2890 | alc880_medion_rim_automute(codec); | 3048 | alc880_medion_rim_automute(codec); |
2891 | } | 3049 | } |
2892 | 3050 | ||
3051 | static void alc880_medion_rim_init_hook(struct hda_codec *codec) | ||
3052 | { | ||
3053 | struct alc_spec *spec = codec->spec; | ||
3054 | |||
3055 | spec->autocfg.hp_pins[0] = 0x14; | ||
3056 | spec->autocfg.speaker_pins[0] = 0x1b; | ||
3057 | alc880_medion_rim_automute(codec); | ||
3058 | } | ||
3059 | |||
2893 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 3060 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2894 | static struct hda_amp_list alc880_loopbacks[] = { | 3061 | static struct hda_amp_list alc880_loopbacks[] = { |
2895 | { 0x0b, HDA_INPUT, 0 }, | 3062 | { 0x0b, HDA_INPUT, 0 }, |
@@ -2918,8 +3085,7 @@ static int alc_init(struct hda_codec *codec) | |||
2918 | unsigned int i; | 3085 | unsigned int i; |
2919 | 3086 | ||
2920 | alc_fix_pll(codec); | 3087 | alc_fix_pll(codec); |
2921 | if (codec->vendor_id == 0x10ec0888) | 3088 | alc_auto_init_amp(codec, spec->init_amp); |
2922 | alc888_coef_init(codec); | ||
2923 | 3089 | ||
2924 | for (i = 0; i < spec->num_init_verbs; i++) | 3090 | for (i = 0; i < spec->num_init_verbs; i++) |
2925 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | 3091 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
@@ -3121,7 +3287,10 @@ static int alc_build_pcms(struct hda_codec *codec) | |||
3121 | if (spec->no_analog) | 3287 | if (spec->no_analog) |
3122 | goto skip_analog; | 3288 | goto skip_analog; |
3123 | 3289 | ||
3290 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), | ||
3291 | "%s Analog", codec->chip_name); | ||
3124 | info->name = spec->stream_name_analog; | 3292 | info->name = spec->stream_name_analog; |
3293 | |||
3125 | if (spec->stream_analog_playback) { | 3294 | if (spec->stream_analog_playback) { |
3126 | if (snd_BUG_ON(!spec->multiout.dac_nids)) | 3295 | if (snd_BUG_ON(!spec->multiout.dac_nids)) |
3127 | return -EINVAL; | 3296 | return -EINVAL; |
@@ -3147,6 +3316,9 @@ static int alc_build_pcms(struct hda_codec *codec) | |||
3147 | skip_analog: | 3316 | skip_analog: |
3148 | /* SPDIF for stream index #1 */ | 3317 | /* SPDIF for stream index #1 */ |
3149 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { | 3318 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
3319 | snprintf(spec->stream_name_digital, | ||
3320 | sizeof(spec->stream_name_digital), | ||
3321 | "%s Digital", codec->chip_name); | ||
3150 | codec->num_pcms = 2; | 3322 | codec->num_pcms = 2; |
3151 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; | 3323 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
3152 | info = spec->pcm_rec + 1; | 3324 | info = spec->pcm_rec + 1; |
@@ -3749,7 +3921,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
3749 | .channel_mode = alc880_2_jack_modes, | 3921 | .channel_mode = alc880_2_jack_modes, |
3750 | .input_mux = &alc880_f1734_capture_source, | 3922 | .input_mux = &alc880_f1734_capture_source, |
3751 | .unsol_event = alc880_uniwill_p53_unsol_event, | 3923 | .unsol_event = alc880_uniwill_p53_unsol_event, |
3752 | .init_hook = alc880_uniwill_p53_hp_automute, | 3924 | .init_hook = alc880_uniwill_p53_init_hook, |
3753 | }, | 3925 | }, |
3754 | [ALC880_ASUS] = { | 3926 | [ALC880_ASUS] = { |
3755 | .mixers = { alc880_asus_mixer }, | 3927 | .mixers = { alc880_asus_mixer }, |
@@ -3826,7 +3998,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
3826 | .need_dac_fix = 1, | 3998 | .need_dac_fix = 1, |
3827 | .input_mux = &alc880_capture_source, | 3999 | .input_mux = &alc880_capture_source, |
3828 | .unsol_event = alc880_uniwill_unsol_event, | 4000 | .unsol_event = alc880_uniwill_unsol_event, |
3829 | .init_hook = alc880_uniwill_automute, | 4001 | .init_hook = alc880_uniwill_init_hook, |
3830 | }, | 4002 | }, |
3831 | [ALC880_UNIWILL_P53] = { | 4003 | [ALC880_UNIWILL_P53] = { |
3832 | .mixers = { alc880_uniwill_p53_mixer }, | 4004 | .mixers = { alc880_uniwill_p53_mixer }, |
@@ -3838,7 +4010,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
3838 | .channel_mode = alc880_threestack_modes, | 4010 | .channel_mode = alc880_threestack_modes, |
3839 | .input_mux = &alc880_capture_source, | 4011 | .input_mux = &alc880_capture_source, |
3840 | .unsol_event = alc880_uniwill_p53_unsol_event, | 4012 | .unsol_event = alc880_uniwill_p53_unsol_event, |
3841 | .init_hook = alc880_uniwill_p53_hp_automute, | 4013 | .init_hook = alc880_uniwill_p53_init_hook, |
3842 | }, | 4014 | }, |
3843 | [ALC880_FUJITSU] = { | 4015 | [ALC880_FUJITSU] = { |
3844 | .mixers = { alc880_fujitsu_mixer }, | 4016 | .mixers = { alc880_fujitsu_mixer }, |
@@ -3852,7 +4024,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
3852 | .channel_mode = alc880_2_jack_modes, | 4024 | .channel_mode = alc880_2_jack_modes, |
3853 | .input_mux = &alc880_capture_source, | 4025 | .input_mux = &alc880_capture_source, |
3854 | .unsol_event = alc880_uniwill_p53_unsol_event, | 4026 | .unsol_event = alc880_uniwill_p53_unsol_event, |
3855 | .init_hook = alc880_uniwill_p53_hp_automute, | 4027 | .init_hook = alc880_uniwill_p53_init_hook, |
3856 | }, | 4028 | }, |
3857 | [ALC880_CLEVO] = { | 4029 | [ALC880_CLEVO] = { |
3858 | .mixers = { alc880_three_stack_mixer }, | 4030 | .mixers = { alc880_three_stack_mixer }, |
@@ -3877,8 +4049,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
3877 | .channel_mode = alc880_lg_ch_modes, | 4049 | .channel_mode = alc880_lg_ch_modes, |
3878 | .need_dac_fix = 1, | 4050 | .need_dac_fix = 1, |
3879 | .input_mux = &alc880_lg_capture_source, | 4051 | .input_mux = &alc880_lg_capture_source, |
3880 | .unsol_event = alc880_lg_unsol_event, | 4052 | .unsol_event = alc_automute_amp_unsol_event, |
3881 | .init_hook = alc880_lg_automute, | 4053 | .init_hook = alc880_lg_init_hook, |
3882 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 4054 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3883 | .loopbacks = alc880_lg_loopbacks, | 4055 | .loopbacks = alc880_lg_loopbacks, |
3884 | #endif | 4056 | #endif |
@@ -3893,8 +4065,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
3893 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), | 4065 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
3894 | .channel_mode = alc880_lg_lw_modes, | 4066 | .channel_mode = alc880_lg_lw_modes, |
3895 | .input_mux = &alc880_lg_lw_capture_source, | 4067 | .input_mux = &alc880_lg_lw_capture_source, |
3896 | .unsol_event = alc880_lg_lw_unsol_event, | 4068 | .unsol_event = alc_automute_amp_unsol_event, |
3897 | .init_hook = alc880_lg_lw_automute, | 4069 | .init_hook = alc880_lg_lw_init_hook, |
3898 | }, | 4070 | }, |
3899 | [ALC880_MEDION_RIM] = { | 4071 | [ALC880_MEDION_RIM] = { |
3900 | .mixers = { alc880_medion_rim_mixer }, | 4072 | .mixers = { alc880_medion_rim_mixer }, |
@@ -3908,7 +4080,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
3908 | .channel_mode = alc880_2_jack_modes, | 4080 | .channel_mode = alc880_2_jack_modes, |
3909 | .input_mux = &alc880_medion_rim_capture_source, | 4081 | .input_mux = &alc880_medion_rim_capture_source, |
3910 | .unsol_event = alc880_medion_rim_unsol_event, | 4082 | .unsol_event = alc880_medion_rim_unsol_event, |
3911 | .init_hook = alc880_medion_rim_automute, | 4083 | .init_hook = alc880_medion_rim_init_hook, |
3912 | }, | 4084 | }, |
3913 | #ifdef CONFIG_SND_DEBUG | 4085 | #ifdef CONFIG_SND_DEBUG |
3914 | [ALC880_TEST] = { | 4086 | [ALC880_TEST] = { |
@@ -4193,7 +4365,6 @@ static void alc880_auto_init_multi_out(struct hda_codec *codec) | |||
4193 | struct alc_spec *spec = codec->spec; | 4365 | struct alc_spec *spec = codec->spec; |
4194 | int i; | 4366 | int i; |
4195 | 4367 | ||
4196 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | ||
4197 | for (i = 0; i < spec->autocfg.line_outs; i++) { | 4368 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
4198 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | 4369 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
4199 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | 4370 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
@@ -4298,6 +4469,8 @@ static int alc880_parse_auto_config(struct hda_codec *codec) | |||
4298 | spec->num_mux_defs = 1; | 4469 | spec->num_mux_defs = 1; |
4299 | spec->input_mux = &spec->private_imux[0]; | 4470 | spec->input_mux = &spec->private_imux[0]; |
4300 | 4471 | ||
4472 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | ||
4473 | |||
4301 | return 1; | 4474 | return 1; |
4302 | } | 4475 | } |
4303 | 4476 | ||
@@ -4355,8 +4528,8 @@ static int patch_alc880(struct hda_codec *codec) | |||
4355 | alc880_models, | 4528 | alc880_models, |
4356 | alc880_cfg_tbl); | 4529 | alc880_cfg_tbl); |
4357 | if (board_config < 0) { | 4530 | if (board_config < 0) { |
4358 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " | 4531 | printk(KERN_INFO "hda_codec: Unknown model for %s, " |
4359 | "trying auto-probe from BIOS...\n"); | 4532 | "trying auto-probe from BIOS...\n", codec->chip_name); |
4360 | board_config = ALC880_AUTO; | 4533 | board_config = ALC880_AUTO; |
4361 | } | 4534 | } |
4362 | 4535 | ||
@@ -4383,12 +4556,10 @@ static int patch_alc880(struct hda_codec *codec) | |||
4383 | if (board_config != ALC880_AUTO) | 4556 | if (board_config != ALC880_AUTO) |
4384 | setup_preset(spec, &alc880_presets[board_config]); | 4557 | setup_preset(spec, &alc880_presets[board_config]); |
4385 | 4558 | ||
4386 | spec->stream_name_analog = "ALC880 Analog"; | ||
4387 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | 4559 | spec->stream_analog_playback = &alc880_pcm_analog_playback; |
4388 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | 4560 | spec->stream_analog_capture = &alc880_pcm_analog_capture; |
4389 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; | 4561 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; |
4390 | 4562 | ||
4391 | spec->stream_name_digital = "ALC880 Digital"; | ||
4392 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | 4563 | spec->stream_digital_playback = &alc880_pcm_digital_playback; |
4393 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | 4564 | spec->stream_digital_capture = &alc880_pcm_digital_capture; |
4394 | 4565 | ||
@@ -5673,7 +5844,6 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec) | |||
5673 | struct alc_spec *spec = codec->spec; | 5844 | struct alc_spec *spec = codec->spec; |
5674 | hda_nid_t nid; | 5845 | hda_nid_t nid; |
5675 | 5846 | ||
5676 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); | ||
5677 | nid = spec->autocfg.line_out_pins[0]; | 5847 | nid = spec->autocfg.line_out_pins[0]; |
5678 | if (nid) { | 5848 | if (nid) { |
5679 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | 5849 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
@@ -5783,6 +5953,8 @@ static int alc260_parse_auto_config(struct hda_codec *codec) | |||
5783 | spec->num_mux_defs = 1; | 5953 | spec->num_mux_defs = 1; |
5784 | spec->input_mux = &spec->private_imux[0]; | 5954 | spec->input_mux = &spec->private_imux[0]; |
5785 | 5955 | ||
5956 | alc_ssid_check(codec, 0x10, 0x15, 0x0f); | ||
5957 | |||
5786 | return 1; | 5958 | return 1; |
5787 | } | 5959 | } |
5788 | 5960 | ||
@@ -6000,8 +6172,9 @@ static int patch_alc260(struct hda_codec *codec) | |||
6000 | alc260_models, | 6172 | alc260_models, |
6001 | alc260_cfg_tbl); | 6173 | alc260_cfg_tbl); |
6002 | if (board_config < 0) { | 6174 | if (board_config < 0) { |
6003 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " | 6175 | snd_printd(KERN_INFO "hda_codec: Unknown model for %s, " |
6004 | "trying auto-probe from BIOS...\n"); | 6176 | "trying auto-probe from BIOS...\n", |
6177 | codec->chip_name); | ||
6005 | board_config = ALC260_AUTO; | 6178 | board_config = ALC260_AUTO; |
6006 | } | 6179 | } |
6007 | 6180 | ||
@@ -6028,11 +6201,9 @@ static int patch_alc260(struct hda_codec *codec) | |||
6028 | if (board_config != ALC260_AUTO) | 6201 | if (board_config != ALC260_AUTO) |
6029 | setup_preset(spec, &alc260_presets[board_config]); | 6202 | setup_preset(spec, &alc260_presets[board_config]); |
6030 | 6203 | ||
6031 | spec->stream_name_analog = "ALC260 Analog"; | ||
6032 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | 6204 | spec->stream_analog_playback = &alc260_pcm_analog_playback; |
6033 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | 6205 | spec->stream_analog_capture = &alc260_pcm_analog_capture; |
6034 | 6206 | ||
6035 | spec->stream_name_digital = "ALC260 Digital"; | ||
6036 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | 6207 | spec->stream_digital_playback = &alc260_pcm_digital_playback; |
6037 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | 6208 | spec->stream_digital_capture = &alc260_pcm_digital_capture; |
6038 | 6209 | ||
@@ -6109,6 +6280,16 @@ static struct hda_input_mux alc882_capture_source = { | |||
6109 | { "CD", 0x4 }, | 6280 | { "CD", 0x4 }, |
6110 | }, | 6281 | }, |
6111 | }; | 6282 | }; |
6283 | |||
6284 | static struct hda_input_mux mb5_capture_source = { | ||
6285 | .num_items = 3, | ||
6286 | .items = { | ||
6287 | { "Mic", 0x1 }, | ||
6288 | { "Line", 0x2 }, | ||
6289 | { "CD", 0x4 }, | ||
6290 | }, | ||
6291 | }; | ||
6292 | |||
6112 | /* | 6293 | /* |
6113 | * 2ch mode | 6294 | * 2ch mode |
6114 | */ | 6295 | */ |
@@ -6196,6 +6377,34 @@ static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | |||
6196 | { 6, alc885_mbp_ch6_init }, | 6377 | { 6, alc885_mbp_ch6_init }, |
6197 | }; | 6378 | }; |
6198 | 6379 | ||
6380 | /* | ||
6381 | * 2ch | ||
6382 | * Speakers/Woofer/HP = Front | ||
6383 | * LineIn = Input | ||
6384 | */ | ||
6385 | static struct hda_verb alc885_mb5_ch2_init[] = { | ||
6386 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
6387 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
6388 | { } /* end */ | ||
6389 | }; | ||
6390 | |||
6391 | /* | ||
6392 | * 6ch mode | ||
6393 | * Speakers/HP = Front | ||
6394 | * Woofer = LFE | ||
6395 | * LineIn = Surround | ||
6396 | */ | ||
6397 | static struct hda_verb alc885_mb5_ch6_init[] = { | ||
6398 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
6399 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
6400 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
6401 | { } /* end */ | ||
6402 | }; | ||
6403 | |||
6404 | static struct hda_channel_mode alc885_mb5_6ch_modes[2] = { | ||
6405 | { 2, alc885_mb5_ch2_init }, | ||
6406 | { 6, alc885_mb5_ch6_init }, | ||
6407 | }; | ||
6199 | 6408 | ||
6200 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | 6409 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6201 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | 6410 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b |
@@ -6238,6 +6447,25 @@ static struct snd_kcontrol_new alc885_mbp3_mixer[] = { | |||
6238 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), | 6447 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), |
6239 | { } /* end */ | 6448 | { } /* end */ |
6240 | }; | 6449 | }; |
6450 | |||
6451 | static struct snd_kcontrol_new alc885_mb5_mixer[] = { | ||
6452 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | ||
6453 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | ||
6454 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | ||
6455 | HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT), | ||
6456 | HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT), | ||
6457 | HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT), | ||
6458 | HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT), | ||
6459 | HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT), | ||
6460 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
6461 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
6462 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | ||
6463 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | ||
6464 | HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT), | ||
6465 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT), | ||
6466 | { } /* end */ | ||
6467 | }; | ||
6468 | |||
6241 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { | 6469 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
6242 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 6470 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
6243 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | 6471 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
@@ -6465,6 +6693,55 @@ static struct hda_verb alc882_macpro_init_verbs[] = { | |||
6465 | { } | 6693 | { } |
6466 | }; | 6694 | }; |
6467 | 6695 | ||
6696 | /* Macbook 5,1 */ | ||
6697 | static struct hda_verb alc885_mb5_init_verbs[] = { | ||
6698 | /* DACs */ | ||
6699 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
6700 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
6701 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
6702 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
6703 | /* Front mixer */ | ||
6704 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
6705 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
6706 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
6707 | /* Surround mixer */ | ||
6708 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
6709 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
6710 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
6711 | /* LFE mixer */ | ||
6712 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
6713 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
6714 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
6715 | /* HP mixer */ | ||
6716 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
6717 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
6718 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
6719 | /* Front Pin (0x0c) */ | ||
6720 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01}, | ||
6721 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
6722 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
6723 | /* LFE Pin (0x0e) */ | ||
6724 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01}, | ||
6725 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
6726 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
6727 | /* HP Pin (0x0f) */ | ||
6728 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
6729 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
6730 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
6731 | /* Front Mic pin: input vref at 80% */ | ||
6732 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
6733 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
6734 | /* Line In pin */ | ||
6735 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
6736 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
6737 | |||
6738 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
6739 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
6740 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
6741 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
6742 | { } | ||
6743 | }; | ||
6744 | |||
6468 | /* Macbook Pro rev3 */ | 6745 | /* Macbook Pro rev3 */ |
6469 | static struct hda_verb alc885_mbp3_init_verbs[] = { | 6746 | static struct hda_verb alc885_mbp3_init_verbs[] = { |
6470 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | 6747 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
@@ -6554,45 +6831,23 @@ static struct hda_verb alc885_imac24_init_verbs[] = { | |||
6554 | }; | 6831 | }; |
6555 | 6832 | ||
6556 | /* Toggle speaker-output according to the hp-jack state */ | 6833 | /* Toggle speaker-output according to the hp-jack state */ |
6557 | static void alc885_imac24_automute(struct hda_codec *codec) | 6834 | static void alc885_imac24_automute_init_hook(struct hda_codec *codec) |
6558 | { | 6835 | { |
6559 | unsigned int present; | 6836 | struct alc_spec *spec = codec->spec; |
6560 | |||
6561 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
6562 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
6563 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, | ||
6564 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
6565 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | ||
6566 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
6567 | } | ||
6568 | 6837 | ||
6569 | /* Processes unsolicited events. */ | 6838 | spec->autocfg.hp_pins[0] = 0x14; |
6570 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | 6839 | spec->autocfg.speaker_pins[0] = 0x18; |
6571 | unsigned int res) | 6840 | spec->autocfg.speaker_pins[1] = 0x1a; |
6572 | { | 6841 | alc_automute_amp(codec); |
6573 | /* Headphone insertion or removal. */ | ||
6574 | if ((res >> 26) == ALC880_HP_EVENT) | ||
6575 | alc885_imac24_automute(codec); | ||
6576 | } | 6842 | } |
6577 | 6843 | ||
6578 | static void alc885_mbp3_automute(struct hda_codec *codec) | 6844 | static void alc885_mbp3_init_hook(struct hda_codec *codec) |
6579 | { | 6845 | { |
6580 | unsigned int present; | 6846 | struct alc_spec *spec = codec->spec; |
6581 | |||
6582 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
6583 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
6584 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
6585 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
6586 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
6587 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | ||
6588 | 6847 | ||
6589 | } | 6848 | spec->autocfg.hp_pins[0] = 0x15; |
6590 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | 6849 | spec->autocfg.speaker_pins[0] = 0x14; |
6591 | unsigned int res) | 6850 | alc_automute_amp(codec); |
6592 | { | ||
6593 | /* Headphone insertion or removal. */ | ||
6594 | if ((res >> 26) == ALC880_HP_EVENT) | ||
6595 | alc885_mbp3_automute(codec); | ||
6596 | } | 6851 | } |
6597 | 6852 | ||
6598 | 6853 | ||
@@ -6617,24 +6872,25 @@ static struct hda_verb alc882_targa_verbs[] = { | |||
6617 | /* toggle speaker-output according to the hp-jack state */ | 6872 | /* toggle speaker-output according to the hp-jack state */ |
6618 | static void alc882_targa_automute(struct hda_codec *codec) | 6873 | static void alc882_targa_automute(struct hda_codec *codec) |
6619 | { | 6874 | { |
6620 | unsigned int present; | 6875 | struct alc_spec *spec = codec->spec; |
6621 | 6876 | alc_automute_amp(codec); | |
6622 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
6623 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
6624 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | ||
6625 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
6626 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, | 6877 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
6627 | present ? 1 : 3); | 6878 | spec->jack_present ? 1 : 3); |
6879 | } | ||
6880 | |||
6881 | static void alc882_targa_init_hook(struct hda_codec *codec) | ||
6882 | { | ||
6883 | struct alc_spec *spec = codec->spec; | ||
6884 | |||
6885 | spec->autocfg.hp_pins[0] = 0x14; | ||
6886 | spec->autocfg.speaker_pins[0] = 0x1b; | ||
6887 | alc882_targa_automute(codec); | ||
6628 | } | 6888 | } |
6629 | 6889 | ||
6630 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | 6890 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) |
6631 | { | 6891 | { |
6632 | /* Looks like the unsol event is incompatible with the standard | 6892 | if ((res >> 26) == ALC880_HP_EVENT) |
6633 | * definition. 4bit tag is placed at 26 bit! | ||
6634 | */ | ||
6635 | if (((res >> 26) == ALC880_HP_EVENT)) { | ||
6636 | alc882_targa_automute(codec); | 6893 | alc882_targa_automute(codec); |
6637 | } | ||
6638 | } | 6894 | } |
6639 | 6895 | ||
6640 | static struct hda_verb alc882_asus_a7j_verbs[] = { | 6896 | static struct hda_verb alc882_asus_a7j_verbs[] = { |
@@ -6716,7 +6972,7 @@ static void alc885_macpro_init_hook(struct hda_codec *codec) | |||
6716 | static void alc885_imac24_init_hook(struct hda_codec *codec) | 6972 | static void alc885_imac24_init_hook(struct hda_codec *codec) |
6717 | { | 6973 | { |
6718 | alc885_macpro_init_hook(codec); | 6974 | alc885_macpro_init_hook(codec); |
6719 | alc885_imac24_automute(codec); | 6975 | alc885_imac24_automute_init_hook(codec); |
6720 | } | 6976 | } |
6721 | 6977 | ||
6722 | /* | 6978 | /* |
@@ -6809,6 +7065,7 @@ static const char *alc882_models[ALC882_MODEL_LAST] = { | |||
6809 | [ALC882_ASUS_A7J] = "asus-a7j", | 7065 | [ALC882_ASUS_A7J] = "asus-a7j", |
6810 | [ALC882_ASUS_A7M] = "asus-a7m", | 7066 | [ALC882_ASUS_A7M] = "asus-a7m", |
6811 | [ALC885_MACPRO] = "macpro", | 7067 | [ALC885_MACPRO] = "macpro", |
7068 | [ALC885_MB5] = "mb5", | ||
6812 | [ALC885_MBP3] = "mbp3", | 7069 | [ALC885_MBP3] = "mbp3", |
6813 | [ALC885_IMAC24] = "imac24", | 7070 | [ALC885_IMAC24] = "imac24", |
6814 | [ALC882_AUTO] = "auto", | 7071 | [ALC882_AUTO] = "auto", |
@@ -6886,8 +7143,20 @@ static struct alc_config_preset alc882_presets[] = { | |||
6886 | .input_mux = &alc882_capture_source, | 7143 | .input_mux = &alc882_capture_source, |
6887 | .dig_out_nid = ALC882_DIGOUT_NID, | 7144 | .dig_out_nid = ALC882_DIGOUT_NID, |
6888 | .dig_in_nid = ALC882_DIGIN_NID, | 7145 | .dig_in_nid = ALC882_DIGIN_NID, |
6889 | .unsol_event = alc885_mbp3_unsol_event, | 7146 | .unsol_event = alc_automute_amp_unsol_event, |
6890 | .init_hook = alc885_mbp3_automute, | 7147 | .init_hook = alc885_mbp3_init_hook, |
7148 | }, | ||
7149 | [ALC885_MB5] = { | ||
7150 | .mixers = { alc885_mb5_mixer, alc882_chmode_mixer }, | ||
7151 | .init_verbs = { alc885_mb5_init_verbs, | ||
7152 | alc880_gpio1_init_verbs }, | ||
7153 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7154 | .dac_nids = alc882_dac_nids, | ||
7155 | .channel_mode = alc885_mb5_6ch_modes, | ||
7156 | .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes), | ||
7157 | .input_mux = &mb5_capture_source, | ||
7158 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7159 | .dig_in_nid = ALC882_DIGIN_NID, | ||
6891 | }, | 7160 | }, |
6892 | [ALC885_MACPRO] = { | 7161 | [ALC885_MACPRO] = { |
6893 | .mixers = { alc882_macpro_mixer }, | 7162 | .mixers = { alc882_macpro_mixer }, |
@@ -6911,7 +7180,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
6911 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | 7180 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), |
6912 | .channel_mode = alc882_ch_modes, | 7181 | .channel_mode = alc882_ch_modes, |
6913 | .input_mux = &alc882_capture_source, | 7182 | .input_mux = &alc882_capture_source, |
6914 | .unsol_event = alc885_imac24_unsol_event, | 7183 | .unsol_event = alc_automute_amp_unsol_event, |
6915 | .init_hook = alc885_imac24_init_hook, | 7184 | .init_hook = alc885_imac24_init_hook, |
6916 | }, | 7185 | }, |
6917 | [ALC882_TARGA] = { | 7186 | [ALC882_TARGA] = { |
@@ -6928,7 +7197,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
6928 | .need_dac_fix = 1, | 7197 | .need_dac_fix = 1, |
6929 | .input_mux = &alc882_capture_source, | 7198 | .input_mux = &alc882_capture_source, |
6930 | .unsol_event = alc882_targa_unsol_event, | 7199 | .unsol_event = alc882_targa_unsol_event, |
6931 | .init_hook = alc882_targa_automute, | 7200 | .init_hook = alc882_targa_init_hook, |
6932 | }, | 7201 | }, |
6933 | [ALC882_ASUS_A7J] = { | 7202 | [ALC882_ASUS_A7J] = { |
6934 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, | 7203 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, |
@@ -7008,7 +7277,6 @@ static void alc882_auto_init_multi_out(struct hda_codec *codec) | |||
7008 | struct alc_spec *spec = codec->spec; | 7277 | struct alc_spec *spec = codec->spec; |
7009 | int i; | 7278 | int i; |
7010 | 7279 | ||
7011 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | ||
7012 | for (i = 0; i <= HDA_SIDE; i++) { | 7280 | for (i = 0; i <= HDA_SIDE; i++) { |
7013 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | 7281 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
7014 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | 7282 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
@@ -7191,10 +7459,17 @@ static int patch_alc882(struct hda_codec *codec) | |||
7191 | case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ | 7459 | case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ |
7192 | case 0x106b00a4: /* MacbookPro4,1 */ | 7460 | case 0x106b00a4: /* MacbookPro4,1 */ |
7193 | case 0x106b2c00: /* Macbook Pro rev3 */ | 7461 | case 0x106b2c00: /* Macbook Pro rev3 */ |
7194 | case 0x106b3600: /* Macbook 3.1 */ | 7462 | /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */ |
7195 | case 0x106b3800: /* MacbookPro4,1 - latter revision */ | 7463 | case 0x106b3800: /* MacbookPro4,1 - latter revision */ |
7196 | board_config = ALC885_MBP3; | 7464 | board_config = ALC885_MBP3; |
7197 | break; | 7465 | break; |
7466 | case 0x106b3f00: /* Macbook 5,1 */ | ||
7467 | case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense | ||
7468 | * seems not working, so apparently | ||
7469 | * no perfect solution yet | ||
7470 | */ | ||
7471 | board_config = ALC885_MB5; | ||
7472 | break; | ||
7198 | default: | 7473 | default: |
7199 | /* ALC889A is handled better as ALC888-compatible */ | 7474 | /* ALC889A is handled better as ALC888-compatible */ |
7200 | if (codec->revision_id == 0x100101 || | 7475 | if (codec->revision_id == 0x100101 || |
@@ -7202,8 +7477,9 @@ static int patch_alc882(struct hda_codec *codec) | |||
7202 | alc_free(codec); | 7477 | alc_free(codec); |
7203 | return patch_alc883(codec); | 7478 | return patch_alc883(codec); |
7204 | } | 7479 | } |
7205 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " | 7480 | printk(KERN_INFO "hda_codec: Unknown model for %s, " |
7206 | "trying auto-probe from BIOS...\n"); | 7481 | "trying auto-probe from BIOS...\n", |
7482 | codec->chip_name); | ||
7207 | board_config = ALC882_AUTO; | 7483 | board_config = ALC882_AUTO; |
7208 | } | 7484 | } |
7209 | } | 7485 | } |
@@ -7233,14 +7509,6 @@ static int patch_alc882(struct hda_codec *codec) | |||
7233 | if (board_config != ALC882_AUTO) | 7509 | if (board_config != ALC882_AUTO) |
7234 | setup_preset(spec, &alc882_presets[board_config]); | 7510 | setup_preset(spec, &alc882_presets[board_config]); |
7235 | 7511 | ||
7236 | if (codec->vendor_id == 0x10ec0885) { | ||
7237 | spec->stream_name_analog = "ALC885 Analog"; | ||
7238 | spec->stream_name_digital = "ALC885 Digital"; | ||
7239 | } else { | ||
7240 | spec->stream_name_analog = "ALC882 Analog"; | ||
7241 | spec->stream_name_digital = "ALC882 Digital"; | ||
7242 | } | ||
7243 | |||
7244 | spec->stream_analog_playback = &alc882_pcm_analog_playback; | 7512 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
7245 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | 7513 | spec->stream_analog_capture = &alc882_pcm_analog_capture; |
7246 | /* FIXME: setup DAC5 */ | 7514 | /* FIXME: setup DAC5 */ |
@@ -7393,6 +7661,17 @@ static struct hda_input_mux alc883_asus_eee1601_capture_source = { | |||
7393 | }, | 7661 | }, |
7394 | }; | 7662 | }; |
7395 | 7663 | ||
7664 | static struct hda_input_mux alc889A_mb31_capture_source = { | ||
7665 | .num_items = 2, | ||
7666 | .items = { | ||
7667 | { "Mic", 0x0 }, | ||
7668 | /* Front Mic (0x01) unused */ | ||
7669 | { "Line", 0x2 }, | ||
7670 | /* Line 2 (0x03) unused */ | ||
7671 | /* CD (0x04) unsused? */ | ||
7672 | }, | ||
7673 | }; | ||
7674 | |||
7396 | /* | 7675 | /* |
7397 | * 2ch mode | 7676 | * 2ch mode |
7398 | */ | 7677 | */ |
@@ -7442,6 +7721,73 @@ static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { | |||
7442 | { 6, alc883_3ST_ch6_init }, | 7721 | { 6, alc883_3ST_ch6_init }, |
7443 | }; | 7722 | }; |
7444 | 7723 | ||
7724 | |||
7725 | /* | ||
7726 | * 2ch mode | ||
7727 | */ | ||
7728 | static struct hda_verb alc883_4ST_ch2_init[] = { | ||
7729 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7730 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7731 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7732 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7733 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
7734 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7735 | { } /* end */ | ||
7736 | }; | ||
7737 | |||
7738 | /* | ||
7739 | * 4ch mode | ||
7740 | */ | ||
7741 | static struct hda_verb alc883_4ST_ch4_init[] = { | ||
7742 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7743 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7744 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7745 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7746 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7747 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7748 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7749 | { } /* end */ | ||
7750 | }; | ||
7751 | |||
7752 | /* | ||
7753 | * 6ch mode | ||
7754 | */ | ||
7755 | static struct hda_verb alc883_4ST_ch6_init[] = { | ||
7756 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7757 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7758 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7759 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7760 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
7761 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7762 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7763 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7764 | { } /* end */ | ||
7765 | }; | ||
7766 | |||
7767 | /* | ||
7768 | * 8ch mode | ||
7769 | */ | ||
7770 | static struct hda_verb alc883_4ST_ch8_init[] = { | ||
7771 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7772 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7773 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
7774 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7775 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7776 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
7777 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7778 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7779 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7780 | { } /* end */ | ||
7781 | }; | ||
7782 | |||
7783 | static struct hda_channel_mode alc883_4ST_8ch_modes[4] = { | ||
7784 | { 2, alc883_4ST_ch2_init }, | ||
7785 | { 4, alc883_4ST_ch4_init }, | ||
7786 | { 6, alc883_4ST_ch6_init }, | ||
7787 | { 8, alc883_4ST_ch8_init }, | ||
7788 | }; | ||
7789 | |||
7790 | |||
7445 | /* | 7791 | /* |
7446 | * 2ch mode | 7792 | * 2ch mode |
7447 | */ | 7793 | */ |
@@ -7511,6 +7857,49 @@ static struct hda_channel_mode alc883_sixstack_modes[2] = { | |||
7511 | { 8, alc883_sixstack_ch8_init }, | 7857 | { 8, alc883_sixstack_ch8_init }, |
7512 | }; | 7858 | }; |
7513 | 7859 | ||
7860 | /* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */ | ||
7861 | static struct hda_verb alc889A_mb31_ch2_init[] = { | ||
7862 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */ | ||
7863 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */ | ||
7864 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */ | ||
7865 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */ | ||
7866 | { } /* end */ | ||
7867 | }; | ||
7868 | |||
7869 | /* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */ | ||
7870 | static struct hda_verb alc889A_mb31_ch4_init[] = { | ||
7871 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */ | ||
7872 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */ | ||
7873 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */ | ||
7874 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */ | ||
7875 | { } /* end */ | ||
7876 | }; | ||
7877 | |||
7878 | /* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */ | ||
7879 | static struct hda_verb alc889A_mb31_ch5_init[] = { | ||
7880 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */ | ||
7881 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */ | ||
7882 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */ | ||
7883 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */ | ||
7884 | { } /* end */ | ||
7885 | }; | ||
7886 | |||
7887 | /* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */ | ||
7888 | static struct hda_verb alc889A_mb31_ch6_init[] = { | ||
7889 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */ | ||
7890 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */ | ||
7891 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */ | ||
7892 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */ | ||
7893 | { } /* end */ | ||
7894 | }; | ||
7895 | |||
7896 | static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = { | ||
7897 | { 2, alc889A_mb31_ch2_init }, | ||
7898 | { 4, alc889A_mb31_ch4_init }, | ||
7899 | { 5, alc889A_mb31_ch5_init }, | ||
7900 | { 6, alc889A_mb31_ch6_init }, | ||
7901 | }; | ||
7902 | |||
7514 | static struct hda_verb alc883_medion_eapd_verbs[] = { | 7903 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
7515 | /* eanable EAPD on medion laptop */ | 7904 | /* eanable EAPD on medion laptop */ |
7516 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | 7905 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
@@ -7776,8 +8165,6 @@ static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = { | |||
7776 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | 8165 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), |
7777 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | 8166 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
7778 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | 8167 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
7779 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | ||
7780 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT), | ||
7781 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | 8168 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
7782 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | 8169 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
7783 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | 8170 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
@@ -7791,6 +8178,42 @@ static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = { | |||
7791 | { } /* end */ | 8178 | { } /* end */ |
7792 | }; | 8179 | }; |
7793 | 8180 | ||
8181 | static struct snd_kcontrol_new alc889A_mb31_mixer[] = { | ||
8182 | /* Output mixers */ | ||
8183 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | ||
8184 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | ||
8185 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | ||
8186 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT), | ||
8187 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00, | ||
8188 | HDA_OUTPUT), | ||
8189 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT), | ||
8190 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT), | ||
8191 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT), | ||
8192 | /* Output switches */ | ||
8193 | HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT), | ||
8194 | HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT), | ||
8195 | HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT), | ||
8196 | /* Boost mixers */ | ||
8197 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), | ||
8198 | HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT), | ||
8199 | /* Input mixers */ | ||
8200 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), | ||
8201 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | ||
8202 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
8203 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
8204 | { } /* end */ | ||
8205 | }; | ||
8206 | |||
8207 | static struct snd_kcontrol_new alc883_vaiott_mixer[] = { | ||
8208 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
8209 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | ||
8210 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | ||
8211 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | ||
8212 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | ||
8213 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | ||
8214 | { } /* end */ | ||
8215 | }; | ||
8216 | |||
7794 | static struct hda_bind_ctls alc883_bind_cap_vol = { | 8217 | static struct hda_bind_ctls alc883_bind_cap_vol = { |
7795 | .ops = &snd_hda_bind_vol, | 8218 | .ops = &snd_hda_bind_vol, |
7796 | .values = { | 8219 | .values = { |
@@ -7926,16 +8349,14 @@ static struct hda_verb alc883_init_verbs[] = { | |||
7926 | }; | 8349 | }; |
7927 | 8350 | ||
7928 | /* toggle speaker-output according to the hp-jack state */ | 8351 | /* toggle speaker-output according to the hp-jack state */ |
7929 | static void alc883_mitac_hp_automute(struct hda_codec *codec) | 8352 | static void alc883_mitac_init_hook(struct hda_codec *codec) |
7930 | { | 8353 | { |
7931 | unsigned int present; | 8354 | struct alc_spec *spec = codec->spec; |
7932 | 8355 | ||
7933 | present = snd_hda_codec_read(codec, 0x15, 0, | 8356 | spec->autocfg.hp_pins[0] = 0x15; |
7934 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 8357 | spec->autocfg.speaker_pins[0] = 0x14; |
7935 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 8358 | spec->autocfg.speaker_pins[1] = 0x17; |
7936 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8359 | alc_automute_amp(codec); |
7937 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | ||
7938 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
7939 | } | 8360 | } |
7940 | 8361 | ||
7941 | /* auto-toggle front mic */ | 8362 | /* auto-toggle front mic */ |
@@ -7952,25 +8373,6 @@ static void alc883_mitac_mic_automute(struct hda_codec *codec) | |||
7952 | } | 8373 | } |
7953 | */ | 8374 | */ |
7954 | 8375 | ||
7955 | static void alc883_mitac_automute(struct hda_codec *codec) | ||
7956 | { | ||
7957 | alc883_mitac_hp_automute(codec); | ||
7958 | /* alc883_mitac_mic_automute(codec); */ | ||
7959 | } | ||
7960 | |||
7961 | static void alc883_mitac_unsol_event(struct hda_codec *codec, | ||
7962 | unsigned int res) | ||
7963 | { | ||
7964 | switch (res >> 26) { | ||
7965 | case ALC880_HP_EVENT: | ||
7966 | alc883_mitac_hp_automute(codec); | ||
7967 | break; | ||
7968 | case ALC880_MIC_EVENT: | ||
7969 | /* alc883_mitac_mic_automute(codec); */ | ||
7970 | break; | ||
7971 | } | ||
7972 | } | ||
7973 | |||
7974 | static struct hda_verb alc883_mitac_verbs[] = { | 8376 | static struct hda_verb alc883_mitac_verbs[] = { |
7975 | /* HP */ | 8377 | /* HP */ |
7976 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | 8378 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -8022,14 +8424,24 @@ static struct hda_verb alc883_tagra_verbs[] = { | |||
8022 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | 8424 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
8023 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | 8425 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
8024 | 8426 | ||
8025 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | 8427 | /* Connect Line-Out side jack (SPDIF) to Side */ |
8026 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | 8428 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
8027 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | 8429 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
8430 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
8431 | /* Connect Mic jack to CLFE */ | ||
8432 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8433 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8434 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
8435 | /* Connect Line-in jack to Surround */ | ||
8436 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8437 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8438 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
8439 | /* Connect HP out jack to Front */ | ||
8440 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8441 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8442 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8028 | 8443 | ||
8029 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | 8444 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
8030 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | ||
8031 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | ||
8032 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | ||
8033 | 8445 | ||
8034 | { } /* end */ | 8446 | { } /* end */ |
8035 | }; | 8447 | }; |
@@ -8088,29 +8500,26 @@ static struct hda_verb alc888_6st_dell_verbs[] = { | |||
8088 | { } | 8500 | { } |
8089 | }; | 8501 | }; |
8090 | 8502 | ||
8091 | static void alc888_3st_hp_front_automute(struct hda_codec *codec) | 8503 | static struct hda_verb alc883_vaiott_verbs[] = { |
8092 | { | 8504 | /* HP */ |
8093 | unsigned int present, bits; | 8505 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, |
8506 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
8094 | 8507 | ||
8095 | present = snd_hda_codec_read(codec, 0x1b, 0, | 8508 | /* enable unsolicited event */ |
8096 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 8509 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
8097 | bits = present ? HDA_AMP_MUTE : 0; | 8510 | |
8098 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 8511 | { } /* end */ |
8099 | HDA_AMP_MUTE, bits); | 8512 | }; |
8100 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8101 | HDA_AMP_MUTE, bits); | ||
8102 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, | ||
8103 | HDA_AMP_MUTE, bits); | ||
8104 | } | ||
8105 | 8513 | ||
8106 | static void alc888_3st_hp_unsol_event(struct hda_codec *codec, | 8514 | static void alc888_3st_hp_init_hook(struct hda_codec *codec) |
8107 | unsigned int res) | ||
8108 | { | 8515 | { |
8109 | switch (res >> 26) { | 8516 | struct alc_spec *spec = codec->spec; |
8110 | case ALC880_HP_EVENT: | 8517 | |
8111 | alc888_3st_hp_front_automute(codec); | 8518 | spec->autocfg.hp_pins[0] = 0x1b; |
8112 | break; | 8519 | spec->autocfg.speaker_pins[0] = 0x14; |
8113 | } | 8520 | spec->autocfg.speaker_pins[1] = 0x16; |
8521 | spec->autocfg.speaker_pins[2] = 0x18; | ||
8522 | alc_automute_amp(codec); | ||
8114 | } | 8523 | } |
8115 | 8524 | ||
8116 | static struct hda_verb alc888_3st_hp_verbs[] = { | 8525 | static struct hda_verb alc888_3st_hp_verbs[] = { |
@@ -8207,56 +8616,18 @@ static struct hda_verb alc883_medion_md2_verbs[] = { | |||
8207 | }; | 8616 | }; |
8208 | 8617 | ||
8209 | /* toggle speaker-output according to the hp-jack state */ | 8618 | /* toggle speaker-output according to the hp-jack state */ |
8210 | static void alc883_medion_md2_automute(struct hda_codec *codec) | 8619 | static void alc883_medion_md2_init_hook(struct hda_codec *codec) |
8211 | { | 8620 | { |
8212 | unsigned int present; | 8621 | struct alc_spec *spec = codec->spec; |
8213 | |||
8214 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
8215 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8216 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8217 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8218 | } | ||
8219 | |||
8220 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | ||
8221 | unsigned int res) | ||
8222 | { | ||
8223 | if ((res >> 26) == ALC880_HP_EVENT) | ||
8224 | alc883_medion_md2_automute(codec); | ||
8225 | } | ||
8226 | |||
8227 | /* toggle speaker-output according to the hp-jack state */ | ||
8228 | static void alc883_tagra_automute(struct hda_codec *codec) | ||
8229 | { | ||
8230 | unsigned int present; | ||
8231 | unsigned char bits; | ||
8232 | |||
8233 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
8234 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8235 | bits = present ? HDA_AMP_MUTE : 0; | ||
8236 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | ||
8237 | HDA_AMP_MUTE, bits); | ||
8238 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, | ||
8239 | present ? 1 : 3); | ||
8240 | } | ||
8241 | 8622 | ||
8242 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | 8623 | spec->autocfg.hp_pins[0] = 0x14; |
8243 | { | 8624 | spec->autocfg.speaker_pins[0] = 0x15; |
8244 | if ((res >> 26) == ALC880_HP_EVENT) | 8625 | alc_automute_amp(codec); |
8245 | alc883_tagra_automute(codec); | ||
8246 | } | 8626 | } |
8247 | 8627 | ||
8248 | /* toggle speaker-output according to the hp-jack state */ | 8628 | /* toggle speaker-output according to the hp-jack state */ |
8249 | static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) | 8629 | #define alc883_tagra_init_hook alc882_targa_init_hook |
8250 | { | 8630 | #define alc883_tagra_unsol_event alc882_targa_unsol_event |
8251 | unsigned int present; | ||
8252 | unsigned char bits; | ||
8253 | |||
8254 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
8255 | & AC_PINSENSE_PRESENCE; | ||
8256 | bits = present ? HDA_AMP_MUTE : 0; | ||
8257 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8258 | HDA_AMP_MUTE, bits); | ||
8259 | } | ||
8260 | 8631 | ||
8261 | static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) | 8632 | static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) |
8262 | { | 8633 | { |
@@ -8268,9 +8639,13 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) | |||
8268 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8639 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8269 | } | 8640 | } |
8270 | 8641 | ||
8271 | static void alc883_clevo_m720_automute(struct hda_codec *codec) | 8642 | static void alc883_clevo_m720_init_hook(struct hda_codec *codec) |
8272 | { | 8643 | { |
8273 | alc883_clevo_m720_hp_automute(codec); | 8644 | struct alc_spec *spec = codec->spec; |
8645 | |||
8646 | spec->autocfg.hp_pins[0] = 0x15; | ||
8647 | spec->autocfg.speaker_pins[0] = 0x14; | ||
8648 | alc_automute_amp(codec); | ||
8274 | alc883_clevo_m720_mic_automute(codec); | 8649 | alc883_clevo_m720_mic_automute(codec); |
8275 | } | 8650 | } |
8276 | 8651 | ||
@@ -8278,52 +8653,32 @@ static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, | |||
8278 | unsigned int res) | 8653 | unsigned int res) |
8279 | { | 8654 | { |
8280 | switch (res >> 26) { | 8655 | switch (res >> 26) { |
8281 | case ALC880_HP_EVENT: | ||
8282 | alc883_clevo_m720_hp_automute(codec); | ||
8283 | break; | ||
8284 | case ALC880_MIC_EVENT: | 8656 | case ALC880_MIC_EVENT: |
8285 | alc883_clevo_m720_mic_automute(codec); | 8657 | alc883_clevo_m720_mic_automute(codec); |
8286 | break; | 8658 | break; |
8659 | default: | ||
8660 | alc_automute_amp_unsol_event(codec, res); | ||
8661 | break; | ||
8287 | } | 8662 | } |
8288 | } | 8663 | } |
8289 | 8664 | ||
8290 | /* toggle speaker-output according to the hp-jack state */ | 8665 | /* toggle speaker-output according to the hp-jack state */ |
8291 | static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) | 8666 | static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec) |
8292 | { | 8667 | { |
8293 | unsigned int present; | 8668 | struct alc_spec *spec = codec->spec; |
8294 | unsigned char bits; | ||
8295 | |||
8296 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
8297 | & AC_PINSENSE_PRESENCE; | ||
8298 | bits = present ? HDA_AMP_MUTE : 0; | ||
8299 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8300 | HDA_AMP_MUTE, bits); | ||
8301 | } | ||
8302 | 8669 | ||
8303 | static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, | 8670 | spec->autocfg.hp_pins[0] = 0x14; |
8304 | unsigned int res) | 8671 | spec->autocfg.speaker_pins[0] = 0x15; |
8305 | { | 8672 | alc_automute_amp(codec); |
8306 | if ((res >> 26) == ALC880_HP_EVENT) | ||
8307 | alc883_2ch_fujitsu_pi2515_automute(codec); | ||
8308 | } | 8673 | } |
8309 | 8674 | ||
8310 | static void alc883_haier_w66_automute(struct hda_codec *codec) | 8675 | static void alc883_haier_w66_init_hook(struct hda_codec *codec) |
8311 | { | 8676 | { |
8312 | unsigned int present; | 8677 | struct alc_spec *spec = codec->spec; |
8313 | unsigned char bits; | ||
8314 | 8678 | ||
8315 | present = snd_hda_codec_read(codec, 0x1b, 0, | 8679 | spec->autocfg.hp_pins[0] = 0x1b; |
8316 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 8680 | spec->autocfg.speaker_pins[0] = 0x14; |
8317 | bits = present ? 0x80 : 0; | 8681 | alc_automute_amp(codec); |
8318 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8319 | 0x80, bits); | ||
8320 | } | ||
8321 | |||
8322 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | ||
8323 | unsigned int res) | ||
8324 | { | ||
8325 | if ((res >> 26) == ALC880_HP_EVENT) | ||
8326 | alc883_haier_w66_automute(codec); | ||
8327 | } | 8682 | } |
8328 | 8683 | ||
8329 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | 8684 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
@@ -8331,8 +8686,8 @@ static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | |||
8331 | unsigned int present; | 8686 | unsigned int present; |
8332 | unsigned char bits; | 8687 | unsigned char bits; |
8333 | 8688 | ||
8334 | present = snd_hda_codec_read(codec, 0x14, 0, | 8689 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) |
8335 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 8690 | & AC_PINSENSE_PRESENCE; |
8336 | bits = present ? HDA_AMP_MUTE : 0; | 8691 | bits = present ? HDA_AMP_MUTE : 0; |
8337 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8692 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8338 | HDA_AMP_MUTE, bits); | 8693 | HDA_AMP_MUTE, bits); |
@@ -8362,23 +8717,14 @@ static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |||
8362 | } | 8717 | } |
8363 | 8718 | ||
8364 | /* toggle speaker-output according to the hp-jack state */ | 8719 | /* toggle speaker-output according to the hp-jack state */ |
8365 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | 8720 | static void alc883_acer_aspire_init_hook(struct hda_codec *codec) |
8366 | { | 8721 | { |
8367 | unsigned int present; | 8722 | struct alc_spec *spec = codec->spec; |
8368 | |||
8369 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
8370 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8371 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8372 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8373 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8374 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8375 | } | ||
8376 | 8723 | ||
8377 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | 8724 | spec->autocfg.hp_pins[0] = 0x14; |
8378 | unsigned int res) | 8725 | spec->autocfg.speaker_pins[0] = 0x15; |
8379 | { | 8726 | spec->autocfg.speaker_pins[1] = 0x16; |
8380 | if ((res >> 26) == ALC880_HP_EVENT) | 8727 | alc_automute_amp(codec); |
8381 | alc883_acer_aspire_automute(codec); | ||
8382 | } | 8728 | } |
8383 | 8729 | ||
8384 | static struct hda_verb alc883_acer_eapd_verbs[] = { | 8730 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
@@ -8399,75 +8745,39 @@ static struct hda_verb alc883_acer_eapd_verbs[] = { | |||
8399 | { } | 8745 | { } |
8400 | }; | 8746 | }; |
8401 | 8747 | ||
8402 | static void alc888_6st_dell_front_automute(struct hda_codec *codec) | 8748 | static void alc888_6st_dell_init_hook(struct hda_codec *codec) |
8403 | { | 8749 | { |
8404 | unsigned int present; | 8750 | struct alc_spec *spec = codec->spec; |
8405 | |||
8406 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
8407 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8408 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8409 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8410 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8411 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8412 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8413 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8414 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | ||
8415 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8416 | } | ||
8417 | 8751 | ||
8418 | static void alc888_6st_dell_unsol_event(struct hda_codec *codec, | 8752 | spec->autocfg.hp_pins[0] = 0x1b; |
8419 | unsigned int res) | 8753 | spec->autocfg.speaker_pins[0] = 0x14; |
8420 | { | 8754 | spec->autocfg.speaker_pins[1] = 0x15; |
8421 | switch (res >> 26) { | 8755 | spec->autocfg.speaker_pins[2] = 0x16; |
8422 | case ALC880_HP_EVENT: | 8756 | spec->autocfg.speaker_pins[3] = 0x17; |
8423 | /* printk(KERN_DEBUG "hp_event\n"); */ | 8757 | alc_automute_amp(codec); |
8424 | alc888_6st_dell_front_automute(codec); | ||
8425 | break; | ||
8426 | } | ||
8427 | } | 8758 | } |
8428 | 8759 | ||
8429 | static void alc888_lenovo_sky_front_automute(struct hda_codec *codec) | 8760 | static void alc888_lenovo_sky_init_hook(struct hda_codec *codec) |
8430 | { | 8761 | { |
8431 | unsigned int mute; | 8762 | struct alc_spec *spec = codec->spec; |
8432 | unsigned int present; | ||
8433 | 8763 | ||
8434 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | 8764 | spec->autocfg.hp_pins[0] = 0x1b; |
8435 | present = snd_hda_codec_read(codec, 0x1b, 0, | 8765 | spec->autocfg.speaker_pins[0] = 0x14; |
8436 | AC_VERB_GET_PIN_SENSE, 0); | 8766 | spec->autocfg.speaker_pins[1] = 0x15; |
8437 | present = (present & 0x80000000) != 0; | 8767 | spec->autocfg.speaker_pins[2] = 0x16; |
8438 | if (present) { | 8768 | spec->autocfg.speaker_pins[3] = 0x17; |
8439 | /* mute internal speaker */ | 8769 | spec->autocfg.speaker_pins[4] = 0x1a; |
8440 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 8770 | alc_automute_amp(codec); |
8441 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
8442 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8443 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
8444 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8445 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
8446 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | ||
8447 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
8448 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | ||
8449 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
8450 | } else { | ||
8451 | /* unmute internal speaker if necessary */ | ||
8452 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | ||
8453 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8454 | HDA_AMP_MUTE, mute); | ||
8455 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
8456 | HDA_AMP_MUTE, mute); | ||
8457 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8458 | HDA_AMP_MUTE, mute); | ||
8459 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | ||
8460 | HDA_AMP_MUTE, mute); | ||
8461 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | ||
8462 | HDA_AMP_MUTE, mute); | ||
8463 | } | ||
8464 | } | 8771 | } |
8465 | 8772 | ||
8466 | static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec, | 8773 | static void alc883_vaiott_init_hook(struct hda_codec *codec) |
8467 | unsigned int res) | ||
8468 | { | 8774 | { |
8469 | if ((res >> 26) == ALC880_HP_EVENT) | 8775 | struct alc_spec *spec = codec->spec; |
8470 | alc888_lenovo_sky_front_automute(codec); | 8776 | |
8777 | spec->autocfg.hp_pins[0] = 0x15; | ||
8778 | spec->autocfg.speaker_pins[0] = 0x14; | ||
8779 | spec->autocfg.speaker_pins[1] = 0x17; | ||
8780 | alc_automute_amp(codec); | ||
8471 | } | 8781 | } |
8472 | 8782 | ||
8473 | /* | 8783 | /* |
@@ -8555,39 +8865,33 @@ static void alc883_nb_mic_automute(struct hda_codec *codec) | |||
8555 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | 8865 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); |
8556 | } | 8866 | } |
8557 | 8867 | ||
8558 | static void alc883_M90V_speaker_automute(struct hda_codec *codec) | 8868 | static void alc883_M90V_init_hook(struct hda_codec *codec) |
8559 | { | 8869 | { |
8560 | unsigned int present; | 8870 | struct alc_spec *spec = codec->spec; |
8561 | unsigned char bits; | ||
8562 | 8871 | ||
8563 | present = snd_hda_codec_read(codec, 0x1b, 0, | 8872 | spec->autocfg.hp_pins[0] = 0x1b; |
8564 | AC_VERB_GET_PIN_SENSE, 0) | 8873 | spec->autocfg.speaker_pins[0] = 0x14; |
8565 | & AC_PINSENSE_PRESENCE; | 8874 | spec->autocfg.speaker_pins[1] = 0x15; |
8566 | bits = present ? 0 : PIN_OUT; | 8875 | spec->autocfg.speaker_pins[2] = 0x16; |
8567 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 8876 | alc_automute_pin(codec); |
8568 | bits); | ||
8569 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
8570 | bits); | ||
8571 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
8572 | bits); | ||
8573 | } | 8877 | } |
8574 | 8878 | ||
8575 | static void alc883_mode2_unsol_event(struct hda_codec *codec, | 8879 | static void alc883_mode2_unsol_event(struct hda_codec *codec, |
8576 | unsigned int res) | 8880 | unsigned int res) |
8577 | { | 8881 | { |
8578 | switch (res >> 26) { | 8882 | switch (res >> 26) { |
8579 | case ALC880_HP_EVENT: | ||
8580 | alc883_M90V_speaker_automute(codec); | ||
8581 | break; | ||
8582 | case ALC880_MIC_EVENT: | 8883 | case ALC880_MIC_EVENT: |
8583 | alc883_nb_mic_automute(codec); | 8884 | alc883_nb_mic_automute(codec); |
8584 | break; | 8885 | break; |
8886 | default: | ||
8887 | alc_sku_unsol_event(codec, res); | ||
8888 | break; | ||
8585 | } | 8889 | } |
8586 | } | 8890 | } |
8587 | 8891 | ||
8588 | static void alc883_mode2_inithook(struct hda_codec *codec) | 8892 | static void alc883_mode2_inithook(struct hda_codec *codec) |
8589 | { | 8893 | { |
8590 | alc883_M90V_speaker_automute(codec); | 8894 | alc883_M90V_init_hook(codec); |
8591 | alc883_nb_mic_automute(codec); | 8895 | alc883_nb_mic_automute(codec); |
8592 | } | 8896 | } |
8593 | 8897 | ||
@@ -8604,32 +8908,49 @@ static struct hda_verb alc888_asus_eee1601_verbs[] = { | |||
8604 | { } /* end */ | 8908 | { } /* end */ |
8605 | }; | 8909 | }; |
8606 | 8910 | ||
8607 | static void alc883_eee1601_speaker_automute(struct hda_codec *codec) | 8911 | static void alc883_eee1601_inithook(struct hda_codec *codec) |
8608 | { | 8912 | { |
8609 | unsigned int present; | 8913 | struct alc_spec *spec = codec->spec; |
8610 | unsigned char bits; | ||
8611 | 8914 | ||
8612 | present = snd_hda_codec_read(codec, 0x14, 0, | 8915 | spec->autocfg.hp_pins[0] = 0x14; |
8613 | AC_VERB_GET_PIN_SENSE, 0) | 8916 | spec->autocfg.speaker_pins[0] = 0x1b; |
8614 | & AC_PINSENSE_PRESENCE; | 8917 | alc_automute_pin(codec); |
8615 | bits = present ? 0 : PIN_OUT; | ||
8616 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
8617 | bits); | ||
8618 | } | 8918 | } |
8619 | 8919 | ||
8620 | static void alc883_eee1601_unsol_event(struct hda_codec *codec, | 8920 | static struct hda_verb alc889A_mb31_verbs[] = { |
8621 | unsigned int res) | 8921 | /* Init rear pin (used as headphone output) */ |
8922 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */ | ||
8923 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */ | ||
8924 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | ||
8925 | /* Init line pin (used as output in 4ch and 6ch mode) */ | ||
8926 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */ | ||
8927 | /* Init line 2 pin (used as headphone out by default) */ | ||
8928 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */ | ||
8929 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */ | ||
8930 | { } /* end */ | ||
8931 | }; | ||
8932 | |||
8933 | /* Mute speakers according to the headphone jack state */ | ||
8934 | static void alc889A_mb31_automute(struct hda_codec *codec) | ||
8622 | { | 8935 | { |
8623 | switch (res >> 26) { | 8936 | unsigned int present; |
8624 | case ALC880_HP_EVENT: | 8937 | |
8625 | alc883_eee1601_speaker_automute(codec); | 8938 | /* Mute only in 2ch or 4ch mode */ |
8626 | break; | 8939 | if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0) |
8940 | == 0x00) { | ||
8941 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
8942 | AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; | ||
8943 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
8944 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8945 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
8946 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
8627 | } | 8947 | } |
8628 | } | 8948 | } |
8629 | 8949 | ||
8630 | static void alc883_eee1601_inithook(struct hda_codec *codec) | 8950 | static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res) |
8631 | { | 8951 | { |
8632 | alc883_eee1601_speaker_automute(codec); | 8952 | if ((res >> 26) == ALC880_HP_EVENT) |
8953 | alc889A_mb31_automute(codec); | ||
8633 | } | 8954 | } |
8634 | 8955 | ||
8635 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 8956 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -8653,9 +8974,11 @@ static const char *alc883_models[ALC883_MODEL_LAST] = { | |||
8653 | [ALC883_6ST_DIG] = "6stack-dig", | 8974 | [ALC883_6ST_DIG] = "6stack-dig", |
8654 | [ALC883_TARGA_DIG] = "targa-dig", | 8975 | [ALC883_TARGA_DIG] = "targa-dig", |
8655 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | 8976 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", |
8977 | [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig", | ||
8656 | [ALC883_ACER] = "acer", | 8978 | [ALC883_ACER] = "acer", |
8657 | [ALC883_ACER_ASPIRE] = "acer-aspire", | 8979 | [ALC883_ACER_ASPIRE] = "acer-aspire", |
8658 | [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", | 8980 | [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", |
8981 | [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g", | ||
8659 | [ALC883_MEDION] = "medion", | 8982 | [ALC883_MEDION] = "medion", |
8660 | [ALC883_MEDION_MD2] = "medion-md2", | 8983 | [ALC883_MEDION_MD2] = "medion-md2", |
8661 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", | 8984 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
@@ -8672,6 +8995,8 @@ static const char *alc883_models[ALC883_MODEL_LAST] = { | |||
8672 | [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", | 8995 | [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", |
8673 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", | 8996 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", |
8674 | [ALC1200_ASUS_P5Q] = "asus-p5q", | 8997 | [ALC1200_ASUS_P5Q] = "asus-p5q", |
8998 | [ALC889A_MB31] = "mb31", | ||
8999 | [ALC883_SONY_VAIO_TT] = "sony-vaio-tt", | ||
8675 | [ALC883_AUTO] = "auto", | 9000 | [ALC883_AUTO] = "auto", |
8676 | }; | 9001 | }; |
8677 | 9002 | ||
@@ -8687,14 +9012,18 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
8687 | ALC888_ACER_ASPIRE_4930G), | 9012 | ALC888_ACER_ASPIRE_4930G), |
8688 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", | 9013 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
8689 | ALC888_ACER_ASPIRE_4930G), | 9014 | ALC888_ACER_ASPIRE_4930G), |
9015 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", | ||
9016 | ALC888_ACER_ASPIRE_8930G), | ||
8690 | SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO), | 9017 | SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO), |
8691 | SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO), | 9018 | SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO), |
8692 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", | 9019 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
8693 | ALC888_ACER_ASPIRE_4930G), | 9020 | ALC888_ACER_ASPIRE_4930G), |
8694 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", | 9021 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
8695 | ALC888_ACER_ASPIRE_4930G), | 9022 | ALC888_ACER_ASPIRE_4930G), |
8696 | /* default Acer */ | 9023 | /* default Acer -- disabled as it causes more problems. |
8697 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), | 9024 | * model=auto should work fine now |
9025 | */ | ||
9026 | /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */ | ||
8698 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), | 9027 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
8699 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), | 9028 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
8700 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), | 9029 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
@@ -8730,6 +9059,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
8730 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), | 9059 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
8731 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | 9060 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), |
8732 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | 9061 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), |
9062 | SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG), | ||
8733 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), | 9063 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
8734 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | 9064 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), |
8735 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), | 9065 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), |
@@ -8762,6 +9092,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
8762 | SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), | 9092 | SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), |
8763 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), | 9093 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), |
8764 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), | 9094 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
9095 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT), | ||
8765 | {} | 9096 | {} |
8766 | }; | 9097 | }; |
8767 | 9098 | ||
@@ -8842,7 +9173,7 @@ static struct alc_config_preset alc883_presets[] = { | |||
8842 | .need_dac_fix = 1, | 9173 | .need_dac_fix = 1, |
8843 | .input_mux = &alc883_capture_source, | 9174 | .input_mux = &alc883_capture_source, |
8844 | .unsol_event = alc883_tagra_unsol_event, | 9175 | .unsol_event = alc883_tagra_unsol_event, |
8845 | .init_hook = alc883_tagra_automute, | 9176 | .init_hook = alc883_tagra_init_hook, |
8846 | }, | 9177 | }, |
8847 | [ALC883_TARGA_2ch_DIG] = { | 9178 | [ALC883_TARGA_2ch_DIG] = { |
8848 | .mixers = { alc883_tagra_2ch_mixer}, | 9179 | .mixers = { alc883_tagra_2ch_mixer}, |
@@ -8856,7 +9187,25 @@ static struct alc_config_preset alc883_presets[] = { | |||
8856 | .channel_mode = alc883_3ST_2ch_modes, | 9187 | .channel_mode = alc883_3ST_2ch_modes, |
8857 | .input_mux = &alc883_capture_source, | 9188 | .input_mux = &alc883_capture_source, |
8858 | .unsol_event = alc883_tagra_unsol_event, | 9189 | .unsol_event = alc883_tagra_unsol_event, |
8859 | .init_hook = alc883_tagra_automute, | 9190 | .init_hook = alc883_tagra_init_hook, |
9191 | }, | ||
9192 | [ALC883_TARGA_8ch_DIG] = { | ||
9193 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | ||
9194 | .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs, | ||
9195 | alc883_tagra_verbs }, | ||
9196 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9197 | .dac_nids = alc883_dac_nids, | ||
9198 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev), | ||
9199 | .adc_nids = alc883_adc_nids_rev, | ||
9200 | .capsrc_nids = alc883_capsrc_nids_rev, | ||
9201 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9202 | .dig_in_nid = ALC883_DIGIN_NID, | ||
9203 | .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes), | ||
9204 | .channel_mode = alc883_4ST_8ch_modes, | ||
9205 | .need_dac_fix = 1, | ||
9206 | .input_mux = &alc883_capture_source, | ||
9207 | .unsol_event = alc883_tagra_unsol_event, | ||
9208 | .init_hook = alc883_tagra_init_hook, | ||
8860 | }, | 9209 | }, |
8861 | [ALC883_ACER] = { | 9210 | [ALC883_ACER] = { |
8862 | .mixers = { alc883_base_mixer }, | 9211 | .mixers = { alc883_base_mixer }, |
@@ -8881,8 +9230,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
8881 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 9230 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8882 | .channel_mode = alc883_3ST_2ch_modes, | 9231 | .channel_mode = alc883_3ST_2ch_modes, |
8883 | .input_mux = &alc883_capture_source, | 9232 | .input_mux = &alc883_capture_source, |
8884 | .unsol_event = alc883_acer_aspire_unsol_event, | 9233 | .unsol_event = alc_automute_amp_unsol_event, |
8885 | .init_hook = alc883_acer_aspire_automute, | 9234 | .init_hook = alc883_acer_aspire_init_hook, |
8886 | }, | 9235 | }, |
8887 | [ALC888_ACER_ASPIRE_4930G] = { | 9236 | [ALC888_ACER_ASPIRE_4930G] = { |
8888 | .mixers = { alc888_base_mixer, | 9237 | .mixers = { alc888_base_mixer, |
@@ -8901,8 +9250,29 @@ static struct alc_config_preset alc883_presets[] = { | |||
8901 | .num_mux_defs = | 9250 | .num_mux_defs = |
8902 | ARRAY_SIZE(alc888_2_capture_sources), | 9251 | ARRAY_SIZE(alc888_2_capture_sources), |
8903 | .input_mux = alc888_2_capture_sources, | 9252 | .input_mux = alc888_2_capture_sources, |
8904 | .unsol_event = alc888_acer_aspire_4930g_unsol_event, | 9253 | .unsol_event = alc_automute_amp_unsol_event, |
8905 | .init_hook = alc888_acer_aspire_4930g_automute, | 9254 | .init_hook = alc888_acer_aspire_4930g_init_hook, |
9255 | }, | ||
9256 | [ALC888_ACER_ASPIRE_8930G] = { | ||
9257 | .mixers = { alc888_base_mixer, | ||
9258 | alc883_chmode_mixer }, | ||
9259 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs, | ||
9260 | alc889_acer_aspire_8930g_verbs }, | ||
9261 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9262 | .dac_nids = alc883_dac_nids, | ||
9263 | .num_adc_nids = ARRAY_SIZE(alc889_adc_nids), | ||
9264 | .adc_nids = alc889_adc_nids, | ||
9265 | .capsrc_nids = alc889_capsrc_nids, | ||
9266 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9267 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | ||
9268 | .channel_mode = alc883_3ST_6ch_modes, | ||
9269 | .need_dac_fix = 1, | ||
9270 | .const_channel_count = 6, | ||
9271 | .num_mux_defs = | ||
9272 | ARRAY_SIZE(alc889_capture_sources), | ||
9273 | .input_mux = alc889_capture_sources, | ||
9274 | .unsol_event = alc_automute_amp_unsol_event, | ||
9275 | .init_hook = alc889_acer_aspire_8930g_init_hook, | ||
8906 | }, | 9276 | }, |
8907 | [ALC883_MEDION] = { | 9277 | [ALC883_MEDION] = { |
8908 | .mixers = { alc883_fivestack_mixer, | 9278 | .mixers = { alc883_fivestack_mixer, |
@@ -8926,8 +9296,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
8926 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 9296 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8927 | .channel_mode = alc883_3ST_2ch_modes, | 9297 | .channel_mode = alc883_3ST_2ch_modes, |
8928 | .input_mux = &alc883_capture_source, | 9298 | .input_mux = &alc883_capture_source, |
8929 | .unsol_event = alc883_medion_md2_unsol_event, | 9299 | .unsol_event = alc_automute_amp_unsol_event, |
8930 | .init_hook = alc883_medion_md2_automute, | 9300 | .init_hook = alc883_medion_md2_init_hook, |
8931 | }, | 9301 | }, |
8932 | [ALC883_LAPTOP_EAPD] = { | 9302 | [ALC883_LAPTOP_EAPD] = { |
8933 | .mixers = { alc883_base_mixer }, | 9303 | .mixers = { alc883_base_mixer }, |
@@ -8948,7 +9318,7 @@ static struct alc_config_preset alc883_presets[] = { | |||
8948 | .channel_mode = alc883_3ST_2ch_modes, | 9318 | .channel_mode = alc883_3ST_2ch_modes, |
8949 | .input_mux = &alc883_capture_source, | 9319 | .input_mux = &alc883_capture_source, |
8950 | .unsol_event = alc883_clevo_m720_unsol_event, | 9320 | .unsol_event = alc883_clevo_m720_unsol_event, |
8951 | .init_hook = alc883_clevo_m720_automute, | 9321 | .init_hook = alc883_clevo_m720_init_hook, |
8952 | }, | 9322 | }, |
8953 | [ALC883_LENOVO_101E_2ch] = { | 9323 | [ALC883_LENOVO_101E_2ch] = { |
8954 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | 9324 | .mixers = { alc883_lenovo_101e_2ch_mixer}, |
@@ -8972,8 +9342,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
8972 | .channel_mode = alc883_3ST_2ch_modes, | 9342 | .channel_mode = alc883_3ST_2ch_modes, |
8973 | .need_dac_fix = 1, | 9343 | .need_dac_fix = 1, |
8974 | .input_mux = &alc883_lenovo_nb0763_capture_source, | 9344 | .input_mux = &alc883_lenovo_nb0763_capture_source, |
8975 | .unsol_event = alc883_medion_md2_unsol_event, | 9345 | .unsol_event = alc_automute_amp_unsol_event, |
8976 | .init_hook = alc883_medion_md2_automute, | 9346 | .init_hook = alc883_medion_md2_init_hook, |
8977 | }, | 9347 | }, |
8978 | [ALC888_LENOVO_MS7195_DIG] = { | 9348 | [ALC888_LENOVO_MS7195_DIG] = { |
8979 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 9349 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -8997,8 +9367,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
8997 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 9367 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8998 | .channel_mode = alc883_3ST_2ch_modes, | 9368 | .channel_mode = alc883_3ST_2ch_modes, |
8999 | .input_mux = &alc883_capture_source, | 9369 | .input_mux = &alc883_capture_source, |
9000 | .unsol_event = alc883_haier_w66_unsol_event, | 9370 | .unsol_event = alc_automute_amp_unsol_event, |
9001 | .init_hook = alc883_haier_w66_automute, | 9371 | .init_hook = alc883_haier_w66_init_hook, |
9002 | }, | 9372 | }, |
9003 | [ALC888_3ST_HP] = { | 9373 | [ALC888_3ST_HP] = { |
9004 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 9374 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9009,8 +9379,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9009 | .channel_mode = alc888_3st_hp_modes, | 9379 | .channel_mode = alc888_3st_hp_modes, |
9010 | .need_dac_fix = 1, | 9380 | .need_dac_fix = 1, |
9011 | .input_mux = &alc883_capture_source, | 9381 | .input_mux = &alc883_capture_source, |
9012 | .unsol_event = alc888_3st_hp_unsol_event, | 9382 | .unsol_event = alc_automute_amp_unsol_event, |
9013 | .init_hook = alc888_3st_hp_front_automute, | 9383 | .init_hook = alc888_3st_hp_init_hook, |
9014 | }, | 9384 | }, |
9015 | [ALC888_6ST_DELL] = { | 9385 | [ALC888_6ST_DELL] = { |
9016 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | 9386 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
@@ -9022,8 +9392,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9022 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | 9392 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
9023 | .channel_mode = alc883_sixstack_modes, | 9393 | .channel_mode = alc883_sixstack_modes, |
9024 | .input_mux = &alc883_capture_source, | 9394 | .input_mux = &alc883_capture_source, |
9025 | .unsol_event = alc888_6st_dell_unsol_event, | 9395 | .unsol_event = alc_automute_amp_unsol_event, |
9026 | .init_hook = alc888_6st_dell_front_automute, | 9396 | .init_hook = alc888_6st_dell_init_hook, |
9027 | }, | 9397 | }, |
9028 | [ALC883_MITAC] = { | 9398 | [ALC883_MITAC] = { |
9029 | .mixers = { alc883_mitac_mixer }, | 9399 | .mixers = { alc883_mitac_mixer }, |
@@ -9033,8 +9403,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9033 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 9403 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9034 | .channel_mode = alc883_3ST_2ch_modes, | 9404 | .channel_mode = alc883_3ST_2ch_modes, |
9035 | .input_mux = &alc883_capture_source, | 9405 | .input_mux = &alc883_capture_source, |
9036 | .unsol_event = alc883_mitac_unsol_event, | 9406 | .unsol_event = alc_automute_amp_unsol_event, |
9037 | .init_hook = alc883_mitac_automute, | 9407 | .init_hook = alc883_mitac_init_hook, |
9038 | }, | 9408 | }, |
9039 | [ALC883_FUJITSU_PI2515] = { | 9409 | [ALC883_FUJITSU_PI2515] = { |
9040 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, | 9410 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, |
@@ -9046,8 +9416,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9046 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | 9416 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
9047 | .channel_mode = alc883_3ST_2ch_modes, | 9417 | .channel_mode = alc883_3ST_2ch_modes, |
9048 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | 9418 | .input_mux = &alc883_fujitsu_pi2515_capture_source, |
9049 | .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, | 9419 | .unsol_event = alc_automute_amp_unsol_event, |
9050 | .init_hook = alc883_2ch_fujitsu_pi2515_automute, | 9420 | .init_hook = alc883_2ch_fujitsu_pi2515_init_hook, |
9051 | }, | 9421 | }, |
9052 | [ALC888_FUJITSU_XA3530] = { | 9422 | [ALC888_FUJITSU_XA3530] = { |
9053 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, | 9423 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, |
@@ -9064,8 +9434,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9064 | .num_mux_defs = | 9434 | .num_mux_defs = |
9065 | ARRAY_SIZE(alc888_2_capture_sources), | 9435 | ARRAY_SIZE(alc888_2_capture_sources), |
9066 | .input_mux = alc888_2_capture_sources, | 9436 | .input_mux = alc888_2_capture_sources, |
9067 | .unsol_event = alc888_fujitsu_xa3530_unsol_event, | 9437 | .unsol_event = alc_automute_amp_unsol_event, |
9068 | .init_hook = alc888_fujitsu_xa3530_automute, | 9438 | .init_hook = alc888_fujitsu_xa3530_init_hook, |
9069 | }, | 9439 | }, |
9070 | [ALC888_LENOVO_SKY] = { | 9440 | [ALC888_LENOVO_SKY] = { |
9071 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, | 9441 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, |
@@ -9077,8 +9447,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9077 | .channel_mode = alc883_sixstack_modes, | 9447 | .channel_mode = alc883_sixstack_modes, |
9078 | .need_dac_fix = 1, | 9448 | .need_dac_fix = 1, |
9079 | .input_mux = &alc883_lenovo_sky_capture_source, | 9449 | .input_mux = &alc883_lenovo_sky_capture_source, |
9080 | .unsol_event = alc883_lenovo_sky_unsol_event, | 9450 | .unsol_event = alc_automute_amp_unsol_event, |
9081 | .init_hook = alc888_lenovo_sky_front_automute, | 9451 | .init_hook = alc888_lenovo_sky_init_hook, |
9082 | }, | 9452 | }, |
9083 | [ALC888_ASUS_M90V] = { | 9453 | [ALC888_ASUS_M90V] = { |
9084 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 9454 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9106,7 +9476,7 @@ static struct alc_config_preset alc883_presets[] = { | |||
9106 | .channel_mode = alc883_3ST_2ch_modes, | 9476 | .channel_mode = alc883_3ST_2ch_modes, |
9107 | .need_dac_fix = 1, | 9477 | .need_dac_fix = 1, |
9108 | .input_mux = &alc883_asus_eee1601_capture_source, | 9478 | .input_mux = &alc883_asus_eee1601_capture_source, |
9109 | .unsol_event = alc883_eee1601_unsol_event, | 9479 | .unsol_event = alc_sku_unsol_event, |
9110 | .init_hook = alc883_eee1601_inithook, | 9480 | .init_hook = alc883_eee1601_inithook, |
9111 | }, | 9481 | }, |
9112 | [ALC1200_ASUS_P5Q] = { | 9482 | [ALC1200_ASUS_P5Q] = { |
@@ -9121,6 +9491,32 @@ static struct alc_config_preset alc883_presets[] = { | |||
9121 | .channel_mode = alc883_sixstack_modes, | 9491 | .channel_mode = alc883_sixstack_modes, |
9122 | .input_mux = &alc883_capture_source, | 9492 | .input_mux = &alc883_capture_source, |
9123 | }, | 9493 | }, |
9494 | [ALC889A_MB31] = { | ||
9495 | .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer}, | ||
9496 | .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs, | ||
9497 | alc880_gpio1_init_verbs }, | ||
9498 | .adc_nids = alc883_adc_nids, | ||
9499 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids), | ||
9500 | .dac_nids = alc883_dac_nids, | ||
9501 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9502 | .channel_mode = alc889A_mb31_6ch_modes, | ||
9503 | .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes), | ||
9504 | .input_mux = &alc889A_mb31_capture_source, | ||
9505 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9506 | .unsol_event = alc889A_mb31_unsol_event, | ||
9507 | .init_hook = alc889A_mb31_automute, | ||
9508 | }, | ||
9509 | [ALC883_SONY_VAIO_TT] = { | ||
9510 | .mixers = { alc883_vaiott_mixer }, | ||
9511 | .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs }, | ||
9512 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9513 | .dac_nids = alc883_dac_nids, | ||
9514 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | ||
9515 | .channel_mode = alc883_3ST_2ch_modes, | ||
9516 | .input_mux = &alc883_capture_source, | ||
9517 | .unsol_event = alc_automute_amp_unsol_event, | ||
9518 | .init_hook = alc883_vaiott_init_hook, | ||
9519 | }, | ||
9124 | }; | 9520 | }; |
9125 | 9521 | ||
9126 | 9522 | ||
@@ -9149,7 +9545,6 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec) | |||
9149 | struct alc_spec *spec = codec->spec; | 9545 | struct alc_spec *spec = codec->spec; |
9150 | int i; | 9546 | int i; |
9151 | 9547 | ||
9152 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | ||
9153 | for (i = 0; i <= HDA_SIDE; i++) { | 9548 | for (i = 0; i <= HDA_SIDE; i++) { |
9154 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | 9549 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
9155 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | 9550 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
@@ -9267,10 +9662,18 @@ static int patch_alc883(struct hda_codec *codec) | |||
9267 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, | 9662 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
9268 | alc883_models, | 9663 | alc883_models, |
9269 | alc883_cfg_tbl); | 9664 | alc883_cfg_tbl); |
9270 | if (board_config < 0) { | 9665 | if (board_config < 0 || board_config >= ALC883_MODEL_LAST) { |
9271 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " | 9666 | /* Pick up systems that don't supply PCI SSID */ |
9272 | "trying auto-probe from BIOS...\n"); | 9667 | switch (codec->subsystem_id) { |
9273 | board_config = ALC883_AUTO; | 9668 | case 0x106b3600: /* Macbook 3.1 */ |
9669 | board_config = ALC889A_MB31; | ||
9670 | break; | ||
9671 | default: | ||
9672 | printk(KERN_INFO | ||
9673 | "hda_codec: Unknown model for %s, trying " | ||
9674 | "auto-probe from BIOS...\n", codec->chip_name); | ||
9675 | board_config = ALC883_AUTO; | ||
9676 | } | ||
9274 | } | 9677 | } |
9275 | 9678 | ||
9276 | if (board_config == ALC883_AUTO) { | 9679 | if (board_config == ALC883_AUTO) { |
@@ -9298,13 +9701,6 @@ static int patch_alc883(struct hda_codec *codec) | |||
9298 | 9701 | ||
9299 | switch (codec->vendor_id) { | 9702 | switch (codec->vendor_id) { |
9300 | case 0x10ec0888: | 9703 | case 0x10ec0888: |
9301 | if (codec->revision_id == 0x100101) { | ||
9302 | spec->stream_name_analog = "ALC1200 Analog"; | ||
9303 | spec->stream_name_digital = "ALC1200 Digital"; | ||
9304 | } else { | ||
9305 | spec->stream_name_analog = "ALC888 Analog"; | ||
9306 | spec->stream_name_digital = "ALC888 Digital"; | ||
9307 | } | ||
9308 | if (!spec->num_adc_nids) { | 9704 | if (!spec->num_adc_nids) { |
9309 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | 9705 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); |
9310 | spec->adc_nids = alc883_adc_nids; | 9706 | spec->adc_nids = alc883_adc_nids; |
@@ -9312,10 +9708,9 @@ static int patch_alc883(struct hda_codec *codec) | |||
9312 | if (!spec->capsrc_nids) | 9708 | if (!spec->capsrc_nids) |
9313 | spec->capsrc_nids = alc883_capsrc_nids; | 9709 | spec->capsrc_nids = alc883_capsrc_nids; |
9314 | spec->capture_style = CAPT_MIX; /* matrix-style capture */ | 9710 | spec->capture_style = CAPT_MIX; /* matrix-style capture */ |
9711 | spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ | ||
9315 | break; | 9712 | break; |
9316 | case 0x10ec0889: | 9713 | case 0x10ec0889: |
9317 | spec->stream_name_analog = "ALC889 Analog"; | ||
9318 | spec->stream_name_digital = "ALC889 Digital"; | ||
9319 | if (!spec->num_adc_nids) { | 9714 | if (!spec->num_adc_nids) { |
9320 | spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids); | 9715 | spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids); |
9321 | spec->adc_nids = alc889_adc_nids; | 9716 | spec->adc_nids = alc889_adc_nids; |
@@ -9326,8 +9721,6 @@ static int patch_alc883(struct hda_codec *codec) | |||
9326 | capture */ | 9721 | capture */ |
9327 | break; | 9722 | break; |
9328 | default: | 9723 | default: |
9329 | spec->stream_name_analog = "ALC883 Analog"; | ||
9330 | spec->stream_name_digital = "ALC883 Digital"; | ||
9331 | if (!spec->num_adc_nids) { | 9724 | if (!spec->num_adc_nids) { |
9332 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | 9725 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); |
9333 | spec->adc_nids = alc883_adc_nids; | 9726 | spec->adc_nids = alc883_adc_nids; |
@@ -9407,24 +9800,6 @@ static struct snd_kcontrol_new alc262_base_mixer[] = { | |||
9407 | { } /* end */ | 9800 | { } /* end */ |
9408 | }; | 9801 | }; |
9409 | 9802 | ||
9410 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { | ||
9411 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
9412 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | ||
9413 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | ||
9414 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | ||
9415 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
9416 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
9417 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
9418 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
9419 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
9420 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | ||
9421 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | ||
9422 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | ||
9423 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ | ||
9424 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | ||
9425 | { } /* end */ | ||
9426 | }; | ||
9427 | |||
9428 | /* update HP, line and mono-out pins according to the master switch */ | 9803 | /* update HP, line and mono-out pins according to the master switch */ |
9429 | static void alc262_hp_master_update(struct hda_codec *codec) | 9804 | static void alc262_hp_master_update(struct hda_codec *codec) |
9430 | { | 9805 | { |
@@ -9480,14 +9855,7 @@ static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec, | |||
9480 | alc262_hp_wildwest_automute(codec); | 9855 | alc262_hp_wildwest_automute(codec); |
9481 | } | 9856 | } |
9482 | 9857 | ||
9483 | static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, | 9858 | #define alc262_hp_master_sw_get alc260_hp_master_sw_get |
9484 | struct snd_ctl_elem_value *ucontrol) | ||
9485 | { | ||
9486 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
9487 | struct alc_spec *spec = codec->spec; | ||
9488 | *ucontrol->value.integer.value = spec->master_sw; | ||
9489 | return 0; | ||
9490 | } | ||
9491 | 9859 | ||
9492 | static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, | 9860 | static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, |
9493 | struct snd_ctl_elem_value *ucontrol) | 9861 | struct snd_ctl_elem_value *ucontrol) |
@@ -9503,14 +9871,17 @@ static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |||
9503 | return 1; | 9871 | return 1; |
9504 | } | 9872 | } |
9505 | 9873 | ||
9874 | #define ALC262_HP_MASTER_SWITCH \ | ||
9875 | { \ | ||
9876 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
9877 | .name = "Master Playback Switch", \ | ||
9878 | .info = snd_ctl_boolean_mono_info, \ | ||
9879 | .get = alc262_hp_master_sw_get, \ | ||
9880 | .put = alc262_hp_master_sw_put, \ | ||
9881 | } | ||
9882 | |||
9506 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { | 9883 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
9507 | { | 9884 | ALC262_HP_MASTER_SWITCH, |
9508 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
9509 | .name = "Master Playback Switch", | ||
9510 | .info = snd_ctl_boolean_mono_info, | ||
9511 | .get = alc262_hp_master_sw_get, | ||
9512 | .put = alc262_hp_master_sw_put, | ||
9513 | }, | ||
9514 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 9885 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9515 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | 9886 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
9516 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | 9887 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
@@ -9534,13 +9905,7 @@ static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { | |||
9534 | }; | 9905 | }; |
9535 | 9906 | ||
9536 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { | 9907 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
9537 | { | 9908 | ALC262_HP_MASTER_SWITCH, |
9538 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
9539 | .name = "Master Playback Switch", | ||
9540 | .info = snd_ctl_boolean_mono_info, | ||
9541 | .get = alc262_hp_master_sw_get, | ||
9542 | .put = alc262_hp_master_sw_put, | ||
9543 | }, | ||
9544 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 9909 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9545 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | 9910 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
9546 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | 9911 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
@@ -9567,32 +9932,13 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |||
9567 | }; | 9932 | }; |
9568 | 9933 | ||
9569 | /* mute/unmute internal speaker according to the hp jack and mute state */ | 9934 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9570 | static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) | 9935 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) |
9571 | { | 9936 | { |
9572 | struct alc_spec *spec = codec->spec; | 9937 | struct alc_spec *spec = codec->spec; |
9573 | 9938 | ||
9574 | if (force || !spec->sense_updated) { | 9939 | spec->autocfg.hp_pins[0] = 0x15; |
9575 | unsigned int present; | 9940 | spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ |
9576 | present = snd_hda_codec_read(codec, 0x15, 0, | 9941 | alc_automute_amp(codec); |
9577 | AC_VERB_GET_PIN_SENSE, 0); | ||
9578 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | ||
9579 | spec->sense_updated = 1; | ||
9580 | } | ||
9581 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, | ||
9582 | spec->jack_present ? HDA_AMP_MUTE : 0); | ||
9583 | } | ||
9584 | |||
9585 | static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, | ||
9586 | unsigned int res) | ||
9587 | { | ||
9588 | if ((res >> 26) != ALC880_HP_EVENT) | ||
9589 | return; | ||
9590 | alc262_hp_t5735_automute(codec, 1); | ||
9591 | } | ||
9592 | |||
9593 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | ||
9594 | { | ||
9595 | alc262_hp_t5735_automute(codec, 1); | ||
9596 | } | 9942 | } |
9597 | 9943 | ||
9598 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | 9944 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { |
@@ -9645,46 +9991,132 @@ static struct hda_input_mux alc262_hp_rp5700_capture_source = { | |||
9645 | }, | 9991 | }, |
9646 | }; | 9992 | }; |
9647 | 9993 | ||
9648 | /* bind hp and internal speaker mute (with plug check) */ | 9994 | /* bind hp and internal speaker mute (with plug check) as master switch */ |
9649 | static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, | 9995 | static void alc262_hippo_master_update(struct hda_codec *codec) |
9650 | struct snd_ctl_elem_value *ucontrol) | ||
9651 | { | 9996 | { |
9652 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 9997 | struct alc_spec *spec = codec->spec; |
9653 | long *valp = ucontrol->value.integer.value; | 9998 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; |
9654 | int change; | 9999 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; |
10000 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | ||
10001 | unsigned int mute; | ||
9655 | 10002 | ||
9656 | /* change hp mute */ | 10003 | /* HP */ |
9657 | change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | 10004 | mute = spec->master_sw ? 0 : HDA_AMP_MUTE; |
9658 | HDA_AMP_MUTE, | 10005 | snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0, |
9659 | valp[0] ? 0 : HDA_AMP_MUTE); | 10006 | HDA_AMP_MUTE, mute); |
9660 | change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | 10007 | /* mute internal speaker per jack sense */ |
9661 | HDA_AMP_MUTE, | 10008 | if (spec->jack_present) |
9662 | valp[1] ? 0 : HDA_AMP_MUTE); | 10009 | mute = HDA_AMP_MUTE; |
9663 | if (change) { | 10010 | if (line_nid) |
9664 | /* change speaker according to HP jack state */ | 10011 | snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0, |
9665 | struct alc_spec *spec = codec->spec; | ||
9666 | unsigned int mute; | ||
9667 | if (spec->jack_present) | ||
9668 | mute = HDA_AMP_MUTE; | ||
9669 | else | ||
9670 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, | ||
9671 | HDA_OUTPUT, 0); | ||
9672 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
9673 | HDA_AMP_MUTE, mute); | 10012 | HDA_AMP_MUTE, mute); |
10013 | if (speaker_nid && speaker_nid != line_nid) | ||
10014 | snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0, | ||
10015 | HDA_AMP_MUTE, mute); | ||
10016 | } | ||
10017 | |||
10018 | #define alc262_hippo_master_sw_get alc262_hp_master_sw_get | ||
10019 | |||
10020 | static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol, | ||
10021 | struct snd_ctl_elem_value *ucontrol) | ||
10022 | { | ||
10023 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
10024 | struct alc_spec *spec = codec->spec; | ||
10025 | int val = !!*ucontrol->value.integer.value; | ||
10026 | |||
10027 | if (val == spec->master_sw) | ||
10028 | return 0; | ||
10029 | spec->master_sw = val; | ||
10030 | alc262_hippo_master_update(codec); | ||
10031 | return 1; | ||
10032 | } | ||
10033 | |||
10034 | #define ALC262_HIPPO_MASTER_SWITCH \ | ||
10035 | { \ | ||
10036 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
10037 | .name = "Master Playback Switch", \ | ||
10038 | .info = snd_ctl_boolean_mono_info, \ | ||
10039 | .get = alc262_hippo_master_sw_get, \ | ||
10040 | .put = alc262_hippo_master_sw_put, \ | ||
9674 | } | 10041 | } |
9675 | return change; | 10042 | |
10043 | static struct snd_kcontrol_new alc262_hippo_mixer[] = { | ||
10044 | ALC262_HIPPO_MASTER_SWITCH, | ||
10045 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
10046 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | ||
10047 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | ||
10048 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
10049 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
10050 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
10051 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
10052 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
10053 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | ||
10054 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | ||
10055 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | ||
10056 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
10057 | { } /* end */ | ||
10058 | }; | ||
10059 | |||
10060 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { | ||
10061 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
10062 | ALC262_HIPPO_MASTER_SWITCH, | ||
10063 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | ||
10064 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | ||
10065 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
10066 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
10067 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
10068 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
10069 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
10070 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | ||
10071 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | ||
10072 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | ||
10073 | { } /* end */ | ||
10074 | }; | ||
10075 | |||
10076 | /* mute/unmute internal speaker according to the hp jack and mute state */ | ||
10077 | static void alc262_hippo_automute(struct hda_codec *codec) | ||
10078 | { | ||
10079 | struct alc_spec *spec = codec->spec; | ||
10080 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | ||
10081 | unsigned int present; | ||
10082 | |||
10083 | /* need to execute and sync at first */ | ||
10084 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
10085 | present = snd_hda_codec_read(codec, hp_nid, 0, | ||
10086 | AC_VERB_GET_PIN_SENSE, 0); | ||
10087 | spec->jack_present = (present & 0x80000000) != 0; | ||
10088 | alc262_hippo_master_update(codec); | ||
10089 | } | ||
10090 | |||
10091 | static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res) | ||
10092 | { | ||
10093 | if ((res >> 26) != ALC880_HP_EVENT) | ||
10094 | return; | ||
10095 | alc262_hippo_automute(codec); | ||
10096 | } | ||
10097 | |||
10098 | static void alc262_hippo_init_hook(struct hda_codec *codec) | ||
10099 | { | ||
10100 | struct alc_spec *spec = codec->spec; | ||
10101 | |||
10102 | spec->autocfg.hp_pins[0] = 0x15; | ||
10103 | spec->autocfg.speaker_pins[0] = 0x14; | ||
10104 | alc262_hippo_automute(codec); | ||
10105 | } | ||
10106 | |||
10107 | static void alc262_hippo1_init_hook(struct hda_codec *codec) | ||
10108 | { | ||
10109 | struct alc_spec *spec = codec->spec; | ||
10110 | |||
10111 | spec->autocfg.hp_pins[0] = 0x1b; | ||
10112 | spec->autocfg.speaker_pins[0] = 0x14; | ||
10113 | alc262_hippo_automute(codec); | ||
9676 | } | 10114 | } |
9677 | 10115 | ||
10116 | |||
9678 | static struct snd_kcontrol_new alc262_sony_mixer[] = { | 10117 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
9679 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 10118 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9680 | { | 10119 | ALC262_HIPPO_MASTER_SWITCH, |
9681 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
9682 | .name = "Master Playback Switch", | ||
9683 | .info = snd_hda_mixer_amp_switch_info, | ||
9684 | .get = snd_hda_mixer_amp_switch_get, | ||
9685 | .put = alc262_sony_master_sw_put, | ||
9686 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | ||
9687 | }, | ||
9688 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | 10120 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
9689 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | 10121 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9690 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | 10122 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
@@ -9693,8 +10125,8 @@ static struct snd_kcontrol_new alc262_sony_mixer[] = { | |||
9693 | }; | 10125 | }; |
9694 | 10126 | ||
9695 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { | 10127 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
9696 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 10128 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9697 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 10129 | ALC262_HIPPO_MASTER_SWITCH, |
9698 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | 10130 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
9699 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | 10131 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
9700 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | 10132 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
@@ -9735,34 +10167,15 @@ static struct hda_verb alc262_tyan_verbs[] = { | |||
9735 | }; | 10167 | }; |
9736 | 10168 | ||
9737 | /* unsolicited event for HP jack sensing */ | 10169 | /* unsolicited event for HP jack sensing */ |
9738 | static void alc262_tyan_automute(struct hda_codec *codec) | 10170 | static void alc262_tyan_init_hook(struct hda_codec *codec) |
9739 | { | 10171 | { |
9740 | unsigned int mute; | 10172 | struct alc_spec *spec = codec->spec; |
9741 | unsigned int present; | ||
9742 | 10173 | ||
9743 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | 10174 | spec->autocfg.hp_pins[0] = 0x1b; |
9744 | present = snd_hda_codec_read(codec, 0x1b, 0, | 10175 | spec->autocfg.speaker_pins[0] = 0x15; |
9745 | AC_VERB_GET_PIN_SENSE, 0); | 10176 | alc_automute_amp(codec); |
9746 | present = (present & 0x80000000) != 0; | ||
9747 | if (present) { | ||
9748 | /* mute line output on ATX panel */ | ||
9749 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
9750 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
9751 | } else { | ||
9752 | /* unmute line output if necessary */ | ||
9753 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | ||
9754 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | ||
9755 | HDA_AMP_MUTE, mute); | ||
9756 | } | ||
9757 | } | 10177 | } |
9758 | 10178 | ||
9759 | static void alc262_tyan_unsol_event(struct hda_codec *codec, | ||
9760 | unsigned int res) | ||
9761 | { | ||
9762 | if ((res >> 26) != ALC880_HP_EVENT) | ||
9763 | return; | ||
9764 | alc262_tyan_automute(codec); | ||
9765 | } | ||
9766 | 10179 | ||
9767 | #define alc262_capture_mixer alc882_capture_mixer | 10180 | #define alc262_capture_mixer alc882_capture_mixer |
9768 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | 10181 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer |
@@ -9917,99 +10330,25 @@ static void alc262_dmic_automute(struct hda_codec *codec) | |||
9917 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); | 10330 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); |
9918 | } | 10331 | } |
9919 | 10332 | ||
9920 | /* toggle speaker-output according to the hp-jack state */ | ||
9921 | static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec) | ||
9922 | { | ||
9923 | unsigned int present; | ||
9924 | unsigned char bits; | ||
9925 | |||
9926 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
9927 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
9928 | bits = present ? 0 : PIN_OUT; | ||
9929 | snd_hda_codec_write(codec, 0x14, 0, | ||
9930 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | ||
9931 | } | ||
9932 | |||
9933 | |||
9934 | 10333 | ||
9935 | /* unsolicited event for HP jack sensing */ | 10334 | /* unsolicited event for HP jack sensing */ |
9936 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, | 10335 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, |
9937 | unsigned int res) | 10336 | unsigned int res) |
9938 | { | 10337 | { |
9939 | if ((res >> 26) == ALC880_HP_EVENT) | ||
9940 | alc262_toshiba_s06_speaker_automute(codec); | ||
9941 | if ((res >> 26) == ALC880_MIC_EVENT) | 10338 | if ((res >> 26) == ALC880_MIC_EVENT) |
9942 | alc262_dmic_automute(codec); | 10339 | alc262_dmic_automute(codec); |
9943 | 10340 | else | |
10341 | alc_sku_unsol_event(codec, res); | ||
9944 | } | 10342 | } |
9945 | 10343 | ||
9946 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) | 10344 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) |
9947 | { | 10345 | { |
9948 | alc262_toshiba_s06_speaker_automute(codec); | ||
9949 | alc262_dmic_automute(codec); | ||
9950 | } | ||
9951 | |||
9952 | /* mute/unmute internal speaker according to the hp jack and mute state */ | ||
9953 | static void alc262_hippo_automute(struct hda_codec *codec) | ||
9954 | { | ||
9955 | struct alc_spec *spec = codec->spec; | 10346 | struct alc_spec *spec = codec->spec; |
9956 | unsigned int mute; | ||
9957 | unsigned int present; | ||
9958 | |||
9959 | /* need to execute and sync at first */ | ||
9960 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
9961 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
9962 | AC_VERB_GET_PIN_SENSE, 0); | ||
9963 | spec->jack_present = (present & 0x80000000) != 0; | ||
9964 | if (spec->jack_present) { | ||
9965 | /* mute internal speaker */ | ||
9966 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
9967 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
9968 | } else { | ||
9969 | /* unmute internal speaker if necessary */ | ||
9970 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | ||
9971 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
9972 | HDA_AMP_MUTE, mute); | ||
9973 | } | ||
9974 | } | ||
9975 | |||
9976 | /* unsolicited event for HP jack sensing */ | ||
9977 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | ||
9978 | unsigned int res) | ||
9979 | { | ||
9980 | if ((res >> 26) != ALC880_HP_EVENT) | ||
9981 | return; | ||
9982 | alc262_hippo_automute(codec); | ||
9983 | } | ||
9984 | |||
9985 | static void alc262_hippo1_automute(struct hda_codec *codec) | ||
9986 | { | ||
9987 | unsigned int mute; | ||
9988 | unsigned int present; | ||
9989 | 10347 | ||
9990 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | 10348 | spec->autocfg.hp_pins[0] = 0x15; |
9991 | present = snd_hda_codec_read(codec, 0x1b, 0, | 10349 | spec->autocfg.speaker_pins[0] = 0x14; |
9992 | AC_VERB_GET_PIN_SENSE, 0); | 10350 | alc_automute_pin(codec); |
9993 | present = (present & 0x80000000) != 0; | 10351 | alc262_dmic_automute(codec); |
9994 | if (present) { | ||
9995 | /* mute internal speaker */ | ||
9996 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
9997 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
9998 | } else { | ||
9999 | /* unmute internal speaker if necessary */ | ||
10000 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | ||
10001 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
10002 | HDA_AMP_MUTE, mute); | ||
10003 | } | ||
10004 | } | ||
10005 | |||
10006 | /* unsolicited event for HP jack sensing */ | ||
10007 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | ||
10008 | unsigned int res) | ||
10009 | { | ||
10010 | if ((res >> 26) != ALC880_HP_EVENT) | ||
10011 | return; | ||
10012 | alc262_hippo1_automute(codec); | ||
10013 | } | 10352 | } |
10014 | 10353 | ||
10015 | /* | 10354 | /* |
@@ -10279,14 +10618,7 @@ static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { | |||
10279 | 10618 | ||
10280 | static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = { | 10619 | static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = { |
10281 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | 10620 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), |
10282 | { | 10621 | ALC262_HIPPO_MASTER_SWITCH, |
10283 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
10284 | .name = "Master Playback Switch", | ||
10285 | .info = snd_hda_mixer_amp_switch_info, | ||
10286 | .get = snd_hda_mixer_amp_switch_get, | ||
10287 | .put = alc262_sony_master_sw_put, | ||
10288 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | ||
10289 | }, | ||
10290 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | 10622 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
10291 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | 10623 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
10292 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | 10624 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
@@ -10633,31 +10965,46 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = { | |||
10633 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | 10965 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
10634 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | 10966 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
10635 | 10967 | ||
10636 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | 10968 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, |
10637 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | 10969 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, |
10638 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | 10970 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, |
10639 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | 10971 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, |
10640 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | 10972 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, |
10641 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | 10973 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, |
10642 | 10974 | ||
10643 | 10975 | ||
10644 | /* FIXME: use matrix-type input source selection */ | 10976 | /* FIXME: use matrix-type input source selection */ |
10645 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | 10977 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */ |
10646 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | 10978 | /* Input mixer1: only unmute Mic */ |
10647 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 10979 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
10648 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | 10980 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, |
10649 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | 10981 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
10650 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | 10982 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
10983 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | ||
10984 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))}, | ||
10985 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))}, | ||
10986 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))}, | ||
10987 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))}, | ||
10651 | /* Input mixer2 */ | 10988 | /* Input mixer2 */ |
10652 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 10989 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
10653 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | 10990 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, |
10654 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | 10991 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
10655 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | 10992 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
10993 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | ||
10994 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))}, | ||
10995 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))}, | ||
10996 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))}, | ||
10997 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))}, | ||
10656 | /* Input mixer3 */ | 10998 | /* Input mixer3 */ |
10657 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 10999 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
10658 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | 11000 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, |
10659 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | 11001 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, |
10660 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | 11002 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
11003 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | ||
11004 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))}, | ||
11005 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))}, | ||
11006 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))}, | ||
11007 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))}, | ||
10661 | 11008 | ||
10662 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | 11009 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10663 | 11010 | ||
@@ -10837,6 +11184,8 @@ static int alc262_parse_auto_config(struct hda_codec *codec) | |||
10837 | if (err < 0) | 11184 | if (err < 0) |
10838 | return err; | 11185 | return err; |
10839 | 11186 | ||
11187 | alc_ssid_check(codec, 0x15, 0x14, 0x1b); | ||
11188 | |||
10840 | return 1; | 11189 | return 1; |
10841 | } | 11190 | } |
10842 | 11191 | ||
@@ -10939,7 +11288,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
10939 | .input_mux = &alc262_capture_source, | 11288 | .input_mux = &alc262_capture_source, |
10940 | }, | 11289 | }, |
10941 | [ALC262_HIPPO] = { | 11290 | [ALC262_HIPPO] = { |
10942 | .mixers = { alc262_base_mixer }, | 11291 | .mixers = { alc262_hippo_mixer }, |
10943 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | 11292 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, |
10944 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | 11293 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10945 | .dac_nids = alc262_dac_nids, | 11294 | .dac_nids = alc262_dac_nids, |
@@ -10949,7 +11298,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
10949 | .channel_mode = alc262_modes, | 11298 | .channel_mode = alc262_modes, |
10950 | .input_mux = &alc262_capture_source, | 11299 | .input_mux = &alc262_capture_source, |
10951 | .unsol_event = alc262_hippo_unsol_event, | 11300 | .unsol_event = alc262_hippo_unsol_event, |
10952 | .init_hook = alc262_hippo_automute, | 11301 | .init_hook = alc262_hippo_init_hook, |
10953 | }, | 11302 | }, |
10954 | [ALC262_HIPPO_1] = { | 11303 | [ALC262_HIPPO_1] = { |
10955 | .mixers = { alc262_hippo1_mixer }, | 11304 | .mixers = { alc262_hippo1_mixer }, |
@@ -10961,8 +11310,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
10961 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | 11310 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
10962 | .channel_mode = alc262_modes, | 11311 | .channel_mode = alc262_modes, |
10963 | .input_mux = &alc262_capture_source, | 11312 | .input_mux = &alc262_capture_source, |
10964 | .unsol_event = alc262_hippo1_unsol_event, | 11313 | .unsol_event = alc262_hippo_unsol_event, |
10965 | .init_hook = alc262_hippo1_automute, | 11314 | .init_hook = alc262_hippo1_init_hook, |
10966 | }, | 11315 | }, |
10967 | [ALC262_FUJITSU] = { | 11316 | [ALC262_FUJITSU] = { |
10968 | .mixers = { alc262_fujitsu_mixer }, | 11317 | .mixers = { alc262_fujitsu_mixer }, |
@@ -11024,7 +11373,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
11024 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | 11373 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
11025 | .channel_mode = alc262_modes, | 11374 | .channel_mode = alc262_modes, |
11026 | .input_mux = &alc262_capture_source, | 11375 | .input_mux = &alc262_capture_source, |
11027 | .unsol_event = alc262_hp_t5735_unsol_event, | 11376 | .unsol_event = alc_automute_amp_unsol_event, |
11028 | .init_hook = alc262_hp_t5735_init_hook, | 11377 | .init_hook = alc262_hp_t5735_init_hook, |
11029 | }, | 11378 | }, |
11030 | [ALC262_HP_RP5700] = { | 11379 | [ALC262_HP_RP5700] = { |
@@ -11056,7 +11405,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
11056 | .channel_mode = alc262_modes, | 11405 | .channel_mode = alc262_modes, |
11057 | .input_mux = &alc262_capture_source, | 11406 | .input_mux = &alc262_capture_source, |
11058 | .unsol_event = alc262_hippo_unsol_event, | 11407 | .unsol_event = alc262_hippo_unsol_event, |
11059 | .init_hook = alc262_hippo_automute, | 11408 | .init_hook = alc262_hippo_init_hook, |
11060 | }, | 11409 | }, |
11061 | [ALC262_BENQ_T31] = { | 11410 | [ALC262_BENQ_T31] = { |
11062 | .mixers = { alc262_benq_t31_mixer }, | 11411 | .mixers = { alc262_benq_t31_mixer }, |
@@ -11068,7 +11417,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
11068 | .channel_mode = alc262_modes, | 11417 | .channel_mode = alc262_modes, |
11069 | .input_mux = &alc262_capture_source, | 11418 | .input_mux = &alc262_capture_source, |
11070 | .unsol_event = alc262_hippo_unsol_event, | 11419 | .unsol_event = alc262_hippo_unsol_event, |
11071 | .init_hook = alc262_hippo_automute, | 11420 | .init_hook = alc262_hippo_init_hook, |
11072 | }, | 11421 | }, |
11073 | [ALC262_ULTRA] = { | 11422 | [ALC262_ULTRA] = { |
11074 | .mixers = { alc262_ultra_mixer }, | 11423 | .mixers = { alc262_ultra_mixer }, |
@@ -11133,7 +11482,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
11133 | .channel_mode = alc262_modes, | 11482 | .channel_mode = alc262_modes, |
11134 | .input_mux = &alc262_capture_source, | 11483 | .input_mux = &alc262_capture_source, |
11135 | .unsol_event = alc262_hippo_unsol_event, | 11484 | .unsol_event = alc262_hippo_unsol_event, |
11136 | .init_hook = alc262_hippo_automute, | 11485 | .init_hook = alc262_hippo_init_hook, |
11137 | }, | 11486 | }, |
11138 | [ALC262_TYAN] = { | 11487 | [ALC262_TYAN] = { |
11139 | .mixers = { alc262_tyan_mixer }, | 11488 | .mixers = { alc262_tyan_mixer }, |
@@ -11145,8 +11494,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11145 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | 11494 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
11146 | .channel_mode = alc262_modes, | 11495 | .channel_mode = alc262_modes, |
11147 | .input_mux = &alc262_capture_source, | 11496 | .input_mux = &alc262_capture_source, |
11148 | .unsol_event = alc262_tyan_unsol_event, | 11497 | .unsol_event = alc_automute_amp_unsol_event, |
11149 | .init_hook = alc262_tyan_automute, | 11498 | .init_hook = alc262_tyan_init_hook, |
11150 | }, | 11499 | }, |
11151 | }; | 11500 | }; |
11152 | 11501 | ||
@@ -11181,8 +11530,8 @@ static int patch_alc262(struct hda_codec *codec) | |||
11181 | alc262_cfg_tbl); | 11530 | alc262_cfg_tbl); |
11182 | 11531 | ||
11183 | if (board_config < 0) { | 11532 | if (board_config < 0) { |
11184 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " | 11533 | printk(KERN_INFO "hda_codec: Unknown model for %s, " |
11185 | "trying auto-probe from BIOS...\n"); | 11534 | "trying auto-probe from BIOS...\n", codec->chip_name); |
11186 | board_config = ALC262_AUTO; | 11535 | board_config = ALC262_AUTO; |
11187 | } | 11536 | } |
11188 | 11537 | ||
@@ -11211,11 +11560,9 @@ static int patch_alc262(struct hda_codec *codec) | |||
11211 | if (board_config != ALC262_AUTO) | 11560 | if (board_config != ALC262_AUTO) |
11212 | setup_preset(spec, &alc262_presets[board_config]); | 11561 | setup_preset(spec, &alc262_presets[board_config]); |
11213 | 11562 | ||
11214 | spec->stream_name_analog = "ALC262 Analog"; | ||
11215 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | 11563 | spec->stream_analog_playback = &alc262_pcm_analog_playback; |
11216 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | 11564 | spec->stream_analog_capture = &alc262_pcm_analog_capture; |
11217 | 11565 | ||
11218 | spec->stream_name_digital = "ALC262 Digital"; | ||
11219 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | 11566 | spec->stream_digital_playback = &alc262_pcm_digital_playback; |
11220 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | 11567 | spec->stream_digital_capture = &alc262_pcm_digital_capture; |
11221 | 11568 | ||
@@ -11290,6 +11637,17 @@ static struct snd_kcontrol_new alc268_base_mixer[] = { | |||
11290 | { } | 11637 | { } |
11291 | }; | 11638 | }; |
11292 | 11639 | ||
11640 | static struct snd_kcontrol_new alc268_toshiba_mixer[] = { | ||
11641 | /* output mixer control */ | ||
11642 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | ||
11643 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | ||
11644 | ALC262_HIPPO_MASTER_SWITCH, | ||
11645 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
11646 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | ||
11647 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | ||
11648 | { } | ||
11649 | }; | ||
11650 | |||
11293 | /* bind Beep switches of both NID 0x0f and 0x10 */ | 11651 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
11294 | static struct hda_bind_ctls alc268_bind_beep_sw = { | 11652 | static struct hda_bind_ctls alc268_bind_beep_sw = { |
11295 | .ops = &snd_hda_bind_sw, | 11653 | .ops = &snd_hda_bind_sw, |
@@ -11313,8 +11671,6 @@ static struct hda_verb alc268_eapd_verbs[] = { | |||
11313 | }; | 11671 | }; |
11314 | 11672 | ||
11315 | /* Toshiba specific */ | 11673 | /* Toshiba specific */ |
11316 | #define alc268_toshiba_automute alc262_hippo_automute | ||
11317 | |||
11318 | static struct hda_verb alc268_toshiba_verbs[] = { | 11674 | static struct hda_verb alc268_toshiba_verbs[] = { |
11319 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | 11675 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
11320 | { } /* end */ | 11676 | { } /* end */ |
@@ -11450,13 +11806,8 @@ static struct hda_verb alc268_acer_verbs[] = { | |||
11450 | }; | 11806 | }; |
11451 | 11807 | ||
11452 | /* unsolicited event for HP jack sensing */ | 11808 | /* unsolicited event for HP jack sensing */ |
11453 | static void alc268_toshiba_unsol_event(struct hda_codec *codec, | 11809 | #define alc268_toshiba_unsol_event alc262_hippo_unsol_event |
11454 | unsigned int res) | 11810 | #define alc268_toshiba_init_hook alc262_hippo_init_hook |
11455 | { | ||
11456 | if ((res >> 26) != ALC880_HP_EVENT) | ||
11457 | return; | ||
11458 | alc268_toshiba_automute(codec); | ||
11459 | } | ||
11460 | 11811 | ||
11461 | static void alc268_acer_unsol_event(struct hda_codec *codec, | 11812 | static void alc268_acer_unsol_event(struct hda_codec *codec, |
11462 | unsigned int res) | 11813 | unsigned int res) |
@@ -11531,30 +11882,15 @@ static struct hda_verb alc268_dell_verbs[] = { | |||
11531 | }; | 11882 | }; |
11532 | 11883 | ||
11533 | /* mute/unmute internal speaker according to the hp jack and mute state */ | 11884 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
11534 | static void alc268_dell_automute(struct hda_codec *codec) | 11885 | static void alc268_dell_init_hook(struct hda_codec *codec) |
11535 | { | 11886 | { |
11536 | unsigned int present; | 11887 | struct alc_spec *spec = codec->spec; |
11537 | unsigned int mute; | ||
11538 | |||
11539 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); | ||
11540 | if (present & 0x80000000) | ||
11541 | mute = HDA_AMP_MUTE; | ||
11542 | else | ||
11543 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | ||
11544 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
11545 | HDA_AMP_MUTE, mute); | ||
11546 | } | ||
11547 | 11888 | ||
11548 | static void alc268_dell_unsol_event(struct hda_codec *codec, | 11889 | spec->autocfg.hp_pins[0] = 0x15; |
11549 | unsigned int res) | 11890 | spec->autocfg.speaker_pins[0] = 0x14; |
11550 | { | 11891 | alc_automute_pin(codec); |
11551 | if ((res >> 26) != ALC880_HP_EVENT) | ||
11552 | return; | ||
11553 | alc268_dell_automute(codec); | ||
11554 | } | 11892 | } |
11555 | 11893 | ||
11556 | #define alc268_dell_init_hook alc268_dell_automute | ||
11557 | |||
11558 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { | 11894 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { |
11559 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), | 11895 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), |
11560 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 11896 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
@@ -11573,16 +11909,6 @@ static struct hda_verb alc267_quanta_il1_verbs[] = { | |||
11573 | { } | 11909 | { } |
11574 | }; | 11910 | }; |
11575 | 11911 | ||
11576 | static void alc267_quanta_il1_hp_automute(struct hda_codec *codec) | ||
11577 | { | ||
11578 | unsigned int present; | ||
11579 | |||
11580 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
11581 | & AC_PINSENSE_PRESENCE; | ||
11582 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
11583 | present ? 0 : PIN_OUT); | ||
11584 | } | ||
11585 | |||
11586 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | 11912 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) |
11587 | { | 11913 | { |
11588 | unsigned int present; | 11914 | unsigned int present; |
@@ -11594,9 +11920,13 @@ static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | |||
11594 | present ? 0x00 : 0x01); | 11920 | present ? 0x00 : 0x01); |
11595 | } | 11921 | } |
11596 | 11922 | ||
11597 | static void alc267_quanta_il1_automute(struct hda_codec *codec) | 11923 | static void alc267_quanta_il1_init_hook(struct hda_codec *codec) |
11598 | { | 11924 | { |
11599 | alc267_quanta_il1_hp_automute(codec); | 11925 | struct alc_spec *spec = codec->spec; |
11926 | |||
11927 | spec->autocfg.hp_pins[0] = 0x15; | ||
11928 | spec->autocfg.speaker_pins[0] = 0x14; | ||
11929 | alc_automute_pin(codec); | ||
11600 | alc267_quanta_il1_mic_automute(codec); | 11930 | alc267_quanta_il1_mic_automute(codec); |
11601 | } | 11931 | } |
11602 | 11932 | ||
@@ -11604,12 +11934,12 @@ static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, | |||
11604 | unsigned int res) | 11934 | unsigned int res) |
11605 | { | 11935 | { |
11606 | switch (res >> 26) { | 11936 | switch (res >> 26) { |
11607 | case ALC880_HP_EVENT: | ||
11608 | alc267_quanta_il1_hp_automute(codec); | ||
11609 | break; | ||
11610 | case ALC880_MIC_EVENT: | 11937 | case ALC880_MIC_EVENT: |
11611 | alc267_quanta_il1_mic_automute(codec); | 11938 | alc267_quanta_il1_mic_automute(codec); |
11612 | break; | 11939 | break; |
11940 | default: | ||
11941 | alc_sku_unsol_event(codec, res); | ||
11942 | break; | ||
11613 | } | 11943 | } |
11614 | } | 11944 | } |
11615 | 11945 | ||
@@ -12057,15 +12387,16 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = { | |||
12057 | ALC268_ACER_ASPIRE_ONE), | 12387 | ALC268_ACER_ASPIRE_ONE), |
12058 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), | 12388 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
12059 | SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), | 12389 | SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), |
12060 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), | 12390 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series", |
12391 | ALC268_TOSHIBA), | ||
12061 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), | 12392 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
12062 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), | 12393 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), |
12063 | SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), | 12394 | SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05", |
12064 | SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA), | 12395 | ALC268_TOSHIBA), |
12065 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), | 12396 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), |
12066 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), | 12397 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
12067 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), | 12398 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), |
12068 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), | 12399 | SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL), |
12069 | {} | 12400 | {} |
12070 | }; | 12401 | }; |
12071 | 12402 | ||
@@ -12083,7 +12414,7 @@ static struct alc_config_preset alc268_presets[] = { | |||
12083 | .channel_mode = alc268_modes, | 12414 | .channel_mode = alc268_modes, |
12084 | .input_mux = &alc268_capture_source, | 12415 | .input_mux = &alc268_capture_source, |
12085 | .unsol_event = alc267_quanta_il1_unsol_event, | 12416 | .unsol_event = alc267_quanta_il1_unsol_event, |
12086 | .init_hook = alc267_quanta_il1_automute, | 12417 | .init_hook = alc267_quanta_il1_init_hook, |
12087 | }, | 12418 | }, |
12088 | [ALC268_3ST] = { | 12419 | [ALC268_3ST] = { |
12089 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, | 12420 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
@@ -12101,7 +12432,7 @@ static struct alc_config_preset alc268_presets[] = { | |||
12101 | .input_mux = &alc268_capture_source, | 12432 | .input_mux = &alc268_capture_source, |
12102 | }, | 12433 | }, |
12103 | [ALC268_TOSHIBA] = { | 12434 | [ALC268_TOSHIBA] = { |
12104 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, | 12435 | .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer, |
12105 | alc268_beep_mixer }, | 12436 | alc268_beep_mixer }, |
12106 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | 12437 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12107 | alc268_toshiba_verbs }, | 12438 | alc268_toshiba_verbs }, |
@@ -12115,7 +12446,7 @@ static struct alc_config_preset alc268_presets[] = { | |||
12115 | .channel_mode = alc268_modes, | 12446 | .channel_mode = alc268_modes, |
12116 | .input_mux = &alc268_capture_source, | 12447 | .input_mux = &alc268_capture_source, |
12117 | .unsol_event = alc268_toshiba_unsol_event, | 12448 | .unsol_event = alc268_toshiba_unsol_event, |
12118 | .init_hook = alc268_toshiba_automute, | 12449 | .init_hook = alc268_toshiba_init_hook, |
12119 | }, | 12450 | }, |
12120 | [ALC268_ACER] = { | 12451 | [ALC268_ACER] = { |
12121 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, | 12452 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, |
@@ -12178,7 +12509,7 @@ static struct alc_config_preset alc268_presets[] = { | |||
12178 | .hp_nid = 0x02, | 12509 | .hp_nid = 0x02, |
12179 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | 12510 | .num_channel_mode = ARRAY_SIZE(alc268_modes), |
12180 | .channel_mode = alc268_modes, | 12511 | .channel_mode = alc268_modes, |
12181 | .unsol_event = alc268_dell_unsol_event, | 12512 | .unsol_event = alc_sku_unsol_event, |
12182 | .init_hook = alc268_dell_init_hook, | 12513 | .init_hook = alc268_dell_init_hook, |
12183 | .input_mux = &alc268_capture_source, | 12514 | .input_mux = &alc268_capture_source, |
12184 | }, | 12515 | }, |
@@ -12198,7 +12529,7 @@ static struct alc_config_preset alc268_presets[] = { | |||
12198 | .channel_mode = alc268_modes, | 12529 | .channel_mode = alc268_modes, |
12199 | .input_mux = &alc268_capture_source, | 12530 | .input_mux = &alc268_capture_source, |
12200 | .unsol_event = alc268_toshiba_unsol_event, | 12531 | .unsol_event = alc268_toshiba_unsol_event, |
12201 | .init_hook = alc268_toshiba_automute | 12532 | .init_hook = alc268_toshiba_init_hook |
12202 | }, | 12533 | }, |
12203 | #ifdef CONFIG_SND_DEBUG | 12534 | #ifdef CONFIG_SND_DEBUG |
12204 | [ALC268_TEST] = { | 12535 | [ALC268_TEST] = { |
@@ -12236,8 +12567,8 @@ static int patch_alc268(struct hda_codec *codec) | |||
12236 | alc268_cfg_tbl); | 12567 | alc268_cfg_tbl); |
12237 | 12568 | ||
12238 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | 12569 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { |
12239 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | 12570 | printk(KERN_INFO "hda_codec: Unknown model for %s, " |
12240 | "trying auto-probe from BIOS...\n"); | 12571 | "trying auto-probe from BIOS...\n", codec->chip_name); |
12241 | board_config = ALC268_AUTO; | 12572 | board_config = ALC268_AUTO; |
12242 | } | 12573 | } |
12243 | 12574 | ||
@@ -12258,14 +12589,6 @@ static int patch_alc268(struct hda_codec *codec) | |||
12258 | if (board_config != ALC268_AUTO) | 12589 | if (board_config != ALC268_AUTO) |
12259 | setup_preset(spec, &alc268_presets[board_config]); | 12590 | setup_preset(spec, &alc268_presets[board_config]); |
12260 | 12591 | ||
12261 | if (codec->vendor_id == 0x10ec0267) { | ||
12262 | spec->stream_name_analog = "ALC267 Analog"; | ||
12263 | spec->stream_name_digital = "ALC267 Digital"; | ||
12264 | } else { | ||
12265 | spec->stream_name_analog = "ALC268 Analog"; | ||
12266 | spec->stream_name_digital = "ALC268 Digital"; | ||
12267 | } | ||
12268 | |||
12269 | spec->stream_analog_playback = &alc268_pcm_analog_playback; | 12592 | spec->stream_analog_playback = &alc268_pcm_analog_playback; |
12270 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | 12593 | spec->stream_analog_capture = &alc268_pcm_analog_capture; |
12271 | spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; | 12594 | spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; |
@@ -13092,8 +13415,8 @@ static int patch_alc269(struct hda_codec *codec) | |||
13092 | alc269_cfg_tbl); | 13415 | alc269_cfg_tbl); |
13093 | 13416 | ||
13094 | if (board_config < 0) { | 13417 | if (board_config < 0) { |
13095 | printk(KERN_INFO "hda_codec: Unknown model for ALC269, " | 13418 | printk(KERN_INFO "hda_codec: Unknown model for %s, " |
13096 | "trying auto-probe from BIOS...\n"); | 13419 | "trying auto-probe from BIOS...\n", codec->chip_name); |
13097 | board_config = ALC269_AUTO; | 13420 | board_config = ALC269_AUTO; |
13098 | } | 13421 | } |
13099 | 13422 | ||
@@ -13120,7 +13443,6 @@ static int patch_alc269(struct hda_codec *codec) | |||
13120 | if (board_config != ALC269_AUTO) | 13443 | if (board_config != ALC269_AUTO) |
13121 | setup_preset(spec, &alc269_presets[board_config]); | 13444 | setup_preset(spec, &alc269_presets[board_config]); |
13122 | 13445 | ||
13123 | spec->stream_name_analog = "ALC269 Analog"; | ||
13124 | if (codec->subsystem_id == 0x17aa3bf8) { | 13446 | if (codec->subsystem_id == 0x17aa3bf8) { |
13125 | /* Due to a hardware problem on Lenovo Ideadpad, we need to | 13447 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
13126 | * fix the sample rate of analog I/O to 44.1kHz | 13448 | * fix the sample rate of analog I/O to 44.1kHz |
@@ -13131,7 +13453,6 @@ static int patch_alc269(struct hda_codec *codec) | |||
13131 | spec->stream_analog_playback = &alc269_pcm_analog_playback; | 13453 | spec->stream_analog_playback = &alc269_pcm_analog_playback; |
13132 | spec->stream_analog_capture = &alc269_pcm_analog_capture; | 13454 | spec->stream_analog_capture = &alc269_pcm_analog_capture; |
13133 | } | 13455 | } |
13134 | spec->stream_name_digital = "ALC269 Digital"; | ||
13135 | spec->stream_digital_playback = &alc269_pcm_digital_playback; | 13456 | spec->stream_digital_playback = &alc269_pcm_digital_playback; |
13136 | spec->stream_digital_capture = &alc269_pcm_digital_capture; | 13457 | spec->stream_digital_capture = &alc269_pcm_digital_capture; |
13137 | 13458 | ||
@@ -13920,7 +14241,6 @@ static void alc861_auto_init_multi_out(struct hda_codec *codec) | |||
13920 | struct alc_spec *spec = codec->spec; | 14241 | struct alc_spec *spec = codec->spec; |
13921 | int i; | 14242 | int i; |
13922 | 14243 | ||
13923 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); | ||
13924 | for (i = 0; i < spec->autocfg.line_outs; i++) { | 14244 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
13925 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | 14245 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
13926 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | 14246 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
@@ -14003,6 +14323,8 @@ static int alc861_parse_auto_config(struct hda_codec *codec) | |||
14003 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | 14323 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); |
14004 | set_capture_mixer(spec); | 14324 | set_capture_mixer(spec); |
14005 | 14325 | ||
14326 | alc_ssid_check(codec, 0x0e, 0x0f, 0x0b); | ||
14327 | |||
14006 | return 1; | 14328 | return 1; |
14007 | } | 14329 | } |
14008 | 14330 | ||
@@ -14192,8 +14514,8 @@ static int patch_alc861(struct hda_codec *codec) | |||
14192 | alc861_cfg_tbl); | 14514 | alc861_cfg_tbl); |
14193 | 14515 | ||
14194 | if (board_config < 0) { | 14516 | if (board_config < 0) { |
14195 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " | 14517 | printk(KERN_INFO "hda_codec: Unknown model for %s, " |
14196 | "trying auto-probe from BIOS...\n"); | 14518 | "trying auto-probe from BIOS...\n", codec->chip_name); |
14197 | board_config = ALC861_AUTO; | 14519 | board_config = ALC861_AUTO; |
14198 | } | 14520 | } |
14199 | 14521 | ||
@@ -14220,11 +14542,9 @@ static int patch_alc861(struct hda_codec *codec) | |||
14220 | if (board_config != ALC861_AUTO) | 14542 | if (board_config != ALC861_AUTO) |
14221 | setup_preset(spec, &alc861_presets[board_config]); | 14543 | setup_preset(spec, &alc861_presets[board_config]); |
14222 | 14544 | ||
14223 | spec->stream_name_analog = "ALC861 Analog"; | ||
14224 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | 14545 | spec->stream_analog_playback = &alc861_pcm_analog_playback; |
14225 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | 14546 | spec->stream_analog_capture = &alc861_pcm_analog_capture; |
14226 | 14547 | ||
14227 | spec->stream_name_digital = "ALC861 Digital"; | ||
14228 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | 14548 | spec->stream_digital_playback = &alc861_pcm_digital_playback; |
14229 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | 14549 | spec->stream_digital_capture = &alc861_pcm_digital_capture; |
14230 | 14550 | ||
@@ -14611,19 +14931,6 @@ static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { | |||
14611 | {} | 14931 | {} |
14612 | }; | 14932 | }; |
14613 | 14933 | ||
14614 | /* toggle speaker-output according to the hp-jack state */ | ||
14615 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | ||
14616 | { | ||
14617 | unsigned int present; | ||
14618 | unsigned char bits; | ||
14619 | |||
14620 | present = snd_hda_codec_read(codec, 0x1b, 0, | ||
14621 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
14622 | bits = present ? HDA_AMP_MUTE : 0; | ||
14623 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
14624 | HDA_AMP_MUTE, bits); | ||
14625 | } | ||
14626 | |||
14627 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | 14934 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) |
14628 | { | 14935 | { |
14629 | unsigned int present; | 14936 | unsigned int present; |
@@ -14636,9 +14943,13 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |||
14636 | HDA_AMP_MUTE, bits); | 14943 | HDA_AMP_MUTE, bits); |
14637 | } | 14944 | } |
14638 | 14945 | ||
14639 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | 14946 | static void alc861vd_lenovo_init_hook(struct hda_codec *codec) |
14640 | { | 14947 | { |
14641 | alc861vd_lenovo_hp_automute(codec); | 14948 | struct alc_spec *spec = codec->spec; |
14949 | |||
14950 | spec->autocfg.hp_pins[0] = 0x1b; | ||
14951 | spec->autocfg.speaker_pins[0] = 0x14; | ||
14952 | alc_automute_amp(codec); | ||
14642 | alc861vd_lenovo_mic_automute(codec); | 14953 | alc861vd_lenovo_mic_automute(codec); |
14643 | } | 14954 | } |
14644 | 14955 | ||
@@ -14646,12 +14957,12 @@ static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |||
14646 | unsigned int res) | 14957 | unsigned int res) |
14647 | { | 14958 | { |
14648 | switch (res >> 26) { | 14959 | switch (res >> 26) { |
14649 | case ALC880_HP_EVENT: | ||
14650 | alc861vd_lenovo_hp_automute(codec); | ||
14651 | break; | ||
14652 | case ALC880_MIC_EVENT: | 14960 | case ALC880_MIC_EVENT: |
14653 | alc861vd_lenovo_mic_automute(codec); | 14961 | alc861vd_lenovo_mic_automute(codec); |
14654 | break; | 14962 | break; |
14963 | default: | ||
14964 | alc_automute_amp_unsol_event(codec, res); | ||
14965 | break; | ||
14655 | } | 14966 | } |
14656 | } | 14967 | } |
14657 | 14968 | ||
@@ -14701,20 +15012,13 @@ static struct hda_verb alc861vd_dallas_verbs[] = { | |||
14701 | }; | 15012 | }; |
14702 | 15013 | ||
14703 | /* toggle speaker-output according to the hp-jack state */ | 15014 | /* toggle speaker-output according to the hp-jack state */ |
14704 | static void alc861vd_dallas_automute(struct hda_codec *codec) | 15015 | static void alc861vd_dallas_init_hook(struct hda_codec *codec) |
14705 | { | 15016 | { |
14706 | unsigned int present; | 15017 | struct alc_spec *spec = codec->spec; |
14707 | |||
14708 | present = snd_hda_codec_read(codec, 0x15, 0, | ||
14709 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
14710 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | ||
14711 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
14712 | } | ||
14713 | 15018 | ||
14714 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | 15019 | spec->autocfg.hp_pins[0] = 0x15; |
14715 | { | 15020 | spec->autocfg.speaker_pins[0] = 0x14; |
14716 | if ((res >> 26) == ALC880_HP_EVENT) | 15021 | alc_automute_amp(codec); |
14717 | alc861vd_dallas_automute(codec); | ||
14718 | } | 15022 | } |
14719 | 15023 | ||
14720 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 15024 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -14828,7 +15132,7 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
14828 | .channel_mode = alc861vd_3stack_2ch_modes, | 15132 | .channel_mode = alc861vd_3stack_2ch_modes, |
14829 | .input_mux = &alc861vd_capture_source, | 15133 | .input_mux = &alc861vd_capture_source, |
14830 | .unsol_event = alc861vd_lenovo_unsol_event, | 15134 | .unsol_event = alc861vd_lenovo_unsol_event, |
14831 | .init_hook = alc861vd_lenovo_automute, | 15135 | .init_hook = alc861vd_lenovo_init_hook, |
14832 | }, | 15136 | }, |
14833 | [ALC861VD_DALLAS] = { | 15137 | [ALC861VD_DALLAS] = { |
14834 | .mixers = { alc861vd_dallas_mixer }, | 15138 | .mixers = { alc861vd_dallas_mixer }, |
@@ -14838,8 +15142,8 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
14838 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | 15142 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14839 | .channel_mode = alc861vd_3stack_2ch_modes, | 15143 | .channel_mode = alc861vd_3stack_2ch_modes, |
14840 | .input_mux = &alc861vd_dallas_capture_source, | 15144 | .input_mux = &alc861vd_dallas_capture_source, |
14841 | .unsol_event = alc861vd_dallas_unsol_event, | 15145 | .unsol_event = alc_automute_amp_unsol_event, |
14842 | .init_hook = alc861vd_dallas_automute, | 15146 | .init_hook = alc861vd_dallas_init_hook, |
14843 | }, | 15147 | }, |
14844 | [ALC861VD_HP] = { | 15148 | [ALC861VD_HP] = { |
14845 | .mixers = { alc861vd_hp_mixer }, | 15149 | .mixers = { alc861vd_hp_mixer }, |
@@ -14850,8 +15154,8 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
14850 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | 15154 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
14851 | .channel_mode = alc861vd_3stack_2ch_modes, | 15155 | .channel_mode = alc861vd_3stack_2ch_modes, |
14852 | .input_mux = &alc861vd_hp_capture_source, | 15156 | .input_mux = &alc861vd_hp_capture_source, |
14853 | .unsol_event = alc861vd_dallas_unsol_event, | 15157 | .unsol_event = alc_automute_amp_unsol_event, |
14854 | .init_hook = alc861vd_dallas_automute, | 15158 | .init_hook = alc861vd_dallas_init_hook, |
14855 | }, | 15159 | }, |
14856 | [ALC660VD_ASUS_V1S] = { | 15160 | [ALC660VD_ASUS_V1S] = { |
14857 | .mixers = { alc861vd_lenovo_mixer }, | 15161 | .mixers = { alc861vd_lenovo_mixer }, |
@@ -14866,7 +15170,7 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
14866 | .channel_mode = alc861vd_3stack_2ch_modes, | 15170 | .channel_mode = alc861vd_3stack_2ch_modes, |
14867 | .input_mux = &alc861vd_capture_source, | 15171 | .input_mux = &alc861vd_capture_source, |
14868 | .unsol_event = alc861vd_lenovo_unsol_event, | 15172 | .unsol_event = alc861vd_lenovo_unsol_event, |
14869 | .init_hook = alc861vd_lenovo_automute, | 15173 | .init_hook = alc861vd_lenovo_init_hook, |
14870 | }, | 15174 | }, |
14871 | }; | 15175 | }; |
14872 | 15176 | ||
@@ -14884,7 +15188,6 @@ static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |||
14884 | struct alc_spec *spec = codec->spec; | 15188 | struct alc_spec *spec = codec->spec; |
14885 | int i; | 15189 | int i; |
14886 | 15190 | ||
14887 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | ||
14888 | for (i = 0; i <= HDA_SIDE; i++) { | 15191 | for (i = 0; i <= HDA_SIDE; i++) { |
14889 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | 15192 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
14890 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | 15193 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
@@ -15102,6 +15405,8 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec) | |||
15102 | if (err < 0) | 15405 | if (err < 0) |
15103 | return err; | 15406 | return err; |
15104 | 15407 | ||
15408 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | ||
15409 | |||
15105 | return 1; | 15410 | return 1; |
15106 | } | 15411 | } |
15107 | 15412 | ||
@@ -15133,8 +15438,8 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
15133 | alc861vd_cfg_tbl); | 15438 | alc861vd_cfg_tbl); |
15134 | 15439 | ||
15135 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | 15440 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { |
15136 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | 15441 | printk(KERN_INFO "hda_codec: Unknown model for %s, " |
15137 | "ALC861VD, trying auto-probe from BIOS...\n"); | 15442 | "trying auto-probe from BIOS...\n", codec->chip_name); |
15138 | board_config = ALC861VD_AUTO; | 15443 | board_config = ALC861VD_AUTO; |
15139 | } | 15444 | } |
15140 | 15445 | ||
@@ -15162,13 +15467,8 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
15162 | setup_preset(spec, &alc861vd_presets[board_config]); | 15467 | setup_preset(spec, &alc861vd_presets[board_config]); |
15163 | 15468 | ||
15164 | if (codec->vendor_id == 0x10ec0660) { | 15469 | if (codec->vendor_id == 0x10ec0660) { |
15165 | spec->stream_name_analog = "ALC660-VD Analog"; | ||
15166 | spec->stream_name_digital = "ALC660-VD Digital"; | ||
15167 | /* always turn on EAPD */ | 15470 | /* always turn on EAPD */ |
15168 | add_verb(spec, alc660vd_eapd_verbs); | 15471 | add_verb(spec, alc660vd_eapd_verbs); |
15169 | } else { | ||
15170 | spec->stream_name_analog = "ALC861VD Analog"; | ||
15171 | spec->stream_name_digital = "ALC861VD Digital"; | ||
15172 | } | 15472 | } |
15173 | 15473 | ||
15174 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; | 15474 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; |
@@ -15282,6 +15582,38 @@ static struct hda_input_mux alc663_m51va_capture_source = { | |||
15282 | }, | 15582 | }, |
15283 | }; | 15583 | }; |
15284 | 15584 | ||
15585 | #if 1 /* set to 0 for testing other input sources below */ | ||
15586 | static struct hda_input_mux alc272_nc10_capture_source = { | ||
15587 | .num_items = 2, | ||
15588 | .items = { | ||
15589 | { "Autoselect Mic", 0x0 }, | ||
15590 | { "Internal Mic", 0x1 }, | ||
15591 | }, | ||
15592 | }; | ||
15593 | #else | ||
15594 | static struct hda_input_mux alc272_nc10_capture_source = { | ||
15595 | .num_items = 16, | ||
15596 | .items = { | ||
15597 | { "Autoselect Mic", 0x0 }, | ||
15598 | { "Internal Mic", 0x1 }, | ||
15599 | { "In-0x02", 0x2 }, | ||
15600 | { "In-0x03", 0x3 }, | ||
15601 | { "In-0x04", 0x4 }, | ||
15602 | { "In-0x05", 0x5 }, | ||
15603 | { "In-0x06", 0x6 }, | ||
15604 | { "In-0x07", 0x7 }, | ||
15605 | { "In-0x08", 0x8 }, | ||
15606 | { "In-0x09", 0x9 }, | ||
15607 | { "In-0x0a", 0x0a }, | ||
15608 | { "In-0x0b", 0x0b }, | ||
15609 | { "In-0x0c", 0x0c }, | ||
15610 | { "In-0x0d", 0x0d }, | ||
15611 | { "In-0x0e", 0x0e }, | ||
15612 | { "In-0x0f", 0x0f }, | ||
15613 | }, | ||
15614 | }; | ||
15615 | #endif | ||
15616 | |||
15285 | /* | 15617 | /* |
15286 | * 2ch mode | 15618 | * 2ch mode |
15287 | */ | 15619 | */ |
@@ -15421,10 +15753,8 @@ static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |||
15421 | }; | 15753 | }; |
15422 | 15754 | ||
15423 | static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { | 15755 | static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { |
15424 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 15756 | HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
15425 | 15757 | ALC262_HIPPO_MASTER_SWITCH, | |
15426 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), | ||
15427 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | ||
15428 | 15758 | ||
15429 | HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), | 15759 | HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), |
15430 | HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | 15760 | HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
@@ -15437,15 +15767,11 @@ static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { | |||
15437 | }; | 15767 | }; |
15438 | 15768 | ||
15439 | static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { | 15769 | static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { |
15440 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), | 15770 | ALC262_HIPPO_MASTER_SWITCH, |
15441 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 15771 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
15442 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | 15772 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
15443 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | ||
15444 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | 15773 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
15445 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | 15774 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), |
15446 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | ||
15447 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | ||
15448 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | ||
15449 | HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), | 15775 | HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), |
15450 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | 15776 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
15451 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | 15777 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
@@ -15953,51 +16279,25 @@ static void alc662_eeepc_mic_automute(struct hda_codec *codec) | |||
15953 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | 16279 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, |
15954 | unsigned int res) | 16280 | unsigned int res) |
15955 | { | 16281 | { |
15956 | if ((res >> 26) == ALC880_HP_EVENT) | ||
15957 | alc262_hippo1_automute( codec ); | ||
15958 | |||
15959 | if ((res >> 26) == ALC880_MIC_EVENT) | 16282 | if ((res >> 26) == ALC880_MIC_EVENT) |
15960 | alc662_eeepc_mic_automute(codec); | 16283 | alc662_eeepc_mic_automute(codec); |
16284 | else | ||
16285 | alc262_hippo_unsol_event(codec, res); | ||
15961 | } | 16286 | } |
15962 | 16287 | ||
15963 | static void alc662_eeepc_inithook(struct hda_codec *codec) | 16288 | static void alc662_eeepc_inithook(struct hda_codec *codec) |
15964 | { | 16289 | { |
15965 | alc262_hippo1_automute( codec ); | 16290 | alc262_hippo1_init_hook(codec); |
15966 | alc662_eeepc_mic_automute(codec); | 16291 | alc662_eeepc_mic_automute(codec); |
15967 | } | 16292 | } |
15968 | 16293 | ||
15969 | static void alc662_eeepc_ep20_automute(struct hda_codec *codec) | ||
15970 | { | ||
15971 | unsigned int mute; | ||
15972 | unsigned int present; | ||
15973 | |||
15974 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
15975 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
15976 | AC_VERB_GET_PIN_SENSE, 0); | ||
15977 | present = (present & 0x80000000) != 0; | ||
15978 | if (present) { | ||
15979 | /* mute internal speaker */ | ||
15980 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | ||
15981 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
15982 | } else { | ||
15983 | /* unmute internal speaker if necessary */ | ||
15984 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | ||
15985 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | ||
15986 | HDA_AMP_MUTE, mute); | ||
15987 | } | ||
15988 | } | ||
15989 | |||
15990 | /* unsolicited event for HP jack sensing */ | ||
15991 | static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec, | ||
15992 | unsigned int res) | ||
15993 | { | ||
15994 | if ((res >> 26) == ALC880_HP_EVENT) | ||
15995 | alc662_eeepc_ep20_automute(codec); | ||
15996 | } | ||
15997 | |||
15998 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) | 16294 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) |
15999 | { | 16295 | { |
16000 | alc662_eeepc_ep20_automute(codec); | 16296 | struct alc_spec *spec = codec->spec; |
16297 | |||
16298 | spec->autocfg.hp_pins[0] = 0x14; | ||
16299 | spec->autocfg.speaker_pins[0] = 0x1b; | ||
16300 | alc262_hippo_master_update(codec); | ||
16001 | } | 16301 | } |
16002 | 16302 | ||
16003 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) | 16303 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) |
@@ -16331,35 +16631,9 @@ static void alc663_g50v_inithook(struct hda_codec *codec) | |||
16331 | alc662_eeepc_mic_automute(codec); | 16631 | alc662_eeepc_mic_automute(codec); |
16332 | } | 16632 | } |
16333 | 16633 | ||
16334 | /* bind hp and internal speaker mute (with plug check) */ | ||
16335 | static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol, | ||
16336 | struct snd_ctl_elem_value *ucontrol) | ||
16337 | { | ||
16338 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
16339 | long *valp = ucontrol->value.integer.value; | ||
16340 | int change; | ||
16341 | |||
16342 | change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, | ||
16343 | HDA_AMP_MUTE, | ||
16344 | valp[0] ? 0 : HDA_AMP_MUTE); | ||
16345 | change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, | ||
16346 | HDA_AMP_MUTE, | ||
16347 | valp[1] ? 0 : HDA_AMP_MUTE); | ||
16348 | if (change) | ||
16349 | alc262_hippo1_automute(codec); | ||
16350 | return change; | ||
16351 | } | ||
16352 | |||
16353 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { | 16634 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { |
16354 | HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), | 16635 | HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
16355 | { | 16636 | ALC262_HIPPO_MASTER_SWITCH, |
16356 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
16357 | .name = "Master Playback Switch", | ||
16358 | .info = snd_hda_mixer_amp_switch_info, | ||
16359 | .get = snd_hda_mixer_amp_switch_get, | ||
16360 | .put = alc662_ecs_master_sw_put, | ||
16361 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | ||
16362 | }, | ||
16363 | 16637 | ||
16364 | HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT), | 16638 | HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT), |
16365 | HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT), | 16639 | HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT), |
@@ -16371,6 +16645,23 @@ static struct snd_kcontrol_new alc662_ecs_mixer[] = { | |||
16371 | { } /* end */ | 16645 | { } /* end */ |
16372 | }; | 16646 | }; |
16373 | 16647 | ||
16648 | static struct snd_kcontrol_new alc272_nc10_mixer[] = { | ||
16649 | /* Master Playback automatically created from Speaker and Headphone */ | ||
16650 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | ||
16651 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | ||
16652 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | ||
16653 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | ||
16654 | |||
16655 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
16656 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
16657 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), | ||
16658 | |||
16659 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | ||
16660 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | ||
16661 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | ||
16662 | { } /* end */ | ||
16663 | }; | ||
16664 | |||
16374 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 16665 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
16375 | #define alc662_loopbacks alc880_loopbacks | 16666 | #define alc662_loopbacks alc880_loopbacks |
16376 | #endif | 16667 | #endif |
@@ -16404,6 +16695,9 @@ static const char *alc662_models[ALC662_MODEL_LAST] = { | |||
16404 | [ALC663_ASUS_MODE4] = "asus-mode4", | 16695 | [ALC663_ASUS_MODE4] = "asus-mode4", |
16405 | [ALC663_ASUS_MODE5] = "asus-mode5", | 16696 | [ALC663_ASUS_MODE5] = "asus-mode5", |
16406 | [ALC663_ASUS_MODE6] = "asus-mode6", | 16697 | [ALC663_ASUS_MODE6] = "asus-mode6", |
16698 | [ALC272_DELL] = "dell", | ||
16699 | [ALC272_DELL_ZM1] = "dell-zm1", | ||
16700 | [ALC272_SAMSUNG_NC10] = "samsung-nc10", | ||
16407 | [ALC662_AUTO] = "auto", | 16701 | [ALC662_AUTO] = "auto", |
16408 | }; | 16702 | }; |
16409 | 16703 | ||
@@ -16461,6 +16755,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = { | |||
16461 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), | 16755 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), |
16462 | SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", | 16756 | SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", |
16463 | ALC662_3ST_6ch_DIG), | 16757 | ALC662_3ST_6ch_DIG), |
16758 | SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10), | ||
16464 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", | 16759 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", |
16465 | ALC662_3ST_6ch_DIG), | 16760 | ALC662_3ST_6ch_DIG), |
16466 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), | 16761 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), |
@@ -16551,7 +16846,7 @@ static struct alc_config_preset alc662_presets[] = { | |||
16551 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | 16846 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
16552 | .channel_mode = alc662_3ST_6ch_modes, | 16847 | .channel_mode = alc662_3ST_6ch_modes, |
16553 | .input_mux = &alc662_lenovo_101e_capture_source, | 16848 | .input_mux = &alc662_lenovo_101e_capture_source, |
16554 | .unsol_event = alc662_eeepc_ep20_unsol_event, | 16849 | .unsol_event = alc662_eeepc_unsol_event, |
16555 | .init_hook = alc662_eeepc_ep20_inithook, | 16850 | .init_hook = alc662_eeepc_ep20_inithook, |
16556 | }, | 16851 | }, |
16557 | [ALC662_ECS] = { | 16852 | [ALC662_ECS] = { |
@@ -16732,6 +17027,18 @@ static struct alc_config_preset alc662_presets[] = { | |||
16732 | .unsol_event = alc663_m51va_unsol_event, | 17027 | .unsol_event = alc663_m51va_unsol_event, |
16733 | .init_hook = alc663_m51va_inithook, | 17028 | .init_hook = alc663_m51va_inithook, |
16734 | }, | 17029 | }, |
17030 | [ALC272_SAMSUNG_NC10] = { | ||
17031 | .mixers = { alc272_nc10_mixer }, | ||
17032 | .init_verbs = { alc662_init_verbs, | ||
17033 | alc663_21jd_amic_init_verbs }, | ||
17034 | .num_dacs = ARRAY_SIZE(alc272_dac_nids), | ||
17035 | .dac_nids = alc272_dac_nids, | ||
17036 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | ||
17037 | .channel_mode = alc662_3ST_2ch_modes, | ||
17038 | .input_mux = &alc272_nc10_capture_source, | ||
17039 | .unsol_event = alc663_mode4_unsol_event, | ||
17040 | .init_hook = alc663_mode4_inithook, | ||
17041 | }, | ||
16735 | }; | 17042 | }; |
16736 | 17043 | ||
16737 | 17044 | ||
@@ -16926,7 +17233,6 @@ static void alc662_auto_init_multi_out(struct hda_codec *codec) | |||
16926 | struct alc_spec *spec = codec->spec; | 17233 | struct alc_spec *spec = codec->spec; |
16927 | int i; | 17234 | int i; |
16928 | 17235 | ||
16929 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); | ||
16930 | for (i = 0; i <= HDA_SIDE; i++) { | 17236 | for (i = 0; i <= HDA_SIDE; i++) { |
16931 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | 17237 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
16932 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | 17238 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
@@ -17023,6 +17329,8 @@ static int alc662_parse_auto_config(struct hda_codec *codec) | |||
17023 | if (err < 0) | 17329 | if (err < 0) |
17024 | return err; | 17330 | return err; |
17025 | 17331 | ||
17332 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | ||
17333 | |||
17026 | return 1; | 17334 | return 1; |
17027 | } | 17335 | } |
17028 | 17336 | ||
@@ -17055,8 +17363,8 @@ static int patch_alc662(struct hda_codec *codec) | |||
17055 | alc662_models, | 17363 | alc662_models, |
17056 | alc662_cfg_tbl); | 17364 | alc662_cfg_tbl); |
17057 | if (board_config < 0) { | 17365 | if (board_config < 0) { |
17058 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | 17366 | printk(KERN_INFO "hda_codec: Unknown model for %s, " |
17059 | "trying auto-probe from BIOS...\n"); | 17367 | "trying auto-probe from BIOS...\n", codec->chip_name); |
17060 | board_config = ALC662_AUTO; | 17368 | board_config = ALC662_AUTO; |
17061 | } | 17369 | } |
17062 | 17370 | ||
@@ -17083,17 +17391,6 @@ static int patch_alc662(struct hda_codec *codec) | |||
17083 | if (board_config != ALC662_AUTO) | 17391 | if (board_config != ALC662_AUTO) |
17084 | setup_preset(spec, &alc662_presets[board_config]); | 17392 | setup_preset(spec, &alc662_presets[board_config]); |
17085 | 17393 | ||
17086 | if (codec->vendor_id == 0x10ec0663) { | ||
17087 | spec->stream_name_analog = "ALC663 Analog"; | ||
17088 | spec->stream_name_digital = "ALC663 Digital"; | ||
17089 | } else if (codec->vendor_id == 0x10ec0272) { | ||
17090 | spec->stream_name_analog = "ALC272 Analog"; | ||
17091 | spec->stream_name_digital = "ALC272 Digital"; | ||
17092 | } else { | ||
17093 | spec->stream_name_analog = "ALC662 Analog"; | ||
17094 | spec->stream_name_digital = "ALC662 Digital"; | ||
17095 | } | ||
17096 | |||
17097 | spec->stream_analog_playback = &alc662_pcm_analog_playback; | 17394 | spec->stream_analog_playback = &alc662_pcm_analog_playback; |
17098 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | 17395 | spec->stream_analog_capture = &alc662_pcm_analog_capture; |
17099 | 17396 | ||
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 917bc5d3ac2c..93e47c96a38b 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -100,6 +100,7 @@ enum { | |||
100 | STAC_HP_M4, | 100 | STAC_HP_M4, |
101 | STAC_HP_DV5, | 101 | STAC_HP_DV5, |
102 | STAC_HP_HDX, | 102 | STAC_HP_HDX, |
103 | STAC_HP_DV4_1222NR, | ||
103 | STAC_92HD71BXX_MODELS | 104 | STAC_92HD71BXX_MODELS |
104 | }; | 105 | }; |
105 | 106 | ||
@@ -150,6 +151,7 @@ enum { | |||
150 | STAC_D965_REF, | 151 | STAC_D965_REF, |
151 | STAC_D965_3ST, | 152 | STAC_D965_3ST, |
152 | STAC_D965_5ST, | 153 | STAC_D965_5ST, |
154 | STAC_D965_5ST_NO_FP, | ||
153 | STAC_DELL_3ST, | 155 | STAC_DELL_3ST, |
154 | STAC_DELL_BIOS, | 156 | STAC_DELL_BIOS, |
155 | STAC_927X_MODELS | 157 | STAC_927X_MODELS |
@@ -192,6 +194,7 @@ struct sigmatel_spec { | |||
192 | unsigned int gpio_dir; | 194 | unsigned int gpio_dir; |
193 | unsigned int gpio_data; | 195 | unsigned int gpio_data; |
194 | unsigned int gpio_mute; | 196 | unsigned int gpio_mute; |
197 | unsigned int gpio_led; | ||
195 | 198 | ||
196 | /* stream */ | 199 | /* stream */ |
197 | unsigned int stream_delay; | 200 | unsigned int stream_delay; |
@@ -633,6 +636,40 @@ static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, | |||
633 | return 0; | 636 | return 0; |
634 | } | 637 | } |
635 | 638 | ||
639 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, | ||
640 | hda_nid_t nid, unsigned int new_vref) | ||
641 | { | ||
642 | unsigned int error; | ||
643 | unsigned int pincfg; | ||
644 | pincfg = snd_hda_codec_read(codec, nid, 0, | ||
645 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
646 | |||
647 | pincfg &= 0xff; | ||
648 | pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); | ||
649 | pincfg |= new_vref; | ||
650 | |||
651 | if (new_vref == AC_PINCTL_VREF_HIZ) | ||
652 | pincfg |= AC_PINCTL_OUT_EN; | ||
653 | else | ||
654 | pincfg |= AC_PINCTL_IN_EN; | ||
655 | |||
656 | error = snd_hda_codec_write_cache(codec, nid, 0, | ||
657 | AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg); | ||
658 | if (error < 0) | ||
659 | return error; | ||
660 | else | ||
661 | return 1; | ||
662 | } | ||
663 | |||
664 | static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid) | ||
665 | { | ||
666 | unsigned int vref; | ||
667 | vref = snd_hda_codec_read(codec, nid, 0, | ||
668 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
669 | vref &= AC_PINCTL_VREFEN; | ||
670 | return vref; | ||
671 | } | ||
672 | |||
636 | static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 673 | static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
637 | { | 674 | { |
638 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 675 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
@@ -994,6 +1031,17 @@ static struct hda_verb stac9205_core_init[] = { | |||
994 | .private_value = verb_read | (verb_write << 16), \ | 1031 | .private_value = verb_read | (verb_write << 16), \ |
995 | } | 1032 | } |
996 | 1033 | ||
1034 | #define DC_BIAS(xname, idx, nid) \ | ||
1035 | { \ | ||
1036 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
1037 | .name = xname, \ | ||
1038 | .index = idx, \ | ||
1039 | .info = stac92xx_dc_bias_info, \ | ||
1040 | .get = stac92xx_dc_bias_get, \ | ||
1041 | .put = stac92xx_dc_bias_put, \ | ||
1042 | .private_value = nid, \ | ||
1043 | } | ||
1044 | |||
997 | static struct snd_kcontrol_new stac9200_mixer[] = { | 1045 | static struct snd_kcontrol_new stac9200_mixer[] = { |
998 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), | 1046 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
999 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), | 1047 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
@@ -1542,6 +1590,8 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = { | |||
1542 | /* SigmaTel reference board */ | 1590 | /* SigmaTel reference board */ |
1543 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 1591 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
1544 | "DFI LanParty", STAC_REF), | 1592 | "DFI LanParty", STAC_REF), |
1593 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, | ||
1594 | "SigmaTel",STAC_9205_REF), | ||
1545 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 1595 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
1546 | "DFI LanParty", STAC_REF), | 1596 | "DFI LanParty", STAC_REF), |
1547 | /* Dell laptops have BIOS problem */ | 1597 | /* Dell laptops have BIOS problem */ |
@@ -1836,6 +1886,7 @@ static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { | |||
1836 | [STAC_HP_M4] = NULL, | 1886 | [STAC_HP_M4] = NULL, |
1837 | [STAC_HP_DV5] = NULL, | 1887 | [STAC_HP_DV5] = NULL, |
1838 | [STAC_HP_HDX] = NULL, | 1888 | [STAC_HP_HDX] = NULL, |
1889 | [STAC_HP_DV4_1222NR] = NULL, | ||
1839 | }; | 1890 | }; |
1840 | 1891 | ||
1841 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { | 1892 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
@@ -1847,6 +1898,7 @@ static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { | |||
1847 | [STAC_HP_M4] = "hp-m4", | 1898 | [STAC_HP_M4] = "hp-m4", |
1848 | [STAC_HP_DV5] = "hp-dv5", | 1899 | [STAC_HP_DV5] = "hp-dv5", |
1849 | [STAC_HP_HDX] = "hp-hdx", | 1900 | [STAC_HP_HDX] = "hp-hdx", |
1901 | [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr", | ||
1850 | }; | 1902 | }; |
1851 | 1903 | ||
1852 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { | 1904 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
@@ -1855,6 +1907,8 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { | |||
1855 | "DFI LanParty", STAC_92HD71BXX_REF), | 1907 | "DFI LanParty", STAC_92HD71BXX_REF), |
1856 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 1908 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
1857 | "DFI LanParty", STAC_92HD71BXX_REF), | 1909 | "DFI LanParty", STAC_92HD71BXX_REF), |
1910 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, | ||
1911 | "HP dv4-1222nr", STAC_HP_DV4_1222NR), | ||
1858 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, | 1912 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, |
1859 | "HP", STAC_HP_DV5), | 1913 | "HP", STAC_HP_DV5), |
1860 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, | 1914 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
@@ -2154,6 +2208,13 @@ static unsigned int d965_5st_pin_configs[14] = { | |||
2154 | 0x40000100, 0x40000100 | 2208 | 0x40000100, 0x40000100 |
2155 | }; | 2209 | }; |
2156 | 2210 | ||
2211 | static unsigned int d965_5st_no_fp_pin_configs[14] = { | ||
2212 | 0x40000100, 0x40000100, 0x0181304e, 0x01014010, | ||
2213 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, | ||
2214 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, | ||
2215 | 0x40000100, 0x40000100 | ||
2216 | }; | ||
2217 | |||
2157 | static unsigned int dell_3st_pin_configs[14] = { | 2218 | static unsigned int dell_3st_pin_configs[14] = { |
2158 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, | 2219 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
2159 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, | 2220 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
@@ -2166,6 +2227,7 @@ static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { | |||
2166 | [STAC_D965_REF] = ref927x_pin_configs, | 2227 | [STAC_D965_REF] = ref927x_pin_configs, |
2167 | [STAC_D965_3ST] = d965_3st_pin_configs, | 2228 | [STAC_D965_3ST] = d965_3st_pin_configs, |
2168 | [STAC_D965_5ST] = d965_5st_pin_configs, | 2229 | [STAC_D965_5ST] = d965_5st_pin_configs, |
2230 | [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs, | ||
2169 | [STAC_DELL_3ST] = dell_3st_pin_configs, | 2231 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
2170 | [STAC_DELL_BIOS] = NULL, | 2232 | [STAC_DELL_BIOS] = NULL, |
2171 | }; | 2233 | }; |
@@ -2176,6 +2238,7 @@ static const char *stac927x_models[STAC_927X_MODELS] = { | |||
2176 | [STAC_D965_REF] = "ref", | 2238 | [STAC_D965_REF] = "ref", |
2177 | [STAC_D965_3ST] = "3stack", | 2239 | [STAC_D965_3ST] = "3stack", |
2178 | [STAC_D965_5ST] = "5stack", | 2240 | [STAC_D965_5ST] = "5stack", |
2241 | [STAC_D965_5ST_NO_FP] = "5stack-no-fp", | ||
2179 | [STAC_DELL_3ST] = "dell-3stack", | 2242 | [STAC_DELL_3ST] = "dell-3stack", |
2180 | [STAC_DELL_BIOS] = "dell-bios", | 2243 | [STAC_DELL_BIOS] = "dell-bios", |
2181 | }; | 2244 | }; |
@@ -2535,7 +2598,8 @@ static int stac92xx_build_pcms(struct hda_codec *codec) | |||
2535 | return 0; | 2598 | return 0; |
2536 | } | 2599 | } |
2537 | 2600 | ||
2538 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) | 2601 | static unsigned int stac92xx_get_default_vref(struct hda_codec *codec, |
2602 | hda_nid_t nid) | ||
2539 | { | 2603 | { |
2540 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); | 2604 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
2541 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; | 2605 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
@@ -2589,15 +2653,108 @@ static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, | |||
2589 | return 1; | 2653 | return 1; |
2590 | } | 2654 | } |
2591 | 2655 | ||
2592 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info | 2656 | static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol, |
2657 | struct snd_ctl_elem_info *uinfo) | ||
2658 | { | ||
2659 | int i; | ||
2660 | static char *texts[] = { | ||
2661 | "Mic In", "Line In", "Line Out" | ||
2662 | }; | ||
2663 | |||
2664 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2665 | struct sigmatel_spec *spec = codec->spec; | ||
2666 | hda_nid_t nid = kcontrol->private_value; | ||
2667 | |||
2668 | if (nid == spec->mic_switch || nid == spec->line_switch) | ||
2669 | i = 3; | ||
2670 | else | ||
2671 | i = 2; | ||
2672 | |||
2673 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
2674 | uinfo->value.enumerated.items = i; | ||
2675 | uinfo->count = 1; | ||
2676 | if (uinfo->value.enumerated.item >= i) | ||
2677 | uinfo->value.enumerated.item = i-1; | ||
2678 | strcpy(uinfo->value.enumerated.name, | ||
2679 | texts[uinfo->value.enumerated.item]); | ||
2680 | |||
2681 | return 0; | ||
2682 | } | ||
2683 | |||
2684 | static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol, | ||
2685 | struct snd_ctl_elem_value *ucontrol) | ||
2686 | { | ||
2687 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2688 | hda_nid_t nid = kcontrol->private_value; | ||
2689 | unsigned int vref = stac92xx_vref_get(codec, nid); | ||
2690 | |||
2691 | if (vref == stac92xx_get_default_vref(codec, nid)) | ||
2692 | ucontrol->value.enumerated.item[0] = 0; | ||
2693 | else if (vref == AC_PINCTL_VREF_GRD) | ||
2694 | ucontrol->value.enumerated.item[0] = 1; | ||
2695 | else if (vref == AC_PINCTL_VREF_HIZ) | ||
2696 | ucontrol->value.enumerated.item[0] = 2; | ||
2697 | |||
2698 | return 0; | ||
2699 | } | ||
2700 | |||
2701 | static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, | ||
2702 | struct snd_ctl_elem_value *ucontrol) | ||
2703 | { | ||
2704 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2705 | unsigned int new_vref = 0; | ||
2706 | unsigned int error; | ||
2707 | hda_nid_t nid = kcontrol->private_value; | ||
2708 | |||
2709 | if (ucontrol->value.enumerated.item[0] == 0) | ||
2710 | new_vref = stac92xx_get_default_vref(codec, nid); | ||
2711 | else if (ucontrol->value.enumerated.item[0] == 1) | ||
2712 | new_vref = AC_PINCTL_VREF_GRD; | ||
2713 | else if (ucontrol->value.enumerated.item[0] == 2) | ||
2714 | new_vref = AC_PINCTL_VREF_HIZ; | ||
2715 | else | ||
2716 | return 0; | ||
2717 | |||
2718 | if (new_vref != stac92xx_vref_get(codec, nid)) { | ||
2719 | error = stac92xx_vref_set(codec, nid, new_vref); | ||
2720 | return error; | ||
2721 | } | ||
2722 | |||
2723 | return 0; | ||
2724 | } | ||
2725 | |||
2726 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, | ||
2727 | struct snd_ctl_elem_info *uinfo) | ||
2728 | { | ||
2729 | static char *texts[2]; | ||
2730 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2731 | struct sigmatel_spec *spec = codec->spec; | ||
2732 | |||
2733 | if (kcontrol->private_value == spec->line_switch) | ||
2734 | texts[0] = "Line In"; | ||
2735 | else | ||
2736 | texts[0] = "Mic In"; | ||
2737 | texts[1] = "Line Out"; | ||
2738 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
2739 | uinfo->value.enumerated.items = 2; | ||
2740 | uinfo->count = 1; | ||
2741 | |||
2742 | if (uinfo->value.enumerated.item >= 2) | ||
2743 | uinfo->value.enumerated.item = 1; | ||
2744 | strcpy(uinfo->value.enumerated.name, | ||
2745 | texts[uinfo->value.enumerated.item]); | ||
2746 | |||
2747 | return 0; | ||
2748 | } | ||
2593 | 2749 | ||
2594 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 2750 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
2595 | { | 2751 | { |
2596 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2752 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
2597 | struct sigmatel_spec *spec = codec->spec; | 2753 | struct sigmatel_spec *spec = codec->spec; |
2598 | int io_idx = kcontrol-> private_value & 0xff; | 2754 | hda_nid_t nid = kcontrol->private_value; |
2755 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; | ||
2599 | 2756 | ||
2600 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; | 2757 | ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx]; |
2601 | return 0; | 2758 | return 0; |
2602 | } | 2759 | } |
2603 | 2760 | ||
@@ -2605,9 +2762,9 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
2605 | { | 2762 | { |
2606 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2763 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
2607 | struct sigmatel_spec *spec = codec->spec; | 2764 | struct sigmatel_spec *spec = codec->spec; |
2608 | hda_nid_t nid = kcontrol->private_value >> 8; | 2765 | hda_nid_t nid = kcontrol->private_value; |
2609 | int io_idx = kcontrol-> private_value & 0xff; | 2766 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
2610 | unsigned short val = !!ucontrol->value.integer.value[0]; | 2767 | unsigned short val = !!ucontrol->value.enumerated.item[0]; |
2611 | 2768 | ||
2612 | spec->io_switch[io_idx] = val; | 2769 | spec->io_switch[io_idx] = val; |
2613 | 2770 | ||
@@ -2616,7 +2773,7 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
2616 | else { | 2773 | else { |
2617 | unsigned int pinctl = AC_PINCTL_IN_EN; | 2774 | unsigned int pinctl = AC_PINCTL_IN_EN; |
2618 | if (io_idx) /* set VREF for mic */ | 2775 | if (io_idx) /* set VREF for mic */ |
2619 | pinctl |= stac92xx_get_vref(codec, nid); | 2776 | pinctl |= stac92xx_get_default_vref(codec, nid); |
2620 | stac92xx_auto_set_pinctl(codec, nid, pinctl); | 2777 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
2621 | } | 2778 | } |
2622 | 2779 | ||
@@ -2697,7 +2854,8 @@ enum { | |||
2697 | STAC_CTL_WIDGET_AMP_VOL, | 2854 | STAC_CTL_WIDGET_AMP_VOL, |
2698 | STAC_CTL_WIDGET_HP_SWITCH, | 2855 | STAC_CTL_WIDGET_HP_SWITCH, |
2699 | STAC_CTL_WIDGET_IO_SWITCH, | 2856 | STAC_CTL_WIDGET_IO_SWITCH, |
2700 | STAC_CTL_WIDGET_CLFE_SWITCH | 2857 | STAC_CTL_WIDGET_CLFE_SWITCH, |
2858 | STAC_CTL_WIDGET_DC_BIAS | ||
2701 | }; | 2859 | }; |
2702 | 2860 | ||
2703 | static struct snd_kcontrol_new stac92xx_control_templates[] = { | 2861 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
@@ -2709,6 +2867,7 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = { | |||
2709 | STAC_CODEC_HP_SWITCH(NULL), | 2867 | STAC_CODEC_HP_SWITCH(NULL), |
2710 | STAC_CODEC_IO_SWITCH(NULL, 0), | 2868 | STAC_CODEC_IO_SWITCH(NULL, 0), |
2711 | STAC_CODEC_CLFE_SWITCH(NULL, 0), | 2869 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
2870 | DC_BIAS(NULL, 0, 0), | ||
2712 | }; | 2871 | }; |
2713 | 2872 | ||
2714 | /* add dynamic controls */ | 2873 | /* add dynamic controls */ |
@@ -2772,6 +2931,34 @@ static struct snd_kcontrol_new stac_input_src_temp = { | |||
2772 | .put = stac92xx_mux_enum_put, | 2931 | .put = stac92xx_mux_enum_put, |
2773 | }; | 2932 | }; |
2774 | 2933 | ||
2934 | static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, | ||
2935 | hda_nid_t nid, int idx) | ||
2936 | { | ||
2937 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
2938 | int control = 0; | ||
2939 | struct sigmatel_spec *spec = codec->spec; | ||
2940 | char name[22]; | ||
2941 | |||
2942 | if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) { | ||
2943 | if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD | ||
2944 | && nid == spec->line_switch) | ||
2945 | control = STAC_CTL_WIDGET_IO_SWITCH; | ||
2946 | else if (snd_hda_query_pin_caps(codec, nid) | ||
2947 | & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT)) | ||
2948 | control = STAC_CTL_WIDGET_DC_BIAS; | ||
2949 | else if (nid == spec->mic_switch) | ||
2950 | control = STAC_CTL_WIDGET_IO_SWITCH; | ||
2951 | } | ||
2952 | |||
2953 | if (control) { | ||
2954 | strcpy(name, auto_pin_cfg_labels[idx]); | ||
2955 | return stac92xx_add_control(codec->spec, control, | ||
2956 | strcat(name, " Jack Mode"), nid); | ||
2957 | } | ||
2958 | |||
2959 | return 0; | ||
2960 | } | ||
2961 | |||
2775 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) | 2962 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
2776 | { | 2963 | { |
2777 | struct snd_kcontrol_new *knew; | 2964 | struct snd_kcontrol_new *knew; |
@@ -3134,7 +3321,9 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | |||
3134 | const struct auto_pin_cfg *cfg) | 3321 | const struct auto_pin_cfg *cfg) |
3135 | { | 3322 | { |
3136 | struct sigmatel_spec *spec = codec->spec; | 3323 | struct sigmatel_spec *spec = codec->spec; |
3324 | hda_nid_t nid; | ||
3137 | int err; | 3325 | int err; |
3326 | int idx; | ||
3138 | 3327 | ||
3139 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, | 3328 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, |
3140 | spec->multiout.dac_nids, | 3329 | spec->multiout.dac_nids, |
@@ -3151,20 +3340,13 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | |||
3151 | return err; | 3340 | return err; |
3152 | } | 3341 | } |
3153 | 3342 | ||
3154 | if (spec->line_switch) { | 3343 | for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) { |
3155 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, | 3344 | nid = cfg->input_pins[idx]; |
3156 | "Line In as Output Switch", | 3345 | if (nid) { |
3157 | spec->line_switch << 8); | 3346 | err = stac92xx_add_jack_mode_control(codec, nid, idx); |
3158 | if (err < 0) | 3347 | if (err < 0) |
3159 | return err; | 3348 | return err; |
3160 | } | 3349 | } |
3161 | |||
3162 | if (spec->mic_switch) { | ||
3163 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, | ||
3164 | "Mic as Output Switch", | ||
3165 | (spec->mic_switch << 8) | 1); | ||
3166 | if (err < 0) | ||
3167 | return err; | ||
3168 | } | 3350 | } |
3169 | 3351 | ||
3170 | return 0; | 3352 | return 0; |
@@ -3629,6 +3811,8 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3629 | err = snd_hda_attach_beep_device(codec, nid); | 3811 | err = snd_hda_attach_beep_device(codec, nid); |
3630 | if (err < 0) | 3812 | if (err < 0) |
3631 | return err; | 3813 | return err; |
3814 | /* IDT/STAC codecs have linear beep tone parameter */ | ||
3815 | codec->beep->linear_tone = 1; | ||
3632 | /* if no beep switch is available, make its own one */ | 3816 | /* if no beep switch is available, make its own one */ |
3633 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); | 3817 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
3634 | if (codec->beep && | 3818 | if (codec->beep && |
@@ -4072,14 +4256,19 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4072 | unsigned int pinctl, conf; | 4256 | unsigned int pinctl, conf; |
4073 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { | 4257 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
4074 | /* for mic pins, force to initialize */ | 4258 | /* for mic pins, force to initialize */ |
4075 | pinctl = stac92xx_get_vref(codec, nid); | 4259 | pinctl = stac92xx_get_default_vref(codec, nid); |
4076 | pinctl |= AC_PINCTL_IN_EN; | 4260 | pinctl |= AC_PINCTL_IN_EN; |
4077 | stac92xx_auto_set_pinctl(codec, nid, pinctl); | 4261 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
4078 | } else { | 4262 | } else { |
4079 | pinctl = snd_hda_codec_read(codec, nid, 0, | 4263 | pinctl = snd_hda_codec_read(codec, nid, 0, |
4080 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 4264 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
4081 | /* if PINCTL already set then skip */ | 4265 | /* if PINCTL already set then skip */ |
4082 | if (!(pinctl & AC_PINCTL_IN_EN)) { | 4266 | /* Also, if both INPUT and OUTPUT are set, |
4267 | * it must be a BIOS bug; need to override, too | ||
4268 | */ | ||
4269 | if (!(pinctl & AC_PINCTL_IN_EN) || | ||
4270 | (pinctl & AC_PINCTL_OUT_EN)) { | ||
4271 | pinctl &= ~AC_PINCTL_OUT_EN; | ||
4083 | pinctl |= AC_PINCTL_IN_EN; | 4272 | pinctl |= AC_PINCTL_IN_EN; |
4084 | stac92xx_auto_set_pinctl(codec, nid, | 4273 | stac92xx_auto_set_pinctl(codec, nid, |
4085 | pinctl); | 4274 | pinctl); |
@@ -4520,17 +4709,19 @@ static int stac92xx_resume(struct hda_codec *codec) | |||
4520 | return 0; | 4709 | return 0; |
4521 | } | 4710 | } |
4522 | 4711 | ||
4523 | |||
4524 | /* | 4712 | /* |
4525 | * using power check for controlling mute led of HP HDX notebooks | 4713 | * using power check for controlling mute led of HP notebooks |
4526 | * check for mute state only on Speakers (nid = 0x10) | 4714 | * check for mute state only on Speakers (nid = 0x10) |
4527 | * | 4715 | * |
4528 | * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise | 4716 | * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise |
4529 | * the LED is NOT working properly ! | 4717 | * the LED is NOT working properly ! |
4718 | * | ||
4719 | * Changed name to reflect that it now works for any designated | ||
4720 | * model, not just HP HDX. | ||
4530 | */ | 4721 | */ |
4531 | 4722 | ||
4532 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 4723 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4533 | static int stac92xx_hp_hdx_check_power_status(struct hda_codec *codec, | 4724 | static int stac92xx_hp_check_power_status(struct hda_codec *codec, |
4534 | hda_nid_t nid) | 4725 | hda_nid_t nid) |
4535 | { | 4726 | { |
4536 | struct sigmatel_spec *spec = codec->spec; | 4727 | struct sigmatel_spec *spec = codec->spec; |
@@ -4538,9 +4729,9 @@ static int stac92xx_hp_hdx_check_power_status(struct hda_codec *codec, | |||
4538 | if (nid == 0x10) { | 4729 | if (nid == 0x10) { |
4539 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & | 4730 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & |
4540 | HDA_AMP_MUTE) | 4731 | HDA_AMP_MUTE) |
4541 | spec->gpio_data &= ~0x08; /* orange */ | 4732 | spec->gpio_data &= ~spec->gpio_led; /* orange */ |
4542 | else | 4733 | else |
4543 | spec->gpio_data |= 0x08; /* white */ | 4734 | spec->gpio_data |= spec->gpio_led; /* white */ |
4544 | 4735 | ||
4545 | stac_gpio_set(codec, spec->gpio_mask, | 4736 | stac_gpio_set(codec, spec->gpio_mask, |
4546 | spec->gpio_dir, | 4737 | spec->gpio_dir, |
@@ -5186,6 +5377,15 @@ again: | |||
5186 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) | 5377 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
5187 | snd_hda_sequence_write_cache(codec, unmute_init); | 5378 | snd_hda_sequence_write_cache(codec, unmute_init); |
5188 | 5379 | ||
5380 | /* Some HP machines seem to have unstable codec communications | ||
5381 | * especially with ATI fglrx driver. For recovering from the | ||
5382 | * CORB/RIRB stall, allow the BUS reset and keep always sync | ||
5383 | */ | ||
5384 | if (spec->board_config == STAC_HP_DV5) { | ||
5385 | codec->bus->sync_write = 1; | ||
5386 | codec->bus->allow_bus_reset = 1; | ||
5387 | } | ||
5388 | |||
5189 | spec->aloopback_ctl = stac92hd71bxx_loopback; | 5389 | spec->aloopback_ctl = stac92hd71bxx_loopback; |
5190 | spec->aloopback_mask = 0x50; | 5390 | spec->aloopback_mask = 0x50; |
5191 | spec->aloopback_shift = 0; | 5391 | spec->aloopback_shift = 0; |
@@ -5219,6 +5419,15 @@ again: | |||
5219 | spec->num_smuxes = 0; | 5419 | spec->num_smuxes = 0; |
5220 | spec->num_dmuxes = 1; | 5420 | spec->num_dmuxes = 1; |
5221 | break; | 5421 | break; |
5422 | case STAC_HP_DV4_1222NR: | ||
5423 | spec->num_dmics = 1; | ||
5424 | /* I don't know if it needs 1 or 2 smuxes - will wait for | ||
5425 | * bug reports to fix if needed | ||
5426 | */ | ||
5427 | spec->num_smuxes = 1; | ||
5428 | spec->num_dmuxes = 1; | ||
5429 | spec->gpio_led = 0x01; | ||
5430 | /* fallthrough */ | ||
5222 | case STAC_HP_DV5: | 5431 | case STAC_HP_DV5: |
5223 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); | 5432 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
5224 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); | 5433 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
@@ -5227,22 +5436,21 @@ again: | |||
5227 | spec->num_dmics = 1; | 5436 | spec->num_dmics = 1; |
5228 | spec->num_dmuxes = 1; | 5437 | spec->num_dmuxes = 1; |
5229 | spec->num_smuxes = 1; | 5438 | spec->num_smuxes = 1; |
5230 | /* | ||
5231 | * For controlling MUTE LED on HP HDX16/HDX18 notebooks, | ||
5232 | * the CONFIG_SND_HDA_POWER_SAVE is needed to be set. | ||
5233 | */ | ||
5234 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
5235 | /* orange/white mute led on GPIO3, orange=0, white=1 */ | 5439 | /* orange/white mute led on GPIO3, orange=0, white=1 */ |
5236 | spec->gpio_mask |= 0x08; | 5440 | spec->gpio_led = 0x08; |
5237 | spec->gpio_dir |= 0x08; | 5441 | break; |
5238 | spec->gpio_data |= 0x08; /* set to white */ | 5442 | } |
5239 | 5443 | ||
5444 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
5445 | if (spec->gpio_led) { | ||
5446 | spec->gpio_mask |= spec->gpio_led; | ||
5447 | spec->gpio_dir |= spec->gpio_led; | ||
5448 | spec->gpio_data |= spec->gpio_led; | ||
5240 | /* register check_power_status callback. */ | 5449 | /* register check_power_status callback. */ |
5241 | codec->patch_ops.check_power_status = | 5450 | codec->patch_ops.check_power_status = |
5242 | stac92xx_hp_hdx_check_power_status; | 5451 | stac92xx_hp_check_power_status; |
5452 | } | ||
5243 | #endif | 5453 | #endif |
5244 | break; | ||
5245 | }; | ||
5246 | 5454 | ||
5247 | spec->multiout.dac_nids = spec->dac_nids; | 5455 | spec->multiout.dac_nids = spec->dac_nids; |
5248 | if (spec->dinput_mux) | 5456 | if (spec->dinput_mux) |
@@ -5267,7 +5475,7 @@ again: | |||
5267 | codec->proc_widget_hook = stac92hd7x_proc_hook; | 5475 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
5268 | 5476 | ||
5269 | return 0; | 5477 | return 0; |
5270 | }; | 5478 | } |
5271 | 5479 | ||
5272 | static int patch_stac922x(struct hda_codec *codec) | 5480 | static int patch_stac922x(struct hda_codec *codec) |
5273 | { | 5481 | { |
@@ -5422,7 +5630,7 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5422 | /* correct the device field to SPDIF out */ | 5630 | /* correct the device field to SPDIF out */ |
5423 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); | 5631 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); |
5424 | break; | 5632 | break; |
5425 | }; | 5633 | } |
5426 | /* configure the analog microphone on some laptops */ | 5634 | /* configure the analog microphone on some laptops */ |
5427 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); | 5635 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); |
5428 | /* correct the front output jack as a hp out */ | 5636 | /* correct the front output jack as a hp out */ |
@@ -5732,6 +5940,7 @@ static struct hda_codec_preset snd_hda_preset_sigmatel[] = { | |||
5732 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, | 5940 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
5733 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, | 5941 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
5734 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, | 5942 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
5943 | { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 }, | ||
5735 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, | 5944 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
5736 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, | 5945 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
5737 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, | 5946 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index b25a5cc637d6..8e004fb6961a 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -205,7 +205,7 @@ struct via_spec { | |||
205 | 205 | ||
206 | /* playback */ | 206 | /* playback */ |
207 | struct hda_multi_out multiout; | 207 | struct hda_multi_out multiout; |
208 | hda_nid_t extra_dig_out_nid; | 208 | hda_nid_t slave_dig_outs[2]; |
209 | 209 | ||
210 | /* capture */ | 210 | /* capture */ |
211 | unsigned int num_adc_nids; | 211 | unsigned int num_adc_nids; |
@@ -731,21 +731,6 @@ static int via_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | |||
731 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | 731 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
732 | } | 732 | } |
733 | 733 | ||
734 | /* setup SPDIF output stream */ | ||
735 | static void setup_dig_playback_stream(struct hda_codec *codec, hda_nid_t nid, | ||
736 | unsigned int stream_tag, unsigned int format) | ||
737 | { | ||
738 | /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ | ||
739 | if (codec->spdif_ctls & AC_DIG1_ENABLE) | ||
740 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, | ||
741 | codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); | ||
742 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); | ||
743 | /* turn on again (if needed) */ | ||
744 | if (codec->spdif_ctls & AC_DIG1_ENABLE) | ||
745 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, | ||
746 | codec->spdif_ctls & 0xff); | ||
747 | } | ||
748 | |||
749 | static int via_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | 734 | static int via_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
750 | struct hda_codec *codec, | 735 | struct hda_codec *codec, |
751 | unsigned int stream_tag, | 736 | unsigned int stream_tag, |
@@ -753,19 +738,16 @@ static int via_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
753 | struct snd_pcm_substream *substream) | 738 | struct snd_pcm_substream *substream) |
754 | { | 739 | { |
755 | struct via_spec *spec = codec->spec; | 740 | struct via_spec *spec = codec->spec; |
756 | hda_nid_t nid; | 741 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
757 | 742 | stream_tag, format, substream); | |
758 | /* 1st or 2nd S/PDIF */ | 743 | } |
759 | if (substream->number == 0) | ||
760 | nid = spec->multiout.dig_out_nid; | ||
761 | else if (substream->number == 1) | ||
762 | nid = spec->extra_dig_out_nid; | ||
763 | else | ||
764 | return -1; | ||
765 | 744 | ||
766 | mutex_lock(&codec->spdif_mutex); | 745 | static int via_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
767 | setup_dig_playback_stream(codec, nid, stream_tag, format); | 746 | struct hda_codec *codec, |
768 | mutex_unlock(&codec->spdif_mutex); | 747 | struct snd_pcm_substream *substream) |
748 | { | ||
749 | struct via_spec *spec = codec->spec; | ||
750 | snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); | ||
769 | return 0; | 751 | return 0; |
770 | } | 752 | } |
771 | 753 | ||
@@ -842,7 +824,8 @@ static struct hda_pcm_stream vt1708_pcm_digital_playback = { | |||
842 | .ops = { | 824 | .ops = { |
843 | .open = via_dig_playback_pcm_open, | 825 | .open = via_dig_playback_pcm_open, |
844 | .close = via_dig_playback_pcm_close, | 826 | .close = via_dig_playback_pcm_close, |
845 | .prepare = via_dig_playback_pcm_prepare | 827 | .prepare = via_dig_playback_pcm_prepare, |
828 | .cleanup = via_dig_playback_pcm_cleanup | ||
846 | }, | 829 | }, |
847 | }; | 830 | }; |
848 | 831 | ||
@@ -874,13 +857,6 @@ static int via_build_controls(struct hda_codec *codec) | |||
874 | if (err < 0) | 857 | if (err < 0) |
875 | return err; | 858 | return err; |
876 | spec->multiout.share_spdif = 1; | 859 | spec->multiout.share_spdif = 1; |
877 | |||
878 | if (spec->extra_dig_out_nid) { | ||
879 | err = snd_hda_create_spdif_out_ctls(codec, | ||
880 | spec->extra_dig_out_nid); | ||
881 | if (err < 0) | ||
882 | return err; | ||
883 | } | ||
884 | } | 860 | } |
885 | if (spec->dig_in_nid) { | 861 | if (spec->dig_in_nid) { |
886 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | 862 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
@@ -1013,10 +989,6 @@ static void via_unsol_event(struct hda_codec *codec, | |||
1013 | via_gpio_control(codec); | 989 | via_gpio_control(codec); |
1014 | } | 990 | } |
1015 | 991 | ||
1016 | static hda_nid_t slave_dig_outs[] = { | ||
1017 | 0, | ||
1018 | }; | ||
1019 | |||
1020 | static int via_init(struct hda_codec *codec) | 992 | static int via_init(struct hda_codec *codec) |
1021 | { | 993 | { |
1022 | struct via_spec *spec = codec->spec; | 994 | struct via_spec *spec = codec->spec; |
@@ -1051,8 +1023,9 @@ static int via_init(struct hda_codec *codec) | |||
1051 | snd_hda_codec_write(codec, spec->autocfg.dig_in_pin, 0, | 1023 | snd_hda_codec_write(codec, spec->autocfg.dig_in_pin, 0, |
1052 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); | 1024 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); |
1053 | 1025 | ||
1054 | /* no slave outs */ | 1026 | /* assign slave outs */ |
1055 | codec->slave_dig_outs = slave_dig_outs; | 1027 | if (spec->slave_dig_outs[0]) |
1028 | codec->slave_dig_outs = spec->slave_dig_outs; | ||
1056 | 1029 | ||
1057 | return 0; | 1030 | return 0; |
1058 | } | 1031 | } |
@@ -2134,7 +2107,8 @@ static struct hda_pcm_stream vt1708B_pcm_digital_playback = { | |||
2134 | .ops = { | 2107 | .ops = { |
2135 | .open = via_dig_playback_pcm_open, | 2108 | .open = via_dig_playback_pcm_open, |
2136 | .close = via_dig_playback_pcm_close, | 2109 | .close = via_dig_playback_pcm_close, |
2137 | .prepare = via_dig_playback_pcm_prepare | 2110 | .prepare = via_dig_playback_pcm_prepare, |
2111 | .cleanup = via_dig_playback_pcm_cleanup | ||
2138 | }, | 2112 | }, |
2139 | }; | 2113 | }; |
2140 | 2114 | ||
@@ -2589,14 +2563,15 @@ static struct hda_pcm_stream vt1708S_pcm_analog_capture = { | |||
2589 | }; | 2563 | }; |
2590 | 2564 | ||
2591 | static struct hda_pcm_stream vt1708S_pcm_digital_playback = { | 2565 | static struct hda_pcm_stream vt1708S_pcm_digital_playback = { |
2592 | .substreams = 2, | 2566 | .substreams = 1, |
2593 | .channels_min = 2, | 2567 | .channels_min = 2, |
2594 | .channels_max = 2, | 2568 | .channels_max = 2, |
2595 | /* NID is set in via_build_pcms */ | 2569 | /* NID is set in via_build_pcms */ |
2596 | .ops = { | 2570 | .ops = { |
2597 | .open = via_dig_playback_pcm_open, | 2571 | .open = via_dig_playback_pcm_open, |
2598 | .close = via_dig_playback_pcm_close, | 2572 | .close = via_dig_playback_pcm_close, |
2599 | .prepare = via_dig_playback_pcm_prepare | 2573 | .prepare = via_dig_playback_pcm_prepare, |
2574 | .cleanup = via_dig_playback_pcm_cleanup | ||
2600 | }, | 2575 | }, |
2601 | }; | 2576 | }; |
2602 | 2577 | ||
@@ -2805,14 +2780,37 @@ static int vt1708S_auto_create_analog_input_ctls(struct via_spec *spec, | |||
2805 | return 0; | 2780 | return 0; |
2806 | } | 2781 | } |
2807 | 2782 | ||
2783 | /* fill out digital output widgets; one for master and one for slave outputs */ | ||
2784 | static void fill_dig_outs(struct hda_codec *codec) | ||
2785 | { | ||
2786 | struct via_spec *spec = codec->spec; | ||
2787 | int i; | ||
2788 | |||
2789 | for (i = 0; i < spec->autocfg.dig_outs; i++) { | ||
2790 | hda_nid_t nid; | ||
2791 | int conn; | ||
2792 | |||
2793 | nid = spec->autocfg.dig_out_pins[i]; | ||
2794 | if (!nid) | ||
2795 | continue; | ||
2796 | conn = snd_hda_get_connections(codec, nid, &nid, 1); | ||
2797 | if (conn < 1) | ||
2798 | continue; | ||
2799 | if (!spec->multiout.dig_out_nid) | ||
2800 | spec->multiout.dig_out_nid = nid; | ||
2801 | else { | ||
2802 | spec->slave_dig_outs[0] = nid; | ||
2803 | break; /* at most two dig outs */ | ||
2804 | } | ||
2805 | } | ||
2806 | } | ||
2807 | |||
2808 | static int vt1708S_parse_auto_config(struct hda_codec *codec) | 2808 | static int vt1708S_parse_auto_config(struct hda_codec *codec) |
2809 | { | 2809 | { |
2810 | struct via_spec *spec = codec->spec; | 2810 | struct via_spec *spec = codec->spec; |
2811 | int err; | 2811 | int err; |
2812 | static hda_nid_t vt1708s_ignore[] = {0x21, 0}; | ||
2813 | 2812 | ||
2814 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | 2813 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); |
2815 | vt1708s_ignore); | ||
2816 | if (err < 0) | 2814 | if (err < 0) |
2817 | return err; | 2815 | return err; |
2818 | err = vt1708S_auto_fill_dac_nids(spec, &spec->autocfg); | 2816 | err = vt1708S_auto_fill_dac_nids(spec, &spec->autocfg); |
@@ -2833,10 +2831,7 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec) | |||
2833 | 2831 | ||
2834 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | 2832 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
2835 | 2833 | ||
2836 | if (spec->autocfg.dig_outs) | 2834 | fill_dig_outs(codec); |
2837 | spec->multiout.dig_out_nid = VT1708S_DIGOUT_NID; | ||
2838 | |||
2839 | spec->extra_dig_out_nid = 0x15; | ||
2840 | 2835 | ||
2841 | if (spec->kctls.list) | 2836 | if (spec->kctls.list) |
2842 | spec->mixers[spec->num_mixers++] = spec->kctls.list; | 2837 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
@@ -3000,7 +2995,8 @@ static struct hda_pcm_stream vt1702_pcm_digital_playback = { | |||
3000 | .ops = { | 2995 | .ops = { |
3001 | .open = via_dig_playback_pcm_open, | 2996 | .open = via_dig_playback_pcm_open, |
3002 | .close = via_dig_playback_pcm_close, | 2997 | .close = via_dig_playback_pcm_close, |
3003 | .prepare = via_dig_playback_pcm_prepare | 2998 | .prepare = via_dig_playback_pcm_prepare, |
2999 | .cleanup = via_dig_playback_pcm_cleanup | ||
3004 | }, | 3000 | }, |
3005 | }; | 3001 | }; |
3006 | 3002 | ||
@@ -3128,10 +3124,8 @@ static int vt1702_parse_auto_config(struct hda_codec *codec) | |||
3128 | { | 3124 | { |
3129 | struct via_spec *spec = codec->spec; | 3125 | struct via_spec *spec = codec->spec; |
3130 | int err; | 3126 | int err; |
3131 | static hda_nid_t vt1702_ignore[] = {0x1C, 0}; | ||
3132 | 3127 | ||
3133 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | 3128 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); |
3134 | vt1702_ignore); | ||
3135 | if (err < 0) | 3129 | if (err < 0) |
3136 | return err; | 3130 | return err; |
3137 | err = vt1702_auto_fill_dac_nids(spec, &spec->autocfg); | 3131 | err = vt1702_auto_fill_dac_nids(spec, &spec->autocfg); |
@@ -3152,10 +3146,7 @@ static int vt1702_parse_auto_config(struct hda_codec *codec) | |||
3152 | 3146 | ||
3153 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | 3147 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
3154 | 3148 | ||
3155 | if (spec->autocfg.dig_outs) | 3149 | fill_dig_outs(codec); |
3156 | spec->multiout.dig_out_nid = VT1702_DIGOUT_NID; | ||
3157 | |||
3158 | spec->extra_dig_out_nid = 0x1B; | ||
3159 | 3150 | ||
3160 | if (spec->kctls.list) | 3151 | if (spec->kctls.list) |
3161 | spec->mixers[spec->num_mixers++] = spec->kctls.list; | 3152 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
diff --git a/sound/pci/ice1712/Makefile b/sound/pci/ice1712/Makefile index f99fe089495d..536eae2ccf94 100644 --- a/sound/pci/ice1712/Makefile +++ b/sound/pci/ice1712/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | snd-ice17xx-ak4xxx-objs := ak4xxx.o | 6 | snd-ice17xx-ak4xxx-objs := ak4xxx.o |
7 | snd-ice1712-objs := ice1712.o delta.o hoontech.o ews.o | 7 | snd-ice1712-objs := ice1712.o delta.o hoontech.o ews.o |
8 | snd-ice1724-objs := ice1724.o amp.o revo.o aureon.o vt1720_mobo.o pontis.o prodigy192.o prodigy_hifi.o juli.o phase.o wtm.o se.o | 8 | snd-ice1724-objs := ice1724.o amp.o revo.o aureon.o vt1720_mobo.o pontis.o prodigy192.o prodigy_hifi.o juli.o phase.o wtm.o se.o maya44.o |
9 | 9 | ||
10 | # Toplevel Module Dependency | 10 | # Toplevel Module Dependency |
11 | obj-$(CONFIG_SND_ICE1712) += snd-ice1712.o snd-ice17xx-ak4xxx.o | 11 | obj-$(CONFIG_SND_ICE1712) += snd-ice1712.o snd-ice17xx-ak4xxx.o |
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h index fdae6deba16b..adc909ec125c 100644 --- a/sound/pci/ice1712/ice1712.h +++ b/sound/pci/ice1712/ice1712.h | |||
@@ -335,6 +335,7 @@ struct snd_ice1712 { | |||
335 | unsigned int force_rdma1:1; /* VT1720/4 - RDMA1 as non-spdif */ | 335 | unsigned int force_rdma1:1; /* VT1720/4 - RDMA1 as non-spdif */ |
336 | unsigned int midi_output:1; /* VT1720/4: MIDI output triggered */ | 336 | unsigned int midi_output:1; /* VT1720/4: MIDI output triggered */ |
337 | unsigned int midi_input:1; /* VT1720/4: MIDI input triggered */ | 337 | unsigned int midi_input:1; /* VT1720/4: MIDI input triggered */ |
338 | unsigned int own_routing:1; /* VT1720/4: use own routing ctls */ | ||
338 | unsigned int num_total_dacs; /* total DACs */ | 339 | unsigned int num_total_dacs; /* total DACs */ |
339 | unsigned int num_total_adcs; /* total ADCs */ | 340 | unsigned int num_total_adcs; /* total ADCs */ |
340 | unsigned int cur_rate; /* current rate */ | 341 | unsigned int cur_rate; /* current rate */ |
@@ -458,10 +459,17 @@ static inline int snd_ice1712_gpio_read_bits(struct snd_ice1712 *ice, | |||
458 | return snd_ice1712_gpio_read(ice) & mask; | 459 | return snd_ice1712_gpio_read(ice) & mask; |
459 | } | 460 | } |
460 | 461 | ||
462 | /* route access functions */ | ||
463 | int snd_ice1724_get_route_val(struct snd_ice1712 *ice, int shift); | ||
464 | int snd_ice1724_put_route_val(struct snd_ice1712 *ice, unsigned int val, | ||
465 | int shift); | ||
466 | |||
461 | int snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice); | 467 | int snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice); |
462 | 468 | ||
463 | int snd_ice1712_akm4xxx_init(struct snd_akm4xxx *ak, const struct snd_akm4xxx *template, | 469 | int snd_ice1712_akm4xxx_init(struct snd_akm4xxx *ak, |
464 | const struct snd_ak4xxx_private *priv, struct snd_ice1712 *ice); | 470 | const struct snd_akm4xxx *template, |
471 | const struct snd_ak4xxx_private *priv, | ||
472 | struct snd_ice1712 *ice); | ||
465 | void snd_ice1712_akm4xxx_free(struct snd_ice1712 *ice); | 473 | void snd_ice1712_akm4xxx_free(struct snd_ice1712 *ice); |
466 | int snd_ice1712_akm4xxx_build_controls(struct snd_ice1712 *ice); | 474 | int snd_ice1712_akm4xxx_build_controls(struct snd_ice1712 *ice); |
467 | 475 | ||
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 128510e77a78..36ade77cf371 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include "prodigy192.h" | 49 | #include "prodigy192.h" |
50 | #include "prodigy_hifi.h" | 50 | #include "prodigy_hifi.h" |
51 | #include "juli.h" | 51 | #include "juli.h" |
52 | #include "maya44.h" | ||
52 | #include "phase.h" | 53 | #include "phase.h" |
53 | #include "wtm.h" | 54 | #include "wtm.h" |
54 | #include "se.h" | 55 | #include "se.h" |
@@ -65,6 +66,7 @@ MODULE_SUPPORTED_DEVICE("{" | |||
65 | PRODIGY192_DEVICE_DESC | 66 | PRODIGY192_DEVICE_DESC |
66 | PRODIGY_HIFI_DEVICE_DESC | 67 | PRODIGY_HIFI_DEVICE_DESC |
67 | JULI_DEVICE_DESC | 68 | JULI_DEVICE_DESC |
69 | MAYA44_DEVICE_DESC | ||
68 | PHASE_DEVICE_DESC | 70 | PHASE_DEVICE_DESC |
69 | WTM_DEVICE_DESC | 71 | WTM_DEVICE_DESC |
70 | SE_DEVICE_DESC | 72 | SE_DEVICE_DESC |
@@ -626,7 +628,7 @@ static unsigned char stdclock_set_mclk(struct snd_ice1712 *ice, | |||
626 | return 0; | 628 | return 0; |
627 | } | 629 | } |
628 | 630 | ||
629 | static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, | 631 | static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, |
630 | int force) | 632 | int force) |
631 | { | 633 | { |
632 | unsigned long flags; | 634 | unsigned long flags; |
@@ -634,17 +636,18 @@ static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, | |||
634 | unsigned int i, old_rate; | 636 | unsigned int i, old_rate; |
635 | 637 | ||
636 | if (rate > ice->hw_rates->list[ice->hw_rates->count - 1]) | 638 | if (rate > ice->hw_rates->list[ice->hw_rates->count - 1]) |
637 | return; | 639 | return -EINVAL; |
640 | |||
638 | spin_lock_irqsave(&ice->reg_lock, flags); | 641 | spin_lock_irqsave(&ice->reg_lock, flags); |
639 | if ((inb(ICEMT1724(ice, DMA_CONTROL)) & DMA_STARTS) || | 642 | if ((inb(ICEMT1724(ice, DMA_CONTROL)) & DMA_STARTS) || |
640 | (inb(ICEMT1724(ice, DMA_PAUSE)) & DMA_PAUSES)) { | 643 | (inb(ICEMT1724(ice, DMA_PAUSE)) & DMA_PAUSES)) { |
641 | /* running? we cannot change the rate now... */ | 644 | /* running? we cannot change the rate now... */ |
642 | spin_unlock_irqrestore(&ice->reg_lock, flags); | 645 | spin_unlock_irqrestore(&ice->reg_lock, flags); |
643 | return; | 646 | return -EBUSY; |
644 | } | 647 | } |
645 | if (!force && is_pro_rate_locked(ice)) { | 648 | if (!force && is_pro_rate_locked(ice)) { |
646 | spin_unlock_irqrestore(&ice->reg_lock, flags); | 649 | spin_unlock_irqrestore(&ice->reg_lock, flags); |
647 | return; | 650 | return (rate == ice->cur_rate) ? 0 : -EBUSY; |
648 | } | 651 | } |
649 | 652 | ||
650 | old_rate = ice->get_rate(ice); | 653 | old_rate = ice->get_rate(ice); |
@@ -652,7 +655,7 @@ static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, | |||
652 | ice->set_rate(ice, rate); | 655 | ice->set_rate(ice, rate); |
653 | else if (rate == ice->cur_rate) { | 656 | else if (rate == ice->cur_rate) { |
654 | spin_unlock_irqrestore(&ice->reg_lock, flags); | 657 | spin_unlock_irqrestore(&ice->reg_lock, flags); |
655 | return; | 658 | return 0; |
656 | } | 659 | } |
657 | 660 | ||
658 | ice->cur_rate = rate; | 661 | ice->cur_rate = rate; |
@@ -674,13 +677,15 @@ static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, | |||
674 | } | 677 | } |
675 | if (ice->spdif.ops.setup_rate) | 678 | if (ice->spdif.ops.setup_rate) |
676 | ice->spdif.ops.setup_rate(ice, rate); | 679 | ice->spdif.ops.setup_rate(ice, rate); |
680 | |||
681 | return 0; | ||
677 | } | 682 | } |
678 | 683 | ||
679 | static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream, | 684 | static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream, |
680 | struct snd_pcm_hw_params *hw_params) | 685 | struct snd_pcm_hw_params *hw_params) |
681 | { | 686 | { |
682 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); | 687 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); |
683 | int i, chs; | 688 | int i, chs, err; |
684 | 689 | ||
685 | chs = params_channels(hw_params); | 690 | chs = params_channels(hw_params); |
686 | mutex_lock(&ice->open_mutex); | 691 | mutex_lock(&ice->open_mutex); |
@@ -715,7 +720,11 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream, | |||
715 | } | 720 | } |
716 | } | 721 | } |
717 | mutex_unlock(&ice->open_mutex); | 722 | mutex_unlock(&ice->open_mutex); |
718 | snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); | 723 | |
724 | err = snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); | ||
725 | if (err < 0) | ||
726 | return err; | ||
727 | |||
719 | return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); | 728 | return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); |
720 | } | 729 | } |
721 | 730 | ||
@@ -848,20 +857,39 @@ static snd_pcm_uframes_t snd_vt1724_pcm_pointer(struct snd_pcm_substream *substr | |||
848 | #endif | 857 | #endif |
849 | } | 858 | } |
850 | 859 | ||
851 | static const struct vt1724_pcm_reg vt1724_playback_pro_reg = { | 860 | static const struct vt1724_pcm_reg vt1724_pdma0_reg = { |
852 | .addr = VT1724_MT_PLAYBACK_ADDR, | 861 | .addr = VT1724_MT_PLAYBACK_ADDR, |
853 | .size = VT1724_MT_PLAYBACK_SIZE, | 862 | .size = VT1724_MT_PLAYBACK_SIZE, |
854 | .count = VT1724_MT_PLAYBACK_COUNT, | 863 | .count = VT1724_MT_PLAYBACK_COUNT, |
855 | .start = VT1724_PDMA0_START, | 864 | .start = VT1724_PDMA0_START, |
856 | }; | 865 | }; |
857 | 866 | ||
858 | static const struct vt1724_pcm_reg vt1724_capture_pro_reg = { | 867 | static const struct vt1724_pcm_reg vt1724_pdma4_reg = { |
868 | .addr = VT1724_MT_PDMA4_ADDR, | ||
869 | .size = VT1724_MT_PDMA4_SIZE, | ||
870 | .count = VT1724_MT_PDMA4_COUNT, | ||
871 | .start = VT1724_PDMA4_START, | ||
872 | }; | ||
873 | |||
874 | static const struct vt1724_pcm_reg vt1724_rdma0_reg = { | ||
859 | .addr = VT1724_MT_CAPTURE_ADDR, | 875 | .addr = VT1724_MT_CAPTURE_ADDR, |
860 | .size = VT1724_MT_CAPTURE_SIZE, | 876 | .size = VT1724_MT_CAPTURE_SIZE, |
861 | .count = VT1724_MT_CAPTURE_COUNT, | 877 | .count = VT1724_MT_CAPTURE_COUNT, |
862 | .start = VT1724_RDMA0_START, | 878 | .start = VT1724_RDMA0_START, |
863 | }; | 879 | }; |
864 | 880 | ||
881 | static const struct vt1724_pcm_reg vt1724_rdma1_reg = { | ||
882 | .addr = VT1724_MT_RDMA1_ADDR, | ||
883 | .size = VT1724_MT_RDMA1_SIZE, | ||
884 | .count = VT1724_MT_RDMA1_COUNT, | ||
885 | .start = VT1724_RDMA1_START, | ||
886 | }; | ||
887 | |||
888 | #define vt1724_playback_pro_reg vt1724_pdma0_reg | ||
889 | #define vt1724_playback_spdif_reg vt1724_pdma4_reg | ||
890 | #define vt1724_capture_pro_reg vt1724_rdma0_reg | ||
891 | #define vt1724_capture_spdif_reg vt1724_rdma1_reg | ||
892 | |||
865 | static const struct snd_pcm_hardware snd_vt1724_playback_pro = { | 893 | static const struct snd_pcm_hardware snd_vt1724_playback_pro = { |
866 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 894 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
867 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 895 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
@@ -1077,20 +1105,6 @@ static int __devinit snd_vt1724_pcm_profi(struct snd_ice1712 *ice, int device) | |||
1077 | * SPDIF PCM | 1105 | * SPDIF PCM |
1078 | */ | 1106 | */ |
1079 | 1107 | ||
1080 | static const struct vt1724_pcm_reg vt1724_playback_spdif_reg = { | ||
1081 | .addr = VT1724_MT_PDMA4_ADDR, | ||
1082 | .size = VT1724_MT_PDMA4_SIZE, | ||
1083 | .count = VT1724_MT_PDMA4_COUNT, | ||
1084 | .start = VT1724_PDMA4_START, | ||
1085 | }; | ||
1086 | |||
1087 | static const struct vt1724_pcm_reg vt1724_capture_spdif_reg = { | ||
1088 | .addr = VT1724_MT_RDMA1_ADDR, | ||
1089 | .size = VT1724_MT_RDMA1_SIZE, | ||
1090 | .count = VT1724_MT_RDMA1_COUNT, | ||
1091 | .start = VT1724_RDMA1_START, | ||
1092 | }; | ||
1093 | |||
1094 | /* update spdif control bits; call with reg_lock */ | 1108 | /* update spdif control bits; call with reg_lock */ |
1095 | static void update_spdif_bits(struct snd_ice1712 *ice, unsigned int val) | 1109 | static void update_spdif_bits(struct snd_ice1712 *ice, unsigned int val) |
1096 | { | 1110 | { |
@@ -1963,7 +1977,7 @@ static inline int digital_route_shift(int idx) | |||
1963 | return idx * 3; | 1977 | return idx * 3; |
1964 | } | 1978 | } |
1965 | 1979 | ||
1966 | static int get_route_val(struct snd_ice1712 *ice, int shift) | 1980 | int snd_ice1724_get_route_val(struct snd_ice1712 *ice, int shift) |
1967 | { | 1981 | { |
1968 | unsigned long val; | 1982 | unsigned long val; |
1969 | unsigned char eitem; | 1983 | unsigned char eitem; |
@@ -1982,7 +1996,8 @@ static int get_route_val(struct snd_ice1712 *ice, int shift) | |||
1982 | return eitem; | 1996 | return eitem; |
1983 | } | 1997 | } |
1984 | 1998 | ||
1985 | static int put_route_val(struct snd_ice1712 *ice, unsigned int val, int shift) | 1999 | int snd_ice1724_put_route_val(struct snd_ice1712 *ice, unsigned int val, |
2000 | int shift) | ||
1986 | { | 2001 | { |
1987 | unsigned int old_val, nval; | 2002 | unsigned int old_val, nval; |
1988 | int change; | 2003 | int change; |
@@ -2010,7 +2025,7 @@ static int snd_vt1724_pro_route_analog_get(struct snd_kcontrol *kcontrol, | |||
2010 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 2025 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
2011 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 2026 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
2012 | ucontrol->value.enumerated.item[0] = | 2027 | ucontrol->value.enumerated.item[0] = |
2013 | get_route_val(ice, analog_route_shift(idx)); | 2028 | snd_ice1724_get_route_val(ice, analog_route_shift(idx)); |
2014 | return 0; | 2029 | return 0; |
2015 | } | 2030 | } |
2016 | 2031 | ||
@@ -2019,8 +2034,9 @@ static int snd_vt1724_pro_route_analog_put(struct snd_kcontrol *kcontrol, | |||
2019 | { | 2034 | { |
2020 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 2035 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
2021 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 2036 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
2022 | return put_route_val(ice, ucontrol->value.enumerated.item[0], | 2037 | return snd_ice1724_put_route_val(ice, |
2023 | analog_route_shift(idx)); | 2038 | ucontrol->value.enumerated.item[0], |
2039 | analog_route_shift(idx)); | ||
2024 | } | 2040 | } |
2025 | 2041 | ||
2026 | static int snd_vt1724_pro_route_spdif_get(struct snd_kcontrol *kcontrol, | 2042 | static int snd_vt1724_pro_route_spdif_get(struct snd_kcontrol *kcontrol, |
@@ -2029,7 +2045,7 @@ static int snd_vt1724_pro_route_spdif_get(struct snd_kcontrol *kcontrol, | |||
2029 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 2045 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
2030 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 2046 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
2031 | ucontrol->value.enumerated.item[0] = | 2047 | ucontrol->value.enumerated.item[0] = |
2032 | get_route_val(ice, digital_route_shift(idx)); | 2048 | snd_ice1724_get_route_val(ice, digital_route_shift(idx)); |
2033 | return 0; | 2049 | return 0; |
2034 | } | 2050 | } |
2035 | 2051 | ||
@@ -2038,11 +2054,13 @@ static int snd_vt1724_pro_route_spdif_put(struct snd_kcontrol *kcontrol, | |||
2038 | { | 2054 | { |
2039 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); | 2055 | struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); |
2040 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 2056 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
2041 | return put_route_val(ice, ucontrol->value.enumerated.item[0], | 2057 | return snd_ice1724_put_route_val(ice, |
2042 | digital_route_shift(idx)); | 2058 | ucontrol->value.enumerated.item[0], |
2059 | digital_route_shift(idx)); | ||
2043 | } | 2060 | } |
2044 | 2061 | ||
2045 | static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = { | 2062 | static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = |
2063 | { | ||
2046 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2064 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2047 | .name = "H/W Playback Route", | 2065 | .name = "H/W Playback Route", |
2048 | .info = snd_vt1724_pro_route_info, | 2066 | .info = snd_vt1724_pro_route_info, |
@@ -2109,6 +2127,7 @@ static struct snd_ice1712_card_info *card_tables[] __devinitdata = { | |||
2109 | snd_vt1724_prodigy_hifi_cards, | 2127 | snd_vt1724_prodigy_hifi_cards, |
2110 | snd_vt1724_prodigy192_cards, | 2128 | snd_vt1724_prodigy192_cards, |
2111 | snd_vt1724_juli_cards, | 2129 | snd_vt1724_juli_cards, |
2130 | snd_vt1724_maya44_cards, | ||
2112 | snd_vt1724_phase_cards, | 2131 | snd_vt1724_phase_cards, |
2113 | snd_vt1724_wtm_cards, | 2132 | snd_vt1724_wtm_cards, |
2114 | snd_vt1724_se_cards, | 2133 | snd_vt1724_se_cards, |
@@ -2246,8 +2265,10 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice, | |||
2246 | static void __devinit snd_vt1724_chip_reset(struct snd_ice1712 *ice) | 2265 | static void __devinit snd_vt1724_chip_reset(struct snd_ice1712 *ice) |
2247 | { | 2266 | { |
2248 | outb(VT1724_RESET , ICEREG1724(ice, CONTROL)); | 2267 | outb(VT1724_RESET , ICEREG1724(ice, CONTROL)); |
2268 | inb(ICEREG1724(ice, CONTROL)); /* pci posting flush */ | ||
2249 | msleep(10); | 2269 | msleep(10); |
2250 | outb(0, ICEREG1724(ice, CONTROL)); | 2270 | outb(0, ICEREG1724(ice, CONTROL)); |
2271 | inb(ICEREG1724(ice, CONTROL)); /* pci posting flush */ | ||
2251 | msleep(10); | 2272 | msleep(10); |
2252 | } | 2273 | } |
2253 | 2274 | ||
@@ -2277,9 +2298,12 @@ static int __devinit snd_vt1724_spdif_build_controls(struct snd_ice1712 *ice) | |||
2277 | if (snd_BUG_ON(!ice->pcm)) | 2298 | if (snd_BUG_ON(!ice->pcm)) |
2278 | return -EIO; | 2299 | return -EIO; |
2279 | 2300 | ||
2280 | err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route, ice)); | 2301 | if (!ice->own_routing) { |
2281 | if (err < 0) | 2302 | err = snd_ctl_add(ice->card, |
2282 | return err; | 2303 | snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route, ice)); |
2304 | if (err < 0) | ||
2305 | return err; | ||
2306 | } | ||
2283 | 2307 | ||
2284 | err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_spdif_switch, ice)); | 2308 | err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_spdif_switch, ice)); |
2285 | if (err < 0) | 2309 | if (err < 0) |
@@ -2326,7 +2350,7 @@ static int __devinit snd_vt1724_build_controls(struct snd_ice1712 *ice) | |||
2326 | if (err < 0) | 2350 | if (err < 0) |
2327 | return err; | 2351 | return err; |
2328 | 2352 | ||
2329 | if (ice->num_total_dacs > 0) { | 2353 | if (!ice->own_routing && ice->num_total_dacs > 0) { |
2330 | struct snd_kcontrol_new tmp = snd_vt1724_mixer_pro_analog_route; | 2354 | struct snd_kcontrol_new tmp = snd_vt1724_mixer_pro_analog_route; |
2331 | tmp.count = ice->num_total_dacs; | 2355 | tmp.count = ice->num_total_dacs; |
2332 | if (ice->vt1720 && tmp.count > 2) | 2356 | if (ice->vt1720 && tmp.count > 2) |
diff --git a/sound/pci/ice1712/maya44.c b/sound/pci/ice1712/maya44.c new file mode 100644 index 000000000000..3e1c20ae2f1c --- /dev/null +++ b/sound/pci/ice1712/maya44.c | |||
@@ -0,0 +1,779 @@ | |||
1 | /* | ||
2 | * ALSA driver for ICEnsemble VT1724 (Envy24HT) | ||
3 | * | ||
4 | * Lowlevel functions for ESI Maya44 cards | ||
5 | * | ||
6 | * Copyright (c) 2009 Takashi Iwai <tiwai@suse.de> | ||
7 | * Based on the patches by Rainer Zimmermann <mail@lightshed.de> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include <linux/init.h> | ||
26 | #include <linux/slab.h> | ||
27 | #include <linux/io.h> | ||
28 | #include <sound/core.h> | ||
29 | #include <sound/control.h> | ||
30 | #include <sound/pcm.h> | ||
31 | #include <sound/tlv.h> | ||
32 | |||
33 | #include "ice1712.h" | ||
34 | #include "envy24ht.h" | ||
35 | #include "maya44.h" | ||
36 | |||
37 | /* WM8776 register indexes */ | ||
38 | #define WM8776_REG_HEADPHONE_L 0x00 | ||
39 | #define WM8776_REG_HEADPHONE_R 0x01 | ||
40 | #define WM8776_REG_HEADPHONE_MASTER 0x02 | ||
41 | #define WM8776_REG_DAC_ATTEN_L 0x03 | ||
42 | #define WM8776_REG_DAC_ATTEN_R 0x04 | ||
43 | #define WM8776_REG_DAC_ATTEN_MASTER 0x05 | ||
44 | #define WM8776_REG_DAC_PHASE 0x06 | ||
45 | #define WM8776_REG_DAC_CONTROL 0x07 | ||
46 | #define WM8776_REG_DAC_MUTE 0x08 | ||
47 | #define WM8776_REG_DAC_DEEMPH 0x09 | ||
48 | #define WM8776_REG_DAC_IF_CONTROL 0x0a | ||
49 | #define WM8776_REG_ADC_IF_CONTROL 0x0b | ||
50 | #define WM8776_REG_MASTER_MODE_CONTROL 0x0c | ||
51 | #define WM8776_REG_POWERDOWN 0x0d | ||
52 | #define WM8776_REG_ADC_ATTEN_L 0x0e | ||
53 | #define WM8776_REG_ADC_ATTEN_R 0x0f | ||
54 | #define WM8776_REG_ADC_ALC1 0x10 | ||
55 | #define WM8776_REG_ADC_ALC2 0x11 | ||
56 | #define WM8776_REG_ADC_ALC3 0x12 | ||
57 | #define WM8776_REG_ADC_NOISE_GATE 0x13 | ||
58 | #define WM8776_REG_ADC_LIMITER 0x14 | ||
59 | #define WM8776_REG_ADC_MUX 0x15 | ||
60 | #define WM8776_REG_OUTPUT_MUX 0x16 | ||
61 | #define WM8776_REG_RESET 0x17 | ||
62 | |||
63 | #define WM8776_NUM_REGS 0x18 | ||
64 | |||
65 | /* clock ratio identifiers for snd_wm8776_set_rate() */ | ||
66 | #define WM8776_CLOCK_RATIO_128FS 0 | ||
67 | #define WM8776_CLOCK_RATIO_192FS 1 | ||
68 | #define WM8776_CLOCK_RATIO_256FS 2 | ||
69 | #define WM8776_CLOCK_RATIO_384FS 3 | ||
70 | #define WM8776_CLOCK_RATIO_512FS 4 | ||
71 | #define WM8776_CLOCK_RATIO_768FS 5 | ||
72 | |||
73 | enum { WM_VOL_HP, WM_VOL_DAC, WM_VOL_ADC, WM_NUM_VOLS }; | ||
74 | enum { WM_SW_DAC, WM_SW_BYPASS, WM_NUM_SWITCHES }; | ||
75 | |||
76 | struct snd_wm8776 { | ||
77 | unsigned char addr; | ||
78 | unsigned short regs[WM8776_NUM_REGS]; | ||
79 | unsigned char volumes[WM_NUM_VOLS][2]; | ||
80 | unsigned int switch_bits; | ||
81 | }; | ||
82 | |||
83 | struct snd_maya44 { | ||
84 | struct snd_ice1712 *ice; | ||
85 | struct snd_wm8776 wm[2]; | ||
86 | struct mutex mutex; | ||
87 | }; | ||
88 | |||
89 | |||
90 | /* write the given register and save the data to the cache */ | ||
91 | static void wm8776_write(struct snd_ice1712 *ice, struct snd_wm8776 *wm, | ||
92 | unsigned char reg, unsigned short val) | ||
93 | { | ||
94 | /* | ||
95 | * WM8776 registers are up to 9 bits wide, bit 8 is placed in the LSB | ||
96 | * of the address field | ||
97 | */ | ||
98 | snd_vt1724_write_i2c(ice, wm->addr, | ||
99 | (reg << 1) | ((val >> 8) & 1), | ||
100 | val & 0xff); | ||
101 | wm->regs[reg] = val; | ||
102 | } | ||
103 | |||
104 | /* | ||
105 | * update the given register with and/or mask and save the data to the cache | ||
106 | */ | ||
107 | static int wm8776_write_bits(struct snd_ice1712 *ice, struct snd_wm8776 *wm, | ||
108 | unsigned char reg, | ||
109 | unsigned short mask, unsigned short val) | ||
110 | { | ||
111 | val |= wm->regs[reg] & ~mask; | ||
112 | if (val != wm->regs[reg]) { | ||
113 | wm8776_write(ice, wm, reg, val); | ||
114 | return 1; | ||
115 | } | ||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | |||
120 | /* | ||
121 | * WM8776 volume controls | ||
122 | */ | ||
123 | |||
124 | struct maya_vol_info { | ||
125 | unsigned int maxval; /* volume range: 0..maxval */ | ||
126 | unsigned char regs[2]; /* left and right registers */ | ||
127 | unsigned short mask; /* value mask */ | ||
128 | unsigned short offset; /* zero-value offset */ | ||
129 | unsigned short mute; /* mute bit */ | ||
130 | unsigned short update; /* update bits */ | ||
131 | unsigned char mux_bits[2]; /* extra bits for ADC mute */ | ||
132 | }; | ||
133 | |||
134 | static struct maya_vol_info vol_info[WM_NUM_VOLS] = { | ||
135 | [WM_VOL_HP] = { | ||
136 | .maxval = 80, | ||
137 | .regs = { WM8776_REG_HEADPHONE_L, WM8776_REG_HEADPHONE_R }, | ||
138 | .mask = 0x7f, | ||
139 | .offset = 0x30, | ||
140 | .mute = 0x00, | ||
141 | .update = 0x180, /* update and zero-cross enable */ | ||
142 | }, | ||
143 | [WM_VOL_DAC] = { | ||
144 | .maxval = 255, | ||
145 | .regs = { WM8776_REG_DAC_ATTEN_L, WM8776_REG_DAC_ATTEN_R }, | ||
146 | .mask = 0xff, | ||
147 | .offset = 0x01, | ||
148 | .mute = 0x00, | ||
149 | .update = 0x100, /* zero-cross enable */ | ||
150 | }, | ||
151 | [WM_VOL_ADC] = { | ||
152 | .maxval = 91, | ||
153 | .regs = { WM8776_REG_ADC_ATTEN_L, WM8776_REG_ADC_ATTEN_R }, | ||
154 | .mask = 0xff, | ||
155 | .offset = 0xa5, | ||
156 | .mute = 0xa5, | ||
157 | .update = 0x100, /* update */ | ||
158 | .mux_bits = { 0x80, 0x40 }, /* ADCMUX bits */ | ||
159 | }, | ||
160 | }; | ||
161 | |||
162 | /* | ||
163 | * dB tables | ||
164 | */ | ||
165 | /* headphone output: mute, -73..+6db (1db step) */ | ||
166 | static const DECLARE_TLV_DB_SCALE(db_scale_hp, -7400, 100, 1); | ||
167 | /* DAC output: mute, -127..0db (0.5db step) */ | ||
168 | static const DECLARE_TLV_DB_SCALE(db_scale_dac, -12750, 50, 1); | ||
169 | /* ADC gain: mute, -21..+24db (0.5db step) */ | ||
170 | static const DECLARE_TLV_DB_SCALE(db_scale_adc, -2100, 50, 1); | ||
171 | |||
172 | static int maya_vol_info(struct snd_kcontrol *kcontrol, | ||
173 | struct snd_ctl_elem_info *uinfo) | ||
174 | { | ||
175 | unsigned int idx = kcontrol->private_value; | ||
176 | struct maya_vol_info *vol = &vol_info[idx]; | ||
177 | |||
178 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
179 | uinfo->count = 2; | ||
180 | uinfo->value.integer.min = 0; | ||
181 | uinfo->value.integer.max = vol->maxval; | ||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | static int maya_vol_get(struct snd_kcontrol *kcontrol, | ||
186 | struct snd_ctl_elem_value *ucontrol) | ||
187 | { | ||
188 | struct snd_maya44 *chip = snd_kcontrol_chip(kcontrol); | ||
189 | struct snd_wm8776 *wm = | ||
190 | &chip->wm[snd_ctl_get_ioff(kcontrol, &ucontrol->id)]; | ||
191 | unsigned int idx = kcontrol->private_value; | ||
192 | |||
193 | mutex_lock(&chip->mutex); | ||
194 | ucontrol->value.integer.value[0] = wm->volumes[idx][0]; | ||
195 | ucontrol->value.integer.value[1] = wm->volumes[idx][1]; | ||
196 | mutex_unlock(&chip->mutex); | ||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | static int maya_vol_put(struct snd_kcontrol *kcontrol, | ||
201 | struct snd_ctl_elem_value *ucontrol) | ||
202 | { | ||
203 | struct snd_maya44 *chip = snd_kcontrol_chip(kcontrol); | ||
204 | struct snd_wm8776 *wm = | ||
205 | &chip->wm[snd_ctl_get_ioff(kcontrol, &ucontrol->id)]; | ||
206 | unsigned int idx = kcontrol->private_value; | ||
207 | struct maya_vol_info *vol = &vol_info[idx]; | ||
208 | unsigned int val, data; | ||
209 | int ch, changed = 0; | ||
210 | |||
211 | mutex_lock(&chip->mutex); | ||
212 | for (ch = 0; ch < 2; ch++) { | ||
213 | val = ucontrol->value.integer.value[ch]; | ||
214 | if (val > vol->maxval) | ||
215 | val = vol->maxval; | ||
216 | if (val == wm->volumes[idx][ch]) | ||
217 | continue; | ||
218 | if (!val) | ||
219 | data = vol->mute; | ||
220 | else | ||
221 | data = (val - 1) + vol->offset; | ||
222 | data |= vol->update; | ||
223 | changed |= wm8776_write_bits(chip->ice, wm, vol->regs[ch], | ||
224 | vol->mask | vol->update, data); | ||
225 | if (vol->mux_bits[ch]) | ||
226 | wm8776_write_bits(chip->ice, wm, WM8776_REG_ADC_MUX, | ||
227 | vol->mux_bits[ch], | ||
228 | val ? 0 : vol->mux_bits[ch]); | ||
229 | wm->volumes[idx][ch] = val; | ||
230 | } | ||
231 | mutex_unlock(&chip->mutex); | ||
232 | return changed; | ||
233 | } | ||
234 | |||
235 | /* | ||
236 | * WM8776 switch controls | ||
237 | */ | ||
238 | |||
239 | #define COMPOSE_SW_VAL(idx, reg, mask) ((idx) | ((reg) << 8) | ((mask) << 16)) | ||
240 | #define GET_SW_VAL_IDX(val) ((val) & 0xff) | ||
241 | #define GET_SW_VAL_REG(val) (((val) >> 8) & 0xff) | ||
242 | #define GET_SW_VAL_MASK(val) (((val) >> 16) & 0xff) | ||
243 | |||
244 | #define maya_sw_info snd_ctl_boolean_mono_info | ||
245 | |||
246 | static int maya_sw_get(struct snd_kcontrol *kcontrol, | ||
247 | struct snd_ctl_elem_value *ucontrol) | ||
248 | { | ||
249 | struct snd_maya44 *chip = snd_kcontrol_chip(kcontrol); | ||
250 | struct snd_wm8776 *wm = | ||
251 | &chip->wm[snd_ctl_get_ioff(kcontrol, &ucontrol->id)]; | ||
252 | unsigned int idx = GET_SW_VAL_IDX(kcontrol->private_value); | ||
253 | |||
254 | ucontrol->value.integer.value[0] = (wm->switch_bits >> idx) & 1; | ||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | static int maya_sw_put(struct snd_kcontrol *kcontrol, | ||
259 | struct snd_ctl_elem_value *ucontrol) | ||
260 | { | ||
261 | struct snd_maya44 *chip = snd_kcontrol_chip(kcontrol); | ||
262 | struct snd_wm8776 *wm = | ||
263 | &chip->wm[snd_ctl_get_ioff(kcontrol, &ucontrol->id)]; | ||
264 | unsigned int idx = GET_SW_VAL_IDX(kcontrol->private_value); | ||
265 | unsigned int mask, val; | ||
266 | int changed; | ||
267 | |||
268 | mutex_lock(&chip->mutex); | ||
269 | mask = 1 << idx; | ||
270 | wm->switch_bits &= ~mask; | ||
271 | val = ucontrol->value.integer.value[0]; | ||
272 | if (val) | ||
273 | wm->switch_bits |= mask; | ||
274 | mask = GET_SW_VAL_MASK(kcontrol->private_value); | ||
275 | changed = wm8776_write_bits(chip->ice, wm, | ||
276 | GET_SW_VAL_REG(kcontrol->private_value), | ||
277 | mask, val ? mask : 0); | ||
278 | mutex_unlock(&chip->mutex); | ||
279 | return changed; | ||
280 | } | ||
281 | |||
282 | /* | ||
283 | * GPIO pins (known ones for maya44) | ||
284 | */ | ||
285 | #define GPIO_PHANTOM_OFF 2 | ||
286 | #define GPIO_MIC_RELAY 4 | ||
287 | #define GPIO_SPDIF_IN_INV 5 | ||
288 | #define GPIO_MUST_BE_0 7 | ||
289 | |||
290 | /* | ||
291 | * GPIO switch controls | ||
292 | */ | ||
293 | |||
294 | #define COMPOSE_GPIO_VAL(shift, inv) ((shift) | ((inv) << 8)) | ||
295 | #define GET_GPIO_VAL_SHIFT(val) ((val) & 0xff) | ||
296 | #define GET_GPIO_VAL_INV(val) (((val) >> 8) & 1) | ||
297 | |||
298 | static int maya_set_gpio_bits(struct snd_ice1712 *ice, unsigned int mask, | ||
299 | unsigned int bits) | ||
300 | { | ||
301 | unsigned int data; | ||
302 | data = snd_ice1712_gpio_read(ice); | ||
303 | if ((data & mask) == bits) | ||
304 | return 0; | ||
305 | snd_ice1712_gpio_write(ice, (data & ~mask) | bits); | ||
306 | return 1; | ||
307 | } | ||
308 | |||
309 | #define maya_gpio_sw_info snd_ctl_boolean_mono_info | ||
310 | |||
311 | static int maya_gpio_sw_get(struct snd_kcontrol *kcontrol, | ||
312 | struct snd_ctl_elem_value *ucontrol) | ||
313 | { | ||
314 | struct snd_maya44 *chip = snd_kcontrol_chip(kcontrol); | ||
315 | unsigned int shift = GET_GPIO_VAL_SHIFT(kcontrol->private_value); | ||
316 | unsigned int val; | ||
317 | |||
318 | val = (snd_ice1712_gpio_read(chip->ice) >> shift) & 1; | ||
319 | if (GET_GPIO_VAL_INV(kcontrol->private_value)) | ||
320 | val = !val; | ||
321 | ucontrol->value.integer.value[0] = val; | ||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | static int maya_gpio_sw_put(struct snd_kcontrol *kcontrol, | ||
326 | struct snd_ctl_elem_value *ucontrol) | ||
327 | { | ||
328 | struct snd_maya44 *chip = snd_kcontrol_chip(kcontrol); | ||
329 | unsigned int shift = GET_GPIO_VAL_SHIFT(kcontrol->private_value); | ||
330 | unsigned int val, mask; | ||
331 | int changed; | ||
332 | |||
333 | mutex_lock(&chip->mutex); | ||
334 | mask = 1 << shift; | ||
335 | val = ucontrol->value.integer.value[0]; | ||
336 | if (GET_GPIO_VAL_INV(kcontrol->private_value)) | ||
337 | val = !val; | ||
338 | val = val ? mask : 0; | ||
339 | changed = maya_set_gpio_bits(chip->ice, mask, val); | ||
340 | mutex_unlock(&chip->mutex); | ||
341 | return changed; | ||
342 | } | ||
343 | |||
344 | /* | ||
345 | * capture source selection | ||
346 | */ | ||
347 | |||
348 | /* known working input slots (0-4) */ | ||
349 | #define MAYA_LINE_IN 1 /* in-2 */ | ||
350 | #define MAYA_MIC_IN 4 /* in-5 */ | ||
351 | |||
352 | static void wm8776_select_input(struct snd_maya44 *chip, int idx, int line) | ||
353 | { | ||
354 | wm8776_write_bits(chip->ice, &chip->wm[idx], WM8776_REG_ADC_MUX, | ||
355 | 0x1f, 1 << line); | ||
356 | } | ||
357 | |||
358 | static int maya_rec_src_info(struct snd_kcontrol *kcontrol, | ||
359 | struct snd_ctl_elem_info *uinfo) | ||
360 | { | ||
361 | static char *texts[] = { "Line", "Mic" }; | ||
362 | |||
363 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
364 | uinfo->count = 1; | ||
365 | uinfo->value.enumerated.items = ARRAY_SIZE(texts); | ||
366 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
367 | uinfo->value.enumerated.item = | ||
368 | uinfo->value.enumerated.items - 1; | ||
369 | strcpy(uinfo->value.enumerated.name, | ||
370 | texts[uinfo->value.enumerated.item]); | ||
371 | return 0; | ||
372 | } | ||
373 | |||
374 | static int maya_rec_src_get(struct snd_kcontrol *kcontrol, | ||
375 | struct snd_ctl_elem_value *ucontrol) | ||
376 | { | ||
377 | struct snd_maya44 *chip = snd_kcontrol_chip(kcontrol); | ||
378 | int sel; | ||
379 | |||
380 | if (snd_ice1712_gpio_read(chip->ice) & (1 << GPIO_MIC_RELAY)) | ||
381 | sel = 1; | ||
382 | else | ||
383 | sel = 0; | ||
384 | ucontrol->value.enumerated.item[0] = sel; | ||
385 | return 0; | ||
386 | } | ||
387 | |||
388 | static int maya_rec_src_put(struct snd_kcontrol *kcontrol, | ||
389 | struct snd_ctl_elem_value *ucontrol) | ||
390 | { | ||
391 | struct snd_maya44 *chip = snd_kcontrol_chip(kcontrol); | ||
392 | int sel = ucontrol->value.enumerated.item[0]; | ||
393 | int changed; | ||
394 | |||
395 | mutex_lock(&chip->mutex); | ||
396 | changed = maya_set_gpio_bits(chip->ice, GPIO_MIC_RELAY, | ||
397 | sel ? GPIO_MIC_RELAY : 0); | ||
398 | wm8776_select_input(chip, 0, sel ? MAYA_MIC_IN : MAYA_LINE_IN); | ||
399 | mutex_unlock(&chip->mutex); | ||
400 | return changed; | ||
401 | } | ||
402 | |||
403 | /* | ||
404 | * Maya44 routing switch settings have different meanings than the standard | ||
405 | * ice1724 switches as defined in snd_vt1724_pro_route_info (ice1724.c). | ||
406 | */ | ||
407 | static int maya_pb_route_info(struct snd_kcontrol *kcontrol, | ||
408 | struct snd_ctl_elem_info *uinfo) | ||
409 | { | ||
410 | static char *texts[] = { | ||
411 | "PCM Out", /* 0 */ | ||
412 | "Input 1", "Input 2", "Input 3", "Input 4" | ||
413 | }; | ||
414 | |||
415 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
416 | uinfo->count = 1; | ||
417 | uinfo->value.enumerated.items = ARRAY_SIZE(texts); | ||
418 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
419 | uinfo->value.enumerated.item = | ||
420 | uinfo->value.enumerated.items - 1; | ||
421 | strcpy(uinfo->value.enumerated.name, | ||
422 | texts[uinfo->value.enumerated.item]); | ||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | static int maya_pb_route_shift(int idx) | ||
427 | { | ||
428 | static const unsigned char shift[10] = | ||
429 | { 8, 20, 0, 3, 11, 23, 14, 26, 17, 29 }; | ||
430 | return shift[idx % 10]; | ||
431 | } | ||
432 | |||
433 | static int maya_pb_route_get(struct snd_kcontrol *kcontrol, | ||
434 | struct snd_ctl_elem_value *ucontrol) | ||
435 | { | ||
436 | struct snd_maya44 *chip = snd_kcontrol_chip(kcontrol); | ||
437 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | ||
438 | ucontrol->value.enumerated.item[0] = | ||
439 | snd_ice1724_get_route_val(chip->ice, maya_pb_route_shift(idx)); | ||
440 | return 0; | ||
441 | } | ||
442 | |||
443 | static int maya_pb_route_put(struct snd_kcontrol *kcontrol, | ||
444 | struct snd_ctl_elem_value *ucontrol) | ||
445 | { | ||
446 | struct snd_maya44 *chip = snd_kcontrol_chip(kcontrol); | ||
447 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | ||
448 | return snd_ice1724_put_route_val(chip->ice, | ||
449 | ucontrol->value.enumerated.item[0], | ||
450 | maya_pb_route_shift(idx)); | ||
451 | } | ||
452 | |||
453 | |||
454 | /* | ||
455 | * controls to be added | ||
456 | */ | ||
457 | |||
458 | static struct snd_kcontrol_new maya_controls[] __devinitdata = { | ||
459 | { | ||
460 | .name = "Crossmix Playback Volume", | ||
461 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
462 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | ||
463 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, | ||
464 | .info = maya_vol_info, | ||
465 | .get = maya_vol_get, | ||
466 | .put = maya_vol_put, | ||
467 | .tlv = { .p = db_scale_hp }, | ||
468 | .private_value = WM_VOL_HP, | ||
469 | .count = 2, | ||
470 | }, | ||
471 | { | ||
472 | .name = "PCM Playback Volume", | ||
473 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
474 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | ||
475 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, | ||
476 | .info = maya_vol_info, | ||
477 | .get = maya_vol_get, | ||
478 | .put = maya_vol_put, | ||
479 | .tlv = { .p = db_scale_dac }, | ||
480 | .private_value = WM_VOL_DAC, | ||
481 | .count = 2, | ||
482 | }, | ||
483 | { | ||
484 | .name = "Line Capture Volume", | ||
485 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
486 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | ||
487 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, | ||
488 | .info = maya_vol_info, | ||
489 | .get = maya_vol_get, | ||
490 | .put = maya_vol_put, | ||
491 | .tlv = { .p = db_scale_adc }, | ||
492 | .private_value = WM_VOL_ADC, | ||
493 | .count = 2, | ||
494 | }, | ||
495 | { | ||
496 | .name = "PCM Playback Switch", | ||
497 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
498 | .info = maya_sw_info, | ||
499 | .get = maya_sw_get, | ||
500 | .put = maya_sw_put, | ||
501 | .private_value = COMPOSE_SW_VAL(WM_SW_DAC, | ||
502 | WM8776_REG_OUTPUT_MUX, 0x01), | ||
503 | .count = 2, | ||
504 | }, | ||
505 | { | ||
506 | .name = "Bypass Playback Switch", | ||
507 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
508 | .info = maya_sw_info, | ||
509 | .get = maya_sw_get, | ||
510 | .put = maya_sw_put, | ||
511 | .private_value = COMPOSE_SW_VAL(WM_SW_BYPASS, | ||
512 | WM8776_REG_OUTPUT_MUX, 0x04), | ||
513 | .count = 2, | ||
514 | }, | ||
515 | { | ||
516 | .name = "Capture Source", | ||
517 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
518 | .info = maya_rec_src_info, | ||
519 | .get = maya_rec_src_get, | ||
520 | .put = maya_rec_src_put, | ||
521 | }, | ||
522 | { | ||
523 | .name = "Mic Phantom Power Switch", | ||
524 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
525 | .info = maya_gpio_sw_info, | ||
526 | .get = maya_gpio_sw_get, | ||
527 | .put = maya_gpio_sw_put, | ||
528 | .private_value = COMPOSE_GPIO_VAL(GPIO_PHANTOM_OFF, 1), | ||
529 | }, | ||
530 | { | ||
531 | .name = "SPDIF Capture Switch", | ||
532 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
533 | .info = maya_gpio_sw_info, | ||
534 | .get = maya_gpio_sw_get, | ||
535 | .put = maya_gpio_sw_put, | ||
536 | .private_value = COMPOSE_GPIO_VAL(GPIO_SPDIF_IN_INV, 1), | ||
537 | }, | ||
538 | { | ||
539 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
540 | .name = "H/W Playback Route", | ||
541 | .info = maya_pb_route_info, | ||
542 | .get = maya_pb_route_get, | ||
543 | .put = maya_pb_route_put, | ||
544 | .count = 4, /* FIXME: do controls 5-9 have any meaning? */ | ||
545 | }, | ||
546 | }; | ||
547 | |||
548 | static int __devinit maya44_add_controls(struct snd_ice1712 *ice) | ||
549 | { | ||
550 | int err, i; | ||
551 | |||
552 | for (i = 0; i < ARRAY_SIZE(maya_controls); i++) { | ||
553 | err = snd_ctl_add(ice->card, snd_ctl_new1(&maya_controls[i], | ||
554 | ice->spec)); | ||
555 | if (err < 0) | ||
556 | return err; | ||
557 | } | ||
558 | return 0; | ||
559 | } | ||
560 | |||
561 | |||
562 | /* | ||
563 | * initialize a wm8776 chip | ||
564 | */ | ||
565 | static void __devinit wm8776_init(struct snd_ice1712 *ice, | ||
566 | struct snd_wm8776 *wm, unsigned int addr) | ||
567 | { | ||
568 | static const unsigned short inits_wm8776[] = { | ||
569 | 0x02, 0x100, /* R2: headphone L+R muted + update */ | ||
570 | 0x05, 0x100, /* R5: DAC output L+R muted + update */ | ||
571 | 0x06, 0x000, /* R6: DAC output phase normal */ | ||
572 | 0x07, 0x091, /* R7: DAC enable zero cross detection, | ||
573 | normal output */ | ||
574 | 0x08, 0x000, /* R8: DAC soft mute off */ | ||
575 | 0x09, 0x000, /* R9: no deemph, DAC zero detect disabled */ | ||
576 | 0x0a, 0x022, /* R10: DAC I2C mode, std polarities, 24bit */ | ||
577 | 0x0b, 0x022, /* R11: ADC I2C mode, std polarities, 24bit, | ||
578 | highpass filter enabled */ | ||
579 | 0x0c, 0x042, /* R12: ADC+DAC slave, ADC+DAC 44,1kHz */ | ||
580 | 0x0d, 0x000, /* R13: all power up */ | ||
581 | 0x0e, 0x100, /* R14: ADC left muted, | ||
582 | enable zero cross detection */ | ||
583 | 0x0f, 0x100, /* R15: ADC right muted, | ||
584 | enable zero cross detection */ | ||
585 | /* R16: ALC...*/ | ||
586 | 0x11, 0x000, /* R17: disable ALC */ | ||
587 | /* R18: ALC...*/ | ||
588 | /* R19: noise gate...*/ | ||
589 | 0x15, 0x000, /* R21: ADC input mux init, mute all inputs */ | ||
590 | 0x16, 0x001, /* R22: output mux, select DAC */ | ||
591 | 0xff, 0xff | ||
592 | }; | ||
593 | |||
594 | const unsigned short *ptr; | ||
595 | unsigned char reg; | ||
596 | unsigned short data; | ||
597 | |||
598 | wm->addr = addr; | ||
599 | /* enable DAC output; mute bypass, aux & all inputs */ | ||
600 | wm->switch_bits = (1 << WM_SW_DAC); | ||
601 | |||
602 | ptr = inits_wm8776; | ||
603 | while (*ptr != 0xff) { | ||
604 | reg = *ptr++; | ||
605 | data = *ptr++; | ||
606 | wm8776_write(ice, wm, reg, data); | ||
607 | } | ||
608 | } | ||
609 | |||
610 | |||
611 | /* | ||
612 | * change the rate on the WM8776 codecs. | ||
613 | * this assumes that the VT17xx's rate is changed by the calling function. | ||
614 | * NOTE: even though the WM8776's are running in slave mode and rate | ||
615 | * selection is automatic, we need to call snd_wm8776_set_rate() here | ||
616 | * to make sure some flags are set correctly. | ||
617 | */ | ||
618 | static void set_rate(struct snd_ice1712 *ice, unsigned int rate) | ||
619 | { | ||
620 | struct snd_maya44 *chip = ice->spec; | ||
621 | unsigned int ratio, adc_ratio, val; | ||
622 | int i; | ||
623 | |||
624 | switch (rate) { | ||
625 | case 192000: | ||
626 | ratio = WM8776_CLOCK_RATIO_128FS; | ||
627 | break; | ||
628 | case 176400: | ||
629 | ratio = WM8776_CLOCK_RATIO_128FS; | ||
630 | break; | ||
631 | case 96000: | ||
632 | ratio = WM8776_CLOCK_RATIO_256FS; | ||
633 | break; | ||
634 | case 88200: | ||
635 | ratio = WM8776_CLOCK_RATIO_384FS; | ||
636 | break; | ||
637 | case 48000: | ||
638 | ratio = WM8776_CLOCK_RATIO_512FS; | ||
639 | break; | ||
640 | case 44100: | ||
641 | ratio = WM8776_CLOCK_RATIO_512FS; | ||
642 | break; | ||
643 | case 32000: | ||
644 | ratio = WM8776_CLOCK_RATIO_768FS; | ||
645 | break; | ||
646 | case 0: | ||
647 | /* no hint - S/PDIF input is master, simply return */ | ||
648 | return; | ||
649 | default: | ||
650 | snd_BUG(); | ||
651 | return; | ||
652 | } | ||
653 | |||
654 | /* | ||
655 | * this currently sets the same rate for ADC and DAC, but limits | ||
656 | * ADC rate to 256X (96kHz). For 256X mode (96kHz), this sets ADC | ||
657 | * oversampling to 64x, as recommended by WM8776 datasheet. | ||
658 | * Setting the rate is not really necessary in slave mode. | ||
659 | */ | ||
660 | adc_ratio = ratio; | ||
661 | if (adc_ratio < WM8776_CLOCK_RATIO_256FS) | ||
662 | adc_ratio = WM8776_CLOCK_RATIO_256FS; | ||
663 | |||
664 | val = adc_ratio; | ||
665 | if (adc_ratio == WM8776_CLOCK_RATIO_256FS) | ||
666 | val |= 8; | ||
667 | val |= ratio << 4; | ||
668 | |||
669 | mutex_lock(&chip->mutex); | ||
670 | for (i = 0; i < 2; i++) | ||
671 | wm8776_write_bits(ice, &chip->wm[i], | ||
672 | WM8776_REG_MASTER_MODE_CONTROL, | ||
673 | 0x180, val); | ||
674 | mutex_unlock(&chip->mutex); | ||
675 | } | ||
676 | |||
677 | /* | ||
678 | * supported sample rates (to override the default one) | ||
679 | */ | ||
680 | |||
681 | static unsigned int rates[] = { | ||
682 | 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000 | ||
683 | }; | ||
684 | |||
685 | /* playback rates: 32..192 kHz */ | ||
686 | static struct snd_pcm_hw_constraint_list dac_rates = { | ||
687 | .count = ARRAY_SIZE(rates), | ||
688 | .list = rates, | ||
689 | .mask = 0 | ||
690 | }; | ||
691 | |||
692 | |||
693 | /* | ||
694 | * chip addresses on I2C bus | ||
695 | */ | ||
696 | static unsigned char wm8776_addr[2] __devinitdata = { | ||
697 | 0x34, 0x36, /* codec 0 & 1 */ | ||
698 | }; | ||
699 | |||
700 | /* | ||
701 | * initialize the chip | ||
702 | */ | ||
703 | static int __devinit maya44_init(struct snd_ice1712 *ice) | ||
704 | { | ||
705 | int i; | ||
706 | struct snd_maya44 *chip; | ||
707 | |||
708 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
709 | if (!chip) | ||
710 | return -ENOMEM; | ||
711 | mutex_init(&chip->mutex); | ||
712 | chip->ice = ice; | ||
713 | ice->spec = chip; | ||
714 | |||
715 | /* initialise codecs */ | ||
716 | ice->num_total_dacs = 4; | ||
717 | ice->num_total_adcs = 4; | ||
718 | ice->akm_codecs = 0; | ||
719 | |||
720 | for (i = 0; i < 2; i++) { | ||
721 | wm8776_init(ice, &chip->wm[i], wm8776_addr[i]); | ||
722 | wm8776_select_input(chip, i, MAYA_LINE_IN); | ||
723 | } | ||
724 | |||
725 | /* set card specific rates */ | ||
726 | ice->hw_rates = &dac_rates; | ||
727 | |||
728 | /* register change rate notifier */ | ||
729 | ice->gpio.set_pro_rate = set_rate; | ||
730 | |||
731 | /* RDMA1 (2nd input channel) is used for ADC by default */ | ||
732 | ice->force_rdma1 = 1; | ||
733 | |||
734 | /* have an own routing control */ | ||
735 | ice->own_routing = 1; | ||
736 | |||
737 | return 0; | ||
738 | } | ||
739 | |||
740 | |||
741 | /* | ||
742 | * Maya44 boards don't provide the EEPROM data except for the vendor IDs. | ||
743 | * hence the driver needs to sets up it properly. | ||
744 | */ | ||
745 | |||
746 | static unsigned char maya44_eeprom[] __devinitdata = { | ||
747 | [ICE_EEP2_SYSCONF] = 0x45, | ||
748 | /* clock xin1=49.152MHz, mpu401, 2 stereo ADCs+DACs */ | ||
749 | [ICE_EEP2_ACLINK] = 0x80, | ||
750 | /* I2S */ | ||
751 | [ICE_EEP2_I2S] = 0xf8, | ||
752 | /* vol, 96k, 24bit, 192k */ | ||
753 | [ICE_EEP2_SPDIF] = 0xc3, | ||
754 | /* enable spdif out, spdif out supp, spdif-in, ext spdif out */ | ||
755 | [ICE_EEP2_GPIO_DIR] = 0xff, | ||
756 | [ICE_EEP2_GPIO_DIR1] = 0xff, | ||
757 | [ICE_EEP2_GPIO_DIR2] = 0xff, | ||
758 | [ICE_EEP2_GPIO_MASK] = 0/*0x9f*/, | ||
759 | [ICE_EEP2_GPIO_MASK1] = 0/*0xff*/, | ||
760 | [ICE_EEP2_GPIO_MASK2] = 0/*0x7f*/, | ||
761 | [ICE_EEP2_GPIO_STATE] = (1 << GPIO_PHANTOM_OFF) | | ||
762 | (1 << GPIO_SPDIF_IN_INV), | ||
763 | [ICE_EEP2_GPIO_STATE1] = 0x00, | ||
764 | [ICE_EEP2_GPIO_STATE2] = 0x00, | ||
765 | }; | ||
766 | |||
767 | /* entry point */ | ||
768 | struct snd_ice1712_card_info snd_vt1724_maya44_cards[] __devinitdata = { | ||
769 | { | ||
770 | .subvendor = VT1724_SUBDEVICE_MAYA44, | ||
771 | .name = "ESI Maya44", | ||
772 | .model = "maya44", | ||
773 | .chip_init = maya44_init, | ||
774 | .build_controls = maya44_add_controls, | ||
775 | .eeprom_size = sizeof(maya44_eeprom), | ||
776 | .eeprom_data = maya44_eeprom, | ||
777 | }, | ||
778 | { } /* terminator */ | ||
779 | }; | ||
diff --git a/sound/pci/ice1712/maya44.h b/sound/pci/ice1712/maya44.h new file mode 100644 index 000000000000..eafd03a8f4b5 --- /dev/null +++ b/sound/pci/ice1712/maya44.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __SOUND_MAYA44_H | ||
2 | #define __SOUND_MAYA44_H | ||
3 | |||
4 | #define MAYA44_DEVICE_DESC "{ESI,Maya44}," | ||
5 | |||
6 | #define VT1724_SUBDEVICE_MAYA44 0x34315441 /* Maya44 */ | ||
7 | |||
8 | extern struct snd_ice1712_card_info snd_vt1724_maya44_cards[]; | ||
9 | |||
10 | #endif /* __SOUND_MAYA44_H */ | ||
diff --git a/sound/pci/lx6464es/Makefile b/sound/pci/lx6464es/Makefile new file mode 100644 index 000000000000..eb04a6c73d8b --- /dev/null +++ b/sound/pci/lx6464es/Makefile | |||
@@ -0,0 +1,2 @@ | |||
1 | snd-lx6464es-objs := lx6464es.o lx_core.o | ||
2 | obj-$(CONFIG_SND_LX6464ES) += snd-lx6464es.o | ||
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c new file mode 100644 index 000000000000..ccf1b38c88ea --- /dev/null +++ b/sound/pci/lx6464es/lx6464es.c | |||
@@ -0,0 +1,1159 @@ | |||
1 | /* -*- linux-c -*- * | ||
2 | * | ||
3 | * ALSA driver for the digigram lx6464es interface | ||
4 | * | ||
5 | * Copyright (c) 2008, 2009 Tim Blechmann <tim@klingt.org> | ||
6 | * | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; see the file COPYING. If not, write to | ||
20 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
21 | * Boston, MA 02111-1307, USA. | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include <linux/module.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/pci.h> | ||
28 | #include <linux/delay.h> | ||
29 | |||
30 | #include <sound/initval.h> | ||
31 | #include <sound/control.h> | ||
32 | #include <sound/info.h> | ||
33 | |||
34 | #include "lx6464es.h" | ||
35 | |||
36 | MODULE_AUTHOR("Tim Blechmann"); | ||
37 | MODULE_LICENSE("GPL"); | ||
38 | MODULE_DESCRIPTION("digigram lx6464es"); | ||
39 | MODULE_SUPPORTED_DEVICE("{digigram lx6464es{}}"); | ||
40 | |||
41 | |||
42 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | ||
43 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; | ||
44 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; | ||
45 | |||
46 | module_param_array(index, int, NULL, 0444); | ||
47 | MODULE_PARM_DESC(index, "Index value for Digigram LX6464ES interface."); | ||
48 | module_param_array(id, charp, NULL, 0444); | ||
49 | MODULE_PARM_DESC(id, "ID string for Digigram LX6464ES interface."); | ||
50 | module_param_array(enable, bool, NULL, 0444); | ||
51 | MODULE_PARM_DESC(enable, "Enable/disable specific Digigram LX6464ES soundcards."); | ||
52 | |||
53 | static const char card_name[] = "LX6464ES"; | ||
54 | |||
55 | |||
56 | #define PCI_DEVICE_ID_PLX_LX6464ES PCI_DEVICE_ID_PLX_9056 | ||
57 | |||
58 | static struct pci_device_id snd_lx6464es_ids[] = { | ||
59 | { PCI_DEVICE(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_LX6464ES), | ||
60 | .subvendor = PCI_VENDOR_ID_DIGIGRAM, | ||
61 | .subdevice = PCI_SUBDEVICE_ID_DIGIGRAM_LX6464ES_SERIAL_SUBSYSTEM | ||
62 | }, /* LX6464ES */ | ||
63 | { PCI_DEVICE(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_LX6464ES), | ||
64 | .subvendor = PCI_VENDOR_ID_DIGIGRAM, | ||
65 | .subdevice = PCI_SUBDEVICE_ID_DIGIGRAM_LX6464ES_CAE_SERIAL_SUBSYSTEM | ||
66 | }, /* LX6464ES-CAE */ | ||
67 | { 0, }, | ||
68 | }; | ||
69 | |||
70 | MODULE_DEVICE_TABLE(pci, snd_lx6464es_ids); | ||
71 | |||
72 | |||
73 | |||
74 | /* PGO pour USERo dans le registre pci_0x06/loc_0xEC */ | ||
75 | #define CHIPSC_RESET_XILINX (1L<<16) | ||
76 | |||
77 | |||
78 | /* alsa callbacks */ | ||
79 | static struct snd_pcm_hardware lx_caps = { | ||
80 | .info = (SNDRV_PCM_INFO_MMAP | | ||
81 | SNDRV_PCM_INFO_INTERLEAVED | | ||
82 | SNDRV_PCM_INFO_MMAP_VALID | | ||
83 | SNDRV_PCM_INFO_SYNC_START), | ||
84 | .formats = (SNDRV_PCM_FMTBIT_S16_LE | | ||
85 | SNDRV_PCM_FMTBIT_S16_BE | | ||
86 | SNDRV_PCM_FMTBIT_S24_3LE | | ||
87 | SNDRV_PCM_FMTBIT_S24_3BE), | ||
88 | .rates = (SNDRV_PCM_RATE_CONTINUOUS | | ||
89 | SNDRV_PCM_RATE_8000_192000), | ||
90 | .rate_min = 8000, | ||
91 | .rate_max = 192000, | ||
92 | .channels_min = 2, | ||
93 | .channels_max = 64, | ||
94 | .buffer_bytes_max = 64*2*3*MICROBLAZE_IBL_MAX*MAX_STREAM_BUFFER, | ||
95 | .period_bytes_min = (2*2*MICROBLAZE_IBL_MIN*2), | ||
96 | .period_bytes_max = (4*64*MICROBLAZE_IBL_MAX*MAX_STREAM_BUFFER), | ||
97 | .periods_min = 2, | ||
98 | .periods_max = MAX_STREAM_BUFFER, | ||
99 | }; | ||
100 | |||
101 | static int lx_set_granularity(struct lx6464es *chip, u32 gran); | ||
102 | |||
103 | |||
104 | static int lx_hardware_open(struct lx6464es *chip, | ||
105 | struct snd_pcm_substream *substream) | ||
106 | { | ||
107 | int err = 0; | ||
108 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
109 | int channels = runtime->channels; | ||
110 | int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | ||
111 | |||
112 | snd_pcm_uframes_t period_size = runtime->period_size; | ||
113 | |||
114 | snd_printd(LXP "allocating pipe for %d channels\n", channels); | ||
115 | err = lx_pipe_allocate(chip, 0, is_capture, channels); | ||
116 | if (err < 0) { | ||
117 | snd_printk(KERN_ERR LXP "allocating pipe failed\n"); | ||
118 | return err; | ||
119 | } | ||
120 | |||
121 | err = lx_set_granularity(chip, period_size); | ||
122 | if (err < 0) { | ||
123 | snd_printk(KERN_ERR LXP "setting granularity to %ld failed\n", | ||
124 | period_size); | ||
125 | return err; | ||
126 | } | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static int lx_hardware_start(struct lx6464es *chip, | ||
132 | struct snd_pcm_substream *substream) | ||
133 | { | ||
134 | int err = 0; | ||
135 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
136 | int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | ||
137 | |||
138 | snd_printd(LXP "setting stream format\n"); | ||
139 | err = lx_stream_set_format(chip, runtime, 0, is_capture); | ||
140 | if (err < 0) { | ||
141 | snd_printk(KERN_ERR LXP "setting stream format failed\n"); | ||
142 | return err; | ||
143 | } | ||
144 | |||
145 | snd_printd(LXP "starting pipe\n"); | ||
146 | err = lx_pipe_start(chip, 0, is_capture); | ||
147 | if (err < 0) { | ||
148 | snd_printk(KERN_ERR LXP "starting pipe failed\n"); | ||
149 | return err; | ||
150 | } | ||
151 | |||
152 | snd_printd(LXP "waiting for pipe to start\n"); | ||
153 | err = lx_pipe_wait_for_start(chip, 0, is_capture); | ||
154 | if (err < 0) { | ||
155 | snd_printk(KERN_ERR LXP "waiting for pipe failed\n"); | ||
156 | return err; | ||
157 | } | ||
158 | |||
159 | return err; | ||
160 | } | ||
161 | |||
162 | |||
163 | static int lx_hardware_stop(struct lx6464es *chip, | ||
164 | struct snd_pcm_substream *substream) | ||
165 | { | ||
166 | int err = 0; | ||
167 | int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | ||
168 | |||
169 | snd_printd(LXP "pausing pipe\n"); | ||
170 | err = lx_pipe_pause(chip, 0, is_capture); | ||
171 | if (err < 0) { | ||
172 | snd_printk(KERN_ERR LXP "pausing pipe failed\n"); | ||
173 | return err; | ||
174 | } | ||
175 | |||
176 | snd_printd(LXP "waiting for pipe to become idle\n"); | ||
177 | err = lx_pipe_wait_for_idle(chip, 0, is_capture); | ||
178 | if (err < 0) { | ||
179 | snd_printk(KERN_ERR LXP "waiting for pipe failed\n"); | ||
180 | return err; | ||
181 | } | ||
182 | |||
183 | snd_printd(LXP "stopping pipe\n"); | ||
184 | err = lx_pipe_stop(chip, 0, is_capture); | ||
185 | if (err < 0) { | ||
186 | snd_printk(LXP "stopping pipe failed\n"); | ||
187 | return err; | ||
188 | } | ||
189 | |||
190 | return err; | ||
191 | } | ||
192 | |||
193 | |||
194 | static int lx_hardware_close(struct lx6464es *chip, | ||
195 | struct snd_pcm_substream *substream) | ||
196 | { | ||
197 | int err = 0; | ||
198 | int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | ||
199 | |||
200 | snd_printd(LXP "releasing pipe\n"); | ||
201 | err = lx_pipe_release(chip, 0, is_capture); | ||
202 | if (err < 0) { | ||
203 | snd_printk(LXP "releasing pipe failed\n"); | ||
204 | return err; | ||
205 | } | ||
206 | |||
207 | return err; | ||
208 | } | ||
209 | |||
210 | |||
211 | static int lx_pcm_open(struct snd_pcm_substream *substream) | ||
212 | { | ||
213 | struct lx6464es *chip = snd_pcm_substream_chip(substream); | ||
214 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
215 | int err = 0; | ||
216 | int board_rate; | ||
217 | |||
218 | snd_printdd("->lx_pcm_open\n"); | ||
219 | mutex_lock(&chip->setup_mutex); | ||
220 | |||
221 | /* copy the struct snd_pcm_hardware struct */ | ||
222 | runtime->hw = lx_caps; | ||
223 | |||
224 | #if 0 | ||
225 | /* buffer-size should better be multiple of period-size */ | ||
226 | err = snd_pcm_hw_constraint_integer(runtime, | ||
227 | SNDRV_PCM_HW_PARAM_PERIODS); | ||
228 | if (err < 0) { | ||
229 | snd_printk(KERN_WARNING LXP "could not constrain periods\n"); | ||
230 | goto exit; | ||
231 | } | ||
232 | #endif | ||
233 | |||
234 | /* the clock rate cannot be changed */ | ||
235 | board_rate = chip->board_sample_rate; | ||
236 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, | ||
237 | board_rate, board_rate); | ||
238 | |||
239 | if (err < 0) { | ||
240 | snd_printk(KERN_WARNING LXP "could not constrain periods\n"); | ||
241 | goto exit; | ||
242 | } | ||
243 | |||
244 | /* constrain period size */ | ||
245 | err = snd_pcm_hw_constraint_minmax(runtime, | ||
246 | SNDRV_PCM_HW_PARAM_PERIOD_SIZE, | ||
247 | MICROBLAZE_IBL_MIN, | ||
248 | MICROBLAZE_IBL_MAX); | ||
249 | if (err < 0) { | ||
250 | snd_printk(KERN_WARNING LXP | ||
251 | "could not constrain period size\n"); | ||
252 | goto exit; | ||
253 | } | ||
254 | |||
255 | snd_pcm_hw_constraint_step(runtime, 0, | ||
256 | SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 32); | ||
257 | |||
258 | snd_pcm_set_sync(substream); | ||
259 | err = 0; | ||
260 | |||
261 | exit: | ||
262 | runtime->private_data = chip; | ||
263 | |||
264 | mutex_unlock(&chip->setup_mutex); | ||
265 | snd_printdd("<-lx_pcm_open, %d\n", err); | ||
266 | return err; | ||
267 | } | ||
268 | |||
269 | static int lx_pcm_close(struct snd_pcm_substream *substream) | ||
270 | { | ||
271 | int err = 0; | ||
272 | snd_printdd("->lx_pcm_close\n"); | ||
273 | return err; | ||
274 | } | ||
275 | |||
276 | static snd_pcm_uframes_t lx_pcm_stream_pointer(struct snd_pcm_substream | ||
277 | *substream) | ||
278 | { | ||
279 | struct lx6464es *chip = snd_pcm_substream_chip(substream); | ||
280 | snd_pcm_uframes_t pos; | ||
281 | unsigned long flags; | ||
282 | int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | ||
283 | |||
284 | struct lx_stream *lx_stream = is_capture ? &chip->capture_stream : | ||
285 | &chip->playback_stream; | ||
286 | |||
287 | snd_printdd("->lx_pcm_stream_pointer\n"); | ||
288 | |||
289 | spin_lock_irqsave(&chip->lock, flags); | ||
290 | pos = lx_stream->frame_pos * substream->runtime->period_size; | ||
291 | spin_unlock_irqrestore(&chip->lock, flags); | ||
292 | |||
293 | snd_printdd(LXP "stream_pointer at %ld\n", pos); | ||
294 | return pos; | ||
295 | } | ||
296 | |||
297 | static int lx_pcm_prepare(struct snd_pcm_substream *substream) | ||
298 | { | ||
299 | struct lx6464es *chip = snd_pcm_substream_chip(substream); | ||
300 | int err = 0; | ||
301 | const int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | ||
302 | |||
303 | snd_printdd("->lx_pcm_prepare\n"); | ||
304 | |||
305 | mutex_lock(&chip->setup_mutex); | ||
306 | |||
307 | if (chip->hardware_running[is_capture]) { | ||
308 | err = lx_hardware_stop(chip, substream); | ||
309 | if (err < 0) { | ||
310 | snd_printk(KERN_ERR LXP "failed to stop hardware. " | ||
311 | "Error code %d\n", err); | ||
312 | goto exit; | ||
313 | } | ||
314 | |||
315 | err = lx_hardware_close(chip, substream); | ||
316 | if (err < 0) { | ||
317 | snd_printk(KERN_ERR LXP "failed to close hardware. " | ||
318 | "Error code %d\n", err); | ||
319 | goto exit; | ||
320 | } | ||
321 | } | ||
322 | |||
323 | snd_printd(LXP "opening hardware\n"); | ||
324 | err = lx_hardware_open(chip, substream); | ||
325 | if (err < 0) { | ||
326 | snd_printk(KERN_ERR LXP "failed to open hardware. " | ||
327 | "Error code %d\n", err); | ||
328 | goto exit; | ||
329 | } | ||
330 | |||
331 | err = lx_hardware_start(chip, substream); | ||
332 | if (err < 0) { | ||
333 | snd_printk(KERN_ERR LXP "failed to start hardware. " | ||
334 | "Error code %d\n", err); | ||
335 | goto exit; | ||
336 | } | ||
337 | |||
338 | chip->hardware_running[is_capture] = 1; | ||
339 | |||
340 | if (chip->board_sample_rate != substream->runtime->rate) { | ||
341 | if (!err) | ||
342 | chip->board_sample_rate = substream->runtime->rate; | ||
343 | } | ||
344 | |||
345 | exit: | ||
346 | mutex_unlock(&chip->setup_mutex); | ||
347 | return err; | ||
348 | } | ||
349 | |||
350 | static int lx_pcm_hw_params(struct snd_pcm_substream *substream, | ||
351 | struct snd_pcm_hw_params *hw_params, int is_capture) | ||
352 | { | ||
353 | struct lx6464es *chip = snd_pcm_substream_chip(substream); | ||
354 | int err = 0; | ||
355 | |||
356 | snd_printdd("->lx_pcm_hw_params\n"); | ||
357 | |||
358 | mutex_lock(&chip->setup_mutex); | ||
359 | |||
360 | /* set dma buffer */ | ||
361 | err = snd_pcm_lib_malloc_pages(substream, | ||
362 | params_buffer_bytes(hw_params)); | ||
363 | |||
364 | if (is_capture) | ||
365 | chip->capture_stream.stream = substream; | ||
366 | else | ||
367 | chip->playback_stream.stream = substream; | ||
368 | |||
369 | mutex_unlock(&chip->setup_mutex); | ||
370 | return err; | ||
371 | } | ||
372 | |||
373 | static int lx_pcm_hw_params_playback(struct snd_pcm_substream *substream, | ||
374 | struct snd_pcm_hw_params *hw_params) | ||
375 | { | ||
376 | return lx_pcm_hw_params(substream, hw_params, 0); | ||
377 | } | ||
378 | |||
379 | static int lx_pcm_hw_params_capture(struct snd_pcm_substream *substream, | ||
380 | struct snd_pcm_hw_params *hw_params) | ||
381 | { | ||
382 | return lx_pcm_hw_params(substream, hw_params, 1); | ||
383 | } | ||
384 | |||
385 | static int lx_pcm_hw_free(struct snd_pcm_substream *substream) | ||
386 | { | ||
387 | struct lx6464es *chip = snd_pcm_substream_chip(substream); | ||
388 | int err = 0; | ||
389 | int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | ||
390 | |||
391 | snd_printdd("->lx_pcm_hw_free\n"); | ||
392 | mutex_lock(&chip->setup_mutex); | ||
393 | |||
394 | if (chip->hardware_running[is_capture]) { | ||
395 | err = lx_hardware_stop(chip, substream); | ||
396 | if (err < 0) { | ||
397 | snd_printk(KERN_ERR LXP "failed to stop hardware. " | ||
398 | "Error code %d\n", err); | ||
399 | goto exit; | ||
400 | } | ||
401 | |||
402 | err = lx_hardware_close(chip, substream); | ||
403 | if (err < 0) { | ||
404 | snd_printk(KERN_ERR LXP "failed to close hardware. " | ||
405 | "Error code %d\n", err); | ||
406 | goto exit; | ||
407 | } | ||
408 | |||
409 | chip->hardware_running[is_capture] = 0; | ||
410 | } | ||
411 | |||
412 | err = snd_pcm_lib_free_pages(substream); | ||
413 | |||
414 | if (is_capture) | ||
415 | chip->capture_stream.stream = 0; | ||
416 | else | ||
417 | chip->playback_stream.stream = 0; | ||
418 | |||
419 | exit: | ||
420 | mutex_unlock(&chip->setup_mutex); | ||
421 | return err; | ||
422 | } | ||
423 | |||
424 | static void lx_trigger_start(struct lx6464es *chip, struct lx_stream *lx_stream) | ||
425 | { | ||
426 | struct snd_pcm_substream *substream = lx_stream->stream; | ||
427 | const int is_capture = lx_stream->is_capture; | ||
428 | |||
429 | int err; | ||
430 | |||
431 | const u32 channels = substream->runtime->channels; | ||
432 | const u32 bytes_per_frame = channels * 3; | ||
433 | const u32 period_size = substream->runtime->period_size; | ||
434 | const u32 periods = substream->runtime->periods; | ||
435 | const u32 period_bytes = period_size * bytes_per_frame; | ||
436 | |||
437 | dma_addr_t buf = substream->dma_buffer.addr; | ||
438 | int i; | ||
439 | |||
440 | u32 needed, freed; | ||
441 | u32 size_array[5]; | ||
442 | |||
443 | for (i = 0; i != periods; ++i) { | ||
444 | u32 buffer_index = 0; | ||
445 | |||
446 | err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, | ||
447 | size_array); | ||
448 | snd_printdd(LXP "starting: needed %d, freed %d\n", | ||
449 | needed, freed); | ||
450 | |||
451 | err = lx_buffer_give(chip, 0, is_capture, period_bytes, | ||
452 | lower_32_bits(buf), upper_32_bits(buf), | ||
453 | &buffer_index); | ||
454 | |||
455 | snd_printdd(LXP "starting: buffer index %x on %p (%d bytes)\n", | ||
456 | buffer_index, (void *)buf, period_bytes); | ||
457 | buf += period_bytes; | ||
458 | } | ||
459 | |||
460 | err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array); | ||
461 | snd_printdd(LXP "starting: needed %d, freed %d\n", needed, freed); | ||
462 | |||
463 | snd_printd(LXP "starting: starting stream\n"); | ||
464 | err = lx_stream_start(chip, 0, is_capture); | ||
465 | if (err < 0) | ||
466 | snd_printk(KERN_ERR LXP "couldn't start stream\n"); | ||
467 | else | ||
468 | lx_stream->status = LX_STREAM_STATUS_RUNNING; | ||
469 | |||
470 | lx_stream->frame_pos = 0; | ||
471 | } | ||
472 | |||
473 | static void lx_trigger_stop(struct lx6464es *chip, struct lx_stream *lx_stream) | ||
474 | { | ||
475 | const int is_capture = lx_stream->is_capture; | ||
476 | int err; | ||
477 | |||
478 | snd_printd(LXP "stopping: stopping stream\n"); | ||
479 | err = lx_stream_stop(chip, 0, is_capture); | ||
480 | if (err < 0) | ||
481 | snd_printk(KERN_ERR LXP "couldn't stop stream\n"); | ||
482 | else | ||
483 | lx_stream->status = LX_STREAM_STATUS_FREE; | ||
484 | |||
485 | } | ||
486 | |||
487 | static void lx_trigger_tasklet_dispatch_stream(struct lx6464es *chip, | ||
488 | struct lx_stream *lx_stream) | ||
489 | { | ||
490 | switch (lx_stream->status) { | ||
491 | case LX_STREAM_STATUS_SCHEDULE_RUN: | ||
492 | lx_trigger_start(chip, lx_stream); | ||
493 | break; | ||
494 | |||
495 | case LX_STREAM_STATUS_SCHEDULE_STOP: | ||
496 | lx_trigger_stop(chip, lx_stream); | ||
497 | break; | ||
498 | |||
499 | default: | ||
500 | break; | ||
501 | } | ||
502 | } | ||
503 | |||
504 | static void lx_trigger_tasklet(unsigned long data) | ||
505 | { | ||
506 | struct lx6464es *chip = (struct lx6464es *)data; | ||
507 | unsigned long flags; | ||
508 | |||
509 | snd_printdd("->lx_trigger_tasklet\n"); | ||
510 | |||
511 | spin_lock_irqsave(&chip->lock, flags); | ||
512 | lx_trigger_tasklet_dispatch_stream(chip, &chip->capture_stream); | ||
513 | lx_trigger_tasklet_dispatch_stream(chip, &chip->playback_stream); | ||
514 | spin_unlock_irqrestore(&chip->lock, flags); | ||
515 | } | ||
516 | |||
517 | static int lx_pcm_trigger_dispatch(struct lx6464es *chip, | ||
518 | struct lx_stream *lx_stream, int cmd) | ||
519 | { | ||
520 | int err = 0; | ||
521 | |||
522 | switch (cmd) { | ||
523 | case SNDRV_PCM_TRIGGER_START: | ||
524 | lx_stream->status = LX_STREAM_STATUS_SCHEDULE_RUN; | ||
525 | break; | ||
526 | |||
527 | case SNDRV_PCM_TRIGGER_STOP: | ||
528 | lx_stream->status = LX_STREAM_STATUS_SCHEDULE_STOP; | ||
529 | break; | ||
530 | |||
531 | default: | ||
532 | err = -EINVAL; | ||
533 | goto exit; | ||
534 | } | ||
535 | tasklet_schedule(&chip->trigger_tasklet); | ||
536 | |||
537 | exit: | ||
538 | return err; | ||
539 | } | ||
540 | |||
541 | |||
542 | static int lx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
543 | { | ||
544 | struct lx6464es *chip = snd_pcm_substream_chip(substream); | ||
545 | const int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | ||
546 | struct lx_stream *stream = is_capture ? &chip->capture_stream : | ||
547 | &chip->playback_stream; | ||
548 | |||
549 | snd_printdd("->lx_pcm_trigger\n"); | ||
550 | |||
551 | return lx_pcm_trigger_dispatch(chip, stream, cmd); | ||
552 | } | ||
553 | |||
554 | static int snd_lx6464es_free(struct lx6464es *chip) | ||
555 | { | ||
556 | snd_printdd("->snd_lx6464es_free\n"); | ||
557 | |||
558 | lx_irq_disable(chip); | ||
559 | |||
560 | if (chip->irq >= 0) | ||
561 | free_irq(chip->irq, chip); | ||
562 | |||
563 | iounmap(chip->port_dsp_bar); | ||
564 | ioport_unmap(chip->port_plx_remapped); | ||
565 | |||
566 | pci_release_regions(chip->pci); | ||
567 | pci_disable_device(chip->pci); | ||
568 | |||
569 | kfree(chip); | ||
570 | |||
571 | return 0; | ||
572 | } | ||
573 | |||
574 | static int snd_lx6464es_dev_free(struct snd_device *device) | ||
575 | { | ||
576 | return snd_lx6464es_free(device->device_data); | ||
577 | } | ||
578 | |||
579 | /* reset the dsp during initialization */ | ||
580 | static int __devinit lx_init_xilinx_reset(struct lx6464es *chip) | ||
581 | { | ||
582 | int i; | ||
583 | u32 plx_reg = lx_plx_reg_read(chip, ePLX_CHIPSC); | ||
584 | |||
585 | snd_printdd("->lx_init_xilinx_reset\n"); | ||
586 | |||
587 | /* activate reset of xilinx */ | ||
588 | plx_reg &= ~CHIPSC_RESET_XILINX; | ||
589 | |||
590 | lx_plx_reg_write(chip, ePLX_CHIPSC, plx_reg); | ||
591 | msleep(1); | ||
592 | |||
593 | lx_plx_reg_write(chip, ePLX_MBOX3, 0); | ||
594 | msleep(1); | ||
595 | |||
596 | plx_reg |= CHIPSC_RESET_XILINX; | ||
597 | lx_plx_reg_write(chip, ePLX_CHIPSC, plx_reg); | ||
598 | |||
599 | /* deactivate reset of xilinx */ | ||
600 | for (i = 0; i != 100; ++i) { | ||
601 | u32 reg_mbox3; | ||
602 | msleep(10); | ||
603 | reg_mbox3 = lx_plx_reg_read(chip, ePLX_MBOX3); | ||
604 | if (reg_mbox3) { | ||
605 | snd_printd(LXP "xilinx reset done\n"); | ||
606 | snd_printdd(LXP "xilinx took %d loops\n", i); | ||
607 | break; | ||
608 | } | ||
609 | } | ||
610 | |||
611 | /* todo: add some error handling? */ | ||
612 | |||
613 | /* clear mr */ | ||
614 | lx_dsp_reg_write(chip, eReg_CSM, 0); | ||
615 | |||
616 | /* le xilinx ES peut ne pas etre encore pret, on attend. */ | ||
617 | msleep(600); | ||
618 | |||
619 | return 0; | ||
620 | } | ||
621 | |||
622 | static int __devinit lx_init_xilinx_test(struct lx6464es *chip) | ||
623 | { | ||
624 | u32 reg; | ||
625 | |||
626 | snd_printdd("->lx_init_xilinx_test\n"); | ||
627 | |||
628 | /* TEST if we have access to Xilinx/MicroBlaze */ | ||
629 | lx_dsp_reg_write(chip, eReg_CSM, 0); | ||
630 | |||
631 | reg = lx_dsp_reg_read(chip, eReg_CSM); | ||
632 | |||
633 | if (reg) { | ||
634 | snd_printk(KERN_ERR LXP "Problem: Reg_CSM %x.\n", reg); | ||
635 | |||
636 | /* PCI9056_SPACE0_REMAP */ | ||
637 | lx_plx_reg_write(chip, ePLX_PCICR, 1); | ||
638 | |||
639 | reg = lx_dsp_reg_read(chip, eReg_CSM); | ||
640 | if (reg) { | ||
641 | snd_printk(KERN_ERR LXP "Error: Reg_CSM %x.\n", reg); | ||
642 | return -EAGAIN; /* seems to be appropriate */ | ||
643 | } | ||
644 | } | ||
645 | |||
646 | snd_printd(LXP "Xilinx/MicroBlaze access test successful\n"); | ||
647 | |||
648 | return 0; | ||
649 | } | ||
650 | |||
651 | /* initialize ethersound */ | ||
652 | static int __devinit lx_init_ethersound_config(struct lx6464es *chip) | ||
653 | { | ||
654 | int i; | ||
655 | u32 orig_conf_es = lx_dsp_reg_read(chip, eReg_CONFES); | ||
656 | |||
657 | u32 default_conf_es = (64 << IOCR_OUTPUTS_OFFSET) | | ||
658 | (64 << IOCR_INPUTS_OFFSET) | | ||
659 | (FREQ_RATIO_SINGLE_MODE << FREQ_RATIO_OFFSET); | ||
660 | |||
661 | u32 conf_es = (orig_conf_es & CONFES_READ_PART_MASK) | ||
662 | | (default_conf_es & CONFES_WRITE_PART_MASK); | ||
663 | |||
664 | snd_printdd("->lx_init_ethersound\n"); | ||
665 | |||
666 | chip->freq_ratio = FREQ_RATIO_SINGLE_MODE; | ||
667 | |||
668 | /* | ||
669 | * write it to the card ! | ||
670 | * this actually kicks the ES xilinx, the first time since poweron. | ||
671 | * the MAC address in the Reg_ADMACESMSB Reg_ADMACESLSB registers | ||
672 | * is not ready before this is done, and the bit 2 in Reg_CSES is set. | ||
673 | * */ | ||
674 | lx_dsp_reg_write(chip, eReg_CONFES, conf_es); | ||
675 | |||
676 | for (i = 0; i != 1000; ++i) { | ||
677 | if (lx_dsp_reg_read(chip, eReg_CSES) & 4) { | ||
678 | snd_printd(LXP "ethersound initialized after %dms\n", | ||
679 | i); | ||
680 | goto ethersound_initialized; | ||
681 | } | ||
682 | msleep(1); | ||
683 | } | ||
684 | snd_printk(KERN_WARNING LXP | ||
685 | "ethersound could not be initialized after %dms\n", i); | ||
686 | return -ETIMEDOUT; | ||
687 | |||
688 | ethersound_initialized: | ||
689 | snd_printd(LXP "ethersound initialized\n"); | ||
690 | return 0; | ||
691 | } | ||
692 | |||
693 | static int __devinit lx_init_get_version_features(struct lx6464es *chip) | ||
694 | { | ||
695 | u32 dsp_version; | ||
696 | |||
697 | int err; | ||
698 | |||
699 | snd_printdd("->lx_init_get_version_features\n"); | ||
700 | |||
701 | err = lx_dsp_get_version(chip, &dsp_version); | ||
702 | |||
703 | if (err == 0) { | ||
704 | u32 freq; | ||
705 | |||
706 | snd_printk(LXP "DSP version: V%02d.%02d #%d\n", | ||
707 | (dsp_version>>16) & 0xff, (dsp_version>>8) & 0xff, | ||
708 | dsp_version & 0xff); | ||
709 | |||
710 | /* later: what firmware version do we expect? */ | ||
711 | |||
712 | /* retrieve Play/Rec features */ | ||
713 | /* done here because we may have to handle alternate | ||
714 | * DSP files. */ | ||
715 | /* later */ | ||
716 | |||
717 | /* init the EtherSound sample rate */ | ||
718 | err = lx_dsp_get_clock_frequency(chip, &freq); | ||
719 | if (err == 0) | ||
720 | chip->board_sample_rate = freq; | ||
721 | snd_printd(LXP "actual clock frequency %d\n", freq); | ||
722 | } else { | ||
723 | snd_printk(KERN_ERR LXP "DSP corrupted \n"); | ||
724 | err = -EAGAIN; | ||
725 | } | ||
726 | |||
727 | return err; | ||
728 | } | ||
729 | |||
730 | static int lx_set_granularity(struct lx6464es *chip, u32 gran) | ||
731 | { | ||
732 | int err = 0; | ||
733 | u32 snapped_gran = MICROBLAZE_IBL_MIN; | ||
734 | |||
735 | snd_printdd("->lx_set_granularity\n"); | ||
736 | |||
737 | /* blocksize is a power of 2 */ | ||
738 | while ((snapped_gran < gran) && | ||
739 | (snapped_gran < MICROBLAZE_IBL_MAX)) { | ||
740 | snapped_gran *= 2; | ||
741 | } | ||
742 | |||
743 | if (snapped_gran == chip->pcm_granularity) | ||
744 | return 0; | ||
745 | |||
746 | err = lx_dsp_set_granularity(chip, snapped_gran); | ||
747 | if (err < 0) { | ||
748 | snd_printk(KERN_WARNING LXP "could not set granularity\n"); | ||
749 | err = -EAGAIN; | ||
750 | } | ||
751 | |||
752 | if (snapped_gran != gran) | ||
753 | snd_printk(LXP "snapped blocksize to %d\n", snapped_gran); | ||
754 | |||
755 | snd_printd(LXP "set blocksize on board %d\n", snapped_gran); | ||
756 | chip->pcm_granularity = snapped_gran; | ||
757 | |||
758 | return err; | ||
759 | } | ||
760 | |||
761 | /* initialize and test the xilinx dsp chip */ | ||
762 | static int __devinit lx_init_dsp(struct lx6464es *chip) | ||
763 | { | ||
764 | int err; | ||
765 | u8 mac_address[6]; | ||
766 | int i; | ||
767 | |||
768 | snd_printdd("->lx_init_dsp\n"); | ||
769 | |||
770 | snd_printd(LXP "initialize board\n"); | ||
771 | err = lx_init_xilinx_reset(chip); | ||
772 | if (err) | ||
773 | return err; | ||
774 | |||
775 | snd_printd(LXP "testing board\n"); | ||
776 | err = lx_init_xilinx_test(chip); | ||
777 | if (err) | ||
778 | return err; | ||
779 | |||
780 | snd_printd(LXP "initialize ethersound configuration\n"); | ||
781 | err = lx_init_ethersound_config(chip); | ||
782 | if (err) | ||
783 | return err; | ||
784 | |||
785 | lx_irq_enable(chip); | ||
786 | |||
787 | /** \todo the mac address should be ready by not, but it isn't, | ||
788 | * so we wait for it */ | ||
789 | for (i = 0; i != 1000; ++i) { | ||
790 | err = lx_dsp_get_mac(chip, mac_address); | ||
791 | if (err) | ||
792 | return err; | ||
793 | if (mac_address[0] || mac_address[1] || mac_address[2] || | ||
794 | mac_address[3] || mac_address[4] || mac_address[5]) | ||
795 | goto mac_ready; | ||
796 | msleep(1); | ||
797 | } | ||
798 | return -ETIMEDOUT; | ||
799 | |||
800 | mac_ready: | ||
801 | snd_printd(LXP "mac address ready read after: %dms\n", i); | ||
802 | snd_printk(LXP "mac address: %02X.%02X.%02X.%02X.%02X.%02X\n", | ||
803 | mac_address[0], mac_address[1], mac_address[2], | ||
804 | mac_address[3], mac_address[4], mac_address[5]); | ||
805 | |||
806 | err = lx_init_get_version_features(chip); | ||
807 | if (err) | ||
808 | return err; | ||
809 | |||
810 | lx_set_granularity(chip, MICROBLAZE_IBL_DEFAULT); | ||
811 | |||
812 | chip->playback_mute = 0; | ||
813 | |||
814 | return err; | ||
815 | } | ||
816 | |||
817 | static struct snd_pcm_ops lx_ops_playback = { | ||
818 | .open = lx_pcm_open, | ||
819 | .close = lx_pcm_close, | ||
820 | .ioctl = snd_pcm_lib_ioctl, | ||
821 | .prepare = lx_pcm_prepare, | ||
822 | .hw_params = lx_pcm_hw_params_playback, | ||
823 | .hw_free = lx_pcm_hw_free, | ||
824 | .trigger = lx_pcm_trigger, | ||
825 | .pointer = lx_pcm_stream_pointer, | ||
826 | }; | ||
827 | |||
828 | static struct snd_pcm_ops lx_ops_capture = { | ||
829 | .open = lx_pcm_open, | ||
830 | .close = lx_pcm_close, | ||
831 | .ioctl = snd_pcm_lib_ioctl, | ||
832 | .prepare = lx_pcm_prepare, | ||
833 | .hw_params = lx_pcm_hw_params_capture, | ||
834 | .hw_free = lx_pcm_hw_free, | ||
835 | .trigger = lx_pcm_trigger, | ||
836 | .pointer = lx_pcm_stream_pointer, | ||
837 | }; | ||
838 | |||
839 | static int __devinit lx_pcm_create(struct lx6464es *chip) | ||
840 | { | ||
841 | int err; | ||
842 | struct snd_pcm *pcm; | ||
843 | |||
844 | u32 size = 64 * /* channels */ | ||
845 | 3 * /* 24 bit samples */ | ||
846 | MAX_STREAM_BUFFER * /* periods */ | ||
847 | MICROBLAZE_IBL_MAX * /* frames per period */ | ||
848 | 2; /* duplex */ | ||
849 | |||
850 | size = PAGE_ALIGN(size); | ||
851 | |||
852 | /* hardcoded device name & channel count */ | ||
853 | err = snd_pcm_new(chip->card, (char *)card_name, 0, | ||
854 | 1, 1, &pcm); | ||
855 | |||
856 | pcm->private_data = chip; | ||
857 | |||
858 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &lx_ops_playback); | ||
859 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &lx_ops_capture); | ||
860 | |||
861 | pcm->info_flags = 0; | ||
862 | strcpy(pcm->name, card_name); | ||
863 | |||
864 | err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | ||
865 | snd_dma_pci_data(chip->pci), | ||
866 | size, size); | ||
867 | if (err < 0) | ||
868 | return err; | ||
869 | |||
870 | chip->pcm = pcm; | ||
871 | chip->capture_stream.is_capture = 1; | ||
872 | |||
873 | return 0; | ||
874 | } | ||
875 | |||
876 | static int lx_control_playback_info(struct snd_kcontrol *kcontrol, | ||
877 | struct snd_ctl_elem_info *uinfo) | ||
878 | { | ||
879 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
880 | uinfo->count = 1; | ||
881 | uinfo->value.integer.min = 0; | ||
882 | uinfo->value.integer.max = 1; | ||
883 | return 0; | ||
884 | } | ||
885 | |||
886 | static int lx_control_playback_get(struct snd_kcontrol *kcontrol, | ||
887 | struct snd_ctl_elem_value *ucontrol) | ||
888 | { | ||
889 | struct lx6464es *chip = snd_kcontrol_chip(kcontrol); | ||
890 | ucontrol->value.integer.value[0] = chip->playback_mute; | ||
891 | return 0; | ||
892 | } | ||
893 | |||
894 | static int lx_control_playback_put(struct snd_kcontrol *kcontrol, | ||
895 | struct snd_ctl_elem_value *ucontrol) | ||
896 | { | ||
897 | struct lx6464es *chip = snd_kcontrol_chip(kcontrol); | ||
898 | int changed = 0; | ||
899 | int current_value = chip->playback_mute; | ||
900 | |||
901 | if (current_value != ucontrol->value.integer.value[0]) { | ||
902 | lx_level_unmute(chip, 0, !current_value); | ||
903 | chip->playback_mute = !current_value; | ||
904 | changed = 1; | ||
905 | } | ||
906 | return changed; | ||
907 | } | ||
908 | |||
909 | static struct snd_kcontrol_new lx_control_playback_switch __devinitdata = { | ||
910 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
911 | .name = "PCM Playback Switch", | ||
912 | .index = 0, | ||
913 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, | ||
914 | .private_value = 0, | ||
915 | .info = lx_control_playback_info, | ||
916 | .get = lx_control_playback_get, | ||
917 | .put = lx_control_playback_put | ||
918 | }; | ||
919 | |||
920 | |||
921 | |||
922 | static void lx_proc_levels_read(struct snd_info_entry *entry, | ||
923 | struct snd_info_buffer *buffer) | ||
924 | { | ||
925 | u32 levels[64]; | ||
926 | int err; | ||
927 | int i, j; | ||
928 | struct lx6464es *chip = entry->private_data; | ||
929 | |||
930 | snd_iprintf(buffer, "capture levels:\n"); | ||
931 | err = lx_level_peaks(chip, 1, 64, levels); | ||
932 | if (err < 0) | ||
933 | return; | ||
934 | |||
935 | for (i = 0; i != 8; ++i) { | ||
936 | for (j = 0; j != 8; ++j) | ||
937 | snd_iprintf(buffer, "%08x ", levels[i*8+j]); | ||
938 | snd_iprintf(buffer, "\n"); | ||
939 | } | ||
940 | |||
941 | snd_iprintf(buffer, "\nplayback levels:\n"); | ||
942 | |||
943 | err = lx_level_peaks(chip, 0, 64, levels); | ||
944 | if (err < 0) | ||
945 | return; | ||
946 | |||
947 | for (i = 0; i != 8; ++i) { | ||
948 | for (j = 0; j != 8; ++j) | ||
949 | snd_iprintf(buffer, "%08x ", levels[i*8+j]); | ||
950 | snd_iprintf(buffer, "\n"); | ||
951 | } | ||
952 | |||
953 | snd_iprintf(buffer, "\n"); | ||
954 | } | ||
955 | |||
956 | static int __devinit lx_proc_create(struct snd_card *card, struct lx6464es *chip) | ||
957 | { | ||
958 | struct snd_info_entry *entry; | ||
959 | int err = snd_card_proc_new(card, "levels", &entry); | ||
960 | if (err < 0) | ||
961 | return err; | ||
962 | |||
963 | snd_info_set_text_ops(entry, chip, lx_proc_levels_read); | ||
964 | return 0; | ||
965 | } | ||
966 | |||
967 | |||
968 | static int __devinit snd_lx6464es_create(struct snd_card *card, | ||
969 | struct pci_dev *pci, | ||
970 | struct lx6464es **rchip) | ||
971 | { | ||
972 | struct lx6464es *chip; | ||
973 | int err; | ||
974 | |||
975 | static struct snd_device_ops ops = { | ||
976 | .dev_free = snd_lx6464es_dev_free, | ||
977 | }; | ||
978 | |||
979 | snd_printdd("->snd_lx6464es_create\n"); | ||
980 | |||
981 | *rchip = NULL; | ||
982 | |||
983 | /* enable PCI device */ | ||
984 | err = pci_enable_device(pci); | ||
985 | if (err < 0) | ||
986 | return err; | ||
987 | |||
988 | pci_set_master(pci); | ||
989 | |||
990 | /* check if we can restrict PCI DMA transfers to 32 bits */ | ||
991 | err = pci_set_dma_mask(pci, DMA_32BIT_MASK); | ||
992 | if (err < 0) { | ||
993 | snd_printk(KERN_ERR "architecture does not support " | ||
994 | "32bit PCI busmaster DMA\n"); | ||
995 | pci_disable_device(pci); | ||
996 | return -ENXIO; | ||
997 | } | ||
998 | |||
999 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
1000 | if (chip == NULL) { | ||
1001 | err = -ENOMEM; | ||
1002 | goto alloc_failed; | ||
1003 | } | ||
1004 | |||
1005 | chip->card = card; | ||
1006 | chip->pci = pci; | ||
1007 | chip->irq = -1; | ||
1008 | |||
1009 | /* initialize synchronization structs */ | ||
1010 | spin_lock_init(&chip->lock); | ||
1011 | spin_lock_init(&chip->msg_lock); | ||
1012 | mutex_init(&chip->setup_mutex); | ||
1013 | tasklet_init(&chip->trigger_tasklet, lx_trigger_tasklet, | ||
1014 | (unsigned long)chip); | ||
1015 | tasklet_init(&chip->tasklet_capture, lx_tasklet_capture, | ||
1016 | (unsigned long)chip); | ||
1017 | tasklet_init(&chip->tasklet_playback, lx_tasklet_playback, | ||
1018 | (unsigned long)chip); | ||
1019 | |||
1020 | /* request resources */ | ||
1021 | err = pci_request_regions(pci, card_name); | ||
1022 | if (err < 0) | ||
1023 | goto request_regions_failed; | ||
1024 | |||
1025 | /* plx port */ | ||
1026 | chip->port_plx = pci_resource_start(pci, 1); | ||
1027 | chip->port_plx_remapped = ioport_map(chip->port_plx, | ||
1028 | pci_resource_len(pci, 1)); | ||
1029 | |||
1030 | /* dsp port */ | ||
1031 | chip->port_dsp_bar = pci_ioremap_bar(pci, 2); | ||
1032 | |||
1033 | err = request_irq(pci->irq, lx_interrupt, IRQF_SHARED, | ||
1034 | card_name, chip); | ||
1035 | if (err) { | ||
1036 | snd_printk(KERN_ERR LXP "unable to grab IRQ %d\n", pci->irq); | ||
1037 | goto request_irq_failed; | ||
1038 | } | ||
1039 | chip->irq = pci->irq; | ||
1040 | |||
1041 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); | ||
1042 | if (err < 0) | ||
1043 | goto device_new_failed; | ||
1044 | |||
1045 | err = lx_init_dsp(chip); | ||
1046 | if (err < 0) { | ||
1047 | snd_printk(KERN_ERR LXP "error during DSP initialization\n"); | ||
1048 | return err; | ||
1049 | } | ||
1050 | |||
1051 | err = lx_pcm_create(chip); | ||
1052 | if (err < 0) | ||
1053 | return err; | ||
1054 | |||
1055 | err = lx_proc_create(card, chip); | ||
1056 | if (err < 0) | ||
1057 | return err; | ||
1058 | |||
1059 | err = snd_ctl_add(card, snd_ctl_new1(&lx_control_playback_switch, | ||
1060 | chip)); | ||
1061 | if (err < 0) | ||
1062 | return err; | ||
1063 | |||
1064 | snd_card_set_dev(card, &pci->dev); | ||
1065 | |||
1066 | *rchip = chip; | ||
1067 | return 0; | ||
1068 | |||
1069 | device_new_failed: | ||
1070 | free_irq(pci->irq, chip); | ||
1071 | |||
1072 | request_irq_failed: | ||
1073 | pci_release_regions(pci); | ||
1074 | |||
1075 | request_regions_failed: | ||
1076 | kfree(chip); | ||
1077 | |||
1078 | alloc_failed: | ||
1079 | pci_disable_device(pci); | ||
1080 | |||
1081 | return err; | ||
1082 | } | ||
1083 | |||
1084 | static int __devinit snd_lx6464es_probe(struct pci_dev *pci, | ||
1085 | const struct pci_device_id *pci_id) | ||
1086 | { | ||
1087 | static int dev; | ||
1088 | struct snd_card *card; | ||
1089 | struct lx6464es *chip; | ||
1090 | int err; | ||
1091 | |||
1092 | snd_printdd("->snd_lx6464es_probe\n"); | ||
1093 | |||
1094 | if (dev >= SNDRV_CARDS) | ||
1095 | return -ENODEV; | ||
1096 | if (!enable[dev]) { | ||
1097 | dev++; | ||
1098 | return -ENOENT; | ||
1099 | } | ||
1100 | |||
1101 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); | ||
1102 | if (err < 0) | ||
1103 | return err; | ||
1104 | |||
1105 | err = snd_lx6464es_create(card, pci, &chip); | ||
1106 | if (err < 0) { | ||
1107 | snd_printk(KERN_ERR LXP "error during snd_lx6464es_create\n"); | ||
1108 | goto out_free; | ||
1109 | } | ||
1110 | |||
1111 | strcpy(card->driver, "lx6464es"); | ||
1112 | strcpy(card->shortname, "Digigram LX6464ES"); | ||
1113 | sprintf(card->longname, "%s at 0x%lx, 0x%p, irq %i", | ||
1114 | card->shortname, chip->port_plx, | ||
1115 | chip->port_dsp_bar, chip->irq); | ||
1116 | |||
1117 | err = snd_card_register(card); | ||
1118 | if (err < 0) | ||
1119 | goto out_free; | ||
1120 | |||
1121 | snd_printdd(LXP "initialization successful\n"); | ||
1122 | pci_set_drvdata(pci, card); | ||
1123 | dev++; | ||
1124 | return 0; | ||
1125 | |||
1126 | out_free: | ||
1127 | snd_card_free(card); | ||
1128 | return err; | ||
1129 | |||
1130 | } | ||
1131 | |||
1132 | static void __devexit snd_lx6464es_remove(struct pci_dev *pci) | ||
1133 | { | ||
1134 | snd_card_free(pci_get_drvdata(pci)); | ||
1135 | pci_set_drvdata(pci, NULL); | ||
1136 | } | ||
1137 | |||
1138 | |||
1139 | static struct pci_driver driver = { | ||
1140 | .name = "Digigram LX6464ES", | ||
1141 | .id_table = snd_lx6464es_ids, | ||
1142 | .probe = snd_lx6464es_probe, | ||
1143 | .remove = __devexit_p(snd_lx6464es_remove), | ||
1144 | }; | ||
1145 | |||
1146 | |||
1147 | /* module initialization */ | ||
1148 | static int __init mod_init(void) | ||
1149 | { | ||
1150 | return pci_register_driver(&driver); | ||
1151 | } | ||
1152 | |||
1153 | static void __exit mod_exit(void) | ||
1154 | { | ||
1155 | pci_unregister_driver(&driver); | ||
1156 | } | ||
1157 | |||
1158 | module_init(mod_init); | ||
1159 | module_exit(mod_exit); | ||
diff --git a/sound/pci/lx6464es/lx6464es.h b/sound/pci/lx6464es/lx6464es.h new file mode 100644 index 000000000000..012c010c8c89 --- /dev/null +++ b/sound/pci/lx6464es/lx6464es.h | |||
@@ -0,0 +1,114 @@ | |||
1 | /* -*- linux-c -*- * | ||
2 | * | ||
3 | * ALSA driver for the digigram lx6464es interface | ||
4 | * | ||
5 | * Copyright (c) 2009 Tim Blechmann <tim@klingt.org> | ||
6 | * | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; see the file COPYING. If not, write to | ||
20 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
21 | * Boston, MA 02111-1307, USA. | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #ifndef LX6464ES_H | ||
26 | #define LX6464ES_H | ||
27 | |||
28 | #include <linux/spinlock.h> | ||
29 | #include <asm/atomic.h> | ||
30 | |||
31 | #include <sound/core.h> | ||
32 | #include <sound/pcm.h> | ||
33 | |||
34 | #include "lx_core.h" | ||
35 | |||
36 | #define LXP "LX6464ES: " | ||
37 | |||
38 | enum { | ||
39 | ES_cmd_free = 0, /* no command executing */ | ||
40 | ES_cmd_processing = 1, /* execution of a read/write command */ | ||
41 | ES_read_pending = 2, /* a asynchron read command is pending */ | ||
42 | ES_read_finishing = 3, /* a read command has finished waiting (set by | ||
43 | * Interrupt or CancelIrp) */ | ||
44 | }; | ||
45 | |||
46 | enum lx_stream_status { | ||
47 | LX_STREAM_STATUS_FREE, | ||
48 | /* LX_STREAM_STATUS_OPEN, */ | ||
49 | LX_STREAM_STATUS_SCHEDULE_RUN, | ||
50 | /* LX_STREAM_STATUS_STARTED, */ | ||
51 | LX_STREAM_STATUS_RUNNING, | ||
52 | LX_STREAM_STATUS_SCHEDULE_STOP, | ||
53 | /* LX_STREAM_STATUS_STOPPED, */ | ||
54 | /* LX_STREAM_STATUS_PAUSED */ | ||
55 | }; | ||
56 | |||
57 | |||
58 | struct lx_stream { | ||
59 | struct snd_pcm_substream *stream; | ||
60 | snd_pcm_uframes_t frame_pos; | ||
61 | enum lx_stream_status status; /* free, open, running, draining | ||
62 | * pause */ | ||
63 | int is_capture:1; | ||
64 | }; | ||
65 | |||
66 | |||
67 | struct lx6464es { | ||
68 | struct snd_card *card; | ||
69 | struct pci_dev *pci; | ||
70 | int irq; | ||
71 | |||
72 | spinlock_t lock; /* interrupt spinlock */ | ||
73 | struct mutex setup_mutex; /* mutex used in hw_params, open | ||
74 | * and close */ | ||
75 | |||
76 | struct tasklet_struct trigger_tasklet; /* trigger tasklet */ | ||
77 | struct tasklet_struct tasklet_capture; | ||
78 | struct tasklet_struct tasklet_playback; | ||
79 | |||
80 | /* ports */ | ||
81 | unsigned long port_plx; /* io port (size=256) */ | ||
82 | void __iomem *port_plx_remapped; /* remapped plx port */ | ||
83 | void __iomem *port_dsp_bar; /* memory port (32-bit, | ||
84 | * non-prefetchable, | ||
85 | * size=8K) */ | ||
86 | |||
87 | /* messaging */ | ||
88 | spinlock_t msg_lock; /* message spinlock */ | ||
89 | atomic_t send_message_locked; | ||
90 | struct lx_rmh rmh; | ||
91 | |||
92 | /* configuration */ | ||
93 | uint freq_ratio : 2; | ||
94 | uint playback_mute : 1; | ||
95 | uint hardware_running[2]; | ||
96 | u32 board_sample_rate; /* sample rate read from | ||
97 | * board */ | ||
98 | u32 sample_rate; /* our sample rate */ | ||
99 | u16 pcm_granularity; /* board blocksize */ | ||
100 | |||
101 | /* dma */ | ||
102 | struct snd_dma_buffer capture_dma_buf; | ||
103 | struct snd_dma_buffer playback_dma_buf; | ||
104 | |||
105 | /* pcm */ | ||
106 | struct snd_pcm *pcm; | ||
107 | |||
108 | /* streams */ | ||
109 | struct lx_stream capture_stream; | ||
110 | struct lx_stream playback_stream; | ||
111 | }; | ||
112 | |||
113 | |||
114 | #endif /* LX6464ES_H */ | ||
diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c new file mode 100644 index 000000000000..5812780d6e89 --- /dev/null +++ b/sound/pci/lx6464es/lx_core.c | |||
@@ -0,0 +1,1444 @@ | |||
1 | /* -*- linux-c -*- * | ||
2 | * | ||
3 | * ALSA driver for the digigram lx6464es interface | ||
4 | * low-level interface | ||
5 | * | ||
6 | * Copyright (c) 2009 Tim Blechmann <tim@klingt.org> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; see the file COPYING. If not, write to | ||
20 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
21 | * Boston, MA 02111-1307, USA. | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | /* #define RMH_DEBUG 1 */ | ||
26 | |||
27 | #include <linux/module.h> | ||
28 | #include <linux/pci.h> | ||
29 | #include <linux/delay.h> | ||
30 | |||
31 | #include "lx6464es.h" | ||
32 | #include "lx_core.h" | ||
33 | |||
34 | /* low-level register access */ | ||
35 | |||
36 | static const unsigned long dsp_port_offsets[] = { | ||
37 | 0, | ||
38 | 0x400, | ||
39 | 0x401, | ||
40 | 0x402, | ||
41 | 0x403, | ||
42 | 0x404, | ||
43 | 0x405, | ||
44 | 0x406, | ||
45 | 0x407, | ||
46 | 0x408, | ||
47 | 0x409, | ||
48 | 0x40a, | ||
49 | 0x40b, | ||
50 | 0x40c, | ||
51 | |||
52 | 0x410, | ||
53 | 0x411, | ||
54 | 0x412, | ||
55 | 0x413, | ||
56 | 0x414, | ||
57 | 0x415, | ||
58 | 0x416, | ||
59 | |||
60 | 0x420, | ||
61 | 0x430, | ||
62 | 0x431, | ||
63 | 0x432, | ||
64 | 0x433, | ||
65 | 0x434, | ||
66 | 0x440 | ||
67 | }; | ||
68 | |||
69 | static void __iomem *lx_dsp_register(struct lx6464es *chip, int port) | ||
70 | { | ||
71 | void __iomem *base_address = chip->port_dsp_bar; | ||
72 | return base_address + dsp_port_offsets[port]*4; | ||
73 | } | ||
74 | |||
75 | unsigned long lx_dsp_reg_read(struct lx6464es *chip, int port) | ||
76 | { | ||
77 | void __iomem *address = lx_dsp_register(chip, port); | ||
78 | return ioread32(address); | ||
79 | } | ||
80 | |||
81 | void lx_dsp_reg_readbuf(struct lx6464es *chip, int port, u32 *data, u32 len) | ||
82 | { | ||
83 | void __iomem *address = lx_dsp_register(chip, port); | ||
84 | memcpy_fromio(data, address, len*sizeof(u32)); | ||
85 | } | ||
86 | |||
87 | |||
88 | void lx_dsp_reg_write(struct lx6464es *chip, int port, unsigned data) | ||
89 | { | ||
90 | void __iomem *address = lx_dsp_register(chip, port); | ||
91 | iowrite32(data, address); | ||
92 | } | ||
93 | |||
94 | void lx_dsp_reg_writebuf(struct lx6464es *chip, int port, const u32 *data, | ||
95 | u32 len) | ||
96 | { | ||
97 | void __iomem *address = lx_dsp_register(chip, port); | ||
98 | memcpy_toio(address, data, len*sizeof(u32)); | ||
99 | } | ||
100 | |||
101 | |||
102 | static const unsigned long plx_port_offsets[] = { | ||
103 | 0x04, | ||
104 | 0x40, | ||
105 | 0x44, | ||
106 | 0x48, | ||
107 | 0x4c, | ||
108 | 0x50, | ||
109 | 0x54, | ||
110 | 0x58, | ||
111 | 0x5c, | ||
112 | 0x64, | ||
113 | 0x68, | ||
114 | 0x6C | ||
115 | }; | ||
116 | |||
117 | static void __iomem *lx_plx_register(struct lx6464es *chip, int port) | ||
118 | { | ||
119 | void __iomem *base_address = chip->port_plx_remapped; | ||
120 | return base_address + plx_port_offsets[port]; | ||
121 | } | ||
122 | |||
123 | unsigned long lx_plx_reg_read(struct lx6464es *chip, int port) | ||
124 | { | ||
125 | void __iomem *address = lx_plx_register(chip, port); | ||
126 | return ioread32(address); | ||
127 | } | ||
128 | |||
129 | void lx_plx_reg_write(struct lx6464es *chip, int port, u32 data) | ||
130 | { | ||
131 | void __iomem *address = lx_plx_register(chip, port); | ||
132 | iowrite32(data, address); | ||
133 | } | ||
134 | |||
135 | u32 lx_plx_mbox_read(struct lx6464es *chip, int mbox_nr) | ||
136 | { | ||
137 | int index; | ||
138 | |||
139 | switch (mbox_nr) { | ||
140 | case 1: | ||
141 | index = ePLX_MBOX1; break; | ||
142 | case 2: | ||
143 | index = ePLX_MBOX2; break; | ||
144 | case 3: | ||
145 | index = ePLX_MBOX3; break; | ||
146 | case 4: | ||
147 | index = ePLX_MBOX4; break; | ||
148 | case 5: | ||
149 | index = ePLX_MBOX5; break; | ||
150 | case 6: | ||
151 | index = ePLX_MBOX6; break; | ||
152 | case 7: | ||
153 | index = ePLX_MBOX7; break; | ||
154 | case 0: /* reserved for HF flags */ | ||
155 | snd_BUG(); | ||
156 | default: | ||
157 | return 0xdeadbeef; | ||
158 | } | ||
159 | |||
160 | return lx_plx_reg_read(chip, index); | ||
161 | } | ||
162 | |||
163 | int lx_plx_mbox_write(struct lx6464es *chip, int mbox_nr, u32 value) | ||
164 | { | ||
165 | int index = -1; | ||
166 | |||
167 | switch (mbox_nr) { | ||
168 | case 1: | ||
169 | index = ePLX_MBOX1; break; | ||
170 | case 3: | ||
171 | index = ePLX_MBOX3; break; | ||
172 | case 4: | ||
173 | index = ePLX_MBOX4; break; | ||
174 | case 5: | ||
175 | index = ePLX_MBOX5; break; | ||
176 | case 6: | ||
177 | index = ePLX_MBOX6; break; | ||
178 | case 7: | ||
179 | index = ePLX_MBOX7; break; | ||
180 | case 0: /* reserved for HF flags */ | ||
181 | case 2: /* reserved for Pipe States | ||
182 | * the DSP keeps an image of it */ | ||
183 | snd_BUG(); | ||
184 | return -EBADRQC; | ||
185 | } | ||
186 | |||
187 | lx_plx_reg_write(chip, index, value); | ||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | |||
192 | /* rmh */ | ||
193 | |||
194 | #ifdef CONFIG_SND_DEBUG | ||
195 | #define CMD_NAME(a) a | ||
196 | #else | ||
197 | #define CMD_NAME(a) NULL | ||
198 | #endif | ||
199 | |||
200 | #define Reg_CSM_MR 0x00000002 | ||
201 | #define Reg_CSM_MC 0x00000001 | ||
202 | |||
203 | struct dsp_cmd_info { | ||
204 | u32 dcCodeOp; /* Op Code of the command (usually 1st 24-bits | ||
205 | * word).*/ | ||
206 | u16 dcCmdLength; /* Command length in words of 24 bits.*/ | ||
207 | u16 dcStatusType; /* Status type: 0 for fixed length, 1 for | ||
208 | * random. */ | ||
209 | u16 dcStatusLength; /* Status length (if fixed).*/ | ||
210 | char *dcOpName; | ||
211 | }; | ||
212 | |||
213 | /* | ||
214 | Initialization and control data for the Microblaze interface | ||
215 | - OpCode: | ||
216 | the opcode field of the command set at the proper offset | ||
217 | - CmdLength | ||
218 | the number of command words | ||
219 | - StatusType | ||
220 | offset in the status registers: 0 means that the return value may be | ||
221 | different from 0, and must be read | ||
222 | - StatusLength | ||
223 | the number of status words (in addition to the return value) | ||
224 | */ | ||
225 | |||
226 | static struct dsp_cmd_info dsp_commands[] = | ||
227 | { | ||
228 | { (CMD_00_INFO_DEBUG << OPCODE_OFFSET) , 1 /*custom*/ | ||
229 | , 1 , 0 /**/ , CMD_NAME("INFO_DEBUG") }, | ||
230 | { (CMD_01_GET_SYS_CFG << OPCODE_OFFSET) , 1 /**/ | ||
231 | , 1 , 2 /**/ , CMD_NAME("GET_SYS_CFG") }, | ||
232 | { (CMD_02_SET_GRANULARITY << OPCODE_OFFSET) , 1 /**/ | ||
233 | , 1 , 0 /**/ , CMD_NAME("SET_GRANULARITY") }, | ||
234 | { (CMD_03_SET_TIMER_IRQ << OPCODE_OFFSET) , 1 /**/ | ||
235 | , 1 , 0 /**/ , CMD_NAME("SET_TIMER_IRQ") }, | ||
236 | { (CMD_04_GET_EVENT << OPCODE_OFFSET) , 1 /**/ | ||
237 | , 1 , 0 /*up to 10*/ , CMD_NAME("GET_EVENT") }, | ||
238 | { (CMD_05_GET_PIPES << OPCODE_OFFSET) , 1 /**/ | ||
239 | , 1 , 2 /*up to 4*/ , CMD_NAME("GET_PIPES") }, | ||
240 | { (CMD_06_ALLOCATE_PIPE << OPCODE_OFFSET) , 1 /**/ | ||
241 | , 0 , 0 /**/ , CMD_NAME("ALLOCATE_PIPE") }, | ||
242 | { (CMD_07_RELEASE_PIPE << OPCODE_OFFSET) , 1 /**/ | ||
243 | , 0 , 0 /**/ , CMD_NAME("RELEASE_PIPE") }, | ||
244 | { (CMD_08_ASK_BUFFERS << OPCODE_OFFSET) , 1 /**/ | ||
245 | , 1 , MAX_STREAM_BUFFER , CMD_NAME("ASK_BUFFERS") }, | ||
246 | { (CMD_09_STOP_PIPE << OPCODE_OFFSET) , 1 /**/ | ||
247 | , 0 , 0 /*up to 2*/ , CMD_NAME("STOP_PIPE") }, | ||
248 | { (CMD_0A_GET_PIPE_SPL_COUNT << OPCODE_OFFSET) , 1 /**/ | ||
249 | , 1 , 1 /*up to 2*/ , CMD_NAME("GET_PIPE_SPL_COUNT") }, | ||
250 | { (CMD_0B_TOGGLE_PIPE_STATE << OPCODE_OFFSET) , 1 /*up to 5*/ | ||
251 | , 1 , 0 /**/ , CMD_NAME("TOGGLE_PIPE_STATE") }, | ||
252 | { (CMD_0C_DEF_STREAM << OPCODE_OFFSET) , 1 /*up to 4*/ | ||
253 | , 1 , 0 /**/ , CMD_NAME("DEF_STREAM") }, | ||
254 | { (CMD_0D_SET_MUTE << OPCODE_OFFSET) , 3 /**/ | ||
255 | , 1 , 0 /**/ , CMD_NAME("SET_MUTE") }, | ||
256 | { (CMD_0E_GET_STREAM_SPL_COUNT << OPCODE_OFFSET) , 1/**/ | ||
257 | , 1 , 2 /**/ , CMD_NAME("GET_STREAM_SPL_COUNT") }, | ||
258 | { (CMD_0F_UPDATE_BUFFER << OPCODE_OFFSET) , 3 /*up to 4*/ | ||
259 | , 0 , 1 /**/ , CMD_NAME("UPDATE_BUFFER") }, | ||
260 | { (CMD_10_GET_BUFFER << OPCODE_OFFSET) , 1 /**/ | ||
261 | , 1 , 4 /**/ , CMD_NAME("GET_BUFFER") }, | ||
262 | { (CMD_11_CANCEL_BUFFER << OPCODE_OFFSET) , 1 /**/ | ||
263 | , 1 , 1 /*up to 4*/ , CMD_NAME("CANCEL_BUFFER") }, | ||
264 | { (CMD_12_GET_PEAK << OPCODE_OFFSET) , 1 /**/ | ||
265 | , 1 , 1 /**/ , CMD_NAME("GET_PEAK") }, | ||
266 | { (CMD_13_SET_STREAM_STATE << OPCODE_OFFSET) , 1 /**/ | ||
267 | , 1 , 0 /**/ , CMD_NAME("SET_STREAM_STATE") }, | ||
268 | }; | ||
269 | |||
270 | static void lx_message_init(struct lx_rmh *rmh, enum cmd_mb_opcodes cmd) | ||
271 | { | ||
272 | snd_BUG_ON(cmd >= CMD_14_INVALID); | ||
273 | |||
274 | rmh->cmd[0] = dsp_commands[cmd].dcCodeOp; | ||
275 | rmh->cmd_len = dsp_commands[cmd].dcCmdLength; | ||
276 | rmh->stat_len = dsp_commands[cmd].dcStatusLength; | ||
277 | rmh->dsp_stat = dsp_commands[cmd].dcStatusType; | ||
278 | rmh->cmd_idx = cmd; | ||
279 | memset(&rmh->cmd[1], 0, (REG_CRM_NUMBER - 1) * sizeof(u32)); | ||
280 | |||
281 | #ifdef CONFIG_SND_DEBUG | ||
282 | memset(rmh->stat, 0, REG_CRM_NUMBER * sizeof(u32)); | ||
283 | #endif | ||
284 | #ifdef RMH_DEBUG | ||
285 | rmh->cmd_idx = cmd; | ||
286 | #endif | ||
287 | } | ||
288 | |||
289 | #ifdef RMH_DEBUG | ||
290 | #define LXRMH "lx6464es rmh: " | ||
291 | static void lx_message_dump(struct lx_rmh *rmh) | ||
292 | { | ||
293 | u8 idx = rmh->cmd_idx; | ||
294 | int i; | ||
295 | |||
296 | snd_printk(LXRMH "command %s\n", dsp_commands[idx].dcOpName); | ||
297 | |||
298 | for (i = 0; i != rmh->cmd_len; ++i) | ||
299 | snd_printk(LXRMH "\tcmd[%d] %08x\n", i, rmh->cmd[i]); | ||
300 | |||
301 | for (i = 0; i != rmh->stat_len; ++i) | ||
302 | snd_printk(LXRMH "\tstat[%d]: %08x\n", i, rmh->stat[i]); | ||
303 | snd_printk("\n"); | ||
304 | } | ||
305 | #else | ||
306 | static inline void lx_message_dump(struct lx_rmh *rmh) | ||
307 | {} | ||
308 | #endif | ||
309 | |||
310 | |||
311 | |||
312 | /* sleep 500 - 100 = 400 times 100us -> the timeout is >= 40 ms */ | ||
313 | #define XILINX_TIMEOUT_MS 40 | ||
314 | #define XILINX_POLL_NO_SLEEP 100 | ||
315 | #define XILINX_POLL_ITERATIONS 150 | ||
316 | |||
317 | #if 0 /* not used now */ | ||
318 | static int lx_message_send(struct lx6464es *chip, struct lx_rmh *rmh) | ||
319 | { | ||
320 | u32 reg = ED_DSP_TIMED_OUT; | ||
321 | int dwloop; | ||
322 | int answer_received; | ||
323 | |||
324 | if (lx_dsp_reg_read(chip, eReg_CSM) & (Reg_CSM_MC | Reg_CSM_MR)) { | ||
325 | snd_printk(KERN_ERR LXP "PIOSendMessage eReg_CSM %x\n", reg); | ||
326 | return -EBUSY; | ||
327 | } | ||
328 | |||
329 | /* write command */ | ||
330 | lx_dsp_reg_writebuf(chip, eReg_CRM1, rmh->cmd, rmh->cmd_len); | ||
331 | |||
332 | snd_BUG_ON(atomic_read(&chip->send_message_locked) != 0); | ||
333 | atomic_set(&chip->send_message_locked, 1); | ||
334 | |||
335 | /* MicoBlaze gogogo */ | ||
336 | lx_dsp_reg_write(chip, eReg_CSM, Reg_CSM_MC); | ||
337 | |||
338 | /* wait for interrupt to answer */ | ||
339 | for (dwloop = 0; dwloop != XILINX_TIMEOUT_MS; ++dwloop) { | ||
340 | answer_received = atomic_read(&chip->send_message_locked); | ||
341 | if (answer_received == 0) | ||
342 | break; | ||
343 | msleep(1); | ||
344 | } | ||
345 | |||
346 | if (answer_received == 0) { | ||
347 | /* in Debug mode verify Reg_CSM_MR */ | ||
348 | snd_BUG_ON(!(lx_dsp_reg_read(chip, eReg_CSM) & Reg_CSM_MR)); | ||
349 | |||
350 | /* command finished, read status */ | ||
351 | if (rmh->dsp_stat == 0) | ||
352 | reg = lx_dsp_reg_read(chip, eReg_CRM1); | ||
353 | else | ||
354 | reg = 0; | ||
355 | } else { | ||
356 | int i; | ||
357 | snd_printk(KERN_WARNING LXP "TIMEOUT lx_message_send! " | ||
358 | "Interrupts disabled?\n"); | ||
359 | |||
360 | /* attente bit Reg_CSM_MR */ | ||
361 | for (i = 0; i != XILINX_POLL_ITERATIONS; i++) { | ||
362 | if ((lx_dsp_reg_read(chip, eReg_CSM) & Reg_CSM_MR)) { | ||
363 | if (rmh->dsp_stat == 0) | ||
364 | reg = lx_dsp_reg_read(chip, eReg_CRM1); | ||
365 | else | ||
366 | reg = 0; | ||
367 | goto polling_successful; | ||
368 | } | ||
369 | |||
370 | if (i > XILINX_POLL_NO_SLEEP) | ||
371 | msleep(1); | ||
372 | } | ||
373 | snd_printk(KERN_WARNING LXP "TIMEOUT lx_message_send! " | ||
374 | "polling failed\n"); | ||
375 | |||
376 | polling_successful: | ||
377 | atomic_set(&chip->send_message_locked, 0); | ||
378 | } | ||
379 | |||
380 | if ((reg & ERROR_VALUE) == 0) { | ||
381 | /* read response */ | ||
382 | if (rmh->stat_len) { | ||
383 | snd_BUG_ON(rmh->stat_len >= (REG_CRM_NUMBER-1)); | ||
384 | |||
385 | lx_dsp_reg_readbuf(chip, eReg_CRM2, rmh->stat, | ||
386 | rmh->stat_len); | ||
387 | } | ||
388 | } else | ||
389 | snd_printk(KERN_WARNING LXP "lx_message_send: error_value %x\n", | ||
390 | reg); | ||
391 | |||
392 | /* clear Reg_CSM_MR */ | ||
393 | lx_dsp_reg_write(chip, eReg_CSM, 0); | ||
394 | |||
395 | switch (reg) { | ||
396 | case ED_DSP_TIMED_OUT: | ||
397 | snd_printk(KERN_WARNING LXP "lx_message_send: dsp timeout\n"); | ||
398 | return -ETIMEDOUT; | ||
399 | |||
400 | case ED_DSP_CRASHED: | ||
401 | snd_printk(KERN_WARNING LXP "lx_message_send: dsp crashed\n"); | ||
402 | return -EAGAIN; | ||
403 | } | ||
404 | |||
405 | lx_message_dump(rmh); | ||
406 | return 0; | ||
407 | } | ||
408 | #endif /* not used now */ | ||
409 | |||
410 | static int lx_message_send_atomic(struct lx6464es *chip, struct lx_rmh *rmh) | ||
411 | { | ||
412 | u32 reg = ED_DSP_TIMED_OUT; | ||
413 | int dwloop; | ||
414 | |||
415 | if (lx_dsp_reg_read(chip, eReg_CSM) & (Reg_CSM_MC | Reg_CSM_MR)) { | ||
416 | snd_printk(KERN_ERR LXP "PIOSendMessage eReg_CSM %x\n", reg); | ||
417 | return -EBUSY; | ||
418 | } | ||
419 | |||
420 | /* write command */ | ||
421 | lx_dsp_reg_writebuf(chip, eReg_CRM1, rmh->cmd, rmh->cmd_len); | ||
422 | |||
423 | /* MicoBlaze gogogo */ | ||
424 | lx_dsp_reg_write(chip, eReg_CSM, Reg_CSM_MC); | ||
425 | |||
426 | /* wait for interrupt to answer */ | ||
427 | for (dwloop = 0; dwloop != XILINX_TIMEOUT_MS * 1000; ++dwloop) { | ||
428 | if (lx_dsp_reg_read(chip, eReg_CSM) & Reg_CSM_MR) { | ||
429 | if (rmh->dsp_stat == 0) | ||
430 | reg = lx_dsp_reg_read(chip, eReg_CRM1); | ||
431 | else | ||
432 | reg = 0; | ||
433 | goto polling_successful; | ||
434 | } else | ||
435 | udelay(1); | ||
436 | } | ||
437 | snd_printk(KERN_WARNING LXP "TIMEOUT lx_message_send_atomic! " | ||
438 | "polling failed\n"); | ||
439 | |||
440 | polling_successful: | ||
441 | if ((reg & ERROR_VALUE) == 0) { | ||
442 | /* read response */ | ||
443 | if (rmh->stat_len) { | ||
444 | snd_BUG_ON(rmh->stat_len >= (REG_CRM_NUMBER-1)); | ||
445 | lx_dsp_reg_readbuf(chip, eReg_CRM2, rmh->stat, | ||
446 | rmh->stat_len); | ||
447 | } | ||
448 | } else | ||
449 | snd_printk(LXP "rmh error: %08x\n", reg); | ||
450 | |||
451 | /* clear Reg_CSM_MR */ | ||
452 | lx_dsp_reg_write(chip, eReg_CSM, 0); | ||
453 | |||
454 | switch (reg) { | ||
455 | case ED_DSP_TIMED_OUT: | ||
456 | snd_printk(KERN_WARNING LXP "lx_message_send: dsp timeout\n"); | ||
457 | return -ETIMEDOUT; | ||
458 | |||
459 | case ED_DSP_CRASHED: | ||
460 | snd_printk(KERN_WARNING LXP "lx_message_send: dsp crashed\n"); | ||
461 | return -EAGAIN; | ||
462 | } | ||
463 | |||
464 | lx_message_dump(rmh); | ||
465 | |||
466 | return reg; | ||
467 | } | ||
468 | |||
469 | |||
470 | /* low-level dsp access */ | ||
471 | int __devinit lx_dsp_get_version(struct lx6464es *chip, u32 *rdsp_version) | ||
472 | { | ||
473 | u16 ret; | ||
474 | unsigned long flags; | ||
475 | |||
476 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
477 | |||
478 | lx_message_init(&chip->rmh, CMD_01_GET_SYS_CFG); | ||
479 | ret = lx_message_send_atomic(chip, &chip->rmh); | ||
480 | |||
481 | *rdsp_version = chip->rmh.stat[1]; | ||
482 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
483 | return ret; | ||
484 | } | ||
485 | |||
486 | int lx_dsp_get_clock_frequency(struct lx6464es *chip, u32 *rfreq) | ||
487 | { | ||
488 | u16 ret = 0; | ||
489 | unsigned long flags; | ||
490 | u32 freq_raw = 0; | ||
491 | u32 freq = 0; | ||
492 | u32 frequency = 0; | ||
493 | |||
494 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
495 | |||
496 | lx_message_init(&chip->rmh, CMD_01_GET_SYS_CFG); | ||
497 | ret = lx_message_send_atomic(chip, &chip->rmh); | ||
498 | |||
499 | if (ret == 0) { | ||
500 | freq_raw = chip->rmh.stat[0] >> FREQ_FIELD_OFFSET; | ||
501 | freq = freq_raw & XES_FREQ_COUNT8_MASK; | ||
502 | |||
503 | if ((freq < XES_FREQ_COUNT8_48_MAX) || | ||
504 | (freq > XES_FREQ_COUNT8_44_MIN)) | ||
505 | frequency = 0; /* unknown */ | ||
506 | else if (freq >= XES_FREQ_COUNT8_44_MAX) | ||
507 | frequency = 44100; | ||
508 | else | ||
509 | frequency = 48000; | ||
510 | } | ||
511 | |||
512 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
513 | |||
514 | *rfreq = frequency * chip->freq_ratio; | ||
515 | |||
516 | return ret; | ||
517 | } | ||
518 | |||
519 | int lx_dsp_get_mac(struct lx6464es *chip, u8 *mac_address) | ||
520 | { | ||
521 | u32 macmsb, maclsb; | ||
522 | |||
523 | macmsb = lx_dsp_reg_read(chip, eReg_ADMACESMSB) & 0x00FFFFFF; | ||
524 | maclsb = lx_dsp_reg_read(chip, eReg_ADMACESLSB) & 0x00FFFFFF; | ||
525 | |||
526 | /* todo: endianess handling */ | ||
527 | mac_address[5] = ((u8 *)(&maclsb))[0]; | ||
528 | mac_address[4] = ((u8 *)(&maclsb))[1]; | ||
529 | mac_address[3] = ((u8 *)(&maclsb))[2]; | ||
530 | mac_address[2] = ((u8 *)(&macmsb))[0]; | ||
531 | mac_address[1] = ((u8 *)(&macmsb))[1]; | ||
532 | mac_address[0] = ((u8 *)(&macmsb))[2]; | ||
533 | |||
534 | return 0; | ||
535 | } | ||
536 | |||
537 | |||
538 | int lx_dsp_set_granularity(struct lx6464es *chip, u32 gran) | ||
539 | { | ||
540 | unsigned long flags; | ||
541 | int ret; | ||
542 | |||
543 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
544 | |||
545 | lx_message_init(&chip->rmh, CMD_02_SET_GRANULARITY); | ||
546 | chip->rmh.cmd[0] |= gran; | ||
547 | |||
548 | ret = lx_message_send_atomic(chip, &chip->rmh); | ||
549 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
550 | return ret; | ||
551 | } | ||
552 | |||
553 | int lx_dsp_read_async_events(struct lx6464es *chip, u32 *data) | ||
554 | { | ||
555 | unsigned long flags; | ||
556 | int ret; | ||
557 | |||
558 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
559 | |||
560 | lx_message_init(&chip->rmh, CMD_04_GET_EVENT); | ||
561 | chip->rmh.stat_len = 9; /* we don't necessarily need the full length */ | ||
562 | |||
563 | ret = lx_message_send_atomic(chip, &chip->rmh); | ||
564 | |||
565 | if (!ret) | ||
566 | memcpy(data, chip->rmh.stat, chip->rmh.stat_len * sizeof(u32)); | ||
567 | |||
568 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
569 | return ret; | ||
570 | } | ||
571 | |||
572 | #define CSES_TIMEOUT 100 /* microseconds */ | ||
573 | #define CSES_CE 0x0001 | ||
574 | #define CSES_BROADCAST 0x0002 | ||
575 | #define CSES_UPDATE_LDSV 0x0004 | ||
576 | |||
577 | int lx_dsp_es_check_pipeline(struct lx6464es *chip) | ||
578 | { | ||
579 | int i; | ||
580 | |||
581 | for (i = 0; i != CSES_TIMEOUT; ++i) { | ||
582 | /* | ||
583 | * le bit CSES_UPDATE_LDSV est à1 dés que le macprog | ||
584 | * est pret. il re-passe à0 lorsque le premier read a | ||
585 | * été fait. pour l'instant on retire le test car ce bit | ||
586 | * passe a 1 environ 200 à400 ms aprés que le registre | ||
587 | * confES àété écrit (kick du xilinx ES). | ||
588 | * | ||
589 | * On ne teste que le bit CE. | ||
590 | * */ | ||
591 | |||
592 | u32 cses = lx_dsp_reg_read(chip, eReg_CSES); | ||
593 | |||
594 | if ((cses & CSES_CE) == 0) | ||
595 | return 0; | ||
596 | |||
597 | udelay(1); | ||
598 | } | ||
599 | |||
600 | return -ETIMEDOUT; | ||
601 | } | ||
602 | |||
603 | |||
604 | #define PIPE_INFO_TO_CMD(capture, pipe) \ | ||
605 | ((u32)((u32)(pipe) | ((capture) ? ID_IS_CAPTURE : 0L)) << ID_OFFSET) | ||
606 | |||
607 | |||
608 | |||
609 | /* low-level pipe handling */ | ||
610 | int lx_pipe_allocate(struct lx6464es *chip, u32 pipe, int is_capture, | ||
611 | int channels) | ||
612 | { | ||
613 | int err; | ||
614 | unsigned long flags; | ||
615 | |||
616 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
617 | |||
618 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
619 | lx_message_init(&chip->rmh, CMD_06_ALLOCATE_PIPE); | ||
620 | |||
621 | chip->rmh.cmd[0] |= pipe_cmd; | ||
622 | chip->rmh.cmd[0] |= channels; | ||
623 | |||
624 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
625 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
626 | |||
627 | if (err != 0) | ||
628 | snd_printk(KERN_ERR "lx6464es: could not allocate pipe\n"); | ||
629 | |||
630 | return err; | ||
631 | } | ||
632 | |||
633 | int lx_pipe_release(struct lx6464es *chip, u32 pipe, int is_capture) | ||
634 | { | ||
635 | int err; | ||
636 | unsigned long flags; | ||
637 | |||
638 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
639 | |||
640 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
641 | lx_message_init(&chip->rmh, CMD_07_RELEASE_PIPE); | ||
642 | |||
643 | chip->rmh.cmd[0] |= pipe_cmd; | ||
644 | |||
645 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
646 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
647 | |||
648 | return err; | ||
649 | } | ||
650 | |||
651 | int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture, | ||
652 | u32 *r_needed, u32 *r_freed, u32 *size_array) | ||
653 | { | ||
654 | int err; | ||
655 | unsigned long flags; | ||
656 | |||
657 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
658 | |||
659 | #ifdef CONFIG_SND_DEBUG | ||
660 | if (size_array) | ||
661 | memset(size_array, 0, sizeof(u32)*MAX_STREAM_BUFFER); | ||
662 | #endif | ||
663 | |||
664 | *r_needed = 0; | ||
665 | *r_freed = 0; | ||
666 | |||
667 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
668 | lx_message_init(&chip->rmh, CMD_08_ASK_BUFFERS); | ||
669 | |||
670 | chip->rmh.cmd[0] |= pipe_cmd; | ||
671 | |||
672 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
673 | |||
674 | if (!err) { | ||
675 | int i; | ||
676 | for (i = 0; i < MAX_STREAM_BUFFER; ++i) { | ||
677 | u32 stat = chip->rmh.stat[i]; | ||
678 | if (stat & (BF_EOB << BUFF_FLAGS_OFFSET)) { | ||
679 | /* finished */ | ||
680 | *r_freed += 1; | ||
681 | if (size_array) | ||
682 | size_array[i] = stat & MASK_DATA_SIZE; | ||
683 | } else if ((stat & (BF_VALID << BUFF_FLAGS_OFFSET)) | ||
684 | == 0) | ||
685 | /* free */ | ||
686 | *r_needed += 1; | ||
687 | } | ||
688 | |||
689 | #if 0 | ||
690 | snd_printdd(LXP "CMD_08_ASK_BUFFERS: needed %d, freed %d\n", | ||
691 | *r_needed, *r_freed); | ||
692 | for (i = 0; i < MAX_STREAM_BUFFER; ++i) { | ||
693 | for (i = 0; i != chip->rmh.stat_len; ++i) | ||
694 | snd_printdd(" stat[%d]: %x, %x\n", i, | ||
695 | chip->rmh.stat[i], | ||
696 | chip->rmh.stat[i] & MASK_DATA_SIZE); | ||
697 | } | ||
698 | #endif | ||
699 | } | ||
700 | |||
701 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
702 | return err; | ||
703 | } | ||
704 | |||
705 | |||
706 | int lx_pipe_stop(struct lx6464es *chip, u32 pipe, int is_capture) | ||
707 | { | ||
708 | int err; | ||
709 | unsigned long flags; | ||
710 | |||
711 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
712 | |||
713 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
714 | lx_message_init(&chip->rmh, CMD_09_STOP_PIPE); | ||
715 | |||
716 | chip->rmh.cmd[0] |= pipe_cmd; | ||
717 | |||
718 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
719 | |||
720 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
721 | return err; | ||
722 | } | ||
723 | |||
724 | static int lx_pipe_toggle_state(struct lx6464es *chip, u32 pipe, int is_capture) | ||
725 | { | ||
726 | int err; | ||
727 | unsigned long flags; | ||
728 | |||
729 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
730 | |||
731 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
732 | lx_message_init(&chip->rmh, CMD_0B_TOGGLE_PIPE_STATE); | ||
733 | |||
734 | chip->rmh.cmd[0] |= pipe_cmd; | ||
735 | |||
736 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
737 | |||
738 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
739 | return err; | ||
740 | } | ||
741 | |||
742 | |||
743 | int lx_pipe_start(struct lx6464es *chip, u32 pipe, int is_capture) | ||
744 | { | ||
745 | int err; | ||
746 | |||
747 | err = lx_pipe_wait_for_idle(chip, pipe, is_capture); | ||
748 | if (err < 0) | ||
749 | return err; | ||
750 | |||
751 | err = lx_pipe_toggle_state(chip, pipe, is_capture); | ||
752 | |||
753 | return err; | ||
754 | } | ||
755 | |||
756 | int lx_pipe_pause(struct lx6464es *chip, u32 pipe, int is_capture) | ||
757 | { | ||
758 | int err = 0; | ||
759 | |||
760 | err = lx_pipe_wait_for_start(chip, pipe, is_capture); | ||
761 | if (err < 0) | ||
762 | return err; | ||
763 | |||
764 | err = lx_pipe_toggle_state(chip, pipe, is_capture); | ||
765 | |||
766 | return err; | ||
767 | } | ||
768 | |||
769 | |||
770 | int lx_pipe_sample_count(struct lx6464es *chip, u32 pipe, int is_capture, | ||
771 | u64 *rsample_count) | ||
772 | { | ||
773 | int err; | ||
774 | unsigned long flags; | ||
775 | |||
776 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
777 | |||
778 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
779 | lx_message_init(&chip->rmh, CMD_0A_GET_PIPE_SPL_COUNT); | ||
780 | |||
781 | chip->rmh.cmd[0] |= pipe_cmd; | ||
782 | chip->rmh.stat_len = 2; /* need all words here! */ | ||
783 | |||
784 | err = lx_message_send_atomic(chip, &chip->rmh); /* don't sleep! */ | ||
785 | |||
786 | if (err != 0) | ||
787 | snd_printk(KERN_ERR | ||
788 | "lx6464es: could not query pipe's sample count\n"); | ||
789 | else { | ||
790 | *rsample_count = ((u64)(chip->rmh.stat[0] & MASK_SPL_COUNT_HI) | ||
791 | << 24) /* hi part */ | ||
792 | + chip->rmh.stat[1]; /* lo part */ | ||
793 | } | ||
794 | |||
795 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
796 | return err; | ||
797 | } | ||
798 | |||
799 | int lx_pipe_state(struct lx6464es *chip, u32 pipe, int is_capture, u16 *rstate) | ||
800 | { | ||
801 | int err; | ||
802 | unsigned long flags; | ||
803 | |||
804 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
805 | |||
806 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
807 | lx_message_init(&chip->rmh, CMD_0A_GET_PIPE_SPL_COUNT); | ||
808 | |||
809 | chip->rmh.cmd[0] |= pipe_cmd; | ||
810 | |||
811 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
812 | |||
813 | if (err != 0) | ||
814 | snd_printk(KERN_ERR "lx6464es: could not query pipe's state\n"); | ||
815 | else | ||
816 | *rstate = (chip->rmh.stat[0] >> PSTATE_OFFSET) & 0x0F; | ||
817 | |||
818 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
819 | return err; | ||
820 | } | ||
821 | |||
822 | static int lx_pipe_wait_for_state(struct lx6464es *chip, u32 pipe, | ||
823 | int is_capture, u16 state) | ||
824 | { | ||
825 | int i; | ||
826 | |||
827 | /* max 2*PCMOnlyGranularity = 2*1024 at 44100 = < 50 ms: | ||
828 | * timeout 50 ms */ | ||
829 | for (i = 0; i != 50; ++i) { | ||
830 | u16 current_state; | ||
831 | int err = lx_pipe_state(chip, pipe, is_capture, ¤t_state); | ||
832 | |||
833 | if (err < 0) | ||
834 | return err; | ||
835 | |||
836 | if (current_state == state) | ||
837 | return 0; | ||
838 | |||
839 | mdelay(1); | ||
840 | } | ||
841 | |||
842 | return -ETIMEDOUT; | ||
843 | } | ||
844 | |||
845 | int lx_pipe_wait_for_start(struct lx6464es *chip, u32 pipe, int is_capture) | ||
846 | { | ||
847 | return lx_pipe_wait_for_state(chip, pipe, is_capture, PSTATE_RUN); | ||
848 | } | ||
849 | |||
850 | int lx_pipe_wait_for_idle(struct lx6464es *chip, u32 pipe, int is_capture) | ||
851 | { | ||
852 | return lx_pipe_wait_for_state(chip, pipe, is_capture, PSTATE_IDLE); | ||
853 | } | ||
854 | |||
855 | /* low-level stream handling */ | ||
856 | int lx_stream_set_state(struct lx6464es *chip, u32 pipe, | ||
857 | int is_capture, enum stream_state_t state) | ||
858 | { | ||
859 | int err; | ||
860 | unsigned long flags; | ||
861 | |||
862 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
863 | |||
864 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
865 | lx_message_init(&chip->rmh, CMD_13_SET_STREAM_STATE); | ||
866 | |||
867 | chip->rmh.cmd[0] |= pipe_cmd; | ||
868 | chip->rmh.cmd[0] |= state; | ||
869 | |||
870 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
871 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
872 | |||
873 | return err; | ||
874 | } | ||
875 | |||
876 | int lx_stream_set_format(struct lx6464es *chip, struct snd_pcm_runtime *runtime, | ||
877 | u32 pipe, int is_capture) | ||
878 | { | ||
879 | int err; | ||
880 | unsigned long flags; | ||
881 | |||
882 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
883 | |||
884 | u32 channels = runtime->channels; | ||
885 | |||
886 | if (runtime->channels != channels) | ||
887 | snd_printk(KERN_ERR LXP "channel count mismatch: %d vs %d", | ||
888 | runtime->channels, channels); | ||
889 | |||
890 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
891 | lx_message_init(&chip->rmh, CMD_0C_DEF_STREAM); | ||
892 | |||
893 | chip->rmh.cmd[0] |= pipe_cmd; | ||
894 | |||
895 | if (runtime->sample_bits == 16) | ||
896 | /* 16 bit format */ | ||
897 | chip->rmh.cmd[0] |= (STREAM_FMT_16b << STREAM_FMT_OFFSET); | ||
898 | |||
899 | if (snd_pcm_format_little_endian(runtime->format)) | ||
900 | /* little endian/intel format */ | ||
901 | chip->rmh.cmd[0] |= (STREAM_FMT_intel << STREAM_FMT_OFFSET); | ||
902 | |||
903 | chip->rmh.cmd[0] |= channels-1; | ||
904 | |||
905 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
906 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
907 | |||
908 | return err; | ||
909 | } | ||
910 | |||
911 | int lx_stream_state(struct lx6464es *chip, u32 pipe, int is_capture, | ||
912 | int *rstate) | ||
913 | { | ||
914 | int err; | ||
915 | unsigned long flags; | ||
916 | |||
917 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
918 | |||
919 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
920 | lx_message_init(&chip->rmh, CMD_0E_GET_STREAM_SPL_COUNT); | ||
921 | |||
922 | chip->rmh.cmd[0] |= pipe_cmd; | ||
923 | |||
924 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
925 | |||
926 | *rstate = (chip->rmh.stat[0] & SF_START) ? START_STATE : PAUSE_STATE; | ||
927 | |||
928 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
929 | return err; | ||
930 | } | ||
931 | |||
932 | int lx_stream_sample_position(struct lx6464es *chip, u32 pipe, int is_capture, | ||
933 | u64 *r_bytepos) | ||
934 | { | ||
935 | int err; | ||
936 | unsigned long flags; | ||
937 | |||
938 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
939 | |||
940 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
941 | lx_message_init(&chip->rmh, CMD_0E_GET_STREAM_SPL_COUNT); | ||
942 | |||
943 | chip->rmh.cmd[0] |= pipe_cmd; | ||
944 | |||
945 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
946 | |||
947 | *r_bytepos = ((u64) (chip->rmh.stat[0] & MASK_SPL_COUNT_HI) | ||
948 | << 32) /* hi part */ | ||
949 | + chip->rmh.stat[1]; /* lo part */ | ||
950 | |||
951 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
952 | return err; | ||
953 | } | ||
954 | |||
955 | /* low-level buffer handling */ | ||
956 | int lx_buffer_give(struct lx6464es *chip, u32 pipe, int is_capture, | ||
957 | u32 buffer_size, u32 buf_address_lo, u32 buf_address_hi, | ||
958 | u32 *r_buffer_index) | ||
959 | { | ||
960 | int err; | ||
961 | unsigned long flags; | ||
962 | |||
963 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
964 | |||
965 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
966 | lx_message_init(&chip->rmh, CMD_0F_UPDATE_BUFFER); | ||
967 | |||
968 | chip->rmh.cmd[0] |= pipe_cmd; | ||
969 | chip->rmh.cmd[0] |= BF_NOTIFY_EOB; /* request interrupt notification */ | ||
970 | |||
971 | /* todo: pause request, circular buffer */ | ||
972 | |||
973 | chip->rmh.cmd[1] = buffer_size & MASK_DATA_SIZE; | ||
974 | chip->rmh.cmd[2] = buf_address_lo; | ||
975 | |||
976 | if (buf_address_hi) { | ||
977 | chip->rmh.cmd_len = 4; | ||
978 | chip->rmh.cmd[3] = buf_address_hi; | ||
979 | chip->rmh.cmd[0] |= BF_64BITS_ADR; | ||
980 | } | ||
981 | |||
982 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
983 | |||
984 | if (err == 0) { | ||
985 | *r_buffer_index = chip->rmh.stat[0]; | ||
986 | goto done; | ||
987 | } | ||
988 | |||
989 | if (err == EB_RBUFFERS_TABLE_OVERFLOW) | ||
990 | snd_printk(LXP "lx_buffer_give EB_RBUFFERS_TABLE_OVERFLOW\n"); | ||
991 | |||
992 | if (err == EB_INVALID_STREAM) | ||
993 | snd_printk(LXP "lx_buffer_give EB_INVALID_STREAM\n"); | ||
994 | |||
995 | if (err == EB_CMD_REFUSED) | ||
996 | snd_printk(LXP "lx_buffer_give EB_CMD_REFUSED\n"); | ||
997 | |||
998 | done: | ||
999 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
1000 | return err; | ||
1001 | } | ||
1002 | |||
1003 | int lx_buffer_free(struct lx6464es *chip, u32 pipe, int is_capture, | ||
1004 | u32 *r_buffer_size) | ||
1005 | { | ||
1006 | int err; | ||
1007 | unsigned long flags; | ||
1008 | |||
1009 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
1010 | |||
1011 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
1012 | lx_message_init(&chip->rmh, CMD_11_CANCEL_BUFFER); | ||
1013 | |||
1014 | chip->rmh.cmd[0] |= pipe_cmd; | ||
1015 | chip->rmh.cmd[0] |= MASK_BUFFER_ID; /* ask for the current buffer: the | ||
1016 | * microblaze will seek for it */ | ||
1017 | |||
1018 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
1019 | |||
1020 | if (err == 0) | ||
1021 | *r_buffer_size = chip->rmh.stat[0] & MASK_DATA_SIZE; | ||
1022 | |||
1023 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
1024 | return err; | ||
1025 | } | ||
1026 | |||
1027 | int lx_buffer_cancel(struct lx6464es *chip, u32 pipe, int is_capture, | ||
1028 | u32 buffer_index) | ||
1029 | { | ||
1030 | int err; | ||
1031 | unsigned long flags; | ||
1032 | |||
1033 | u32 pipe_cmd = PIPE_INFO_TO_CMD(is_capture, pipe); | ||
1034 | |||
1035 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
1036 | lx_message_init(&chip->rmh, CMD_11_CANCEL_BUFFER); | ||
1037 | |||
1038 | chip->rmh.cmd[0] |= pipe_cmd; | ||
1039 | chip->rmh.cmd[0] |= buffer_index; | ||
1040 | |||
1041 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
1042 | |||
1043 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
1044 | return err; | ||
1045 | } | ||
1046 | |||
1047 | |||
1048 | /* low-level gain/peak handling | ||
1049 | * | ||
1050 | * \todo: can we unmute capture/playback channels independently? | ||
1051 | * | ||
1052 | * */ | ||
1053 | int lx_level_unmute(struct lx6464es *chip, int is_capture, int unmute) | ||
1054 | { | ||
1055 | int err; | ||
1056 | unsigned long flags; | ||
1057 | |||
1058 | /* bit set to 1: channel muted */ | ||
1059 | u64 mute_mask = unmute ? 0 : 0xFFFFFFFFFFFFFFFFLLU; | ||
1060 | |||
1061 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
1062 | lx_message_init(&chip->rmh, CMD_0D_SET_MUTE); | ||
1063 | |||
1064 | chip->rmh.cmd[0] |= PIPE_INFO_TO_CMD(is_capture, 0); | ||
1065 | |||
1066 | chip->rmh.cmd[1] = (u32)(mute_mask >> (u64)32); /* hi part */ | ||
1067 | chip->rmh.cmd[2] = (u32)(mute_mask & (u64)0xFFFFFFFF); /* lo part */ | ||
1068 | |||
1069 | snd_printk("mute %x %x %x\n", chip->rmh.cmd[0], chip->rmh.cmd[1], | ||
1070 | chip->rmh.cmd[2]); | ||
1071 | |||
1072 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
1073 | |||
1074 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
1075 | return err; | ||
1076 | } | ||
1077 | |||
1078 | static u32 peak_map[] = { | ||
1079 | 0x00000109, /* -90.308dB */ | ||
1080 | 0x0000083B, /* -72.247dB */ | ||
1081 | 0x000020C4, /* -60.205dB */ | ||
1082 | 0x00008273, /* -48.030dB */ | ||
1083 | 0x00020756, /* -36.005dB */ | ||
1084 | 0x00040C37, /* -30.001dB */ | ||
1085 | 0x00081385, /* -24.002dB */ | ||
1086 | 0x00101D3F, /* -18.000dB */ | ||
1087 | 0x0016C310, /* -15.000dB */ | ||
1088 | 0x002026F2, /* -12.001dB */ | ||
1089 | 0x002D6A86, /* -9.000dB */ | ||
1090 | 0x004026E6, /* -6.004dB */ | ||
1091 | 0x005A9DF6, /* -3.000dB */ | ||
1092 | 0x0065AC8B, /* -2.000dB */ | ||
1093 | 0x00721481, /* -1.000dB */ | ||
1094 | 0x007FFFFF, /* FS */ | ||
1095 | }; | ||
1096 | |||
1097 | int lx_level_peaks(struct lx6464es *chip, int is_capture, int channels, | ||
1098 | u32 *r_levels) | ||
1099 | { | ||
1100 | int err = 0; | ||
1101 | unsigned long flags; | ||
1102 | int i; | ||
1103 | spin_lock_irqsave(&chip->msg_lock, flags); | ||
1104 | |||
1105 | for (i = 0; i < channels; i += 4) { | ||
1106 | u32 s0, s1, s2, s3; | ||
1107 | |||
1108 | lx_message_init(&chip->rmh, CMD_12_GET_PEAK); | ||
1109 | chip->rmh.cmd[0] |= PIPE_INFO_TO_CMD(is_capture, i); | ||
1110 | |||
1111 | err = lx_message_send_atomic(chip, &chip->rmh); | ||
1112 | |||
1113 | if (err == 0) { | ||
1114 | s0 = peak_map[chip->rmh.stat[0] & 0x0F]; | ||
1115 | s1 = peak_map[(chip->rmh.stat[0] >> 4) & 0xf]; | ||
1116 | s2 = peak_map[(chip->rmh.stat[0] >> 8) & 0xf]; | ||
1117 | s3 = peak_map[(chip->rmh.stat[0] >> 12) & 0xf]; | ||
1118 | } else | ||
1119 | s0 = s1 = s2 = s3 = 0; | ||
1120 | |||
1121 | r_levels[0] = s0; | ||
1122 | r_levels[1] = s1; | ||
1123 | r_levels[2] = s2; | ||
1124 | r_levels[3] = s3; | ||
1125 | |||
1126 | r_levels += 4; | ||
1127 | } | ||
1128 | |||
1129 | spin_unlock_irqrestore(&chip->msg_lock, flags); | ||
1130 | return err; | ||
1131 | } | ||
1132 | |||
1133 | /* interrupt handling */ | ||
1134 | #define PCX_IRQ_NONE 0 | ||
1135 | #define IRQCS_ACTIVE_PCIDB 0x00002000L /* Bit nø 13 */ | ||
1136 | #define IRQCS_ENABLE_PCIIRQ 0x00000100L /* Bit nø 08 */ | ||
1137 | #define IRQCS_ENABLE_PCIDB 0x00000200L /* Bit nø 09 */ | ||
1138 | |||
1139 | static u32 lx_interrupt_test_ack(struct lx6464es *chip) | ||
1140 | { | ||
1141 | u32 irqcs = lx_plx_reg_read(chip, ePLX_IRQCS); | ||
1142 | |||
1143 | /* Test if PCI Doorbell interrupt is active */ | ||
1144 | if (irqcs & IRQCS_ACTIVE_PCIDB) { | ||
1145 | u32 temp; | ||
1146 | irqcs = PCX_IRQ_NONE; | ||
1147 | |||
1148 | while ((temp = lx_plx_reg_read(chip, ePLX_L2PCIDB))) { | ||
1149 | /* RAZ interrupt */ | ||
1150 | irqcs |= temp; | ||
1151 | lx_plx_reg_write(chip, ePLX_L2PCIDB, temp); | ||
1152 | } | ||
1153 | |||
1154 | return irqcs; | ||
1155 | } | ||
1156 | return PCX_IRQ_NONE; | ||
1157 | } | ||
1158 | |||
1159 | static int lx_interrupt_ack(struct lx6464es *chip, u32 *r_irqsrc, | ||
1160 | int *r_async_pending, int *r_async_escmd) | ||
1161 | { | ||
1162 | u32 irq_async; | ||
1163 | u32 irqsrc = lx_interrupt_test_ack(chip); | ||
1164 | |||
1165 | if (irqsrc == PCX_IRQ_NONE) | ||
1166 | return 0; | ||
1167 | |||
1168 | *r_irqsrc = irqsrc; | ||
1169 | |||
1170 | irq_async = irqsrc & MASK_SYS_ASYNC_EVENTS; /* + EtherSound response | ||
1171 | * (set by xilinx) + EOB */ | ||
1172 | |||
1173 | if (irq_async & MASK_SYS_STATUS_ESA) { | ||
1174 | irq_async &= ~MASK_SYS_STATUS_ESA; | ||
1175 | *r_async_escmd = 1; | ||
1176 | } | ||
1177 | |||
1178 | if (irqsrc & MASK_SYS_STATUS_CMD_DONE) | ||
1179 | /* xilinx command notification */ | ||
1180 | atomic_set(&chip->send_message_locked, 0); | ||
1181 | |||
1182 | if (irq_async) { | ||
1183 | /* snd_printd("interrupt: async event pending\n"); */ | ||
1184 | *r_async_pending = 1; | ||
1185 | } | ||
1186 | |||
1187 | return 1; | ||
1188 | } | ||
1189 | |||
1190 | static int lx_interrupt_handle_async_events(struct lx6464es *chip, u32 irqsrc, | ||
1191 | int *r_freq_changed, | ||
1192 | u64 *r_notified_in_pipe_mask, | ||
1193 | u64 *r_notified_out_pipe_mask) | ||
1194 | { | ||
1195 | int err; | ||
1196 | u32 stat[9]; /* answer from CMD_04_GET_EVENT */ | ||
1197 | |||
1198 | /* On peut optimiser pour ne pas lire les evenements vides | ||
1199 | * les mots de réponse sont dans l'ordre suivant : | ||
1200 | * Stat[0] mot de status général | ||
1201 | * Stat[1] fin de buffer OUT pF | ||
1202 | * Stat[2] fin de buffer OUT pf | ||
1203 | * Stat[3] fin de buffer IN pF | ||
1204 | * Stat[4] fin de buffer IN pf | ||
1205 | * Stat[5] underrun poid fort | ||
1206 | * Stat[6] underrun poid faible | ||
1207 | * Stat[7] overrun poid fort | ||
1208 | * Stat[8] overrun poid faible | ||
1209 | * */ | ||
1210 | |||
1211 | u64 orun_mask; | ||
1212 | u64 urun_mask; | ||
1213 | #if 0 | ||
1214 | int has_underrun = (irqsrc & MASK_SYS_STATUS_URUN) ? 1 : 0; | ||
1215 | int has_overrun = (irqsrc & MASK_SYS_STATUS_ORUN) ? 1 : 0; | ||
1216 | #endif | ||
1217 | int eb_pending_out = (irqsrc & MASK_SYS_STATUS_EOBO) ? 1 : 0; | ||
1218 | int eb_pending_in = (irqsrc & MASK_SYS_STATUS_EOBI) ? 1 : 0; | ||
1219 | |||
1220 | *r_freq_changed = (irqsrc & MASK_SYS_STATUS_FREQ) ? 1 : 0; | ||
1221 | |||
1222 | err = lx_dsp_read_async_events(chip, stat); | ||
1223 | if (err < 0) | ||
1224 | return err; | ||
1225 | |||
1226 | if (eb_pending_in) { | ||
1227 | *r_notified_in_pipe_mask = ((u64)stat[3] << 32) | ||
1228 | + stat[4]; | ||
1229 | snd_printdd(LXP "interrupt: EOBI pending %llx\n", | ||
1230 | *r_notified_in_pipe_mask); | ||
1231 | } | ||
1232 | if (eb_pending_out) { | ||
1233 | *r_notified_out_pipe_mask = ((u64)stat[1] << 32) | ||
1234 | + stat[2]; | ||
1235 | snd_printdd(LXP "interrupt: EOBO pending %llx\n", | ||
1236 | *r_notified_out_pipe_mask); | ||
1237 | } | ||
1238 | |||
1239 | orun_mask = ((u64)stat[7] << 32) + stat[8]; | ||
1240 | urun_mask = ((u64)stat[5] << 32) + stat[6]; | ||
1241 | |||
1242 | /* todo: handle xrun notification */ | ||
1243 | |||
1244 | return err; | ||
1245 | } | ||
1246 | |||
1247 | static int lx_interrupt_request_new_buffer(struct lx6464es *chip, | ||
1248 | struct lx_stream *lx_stream) | ||
1249 | { | ||
1250 | struct snd_pcm_substream *substream = lx_stream->stream; | ||
1251 | int is_capture = lx_stream->is_capture; | ||
1252 | int err; | ||
1253 | unsigned long flags; | ||
1254 | |||
1255 | const u32 channels = substream->runtime->channels; | ||
1256 | const u32 bytes_per_frame = channels * 3; | ||
1257 | const u32 period_size = substream->runtime->period_size; | ||
1258 | const u32 period_bytes = period_size * bytes_per_frame; | ||
1259 | const u32 pos = lx_stream->frame_pos; | ||
1260 | const u32 next_pos = ((pos+1) == substream->runtime->periods) ? | ||
1261 | 0 : pos + 1; | ||
1262 | |||
1263 | dma_addr_t buf = substream->dma_buffer.addr + pos * period_bytes; | ||
1264 | u32 buf_hi = 0; | ||
1265 | u32 buf_lo = 0; | ||
1266 | u32 buffer_index = 0; | ||
1267 | |||
1268 | u32 needed, freed; | ||
1269 | u32 size_array[MAX_STREAM_BUFFER]; | ||
1270 | |||
1271 | snd_printdd("->lx_interrupt_request_new_buffer\n"); | ||
1272 | |||
1273 | spin_lock_irqsave(&chip->lock, flags); | ||
1274 | |||
1275 | err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array); | ||
1276 | snd_printdd(LXP "interrupt: needed %d, freed %d\n", needed, freed); | ||
1277 | |||
1278 | unpack_pointer(buf, &buf_lo, &buf_hi); | ||
1279 | err = lx_buffer_give(chip, 0, is_capture, period_bytes, buf_lo, buf_hi, | ||
1280 | &buffer_index); | ||
1281 | snd_printdd(LXP "interrupt: gave buffer index %x on %p (%d bytes)\n", | ||
1282 | buffer_index, (void *)buf, period_bytes); | ||
1283 | |||
1284 | lx_stream->frame_pos = next_pos; | ||
1285 | spin_unlock_irqrestore(&chip->lock, flags); | ||
1286 | |||
1287 | return err; | ||
1288 | } | ||
1289 | |||
1290 | void lx_tasklet_playback(unsigned long data) | ||
1291 | { | ||
1292 | struct lx6464es *chip = (struct lx6464es *)data; | ||
1293 | struct lx_stream *lx_stream = &chip->playback_stream; | ||
1294 | int err; | ||
1295 | |||
1296 | snd_printdd("->lx_tasklet_playback\n"); | ||
1297 | |||
1298 | err = lx_interrupt_request_new_buffer(chip, lx_stream); | ||
1299 | if (err < 0) | ||
1300 | snd_printk(KERN_ERR LXP | ||
1301 | "cannot request new buffer for playback\n"); | ||
1302 | |||
1303 | snd_pcm_period_elapsed(lx_stream->stream); | ||
1304 | } | ||
1305 | |||
1306 | void lx_tasklet_capture(unsigned long data) | ||
1307 | { | ||
1308 | struct lx6464es *chip = (struct lx6464es *)data; | ||
1309 | struct lx_stream *lx_stream = &chip->capture_stream; | ||
1310 | int err; | ||
1311 | |||
1312 | snd_printdd("->lx_tasklet_capture\n"); | ||
1313 | err = lx_interrupt_request_new_buffer(chip, lx_stream); | ||
1314 | if (err < 0) | ||
1315 | snd_printk(KERN_ERR LXP | ||
1316 | "cannot request new buffer for capture\n"); | ||
1317 | |||
1318 | snd_pcm_period_elapsed(lx_stream->stream); | ||
1319 | } | ||
1320 | |||
1321 | |||
1322 | |||
1323 | static int lx_interrupt_handle_audio_transfer(struct lx6464es *chip, | ||
1324 | u64 notified_in_pipe_mask, | ||
1325 | u64 notified_out_pipe_mask) | ||
1326 | { | ||
1327 | int err = 0; | ||
1328 | |||
1329 | if (notified_in_pipe_mask) { | ||
1330 | snd_printdd(LXP "requesting audio transfer for capture\n"); | ||
1331 | tasklet_hi_schedule(&chip->tasklet_capture); | ||
1332 | } | ||
1333 | |||
1334 | if (notified_out_pipe_mask) { | ||
1335 | snd_printdd(LXP "requesting audio transfer for playback\n"); | ||
1336 | tasklet_hi_schedule(&chip->tasklet_playback); | ||
1337 | } | ||
1338 | |||
1339 | return err; | ||
1340 | } | ||
1341 | |||
1342 | |||
1343 | irqreturn_t lx_interrupt(int irq, void *dev_id) | ||
1344 | { | ||
1345 | struct lx6464es *chip = dev_id; | ||
1346 | int async_pending, async_escmd; | ||
1347 | u32 irqsrc; | ||
1348 | |||
1349 | spin_lock(&chip->lock); | ||
1350 | |||
1351 | snd_printdd("**************************************************\n"); | ||
1352 | |||
1353 | if (!lx_interrupt_ack(chip, &irqsrc, &async_pending, &async_escmd)) { | ||
1354 | spin_unlock(&chip->lock); | ||
1355 | snd_printdd("IRQ_NONE\n"); | ||
1356 | return IRQ_NONE; /* this device did not cause the interrupt */ | ||
1357 | } | ||
1358 | |||
1359 | if (irqsrc & MASK_SYS_STATUS_CMD_DONE) | ||
1360 | goto exit; | ||
1361 | |||
1362 | #if 0 | ||
1363 | if (irqsrc & MASK_SYS_STATUS_EOBI) | ||
1364 | snd_printdd(LXP "interrupt: EOBI\n"); | ||
1365 | |||
1366 | if (irqsrc & MASK_SYS_STATUS_EOBO) | ||
1367 | snd_printdd(LXP "interrupt: EOBO\n"); | ||
1368 | |||
1369 | if (irqsrc & MASK_SYS_STATUS_URUN) | ||
1370 | snd_printdd(LXP "interrupt: URUN\n"); | ||
1371 | |||
1372 | if (irqsrc & MASK_SYS_STATUS_ORUN) | ||
1373 | snd_printdd(LXP "interrupt: ORUN\n"); | ||
1374 | #endif | ||
1375 | |||
1376 | if (async_pending) { | ||
1377 | u64 notified_in_pipe_mask = 0; | ||
1378 | u64 notified_out_pipe_mask = 0; | ||
1379 | int freq_changed; | ||
1380 | int err; | ||
1381 | |||
1382 | /* handle async events */ | ||
1383 | err = lx_interrupt_handle_async_events(chip, irqsrc, | ||
1384 | &freq_changed, | ||
1385 | ¬ified_in_pipe_mask, | ||
1386 | ¬ified_out_pipe_mask); | ||
1387 | if (err) | ||
1388 | snd_printk(KERN_ERR LXP | ||
1389 | "error handling async events\n"); | ||
1390 | |||
1391 | err = lx_interrupt_handle_audio_transfer(chip, | ||
1392 | notified_in_pipe_mask, | ||
1393 | notified_out_pipe_mask | ||
1394 | ); | ||
1395 | if (err) | ||
1396 | snd_printk(KERN_ERR LXP | ||
1397 | "error during audio transfer\n"); | ||
1398 | } | ||
1399 | |||
1400 | if (async_escmd) { | ||
1401 | #if 0 | ||
1402 | /* backdoor for ethersound commands | ||
1403 | * | ||
1404 | * for now, we do not need this | ||
1405 | * | ||
1406 | * */ | ||
1407 | |||
1408 | snd_printdd("lx6464es: interrupt requests escmd handling\n"); | ||
1409 | #endif | ||
1410 | } | ||
1411 | |||
1412 | exit: | ||
1413 | spin_unlock(&chip->lock); | ||
1414 | return IRQ_HANDLED; /* this device caused the interrupt */ | ||
1415 | } | ||
1416 | |||
1417 | |||
1418 | static void lx_irq_set(struct lx6464es *chip, int enable) | ||
1419 | { | ||
1420 | u32 reg = lx_plx_reg_read(chip, ePLX_IRQCS); | ||
1421 | |||
1422 | /* enable/disable interrupts | ||
1423 | * | ||
1424 | * Set the Doorbell and PCI interrupt enable bits | ||
1425 | * | ||
1426 | * */ | ||
1427 | if (enable) | ||
1428 | reg |= (IRQCS_ENABLE_PCIIRQ | IRQCS_ENABLE_PCIDB); | ||
1429 | else | ||
1430 | reg &= ~(IRQCS_ENABLE_PCIIRQ | IRQCS_ENABLE_PCIDB); | ||
1431 | lx_plx_reg_write(chip, ePLX_IRQCS, reg); | ||
1432 | } | ||
1433 | |||
1434 | void lx_irq_enable(struct lx6464es *chip) | ||
1435 | { | ||
1436 | snd_printdd("->lx_irq_enable\n"); | ||
1437 | lx_irq_set(chip, 1); | ||
1438 | } | ||
1439 | |||
1440 | void lx_irq_disable(struct lx6464es *chip) | ||
1441 | { | ||
1442 | snd_printdd("->lx_irq_disable\n"); | ||
1443 | lx_irq_set(chip, 0); | ||
1444 | } | ||
diff --git a/sound/pci/lx6464es/lx_core.h b/sound/pci/lx6464es/lx_core.h new file mode 100644 index 000000000000..6bd9cbbbc68d --- /dev/null +++ b/sound/pci/lx6464es/lx_core.h | |||
@@ -0,0 +1,242 @@ | |||
1 | /* -*- linux-c -*- * | ||
2 | * | ||
3 | * ALSA driver for the digigram lx6464es interface | ||
4 | * low-level interface | ||
5 | * | ||
6 | * Copyright (c) 2009 Tim Blechmann <tim@klingt.org> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; see the file COPYING. If not, write to | ||
20 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
21 | * Boston, MA 02111-1307, USA. | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #ifndef LX_CORE_H | ||
26 | #define LX_CORE_H | ||
27 | |||
28 | #include <linux/interrupt.h> | ||
29 | |||
30 | #include "lx_defs.h" | ||
31 | |||
32 | #define REG_CRM_NUMBER 12 | ||
33 | |||
34 | struct lx6464es; | ||
35 | |||
36 | /* low-level register access */ | ||
37 | |||
38 | /* dsp register access */ | ||
39 | enum { | ||
40 | eReg_BASE, | ||
41 | eReg_CSM, | ||
42 | eReg_CRM1, | ||
43 | eReg_CRM2, | ||
44 | eReg_CRM3, | ||
45 | eReg_CRM4, | ||
46 | eReg_CRM5, | ||
47 | eReg_CRM6, | ||
48 | eReg_CRM7, | ||
49 | eReg_CRM8, | ||
50 | eReg_CRM9, | ||
51 | eReg_CRM10, | ||
52 | eReg_CRM11, | ||
53 | eReg_CRM12, | ||
54 | |||
55 | eReg_ICR, | ||
56 | eReg_CVR, | ||
57 | eReg_ISR, | ||
58 | eReg_RXHTXH, | ||
59 | eReg_RXMTXM, | ||
60 | eReg_RHLTXL, | ||
61 | eReg_RESETDSP, | ||
62 | |||
63 | eReg_CSUF, | ||
64 | eReg_CSES, | ||
65 | eReg_CRESMSB, | ||
66 | eReg_CRESLSB, | ||
67 | eReg_ADMACESMSB, | ||
68 | eReg_ADMACESLSB, | ||
69 | eReg_CONFES, | ||
70 | |||
71 | eMaxPortLx | ||
72 | }; | ||
73 | |||
74 | unsigned long lx_dsp_reg_read(struct lx6464es *chip, int port); | ||
75 | void lx_dsp_reg_readbuf(struct lx6464es *chip, int port, u32 *data, u32 len); | ||
76 | void lx_dsp_reg_write(struct lx6464es *chip, int port, unsigned data); | ||
77 | void lx_dsp_reg_writebuf(struct lx6464es *chip, int port, const u32 *data, | ||
78 | u32 len); | ||
79 | |||
80 | /* plx register access */ | ||
81 | enum { | ||
82 | ePLX_PCICR, | ||
83 | |||
84 | ePLX_MBOX0, | ||
85 | ePLX_MBOX1, | ||
86 | ePLX_MBOX2, | ||
87 | ePLX_MBOX3, | ||
88 | ePLX_MBOX4, | ||
89 | ePLX_MBOX5, | ||
90 | ePLX_MBOX6, | ||
91 | ePLX_MBOX7, | ||
92 | |||
93 | ePLX_L2PCIDB, | ||
94 | ePLX_IRQCS, | ||
95 | ePLX_CHIPSC, | ||
96 | |||
97 | eMaxPort | ||
98 | }; | ||
99 | |||
100 | unsigned long lx_plx_reg_read(struct lx6464es *chip, int port); | ||
101 | void lx_plx_reg_write(struct lx6464es *chip, int port, u32 data); | ||
102 | |||
103 | /* rhm */ | ||
104 | struct lx_rmh { | ||
105 | u16 cmd_len; /* length of the command to send (WORDs) */ | ||
106 | u16 stat_len; /* length of the status received (WORDs) */ | ||
107 | u16 dsp_stat; /* status type, RMP_SSIZE_XXX */ | ||
108 | u16 cmd_idx; /* index of the command */ | ||
109 | u32 cmd[REG_CRM_NUMBER]; | ||
110 | u32 stat[REG_CRM_NUMBER]; | ||
111 | }; | ||
112 | |||
113 | |||
114 | /* low-level dsp access */ | ||
115 | int __devinit lx_dsp_get_version(struct lx6464es *chip, u32 *rdsp_version); | ||
116 | int lx_dsp_get_clock_frequency(struct lx6464es *chip, u32 *rfreq); | ||
117 | int lx_dsp_set_granularity(struct lx6464es *chip, u32 gran); | ||
118 | int lx_dsp_read_async_events(struct lx6464es *chip, u32 *data); | ||
119 | int lx_dsp_get_mac(struct lx6464es *chip, u8 *mac_address); | ||
120 | |||
121 | |||
122 | /* low-level pipe handling */ | ||
123 | int lx_pipe_allocate(struct lx6464es *chip, u32 pipe, int is_capture, | ||
124 | int channels); | ||
125 | int lx_pipe_release(struct lx6464es *chip, u32 pipe, int is_capture); | ||
126 | int lx_pipe_sample_count(struct lx6464es *chip, u32 pipe, int is_capture, | ||
127 | u64 *rsample_count); | ||
128 | int lx_pipe_state(struct lx6464es *chip, u32 pipe, int is_capture, u16 *rstate); | ||
129 | int lx_pipe_stop(struct lx6464es *chip, u32 pipe, int is_capture); | ||
130 | int lx_pipe_start(struct lx6464es *chip, u32 pipe, int is_capture); | ||
131 | int lx_pipe_pause(struct lx6464es *chip, u32 pipe, int is_capture); | ||
132 | |||
133 | int lx_pipe_wait_for_start(struct lx6464es *chip, u32 pipe, int is_capture); | ||
134 | int lx_pipe_wait_for_idle(struct lx6464es *chip, u32 pipe, int is_capture); | ||
135 | |||
136 | /* low-level stream handling */ | ||
137 | int lx_stream_set_format(struct lx6464es *chip, struct snd_pcm_runtime *runtime, | ||
138 | u32 pipe, int is_capture); | ||
139 | int lx_stream_state(struct lx6464es *chip, u32 pipe, int is_capture, | ||
140 | int *rstate); | ||
141 | int lx_stream_sample_position(struct lx6464es *chip, u32 pipe, int is_capture, | ||
142 | u64 *r_bytepos); | ||
143 | |||
144 | int lx_stream_set_state(struct lx6464es *chip, u32 pipe, | ||
145 | int is_capture, enum stream_state_t state); | ||
146 | |||
147 | static inline int lx_stream_start(struct lx6464es *chip, u32 pipe, | ||
148 | int is_capture) | ||
149 | { | ||
150 | snd_printdd("->lx_stream_start\n"); | ||
151 | return lx_stream_set_state(chip, pipe, is_capture, SSTATE_RUN); | ||
152 | } | ||
153 | |||
154 | static inline int lx_stream_pause(struct lx6464es *chip, u32 pipe, | ||
155 | int is_capture) | ||
156 | { | ||
157 | snd_printdd("->lx_stream_pause\n"); | ||
158 | return lx_stream_set_state(chip, pipe, is_capture, SSTATE_PAUSE); | ||
159 | } | ||
160 | |||
161 | static inline int lx_stream_stop(struct lx6464es *chip, u32 pipe, | ||
162 | int is_capture) | ||
163 | { | ||
164 | snd_printdd("->lx_stream_stop\n"); | ||
165 | return lx_stream_set_state(chip, pipe, is_capture, SSTATE_STOP); | ||
166 | } | ||
167 | |||
168 | /* low-level buffer handling */ | ||
169 | int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture, | ||
170 | u32 *r_needed, u32 *r_freed, u32 *size_array); | ||
171 | int lx_buffer_give(struct lx6464es *chip, u32 pipe, int is_capture, | ||
172 | u32 buffer_size, u32 buf_address_lo, u32 buf_address_hi, | ||
173 | u32 *r_buffer_index); | ||
174 | int lx_buffer_free(struct lx6464es *chip, u32 pipe, int is_capture, | ||
175 | u32 *r_buffer_size); | ||
176 | int lx_buffer_cancel(struct lx6464es *chip, u32 pipe, int is_capture, | ||
177 | u32 buffer_index); | ||
178 | |||
179 | /* low-level gain/peak handling */ | ||
180 | int lx_level_unmute(struct lx6464es *chip, int is_capture, int unmute); | ||
181 | int lx_level_peaks(struct lx6464es *chip, int is_capture, int channels, | ||
182 | u32 *r_levels); | ||
183 | |||
184 | |||
185 | /* interrupt handling */ | ||
186 | irqreturn_t lx_interrupt(int irq, void *dev_id); | ||
187 | void lx_irq_enable(struct lx6464es *chip); | ||
188 | void lx_irq_disable(struct lx6464es *chip); | ||
189 | |||
190 | void lx_tasklet_capture(unsigned long data); | ||
191 | void lx_tasklet_playback(unsigned long data); | ||
192 | |||
193 | |||
194 | /* Stream Format Header Defines (for LIN and IEEE754) */ | ||
195 | #define HEADER_FMT_BASE HEADER_FMT_BASE_LIN | ||
196 | #define HEADER_FMT_BASE_LIN 0xFED00000 | ||
197 | #define HEADER_FMT_BASE_FLOAT 0xFAD00000 | ||
198 | #define HEADER_FMT_MONO 0x00000080 /* bit 23 in header_lo. WARNING: old | ||
199 | * bit 22 is ignored in float | ||
200 | * format */ | ||
201 | #define HEADER_FMT_INTEL 0x00008000 | ||
202 | #define HEADER_FMT_16BITS 0x00002000 | ||
203 | #define HEADER_FMT_24BITS 0x00004000 | ||
204 | #define HEADER_FMT_UPTO11 0x00000200 /* frequency is less or equ. to 11k. | ||
205 | * */ | ||
206 | #define HEADER_FMT_UPTO32 0x00000100 /* frequency is over 11k and less | ||
207 | * then 32k.*/ | ||
208 | |||
209 | |||
210 | #define BIT_FMP_HEADER 23 | ||
211 | #define BIT_FMP_SD 22 | ||
212 | #define BIT_FMP_MULTICHANNEL 19 | ||
213 | |||
214 | #define START_STATE 1 | ||
215 | #define PAUSE_STATE 0 | ||
216 | |||
217 | |||
218 | |||
219 | |||
220 | |||
221 | /* from PcxAll_e.h */ | ||
222 | /* Start/Pause condition for pipes (PCXStartPipe, PCXPausePipe) */ | ||
223 | #define START_PAUSE_IMMEDIATE 0 | ||
224 | #define START_PAUSE_ON_SYNCHRO 1 | ||
225 | #define START_PAUSE_ON_TIME_CODE 2 | ||
226 | |||
227 | |||
228 | /* Pipe / Stream state */ | ||
229 | #define START_STATE 1 | ||
230 | #define PAUSE_STATE 0 | ||
231 | |||
232 | static inline void unpack_pointer(dma_addr_t ptr, u32 *r_low, u32 *r_high) | ||
233 | { | ||
234 | *r_low = (u32)(ptr & 0xffffffff); | ||
235 | #if BITS_PER_LONG == 32 | ||
236 | *r_high = 0; | ||
237 | #else | ||
238 | *r_high = (u32)((u64)ptr>>32); | ||
239 | #endif | ||
240 | } | ||
241 | |||
242 | #endif /* LX_CORE_H */ | ||
diff --git a/sound/pci/lx6464es/lx_defs.h b/sound/pci/lx6464es/lx_defs.h new file mode 100644 index 000000000000..49d36bdd512c --- /dev/null +++ b/sound/pci/lx6464es/lx_defs.h | |||
@@ -0,0 +1,376 @@ | |||
1 | /* -*- linux-c -*- * | ||
2 | * | ||
3 | * ALSA driver for the digigram lx6464es interface | ||
4 | * adapted upstream headers | ||
5 | * | ||
6 | * Copyright (c) 2009 Tim Blechmann <tim@klingt.org> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; see the file COPYING. If not, write to | ||
20 | * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
21 | * Boston, MA 02111-1307, USA. | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #ifndef LX_DEFS_H | ||
26 | #define LX_DEFS_H | ||
27 | |||
28 | /* code adapted from ethersound.h */ | ||
29 | #define XES_FREQ_COUNT8_MASK 0x00001FFF /* compteur 25MHz entre 8 ech. */ | ||
30 | #define XES_FREQ_COUNT8_44_MIN 0x00001288 /* 25M / | ||
31 | * [ 44k - ( 44.1k + 48k ) / 2 ] | ||
32 | * * 8 */ | ||
33 | #define XES_FREQ_COUNT8_44_MAX 0x000010F0 /* 25M / [ ( 44.1k + 48k ) / 2 ] | ||
34 | * * 8 */ | ||
35 | #define XES_FREQ_COUNT8_48_MAX 0x00000F08 /* 25M / | ||
36 | * [ 48k + ( 44.1k + 48k ) / 2 ] | ||
37 | * * 8 */ | ||
38 | |||
39 | /* code adapted from LXES_registers.h */ | ||
40 | |||
41 | #define IOCR_OUTPUTS_OFFSET 0 /* (rw) offset for the number of OUTs in the | ||
42 | * ConfES register. */ | ||
43 | #define IOCR_INPUTS_OFFSET 8 /* (rw) offset for the number of INs in the | ||
44 | * ConfES register. */ | ||
45 | #define FREQ_RATIO_OFFSET 19 /* (rw) offset for frequency ratio in the | ||
46 | * ConfES register. */ | ||
47 | #define FREQ_RATIO_SINGLE_MODE 0x01 /* value for single mode frequency ratio: | ||
48 | * sample rate = frequency rate. */ | ||
49 | |||
50 | #define CONFES_READ_PART_MASK 0x00070000 | ||
51 | #define CONFES_WRITE_PART_MASK 0x00F80000 | ||
52 | |||
53 | /* code adapted from if_drv_mb.h */ | ||
54 | |||
55 | #define MASK_SYS_STATUS_ERROR (1L << 31) /* events that lead to a PCI irq if | ||
56 | * not yet pending */ | ||
57 | #define MASK_SYS_STATUS_URUN (1L << 30) | ||
58 | #define MASK_SYS_STATUS_ORUN (1L << 29) | ||
59 | #define MASK_SYS_STATUS_EOBO (1L << 28) | ||
60 | #define MASK_SYS_STATUS_EOBI (1L << 27) | ||
61 | #define MASK_SYS_STATUS_FREQ (1L << 26) | ||
62 | #define MASK_SYS_STATUS_ESA (1L << 25) /* reserved, this is set by the | ||
63 | * XES */ | ||
64 | #define MASK_SYS_STATUS_TIMER (1L << 24) | ||
65 | |||
66 | #define MASK_SYS_ASYNC_EVENTS (MASK_SYS_STATUS_ERROR | \ | ||
67 | MASK_SYS_STATUS_URUN | \ | ||
68 | MASK_SYS_STATUS_ORUN | \ | ||
69 | MASK_SYS_STATUS_EOBO | \ | ||
70 | MASK_SYS_STATUS_EOBI | \ | ||
71 | MASK_SYS_STATUS_FREQ | \ | ||
72 | MASK_SYS_STATUS_ESA) | ||
73 | |||
74 | #define MASK_SYS_PCI_EVENTS (MASK_SYS_ASYNC_EVENTS | \ | ||
75 | MASK_SYS_STATUS_TIMER) | ||
76 | |||
77 | #define MASK_SYS_TIMER_COUNT 0x0000FFFF | ||
78 | |||
79 | #define MASK_SYS_STATUS_EOT_PLX (1L << 22) /* event that remains | ||
80 | * internal: reserved fo end | ||
81 | * of plx dma */ | ||
82 | #define MASK_SYS_STATUS_XES (1L << 21) /* event that remains | ||
83 | * internal: pending XES | ||
84 | * IRQ */ | ||
85 | #define MASK_SYS_STATUS_CMD_DONE (1L << 20) /* alternate command | ||
86 | * management: notify driver | ||
87 | * instead of polling */ | ||
88 | |||
89 | |||
90 | #define MAX_STREAM_BUFFER 5 /* max amount of stream buffers. */ | ||
91 | |||
92 | #define MICROBLAZE_IBL_MIN 32 | ||
93 | #define MICROBLAZE_IBL_DEFAULT 128 | ||
94 | #define MICROBLAZE_IBL_MAX 512 | ||
95 | /* #define MASK_GRANULARITY (2*MICROBLAZE_IBL_MAX-1) */ | ||
96 | |||
97 | |||
98 | |||
99 | /* command opcodes, see reference for details */ | ||
100 | |||
101 | /* | ||
102 | the capture bit position in the object_id field in driver commands | ||
103 | depends upon the number of managed channels. For now, 64 IN + 64 OUT are | ||
104 | supported. HOwever, the communication protocol forsees 1024 channels, hence | ||
105 | bit 10 indicates a capture (input) object). | ||
106 | */ | ||
107 | #define ID_IS_CAPTURE (1L << 10) | ||
108 | #define ID_OFFSET 13 /* object ID is at the 13th bit in the | ||
109 | * 1st command word.*/ | ||
110 | #define ID_CH_MASK 0x3F | ||
111 | #define OPCODE_OFFSET 24 /* offset of the command opcode in the first | ||
112 | * command word.*/ | ||
113 | |||
114 | enum cmd_mb_opcodes { | ||
115 | CMD_00_INFO_DEBUG = 0x00, | ||
116 | CMD_01_GET_SYS_CFG = 0x01, | ||
117 | CMD_02_SET_GRANULARITY = 0x02, | ||
118 | CMD_03_SET_TIMER_IRQ = 0x03, | ||
119 | CMD_04_GET_EVENT = 0x04, | ||
120 | CMD_05_GET_PIPES = 0x05, | ||
121 | |||
122 | CMD_06_ALLOCATE_PIPE = 0x06, | ||
123 | CMD_07_RELEASE_PIPE = 0x07, | ||
124 | CMD_08_ASK_BUFFERS = 0x08, | ||
125 | CMD_09_STOP_PIPE = 0x09, | ||
126 | CMD_0A_GET_PIPE_SPL_COUNT = 0x0a, | ||
127 | CMD_0B_TOGGLE_PIPE_STATE = 0x0b, | ||
128 | |||
129 | CMD_0C_DEF_STREAM = 0x0c, | ||
130 | CMD_0D_SET_MUTE = 0x0d, | ||
131 | CMD_0E_GET_STREAM_SPL_COUNT = 0x0e, | ||
132 | CMD_0F_UPDATE_BUFFER = 0x0f, | ||
133 | CMD_10_GET_BUFFER = 0x10, | ||
134 | CMD_11_CANCEL_BUFFER = 0x11, | ||
135 | CMD_12_GET_PEAK = 0x12, | ||
136 | CMD_13_SET_STREAM_STATE = 0x13, | ||
137 | CMD_14_INVALID = 0x14, | ||
138 | }; | ||
139 | |||
140 | /* pipe states */ | ||
141 | enum pipe_state_t { | ||
142 | PSTATE_IDLE = 0, /* the pipe is not processed in the XES_IRQ | ||
143 | * (free or stopped, or paused). */ | ||
144 | PSTATE_RUN = 1, /* sustained play/record state. */ | ||
145 | PSTATE_PURGE = 2, /* the ES channels are now off, render pipes do | ||
146 | * not DMA, record pipe do a last DMA. */ | ||
147 | PSTATE_ACQUIRE = 3, /* the ES channels are now on, render pipes do | ||
148 | * not yet increase their sample count, record | ||
149 | * pipes do not DMA. */ | ||
150 | PSTATE_CLOSING = 4, /* the pipe is releasing, and may not yet | ||
151 | * receive an "alloc" command. */ | ||
152 | }; | ||
153 | |||
154 | /* stream states */ | ||
155 | enum stream_state_t { | ||
156 | SSTATE_STOP = 0x00, /* setting to stop resets the stream spl | ||
157 | * count.*/ | ||
158 | SSTATE_RUN = (0x01 << 0), /* start DMA and spl count handling. */ | ||
159 | SSTATE_PAUSE = (0x01 << 1), /* pause DMA and spl count handling. */ | ||
160 | }; | ||
161 | |||
162 | /* buffer flags */ | ||
163 | enum buffer_flags { | ||
164 | BF_VALID = 0x80, /* set if the buffer is valid, clear if free.*/ | ||
165 | BF_CURRENT = 0x40, /* set if this is the current buffer (there is | ||
166 | * always a current buffer).*/ | ||
167 | BF_NOTIFY_EOB = 0x20, /* set if this buffer must cause a PCI event | ||
168 | * when finished.*/ | ||
169 | BF_CIRCULAR = 0x10, /* set if buffer[1] must be copied to buffer[0] | ||
170 | * by the end of this buffer.*/ | ||
171 | BF_64BITS_ADR = 0x08, /* set if the hi part of the address is valid.*/ | ||
172 | BF_xx = 0x04, /* future extension.*/ | ||
173 | BF_EOB = 0x02, /* set if finished, but not yet free.*/ | ||
174 | BF_PAUSE = 0x01, /* pause stream at buffer end.*/ | ||
175 | BF_ZERO = 0x00, /* no flags (init).*/ | ||
176 | }; | ||
177 | |||
178 | /** | ||
179 | * Stream Flags definitions | ||
180 | */ | ||
181 | enum stream_flags { | ||
182 | SF_ZERO = 0x00000000, /* no flags (stream invalid). */ | ||
183 | SF_VALID = 0x10000000, /* the stream has a valid DMA_conf | ||
184 | * info (setstreamformat). */ | ||
185 | SF_XRUN = 0x20000000, /* the stream is un x-run state. */ | ||
186 | SF_START = 0x40000000, /* the DMA is running.*/ | ||
187 | SF_ASIO = 0x80000000, /* ASIO.*/ | ||
188 | }; | ||
189 | |||
190 | |||
191 | #define MASK_SPL_COUNT_HI 0x00FFFFFF /* 4 MSBits are status bits */ | ||
192 | #define PSTATE_OFFSET 28 /* 4 MSBits are status bits */ | ||
193 | |||
194 | |||
195 | #define MASK_STREAM_HAS_MAPPING (1L << 12) | ||
196 | #define MASK_STREAM_IS_ASIO (1L << 9) | ||
197 | #define STREAM_FMT_OFFSET 10 /* the stream fmt bits start at the 10th | ||
198 | * bit in the command word. */ | ||
199 | |||
200 | #define STREAM_FMT_16b 0x02 | ||
201 | #define STREAM_FMT_intel 0x01 | ||
202 | |||
203 | #define FREQ_FIELD_OFFSET 15 /* offset of the freq field in the response | ||
204 | * word */ | ||
205 | |||
206 | #define BUFF_FLAGS_OFFSET 24 /* offset of the buffer flags in the | ||
207 | * response word. */ | ||
208 | #define MASK_DATA_SIZE 0x00FFFFFF /* this must match the field size of | ||
209 | * datasize in the buffer_t structure. */ | ||
210 | |||
211 | #define MASK_BUFFER_ID 0xFF /* the cancel command awaits a buffer ID, | ||
212 | * may be 0xFF for "current". */ | ||
213 | |||
214 | |||
215 | /* code adapted from PcxErr_e.h */ | ||
216 | |||
217 | /* Bits masks */ | ||
218 | |||
219 | #define ERROR_MASK 0x8000 | ||
220 | |||
221 | #define SOURCE_MASK 0x7800 | ||
222 | |||
223 | #define E_SOURCE_BOARD 0x4000 /* 8 >> 1 */ | ||
224 | #define E_SOURCE_DRV 0x2000 /* 4 >> 1 */ | ||
225 | #define E_SOURCE_API 0x1000 /* 2 >> 1 */ | ||
226 | /* Error tools */ | ||
227 | #define E_SOURCE_TOOLS 0x0800 /* 1 >> 1 */ | ||
228 | /* Error pcxaudio */ | ||
229 | #define E_SOURCE_AUDIO 0x1800 /* 3 >> 1 */ | ||
230 | /* Error virtual pcx */ | ||
231 | #define E_SOURCE_VPCX 0x2800 /* 5 >> 1 */ | ||
232 | /* Error dispatcher */ | ||
233 | #define E_SOURCE_DISPATCHER 0x3000 /* 6 >> 1 */ | ||
234 | /* Error from CobraNet firmware */ | ||
235 | #define E_SOURCE_COBRANET 0x3800 /* 7 >> 1 */ | ||
236 | |||
237 | #define E_SOURCE_USER 0x7800 | ||
238 | |||
239 | #define CLASS_MASK 0x0700 | ||
240 | |||
241 | #define CODE_MASK 0x00FF | ||
242 | |||
243 | /* Bits values */ | ||
244 | |||
245 | /* Values for the error/warning bit */ | ||
246 | #define ERROR_VALUE 0x8000 | ||
247 | #define WARNING_VALUE 0x0000 | ||
248 | |||
249 | /* Class values */ | ||
250 | #define E_CLASS_GENERAL 0x0000 | ||
251 | #define E_CLASS_INVALID_CMD 0x0100 | ||
252 | #define E_CLASS_INVALID_STD_OBJECT 0x0200 | ||
253 | #define E_CLASS_RSRC_IMPOSSIBLE 0x0300 | ||
254 | #define E_CLASS_WRONG_CONTEXT 0x0400 | ||
255 | #define E_CLASS_BAD_SPECIFIC_PARAMETER 0x0500 | ||
256 | #define E_CLASS_REAL_TIME_ERROR 0x0600 | ||
257 | #define E_CLASS_DIRECTSHOW 0x0700 | ||
258 | #define E_CLASS_FREE 0x0700 | ||
259 | |||
260 | |||
261 | /* Complete DRV error code for the general class */ | ||
262 | #define ED_GN (ERROR_VALUE | E_SOURCE_DRV | E_CLASS_GENERAL) | ||
263 | #define ED_CONCURRENCY (ED_GN | 0x01) | ||
264 | #define ED_DSP_CRASHED (ED_GN | 0x02) | ||
265 | #define ED_UNKNOWN_BOARD (ED_GN | 0x03) | ||
266 | #define ED_NOT_INSTALLED (ED_GN | 0x04) | ||
267 | #define ED_CANNOT_OPEN_SVC_MANAGER (ED_GN | 0x05) | ||
268 | #define ED_CANNOT_READ_REGISTRY (ED_GN | 0x06) | ||
269 | #define ED_DSP_VERSION_MISMATCH (ED_GN | 0x07) | ||
270 | #define ED_UNAVAILABLE_FEATURE (ED_GN | 0x08) | ||
271 | #define ED_CANCELLED (ED_GN | 0x09) | ||
272 | #define ED_NO_RESPONSE_AT_IRQA (ED_GN | 0x10) | ||
273 | #define ED_INVALID_ADDRESS (ED_GN | 0x11) | ||
274 | #define ED_DSP_CORRUPTED (ED_GN | 0x12) | ||
275 | #define ED_PENDING_OPERATION (ED_GN | 0x13) | ||
276 | #define ED_NET_ALLOCATE_MEMORY_IMPOSSIBLE (ED_GN | 0x14) | ||
277 | #define ED_NET_REGISTER_ERROR (ED_GN | 0x15) | ||
278 | #define ED_NET_THREAD_ERROR (ED_GN | 0x16) | ||
279 | #define ED_NET_OPEN_ERROR (ED_GN | 0x17) | ||
280 | #define ED_NET_CLOSE_ERROR (ED_GN | 0x18) | ||
281 | #define ED_NET_NO_MORE_PACKET (ED_GN | 0x19) | ||
282 | #define ED_NET_NO_MORE_BUFFER (ED_GN | 0x1A) | ||
283 | #define ED_NET_SEND_ERROR (ED_GN | 0x1B) | ||
284 | #define ED_NET_RECEIVE_ERROR (ED_GN | 0x1C) | ||
285 | #define ED_NET_WRONG_MSG_SIZE (ED_GN | 0x1D) | ||
286 | #define ED_NET_WAIT_ERROR (ED_GN | 0x1E) | ||
287 | #define ED_NET_EEPROM_ERROR (ED_GN | 0x1F) | ||
288 | #define ED_INVALID_RS232_COM_NUMBER (ED_GN | 0x20) | ||
289 | #define ED_INVALID_RS232_INIT (ED_GN | 0x21) | ||
290 | #define ED_FILE_ERROR (ED_GN | 0x22) | ||
291 | #define ED_INVALID_GPIO_CMD (ED_GN | 0x23) | ||
292 | #define ED_RS232_ALREADY_OPENED (ED_GN | 0x24) | ||
293 | #define ED_RS232_NOT_OPENED (ED_GN | 0x25) | ||
294 | #define ED_GPIO_ALREADY_OPENED (ED_GN | 0x26) | ||
295 | #define ED_GPIO_NOT_OPENED (ED_GN | 0x27) | ||
296 | #define ED_REGISTRY_ERROR (ED_GN | 0x28) /* <- NCX */ | ||
297 | #define ED_INVALID_SERVICE (ED_GN | 0x29) /* <- NCX */ | ||
298 | |||
299 | #define ED_READ_FILE_ALREADY_OPENED (ED_GN | 0x2a) /* <- Decalage | ||
300 | * pour RCX | ||
301 | * (old 0x28) | ||
302 | * */ | ||
303 | #define ED_READ_FILE_INVALID_COMMAND (ED_GN | 0x2b) /* ~ */ | ||
304 | #define ED_READ_FILE_INVALID_PARAMETER (ED_GN | 0x2c) /* ~ */ | ||
305 | #define ED_READ_FILE_ALREADY_CLOSED (ED_GN | 0x2d) /* ~ */ | ||
306 | #define ED_READ_FILE_NO_INFORMATION (ED_GN | 0x2e) /* ~ */ | ||
307 | #define ED_READ_FILE_INVALID_HANDLE (ED_GN | 0x2f) /* ~ */ | ||
308 | #define ED_READ_FILE_END_OF_FILE (ED_GN | 0x30) /* ~ */ | ||
309 | #define ED_READ_FILE_ERROR (ED_GN | 0x31) /* ~ */ | ||
310 | |||
311 | #define ED_DSP_CRASHED_EXC_DSPSTACK_OVERFLOW (ED_GN | 0x32) /* <- Decalage pour | ||
312 | * PCX (old 0x14) */ | ||
313 | #define ED_DSP_CRASHED_EXC_SYSSTACK_OVERFLOW (ED_GN | 0x33) /* ~ */ | ||
314 | #define ED_DSP_CRASHED_EXC_ILLEGAL (ED_GN | 0x34) /* ~ */ | ||
315 | #define ED_DSP_CRASHED_EXC_TIMER_REENTRY (ED_GN | 0x35) /* ~ */ | ||
316 | #define ED_DSP_CRASHED_EXC_FATAL_ERROR (ED_GN | 0x36) /* ~ */ | ||
317 | |||
318 | #define ED_FLASH_PCCARD_NOT_PRESENT (ED_GN | 0x37) | ||
319 | |||
320 | #define ED_NO_CURRENT_CLOCK (ED_GN | 0x38) | ||
321 | |||
322 | /* Complete DRV error code for real time class */ | ||
323 | #define ED_RT (ERROR_VALUE | E_SOURCE_DRV | E_CLASS_REAL_TIME_ERROR) | ||
324 | #define ED_DSP_TIMED_OUT (ED_RT | 0x01) | ||
325 | #define ED_DSP_CHK_TIMED_OUT (ED_RT | 0x02) | ||
326 | #define ED_STREAM_OVERRUN (ED_RT | 0x03) | ||
327 | #define ED_DSP_BUSY (ED_RT | 0x04) | ||
328 | #define ED_DSP_SEMAPHORE_TIME_OUT (ED_RT | 0x05) | ||
329 | #define ED_BOARD_TIME_OUT (ED_RT | 0x06) | ||
330 | #define ED_XILINX_ERROR (ED_RT | 0x07) | ||
331 | #define ED_COBRANET_ITF_NOT_RESPONDING (ED_RT | 0x08) | ||
332 | |||
333 | /* Complete BOARD error code for the invaid standard object class */ | ||
334 | #define EB_ISO (ERROR_VALUE | E_SOURCE_BOARD | \ | ||
335 | E_CLASS_INVALID_STD_OBJECT) | ||
336 | #define EB_INVALID_EFFECT (EB_ISO | 0x00) | ||
337 | #define EB_INVALID_PIPE (EB_ISO | 0x40) | ||
338 | #define EB_INVALID_STREAM (EB_ISO | 0x80) | ||
339 | #define EB_INVALID_AUDIO (EB_ISO | 0xC0) | ||
340 | |||
341 | /* Complete BOARD error code for impossible resource allocation class */ | ||
342 | #define EB_RI (ERROR_VALUE | E_SOURCE_BOARD | E_CLASS_RSRC_IMPOSSIBLE) | ||
343 | #define EB_ALLOCATE_ALL_STREAM_TRANSFERT_BUFFERS_IMPOSSIBLE (EB_RI | 0x01) | ||
344 | #define EB_ALLOCATE_PIPE_SAMPLE_BUFFER_IMPOSSIBLE (EB_RI | 0x02) | ||
345 | |||
346 | #define EB_ALLOCATE_MEM_STREAM_IMPOSSIBLE \ | ||
347 | EB_ALLOCATE_ALL_STREAM_TRANSFERT_BUFFERS_IMPOSSIBLE | ||
348 | #define EB_ALLOCATE_MEM_PIPE_IMPOSSIBLE \ | ||
349 | EB_ALLOCATE_PIPE_SAMPLE_BUFFER_IMPOSSIBLE | ||
350 | |||
351 | #define EB_ALLOCATE_DIFFERED_CMD_IMPOSSIBLE (EB_RI | 0x03) | ||
352 | #define EB_TOO_MANY_DIFFERED_CMD (EB_RI | 0x04) | ||
353 | #define EB_RBUFFERS_TABLE_OVERFLOW (EB_RI | 0x05) | ||
354 | #define EB_ALLOCATE_EFFECTS_IMPOSSIBLE (EB_RI | 0x08) | ||
355 | #define EB_ALLOCATE_EFFECT_POS_IMPOSSIBLE (EB_RI | 0x09) | ||
356 | #define EB_RBUFFER_NOT_AVAILABLE (EB_RI | 0x0A) | ||
357 | #define EB_ALLOCATE_CONTEXT_LIII_IMPOSSIBLE (EB_RI | 0x0B) | ||
358 | #define EB_STATUS_DIALOG_IMPOSSIBLE (EB_RI | 0x1D) | ||
359 | #define EB_CONTROL_CMD_IMPOSSIBLE (EB_RI | 0x1E) | ||
360 | #define EB_STATUS_SEND_IMPOSSIBLE (EB_RI | 0x1F) | ||
361 | #define EB_ALLOCATE_PIPE_IMPOSSIBLE (EB_RI | 0x40) | ||
362 | #define EB_ALLOCATE_STREAM_IMPOSSIBLE (EB_RI | 0x80) | ||
363 | #define EB_ALLOCATE_AUDIO_IMPOSSIBLE (EB_RI | 0xC0) | ||
364 | |||
365 | /* Complete BOARD error code for wrong call context class */ | ||
366 | #define EB_WCC (ERROR_VALUE | E_SOURCE_BOARD | E_CLASS_WRONG_CONTEXT) | ||
367 | #define EB_CMD_REFUSED (EB_WCC | 0x00) | ||
368 | #define EB_START_STREAM_REFUSED (EB_WCC | 0xFC) | ||
369 | #define EB_SPC_REFUSED (EB_WCC | 0xFD) | ||
370 | #define EB_CSN_REFUSED (EB_WCC | 0xFE) | ||
371 | #define EB_CSE_REFUSED (EB_WCC | 0xFF) | ||
372 | |||
373 | |||
374 | |||
375 | |||
376 | #endif /* LX_DEFS_H */ | ||
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index c262049961e1..3b5ca70c9d4d 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c | |||
@@ -487,10 +487,14 @@ static int oxygen_hw_free(struct snd_pcm_substream *substream) | |||
487 | { | 487 | { |
488 | struct oxygen *chip = snd_pcm_substream_chip(substream); | 488 | struct oxygen *chip = snd_pcm_substream_chip(substream); |
489 | unsigned int channel = oxygen_substream_channel(substream); | 489 | unsigned int channel = oxygen_substream_channel(substream); |
490 | unsigned int channel_mask = 1 << channel; | ||
490 | 491 | ||
491 | spin_lock_irq(&chip->reg_lock); | 492 | spin_lock_irq(&chip->reg_lock); |
492 | chip->interrupt_mask &= ~(1 << channel); | 493 | chip->interrupt_mask &= ~channel_mask; |
493 | oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask); | 494 | oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask); |
495 | |||
496 | oxygen_set_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask); | ||
497 | oxygen_clear_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask); | ||
494 | spin_unlock_irq(&chip->reg_lock); | 498 | spin_unlock_irq(&chip->reg_lock); |
495 | 499 | ||
496 | return snd_pcm_lib_free_pages(substream); | 500 | return snd_pcm_lib_free_pages(substream); |
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index bc5ce11c8b14..bf971f7cfdc6 100644 --- a/sound/pci/oxygen/virtuoso.c +++ b/sound/pci/oxygen/virtuoso.c | |||
@@ -113,8 +113,8 @@ | |||
113 | */ | 113 | */ |
114 | 114 | ||
115 | /* | 115 | /* |
116 | * Xonar Essence STX | 116 | * Xonar Essence ST (Deluxe)/STX |
117 | * ----------------- | 117 | * ----------------------------- |
118 | * | 118 | * |
119 | * CMI8788: | 119 | * CMI8788: |
120 | * | 120 | * |
@@ -180,6 +180,8 @@ enum { | |||
180 | MODEL_DX, | 180 | MODEL_DX, |
181 | MODEL_HDAV, /* without daughterboard */ | 181 | MODEL_HDAV, /* without daughterboard */ |
182 | MODEL_HDAV_H6, /* with H6 daughterboard */ | 182 | MODEL_HDAV_H6, /* with H6 daughterboard */ |
183 | MODEL_ST, | ||
184 | MODEL_ST_H6, | ||
183 | MODEL_STX, | 185 | MODEL_STX, |
184 | }; | 186 | }; |
185 | 187 | ||
@@ -188,8 +190,10 @@ static struct pci_device_id xonar_ids[] __devinitdata = { | |||
188 | { OXYGEN_PCI_SUBID(0x1043, 0x8275), .driver_data = MODEL_DX }, | 190 | { OXYGEN_PCI_SUBID(0x1043, 0x8275), .driver_data = MODEL_DX }, |
189 | { OXYGEN_PCI_SUBID(0x1043, 0x82b7), .driver_data = MODEL_D2X }, | 191 | { OXYGEN_PCI_SUBID(0x1043, 0x82b7), .driver_data = MODEL_D2X }, |
190 | { OXYGEN_PCI_SUBID(0x1043, 0x8314), .driver_data = MODEL_HDAV }, | 192 | { OXYGEN_PCI_SUBID(0x1043, 0x8314), .driver_data = MODEL_HDAV }, |
193 | { OXYGEN_PCI_SUBID(0x1043, 0x8327), .driver_data = MODEL_DX }, | ||
191 | { OXYGEN_PCI_SUBID(0x1043, 0x834f), .driver_data = MODEL_D1 }, | 194 | { OXYGEN_PCI_SUBID(0x1043, 0x834f), .driver_data = MODEL_D1 }, |
192 | { OXYGEN_PCI_SUBID(0x1043, 0x835c), .driver_data = MODEL_STX }, | 195 | { OXYGEN_PCI_SUBID(0x1043, 0x835c), .driver_data = MODEL_STX }, |
196 | { OXYGEN_PCI_SUBID(0x1043, 0x835d), .driver_data = MODEL_ST }, | ||
193 | { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, | 197 | { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, |
194 | { } | 198 | { } |
195 | }; | 199 | }; |
@@ -210,9 +214,9 @@ MODULE_DEVICE_TABLE(pci, xonar_ids); | |||
210 | #define GPIO_DX_FRONT_PANEL 0x0002 | 214 | #define GPIO_DX_FRONT_PANEL 0x0002 |
211 | #define GPIO_DX_INPUT_ROUTE 0x0100 | 215 | #define GPIO_DX_INPUT_ROUTE 0x0100 |
212 | 216 | ||
213 | #define GPIO_HDAV_DB_MASK 0x0030 | 217 | #define GPIO_DB_MASK 0x0030 |
214 | #define GPIO_HDAV_DB_H6 0x0000 | 218 | #define GPIO_DB_H6 0x0000 |
215 | #define GPIO_HDAV_DB_XX 0x0020 | 219 | #define GPIO_DB_XX 0x0020 |
216 | 220 | ||
217 | #define GPIO_ST_HP_REAR 0x0002 | 221 | #define GPIO_ST_HP_REAR 0x0002 |
218 | #define GPIO_ST_HP 0x0080 | 222 | #define GPIO_ST_HP 0x0080 |
@@ -530,7 +534,7 @@ static void xonar_hdav_init(struct oxygen *chip) | |||
530 | snd_component_add(chip->card, "CS5381"); | 534 | snd_component_add(chip->card, "CS5381"); |
531 | } | 535 | } |
532 | 536 | ||
533 | static void xonar_stx_init(struct oxygen *chip) | 537 | static void xonar_st_init(struct oxygen *chip) |
534 | { | 538 | { |
535 | struct xonar_data *data = chip->model_data; | 539 | struct xonar_data *data = chip->model_data; |
536 | 540 | ||
@@ -539,12 +543,11 @@ static void xonar_stx_init(struct oxygen *chip) | |||
539 | OXYGEN_2WIRE_INTERRUPT_MASK | | 543 | OXYGEN_2WIRE_INTERRUPT_MASK | |
540 | OXYGEN_2WIRE_SPEED_FAST); | 544 | OXYGEN_2WIRE_SPEED_FAST); |
541 | 545 | ||
546 | if (chip->model.private_data == MODEL_ST_H6) | ||
547 | chip->model.dac_channels = 8; | ||
542 | data->anti_pop_delay = 100; | 548 | data->anti_pop_delay = 100; |
543 | data->dacs = 1; | 549 | data->dacs = chip->model.private_data == MODEL_ST_H6 ? 4 : 1; |
544 | data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE; | 550 | data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE; |
545 | data->ext_power_reg = OXYGEN_GPI_DATA; | ||
546 | data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; | ||
547 | data->ext_power_bit = GPI_DX_EXT_POWER; | ||
548 | data->pcm1796_oversampling = PCM1796_OS_64; | 551 | data->pcm1796_oversampling = PCM1796_OS_64; |
549 | 552 | ||
550 | pcm1796_init(chip); | 553 | pcm1796_init(chip); |
@@ -560,6 +563,17 @@ static void xonar_stx_init(struct oxygen *chip) | |||
560 | snd_component_add(chip->card, "CS5381"); | 563 | snd_component_add(chip->card, "CS5381"); |
561 | } | 564 | } |
562 | 565 | ||
566 | static void xonar_stx_init(struct oxygen *chip) | ||
567 | { | ||
568 | struct xonar_data *data = chip->model_data; | ||
569 | |||
570 | data->ext_power_reg = OXYGEN_GPI_DATA; | ||
571 | data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; | ||
572 | data->ext_power_bit = GPI_DX_EXT_POWER; | ||
573 | |||
574 | xonar_st_init(chip); | ||
575 | } | ||
576 | |||
563 | static void xonar_disable_output(struct oxygen *chip) | 577 | static void xonar_disable_output(struct oxygen *chip) |
564 | { | 578 | { |
565 | struct xonar_data *data = chip->model_data; | 579 | struct xonar_data *data = chip->model_data; |
@@ -1021,7 +1035,8 @@ static const struct oxygen_model model_xonar_hdav = { | |||
1021 | .model_data_size = sizeof(struct xonar_data), | 1035 | .model_data_size = sizeof(struct xonar_data), |
1022 | .device_config = PLAYBACK_0_TO_I2S | | 1036 | .device_config = PLAYBACK_0_TO_I2S | |
1023 | PLAYBACK_1_TO_SPDIF | | 1037 | PLAYBACK_1_TO_SPDIF | |
1024 | CAPTURE_0_FROM_I2S_2, | 1038 | CAPTURE_0_FROM_I2S_2 | |
1039 | CAPTURE_1_FROM_SPDIF, | ||
1025 | .dac_channels = 8, | 1040 | .dac_channels = 8, |
1026 | .dac_volume_min = 255 - 2*60, | 1041 | .dac_volume_min = 255 - 2*60, |
1027 | .dac_volume_max = 255, | 1042 | .dac_volume_max = 255, |
@@ -1034,7 +1049,7 @@ static const struct oxygen_model model_xonar_hdav = { | |||
1034 | static const struct oxygen_model model_xonar_st = { | 1049 | static const struct oxygen_model model_xonar_st = { |
1035 | .longname = "Asus Virtuoso 100", | 1050 | .longname = "Asus Virtuoso 100", |
1036 | .chip = "AV200", | 1051 | .chip = "AV200", |
1037 | .init = xonar_stx_init, | 1052 | .init = xonar_st_init, |
1038 | .control_filter = xonar_st_control_filter, | 1053 | .control_filter = xonar_st_control_filter, |
1039 | .mixer_init = xonar_st_mixer_init, | 1054 | .mixer_init = xonar_st_mixer_init, |
1040 | .cleanup = xonar_st_cleanup, | 1055 | .cleanup = xonar_st_cleanup, |
@@ -1067,6 +1082,7 @@ static int __devinit get_xonar_model(struct oxygen *chip, | |||
1067 | [MODEL_D2] = &model_xonar_d2, | 1082 | [MODEL_D2] = &model_xonar_d2, |
1068 | [MODEL_D2X] = &model_xonar_d2, | 1083 | [MODEL_D2X] = &model_xonar_d2, |
1069 | [MODEL_HDAV] = &model_xonar_hdav, | 1084 | [MODEL_HDAV] = &model_xonar_hdav, |
1085 | [MODEL_ST] = &model_xonar_st, | ||
1070 | [MODEL_STX] = &model_xonar_st, | 1086 | [MODEL_STX] = &model_xonar_st, |
1071 | }; | 1087 | }; |
1072 | static const char *const names[] = { | 1088 | static const char *const names[] = { |
@@ -1076,6 +1092,8 @@ static int __devinit get_xonar_model(struct oxygen *chip, | |||
1076 | [MODEL_D2X] = "Xonar D2X", | 1092 | [MODEL_D2X] = "Xonar D2X", |
1077 | [MODEL_HDAV] = "Xonar HDAV1.3", | 1093 | [MODEL_HDAV] = "Xonar HDAV1.3", |
1078 | [MODEL_HDAV_H6] = "Xonar HDAV1.3+H6", | 1094 | [MODEL_HDAV_H6] = "Xonar HDAV1.3+H6", |
1095 | [MODEL_ST] = "Xonar Essence ST", | ||
1096 | [MODEL_ST_H6] = "Xonar Essence ST+H6", | ||
1079 | [MODEL_STX] = "Xonar Essence STX", | 1097 | [MODEL_STX] = "Xonar Essence STX", |
1080 | }; | 1098 | }; |
1081 | unsigned int model = id->driver_data; | 1099 | unsigned int model = id->driver_data; |
@@ -1092,21 +1110,27 @@ static int __devinit get_xonar_model(struct oxygen *chip, | |||
1092 | chip->model.init = xonar_dx_init; | 1110 | chip->model.init = xonar_dx_init; |
1093 | break; | 1111 | break; |
1094 | case MODEL_HDAV: | 1112 | case MODEL_HDAV: |
1095 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, | 1113 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DB_MASK); |
1096 | GPIO_HDAV_DB_MASK); | 1114 | switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DB_MASK) { |
1097 | switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) & | 1115 | case GPIO_DB_H6: |
1098 | GPIO_HDAV_DB_MASK) { | ||
1099 | case GPIO_HDAV_DB_H6: | ||
1100 | model = MODEL_HDAV_H6; | 1116 | model = MODEL_HDAV_H6; |
1101 | break; | 1117 | break; |
1102 | case GPIO_HDAV_DB_XX: | 1118 | case GPIO_DB_XX: |
1103 | snd_printk(KERN_ERR "unknown daughterboard\n"); | 1119 | snd_printk(KERN_ERR "unknown daughterboard\n"); |
1104 | return -ENODEV; | 1120 | return -ENODEV; |
1105 | } | 1121 | } |
1106 | break; | 1122 | break; |
1123 | case MODEL_ST: | ||
1124 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DB_MASK); | ||
1125 | switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DB_MASK) { | ||
1126 | case GPIO_DB_H6: | ||
1127 | model = MODEL_ST_H6; | ||
1128 | break; | ||
1129 | } | ||
1130 | break; | ||
1107 | case MODEL_STX: | 1131 | case MODEL_STX: |
1108 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, | 1132 | chip->model.init = xonar_stx_init; |
1109 | GPIO_HDAV_DB_MASK); | 1133 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DB_MASK); |
1110 | break; | 1134 | break; |
1111 | } | 1135 | } |
1112 | 1136 | ||
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 6f1034417a02..235a71e5ac8d 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c | |||
@@ -507,41 +507,19 @@ static int riptide_reset(struct cmdif *cif, struct snd_riptide *chip); | |||
507 | */ | 507 | */ |
508 | 508 | ||
509 | static struct pci_device_id snd_riptide_ids[] = { | 509 | static struct pci_device_id snd_riptide_ids[] = { |
510 | { | 510 | { PCI_DEVICE(0x127a, 0x4310) }, |
511 | .vendor = 0x127a,.device = 0x4310, | 511 | { PCI_DEVICE(0x127a, 0x4320) }, |
512 | .subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID, | 512 | { PCI_DEVICE(0x127a, 0x4330) }, |
513 | }, | 513 | { PCI_DEVICE(0x127a, 0x4340) }, |
514 | { | ||
515 | .vendor = 0x127a,.device = 0x4320, | ||
516 | .subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID, | ||
517 | }, | ||
518 | { | ||
519 | .vendor = 0x127a,.device = 0x4330, | ||
520 | .subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID, | ||
521 | }, | ||
522 | { | ||
523 | .vendor = 0x127a,.device = 0x4340, | ||
524 | .subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID, | ||
525 | }, | ||
526 | {0,}, | 514 | {0,}, |
527 | }; | 515 | }; |
528 | 516 | ||
529 | #ifdef SUPPORT_JOYSTICK | 517 | #ifdef SUPPORT_JOYSTICK |
530 | static struct pci_device_id snd_riptide_joystick_ids[] __devinitdata = { | 518 | static struct pci_device_id snd_riptide_joystick_ids[] __devinitdata = { |
531 | { | 519 | { PCI_DEVICE(0x127a, 0x4312) }, |
532 | .vendor = 0x127a,.device = 0x4312, | 520 | { PCI_DEVICE(0x127a, 0x4322) }, |
533 | .subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID, | 521 | { PCI_DEVICE(0x127a, 0x4332) }, |
534 | }, | 522 | { PCI_DEVICE(0x127a, 0x4342) }, |
535 | { | ||
536 | .vendor = 0x127a,.device = 0x4322, | ||
537 | .subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID, | ||
538 | }, | ||
539 | {.vendor = 0x127a,.device = 0x4332, | ||
540 | .subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID, | ||
541 | }, | ||
542 | {.vendor = 0x127a,.device = 0x4342, | ||
543 | .subvendor = PCI_ANY_ID,.subdevice = PCI_ANY_ID, | ||
544 | }, | ||
545 | {0,}, | 523 | {0,}, |
546 | }; | 524 | }; |
547 | #endif | 525 | #endif |
@@ -889,7 +867,7 @@ static int sendcmd(struct cmdif *cif, u32 flags, u32 cmd, u32 parm, | |||
889 | spin_lock_irqsave(&cif->lock, irqflags); | 867 | spin_lock_irqsave(&cif->lock, irqflags); |
890 | while (i++ < CMDIF_TIMEOUT && !IS_READY(cif->hwport)) | 868 | while (i++ < CMDIF_TIMEOUT && !IS_READY(cif->hwport)) |
891 | udelay(10); | 869 | udelay(10); |
892 | if (i >= CMDIF_TIMEOUT) { | 870 | if (i > CMDIF_TIMEOUT) { |
893 | err = -EBUSY; | 871 | err = -EBUSY; |
894 | goto errout; | 872 | goto errout; |
895 | } | 873 | } |
@@ -907,8 +885,10 @@ static int sendcmd(struct cmdif *cif, u32 flags, u32 cmd, u32 parm, | |||
907 | WRITE_PORT_ULONG(cmdport->data1, cmd); /* write cmd */ | 885 | WRITE_PORT_ULONG(cmdport->data1, cmd); /* write cmd */ |
908 | if ((flags & RESP) && ret) { | 886 | if ((flags & RESP) && ret) { |
909 | while (!IS_DATF(cmdport) && | 887 | while (!IS_DATF(cmdport) && |
910 | time++ < CMDIF_TIMEOUT) | 888 | time < CMDIF_TIMEOUT) { |
911 | udelay(10); | 889 | udelay(10); |
890 | time++; | ||
891 | } | ||
912 | if (time < CMDIF_TIMEOUT) { /* read response */ | 892 | if (time < CMDIF_TIMEOUT) { /* read response */ |
913 | ret->retlongs[0] = | 893 | ret->retlongs[0] = |
914 | READ_PORT_ULONG(cmdport->data1); | 894 | READ_PORT_ULONG(cmdport->data1); |
@@ -1207,12 +1187,79 @@ static int riptide_resume(struct pci_dev *pci) | |||
1207 | } | 1187 | } |
1208 | #endif | 1188 | #endif |
1209 | 1189 | ||
1190 | static int try_to_load_firmware(struct cmdif *cif, struct snd_riptide *chip) | ||
1191 | { | ||
1192 | union firmware_version firmware = { .ret = CMDRET_ZERO }; | ||
1193 | int i, timeout, err; | ||
1194 | |||
1195 | for (i = 0; i < 2; i++) { | ||
1196 | WRITE_PORT_ULONG(cif->hwport->port[i].data1, 0); | ||
1197 | WRITE_PORT_ULONG(cif->hwport->port[i].data2, 0); | ||
1198 | } | ||
1199 | SET_GRESET(cif->hwport); | ||
1200 | udelay(100); | ||
1201 | UNSET_GRESET(cif->hwport); | ||
1202 | udelay(100); | ||
1203 | |||
1204 | for (timeout = 100000; --timeout; udelay(10)) { | ||
1205 | if (IS_READY(cif->hwport) && !IS_GERR(cif->hwport)) | ||
1206 | break; | ||
1207 | } | ||
1208 | if (!timeout) { | ||
1209 | snd_printk(KERN_ERR | ||
1210 | "Riptide: device not ready, audio status: 0x%x " | ||
1211 | "ready: %d gerr: %d\n", | ||
1212 | READ_AUDIO_STATUS(cif->hwport), | ||
1213 | IS_READY(cif->hwport), IS_GERR(cif->hwport)); | ||
1214 | return -EIO; | ||
1215 | } else { | ||
1216 | snd_printdd | ||
1217 | ("Riptide: audio status: 0x%x ready: %d gerr: %d\n", | ||
1218 | READ_AUDIO_STATUS(cif->hwport), | ||
1219 | IS_READY(cif->hwport), IS_GERR(cif->hwport)); | ||
1220 | } | ||
1221 | |||
1222 | SEND_GETV(cif, &firmware.ret); | ||
1223 | snd_printdd("Firmware version: ASIC: %d CODEC %d AUXDSP %d PROG %d\n", | ||
1224 | firmware.firmware.ASIC, firmware.firmware.CODEC, | ||
1225 | firmware.firmware.AUXDSP, firmware.firmware.PROG); | ||
1226 | |||
1227 | for (i = 0; i < FIRMWARE_VERSIONS; i++) { | ||
1228 | if (!memcmp(&firmware_versions[i], &firmware, sizeof(firmware))) | ||
1229 | break; | ||
1230 | } | ||
1231 | if (i >= FIRMWARE_VERSIONS) | ||
1232 | return 0; /* no match */ | ||
1233 | |||
1234 | if (!chip) | ||
1235 | return 1; /* OK */ | ||
1236 | |||
1237 | snd_printdd("Writing Firmware\n"); | ||
1238 | if (!chip->fw_entry) { | ||
1239 | err = request_firmware(&chip->fw_entry, "riptide.hex", | ||
1240 | &chip->pci->dev); | ||
1241 | if (err) { | ||
1242 | snd_printk(KERN_ERR | ||
1243 | "Riptide: Firmware not available %d\n", err); | ||
1244 | return -EIO; | ||
1245 | } | ||
1246 | } | ||
1247 | err = loadfirmware(cif, chip->fw_entry->data, chip->fw_entry->size); | ||
1248 | if (err) { | ||
1249 | snd_printk(KERN_ERR | ||
1250 | "Riptide: Could not load firmware %d\n", err); | ||
1251 | return err; | ||
1252 | } | ||
1253 | |||
1254 | chip->firmware = firmware; | ||
1255 | |||
1256 | return 1; /* OK */ | ||
1257 | } | ||
1258 | |||
1210 | static int riptide_reset(struct cmdif *cif, struct snd_riptide *chip) | 1259 | static int riptide_reset(struct cmdif *cif, struct snd_riptide *chip) |
1211 | { | 1260 | { |
1212 | int timeout, tries; | ||
1213 | union cmdret rptr = CMDRET_ZERO; | 1261 | union cmdret rptr = CMDRET_ZERO; |
1214 | union firmware_version firmware; | 1262 | int err, tries; |
1215 | int i, j, err, has_firmware; | ||
1216 | 1263 | ||
1217 | if (!cif) | 1264 | if (!cif) |
1218 | return -EINVAL; | 1265 | return -EINVAL; |
@@ -1225,75 +1272,11 @@ static int riptide_reset(struct cmdif *cif, struct snd_riptide *chip) | |||
1225 | cif->is_reset = 0; | 1272 | cif->is_reset = 0; |
1226 | 1273 | ||
1227 | tries = RESET_TRIES; | 1274 | tries = RESET_TRIES; |
1228 | has_firmware = 0; | 1275 | do { |
1229 | while (has_firmware == 0 && tries-- > 0) { | 1276 | err = try_to_load_firmware(cif, chip); |
1230 | for (i = 0; i < 2; i++) { | 1277 | if (err < 0) |
1231 | WRITE_PORT_ULONG(cif->hwport->port[i].data1, 0); | 1278 | return err; |
1232 | WRITE_PORT_ULONG(cif->hwport->port[i].data2, 0); | 1279 | } while (!err && --tries); |
1233 | } | ||
1234 | SET_GRESET(cif->hwport); | ||
1235 | udelay(100); | ||
1236 | UNSET_GRESET(cif->hwport); | ||
1237 | udelay(100); | ||
1238 | |||
1239 | for (timeout = 100000; --timeout; udelay(10)) { | ||
1240 | if (IS_READY(cif->hwport) && !IS_GERR(cif->hwport)) | ||
1241 | break; | ||
1242 | } | ||
1243 | if (timeout == 0) { | ||
1244 | snd_printk(KERN_ERR | ||
1245 | "Riptide: device not ready, audio status: 0x%x ready: %d gerr: %d\n", | ||
1246 | READ_AUDIO_STATUS(cif->hwport), | ||
1247 | IS_READY(cif->hwport), IS_GERR(cif->hwport)); | ||
1248 | return -EIO; | ||
1249 | } else { | ||
1250 | snd_printdd | ||
1251 | ("Riptide: audio status: 0x%x ready: %d gerr: %d\n", | ||
1252 | READ_AUDIO_STATUS(cif->hwport), | ||
1253 | IS_READY(cif->hwport), IS_GERR(cif->hwport)); | ||
1254 | } | ||
1255 | |||
1256 | SEND_GETV(cif, &rptr); | ||
1257 | for (i = 0; i < 4; i++) | ||
1258 | firmware.ret.retwords[i] = rptr.retwords[i]; | ||
1259 | |||
1260 | snd_printdd | ||
1261 | ("Firmware version: ASIC: %d CODEC %d AUXDSP %d PROG %d\n", | ||
1262 | firmware.firmware.ASIC, firmware.firmware.CODEC, | ||
1263 | firmware.firmware.AUXDSP, firmware.firmware.PROG); | ||
1264 | |||
1265 | for (j = 0; j < FIRMWARE_VERSIONS; j++) { | ||
1266 | has_firmware = 1; | ||
1267 | for (i = 0; i < 4; i++) { | ||
1268 | if (firmware_versions[j].ret.retwords[i] != | ||
1269 | firmware.ret.retwords[i]) | ||
1270 | has_firmware = 0; | ||
1271 | } | ||
1272 | if (has_firmware) | ||
1273 | break; | ||
1274 | } | ||
1275 | |||
1276 | if (chip != NULL && has_firmware == 0) { | ||
1277 | snd_printdd("Writing Firmware\n"); | ||
1278 | if (!chip->fw_entry) { | ||
1279 | if ((err = | ||
1280 | request_firmware(&chip->fw_entry, | ||
1281 | "riptide.hex", | ||
1282 | &chip->pci->dev)) != 0) { | ||
1283 | snd_printk(KERN_ERR | ||
1284 | "Riptide: Firmware not available %d\n", | ||
1285 | err); | ||
1286 | return -EIO; | ||
1287 | } | ||
1288 | } | ||
1289 | err = loadfirmware(cif, chip->fw_entry->data, | ||
1290 | chip->fw_entry->size); | ||
1291 | if (err) | ||
1292 | snd_printk(KERN_ERR | ||
1293 | "Riptide: Could not load firmware %d\n", | ||
1294 | err); | ||
1295 | } | ||
1296 | } | ||
1297 | 1280 | ||
1298 | SEND_SACR(cif, 0, AC97_RESET); | 1281 | SEND_SACR(cif, 0, AC97_RESET); |
1299 | SEND_RACR(cif, AC97_RESET, &rptr); | 1282 | SEND_RACR(cif, AC97_RESET, &rptr); |
@@ -1335,11 +1318,6 @@ static int riptide_reset(struct cmdif *cif, struct snd_riptide *chip) | |||
1335 | SET_AIE(cif->hwport); | 1318 | SET_AIE(cif->hwport); |
1336 | SET_AIACK(cif->hwport); | 1319 | SET_AIACK(cif->hwport); |
1337 | cif->is_reset = 1; | 1320 | cif->is_reset = 1; |
1338 | if (chip) { | ||
1339 | for (i = 0; i < 4; i++) | ||
1340 | chip->firmware.ret.retwords[i] = | ||
1341 | firmware.ret.retwords[i]; | ||
1342 | } | ||
1343 | 1321 | ||
1344 | return 0; | 1322 | return 0; |
1345 | } | 1323 | } |
@@ -1454,7 +1432,7 @@ static int snd_riptide_trigger(struct snd_pcm_substream *substream, int cmd) | |||
1454 | SEND_GPOS(cif, 0, data->id, &rptr); | 1432 | SEND_GPOS(cif, 0, data->id, &rptr); |
1455 | udelay(1); | 1433 | udelay(1); |
1456 | } while (i != rptr.retlongs[1] && j++ < MAX_WRITE_RETRY); | 1434 | } while (i != rptr.retlongs[1] && j++ < MAX_WRITE_RETRY); |
1457 | if (j >= MAX_WRITE_RETRY) | 1435 | if (j > MAX_WRITE_RETRY) |
1458 | snd_printk(KERN_ERR "Riptide: Could not stop stream!"); | 1436 | snd_printk(KERN_ERR "Riptide: Could not stop stream!"); |
1459 | break; | 1437 | break; |
1460 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 1438 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
@@ -1783,7 +1761,7 @@ snd_riptide_codec_write(struct snd_ac97 *ac97, unsigned short reg, | |||
1783 | SEND_SACR(cif, val, reg); | 1761 | SEND_SACR(cif, val, reg); |
1784 | SEND_RACR(cif, reg, &rptr); | 1762 | SEND_RACR(cif, reg, &rptr); |
1785 | } while (rptr.retwords[1] != val && i++ < MAX_WRITE_RETRY); | 1763 | } while (rptr.retwords[1] != val && i++ < MAX_WRITE_RETRY); |
1786 | if (i == MAX_WRITE_RETRY) | 1764 | if (i > MAX_WRITE_RETRY) |
1787 | snd_printdd("Write AC97 reg failed\n"); | 1765 | snd_printdd("Write AC97 reg failed\n"); |
1788 | } | 1766 | } |
1789 | 1767 | ||
@@ -2036,14 +2014,12 @@ static int __devinit snd_riptide_mixer(struct snd_riptide *chip) | |||
2036 | } | 2014 | } |
2037 | 2015 | ||
2038 | #ifdef SUPPORT_JOYSTICK | 2016 | #ifdef SUPPORT_JOYSTICK |
2039 | static int have_joystick; | ||
2040 | static struct pci_dev *riptide_gameport_pci; | ||
2041 | static struct gameport *riptide_gameport; | ||
2042 | 2017 | ||
2043 | static int __devinit | 2018 | static int __devinit |
2044 | snd_riptide_joystick_probe(struct pci_dev *pci, const struct pci_device_id *id) | 2019 | snd_riptide_joystick_probe(struct pci_dev *pci, const struct pci_device_id *id) |
2045 | { | 2020 | { |
2046 | static int dev; | 2021 | static int dev; |
2022 | struct gameport *gameport; | ||
2047 | 2023 | ||
2048 | if (dev >= SNDRV_CARDS) | 2024 | if (dev >= SNDRV_CARDS) |
2049 | return -ENODEV; | 2025 | return -ENODEV; |
@@ -2052,36 +2028,33 @@ snd_riptide_joystick_probe(struct pci_dev *pci, const struct pci_device_id *id) | |||
2052 | return -ENOENT; | 2028 | return -ENOENT; |
2053 | } | 2029 | } |
2054 | 2030 | ||
2055 | if (joystick_port[dev]) { | 2031 | if (!joystick_port[dev++]) |
2056 | riptide_gameport = gameport_allocate_port(); | 2032 | return 0; |
2057 | if (riptide_gameport) { | 2033 | |
2058 | if (!request_region | 2034 | gameport = gameport_allocate_port(); |
2059 | (joystick_port[dev], 8, "Riptide gameport")) { | 2035 | if (!gameport) |
2060 | snd_printk(KERN_WARNING | 2036 | return -ENOMEM; |
2061 | "Riptide: cannot grab gameport 0x%x\n", | 2037 | if (!request_region(joystick_port[dev], 8, "Riptide gameport")) { |
2062 | joystick_port[dev]); | 2038 | snd_printk(KERN_WARNING |
2063 | gameport_free_port(riptide_gameport); | 2039 | "Riptide: cannot grab gameport 0x%x\n", |
2064 | riptide_gameport = NULL; | 2040 | joystick_port[dev]); |
2065 | } else { | 2041 | gameport_free_port(gameport); |
2066 | riptide_gameport_pci = pci; | 2042 | return -EBUSY; |
2067 | riptide_gameport->io = joystick_port[dev]; | ||
2068 | gameport_register_port(riptide_gameport); | ||
2069 | } | ||
2070 | } | ||
2071 | } | 2043 | } |
2072 | dev++; | 2044 | |
2045 | gameport->io = joystick_port[dev]; | ||
2046 | gameport_register_port(gameport); | ||
2047 | pci_set_drvdata(pci, gameport); | ||
2073 | return 0; | 2048 | return 0; |
2074 | } | 2049 | } |
2075 | 2050 | ||
2076 | static void __devexit snd_riptide_joystick_remove(struct pci_dev *pci) | 2051 | static void __devexit snd_riptide_joystick_remove(struct pci_dev *pci) |
2077 | { | 2052 | { |
2078 | if (riptide_gameport) { | 2053 | struct gameport *gameport = pci_get_drvdata(pci); |
2079 | if (riptide_gameport_pci == pci) { | 2054 | if (gameport) { |
2080 | release_region(riptide_gameport->io, 8); | 2055 | release_region(gameport->io, 8); |
2081 | riptide_gameport_pci = NULL; | 2056 | gameport_unregister_port(gameport); |
2082 | gameport_unregister_port(riptide_gameport); | 2057 | pci_set_drvdata(pci, NULL); |
2083 | riptide_gameport = NULL; | ||
2084 | } | ||
2085 | } | 2058 | } |
2086 | } | 2059 | } |
2087 | #endif | 2060 | #endif |
@@ -2092,8 +2065,8 @@ snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
2092 | static int dev; | 2065 | static int dev; |
2093 | struct snd_card *card; | 2066 | struct snd_card *card; |
2094 | struct snd_riptide *chip; | 2067 | struct snd_riptide *chip; |
2095 | unsigned short addr; | 2068 | unsigned short val; |
2096 | int err = 0; | 2069 | int err; |
2097 | 2070 | ||
2098 | if (dev >= SNDRV_CARDS) | 2071 | if (dev >= SNDRV_CARDS) |
2099 | return -ENODEV; | 2072 | return -ENODEV; |
@@ -2105,60 +2078,63 @@ snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
2105 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); | 2078 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); |
2106 | if (err < 0) | 2079 | if (err < 0) |
2107 | return err; | 2080 | return err; |
2108 | if ((err = snd_riptide_create(card, pci, &chip)) < 0) { | 2081 | err = snd_riptide_create(card, pci, &chip); |
2109 | snd_card_free(card); | 2082 | if (err < 0) |
2110 | return err; | 2083 | goto error; |
2111 | } | ||
2112 | card->private_data = chip; | 2084 | card->private_data = chip; |
2113 | if ((err = snd_riptide_pcm(chip, 0, NULL)) < 0) { | 2085 | err = snd_riptide_pcm(chip, 0, NULL); |
2114 | snd_card_free(card); | 2086 | if (err < 0) |
2115 | return err; | 2087 | goto error; |
2116 | } | 2088 | err = snd_riptide_mixer(chip); |
2117 | if ((err = snd_riptide_mixer(chip)) < 0) { | 2089 | if (err < 0) |
2118 | snd_card_free(card); | 2090 | goto error; |
2119 | return err; | 2091 | |
2120 | } | 2092 | val = LEGACY_ENABLE_ALL; |
2121 | pci_write_config_word(chip->pci, PCI_EXT_Legacy_Mask, LEGACY_ENABLE_ALL | 2093 | if (opl3_port[dev]) |
2122 | | (opl3_port[dev] ? LEGACY_ENABLE_FM : 0) | 2094 | val |= LEGACY_ENABLE_FM; |
2123 | #ifdef SUPPORT_JOYSTICK | 2095 | #ifdef SUPPORT_JOYSTICK |
2124 | | (joystick_port[dev] ? LEGACY_ENABLE_GAMEPORT : | 2096 | if (joystick_port[dev]) |
2125 | 0) | 2097 | val |= LEGACY_ENABLE_GAMEPORT; |
2126 | #endif | 2098 | #endif |
2127 | | (mpu_port[dev] | 2099 | if (mpu_port[dev]) |
2128 | ? (LEGACY_ENABLE_MPU_INT | LEGACY_ENABLE_MPU) : | 2100 | val |= LEGACY_ENABLE_MPU_INT | LEGACY_ENABLE_MPU; |
2129 | 0) | 2101 | val |= (chip->irq << 4) & 0xf0; |
2130 | | ((chip->irq << 4) & 0xF0)); | 2102 | pci_write_config_word(chip->pci, PCI_EXT_Legacy_Mask, val); |
2131 | if ((addr = mpu_port[dev]) != 0) { | 2103 | if (mpu_port[dev]) { |
2132 | pci_write_config_word(chip->pci, PCI_EXT_MPU_Base, addr); | 2104 | val = mpu_port[dev]; |
2133 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_RIPTIDE, | 2105 | pci_write_config_word(chip->pci, PCI_EXT_MPU_Base, val); |
2134 | addr, 0, chip->irq, 0, | 2106 | err = snd_mpu401_uart_new(card, 0, MPU401_HW_RIPTIDE, |
2135 | &chip->rmidi)) < 0) | 2107 | val, 0, chip->irq, 0, |
2108 | &chip->rmidi); | ||
2109 | if (err < 0) | ||
2136 | snd_printk(KERN_WARNING | 2110 | snd_printk(KERN_WARNING |
2137 | "Riptide: Can't Allocate MPU at 0x%x\n", | 2111 | "Riptide: Can't Allocate MPU at 0x%x\n", |
2138 | addr); | 2112 | val); |
2139 | else | 2113 | else |
2140 | chip->mpuaddr = addr; | 2114 | chip->mpuaddr = val; |
2141 | } | 2115 | } |
2142 | if ((addr = opl3_port[dev]) != 0) { | 2116 | if (opl3_port[dev]) { |
2143 | pci_write_config_word(chip->pci, PCI_EXT_FM_Base, addr); | 2117 | val = opl3_port[dev]; |
2144 | if ((err = snd_opl3_create(card, addr, addr + 2, | 2118 | pci_write_config_word(chip->pci, PCI_EXT_FM_Base, val); |
2145 | OPL3_HW_RIPTIDE, 0, | 2119 | err = snd_opl3_create(card, val, val + 2, |
2146 | &chip->opl3)) < 0) | 2120 | OPL3_HW_RIPTIDE, 0, &chip->opl3); |
2121 | if (err < 0) | ||
2147 | snd_printk(KERN_WARNING | 2122 | snd_printk(KERN_WARNING |
2148 | "Riptide: Can't Allocate OPL3 at 0x%x\n", | 2123 | "Riptide: Can't Allocate OPL3 at 0x%x\n", |
2149 | addr); | 2124 | val); |
2150 | else { | 2125 | else { |
2151 | chip->opladdr = addr; | 2126 | chip->opladdr = val; |
2152 | if ((err = | 2127 | err = snd_opl3_hwdep_new(chip->opl3, 0, 1, NULL); |
2153 | snd_opl3_hwdep_new(chip->opl3, 0, 1, NULL)) < 0) | 2128 | if (err < 0) |
2154 | snd_printk(KERN_WARNING | 2129 | snd_printk(KERN_WARNING |
2155 | "Riptide: Can't Allocate OPL3-HWDEP\n"); | 2130 | "Riptide: Can't Allocate OPL3-HWDEP\n"); |
2156 | } | 2131 | } |
2157 | } | 2132 | } |
2158 | #ifdef SUPPORT_JOYSTICK | 2133 | #ifdef SUPPORT_JOYSTICK |
2159 | if ((addr = joystick_port[dev]) != 0) { | 2134 | if (joystick_port[dev]) { |
2160 | pci_write_config_word(chip->pci, PCI_EXT_Game_Base, addr); | 2135 | val = joystick_port[dev]; |
2161 | chip->gameaddr = addr; | 2136 | pci_write_config_word(chip->pci, PCI_EXT_Game_Base, val); |
2137 | chip->gameaddr = val; | ||
2162 | } | 2138 | } |
2163 | #endif | 2139 | #endif |
2164 | 2140 | ||
@@ -2176,13 +2152,16 @@ snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
2176 | chip->opladdr); | 2152 | chip->opladdr); |
2177 | #endif | 2153 | #endif |
2178 | snd_riptide_proc_init(chip); | 2154 | snd_riptide_proc_init(chip); |
2179 | if ((err = snd_card_register(card)) < 0) { | 2155 | err = snd_card_register(card); |
2180 | snd_card_free(card); | 2156 | if (err < 0) |
2181 | return err; | 2157 | goto error; |
2182 | } | ||
2183 | pci_set_drvdata(pci, card); | 2158 | pci_set_drvdata(pci, card); |
2184 | dev++; | 2159 | dev++; |
2185 | return 0; | 2160 | return 0; |
2161 | |||
2162 | error: | ||
2163 | snd_card_free(card); | ||
2164 | return err; | ||
2186 | } | 2165 | } |
2187 | 2166 | ||
2188 | static void __devexit snd_card_riptide_remove(struct pci_dev *pci) | 2167 | static void __devexit snd_card_riptide_remove(struct pci_dev *pci) |
@@ -2214,14 +2193,11 @@ static struct pci_driver joystick_driver = { | |||
2214 | static int __init alsa_card_riptide_init(void) | 2193 | static int __init alsa_card_riptide_init(void) |
2215 | { | 2194 | { |
2216 | int err; | 2195 | int err; |
2217 | if ((err = pci_register_driver(&driver)) < 0) | 2196 | err = pci_register_driver(&driver); |
2197 | if (err < 0) | ||
2218 | return err; | 2198 | return err; |
2219 | #if defined(SUPPORT_JOYSTICK) | 2199 | #if defined(SUPPORT_JOYSTICK) |
2220 | if (pci_register_driver(&joystick_driver) < 0) { | 2200 | pci_register_driver(&joystick_driver); |
2221 | have_joystick = 0; | ||
2222 | snd_printk(KERN_INFO "no joystick found\n"); | ||
2223 | } else | ||
2224 | have_joystick = 1; | ||
2225 | #endif | 2201 | #endif |
2226 | return 0; | 2202 | return 0; |
2227 | } | 2203 | } |
@@ -2230,8 +2206,7 @@ static void __exit alsa_card_riptide_exit(void) | |||
2230 | { | 2206 | { |
2231 | pci_unregister_driver(&driver); | 2207 | pci_unregister_driver(&driver); |
2232 | #if defined(SUPPORT_JOYSTICK) | 2208 | #if defined(SUPPORT_JOYSTICK) |
2233 | if (have_joystick) | 2209 | pci_unregister_driver(&joystick_driver); |
2234 | pci_unregister_driver(&joystick_driver); | ||
2235 | #endif | 2210 | #endif |
2236 | } | 2211 | } |
2237 | 2212 | ||
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 314e73531bd1..3da5c029f93b 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/pci.h> | 28 | #include <linux/pci.h> |
29 | #include <linux/firmware.h> | 29 | #include <linux/firmware.h> |
30 | #include <linux/moduleparam.h> | 30 | #include <linux/moduleparam.h> |
31 | #include <linux/math64.h> | ||
31 | 32 | ||
32 | #include <sound/core.h> | 33 | #include <sound/core.h> |
33 | #include <sound/control.h> | 34 | #include <sound/control.h> |
@@ -402,9 +403,9 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin"); | |||
402 | #define HDSP_DMA_AREA_BYTES ((HDSP_MAX_CHANNELS+1) * HDSP_CHANNEL_BUFFER_BYTES) | 403 | #define HDSP_DMA_AREA_BYTES ((HDSP_MAX_CHANNELS+1) * HDSP_CHANNEL_BUFFER_BYTES) |
403 | #define HDSP_DMA_AREA_KILOBYTES (HDSP_DMA_AREA_BYTES/1024) | 404 | #define HDSP_DMA_AREA_KILOBYTES (HDSP_DMA_AREA_BYTES/1024) |
404 | 405 | ||
405 | /* use hotplug firmeare loader? */ | 406 | /* use hotplug firmware loader? */ |
406 | #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) | 407 | #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) |
407 | #if !defined(HDSP_USE_HWDEP_LOADER) && !defined(CONFIG_SND_HDSP) | 408 | #if !defined(HDSP_USE_HWDEP_LOADER) |
408 | #define HDSP_FW_LOADER | 409 | #define HDSP_FW_LOADER |
409 | #endif | 410 | #endif |
410 | #endif | 411 | #endif |
@@ -1047,7 +1048,6 @@ static int hdsp_set_interrupt_interval(struct hdsp *s, unsigned int frames) | |||
1047 | static void hdsp_set_dds_value(struct hdsp *hdsp, int rate) | 1048 | static void hdsp_set_dds_value(struct hdsp *hdsp, int rate) |
1048 | { | 1049 | { |
1049 | u64 n; | 1050 | u64 n; |
1050 | u32 r; | ||
1051 | 1051 | ||
1052 | if (rate >= 112000) | 1052 | if (rate >= 112000) |
1053 | rate /= 4; | 1053 | rate /= 4; |
@@ -1055,7 +1055,7 @@ static void hdsp_set_dds_value(struct hdsp *hdsp, int rate) | |||
1055 | rate /= 2; | 1055 | rate /= 2; |
1056 | 1056 | ||
1057 | n = DDS_NUMERATOR; | 1057 | n = DDS_NUMERATOR; |
1058 | div64_32(&n, rate, &r); | 1058 | n = div_u64(n, rate); |
1059 | /* n should be less than 2^32 for being written to FREQ register */ | 1059 | /* n should be less than 2^32 for being written to FREQ register */ |
1060 | snd_BUG_ON(n >> 32); | 1060 | snd_BUG_ON(n >> 32); |
1061 | /* HDSP_freqReg and HDSP_resetPointer are the same, so keep the DDS | 1061 | /* HDSP_freqReg and HDSP_resetPointer are the same, so keep the DDS |
@@ -3097,7 +3097,6 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn | |||
3097 | static int hdsp_dds_offset(struct hdsp *hdsp) | 3097 | static int hdsp_dds_offset(struct hdsp *hdsp) |
3098 | { | 3098 | { |
3099 | u64 n; | 3099 | u64 n; |
3100 | u32 r; | ||
3101 | unsigned int dds_value = hdsp->dds_value; | 3100 | unsigned int dds_value = hdsp->dds_value; |
3102 | int system_sample_rate = hdsp->system_sample_rate; | 3101 | int system_sample_rate = hdsp->system_sample_rate; |
3103 | 3102 | ||
@@ -3109,7 +3108,7 @@ static int hdsp_dds_offset(struct hdsp *hdsp) | |||
3109 | * dds_value = n / rate | 3108 | * dds_value = n / rate |
3110 | * rate = n / dds_value | 3109 | * rate = n / dds_value |
3111 | */ | 3110 | */ |
3112 | div64_32(&n, dds_value, &r); | 3111 | n = div_u64(n, dds_value); |
3113 | if (system_sample_rate >= 112000) | 3112 | if (system_sample_rate >= 112000) |
3114 | n *= 4; | 3113 | n *= 4; |
3115 | else if (system_sample_rate >= 56000) | 3114 | else if (system_sample_rate >= 56000) |
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index bac2dc0c5d85..0dce331a2a3b 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/moduleparam.h> | 29 | #include <linux/moduleparam.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
32 | #include <linux/math64.h> | ||
32 | #include <asm/io.h> | 33 | #include <asm/io.h> |
33 | 34 | ||
34 | #include <sound/core.h> | 35 | #include <sound/core.h> |
@@ -831,7 +832,6 @@ static int hdspm_set_interrupt_interval(struct hdspm * s, unsigned int frames) | |||
831 | static void hdspm_set_dds_value(struct hdspm *hdspm, int rate) | 832 | static void hdspm_set_dds_value(struct hdspm *hdspm, int rate) |
832 | { | 833 | { |
833 | u64 n; | 834 | u64 n; |
834 | u32 r; | ||
835 | 835 | ||
836 | if (rate >= 112000) | 836 | if (rate >= 112000) |
837 | rate /= 4; | 837 | rate /= 4; |
@@ -844,7 +844,7 @@ static void hdspm_set_dds_value(struct hdspm *hdspm, int rate) | |||
844 | */ | 844 | */ |
845 | /* n = 104857600000000ULL; */ /* = 2^20 * 10^8 */ | 845 | /* n = 104857600000000ULL; */ /* = 2^20 * 10^8 */ |
846 | n = 110100480000000ULL; /* Value checked for AES32 and MADI */ | 846 | n = 110100480000000ULL; /* Value checked for AES32 and MADI */ |
847 | div64_32(&n, rate, &r); | 847 | n = div_u64(n, rate); |
848 | /* n should be less than 2^32 for being written to FREQ register */ | 848 | /* n should be less than 2^32 for being written to FREQ register */ |
849 | snd_BUG_ON(n >> 32); | 849 | snd_BUG_ON(n >> 32); |
850 | hdspm_write(hdspm, HDSPM_freqReg, (u32)n); | 850 | hdspm_write(hdspm, HDSPM_freqReg, (u32)n); |
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 809b233dd4a3..1ef58c51c213 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c | |||
@@ -1687,7 +1687,7 @@ static int snd_via8233_pcmdxs_volume_put(struct snd_kcontrol *kcontrol, | |||
1687 | return change; | 1687 | return change; |
1688 | } | 1688 | } |
1689 | 1689 | ||
1690 | static const DECLARE_TLV_DB_SCALE(db_scale_dxs, -9450, 150, 1); | 1690 | static const DECLARE_TLV_DB_SCALE(db_scale_dxs, -4650, 150, 1); |
1691 | 1691 | ||
1692 | static struct snd_kcontrol_new snd_via8233_pcmdxs_volume_control __devinitdata = { | 1692 | static struct snd_kcontrol_new snd_via8233_pcmdxs_volume_control __devinitdata = { |
1693 | .name = "PCM Playback Volume", | 1693 | .name = "PCM Playback Volume", |
diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c index 80df9b1f651e..2cc0eda4f20e 100644 --- a/sound/ppc/awacs.c +++ b/sound/ppc/awacs.c | |||
@@ -477,7 +477,7 @@ static int snd_pmac_awacs_put_master_amp(struct snd_kcontrol *kcontrol, | |||
477 | #define AMP_CH_SPK 0 | 477 | #define AMP_CH_SPK 0 |
478 | #define AMP_CH_HD 1 | 478 | #define AMP_CH_HD 1 |
479 | 479 | ||
480 | static struct snd_kcontrol_new snd_pmac_awacs_amp_vol[] __initdata = { | 480 | static struct snd_kcontrol_new snd_pmac_awacs_amp_vol[] __devinitdata = { |
481 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 481 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
482 | .name = "PC Speaker Playback Volume", | 482 | .name = "PC Speaker Playback Volume", |
483 | .info = snd_pmac_awacs_info_volume_amp, | 483 | .info = snd_pmac_awacs_info_volume_amp, |
@@ -514,7 +514,7 @@ static struct snd_kcontrol_new snd_pmac_awacs_amp_vol[] __initdata = { | |||
514 | }, | 514 | }, |
515 | }; | 515 | }; |
516 | 516 | ||
517 | static struct snd_kcontrol_new snd_pmac_awacs_amp_hp_sw __initdata = { | 517 | static struct snd_kcontrol_new snd_pmac_awacs_amp_hp_sw __devinitdata = { |
518 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 518 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
519 | .name = "Headphone Playback Switch", | 519 | .name = "Headphone Playback Switch", |
520 | .info = snd_pmac_boolean_stereo_info, | 520 | .info = snd_pmac_boolean_stereo_info, |
@@ -523,7 +523,7 @@ static struct snd_kcontrol_new snd_pmac_awacs_amp_hp_sw __initdata = { | |||
523 | .private_value = AMP_CH_HD, | 523 | .private_value = AMP_CH_HD, |
524 | }; | 524 | }; |
525 | 525 | ||
526 | static struct snd_kcontrol_new snd_pmac_awacs_amp_spk_sw __initdata = { | 526 | static struct snd_kcontrol_new snd_pmac_awacs_amp_spk_sw __devinitdata = { |
527 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 527 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
528 | .name = "PC Speaker Playback Switch", | 528 | .name = "PC Speaker Playback Switch", |
529 | .info = snd_pmac_boolean_stereo_info, | 529 | .info = snd_pmac_boolean_stereo_info, |
@@ -595,46 +595,46 @@ static int snd_pmac_screamer_mic_boost_put(struct snd_kcontrol *kcontrol, | |||
595 | /* | 595 | /* |
596 | * lists of mixer elements | 596 | * lists of mixer elements |
597 | */ | 597 | */ |
598 | static struct snd_kcontrol_new snd_pmac_awacs_mixers[] __initdata = { | 598 | static struct snd_kcontrol_new snd_pmac_awacs_mixers[] __devinitdata = { |
599 | AWACS_SWITCH("Master Capture Switch", 1, SHIFT_LOOPTHRU, 0), | 599 | AWACS_SWITCH("Master Capture Switch", 1, SHIFT_LOOPTHRU, 0), |
600 | AWACS_VOLUME("Master Capture Volume", 0, 4, 0), | 600 | AWACS_VOLUME("Master Capture Volume", 0, 4, 0), |
601 | /* AWACS_SWITCH("Unknown Playback Switch", 6, SHIFT_PAROUT0, 0), */ | 601 | /* AWACS_SWITCH("Unknown Playback Switch", 6, SHIFT_PAROUT0, 0), */ |
602 | }; | 602 | }; |
603 | 603 | ||
604 | static struct snd_kcontrol_new snd_pmac_screamer_mixers_beige[] __initdata = { | 604 | static struct snd_kcontrol_new snd_pmac_screamer_mixers_beige[] __devinitdata = { |
605 | AWACS_VOLUME("Master Playback Volume", 2, 6, 1), | 605 | AWACS_VOLUME("Master Playback Volume", 2, 6, 1), |
606 | AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1), | 606 | AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1), |
607 | AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), | 607 | AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), |
608 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_LINE, 0), | 608 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_LINE, 0), |
609 | }; | 609 | }; |
610 | 610 | ||
611 | static struct snd_kcontrol_new snd_pmac_screamer_mixers_lo[] __initdata = { | 611 | static struct snd_kcontrol_new snd_pmac_screamer_mixers_lo[] __devinitdata = { |
612 | AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), | 612 | AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), |
613 | }; | 613 | }; |
614 | 614 | ||
615 | static struct snd_kcontrol_new snd_pmac_screamer_mixers_imac[] __initdata = { | 615 | static struct snd_kcontrol_new snd_pmac_screamer_mixers_imac[] __devinitdata = { |
616 | AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1), | 616 | AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1), |
617 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), | 617 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), |
618 | }; | 618 | }; |
619 | 619 | ||
620 | static struct snd_kcontrol_new snd_pmac_screamer_mixers_g4agp[] __initdata = { | 620 | static struct snd_kcontrol_new snd_pmac_screamer_mixers_g4agp[] __devinitdata = { |
621 | AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), | 621 | AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), |
622 | AWACS_VOLUME("Master Playback Volume", 5, 6, 1), | 622 | AWACS_VOLUME("Master Playback Volume", 5, 6, 1), |
623 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), | 623 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), |
624 | AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), | 624 | AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), |
625 | }; | 625 | }; |
626 | 626 | ||
627 | static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac7500[] __initdata = { | 627 | static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac7500[] __devinitdata = { |
628 | AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), | 628 | AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), |
629 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), | 629 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), |
630 | AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), | 630 | AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), |
631 | }; | 631 | }; |
632 | 632 | ||
633 | static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac5500[] __initdata = { | 633 | static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac5500[] __devinitdata = { |
634 | AWACS_VOLUME("Headphone Playback Volume", 2, 6, 1), | 634 | AWACS_VOLUME("Headphone Playback Volume", 2, 6, 1), |
635 | }; | 635 | }; |
636 | 636 | ||
637 | static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] __initdata = { | 637 | static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] __devinitdata = { |
638 | AWACS_VOLUME("Master Playback Volume", 2, 6, 1), | 638 | AWACS_VOLUME("Master Playback Volume", 2, 6, 1), |
639 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), | 639 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), |
640 | }; | 640 | }; |
@@ -642,34 +642,34 @@ static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] __initdata = { | |||
642 | /* FIXME: is this correct order? | 642 | /* FIXME: is this correct order? |
643 | * screamer (powerbook G3 pismo) seems to have different bits... | 643 | * screamer (powerbook G3 pismo) seems to have different bits... |
644 | */ | 644 | */ |
645 | static struct snd_kcontrol_new snd_pmac_awacs_mixers2[] __initdata = { | 645 | static struct snd_kcontrol_new snd_pmac_awacs_mixers2[] __devinitdata = { |
646 | AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_LINE, 0), | 646 | AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_LINE, 0), |
647 | AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_MIC, 0), | 647 | AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_MIC, 0), |
648 | }; | 648 | }; |
649 | 649 | ||
650 | static struct snd_kcontrol_new snd_pmac_screamer_mixers2[] __initdata = { | 650 | static struct snd_kcontrol_new snd_pmac_screamer_mixers2[] __devinitdata = { |
651 | AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), | 651 | AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), |
652 | AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_LINE, 0), | 652 | AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_LINE, 0), |
653 | }; | 653 | }; |
654 | 654 | ||
655 | static struct snd_kcontrol_new snd_pmac_awacs_mixers2_pmac5500[] __initdata = { | 655 | static struct snd_kcontrol_new snd_pmac_awacs_mixers2_pmac5500[] __devinitdata = { |
656 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), | 656 | AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), |
657 | }; | 657 | }; |
658 | 658 | ||
659 | static struct snd_kcontrol_new snd_pmac_awacs_master_sw __initdata = | 659 | static struct snd_kcontrol_new snd_pmac_awacs_master_sw __devinitdata = |
660 | AWACS_SWITCH("Master Playback Switch", 1, SHIFT_HDMUTE, 1); | 660 | AWACS_SWITCH("Master Playback Switch", 1, SHIFT_HDMUTE, 1); |
661 | 661 | ||
662 | static struct snd_kcontrol_new snd_pmac_awacs_master_sw_imac __initdata = | 662 | static struct snd_kcontrol_new snd_pmac_awacs_master_sw_imac __devinitdata = |
663 | AWACS_SWITCH("Line out Playback Switch", 1, SHIFT_HDMUTE, 1); | 663 | AWACS_SWITCH("Line out Playback Switch", 1, SHIFT_HDMUTE, 1); |
664 | 664 | ||
665 | static struct snd_kcontrol_new snd_pmac_awacs_master_sw_pmac5500 __initdata = | 665 | static struct snd_kcontrol_new snd_pmac_awacs_master_sw_pmac5500 __devinitdata = |
666 | AWACS_SWITCH("Headphone Playback Switch", 1, SHIFT_HDMUTE, 1); | 666 | AWACS_SWITCH("Headphone Playback Switch", 1, SHIFT_HDMUTE, 1); |
667 | 667 | ||
668 | static struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] __initdata = { | 668 | static struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] __devinitdata = { |
669 | AWACS_SWITCH("Mic Boost Capture Switch", 0, SHIFT_GAINLINE, 0), | 669 | AWACS_SWITCH("Mic Boost Capture Switch", 0, SHIFT_GAINLINE, 0), |
670 | }; | 670 | }; |
671 | 671 | ||
672 | static struct snd_kcontrol_new snd_pmac_screamer_mic_boost[] __initdata = { | 672 | static struct snd_kcontrol_new snd_pmac_screamer_mic_boost[] __devinitdata = { |
673 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 673 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
674 | .name = "Mic Boost Capture Volume", | 674 | .name = "Mic Boost Capture Volume", |
675 | .info = snd_pmac_screamer_mic_boost_info, | 675 | .info = snd_pmac_screamer_mic_boost_info, |
@@ -678,34 +678,34 @@ static struct snd_kcontrol_new snd_pmac_screamer_mic_boost[] __initdata = { | |||
678 | }, | 678 | }, |
679 | }; | 679 | }; |
680 | 680 | ||
681 | static struct snd_kcontrol_new snd_pmac_awacs_mic_boost_pmac7500[] __initdata = | 681 | static struct snd_kcontrol_new snd_pmac_awacs_mic_boost_pmac7500[] __devinitdata = |
682 | { | 682 | { |
683 | AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), | 683 | AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), |
684 | }; | 684 | }; |
685 | 685 | ||
686 | static struct snd_kcontrol_new snd_pmac_screamer_mic_boost_beige[] __initdata = | 686 | static struct snd_kcontrol_new snd_pmac_screamer_mic_boost_beige[] __devinitdata = |
687 | { | 687 | { |
688 | AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), | 688 | AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), |
689 | AWACS_SWITCH("CD Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0), | 689 | AWACS_SWITCH("CD Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0), |
690 | }; | 690 | }; |
691 | 691 | ||
692 | static struct snd_kcontrol_new snd_pmac_screamer_mic_boost_imac[] __initdata = | 692 | static struct snd_kcontrol_new snd_pmac_screamer_mic_boost_imac[] __devinitdata = |
693 | { | 693 | { |
694 | AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), | 694 | AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), |
695 | AWACS_SWITCH("Mic Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0), | 695 | AWACS_SWITCH("Mic Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0), |
696 | }; | 696 | }; |
697 | 697 | ||
698 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] __initdata = { | 698 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] __devinitdata = { |
699 | AWACS_VOLUME("PC Speaker Playback Volume", 4, 6, 1), | 699 | AWACS_VOLUME("PC Speaker Playback Volume", 4, 6, 1), |
700 | }; | 700 | }; |
701 | 701 | ||
702 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw __initdata = | 702 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw __devinitdata = |
703 | AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_SPKMUTE, 1); | 703 | AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_SPKMUTE, 1); |
704 | 704 | ||
705 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac1 __initdata = | 705 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac1 __devinitdata = |
706 | AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_PAROUT1, 1); | 706 | AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_PAROUT1, 1); |
707 | 707 | ||
708 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac2 __initdata = | 708 | static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac2 __devinitdata = |
709 | AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_PAROUT1, 0); | 709 | AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_PAROUT1, 0); |
710 | 710 | ||
711 | 711 | ||
@@ -872,7 +872,7 @@ static void snd_pmac_awacs_update_automute(struct snd_pmac *chip, int do_notify) | |||
872 | /* | 872 | /* |
873 | * initialize chip | 873 | * initialize chip |
874 | */ | 874 | */ |
875 | int __init | 875 | int __devinit |
876 | snd_pmac_awacs_init(struct snd_pmac *chip) | 876 | snd_pmac_awacs_init(struct snd_pmac *chip) |
877 | { | 877 | { |
878 | int pm7500 = IS_PM7500; | 878 | int pm7500 = IS_PM7500; |
diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c index 89f5c328acfe..a9d350789f55 100644 --- a/sound/ppc/beep.c +++ b/sound/ppc/beep.c | |||
@@ -215,7 +215,7 @@ static struct snd_kcontrol_new snd_pmac_beep_mixer = { | |||
215 | }; | 215 | }; |
216 | 216 | ||
217 | /* Initialize beep stuff */ | 217 | /* Initialize beep stuff */ |
218 | int __init snd_pmac_attach_beep(struct snd_pmac *chip) | 218 | int __devinit snd_pmac_attach_beep(struct snd_pmac *chip) |
219 | { | 219 | { |
220 | struct pmac_beep *beep; | 220 | struct pmac_beep *beep; |
221 | struct input_dev *input_dev; | 221 | struct input_dev *input_dev; |
diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c index 45a76297c38d..16ed240e423c 100644 --- a/sound/ppc/burgundy.c +++ b/sound/ppc/burgundy.c | |||
@@ -46,12 +46,12 @@ snd_pmac_burgundy_extend_wait(struct snd_pmac *chip) | |||
46 | timeout = 50; | 46 | timeout = 50; |
47 | while (!(in_le32(&chip->awacs->codec_stat) & MASK_EXTEND) && timeout--) | 47 | while (!(in_le32(&chip->awacs->codec_stat) & MASK_EXTEND) && timeout--) |
48 | udelay(1); | 48 | udelay(1); |
49 | if (! timeout) | 49 | if (timeout < 0) |
50 | printk(KERN_DEBUG "burgundy_extend_wait: timeout #1\n"); | 50 | printk(KERN_DEBUG "burgundy_extend_wait: timeout #1\n"); |
51 | timeout = 50; | 51 | timeout = 50; |
52 | while ((in_le32(&chip->awacs->codec_stat) & MASK_EXTEND) && timeout--) | 52 | while ((in_le32(&chip->awacs->codec_stat) & MASK_EXTEND) && timeout--) |
53 | udelay(1); | 53 | udelay(1); |
54 | if (! timeout) | 54 | if (timeout < 0) |
55 | printk(KERN_DEBUG "burgundy_extend_wait: timeout #2\n"); | 55 | printk(KERN_DEBUG "burgundy_extend_wait: timeout #2\n"); |
56 | } | 56 | } |
57 | 57 | ||
@@ -468,7 +468,7 @@ static int snd_pmac_burgundy_put_switch_b(struct snd_kcontrol *kcontrol, | |||
468 | /* | 468 | /* |
469 | * Burgundy mixers | 469 | * Burgundy mixers |
470 | */ | 470 | */ |
471 | static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __initdata = { | 471 | static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __devinitdata = { |
472 | BURGUNDY_VOLUME_W("Master Playback Volume", 0, | 472 | BURGUNDY_VOLUME_W("Master Playback Volume", 0, |
473 | MASK_ADDR_BURGUNDY_MASTER_VOLUME, 8), | 473 | MASK_ADDR_BURGUNDY_MASTER_VOLUME, 8), |
474 | BURGUNDY_VOLUME_W("CD Capture Volume", 0, | 474 | BURGUNDY_VOLUME_W("CD Capture Volume", 0, |
@@ -496,7 +496,7 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __initdata = { | |||
496 | */ BURGUNDY_SWITCH_B("PCM Capture Switch", 0, | 496 | */ BURGUNDY_SWITCH_B("PCM Capture Switch", 0, |
497 | MASK_ADDR_BURGUNDY_HOSTIFEH, 0x01, 0, 0) | 497 | MASK_ADDR_BURGUNDY_HOSTIFEH, 0x01, 0, 0) |
498 | }; | 498 | }; |
499 | static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __initdata = { | 499 | static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __devinitdata = { |
500 | BURGUNDY_VOLUME_W("Line in Capture Volume", 0, | 500 | BURGUNDY_VOLUME_W("Line in Capture Volume", 0, |
501 | MASK_ADDR_BURGUNDY_VOLLINE, 16), | 501 | MASK_ADDR_BURGUNDY_VOLLINE, 16), |
502 | BURGUNDY_VOLUME_W("Mic Capture Volume", 0, | 502 | BURGUNDY_VOLUME_W("Mic Capture Volume", 0, |
@@ -522,7 +522,7 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __initdata = { | |||
522 | BURGUNDY_SWITCH_B("Mic Boost Capture Switch", 0, | 522 | BURGUNDY_SWITCH_B("Mic Boost Capture Switch", 0, |
523 | MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1) | 523 | MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1) |
524 | }; | 524 | }; |
525 | static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] __initdata = { | 525 | static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] __devinitdata = { |
526 | BURGUNDY_VOLUME_W("Line in Capture Volume", 0, | 526 | BURGUNDY_VOLUME_W("Line in Capture Volume", 0, |
527 | MASK_ADDR_BURGUNDY_VOLMIC, 16), | 527 | MASK_ADDR_BURGUNDY_VOLMIC, 16), |
528 | BURGUNDY_VOLUME_B("Line in Gain Capture Volume", 0, | 528 | BURGUNDY_VOLUME_B("Line in Gain Capture Volume", 0, |
@@ -538,33 +538,33 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] __initdata = { | |||
538 | /* BURGUNDY_SWITCH_B("Line in Boost Capture Switch", 0, | 538 | /* BURGUNDY_SWITCH_B("Line in Boost Capture Switch", 0, |
539 | * MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1) */ | 539 | * MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1) */ |
540 | }; | 540 | }; |
541 | static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_imac __initdata = | 541 | static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_imac __devinitdata = |
542 | BURGUNDY_SWITCH_B("Master Playback Switch", 0, | 542 | BURGUNDY_SWITCH_B("Master Playback Switch", 0, |
543 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, | 543 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, |
544 | BURGUNDY_OUTPUT_LEFT | BURGUNDY_LINEOUT_LEFT | BURGUNDY_HP_LEFT, | 544 | BURGUNDY_OUTPUT_LEFT | BURGUNDY_LINEOUT_LEFT | BURGUNDY_HP_LEFT, |
545 | BURGUNDY_OUTPUT_RIGHT | BURGUNDY_LINEOUT_RIGHT | BURGUNDY_HP_RIGHT, 1); | 545 | BURGUNDY_OUTPUT_RIGHT | BURGUNDY_LINEOUT_RIGHT | BURGUNDY_HP_RIGHT, 1); |
546 | static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_pmac __initdata = | 546 | static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_pmac __devinitdata = |
547 | BURGUNDY_SWITCH_B("Master Playback Switch", 0, | 547 | BURGUNDY_SWITCH_B("Master Playback Switch", 0, |
548 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, | 548 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, |
549 | BURGUNDY_OUTPUT_INTERN | 549 | BURGUNDY_OUTPUT_INTERN |
550 | | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); | 550 | | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); |
551 | static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac __initdata = | 551 | static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac __devinitdata = |
552 | BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0, | 552 | BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0, |
553 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, | 553 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, |
554 | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); | 554 | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); |
555 | static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac __initdata = | 555 | static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac __devinitdata = |
556 | BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0, | 556 | BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0, |
557 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, | 557 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, |
558 | BURGUNDY_OUTPUT_INTERN, 0, 0); | 558 | BURGUNDY_OUTPUT_INTERN, 0, 0); |
559 | static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac __initdata = | 559 | static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac __devinitdata = |
560 | BURGUNDY_SWITCH_B("Line out Playback Switch", 0, | 560 | BURGUNDY_SWITCH_B("Line out Playback Switch", 0, |
561 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, | 561 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, |
562 | BURGUNDY_LINEOUT_LEFT, BURGUNDY_LINEOUT_RIGHT, 1); | 562 | BURGUNDY_LINEOUT_LEFT, BURGUNDY_LINEOUT_RIGHT, 1); |
563 | static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_pmac __initdata = | 563 | static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_pmac __devinitdata = |
564 | BURGUNDY_SWITCH_B("Line out Playback Switch", 0, | 564 | BURGUNDY_SWITCH_B("Line out Playback Switch", 0, |
565 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, | 565 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, |
566 | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); | 566 | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); |
567 | static struct snd_kcontrol_new snd_pmac_burgundy_hp_sw_imac __initdata = | 567 | static struct snd_kcontrol_new snd_pmac_burgundy_hp_sw_imac __devinitdata = |
568 | BURGUNDY_SWITCH_B("Headphone Playback Switch", 0, | 568 | BURGUNDY_SWITCH_B("Headphone Playback Switch", 0, |
569 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, | 569 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, |
570 | BURGUNDY_HP_LEFT, BURGUNDY_HP_RIGHT, 1); | 570 | BURGUNDY_HP_LEFT, BURGUNDY_HP_RIGHT, 1); |
@@ -618,7 +618,7 @@ static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_noti | |||
618 | /* | 618 | /* |
619 | * initialize burgundy | 619 | * initialize burgundy |
620 | */ | 620 | */ |
621 | int __init snd_pmac_burgundy_init(struct snd_pmac *chip) | 621 | int __devinit snd_pmac_burgundy_init(struct snd_pmac *chip) |
622 | { | 622 | { |
623 | int imac = machine_is_compatible("iMac"); | 623 | int imac = machine_is_compatible("iMac"); |
624 | int i, err; | 624 | int i, err; |
diff --git a/sound/ppc/daca.c b/sound/ppc/daca.c index f8d478c2da62..24200b7bdace 100644 --- a/sound/ppc/daca.c +++ b/sound/ppc/daca.c | |||
@@ -244,7 +244,7 @@ static void daca_cleanup(struct snd_pmac *chip) | |||
244 | } | 244 | } |
245 | 245 | ||
246 | /* exported */ | 246 | /* exported */ |
247 | int __init snd_pmac_daca_init(struct snd_pmac *chip) | 247 | int __devinit snd_pmac_daca_init(struct snd_pmac *chip) |
248 | { | 248 | { |
249 | int i, err; | 249 | int i, err; |
250 | struct pmac_daca *mix; | 250 | struct pmac_daca *mix; |
diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index a5afb2682e7f..835fa19ed461 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c | |||
@@ -33,10 +33,6 @@ | |||
33 | static struct pmac_keywest *keywest_ctx; | 33 | static struct pmac_keywest *keywest_ctx; |
34 | 34 | ||
35 | 35 | ||
36 | #ifndef i2c_device_name | ||
37 | #define i2c_device_name(x) ((x)->name) | ||
38 | #endif | ||
39 | |||
40 | static int keywest_probe(struct i2c_client *client, | 36 | static int keywest_probe(struct i2c_client *client, |
41 | const struct i2c_device_id *id) | 37 | const struct i2c_device_id *id) |
42 | { | 38 | { |
@@ -56,7 +52,7 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter) | |||
56 | if (! keywest_ctx) | 52 | if (! keywest_ctx) |
57 | return -EINVAL; | 53 | return -EINVAL; |
58 | 54 | ||
59 | if (strncmp(i2c_device_name(adapter), "mac-io", 6)) | 55 | if (strncmp(adapter->name, "mac-io", 6)) |
60 | return 0; /* ignored */ | 56 | return 0; /* ignored */ |
61 | 57 | ||
62 | memset(&info, 0, sizeof(struct i2c_board_info)); | 58 | memset(&info, 0, sizeof(struct i2c_board_info)); |
@@ -109,7 +105,7 @@ void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c) | |||
109 | } | 105 | } |
110 | } | 106 | } |
111 | 107 | ||
112 | int __init snd_pmac_tumbler_post_init(void) | 108 | int __devinit snd_pmac_tumbler_post_init(void) |
113 | { | 109 | { |
114 | int err; | 110 | int err; |
115 | 111 | ||
@@ -124,7 +120,7 @@ int __init snd_pmac_tumbler_post_init(void) | |||
124 | } | 120 | } |
125 | 121 | ||
126 | /* exported */ | 122 | /* exported */ |
127 | int __init snd_pmac_keywest_init(struct pmac_keywest *i2c) | 123 | int __devinit snd_pmac_keywest_init(struct pmac_keywest *i2c) |
128 | { | 124 | { |
129 | int err; | 125 | int err; |
130 | 126 | ||
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 9b4e9c316695..7bc492ee77ec 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c | |||
@@ -702,7 +702,7 @@ static struct snd_pcm_ops snd_pmac_capture_ops = { | |||
702 | .pointer = snd_pmac_capture_pointer, | 702 | .pointer = snd_pmac_capture_pointer, |
703 | }; | 703 | }; |
704 | 704 | ||
705 | int __init snd_pmac_pcm_new(struct snd_pmac *chip) | 705 | int __devinit snd_pmac_pcm_new(struct snd_pmac *chip) |
706 | { | 706 | { |
707 | struct snd_pcm *pcm; | 707 | struct snd_pcm *pcm; |
708 | int err; | 708 | int err; |
@@ -908,7 +908,7 @@ static int snd_pmac_dev_free(struct snd_device *device) | |||
908 | * check the machine support byteswap (little-endian) | 908 | * check the machine support byteswap (little-endian) |
909 | */ | 909 | */ |
910 | 910 | ||
911 | static void __init detect_byte_swap(struct snd_pmac *chip) | 911 | static void __devinit detect_byte_swap(struct snd_pmac *chip) |
912 | { | 912 | { |
913 | struct device_node *mio; | 913 | struct device_node *mio; |
914 | 914 | ||
@@ -934,7 +934,7 @@ static void __init detect_byte_swap(struct snd_pmac *chip) | |||
934 | /* | 934 | /* |
935 | * detect a sound chip | 935 | * detect a sound chip |
936 | */ | 936 | */ |
937 | static int __init snd_pmac_detect(struct snd_pmac *chip) | 937 | static int __devinit snd_pmac_detect(struct snd_pmac *chip) |
938 | { | 938 | { |
939 | struct device_node *sound; | 939 | struct device_node *sound; |
940 | struct device_node *dn; | 940 | struct device_node *dn; |
@@ -1143,7 +1143,7 @@ static int pmac_hp_detect_get(struct snd_kcontrol *kcontrol, | |||
1143 | return 0; | 1143 | return 0; |
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | static struct snd_kcontrol_new auto_mute_controls[] __initdata = { | 1146 | static struct snd_kcontrol_new auto_mute_controls[] __devinitdata = { |
1147 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1147 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
1148 | .name = "Auto Mute Switch", | 1148 | .name = "Auto Mute Switch", |
1149 | .info = snd_pmac_boolean_mono_info, | 1149 | .info = snd_pmac_boolean_mono_info, |
@@ -1158,7 +1158,7 @@ static struct snd_kcontrol_new auto_mute_controls[] __initdata = { | |||
1158 | }, | 1158 | }, |
1159 | }; | 1159 | }; |
1160 | 1160 | ||
1161 | int __init snd_pmac_add_automute(struct snd_pmac *chip) | 1161 | int __devinit snd_pmac_add_automute(struct snd_pmac *chip) |
1162 | { | 1162 | { |
1163 | int err; | 1163 | int err; |
1164 | chip->auto_mute = 1; | 1164 | chip->auto_mute = 1; |
@@ -1175,7 +1175,7 @@ int __init snd_pmac_add_automute(struct snd_pmac *chip) | |||
1175 | /* | 1175 | /* |
1176 | * create and detect a pmac chip record | 1176 | * create and detect a pmac chip record |
1177 | */ | 1177 | */ |
1178 | int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) | 1178 | int __devinit snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) |
1179 | { | 1179 | { |
1180 | struct snd_pmac *chip; | 1180 | struct snd_pmac *chip; |
1181 | struct device_node *np; | 1181 | struct device_node *np; |
diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index f361c26506aa..53c81a547613 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c | |||
@@ -18,81 +18,31 @@ | |||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/dma-mapping.h> | ||
22 | #include <linux/dmapool.h> | ||
21 | #include <linux/init.h> | 23 | #include <linux/init.h> |
22 | #include <linux/slab.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/io.h> | ||
26 | #include <linux/slab.h> | ||
27 | |||
28 | #include <sound/asound.h> | ||
29 | #include <sound/control.h> | ||
25 | #include <sound/core.h> | 30 | #include <sound/core.h> |
26 | #include <sound/initval.h> | 31 | #include <sound/initval.h> |
27 | #include <sound/pcm.h> | ||
28 | #include <sound/asound.h> | ||
29 | #include <sound/memalloc.h> | 32 | #include <sound/memalloc.h> |
33 | #include <sound/pcm.h> | ||
30 | #include <sound/pcm_params.h> | 34 | #include <sound/pcm_params.h> |
31 | #include <sound/control.h> | 35 | |
32 | #include <linux/dmapool.h> | ||
33 | #include <linux/dma-mapping.h> | ||
34 | #include <asm/firmware.h> | ||
35 | #include <asm/dma.h> | 36 | #include <asm/dma.h> |
37 | #include <asm/firmware.h> | ||
36 | #include <asm/lv1call.h> | 38 | #include <asm/lv1call.h> |
37 | #include <asm/ps3.h> | 39 | #include <asm/ps3.h> |
38 | #include <asm/ps3av.h> | 40 | #include <asm/ps3av.h> |
39 | 41 | ||
40 | #include "snd_ps3_reg.h" | ||
41 | #include "snd_ps3.h" | 42 | #include "snd_ps3.h" |
42 | 43 | #include "snd_ps3_reg.h" | |
43 | MODULE_LICENSE("GPL v2"); | ||
44 | MODULE_DESCRIPTION("PS3 sound driver"); | ||
45 | MODULE_AUTHOR("Sony Computer Entertainment Inc."); | ||
46 | |||
47 | /* module entries */ | ||
48 | static int __init snd_ps3_init(void); | ||
49 | static void __exit snd_ps3_exit(void); | ||
50 | |||
51 | /* ALSA snd driver ops */ | ||
52 | static int snd_ps3_pcm_open(struct snd_pcm_substream *substream); | ||
53 | static int snd_ps3_pcm_close(struct snd_pcm_substream *substream); | ||
54 | static int snd_ps3_pcm_prepare(struct snd_pcm_substream *substream); | ||
55 | static int snd_ps3_pcm_trigger(struct snd_pcm_substream *substream, | ||
56 | int cmd); | ||
57 | static snd_pcm_uframes_t snd_ps3_pcm_pointer(struct snd_pcm_substream | ||
58 | *substream); | ||
59 | static int snd_ps3_pcm_hw_params(struct snd_pcm_substream *substream, | ||
60 | struct snd_pcm_hw_params *hw_params); | ||
61 | static int snd_ps3_pcm_hw_free(struct snd_pcm_substream *substream); | ||
62 | |||
63 | |||
64 | /* ps3_system_bus_driver entries */ | ||
65 | static int __init snd_ps3_driver_probe(struct ps3_system_bus_device *dev); | ||
66 | static int snd_ps3_driver_remove(struct ps3_system_bus_device *dev); | ||
67 | |||
68 | /* address setup */ | ||
69 | static int snd_ps3_map_mmio(void); | ||
70 | static void snd_ps3_unmap_mmio(void); | ||
71 | static int snd_ps3_allocate_irq(void); | ||
72 | static void snd_ps3_free_irq(void); | ||
73 | static void snd_ps3_audio_set_base_addr(uint64_t ioaddr_start); | ||
74 | |||
75 | /* interrupt handler */ | ||
76 | static irqreturn_t snd_ps3_interrupt(int irq, void *dev_id); | ||
77 | |||
78 | |||
79 | /* set sampling rate/format */ | ||
80 | static int snd_ps3_set_avsetting(struct snd_pcm_substream *substream); | ||
81 | /* take effect parameter change */ | ||
82 | static int snd_ps3_change_avsetting(struct snd_ps3_card_info *card); | ||
83 | /* initialize avsetting and take it effect */ | ||
84 | static int snd_ps3_init_avsetting(struct snd_ps3_card_info *card); | ||
85 | /* setup dma */ | ||
86 | static int snd_ps3_program_dma(struct snd_ps3_card_info *card, | ||
87 | enum snd_ps3_dma_filltype filltype); | ||
88 | static void snd_ps3_wait_for_dma_stop(struct snd_ps3_card_info *card); | ||
89 | |||
90 | static dma_addr_t v_to_bus(struct snd_ps3_card_info *, void *vaddr, int ch); | ||
91 | 44 | ||
92 | 45 | ||
93 | module_init(snd_ps3_init); | ||
94 | module_exit(snd_ps3_exit); | ||
95 | |||
96 | /* | 46 | /* |
97 | * global | 47 | * global |
98 | */ | 48 | */ |
@@ -165,25 +115,13 @@ static const struct snd_pcm_hardware snd_ps3_pcm_hw = { | |||
165 | .fifo_size = PS3_AUDIO_FIFO_SIZE | 115 | .fifo_size = PS3_AUDIO_FIFO_SIZE |
166 | }; | 116 | }; |
167 | 117 | ||
168 | static struct snd_pcm_ops snd_ps3_pcm_spdif_ops = | ||
169 | { | ||
170 | .open = snd_ps3_pcm_open, | ||
171 | .close = snd_ps3_pcm_close, | ||
172 | .prepare = snd_ps3_pcm_prepare, | ||
173 | .ioctl = snd_pcm_lib_ioctl, | ||
174 | .trigger = snd_ps3_pcm_trigger, | ||
175 | .pointer = snd_ps3_pcm_pointer, | ||
176 | .hw_params = snd_ps3_pcm_hw_params, | ||
177 | .hw_free = snd_ps3_pcm_hw_free | ||
178 | }; | ||
179 | |||
180 | static int snd_ps3_verify_dma_stop(struct snd_ps3_card_info *card, | 118 | static int snd_ps3_verify_dma_stop(struct snd_ps3_card_info *card, |
181 | int count, int force_stop) | 119 | int count, int force_stop) |
182 | { | 120 | { |
183 | int dma_ch, done, retries, stop_forced = 0; | 121 | int dma_ch, done, retries, stop_forced = 0; |
184 | uint32_t status; | 122 | uint32_t status; |
185 | 123 | ||
186 | for (dma_ch = 0; dma_ch < 8; dma_ch ++) { | 124 | for (dma_ch = 0; dma_ch < 8; dma_ch++) { |
187 | retries = count; | 125 | retries = count; |
188 | do { | 126 | do { |
189 | status = read_reg(PS3_AUDIO_KICK(dma_ch)) & | 127 | status = read_reg(PS3_AUDIO_KICK(dma_ch)) & |
@@ -259,9 +197,7 @@ static void snd_ps3_kick_dma(struct snd_ps3_card_info *card) | |||
259 | /* | 197 | /* |
260 | * convert virtual addr to ioif bus addr. | 198 | * convert virtual addr to ioif bus addr. |
261 | */ | 199 | */ |
262 | static dma_addr_t v_to_bus(struct snd_ps3_card_info *card, | 200 | static dma_addr_t v_to_bus(struct snd_ps3_card_info *card, void *paddr, int ch) |
263 | void * paddr, | ||
264 | int ch) | ||
265 | { | 201 | { |
266 | return card->dma_start_bus_addr[ch] + | 202 | return card->dma_start_bus_addr[ch] + |
267 | (paddr - card->dma_start_vaddr[ch]); | 203 | (paddr - card->dma_start_vaddr[ch]); |
@@ -321,7 +257,7 @@ static int snd_ps3_program_dma(struct snd_ps3_card_info *card, | |||
321 | spin_lock_irqsave(&card->dma_lock, irqsave); | 257 | spin_lock_irqsave(&card->dma_lock, irqsave); |
322 | for (ch = 0; ch < 2; ch++) { | 258 | for (ch = 0; ch < 2; ch++) { |
323 | start_vaddr = card->dma_next_transfer_vaddr[0]; | 259 | start_vaddr = card->dma_next_transfer_vaddr[0]; |
324 | for (stage = 0; stage < fill_stages; stage ++) { | 260 | for (stage = 0; stage < fill_stages; stage++) { |
325 | dma_ch = stage * 2 + ch; | 261 | dma_ch = stage * 2 + ch; |
326 | if (silent) | 262 | if (silent) |
327 | dma_addr = card->null_buffer_start_dma_addr; | 263 | dma_addr = card->null_buffer_start_dma_addr; |
@@ -372,6 +308,71 @@ static int snd_ps3_program_dma(struct snd_ps3_card_info *card, | |||
372 | } | 308 | } |
373 | 309 | ||
374 | /* | 310 | /* |
311 | * Interrupt handler | ||
312 | */ | ||
313 | static irqreturn_t snd_ps3_interrupt(int irq, void *dev_id) | ||
314 | { | ||
315 | |||
316 | uint32_t port_intr; | ||
317 | int underflow_occured = 0; | ||
318 | struct snd_ps3_card_info *card = dev_id; | ||
319 | |||
320 | if (!card->running) { | ||
321 | update_reg(PS3_AUDIO_AX_IS, 0); | ||
322 | update_reg(PS3_AUDIO_INTR_0, 0); | ||
323 | return IRQ_HANDLED; | ||
324 | } | ||
325 | |||
326 | port_intr = read_reg(PS3_AUDIO_AX_IS); | ||
327 | /* | ||
328 | *serial buffer empty detected (every 4 times), | ||
329 | *program next dma and kick it | ||
330 | */ | ||
331 | if (port_intr & PS3_AUDIO_AX_IE_ASOBEIE(0)) { | ||
332 | write_reg(PS3_AUDIO_AX_IS, PS3_AUDIO_AX_IE_ASOBEIE(0)); | ||
333 | if (port_intr & PS3_AUDIO_AX_IE_ASOBUIE(0)) { | ||
334 | write_reg(PS3_AUDIO_AX_IS, port_intr); | ||
335 | underflow_occured = 1; | ||
336 | } | ||
337 | if (card->silent) { | ||
338 | /* we are still in silent time */ | ||
339 | snd_ps3_program_dma(card, | ||
340 | (underflow_occured) ? | ||
341 | SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL : | ||
342 | SND_PS3_DMA_FILLTYPE_SILENT_RUNNING); | ||
343 | snd_ps3_kick_dma(card); | ||
344 | card->silent--; | ||
345 | } else { | ||
346 | snd_ps3_program_dma(card, | ||
347 | (underflow_occured) ? | ||
348 | SND_PS3_DMA_FILLTYPE_FIRSTFILL : | ||
349 | SND_PS3_DMA_FILLTYPE_RUNNING); | ||
350 | snd_ps3_kick_dma(card); | ||
351 | snd_pcm_period_elapsed(card->substream); | ||
352 | } | ||
353 | } else if (port_intr & PS3_AUDIO_AX_IE_ASOBUIE(0)) { | ||
354 | write_reg(PS3_AUDIO_AX_IS, PS3_AUDIO_AX_IE_ASOBUIE(0)); | ||
355 | /* | ||
356 | * serial out underflow, but buffer empty not detected. | ||
357 | * in this case, fill fifo with 0 to recover. After | ||
358 | * filling dummy data, serial automatically start to | ||
359 | * consume them and then will generate normal buffer | ||
360 | * empty interrupts. | ||
361 | * If both buffer underflow and buffer empty are occured, | ||
362 | * it is better to do nomal data transfer than empty one | ||
363 | */ | ||
364 | snd_ps3_program_dma(card, | ||
365 | SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL); | ||
366 | snd_ps3_kick_dma(card); | ||
367 | snd_ps3_program_dma(card, | ||
368 | SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL); | ||
369 | snd_ps3_kick_dma(card); | ||
370 | } | ||
371 | /* clear interrupt cause */ | ||
372 | return IRQ_HANDLED; | ||
373 | }; | ||
374 | |||
375 | /* | ||
375 | * audio mute on/off | 376 | * audio mute on/off |
376 | * mute_on : 0 output enabled | 377 | * mute_on : 0 output enabled |
377 | * 1 mute | 378 | * 1 mute |
@@ -382,6 +383,142 @@ static int snd_ps3_mute(int mute_on) | |||
382 | } | 383 | } |
383 | 384 | ||
384 | /* | 385 | /* |
386 | * av setting | ||
387 | * NOTE: calling this function may generate audio interrupt. | ||
388 | */ | ||
389 | static int snd_ps3_change_avsetting(struct snd_ps3_card_info *card) | ||
390 | { | ||
391 | int ret, retries, i; | ||
392 | pr_debug("%s: start\n", __func__); | ||
393 | |||
394 | ret = ps3av_set_audio_mode(card->avs.avs_audio_ch, | ||
395 | card->avs.avs_audio_rate, | ||
396 | card->avs.avs_audio_width, | ||
397 | card->avs.avs_audio_format, | ||
398 | card->avs.avs_audio_source); | ||
399 | /* | ||
400 | * Reset the following unwanted settings: | ||
401 | */ | ||
402 | |||
403 | /* disable all 3wire buffers */ | ||
404 | update_mask_reg(PS3_AUDIO_AO_3WMCTRL, | ||
405 | ~(PS3_AUDIO_AO_3WMCTRL_ASOEN(0) | | ||
406 | PS3_AUDIO_AO_3WMCTRL_ASOEN(1) | | ||
407 | PS3_AUDIO_AO_3WMCTRL_ASOEN(2) | | ||
408 | PS3_AUDIO_AO_3WMCTRL_ASOEN(3)), | ||
409 | 0); | ||
410 | wmb(); /* ensure the hardware sees the change */ | ||
411 | /* wait for actually stopped */ | ||
412 | retries = 1000; | ||
413 | while ((read_reg(PS3_AUDIO_AO_3WMCTRL) & | ||
414 | (PS3_AUDIO_AO_3WMCTRL_ASORUN(0) | | ||
415 | PS3_AUDIO_AO_3WMCTRL_ASORUN(1) | | ||
416 | PS3_AUDIO_AO_3WMCTRL_ASORUN(2) | | ||
417 | PS3_AUDIO_AO_3WMCTRL_ASORUN(3))) && | ||
418 | --retries) { | ||
419 | udelay(1); | ||
420 | } | ||
421 | |||
422 | /* reset buffer pointer */ | ||
423 | for (i = 0; i < 4; i++) { | ||
424 | update_reg(PS3_AUDIO_AO_3WCTRL(i), | ||
425 | PS3_AUDIO_AO_3WCTRL_ASOBRST_RESET); | ||
426 | udelay(10); | ||
427 | } | ||
428 | wmb(); /* ensure the hardware actually start resetting */ | ||
429 | |||
430 | /* enable 3wire#0 buffer */ | ||
431 | update_reg(PS3_AUDIO_AO_3WMCTRL, PS3_AUDIO_AO_3WMCTRL_ASOEN(0)); | ||
432 | |||
433 | |||
434 | /* In 24bit mode,ALSA inserts a zero byte at first byte of per sample */ | ||
435 | update_mask_reg(PS3_AUDIO_AO_3WCTRL(0), | ||
436 | ~PS3_AUDIO_AO_3WCTRL_ASODF, | ||
437 | PS3_AUDIO_AO_3WCTRL_ASODF_LSB); | ||
438 | update_mask_reg(PS3_AUDIO_AO_SPDCTRL(0), | ||
439 | ~PS3_AUDIO_AO_SPDCTRL_SPODF, | ||
440 | PS3_AUDIO_AO_SPDCTRL_SPODF_LSB); | ||
441 | /* ensure all the setting above is written back to register */ | ||
442 | wmb(); | ||
443 | /* avsetting driver altered AX_IE, caller must reset it if you want */ | ||
444 | pr_debug("%s: end\n", __func__); | ||
445 | return ret; | ||
446 | } | ||
447 | |||
448 | /* | ||
449 | * set sampling rate according to the substream | ||
450 | */ | ||
451 | static int snd_ps3_set_avsetting(struct snd_pcm_substream *substream) | ||
452 | { | ||
453 | struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); | ||
454 | struct snd_ps3_avsetting_info avs; | ||
455 | int ret; | ||
456 | |||
457 | avs = card->avs; | ||
458 | |||
459 | pr_debug("%s: called freq=%d width=%d\n", __func__, | ||
460 | substream->runtime->rate, | ||
461 | snd_pcm_format_width(substream->runtime->format)); | ||
462 | |||
463 | pr_debug("%s: before freq=%d width=%d\n", __func__, | ||
464 | card->avs.avs_audio_rate, card->avs.avs_audio_width); | ||
465 | |||
466 | /* sample rate */ | ||
467 | switch (substream->runtime->rate) { | ||
468 | case 44100: | ||
469 | avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_44K; | ||
470 | break; | ||
471 | case 48000: | ||
472 | avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_48K; | ||
473 | break; | ||
474 | case 88200: | ||
475 | avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_88K; | ||
476 | break; | ||
477 | case 96000: | ||
478 | avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_96K; | ||
479 | break; | ||
480 | default: | ||
481 | pr_info("%s: invalid rate %d\n", __func__, | ||
482 | substream->runtime->rate); | ||
483 | return 1; | ||
484 | } | ||
485 | |||
486 | /* width */ | ||
487 | switch (snd_pcm_format_width(substream->runtime->format)) { | ||
488 | case 16: | ||
489 | avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_16; | ||
490 | break; | ||
491 | case 24: | ||
492 | avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_24; | ||
493 | break; | ||
494 | default: | ||
495 | pr_info("%s: invalid width %d\n", __func__, | ||
496 | snd_pcm_format_width(substream->runtime->format)); | ||
497 | return 1; | ||
498 | } | ||
499 | |||
500 | memcpy(avs.avs_cs_info, ps3av_mode_cs_info, 8); | ||
501 | |||
502 | if (memcmp(&card->avs, &avs, sizeof(avs))) { | ||
503 | pr_debug("%s: after freq=%d width=%d\n", __func__, | ||
504 | card->avs.avs_audio_rate, card->avs.avs_audio_width); | ||
505 | |||
506 | card->avs = avs; | ||
507 | snd_ps3_change_avsetting(card); | ||
508 | ret = 0; | ||
509 | } else | ||
510 | ret = 1; | ||
511 | |||
512 | /* check CS non-audio bit and mute accordingly */ | ||
513 | if (avs.avs_cs_info[0] & 0x02) | ||
514 | ps3av_audio_mute_analog(1); /* mute if non-audio */ | ||
515 | else | ||
516 | ps3av_audio_mute_analog(0); | ||
517 | |||
518 | return ret; | ||
519 | } | ||
520 | |||
521 | /* | ||
385 | * PCM operators | 522 | * PCM operators |
386 | */ | 523 | */ |
387 | static int snd_ps3_pcm_open(struct snd_pcm_substream *substream) | 524 | static int snd_ps3_pcm_open(struct snd_pcm_substream *substream) |
@@ -406,6 +543,13 @@ static int snd_ps3_pcm_open(struct snd_pcm_substream *substream) | |||
406 | return 0; | 543 | return 0; |
407 | }; | 544 | }; |
408 | 545 | ||
546 | static int snd_ps3_pcm_close(struct snd_pcm_substream *substream) | ||
547 | { | ||
548 | /* mute on */ | ||
549 | snd_ps3_mute(1); | ||
550 | return 0; | ||
551 | }; | ||
552 | |||
409 | static int snd_ps3_pcm_hw_params(struct snd_pcm_substream *substream, | 553 | static int snd_ps3_pcm_hw_params(struct snd_pcm_substream *substream, |
410 | struct snd_pcm_hw_params *hw_params) | 554 | struct snd_pcm_hw_params *hw_params) |
411 | { | 555 | { |
@@ -417,6 +561,13 @@ static int snd_ps3_pcm_hw_params(struct snd_pcm_substream *substream, | |||
417 | return 0; | 561 | return 0; |
418 | }; | 562 | }; |
419 | 563 | ||
564 | static int snd_ps3_pcm_hw_free(struct snd_pcm_substream *substream) | ||
565 | { | ||
566 | int ret; | ||
567 | ret = snd_pcm_lib_free_pages(substream); | ||
568 | return ret; | ||
569 | }; | ||
570 | |||
420 | static int snd_ps3_delay_to_bytes(struct snd_pcm_substream *substream, | 571 | static int snd_ps3_delay_to_bytes(struct snd_pcm_substream *substream, |
421 | unsigned int delay_ms) | 572 | unsigned int delay_ms) |
422 | { | 573 | { |
@@ -556,202 +707,6 @@ static snd_pcm_uframes_t snd_ps3_pcm_pointer( | |||
556 | return ret; | 707 | return ret; |
557 | }; | 708 | }; |
558 | 709 | ||
559 | static int snd_ps3_pcm_hw_free(struct snd_pcm_substream *substream) | ||
560 | { | ||
561 | int ret; | ||
562 | ret = snd_pcm_lib_free_pages(substream); | ||
563 | return ret; | ||
564 | }; | ||
565 | |||
566 | static int snd_ps3_pcm_close(struct snd_pcm_substream *substream) | ||
567 | { | ||
568 | /* mute on */ | ||
569 | snd_ps3_mute(1); | ||
570 | return 0; | ||
571 | }; | ||
572 | |||
573 | static void snd_ps3_audio_fixup(struct snd_ps3_card_info *card) | ||
574 | { | ||
575 | /* | ||
576 | * avsetting driver seems to never change the followings | ||
577 | * so, init them here once | ||
578 | */ | ||
579 | |||
580 | /* no dma interrupt needed */ | ||
581 | write_reg(PS3_AUDIO_INTR_EN_0, 0); | ||
582 | |||
583 | /* use every 4 buffer empty interrupt */ | ||
584 | update_mask_reg(PS3_AUDIO_AX_IC, | ||
585 | PS3_AUDIO_AX_IC_AASOIMD_MASK, | ||
586 | PS3_AUDIO_AX_IC_AASOIMD_EVERY4); | ||
587 | |||
588 | /* enable 3wire clocks */ | ||
589 | update_mask_reg(PS3_AUDIO_AO_3WMCTRL, | ||
590 | ~(PS3_AUDIO_AO_3WMCTRL_ASOBCLKD_DISABLED | | ||
591 | PS3_AUDIO_AO_3WMCTRL_ASOLRCKD_DISABLED), | ||
592 | 0); | ||
593 | update_reg(PS3_AUDIO_AO_3WMCTRL, | ||
594 | PS3_AUDIO_AO_3WMCTRL_ASOPLRCK_DEFAULT); | ||
595 | } | ||
596 | |||
597 | /* | ||
598 | * av setting | ||
599 | * NOTE: calling this function may generate audio interrupt. | ||
600 | */ | ||
601 | static int snd_ps3_change_avsetting(struct snd_ps3_card_info *card) | ||
602 | { | ||
603 | int ret, retries, i; | ||
604 | pr_debug("%s: start\n", __func__); | ||
605 | |||
606 | ret = ps3av_set_audio_mode(card->avs.avs_audio_ch, | ||
607 | card->avs.avs_audio_rate, | ||
608 | card->avs.avs_audio_width, | ||
609 | card->avs.avs_audio_format, | ||
610 | card->avs.avs_audio_source); | ||
611 | /* | ||
612 | * Reset the following unwanted settings: | ||
613 | */ | ||
614 | |||
615 | /* disable all 3wire buffers */ | ||
616 | update_mask_reg(PS3_AUDIO_AO_3WMCTRL, | ||
617 | ~(PS3_AUDIO_AO_3WMCTRL_ASOEN(0) | | ||
618 | PS3_AUDIO_AO_3WMCTRL_ASOEN(1) | | ||
619 | PS3_AUDIO_AO_3WMCTRL_ASOEN(2) | | ||
620 | PS3_AUDIO_AO_3WMCTRL_ASOEN(3)), | ||
621 | 0); | ||
622 | wmb(); /* ensure the hardware sees the change */ | ||
623 | /* wait for actually stopped */ | ||
624 | retries = 1000; | ||
625 | while ((read_reg(PS3_AUDIO_AO_3WMCTRL) & | ||
626 | (PS3_AUDIO_AO_3WMCTRL_ASORUN(0) | | ||
627 | PS3_AUDIO_AO_3WMCTRL_ASORUN(1) | | ||
628 | PS3_AUDIO_AO_3WMCTRL_ASORUN(2) | | ||
629 | PS3_AUDIO_AO_3WMCTRL_ASORUN(3))) && | ||
630 | --retries) { | ||
631 | udelay(1); | ||
632 | } | ||
633 | |||
634 | /* reset buffer pointer */ | ||
635 | for (i = 0; i < 4; i++) { | ||
636 | update_reg(PS3_AUDIO_AO_3WCTRL(i), | ||
637 | PS3_AUDIO_AO_3WCTRL_ASOBRST_RESET); | ||
638 | udelay(10); | ||
639 | } | ||
640 | wmb(); /* ensure the hardware actually start resetting */ | ||
641 | |||
642 | /* enable 3wire#0 buffer */ | ||
643 | update_reg(PS3_AUDIO_AO_3WMCTRL, PS3_AUDIO_AO_3WMCTRL_ASOEN(0)); | ||
644 | |||
645 | |||
646 | /* In 24bit mode,ALSA inserts a zero byte at first byte of per sample */ | ||
647 | update_mask_reg(PS3_AUDIO_AO_3WCTRL(0), | ||
648 | ~PS3_AUDIO_AO_3WCTRL_ASODF, | ||
649 | PS3_AUDIO_AO_3WCTRL_ASODF_LSB); | ||
650 | update_mask_reg(PS3_AUDIO_AO_SPDCTRL(0), | ||
651 | ~PS3_AUDIO_AO_SPDCTRL_SPODF, | ||
652 | PS3_AUDIO_AO_SPDCTRL_SPODF_LSB); | ||
653 | /* ensure all the setting above is written back to register */ | ||
654 | wmb(); | ||
655 | /* avsetting driver altered AX_IE, caller must reset it if you want */ | ||
656 | pr_debug("%s: end\n", __func__); | ||
657 | return ret; | ||
658 | } | ||
659 | |||
660 | static int snd_ps3_init_avsetting(struct snd_ps3_card_info *card) | ||
661 | { | ||
662 | int ret; | ||
663 | pr_debug("%s: start\n", __func__); | ||
664 | card->avs.avs_audio_ch = PS3AV_CMD_AUDIO_NUM_OF_CH_2; | ||
665 | card->avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_48K; | ||
666 | card->avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_16; | ||
667 | card->avs.avs_audio_format = PS3AV_CMD_AUDIO_FORMAT_PCM; | ||
668 | card->avs.avs_audio_source = PS3AV_CMD_AUDIO_SOURCE_SERIAL; | ||
669 | memcpy(card->avs.avs_cs_info, ps3av_mode_cs_info, 8); | ||
670 | |||
671 | ret = snd_ps3_change_avsetting(card); | ||
672 | |||
673 | snd_ps3_audio_fixup(card); | ||
674 | |||
675 | /* to start to generate SPDIF signal, fill data */ | ||
676 | snd_ps3_program_dma(card, SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL); | ||
677 | snd_ps3_kick_dma(card); | ||
678 | pr_debug("%s: end\n", __func__); | ||
679 | return ret; | ||
680 | } | ||
681 | |||
682 | /* | ||
683 | * set sampling rate according to the substream | ||
684 | */ | ||
685 | static int snd_ps3_set_avsetting(struct snd_pcm_substream *substream) | ||
686 | { | ||
687 | struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); | ||
688 | struct snd_ps3_avsetting_info avs; | ||
689 | int ret; | ||
690 | |||
691 | avs = card->avs; | ||
692 | |||
693 | pr_debug("%s: called freq=%d width=%d\n", __func__, | ||
694 | substream->runtime->rate, | ||
695 | snd_pcm_format_width(substream->runtime->format)); | ||
696 | |||
697 | pr_debug("%s: before freq=%d width=%d\n", __func__, | ||
698 | card->avs.avs_audio_rate, card->avs.avs_audio_width); | ||
699 | |||
700 | /* sample rate */ | ||
701 | switch (substream->runtime->rate) { | ||
702 | case 44100: | ||
703 | avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_44K; | ||
704 | break; | ||
705 | case 48000: | ||
706 | avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_48K; | ||
707 | break; | ||
708 | case 88200: | ||
709 | avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_88K; | ||
710 | break; | ||
711 | case 96000: | ||
712 | avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_96K; | ||
713 | break; | ||
714 | default: | ||
715 | pr_info("%s: invalid rate %d\n", __func__, | ||
716 | substream->runtime->rate); | ||
717 | return 1; | ||
718 | } | ||
719 | |||
720 | /* width */ | ||
721 | switch (snd_pcm_format_width(substream->runtime->format)) { | ||
722 | case 16: | ||
723 | avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_16; | ||
724 | break; | ||
725 | case 24: | ||
726 | avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_24; | ||
727 | break; | ||
728 | default: | ||
729 | pr_info("%s: invalid width %d\n", __func__, | ||
730 | snd_pcm_format_width(substream->runtime->format)); | ||
731 | return 1; | ||
732 | } | ||
733 | |||
734 | memcpy(avs.avs_cs_info, ps3av_mode_cs_info, 8); | ||
735 | |||
736 | if (memcmp(&card->avs, &avs, sizeof(avs))) { | ||
737 | pr_debug("%s: after freq=%d width=%d\n", __func__, | ||
738 | card->avs.avs_audio_rate, card->avs.avs_audio_width); | ||
739 | |||
740 | card->avs = avs; | ||
741 | snd_ps3_change_avsetting(card); | ||
742 | ret = 0; | ||
743 | } else | ||
744 | ret = 1; | ||
745 | |||
746 | /* check CS non-audio bit and mute accordingly */ | ||
747 | if (avs.avs_cs_info[0] & 0x02) | ||
748 | ps3av_audio_mute_analog(1); /* mute if non-audio */ | ||
749 | else | ||
750 | ps3av_audio_mute_analog(0); | ||
751 | |||
752 | return ret; | ||
753 | } | ||
754 | |||
755 | /* | 710 | /* |
756 | * SPDIF status bits controls | 711 | * SPDIF status bits controls |
757 | */ | 712 | */ |
@@ -798,28 +753,39 @@ static struct snd_kcontrol_new spdif_ctls[] = { | |||
798 | { | 753 | { |
799 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | 754 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
800 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | 755 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
801 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK), | 756 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK), |
802 | .info = snd_ps3_spdif_mask_info, | 757 | .info = snd_ps3_spdif_mask_info, |
803 | .get = snd_ps3_spdif_cmask_get, | 758 | .get = snd_ps3_spdif_cmask_get, |
804 | }, | 759 | }, |
805 | { | 760 | { |
806 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | 761 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
807 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | 762 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
808 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK), | 763 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK), |
809 | .info = snd_ps3_spdif_mask_info, | 764 | .info = snd_ps3_spdif_mask_info, |
810 | .get = snd_ps3_spdif_pmask_get, | 765 | .get = snd_ps3_spdif_pmask_get, |
811 | }, | 766 | }, |
812 | { | 767 | { |
813 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | 768 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
814 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), | 769 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), |
815 | .info = snd_ps3_spdif_mask_info, | 770 | .info = snd_ps3_spdif_mask_info, |
816 | .get = snd_ps3_spdif_default_get, | 771 | .get = snd_ps3_spdif_default_get, |
817 | .put = snd_ps3_spdif_default_put, | 772 | .put = snd_ps3_spdif_default_put, |
818 | }, | 773 | }, |
819 | }; | 774 | }; |
820 | 775 | ||
776 | static struct snd_pcm_ops snd_ps3_pcm_spdif_ops = { | ||
777 | .open = snd_ps3_pcm_open, | ||
778 | .close = snd_ps3_pcm_close, | ||
779 | .ioctl = snd_pcm_lib_ioctl, | ||
780 | .hw_params = snd_ps3_pcm_hw_params, | ||
781 | .hw_free = snd_ps3_pcm_hw_free, | ||
782 | .prepare = snd_ps3_pcm_prepare, | ||
783 | .trigger = snd_ps3_pcm_trigger, | ||
784 | .pointer = snd_ps3_pcm_pointer, | ||
785 | }; | ||
786 | |||
821 | 787 | ||
822 | static int snd_ps3_map_mmio(void) | 788 | static int __devinit snd_ps3_map_mmio(void) |
823 | { | 789 | { |
824 | the_card.mapped_mmio_vaddr = | 790 | the_card.mapped_mmio_vaddr = |
825 | ioremap(the_card.ps3_dev->m_region->bus_addr, | 791 | ioremap(the_card.ps3_dev->m_region->bus_addr, |
@@ -841,7 +807,7 @@ static void snd_ps3_unmap_mmio(void) | |||
841 | the_card.mapped_mmio_vaddr = NULL; | 807 | the_card.mapped_mmio_vaddr = NULL; |
842 | } | 808 | } |
843 | 809 | ||
844 | static int snd_ps3_allocate_irq(void) | 810 | static int __devinit snd_ps3_allocate_irq(void) |
845 | { | 811 | { |
846 | int ret; | 812 | int ret; |
847 | u64 lpar_addr, lpar_size; | 813 | u64 lpar_addr, lpar_size; |
@@ -899,7 +865,7 @@ static void snd_ps3_free_irq(void) | |||
899 | ps3_irq_plug_destroy(the_card.irq_no); | 865 | ps3_irq_plug_destroy(the_card.irq_no); |
900 | } | 866 | } |
901 | 867 | ||
902 | static void snd_ps3_audio_set_base_addr(uint64_t ioaddr_start) | 868 | static void __devinit snd_ps3_audio_set_base_addr(uint64_t ioaddr_start) |
903 | { | 869 | { |
904 | uint64_t val; | 870 | uint64_t val; |
905 | int ret; | 871 | int ret; |
@@ -915,7 +881,53 @@ static void snd_ps3_audio_set_base_addr(uint64_t ioaddr_start) | |||
915 | ret); | 881 | ret); |
916 | } | 882 | } |
917 | 883 | ||
918 | static int __init snd_ps3_driver_probe(struct ps3_system_bus_device *dev) | 884 | static void __devinit snd_ps3_audio_fixup(struct snd_ps3_card_info *card) |
885 | { | ||
886 | /* | ||
887 | * avsetting driver seems to never change the followings | ||
888 | * so, init them here once | ||
889 | */ | ||
890 | |||
891 | /* no dma interrupt needed */ | ||
892 | write_reg(PS3_AUDIO_INTR_EN_0, 0); | ||
893 | |||
894 | /* use every 4 buffer empty interrupt */ | ||
895 | update_mask_reg(PS3_AUDIO_AX_IC, | ||
896 | PS3_AUDIO_AX_IC_AASOIMD_MASK, | ||
897 | PS3_AUDIO_AX_IC_AASOIMD_EVERY4); | ||
898 | |||
899 | /* enable 3wire clocks */ | ||
900 | update_mask_reg(PS3_AUDIO_AO_3WMCTRL, | ||
901 | ~(PS3_AUDIO_AO_3WMCTRL_ASOBCLKD_DISABLED | | ||
902 | PS3_AUDIO_AO_3WMCTRL_ASOLRCKD_DISABLED), | ||
903 | 0); | ||
904 | update_reg(PS3_AUDIO_AO_3WMCTRL, | ||
905 | PS3_AUDIO_AO_3WMCTRL_ASOPLRCK_DEFAULT); | ||
906 | } | ||
907 | |||
908 | static int __devinit snd_ps3_init_avsetting(struct snd_ps3_card_info *card) | ||
909 | { | ||
910 | int ret; | ||
911 | pr_debug("%s: start\n", __func__); | ||
912 | card->avs.avs_audio_ch = PS3AV_CMD_AUDIO_NUM_OF_CH_2; | ||
913 | card->avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_48K; | ||
914 | card->avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_16; | ||
915 | card->avs.avs_audio_format = PS3AV_CMD_AUDIO_FORMAT_PCM; | ||
916 | card->avs.avs_audio_source = PS3AV_CMD_AUDIO_SOURCE_SERIAL; | ||
917 | memcpy(card->avs.avs_cs_info, ps3av_mode_cs_info, 8); | ||
918 | |||
919 | ret = snd_ps3_change_avsetting(card); | ||
920 | |||
921 | snd_ps3_audio_fixup(card); | ||
922 | |||
923 | /* to start to generate SPDIF signal, fill data */ | ||
924 | snd_ps3_program_dma(card, SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL); | ||
925 | snd_ps3_kick_dma(card); | ||
926 | pr_debug("%s: end\n", __func__); | ||
927 | return ret; | ||
928 | } | ||
929 | |||
930 | static int __devinit snd_ps3_driver_probe(struct ps3_system_bus_device *dev) | ||
919 | { | 931 | { |
920 | int i, ret; | 932 | int i, ret; |
921 | u64 lpar_addr, lpar_size; | 933 | u64 lpar_addr, lpar_size; |
@@ -1020,11 +1032,12 @@ static int __init snd_ps3_driver_probe(struct ps3_system_bus_device *dev) | |||
1020 | * its size should be lager than PS3_AUDIO_FIFO_STAGE_SIZE * 2 | 1032 | * its size should be lager than PS3_AUDIO_FIFO_STAGE_SIZE * 2 |
1021 | * PAGE_SIZE is enogh | 1033 | * PAGE_SIZE is enogh |
1022 | */ | 1034 | */ |
1023 | if (!(the_card.null_buffer_start_vaddr = | 1035 | the_card.null_buffer_start_vaddr = |
1024 | dma_alloc_coherent(&the_card.ps3_dev->core, | 1036 | dma_alloc_coherent(&the_card.ps3_dev->core, |
1025 | PAGE_SIZE, | 1037 | PAGE_SIZE, |
1026 | &the_card.null_buffer_start_dma_addr, | 1038 | &the_card.null_buffer_start_dma_addr, |
1027 | GFP_KERNEL))) { | 1039 | GFP_KERNEL); |
1040 | if (!the_card.null_buffer_start_vaddr) { | ||
1028 | pr_info("%s: nullbuffer alloc failed\n", __func__); | 1041 | pr_info("%s: nullbuffer alloc failed\n", __func__); |
1029 | goto clean_preallocate; | 1042 | goto clean_preallocate; |
1030 | } | 1043 | } |
@@ -1115,71 +1128,6 @@ static struct ps3_system_bus_driver snd_ps3_bus_driver_info = { | |||
1115 | 1128 | ||
1116 | 1129 | ||
1117 | /* | 1130 | /* |
1118 | * Interrupt handler | ||
1119 | */ | ||
1120 | static irqreturn_t snd_ps3_interrupt(int irq, void *dev_id) | ||
1121 | { | ||
1122 | |||
1123 | uint32_t port_intr; | ||
1124 | int underflow_occured = 0; | ||
1125 | struct snd_ps3_card_info *card = dev_id; | ||
1126 | |||
1127 | if (!card->running) { | ||
1128 | update_reg(PS3_AUDIO_AX_IS, 0); | ||
1129 | update_reg(PS3_AUDIO_INTR_0, 0); | ||
1130 | return IRQ_HANDLED; | ||
1131 | } | ||
1132 | |||
1133 | port_intr = read_reg(PS3_AUDIO_AX_IS); | ||
1134 | /* | ||
1135 | *serial buffer empty detected (every 4 times), | ||
1136 | *program next dma and kick it | ||
1137 | */ | ||
1138 | if (port_intr & PS3_AUDIO_AX_IE_ASOBEIE(0)) { | ||
1139 | write_reg(PS3_AUDIO_AX_IS, PS3_AUDIO_AX_IE_ASOBEIE(0)); | ||
1140 | if (port_intr & PS3_AUDIO_AX_IE_ASOBUIE(0)) { | ||
1141 | write_reg(PS3_AUDIO_AX_IS, port_intr); | ||
1142 | underflow_occured = 1; | ||
1143 | } | ||
1144 | if (card->silent) { | ||
1145 | /* we are still in silent time */ | ||
1146 | snd_ps3_program_dma(card, | ||
1147 | (underflow_occured) ? | ||
1148 | SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL : | ||
1149 | SND_PS3_DMA_FILLTYPE_SILENT_RUNNING); | ||
1150 | snd_ps3_kick_dma(card); | ||
1151 | card->silent --; | ||
1152 | } else { | ||
1153 | snd_ps3_program_dma(card, | ||
1154 | (underflow_occured) ? | ||
1155 | SND_PS3_DMA_FILLTYPE_FIRSTFILL : | ||
1156 | SND_PS3_DMA_FILLTYPE_RUNNING); | ||
1157 | snd_ps3_kick_dma(card); | ||
1158 | snd_pcm_period_elapsed(card->substream); | ||
1159 | } | ||
1160 | } else if (port_intr & PS3_AUDIO_AX_IE_ASOBUIE(0)) { | ||
1161 | write_reg(PS3_AUDIO_AX_IS, PS3_AUDIO_AX_IE_ASOBUIE(0)); | ||
1162 | /* | ||
1163 | * serial out underflow, but buffer empty not detected. | ||
1164 | * in this case, fill fifo with 0 to recover. After | ||
1165 | * filling dummy data, serial automatically start to | ||
1166 | * consume them and then will generate normal buffer | ||
1167 | * empty interrupts. | ||
1168 | * If both buffer underflow and buffer empty are occured, | ||
1169 | * it is better to do nomal data transfer than empty one | ||
1170 | */ | ||
1171 | snd_ps3_program_dma(card, | ||
1172 | SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL); | ||
1173 | snd_ps3_kick_dma(card); | ||
1174 | snd_ps3_program_dma(card, | ||
1175 | SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL); | ||
1176 | snd_ps3_kick_dma(card); | ||
1177 | } | ||
1178 | /* clear interrupt cause */ | ||
1179 | return IRQ_HANDLED; | ||
1180 | }; | ||
1181 | |||
1182 | /* | ||
1183 | * module/subsystem initialize/terminate | 1131 | * module/subsystem initialize/terminate |
1184 | */ | 1132 | */ |
1185 | static int __init snd_ps3_init(void) | 1133 | static int __init snd_ps3_init(void) |
@@ -1197,10 +1145,15 @@ static int __init snd_ps3_init(void) | |||
1197 | 1145 | ||
1198 | return ret; | 1146 | return ret; |
1199 | } | 1147 | } |
1148 | module_init(snd_ps3_init); | ||
1200 | 1149 | ||
1201 | static void __exit snd_ps3_exit(void) | 1150 | static void __exit snd_ps3_exit(void) |
1202 | { | 1151 | { |
1203 | ps3_system_bus_driver_unregister(&snd_ps3_bus_driver_info); | 1152 | ps3_system_bus_driver_unregister(&snd_ps3_bus_driver_info); |
1204 | } | 1153 | } |
1154 | module_exit(snd_ps3_exit); | ||
1205 | 1155 | ||
1156 | MODULE_LICENSE("GPL v2"); | ||
1157 | MODULE_DESCRIPTION("PS3 sound driver"); | ||
1158 | MODULE_AUTHOR("Sony Computer Entertainment Inc."); | ||
1206 | MODULE_ALIAS(PS3_MODULE_ALIAS_SOUND); | 1159 | MODULE_ALIAS(PS3_MODULE_ALIAS_SOUND); |
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index 40222fcc0878..08e584d1453a 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c | |||
@@ -838,7 +838,7 @@ static int snapper_put_capture_source(struct snd_kcontrol *kcontrol, | |||
838 | 838 | ||
839 | /* | 839 | /* |
840 | */ | 840 | */ |
841 | static struct snd_kcontrol_new tumbler_mixers[] __initdata = { | 841 | static struct snd_kcontrol_new tumbler_mixers[] __devinitdata = { |
842 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 842 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
843 | .name = "Master Playback Volume", | 843 | .name = "Master Playback Volume", |
844 | .info = tumbler_info_master_volume, | 844 | .info = tumbler_info_master_volume, |
@@ -862,7 +862,7 @@ static struct snd_kcontrol_new tumbler_mixers[] __initdata = { | |||
862 | }, | 862 | }, |
863 | }; | 863 | }; |
864 | 864 | ||
865 | static struct snd_kcontrol_new snapper_mixers[] __initdata = { | 865 | static struct snd_kcontrol_new snapper_mixers[] __devinitdata = { |
866 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 866 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
867 | .name = "Master Playback Volume", | 867 | .name = "Master Playback Volume", |
868 | .info = tumbler_info_master_volume, | 868 | .info = tumbler_info_master_volume, |
@@ -895,7 +895,7 @@ static struct snd_kcontrol_new snapper_mixers[] __initdata = { | |||
895 | }, | 895 | }, |
896 | }; | 896 | }; |
897 | 897 | ||
898 | static struct snd_kcontrol_new tumbler_hp_sw __initdata = { | 898 | static struct snd_kcontrol_new tumbler_hp_sw __devinitdata = { |
899 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 899 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
900 | .name = "Headphone Playback Switch", | 900 | .name = "Headphone Playback Switch", |
901 | .info = snd_pmac_boolean_mono_info, | 901 | .info = snd_pmac_boolean_mono_info, |
@@ -903,7 +903,7 @@ static struct snd_kcontrol_new tumbler_hp_sw __initdata = { | |||
903 | .put = tumbler_put_mute_switch, | 903 | .put = tumbler_put_mute_switch, |
904 | .private_value = TUMBLER_MUTE_HP, | 904 | .private_value = TUMBLER_MUTE_HP, |
905 | }; | 905 | }; |
906 | static struct snd_kcontrol_new tumbler_speaker_sw __initdata = { | 906 | static struct snd_kcontrol_new tumbler_speaker_sw __devinitdata = { |
907 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 907 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
908 | .name = "PC Speaker Playback Switch", | 908 | .name = "PC Speaker Playback Switch", |
909 | .info = snd_pmac_boolean_mono_info, | 909 | .info = snd_pmac_boolean_mono_info, |
@@ -911,7 +911,7 @@ static struct snd_kcontrol_new tumbler_speaker_sw __initdata = { | |||
911 | .put = tumbler_put_mute_switch, | 911 | .put = tumbler_put_mute_switch, |
912 | .private_value = TUMBLER_MUTE_AMP, | 912 | .private_value = TUMBLER_MUTE_AMP, |
913 | }; | 913 | }; |
914 | static struct snd_kcontrol_new tumbler_lineout_sw __initdata = { | 914 | static struct snd_kcontrol_new tumbler_lineout_sw __devinitdata = { |
915 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 915 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
916 | .name = "Line Out Playback Switch", | 916 | .name = "Line Out Playback Switch", |
917 | .info = snd_pmac_boolean_mono_info, | 917 | .info = snd_pmac_boolean_mono_info, |
@@ -919,7 +919,7 @@ static struct snd_kcontrol_new tumbler_lineout_sw __initdata = { | |||
919 | .put = tumbler_put_mute_switch, | 919 | .put = tumbler_put_mute_switch, |
920 | .private_value = TUMBLER_MUTE_LINE, | 920 | .private_value = TUMBLER_MUTE_LINE, |
921 | }; | 921 | }; |
922 | static struct snd_kcontrol_new tumbler_drc_sw __initdata = { | 922 | static struct snd_kcontrol_new tumbler_drc_sw __devinitdata = { |
923 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 923 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
924 | .name = "DRC Switch", | 924 | .name = "DRC Switch", |
925 | .info = snd_pmac_boolean_mono_info, | 925 | .info = snd_pmac_boolean_mono_info, |
@@ -1269,7 +1269,7 @@ static void tumbler_resume(struct snd_pmac *chip) | |||
1269 | #endif | 1269 | #endif |
1270 | 1270 | ||
1271 | /* initialize tumbler */ | 1271 | /* initialize tumbler */ |
1272 | static int __init tumbler_init(struct snd_pmac *chip) | 1272 | static int __devinit tumbler_init(struct snd_pmac *chip) |
1273 | { | 1273 | { |
1274 | int irq; | 1274 | int irq; |
1275 | struct pmac_tumbler *mix = chip->mixer_data; | 1275 | struct pmac_tumbler *mix = chip->mixer_data; |
@@ -1339,7 +1339,7 @@ static void tumbler_cleanup(struct snd_pmac *chip) | |||
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | /* exported */ | 1341 | /* exported */ |
1342 | int __init snd_pmac_tumbler_init(struct snd_pmac *chip) | 1342 | int __devinit snd_pmac_tumbler_init(struct snd_pmac *chip) |
1343 | { | 1343 | { |
1344 | int i, err; | 1344 | int i, err; |
1345 | struct pmac_tumbler *mix; | 1345 | struct pmac_tumbler *mix; |
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 3d2bb6fc6dcc..d3e786a9a0a7 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig | |||
@@ -32,7 +32,9 @@ source "sound/soc/fsl/Kconfig" | |||
32 | source "sound/soc/omap/Kconfig" | 32 | source "sound/soc/omap/Kconfig" |
33 | source "sound/soc/pxa/Kconfig" | 33 | source "sound/soc/pxa/Kconfig" |
34 | source "sound/soc/s3c24xx/Kconfig" | 34 | source "sound/soc/s3c24xx/Kconfig" |
35 | source "sound/soc/s6000/Kconfig" | ||
35 | source "sound/soc/sh/Kconfig" | 36 | source "sound/soc/sh/Kconfig" |
37 | source "sound/soc/txx9/Kconfig" | ||
36 | 38 | ||
37 | # Supported codecs | 39 | # Supported codecs |
38 | source "sound/soc/codecs/Kconfig" | 40 | source "sound/soc/codecs/Kconfig" |
diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 0237879fd412..6f1e28de23cf 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile | |||
@@ -10,4 +10,6 @@ obj-$(CONFIG_SND_SOC) += fsl/ | |||
10 | obj-$(CONFIG_SND_SOC) += omap/ | 10 | obj-$(CONFIG_SND_SOC) += omap/ |
11 | obj-$(CONFIG_SND_SOC) += pxa/ | 11 | obj-$(CONFIG_SND_SOC) += pxa/ |
12 | obj-$(CONFIG_SND_SOC) += s3c24xx/ | 12 | obj-$(CONFIG_SND_SOC) += s3c24xx/ |
13 | obj-$(CONFIG_SND_SOC) += s6000/ | ||
13 | obj-$(CONFIG_SND_SOC) += sh/ | 14 | obj-$(CONFIG_SND_SOC) += sh/ |
15 | obj-$(CONFIG_SND_SOC) += txx9/ | ||
diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index a608d7009dbd..e720d5e6f04c 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig | |||
@@ -41,3 +41,11 @@ config SND_AT32_SOC_PLAYPAQ_SLAVE | |||
41 | and FRAME signals on the PlayPaq. Unless you want to play | 41 | and FRAME signals on the PlayPaq. Unless you want to play |
42 | with the AT32 as the SSC master, you probably want to say N here, | 42 | with the AT32 as the SSC master, you probably want to say N here, |
43 | as this will give you better sound quality. | 43 | as this will give you better sound quality. |
44 | |||
45 | config SND_AT91_SOC_AFEB9260 | ||
46 | tristate "SoC Audio support for AFEB9260 board" | ||
47 | depends on ARCH_AT91 && MACH_AFEB9260 && SND_ATMEL_SOC | ||
48 | select SND_ATMEL_SOC_SSC | ||
49 | select SND_SOC_TLV320AIC23 | ||
50 | help | ||
51 | Say Y here to support sound on AFEB9260 board. | ||
diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile index f54a7cc68e66..e7ea56bd5f82 100644 --- a/sound/soc/atmel/Makefile +++ b/sound/soc/atmel/Makefile | |||
@@ -13,3 +13,4 @@ snd-soc-playpaq-objs := playpaq_wm8510.o | |||
13 | 13 | ||
14 | obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o | 14 | obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o |
15 | obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o | 15 | obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o |
16 | obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o | ||
diff --git a/sound/soc/atmel/playpaq_wm8510.c b/sound/soc/atmel/playpaq_wm8510.c index 70657534e6b1..9eb610c2ba91 100644 --- a/sound/soc/atmel/playpaq_wm8510.c +++ b/sound/soc/atmel/playpaq_wm8510.c | |||
@@ -117,7 +117,7 @@ static struct ssc_clock_data playpaq_wm8510_calc_ssc_clock( | |||
117 | * Find actual rate, compare to requested rate | 117 | * Find actual rate, compare to requested rate |
118 | */ | 118 | */ |
119 | actual_rate = (cd.ssc_rate / (cd.cmr_div * 2)) / (2 * (cd.period + 1)); | 119 | actual_rate = (cd.ssc_rate / (cd.cmr_div * 2)) / (2 * (cd.period + 1)); |
120 | pr_debug("playpaq_wm8510: Request rate = %d, actual rate = %d\n", | 120 | pr_debug("playpaq_wm8510: Request rate = %u, actual rate = %u\n", |
121 | rate, actual_rate); | 121 | rate, actual_rate); |
122 | 122 | ||
123 | 123 | ||
diff --git a/sound/soc/atmel/snd-soc-afeb9260.c b/sound/soc/atmel/snd-soc-afeb9260.c new file mode 100644 index 000000000000..23349de27313 --- /dev/null +++ b/sound/soc/atmel/snd-soc-afeb9260.c | |||
@@ -0,0 +1,203 @@ | |||
1 | /* | ||
2 | * afeb9260.c -- SoC audio for AFEB9260 | ||
3 | * | ||
4 | * Copyright (C) 2009 Sergey Lapin <slapin@ossfans.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/moduleparam.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/clk.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | |||
28 | #include <linux/atmel-ssc.h> | ||
29 | #include <sound/core.h> | ||
30 | #include <sound/pcm.h> | ||
31 | #include <sound/pcm_params.h> | ||
32 | #include <sound/soc.h> | ||
33 | #include <sound/soc-dapm.h> | ||
34 | |||
35 | #include <asm/mach-types.h> | ||
36 | #include <mach/hardware.h> | ||
37 | #include <linux/gpio.h> | ||
38 | |||
39 | #include "../codecs/tlv320aic23.h" | ||
40 | #include "atmel-pcm.h" | ||
41 | #include "atmel_ssc_dai.h" | ||
42 | |||
43 | #define CODEC_CLOCK 12000000 | ||
44 | |||
45 | static int afeb9260_hw_params(struct snd_pcm_substream *substream, | ||
46 | struct snd_pcm_hw_params *params) | ||
47 | { | ||
48 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
49 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
50 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
51 | int err; | ||
52 | |||
53 | /* Set codec DAI configuration */ | ||
54 | err = snd_soc_dai_set_fmt(codec_dai, | ||
55 | SND_SOC_DAIFMT_I2S| | ||
56 | SND_SOC_DAIFMT_NB_IF | | ||
57 | SND_SOC_DAIFMT_CBM_CFM); | ||
58 | if (err < 0) { | ||
59 | printk(KERN_ERR "can't set codec DAI configuration\n"); | ||
60 | return err; | ||
61 | } | ||
62 | |||
63 | /* Set cpu DAI configuration */ | ||
64 | err = snd_soc_dai_set_fmt(cpu_dai, | ||
65 | SND_SOC_DAIFMT_I2S | | ||
66 | SND_SOC_DAIFMT_NB_IF | | ||
67 | SND_SOC_DAIFMT_CBM_CFM); | ||
68 | if (err < 0) { | ||
69 | printk(KERN_ERR "can't set cpu DAI configuration\n"); | ||
70 | return err; | ||
71 | } | ||
72 | |||
73 | /* Set the codec system clock for DAC and ADC */ | ||
74 | err = | ||
75 | snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_CLOCK, SND_SOC_CLOCK_IN); | ||
76 | |||
77 | if (err < 0) { | ||
78 | printk(KERN_ERR "can't set codec system clock\n"); | ||
79 | return err; | ||
80 | } | ||
81 | |||
82 | return err; | ||
83 | } | ||
84 | |||
85 | static struct snd_soc_ops afeb9260_ops = { | ||
86 | .hw_params = afeb9260_hw_params, | ||
87 | }; | ||
88 | |||
89 | static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = { | ||
90 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | ||
91 | SND_SOC_DAPM_LINE("Line In", NULL), | ||
92 | SND_SOC_DAPM_MIC("Mic Jack", NULL), | ||
93 | }; | ||
94 | |||
95 | static const struct snd_soc_dapm_route audio_map[] = { | ||
96 | {"Headphone Jack", NULL, "LHPOUT"}, | ||
97 | {"Headphone Jack", NULL, "RHPOUT"}, | ||
98 | |||
99 | {"LLINEIN", NULL, "Line In"}, | ||
100 | {"RLINEIN", NULL, "Line In"}, | ||
101 | |||
102 | {"MICIN", NULL, "Mic Jack"}, | ||
103 | }; | ||
104 | |||
105 | static int afeb9260_tlv320aic23_init(struct snd_soc_codec *codec) | ||
106 | { | ||
107 | |||
108 | /* Add afeb9260 specific widgets */ | ||
109 | snd_soc_dapm_new_controls(codec, tlv320aic23_dapm_widgets, | ||
110 | ARRAY_SIZE(tlv320aic23_dapm_widgets)); | ||
111 | |||
112 | /* Set up afeb9260 specific audio path audio_map */ | ||
113 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | ||
114 | |||
115 | snd_soc_dapm_enable_pin(codec, "Headphone Jack"); | ||
116 | snd_soc_dapm_enable_pin(codec, "Line In"); | ||
117 | snd_soc_dapm_enable_pin(codec, "Mic Jack"); | ||
118 | |||
119 | snd_soc_dapm_sync(codec); | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | /* Digital audio interface glue - connects codec <--> CPU */ | ||
125 | static struct snd_soc_dai_link afeb9260_dai = { | ||
126 | .name = "TLV320AIC23", | ||
127 | .stream_name = "AIC23", | ||
128 | .cpu_dai = &atmel_ssc_dai[0], | ||
129 | .codec_dai = &tlv320aic23_dai, | ||
130 | .init = afeb9260_tlv320aic23_init, | ||
131 | .ops = &afeb9260_ops, | ||
132 | }; | ||
133 | |||
134 | /* Audio machine driver */ | ||
135 | static struct snd_soc_card snd_soc_machine_afeb9260 = { | ||
136 | .name = "AFEB9260", | ||
137 | .platform = &atmel_soc_platform, | ||
138 | .dai_link = &afeb9260_dai, | ||
139 | .num_links = 1, | ||
140 | }; | ||
141 | |||
142 | /* Audio subsystem */ | ||
143 | static struct snd_soc_device afeb9260_snd_devdata = { | ||
144 | .card = &snd_soc_machine_afeb9260, | ||
145 | .codec_dev = &soc_codec_dev_tlv320aic23, | ||
146 | }; | ||
147 | |||
148 | static struct platform_device *afeb9260_snd_device; | ||
149 | |||
150 | static int __init afeb9260_soc_init(void) | ||
151 | { | ||
152 | int err; | ||
153 | struct device *dev; | ||
154 | struct atmel_ssc_info *ssc_p = afeb9260_dai.cpu_dai->private_data; | ||
155 | struct ssc_device *ssc = NULL; | ||
156 | |||
157 | if (!(machine_is_afeb9260())) | ||
158 | return -ENODEV; | ||
159 | |||
160 | ssc = ssc_request(0); | ||
161 | if (IS_ERR(ssc)) { | ||
162 | printk(KERN_ERR "ASoC: Failed to request SSC 0\n"); | ||
163 | err = PTR_ERR(ssc); | ||
164 | ssc = NULL; | ||
165 | goto err_ssc; | ||
166 | } | ||
167 | ssc_p->ssc = ssc; | ||
168 | |||
169 | afeb9260_snd_device = platform_device_alloc("soc-audio", -1); | ||
170 | if (!afeb9260_snd_device) { | ||
171 | printk(KERN_ERR "ASoC: Platform device allocation failed\n"); | ||
172 | return -ENOMEM; | ||
173 | } | ||
174 | |||
175 | platform_set_drvdata(afeb9260_snd_device, &afeb9260_snd_devdata); | ||
176 | afeb9260_snd_devdata.dev = &afeb9260_snd_device->dev; | ||
177 | err = platform_device_add(afeb9260_snd_device); | ||
178 | if (err) | ||
179 | goto err1; | ||
180 | |||
181 | dev = &afeb9260_snd_device->dev; | ||
182 | |||
183 | return 0; | ||
184 | err1: | ||
185 | platform_device_del(afeb9260_snd_device); | ||
186 | platform_device_put(afeb9260_snd_device); | ||
187 | err_ssc: | ||
188 | return err; | ||
189 | |||
190 | } | ||
191 | |||
192 | static void __exit afeb9260_soc_exit(void) | ||
193 | { | ||
194 | platform_device_unregister(afeb9260_snd_device); | ||
195 | } | ||
196 | |||
197 | module_init(afeb9260_soc_init); | ||
198 | module_exit(afeb9260_soc_exit); | ||
199 | |||
200 | MODULE_AUTHOR("Sergey Lapin <slapin@ossfans.org>"); | ||
201 | MODULE_DESCRIPTION("ALSA SoC for AFEB9260"); | ||
202 | MODULE_LICENSE("GPL"); | ||
203 | |||
diff --git a/sound/soc/blackfin/bf5xx-ac97.c b/sound/soc/blackfin/bf5xx-ac97.c index 8a935f2d1767..b1ed423fabd5 100644 --- a/sound/soc/blackfin/bf5xx-ac97.c +++ b/sound/soc/blackfin/bf5xx-ac97.c | |||
@@ -31,6 +31,15 @@ | |||
31 | #include "bf5xx-sport.h" | 31 | #include "bf5xx-sport.h" |
32 | #include "bf5xx-ac97.h" | 32 | #include "bf5xx-ac97.h" |
33 | 33 | ||
34 | /* Anomaly notes: | ||
35 | * 05000250 - AD1980 is running in TDM mode and RFS/TFS are generated by SPORT | ||
36 | * contrtoller. But, RFSDIV and TFSDIV are always set to 16*16-1, | ||
37 | * while the max AC97 data size is 13*16. The DIV is always larger | ||
38 | * than data size. AD73311 and ad2602 are not running in TDM mode. | ||
39 | * AD1836 and AD73322 depend on external RFS/TFS only. So, this | ||
40 | * anomaly does not affect blackfin sound drivers. | ||
41 | */ | ||
42 | |||
34 | static int *cmd_count; | 43 | static int *cmd_count; |
35 | static int sport_num = CONFIG_SND_BF5XX_SPORT_NUM; | 44 | static int sport_num = CONFIG_SND_BF5XX_SPORT_NUM; |
36 | 45 | ||
diff --git a/sound/soc/blackfin/bf5xx-sport.c b/sound/soc/blackfin/bf5xx-sport.c index b7953c8cf838..469ce7fab20c 100644 --- a/sound/soc/blackfin/bf5xx-sport.c +++ b/sound/soc/blackfin/bf5xx-sport.c | |||
@@ -190,7 +190,7 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) | |||
190 | desc = get_dma_next_desc_ptr(sport->dma_rx_chan); | 190 | desc = get_dma_next_desc_ptr(sport->dma_rx_chan); |
191 | /* Copy the descriptor which will be damaged to backup */ | 191 | /* Copy the descriptor which will be damaged to backup */ |
192 | temp_desc = *desc; | 192 | temp_desc = *desc; |
193 | desc->x_count = 0xa; | 193 | desc->x_count = sport->dummy_count / 2; |
194 | desc->y_count = 0; | 194 | desc->y_count = 0; |
195 | desc->next_desc_addr = sport->dummy_rx_desc; | 195 | desc->next_desc_addr = sport->dummy_rx_desc; |
196 | local_irq_restore(flags); | 196 | local_irq_restore(flags); |
@@ -309,7 +309,7 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport) | |||
309 | desc = get_dma_next_desc_ptr(sport->dma_tx_chan); | 309 | desc = get_dma_next_desc_ptr(sport->dma_tx_chan); |
310 | /* Store the descriptor which will be damaged */ | 310 | /* Store the descriptor which will be damaged */ |
311 | temp_desc = *desc; | 311 | temp_desc = *desc; |
312 | desc->x_count = 0xa; | 312 | desc->x_count = sport->dummy_count / 2; |
313 | desc->y_count = 0; | 313 | desc->y_count = 0; |
314 | desc->next_desc_addr = sport->dummy_tx_desc; | 314 | desc->next_desc_addr = sport->dummy_tx_desc; |
315 | local_irq_restore(flags); | 315 | local_irq_restore(flags); |
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index b6c7f7a01cb0..bbc97fd76648 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -18,7 +18,9 @@ config SND_SOC_ALL_CODECS | |||
18 | select SND_SOC_AK4535 if I2C | 18 | select SND_SOC_AK4535 if I2C |
19 | select SND_SOC_CS4270 if I2C | 19 | select SND_SOC_CS4270 if I2C |
20 | select SND_SOC_PCM3008 | 20 | select SND_SOC_PCM3008 |
21 | select SND_SOC_SPDIF | ||
21 | select SND_SOC_SSM2602 if I2C | 22 | select SND_SOC_SSM2602 if I2C |
23 | select SND_SOC_STAC9766 if SND_SOC_AC97_BUS | ||
22 | select SND_SOC_TLV320AIC23 if I2C | 24 | select SND_SOC_TLV320AIC23 if I2C |
23 | select SND_SOC_TLV320AIC26 if SPI_MASTER | 25 | select SND_SOC_TLV320AIC26 if SPI_MASTER |
24 | select SND_SOC_TLV320AIC3X if I2C | 26 | select SND_SOC_TLV320AIC3X if I2C |
@@ -35,8 +37,12 @@ config SND_SOC_ALL_CODECS | |||
35 | select SND_SOC_WM8753 if SND_SOC_I2C_AND_SPI | 37 | select SND_SOC_WM8753 if SND_SOC_I2C_AND_SPI |
36 | select SND_SOC_WM8900 if I2C | 38 | select SND_SOC_WM8900 if I2C |
37 | select SND_SOC_WM8903 if I2C | 39 | select SND_SOC_WM8903 if I2C |
40 | select SND_SOC_WM8940 if I2C | ||
41 | select SND_SOC_WM8960 if I2C | ||
38 | select SND_SOC_WM8971 if I2C | 42 | select SND_SOC_WM8971 if I2C |
43 | select SND_SOC_WM8988 if SND_SOC_I2C_AND_SPI | ||
39 | select SND_SOC_WM8990 if I2C | 44 | select SND_SOC_WM8990 if I2C |
45 | select SND_SOC_WM9081 if I2C | ||
40 | select SND_SOC_WM9705 if SND_SOC_AC97_BUS | 46 | select SND_SOC_WM9705 if SND_SOC_AC97_BUS |
41 | select SND_SOC_WM9712 if SND_SOC_AC97_BUS | 47 | select SND_SOC_WM9712 if SND_SOC_AC97_BUS |
42 | select SND_SOC_WM9713 if SND_SOC_AC97_BUS | 48 | select SND_SOC_WM9713 if SND_SOC_AC97_BUS |
@@ -86,9 +92,15 @@ config SND_SOC_L3 | |||
86 | config SND_SOC_PCM3008 | 92 | config SND_SOC_PCM3008 |
87 | tristate | 93 | tristate |
88 | 94 | ||
95 | config SND_SOC_SPDIF | ||
96 | tristate | ||
97 | |||
89 | config SND_SOC_SSM2602 | 98 | config SND_SOC_SSM2602 |
90 | tristate | 99 | tristate |
91 | 100 | ||
101 | config SND_SOC_STAC9766 | ||
102 | tristate | ||
103 | |||
92 | config SND_SOC_TLV320AIC23 | 104 | config SND_SOC_TLV320AIC23 |
93 | tristate | 105 | tristate |
94 | 106 | ||
@@ -138,12 +150,24 @@ config SND_SOC_WM8900 | |||
138 | config SND_SOC_WM8903 | 150 | config SND_SOC_WM8903 |
139 | tristate | 151 | tristate |
140 | 152 | ||
153 | config SND_SOC_WM8940 | ||
154 | tristate | ||
155 | |||
156 | config SND_SOC_WM8960 | ||
157 | tristate | ||
158 | |||
141 | config SND_SOC_WM8971 | 159 | config SND_SOC_WM8971 |
142 | tristate | 160 | tristate |
143 | 161 | ||
162 | config SND_SOC_WM8988 | ||
163 | tristate | ||
164 | |||
144 | config SND_SOC_WM8990 | 165 | config SND_SOC_WM8990 |
145 | tristate | 166 | tristate |
146 | 167 | ||
168 | config SND_SOC_WM9081 | ||
169 | tristate | ||
170 | |||
147 | config SND_SOC_WM9705 | 171 | config SND_SOC_WM9705 |
148 | tristate | 172 | tristate |
149 | 173 | ||
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index f2653803ede8..8b7530546f4d 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
@@ -6,7 +6,9 @@ snd-soc-ak4535-objs := ak4535.o | |||
6 | snd-soc-cs4270-objs := cs4270.o | 6 | snd-soc-cs4270-objs := cs4270.o |
7 | snd-soc-l3-objs := l3.o | 7 | snd-soc-l3-objs := l3.o |
8 | snd-soc-pcm3008-objs := pcm3008.o | 8 | snd-soc-pcm3008-objs := pcm3008.o |
9 | snd-soc-spdif-objs := spdif_transciever.o | ||
9 | snd-soc-ssm2602-objs := ssm2602.o | 10 | snd-soc-ssm2602-objs := ssm2602.o |
11 | snd-soc-stac9766-objs := stac9766.o | ||
10 | snd-soc-tlv320aic23-objs := tlv320aic23.o | 12 | snd-soc-tlv320aic23-objs := tlv320aic23.o |
11 | snd-soc-tlv320aic26-objs := tlv320aic26.o | 13 | snd-soc-tlv320aic26-objs := tlv320aic26.o |
12 | snd-soc-tlv320aic3x-objs := tlv320aic3x.o | 14 | snd-soc-tlv320aic3x-objs := tlv320aic3x.o |
@@ -23,8 +25,12 @@ snd-soc-wm8750-objs := wm8750.o | |||
23 | snd-soc-wm8753-objs := wm8753.o | 25 | snd-soc-wm8753-objs := wm8753.o |
24 | snd-soc-wm8900-objs := wm8900.o | 26 | snd-soc-wm8900-objs := wm8900.o |
25 | snd-soc-wm8903-objs := wm8903.o | 27 | snd-soc-wm8903-objs := wm8903.o |
28 | snd-soc-wm8940-objs := wm8940.o | ||
29 | snd-soc-wm8960-objs := wm8960.o | ||
26 | snd-soc-wm8971-objs := wm8971.o | 30 | snd-soc-wm8971-objs := wm8971.o |
31 | snd-soc-wm8988-objs := wm8988.o | ||
27 | snd-soc-wm8990-objs := wm8990.o | 32 | snd-soc-wm8990-objs := wm8990.o |
33 | snd-soc-wm9081-objs := wm9081.o | ||
28 | snd-soc-wm9705-objs := wm9705.o | 34 | snd-soc-wm9705-objs := wm9705.o |
29 | snd-soc-wm9712-objs := wm9712.o | 35 | snd-soc-wm9712-objs := wm9712.o |
30 | snd-soc-wm9713-objs := wm9713.o | 36 | snd-soc-wm9713-objs := wm9713.o |
@@ -37,7 +43,9 @@ obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o | |||
37 | obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o | 43 | obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o |
38 | obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o | 44 | obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o |
39 | obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o | 45 | obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o |
46 | obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif.o | ||
40 | obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o | 47 | obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o |
48 | obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o | ||
41 | obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o | 49 | obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o |
42 | obj-$(CONFIG_SND_SOC_TLV320AIC26) += snd-soc-tlv320aic26.o | 50 | obj-$(CONFIG_SND_SOC_TLV320AIC26) += snd-soc-tlv320aic26.o |
43 | obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o | 51 | obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o |
@@ -55,7 +63,11 @@ obj-$(CONFIG_SND_SOC_WM8753) += snd-soc-wm8753.o | |||
55 | obj-$(CONFIG_SND_SOC_WM8900) += snd-soc-wm8900.o | 63 | obj-$(CONFIG_SND_SOC_WM8900) += snd-soc-wm8900.o |
56 | obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o | 64 | obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o |
57 | obj-$(CONFIG_SND_SOC_WM8971) += snd-soc-wm8971.o | 65 | obj-$(CONFIG_SND_SOC_WM8971) += snd-soc-wm8971.o |
66 | obj-$(CONFIG_SND_SOC_WM8940) += snd-soc-wm8940.o | ||
67 | obj-$(CONFIG_SND_SOC_WM8960) += snd-soc-wm8960.o | ||
68 | obj-$(CONFIG_SND_SOC_WM8988) += snd-soc-wm8988.o | ||
58 | obj-$(CONFIG_SND_SOC_WM8990) += snd-soc-wm8990.o | 69 | obj-$(CONFIG_SND_SOC_WM8990) += snd-soc-wm8990.o |
70 | obj-$(CONFIG_SND_SOC_WM9081) += snd-soc-wm9081.o | ||
59 | obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o | 71 | obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o |
60 | obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o | 72 | obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o |
61 | obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o | 73 | obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o |
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c index b0d4af145b87..932299bb5d1e 100644 --- a/sound/soc/codecs/ac97.c +++ b/sound/soc/codecs/ac97.c | |||
@@ -53,13 +53,13 @@ struct snd_soc_dai ac97_dai = { | |||
53 | .channels_min = 1, | 53 | .channels_min = 1, |
54 | .channels_max = 2, | 54 | .channels_max = 2, |
55 | .rates = STD_AC97_RATES, | 55 | .rates = STD_AC97_RATES, |
56 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 56 | .formats = SND_SOC_STD_AC97_FMTS,}, |
57 | .capture = { | 57 | .capture = { |
58 | .stream_name = "AC97 Capture", | 58 | .stream_name = "AC97 Capture", |
59 | .channels_min = 1, | 59 | .channels_min = 1, |
60 | .channels_max = 2, | 60 | .channels_max = 2, |
61 | .rates = STD_AC97_RATES, | 61 | .rates = STD_AC97_RATES, |
62 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 62 | .formats = SND_SOC_STD_AC97_FMTS,}, |
63 | .ops = &ac97_dai_ops, | 63 | .ops = &ac97_dai_ops, |
64 | }; | 64 | }; |
65 | EXPORT_SYMBOL_GPL(ac97_dai); | 65 | EXPORT_SYMBOL_GPL(ac97_dai); |
diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c index ddb3b08ac23c..d7440a982d22 100644 --- a/sound/soc/codecs/ad1980.c +++ b/sound/soc/codecs/ad1980.c | |||
@@ -137,13 +137,13 @@ struct snd_soc_dai ad1980_dai = { | |||
137 | .channels_min = 2, | 137 | .channels_min = 2, |
138 | .channels_max = 6, | 138 | .channels_max = 6, |
139 | .rates = SNDRV_PCM_RATE_48000, | 139 | .rates = SNDRV_PCM_RATE_48000, |
140 | .formats = SNDRV_PCM_FMTBIT_S16_LE, }, | 140 | .formats = SND_SOC_STD_AC97_FMTS, }, |
141 | .capture = { | 141 | .capture = { |
142 | .stream_name = "Capture", | 142 | .stream_name = "Capture", |
143 | .channels_min = 2, | 143 | .channels_min = 2, |
144 | .channels_max = 2, | 144 | .channels_max = 2, |
145 | .rates = SNDRV_PCM_RATE_48000, | 145 | .rates = SNDRV_PCM_RATE_48000, |
146 | .formats = SNDRV_PCM_FMTBIT_S16_LE, }, | 146 | .formats = SND_SOC_STD_AC97_FMTS, }, |
147 | }; | 147 | }; |
148 | EXPORT_SYMBOL_GPL(ad1980_dai); | 148 | EXPORT_SYMBOL_GPL(ad1980_dai); |
149 | 149 | ||
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 7fa09a387622..a32b8226c8a4 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c | |||
@@ -18,7 +18,7 @@ | |||
18 | * - The machine driver's 'startup' function must call | 18 | * - The machine driver's 'startup' function must call |
19 | * cs4270_set_dai_sysclk() with the value of MCLK. | 19 | * cs4270_set_dai_sysclk() with the value of MCLK. |
20 | * - Only I2S and left-justified modes are supported | 20 | * - Only I2S and left-justified modes are supported |
21 | * - Power management is not supported | 21 | * - Power management is supported |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
@@ -27,6 +27,7 @@ | |||
27 | #include <sound/soc.h> | 27 | #include <sound/soc.h> |
28 | #include <sound/initval.h> | 28 | #include <sound/initval.h> |
29 | #include <linux/i2c.h> | 29 | #include <linux/i2c.h> |
30 | #include <linux/delay.h> | ||
30 | 31 | ||
31 | #include "cs4270.h" | 32 | #include "cs4270.h" |
32 | 33 | ||
@@ -56,6 +57,7 @@ | |||
56 | #define CS4270_FIRSTREG 0x01 | 57 | #define CS4270_FIRSTREG 0x01 |
57 | #define CS4270_LASTREG 0x08 | 58 | #define CS4270_LASTREG 0x08 |
58 | #define CS4270_NUMREGS (CS4270_LASTREG - CS4270_FIRSTREG + 1) | 59 | #define CS4270_NUMREGS (CS4270_LASTREG - CS4270_FIRSTREG + 1) |
60 | #define CS4270_I2C_INCR 0x80 | ||
59 | 61 | ||
60 | /* Bit masks for the CS4270 registers */ | 62 | /* Bit masks for the CS4270 registers */ |
61 | #define CS4270_CHIPID_ID 0xF0 | 63 | #define CS4270_CHIPID_ID 0xF0 |
@@ -64,6 +66,8 @@ | |||
64 | #define CS4270_PWRCTL_PDN_ADC 0x20 | 66 | #define CS4270_PWRCTL_PDN_ADC 0x20 |
65 | #define CS4270_PWRCTL_PDN_DAC 0x02 | 67 | #define CS4270_PWRCTL_PDN_DAC 0x02 |
66 | #define CS4270_PWRCTL_PDN 0x01 | 68 | #define CS4270_PWRCTL_PDN 0x01 |
69 | #define CS4270_PWRCTL_PDN_ALL \ | ||
70 | (CS4270_PWRCTL_PDN_ADC | CS4270_PWRCTL_PDN_DAC | CS4270_PWRCTL_PDN) | ||
67 | #define CS4270_MODE_SPEED_MASK 0x30 | 71 | #define CS4270_MODE_SPEED_MASK 0x30 |
68 | #define CS4270_MODE_1X 0x00 | 72 | #define CS4270_MODE_1X 0x00 |
69 | #define CS4270_MODE_2X 0x10 | 73 | #define CS4270_MODE_2X 0x10 |
@@ -109,6 +113,7 @@ struct cs4270_private { | |||
109 | unsigned int mclk; /* Input frequency of the MCLK pin */ | 113 | unsigned int mclk; /* Input frequency of the MCLK pin */ |
110 | unsigned int mode; /* The mode (I2S or left-justified) */ | 114 | unsigned int mode; /* The mode (I2S or left-justified) */ |
111 | unsigned int slave_mode; | 115 | unsigned int slave_mode; |
116 | unsigned int manual_mute; | ||
112 | }; | 117 | }; |
113 | 118 | ||
114 | /** | 119 | /** |
@@ -295,7 +300,7 @@ static int cs4270_fill_cache(struct snd_soc_codec *codec) | |||
295 | s32 length; | 300 | s32 length; |
296 | 301 | ||
297 | length = i2c_smbus_read_i2c_block_data(i2c_client, | 302 | length = i2c_smbus_read_i2c_block_data(i2c_client, |
298 | CS4270_FIRSTREG | 0x80, CS4270_NUMREGS, cache); | 303 | CS4270_FIRSTREG | CS4270_I2C_INCR, CS4270_NUMREGS, cache); |
299 | 304 | ||
300 | if (length != CS4270_NUMREGS) { | 305 | if (length != CS4270_NUMREGS) { |
301 | dev_err(codec->dev, "i2c read failure, addr=0x%x\n", | 306 | dev_err(codec->dev, "i2c read failure, addr=0x%x\n", |
@@ -453,7 +458,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, | |||
453 | } | 458 | } |
454 | 459 | ||
455 | /** | 460 | /** |
456 | * cs4270_mute - enable/disable the CS4270 external mute | 461 | * cs4270_dai_mute - enable/disable the CS4270 external mute |
457 | * @dai: the SOC DAI | 462 | * @dai: the SOC DAI |
458 | * @mute: 0 = disable mute, 1 = enable mute | 463 | * @mute: 0 = disable mute, 1 = enable mute |
459 | * | 464 | * |
@@ -462,21 +467,52 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, | |||
462 | * board does not have the MUTEA or MUTEB pins connected to such circuitry, | 467 | * board does not have the MUTEA or MUTEB pins connected to such circuitry, |
463 | * then this function will do nothing. | 468 | * then this function will do nothing. |
464 | */ | 469 | */ |
465 | static int cs4270_mute(struct snd_soc_dai *dai, int mute) | 470 | static int cs4270_dai_mute(struct snd_soc_dai *dai, int mute) |
466 | { | 471 | { |
467 | struct snd_soc_codec *codec = dai->codec; | 472 | struct snd_soc_codec *codec = dai->codec; |
473 | struct cs4270_private *cs4270 = codec->private_data; | ||
468 | int reg6; | 474 | int reg6; |
469 | 475 | ||
470 | reg6 = snd_soc_read(codec, CS4270_MUTE); | 476 | reg6 = snd_soc_read(codec, CS4270_MUTE); |
471 | 477 | ||
472 | if (mute) | 478 | if (mute) |
473 | reg6 |= CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B; | 479 | reg6 |= CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B; |
474 | else | 480 | else { |
475 | reg6 &= ~(CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B); | 481 | reg6 &= ~(CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B); |
482 | reg6 |= cs4270->manual_mute; | ||
483 | } | ||
476 | 484 | ||
477 | return snd_soc_write(codec, CS4270_MUTE, reg6); | 485 | return snd_soc_write(codec, CS4270_MUTE, reg6); |
478 | } | 486 | } |
479 | 487 | ||
488 | /** | ||
489 | * cs4270_soc_put_mute - put callback for the 'Master Playback switch' | ||
490 | * alsa control. | ||
491 | * @kcontrol: mixer control | ||
492 | * @ucontrol: control element information | ||
493 | * | ||
494 | * This function basically passes the arguments on to the generic | ||
495 | * snd_soc_put_volsw() function and saves the mute information in | ||
496 | * our private data structure. This is because we want to prevent | ||
497 | * cs4270_dai_mute() neglecting the user's decision to manually | ||
498 | * mute the codec's output. | ||
499 | * | ||
500 | * Returns 0 for success. | ||
501 | */ | ||
502 | static int cs4270_soc_put_mute(struct snd_kcontrol *kcontrol, | ||
503 | struct snd_ctl_elem_value *ucontrol) | ||
504 | { | ||
505 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
506 | struct cs4270_private *cs4270 = codec->private_data; | ||
507 | int left = !ucontrol->value.integer.value[0]; | ||
508 | int right = !ucontrol->value.integer.value[1]; | ||
509 | |||
510 | cs4270->manual_mute = (left ? CS4270_MUTE_DAC_A : 0) | | ||
511 | (right ? CS4270_MUTE_DAC_B : 0); | ||
512 | |||
513 | return snd_soc_put_volsw(kcontrol, ucontrol); | ||
514 | } | ||
515 | |||
480 | /* A list of non-DAPM controls that the CS4270 supports */ | 516 | /* A list of non-DAPM controls that the CS4270 supports */ |
481 | static const struct snd_kcontrol_new cs4270_snd_controls[] = { | 517 | static const struct snd_kcontrol_new cs4270_snd_controls[] = { |
482 | SOC_DOUBLE_R("Master Playback Volume", | 518 | SOC_DOUBLE_R("Master Playback Volume", |
@@ -486,7 +522,9 @@ static const struct snd_kcontrol_new cs4270_snd_controls[] = { | |||
486 | SOC_SINGLE("Zero Cross Switch", CS4270_TRANS, 5, 1, 0), | 522 | SOC_SINGLE("Zero Cross Switch", CS4270_TRANS, 5, 1, 0), |
487 | SOC_SINGLE("Popguard Switch", CS4270_MODE, 0, 1, 1), | 523 | SOC_SINGLE("Popguard Switch", CS4270_MODE, 0, 1, 1), |
488 | SOC_SINGLE("Auto-Mute Switch", CS4270_MUTE, 5, 1, 0), | 524 | SOC_SINGLE("Auto-Mute Switch", CS4270_MUTE, 5, 1, 0), |
489 | SOC_DOUBLE("Master Capture Switch", CS4270_MUTE, 3, 4, 1, 0) | 525 | SOC_DOUBLE("Master Capture Switch", CS4270_MUTE, 3, 4, 1, 1), |
526 | SOC_DOUBLE_EXT("Master Playback Switch", CS4270_MUTE, 0, 1, 1, 1, | ||
527 | snd_soc_get_volsw, cs4270_soc_put_mute), | ||
490 | }; | 528 | }; |
491 | 529 | ||
492 | /* | 530 | /* |
@@ -506,7 +544,7 @@ static struct snd_soc_dai_ops cs4270_dai_ops = { | |||
506 | .hw_params = cs4270_hw_params, | 544 | .hw_params = cs4270_hw_params, |
507 | .set_sysclk = cs4270_set_dai_sysclk, | 545 | .set_sysclk = cs4270_set_dai_sysclk, |
508 | .set_fmt = cs4270_set_dai_fmt, | 546 | .set_fmt = cs4270_set_dai_fmt, |
509 | .digital_mute = cs4270_mute, | 547 | .digital_mute = cs4270_dai_mute, |
510 | }; | 548 | }; |
511 | 549 | ||
512 | struct snd_soc_dai cs4270_dai = { | 550 | struct snd_soc_dai cs4270_dai = { |
@@ -753,6 +791,57 @@ static struct i2c_device_id cs4270_id[] = { | |||
753 | }; | 791 | }; |
754 | MODULE_DEVICE_TABLE(i2c, cs4270_id); | 792 | MODULE_DEVICE_TABLE(i2c, cs4270_id); |
755 | 793 | ||
794 | #ifdef CONFIG_PM | ||
795 | |||
796 | /* This suspend/resume implementation can handle both - a simple standby | ||
797 | * where the codec remains powered, and a full suspend, where the voltage | ||
798 | * domain the codec is connected to is teared down and/or any other hardware | ||
799 | * reset condition is asserted. | ||
800 | * | ||
801 | * The codec's own power saving features are enabled in the suspend callback, | ||
802 | * and all registers are written back to the hardware when resuming. | ||
803 | */ | ||
804 | |||
805 | static int cs4270_i2c_suspend(struct i2c_client *client, pm_message_t mesg) | ||
806 | { | ||
807 | struct cs4270_private *cs4270 = i2c_get_clientdata(client); | ||
808 | struct snd_soc_codec *codec = &cs4270->codec; | ||
809 | int reg = snd_soc_read(codec, CS4270_PWRCTL) | CS4270_PWRCTL_PDN_ALL; | ||
810 | |||
811 | return snd_soc_write(codec, CS4270_PWRCTL, reg); | ||
812 | } | ||
813 | |||
814 | static int cs4270_i2c_resume(struct i2c_client *client) | ||
815 | { | ||
816 | struct cs4270_private *cs4270 = i2c_get_clientdata(client); | ||
817 | struct snd_soc_codec *codec = &cs4270->codec; | ||
818 | int reg; | ||
819 | |||
820 | /* In case the device was put to hard reset during sleep, we need to | ||
821 | * wait 500ns here before any I2C communication. */ | ||
822 | ndelay(500); | ||
823 | |||
824 | /* first restore the entire register cache ... */ | ||
825 | for (reg = CS4270_FIRSTREG; reg <= CS4270_LASTREG; reg++) { | ||
826 | u8 val = snd_soc_read(codec, reg); | ||
827 | |||
828 | if (i2c_smbus_write_byte_data(client, reg, val)) { | ||
829 | dev_err(codec->dev, "i2c write failed\n"); | ||
830 | return -EIO; | ||
831 | } | ||
832 | } | ||
833 | |||
834 | /* ... then disable the power-down bits */ | ||
835 | reg = snd_soc_read(codec, CS4270_PWRCTL); | ||
836 | reg &= ~CS4270_PWRCTL_PDN_ALL; | ||
837 | |||
838 | return snd_soc_write(codec, CS4270_PWRCTL, reg); | ||
839 | } | ||
840 | #else | ||
841 | #define cs4270_i2c_suspend NULL | ||
842 | #define cs4270_i2c_resume NULL | ||
843 | #endif /* CONFIG_PM */ | ||
844 | |||
756 | /* | 845 | /* |
757 | * cs4270_i2c_driver - I2C device identification | 846 | * cs4270_i2c_driver - I2C device identification |
758 | * | 847 | * |
@@ -767,6 +856,8 @@ static struct i2c_driver cs4270_i2c_driver = { | |||
767 | .id_table = cs4270_id, | 856 | .id_table = cs4270_id, |
768 | .probe = cs4270_i2c_probe, | 857 | .probe = cs4270_i2c_probe, |
769 | .remove = cs4270_i2c_remove, | 858 | .remove = cs4270_i2c_remove, |
859 | .suspend = cs4270_i2c_suspend, | ||
860 | .resume = cs4270_i2c_resume, | ||
770 | }; | 861 | }; |
771 | 862 | ||
772 | /* | 863 | /* |
diff --git a/sound/soc/codecs/spdif_transciever.c b/sound/soc/codecs/spdif_transciever.c new file mode 100644 index 000000000000..218b33adad90 --- /dev/null +++ b/sound/soc/codecs/spdif_transciever.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * ALSA SoC SPDIF DIT driver | ||
3 | * | ||
4 | * This driver is used by controllers which can operate in DIT (SPDI/F) where | ||
5 | * no codec is needed. This file provides stub codec that can be used | ||
6 | * in these configurations. TI DaVinci Audio controller uses this driver. | ||
7 | * | ||
8 | * Author: Steve Chen, <schen@mvista.com> | ||
9 | * Copyright: (C) 2009 MontaVista Software, Inc., <source@mvista.com> | ||
10 | * Copyright: (C) 2009 Texas Instruments, India | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License version 2 as | ||
14 | * published by the Free Software Foundation. | ||
15 | */ | ||
16 | |||
17 | #include <linux/module.h> | ||
18 | #include <linux/moduleparam.h> | ||
19 | #include <sound/soc.h> | ||
20 | #include <sound/pcm.h> | ||
21 | |||
22 | #include "spdif_transciever.h" | ||
23 | |||
24 | #define STUB_RATES SNDRV_PCM_RATE_8000_96000 | ||
25 | #define STUB_FORMATS SNDRV_PCM_FMTBIT_S16_LE | ||
26 | |||
27 | struct snd_soc_dai dit_stub_dai = { | ||
28 | .name = "DIT", | ||
29 | .playback = { | ||
30 | .stream_name = "Playback", | ||
31 | .channels_min = 1, | ||
32 | .channels_max = 384, | ||
33 | .rates = STUB_RATES, | ||
34 | .formats = STUB_FORMATS, | ||
35 | }, | ||
36 | }; | ||
37 | |||
38 | static int spdif_dit_probe(struct platform_device *pdev) | ||
39 | { | ||
40 | dit_stub_dai.dev = &pdev->dev; | ||
41 | return snd_soc_register_dai(&dit_stub_dai); | ||
42 | } | ||
43 | |||
44 | static int spdif_dit_remove(struct platform_device *pdev) | ||
45 | { | ||
46 | snd_soc_unregister_dai(&dit_stub_dai); | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static struct platform_driver spdif_dit_driver = { | ||
51 | .probe = spdif_dit_probe, | ||
52 | .remove = spdif_dit_remove, | ||
53 | .driver = { | ||
54 | .name = "spdif-dit", | ||
55 | .owner = THIS_MODULE, | ||
56 | }, | ||
57 | }; | ||
58 | |||
59 | static int __init dit_modinit(void) | ||
60 | { | ||
61 | return platform_driver_register(&spdif_dit_driver); | ||
62 | } | ||
63 | |||
64 | static void __exit dit_exit(void) | ||
65 | { | ||
66 | platform_driver_unregister(&spdif_dit_driver); | ||
67 | } | ||
68 | |||
69 | module_init(dit_modinit); | ||
70 | module_exit(dit_exit); | ||
71 | |||
diff --git a/sound/soc/codecs/spdif_transciever.h b/sound/soc/codecs/spdif_transciever.h new file mode 100644 index 000000000000..296f2eb6c4ef --- /dev/null +++ b/sound/soc/codecs/spdif_transciever.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* | ||
2 | * ALSA SoC DIT/DIR driver header | ||
3 | * | ||
4 | * Author: Steve Chen, <schen@mvista.com> | ||
5 | * Copyright: (C) 2008 MontaVista Software, Inc., <source@mvista.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef CODEC_STUBS_H | ||
13 | #define CODEC_STUBS_H | ||
14 | |||
15 | extern struct snd_soc_dai dit_stub_dai; | ||
16 | |||
17 | #endif /* CODEC_STUBS_H */ | ||
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 87f606c76822..c550750c79c0 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c | |||
@@ -336,15 +336,17 @@ static int ssm2602_startup(struct snd_pcm_substream *substream, | |||
336 | master_runtime->sample_bits, | 336 | master_runtime->sample_bits, |
337 | master_runtime->rate); | 337 | master_runtime->rate); |
338 | 338 | ||
339 | snd_pcm_hw_constraint_minmax(substream->runtime, | 339 | if (master_runtime->rate != 0) |
340 | SNDRV_PCM_HW_PARAM_RATE, | 340 | snd_pcm_hw_constraint_minmax(substream->runtime, |
341 | master_runtime->rate, | 341 | SNDRV_PCM_HW_PARAM_RATE, |
342 | master_runtime->rate); | 342 | master_runtime->rate, |
343 | 343 | master_runtime->rate); | |
344 | snd_pcm_hw_constraint_minmax(substream->runtime, | 344 | |
345 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, | 345 | if (master_runtime->sample_bits != 0) |
346 | master_runtime->sample_bits, | 346 | snd_pcm_hw_constraint_minmax(substream->runtime, |
347 | master_runtime->sample_bits); | 347 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, |
348 | master_runtime->sample_bits, | ||
349 | master_runtime->sample_bits); | ||
348 | 350 | ||
349 | ssm2602->slave_substream = substream; | 351 | ssm2602->slave_substream = substream; |
350 | } else | 352 | } else |
@@ -372,6 +374,7 @@ static void ssm2602_shutdown(struct snd_pcm_substream *substream, | |||
372 | struct snd_soc_device *socdev = rtd->socdev; | 374 | struct snd_soc_device *socdev = rtd->socdev; |
373 | struct snd_soc_codec *codec = socdev->card->codec; | 375 | struct snd_soc_codec *codec = socdev->card->codec; |
374 | struct ssm2602_priv *ssm2602 = codec->private_data; | 376 | struct ssm2602_priv *ssm2602 = codec->private_data; |
377 | |||
375 | /* deactivate */ | 378 | /* deactivate */ |
376 | if (!codec->active) | 379 | if (!codec->active) |
377 | ssm2602_write(codec, SSM2602_ACTIVE, 0); | 380 | ssm2602_write(codec, SSM2602_ACTIVE, 0); |
@@ -497,11 +500,9 @@ static int ssm2602_set_bias_level(struct snd_soc_codec *codec, | |||
497 | return 0; | 500 | return 0; |
498 | } | 501 | } |
499 | 502 | ||
500 | #define SSM2602_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ | 503 | #define SSM2602_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_32000 |\ |
501 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ | 504 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\ |
502 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\ | 505 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) |
503 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\ | ||
504 | SNDRV_PCM_RATE_96000) | ||
505 | 506 | ||
506 | #define SSM2602_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ | 507 | #define SSM2602_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ |
507 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) | 508 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) |
diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c new file mode 100644 index 000000000000..8ad4b7b3e3ba --- /dev/null +++ b/sound/soc/codecs/stac9766.c | |||
@@ -0,0 +1,463 @@ | |||
1 | /* | ||
2 | * stac9766.c -- ALSA SoC STAC9766 codec support | ||
3 | * | ||
4 | * Copyright 2009 Jon Smirl, Digispeaker | ||
5 | * Author: Jon Smirl <jonsmirl@gmail.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | * | ||
12 | * Features:- | ||
13 | * | ||
14 | * o Support for AC97 Codec, S/PDIF | ||
15 | */ | ||
16 | |||
17 | #include <linux/init.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/device.h> | ||
20 | #include <sound/core.h> | ||
21 | #include <sound/pcm.h> | ||
22 | #include <sound/ac97_codec.h> | ||
23 | #include <sound/initval.h> | ||
24 | #include <sound/pcm_params.h> | ||
25 | #include <sound/soc.h> | ||
26 | #include <sound/tlv.h> | ||
27 | #include <sound/soc-of-simple.h> | ||
28 | |||
29 | #include "stac9766.h" | ||
30 | |||
31 | #define STAC9766_VERSION "0.10" | ||
32 | |||
33 | /* | ||
34 | * STAC9766 register cache | ||
35 | */ | ||
36 | static const u16 stac9766_reg[] = { | ||
37 | 0x6A90, 0x8000, 0x8000, 0x8000, /* 6 */ | ||
38 | 0x0000, 0x0000, 0x8008, 0x8008, /* e */ | ||
39 | 0x8808, 0x8808, 0x8808, 0x8808, /* 16 */ | ||
40 | 0x8808, 0x0000, 0x8000, 0x0000, /* 1e */ | ||
41 | 0x0000, 0x0000, 0x0000, 0x000f, /* 26 */ | ||
42 | 0x0a05, 0x0400, 0xbb80, 0x0000, /* 2e */ | ||
43 | 0x0000, 0xbb80, 0x0000, 0x0000, /* 36 */ | ||
44 | 0x0000, 0x2000, 0x0000, 0x0100, /* 3e */ | ||
45 | 0x0000, 0x0000, 0x0080, 0x0000, /* 46 */ | ||
46 | 0x0000, 0x0000, 0x0003, 0xffff, /* 4e */ | ||
47 | 0x0000, 0x0000, 0x0000, 0x0000, /* 56 */ | ||
48 | 0x4000, 0x0000, 0x0000, 0x0000, /* 5e */ | ||
49 | 0x1201, 0xFFFF, 0xFFFF, 0x0000, /* 66 */ | ||
50 | 0x0000, 0x0000, 0x0000, 0x0000, /* 6e */ | ||
51 | 0x0000, 0x0000, 0x0000, 0x0006, /* 76 */ | ||
52 | 0x0000, 0x0000, 0x0000, 0x0000, /* 7e */ | ||
53 | }; | ||
54 | |||
55 | static const char *stac9766_record_mux[] = {"Mic", "CD", "Video", "AUX", | ||
56 | "Line", "Stereo Mix", "Mono Mix", "Phone"}; | ||
57 | static const char *stac9766_mono_mux[] = {"Mix", "Mic"}; | ||
58 | static const char *stac9766_mic_mux[] = {"Mic1", "Mic2"}; | ||
59 | static const char *stac9766_SPDIF_mux[] = {"PCM", "ADC Record"}; | ||
60 | static const char *stac9766_popbypass_mux[] = {"Normal", "Bypass Mixer"}; | ||
61 | static const char *stac9766_record_all_mux[] = {"All analog", | ||
62 | "Analog plus DAC"}; | ||
63 | static const char *stac9766_boost1[] = {"0dB", "10dB"}; | ||
64 | static const char *stac9766_boost2[] = {"0dB", "20dB"}; | ||
65 | static const char *stac9766_stereo_mic[] = {"Off", "On"}; | ||
66 | |||
67 | static const struct soc_enum stac9766_record_enum = | ||
68 | SOC_ENUM_DOUBLE(AC97_REC_SEL, 8, 0, 8, stac9766_record_mux); | ||
69 | static const struct soc_enum stac9766_mono_enum = | ||
70 | SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 9, 2, stac9766_mono_mux); | ||
71 | static const struct soc_enum stac9766_mic_enum = | ||
72 | SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 8, 2, stac9766_mic_mux); | ||
73 | static const struct soc_enum stac9766_SPDIF_enum = | ||
74 | SOC_ENUM_SINGLE(AC97_STAC_DA_CONTROL, 1, 2, stac9766_SPDIF_mux); | ||
75 | static const struct soc_enum stac9766_popbypass_enum = | ||
76 | SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 15, 2, stac9766_popbypass_mux); | ||
77 | static const struct soc_enum stac9766_record_all_enum = | ||
78 | SOC_ENUM_SINGLE(AC97_STAC_ANALOG_SPECIAL, 12, 2, | ||
79 | stac9766_record_all_mux); | ||
80 | static const struct soc_enum stac9766_boost1_enum = | ||
81 | SOC_ENUM_SINGLE(AC97_MIC, 6, 2, stac9766_boost1); /* 0/10dB */ | ||
82 | static const struct soc_enum stac9766_boost2_enum = | ||
83 | SOC_ENUM_SINGLE(AC97_STAC_ANALOG_SPECIAL, 2, 2, stac9766_boost2); /* 0/20dB */ | ||
84 | static const struct soc_enum stac9766_stereo_mic_enum = | ||
85 | SOC_ENUM_SINGLE(AC97_STAC_STEREO_MIC, 2, 1, stac9766_stereo_mic); | ||
86 | |||
87 | static const DECLARE_TLV_DB_LINEAR(master_tlv, -4600, 0); | ||
88 | static const DECLARE_TLV_DB_LINEAR(record_tlv, 0, 2250); | ||
89 | static const DECLARE_TLV_DB_LINEAR(beep_tlv, -4500, 0); | ||
90 | static const DECLARE_TLV_DB_LINEAR(mix_tlv, -3450, 1200); | ||
91 | |||
92 | static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = { | ||
93 | SOC_DOUBLE_TLV("Speaker Volume", AC97_MASTER, 8, 0, 31, 1, master_tlv), | ||
94 | SOC_SINGLE("Speaker Switch", AC97_MASTER, 15, 1, 1), | ||
95 | SOC_DOUBLE_TLV("Headphone Volume", AC97_HEADPHONE, 8, 0, 31, 1, | ||
96 | master_tlv), | ||
97 | SOC_SINGLE("Headphone Switch", AC97_HEADPHONE, 15, 1, 1), | ||
98 | SOC_SINGLE_TLV("Mono Out Volume", AC97_MASTER_MONO, 0, 31, 1, | ||
99 | master_tlv), | ||
100 | SOC_SINGLE("Mono Out Switch", AC97_MASTER_MONO, 15, 1, 1), | ||
101 | |||
102 | SOC_DOUBLE_TLV("Record Volume", AC97_REC_GAIN, 8, 0, 15, 0, record_tlv), | ||
103 | SOC_SINGLE("Record Switch", AC97_REC_GAIN, 15, 1, 1), | ||
104 | |||
105 | |||
106 | SOC_SINGLE_TLV("Beep Volume", AC97_PC_BEEP, 1, 15, 1, beep_tlv), | ||
107 | SOC_SINGLE("Beep Switch", AC97_PC_BEEP, 15, 1, 1), | ||
108 | SOC_SINGLE("Beep Frequency", AC97_PC_BEEP, 5, 127, 1), | ||
109 | SOC_SINGLE_TLV("Phone Volume", AC97_PHONE, 0, 31, 1, mix_tlv), | ||
110 | SOC_SINGLE("Phone Switch", AC97_PHONE, 15, 1, 1), | ||
111 | |||
112 | SOC_ENUM("Mic Boost1", stac9766_boost1_enum), | ||
113 | SOC_ENUM("Mic Boost2", stac9766_boost2_enum), | ||
114 | SOC_SINGLE_TLV("Mic Volume", AC97_MIC, 0, 31, 1, mix_tlv), | ||
115 | SOC_SINGLE("Mic Switch", AC97_MIC, 15, 1, 1), | ||
116 | SOC_ENUM("Stereo Mic", stac9766_stereo_mic_enum), | ||
117 | |||
118 | SOC_DOUBLE_TLV("Line Volume", AC97_LINE, 8, 0, 31, 1, mix_tlv), | ||
119 | SOC_SINGLE("Line Switch", AC97_LINE, 15, 1, 1), | ||
120 | SOC_DOUBLE_TLV("CD Volume", AC97_CD, 8, 0, 31, 1, mix_tlv), | ||
121 | SOC_SINGLE("CD Switch", AC97_CD, 15, 1, 1), | ||
122 | SOC_DOUBLE_TLV("AUX Volume", AC97_AUX, 8, 0, 31, 1, mix_tlv), | ||
123 | SOC_SINGLE("AUX Switch", AC97_AUX, 15, 1, 1), | ||
124 | SOC_DOUBLE_TLV("Video Volume", AC97_VIDEO, 8, 0, 31, 1, mix_tlv), | ||
125 | SOC_SINGLE("Video Switch", AC97_VIDEO, 15, 1, 1), | ||
126 | |||
127 | SOC_DOUBLE_TLV("DAC Volume", AC97_PCM, 8, 0, 31, 1, mix_tlv), | ||
128 | SOC_SINGLE("DAC Switch", AC97_PCM, 15, 1, 1), | ||
129 | SOC_SINGLE("Loopback Test Switch", AC97_GENERAL_PURPOSE, 7, 1, 0), | ||
130 | SOC_SINGLE("3D Volume", AC97_3D_CONTROL, 3, 2, 1), | ||
131 | SOC_SINGLE("3D Switch", AC97_GENERAL_PURPOSE, 13, 1, 0), | ||
132 | |||
133 | SOC_ENUM("SPDIF Mux", stac9766_SPDIF_enum), | ||
134 | SOC_ENUM("Mic1/2 Mux", stac9766_mic_enum), | ||
135 | SOC_ENUM("Record All Mux", stac9766_record_all_enum), | ||
136 | SOC_ENUM("Record Mux", stac9766_record_enum), | ||
137 | SOC_ENUM("Mono Mux", stac9766_mono_enum), | ||
138 | SOC_ENUM("Pop Bypass Mux", stac9766_popbypass_enum), | ||
139 | }; | ||
140 | |||
141 | static int stac9766_ac97_write(struct snd_soc_codec *codec, unsigned int reg, | ||
142 | unsigned int val) | ||
143 | { | ||
144 | u16 *cache = codec->reg_cache; | ||
145 | |||
146 | if (reg > AC97_STAC_PAGE0) { | ||
147 | stac9766_ac97_write(codec, AC97_INT_PAGING, 0); | ||
148 | soc_ac97_ops.write(codec->ac97, reg, val); | ||
149 | stac9766_ac97_write(codec, AC97_INT_PAGING, 1); | ||
150 | return 0; | ||
151 | } | ||
152 | if (reg / 2 > ARRAY_SIZE(stac9766_reg)) | ||
153 | return -EIO; | ||
154 | |||
155 | soc_ac97_ops.write(codec->ac97, reg, val); | ||
156 | cache[reg / 2] = val; | ||
157 | return 0; | ||
158 | } | ||
159 | |||
160 | static unsigned int stac9766_ac97_read(struct snd_soc_codec *codec, | ||
161 | unsigned int reg) | ||
162 | { | ||
163 | u16 val = 0, *cache = codec->reg_cache; | ||
164 | |||
165 | if (reg > AC97_STAC_PAGE0) { | ||
166 | stac9766_ac97_write(codec, AC97_INT_PAGING, 0); | ||
167 | val = soc_ac97_ops.read(codec->ac97, reg - AC97_STAC_PAGE0); | ||
168 | stac9766_ac97_write(codec, AC97_INT_PAGING, 1); | ||
169 | return val; | ||
170 | } | ||
171 | if (reg / 2 > ARRAY_SIZE(stac9766_reg)) | ||
172 | return -EIO; | ||
173 | |||
174 | if (reg == AC97_RESET || reg == AC97_GPIO_STATUS || | ||
175 | reg == AC97_INT_PAGING || reg == AC97_VENDOR_ID1 || | ||
176 | reg == AC97_VENDOR_ID2) { | ||
177 | |||
178 | val = soc_ac97_ops.read(codec->ac97, reg); | ||
179 | return val; | ||
180 | } | ||
181 | return cache[reg / 2]; | ||
182 | } | ||
183 | |||
184 | static int ac97_analog_prepare(struct snd_pcm_substream *substream, | ||
185 | struct snd_soc_dai *dai) | ||
186 | { | ||
187 | struct snd_soc_codec *codec = dai->codec; | ||
188 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
189 | unsigned short reg, vra; | ||
190 | |||
191 | vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS); | ||
192 | |||
193 | vra |= 0x1; /* enable variable rate audio */ | ||
194 | |||
195 | stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra); | ||
196 | |||
197 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
198 | reg = AC97_PCM_FRONT_DAC_RATE; | ||
199 | else | ||
200 | reg = AC97_PCM_LR_ADC_RATE; | ||
201 | |||
202 | return stac9766_ac97_write(codec, reg, runtime->rate); | ||
203 | } | ||
204 | |||
205 | static int ac97_digital_prepare(struct snd_pcm_substream *substream, | ||
206 | struct snd_soc_dai *dai) | ||
207 | { | ||
208 | struct snd_soc_codec *codec = dai->codec; | ||
209 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
210 | unsigned short reg, vra; | ||
211 | |||
212 | stac9766_ac97_write(codec, AC97_SPDIF, 0x2002); | ||
213 | |||
214 | vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS); | ||
215 | vra |= 0x5; /* Enable VRA and SPDIF out */ | ||
216 | |||
217 | stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra); | ||
218 | |||
219 | reg = AC97_PCM_FRONT_DAC_RATE; | ||
220 | |||
221 | return stac9766_ac97_write(codec, reg, runtime->rate); | ||
222 | } | ||
223 | |||
224 | static int ac97_digital_trigger(struct snd_pcm_substream *substream, | ||
225 | int cmd, struct snd_soc_dai *dai) | ||
226 | { | ||
227 | struct snd_soc_codec *codec = dai->codec; | ||
228 | unsigned short vra; | ||
229 | |||
230 | switch (cmd) { | ||
231 | case SNDRV_PCM_TRIGGER_STOP: | ||
232 | vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS); | ||
233 | vra &= !0x04; | ||
234 | stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra); | ||
235 | break; | ||
236 | } | ||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int stac9766_set_bias_level(struct snd_soc_codec *codec, | ||
241 | enum snd_soc_bias_level level) | ||
242 | { | ||
243 | switch (level) { | ||
244 | case SND_SOC_BIAS_ON: /* full On */ | ||
245 | case SND_SOC_BIAS_PREPARE: /* partial On */ | ||
246 | case SND_SOC_BIAS_STANDBY: /* Off, with power */ | ||
247 | stac9766_ac97_write(codec, AC97_POWERDOWN, 0x0000); | ||
248 | break; | ||
249 | case SND_SOC_BIAS_OFF: /* Off, without power */ | ||
250 | /* disable everything including AC link */ | ||
251 | stac9766_ac97_write(codec, AC97_POWERDOWN, 0xffff); | ||
252 | break; | ||
253 | } | ||
254 | codec->bias_level = level; | ||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | static int stac9766_reset(struct snd_soc_codec *codec, int try_warm) | ||
259 | { | ||
260 | if (try_warm && soc_ac97_ops.warm_reset) { | ||
261 | soc_ac97_ops.warm_reset(codec->ac97); | ||
262 | if (stac9766_ac97_read(codec, 0) == stac9766_reg[0]) | ||
263 | return 1; | ||
264 | } | ||
265 | |||
266 | soc_ac97_ops.reset(codec->ac97); | ||
267 | if (soc_ac97_ops.warm_reset) | ||
268 | soc_ac97_ops.warm_reset(codec->ac97); | ||
269 | if (stac9766_ac97_read(codec, 0) != stac9766_reg[0]) | ||
270 | return -EIO; | ||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | static int stac9766_codec_suspend(struct platform_device *pdev, | ||
275 | pm_message_t state) | ||
276 | { | ||
277 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
278 | struct snd_soc_codec *codec = socdev->card->codec; | ||
279 | |||
280 | stac9766_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
281 | return 0; | ||
282 | } | ||
283 | |||
284 | static int stac9766_codec_resume(struct platform_device *pdev) | ||
285 | { | ||
286 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
287 | struct snd_soc_codec *codec = socdev->card->codec; | ||
288 | u16 id, reset; | ||
289 | |||
290 | reset = 0; | ||
291 | /* give the codec an AC97 warm reset to start the link */ | ||
292 | reset: | ||
293 | if (reset > 5) { | ||
294 | printk(KERN_ERR "stac9766 failed to resume"); | ||
295 | return -EIO; | ||
296 | } | ||
297 | codec->ac97->bus->ops->warm_reset(codec->ac97); | ||
298 | id = soc_ac97_ops.read(codec->ac97, AC97_VENDOR_ID2); | ||
299 | if (id != 0x4c13) { | ||
300 | stac9766_reset(codec, 0); | ||
301 | reset++; | ||
302 | goto reset; | ||
303 | } | ||
304 | stac9766_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
305 | |||
306 | if (codec->suspend_bias_level == SND_SOC_BIAS_ON) | ||
307 | stac9766_set_bias_level(codec, SND_SOC_BIAS_ON); | ||
308 | |||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | static struct snd_soc_dai_ops stac9766_dai_ops_analog = { | ||
313 | .prepare = ac97_analog_prepare, | ||
314 | }; | ||
315 | |||
316 | static struct snd_soc_dai_ops stac9766_dai_ops_digital = { | ||
317 | .prepare = ac97_digital_prepare, | ||
318 | .trigger = ac97_digital_trigger, | ||
319 | }; | ||
320 | |||
321 | struct snd_soc_dai stac9766_dai[] = { | ||
322 | { | ||
323 | .name = "stac9766 analog", | ||
324 | .id = 0, | ||
325 | .ac97_control = 1, | ||
326 | |||
327 | /* stream cababilities */ | ||
328 | .playback = { | ||
329 | .stream_name = "stac9766 analog", | ||
330 | .channels_min = 1, | ||
331 | .channels_max = 2, | ||
332 | .rates = SNDRV_PCM_RATE_8000_48000, | ||
333 | .formats = SND_SOC_STD_AC97_FMTS, | ||
334 | }, | ||
335 | .capture = { | ||
336 | .stream_name = "stac9766 analog", | ||
337 | .channels_min = 1, | ||
338 | .channels_max = 2, | ||
339 | .rates = SNDRV_PCM_RATE_8000_48000, | ||
340 | .formats = SND_SOC_STD_AC97_FMTS, | ||
341 | }, | ||
342 | /* alsa ops */ | ||
343 | .ops = &stac9766_dai_ops_analog, | ||
344 | }, | ||
345 | { | ||
346 | .name = "stac9766 IEC958", | ||
347 | .id = 1, | ||
348 | .ac97_control = 1, | ||
349 | |||
350 | /* stream cababilities */ | ||
351 | .playback = { | ||
352 | .stream_name = "stac9766 IEC958", | ||
353 | .channels_min = 1, | ||
354 | .channels_max = 2, | ||
355 | .rates = SNDRV_PCM_RATE_32000 | \ | ||
356 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, | ||
357 | .formats = SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE, | ||
358 | }, | ||
359 | /* alsa ops */ | ||
360 | .ops = &stac9766_dai_ops_digital, | ||
361 | } | ||
362 | }; | ||
363 | EXPORT_SYMBOL_GPL(stac9766_dai); | ||
364 | |||
365 | static int stac9766_codec_probe(struct platform_device *pdev) | ||
366 | { | ||
367 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
368 | struct snd_soc_codec *codec; | ||
369 | int ret = 0; | ||
370 | |||
371 | printk(KERN_INFO "STAC9766 SoC Audio Codec %s\n", STAC9766_VERSION); | ||
372 | |||
373 | socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); | ||
374 | if (socdev->card->codec == NULL) | ||
375 | return -ENOMEM; | ||
376 | codec = socdev->card->codec; | ||
377 | mutex_init(&codec->mutex); | ||
378 | |||
379 | codec->reg_cache = kmemdup(stac9766_reg, sizeof(stac9766_reg), | ||
380 | GFP_KERNEL); | ||
381 | if (codec->reg_cache == NULL) { | ||
382 | ret = -ENOMEM; | ||
383 | goto cache_err; | ||
384 | } | ||
385 | codec->reg_cache_size = sizeof(stac9766_reg); | ||
386 | codec->reg_cache_step = 2; | ||
387 | |||
388 | codec->name = "STAC9766"; | ||
389 | codec->owner = THIS_MODULE; | ||
390 | codec->dai = stac9766_dai; | ||
391 | codec->num_dai = ARRAY_SIZE(stac9766_dai); | ||
392 | codec->write = stac9766_ac97_write; | ||
393 | codec->read = stac9766_ac97_read; | ||
394 | codec->set_bias_level = stac9766_set_bias_level; | ||
395 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
396 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
397 | |||
398 | ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); | ||
399 | if (ret < 0) | ||
400 | goto codec_err; | ||
401 | |||
402 | /* register pcms */ | ||
403 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
404 | if (ret < 0) | ||
405 | goto pcm_err; | ||
406 | |||
407 | /* do a cold reset for the controller and then try | ||
408 | * a warm reset followed by an optional cold reset for codec */ | ||
409 | stac9766_reset(codec, 0); | ||
410 | ret = stac9766_reset(codec, 1); | ||
411 | if (ret < 0) { | ||
412 | printk(KERN_ERR "Failed to reset STAC9766: AC97 link error\n"); | ||
413 | goto reset_err; | ||
414 | } | ||
415 | |||
416 | stac9766_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
417 | |||
418 | snd_soc_add_controls(codec, stac9766_snd_ac97_controls, | ||
419 | ARRAY_SIZE(stac9766_snd_ac97_controls)); | ||
420 | |||
421 | ret = snd_soc_init_card(socdev); | ||
422 | if (ret < 0) | ||
423 | goto reset_err; | ||
424 | return 0; | ||
425 | |||
426 | reset_err: | ||
427 | snd_soc_free_pcms(socdev); | ||
428 | pcm_err: | ||
429 | snd_soc_free_ac97_codec(codec); | ||
430 | codec_err: | ||
431 | kfree(codec->private_data); | ||
432 | cache_err: | ||
433 | kfree(socdev->card->codec); | ||
434 | socdev->card->codec = NULL; | ||
435 | return ret; | ||
436 | } | ||
437 | |||
438 | static int stac9766_codec_remove(struct platform_device *pdev) | ||
439 | { | ||
440 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
441 | struct snd_soc_codec *codec = socdev->card->codec; | ||
442 | |||
443 | if (codec == NULL) | ||
444 | return 0; | ||
445 | |||
446 | snd_soc_free_pcms(socdev); | ||
447 | snd_soc_free_ac97_codec(codec); | ||
448 | kfree(codec->reg_cache); | ||
449 | kfree(codec); | ||
450 | return 0; | ||
451 | } | ||
452 | |||
453 | struct snd_soc_codec_device soc_codec_dev_stac9766 = { | ||
454 | .probe = stac9766_codec_probe, | ||
455 | .remove = stac9766_codec_remove, | ||
456 | .suspend = stac9766_codec_suspend, | ||
457 | .resume = stac9766_codec_resume, | ||
458 | }; | ||
459 | EXPORT_SYMBOL_GPL(soc_codec_dev_stac9766); | ||
460 | |||
461 | MODULE_DESCRIPTION("ASoC stac9766 driver"); | ||
462 | MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); | ||
463 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/stac9766.h b/sound/soc/codecs/stac9766.h new file mode 100644 index 000000000000..65642eb8393e --- /dev/null +++ b/sound/soc/codecs/stac9766.h | |||
@@ -0,0 +1,21 @@ | |||
1 | /* | ||
2 | * stac9766.h -- STAC9766 Soc Audio driver | ||
3 | */ | ||
4 | |||
5 | #ifndef _STAC9766_H | ||
6 | #define _STAC9766_H | ||
7 | |||
8 | #define AC97_STAC_PAGE0 0x1000 | ||
9 | #define AC97_STAC_DA_CONTROL (AC97_STAC_PAGE0 | 0x6A) | ||
10 | #define AC97_STAC_ANALOG_SPECIAL (AC97_STAC_PAGE0 | 0x6E) | ||
11 | #define AC97_STAC_STEREO_MIC 0x78 | ||
12 | |||
13 | /* STAC9766 DAI ID's */ | ||
14 | #define STAC9766_DAI_AC97_ANALOG 0 | ||
15 | #define STAC9766_DAI_AC97_DIGITAL 1 | ||
16 | |||
17 | extern struct snd_soc_dai stac9766_dai[]; | ||
18 | extern struct snd_soc_codec_device soc_codec_dev_stac9766; | ||
19 | |||
20 | |||
21 | #endif | ||
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index c3f4afb5d017..0b8dcb5cd729 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c | |||
@@ -86,7 +86,7 @@ static int tlv320aic23_write(struct snd_soc_codec *codec, unsigned int reg, | |||
86 | */ | 86 | */ |
87 | 87 | ||
88 | if ((reg < 0 || reg > 9) && (reg != 15)) { | 88 | if ((reg < 0 || reg > 9) && (reg != 15)) { |
89 | printk(KERN_WARNING "%s Invalid register R%d\n", __func__, reg); | 89 | printk(KERN_WARNING "%s Invalid register R%u\n", __func__, reg); |
90 | return -1; | 90 | return -1; |
91 | } | 91 | } |
92 | 92 | ||
@@ -98,7 +98,7 @@ static int tlv320aic23_write(struct snd_soc_codec *codec, unsigned int reg, | |||
98 | if (codec->hw_write(codec->control_data, data, 2) == 2) | 98 | if (codec->hw_write(codec->control_data, data, 2) == 2) |
99 | return 0; | 99 | return 0; |
100 | 100 | ||
101 | printk(KERN_ERR "%s cannot write %03x to register R%d\n", __func__, | 101 | printk(KERN_ERR "%s cannot write %03x to register R%u\n", __func__, |
102 | value, reg); | 102 | value, reg); |
103 | 103 | ||
104 | return -EIO; | 104 | return -EIO; |
@@ -273,14 +273,14 @@ static const unsigned short sr_valid_mask[] = { | |||
273 | * Every divisor is a factor of 11*12 | 273 | * Every divisor is a factor of 11*12 |
274 | */ | 274 | */ |
275 | #define SR_MULT (11*12) | 275 | #define SR_MULT (11*12) |
276 | #define A(x) (x) ? (SR_MULT/x) : 0 | 276 | #define A(x) (SR_MULT/x) |
277 | static const unsigned char sr_adc_mult_table[] = { | 277 | static const unsigned char sr_adc_mult_table[] = { |
278 | A(2), A(2), A(12), A(12), A(0), A(0), A(3), A(1), | 278 | A(2), A(2), A(12), A(12), 0, 0, A(3), A(1), |
279 | A(2), A(2), A(11), A(11), A(0), A(0), A(0), A(1) | 279 | A(2), A(2), A(11), A(11), 0, 0, 0, A(1) |
280 | }; | 280 | }; |
281 | static const unsigned char sr_dac_mult_table[] = { | 281 | static const unsigned char sr_dac_mult_table[] = { |
282 | A(2), A(12), A(2), A(12), A(0), A(0), A(3), A(1), | 282 | A(2), A(12), A(2), A(12), 0, 0, A(3), A(1), |
283 | A(2), A(11), A(2), A(11), A(0), A(0), A(0), A(1) | 283 | A(2), A(11), A(2), A(11), 0, 0, 0, A(1) |
284 | }; | 284 | }; |
285 | 285 | ||
286 | static unsigned get_score(int adc, int adc_l, int adc_h, int need_adc, | 286 | static unsigned get_score(int adc, int adc_l, int adc_h, int need_adc, |
@@ -523,6 +523,8 @@ static int tlv320aic23_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
523 | case SND_SOC_DAIFMT_I2S: | 523 | case SND_SOC_DAIFMT_I2S: |
524 | iface_reg |= TLV320AIC23_FOR_I2S; | 524 | iface_reg |= TLV320AIC23_FOR_I2S; |
525 | break; | 525 | break; |
526 | case SND_SOC_DAIFMT_DSP_A: | ||
527 | iface_reg |= TLV320AIC23_LRP_ON; | ||
526 | case SND_SOC_DAIFMT_DSP_B: | 528 | case SND_SOC_DAIFMT_DSP_B: |
527 | iface_reg |= TLV320AIC23_FOR_DSP; | 529 | iface_reg |= TLV320AIC23_FOR_DSP; |
528 | break; | 530 | break; |
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index df7c8c281d2f..4dbb853eef5a 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -115,6 +115,7 @@ static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = { | |||
115 | 0x00, /* REG_VIBRA_PWM_SET (0x47) */ | 115 | 0x00, /* REG_VIBRA_PWM_SET (0x47) */ |
116 | 0x00, /* REG_ANAMIC_GAIN (0x48) */ | 116 | 0x00, /* REG_ANAMIC_GAIN (0x48) */ |
117 | 0x00, /* REG_MISC_SET_2 (0x49) */ | 117 | 0x00, /* REG_MISC_SET_2 (0x49) */ |
118 | 0x00, /* REG_SW_SHADOW (0x4A) - Shadow, non HW register */ | ||
118 | }; | 119 | }; |
119 | 120 | ||
120 | /* codec private data */ | 121 | /* codec private data */ |
@@ -125,6 +126,17 @@ struct twl4030_priv { | |||
125 | 126 | ||
126 | struct snd_pcm_substream *master_substream; | 127 | struct snd_pcm_substream *master_substream; |
127 | struct snd_pcm_substream *slave_substream; | 128 | struct snd_pcm_substream *slave_substream; |
129 | |||
130 | unsigned int configured; | ||
131 | unsigned int rate; | ||
132 | unsigned int sample_bits; | ||
133 | unsigned int channels; | ||
134 | |||
135 | unsigned int sysclk; | ||
136 | |||
137 | /* Headset output state handling */ | ||
138 | unsigned int hsl_enabled; | ||
139 | unsigned int hsr_enabled; | ||
128 | }; | 140 | }; |
129 | 141 | ||
130 | /* | 142 | /* |
@@ -161,7 +173,11 @@ static int twl4030_write(struct snd_soc_codec *codec, | |||
161 | unsigned int reg, unsigned int value) | 173 | unsigned int reg, unsigned int value) |
162 | { | 174 | { |
163 | twl4030_write_reg_cache(codec, reg, value); | 175 | twl4030_write_reg_cache(codec, reg, value); |
164 | return twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, reg); | 176 | if (likely(reg < TWL4030_REG_SW_SHADOW)) |
177 | return twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, | ||
178 | reg); | ||
179 | else | ||
180 | return 0; | ||
165 | } | 181 | } |
166 | 182 | ||
167 | static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) | 183 | static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) |
@@ -188,6 +204,7 @@ static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) | |||
188 | 204 | ||
189 | static void twl4030_init_chip(struct snd_soc_codec *codec) | 205 | static void twl4030_init_chip(struct snd_soc_codec *codec) |
190 | { | 206 | { |
207 | u8 *cache = codec->reg_cache; | ||
191 | int i; | 208 | int i; |
192 | 209 | ||
193 | /* clear CODECPDZ prior to setting register defaults */ | 210 | /* clear CODECPDZ prior to setting register defaults */ |
@@ -195,7 +212,7 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) | |||
195 | 212 | ||
196 | /* set all audio section registers to reasonable defaults */ | 213 | /* set all audio section registers to reasonable defaults */ |
197 | for (i = TWL4030_REG_OPTION; i <= TWL4030_REG_MISC_SET_2; i++) | 214 | for (i = TWL4030_REG_OPTION; i <= TWL4030_REG_MISC_SET_2; i++) |
198 | twl4030_write(codec, i, twl4030_reg[i]); | 215 | twl4030_write(codec, i, cache[i]); |
199 | 216 | ||
200 | } | 217 | } |
201 | 218 | ||
@@ -232,7 +249,7 @@ static void twl4030_codec_mute(struct snd_soc_codec *codec, int mute) | |||
232 | TWL4030_REG_PRECKL_CTL); | 249 | TWL4030_REG_PRECKL_CTL); |
233 | reg_val = twl4030_read_reg_cache(codec, TWL4030_REG_PRECKR_CTL); | 250 | reg_val = twl4030_read_reg_cache(codec, TWL4030_REG_PRECKR_CTL); |
234 | twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, | 251 | twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, |
235 | reg_val & (~TWL4030_PRECKL_GAIN), | 252 | reg_val & (~TWL4030_PRECKR_GAIN), |
236 | TWL4030_REG_PRECKR_CTL); | 253 | TWL4030_REG_PRECKR_CTL); |
237 | 254 | ||
238 | /* Disable PLL */ | 255 | /* Disable PLL */ |
@@ -316,104 +333,60 @@ static void twl4030_power_down(struct snd_soc_codec *codec) | |||
316 | } | 333 | } |
317 | 334 | ||
318 | /* Earpiece */ | 335 | /* Earpiece */ |
319 | static const char *twl4030_earpiece_texts[] = | 336 | static const struct snd_kcontrol_new twl4030_dapm_earpiece_controls[] = { |
320 | {"Off", "DACL1", "DACL2", "DACR1"}; | 337 | SOC_DAPM_SINGLE("Voice", TWL4030_REG_EAR_CTL, 0, 1, 0), |
321 | 338 | SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_EAR_CTL, 1, 1, 0), | |
322 | static const unsigned int twl4030_earpiece_values[] = | 339 | SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_EAR_CTL, 2, 1, 0), |
323 | {0x0, 0x1, 0x2, 0x4}; | 340 | SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_EAR_CTL, 3, 1, 0), |
324 | 341 | }; | |
325 | static const struct soc_enum twl4030_earpiece_enum = | ||
326 | SOC_VALUE_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, 0x7, | ||
327 | ARRAY_SIZE(twl4030_earpiece_texts), | ||
328 | twl4030_earpiece_texts, | ||
329 | twl4030_earpiece_values); | ||
330 | |||
331 | static const struct snd_kcontrol_new twl4030_dapm_earpiece_control = | ||
332 | SOC_DAPM_VALUE_ENUM("Route", twl4030_earpiece_enum); | ||
333 | 342 | ||
334 | /* PreDrive Left */ | 343 | /* PreDrive Left */ |
335 | static const char *twl4030_predrivel_texts[] = | 344 | static const struct snd_kcontrol_new twl4030_dapm_predrivel_controls[] = { |
336 | {"Off", "DACL1", "DACL2", "DACR2"}; | 345 | SOC_DAPM_SINGLE("Voice", TWL4030_REG_PREDL_CTL, 0, 1, 0), |
337 | 346 | SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_PREDL_CTL, 1, 1, 0), | |
338 | static const unsigned int twl4030_predrivel_values[] = | 347 | SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_PREDL_CTL, 2, 1, 0), |
339 | {0x0, 0x1, 0x2, 0x4}; | 348 | SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_PREDL_CTL, 3, 1, 0), |
340 | 349 | }; | |
341 | static const struct soc_enum twl4030_predrivel_enum = | ||
342 | SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDL_CTL, 1, 0x7, | ||
343 | ARRAY_SIZE(twl4030_predrivel_texts), | ||
344 | twl4030_predrivel_texts, | ||
345 | twl4030_predrivel_values); | ||
346 | |||
347 | static const struct snd_kcontrol_new twl4030_dapm_predrivel_control = | ||
348 | SOC_DAPM_VALUE_ENUM("Route", twl4030_predrivel_enum); | ||
349 | 350 | ||
350 | /* PreDrive Right */ | 351 | /* PreDrive Right */ |
351 | static const char *twl4030_predriver_texts[] = | 352 | static const struct snd_kcontrol_new twl4030_dapm_predriver_controls[] = { |
352 | {"Off", "DACR1", "DACR2", "DACL2"}; | 353 | SOC_DAPM_SINGLE("Voice", TWL4030_REG_PREDR_CTL, 0, 1, 0), |
353 | 354 | SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_PREDR_CTL, 1, 1, 0), | |
354 | static const unsigned int twl4030_predriver_values[] = | 355 | SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_PREDR_CTL, 2, 1, 0), |
355 | {0x0, 0x1, 0x2, 0x4}; | 356 | SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_PREDR_CTL, 3, 1, 0), |
356 | 357 | }; | |
357 | static const struct soc_enum twl4030_predriver_enum = | ||
358 | SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, 0x7, | ||
359 | ARRAY_SIZE(twl4030_predriver_texts), | ||
360 | twl4030_predriver_texts, | ||
361 | twl4030_predriver_values); | ||
362 | |||
363 | static const struct snd_kcontrol_new twl4030_dapm_predriver_control = | ||
364 | SOC_DAPM_VALUE_ENUM("Route", twl4030_predriver_enum); | ||
365 | 358 | ||
366 | /* Headset Left */ | 359 | /* Headset Left */ |
367 | static const char *twl4030_hsol_texts[] = | 360 | static const struct snd_kcontrol_new twl4030_dapm_hsol_controls[] = { |
368 | {"Off", "DACL1", "DACL2"}; | 361 | SOC_DAPM_SINGLE("Voice", TWL4030_REG_HS_SEL, 0, 1, 0), |
369 | 362 | SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_HS_SEL, 1, 1, 0), | |
370 | static const struct soc_enum twl4030_hsol_enum = | 363 | SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_HS_SEL, 2, 1, 0), |
371 | SOC_ENUM_SINGLE(TWL4030_REG_HS_SEL, 1, | 364 | }; |
372 | ARRAY_SIZE(twl4030_hsol_texts), | ||
373 | twl4030_hsol_texts); | ||
374 | |||
375 | static const struct snd_kcontrol_new twl4030_dapm_hsol_control = | ||
376 | SOC_DAPM_ENUM("Route", twl4030_hsol_enum); | ||
377 | 365 | ||
378 | /* Headset Right */ | 366 | /* Headset Right */ |
379 | static const char *twl4030_hsor_texts[] = | 367 | static const struct snd_kcontrol_new twl4030_dapm_hsor_controls[] = { |
380 | {"Off", "DACR1", "DACR2"}; | 368 | SOC_DAPM_SINGLE("Voice", TWL4030_REG_HS_SEL, 3, 1, 0), |
381 | 369 | SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_HS_SEL, 4, 1, 0), | |
382 | static const struct soc_enum twl4030_hsor_enum = | 370 | SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_HS_SEL, 5, 1, 0), |
383 | SOC_ENUM_SINGLE(TWL4030_REG_HS_SEL, 4, | 371 | }; |
384 | ARRAY_SIZE(twl4030_hsor_texts), | ||
385 | twl4030_hsor_texts); | ||
386 | |||
387 | static const struct snd_kcontrol_new twl4030_dapm_hsor_control = | ||
388 | SOC_DAPM_ENUM("Route", twl4030_hsor_enum); | ||
389 | 372 | ||
390 | /* Carkit Left */ | 373 | /* Carkit Left */ |
391 | static const char *twl4030_carkitl_texts[] = | 374 | static const struct snd_kcontrol_new twl4030_dapm_carkitl_controls[] = { |
392 | {"Off", "DACL1", "DACL2"}; | 375 | SOC_DAPM_SINGLE("Voice", TWL4030_REG_PRECKL_CTL, 0, 1, 0), |
393 | 376 | SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_PRECKL_CTL, 1, 1, 0), | |
394 | static const struct soc_enum twl4030_carkitl_enum = | 377 | SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_PRECKL_CTL, 2, 1, 0), |
395 | SOC_ENUM_SINGLE(TWL4030_REG_PRECKL_CTL, 1, | 378 | }; |
396 | ARRAY_SIZE(twl4030_carkitl_texts), | ||
397 | twl4030_carkitl_texts); | ||
398 | |||
399 | static const struct snd_kcontrol_new twl4030_dapm_carkitl_control = | ||
400 | SOC_DAPM_ENUM("Route", twl4030_carkitl_enum); | ||
401 | 379 | ||
402 | /* Carkit Right */ | 380 | /* Carkit Right */ |
403 | static const char *twl4030_carkitr_texts[] = | 381 | static const struct snd_kcontrol_new twl4030_dapm_carkitr_controls[] = { |
404 | {"Off", "DACR1", "DACR2"}; | 382 | SOC_DAPM_SINGLE("Voice", TWL4030_REG_PRECKR_CTL, 0, 1, 0), |
405 | 383 | SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_PRECKR_CTL, 1, 1, 0), | |
406 | static const struct soc_enum twl4030_carkitr_enum = | 384 | SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_PRECKR_CTL, 2, 1, 0), |
407 | SOC_ENUM_SINGLE(TWL4030_REG_PRECKR_CTL, 1, | 385 | }; |
408 | ARRAY_SIZE(twl4030_carkitr_texts), | ||
409 | twl4030_carkitr_texts); | ||
410 | |||
411 | static const struct snd_kcontrol_new twl4030_dapm_carkitr_control = | ||
412 | SOC_DAPM_ENUM("Route", twl4030_carkitr_enum); | ||
413 | 386 | ||
414 | /* Handsfree Left */ | 387 | /* Handsfree Left */ |
415 | static const char *twl4030_handsfreel_texts[] = | 388 | static const char *twl4030_handsfreel_texts[] = |
416 | {"Voice", "DACL1", "DACL2", "DACR2"}; | 389 | {"Voice", "AudioL1", "AudioL2", "AudioR2"}; |
417 | 390 | ||
418 | static const struct soc_enum twl4030_handsfreel_enum = | 391 | static const struct soc_enum twl4030_handsfreel_enum = |
419 | SOC_ENUM_SINGLE(TWL4030_REG_HFL_CTL, 0, | 392 | SOC_ENUM_SINGLE(TWL4030_REG_HFL_CTL, 0, |
@@ -423,9 +396,13 @@ static const struct soc_enum twl4030_handsfreel_enum = | |||
423 | static const struct snd_kcontrol_new twl4030_dapm_handsfreel_control = | 396 | static const struct snd_kcontrol_new twl4030_dapm_handsfreel_control = |
424 | SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum); | 397 | SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum); |
425 | 398 | ||
399 | /* Handsfree Left virtual mute */ | ||
400 | static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control = | ||
401 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 0, 1, 0); | ||
402 | |||
426 | /* Handsfree Right */ | 403 | /* Handsfree Right */ |
427 | static const char *twl4030_handsfreer_texts[] = | 404 | static const char *twl4030_handsfreer_texts[] = |
428 | {"Voice", "DACR1", "DACR2", "DACL2"}; | 405 | {"Voice", "AudioR1", "AudioR2", "AudioL2"}; |
429 | 406 | ||
430 | static const struct soc_enum twl4030_handsfreer_enum = | 407 | static const struct soc_enum twl4030_handsfreer_enum = |
431 | SOC_ENUM_SINGLE(TWL4030_REG_HFR_CTL, 0, | 408 | SOC_ENUM_SINGLE(TWL4030_REG_HFR_CTL, 0, |
@@ -435,37 +412,48 @@ static const struct soc_enum twl4030_handsfreer_enum = | |||
435 | static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control = | 412 | static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control = |
436 | SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); | 413 | SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); |
437 | 414 | ||
438 | /* Left analog microphone selection */ | 415 | /* Handsfree Right virtual mute */ |
439 | static const char *twl4030_analoglmic_texts[] = | 416 | static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control = |
440 | {"Off", "Main mic", "Headset mic", "AUXL", "Carkit mic"}; | 417 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 1, 1, 0); |
441 | 418 | ||
442 | static const unsigned int twl4030_analoglmic_values[] = | 419 | /* Vibra */ |
443 | {0x0, 0x1, 0x2, 0x4, 0x8}; | 420 | /* Vibra audio path selection */ |
421 | static const char *twl4030_vibra_texts[] = | ||
422 | {"AudioL1", "AudioR1", "AudioL2", "AudioR2"}; | ||
444 | 423 | ||
445 | static const struct soc_enum twl4030_analoglmic_enum = | 424 | static const struct soc_enum twl4030_vibra_enum = |
446 | SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICL, 0, 0xf, | 425 | SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 2, |
447 | ARRAY_SIZE(twl4030_analoglmic_texts), | 426 | ARRAY_SIZE(twl4030_vibra_texts), |
448 | twl4030_analoglmic_texts, | 427 | twl4030_vibra_texts); |
449 | twl4030_analoglmic_values); | ||
450 | 428 | ||
451 | static const struct snd_kcontrol_new twl4030_dapm_analoglmic_control = | 429 | static const struct snd_kcontrol_new twl4030_dapm_vibra_control = |
452 | SOC_DAPM_VALUE_ENUM("Route", twl4030_analoglmic_enum); | 430 | SOC_DAPM_ENUM("Route", twl4030_vibra_enum); |
453 | 431 | ||
454 | /* Right analog microphone selection */ | 432 | /* Vibra path selection: local vibrator (PWM) or audio driven */ |
455 | static const char *twl4030_analogrmic_texts[] = | 433 | static const char *twl4030_vibrapath_texts[] = |
456 | {"Off", "Sub mic", "AUXR"}; | 434 | {"Local vibrator", "Audio"}; |
457 | 435 | ||
458 | static const unsigned int twl4030_analogrmic_values[] = | 436 | static const struct soc_enum twl4030_vibrapath_enum = |
459 | {0x0, 0x1, 0x4}; | 437 | SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 4, |
438 | ARRAY_SIZE(twl4030_vibrapath_texts), | ||
439 | twl4030_vibrapath_texts); | ||
460 | 440 | ||
461 | static const struct soc_enum twl4030_analogrmic_enum = | 441 | static const struct snd_kcontrol_new twl4030_dapm_vibrapath_control = |
462 | SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICR, 0, 0x5, | 442 | SOC_DAPM_ENUM("Route", twl4030_vibrapath_enum); |
463 | ARRAY_SIZE(twl4030_analogrmic_texts), | ||
464 | twl4030_analogrmic_texts, | ||
465 | twl4030_analogrmic_values); | ||
466 | 443 | ||
467 | static const struct snd_kcontrol_new twl4030_dapm_analogrmic_control = | 444 | /* Left analog microphone selection */ |
468 | SOC_DAPM_VALUE_ENUM("Route", twl4030_analogrmic_enum); | 445 | static const struct snd_kcontrol_new twl4030_dapm_analoglmic_controls[] = { |
446 | SOC_DAPM_SINGLE("Main mic", TWL4030_REG_ANAMICL, 0, 1, 0), | ||
447 | SOC_DAPM_SINGLE("Headset mic", TWL4030_REG_ANAMICL, 1, 1, 0), | ||
448 | SOC_DAPM_SINGLE("AUXL", TWL4030_REG_ANAMICL, 2, 1, 0), | ||
449 | SOC_DAPM_SINGLE("Carkit mic", TWL4030_REG_ANAMICL, 3, 1, 0), | ||
450 | }; | ||
451 | |||
452 | /* Right analog microphone selection */ | ||
453 | static const struct snd_kcontrol_new twl4030_dapm_analogrmic_controls[] = { | ||
454 | SOC_DAPM_SINGLE("Sub mic", TWL4030_REG_ANAMICR, 0, 1, 0), | ||
455 | SOC_DAPM_SINGLE("AUXR", TWL4030_REG_ANAMICR, 2, 1, 0), | ||
456 | }; | ||
469 | 457 | ||
470 | /* TX1 L/R Analog/Digital microphone selection */ | 458 | /* TX1 L/R Analog/Digital microphone selection */ |
471 | static const char *twl4030_micpathtx1_texts[] = | 459 | static const char *twl4030_micpathtx1_texts[] = |
@@ -507,6 +495,10 @@ static const struct snd_kcontrol_new twl4030_dapm_abypassr2_control = | |||
507 | static const struct snd_kcontrol_new twl4030_dapm_abypassl2_control = | 495 | static const struct snd_kcontrol_new twl4030_dapm_abypassl2_control = |
508 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL2_APGA_CTL, 2, 1, 0); | 496 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL2_APGA_CTL, 2, 1, 0); |
509 | 497 | ||
498 | /* Analog bypass for Voice */ | ||
499 | static const struct snd_kcontrol_new twl4030_dapm_abypassv_control = | ||
500 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_VDL_APGA_CTL, 2, 1, 0); | ||
501 | |||
510 | /* Digital bypass gain, 0 mutes the bypass */ | 502 | /* Digital bypass gain, 0 mutes the bypass */ |
511 | static const unsigned int twl4030_dapm_dbypass_tlv[] = { | 503 | static const unsigned int twl4030_dapm_dbypass_tlv[] = { |
512 | TLV_DB_RANGE_HEAD(2), | 504 | TLV_DB_RANGE_HEAD(2), |
@@ -526,6 +518,18 @@ static const struct snd_kcontrol_new twl4030_dapm_dbypassr_control = | |||
526 | TWL4030_REG_ATX2ARXPGA, 0, 7, 0, | 518 | TWL4030_REG_ATX2ARXPGA, 0, 7, 0, |
527 | twl4030_dapm_dbypass_tlv); | 519 | twl4030_dapm_dbypass_tlv); |
528 | 520 | ||
521 | /* | ||
522 | * Voice Sidetone GAIN volume control: | ||
523 | * from -51 to -10 dB in 1 dB steps (mute instead of -51 dB) | ||
524 | */ | ||
525 | static DECLARE_TLV_DB_SCALE(twl4030_dapm_dbypassv_tlv, -5100, 100, 1); | ||
526 | |||
527 | /* Digital bypass voice: sidetone (VUL -> VDL)*/ | ||
528 | static const struct snd_kcontrol_new twl4030_dapm_dbypassv_control = | ||
529 | SOC_DAPM_SINGLE_TLV("Volume", | ||
530 | TWL4030_REG_VSTPGA, 0, 0x29, 0, | ||
531 | twl4030_dapm_dbypassv_tlv); | ||
532 | |||
529 | static int micpath_event(struct snd_soc_dapm_widget *w, | 533 | static int micpath_event(struct snd_soc_dapm_widget *w, |
530 | struct snd_kcontrol *kcontrol, int event) | 534 | struct snd_kcontrol *kcontrol, int event) |
531 | { | 535 | { |
@@ -556,63 +560,143 @@ static int micpath_event(struct snd_soc_dapm_widget *w, | |||
556 | return 0; | 560 | return 0; |
557 | } | 561 | } |
558 | 562 | ||
559 | static int handsfree_event(struct snd_soc_dapm_widget *w, | 563 | static void handsfree_ramp(struct snd_soc_codec *codec, int reg, int ramp) |
560 | struct snd_kcontrol *kcontrol, int event) | ||
561 | { | 564 | { |
562 | struct soc_enum *e = (struct soc_enum *)w->kcontrols->private_value; | ||
563 | unsigned char hs_ctl; | 565 | unsigned char hs_ctl; |
564 | 566 | ||
565 | hs_ctl = twl4030_read_reg_cache(w->codec, e->reg); | 567 | hs_ctl = twl4030_read_reg_cache(codec, reg); |
566 | 568 | ||
567 | if (hs_ctl & TWL4030_HF_CTL_REF_EN) { | 569 | if (ramp) { |
570 | /* HF ramp-up */ | ||
571 | hs_ctl |= TWL4030_HF_CTL_REF_EN; | ||
572 | twl4030_write(codec, reg, hs_ctl); | ||
573 | udelay(10); | ||
568 | hs_ctl |= TWL4030_HF_CTL_RAMP_EN; | 574 | hs_ctl |= TWL4030_HF_CTL_RAMP_EN; |
569 | twl4030_write(w->codec, e->reg, hs_ctl); | 575 | twl4030_write(codec, reg, hs_ctl); |
576 | udelay(40); | ||
570 | hs_ctl |= TWL4030_HF_CTL_LOOP_EN; | 577 | hs_ctl |= TWL4030_HF_CTL_LOOP_EN; |
571 | twl4030_write(w->codec, e->reg, hs_ctl); | ||
572 | hs_ctl |= TWL4030_HF_CTL_HB_EN; | 578 | hs_ctl |= TWL4030_HF_CTL_HB_EN; |
573 | twl4030_write(w->codec, e->reg, hs_ctl); | 579 | twl4030_write(codec, reg, hs_ctl); |
574 | } else { | 580 | } else { |
575 | hs_ctl &= ~(TWL4030_HF_CTL_RAMP_EN | TWL4030_HF_CTL_LOOP_EN | 581 | /* HF ramp-down */ |
576 | | TWL4030_HF_CTL_HB_EN); | 582 | hs_ctl &= ~TWL4030_HF_CTL_LOOP_EN; |
577 | twl4030_write(w->codec, e->reg, hs_ctl); | 583 | hs_ctl &= ~TWL4030_HF_CTL_HB_EN; |
584 | twl4030_write(codec, reg, hs_ctl); | ||
585 | hs_ctl &= ~TWL4030_HF_CTL_RAMP_EN; | ||
586 | twl4030_write(codec, reg, hs_ctl); | ||
587 | udelay(40); | ||
588 | hs_ctl &= ~TWL4030_HF_CTL_REF_EN; | ||
589 | twl4030_write(codec, reg, hs_ctl); | ||
578 | } | 590 | } |
591 | } | ||
579 | 592 | ||
593 | static int handsfreelpga_event(struct snd_soc_dapm_widget *w, | ||
594 | struct snd_kcontrol *kcontrol, int event) | ||
595 | { | ||
596 | switch (event) { | ||
597 | case SND_SOC_DAPM_POST_PMU: | ||
598 | handsfree_ramp(w->codec, TWL4030_REG_HFL_CTL, 1); | ||
599 | break; | ||
600 | case SND_SOC_DAPM_POST_PMD: | ||
601 | handsfree_ramp(w->codec, TWL4030_REG_HFL_CTL, 0); | ||
602 | break; | ||
603 | } | ||
580 | return 0; | 604 | return 0; |
581 | } | 605 | } |
582 | 606 | ||
583 | static int headsetl_event(struct snd_soc_dapm_widget *w, | 607 | static int handsfreerpga_event(struct snd_soc_dapm_widget *w, |
584 | struct snd_kcontrol *kcontrol, int event) | 608 | struct snd_kcontrol *kcontrol, int event) |
585 | { | 609 | { |
610 | switch (event) { | ||
611 | case SND_SOC_DAPM_POST_PMU: | ||
612 | handsfree_ramp(w->codec, TWL4030_REG_HFR_CTL, 1); | ||
613 | break; | ||
614 | case SND_SOC_DAPM_POST_PMD: | ||
615 | handsfree_ramp(w->codec, TWL4030_REG_HFR_CTL, 0); | ||
616 | break; | ||
617 | } | ||
618 | return 0; | ||
619 | } | ||
620 | |||
621 | static void headset_ramp(struct snd_soc_codec *codec, int ramp) | ||
622 | { | ||
586 | unsigned char hs_gain, hs_pop; | 623 | unsigned char hs_gain, hs_pop; |
624 | struct twl4030_priv *twl4030 = codec->private_data; | ||
625 | /* Base values for ramp delay calculation: 2^19 - 2^26 */ | ||
626 | unsigned int ramp_base[] = {524288, 1048576, 2097152, 4194304, | ||
627 | 8388608, 16777216, 33554432, 67108864}; | ||
587 | 628 | ||
588 | /* Save the current volume */ | 629 | hs_gain = twl4030_read_reg_cache(codec, TWL4030_REG_HS_GAIN_SET); |
589 | hs_gain = twl4030_read_reg_cache(w->codec, TWL4030_REG_HS_GAIN_SET); | 630 | hs_pop = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); |
590 | hs_pop = twl4030_read_reg_cache(w->codec, TWL4030_REG_HS_POPN_SET); | ||
591 | 631 | ||
592 | switch (event) { | 632 | if (ramp) { |
593 | case SND_SOC_DAPM_POST_PMU: | 633 | /* Headset ramp-up according to the TRM */ |
594 | /* Do the anti-pop/bias ramp enable according to the TRM */ | ||
595 | hs_pop |= TWL4030_VMID_EN; | 634 | hs_pop |= TWL4030_VMID_EN; |
596 | twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); | 635 | twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); |
597 | /* Is this needed? Can we just use whatever gain here? */ | 636 | twl4030_write(codec, TWL4030_REG_HS_GAIN_SET, hs_gain); |
598 | twl4030_write(w->codec, TWL4030_REG_HS_GAIN_SET, | ||
599 | (hs_gain & (~0x0f)) | 0x0a); | ||
600 | hs_pop |= TWL4030_RAMP_EN; | 637 | hs_pop |= TWL4030_RAMP_EN; |
601 | twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); | 638 | twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); |
602 | 639 | } else { | |
603 | /* Restore the original volume */ | 640 | /* Headset ramp-down _not_ according to |
604 | twl4030_write(w->codec, TWL4030_REG_HS_GAIN_SET, hs_gain); | 641 | * the TRM, but in a way that it is working */ |
605 | break; | ||
606 | case SND_SOC_DAPM_POST_PMD: | ||
607 | /* Do the anti-pop/bias ramp disable according to the TRM */ | ||
608 | hs_pop &= ~TWL4030_RAMP_EN; | 642 | hs_pop &= ~TWL4030_RAMP_EN; |
609 | twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); | 643 | twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); |
644 | /* Wait ramp delay time + 1, so the VMID can settle */ | ||
645 | mdelay((ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / | ||
646 | twl4030->sysclk) + 1); | ||
610 | /* Bypass the reg_cache to mute the headset */ | 647 | /* Bypass the reg_cache to mute the headset */ |
611 | twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, | 648 | twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, |
612 | hs_gain & (~0x0f), | 649 | hs_gain & (~0x0f), |
613 | TWL4030_REG_HS_GAIN_SET); | 650 | TWL4030_REG_HS_GAIN_SET); |
651 | |||
614 | hs_pop &= ~TWL4030_VMID_EN; | 652 | hs_pop &= ~TWL4030_VMID_EN; |
615 | twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); | 653 | twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); |
654 | } | ||
655 | } | ||
656 | |||
657 | static int headsetlpga_event(struct snd_soc_dapm_widget *w, | ||
658 | struct snd_kcontrol *kcontrol, int event) | ||
659 | { | ||
660 | struct twl4030_priv *twl4030 = w->codec->private_data; | ||
661 | |||
662 | switch (event) { | ||
663 | case SND_SOC_DAPM_POST_PMU: | ||
664 | /* Do the ramp-up only once */ | ||
665 | if (!twl4030->hsr_enabled) | ||
666 | headset_ramp(w->codec, 1); | ||
667 | |||
668 | twl4030->hsl_enabled = 1; | ||
669 | break; | ||
670 | case SND_SOC_DAPM_POST_PMD: | ||
671 | /* Do the ramp-down only if both headsetL/R is disabled */ | ||
672 | if (!twl4030->hsr_enabled) | ||
673 | headset_ramp(w->codec, 0); | ||
674 | |||
675 | twl4030->hsl_enabled = 0; | ||
676 | break; | ||
677 | } | ||
678 | return 0; | ||
679 | } | ||
680 | |||
681 | static int headsetrpga_event(struct snd_soc_dapm_widget *w, | ||
682 | struct snd_kcontrol *kcontrol, int event) | ||
683 | { | ||
684 | struct twl4030_priv *twl4030 = w->codec->private_data; | ||
685 | |||
686 | switch (event) { | ||
687 | case SND_SOC_DAPM_POST_PMU: | ||
688 | /* Do the ramp-up only once */ | ||
689 | if (!twl4030->hsl_enabled) | ||
690 | headset_ramp(w->codec, 1); | ||
691 | |||
692 | twl4030->hsr_enabled = 1; | ||
693 | break; | ||
694 | case SND_SOC_DAPM_POST_PMD: | ||
695 | /* Do the ramp-down only if both headsetL/R is disabled */ | ||
696 | if (!twl4030->hsl_enabled) | ||
697 | headset_ramp(w->codec, 0); | ||
698 | |||
699 | twl4030->hsr_enabled = 0; | ||
616 | break; | 700 | break; |
617 | } | 701 | } |
618 | return 0; | 702 | return 0; |
@@ -624,7 +708,7 @@ static int bypass_event(struct snd_soc_dapm_widget *w, | |||
624 | struct soc_mixer_control *m = | 708 | struct soc_mixer_control *m = |
625 | (struct soc_mixer_control *)w->kcontrols->private_value; | 709 | (struct soc_mixer_control *)w->kcontrols->private_value; |
626 | struct twl4030_priv *twl4030 = w->codec->private_data; | 710 | struct twl4030_priv *twl4030 = w->codec->private_data; |
627 | unsigned char reg; | 711 | unsigned char reg, misc; |
628 | 712 | ||
629 | reg = twl4030_read_reg_cache(w->codec, m->reg); | 713 | reg = twl4030_read_reg_cache(w->codec, m->reg); |
630 | 714 | ||
@@ -636,14 +720,34 @@ static int bypass_event(struct snd_soc_dapm_widget *w, | |||
636 | else | 720 | else |
637 | twl4030->bypass_state &= | 721 | twl4030->bypass_state &= |
638 | ~(1 << (m->reg - TWL4030_REG_ARXL1_APGA_CTL)); | 722 | ~(1 << (m->reg - TWL4030_REG_ARXL1_APGA_CTL)); |
723 | } else if (m->reg == TWL4030_REG_VDL_APGA_CTL) { | ||
724 | /* Analog voice bypass */ | ||
725 | if (reg & (1 << m->shift)) | ||
726 | twl4030->bypass_state |= (1 << 4); | ||
727 | else | ||
728 | twl4030->bypass_state &= ~(1 << 4); | ||
729 | } else if (m->reg == TWL4030_REG_VSTPGA) { | ||
730 | /* Voice digital bypass */ | ||
731 | if (reg) | ||
732 | twl4030->bypass_state |= (1 << 5); | ||
733 | else | ||
734 | twl4030->bypass_state &= ~(1 << 5); | ||
639 | } else { | 735 | } else { |
640 | /* Digital bypass */ | 736 | /* Digital bypass */ |
641 | if (reg & (0x7 << m->shift)) | 737 | if (reg & (0x7 << m->shift)) |
642 | twl4030->bypass_state |= (1 << (m->shift ? 5 : 4)); | 738 | twl4030->bypass_state |= (1 << (m->shift ? 7 : 6)); |
643 | else | 739 | else |
644 | twl4030->bypass_state &= ~(1 << (m->shift ? 5 : 4)); | 740 | twl4030->bypass_state &= ~(1 << (m->shift ? 7 : 6)); |
645 | } | 741 | } |
646 | 742 | ||
743 | /* Enable master analog loopback mode if any analog switch is enabled*/ | ||
744 | misc = twl4030_read_reg_cache(w->codec, TWL4030_REG_MISC_SET_1); | ||
745 | if (twl4030->bypass_state & 0x1F) | ||
746 | misc |= TWL4030_FMLOOP_EN; | ||
747 | else | ||
748 | misc &= ~TWL4030_FMLOOP_EN; | ||
749 | twl4030_write(w->codec, TWL4030_REG_MISC_SET_1, misc); | ||
750 | |||
647 | if (w->codec->bias_level == SND_SOC_BIAS_STANDBY) { | 751 | if (w->codec->bias_level == SND_SOC_BIAS_STANDBY) { |
648 | if (twl4030->bypass_state) | 752 | if (twl4030->bypass_state) |
649 | twl4030_codec_mute(w->codec, 0); | 753 | twl4030_codec_mute(w->codec, 0); |
@@ -810,6 +914,48 @@ static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, | |||
810 | return err; | 914 | return err; |
811 | } | 915 | } |
812 | 916 | ||
917 | /* Codec operation modes */ | ||
918 | static const char *twl4030_op_modes_texts[] = { | ||
919 | "Option 2 (voice/audio)", "Option 1 (audio)" | ||
920 | }; | ||
921 | |||
922 | static const struct soc_enum twl4030_op_modes_enum = | ||
923 | SOC_ENUM_SINGLE(TWL4030_REG_CODEC_MODE, 0, | ||
924 | ARRAY_SIZE(twl4030_op_modes_texts), | ||
925 | twl4030_op_modes_texts); | ||
926 | |||
927 | int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol, | ||
928 | struct snd_ctl_elem_value *ucontrol) | ||
929 | { | ||
930 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
931 | struct twl4030_priv *twl4030 = codec->private_data; | ||
932 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | ||
933 | unsigned short val; | ||
934 | unsigned short mask, bitmask; | ||
935 | |||
936 | if (twl4030->configured) { | ||
937 | printk(KERN_ERR "twl4030 operation mode cannot be " | ||
938 | "changed on-the-fly\n"); | ||
939 | return -EBUSY; | ||
940 | } | ||
941 | |||
942 | for (bitmask = 1; bitmask < e->max; bitmask <<= 1) | ||
943 | ; | ||
944 | if (ucontrol->value.enumerated.item[0] > e->max - 1) | ||
945 | return -EINVAL; | ||
946 | |||
947 | val = ucontrol->value.enumerated.item[0] << e->shift_l; | ||
948 | mask = (bitmask - 1) << e->shift_l; | ||
949 | if (e->shift_l != e->shift_r) { | ||
950 | if (ucontrol->value.enumerated.item[1] > e->max - 1) | ||
951 | return -EINVAL; | ||
952 | val |= ucontrol->value.enumerated.item[1] << e->shift_r; | ||
953 | mask |= (bitmask - 1) << e->shift_r; | ||
954 | } | ||
955 | |||
956 | return snd_soc_update_bits(codec, e->reg, mask, val); | ||
957 | } | ||
958 | |||
813 | /* | 959 | /* |
814 | * FGAIN volume control: | 960 | * FGAIN volume control: |
815 | * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB) | 961 | * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB) |
@@ -824,6 +970,12 @@ static DECLARE_TLV_DB_SCALE(digital_fine_tlv, -6300, 100, 1); | |||
824 | static DECLARE_TLV_DB_SCALE(digital_coarse_tlv, 0, 600, 0); | 970 | static DECLARE_TLV_DB_SCALE(digital_coarse_tlv, 0, 600, 0); |
825 | 971 | ||
826 | /* | 972 | /* |
973 | * Voice Downlink GAIN volume control: | ||
974 | * from -37 to 12 dB in 1 dB steps (mute instead of -37 dB) | ||
975 | */ | ||
976 | static DECLARE_TLV_DB_SCALE(digital_voice_downlink_tlv, -3700, 100, 1); | ||
977 | |||
978 | /* | ||
827 | * Analog playback gain | 979 | * Analog playback gain |
828 | * -24 dB to 12 dB in 2 dB steps | 980 | * -24 dB to 12 dB in 2 dB steps |
829 | */ | 981 | */ |
@@ -864,7 +1016,32 @@ static const struct soc_enum twl4030_rampdelay_enum = | |||
864 | ARRAY_SIZE(twl4030_rampdelay_texts), | 1016 | ARRAY_SIZE(twl4030_rampdelay_texts), |
865 | twl4030_rampdelay_texts); | 1017 | twl4030_rampdelay_texts); |
866 | 1018 | ||
1019 | /* Vibra H-bridge direction mode */ | ||
1020 | static const char *twl4030_vibradirmode_texts[] = { | ||
1021 | "Vibra H-bridge direction", "Audio data MSB", | ||
1022 | }; | ||
1023 | |||
1024 | static const struct soc_enum twl4030_vibradirmode_enum = | ||
1025 | SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 5, | ||
1026 | ARRAY_SIZE(twl4030_vibradirmode_texts), | ||
1027 | twl4030_vibradirmode_texts); | ||
1028 | |||
1029 | /* Vibra H-bridge direction */ | ||
1030 | static const char *twl4030_vibradir_texts[] = { | ||
1031 | "Positive polarity", "Negative polarity", | ||
1032 | }; | ||
1033 | |||
1034 | static const struct soc_enum twl4030_vibradir_enum = | ||
1035 | SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 1, | ||
1036 | ARRAY_SIZE(twl4030_vibradir_texts), | ||
1037 | twl4030_vibradir_texts); | ||
1038 | |||
867 | static const struct snd_kcontrol_new twl4030_snd_controls[] = { | 1039 | static const struct snd_kcontrol_new twl4030_snd_controls[] = { |
1040 | /* Codec operation mode control */ | ||
1041 | SOC_ENUM_EXT("Codec Operation Mode", twl4030_op_modes_enum, | ||
1042 | snd_soc_get_enum_double, | ||
1043 | snd_soc_put_twl4030_opmode_enum_double), | ||
1044 | |||
868 | /* Common playback gain controls */ | 1045 | /* Common playback gain controls */ |
869 | SOC_DOUBLE_R_TLV("DAC1 Digital Fine Playback Volume", | 1046 | SOC_DOUBLE_R_TLV("DAC1 Digital Fine Playback Volume", |
870 | TWL4030_REG_ARXL1PGA, TWL4030_REG_ARXR1PGA, | 1047 | TWL4030_REG_ARXL1PGA, TWL4030_REG_ARXR1PGA, |
@@ -893,6 +1070,16 @@ static const struct snd_kcontrol_new twl4030_snd_controls[] = { | |||
893 | TWL4030_REG_ARXL2_APGA_CTL, TWL4030_REG_ARXR2_APGA_CTL, | 1070 | TWL4030_REG_ARXL2_APGA_CTL, TWL4030_REG_ARXR2_APGA_CTL, |
894 | 1, 1, 0), | 1071 | 1, 1, 0), |
895 | 1072 | ||
1073 | /* Common voice downlink gain controls */ | ||
1074 | SOC_SINGLE_TLV("DAC Voice Digital Downlink Volume", | ||
1075 | TWL4030_REG_VRXPGA, 0, 0x31, 0, digital_voice_downlink_tlv), | ||
1076 | |||
1077 | SOC_SINGLE_TLV("DAC Voice Analog Downlink Volume", | ||
1078 | TWL4030_REG_VDL_APGA_CTL, 3, 0x12, 1, analog_tlv), | ||
1079 | |||
1080 | SOC_SINGLE("DAC Voice Analog Downlink Switch", | ||
1081 | TWL4030_REG_VDL_APGA_CTL, 1, 1, 0), | ||
1082 | |||
896 | /* Separate output gain controls */ | 1083 | /* Separate output gain controls */ |
897 | SOC_DOUBLE_R_TLV_TWL4030("PreDriv Playback Volume", | 1084 | SOC_DOUBLE_R_TLV_TWL4030("PreDriv Playback Volume", |
898 | TWL4030_REG_PREDL_CTL, TWL4030_REG_PREDR_CTL, | 1085 | TWL4030_REG_PREDL_CTL, TWL4030_REG_PREDR_CTL, |
@@ -920,6 +1107,9 @@ static const struct snd_kcontrol_new twl4030_snd_controls[] = { | |||
920 | 0, 3, 5, 0, input_gain_tlv), | 1107 | 0, 3, 5, 0, input_gain_tlv), |
921 | 1108 | ||
922 | SOC_ENUM("HS ramp delay", twl4030_rampdelay_enum), | 1109 | SOC_ENUM("HS ramp delay", twl4030_rampdelay_enum), |
1110 | |||
1111 | SOC_ENUM("Vibra H-bridge mode", twl4030_vibradirmode_enum), | ||
1112 | SOC_ENUM("Vibra H-bridge direction", twl4030_vibradir_enum), | ||
923 | }; | 1113 | }; |
924 | 1114 | ||
925 | static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | 1115 | static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { |
@@ -947,26 +1137,19 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | |||
947 | SND_SOC_DAPM_OUTPUT("CARKITR"), | 1137 | SND_SOC_DAPM_OUTPUT("CARKITR"), |
948 | SND_SOC_DAPM_OUTPUT("HFL"), | 1138 | SND_SOC_DAPM_OUTPUT("HFL"), |
949 | SND_SOC_DAPM_OUTPUT("HFR"), | 1139 | SND_SOC_DAPM_OUTPUT("HFR"), |
1140 | SND_SOC_DAPM_OUTPUT("VIBRA"), | ||
950 | 1141 | ||
951 | /* DACs */ | 1142 | /* DACs */ |
952 | SND_SOC_DAPM_DAC("DAC Right1", "Right Front Playback", | 1143 | SND_SOC_DAPM_DAC("DAC Right1", "Right Front HiFi Playback", |
953 | SND_SOC_NOPM, 0, 0), | 1144 | SND_SOC_NOPM, 0, 0), |
954 | SND_SOC_DAPM_DAC("DAC Left1", "Left Front Playback", | 1145 | SND_SOC_DAPM_DAC("DAC Left1", "Left Front HiFi Playback", |
955 | SND_SOC_NOPM, 0, 0), | 1146 | SND_SOC_NOPM, 0, 0), |
956 | SND_SOC_DAPM_DAC("DAC Right2", "Right Rear Playback", | 1147 | SND_SOC_DAPM_DAC("DAC Right2", "Right Rear HiFi Playback", |
957 | SND_SOC_NOPM, 0, 0), | 1148 | SND_SOC_NOPM, 0, 0), |
958 | SND_SOC_DAPM_DAC("DAC Left2", "Left Rear Playback", | 1149 | SND_SOC_DAPM_DAC("DAC Left2", "Left Rear HiFi Playback", |
1150 | SND_SOC_NOPM, 0, 0), | ||
1151 | SND_SOC_DAPM_DAC("DAC Voice", "Voice Playback", | ||
959 | SND_SOC_NOPM, 0, 0), | 1152 | SND_SOC_NOPM, 0, 0), |
960 | |||
961 | /* Analog PGAs */ | ||
962 | SND_SOC_DAPM_PGA("ARXR1_APGA", TWL4030_REG_ARXR1_APGA_CTL, | ||
963 | 0, 0, NULL, 0), | ||
964 | SND_SOC_DAPM_PGA("ARXL1_APGA", TWL4030_REG_ARXL1_APGA_CTL, | ||
965 | 0, 0, NULL, 0), | ||
966 | SND_SOC_DAPM_PGA("ARXR2_APGA", TWL4030_REG_ARXR2_APGA_CTL, | ||
967 | 0, 0, NULL, 0), | ||
968 | SND_SOC_DAPM_PGA("ARXL2_APGA", TWL4030_REG_ARXL2_APGA_CTL, | ||
969 | 0, 0, NULL, 0), | ||
970 | 1153 | ||
971 | /* Analog bypasses */ | 1154 | /* Analog bypasses */ |
972 | SND_SOC_DAPM_SWITCH_E("Right1 Analog Loopback", SND_SOC_NOPM, 0, 0, | 1155 | SND_SOC_DAPM_SWITCH_E("Right1 Analog Loopback", SND_SOC_NOPM, 0, 0, |
@@ -981,6 +1164,9 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | |||
981 | SND_SOC_DAPM_SWITCH_E("Left2 Analog Loopback", SND_SOC_NOPM, 0, 0, | 1164 | SND_SOC_DAPM_SWITCH_E("Left2 Analog Loopback", SND_SOC_NOPM, 0, 0, |
982 | &twl4030_dapm_abypassl2_control, | 1165 | &twl4030_dapm_abypassl2_control, |
983 | bypass_event, SND_SOC_DAPM_POST_REG), | 1166 | bypass_event, SND_SOC_DAPM_POST_REG), |
1167 | SND_SOC_DAPM_SWITCH_E("Voice Analog Loopback", SND_SOC_NOPM, 0, 0, | ||
1168 | &twl4030_dapm_abypassv_control, | ||
1169 | bypass_event, SND_SOC_DAPM_POST_REG), | ||
984 | 1170 | ||
985 | /* Digital bypasses */ | 1171 | /* Digital bypasses */ |
986 | SND_SOC_DAPM_SWITCH_E("Left Digital Loopback", SND_SOC_NOPM, 0, 0, | 1172 | SND_SOC_DAPM_SWITCH_E("Left Digital Loopback", SND_SOC_NOPM, 0, 0, |
@@ -989,43 +1175,88 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | |||
989 | SND_SOC_DAPM_SWITCH_E("Right Digital Loopback", SND_SOC_NOPM, 0, 0, | 1175 | SND_SOC_DAPM_SWITCH_E("Right Digital Loopback", SND_SOC_NOPM, 0, 0, |
990 | &twl4030_dapm_dbypassr_control, bypass_event, | 1176 | &twl4030_dapm_dbypassr_control, bypass_event, |
991 | SND_SOC_DAPM_POST_REG), | 1177 | SND_SOC_DAPM_POST_REG), |
1178 | SND_SOC_DAPM_SWITCH_E("Voice Digital Loopback", SND_SOC_NOPM, 0, 0, | ||
1179 | &twl4030_dapm_dbypassv_control, bypass_event, | ||
1180 | SND_SOC_DAPM_POST_REG), | ||
992 | 1181 | ||
993 | SND_SOC_DAPM_MIXER("Analog R1 Playback Mixer", TWL4030_REG_AVDAC_CTL, | 1182 | /* Digital mixers, power control for the physical DACs */ |
994 | 0, 0, NULL, 0), | 1183 | SND_SOC_DAPM_MIXER("Digital R1 Playback Mixer", |
995 | SND_SOC_DAPM_MIXER("Analog L1 Playback Mixer", TWL4030_REG_AVDAC_CTL, | 1184 | TWL4030_REG_AVDAC_CTL, 0, 0, NULL, 0), |
996 | 1, 0, NULL, 0), | 1185 | SND_SOC_DAPM_MIXER("Digital L1 Playback Mixer", |
997 | SND_SOC_DAPM_MIXER("Analog R2 Playback Mixer", TWL4030_REG_AVDAC_CTL, | 1186 | TWL4030_REG_AVDAC_CTL, 1, 0, NULL, 0), |
998 | 2, 0, NULL, 0), | 1187 | SND_SOC_DAPM_MIXER("Digital R2 Playback Mixer", |
999 | SND_SOC_DAPM_MIXER("Analog L2 Playback Mixer", TWL4030_REG_AVDAC_CTL, | 1188 | TWL4030_REG_AVDAC_CTL, 2, 0, NULL, 0), |
1000 | 3, 0, NULL, 0), | 1189 | SND_SOC_DAPM_MIXER("Digital L2 Playback Mixer", |
1001 | 1190 | TWL4030_REG_AVDAC_CTL, 3, 0, NULL, 0), | |
1002 | /* Output MUX controls */ | 1191 | SND_SOC_DAPM_MIXER("Digital Voice Playback Mixer", |
1192 | TWL4030_REG_AVDAC_CTL, 4, 0, NULL, 0), | ||
1193 | |||
1194 | /* Analog mixers, power control for the physical PGAs */ | ||
1195 | SND_SOC_DAPM_MIXER("Analog R1 Playback Mixer", | ||
1196 | TWL4030_REG_ARXR1_APGA_CTL, 0, 0, NULL, 0), | ||
1197 | SND_SOC_DAPM_MIXER("Analog L1 Playback Mixer", | ||
1198 | TWL4030_REG_ARXL1_APGA_CTL, 0, 0, NULL, 0), | ||
1199 | SND_SOC_DAPM_MIXER("Analog R2 Playback Mixer", | ||
1200 | TWL4030_REG_ARXR2_APGA_CTL, 0, 0, NULL, 0), | ||
1201 | SND_SOC_DAPM_MIXER("Analog L2 Playback Mixer", | ||
1202 | TWL4030_REG_ARXL2_APGA_CTL, 0, 0, NULL, 0), | ||
1203 | SND_SOC_DAPM_MIXER("Analog Voice Playback Mixer", | ||
1204 | TWL4030_REG_VDL_APGA_CTL, 0, 0, NULL, 0), | ||
1205 | |||
1206 | /* Output MIXER controls */ | ||
1003 | /* Earpiece */ | 1207 | /* Earpiece */ |
1004 | SND_SOC_DAPM_VALUE_MUX("Earpiece Mux", SND_SOC_NOPM, 0, 0, | 1208 | SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM, 0, 0, |
1005 | &twl4030_dapm_earpiece_control), | 1209 | &twl4030_dapm_earpiece_controls[0], |
1210 | ARRAY_SIZE(twl4030_dapm_earpiece_controls)), | ||
1006 | /* PreDrivL/R */ | 1211 | /* PreDrivL/R */ |
1007 | SND_SOC_DAPM_VALUE_MUX("PredriveL Mux", SND_SOC_NOPM, 0, 0, | 1212 | SND_SOC_DAPM_MIXER("PredriveL Mixer", SND_SOC_NOPM, 0, 0, |
1008 | &twl4030_dapm_predrivel_control), | 1213 | &twl4030_dapm_predrivel_controls[0], |
1009 | SND_SOC_DAPM_VALUE_MUX("PredriveR Mux", SND_SOC_NOPM, 0, 0, | 1214 | ARRAY_SIZE(twl4030_dapm_predrivel_controls)), |
1010 | &twl4030_dapm_predriver_control), | 1215 | SND_SOC_DAPM_MIXER("PredriveR Mixer", SND_SOC_NOPM, 0, 0, |
1216 | &twl4030_dapm_predriver_controls[0], | ||
1217 | ARRAY_SIZE(twl4030_dapm_predriver_controls)), | ||
1011 | /* HeadsetL/R */ | 1218 | /* HeadsetL/R */ |
1012 | SND_SOC_DAPM_MUX_E("HeadsetL Mux", SND_SOC_NOPM, 0, 0, | 1219 | SND_SOC_DAPM_MIXER("HeadsetL Mixer", SND_SOC_NOPM, 0, 0, |
1013 | &twl4030_dapm_hsol_control, headsetl_event, | 1220 | &twl4030_dapm_hsol_controls[0], |
1014 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | 1221 | ARRAY_SIZE(twl4030_dapm_hsol_controls)), |
1015 | SND_SOC_DAPM_MUX("HeadsetR Mux", SND_SOC_NOPM, 0, 0, | 1222 | SND_SOC_DAPM_PGA_E("HeadsetL PGA", SND_SOC_NOPM, |
1016 | &twl4030_dapm_hsor_control), | 1223 | 0, 0, NULL, 0, headsetlpga_event, |
1224 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | ||
1225 | SND_SOC_DAPM_MIXER("HeadsetR Mixer", SND_SOC_NOPM, 0, 0, | ||
1226 | &twl4030_dapm_hsor_controls[0], | ||
1227 | ARRAY_SIZE(twl4030_dapm_hsor_controls)), | ||
1228 | SND_SOC_DAPM_PGA_E("HeadsetR PGA", SND_SOC_NOPM, | ||
1229 | 0, 0, NULL, 0, headsetrpga_event, | ||
1230 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | ||
1017 | /* CarkitL/R */ | 1231 | /* CarkitL/R */ |
1018 | SND_SOC_DAPM_MUX("CarkitL Mux", SND_SOC_NOPM, 0, 0, | 1232 | SND_SOC_DAPM_MIXER("CarkitL Mixer", SND_SOC_NOPM, 0, 0, |
1019 | &twl4030_dapm_carkitl_control), | 1233 | &twl4030_dapm_carkitl_controls[0], |
1020 | SND_SOC_DAPM_MUX("CarkitR Mux", SND_SOC_NOPM, 0, 0, | 1234 | ARRAY_SIZE(twl4030_dapm_carkitl_controls)), |
1021 | &twl4030_dapm_carkitr_control), | 1235 | SND_SOC_DAPM_MIXER("CarkitR Mixer", SND_SOC_NOPM, 0, 0, |
1236 | &twl4030_dapm_carkitr_controls[0], | ||
1237 | ARRAY_SIZE(twl4030_dapm_carkitr_controls)), | ||
1238 | |||
1239 | /* Output MUX controls */ | ||
1022 | /* HandsfreeL/R */ | 1240 | /* HandsfreeL/R */ |
1023 | SND_SOC_DAPM_MUX_E("HandsfreeL Mux", TWL4030_REG_HFL_CTL, 5, 0, | 1241 | SND_SOC_DAPM_MUX("HandsfreeL Mux", SND_SOC_NOPM, 0, 0, |
1024 | &twl4030_dapm_handsfreel_control, handsfree_event, | 1242 | &twl4030_dapm_handsfreel_control), |
1025 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | 1243 | SND_SOC_DAPM_SWITCH("HandsfreeL Switch", SND_SOC_NOPM, 0, 0, |
1026 | SND_SOC_DAPM_MUX_E("HandsfreeR Mux", TWL4030_REG_HFR_CTL, 5, 0, | 1244 | &twl4030_dapm_handsfreelmute_control), |
1027 | &twl4030_dapm_handsfreer_control, handsfree_event, | 1245 | SND_SOC_DAPM_PGA_E("HandsfreeL PGA", SND_SOC_NOPM, |
1028 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | 1246 | 0, 0, NULL, 0, handsfreelpga_event, |
1247 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | ||
1248 | SND_SOC_DAPM_MUX("HandsfreeR Mux", SND_SOC_NOPM, 5, 0, | ||
1249 | &twl4030_dapm_handsfreer_control), | ||
1250 | SND_SOC_DAPM_SWITCH("HandsfreeR Switch", SND_SOC_NOPM, 0, 0, | ||
1251 | &twl4030_dapm_handsfreermute_control), | ||
1252 | SND_SOC_DAPM_PGA_E("HandsfreeR PGA", SND_SOC_NOPM, | ||
1253 | 0, 0, NULL, 0, handsfreerpga_event, | ||
1254 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | ||
1255 | /* Vibra */ | ||
1256 | SND_SOC_DAPM_MUX("Vibra Mux", TWL4030_REG_VIBRA_CTL, 0, 0, | ||
1257 | &twl4030_dapm_vibra_control), | ||
1258 | SND_SOC_DAPM_MUX("Vibra Route", SND_SOC_NOPM, 0, 0, | ||
1259 | &twl4030_dapm_vibrapath_control), | ||
1029 | 1260 | ||
1030 | /* Introducing four virtual ADC, since TWL4030 have four channel for | 1261 | /* Introducing four virtual ADC, since TWL4030 have four channel for |
1031 | capture */ | 1262 | capture */ |
@@ -1050,11 +1281,15 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | |||
1050 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD| | 1281 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD| |
1051 | SND_SOC_DAPM_POST_REG), | 1282 | SND_SOC_DAPM_POST_REG), |
1052 | 1283 | ||
1053 | /* Analog input muxes with switch for the capture amplifiers */ | 1284 | /* Analog input mixers for the capture amplifiers */ |
1054 | SND_SOC_DAPM_VALUE_MUX("Analog Left Capture Route", | 1285 | SND_SOC_DAPM_MIXER("Analog Left Capture Route", |
1055 | TWL4030_REG_ANAMICL, 4, 0, &twl4030_dapm_analoglmic_control), | 1286 | TWL4030_REG_ANAMICL, 4, 0, |
1056 | SND_SOC_DAPM_VALUE_MUX("Analog Right Capture Route", | 1287 | &twl4030_dapm_analoglmic_controls[0], |
1057 | TWL4030_REG_ANAMICR, 4, 0, &twl4030_dapm_analogrmic_control), | 1288 | ARRAY_SIZE(twl4030_dapm_analoglmic_controls)), |
1289 | SND_SOC_DAPM_MIXER("Analog Right Capture Route", | ||
1290 | TWL4030_REG_ANAMICR, 4, 0, | ||
1291 | &twl4030_dapm_analogrmic_controls[0], | ||
1292 | ARRAY_SIZE(twl4030_dapm_analogrmic_controls)), | ||
1058 | 1293 | ||
1059 | SND_SOC_DAPM_PGA("ADC Physical Left", | 1294 | SND_SOC_DAPM_PGA("ADC Physical Left", |
1060 | TWL4030_REG_AVADC_CTL, 3, 0, NULL, 0), | 1295 | TWL4030_REG_AVADC_CTL, 3, 0, NULL, 0), |
@@ -1073,62 +1308,86 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | |||
1073 | }; | 1308 | }; |
1074 | 1309 | ||
1075 | static const struct snd_soc_dapm_route intercon[] = { | 1310 | static const struct snd_soc_dapm_route intercon[] = { |
1076 | {"Analog L1 Playback Mixer", NULL, "DAC Left1"}, | 1311 | {"Digital L1 Playback Mixer", NULL, "DAC Left1"}, |
1077 | {"Analog R1 Playback Mixer", NULL, "DAC Right1"}, | 1312 | {"Digital R1 Playback Mixer", NULL, "DAC Right1"}, |
1078 | {"Analog L2 Playback Mixer", NULL, "DAC Left2"}, | 1313 | {"Digital L2 Playback Mixer", NULL, "DAC Left2"}, |
1079 | {"Analog R2 Playback Mixer", NULL, "DAC Right2"}, | 1314 | {"Digital R2 Playback Mixer", NULL, "DAC Right2"}, |
1080 | 1315 | {"Digital Voice Playback Mixer", NULL, "DAC Voice"}, | |
1081 | {"ARXL1_APGA", NULL, "Analog L1 Playback Mixer"}, | 1316 | |
1082 | {"ARXR1_APGA", NULL, "Analog R1 Playback Mixer"}, | 1317 | {"Analog L1 Playback Mixer", NULL, "Digital L1 Playback Mixer"}, |
1083 | {"ARXL2_APGA", NULL, "Analog L2 Playback Mixer"}, | 1318 | {"Analog R1 Playback Mixer", NULL, "Digital R1 Playback Mixer"}, |
1084 | {"ARXR2_APGA", NULL, "Analog R2 Playback Mixer"}, | 1319 | {"Analog L2 Playback Mixer", NULL, "Digital L2 Playback Mixer"}, |
1320 | {"Analog R2 Playback Mixer", NULL, "Digital R2 Playback Mixer"}, | ||
1321 | {"Analog Voice Playback Mixer", NULL, "Digital Voice Playback Mixer"}, | ||
1085 | 1322 | ||
1086 | /* Internal playback routings */ | 1323 | /* Internal playback routings */ |
1087 | /* Earpiece */ | 1324 | /* Earpiece */ |
1088 | {"Earpiece Mux", "DACL1", "ARXL1_APGA"}, | 1325 | {"Earpiece Mixer", "Voice", "Analog Voice Playback Mixer"}, |
1089 | {"Earpiece Mux", "DACL2", "ARXL2_APGA"}, | 1326 | {"Earpiece Mixer", "AudioL1", "Analog L1 Playback Mixer"}, |
1090 | {"Earpiece Mux", "DACR1", "ARXR1_APGA"}, | 1327 | {"Earpiece Mixer", "AudioL2", "Analog L2 Playback Mixer"}, |
1328 | {"Earpiece Mixer", "AudioR1", "Analog R1 Playback Mixer"}, | ||
1091 | /* PreDrivL */ | 1329 | /* PreDrivL */ |
1092 | {"PredriveL Mux", "DACL1", "ARXL1_APGA"}, | 1330 | {"PredriveL Mixer", "Voice", "Analog Voice Playback Mixer"}, |
1093 | {"PredriveL Mux", "DACL2", "ARXL2_APGA"}, | 1331 | {"PredriveL Mixer", "AudioL1", "Analog L1 Playback Mixer"}, |
1094 | {"PredriveL Mux", "DACR2", "ARXR2_APGA"}, | 1332 | {"PredriveL Mixer", "AudioL2", "Analog L2 Playback Mixer"}, |
1333 | {"PredriveL Mixer", "AudioR2", "Analog R2 Playback Mixer"}, | ||
1095 | /* PreDrivR */ | 1334 | /* PreDrivR */ |
1096 | {"PredriveR Mux", "DACR1", "ARXR1_APGA"}, | 1335 | {"PredriveR Mixer", "Voice", "Analog Voice Playback Mixer"}, |
1097 | {"PredriveR Mux", "DACR2", "ARXR2_APGA"}, | 1336 | {"PredriveR Mixer", "AudioR1", "Analog R1 Playback Mixer"}, |
1098 | {"PredriveR Mux", "DACL2", "ARXL2_APGA"}, | 1337 | {"PredriveR Mixer", "AudioR2", "Analog R2 Playback Mixer"}, |
1338 | {"PredriveR Mixer", "AudioL2", "Analog L2 Playback Mixer"}, | ||
1099 | /* HeadsetL */ | 1339 | /* HeadsetL */ |
1100 | {"HeadsetL Mux", "DACL1", "ARXL1_APGA"}, | 1340 | {"HeadsetL Mixer", "Voice", "Analog Voice Playback Mixer"}, |
1101 | {"HeadsetL Mux", "DACL2", "ARXL2_APGA"}, | 1341 | {"HeadsetL Mixer", "AudioL1", "Analog L1 Playback Mixer"}, |
1342 | {"HeadsetL Mixer", "AudioL2", "Analog L2 Playback Mixer"}, | ||
1343 | {"HeadsetL PGA", NULL, "HeadsetL Mixer"}, | ||
1102 | /* HeadsetR */ | 1344 | /* HeadsetR */ |
1103 | {"HeadsetR Mux", "DACR1", "ARXR1_APGA"}, | 1345 | {"HeadsetR Mixer", "Voice", "Analog Voice Playback Mixer"}, |
1104 | {"HeadsetR Mux", "DACR2", "ARXR2_APGA"}, | 1346 | {"HeadsetR Mixer", "AudioR1", "Analog R1 Playback Mixer"}, |
1347 | {"HeadsetR Mixer", "AudioR2", "Analog R2 Playback Mixer"}, | ||
1348 | {"HeadsetR PGA", NULL, "HeadsetR Mixer"}, | ||
1105 | /* CarkitL */ | 1349 | /* CarkitL */ |
1106 | {"CarkitL Mux", "DACL1", "ARXL1_APGA"}, | 1350 | {"CarkitL Mixer", "Voice", "Analog Voice Playback Mixer"}, |
1107 | {"CarkitL Mux", "DACL2", "ARXL2_APGA"}, | 1351 | {"CarkitL Mixer", "AudioL1", "Analog L1 Playback Mixer"}, |
1352 | {"CarkitL Mixer", "AudioL2", "Analog L2 Playback Mixer"}, | ||
1108 | /* CarkitR */ | 1353 | /* CarkitR */ |
1109 | {"CarkitR Mux", "DACR1", "ARXR1_APGA"}, | 1354 | {"CarkitR Mixer", "Voice", "Analog Voice Playback Mixer"}, |
1110 | {"CarkitR Mux", "DACR2", "ARXR2_APGA"}, | 1355 | {"CarkitR Mixer", "AudioR1", "Analog R1 Playback Mixer"}, |
1356 | {"CarkitR Mixer", "AudioR2", "Analog R2 Playback Mixer"}, | ||
1111 | /* HandsfreeL */ | 1357 | /* HandsfreeL */ |
1112 | {"HandsfreeL Mux", "DACL1", "ARXL1_APGA"}, | 1358 | {"HandsfreeL Mux", "Voice", "Analog Voice Playback Mixer"}, |
1113 | {"HandsfreeL Mux", "DACL2", "ARXL2_APGA"}, | 1359 | {"HandsfreeL Mux", "AudioL1", "Analog L1 Playback Mixer"}, |
1114 | {"HandsfreeL Mux", "DACR2", "ARXR2_APGA"}, | 1360 | {"HandsfreeL Mux", "AudioL2", "Analog L2 Playback Mixer"}, |
1361 | {"HandsfreeL Mux", "AudioR2", "Analog R2 Playback Mixer"}, | ||
1362 | {"HandsfreeL Switch", "Switch", "HandsfreeL Mux"}, | ||
1363 | {"HandsfreeL PGA", NULL, "HandsfreeL Switch"}, | ||
1115 | /* HandsfreeR */ | 1364 | /* HandsfreeR */ |
1116 | {"HandsfreeR Mux", "DACR1", "ARXR1_APGA"}, | 1365 | {"HandsfreeR Mux", "Voice", "Analog Voice Playback Mixer"}, |
1117 | {"HandsfreeR Mux", "DACR2", "ARXR2_APGA"}, | 1366 | {"HandsfreeR Mux", "AudioR1", "Analog R1 Playback Mixer"}, |
1118 | {"HandsfreeR Mux", "DACL2", "ARXL2_APGA"}, | 1367 | {"HandsfreeR Mux", "AudioR2", "Analog R2 Playback Mixer"}, |
1368 | {"HandsfreeR Mux", "AudioL2", "Analog L2 Playback Mixer"}, | ||
1369 | {"HandsfreeR Switch", "Switch", "HandsfreeR Mux"}, | ||
1370 | {"HandsfreeR PGA", NULL, "HandsfreeR Switch"}, | ||
1371 | /* Vibra */ | ||
1372 | {"Vibra Mux", "AudioL1", "DAC Left1"}, | ||
1373 | {"Vibra Mux", "AudioR1", "DAC Right1"}, | ||
1374 | {"Vibra Mux", "AudioL2", "DAC Left2"}, | ||
1375 | {"Vibra Mux", "AudioR2", "DAC Right2"}, | ||
1119 | 1376 | ||
1120 | /* outputs */ | 1377 | /* outputs */ |
1121 | {"OUTL", NULL, "ARXL2_APGA"}, | 1378 | {"OUTL", NULL, "Analog L2 Playback Mixer"}, |
1122 | {"OUTR", NULL, "ARXR2_APGA"}, | 1379 | {"OUTR", NULL, "Analog R2 Playback Mixer"}, |
1123 | {"EARPIECE", NULL, "Earpiece Mux"}, | 1380 | {"EARPIECE", NULL, "Earpiece Mixer"}, |
1124 | {"PREDRIVEL", NULL, "PredriveL Mux"}, | 1381 | {"PREDRIVEL", NULL, "PredriveL Mixer"}, |
1125 | {"PREDRIVER", NULL, "PredriveR Mux"}, | 1382 | {"PREDRIVER", NULL, "PredriveR Mixer"}, |
1126 | {"HSOL", NULL, "HeadsetL Mux"}, | 1383 | {"HSOL", NULL, "HeadsetL PGA"}, |
1127 | {"HSOR", NULL, "HeadsetR Mux"}, | 1384 | {"HSOR", NULL, "HeadsetR PGA"}, |
1128 | {"CARKITL", NULL, "CarkitL Mux"}, | 1385 | {"CARKITL", NULL, "CarkitL Mixer"}, |
1129 | {"CARKITR", NULL, "CarkitR Mux"}, | 1386 | {"CARKITR", NULL, "CarkitR Mixer"}, |
1130 | {"HFL", NULL, "HandsfreeL Mux"}, | 1387 | {"HFL", NULL, "HandsfreeL PGA"}, |
1131 | {"HFR", NULL, "HandsfreeR Mux"}, | 1388 | {"HFR", NULL, "HandsfreeR PGA"}, |
1389 | {"Vibra Route", "Audio", "Vibra Mux"}, | ||
1390 | {"VIBRA", NULL, "Vibra Route"}, | ||
1132 | 1391 | ||
1133 | /* Capture path */ | 1392 | /* Capture path */ |
1134 | {"Analog Left Capture Route", "Main mic", "MAINMIC"}, | 1393 | {"Analog Left Capture Route", "Main mic", "MAINMIC"}, |
@@ -1168,18 +1427,22 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
1168 | {"Left1 Analog Loopback", "Switch", "Analog Left Capture Route"}, | 1427 | {"Left1 Analog Loopback", "Switch", "Analog Left Capture Route"}, |
1169 | {"Right2 Analog Loopback", "Switch", "Analog Right Capture Route"}, | 1428 | {"Right2 Analog Loopback", "Switch", "Analog Right Capture Route"}, |
1170 | {"Left2 Analog Loopback", "Switch", "Analog Left Capture Route"}, | 1429 | {"Left2 Analog Loopback", "Switch", "Analog Left Capture Route"}, |
1430 | {"Voice Analog Loopback", "Switch", "Analog Left Capture Route"}, | ||
1171 | 1431 | ||
1172 | {"Analog R1 Playback Mixer", NULL, "Right1 Analog Loopback"}, | 1432 | {"Analog R1 Playback Mixer", NULL, "Right1 Analog Loopback"}, |
1173 | {"Analog L1 Playback Mixer", NULL, "Left1 Analog Loopback"}, | 1433 | {"Analog L1 Playback Mixer", NULL, "Left1 Analog Loopback"}, |
1174 | {"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"}, | 1434 | {"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"}, |
1175 | {"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"}, | 1435 | {"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"}, |
1436 | {"Analog Voice Playback Mixer", NULL, "Voice Analog Loopback"}, | ||
1176 | 1437 | ||
1177 | /* Digital bypass routes */ | 1438 | /* Digital bypass routes */ |
1178 | {"Right Digital Loopback", "Volume", "TX1 Capture Route"}, | 1439 | {"Right Digital Loopback", "Volume", "TX1 Capture Route"}, |
1179 | {"Left Digital Loopback", "Volume", "TX1 Capture Route"}, | 1440 | {"Left Digital Loopback", "Volume", "TX1 Capture Route"}, |
1441 | {"Voice Digital Loopback", "Volume", "TX2 Capture Route"}, | ||
1180 | 1442 | ||
1181 | {"Analog R2 Playback Mixer", NULL, "Right Digital Loopback"}, | 1443 | {"Digital R2 Playback Mixer", NULL, "Right Digital Loopback"}, |
1182 | {"Analog L2 Playback Mixer", NULL, "Left Digital Loopback"}, | 1444 | {"Digital L2 Playback Mixer", NULL, "Left Digital Loopback"}, |
1445 | {"Digital Voice Playback Mixer", NULL, "Voice Digital Loopback"}, | ||
1183 | 1446 | ||
1184 | }; | 1447 | }; |
1185 | 1448 | ||
@@ -1226,6 +1489,58 @@ static int twl4030_set_bias_level(struct snd_soc_codec *codec, | |||
1226 | return 0; | 1489 | return 0; |
1227 | } | 1490 | } |
1228 | 1491 | ||
1492 | static void twl4030_constraints(struct twl4030_priv *twl4030, | ||
1493 | struct snd_pcm_substream *mst_substream) | ||
1494 | { | ||
1495 | struct snd_pcm_substream *slv_substream; | ||
1496 | |||
1497 | /* Pick the stream, which need to be constrained */ | ||
1498 | if (mst_substream == twl4030->master_substream) | ||
1499 | slv_substream = twl4030->slave_substream; | ||
1500 | else if (mst_substream == twl4030->slave_substream) | ||
1501 | slv_substream = twl4030->master_substream; | ||
1502 | else /* This should not happen.. */ | ||
1503 | return; | ||
1504 | |||
1505 | /* Set the constraints according to the already configured stream */ | ||
1506 | snd_pcm_hw_constraint_minmax(slv_substream->runtime, | ||
1507 | SNDRV_PCM_HW_PARAM_RATE, | ||
1508 | twl4030->rate, | ||
1509 | twl4030->rate); | ||
1510 | |||
1511 | snd_pcm_hw_constraint_minmax(slv_substream->runtime, | ||
1512 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, | ||
1513 | twl4030->sample_bits, | ||
1514 | twl4030->sample_bits); | ||
1515 | |||
1516 | snd_pcm_hw_constraint_minmax(slv_substream->runtime, | ||
1517 | SNDRV_PCM_HW_PARAM_CHANNELS, | ||
1518 | twl4030->channels, | ||
1519 | twl4030->channels); | ||
1520 | } | ||
1521 | |||
1522 | /* In case of 4 channel mode, the RX1 L/R for playback and the TX2 L/R for | ||
1523 | * capture has to be enabled/disabled. */ | ||
1524 | static void twl4030_tdm_enable(struct snd_soc_codec *codec, int direction, | ||
1525 | int enable) | ||
1526 | { | ||
1527 | u8 reg, mask; | ||
1528 | |||
1529 | reg = twl4030_read_reg_cache(codec, TWL4030_REG_OPTION); | ||
1530 | |||
1531 | if (direction == SNDRV_PCM_STREAM_PLAYBACK) | ||
1532 | mask = TWL4030_ARXL1_VRX_EN | TWL4030_ARXR1_EN; | ||
1533 | else | ||
1534 | mask = TWL4030_ATXL2_VTXL_EN | TWL4030_ATXR2_VTXR_EN; | ||
1535 | |||
1536 | if (enable) | ||
1537 | reg |= mask; | ||
1538 | else | ||
1539 | reg &= ~mask; | ||
1540 | |||
1541 | twl4030_write(codec, TWL4030_REG_OPTION, reg); | ||
1542 | } | ||
1543 | |||
1229 | static int twl4030_startup(struct snd_pcm_substream *substream, | 1544 | static int twl4030_startup(struct snd_pcm_substream *substream, |
1230 | struct snd_soc_dai *dai) | 1545 | struct snd_soc_dai *dai) |
1231 | { | 1546 | { |
@@ -1234,26 +1549,25 @@ static int twl4030_startup(struct snd_pcm_substream *substream, | |||
1234 | struct snd_soc_codec *codec = socdev->card->codec; | 1549 | struct snd_soc_codec *codec = socdev->card->codec; |
1235 | struct twl4030_priv *twl4030 = codec->private_data; | 1550 | struct twl4030_priv *twl4030 = codec->private_data; |
1236 | 1551 | ||
1237 | /* If we already have a playback or capture going then constrain | ||
1238 | * this substream to match it. | ||
1239 | */ | ||
1240 | if (twl4030->master_substream) { | 1552 | if (twl4030->master_substream) { |
1241 | struct snd_pcm_runtime *master_runtime; | ||
1242 | master_runtime = twl4030->master_substream->runtime; | ||
1243 | |||
1244 | snd_pcm_hw_constraint_minmax(substream->runtime, | ||
1245 | SNDRV_PCM_HW_PARAM_RATE, | ||
1246 | master_runtime->rate, | ||
1247 | master_runtime->rate); | ||
1248 | |||
1249 | snd_pcm_hw_constraint_minmax(substream->runtime, | ||
1250 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, | ||
1251 | master_runtime->sample_bits, | ||
1252 | master_runtime->sample_bits); | ||
1253 | |||
1254 | twl4030->slave_substream = substream; | 1553 | twl4030->slave_substream = substream; |
1255 | } else | 1554 | /* The DAI has one configuration for playback and capture, so |
1555 | * if the DAI has been already configured then constrain this | ||
1556 | * substream to match it. */ | ||
1557 | if (twl4030->configured) | ||
1558 | twl4030_constraints(twl4030, twl4030->master_substream); | ||
1559 | } else { | ||
1560 | if (!(twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) & | ||
1561 | TWL4030_OPTION_1)) { | ||
1562 | /* In option2 4 channel is not supported, set the | ||
1563 | * constraint for the first stream for channels, the | ||
1564 | * second stream will 'inherit' this cosntraint */ | ||
1565 | snd_pcm_hw_constraint_minmax(substream->runtime, | ||
1566 | SNDRV_PCM_HW_PARAM_CHANNELS, | ||
1567 | 2, 2); | ||
1568 | } | ||
1256 | twl4030->master_substream = substream; | 1569 | twl4030->master_substream = substream; |
1570 | } | ||
1257 | 1571 | ||
1258 | return 0; | 1572 | return 0; |
1259 | } | 1573 | } |
@@ -1270,6 +1584,17 @@ static void twl4030_shutdown(struct snd_pcm_substream *substream, | |||
1270 | twl4030->master_substream = twl4030->slave_substream; | 1584 | twl4030->master_substream = twl4030->slave_substream; |
1271 | 1585 | ||
1272 | twl4030->slave_substream = NULL; | 1586 | twl4030->slave_substream = NULL; |
1587 | |||
1588 | /* If all streams are closed, or the remaining stream has not yet | ||
1589 | * been configured than set the DAI as not configured. */ | ||
1590 | if (!twl4030->master_substream) | ||
1591 | twl4030->configured = 0; | ||
1592 | else if (!twl4030->master_substream->runtime->channels) | ||
1593 | twl4030->configured = 0; | ||
1594 | |||
1595 | /* If the closing substream had 4 channel, do the necessary cleanup */ | ||
1596 | if (substream->runtime->channels == 4) | ||
1597 | twl4030_tdm_enable(codec, substream->stream, 0); | ||
1273 | } | 1598 | } |
1274 | 1599 | ||
1275 | static int twl4030_hw_params(struct snd_pcm_substream *substream, | 1600 | static int twl4030_hw_params(struct snd_pcm_substream *substream, |
@@ -1282,8 +1607,24 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, | |||
1282 | struct twl4030_priv *twl4030 = codec->private_data; | 1607 | struct twl4030_priv *twl4030 = codec->private_data; |
1283 | u8 mode, old_mode, format, old_format; | 1608 | u8 mode, old_mode, format, old_format; |
1284 | 1609 | ||
1285 | if (substream == twl4030->slave_substream) | 1610 | /* If the substream has 4 channel, do the necessary setup */ |
1286 | /* Ignoring hw_params for slave substream */ | 1611 | if (params_channels(params) == 4) { |
1612 | u8 format, mode; | ||
1613 | |||
1614 | format = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF); | ||
1615 | mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE); | ||
1616 | |||
1617 | /* Safety check: are we in the correct operating mode and | ||
1618 | * the interface is in TDM mode? */ | ||
1619 | if ((mode & TWL4030_OPTION_1) && | ||
1620 | ((format & TWL4030_AIF_FORMAT) == TWL4030_AIF_FORMAT_TDM)) | ||
1621 | twl4030_tdm_enable(codec, substream->stream, 1); | ||
1622 | else | ||
1623 | return -EINVAL; | ||
1624 | } | ||
1625 | |||
1626 | if (twl4030->configured) | ||
1627 | /* Ignoring hw_params for already configured DAI */ | ||
1287 | return 0; | 1628 | return 0; |
1288 | 1629 | ||
1289 | /* bit rate */ | 1630 | /* bit rate */ |
@@ -1363,6 +1704,21 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, | |||
1363 | /* set CODECPDZ afterwards */ | 1704 | /* set CODECPDZ afterwards */ |
1364 | twl4030_codec_enable(codec, 1); | 1705 | twl4030_codec_enable(codec, 1); |
1365 | } | 1706 | } |
1707 | |||
1708 | /* Store the important parameters for the DAI configuration and set | ||
1709 | * the DAI as configured */ | ||
1710 | twl4030->configured = 1; | ||
1711 | twl4030->rate = params_rate(params); | ||
1712 | twl4030->sample_bits = hw_param_interval(params, | ||
1713 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min; | ||
1714 | twl4030->channels = params_channels(params); | ||
1715 | |||
1716 | /* If both playback and capture streams are open, and one of them | ||
1717 | * is setting the hw parameters right now (since we are here), set | ||
1718 | * constraints to the other stream to match the current one. */ | ||
1719 | if (twl4030->slave_substream) | ||
1720 | twl4030_constraints(twl4030, substream); | ||
1721 | |||
1366 | return 0; | 1722 | return 0; |
1367 | } | 1723 | } |
1368 | 1724 | ||
@@ -1370,17 +1726,21 @@ static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1370 | int clk_id, unsigned int freq, int dir) | 1726 | int clk_id, unsigned int freq, int dir) |
1371 | { | 1727 | { |
1372 | struct snd_soc_codec *codec = codec_dai->codec; | 1728 | struct snd_soc_codec *codec = codec_dai->codec; |
1729 | struct twl4030_priv *twl4030 = codec->private_data; | ||
1373 | u8 infreq; | 1730 | u8 infreq; |
1374 | 1731 | ||
1375 | switch (freq) { | 1732 | switch (freq) { |
1376 | case 19200000: | 1733 | case 19200000: |
1377 | infreq = TWL4030_APLL_INFREQ_19200KHZ; | 1734 | infreq = TWL4030_APLL_INFREQ_19200KHZ; |
1735 | twl4030->sysclk = 19200; | ||
1378 | break; | 1736 | break; |
1379 | case 26000000: | 1737 | case 26000000: |
1380 | infreq = TWL4030_APLL_INFREQ_26000KHZ; | 1738 | infreq = TWL4030_APLL_INFREQ_26000KHZ; |
1739 | twl4030->sysclk = 26000; | ||
1381 | break; | 1740 | break; |
1382 | case 38400000: | 1741 | case 38400000: |
1383 | infreq = TWL4030_APLL_INFREQ_38400KHZ; | 1742 | infreq = TWL4030_APLL_INFREQ_38400KHZ; |
1743 | twl4030->sysclk = 38400; | ||
1384 | break; | 1744 | break; |
1385 | default: | 1745 | default: |
1386 | printk(KERN_ERR "TWL4030 set sysclk: unknown rate %d\n", | 1746 | printk(KERN_ERR "TWL4030 set sysclk: unknown rate %d\n", |
@@ -1424,6 +1784,9 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
1424 | case SND_SOC_DAIFMT_I2S: | 1784 | case SND_SOC_DAIFMT_I2S: |
1425 | format |= TWL4030_AIF_FORMAT_CODEC; | 1785 | format |= TWL4030_AIF_FORMAT_CODEC; |
1426 | break; | 1786 | break; |
1787 | case SND_SOC_DAIFMT_DSP_A: | ||
1788 | format |= TWL4030_AIF_FORMAT_TDM; | ||
1789 | break; | ||
1427 | default: | 1790 | default: |
1428 | return -EINVAL; | 1791 | return -EINVAL; |
1429 | } | 1792 | } |
@@ -1443,6 +1806,180 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
1443 | return 0; | 1806 | return 0; |
1444 | } | 1807 | } |
1445 | 1808 | ||
1809 | /* In case of voice mode, the RX1 L(VRX) for downlink and the TX2 L/R | ||
1810 | * (VTXL, VTXR) for uplink has to be enabled/disabled. */ | ||
1811 | static void twl4030_voice_enable(struct snd_soc_codec *codec, int direction, | ||
1812 | int enable) | ||
1813 | { | ||
1814 | u8 reg, mask; | ||
1815 | |||
1816 | reg = twl4030_read_reg_cache(codec, TWL4030_REG_OPTION); | ||
1817 | |||
1818 | if (direction == SNDRV_PCM_STREAM_PLAYBACK) | ||
1819 | mask = TWL4030_ARXL1_VRX_EN; | ||
1820 | else | ||
1821 | mask = TWL4030_ATXL2_VTXL_EN | TWL4030_ATXR2_VTXR_EN; | ||
1822 | |||
1823 | if (enable) | ||
1824 | reg |= mask; | ||
1825 | else | ||
1826 | reg &= ~mask; | ||
1827 | |||
1828 | twl4030_write(codec, TWL4030_REG_OPTION, reg); | ||
1829 | } | ||
1830 | |||
1831 | static int twl4030_voice_startup(struct snd_pcm_substream *substream, | ||
1832 | struct snd_soc_dai *dai) | ||
1833 | { | ||
1834 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
1835 | struct snd_soc_device *socdev = rtd->socdev; | ||
1836 | struct snd_soc_codec *codec = socdev->card->codec; | ||
1837 | u8 infreq; | ||
1838 | u8 mode; | ||
1839 | |||
1840 | /* If the system master clock is not 26MHz, the voice PCM interface is | ||
1841 | * not avilable. | ||
1842 | */ | ||
1843 | infreq = twl4030_read_reg_cache(codec, TWL4030_REG_APLL_CTL) | ||
1844 | & TWL4030_APLL_INFREQ; | ||
1845 | |||
1846 | if (infreq != TWL4030_APLL_INFREQ_26000KHZ) { | ||
1847 | printk(KERN_ERR "TWL4030 voice startup: " | ||
1848 | "MCLK is not 26MHz, call set_sysclk() on init\n"); | ||
1849 | return -EINVAL; | ||
1850 | } | ||
1851 | |||
1852 | /* If the codec mode is not option2, the voice PCM interface is not | ||
1853 | * avilable. | ||
1854 | */ | ||
1855 | mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) | ||
1856 | & TWL4030_OPT_MODE; | ||
1857 | |||
1858 | if (mode != TWL4030_OPTION_2) { | ||
1859 | printk(KERN_ERR "TWL4030 voice startup: " | ||
1860 | "the codec mode is not option2\n"); | ||
1861 | return -EINVAL; | ||
1862 | } | ||
1863 | |||
1864 | return 0; | ||
1865 | } | ||
1866 | |||
1867 | static void twl4030_voice_shutdown(struct snd_pcm_substream *substream, | ||
1868 | struct snd_soc_dai *dai) | ||
1869 | { | ||
1870 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
1871 | struct snd_soc_device *socdev = rtd->socdev; | ||
1872 | struct snd_soc_codec *codec = socdev->card->codec; | ||
1873 | |||
1874 | /* Enable voice digital filters */ | ||
1875 | twl4030_voice_enable(codec, substream->stream, 0); | ||
1876 | } | ||
1877 | |||
1878 | static int twl4030_voice_hw_params(struct snd_pcm_substream *substream, | ||
1879 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | ||
1880 | { | ||
1881 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
1882 | struct snd_soc_device *socdev = rtd->socdev; | ||
1883 | struct snd_soc_codec *codec = socdev->card->codec; | ||
1884 | u8 old_mode, mode; | ||
1885 | |||
1886 | /* Enable voice digital filters */ | ||
1887 | twl4030_voice_enable(codec, substream->stream, 1); | ||
1888 | |||
1889 | /* bit rate */ | ||
1890 | old_mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) | ||
1891 | & ~(TWL4030_CODECPDZ); | ||
1892 | mode = old_mode; | ||
1893 | |||
1894 | switch (params_rate(params)) { | ||
1895 | case 8000: | ||
1896 | mode &= ~(TWL4030_SEL_16K); | ||
1897 | break; | ||
1898 | case 16000: | ||
1899 | mode |= TWL4030_SEL_16K; | ||
1900 | break; | ||
1901 | default: | ||
1902 | printk(KERN_ERR "TWL4030 voice hw params: unknown rate %d\n", | ||
1903 | params_rate(params)); | ||
1904 | return -EINVAL; | ||
1905 | } | ||
1906 | |||
1907 | if (mode != old_mode) { | ||
1908 | /* change rate and set CODECPDZ */ | ||
1909 | twl4030_codec_enable(codec, 0); | ||
1910 | twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode); | ||
1911 | twl4030_codec_enable(codec, 1); | ||
1912 | } | ||
1913 | |||
1914 | return 0; | ||
1915 | } | ||
1916 | |||
1917 | static int twl4030_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai, | ||
1918 | int clk_id, unsigned int freq, int dir) | ||
1919 | { | ||
1920 | struct snd_soc_codec *codec = codec_dai->codec; | ||
1921 | u8 infreq; | ||
1922 | |||
1923 | switch (freq) { | ||
1924 | case 26000000: | ||
1925 | infreq = TWL4030_APLL_INFREQ_26000KHZ; | ||
1926 | break; | ||
1927 | default: | ||
1928 | printk(KERN_ERR "TWL4030 voice set sysclk: unknown rate %d\n", | ||
1929 | freq); | ||
1930 | return -EINVAL; | ||
1931 | } | ||
1932 | |||
1933 | infreq |= TWL4030_APLL_EN; | ||
1934 | twl4030_write(codec, TWL4030_REG_APLL_CTL, infreq); | ||
1935 | |||
1936 | return 0; | ||
1937 | } | ||
1938 | |||
1939 | static int twl4030_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, | ||
1940 | unsigned int fmt) | ||
1941 | { | ||
1942 | struct snd_soc_codec *codec = codec_dai->codec; | ||
1943 | u8 old_format, format; | ||
1944 | |||
1945 | /* get format */ | ||
1946 | old_format = twl4030_read_reg_cache(codec, TWL4030_REG_VOICE_IF); | ||
1947 | format = old_format; | ||
1948 | |||
1949 | /* set master/slave audio interface */ | ||
1950 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
1951 | case SND_SOC_DAIFMT_CBS_CFM: | ||
1952 | format &= ~(TWL4030_VIF_SLAVE_EN); | ||
1953 | break; | ||
1954 | case SND_SOC_DAIFMT_CBS_CFS: | ||
1955 | format |= TWL4030_VIF_SLAVE_EN; | ||
1956 | break; | ||
1957 | default: | ||
1958 | return -EINVAL; | ||
1959 | } | ||
1960 | |||
1961 | /* clock inversion */ | ||
1962 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
1963 | case SND_SOC_DAIFMT_IB_NF: | ||
1964 | format &= ~(TWL4030_VIF_FORMAT); | ||
1965 | break; | ||
1966 | case SND_SOC_DAIFMT_NB_IF: | ||
1967 | format |= TWL4030_VIF_FORMAT; | ||
1968 | break; | ||
1969 | default: | ||
1970 | return -EINVAL; | ||
1971 | } | ||
1972 | |||
1973 | if (format != old_format) { | ||
1974 | /* change format and set CODECPDZ */ | ||
1975 | twl4030_codec_enable(codec, 0); | ||
1976 | twl4030_write(codec, TWL4030_REG_VOICE_IF, format); | ||
1977 | twl4030_codec_enable(codec, 1); | ||
1978 | } | ||
1979 | |||
1980 | return 0; | ||
1981 | } | ||
1982 | |||
1446 | #define TWL4030_RATES (SNDRV_PCM_RATE_8000_48000) | 1983 | #define TWL4030_RATES (SNDRV_PCM_RATE_8000_48000) |
1447 | #define TWL4030_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FORMAT_S24_LE) | 1984 | #define TWL4030_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FORMAT_S24_LE) |
1448 | 1985 | ||
@@ -1454,21 +1991,47 @@ static struct snd_soc_dai_ops twl4030_dai_ops = { | |||
1454 | .set_fmt = twl4030_set_dai_fmt, | 1991 | .set_fmt = twl4030_set_dai_fmt, |
1455 | }; | 1992 | }; |
1456 | 1993 | ||
1457 | struct snd_soc_dai twl4030_dai = { | 1994 | static struct snd_soc_dai_ops twl4030_dai_voice_ops = { |
1995 | .startup = twl4030_voice_startup, | ||
1996 | .shutdown = twl4030_voice_shutdown, | ||
1997 | .hw_params = twl4030_voice_hw_params, | ||
1998 | .set_sysclk = twl4030_voice_set_dai_sysclk, | ||
1999 | .set_fmt = twl4030_voice_set_dai_fmt, | ||
2000 | }; | ||
2001 | |||
2002 | struct snd_soc_dai twl4030_dai[] = { | ||
2003 | { | ||
1458 | .name = "twl4030", | 2004 | .name = "twl4030", |
1459 | .playback = { | 2005 | .playback = { |
1460 | .stream_name = "Playback", | 2006 | .stream_name = "HiFi Playback", |
1461 | .channels_min = 2, | 2007 | .channels_min = 2, |
1462 | .channels_max = 2, | 2008 | .channels_max = 4, |
1463 | .rates = TWL4030_RATES | SNDRV_PCM_RATE_96000, | 2009 | .rates = TWL4030_RATES | SNDRV_PCM_RATE_96000, |
1464 | .formats = TWL4030_FORMATS,}, | 2010 | .formats = TWL4030_FORMATS,}, |
1465 | .capture = { | 2011 | .capture = { |
1466 | .stream_name = "Capture", | 2012 | .stream_name = "Capture", |
1467 | .channels_min = 2, | 2013 | .channels_min = 2, |
1468 | .channels_max = 2, | 2014 | .channels_max = 4, |
1469 | .rates = TWL4030_RATES, | 2015 | .rates = TWL4030_RATES, |
1470 | .formats = TWL4030_FORMATS,}, | 2016 | .formats = TWL4030_FORMATS,}, |
1471 | .ops = &twl4030_dai_ops, | 2017 | .ops = &twl4030_dai_ops, |
2018 | }, | ||
2019 | { | ||
2020 | .name = "twl4030 Voice", | ||
2021 | .playback = { | ||
2022 | .stream_name = "Voice Playback", | ||
2023 | .channels_min = 1, | ||
2024 | .channels_max = 1, | ||
2025 | .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, | ||
2026 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | ||
2027 | .capture = { | ||
2028 | .stream_name = "Capture", | ||
2029 | .channels_min = 1, | ||
2030 | .channels_max = 2, | ||
2031 | .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, | ||
2032 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | ||
2033 | .ops = &twl4030_dai_voice_ops, | ||
2034 | }, | ||
1472 | }; | 2035 | }; |
1473 | EXPORT_SYMBOL_GPL(twl4030_dai); | 2036 | EXPORT_SYMBOL_GPL(twl4030_dai); |
1474 | 2037 | ||
@@ -1500,6 +2063,8 @@ static int twl4030_resume(struct platform_device *pdev) | |||
1500 | static int twl4030_init(struct snd_soc_device *socdev) | 2063 | static int twl4030_init(struct snd_soc_device *socdev) |
1501 | { | 2064 | { |
1502 | struct snd_soc_codec *codec = socdev->card->codec; | 2065 | struct snd_soc_codec *codec = socdev->card->codec; |
2066 | struct twl4030_setup_data *setup = socdev->codec_data; | ||
2067 | struct twl4030_priv *twl4030 = codec->private_data; | ||
1503 | int ret = 0; | 2068 | int ret = 0; |
1504 | 2069 | ||
1505 | printk(KERN_INFO "TWL4030 Audio Codec init \n"); | 2070 | printk(KERN_INFO "TWL4030 Audio Codec init \n"); |
@@ -1509,14 +2074,31 @@ static int twl4030_init(struct snd_soc_device *socdev) | |||
1509 | codec->read = twl4030_read_reg_cache; | 2074 | codec->read = twl4030_read_reg_cache; |
1510 | codec->write = twl4030_write; | 2075 | codec->write = twl4030_write; |
1511 | codec->set_bias_level = twl4030_set_bias_level; | 2076 | codec->set_bias_level = twl4030_set_bias_level; |
1512 | codec->dai = &twl4030_dai; | 2077 | codec->dai = twl4030_dai; |
1513 | codec->num_dai = 1; | 2078 | codec->num_dai = ARRAY_SIZE(twl4030_dai), |
1514 | codec->reg_cache_size = sizeof(twl4030_reg); | 2079 | codec->reg_cache_size = sizeof(twl4030_reg); |
1515 | codec->reg_cache = kmemdup(twl4030_reg, sizeof(twl4030_reg), | 2080 | codec->reg_cache = kmemdup(twl4030_reg, sizeof(twl4030_reg), |
1516 | GFP_KERNEL); | 2081 | GFP_KERNEL); |
1517 | if (codec->reg_cache == NULL) | 2082 | if (codec->reg_cache == NULL) |
1518 | return -ENOMEM; | 2083 | return -ENOMEM; |
1519 | 2084 | ||
2085 | /* Configuration for headset ramp delay from setup data */ | ||
2086 | if (setup) { | ||
2087 | unsigned char hs_pop; | ||
2088 | |||
2089 | if (setup->sysclk) | ||
2090 | twl4030->sysclk = setup->sysclk; | ||
2091 | else | ||
2092 | twl4030->sysclk = 26000; | ||
2093 | |||
2094 | hs_pop = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); | ||
2095 | hs_pop &= ~TWL4030_RAMP_DELAY; | ||
2096 | hs_pop |= (setup->ramp_delay_value << 2); | ||
2097 | twl4030_write_reg_cache(codec, TWL4030_REG_HS_POPN_SET, hs_pop); | ||
2098 | } else { | ||
2099 | twl4030->sysclk = 26000; | ||
2100 | } | ||
2101 | |||
1520 | /* register pcms */ | 2102 | /* register pcms */ |
1521 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | 2103 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); |
1522 | if (ret < 0) { | 2104 | if (ret < 0) { |
@@ -1604,13 +2186,13 @@ EXPORT_SYMBOL_GPL(soc_codec_dev_twl4030); | |||
1604 | 2186 | ||
1605 | static int __init twl4030_modinit(void) | 2187 | static int __init twl4030_modinit(void) |
1606 | { | 2188 | { |
1607 | return snd_soc_register_dai(&twl4030_dai); | 2189 | return snd_soc_register_dais(&twl4030_dai[0], ARRAY_SIZE(twl4030_dai)); |
1608 | } | 2190 | } |
1609 | module_init(twl4030_modinit); | 2191 | module_init(twl4030_modinit); |
1610 | 2192 | ||
1611 | static void __exit twl4030_exit(void) | 2193 | static void __exit twl4030_exit(void) |
1612 | { | 2194 | { |
1613 | snd_soc_unregister_dai(&twl4030_dai); | 2195 | snd_soc_unregister_dais(&twl4030_dai[0], ARRAY_SIZE(twl4030_dai)); |
1614 | } | 2196 | } |
1615 | module_exit(twl4030_exit); | 2197 | module_exit(twl4030_exit); |
1616 | 2198 | ||
diff --git a/sound/soc/codecs/twl4030.h b/sound/soc/codecs/twl4030.h index cb63765db1df..fe5f395d9e4f 100644 --- a/sound/soc/codecs/twl4030.h +++ b/sound/soc/codecs/twl4030.h | |||
@@ -92,8 +92,9 @@ | |||
92 | #define TWL4030_REG_VIBRA_PWM_SET 0x47 | 92 | #define TWL4030_REG_VIBRA_PWM_SET 0x47 |
93 | #define TWL4030_REG_ANAMIC_GAIN 0x48 | 93 | #define TWL4030_REG_ANAMIC_GAIN 0x48 |
94 | #define TWL4030_REG_MISC_SET_2 0x49 | 94 | #define TWL4030_REG_MISC_SET_2 0x49 |
95 | #define TWL4030_REG_SW_SHADOW 0x4A | ||
95 | 96 | ||
96 | #define TWL4030_CACHEREGNUM (TWL4030_REG_MISC_SET_2 + 1) | 97 | #define TWL4030_CACHEREGNUM (TWL4030_REG_SW_SHADOW + 1) |
97 | 98 | ||
98 | /* Bitfield Definitions */ | 99 | /* Bitfield Definitions */ |
99 | 100 | ||
@@ -110,9 +111,22 @@ | |||
110 | #define TWL4030_APLL_RATE_44100 0x90 | 111 | #define TWL4030_APLL_RATE_44100 0x90 |
111 | #define TWL4030_APLL_RATE_48000 0xA0 | 112 | #define TWL4030_APLL_RATE_48000 0xA0 |
112 | #define TWL4030_APLL_RATE_96000 0xE0 | 113 | #define TWL4030_APLL_RATE_96000 0xE0 |
113 | #define TWL4030_SEL_16K 0x04 | 114 | #define TWL4030_SEL_16K 0x08 |
114 | #define TWL4030_CODECPDZ 0x02 | 115 | #define TWL4030_CODECPDZ 0x02 |
115 | #define TWL4030_OPT_MODE 0x01 | 116 | #define TWL4030_OPT_MODE 0x01 |
117 | #define TWL4030_OPTION_1 (1 << 0) | ||
118 | #define TWL4030_OPTION_2 (0 << 0) | ||
119 | |||
120 | /* TWL4030_OPTION (0x02) Fields */ | ||
121 | |||
122 | #define TWL4030_ATXL1_EN (1 << 0) | ||
123 | #define TWL4030_ATXR1_EN (1 << 1) | ||
124 | #define TWL4030_ATXL2_VTXL_EN (1 << 2) | ||
125 | #define TWL4030_ATXR2_VTXR_EN (1 << 3) | ||
126 | #define TWL4030_ARXL1_VRX_EN (1 << 4) | ||
127 | #define TWL4030_ARXR1_EN (1 << 5) | ||
128 | #define TWL4030_ARXL2_EN (1 << 6) | ||
129 | #define TWL4030_ARXR2_EN (1 << 7) | ||
116 | 130 | ||
117 | /* TWL4030_REG_MICBIAS_CTL (0x04) Fields */ | 131 | /* TWL4030_REG_MICBIAS_CTL (0x04) Fields */ |
118 | 132 | ||
@@ -171,6 +185,17 @@ | |||
171 | #define TWL4030_CLK256FS_EN 0x02 | 185 | #define TWL4030_CLK256FS_EN 0x02 |
172 | #define TWL4030_AIF_EN 0x01 | 186 | #define TWL4030_AIF_EN 0x01 |
173 | 187 | ||
188 | /* VOICE_IF (0x0F) Fields */ | ||
189 | |||
190 | #define TWL4030_VIF_SLAVE_EN 0x80 | ||
191 | #define TWL4030_VIF_DIN_EN 0x40 | ||
192 | #define TWL4030_VIF_DOUT_EN 0x20 | ||
193 | #define TWL4030_VIF_SWAP 0x10 | ||
194 | #define TWL4030_VIF_FORMAT 0x08 | ||
195 | #define TWL4030_VIF_TRI_EN 0x04 | ||
196 | #define TWL4030_VIF_SUB_EN 0x02 | ||
197 | #define TWL4030_VIF_EN 0x01 | ||
198 | |||
174 | /* EAR_CTL (0x21) */ | 199 | /* EAR_CTL (0x21) */ |
175 | #define TWL4030_EAR_GAIN 0x30 | 200 | #define TWL4030_EAR_GAIN 0x30 |
176 | 201 | ||
@@ -236,7 +261,19 @@ | |||
236 | #define TWL4030_SMOOTH_ANAVOL_EN 0x02 | 261 | #define TWL4030_SMOOTH_ANAVOL_EN 0x02 |
237 | #define TWL4030_DIGMIC_LR_SWAP_EN 0x01 | 262 | #define TWL4030_DIGMIC_LR_SWAP_EN 0x01 |
238 | 263 | ||
239 | extern struct snd_soc_dai twl4030_dai; | 264 | /* TWL4030_REG_SW_SHADOW (0x4A) Fields */ |
265 | #define TWL4030_HFL_EN 0x01 | ||
266 | #define TWL4030_HFR_EN 0x02 | ||
267 | |||
268 | #define TWL4030_DAI_HIFI 0 | ||
269 | #define TWL4030_DAI_VOICE 1 | ||
270 | |||
271 | extern struct snd_soc_dai twl4030_dai[2]; | ||
240 | extern struct snd_soc_codec_device soc_codec_dev_twl4030; | 272 | extern struct snd_soc_codec_device soc_codec_dev_twl4030; |
241 | 273 | ||
274 | struct twl4030_setup_data { | ||
275 | unsigned int ramp_delay_value; | ||
276 | unsigned int sysclk; | ||
277 | }; | ||
278 | |||
242 | #endif /* End of __TWL4030_AUDIO_H__ */ | 279 | #endif /* End of __TWL4030_AUDIO_H__ */ |
diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index ddefb8f80145..269b108e1de6 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c | |||
@@ -101,7 +101,7 @@ static int uda134x_write(struct snd_soc_codec *codec, unsigned int reg, | |||
101 | pr_debug("%s reg: %02X, value:%02X\n", __func__, reg, value); | 101 | pr_debug("%s reg: %02X, value:%02X\n", __func__, reg, value); |
102 | 102 | ||
103 | if (reg >= UDA134X_REGS_NUM) { | 103 | if (reg >= UDA134X_REGS_NUM) { |
104 | printk(KERN_ERR "%s unkown register: reg: %d", | 104 | printk(KERN_ERR "%s unkown register: reg: %u", |
105 | __func__, reg); | 105 | __func__, reg); |
106 | return -EINVAL; | 106 | return -EINVAL; |
107 | } | 107 | } |
@@ -296,7 +296,7 @@ static int uda134x_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
296 | struct snd_soc_codec *codec = codec_dai->codec; | 296 | struct snd_soc_codec *codec = codec_dai->codec; |
297 | struct uda134x_priv *uda134x = codec->private_data; | 297 | struct uda134x_priv *uda134x = codec->private_data; |
298 | 298 | ||
299 | pr_debug("%s clk_id: %d, freq: %d, dir: %d\n", __func__, | 299 | pr_debug("%s clk_id: %d, freq: %u, dir: %d\n", __func__, |
300 | clk_id, freq, dir); | 300 | clk_id, freq, dir); |
301 | 301 | ||
302 | /* Anything between 256fs*8Khz and 512fs*48Khz should be acceptable | 302 | /* Anything between 256fs*8Khz and 512fs*48Khz should be acceptable |
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 0275321ff8ab..e7348d341b76 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c | |||
@@ -1108,7 +1108,7 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai, | |||
1108 | if (ret < 0) | 1108 | if (ret < 0) |
1109 | return ret; | 1109 | return ret; |
1110 | dev_dbg(wm8350->dev, | 1110 | dev_dbg(wm8350->dev, |
1111 | "FLL in %d FLL out %d N 0x%x K 0x%x div %d ratio %d", | 1111 | "FLL in %u FLL out %u N 0x%x K 0x%x div %d ratio %d", |
1112 | freq_in, freq_out, fll_div.n, fll_div.k, fll_div.div, | 1112 | freq_in, freq_out, fll_div.n, fll_div.k, fll_div.div, |
1113 | fll_div.ratio); | 1113 | fll_div.ratio); |
1114 | 1114 | ||
diff --git a/sound/soc/codecs/wm8350.h b/sound/soc/codecs/wm8350.h index d11bd9288cf9..d088eb4b88bb 100644 --- a/sound/soc/codecs/wm8350.h +++ b/sound/soc/codecs/wm8350.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #define _WM8350_H | 13 | #define _WM8350_H |
14 | 14 | ||
15 | #include <sound/soc.h> | 15 | #include <sound/soc.h> |
16 | #include <linux/mfd/wm8350/audio.h> | ||
16 | 17 | ||
17 | extern struct snd_soc_dai wm8350_dai; | 18 | extern struct snd_soc_dai wm8350_dai; |
18 | extern struct snd_soc_codec_device soc_codec_dev_wm8350; | 19 | extern struct snd_soc_codec_device soc_codec_dev_wm8350; |
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 510efa604008..502eefac1ecd 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c | |||
@@ -954,7 +954,7 @@ static int fll_factors(struct wm8400_priv *wm8400, struct fll_factors *factors, | |||
954 | factors->outdiv *= 2; | 954 | factors->outdiv *= 2; |
955 | if (factors->outdiv > 32) { | 955 | if (factors->outdiv > 32) { |
956 | dev_err(wm8400->wm8400->dev, | 956 | dev_err(wm8400->wm8400->dev, |
957 | "Unsupported FLL output frequency %dHz\n", | 957 | "Unsupported FLL output frequency %uHz\n", |
958 | Fout); | 958 | Fout); |
959 | return -EINVAL; | 959 | return -EINVAL; |
960 | } | 960 | } |
@@ -1003,7 +1003,7 @@ static int fll_factors(struct wm8400_priv *wm8400, struct fll_factors *factors, | |||
1003 | factors->k = K / 10; | 1003 | factors->k = K / 10; |
1004 | 1004 | ||
1005 | dev_dbg(wm8400->wm8400->dev, | 1005 | dev_dbg(wm8400->wm8400->dev, |
1006 | "FLL: Fref=%d Fout=%d N=%x K=%x, FRATIO=%x OUTDIV=%x\n", | 1006 | "FLL: Fref=%u Fout=%u N=%x K=%x, FRATIO=%x OUTDIV=%x\n", |
1007 | Fref, Fout, | 1007 | Fref, Fout, |
1008 | factors->n, factors->k, factors->fratio, factors->outdiv); | 1008 | factors->n, factors->k, factors->fratio, factors->outdiv); |
1009 | 1009 | ||
@@ -1473,8 +1473,8 @@ static int wm8400_codec_probe(struct platform_device *dev) | |||
1473 | 1473 | ||
1474 | codec = &priv->codec; | 1474 | codec = &priv->codec; |
1475 | codec->private_data = priv; | 1475 | codec->private_data = priv; |
1476 | codec->control_data = dev->dev.driver_data; | 1476 | codec->control_data = dev_get_drvdata(&dev->dev); |
1477 | priv->wm8400 = dev->dev.driver_data; | 1477 | priv->wm8400 = dev_get_drvdata(&dev->dev); |
1478 | 1478 | ||
1479 | ret = regulator_bulk_get(priv->wm8400->dev, | 1479 | ret = regulator_bulk_get(priv->wm8400->dev, |
1480 | ARRAY_SIZE(power), &power[0]); | 1480 | ARRAY_SIZE(power), &power[0]); |
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index 6a4cea09c45d..c8b8dba85890 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c | |||
@@ -298,7 +298,7 @@ static void pll_factors(unsigned int target, unsigned int source) | |||
298 | 298 | ||
299 | if ((Ndiv < 6) || (Ndiv > 12)) | 299 | if ((Ndiv < 6) || (Ndiv > 12)) |
300 | printk(KERN_WARNING | 300 | printk(KERN_WARNING |
301 | "WM8510 N value %d outwith recommended range!d\n", | 301 | "WM8510 N value %u outwith recommended range!d\n", |
302 | Ndiv); | 302 | Ndiv); |
303 | 303 | ||
304 | pll_div.n = Ndiv; | 304 | pll_div.n = Ndiv; |
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 9f6be3d31ac0..86c4b24db817 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c | |||
@@ -415,7 +415,7 @@ static int pll_factors(struct _pll_div *pll_div, unsigned int target, | |||
415 | unsigned int K, Ndiv, Nmod; | 415 | unsigned int K, Ndiv, Nmod; |
416 | int i; | 416 | int i; |
417 | 417 | ||
418 | pr_debug("wm8580: PLL %dHz->%dHz\n", source, target); | 418 | pr_debug("wm8580: PLL %uHz->%uHz\n", source, target); |
419 | 419 | ||
420 | /* Scale the output frequency up; the PLL should run in the | 420 | /* Scale the output frequency up; the PLL should run in the |
421 | * region of 90-100MHz. | 421 | * region of 90-100MHz. |
@@ -447,7 +447,7 @@ static int pll_factors(struct _pll_div *pll_div, unsigned int target, | |||
447 | 447 | ||
448 | if ((Ndiv < 5) || (Ndiv > 13)) { | 448 | if ((Ndiv < 5) || (Ndiv > 13)) { |
449 | printk(KERN_ERR | 449 | printk(KERN_ERR |
450 | "WM8580 N=%d outside supported range\n", Ndiv); | 450 | "WM8580 N=%u outside supported range\n", Ndiv); |
451 | return -EINVAL; | 451 | return -EINVAL; |
452 | } | 452 | } |
453 | 453 | ||
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index e043e3f60008..7a205876ef4f 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c | |||
@@ -666,14 +666,14 @@ static int __devinit wm8731_spi_probe(struct spi_device *spi) | |||
666 | codec->hw_write = (hw_write_t)wm8731_spi_write; | 666 | codec->hw_write = (hw_write_t)wm8731_spi_write; |
667 | codec->dev = &spi->dev; | 667 | codec->dev = &spi->dev; |
668 | 668 | ||
669 | spi->dev.driver_data = wm8731; | 669 | dev_set_drvdata(&spi->dev, wm8731); |
670 | 670 | ||
671 | return wm8731_register(wm8731); | 671 | return wm8731_register(wm8731); |
672 | } | 672 | } |
673 | 673 | ||
674 | static int __devexit wm8731_spi_remove(struct spi_device *spi) | 674 | static int __devexit wm8731_spi_remove(struct spi_device *spi) |
675 | { | 675 | { |
676 | struct wm8731_priv *wm8731 = spi->dev.driver_data; | 676 | struct wm8731_priv *wm8731 = dev_get_drvdata(&spi->dev); |
677 | 677 | ||
678 | wm8731_unregister(wm8731); | 678 | wm8731_unregister(wm8731); |
679 | 679 | ||
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index a6e8f3f7f052..d28eeaceb857 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c | |||
@@ -703,7 +703,7 @@ static void pll_factors(struct _pll_div *pll_div, unsigned int target, | |||
703 | 703 | ||
704 | if ((Ndiv < 6) || (Ndiv > 12)) | 704 | if ((Ndiv < 6) || (Ndiv > 12)) |
705 | printk(KERN_WARNING | 705 | printk(KERN_WARNING |
706 | "wm8753: unsupported N = %d\n", Ndiv); | 706 | "wm8753: unsupported N = %u\n", Ndiv); |
707 | 707 | ||
708 | pll_div->n = Ndiv; | 708 | pll_div->n = Ndiv; |
709 | Nmod = target % source; | 709 | Nmod = target % source; |
@@ -1822,14 +1822,14 @@ static int __devinit wm8753_spi_probe(struct spi_device *spi) | |||
1822 | codec->hw_write = (hw_write_t)wm8753_spi_write; | 1822 | codec->hw_write = (hw_write_t)wm8753_spi_write; |
1823 | codec->dev = &spi->dev; | 1823 | codec->dev = &spi->dev; |
1824 | 1824 | ||
1825 | spi->dev.driver_data = wm8753; | 1825 | dev_set_drvdata(&spi->dev, wm8753); |
1826 | 1826 | ||
1827 | return wm8753_register(wm8753); | 1827 | return wm8753_register(wm8753); |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | static int __devexit wm8753_spi_remove(struct spi_device *spi) | 1830 | static int __devexit wm8753_spi_remove(struct spi_device *spi) |
1831 | { | 1831 | { |
1832 | struct wm8753_priv *wm8753 = spi->dev.driver_data; | 1832 | struct wm8753_priv *wm8753 = dev_get_drvdata(&spi->dev); |
1833 | wm8753_unregister(wm8753); | 1833 | wm8753_unregister(wm8753); |
1834 | return 0; | 1834 | return 0; |
1835 | } | 1835 | } |
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 46c5ea1ff921..3c78945244b8 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c | |||
@@ -778,11 +778,11 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, | |||
778 | } | 778 | } |
779 | 779 | ||
780 | if (target > 100000000) | 780 | if (target > 100000000) |
781 | printk(KERN_WARNING "wm8900: FLL rate %d out of range, Fref=%d" | 781 | printk(KERN_WARNING "wm8900: FLL rate %u out of range, Fref=%u" |
782 | " Fout=%d\n", target, Fref, Fout); | 782 | " Fout=%u\n", target, Fref, Fout); |
783 | if (div > 32) { | 783 | if (div > 32) { |
784 | printk(KERN_ERR "wm8900: Invalid FLL division rate %u, " | 784 | printk(KERN_ERR "wm8900: Invalid FLL division rate %u, " |
785 | "Fref=%d, Fout=%d, target=%d\n", | 785 | "Fref=%u, Fout=%u, target=%u\n", |
786 | div, Fref, Fout, target); | 786 | div, Fref, Fout, target); |
787 | return -EINVAL; | 787 | return -EINVAL; |
788 | } | 788 | } |
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index 8cf571f1a803..e8d2e3e14c45 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
@@ -217,7 +217,6 @@ struct wm8903_priv { | |||
217 | int sysclk; | 217 | int sysclk; |
218 | 218 | ||
219 | /* Reference counts */ | 219 | /* Reference counts */ |
220 | int charge_pump_users; | ||
221 | int class_w_users; | 220 | int class_w_users; |
222 | int playback_active; | 221 | int playback_active; |
223 | int capture_active; | 222 | int capture_active; |
@@ -373,6 +372,15 @@ static void wm8903_reset(struct snd_soc_codec *codec) | |||
373 | #define WM8903_OUTPUT_INT 0x2 | 372 | #define WM8903_OUTPUT_INT 0x2 |
374 | #define WM8903_OUTPUT_IN 0x1 | 373 | #define WM8903_OUTPUT_IN 0x1 |
375 | 374 | ||
375 | static int wm8903_cp_event(struct snd_soc_dapm_widget *w, | ||
376 | struct snd_kcontrol *kcontrol, int event) | ||
377 | { | ||
378 | WARN_ON(event != SND_SOC_DAPM_POST_PMU); | ||
379 | mdelay(4); | ||
380 | |||
381 | return 0; | ||
382 | } | ||
383 | |||
376 | /* | 384 | /* |
377 | * Event for headphone and line out amplifier power changes. Special | 385 | * Event for headphone and line out amplifier power changes. Special |
378 | * power up/down sequences are required in order to maximise pop/click | 386 | * power up/down sequences are required in order to maximise pop/click |
@@ -382,19 +390,20 @@ static int wm8903_output_event(struct snd_soc_dapm_widget *w, | |||
382 | struct snd_kcontrol *kcontrol, int event) | 390 | struct snd_kcontrol *kcontrol, int event) |
383 | { | 391 | { |
384 | struct snd_soc_codec *codec = w->codec; | 392 | struct snd_soc_codec *codec = w->codec; |
385 | struct wm8903_priv *wm8903 = codec->private_data; | ||
386 | struct i2c_client *i2c = codec->control_data; | ||
387 | u16 val; | 393 | u16 val; |
388 | u16 reg; | 394 | u16 reg; |
395 | u16 dcs_reg; | ||
396 | u16 dcs_bit; | ||
389 | int shift; | 397 | int shift; |
390 | u16 cp_reg = wm8903_read(codec, WM8903_CHARGE_PUMP_0); | ||
391 | 398 | ||
392 | switch (w->reg) { | 399 | switch (w->reg) { |
393 | case WM8903_POWER_MANAGEMENT_2: | 400 | case WM8903_POWER_MANAGEMENT_2: |
394 | reg = WM8903_ANALOGUE_HP_0; | 401 | reg = WM8903_ANALOGUE_HP_0; |
402 | dcs_bit = 0 + w->shift; | ||
395 | break; | 403 | break; |
396 | case WM8903_POWER_MANAGEMENT_3: | 404 | case WM8903_POWER_MANAGEMENT_3: |
397 | reg = WM8903_ANALOGUE_LINEOUT_0; | 405 | reg = WM8903_ANALOGUE_LINEOUT_0; |
406 | dcs_bit = 2 + w->shift; | ||
398 | break; | 407 | break; |
399 | default: | 408 | default: |
400 | BUG(); | 409 | BUG(); |
@@ -419,18 +428,6 @@ static int wm8903_output_event(struct snd_soc_dapm_widget *w, | |||
419 | /* Short the output */ | 428 | /* Short the output */ |
420 | val &= ~(WM8903_OUTPUT_SHORT << shift); | 429 | val &= ~(WM8903_OUTPUT_SHORT << shift); |
421 | wm8903_write(codec, reg, val); | 430 | wm8903_write(codec, reg, val); |
422 | |||
423 | wm8903->charge_pump_users++; | ||
424 | |||
425 | dev_dbg(&i2c->dev, "Charge pump use count now %d\n", | ||
426 | wm8903->charge_pump_users); | ||
427 | |||
428 | if (wm8903->charge_pump_users == 1) { | ||
429 | dev_dbg(&i2c->dev, "Enabling charge pump\n"); | ||
430 | wm8903_write(codec, WM8903_CHARGE_PUMP_0, | ||
431 | cp_reg | WM8903_CP_ENA); | ||
432 | mdelay(4); | ||
433 | } | ||
434 | } | 431 | } |
435 | 432 | ||
436 | if (event & SND_SOC_DAPM_POST_PMU) { | 433 | if (event & SND_SOC_DAPM_POST_PMU) { |
@@ -446,6 +443,11 @@ static int wm8903_output_event(struct snd_soc_dapm_widget *w, | |||
446 | val |= (WM8903_OUTPUT_OUT << shift); | 443 | val |= (WM8903_OUTPUT_OUT << shift); |
447 | wm8903_write(codec, reg, val); | 444 | wm8903_write(codec, reg, val); |
448 | 445 | ||
446 | /* Enable the DC servo */ | ||
447 | dcs_reg = wm8903_read(codec, WM8903_DC_SERVO_0); | ||
448 | dcs_reg |= dcs_bit; | ||
449 | wm8903_write(codec, WM8903_DC_SERVO_0, dcs_reg); | ||
450 | |||
449 | /* Remove the short */ | 451 | /* Remove the short */ |
450 | val |= (WM8903_OUTPUT_SHORT << shift); | 452 | val |= (WM8903_OUTPUT_SHORT << shift); |
451 | wm8903_write(codec, reg, val); | 453 | wm8903_write(codec, reg, val); |
@@ -458,25 +460,17 @@ static int wm8903_output_event(struct snd_soc_dapm_widget *w, | |||
458 | val &= ~(WM8903_OUTPUT_SHORT << shift); | 460 | val &= ~(WM8903_OUTPUT_SHORT << shift); |
459 | wm8903_write(codec, reg, val); | 461 | wm8903_write(codec, reg, val); |
460 | 462 | ||
463 | /* Disable the DC servo */ | ||
464 | dcs_reg = wm8903_read(codec, WM8903_DC_SERVO_0); | ||
465 | dcs_reg &= ~dcs_bit; | ||
466 | wm8903_write(codec, WM8903_DC_SERVO_0, dcs_reg); | ||
467 | |||
461 | /* Then disable the intermediate and output stages */ | 468 | /* Then disable the intermediate and output stages */ |
462 | val &= ~((WM8903_OUTPUT_OUT | WM8903_OUTPUT_INT | | 469 | val &= ~((WM8903_OUTPUT_OUT | WM8903_OUTPUT_INT | |
463 | WM8903_OUTPUT_IN) << shift); | 470 | WM8903_OUTPUT_IN) << shift); |
464 | wm8903_write(codec, reg, val); | 471 | wm8903_write(codec, reg, val); |
465 | } | 472 | } |
466 | 473 | ||
467 | if (event & SND_SOC_DAPM_POST_PMD) { | ||
468 | wm8903->charge_pump_users--; | ||
469 | |||
470 | dev_dbg(&i2c->dev, "Charge pump use count now %d\n", | ||
471 | wm8903->charge_pump_users); | ||
472 | |||
473 | if (wm8903->charge_pump_users == 0) { | ||
474 | dev_dbg(&i2c->dev, "Disabling charge pump\n"); | ||
475 | wm8903_write(codec, WM8903_CHARGE_PUMP_0, | ||
476 | cp_reg & ~WM8903_CP_ENA); | ||
477 | } | ||
478 | } | ||
479 | |||
480 | return 0; | 474 | return 0; |
481 | } | 475 | } |
482 | 476 | ||
@@ -539,6 +533,7 @@ static int wm8903_class_w_put(struct snd_kcontrol *kcontrol, | |||
539 | /* ALSA can only do steps of .01dB */ | 533 | /* ALSA can only do steps of .01dB */ |
540 | static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1); | 534 | static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1); |
541 | 535 | ||
536 | static const DECLARE_TLV_DB_SCALE(digital_sidetone_tlv, -3600, 300, 0); | ||
542 | static const DECLARE_TLV_DB_SCALE(out_tlv, -5700, 100, 0); | 537 | static const DECLARE_TLV_DB_SCALE(out_tlv, -5700, 100, 0); |
543 | 538 | ||
544 | static const DECLARE_TLV_DB_SCALE(drc_tlv_thresh, 0, 75, 0); | 539 | static const DECLARE_TLV_DB_SCALE(drc_tlv_thresh, 0, 75, 0); |
@@ -657,6 +652,16 @@ static const struct soc_enum rinput_inv_enum = | |||
657 | SOC_ENUM_SINGLE(WM8903_ANALOGUE_RIGHT_INPUT_1, 4, 3, rinput_mux_text); | 652 | SOC_ENUM_SINGLE(WM8903_ANALOGUE_RIGHT_INPUT_1, 4, 3, rinput_mux_text); |
658 | 653 | ||
659 | 654 | ||
655 | static const char *sidetone_text[] = { | ||
656 | "None", "Left", "Right" | ||
657 | }; | ||
658 | |||
659 | static const struct soc_enum lsidetone_enum = | ||
660 | SOC_ENUM_SINGLE(WM8903_DAC_DIGITAL_0, 2, 3, sidetone_text); | ||
661 | |||
662 | static const struct soc_enum rsidetone_enum = | ||
663 | SOC_ENUM_SINGLE(WM8903_DAC_DIGITAL_0, 0, 3, sidetone_text); | ||
664 | |||
660 | static const struct snd_kcontrol_new wm8903_snd_controls[] = { | 665 | static const struct snd_kcontrol_new wm8903_snd_controls[] = { |
661 | 666 | ||
662 | /* Input PGAs - No TLV since the scale depends on PGA mode */ | 667 | /* Input PGAs - No TLV since the scale depends on PGA mode */ |
@@ -700,6 +705,9 @@ SOC_DOUBLE_R_TLV("Digital Capture Volume", WM8903_ADC_DIGITAL_VOLUME_LEFT, | |||
700 | SOC_ENUM("ADC Companding Mode", adc_companding), | 705 | SOC_ENUM("ADC Companding Mode", adc_companding), |
701 | SOC_SINGLE("ADC Companding Switch", WM8903_AUDIO_INTERFACE_0, 3, 1, 0), | 706 | SOC_SINGLE("ADC Companding Switch", WM8903_AUDIO_INTERFACE_0, 3, 1, 0), |
702 | 707 | ||
708 | SOC_DOUBLE_TLV("Digital Sidetone Volume", WM8903_DAC_DIGITAL_0, 4, 8, | ||
709 | 12, 0, digital_sidetone_tlv), | ||
710 | |||
703 | /* DAC */ | 711 | /* DAC */ |
704 | SOC_DOUBLE_R_TLV("Digital Playback Volume", WM8903_DAC_DIGITAL_VOLUME_LEFT, | 712 | SOC_DOUBLE_R_TLV("Digital Playback Volume", WM8903_DAC_DIGITAL_VOLUME_LEFT, |
705 | WM8903_DAC_DIGITAL_VOLUME_RIGHT, 1, 120, 0, digital_tlv), | 713 | WM8903_DAC_DIGITAL_VOLUME_RIGHT, 1, 120, 0, digital_tlv), |
@@ -762,6 +770,12 @@ static const struct snd_kcontrol_new rinput_mux = | |||
762 | static const struct snd_kcontrol_new rinput_inv_mux = | 770 | static const struct snd_kcontrol_new rinput_inv_mux = |
763 | SOC_DAPM_ENUM("Right Inverting Input Mux", rinput_inv_enum); | 771 | SOC_DAPM_ENUM("Right Inverting Input Mux", rinput_inv_enum); |
764 | 772 | ||
773 | static const struct snd_kcontrol_new lsidetone_mux = | ||
774 | SOC_DAPM_ENUM("DACL Sidetone Mux", lsidetone_enum); | ||
775 | |||
776 | static const struct snd_kcontrol_new rsidetone_mux = | ||
777 | SOC_DAPM_ENUM("DACR Sidetone Mux", rsidetone_enum); | ||
778 | |||
765 | static const struct snd_kcontrol_new left_output_mixer[] = { | 779 | static const struct snd_kcontrol_new left_output_mixer[] = { |
766 | SOC_DAPM_SINGLE("DACL Switch", WM8903_ANALOGUE_LEFT_MIX_0, 3, 1, 0), | 780 | SOC_DAPM_SINGLE("DACL Switch", WM8903_ANALOGUE_LEFT_MIX_0, 3, 1, 0), |
767 | SOC_DAPM_SINGLE("DACR Switch", WM8903_ANALOGUE_LEFT_MIX_0, 2, 1, 0), | 781 | SOC_DAPM_SINGLE("DACR Switch", WM8903_ANALOGUE_LEFT_MIX_0, 2, 1, 0), |
@@ -828,6 +842,9 @@ SND_SOC_DAPM_PGA("Right Input PGA", WM8903_POWER_MANAGEMENT_0, 0, 0, NULL, 0), | |||
828 | SND_SOC_DAPM_ADC("ADCL", "Left HiFi Capture", WM8903_POWER_MANAGEMENT_6, 1, 0), | 842 | SND_SOC_DAPM_ADC("ADCL", "Left HiFi Capture", WM8903_POWER_MANAGEMENT_6, 1, 0), |
829 | SND_SOC_DAPM_ADC("ADCR", "Right HiFi Capture", WM8903_POWER_MANAGEMENT_6, 0, 0), | 843 | SND_SOC_DAPM_ADC("ADCR", "Right HiFi Capture", WM8903_POWER_MANAGEMENT_6, 0, 0), |
830 | 844 | ||
845 | SND_SOC_DAPM_MUX("DACL Sidetone", SND_SOC_NOPM, 0, 0, &lsidetone_mux), | ||
846 | SND_SOC_DAPM_MUX("DACR Sidetone", SND_SOC_NOPM, 0, 0, &rsidetone_mux), | ||
847 | |||
831 | SND_SOC_DAPM_DAC("DACL", "Left Playback", WM8903_POWER_MANAGEMENT_6, 3, 0), | 848 | SND_SOC_DAPM_DAC("DACL", "Left Playback", WM8903_POWER_MANAGEMENT_6, 3, 0), |
832 | SND_SOC_DAPM_DAC("DACR", "Right Playback", WM8903_POWER_MANAGEMENT_6, 2, 0), | 849 | SND_SOC_DAPM_DAC("DACR", "Right Playback", WM8903_POWER_MANAGEMENT_6, 2, 0), |
833 | 850 | ||
@@ -844,26 +861,29 @@ SND_SOC_DAPM_MIXER("Right Speaker Mixer", WM8903_POWER_MANAGEMENT_4, 0, 0, | |||
844 | SND_SOC_DAPM_PGA_E("Left Headphone Output PGA", WM8903_POWER_MANAGEMENT_2, | 861 | SND_SOC_DAPM_PGA_E("Left Headphone Output PGA", WM8903_POWER_MANAGEMENT_2, |
845 | 1, 0, NULL, 0, wm8903_output_event, | 862 | 1, 0, NULL, 0, wm8903_output_event, |
846 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | | 863 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
847 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), | 864 | SND_SOC_DAPM_PRE_PMD), |
848 | SND_SOC_DAPM_PGA_E("Right Headphone Output PGA", WM8903_POWER_MANAGEMENT_2, | 865 | SND_SOC_DAPM_PGA_E("Right Headphone Output PGA", WM8903_POWER_MANAGEMENT_2, |
849 | 0, 0, NULL, 0, wm8903_output_event, | 866 | 0, 0, NULL, 0, wm8903_output_event, |
850 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | | 867 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
851 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), | 868 | SND_SOC_DAPM_PRE_PMD), |
852 | 869 | ||
853 | SND_SOC_DAPM_PGA_E("Left Line Output PGA", WM8903_POWER_MANAGEMENT_3, 1, 0, | 870 | SND_SOC_DAPM_PGA_E("Left Line Output PGA", WM8903_POWER_MANAGEMENT_3, 1, 0, |
854 | NULL, 0, wm8903_output_event, | 871 | NULL, 0, wm8903_output_event, |
855 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | | 872 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
856 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), | 873 | SND_SOC_DAPM_PRE_PMD), |
857 | SND_SOC_DAPM_PGA_E("Right Line Output PGA", WM8903_POWER_MANAGEMENT_3, 0, 0, | 874 | SND_SOC_DAPM_PGA_E("Right Line Output PGA", WM8903_POWER_MANAGEMENT_3, 0, 0, |
858 | NULL, 0, wm8903_output_event, | 875 | NULL, 0, wm8903_output_event, |
859 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | | 876 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | |
860 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), | 877 | SND_SOC_DAPM_PRE_PMD), |
861 | 878 | ||
862 | SND_SOC_DAPM_PGA("Left Speaker PGA", WM8903_POWER_MANAGEMENT_5, 1, 0, | 879 | SND_SOC_DAPM_PGA("Left Speaker PGA", WM8903_POWER_MANAGEMENT_5, 1, 0, |
863 | NULL, 0), | 880 | NULL, 0), |
864 | SND_SOC_DAPM_PGA("Right Speaker PGA", WM8903_POWER_MANAGEMENT_5, 0, 0, | 881 | SND_SOC_DAPM_PGA("Right Speaker PGA", WM8903_POWER_MANAGEMENT_5, 0, 0, |
865 | NULL, 0), | 882 | NULL, 0), |
866 | 883 | ||
884 | SND_SOC_DAPM_SUPPLY("Charge Pump", WM8903_CHARGE_PUMP_0, 0, 0, | ||
885 | wm8903_cp_event, SND_SOC_DAPM_POST_PMU), | ||
886 | SND_SOC_DAPM_SUPPLY("CLK_DSP", WM8903_CLOCK_RATES_2, 1, 0, NULL, 0), | ||
867 | }; | 887 | }; |
868 | 888 | ||
869 | static const struct snd_soc_dapm_route intercon[] = { | 889 | static const struct snd_soc_dapm_route intercon[] = { |
@@ -909,7 +929,19 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
909 | { "Right Input PGA", NULL, "Right Input Mode Mux" }, | 929 | { "Right Input PGA", NULL, "Right Input Mode Mux" }, |
910 | 930 | ||
911 | { "ADCL", NULL, "Left Input PGA" }, | 931 | { "ADCL", NULL, "Left Input PGA" }, |
932 | { "ADCL", NULL, "CLK_DSP" }, | ||
912 | { "ADCR", NULL, "Right Input PGA" }, | 933 | { "ADCR", NULL, "Right Input PGA" }, |
934 | { "ADCR", NULL, "CLK_DSP" }, | ||
935 | |||
936 | { "DACL Sidetone", "Left", "ADCL" }, | ||
937 | { "DACL Sidetone", "Right", "ADCR" }, | ||
938 | { "DACR Sidetone", "Left", "ADCL" }, | ||
939 | { "DACR Sidetone", "Right", "ADCR" }, | ||
940 | |||
941 | { "DACL", NULL, "DACL Sidetone" }, | ||
942 | { "DACL", NULL, "CLK_DSP" }, | ||
943 | { "DACR", NULL, "DACR Sidetone" }, | ||
944 | { "DACR", NULL, "CLK_DSP" }, | ||
913 | 945 | ||
914 | { "Left Output Mixer", "Left Bypass Switch", "Left Input PGA" }, | 946 | { "Left Output Mixer", "Left Bypass Switch", "Left Input PGA" }, |
915 | { "Left Output Mixer", "Right Bypass Switch", "Right Input PGA" }, | 947 | { "Left Output Mixer", "Right Bypass Switch", "Right Input PGA" }, |
@@ -951,6 +983,11 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
951 | 983 | ||
952 | { "ROP", NULL, "Right Speaker PGA" }, | 984 | { "ROP", NULL, "Right Speaker PGA" }, |
953 | { "RON", NULL, "Right Speaker PGA" }, | 985 | { "RON", NULL, "Right Speaker PGA" }, |
986 | |||
987 | { "Left Headphone Output PGA", NULL, "Charge Pump" }, | ||
988 | { "Right Headphone Output PGA", NULL, "Charge Pump" }, | ||
989 | { "Left Line Output PGA", NULL, "Charge Pump" }, | ||
990 | { "Right Line Output PGA", NULL, "Charge Pump" }, | ||
954 | }; | 991 | }; |
955 | 992 | ||
956 | static int wm8903_add_widgets(struct snd_soc_codec *codec) | 993 | static int wm8903_add_widgets(struct snd_soc_codec *codec) |
@@ -985,6 +1022,11 @@ static int wm8903_set_bias_level(struct snd_soc_codec *codec, | |||
985 | wm8903_write(codec, WM8903_CLOCK_RATES_2, | 1022 | wm8903_write(codec, WM8903_CLOCK_RATES_2, |
986 | WM8903_CLK_SYS_ENA); | 1023 | WM8903_CLK_SYS_ENA); |
987 | 1024 | ||
1025 | /* Change DC servo dither level in startup sequence */ | ||
1026 | wm8903_write(codec, WM8903_WRITE_SEQUENCER_0, 0x11); | ||
1027 | wm8903_write(codec, WM8903_WRITE_SEQUENCER_1, 0x1257); | ||
1028 | wm8903_write(codec, WM8903_WRITE_SEQUENCER_2, 0x2); | ||
1029 | |||
988 | wm8903_run_sequence(codec, 0); | 1030 | wm8903_run_sequence(codec, 0); |
989 | wm8903_sync_reg_cache(codec, codec->reg_cache); | 1031 | wm8903_sync_reg_cache(codec, codec->reg_cache); |
990 | 1032 | ||
@@ -1215,22 +1257,18 @@ static struct { | |||
1215 | int div; | 1257 | int div; |
1216 | } bclk_divs[] = { | 1258 | } bclk_divs[] = { |
1217 | { 10, 0 }, | 1259 | { 10, 0 }, |
1218 | { 15, 1 }, | ||
1219 | { 20, 2 }, | 1260 | { 20, 2 }, |
1220 | { 30, 3 }, | 1261 | { 30, 3 }, |
1221 | { 40, 4 }, | 1262 | { 40, 4 }, |
1222 | { 50, 5 }, | 1263 | { 50, 5 }, |
1223 | { 55, 6 }, | ||
1224 | { 60, 7 }, | 1264 | { 60, 7 }, |
1225 | { 80, 8 }, | 1265 | { 80, 8 }, |
1226 | { 100, 9 }, | 1266 | { 100, 9 }, |
1227 | { 110, 10 }, | ||
1228 | { 120, 11 }, | 1267 | { 120, 11 }, |
1229 | { 160, 12 }, | 1268 | { 160, 12 }, |
1230 | { 200, 13 }, | 1269 | { 200, 13 }, |
1231 | { 220, 14 }, | 1270 | { 220, 14 }, |
1232 | { 240, 15 }, | 1271 | { 240, 15 }, |
1233 | { 250, 16 }, | ||
1234 | { 300, 17 }, | 1272 | { 300, 17 }, |
1235 | { 320, 18 }, | 1273 | { 320, 18 }, |
1236 | { 440, 19 }, | 1274 | { 440, 19 }, |
@@ -1277,14 +1315,8 @@ static int wm8903_startup(struct snd_pcm_substream *substream, | |||
1277 | if (wm8903->master_substream) { | 1315 | if (wm8903->master_substream) { |
1278 | master_runtime = wm8903->master_substream->runtime; | 1316 | master_runtime = wm8903->master_substream->runtime; |
1279 | 1317 | ||
1280 | dev_dbg(&i2c->dev, "Constraining to %d bits at %dHz\n", | 1318 | dev_dbg(&i2c->dev, "Constraining to %d bits\n", |
1281 | master_runtime->sample_bits, | 1319 | master_runtime->sample_bits); |
1282 | master_runtime->rate); | ||
1283 | |||
1284 | snd_pcm_hw_constraint_minmax(substream->runtime, | ||
1285 | SNDRV_PCM_HW_PARAM_RATE, | ||
1286 | master_runtime->rate, | ||
1287 | master_runtime->rate); | ||
1288 | 1320 | ||
1289 | snd_pcm_hw_constraint_minmax(substream->runtime, | 1321 | snd_pcm_hw_constraint_minmax(substream->runtime, |
1290 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, | 1322 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, |
@@ -1523,6 +1555,7 @@ struct snd_soc_dai wm8903_dai = { | |||
1523 | .formats = WM8903_FORMATS, | 1555 | .formats = WM8903_FORMATS, |
1524 | }, | 1556 | }, |
1525 | .ops = &wm8903_dai_ops, | 1557 | .ops = &wm8903_dai_ops, |
1558 | .symmetric_rates = 1, | ||
1526 | }; | 1559 | }; |
1527 | EXPORT_SYMBOL_GPL(wm8903_dai); | 1560 | EXPORT_SYMBOL_GPL(wm8903_dai); |
1528 | 1561 | ||
diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c new file mode 100644 index 000000000000..b8e17d6bc1f7 --- /dev/null +++ b/sound/soc/codecs/wm8940.c | |||
@@ -0,0 +1,955 @@ | |||
1 | /* | ||
2 | * wm8940.c -- WM8940 ALSA Soc Audio driver | ||
3 | * | ||
4 | * Author: Jonathan Cameron <jic23@cam.ac.uk> | ||
5 | * | ||
6 | * Based on wm8510.c | ||
7 | * Copyright 2006 Wolfson Microelectronics PLC. | ||
8 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | * Not currently handled: | ||
15 | * Notch filter control | ||
16 | * AUXMode (inverting vs mixer) | ||
17 | * No means to obtain current gain if alc enabled. | ||
18 | * No use made of gpio | ||
19 | * Fast VMID discharge for power down | ||
20 | * Soft Start | ||
21 | * DLR and ALR Swaps not enabled | ||
22 | * Digital Sidetone not supported | ||
23 | */ | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/moduleparam.h> | ||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/init.h> | ||
28 | #include <linux/delay.h> | ||
29 | #include <linux/pm.h> | ||
30 | #include <linux/i2c.h> | ||
31 | #include <linux/platform_device.h> | ||
32 | #include <linux/spi/spi.h> | ||
33 | #include <sound/core.h> | ||
34 | #include <sound/pcm.h> | ||
35 | #include <sound/pcm_params.h> | ||
36 | #include <sound/soc.h> | ||
37 | #include <sound/soc-dapm.h> | ||
38 | #include <sound/initval.h> | ||
39 | #include <sound/tlv.h> | ||
40 | |||
41 | #include "wm8940.h" | ||
42 | |||
43 | struct wm8940_priv { | ||
44 | unsigned int sysclk; | ||
45 | u16 reg_cache[WM8940_CACHEREGNUM]; | ||
46 | struct snd_soc_codec codec; | ||
47 | }; | ||
48 | |||
49 | static u16 wm8940_reg_defaults[] = { | ||
50 | 0x8940, /* Soft Reset */ | ||
51 | 0x0000, /* Power 1 */ | ||
52 | 0x0000, /* Power 2 */ | ||
53 | 0x0000, /* Power 3 */ | ||
54 | 0x0010, /* Interface Control */ | ||
55 | 0x0000, /* Companding Control */ | ||
56 | 0x0140, /* Clock Control */ | ||
57 | 0x0000, /* Additional Controls */ | ||
58 | 0x0000, /* GPIO Control */ | ||
59 | 0x0002, /* Auto Increment Control */ | ||
60 | 0x0000, /* DAC Control */ | ||
61 | 0x00FF, /* DAC Volume */ | ||
62 | 0, | ||
63 | 0, | ||
64 | 0x0100, /* ADC Control */ | ||
65 | 0x00FF, /* ADC Volume */ | ||
66 | 0x0000, /* Notch Filter 1 Control 1 */ | ||
67 | 0x0000, /* Notch Filter 1 Control 2 */ | ||
68 | 0x0000, /* Notch Filter 2 Control 1 */ | ||
69 | 0x0000, /* Notch Filter 2 Control 2 */ | ||
70 | 0x0000, /* Notch Filter 3 Control 1 */ | ||
71 | 0x0000, /* Notch Filter 3 Control 2 */ | ||
72 | 0x0000, /* Notch Filter 4 Control 1 */ | ||
73 | 0x0000, /* Notch Filter 4 Control 2 */ | ||
74 | 0x0032, /* DAC Limit Control 1 */ | ||
75 | 0x0000, /* DAC Limit Control 2 */ | ||
76 | 0, | ||
77 | 0, | ||
78 | 0, | ||
79 | 0, | ||
80 | 0, | ||
81 | 0, | ||
82 | 0x0038, /* ALC Control 1 */ | ||
83 | 0x000B, /* ALC Control 2 */ | ||
84 | 0x0032, /* ALC Control 3 */ | ||
85 | 0x0000, /* Noise Gate */ | ||
86 | 0x0041, /* PLLN */ | ||
87 | 0x000C, /* PLLK1 */ | ||
88 | 0x0093, /* PLLK2 */ | ||
89 | 0x00E9, /* PLLK3 */ | ||
90 | 0, | ||
91 | 0, | ||
92 | 0x0030, /* ALC Control 4 */ | ||
93 | 0, | ||
94 | 0x0002, /* Input Control */ | ||
95 | 0x0050, /* PGA Gain */ | ||
96 | 0, | ||
97 | 0x0002, /* ADC Boost Control */ | ||
98 | 0, | ||
99 | 0x0002, /* Output Control */ | ||
100 | 0x0000, /* Speaker Mixer Control */ | ||
101 | 0, | ||
102 | 0, | ||
103 | 0, | ||
104 | 0x0079, /* Speaker Volume */ | ||
105 | 0, | ||
106 | 0x0000, /* Mono Mixer Control */ | ||
107 | }; | ||
108 | |||
109 | static inline unsigned int wm8940_read_reg_cache(struct snd_soc_codec *codec, | ||
110 | unsigned int reg) | ||
111 | { | ||
112 | u16 *cache = codec->reg_cache; | ||
113 | |||
114 | if (reg >= ARRAY_SIZE(wm8940_reg_defaults)) | ||
115 | return -1; | ||
116 | |||
117 | return cache[reg]; | ||
118 | } | ||
119 | |||
120 | static inline int wm8940_write_reg_cache(struct snd_soc_codec *codec, | ||
121 | u16 reg, unsigned int value) | ||
122 | { | ||
123 | u16 *cache = codec->reg_cache; | ||
124 | |||
125 | if (reg >= ARRAY_SIZE(wm8940_reg_defaults)) | ||
126 | return -1; | ||
127 | |||
128 | cache[reg] = value; | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | static int wm8940_write(struct snd_soc_codec *codec, unsigned int reg, | ||
134 | unsigned int value) | ||
135 | { | ||
136 | int ret; | ||
137 | u8 data[3] = { reg, | ||
138 | (value & 0xff00) >> 8, | ||
139 | (value & 0x00ff) | ||
140 | }; | ||
141 | |||
142 | wm8940_write_reg_cache(codec, reg, value); | ||
143 | |||
144 | ret = codec->hw_write(codec->control_data, data, 3); | ||
145 | |||
146 | if (ret < 0) | ||
147 | return ret; | ||
148 | else if (ret != 3) | ||
149 | return -EIO; | ||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static const char *wm8940_companding[] = { "Off", "NC", "u-law", "A-law" }; | ||
154 | static const struct soc_enum wm8940_adc_companding_enum | ||
155 | = SOC_ENUM_SINGLE(WM8940_COMPANDINGCTL, 1, 4, wm8940_companding); | ||
156 | static const struct soc_enum wm8940_dac_companding_enum | ||
157 | = SOC_ENUM_SINGLE(WM8940_COMPANDINGCTL, 3, 4, wm8940_companding); | ||
158 | |||
159 | static const char *wm8940_alc_mode_text[] = {"ALC", "Limiter"}; | ||
160 | static const struct soc_enum wm8940_alc_mode_enum | ||
161 | = SOC_ENUM_SINGLE(WM8940_ALC3, 8, 2, wm8940_alc_mode_text); | ||
162 | |||
163 | static const char *wm8940_mic_bias_level_text[] = {"0.9", "0.65"}; | ||
164 | static const struct soc_enum wm8940_mic_bias_level_enum | ||
165 | = SOC_ENUM_SINGLE(WM8940_INPUTCTL, 8, 2, wm8940_mic_bias_level_text); | ||
166 | |||
167 | static const char *wm8940_filter_mode_text[] = {"Audio", "Application"}; | ||
168 | static const struct soc_enum wm8940_filter_mode_enum | ||
169 | = SOC_ENUM_SINGLE(WM8940_ADC, 7, 2, wm8940_filter_mode_text); | ||
170 | |||
171 | static DECLARE_TLV_DB_SCALE(wm8940_spk_vol_tlv, -5700, 100, 1); | ||
172 | static DECLARE_TLV_DB_SCALE(wm8940_att_tlv, -1000, 1000, 0); | ||
173 | static DECLARE_TLV_DB_SCALE(wm8940_pga_vol_tlv, -1200, 75, 0); | ||
174 | static DECLARE_TLV_DB_SCALE(wm8940_alc_min_tlv, -1200, 600, 0); | ||
175 | static DECLARE_TLV_DB_SCALE(wm8940_alc_max_tlv, 675, 600, 0); | ||
176 | static DECLARE_TLV_DB_SCALE(wm8940_alc_tar_tlv, -2250, 50, 0); | ||
177 | static DECLARE_TLV_DB_SCALE(wm8940_lim_boost_tlv, 0, 100, 0); | ||
178 | static DECLARE_TLV_DB_SCALE(wm8940_lim_thresh_tlv, -600, 100, 0); | ||
179 | static DECLARE_TLV_DB_SCALE(wm8940_adc_tlv, -12750, 50, 1); | ||
180 | static DECLARE_TLV_DB_SCALE(wm8940_capture_boost_vol_tlv, 0, 2000, 0); | ||
181 | |||
182 | static const struct snd_kcontrol_new wm8940_snd_controls[] = { | ||
183 | SOC_SINGLE("Digital Loopback Switch", WM8940_COMPANDINGCTL, | ||
184 | 6, 1, 0), | ||
185 | SOC_ENUM("DAC Companding", wm8940_dac_companding_enum), | ||
186 | SOC_ENUM("ADC Companding", wm8940_adc_companding_enum), | ||
187 | |||
188 | SOC_ENUM("ALC Mode", wm8940_alc_mode_enum), | ||
189 | SOC_SINGLE("ALC Switch", WM8940_ALC1, 8, 1, 0), | ||
190 | SOC_SINGLE_TLV("ALC Capture Max Gain", WM8940_ALC1, | ||
191 | 3, 7, 1, wm8940_alc_max_tlv), | ||
192 | SOC_SINGLE_TLV("ALC Capture Min Gain", WM8940_ALC1, | ||
193 | 0, 7, 0, wm8940_alc_min_tlv), | ||
194 | SOC_SINGLE_TLV("ALC Capture Target", WM8940_ALC2, | ||
195 | 0, 14, 0, wm8940_alc_tar_tlv), | ||
196 | SOC_SINGLE("ALC Capture Hold", WM8940_ALC2, 4, 10, 0), | ||
197 | SOC_SINGLE("ALC Capture Decay", WM8940_ALC3, 4, 10, 0), | ||
198 | SOC_SINGLE("ALC Capture Attach", WM8940_ALC3, 0, 10, 0), | ||
199 | SOC_SINGLE("ALC ZC Switch", WM8940_ALC4, 1, 1, 0), | ||
200 | SOC_SINGLE("ALC Capture Noise Gate Switch", WM8940_NOISEGATE, | ||
201 | 3, 1, 0), | ||
202 | SOC_SINGLE("ALC Capture Noise Gate Threshold", WM8940_NOISEGATE, | ||
203 | 0, 7, 0), | ||
204 | |||
205 | SOC_SINGLE("DAC Playback Limiter Switch", WM8940_DACLIM1, 8, 1, 0), | ||
206 | SOC_SINGLE("DAC Playback Limiter Attack", WM8940_DACLIM1, 0, 9, 0), | ||
207 | SOC_SINGLE("DAC Playback Limiter Decay", WM8940_DACLIM1, 4, 11, 0), | ||
208 | SOC_SINGLE_TLV("DAC Playback Limiter Threshold", WM8940_DACLIM2, | ||
209 | 4, 9, 1, wm8940_lim_thresh_tlv), | ||
210 | SOC_SINGLE_TLV("DAC Playback Limiter Boost", WM8940_DACLIM2, | ||
211 | 0, 12, 0, wm8940_lim_boost_tlv), | ||
212 | |||
213 | SOC_SINGLE("Capture PGA ZC Switch", WM8940_PGAGAIN, 7, 1, 0), | ||
214 | SOC_SINGLE_TLV("Capture PGA Volume", WM8940_PGAGAIN, | ||
215 | 0, 63, 0, wm8940_pga_vol_tlv), | ||
216 | SOC_SINGLE_TLV("Digital Playback Volume", WM8940_DACVOL, | ||
217 | 0, 255, 0, wm8940_adc_tlv), | ||
218 | SOC_SINGLE_TLV("Digital Capture Volume", WM8940_ADCVOL, | ||
219 | 0, 255, 0, wm8940_adc_tlv), | ||
220 | SOC_ENUM("Mic Bias Level", wm8940_mic_bias_level_enum), | ||
221 | SOC_SINGLE_TLV("Capture Boost Volue", WM8940_ADCBOOST, | ||
222 | 8, 1, 0, wm8940_capture_boost_vol_tlv), | ||
223 | SOC_SINGLE_TLV("Speaker Playback Volume", WM8940_SPKVOL, | ||
224 | 0, 63, 0, wm8940_spk_vol_tlv), | ||
225 | SOC_SINGLE("Speaker Playback Switch", WM8940_SPKVOL, 6, 1, 1), | ||
226 | |||
227 | SOC_SINGLE_TLV("Speaker Mixer Line Bypass Volume", WM8940_SPKVOL, | ||
228 | 8, 1, 1, wm8940_att_tlv), | ||
229 | SOC_SINGLE("Speaker Playback ZC Switch", WM8940_SPKVOL, 7, 1, 0), | ||
230 | |||
231 | SOC_SINGLE("Mono Out Switch", WM8940_MONOMIX, 6, 1, 1), | ||
232 | SOC_SINGLE_TLV("Mono Mixer Line Bypass Volume", WM8940_MONOMIX, | ||
233 | 7, 1, 1, wm8940_att_tlv), | ||
234 | |||
235 | SOC_SINGLE("High Pass Filter Switch", WM8940_ADC, 8, 1, 0), | ||
236 | SOC_ENUM("High Pass Filter Mode", wm8940_filter_mode_enum), | ||
237 | SOC_SINGLE("High Pass Filter Cut Off", WM8940_ADC, 4, 7, 0), | ||
238 | SOC_SINGLE("ADC Inversion Switch", WM8940_ADC, 0, 1, 0), | ||
239 | SOC_SINGLE("DAC Inversion Switch", WM8940_DAC, 0, 1, 0), | ||
240 | SOC_SINGLE("DAC Auto Mute Switch", WM8940_DAC, 2, 1, 0), | ||
241 | SOC_SINGLE("ZC Timeout Clock Switch", WM8940_ADDCNTRL, 0, 1, 0), | ||
242 | }; | ||
243 | |||
244 | static const struct snd_kcontrol_new wm8940_speaker_mixer_controls[] = { | ||
245 | SOC_DAPM_SINGLE("Line Bypass Switch", WM8940_SPKMIX, 1, 1, 0), | ||
246 | SOC_DAPM_SINGLE("Aux Playback Switch", WM8940_SPKMIX, 5, 1, 0), | ||
247 | SOC_DAPM_SINGLE("PCM Playback Switch", WM8940_SPKMIX, 0, 1, 0), | ||
248 | }; | ||
249 | |||
250 | static const struct snd_kcontrol_new wm8940_mono_mixer_controls[] = { | ||
251 | SOC_DAPM_SINGLE("Line Bypass Switch", WM8940_MONOMIX, 1, 1, 0), | ||
252 | SOC_DAPM_SINGLE("Aux Playback Switch", WM8940_MONOMIX, 2, 1, 0), | ||
253 | SOC_DAPM_SINGLE("PCM Playback Switch", WM8940_MONOMIX, 0, 1, 0), | ||
254 | }; | ||
255 | |||
256 | static DECLARE_TLV_DB_SCALE(wm8940_boost_vol_tlv, -1500, 300, 1); | ||
257 | static const struct snd_kcontrol_new wm8940_input_boost_controls[] = { | ||
258 | SOC_DAPM_SINGLE("Mic PGA Switch", WM8940_PGAGAIN, 6, 1, 1), | ||
259 | SOC_DAPM_SINGLE_TLV("Aux Volume", WM8940_ADCBOOST, | ||
260 | 0, 7, 0, wm8940_boost_vol_tlv), | ||
261 | SOC_DAPM_SINGLE_TLV("Mic Volume", WM8940_ADCBOOST, | ||
262 | 4, 7, 0, wm8940_boost_vol_tlv), | ||
263 | }; | ||
264 | |||
265 | static const struct snd_kcontrol_new wm8940_micpga_controls[] = { | ||
266 | SOC_DAPM_SINGLE("AUX Switch", WM8940_INPUTCTL, 2, 1, 0), | ||
267 | SOC_DAPM_SINGLE("MICP Switch", WM8940_INPUTCTL, 0, 1, 0), | ||
268 | SOC_DAPM_SINGLE("MICN Switch", WM8940_INPUTCTL, 1, 1, 0), | ||
269 | }; | ||
270 | |||
271 | static const struct snd_soc_dapm_widget wm8940_dapm_widgets[] = { | ||
272 | SND_SOC_DAPM_MIXER("Speaker Mixer", WM8940_POWER3, 2, 0, | ||
273 | &wm8940_speaker_mixer_controls[0], | ||
274 | ARRAY_SIZE(wm8940_speaker_mixer_controls)), | ||
275 | SND_SOC_DAPM_MIXER("Mono Mixer", WM8940_POWER3, 3, 0, | ||
276 | &wm8940_mono_mixer_controls[0], | ||
277 | ARRAY_SIZE(wm8940_mono_mixer_controls)), | ||
278 | SND_SOC_DAPM_DAC("DAC", "HiFi Playback", WM8940_POWER3, 0, 0), | ||
279 | |||
280 | SND_SOC_DAPM_PGA("SpkN Out", WM8940_POWER3, 5, 0, NULL, 0), | ||
281 | SND_SOC_DAPM_PGA("SpkP Out", WM8940_POWER3, 6, 0, NULL, 0), | ||
282 | SND_SOC_DAPM_PGA("Mono Out", WM8940_POWER3, 7, 0, NULL, 0), | ||
283 | SND_SOC_DAPM_OUTPUT("MONOOUT"), | ||
284 | SND_SOC_DAPM_OUTPUT("SPKOUTP"), | ||
285 | SND_SOC_DAPM_OUTPUT("SPKOUTN"), | ||
286 | |||
287 | SND_SOC_DAPM_PGA("Aux Input", WM8940_POWER1, 6, 0, NULL, 0), | ||
288 | SND_SOC_DAPM_ADC("ADC", "HiFi Capture", WM8940_POWER2, 0, 0), | ||
289 | SND_SOC_DAPM_MIXER("Mic PGA", WM8940_POWER2, 2, 0, | ||
290 | &wm8940_micpga_controls[0], | ||
291 | ARRAY_SIZE(wm8940_micpga_controls)), | ||
292 | SND_SOC_DAPM_MIXER("Boost Mixer", WM8940_POWER2, 4, 0, | ||
293 | &wm8940_input_boost_controls[0], | ||
294 | ARRAY_SIZE(wm8940_input_boost_controls)), | ||
295 | SND_SOC_DAPM_MICBIAS("Mic Bias", WM8940_POWER1, 4, 0), | ||
296 | |||
297 | SND_SOC_DAPM_INPUT("MICN"), | ||
298 | SND_SOC_DAPM_INPUT("MICP"), | ||
299 | SND_SOC_DAPM_INPUT("AUX"), | ||
300 | }; | ||
301 | |||
302 | static const struct snd_soc_dapm_route audio_map[] = { | ||
303 | /* Mono output mixer */ | ||
304 | {"Mono Mixer", "PCM Playback Switch", "DAC"}, | ||
305 | {"Mono Mixer", "Aux Playback Switch", "Aux Input"}, | ||
306 | {"Mono Mixer", "Line Bypass Switch", "Boost Mixer"}, | ||
307 | |||
308 | /* Speaker output mixer */ | ||
309 | {"Speaker Mixer", "PCM Playback Switch", "DAC"}, | ||
310 | {"Speaker Mixer", "Aux Playback Switch", "Aux Input"}, | ||
311 | {"Speaker Mixer", "Line Bypass Switch", "Boost Mixer"}, | ||
312 | |||
313 | /* Outputs */ | ||
314 | {"Mono Out", NULL, "Mono Mixer"}, | ||
315 | {"MONOOUT", NULL, "Mono Out"}, | ||
316 | {"SpkN Out", NULL, "Speaker Mixer"}, | ||
317 | {"SpkP Out", NULL, "Speaker Mixer"}, | ||
318 | {"SPKOUTN", NULL, "SpkN Out"}, | ||
319 | {"SPKOUTP", NULL, "SpkP Out"}, | ||
320 | |||
321 | /* Microphone PGA */ | ||
322 | {"Mic PGA", "MICN Switch", "MICN"}, | ||
323 | {"Mic PGA", "MICP Switch", "MICP"}, | ||
324 | {"Mic PGA", "AUX Switch", "AUX"}, | ||
325 | |||
326 | /* Boost Mixer */ | ||
327 | {"Boost Mixer", "Mic PGA Switch", "Mic PGA"}, | ||
328 | {"Boost Mixer", "Mic Volume", "MICP"}, | ||
329 | {"Boost Mixer", "Aux Volume", "Aux Input"}, | ||
330 | |||
331 | {"ADC", NULL, "Boost Mixer"}, | ||
332 | }; | ||
333 | |||
334 | static int wm8940_add_widgets(struct snd_soc_codec *codec) | ||
335 | { | ||
336 | int ret; | ||
337 | |||
338 | ret = snd_soc_dapm_new_controls(codec, wm8940_dapm_widgets, | ||
339 | ARRAY_SIZE(wm8940_dapm_widgets)); | ||
340 | if (ret) | ||
341 | goto error_ret; | ||
342 | ret = snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | ||
343 | if (ret) | ||
344 | goto error_ret; | ||
345 | ret = snd_soc_dapm_new_widgets(codec); | ||
346 | |||
347 | error_ret: | ||
348 | return ret; | ||
349 | } | ||
350 | |||
351 | #define wm8940_reset(c) wm8940_write(c, WM8940_SOFTRESET, 0); | ||
352 | |||
353 | static int wm8940_set_dai_fmt(struct snd_soc_dai *codec_dai, | ||
354 | unsigned int fmt) | ||
355 | { | ||
356 | struct snd_soc_codec *codec = codec_dai->codec; | ||
357 | u16 iface = wm8940_read_reg_cache(codec, WM8940_IFACE) & 0xFE67; | ||
358 | u16 clk = wm8940_read_reg_cache(codec, WM8940_CLOCK) & 0x1fe; | ||
359 | |||
360 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
361 | case SND_SOC_DAIFMT_CBM_CFM: | ||
362 | clk |= 1; | ||
363 | break; | ||
364 | case SND_SOC_DAIFMT_CBS_CFS: | ||
365 | break; | ||
366 | default: | ||
367 | return -EINVAL; | ||
368 | } | ||
369 | wm8940_write(codec, WM8940_CLOCK, clk); | ||
370 | |||
371 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
372 | case SND_SOC_DAIFMT_I2S: | ||
373 | iface |= (2 << 3); | ||
374 | break; | ||
375 | case SND_SOC_DAIFMT_LEFT_J: | ||
376 | iface |= (1 << 3); | ||
377 | break; | ||
378 | case SND_SOC_DAIFMT_RIGHT_J: | ||
379 | break; | ||
380 | case SND_SOC_DAIFMT_DSP_A: | ||
381 | iface |= (3 << 3); | ||
382 | break; | ||
383 | case SND_SOC_DAIFMT_DSP_B: | ||
384 | iface |= (3 << 3) | (1 << 7); | ||
385 | break; | ||
386 | } | ||
387 | |||
388 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
389 | case SND_SOC_DAIFMT_NB_NF: | ||
390 | break; | ||
391 | case SND_SOC_DAIFMT_NB_IF: | ||
392 | iface |= (1 << 7); | ||
393 | break; | ||
394 | case SND_SOC_DAIFMT_IB_NF: | ||
395 | iface |= (1 << 8); | ||
396 | break; | ||
397 | case SND_SOC_DAIFMT_IB_IF: | ||
398 | iface |= (1 << 8) | (1 << 7); | ||
399 | break; | ||
400 | } | ||
401 | |||
402 | wm8940_write(codec, WM8940_IFACE, iface); | ||
403 | |||
404 | return 0; | ||
405 | } | ||
406 | |||
407 | static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream, | ||
408 | struct snd_pcm_hw_params *params, | ||
409 | struct snd_soc_dai *dai) | ||
410 | { | ||
411 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
412 | struct snd_soc_device *socdev = rtd->socdev; | ||
413 | struct snd_soc_codec *codec = socdev->card->codec; | ||
414 | u16 iface = wm8940_read_reg_cache(codec, WM8940_IFACE) & 0xFD9F; | ||
415 | u16 addcntrl = wm8940_read_reg_cache(codec, WM8940_ADDCNTRL) & 0xFFF1; | ||
416 | u16 companding = wm8940_read_reg_cache(codec, | ||
417 | WM8940_COMPANDINGCTL) & 0xFFDF; | ||
418 | int ret; | ||
419 | |||
420 | /* LoutR control */ | ||
421 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE | ||
422 | && params_channels(params) == 2) | ||
423 | iface |= (1 << 9); | ||
424 | |||
425 | switch (params_rate(params)) { | ||
426 | case SNDRV_PCM_RATE_8000: | ||
427 | addcntrl |= (0x5 << 1); | ||
428 | break; | ||
429 | case SNDRV_PCM_RATE_11025: | ||
430 | addcntrl |= (0x4 << 1); | ||
431 | break; | ||
432 | case SNDRV_PCM_RATE_16000: | ||
433 | addcntrl |= (0x3 << 1); | ||
434 | break; | ||
435 | case SNDRV_PCM_RATE_22050: | ||
436 | addcntrl |= (0x2 << 1); | ||
437 | break; | ||
438 | case SNDRV_PCM_RATE_32000: | ||
439 | addcntrl |= (0x1 << 1); | ||
440 | break; | ||
441 | case SNDRV_PCM_RATE_44100: | ||
442 | case SNDRV_PCM_RATE_48000: | ||
443 | break; | ||
444 | } | ||
445 | ret = wm8940_write(codec, WM8940_ADDCNTRL, addcntrl); | ||
446 | if (ret) | ||
447 | goto error_ret; | ||
448 | |||
449 | switch (params_format(params)) { | ||
450 | case SNDRV_PCM_FORMAT_S8: | ||
451 | companding = companding | (1 << 5); | ||
452 | break; | ||
453 | case SNDRV_PCM_FORMAT_S16_LE: | ||
454 | break; | ||
455 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
456 | iface |= (1 << 5); | ||
457 | break; | ||
458 | case SNDRV_PCM_FORMAT_S24_LE: | ||
459 | iface |= (2 << 5); | ||
460 | break; | ||
461 | case SNDRV_PCM_FORMAT_S32_LE: | ||
462 | iface |= (3 << 5); | ||
463 | break; | ||
464 | } | ||
465 | ret = wm8940_write(codec, WM8940_COMPANDINGCTL, companding); | ||
466 | if (ret) | ||
467 | goto error_ret; | ||
468 | ret = wm8940_write(codec, WM8940_IFACE, iface); | ||
469 | |||
470 | error_ret: | ||
471 | return ret; | ||
472 | } | ||
473 | |||
474 | static int wm8940_mute(struct snd_soc_dai *dai, int mute) | ||
475 | { | ||
476 | struct snd_soc_codec *codec = dai->codec; | ||
477 | u16 mute_reg = wm8940_read_reg_cache(codec, WM8940_DAC) & 0xffbf; | ||
478 | |||
479 | if (mute) | ||
480 | mute_reg |= 0x40; | ||
481 | |||
482 | return wm8940_write(codec, WM8940_DAC, mute_reg); | ||
483 | } | ||
484 | |||
485 | static int wm8940_set_bias_level(struct snd_soc_codec *codec, | ||
486 | enum snd_soc_bias_level level) | ||
487 | { | ||
488 | u16 val; | ||
489 | u16 pwr_reg = wm8940_read_reg_cache(codec, WM8940_POWER1) & 0x1F0; | ||
490 | int ret = 0; | ||
491 | |||
492 | switch (level) { | ||
493 | case SND_SOC_BIAS_ON: | ||
494 | /* ensure bufioen and biasen */ | ||
495 | pwr_reg |= (1 << 2) | (1 << 3); | ||
496 | /* Enable thermal shutdown */ | ||
497 | val = wm8940_read_reg_cache(codec, WM8940_OUTPUTCTL); | ||
498 | ret = wm8940_write(codec, WM8940_OUTPUTCTL, val | 0x2); | ||
499 | if (ret) | ||
500 | break; | ||
501 | /* set vmid to 75k */ | ||
502 | ret = wm8940_write(codec, WM8940_POWER1, pwr_reg | 0x1); | ||
503 | break; | ||
504 | case SND_SOC_BIAS_PREPARE: | ||
505 | /* ensure bufioen and biasen */ | ||
506 | pwr_reg |= (1 << 2) | (1 << 3); | ||
507 | ret = wm8940_write(codec, WM8940_POWER1, pwr_reg | 0x1); | ||
508 | break; | ||
509 | case SND_SOC_BIAS_STANDBY: | ||
510 | /* ensure bufioen and biasen */ | ||
511 | pwr_reg |= (1 << 2) | (1 << 3); | ||
512 | /* set vmid to 300k for standby */ | ||
513 | ret = wm8940_write(codec, WM8940_POWER1, pwr_reg | 0x2); | ||
514 | break; | ||
515 | case SND_SOC_BIAS_OFF: | ||
516 | ret = wm8940_write(codec, WM8940_POWER1, pwr_reg); | ||
517 | break; | ||
518 | } | ||
519 | |||
520 | return ret; | ||
521 | } | ||
522 | |||
523 | struct pll_ { | ||
524 | unsigned int pre_scale:2; | ||
525 | unsigned int n:4; | ||
526 | unsigned int k; | ||
527 | }; | ||
528 | |||
529 | static struct pll_ pll_div; | ||
530 | |||
531 | /* The size in bits of the pll divide multiplied by 10 | ||
532 | * to allow rounding later */ | ||
533 | #define FIXED_PLL_SIZE ((1 << 24) * 10) | ||
534 | static void pll_factors(unsigned int target, unsigned int source) | ||
535 | { | ||
536 | unsigned long long Kpart; | ||
537 | unsigned int K, Ndiv, Nmod; | ||
538 | /* The left shift ist to avoid accuracy loss when right shifting */ | ||
539 | Ndiv = target / source; | ||
540 | |||
541 | if (Ndiv > 12) { | ||
542 | source <<= 1; | ||
543 | /* Multiply by 2 */ | ||
544 | pll_div.pre_scale = 0; | ||
545 | Ndiv = target / source; | ||
546 | } else if (Ndiv < 3) { | ||
547 | source >>= 2; | ||
548 | /* Divide by 4 */ | ||
549 | pll_div.pre_scale = 3; | ||
550 | Ndiv = target / source; | ||
551 | } else if (Ndiv < 6) { | ||
552 | source >>= 1; | ||
553 | /* divide by 2 */ | ||
554 | pll_div.pre_scale = 2; | ||
555 | Ndiv = target / source; | ||
556 | } else | ||
557 | pll_div.pre_scale = 1; | ||
558 | |||
559 | if ((Ndiv < 6) || (Ndiv > 12)) | ||
560 | printk(KERN_WARNING | ||
561 | "WM8940 N value %d outwith recommended range!d\n", | ||
562 | Ndiv); | ||
563 | |||
564 | pll_div.n = Ndiv; | ||
565 | Nmod = target % source; | ||
566 | Kpart = FIXED_PLL_SIZE * (long long)Nmod; | ||
567 | |||
568 | do_div(Kpart, source); | ||
569 | |||
570 | K = Kpart & 0xFFFFFFFF; | ||
571 | |||
572 | /* Check if we need to round */ | ||
573 | if ((K % 10) >= 5) | ||
574 | K += 5; | ||
575 | |||
576 | /* Move down to proper range now rounding is done */ | ||
577 | K /= 10; | ||
578 | |||
579 | pll_div.k = K; | ||
580 | } | ||
581 | |||
582 | /* Untested at the moment */ | ||
583 | static int wm8940_set_dai_pll(struct snd_soc_dai *codec_dai, | ||
584 | int pll_id, unsigned int freq_in, unsigned int freq_out) | ||
585 | { | ||
586 | struct snd_soc_codec *codec = codec_dai->codec; | ||
587 | u16 reg; | ||
588 | |||
589 | /* Turn off PLL */ | ||
590 | reg = wm8940_read_reg_cache(codec, WM8940_POWER1); | ||
591 | wm8940_write(codec, WM8940_POWER1, reg & 0x1df); | ||
592 | |||
593 | if (freq_in == 0 || freq_out == 0) { | ||
594 | /* Clock CODEC directly from MCLK */ | ||
595 | reg = wm8940_read_reg_cache(codec, WM8940_CLOCK); | ||
596 | wm8940_write(codec, WM8940_CLOCK, reg & 0x0ff); | ||
597 | /* Pll power down */ | ||
598 | wm8940_write(codec, WM8940_PLLN, (1 << 7)); | ||
599 | return 0; | ||
600 | } | ||
601 | |||
602 | /* Pll is followed by a frequency divide by 4 */ | ||
603 | pll_factors(freq_out*4, freq_in); | ||
604 | if (pll_div.k) | ||
605 | wm8940_write(codec, WM8940_PLLN, | ||
606 | (pll_div.pre_scale << 4) | pll_div.n | (1 << 6)); | ||
607 | else /* No factional component */ | ||
608 | wm8940_write(codec, WM8940_PLLN, | ||
609 | (pll_div.pre_scale << 4) | pll_div.n); | ||
610 | wm8940_write(codec, WM8940_PLLK1, pll_div.k >> 18); | ||
611 | wm8940_write(codec, WM8940_PLLK2, (pll_div.k >> 9) & 0x1ff); | ||
612 | wm8940_write(codec, WM8940_PLLK3, pll_div.k & 0x1ff); | ||
613 | /* Enable the PLL */ | ||
614 | reg = wm8940_read_reg_cache(codec, WM8940_POWER1); | ||
615 | wm8940_write(codec, WM8940_POWER1, reg | 0x020); | ||
616 | |||
617 | /* Run CODEC from PLL instead of MCLK */ | ||
618 | reg = wm8940_read_reg_cache(codec, WM8940_CLOCK); | ||
619 | wm8940_write(codec, WM8940_CLOCK, reg | 0x100); | ||
620 | |||
621 | return 0; | ||
622 | } | ||
623 | |||
624 | static int wm8940_set_dai_sysclk(struct snd_soc_dai *codec_dai, | ||
625 | int clk_id, unsigned int freq, int dir) | ||
626 | { | ||
627 | struct snd_soc_codec *codec = codec_dai->codec; | ||
628 | struct wm8940_priv *wm8940 = codec->private_data; | ||
629 | |||
630 | switch (freq) { | ||
631 | case 11289600: | ||
632 | case 12000000: | ||
633 | case 12288000: | ||
634 | case 16934400: | ||
635 | case 18432000: | ||
636 | wm8940->sysclk = freq; | ||
637 | return 0; | ||
638 | } | ||
639 | return -EINVAL; | ||
640 | } | ||
641 | |||
642 | static int wm8940_set_dai_clkdiv(struct snd_soc_dai *codec_dai, | ||
643 | int div_id, int div) | ||
644 | { | ||
645 | struct snd_soc_codec *codec = codec_dai->codec; | ||
646 | u16 reg; | ||
647 | int ret = 0; | ||
648 | |||
649 | switch (div_id) { | ||
650 | case WM8940_BCLKDIV: | ||
651 | reg = wm8940_read_reg_cache(codec, WM8940_CLOCK) & 0xFFEF3; | ||
652 | ret = wm8940_write(codec, WM8940_CLOCK, reg | (div << 2)); | ||
653 | break; | ||
654 | case WM8940_MCLKDIV: | ||
655 | reg = wm8940_read_reg_cache(codec, WM8940_CLOCK) & 0xFF1F; | ||
656 | ret = wm8940_write(codec, WM8940_CLOCK, reg | (div << 5)); | ||
657 | break; | ||
658 | case WM8940_OPCLKDIV: | ||
659 | reg = wm8940_read_reg_cache(codec, WM8940_ADDCNTRL) & 0xFFCF; | ||
660 | ret = wm8940_write(codec, WM8940_ADDCNTRL, reg | (div << 4)); | ||
661 | break; | ||
662 | } | ||
663 | return ret; | ||
664 | } | ||
665 | |||
666 | #define WM8940_RATES SNDRV_PCM_RATE_8000_48000 | ||
667 | |||
668 | #define WM8940_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ | ||
669 | SNDRV_PCM_FMTBIT_S16_LE | \ | ||
670 | SNDRV_PCM_FMTBIT_S20_3LE | \ | ||
671 | SNDRV_PCM_FMTBIT_S24_LE | \ | ||
672 | SNDRV_PCM_FMTBIT_S32_LE) | ||
673 | |||
674 | static struct snd_soc_dai_ops wm8940_dai_ops = { | ||
675 | .hw_params = wm8940_i2s_hw_params, | ||
676 | .set_sysclk = wm8940_set_dai_sysclk, | ||
677 | .digital_mute = wm8940_mute, | ||
678 | .set_fmt = wm8940_set_dai_fmt, | ||
679 | .set_clkdiv = wm8940_set_dai_clkdiv, | ||
680 | .set_pll = wm8940_set_dai_pll, | ||
681 | }; | ||
682 | |||
683 | struct snd_soc_dai wm8940_dai = { | ||
684 | .name = "WM8940", | ||
685 | .playback = { | ||
686 | .stream_name = "Playback", | ||
687 | .channels_min = 1, | ||
688 | .channels_max = 2, | ||
689 | .rates = WM8940_RATES, | ||
690 | .formats = WM8940_FORMATS, | ||
691 | }, | ||
692 | .capture = { | ||
693 | .stream_name = "Capture", | ||
694 | .channels_min = 1, | ||
695 | .channels_max = 2, | ||
696 | .rates = WM8940_RATES, | ||
697 | .formats = WM8940_FORMATS, | ||
698 | }, | ||
699 | .ops = &wm8940_dai_ops, | ||
700 | .symmetric_rates = 1, | ||
701 | }; | ||
702 | EXPORT_SYMBOL_GPL(wm8940_dai); | ||
703 | |||
704 | static int wm8940_suspend(struct platform_device *pdev, pm_message_t state) | ||
705 | { | ||
706 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
707 | struct snd_soc_codec *codec = socdev->card->codec; | ||
708 | |||
709 | return wm8940_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
710 | } | ||
711 | |||
712 | static int wm8940_resume(struct platform_device *pdev) | ||
713 | { | ||
714 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
715 | struct snd_soc_codec *codec = socdev->card->codec; | ||
716 | int i; | ||
717 | int ret; | ||
718 | u8 data[3]; | ||
719 | u16 *cache = codec->reg_cache; | ||
720 | |||
721 | /* Sync reg_cache with the hardware | ||
722 | * Could use auto incremented writes to speed this up | ||
723 | */ | ||
724 | for (i = 0; i < ARRAY_SIZE(wm8940_reg_defaults); i++) { | ||
725 | data[0] = i; | ||
726 | data[1] = (cache[i] & 0xFF00) >> 8; | ||
727 | data[2] = cache[i] & 0x00FF; | ||
728 | ret = codec->hw_write(codec->control_data, data, 3); | ||
729 | if (ret < 0) | ||
730 | goto error_ret; | ||
731 | else if (ret != 3) { | ||
732 | ret = -EIO; | ||
733 | goto error_ret; | ||
734 | } | ||
735 | } | ||
736 | ret = wm8940_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
737 | if (ret) | ||
738 | goto error_ret; | ||
739 | ret = wm8940_set_bias_level(codec, codec->suspend_bias_level); | ||
740 | |||
741 | error_ret: | ||
742 | return ret; | ||
743 | } | ||
744 | |||
745 | static struct snd_soc_codec *wm8940_codec; | ||
746 | |||
747 | static int wm8940_probe(struct platform_device *pdev) | ||
748 | { | ||
749 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
750 | struct snd_soc_codec *codec; | ||
751 | |||
752 | int ret = 0; | ||
753 | |||
754 | if (wm8940_codec == NULL) { | ||
755 | dev_err(&pdev->dev, "Codec device not registered\n"); | ||
756 | return -ENODEV; | ||
757 | } | ||
758 | |||
759 | socdev->card->codec = wm8940_codec; | ||
760 | codec = wm8940_codec; | ||
761 | |||
762 | mutex_init(&codec->mutex); | ||
763 | /* register pcms */ | ||
764 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
765 | if (ret < 0) { | ||
766 | dev_err(codec->dev, "failed to create pcms: %d\n", ret); | ||
767 | goto pcm_err; | ||
768 | } | ||
769 | |||
770 | ret = snd_soc_add_controls(codec, wm8940_snd_controls, | ||
771 | ARRAY_SIZE(wm8940_snd_controls)); | ||
772 | if (ret) | ||
773 | goto error_free_pcms; | ||
774 | ret = wm8940_add_widgets(codec); | ||
775 | if (ret) | ||
776 | goto error_free_pcms; | ||
777 | |||
778 | ret = snd_soc_init_card(socdev); | ||
779 | if (ret < 0) { | ||
780 | dev_err(codec->dev, "failed to register card: %d\n", ret); | ||
781 | goto error_free_pcms; | ||
782 | } | ||
783 | |||
784 | return ret; | ||
785 | |||
786 | error_free_pcms: | ||
787 | snd_soc_free_pcms(socdev); | ||
788 | snd_soc_dapm_free(socdev); | ||
789 | pcm_err: | ||
790 | return ret; | ||
791 | } | ||
792 | |||
793 | static int wm8940_remove(struct platform_device *pdev) | ||
794 | { | ||
795 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
796 | |||
797 | snd_soc_free_pcms(socdev); | ||
798 | snd_soc_dapm_free(socdev); | ||
799 | |||
800 | return 0; | ||
801 | } | ||
802 | |||
803 | struct snd_soc_codec_device soc_codec_dev_wm8940 = { | ||
804 | .probe = wm8940_probe, | ||
805 | .remove = wm8940_remove, | ||
806 | .suspend = wm8940_suspend, | ||
807 | .resume = wm8940_resume, | ||
808 | }; | ||
809 | EXPORT_SYMBOL_GPL(soc_codec_dev_wm8940); | ||
810 | |||
811 | static int wm8940_register(struct wm8940_priv *wm8940) | ||
812 | { | ||
813 | struct wm8940_setup_data *pdata = wm8940->codec.dev->platform_data; | ||
814 | struct snd_soc_codec *codec = &wm8940->codec; | ||
815 | int ret; | ||
816 | u16 reg; | ||
817 | if (wm8940_codec) { | ||
818 | dev_err(codec->dev, "Another WM8940 is registered\n"); | ||
819 | return -EINVAL; | ||
820 | } | ||
821 | |||
822 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
823 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
824 | |||
825 | codec->private_data = wm8940; | ||
826 | codec->name = "WM8940"; | ||
827 | codec->owner = THIS_MODULE; | ||
828 | codec->read = wm8940_read_reg_cache; | ||
829 | codec->write = wm8940_write; | ||
830 | codec->bias_level = SND_SOC_BIAS_OFF; | ||
831 | codec->set_bias_level = wm8940_set_bias_level; | ||
832 | codec->dai = &wm8940_dai; | ||
833 | codec->num_dai = 1; | ||
834 | codec->reg_cache_size = ARRAY_SIZE(wm8940_reg_defaults); | ||
835 | codec->reg_cache = &wm8940->reg_cache; | ||
836 | |||
837 | memcpy(codec->reg_cache, wm8940_reg_defaults, | ||
838 | sizeof(wm8940_reg_defaults)); | ||
839 | |||
840 | ret = wm8940_reset(codec); | ||
841 | if (ret < 0) { | ||
842 | dev_err(codec->dev, "Failed to issue reset\n"); | ||
843 | return ret; | ||
844 | } | ||
845 | |||
846 | wm8940_dai.dev = codec->dev; | ||
847 | |||
848 | wm8940_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
849 | |||
850 | ret = wm8940_write(codec, WM8940_POWER1, 0x180); | ||
851 | if (ret < 0) | ||
852 | return ret; | ||
853 | |||
854 | if (!pdata) | ||
855 | dev_warn(codec->dev, "No platform data supplied\n"); | ||
856 | else { | ||
857 | reg = wm8940_read_reg_cache(codec, WM8940_OUTPUTCTL); | ||
858 | ret = wm8940_write(codec, WM8940_OUTPUTCTL, reg | pdata->vroi); | ||
859 | if (ret < 0) | ||
860 | return ret; | ||
861 | } | ||
862 | |||
863 | |||
864 | wm8940_codec = codec; | ||
865 | |||
866 | ret = snd_soc_register_codec(codec); | ||
867 | if (ret) { | ||
868 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); | ||
869 | return ret; | ||
870 | } | ||
871 | |||
872 | ret = snd_soc_register_dai(&wm8940_dai); | ||
873 | if (ret) { | ||
874 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); | ||
875 | snd_soc_unregister_codec(codec); | ||
876 | return ret; | ||
877 | } | ||
878 | |||
879 | return 0; | ||
880 | } | ||
881 | |||
882 | static void wm8940_unregister(struct wm8940_priv *wm8940) | ||
883 | { | ||
884 | wm8940_set_bias_level(&wm8940->codec, SND_SOC_BIAS_OFF); | ||
885 | snd_soc_unregister_dai(&wm8940_dai); | ||
886 | snd_soc_unregister_codec(&wm8940->codec); | ||
887 | kfree(wm8940); | ||
888 | wm8940_codec = NULL; | ||
889 | } | ||
890 | |||
891 | static int wm8940_i2c_probe(struct i2c_client *i2c, | ||
892 | const struct i2c_device_id *id) | ||
893 | { | ||
894 | struct wm8940_priv *wm8940; | ||
895 | struct snd_soc_codec *codec; | ||
896 | |||
897 | wm8940 = kzalloc(sizeof *wm8940, GFP_KERNEL); | ||
898 | if (wm8940 == NULL) | ||
899 | return -ENOMEM; | ||
900 | |||
901 | codec = &wm8940->codec; | ||
902 | codec->hw_write = (hw_write_t)i2c_master_send; | ||
903 | i2c_set_clientdata(i2c, wm8940); | ||
904 | codec->control_data = i2c; | ||
905 | codec->dev = &i2c->dev; | ||
906 | |||
907 | return wm8940_register(wm8940); | ||
908 | } | ||
909 | |||
910 | static int __devexit wm8940_i2c_remove(struct i2c_client *client) | ||
911 | { | ||
912 | struct wm8940_priv *wm8940 = i2c_get_clientdata(client); | ||
913 | |||
914 | wm8940_unregister(wm8940); | ||
915 | |||
916 | return 0; | ||
917 | } | ||
918 | |||
919 | static const struct i2c_device_id wm8940_i2c_id[] = { | ||
920 | { "wm8940", 0 }, | ||
921 | { } | ||
922 | }; | ||
923 | MODULE_DEVICE_TABLE(i2c, wm8940_i2c_id); | ||
924 | |||
925 | static struct i2c_driver wm8940_i2c_driver = { | ||
926 | .driver = { | ||
927 | .name = "WM8940 I2C Codec", | ||
928 | .owner = THIS_MODULE, | ||
929 | }, | ||
930 | .probe = wm8940_i2c_probe, | ||
931 | .remove = __devexit_p(wm8940_i2c_remove), | ||
932 | .id_table = wm8940_i2c_id, | ||
933 | }; | ||
934 | |||
935 | static int __init wm8940_modinit(void) | ||
936 | { | ||
937 | int ret; | ||
938 | |||
939 | ret = i2c_add_driver(&wm8940_i2c_driver); | ||
940 | if (ret) | ||
941 | printk(KERN_ERR "Failed to register WM8940 I2C driver: %d\n", | ||
942 | ret); | ||
943 | return ret; | ||
944 | } | ||
945 | module_init(wm8940_modinit); | ||
946 | |||
947 | static void __exit wm8940_exit(void) | ||
948 | { | ||
949 | i2c_del_driver(&wm8940_i2c_driver); | ||
950 | } | ||
951 | module_exit(wm8940_exit); | ||
952 | |||
953 | MODULE_DESCRIPTION("ASoC WM8940 driver"); | ||
954 | MODULE_AUTHOR("Jonathan Cameron"); | ||
955 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/wm8940.h b/sound/soc/codecs/wm8940.h new file mode 100644 index 000000000000..8410eed3ef84 --- /dev/null +++ b/sound/soc/codecs/wm8940.h | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * wm8940.h -- WM8940 Soc Audio driver | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #ifndef _WM8940_H | ||
10 | #define _WM8940_H | ||
11 | |||
12 | struct wm8940_setup_data { | ||
13 | /* Vref to analogue output resistance */ | ||
14 | #define WM8940_VROI_1K 0 | ||
15 | #define WM8940_VROI_30K 1 | ||
16 | unsigned int vroi:1; | ||
17 | }; | ||
18 | extern struct snd_soc_dai wm8940_dai; | ||
19 | extern struct snd_soc_codec_device soc_codec_dev_wm8940; | ||
20 | |||
21 | /* WM8940 register space */ | ||
22 | #define WM8940_SOFTRESET 0x00 | ||
23 | #define WM8940_POWER1 0x01 | ||
24 | #define WM8940_POWER2 0x02 | ||
25 | #define WM8940_POWER3 0x03 | ||
26 | #define WM8940_IFACE 0x04 | ||
27 | #define WM8940_COMPANDINGCTL 0x05 | ||
28 | #define WM8940_CLOCK 0x06 | ||
29 | #define WM8940_ADDCNTRL 0x07 | ||
30 | #define WM8940_GPIO 0x08 | ||
31 | #define WM8940_CTLINT 0x09 | ||
32 | #define WM8940_DAC 0x0A | ||
33 | #define WM8940_DACVOL 0x0B | ||
34 | |||
35 | #define WM8940_ADC 0x0E | ||
36 | #define WM8940_ADCVOL 0x0F | ||
37 | #define WM8940_NOTCH1 0x10 | ||
38 | #define WM8940_NOTCH2 0x11 | ||
39 | #define WM8940_NOTCH3 0x12 | ||
40 | #define WM8940_NOTCH4 0x13 | ||
41 | #define WM8940_NOTCH5 0x14 | ||
42 | #define WM8940_NOTCH6 0x15 | ||
43 | #define WM8940_NOTCH7 0x16 | ||
44 | #define WM8940_NOTCH8 0x17 | ||
45 | #define WM8940_DACLIM1 0x18 | ||
46 | #define WM8940_DACLIM2 0x19 | ||
47 | |||
48 | #define WM8940_ALC1 0x20 | ||
49 | #define WM8940_ALC2 0x21 | ||
50 | #define WM8940_ALC3 0x22 | ||
51 | #define WM8940_NOISEGATE 0x23 | ||
52 | #define WM8940_PLLN 0x24 | ||
53 | #define WM8940_PLLK1 0x25 | ||
54 | #define WM8940_PLLK2 0x26 | ||
55 | #define WM8940_PLLK3 0x27 | ||
56 | |||
57 | #define WM8940_ALC4 0x2A | ||
58 | |||
59 | #define WM8940_INPUTCTL 0x2C | ||
60 | #define WM8940_PGAGAIN 0x2D | ||
61 | |||
62 | #define WM8940_ADCBOOST 0x2F | ||
63 | |||
64 | #define WM8940_OUTPUTCTL 0x31 | ||
65 | #define WM8940_SPKMIX 0x32 | ||
66 | |||
67 | #define WM8940_SPKVOL 0x36 | ||
68 | |||
69 | #define WM8940_MONOMIX 0x38 | ||
70 | |||
71 | #define WM8940_CACHEREGNUM 0x57 | ||
72 | |||
73 | |||
74 | /* Clock divider Id's */ | ||
75 | #define WM8940_BCLKDIV 0 | ||
76 | #define WM8940_MCLKDIV 1 | ||
77 | #define WM8940_OPCLKDIV 2 | ||
78 | |||
79 | /* MCLK clock dividers */ | ||
80 | #define WM8940_MCLKDIV_1 0 | ||
81 | #define WM8940_MCLKDIV_1_5 1 | ||
82 | #define WM8940_MCLKDIV_2 2 | ||
83 | #define WM8940_MCLKDIV_3 3 | ||
84 | #define WM8940_MCLKDIV_4 4 | ||
85 | #define WM8940_MCLKDIV_6 5 | ||
86 | #define WM8940_MCLKDIV_8 6 | ||
87 | #define WM8940_MCLKDIV_12 7 | ||
88 | |||
89 | /* BCLK clock dividers */ | ||
90 | #define WM8940_BCLKDIV_1 0 | ||
91 | #define WM8940_BCLKDIV_2 1 | ||
92 | #define WM8940_BCLKDIV_4 2 | ||
93 | #define WM8940_BCLKDIV_8 3 | ||
94 | #define WM8940_BCLKDIV_16 4 | ||
95 | #define WM8940_BCLKDIV_32 5 | ||
96 | |||
97 | /* PLL Out Dividers */ | ||
98 | #define WM8940_OPCLKDIV_1 0 | ||
99 | #define WM8940_OPCLKDIV_2 1 | ||
100 | #define WM8940_OPCLKDIV_3 2 | ||
101 | #define WM8940_OPCLKDIV_4 3 | ||
102 | |||
103 | #endif /* _WM8940_H */ | ||
104 | |||
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c new file mode 100644 index 000000000000..e224d8add170 --- /dev/null +++ b/sound/soc/codecs/wm8960.c | |||
@@ -0,0 +1,969 @@ | |||
1 | /* | ||
2 | * wm8960.c -- WM8960 ALSA SoC Audio driver | ||
3 | * | ||
4 | * Author: Liam Girdwood | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/moduleparam.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/delay.h> | ||
15 | #include <linux/pm.h> | ||
16 | #include <linux/i2c.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <sound/core.h> | ||
19 | #include <sound/pcm.h> | ||
20 | #include <sound/pcm_params.h> | ||
21 | #include <sound/soc.h> | ||
22 | #include <sound/soc-dapm.h> | ||
23 | #include <sound/initval.h> | ||
24 | #include <sound/tlv.h> | ||
25 | |||
26 | #include "wm8960.h" | ||
27 | |||
28 | #define AUDIO_NAME "wm8960" | ||
29 | |||
30 | struct snd_soc_codec_device soc_codec_dev_wm8960; | ||
31 | |||
32 | /* R25 - Power 1 */ | ||
33 | #define WM8960_VREF 0x40 | ||
34 | |||
35 | /* R28 - Anti-pop 1 */ | ||
36 | #define WM8960_POBCTRL 0x80 | ||
37 | #define WM8960_BUFDCOPEN 0x10 | ||
38 | #define WM8960_BUFIOEN 0x08 | ||
39 | #define WM8960_SOFT_ST 0x04 | ||
40 | #define WM8960_HPSTBY 0x01 | ||
41 | |||
42 | /* R29 - Anti-pop 2 */ | ||
43 | #define WM8960_DISOP 0x40 | ||
44 | |||
45 | /* | ||
46 | * wm8960 register cache | ||
47 | * We can't read the WM8960 register space when we are | ||
48 | * using 2 wire for device control, so we cache them instead. | ||
49 | */ | ||
50 | static const u16 wm8960_reg[WM8960_CACHEREGNUM] = { | ||
51 | 0x0097, 0x0097, 0x0000, 0x0000, | ||
52 | 0x0000, 0x0008, 0x0000, 0x000a, | ||
53 | 0x01c0, 0x0000, 0x00ff, 0x00ff, | ||
54 | 0x0000, 0x0000, 0x0000, 0x0000, | ||
55 | 0x0000, 0x007b, 0x0100, 0x0032, | ||
56 | 0x0000, 0x00c3, 0x00c3, 0x01c0, | ||
57 | 0x0000, 0x0000, 0x0000, 0x0000, | ||
58 | 0x0000, 0x0000, 0x0000, 0x0000, | ||
59 | 0x0100, 0x0100, 0x0050, 0x0050, | ||
60 | 0x0050, 0x0050, 0x0000, 0x0000, | ||
61 | 0x0000, 0x0000, 0x0040, 0x0000, | ||
62 | 0x0000, 0x0050, 0x0050, 0x0000, | ||
63 | 0x0002, 0x0037, 0x004d, 0x0080, | ||
64 | 0x0008, 0x0031, 0x0026, 0x00e9, | ||
65 | }; | ||
66 | |||
67 | struct wm8960_priv { | ||
68 | u16 reg_cache[WM8960_CACHEREGNUM]; | ||
69 | struct snd_soc_codec codec; | ||
70 | }; | ||
71 | |||
72 | /* | ||
73 | * read wm8960 register cache | ||
74 | */ | ||
75 | static inline unsigned int wm8960_read_reg_cache(struct snd_soc_codec *codec, | ||
76 | unsigned int reg) | ||
77 | { | ||
78 | u16 *cache = codec->reg_cache; | ||
79 | if (reg == WM8960_RESET) | ||
80 | return 0; | ||
81 | if (reg >= WM8960_CACHEREGNUM) | ||
82 | return -1; | ||
83 | return cache[reg]; | ||
84 | } | ||
85 | |||
86 | /* | ||
87 | * write wm8960 register cache | ||
88 | */ | ||
89 | static inline void wm8960_write_reg_cache(struct snd_soc_codec *codec, | ||
90 | u16 reg, unsigned int value) | ||
91 | { | ||
92 | u16 *cache = codec->reg_cache; | ||
93 | if (reg >= WM8960_CACHEREGNUM) | ||
94 | return; | ||
95 | cache[reg] = value; | ||
96 | } | ||
97 | |||
98 | static inline unsigned int wm8960_read(struct snd_soc_codec *codec, | ||
99 | unsigned int reg) | ||
100 | { | ||
101 | return wm8960_read_reg_cache(codec, reg); | ||
102 | } | ||
103 | |||
104 | /* | ||
105 | * write to the WM8960 register space | ||
106 | */ | ||
107 | static int wm8960_write(struct snd_soc_codec *codec, unsigned int reg, | ||
108 | unsigned int value) | ||
109 | { | ||
110 | u8 data[2]; | ||
111 | |||
112 | /* data is | ||
113 | * D15..D9 WM8960 register offset | ||
114 | * D8...D0 register data | ||
115 | */ | ||
116 | data[0] = (reg << 1) | ((value >> 8) & 0x0001); | ||
117 | data[1] = value & 0x00ff; | ||
118 | |||
119 | wm8960_write_reg_cache(codec, reg, value); | ||
120 | if (codec->hw_write(codec->control_data, data, 2) == 2) | ||
121 | return 0; | ||
122 | else | ||
123 | return -EIO; | ||
124 | } | ||
125 | |||
126 | #define wm8960_reset(c) wm8960_write(c, WM8960_RESET, 0) | ||
127 | |||
128 | /* enumerated controls */ | ||
129 | static const char *wm8960_deemph[] = {"None", "32Khz", "44.1Khz", "48Khz"}; | ||
130 | static const char *wm8960_polarity[] = {"No Inversion", "Left Inverted", | ||
131 | "Right Inverted", "Stereo Inversion"}; | ||
132 | static const char *wm8960_3d_upper_cutoff[] = {"High", "Low"}; | ||
133 | static const char *wm8960_3d_lower_cutoff[] = {"Low", "High"}; | ||
134 | static const char *wm8960_alcfunc[] = {"Off", "Right", "Left", "Stereo"}; | ||
135 | static const char *wm8960_alcmode[] = {"ALC", "Limiter"}; | ||
136 | |||
137 | static const struct soc_enum wm8960_enum[] = { | ||
138 | SOC_ENUM_SINGLE(WM8960_DACCTL1, 1, 4, wm8960_deemph), | ||
139 | SOC_ENUM_SINGLE(WM8960_DACCTL1, 5, 4, wm8960_polarity), | ||
140 | SOC_ENUM_SINGLE(WM8960_DACCTL2, 5, 4, wm8960_polarity), | ||
141 | SOC_ENUM_SINGLE(WM8960_3D, 6, 2, wm8960_3d_upper_cutoff), | ||
142 | SOC_ENUM_SINGLE(WM8960_3D, 5, 2, wm8960_3d_lower_cutoff), | ||
143 | SOC_ENUM_SINGLE(WM8960_ALC1, 7, 4, wm8960_alcfunc), | ||
144 | SOC_ENUM_SINGLE(WM8960_ALC3, 8, 2, wm8960_alcmode), | ||
145 | }; | ||
146 | |||
147 | static const DECLARE_TLV_DB_SCALE(adc_tlv, -9700, 50, 0); | ||
148 | static const DECLARE_TLV_DB_SCALE(dac_tlv, -12700, 50, 1); | ||
149 | static const DECLARE_TLV_DB_SCALE(bypass_tlv, -2100, 300, 0); | ||
150 | static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1); | ||
151 | |||
152 | static const struct snd_kcontrol_new wm8960_snd_controls[] = { | ||
153 | SOC_DOUBLE_R_TLV("Capture Volume", WM8960_LINVOL, WM8960_RINVOL, | ||
154 | 0, 63, 0, adc_tlv), | ||
155 | SOC_DOUBLE_R("Capture Volume ZC Switch", WM8960_LINVOL, WM8960_RINVOL, | ||
156 | 6, 1, 0), | ||
157 | SOC_DOUBLE_R("Capture Switch", WM8960_LINVOL, WM8960_RINVOL, | ||
158 | 7, 1, 0), | ||
159 | |||
160 | SOC_DOUBLE_R_TLV("Playback Volume", WM8960_LDAC, WM8960_RDAC, | ||
161 | 0, 255, 0, dac_tlv), | ||
162 | |||
163 | SOC_DOUBLE_R_TLV("Headphone Playback Volume", WM8960_LOUT1, WM8960_ROUT1, | ||
164 | 0, 127, 0, out_tlv), | ||
165 | SOC_DOUBLE_R("Headphone Playback ZC Switch", WM8960_LOUT1, WM8960_ROUT1, | ||
166 | 7, 1, 0), | ||
167 | |||
168 | SOC_DOUBLE_R_TLV("Speaker Playback Volume", WM8960_LOUT2, WM8960_ROUT2, | ||
169 | 0, 127, 0, out_tlv), | ||
170 | SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8960_LOUT2, WM8960_ROUT2, | ||
171 | 7, 1, 0), | ||
172 | SOC_SINGLE("Speaker DC Volume", WM8960_CLASSD3, 3, 5, 0), | ||
173 | SOC_SINGLE("Speaker AC Volume", WM8960_CLASSD3, 0, 5, 0), | ||
174 | |||
175 | SOC_SINGLE("PCM Playback -6dB Switch", WM8960_DACCTL1, 7, 1, 0), | ||
176 | SOC_ENUM("ADC Polarity", wm8960_enum[1]), | ||
177 | SOC_ENUM("Playback De-emphasis", wm8960_enum[0]), | ||
178 | SOC_SINGLE("ADC High Pass Filter Switch", WM8960_DACCTL1, 0, 1, 0), | ||
179 | |||
180 | SOC_ENUM("DAC Polarity", wm8960_enum[2]), | ||
181 | |||
182 | SOC_ENUM("3D Filter Upper Cut-Off", wm8960_enum[3]), | ||
183 | SOC_ENUM("3D Filter Lower Cut-Off", wm8960_enum[4]), | ||
184 | SOC_SINGLE("3D Volume", WM8960_3D, 1, 15, 0), | ||
185 | SOC_SINGLE("3D Switch", WM8960_3D, 0, 1, 0), | ||
186 | |||
187 | SOC_ENUM("ALC Function", wm8960_enum[5]), | ||
188 | SOC_SINGLE("ALC Max Gain", WM8960_ALC1, 4, 7, 0), | ||
189 | SOC_SINGLE("ALC Target", WM8960_ALC1, 0, 15, 1), | ||
190 | SOC_SINGLE("ALC Min Gain", WM8960_ALC2, 4, 7, 0), | ||
191 | SOC_SINGLE("ALC Hold Time", WM8960_ALC2, 0, 15, 0), | ||
192 | SOC_ENUM("ALC Mode", wm8960_enum[6]), | ||
193 | SOC_SINGLE("ALC Decay", WM8960_ALC3, 4, 15, 0), | ||
194 | SOC_SINGLE("ALC Attack", WM8960_ALC3, 0, 15, 0), | ||
195 | |||
196 | SOC_SINGLE("Noise Gate Threshold", WM8960_NOISEG, 3, 31, 0), | ||
197 | SOC_SINGLE("Noise Gate Switch", WM8960_NOISEG, 0, 1, 0), | ||
198 | |||
199 | SOC_DOUBLE_R("ADC PCM Capture Volume", WM8960_LINPATH, WM8960_RINPATH, | ||
200 | 0, 127, 0), | ||
201 | |||
202 | SOC_SINGLE_TLV("Left Output Mixer Boost Bypass Volume", | ||
203 | WM8960_BYPASS1, 4, 7, 1, bypass_tlv), | ||
204 | SOC_SINGLE_TLV("Left Output Mixer LINPUT3 Volume", | ||
205 | WM8960_LOUTMIX, 4, 7, 1, bypass_tlv), | ||
206 | SOC_SINGLE_TLV("Right Output Mixer Boost Bypass Volume", | ||
207 | WM8960_BYPASS2, 4, 7, 1, bypass_tlv), | ||
208 | SOC_SINGLE_TLV("Right Output Mixer RINPUT3 Volume", | ||
209 | WM8960_ROUTMIX, 4, 7, 1, bypass_tlv), | ||
210 | }; | ||
211 | |||
212 | static const struct snd_kcontrol_new wm8960_lin_boost[] = { | ||
213 | SOC_DAPM_SINGLE("LINPUT2 Switch", WM8960_LINPATH, 6, 1, 0), | ||
214 | SOC_DAPM_SINGLE("LINPUT3 Switch", WM8960_LINPATH, 7, 1, 0), | ||
215 | SOC_DAPM_SINGLE("LINPUT1 Switch", WM8960_LINPATH, 8, 1, 0), | ||
216 | }; | ||
217 | |||
218 | static const struct snd_kcontrol_new wm8960_lin[] = { | ||
219 | SOC_DAPM_SINGLE("Boost Switch", WM8960_LINPATH, 3, 1, 0), | ||
220 | }; | ||
221 | |||
222 | static const struct snd_kcontrol_new wm8960_rin_boost[] = { | ||
223 | SOC_DAPM_SINGLE("RINPUT2 Switch", WM8960_RINPATH, 6, 1, 0), | ||
224 | SOC_DAPM_SINGLE("RINPUT3 Switch", WM8960_RINPATH, 7, 1, 0), | ||
225 | SOC_DAPM_SINGLE("RINPUT1 Switch", WM8960_RINPATH, 8, 1, 0), | ||
226 | }; | ||
227 | |||
228 | static const struct snd_kcontrol_new wm8960_rin[] = { | ||
229 | SOC_DAPM_SINGLE("Boost Switch", WM8960_RINPATH, 3, 1, 0), | ||
230 | }; | ||
231 | |||
232 | static const struct snd_kcontrol_new wm8960_loutput_mixer[] = { | ||
233 | SOC_DAPM_SINGLE("PCM Playback Switch", WM8960_LOUTMIX, 8, 1, 0), | ||
234 | SOC_DAPM_SINGLE("LINPUT3 Switch", WM8960_LOUTMIX, 7, 1, 0), | ||
235 | SOC_DAPM_SINGLE("Boost Bypass Switch", WM8960_BYPASS1, 7, 1, 0), | ||
236 | }; | ||
237 | |||
238 | static const struct snd_kcontrol_new wm8960_routput_mixer[] = { | ||
239 | SOC_DAPM_SINGLE("PCM Playback Switch", WM8960_ROUTMIX, 8, 1, 0), | ||
240 | SOC_DAPM_SINGLE("RINPUT3 Switch", WM8960_ROUTMIX, 7, 1, 0), | ||
241 | SOC_DAPM_SINGLE("Boost Bypass Switch", WM8960_BYPASS2, 7, 1, 0), | ||
242 | }; | ||
243 | |||
244 | static const struct snd_kcontrol_new wm8960_mono_out[] = { | ||
245 | SOC_DAPM_SINGLE("Left Switch", WM8960_MONOMIX1, 7, 1, 0), | ||
246 | SOC_DAPM_SINGLE("Right Switch", WM8960_MONOMIX2, 7, 1, 0), | ||
247 | }; | ||
248 | |||
249 | static const struct snd_soc_dapm_widget wm8960_dapm_widgets[] = { | ||
250 | SND_SOC_DAPM_INPUT("LINPUT1"), | ||
251 | SND_SOC_DAPM_INPUT("RINPUT1"), | ||
252 | SND_SOC_DAPM_INPUT("LINPUT2"), | ||
253 | SND_SOC_DAPM_INPUT("RINPUT2"), | ||
254 | SND_SOC_DAPM_INPUT("LINPUT3"), | ||
255 | SND_SOC_DAPM_INPUT("RINPUT3"), | ||
256 | |||
257 | SND_SOC_DAPM_MICBIAS("MICB", WM8960_POWER1, 1, 0), | ||
258 | |||
259 | SND_SOC_DAPM_MIXER("Left Boost Mixer", WM8960_POWER1, 5, 0, | ||
260 | wm8960_lin_boost, ARRAY_SIZE(wm8960_lin_boost)), | ||
261 | SND_SOC_DAPM_MIXER("Right Boost Mixer", WM8960_POWER1, 4, 0, | ||
262 | wm8960_rin_boost, ARRAY_SIZE(wm8960_rin_boost)), | ||
263 | |||
264 | SND_SOC_DAPM_MIXER("Left Input Mixer", WM8960_POWER3, 5, 0, | ||
265 | wm8960_lin, ARRAY_SIZE(wm8960_lin)), | ||
266 | SND_SOC_DAPM_MIXER("Right Input Mixer", WM8960_POWER3, 4, 0, | ||
267 | wm8960_rin, ARRAY_SIZE(wm8960_rin)), | ||
268 | |||
269 | SND_SOC_DAPM_ADC("Left ADC", "Capture", WM8960_POWER2, 3, 0), | ||
270 | SND_SOC_DAPM_ADC("Right ADC", "Capture", WM8960_POWER2, 2, 0), | ||
271 | |||
272 | SND_SOC_DAPM_DAC("Left DAC", "Playback", WM8960_POWER2, 8, 0), | ||
273 | SND_SOC_DAPM_DAC("Right DAC", "Playback", WM8960_POWER2, 7, 0), | ||
274 | |||
275 | SND_SOC_DAPM_MIXER("Left Output Mixer", WM8960_POWER3, 3, 0, | ||
276 | &wm8960_loutput_mixer[0], | ||
277 | ARRAY_SIZE(wm8960_loutput_mixer)), | ||
278 | SND_SOC_DAPM_MIXER("Right Output Mixer", WM8960_POWER3, 2, 0, | ||
279 | &wm8960_routput_mixer[0], | ||
280 | ARRAY_SIZE(wm8960_routput_mixer)), | ||
281 | |||
282 | SND_SOC_DAPM_MIXER("Mono Output Mixer", WM8960_POWER2, 1, 0, | ||
283 | &wm8960_mono_out[0], | ||
284 | ARRAY_SIZE(wm8960_mono_out)), | ||
285 | |||
286 | SND_SOC_DAPM_PGA("LOUT1 PGA", WM8960_POWER2, 6, 0, NULL, 0), | ||
287 | SND_SOC_DAPM_PGA("ROUT1 PGA", WM8960_POWER2, 5, 0, NULL, 0), | ||
288 | |||
289 | SND_SOC_DAPM_PGA("Left Speaker PGA", WM8960_POWER2, 4, 0, NULL, 0), | ||
290 | SND_SOC_DAPM_PGA("Right Speaker PGA", WM8960_POWER2, 3, 0, NULL, 0), | ||
291 | |||
292 | SND_SOC_DAPM_PGA("Right Speaker Output", WM8960_CLASSD1, 7, 0, NULL, 0), | ||
293 | SND_SOC_DAPM_PGA("Left Speaker Output", WM8960_CLASSD1, 6, 0, NULL, 0), | ||
294 | |||
295 | SND_SOC_DAPM_OUTPUT("SPK_LP"), | ||
296 | SND_SOC_DAPM_OUTPUT("SPK_LN"), | ||
297 | SND_SOC_DAPM_OUTPUT("HP_L"), | ||
298 | SND_SOC_DAPM_OUTPUT("HP_R"), | ||
299 | SND_SOC_DAPM_OUTPUT("SPK_RP"), | ||
300 | SND_SOC_DAPM_OUTPUT("SPK_RN"), | ||
301 | SND_SOC_DAPM_OUTPUT("OUT3"), | ||
302 | }; | ||
303 | |||
304 | static const struct snd_soc_dapm_route audio_paths[] = { | ||
305 | { "Left Boost Mixer", "LINPUT1 Switch", "LINPUT1" }, | ||
306 | { "Left Boost Mixer", "LINPUT2 Switch", "LINPUT2" }, | ||
307 | { "Left Boost Mixer", "LINPUT3 Switch", "LINPUT3" }, | ||
308 | |||
309 | { "Left Input Mixer", "Boost Switch", "Left Boost Mixer", }, | ||
310 | { "Left Input Mixer", NULL, "LINPUT1", }, /* Really Boost Switch */ | ||
311 | { "Left Input Mixer", NULL, "LINPUT2" }, | ||
312 | { "Left Input Mixer", NULL, "LINPUT3" }, | ||
313 | |||
314 | { "Right Boost Mixer", "RINPUT1 Switch", "RINPUT1" }, | ||
315 | { "Right Boost Mixer", "RINPUT2 Switch", "RINPUT2" }, | ||
316 | { "Right Boost Mixer", "RINPUT3 Switch", "RINPUT3" }, | ||
317 | |||
318 | { "Right Input Mixer", "Boost Switch", "Right Boost Mixer", }, | ||
319 | { "Right Input Mixer", NULL, "RINPUT1", }, /* Really Boost Switch */ | ||
320 | { "Right Input Mixer", NULL, "RINPUT2" }, | ||
321 | { "Right Input Mixer", NULL, "LINPUT3" }, | ||
322 | |||
323 | { "Left ADC", NULL, "Left Input Mixer" }, | ||
324 | { "Right ADC", NULL, "Right Input Mixer" }, | ||
325 | |||
326 | { "Left Output Mixer", "LINPUT3 Switch", "LINPUT3" }, | ||
327 | { "Left Output Mixer", "Boost Bypass Switch", "Left Boost Mixer"} , | ||
328 | { "Left Output Mixer", "PCM Playback Switch", "Left DAC" }, | ||
329 | |||
330 | { "Right Output Mixer", "RINPUT3 Switch", "RINPUT3" }, | ||
331 | { "Right Output Mixer", "Boost Bypass Switch", "Right Boost Mixer" } , | ||
332 | { "Right Output Mixer", "PCM Playback Switch", "Right DAC" }, | ||
333 | |||
334 | { "Mono Output Mixer", "Left Switch", "Left Output Mixer" }, | ||
335 | { "Mono Output Mixer", "Right Switch", "Right Output Mixer" }, | ||
336 | |||
337 | { "LOUT1 PGA", NULL, "Left Output Mixer" }, | ||
338 | { "ROUT1 PGA", NULL, "Right Output Mixer" }, | ||
339 | |||
340 | { "HP_L", NULL, "LOUT1 PGA" }, | ||
341 | { "HP_R", NULL, "ROUT1 PGA" }, | ||
342 | |||
343 | { "Left Speaker PGA", NULL, "Left Output Mixer" }, | ||
344 | { "Right Speaker PGA", NULL, "Right Output Mixer" }, | ||
345 | |||
346 | { "Left Speaker Output", NULL, "Left Speaker PGA" }, | ||
347 | { "Right Speaker Output", NULL, "Right Speaker PGA" }, | ||
348 | |||
349 | { "SPK_LN", NULL, "Left Speaker Output" }, | ||
350 | { "SPK_LP", NULL, "Left Speaker Output" }, | ||
351 | { "SPK_RN", NULL, "Right Speaker Output" }, | ||
352 | { "SPK_RP", NULL, "Right Speaker Output" }, | ||
353 | |||
354 | { "OUT3", NULL, "Mono Output Mixer", } | ||
355 | }; | ||
356 | |||
357 | static int wm8960_add_widgets(struct snd_soc_codec *codec) | ||
358 | { | ||
359 | snd_soc_dapm_new_controls(codec, wm8960_dapm_widgets, | ||
360 | ARRAY_SIZE(wm8960_dapm_widgets)); | ||
361 | |||
362 | snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths)); | ||
363 | |||
364 | snd_soc_dapm_new_widgets(codec); | ||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | static int wm8960_set_dai_fmt(struct snd_soc_dai *codec_dai, | ||
369 | unsigned int fmt) | ||
370 | { | ||
371 | struct snd_soc_codec *codec = codec_dai->codec; | ||
372 | u16 iface = 0; | ||
373 | |||
374 | /* set master/slave audio interface */ | ||
375 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
376 | case SND_SOC_DAIFMT_CBM_CFM: | ||
377 | iface |= 0x0040; | ||
378 | break; | ||
379 | case SND_SOC_DAIFMT_CBS_CFS: | ||
380 | break; | ||
381 | default: | ||
382 | return -EINVAL; | ||
383 | } | ||
384 | |||
385 | /* interface format */ | ||
386 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
387 | case SND_SOC_DAIFMT_I2S: | ||
388 | iface |= 0x0002; | ||
389 | break; | ||
390 | case SND_SOC_DAIFMT_RIGHT_J: | ||
391 | break; | ||
392 | case SND_SOC_DAIFMT_LEFT_J: | ||
393 | iface |= 0x0001; | ||
394 | break; | ||
395 | case SND_SOC_DAIFMT_DSP_A: | ||
396 | iface |= 0x0003; | ||
397 | break; | ||
398 | case SND_SOC_DAIFMT_DSP_B: | ||
399 | iface |= 0x0013; | ||
400 | break; | ||
401 | default: | ||
402 | return -EINVAL; | ||
403 | } | ||
404 | |||
405 | /* clock inversion */ | ||
406 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
407 | case SND_SOC_DAIFMT_NB_NF: | ||
408 | break; | ||
409 | case SND_SOC_DAIFMT_IB_IF: | ||
410 | iface |= 0x0090; | ||
411 | break; | ||
412 | case SND_SOC_DAIFMT_IB_NF: | ||
413 | iface |= 0x0080; | ||
414 | break; | ||
415 | case SND_SOC_DAIFMT_NB_IF: | ||
416 | iface |= 0x0010; | ||
417 | break; | ||
418 | default: | ||
419 | return -EINVAL; | ||
420 | } | ||
421 | |||
422 | /* set iface */ | ||
423 | wm8960_write(codec, WM8960_IFACE1, iface); | ||
424 | return 0; | ||
425 | } | ||
426 | |||
427 | static int wm8960_hw_params(struct snd_pcm_substream *substream, | ||
428 | struct snd_pcm_hw_params *params, | ||
429 | struct snd_soc_dai *dai) | ||
430 | { | ||
431 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
432 | struct snd_soc_device *socdev = rtd->socdev; | ||
433 | struct snd_soc_codec *codec = socdev->card->codec; | ||
434 | u16 iface = wm8960_read(codec, WM8960_IFACE1) & 0xfff3; | ||
435 | |||
436 | /* bit size */ | ||
437 | switch (params_format(params)) { | ||
438 | case SNDRV_PCM_FORMAT_S16_LE: | ||
439 | break; | ||
440 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
441 | iface |= 0x0004; | ||
442 | break; | ||
443 | case SNDRV_PCM_FORMAT_S24_LE: | ||
444 | iface |= 0x0008; | ||
445 | break; | ||
446 | } | ||
447 | |||
448 | /* set iface */ | ||
449 | wm8960_write(codec, WM8960_IFACE1, iface); | ||
450 | return 0; | ||
451 | } | ||
452 | |||
453 | static int wm8960_mute(struct snd_soc_dai *dai, int mute) | ||
454 | { | ||
455 | struct snd_soc_codec *codec = dai->codec; | ||
456 | u16 mute_reg = wm8960_read(codec, WM8960_DACCTL1) & 0xfff7; | ||
457 | |||
458 | if (mute) | ||
459 | wm8960_write(codec, WM8960_DACCTL1, mute_reg | 0x8); | ||
460 | else | ||
461 | wm8960_write(codec, WM8960_DACCTL1, mute_reg); | ||
462 | return 0; | ||
463 | } | ||
464 | |||
465 | static int wm8960_set_bias_level(struct snd_soc_codec *codec, | ||
466 | enum snd_soc_bias_level level) | ||
467 | { | ||
468 | struct wm8960_data *pdata = codec->dev->platform_data; | ||
469 | u16 reg; | ||
470 | |||
471 | switch (level) { | ||
472 | case SND_SOC_BIAS_ON: | ||
473 | break; | ||
474 | |||
475 | case SND_SOC_BIAS_PREPARE: | ||
476 | /* Set VMID to 2x50k */ | ||
477 | reg = wm8960_read(codec, WM8960_POWER1); | ||
478 | reg &= ~0x180; | ||
479 | reg |= 0x80; | ||
480 | wm8960_write(codec, WM8960_POWER1, reg); | ||
481 | break; | ||
482 | |||
483 | case SND_SOC_BIAS_STANDBY: | ||
484 | if (codec->bias_level == SND_SOC_BIAS_OFF) { | ||
485 | /* Enable anti-pop features */ | ||
486 | wm8960_write(codec, WM8960_APOP1, | ||
487 | WM8960_POBCTRL | WM8960_SOFT_ST | | ||
488 | WM8960_BUFDCOPEN | WM8960_BUFIOEN); | ||
489 | |||
490 | /* Discharge HP output */ | ||
491 | reg = WM8960_DISOP; | ||
492 | if (pdata) | ||
493 | reg |= pdata->dres << 4; | ||
494 | wm8960_write(codec, WM8960_APOP2, reg); | ||
495 | |||
496 | msleep(400); | ||
497 | |||
498 | wm8960_write(codec, WM8960_APOP2, 0); | ||
499 | |||
500 | /* Enable & ramp VMID at 2x50k */ | ||
501 | reg = wm8960_read(codec, WM8960_POWER1); | ||
502 | reg |= 0x80; | ||
503 | wm8960_write(codec, WM8960_POWER1, reg); | ||
504 | msleep(100); | ||
505 | |||
506 | /* Enable VREF */ | ||
507 | wm8960_write(codec, WM8960_POWER1, reg | WM8960_VREF); | ||
508 | |||
509 | /* Disable anti-pop features */ | ||
510 | wm8960_write(codec, WM8960_APOP1, WM8960_BUFIOEN); | ||
511 | } | ||
512 | |||
513 | /* Set VMID to 2x250k */ | ||
514 | reg = wm8960_read(codec, WM8960_POWER1); | ||
515 | reg &= ~0x180; | ||
516 | reg |= 0x100; | ||
517 | wm8960_write(codec, WM8960_POWER1, reg); | ||
518 | break; | ||
519 | |||
520 | case SND_SOC_BIAS_OFF: | ||
521 | /* Enable anti-pop features */ | ||
522 | wm8960_write(codec, WM8960_APOP1, | ||
523 | WM8960_POBCTRL | WM8960_SOFT_ST | | ||
524 | WM8960_BUFDCOPEN | WM8960_BUFIOEN); | ||
525 | |||
526 | /* Disable VMID and VREF, let them discharge */ | ||
527 | wm8960_write(codec, WM8960_POWER1, 0); | ||
528 | msleep(600); | ||
529 | |||
530 | wm8960_write(codec, WM8960_APOP1, 0); | ||
531 | break; | ||
532 | } | ||
533 | |||
534 | codec->bias_level = level; | ||
535 | |||
536 | return 0; | ||
537 | } | ||
538 | |||
539 | /* PLL divisors */ | ||
540 | struct _pll_div { | ||
541 | u32 pre_div:1; | ||
542 | u32 n:4; | ||
543 | u32 k:24; | ||
544 | }; | ||
545 | |||
546 | /* The size in bits of the pll divide multiplied by 10 | ||
547 | * to allow rounding later */ | ||
548 | #define FIXED_PLL_SIZE ((1 << 24) * 10) | ||
549 | |||
550 | static int pll_factors(unsigned int source, unsigned int target, | ||
551 | struct _pll_div *pll_div) | ||
552 | { | ||
553 | unsigned long long Kpart; | ||
554 | unsigned int K, Ndiv, Nmod; | ||
555 | |||
556 | pr_debug("WM8960 PLL: setting %dHz->%dHz\n", source, target); | ||
557 | |||
558 | /* Scale up target to PLL operating frequency */ | ||
559 | target *= 4; | ||
560 | |||
561 | Ndiv = target / source; | ||
562 | if (Ndiv < 6) { | ||
563 | source >>= 1; | ||
564 | pll_div->pre_div = 1; | ||
565 | Ndiv = target / source; | ||
566 | } else | ||
567 | pll_div->pre_div = 0; | ||
568 | |||
569 | if ((Ndiv < 6) || (Ndiv > 12)) { | ||
570 | pr_err("WM8960 PLL: Unsupported N=%d\n", Ndiv); | ||
571 | return -EINVAL; | ||
572 | } | ||
573 | |||
574 | pll_div->n = Ndiv; | ||
575 | Nmod = target % source; | ||
576 | Kpart = FIXED_PLL_SIZE * (long long)Nmod; | ||
577 | |||
578 | do_div(Kpart, source); | ||
579 | |||
580 | K = Kpart & 0xFFFFFFFF; | ||
581 | |||
582 | /* Check if we need to round */ | ||
583 | if ((K % 10) >= 5) | ||
584 | K += 5; | ||
585 | |||
586 | /* Move down to proper range now rounding is done */ | ||
587 | K /= 10; | ||
588 | |||
589 | pll_div->k = K; | ||
590 | |||
591 | pr_debug("WM8960 PLL: N=%x K=%x pre_div=%d\n", | ||
592 | pll_div->n, pll_div->k, pll_div->pre_div); | ||
593 | |||
594 | return 0; | ||
595 | } | ||
596 | |||
597 | static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, | ||
598 | int pll_id, unsigned int freq_in, unsigned int freq_out) | ||
599 | { | ||
600 | struct snd_soc_codec *codec = codec_dai->codec; | ||
601 | u16 reg; | ||
602 | static struct _pll_div pll_div; | ||
603 | int ret; | ||
604 | |||
605 | if (freq_in && freq_out) { | ||
606 | ret = pll_factors(freq_in, freq_out, &pll_div); | ||
607 | if (ret != 0) | ||
608 | return ret; | ||
609 | } | ||
610 | |||
611 | /* Disable the PLL: even if we are changing the frequency the | ||
612 | * PLL needs to be disabled while we do so. */ | ||
613 | wm8960_write(codec, WM8960_CLOCK1, | ||
614 | wm8960_read(codec, WM8960_CLOCK1) & ~1); | ||
615 | wm8960_write(codec, WM8960_POWER2, | ||
616 | wm8960_read(codec, WM8960_POWER2) & ~1); | ||
617 | |||
618 | if (!freq_in || !freq_out) | ||
619 | return 0; | ||
620 | |||
621 | reg = wm8960_read(codec, WM8960_PLL1) & ~0x3f; | ||
622 | reg |= pll_div.pre_div << 4; | ||
623 | reg |= pll_div.n; | ||
624 | |||
625 | if (pll_div.k) { | ||
626 | reg |= 0x20; | ||
627 | |||
628 | wm8960_write(codec, WM8960_PLL2, (pll_div.k >> 18) & 0x3f); | ||
629 | wm8960_write(codec, WM8960_PLL3, (pll_div.k >> 9) & 0x1ff); | ||
630 | wm8960_write(codec, WM8960_PLL4, pll_div.k & 0x1ff); | ||
631 | } | ||
632 | wm8960_write(codec, WM8960_PLL1, reg); | ||
633 | |||
634 | /* Turn it on */ | ||
635 | wm8960_write(codec, WM8960_POWER2, | ||
636 | wm8960_read(codec, WM8960_POWER2) | 1); | ||
637 | msleep(250); | ||
638 | wm8960_write(codec, WM8960_CLOCK1, | ||
639 | wm8960_read(codec, WM8960_CLOCK1) | 1); | ||
640 | |||
641 | return 0; | ||
642 | } | ||
643 | |||
644 | static int wm8960_set_dai_clkdiv(struct snd_soc_dai *codec_dai, | ||
645 | int div_id, int div) | ||
646 | { | ||
647 | struct snd_soc_codec *codec = codec_dai->codec; | ||
648 | u16 reg; | ||
649 | |||
650 | switch (div_id) { | ||
651 | case WM8960_SYSCLKSEL: | ||
652 | reg = wm8960_read(codec, WM8960_CLOCK1) & 0x1fe; | ||
653 | wm8960_write(codec, WM8960_CLOCK1, reg | div); | ||
654 | break; | ||
655 | case WM8960_SYSCLKDIV: | ||
656 | reg = wm8960_read(codec, WM8960_CLOCK1) & 0x1f9; | ||
657 | wm8960_write(codec, WM8960_CLOCK1, reg | div); | ||
658 | break; | ||
659 | case WM8960_DACDIV: | ||
660 | reg = wm8960_read(codec, WM8960_CLOCK1) & 0x1c7; | ||
661 | wm8960_write(codec, WM8960_CLOCK1, reg | div); | ||
662 | break; | ||
663 | case WM8960_OPCLKDIV: | ||
664 | reg = wm8960_read(codec, WM8960_PLL1) & 0x03f; | ||
665 | wm8960_write(codec, WM8960_PLL1, reg | div); | ||
666 | break; | ||
667 | case WM8960_DCLKDIV: | ||
668 | reg = wm8960_read(codec, WM8960_CLOCK2) & 0x03f; | ||
669 | wm8960_write(codec, WM8960_CLOCK2, reg | div); | ||
670 | break; | ||
671 | case WM8960_TOCLKSEL: | ||
672 | reg = wm8960_read(codec, WM8960_ADDCTL1) & 0x1fd; | ||
673 | wm8960_write(codec, WM8960_ADDCTL1, reg | div); | ||
674 | break; | ||
675 | default: | ||
676 | return -EINVAL; | ||
677 | } | ||
678 | |||
679 | return 0; | ||
680 | } | ||
681 | |||
682 | #define WM8960_RATES SNDRV_PCM_RATE_8000_48000 | ||
683 | |||
684 | #define WM8960_FORMATS \ | ||
685 | (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ | ||
686 | SNDRV_PCM_FMTBIT_S24_LE) | ||
687 | |||
688 | static struct snd_soc_dai_ops wm8960_dai_ops = { | ||
689 | .hw_params = wm8960_hw_params, | ||
690 | .digital_mute = wm8960_mute, | ||
691 | .set_fmt = wm8960_set_dai_fmt, | ||
692 | .set_clkdiv = wm8960_set_dai_clkdiv, | ||
693 | .set_pll = wm8960_set_dai_pll, | ||
694 | }; | ||
695 | |||
696 | struct snd_soc_dai wm8960_dai = { | ||
697 | .name = "WM8960", | ||
698 | .playback = { | ||
699 | .stream_name = "Playback", | ||
700 | .channels_min = 1, | ||
701 | .channels_max = 2, | ||
702 | .rates = WM8960_RATES, | ||
703 | .formats = WM8960_FORMATS,}, | ||
704 | .capture = { | ||
705 | .stream_name = "Capture", | ||
706 | .channels_min = 1, | ||
707 | .channels_max = 2, | ||
708 | .rates = WM8960_RATES, | ||
709 | .formats = WM8960_FORMATS,}, | ||
710 | .ops = &wm8960_dai_ops, | ||
711 | .symmetric_rates = 1, | ||
712 | }; | ||
713 | EXPORT_SYMBOL_GPL(wm8960_dai); | ||
714 | |||
715 | static int wm8960_suspend(struct platform_device *pdev, pm_message_t state) | ||
716 | { | ||
717 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
718 | struct snd_soc_codec *codec = socdev->card->codec; | ||
719 | |||
720 | wm8960_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
721 | return 0; | ||
722 | } | ||
723 | |||
724 | static int wm8960_resume(struct platform_device *pdev) | ||
725 | { | ||
726 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
727 | struct snd_soc_codec *codec = socdev->card->codec; | ||
728 | int i; | ||
729 | u8 data[2]; | ||
730 | u16 *cache = codec->reg_cache; | ||
731 | |||
732 | /* Sync reg_cache with the hardware */ | ||
733 | for (i = 0; i < ARRAY_SIZE(wm8960_reg); i++) { | ||
734 | data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001); | ||
735 | data[1] = cache[i] & 0x00ff; | ||
736 | codec->hw_write(codec->control_data, data, 2); | ||
737 | } | ||
738 | |||
739 | wm8960_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
740 | wm8960_set_bias_level(codec, codec->suspend_bias_level); | ||
741 | return 0; | ||
742 | } | ||
743 | |||
744 | static struct snd_soc_codec *wm8960_codec; | ||
745 | |||
746 | static int wm8960_probe(struct platform_device *pdev) | ||
747 | { | ||
748 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
749 | struct snd_soc_codec *codec; | ||
750 | int ret = 0; | ||
751 | |||
752 | if (wm8960_codec == NULL) { | ||
753 | dev_err(&pdev->dev, "Codec device not registered\n"); | ||
754 | return -ENODEV; | ||
755 | } | ||
756 | |||
757 | socdev->card->codec = wm8960_codec; | ||
758 | codec = wm8960_codec; | ||
759 | |||
760 | /* register pcms */ | ||
761 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
762 | if (ret < 0) { | ||
763 | dev_err(codec->dev, "failed to create pcms: %d\n", ret); | ||
764 | goto pcm_err; | ||
765 | } | ||
766 | |||
767 | snd_soc_add_controls(codec, wm8960_snd_controls, | ||
768 | ARRAY_SIZE(wm8960_snd_controls)); | ||
769 | wm8960_add_widgets(codec); | ||
770 | ret = snd_soc_init_card(socdev); | ||
771 | if (ret < 0) { | ||
772 | dev_err(codec->dev, "failed to register card: %d\n", ret); | ||
773 | goto card_err; | ||
774 | } | ||
775 | |||
776 | return ret; | ||
777 | |||
778 | card_err: | ||
779 | snd_soc_free_pcms(socdev); | ||
780 | snd_soc_dapm_free(socdev); | ||
781 | pcm_err: | ||
782 | return ret; | ||
783 | } | ||
784 | |||
785 | /* power down chip */ | ||
786 | static int wm8960_remove(struct platform_device *pdev) | ||
787 | { | ||
788 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
789 | |||
790 | snd_soc_free_pcms(socdev); | ||
791 | snd_soc_dapm_free(socdev); | ||
792 | |||
793 | return 0; | ||
794 | } | ||
795 | |||
796 | struct snd_soc_codec_device soc_codec_dev_wm8960 = { | ||
797 | .probe = wm8960_probe, | ||
798 | .remove = wm8960_remove, | ||
799 | .suspend = wm8960_suspend, | ||
800 | .resume = wm8960_resume, | ||
801 | }; | ||
802 | EXPORT_SYMBOL_GPL(soc_codec_dev_wm8960); | ||
803 | |||
804 | static int wm8960_register(struct wm8960_priv *wm8960) | ||
805 | { | ||
806 | struct wm8960_data *pdata = wm8960->codec.dev->platform_data; | ||
807 | struct snd_soc_codec *codec = &wm8960->codec; | ||
808 | int ret; | ||
809 | u16 reg; | ||
810 | |||
811 | if (wm8960_codec) { | ||
812 | dev_err(codec->dev, "Another WM8960 is registered\n"); | ||
813 | return -EINVAL; | ||
814 | } | ||
815 | |||
816 | if (!pdata) { | ||
817 | dev_warn(codec->dev, "No platform data supplied\n"); | ||
818 | } else { | ||
819 | if (pdata->dres > WM8960_DRES_MAX) { | ||
820 | dev_err(codec->dev, "Invalid DRES: %d\n", pdata->dres); | ||
821 | pdata->dres = 0; | ||
822 | } | ||
823 | } | ||
824 | |||
825 | mutex_init(&codec->mutex); | ||
826 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
827 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
828 | |||
829 | codec->private_data = wm8960; | ||
830 | codec->name = "WM8960"; | ||
831 | codec->owner = THIS_MODULE; | ||
832 | codec->read = wm8960_read_reg_cache; | ||
833 | codec->write = wm8960_write; | ||
834 | codec->bias_level = SND_SOC_BIAS_OFF; | ||
835 | codec->set_bias_level = wm8960_set_bias_level; | ||
836 | codec->dai = &wm8960_dai; | ||
837 | codec->num_dai = 1; | ||
838 | codec->reg_cache_size = WM8960_CACHEREGNUM; | ||
839 | codec->reg_cache = &wm8960->reg_cache; | ||
840 | |||
841 | memcpy(codec->reg_cache, wm8960_reg, sizeof(wm8960_reg)); | ||
842 | |||
843 | ret = wm8960_reset(codec); | ||
844 | if (ret < 0) { | ||
845 | dev_err(codec->dev, "Failed to issue reset\n"); | ||
846 | return ret; | ||
847 | } | ||
848 | |||
849 | wm8960_dai.dev = codec->dev; | ||
850 | |||
851 | wm8960_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
852 | |||
853 | /* Latch the update bits */ | ||
854 | reg = wm8960_read(codec, WM8960_LINVOL); | ||
855 | wm8960_write(codec, WM8960_LINVOL, reg | 0x100); | ||
856 | reg = wm8960_read(codec, WM8960_RINVOL); | ||
857 | wm8960_write(codec, WM8960_RINVOL, reg | 0x100); | ||
858 | reg = wm8960_read(codec, WM8960_LADC); | ||
859 | wm8960_write(codec, WM8960_LADC, reg | 0x100); | ||
860 | reg = wm8960_read(codec, WM8960_RADC); | ||
861 | wm8960_write(codec, WM8960_RADC, reg | 0x100); | ||
862 | reg = wm8960_read(codec, WM8960_LDAC); | ||
863 | wm8960_write(codec, WM8960_LDAC, reg | 0x100); | ||
864 | reg = wm8960_read(codec, WM8960_RDAC); | ||
865 | wm8960_write(codec, WM8960_RDAC, reg | 0x100); | ||
866 | reg = wm8960_read(codec, WM8960_LOUT1); | ||
867 | wm8960_write(codec, WM8960_LOUT1, reg | 0x100); | ||
868 | reg = wm8960_read(codec, WM8960_ROUT1); | ||
869 | wm8960_write(codec, WM8960_ROUT1, reg | 0x100); | ||
870 | reg = wm8960_read(codec, WM8960_LOUT2); | ||
871 | wm8960_write(codec, WM8960_LOUT2, reg | 0x100); | ||
872 | reg = wm8960_read(codec, WM8960_ROUT2); | ||
873 | wm8960_write(codec, WM8960_ROUT2, reg | 0x100); | ||
874 | |||
875 | wm8960_codec = codec; | ||
876 | |||
877 | ret = snd_soc_register_codec(codec); | ||
878 | if (ret != 0) { | ||
879 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); | ||
880 | return ret; | ||
881 | } | ||
882 | |||
883 | ret = snd_soc_register_dai(&wm8960_dai); | ||
884 | if (ret != 0) { | ||
885 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); | ||
886 | snd_soc_unregister_codec(codec); | ||
887 | return ret; | ||
888 | } | ||
889 | |||
890 | return 0; | ||
891 | } | ||
892 | |||
893 | static void wm8960_unregister(struct wm8960_priv *wm8960) | ||
894 | { | ||
895 | wm8960_set_bias_level(&wm8960->codec, SND_SOC_BIAS_OFF); | ||
896 | snd_soc_unregister_dai(&wm8960_dai); | ||
897 | snd_soc_unregister_codec(&wm8960->codec); | ||
898 | kfree(wm8960); | ||
899 | wm8960_codec = NULL; | ||
900 | } | ||
901 | |||
902 | static __devinit int wm8960_i2c_probe(struct i2c_client *i2c, | ||
903 | const struct i2c_device_id *id) | ||
904 | { | ||
905 | struct wm8960_priv *wm8960; | ||
906 | struct snd_soc_codec *codec; | ||
907 | |||
908 | wm8960 = kzalloc(sizeof(struct wm8960_priv), GFP_KERNEL); | ||
909 | if (wm8960 == NULL) | ||
910 | return -ENOMEM; | ||
911 | |||
912 | codec = &wm8960->codec; | ||
913 | codec->hw_write = (hw_write_t)i2c_master_send; | ||
914 | |||
915 | i2c_set_clientdata(i2c, wm8960); | ||
916 | codec->control_data = i2c; | ||
917 | |||
918 | codec->dev = &i2c->dev; | ||
919 | |||
920 | return wm8960_register(wm8960); | ||
921 | } | ||
922 | |||
923 | static __devexit int wm8960_i2c_remove(struct i2c_client *client) | ||
924 | { | ||
925 | struct wm8960_priv *wm8960 = i2c_get_clientdata(client); | ||
926 | wm8960_unregister(wm8960); | ||
927 | return 0; | ||
928 | } | ||
929 | |||
930 | static const struct i2c_device_id wm8960_i2c_id[] = { | ||
931 | { "wm8960", 0 }, | ||
932 | { } | ||
933 | }; | ||
934 | MODULE_DEVICE_TABLE(i2c, wm8960_i2c_id); | ||
935 | |||
936 | static struct i2c_driver wm8960_i2c_driver = { | ||
937 | .driver = { | ||
938 | .name = "WM8960 I2C Codec", | ||
939 | .owner = THIS_MODULE, | ||
940 | }, | ||
941 | .probe = wm8960_i2c_probe, | ||
942 | .remove = __devexit_p(wm8960_i2c_remove), | ||
943 | .id_table = wm8960_i2c_id, | ||
944 | }; | ||
945 | |||
946 | static int __init wm8960_modinit(void) | ||
947 | { | ||
948 | int ret; | ||
949 | |||
950 | ret = i2c_add_driver(&wm8960_i2c_driver); | ||
951 | if (ret != 0) { | ||
952 | printk(KERN_ERR "Failed to register WM8960 I2C driver: %d\n", | ||
953 | ret); | ||
954 | } | ||
955 | |||
956 | return ret; | ||
957 | } | ||
958 | module_init(wm8960_modinit); | ||
959 | |||
960 | static void __exit wm8960_exit(void) | ||
961 | { | ||
962 | i2c_del_driver(&wm8960_i2c_driver); | ||
963 | } | ||
964 | module_exit(wm8960_exit); | ||
965 | |||
966 | |||
967 | MODULE_DESCRIPTION("ASoC WM8960 driver"); | ||
968 | MODULE_AUTHOR("Liam Girdwood"); | ||
969 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/wm8960.h b/sound/soc/codecs/wm8960.h new file mode 100644 index 000000000000..c9af56c9d9d4 --- /dev/null +++ b/sound/soc/codecs/wm8960.h | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | * wm8960.h -- WM8960 Soc Audio driver | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #ifndef _WM8960_H | ||
10 | #define _WM8960_H | ||
11 | |||
12 | /* WM8960 register space */ | ||
13 | |||
14 | |||
15 | #define WM8960_CACHEREGNUM 56 | ||
16 | |||
17 | #define WM8960_LINVOL 0x0 | ||
18 | #define WM8960_RINVOL 0x1 | ||
19 | #define WM8960_LOUT1 0x2 | ||
20 | #define WM8960_ROUT1 0x3 | ||
21 | #define WM8960_CLOCK1 0x4 | ||
22 | #define WM8960_DACCTL1 0x5 | ||
23 | #define WM8960_DACCTL2 0x6 | ||
24 | #define WM8960_IFACE1 0x7 | ||
25 | #define WM8960_CLOCK2 0x8 | ||
26 | #define WM8960_IFACE2 0x9 | ||
27 | #define WM8960_LDAC 0xa | ||
28 | #define WM8960_RDAC 0xb | ||
29 | |||
30 | #define WM8960_RESET 0xf | ||
31 | #define WM8960_3D 0x10 | ||
32 | #define WM8960_ALC1 0x11 | ||
33 | #define WM8960_ALC2 0x12 | ||
34 | #define WM8960_ALC3 0x13 | ||
35 | #define WM8960_NOISEG 0x14 | ||
36 | #define WM8960_LADC 0x15 | ||
37 | #define WM8960_RADC 0x16 | ||
38 | #define WM8960_ADDCTL1 0x17 | ||
39 | #define WM8960_ADDCTL2 0x18 | ||
40 | #define WM8960_POWER1 0x19 | ||
41 | #define WM8960_POWER2 0x1a | ||
42 | #define WM8960_ADDCTL3 0x1b | ||
43 | #define WM8960_APOP1 0x1c | ||
44 | #define WM8960_APOP2 0x1d | ||
45 | |||
46 | #define WM8960_LINPATH 0x20 | ||
47 | #define WM8960_RINPATH 0x21 | ||
48 | #define WM8960_LOUTMIX 0x22 | ||
49 | |||
50 | #define WM8960_ROUTMIX 0x25 | ||
51 | #define WM8960_MONOMIX1 0x26 | ||
52 | #define WM8960_MONOMIX2 0x27 | ||
53 | #define WM8960_LOUT2 0x28 | ||
54 | #define WM8960_ROUT2 0x29 | ||
55 | #define WM8960_MONO 0x2a | ||
56 | #define WM8960_INBMIX1 0x2b | ||
57 | #define WM8960_INBMIX2 0x2c | ||
58 | #define WM8960_BYPASS1 0x2d | ||
59 | #define WM8960_BYPASS2 0x2e | ||
60 | #define WM8960_POWER3 0x2f | ||
61 | #define WM8960_ADDCTL4 0x30 | ||
62 | #define WM8960_CLASSD1 0x31 | ||
63 | |||
64 | #define WM8960_CLASSD3 0x33 | ||
65 | #define WM8960_PLL1 0x34 | ||
66 | #define WM8960_PLL2 0x35 | ||
67 | #define WM8960_PLL3 0x36 | ||
68 | #define WM8960_PLL4 0x37 | ||
69 | |||
70 | |||
71 | /* | ||
72 | * WM8960 Clock dividers | ||
73 | */ | ||
74 | #define WM8960_SYSCLKDIV 0 | ||
75 | #define WM8960_DACDIV 1 | ||
76 | #define WM8960_OPCLKDIV 2 | ||
77 | #define WM8960_DCLKDIV 3 | ||
78 | #define WM8960_TOCLKSEL 4 | ||
79 | #define WM8960_SYSCLKSEL 5 | ||
80 | |||
81 | #define WM8960_SYSCLK_DIV_1 (0 << 1) | ||
82 | #define WM8960_SYSCLK_DIV_2 (2 << 1) | ||
83 | |||
84 | #define WM8960_SYSCLK_MCLK (0 << 0) | ||
85 | #define WM8960_SYSCLK_PLL (1 << 0) | ||
86 | |||
87 | #define WM8960_DAC_DIV_1 (0 << 3) | ||
88 | #define WM8960_DAC_DIV_1_5 (1 << 3) | ||
89 | #define WM8960_DAC_DIV_2 (2 << 3) | ||
90 | #define WM8960_DAC_DIV_3 (3 << 3) | ||
91 | #define WM8960_DAC_DIV_4 (4 << 3) | ||
92 | #define WM8960_DAC_DIV_5_5 (5 << 3) | ||
93 | #define WM8960_DAC_DIV_6 (6 << 3) | ||
94 | |||
95 | #define WM8960_DCLK_DIV_1_5 (0 << 6) | ||
96 | #define WM8960_DCLK_DIV_2 (1 << 6) | ||
97 | #define WM8960_DCLK_DIV_3 (2 << 6) | ||
98 | #define WM8960_DCLK_DIV_4 (3 << 6) | ||
99 | #define WM8960_DCLK_DIV_6 (4 << 6) | ||
100 | #define WM8960_DCLK_DIV_8 (5 << 6) | ||
101 | #define WM8960_DCLK_DIV_12 (6 << 6) | ||
102 | #define WM8960_DCLK_DIV_16 (7 << 6) | ||
103 | |||
104 | #define WM8960_TOCLK_F19 (0 << 1) | ||
105 | #define WM8960_TOCLK_F21 (1 << 1) | ||
106 | |||
107 | #define WM8960_OPCLK_DIV_1 (0 << 0) | ||
108 | #define WM8960_OPCLK_DIV_2 (1 << 0) | ||
109 | #define WM8960_OPCLK_DIV_3 (2 << 0) | ||
110 | #define WM8960_OPCLK_DIV_4 (3 << 0) | ||
111 | #define WM8960_OPCLK_DIV_5_5 (4 << 0) | ||
112 | #define WM8960_OPCLK_DIV_6 (5 << 0) | ||
113 | |||
114 | extern struct snd_soc_dai wm8960_dai; | ||
115 | extern struct snd_soc_codec_device soc_codec_dev_wm8960; | ||
116 | |||
117 | #define WM8960_DRES_400R 0 | ||
118 | #define WM8960_DRES_200R 1 | ||
119 | #define WM8960_DRES_600R 2 | ||
120 | #define WM8960_DRES_150R 3 | ||
121 | #define WM8960_DRES_MAX 3 | ||
122 | |||
123 | struct wm8960_data { | ||
124 | int dres; | ||
125 | }; | ||
126 | |||
127 | #endif | ||
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c new file mode 100644 index 000000000000..c05f71803aa8 --- /dev/null +++ b/sound/soc/codecs/wm8988.c | |||
@@ -0,0 +1,1097 @@ | |||
1 | /* | ||
2 | * wm8988.c -- WM8988 ALSA SoC audio driver | ||
3 | * | ||
4 | * Copyright 2009 Wolfson Microelectronics plc | ||
5 | * Copyright 2005 Openedhand Ltd. | ||
6 | * | ||
7 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/moduleparam.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/pm.h> | ||
19 | #include <linux/i2c.h> | ||
20 | #include <linux/spi/spi.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <sound/core.h> | ||
23 | #include <sound/pcm.h> | ||
24 | #include <sound/pcm_params.h> | ||
25 | #include <sound/tlv.h> | ||
26 | #include <sound/soc.h> | ||
27 | #include <sound/soc-dapm.h> | ||
28 | #include <sound/initval.h> | ||
29 | |||
30 | #include "wm8988.h" | ||
31 | |||
32 | /* | ||
33 | * wm8988 register cache | ||
34 | * We can't read the WM8988 register space when we | ||
35 | * are using 2 wire for device control, so we cache them instead. | ||
36 | */ | ||
37 | static const u16 wm8988_reg[] = { | ||
38 | 0x0097, 0x0097, 0x0079, 0x0079, /* 0 */ | ||
39 | 0x0000, 0x0008, 0x0000, 0x000a, /* 4 */ | ||
40 | 0x0000, 0x0000, 0x00ff, 0x00ff, /* 8 */ | ||
41 | 0x000f, 0x000f, 0x0000, 0x0000, /* 12 */ | ||
42 | 0x0000, 0x007b, 0x0000, 0x0032, /* 16 */ | ||
43 | 0x0000, 0x00c3, 0x00c3, 0x00c0, /* 20 */ | ||
44 | 0x0000, 0x0000, 0x0000, 0x0000, /* 24 */ | ||
45 | 0x0000, 0x0000, 0x0000, 0x0000, /* 28 */ | ||
46 | 0x0000, 0x0000, 0x0050, 0x0050, /* 32 */ | ||
47 | 0x0050, 0x0050, 0x0050, 0x0050, /* 36 */ | ||
48 | 0x0079, 0x0079, 0x0079, /* 40 */ | ||
49 | }; | ||
50 | |||
51 | /* codec private data */ | ||
52 | struct wm8988_priv { | ||
53 | unsigned int sysclk; | ||
54 | struct snd_soc_codec codec; | ||
55 | struct snd_pcm_hw_constraint_list *sysclk_constraints; | ||
56 | u16 reg_cache[WM8988_NUM_REG]; | ||
57 | }; | ||
58 | |||
59 | |||
60 | /* | ||
61 | * read wm8988 register cache | ||
62 | */ | ||
63 | static inline unsigned int wm8988_read_reg_cache(struct snd_soc_codec *codec, | ||
64 | unsigned int reg) | ||
65 | { | ||
66 | u16 *cache = codec->reg_cache; | ||
67 | if (reg > WM8988_NUM_REG) | ||
68 | return -1; | ||
69 | return cache[reg]; | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * write wm8988 register cache | ||
74 | */ | ||
75 | static inline void wm8988_write_reg_cache(struct snd_soc_codec *codec, | ||
76 | unsigned int reg, unsigned int value) | ||
77 | { | ||
78 | u16 *cache = codec->reg_cache; | ||
79 | if (reg > WM8988_NUM_REG) | ||
80 | return; | ||
81 | cache[reg] = value; | ||
82 | } | ||
83 | |||
84 | static int wm8988_write(struct snd_soc_codec *codec, unsigned int reg, | ||
85 | unsigned int value) | ||
86 | { | ||
87 | u8 data[2]; | ||
88 | |||
89 | /* data is | ||
90 | * D15..D9 WM8753 register offset | ||
91 | * D8...D0 register data | ||
92 | */ | ||
93 | data[0] = (reg << 1) | ((value >> 8) & 0x0001); | ||
94 | data[1] = value & 0x00ff; | ||
95 | |||
96 | wm8988_write_reg_cache(codec, reg, value); | ||
97 | if (codec->hw_write(codec->control_data, data, 2) == 2) | ||
98 | return 0; | ||
99 | else | ||
100 | return -EIO; | ||
101 | } | ||
102 | |||
103 | #define wm8988_reset(c) wm8988_write(c, WM8988_RESET, 0) | ||
104 | |||
105 | /* | ||
106 | * WM8988 Controls | ||
107 | */ | ||
108 | |||
109 | static const char *bass_boost_txt[] = {"Linear Control", "Adaptive Boost"}; | ||
110 | static const struct soc_enum bass_boost = | ||
111 | SOC_ENUM_SINGLE(WM8988_BASS, 7, 2, bass_boost_txt); | ||
112 | |||
113 | static const char *bass_filter_txt[] = { "130Hz @ 48kHz", "200Hz @ 48kHz" }; | ||
114 | static const struct soc_enum bass_filter = | ||
115 | SOC_ENUM_SINGLE(WM8988_BASS, 6, 2, bass_filter_txt); | ||
116 | |||
117 | static const char *treble_txt[] = {"8kHz", "4kHz"}; | ||
118 | static const struct soc_enum treble = | ||
119 | SOC_ENUM_SINGLE(WM8988_TREBLE, 6, 2, treble_txt); | ||
120 | |||
121 | static const char *stereo_3d_lc_txt[] = {"200Hz", "500Hz"}; | ||
122 | static const struct soc_enum stereo_3d_lc = | ||
123 | SOC_ENUM_SINGLE(WM8988_3D, 5, 2, stereo_3d_lc_txt); | ||
124 | |||
125 | static const char *stereo_3d_uc_txt[] = {"2.2kHz", "1.5kHz"}; | ||
126 | static const struct soc_enum stereo_3d_uc = | ||
127 | SOC_ENUM_SINGLE(WM8988_3D, 6, 2, stereo_3d_uc_txt); | ||
128 | |||
129 | static const char *stereo_3d_func_txt[] = {"Capture", "Playback"}; | ||
130 | static const struct soc_enum stereo_3d_func = | ||
131 | SOC_ENUM_SINGLE(WM8988_3D, 7, 2, stereo_3d_func_txt); | ||
132 | |||
133 | static const char *alc_func_txt[] = {"Off", "Right", "Left", "Stereo"}; | ||
134 | static const struct soc_enum alc_func = | ||
135 | SOC_ENUM_SINGLE(WM8988_ALC1, 7, 4, alc_func_txt); | ||
136 | |||
137 | static const char *ng_type_txt[] = {"Constant PGA Gain", | ||
138 | "Mute ADC Output"}; | ||
139 | static const struct soc_enum ng_type = | ||
140 | SOC_ENUM_SINGLE(WM8988_NGATE, 1, 2, ng_type_txt); | ||
141 | |||
142 | static const char *deemph_txt[] = {"None", "32Khz", "44.1Khz", "48Khz"}; | ||
143 | static const struct soc_enum deemph = | ||
144 | SOC_ENUM_SINGLE(WM8988_ADCDAC, 1, 4, deemph_txt); | ||
145 | |||
146 | static const char *adcpol_txt[] = {"Normal", "L Invert", "R Invert", | ||
147 | "L + R Invert"}; | ||
148 | static const struct soc_enum adcpol = | ||
149 | SOC_ENUM_SINGLE(WM8988_ADCDAC, 5, 4, adcpol_txt); | ||
150 | |||
151 | static const DECLARE_TLV_DB_SCALE(pga_tlv, -1725, 75, 0); | ||
152 | static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1); | ||
153 | static const DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 1); | ||
154 | static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1); | ||
155 | static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0); | ||
156 | |||
157 | static const struct snd_kcontrol_new wm8988_snd_controls[] = { | ||
158 | |||
159 | SOC_ENUM("Bass Boost", bass_boost), | ||
160 | SOC_ENUM("Bass Filter", bass_filter), | ||
161 | SOC_SINGLE("Bass Volume", WM8988_BASS, 0, 15, 1), | ||
162 | |||
163 | SOC_SINGLE("Treble Volume", WM8988_TREBLE, 0, 15, 0), | ||
164 | SOC_ENUM("Treble Cut-off", treble), | ||
165 | |||
166 | SOC_SINGLE("3D Switch", WM8988_3D, 0, 1, 0), | ||
167 | SOC_SINGLE("3D Volume", WM8988_3D, 1, 15, 0), | ||
168 | SOC_ENUM("3D Lower Cut-off", stereo_3d_lc), | ||
169 | SOC_ENUM("3D Upper Cut-off", stereo_3d_uc), | ||
170 | SOC_ENUM("3D Mode", stereo_3d_func), | ||
171 | |||
172 | SOC_SINGLE("ALC Capture Target Volume", WM8988_ALC1, 0, 7, 0), | ||
173 | SOC_SINGLE("ALC Capture Max Volume", WM8988_ALC1, 4, 7, 0), | ||
174 | SOC_ENUM("ALC Capture Function", alc_func), | ||
175 | SOC_SINGLE("ALC Capture ZC Switch", WM8988_ALC2, 7, 1, 0), | ||
176 | SOC_SINGLE("ALC Capture Hold Time", WM8988_ALC2, 0, 15, 0), | ||
177 | SOC_SINGLE("ALC Capture Decay Time", WM8988_ALC3, 4, 15, 0), | ||
178 | SOC_SINGLE("ALC Capture Attack Time", WM8988_ALC3, 0, 15, 0), | ||
179 | SOC_SINGLE("ALC Capture NG Threshold", WM8988_NGATE, 3, 31, 0), | ||
180 | SOC_ENUM("ALC Capture NG Type", ng_type), | ||
181 | SOC_SINGLE("ALC Capture NG Switch", WM8988_NGATE, 0, 1, 0), | ||
182 | |||
183 | SOC_SINGLE("ZC Timeout Switch", WM8988_ADCTL1, 0, 1, 0), | ||
184 | |||
185 | SOC_DOUBLE_R_TLV("Capture Digital Volume", WM8988_LADC, WM8988_RADC, | ||
186 | 0, 255, 0, adc_tlv), | ||
187 | SOC_DOUBLE_R_TLV("Capture Volume", WM8988_LINVOL, WM8988_RINVOL, | ||
188 | 0, 63, 0, pga_tlv), | ||
189 | SOC_DOUBLE_R("Capture ZC Switch", WM8988_LINVOL, WM8988_RINVOL, 6, 1, 0), | ||
190 | SOC_DOUBLE_R("Capture Switch", WM8988_LINVOL, WM8988_RINVOL, 7, 1, 1), | ||
191 | |||
192 | SOC_ENUM("Playback De-emphasis", deemph), | ||
193 | |||
194 | SOC_ENUM("Capture Polarity", adcpol), | ||
195 | SOC_SINGLE("Playback 6dB Attenuate", WM8988_ADCDAC, 7, 1, 0), | ||
196 | SOC_SINGLE("Capture 6dB Attenuate", WM8988_ADCDAC, 8, 1, 0), | ||
197 | |||
198 | SOC_DOUBLE_R_TLV("PCM Volume", WM8988_LDAC, WM8988_RDAC, 0, 255, 0, dac_tlv), | ||
199 | |||
200 | SOC_SINGLE_TLV("Left Mixer Left Bypass Volume", WM8988_LOUTM1, 4, 7, 1, | ||
201 | bypass_tlv), | ||
202 | SOC_SINGLE_TLV("Left Mixer Right Bypass Volume", WM8988_LOUTM2, 4, 7, 1, | ||
203 | bypass_tlv), | ||
204 | SOC_SINGLE_TLV("Right Mixer Left Bypass Volume", WM8988_ROUTM1, 4, 7, 1, | ||
205 | bypass_tlv), | ||
206 | SOC_SINGLE_TLV("Right Mixer Right Bypass Volume", WM8988_ROUTM2, 4, 7, 1, | ||
207 | bypass_tlv), | ||
208 | |||
209 | SOC_DOUBLE_R("Output 1 Playback ZC Switch", WM8988_LOUT1V, | ||
210 | WM8988_ROUT1V, 7, 1, 0), | ||
211 | SOC_DOUBLE_R_TLV("Output 1 Playback Volume", WM8988_LOUT1V, WM8988_ROUT1V, | ||
212 | 0, 127, 0, out_tlv), | ||
213 | |||
214 | SOC_DOUBLE_R("Output 2 Playback ZC Switch", WM8988_LOUT2V, | ||
215 | WM8988_ROUT2V, 7, 1, 0), | ||
216 | SOC_DOUBLE_R_TLV("Output 2 Playback Volume", WM8988_LOUT2V, WM8988_ROUT2V, | ||
217 | 0, 127, 0, out_tlv), | ||
218 | |||
219 | }; | ||
220 | |||
221 | /* | ||
222 | * DAPM Controls | ||
223 | */ | ||
224 | |||
225 | static int wm8988_lrc_control(struct snd_soc_dapm_widget *w, | ||
226 | struct snd_kcontrol *kcontrol, int event) | ||
227 | { | ||
228 | struct snd_soc_codec *codec = w->codec; | ||
229 | u16 adctl2 = wm8988_read_reg_cache(codec, WM8988_ADCTL2); | ||
230 | |||
231 | /* Use the DAC to gate LRC if active, otherwise use ADC */ | ||
232 | if (wm8988_read_reg_cache(codec, WM8988_PWR2) & 0x180) | ||
233 | adctl2 &= ~0x4; | ||
234 | else | ||
235 | adctl2 |= 0x4; | ||
236 | |||
237 | return wm8988_write(codec, WM8988_ADCTL2, adctl2); | ||
238 | } | ||
239 | |||
240 | static const char *wm8988_line_texts[] = { | ||
241 | "Line 1", "Line 2", "PGA", "Differential"}; | ||
242 | |||
243 | static const unsigned int wm8988_line_values[] = { | ||
244 | 0, 1, 3, 4}; | ||
245 | |||
246 | static const struct soc_enum wm8988_lline_enum = | ||
247 | SOC_VALUE_ENUM_SINGLE(WM8988_LOUTM1, 0, 7, | ||
248 | ARRAY_SIZE(wm8988_line_texts), | ||
249 | wm8988_line_texts, | ||
250 | wm8988_line_values); | ||
251 | static const struct snd_kcontrol_new wm8988_left_line_controls = | ||
252 | SOC_DAPM_VALUE_ENUM("Route", wm8988_lline_enum); | ||
253 | |||
254 | static const struct soc_enum wm8988_rline_enum = | ||
255 | SOC_VALUE_ENUM_SINGLE(WM8988_ROUTM1, 0, 7, | ||
256 | ARRAY_SIZE(wm8988_line_texts), | ||
257 | wm8988_line_texts, | ||
258 | wm8988_line_values); | ||
259 | static const struct snd_kcontrol_new wm8988_right_line_controls = | ||
260 | SOC_DAPM_VALUE_ENUM("Route", wm8988_lline_enum); | ||
261 | |||
262 | /* Left Mixer */ | ||
263 | static const struct snd_kcontrol_new wm8988_left_mixer_controls[] = { | ||
264 | SOC_DAPM_SINGLE("Playback Switch", WM8988_LOUTM1, 8, 1, 0), | ||
265 | SOC_DAPM_SINGLE("Left Bypass Switch", WM8988_LOUTM1, 7, 1, 0), | ||
266 | SOC_DAPM_SINGLE("Right Playback Switch", WM8988_LOUTM2, 8, 1, 0), | ||
267 | SOC_DAPM_SINGLE("Right Bypass Switch", WM8988_LOUTM2, 7, 1, 0), | ||
268 | }; | ||
269 | |||
270 | /* Right Mixer */ | ||
271 | static const struct snd_kcontrol_new wm8988_right_mixer_controls[] = { | ||
272 | SOC_DAPM_SINGLE("Left Playback Switch", WM8988_ROUTM1, 8, 1, 0), | ||
273 | SOC_DAPM_SINGLE("Left Bypass Switch", WM8988_ROUTM1, 7, 1, 0), | ||
274 | SOC_DAPM_SINGLE("Playback Switch", WM8988_ROUTM2, 8, 1, 0), | ||
275 | SOC_DAPM_SINGLE("Right Bypass Switch", WM8988_ROUTM2, 7, 1, 0), | ||
276 | }; | ||
277 | |||
278 | static const char *wm8988_pga_sel[] = {"Line 1", "Line 2", "Differential"}; | ||
279 | static const unsigned int wm8988_pga_val[] = { 0, 1, 3 }; | ||
280 | |||
281 | /* Left PGA Mux */ | ||
282 | static const struct soc_enum wm8988_lpga_enum = | ||
283 | SOC_VALUE_ENUM_SINGLE(WM8988_LADCIN, 6, 3, | ||
284 | ARRAY_SIZE(wm8988_pga_sel), | ||
285 | wm8988_pga_sel, | ||
286 | wm8988_pga_val); | ||
287 | static const struct snd_kcontrol_new wm8988_left_pga_controls = | ||
288 | SOC_DAPM_VALUE_ENUM("Route", wm8988_lpga_enum); | ||
289 | |||
290 | /* Right PGA Mux */ | ||
291 | static const struct soc_enum wm8988_rpga_enum = | ||
292 | SOC_VALUE_ENUM_SINGLE(WM8988_RADCIN, 6, 3, | ||
293 | ARRAY_SIZE(wm8988_pga_sel), | ||
294 | wm8988_pga_sel, | ||
295 | wm8988_pga_val); | ||
296 | static const struct snd_kcontrol_new wm8988_right_pga_controls = | ||
297 | SOC_DAPM_VALUE_ENUM("Route", wm8988_rpga_enum); | ||
298 | |||
299 | /* Differential Mux */ | ||
300 | static const char *wm8988_diff_sel[] = {"Line 1", "Line 2"}; | ||
301 | static const struct soc_enum diffmux = | ||
302 | SOC_ENUM_SINGLE(WM8988_ADCIN, 8, 2, wm8988_diff_sel); | ||
303 | static const struct snd_kcontrol_new wm8988_diffmux_controls = | ||
304 | SOC_DAPM_ENUM("Route", diffmux); | ||
305 | |||
306 | /* Mono ADC Mux */ | ||
307 | static const char *wm8988_mono_mux[] = {"Stereo", "Mono (Left)", | ||
308 | "Mono (Right)", "Digital Mono"}; | ||
309 | static const struct soc_enum monomux = | ||
310 | SOC_ENUM_SINGLE(WM8988_ADCIN, 6, 4, wm8988_mono_mux); | ||
311 | static const struct snd_kcontrol_new wm8988_monomux_controls = | ||
312 | SOC_DAPM_ENUM("Route", monomux); | ||
313 | |||
314 | static const struct snd_soc_dapm_widget wm8988_dapm_widgets[] = { | ||
315 | SND_SOC_DAPM_MICBIAS("Mic Bias", WM8988_PWR1, 1, 0), | ||
316 | |||
317 | SND_SOC_DAPM_MUX("Differential Mux", SND_SOC_NOPM, 0, 0, | ||
318 | &wm8988_diffmux_controls), | ||
319 | SND_SOC_DAPM_MUX("Left ADC Mux", SND_SOC_NOPM, 0, 0, | ||
320 | &wm8988_monomux_controls), | ||
321 | SND_SOC_DAPM_MUX("Right ADC Mux", SND_SOC_NOPM, 0, 0, | ||
322 | &wm8988_monomux_controls), | ||
323 | |||
324 | SND_SOC_DAPM_MUX("Left PGA Mux", WM8988_PWR1, 5, 0, | ||
325 | &wm8988_left_pga_controls), | ||
326 | SND_SOC_DAPM_MUX("Right PGA Mux", WM8988_PWR1, 4, 0, | ||
327 | &wm8988_right_pga_controls), | ||
328 | |||
329 | SND_SOC_DAPM_MUX("Left Line Mux", SND_SOC_NOPM, 0, 0, | ||
330 | &wm8988_left_line_controls), | ||
331 | SND_SOC_DAPM_MUX("Right Line Mux", SND_SOC_NOPM, 0, 0, | ||
332 | &wm8988_right_line_controls), | ||
333 | |||
334 | SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8988_PWR1, 2, 0), | ||
335 | SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8988_PWR1, 3, 0), | ||
336 | |||
337 | SND_SOC_DAPM_DAC("Right DAC", "Right Playback", WM8988_PWR2, 7, 0), | ||
338 | SND_SOC_DAPM_DAC("Left DAC", "Left Playback", WM8988_PWR2, 8, 0), | ||
339 | |||
340 | SND_SOC_DAPM_MIXER("Left Mixer", SND_SOC_NOPM, 0, 0, | ||
341 | &wm8988_left_mixer_controls[0], | ||
342 | ARRAY_SIZE(wm8988_left_mixer_controls)), | ||
343 | SND_SOC_DAPM_MIXER("Right Mixer", SND_SOC_NOPM, 0, 0, | ||
344 | &wm8988_right_mixer_controls[0], | ||
345 | ARRAY_SIZE(wm8988_right_mixer_controls)), | ||
346 | |||
347 | SND_SOC_DAPM_PGA("Right Out 2", WM8988_PWR2, 3, 0, NULL, 0), | ||
348 | SND_SOC_DAPM_PGA("Left Out 2", WM8988_PWR2, 4, 0, NULL, 0), | ||
349 | SND_SOC_DAPM_PGA("Right Out 1", WM8988_PWR2, 5, 0, NULL, 0), | ||
350 | SND_SOC_DAPM_PGA("Left Out 1", WM8988_PWR2, 6, 0, NULL, 0), | ||
351 | |||
352 | SND_SOC_DAPM_POST("LRC control", wm8988_lrc_control), | ||
353 | |||
354 | SND_SOC_DAPM_OUTPUT("LOUT1"), | ||
355 | SND_SOC_DAPM_OUTPUT("ROUT1"), | ||
356 | SND_SOC_DAPM_OUTPUT("LOUT2"), | ||
357 | SND_SOC_DAPM_OUTPUT("ROUT2"), | ||
358 | SND_SOC_DAPM_OUTPUT("VREF"), | ||
359 | |||
360 | SND_SOC_DAPM_INPUT("LINPUT1"), | ||
361 | SND_SOC_DAPM_INPUT("LINPUT2"), | ||
362 | SND_SOC_DAPM_INPUT("RINPUT1"), | ||
363 | SND_SOC_DAPM_INPUT("RINPUT2"), | ||
364 | }; | ||
365 | |||
366 | static const struct snd_soc_dapm_route audio_map[] = { | ||
367 | |||
368 | { "Left Line Mux", "Line 1", "LINPUT1" }, | ||
369 | { "Left Line Mux", "Line 2", "LINPUT2" }, | ||
370 | { "Left Line Mux", "PGA", "Left PGA Mux" }, | ||
371 | { "Left Line Mux", "Differential", "Differential Mux" }, | ||
372 | |||
373 | { "Right Line Mux", "Line 1", "RINPUT1" }, | ||
374 | { "Right Line Mux", "Line 2", "RINPUT2" }, | ||
375 | { "Right Line Mux", "PGA", "Right PGA Mux" }, | ||
376 | { "Right Line Mux", "Differential", "Differential Mux" }, | ||
377 | |||
378 | { "Left PGA Mux", "Line 1", "LINPUT1" }, | ||
379 | { "Left PGA Mux", "Line 2", "LINPUT2" }, | ||
380 | { "Left PGA Mux", "Differential", "Differential Mux" }, | ||
381 | |||
382 | { "Right PGA Mux", "Line 1", "RINPUT1" }, | ||
383 | { "Right PGA Mux", "Line 2", "RINPUT2" }, | ||
384 | { "Right PGA Mux", "Differential", "Differential Mux" }, | ||
385 | |||
386 | { "Differential Mux", "Line 1", "LINPUT1" }, | ||
387 | { "Differential Mux", "Line 1", "RINPUT1" }, | ||
388 | { "Differential Mux", "Line 2", "LINPUT2" }, | ||
389 | { "Differential Mux", "Line 2", "RINPUT2" }, | ||
390 | |||
391 | { "Left ADC Mux", "Stereo", "Left PGA Mux" }, | ||
392 | { "Left ADC Mux", "Mono (Left)", "Left PGA Mux" }, | ||
393 | { "Left ADC Mux", "Digital Mono", "Left PGA Mux" }, | ||
394 | |||
395 | { "Right ADC Mux", "Stereo", "Right PGA Mux" }, | ||
396 | { "Right ADC Mux", "Mono (Right)", "Right PGA Mux" }, | ||
397 | { "Right ADC Mux", "Digital Mono", "Right PGA Mux" }, | ||
398 | |||
399 | { "Left ADC", NULL, "Left ADC Mux" }, | ||
400 | { "Right ADC", NULL, "Right ADC Mux" }, | ||
401 | |||
402 | { "Left Line Mux", "Line 1", "LINPUT1" }, | ||
403 | { "Left Line Mux", "Line 2", "LINPUT2" }, | ||
404 | { "Left Line Mux", "PGA", "Left PGA Mux" }, | ||
405 | { "Left Line Mux", "Differential", "Differential Mux" }, | ||
406 | |||
407 | { "Right Line Mux", "Line 1", "RINPUT1" }, | ||
408 | { "Right Line Mux", "Line 2", "RINPUT2" }, | ||
409 | { "Right Line Mux", "PGA", "Right PGA Mux" }, | ||
410 | { "Right Line Mux", "Differential", "Differential Mux" }, | ||
411 | |||
412 | { "Left Mixer", "Playback Switch", "Left DAC" }, | ||
413 | { "Left Mixer", "Left Bypass Switch", "Left Line Mux" }, | ||
414 | { "Left Mixer", "Right Playback Switch", "Right DAC" }, | ||
415 | { "Left Mixer", "Right Bypass Switch", "Right Line Mux" }, | ||
416 | |||
417 | { "Right Mixer", "Left Playback Switch", "Left DAC" }, | ||
418 | { "Right Mixer", "Left Bypass Switch", "Left Line Mux" }, | ||
419 | { "Right Mixer", "Playback Switch", "Right DAC" }, | ||
420 | { "Right Mixer", "Right Bypass Switch", "Right Line Mux" }, | ||
421 | |||
422 | { "Left Out 1", NULL, "Left Mixer" }, | ||
423 | { "LOUT1", NULL, "Left Out 1" }, | ||
424 | { "Right Out 1", NULL, "Right Mixer" }, | ||
425 | { "ROUT1", NULL, "Right Out 1" }, | ||
426 | |||
427 | { "Left Out 2", NULL, "Left Mixer" }, | ||
428 | { "LOUT2", NULL, "Left Out 2" }, | ||
429 | { "Right Out 2", NULL, "Right Mixer" }, | ||
430 | { "ROUT2", NULL, "Right Out 2" }, | ||
431 | }; | ||
432 | |||
433 | struct _coeff_div { | ||
434 | u32 mclk; | ||
435 | u32 rate; | ||
436 | u16 fs; | ||
437 | u8 sr:5; | ||
438 | u8 usb:1; | ||
439 | }; | ||
440 | |||
441 | /* codec hifi mclk clock divider coefficients */ | ||
442 | static const struct _coeff_div coeff_div[] = { | ||
443 | /* 8k */ | ||
444 | {12288000, 8000, 1536, 0x6, 0x0}, | ||
445 | {11289600, 8000, 1408, 0x16, 0x0}, | ||
446 | {18432000, 8000, 2304, 0x7, 0x0}, | ||
447 | {16934400, 8000, 2112, 0x17, 0x0}, | ||
448 | {12000000, 8000, 1500, 0x6, 0x1}, | ||
449 | |||
450 | /* 11.025k */ | ||
451 | {11289600, 11025, 1024, 0x18, 0x0}, | ||
452 | {16934400, 11025, 1536, 0x19, 0x0}, | ||
453 | {12000000, 11025, 1088, 0x19, 0x1}, | ||
454 | |||
455 | /* 16k */ | ||
456 | {12288000, 16000, 768, 0xa, 0x0}, | ||
457 | {18432000, 16000, 1152, 0xb, 0x0}, | ||
458 | {12000000, 16000, 750, 0xa, 0x1}, | ||
459 | |||
460 | /* 22.05k */ | ||
461 | {11289600, 22050, 512, 0x1a, 0x0}, | ||
462 | {16934400, 22050, 768, 0x1b, 0x0}, | ||
463 | {12000000, 22050, 544, 0x1b, 0x1}, | ||
464 | |||
465 | /* 32k */ | ||
466 | {12288000, 32000, 384, 0xc, 0x0}, | ||
467 | {18432000, 32000, 576, 0xd, 0x0}, | ||
468 | {12000000, 32000, 375, 0xa, 0x1}, | ||
469 | |||
470 | /* 44.1k */ | ||
471 | {11289600, 44100, 256, 0x10, 0x0}, | ||
472 | {16934400, 44100, 384, 0x11, 0x0}, | ||
473 | {12000000, 44100, 272, 0x11, 0x1}, | ||
474 | |||
475 | /* 48k */ | ||
476 | {12288000, 48000, 256, 0x0, 0x0}, | ||
477 | {18432000, 48000, 384, 0x1, 0x0}, | ||
478 | {12000000, 48000, 250, 0x0, 0x1}, | ||
479 | |||
480 | /* 88.2k */ | ||
481 | {11289600, 88200, 128, 0x1e, 0x0}, | ||
482 | {16934400, 88200, 192, 0x1f, 0x0}, | ||
483 | {12000000, 88200, 136, 0x1f, 0x1}, | ||
484 | |||
485 | /* 96k */ | ||
486 | {12288000, 96000, 128, 0xe, 0x0}, | ||
487 | {18432000, 96000, 192, 0xf, 0x0}, | ||
488 | {12000000, 96000, 125, 0xe, 0x1}, | ||
489 | }; | ||
490 | |||
491 | static inline int get_coeff(int mclk, int rate) | ||
492 | { | ||
493 | int i; | ||
494 | |||
495 | for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { | ||
496 | if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk) | ||
497 | return i; | ||
498 | } | ||
499 | |||
500 | return -EINVAL; | ||
501 | } | ||
502 | |||
503 | /* The set of rates we can generate from the above for each SYSCLK */ | ||
504 | |||
505 | static unsigned int rates_12288[] = { | ||
506 | 8000, 12000, 16000, 24000, 24000, 32000, 48000, 96000, | ||
507 | }; | ||
508 | |||
509 | static struct snd_pcm_hw_constraint_list constraints_12288 = { | ||
510 | .count = ARRAY_SIZE(rates_12288), | ||
511 | .list = rates_12288, | ||
512 | }; | ||
513 | |||
514 | static unsigned int rates_112896[] = { | ||
515 | 8000, 11025, 22050, 44100, | ||
516 | }; | ||
517 | |||
518 | static struct snd_pcm_hw_constraint_list constraints_112896 = { | ||
519 | .count = ARRAY_SIZE(rates_112896), | ||
520 | .list = rates_112896, | ||
521 | }; | ||
522 | |||
523 | static unsigned int rates_12[] = { | ||
524 | 8000, 11025, 12000, 16000, 22050, 2400, 32000, 41100, 48000, | ||
525 | 48000, 88235, 96000, | ||
526 | }; | ||
527 | |||
528 | static struct snd_pcm_hw_constraint_list constraints_12 = { | ||
529 | .count = ARRAY_SIZE(rates_12), | ||
530 | .list = rates_12, | ||
531 | }; | ||
532 | |||
533 | /* | ||
534 | * Note that this should be called from init rather than from hw_params. | ||
535 | */ | ||
536 | static int wm8988_set_dai_sysclk(struct snd_soc_dai *codec_dai, | ||
537 | int clk_id, unsigned int freq, int dir) | ||
538 | { | ||
539 | struct snd_soc_codec *codec = codec_dai->codec; | ||
540 | struct wm8988_priv *wm8988 = codec->private_data; | ||
541 | |||
542 | switch (freq) { | ||
543 | case 11289600: | ||
544 | case 18432000: | ||
545 | case 22579200: | ||
546 | case 36864000: | ||
547 | wm8988->sysclk_constraints = &constraints_112896; | ||
548 | wm8988->sysclk = freq; | ||
549 | return 0; | ||
550 | |||
551 | case 12288000: | ||
552 | case 16934400: | ||
553 | case 24576000: | ||
554 | case 33868800: | ||
555 | wm8988->sysclk_constraints = &constraints_12288; | ||
556 | wm8988->sysclk = freq; | ||
557 | return 0; | ||
558 | |||
559 | case 12000000: | ||
560 | case 24000000: | ||
561 | wm8988->sysclk_constraints = &constraints_12; | ||
562 | wm8988->sysclk = freq; | ||
563 | return 0; | ||
564 | } | ||
565 | return -EINVAL; | ||
566 | } | ||
567 | |||
568 | static int wm8988_set_dai_fmt(struct snd_soc_dai *codec_dai, | ||
569 | unsigned int fmt) | ||
570 | { | ||
571 | struct snd_soc_codec *codec = codec_dai->codec; | ||
572 | u16 iface = 0; | ||
573 | |||
574 | /* set master/slave audio interface */ | ||
575 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
576 | case SND_SOC_DAIFMT_CBM_CFM: | ||
577 | iface = 0x0040; | ||
578 | break; | ||
579 | case SND_SOC_DAIFMT_CBS_CFS: | ||
580 | break; | ||
581 | default: | ||
582 | return -EINVAL; | ||
583 | } | ||
584 | |||
585 | /* interface format */ | ||
586 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
587 | case SND_SOC_DAIFMT_I2S: | ||
588 | iface |= 0x0002; | ||
589 | break; | ||
590 | case SND_SOC_DAIFMT_RIGHT_J: | ||
591 | break; | ||
592 | case SND_SOC_DAIFMT_LEFT_J: | ||
593 | iface |= 0x0001; | ||
594 | break; | ||
595 | case SND_SOC_DAIFMT_DSP_A: | ||
596 | iface |= 0x0003; | ||
597 | break; | ||
598 | case SND_SOC_DAIFMT_DSP_B: | ||
599 | iface |= 0x0013; | ||
600 | break; | ||
601 | default: | ||
602 | return -EINVAL; | ||
603 | } | ||
604 | |||
605 | /* clock inversion */ | ||
606 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
607 | case SND_SOC_DAIFMT_NB_NF: | ||
608 | break; | ||
609 | case SND_SOC_DAIFMT_IB_IF: | ||
610 | iface |= 0x0090; | ||
611 | break; | ||
612 | case SND_SOC_DAIFMT_IB_NF: | ||
613 | iface |= 0x0080; | ||
614 | break; | ||
615 | case SND_SOC_DAIFMT_NB_IF: | ||
616 | iface |= 0x0010; | ||
617 | break; | ||
618 | default: | ||
619 | return -EINVAL; | ||
620 | } | ||
621 | |||
622 | wm8988_write(codec, WM8988_IFACE, iface); | ||
623 | return 0; | ||
624 | } | ||
625 | |||
626 | static int wm8988_pcm_startup(struct snd_pcm_substream *substream, | ||
627 | struct snd_soc_dai *dai) | ||
628 | { | ||
629 | struct snd_soc_codec *codec = dai->codec; | ||
630 | struct wm8988_priv *wm8988 = codec->private_data; | ||
631 | |||
632 | /* The set of sample rates that can be supported depends on the | ||
633 | * MCLK supplied to the CODEC - enforce this. | ||
634 | */ | ||
635 | if (!wm8988->sysclk) { | ||
636 | dev_err(codec->dev, | ||
637 | "No MCLK configured, call set_sysclk() on init\n"); | ||
638 | return -EINVAL; | ||
639 | } | ||
640 | |||
641 | snd_pcm_hw_constraint_list(substream->runtime, 0, | ||
642 | SNDRV_PCM_HW_PARAM_RATE, | ||
643 | wm8988->sysclk_constraints); | ||
644 | |||
645 | return 0; | ||
646 | } | ||
647 | |||
648 | static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream, | ||
649 | struct snd_pcm_hw_params *params, | ||
650 | struct snd_soc_dai *dai) | ||
651 | { | ||
652 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
653 | struct snd_soc_device *socdev = rtd->socdev; | ||
654 | struct snd_soc_codec *codec = socdev->card->codec; | ||
655 | struct wm8988_priv *wm8988 = codec->private_data; | ||
656 | u16 iface = wm8988_read_reg_cache(codec, WM8988_IFACE) & 0x1f3; | ||
657 | u16 srate = wm8988_read_reg_cache(codec, WM8988_SRATE) & 0x180; | ||
658 | int coeff; | ||
659 | |||
660 | coeff = get_coeff(wm8988->sysclk, params_rate(params)); | ||
661 | if (coeff < 0) { | ||
662 | coeff = get_coeff(wm8988->sysclk / 2, params_rate(params)); | ||
663 | srate |= 0x40; | ||
664 | } | ||
665 | if (coeff < 0) { | ||
666 | dev_err(codec->dev, | ||
667 | "Unable to configure sample rate %dHz with %dHz MCLK\n", | ||
668 | params_rate(params), wm8988->sysclk); | ||
669 | return coeff; | ||
670 | } | ||
671 | |||
672 | /* bit size */ | ||
673 | switch (params_format(params)) { | ||
674 | case SNDRV_PCM_FORMAT_S16_LE: | ||
675 | break; | ||
676 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
677 | iface |= 0x0004; | ||
678 | break; | ||
679 | case SNDRV_PCM_FORMAT_S24_LE: | ||
680 | iface |= 0x0008; | ||
681 | break; | ||
682 | case SNDRV_PCM_FORMAT_S32_LE: | ||
683 | iface |= 0x000c; | ||
684 | break; | ||
685 | } | ||
686 | |||
687 | /* set iface & srate */ | ||
688 | wm8988_write(codec, WM8988_IFACE, iface); | ||
689 | if (coeff >= 0) | ||
690 | wm8988_write(codec, WM8988_SRATE, srate | | ||
691 | (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb); | ||
692 | |||
693 | return 0; | ||
694 | } | ||
695 | |||
696 | static int wm8988_mute(struct snd_soc_dai *dai, int mute) | ||
697 | { | ||
698 | struct snd_soc_codec *codec = dai->codec; | ||
699 | u16 mute_reg = wm8988_read_reg_cache(codec, WM8988_ADCDAC) & 0xfff7; | ||
700 | |||
701 | if (mute) | ||
702 | wm8988_write(codec, WM8988_ADCDAC, mute_reg | 0x8); | ||
703 | else | ||
704 | wm8988_write(codec, WM8988_ADCDAC, mute_reg); | ||
705 | return 0; | ||
706 | } | ||
707 | |||
708 | static int wm8988_set_bias_level(struct snd_soc_codec *codec, | ||
709 | enum snd_soc_bias_level level) | ||
710 | { | ||
711 | u16 pwr_reg = wm8988_read_reg_cache(codec, WM8988_PWR1) & ~0x1c1; | ||
712 | |||
713 | switch (level) { | ||
714 | case SND_SOC_BIAS_ON: | ||
715 | break; | ||
716 | |||
717 | case SND_SOC_BIAS_PREPARE: | ||
718 | /* VREF, VMID=2x50k, digital enabled */ | ||
719 | wm8988_write(codec, WM8988_PWR1, pwr_reg | 0x00c0); | ||
720 | break; | ||
721 | |||
722 | case SND_SOC_BIAS_STANDBY: | ||
723 | if (codec->bias_level == SND_SOC_BIAS_OFF) { | ||
724 | /* VREF, VMID=2x5k */ | ||
725 | wm8988_write(codec, WM8988_PWR1, pwr_reg | 0x1c1); | ||
726 | |||
727 | /* Charge caps */ | ||
728 | msleep(100); | ||
729 | } | ||
730 | |||
731 | /* VREF, VMID=2*500k, digital stopped */ | ||
732 | wm8988_write(codec, WM8988_PWR1, pwr_reg | 0x0141); | ||
733 | break; | ||
734 | |||
735 | case SND_SOC_BIAS_OFF: | ||
736 | wm8988_write(codec, WM8988_PWR1, 0x0000); | ||
737 | break; | ||
738 | } | ||
739 | codec->bias_level = level; | ||
740 | return 0; | ||
741 | } | ||
742 | |||
743 | #define WM8988_RATES SNDRV_PCM_RATE_8000_96000 | ||
744 | |||
745 | #define WM8988_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ | ||
746 | SNDRV_PCM_FMTBIT_S24_LE) | ||
747 | |||
748 | static struct snd_soc_dai_ops wm8988_ops = { | ||
749 | .startup = wm8988_pcm_startup, | ||
750 | .hw_params = wm8988_pcm_hw_params, | ||
751 | .set_fmt = wm8988_set_dai_fmt, | ||
752 | .set_sysclk = wm8988_set_dai_sysclk, | ||
753 | .digital_mute = wm8988_mute, | ||
754 | }; | ||
755 | |||
756 | struct snd_soc_dai wm8988_dai = { | ||
757 | .name = "WM8988", | ||
758 | .playback = { | ||
759 | .stream_name = "Playback", | ||
760 | .channels_min = 1, | ||
761 | .channels_max = 2, | ||
762 | .rates = WM8988_RATES, | ||
763 | .formats = WM8988_FORMATS, | ||
764 | }, | ||
765 | .capture = { | ||
766 | .stream_name = "Capture", | ||
767 | .channels_min = 1, | ||
768 | .channels_max = 2, | ||
769 | .rates = WM8988_RATES, | ||
770 | .formats = WM8988_FORMATS, | ||
771 | }, | ||
772 | .ops = &wm8988_ops, | ||
773 | .symmetric_rates = 1, | ||
774 | }; | ||
775 | EXPORT_SYMBOL_GPL(wm8988_dai); | ||
776 | |||
777 | static int wm8988_suspend(struct platform_device *pdev, pm_message_t state) | ||
778 | { | ||
779 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
780 | struct snd_soc_codec *codec = socdev->card->codec; | ||
781 | |||
782 | wm8988_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
783 | return 0; | ||
784 | } | ||
785 | |||
786 | static int wm8988_resume(struct platform_device *pdev) | ||
787 | { | ||
788 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
789 | struct snd_soc_codec *codec = socdev->card->codec; | ||
790 | int i; | ||
791 | u8 data[2]; | ||
792 | u16 *cache = codec->reg_cache; | ||
793 | |||
794 | /* Sync reg_cache with the hardware */ | ||
795 | for (i = 0; i < WM8988_NUM_REG; i++) { | ||
796 | if (i == WM8988_RESET) | ||
797 | continue; | ||
798 | data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001); | ||
799 | data[1] = cache[i] & 0x00ff; | ||
800 | codec->hw_write(codec->control_data, data, 2); | ||
801 | } | ||
802 | |||
803 | wm8988_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
804 | |||
805 | return 0; | ||
806 | } | ||
807 | |||
808 | static struct snd_soc_codec *wm8988_codec; | ||
809 | |||
810 | static int wm8988_probe(struct platform_device *pdev) | ||
811 | { | ||
812 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
813 | struct snd_soc_codec *codec; | ||
814 | int ret = 0; | ||
815 | |||
816 | if (wm8988_codec == NULL) { | ||
817 | dev_err(&pdev->dev, "Codec device not registered\n"); | ||
818 | return -ENODEV; | ||
819 | } | ||
820 | |||
821 | socdev->card->codec = wm8988_codec; | ||
822 | codec = wm8988_codec; | ||
823 | |||
824 | /* register pcms */ | ||
825 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
826 | if (ret < 0) { | ||
827 | dev_err(codec->dev, "failed to create pcms: %d\n", ret); | ||
828 | goto pcm_err; | ||
829 | } | ||
830 | |||
831 | snd_soc_add_controls(codec, wm8988_snd_controls, | ||
832 | ARRAY_SIZE(wm8988_snd_controls)); | ||
833 | snd_soc_dapm_new_controls(codec, wm8988_dapm_widgets, | ||
834 | ARRAY_SIZE(wm8988_dapm_widgets)); | ||
835 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | ||
836 | snd_soc_dapm_new_widgets(codec); | ||
837 | |||
838 | ret = snd_soc_init_card(socdev); | ||
839 | if (ret < 0) { | ||
840 | dev_err(codec->dev, "failed to register card: %d\n", ret); | ||
841 | goto card_err; | ||
842 | } | ||
843 | |||
844 | return ret; | ||
845 | |||
846 | card_err: | ||
847 | snd_soc_free_pcms(socdev); | ||
848 | snd_soc_dapm_free(socdev); | ||
849 | pcm_err: | ||
850 | return ret; | ||
851 | } | ||
852 | |||
853 | static int wm8988_remove(struct platform_device *pdev) | ||
854 | { | ||
855 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
856 | |||
857 | snd_soc_free_pcms(socdev); | ||
858 | snd_soc_dapm_free(socdev); | ||
859 | |||
860 | return 0; | ||
861 | } | ||
862 | |||
863 | struct snd_soc_codec_device soc_codec_dev_wm8988 = { | ||
864 | .probe = wm8988_probe, | ||
865 | .remove = wm8988_remove, | ||
866 | .suspend = wm8988_suspend, | ||
867 | .resume = wm8988_resume, | ||
868 | }; | ||
869 | EXPORT_SYMBOL_GPL(soc_codec_dev_wm8988); | ||
870 | |||
871 | static int wm8988_register(struct wm8988_priv *wm8988) | ||
872 | { | ||
873 | struct snd_soc_codec *codec = &wm8988->codec; | ||
874 | int ret; | ||
875 | u16 reg; | ||
876 | |||
877 | if (wm8988_codec) { | ||
878 | dev_err(codec->dev, "Another WM8988 is registered\n"); | ||
879 | ret = -EINVAL; | ||
880 | goto err; | ||
881 | } | ||
882 | |||
883 | mutex_init(&codec->mutex); | ||
884 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
885 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
886 | |||
887 | codec->private_data = wm8988; | ||
888 | codec->name = "WM8988"; | ||
889 | codec->owner = THIS_MODULE; | ||
890 | codec->read = wm8988_read_reg_cache; | ||
891 | codec->write = wm8988_write; | ||
892 | codec->dai = &wm8988_dai; | ||
893 | codec->num_dai = 1; | ||
894 | codec->reg_cache_size = ARRAY_SIZE(wm8988->reg_cache); | ||
895 | codec->reg_cache = &wm8988->reg_cache; | ||
896 | codec->bias_level = SND_SOC_BIAS_OFF; | ||
897 | codec->set_bias_level = wm8988_set_bias_level; | ||
898 | |||
899 | memcpy(codec->reg_cache, wm8988_reg, | ||
900 | sizeof(wm8988_reg)); | ||
901 | |||
902 | ret = wm8988_reset(codec); | ||
903 | if (ret < 0) { | ||
904 | dev_err(codec->dev, "Failed to issue reset\n"); | ||
905 | return ret; | ||
906 | } | ||
907 | |||
908 | /* set the update bits (we always update left then right) */ | ||
909 | reg = wm8988_read_reg_cache(codec, WM8988_RADC); | ||
910 | wm8988_write(codec, WM8988_RADC, reg | 0x100); | ||
911 | reg = wm8988_read_reg_cache(codec, WM8988_RDAC); | ||
912 | wm8988_write(codec, WM8988_RDAC, reg | 0x0100); | ||
913 | reg = wm8988_read_reg_cache(codec, WM8988_ROUT1V); | ||
914 | wm8988_write(codec, WM8988_ROUT1V, reg | 0x0100); | ||
915 | reg = wm8988_read_reg_cache(codec, WM8988_ROUT2V); | ||
916 | wm8988_write(codec, WM8988_ROUT2V, reg | 0x0100); | ||
917 | reg = wm8988_read_reg_cache(codec, WM8988_RINVOL); | ||
918 | wm8988_write(codec, WM8988_RINVOL, reg | 0x0100); | ||
919 | |||
920 | wm8988_set_bias_level(&wm8988->codec, SND_SOC_BIAS_STANDBY); | ||
921 | |||
922 | wm8988_dai.dev = codec->dev; | ||
923 | |||
924 | wm8988_codec = codec; | ||
925 | |||
926 | ret = snd_soc_register_codec(codec); | ||
927 | if (ret != 0) { | ||
928 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); | ||
929 | return ret; | ||
930 | } | ||
931 | |||
932 | ret = snd_soc_register_dai(&wm8988_dai); | ||
933 | if (ret != 0) { | ||
934 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); | ||
935 | snd_soc_unregister_codec(codec); | ||
936 | return ret; | ||
937 | } | ||
938 | |||
939 | return 0; | ||
940 | |||
941 | err: | ||
942 | kfree(wm8988); | ||
943 | return ret; | ||
944 | } | ||
945 | |||
946 | static void wm8988_unregister(struct wm8988_priv *wm8988) | ||
947 | { | ||
948 | wm8988_set_bias_level(&wm8988->codec, SND_SOC_BIAS_OFF); | ||
949 | snd_soc_unregister_dai(&wm8988_dai); | ||
950 | snd_soc_unregister_codec(&wm8988->codec); | ||
951 | kfree(wm8988); | ||
952 | wm8988_codec = NULL; | ||
953 | } | ||
954 | |||
955 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
956 | static int wm8988_i2c_probe(struct i2c_client *i2c, | ||
957 | const struct i2c_device_id *id) | ||
958 | { | ||
959 | struct wm8988_priv *wm8988; | ||
960 | struct snd_soc_codec *codec; | ||
961 | |||
962 | wm8988 = kzalloc(sizeof(struct wm8988_priv), GFP_KERNEL); | ||
963 | if (wm8988 == NULL) | ||
964 | return -ENOMEM; | ||
965 | |||
966 | codec = &wm8988->codec; | ||
967 | codec->hw_write = (hw_write_t)i2c_master_send; | ||
968 | |||
969 | i2c_set_clientdata(i2c, wm8988); | ||
970 | codec->control_data = i2c; | ||
971 | |||
972 | codec->dev = &i2c->dev; | ||
973 | |||
974 | return wm8988_register(wm8988); | ||
975 | } | ||
976 | |||
977 | static int wm8988_i2c_remove(struct i2c_client *client) | ||
978 | { | ||
979 | struct wm8988_priv *wm8988 = i2c_get_clientdata(client); | ||
980 | wm8988_unregister(wm8988); | ||
981 | return 0; | ||
982 | } | ||
983 | |||
984 | static const struct i2c_device_id wm8988_i2c_id[] = { | ||
985 | { "wm8988", 0 }, | ||
986 | { } | ||
987 | }; | ||
988 | MODULE_DEVICE_TABLE(i2c, wm8988_i2c_id); | ||
989 | |||
990 | static struct i2c_driver wm8988_i2c_driver = { | ||
991 | .driver = { | ||
992 | .name = "WM8988", | ||
993 | .owner = THIS_MODULE, | ||
994 | }, | ||
995 | .probe = wm8988_i2c_probe, | ||
996 | .remove = wm8988_i2c_remove, | ||
997 | .id_table = wm8988_i2c_id, | ||
998 | }; | ||
999 | #endif | ||
1000 | |||
1001 | #if defined(CONFIG_SPI_MASTER) | ||
1002 | static int wm8988_spi_write(struct spi_device *spi, const char *data, int len) | ||
1003 | { | ||
1004 | struct spi_transfer t; | ||
1005 | struct spi_message m; | ||
1006 | u8 msg[2]; | ||
1007 | |||
1008 | if (len <= 0) | ||
1009 | return 0; | ||
1010 | |||
1011 | msg[0] = data[0]; | ||
1012 | msg[1] = data[1]; | ||
1013 | |||
1014 | spi_message_init(&m); | ||
1015 | memset(&t, 0, (sizeof t)); | ||
1016 | |||
1017 | t.tx_buf = &msg[0]; | ||
1018 | t.len = len; | ||
1019 | |||
1020 | spi_message_add_tail(&t, &m); | ||
1021 | spi_sync(spi, &m); | ||
1022 | |||
1023 | return len; | ||
1024 | } | ||
1025 | |||
1026 | static int __devinit wm8988_spi_probe(struct spi_device *spi) | ||
1027 | { | ||
1028 | struct wm8988_priv *wm8988; | ||
1029 | struct snd_soc_codec *codec; | ||
1030 | |||
1031 | wm8988 = kzalloc(sizeof(struct wm8988_priv), GFP_KERNEL); | ||
1032 | if (wm8988 == NULL) | ||
1033 | return -ENOMEM; | ||
1034 | |||
1035 | codec = &wm8988->codec; | ||
1036 | codec->hw_write = (hw_write_t)wm8988_spi_write; | ||
1037 | codec->control_data = spi; | ||
1038 | codec->dev = &spi->dev; | ||
1039 | |||
1040 | spi->dev.driver_data = wm8988; | ||
1041 | |||
1042 | return wm8988_register(wm8988); | ||
1043 | } | ||
1044 | |||
1045 | static int __devexit wm8988_spi_remove(struct spi_device *spi) | ||
1046 | { | ||
1047 | struct wm8988_priv *wm8988 = spi->dev.driver_data; | ||
1048 | |||
1049 | wm8988_unregister(wm8988); | ||
1050 | |||
1051 | return 0; | ||
1052 | } | ||
1053 | |||
1054 | static struct spi_driver wm8988_spi_driver = { | ||
1055 | .driver = { | ||
1056 | .name = "wm8988", | ||
1057 | .bus = &spi_bus_type, | ||
1058 | .owner = THIS_MODULE, | ||
1059 | }, | ||
1060 | .probe = wm8988_spi_probe, | ||
1061 | .remove = __devexit_p(wm8988_spi_remove), | ||
1062 | }; | ||
1063 | #endif | ||
1064 | |||
1065 | static int __init wm8988_modinit(void) | ||
1066 | { | ||
1067 | int ret; | ||
1068 | |||
1069 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
1070 | ret = i2c_add_driver(&wm8988_i2c_driver); | ||
1071 | if (ret != 0) | ||
1072 | pr_err("WM8988: Unable to register I2C driver: %d\n", ret); | ||
1073 | #endif | ||
1074 | #if defined(CONFIG_SPI_MASTER) | ||
1075 | ret = spi_register_driver(&wm8988_spi_driver); | ||
1076 | if (ret != 0) | ||
1077 | pr_err("WM8988: Unable to register SPI driver: %d\n", ret); | ||
1078 | #endif | ||
1079 | return ret; | ||
1080 | } | ||
1081 | module_init(wm8988_modinit); | ||
1082 | |||
1083 | static void __exit wm8988_exit(void) | ||
1084 | { | ||
1085 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
1086 | i2c_del_driver(&wm8988_i2c_driver); | ||
1087 | #endif | ||
1088 | #if defined(CONFIG_SPI_MASTER) | ||
1089 | spi_unregister_driver(&wm8988_spi_driver); | ||
1090 | #endif | ||
1091 | } | ||
1092 | module_exit(wm8988_exit); | ||
1093 | |||
1094 | |||
1095 | MODULE_DESCRIPTION("ASoC WM8988 driver"); | ||
1096 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | ||
1097 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/wm8988.h b/sound/soc/codecs/wm8988.h new file mode 100644 index 000000000000..4552d37fdd41 --- /dev/null +++ b/sound/soc/codecs/wm8988.h | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * Copyright 2005 Openedhand Ltd. | ||
3 | * | ||
4 | * Author: Richard Purdie <richard@openedhand.com> | ||
5 | * | ||
6 | * Based on WM8753.h | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #ifndef _WM8988_H | ||
15 | #define _WM8988_H | ||
16 | |||
17 | /* WM8988 register space */ | ||
18 | |||
19 | #define WM8988_LINVOL 0x00 | ||
20 | #define WM8988_RINVOL 0x01 | ||
21 | #define WM8988_LOUT1V 0x02 | ||
22 | #define WM8988_ROUT1V 0x03 | ||
23 | #define WM8988_ADCDAC 0x05 | ||
24 | #define WM8988_IFACE 0x07 | ||
25 | #define WM8988_SRATE 0x08 | ||
26 | #define WM8988_LDAC 0x0a | ||
27 | #define WM8988_RDAC 0x0b | ||
28 | #define WM8988_BASS 0x0c | ||
29 | #define WM8988_TREBLE 0x0d | ||
30 | #define WM8988_RESET 0x0f | ||
31 | #define WM8988_3D 0x10 | ||
32 | #define WM8988_ALC1 0x11 | ||
33 | #define WM8988_ALC2 0x12 | ||
34 | #define WM8988_ALC3 0x13 | ||
35 | #define WM8988_NGATE 0x14 | ||
36 | #define WM8988_LADC 0x15 | ||
37 | #define WM8988_RADC 0x16 | ||
38 | #define WM8988_ADCTL1 0x17 | ||
39 | #define WM8988_ADCTL2 0x18 | ||
40 | #define WM8988_PWR1 0x19 | ||
41 | #define WM8988_PWR2 0x1a | ||
42 | #define WM8988_ADCTL3 0x1b | ||
43 | #define WM8988_ADCIN 0x1f | ||
44 | #define WM8988_LADCIN 0x20 | ||
45 | #define WM8988_RADCIN 0x21 | ||
46 | #define WM8988_LOUTM1 0x22 | ||
47 | #define WM8988_LOUTM2 0x23 | ||
48 | #define WM8988_ROUTM1 0x24 | ||
49 | #define WM8988_ROUTM2 0x25 | ||
50 | #define WM8988_LOUT2V 0x28 | ||
51 | #define WM8988_ROUT2V 0x29 | ||
52 | #define WM8988_LPPB 0x43 | ||
53 | #define WM8988_NUM_REG 0x44 | ||
54 | |||
55 | #define WM8988_SYSCLK 0 | ||
56 | |||
57 | extern struct snd_soc_dai wm8988_dai; | ||
58 | extern struct snd_soc_codec_device soc_codec_dev_wm8988; | ||
59 | |||
60 | #endif | ||
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index c518c3e5aa3f..d029818350e9 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c | |||
@@ -729,7 +729,7 @@ SND_SOC_DAPM_MIXER_E("INMIXL", WM8990_INTDRIVBITS, WM8990_INMIXL_PWR_BIT, 0, | |||
729 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | 729 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
730 | 730 | ||
731 | /* AINLMUX */ | 731 | /* AINLMUX */ |
732 | SND_SOC_DAPM_MUX_E("AILNMUX", WM8990_INTDRIVBITS, WM8990_AINLMUX_PWR_BIT, 0, | 732 | SND_SOC_DAPM_MUX_E("AINLMUX", WM8990_INTDRIVBITS, WM8990_AINLMUX_PWR_BIT, 0, |
733 | &wm8990_dapm_ainlmux_controls, inmixer_event, | 733 | &wm8990_dapm_ainlmux_controls, inmixer_event, |
734 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | 734 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
735 | 735 | ||
@@ -740,7 +740,7 @@ SND_SOC_DAPM_MIXER_E("INMIXR", WM8990_INTDRIVBITS, WM8990_INMIXR_PWR_BIT, 0, | |||
740 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | 740 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
741 | 741 | ||
742 | /* AINRMUX */ | 742 | /* AINRMUX */ |
743 | SND_SOC_DAPM_MUX_E("AIRNMUX", WM8990_INTDRIVBITS, WM8990_AINRMUX_PWR_BIT, 0, | 743 | SND_SOC_DAPM_MUX_E("AINRMUX", WM8990_INTDRIVBITS, WM8990_AINRMUX_PWR_BIT, 0, |
744 | &wm8990_dapm_ainrmux_controls, inmixer_event, | 744 | &wm8990_dapm_ainrmux_controls, inmixer_event, |
745 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | 745 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), |
746 | 746 | ||
@@ -848,40 +848,40 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
848 | {"LIN12 PGA", "LIN2 Switch", "LIN2"}, | 848 | {"LIN12 PGA", "LIN2 Switch", "LIN2"}, |
849 | /* LIN34 PGA */ | 849 | /* LIN34 PGA */ |
850 | {"LIN34 PGA", "LIN3 Switch", "LIN3"}, | 850 | {"LIN34 PGA", "LIN3 Switch", "LIN3"}, |
851 | {"LIN34 PGA", "LIN4 Switch", "LIN4"}, | 851 | {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"}, |
852 | /* INMIXL */ | 852 | /* INMIXL */ |
853 | {"INMIXL", "Record Left Volume", "LOMIX"}, | 853 | {"INMIXL", "Record Left Volume", "LOMIX"}, |
854 | {"INMIXL", "LIN2 Volume", "LIN2"}, | 854 | {"INMIXL", "LIN2 Volume", "LIN2"}, |
855 | {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, | 855 | {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, |
856 | {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, | 856 | {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, |
857 | /* AILNMUX */ | 857 | /* AINLMUX */ |
858 | {"AILNMUX", "INMIXL Mix", "INMIXL"}, | 858 | {"AINLMUX", "INMIXL Mix", "INMIXL"}, |
859 | {"AILNMUX", "DIFFINL Mix", "LIN12PGA"}, | 859 | {"AINLMUX", "DIFFINL Mix", "LIN12 PGA"}, |
860 | {"AILNMUX", "DIFFINL Mix", "LIN34PGA"}, | 860 | {"AINLMUX", "DIFFINL Mix", "LIN34 PGA"}, |
861 | {"AILNMUX", "RXVOICE Mix", "LIN4/RXN"}, | 861 | {"AINLMUX", "RXVOICE Mix", "LIN4/RXN"}, |
862 | {"AILNMUX", "RXVOICE Mix", "RIN4/RXP"}, | 862 | {"AINLMUX", "RXVOICE Mix", "RIN4/RXP"}, |
863 | /* ADC */ | 863 | /* ADC */ |
864 | {"Left ADC", NULL, "AILNMUX"}, | 864 | {"Left ADC", NULL, "AINLMUX"}, |
865 | 865 | ||
866 | /* RIN12 PGA */ | 866 | /* RIN12 PGA */ |
867 | {"RIN12 PGA", "RIN1 Switch", "RIN1"}, | 867 | {"RIN12 PGA", "RIN1 Switch", "RIN1"}, |
868 | {"RIN12 PGA", "RIN2 Switch", "RIN2"}, | 868 | {"RIN12 PGA", "RIN2 Switch", "RIN2"}, |
869 | /* RIN34 PGA */ | 869 | /* RIN34 PGA */ |
870 | {"RIN34 PGA", "RIN3 Switch", "RIN3"}, | 870 | {"RIN34 PGA", "RIN3 Switch", "RIN3"}, |
871 | {"RIN34 PGA", "RIN4 Switch", "RIN4"}, | 871 | {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"}, |
872 | /* INMIXL */ | 872 | /* INMIXL */ |
873 | {"INMIXR", "Record Right Volume", "ROMIX"}, | 873 | {"INMIXR", "Record Right Volume", "ROMIX"}, |
874 | {"INMIXR", "RIN2 Volume", "RIN2"}, | 874 | {"INMIXR", "RIN2 Volume", "RIN2"}, |
875 | {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, | 875 | {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, |
876 | {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, | 876 | {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, |
877 | /* AIRNMUX */ | 877 | /* AINRMUX */ |
878 | {"AIRNMUX", "INMIXR Mix", "INMIXR"}, | 878 | {"AINRMUX", "INMIXR Mix", "INMIXR"}, |
879 | {"AIRNMUX", "DIFFINR Mix", "RIN12PGA"}, | 879 | {"AINRMUX", "DIFFINR Mix", "RIN12 PGA"}, |
880 | {"AIRNMUX", "DIFFINR Mix", "RIN34PGA"}, | 880 | {"AINRMUX", "DIFFINR Mix", "RIN34 PGA"}, |
881 | {"AIRNMUX", "RXVOICE Mix", "RIN4/RXN"}, | 881 | {"AINRMUX", "RXVOICE Mix", "LIN4/RXN"}, |
882 | {"AIRNMUX", "RXVOICE Mix", "RIN4/RXP"}, | 882 | {"AINRMUX", "RXVOICE Mix", "RIN4/RXP"}, |
883 | /* ADC */ | 883 | /* ADC */ |
884 | {"Right ADC", NULL, "AIRNMUX"}, | 884 | {"Right ADC", NULL, "AINRMUX"}, |
885 | 885 | ||
886 | /* LOMIX */ | 886 | /* LOMIX */ |
887 | {"LOMIX", "LOMIX RIN3 Bypass Switch", "RIN3"}, | 887 | {"LOMIX", "LOMIX RIN3 Bypass Switch", "RIN3"}, |
@@ -922,7 +922,7 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
922 | {"LOPMIX", "LOPMIX Left Mixer PGA Switch", "LOPGA"}, | 922 | {"LOPMIX", "LOPMIX Left Mixer PGA Switch", "LOPGA"}, |
923 | 923 | ||
924 | /* OUT3MIX */ | 924 | /* OUT3MIX */ |
925 | {"OUT3MIX", "OUT3MIX LIN4/RXP Bypass Switch", "LIN4/RXP"}, | 925 | {"OUT3MIX", "OUT3MIX LIN4/RXP Bypass Switch", "LIN4/RXN"}, |
926 | {"OUT3MIX", "OUT3MIX Left Out PGA Switch", "LOPGA"}, | 926 | {"OUT3MIX", "OUT3MIX Left Out PGA Switch", "LOPGA"}, |
927 | 927 | ||
928 | /* OUT4MIX */ | 928 | /* OUT4MIX */ |
@@ -949,7 +949,7 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
949 | /* Output Pins */ | 949 | /* Output Pins */ |
950 | {"LON", NULL, "LONMIX"}, | 950 | {"LON", NULL, "LONMIX"}, |
951 | {"LOP", NULL, "LOPMIX"}, | 951 | {"LOP", NULL, "LOPMIX"}, |
952 | {"OUT", NULL, "OUT3MIX"}, | 952 | {"OUT3", NULL, "OUT3MIX"}, |
953 | {"LOUT", NULL, "LOUT PGA"}, | 953 | {"LOUT", NULL, "LOUT PGA"}, |
954 | {"SPKN", NULL, "SPKMIX"}, | 954 | {"SPKN", NULL, "SPKMIX"}, |
955 | {"ROUT", NULL, "ROUT PGA"}, | 955 | {"ROUT", NULL, "ROUT PGA"}, |
@@ -998,7 +998,7 @@ static void pll_factors(struct _pll_div *pll_div, unsigned int target, | |||
998 | 998 | ||
999 | if ((Ndiv < 6) || (Ndiv > 12)) | 999 | if ((Ndiv < 6) || (Ndiv > 12)) |
1000 | printk(KERN_WARNING | 1000 | printk(KERN_WARNING |
1001 | "WM8990 N value outwith recommended range! N = %d\n", Ndiv); | 1001 | "WM8990 N value outwith recommended range! N = %u\n", Ndiv); |
1002 | 1002 | ||
1003 | pll_div->n = Ndiv; | 1003 | pll_div->n = Ndiv; |
1004 | Nmod = target % source; | 1004 | Nmod = target % source; |
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c new file mode 100644 index 000000000000..86fc57e25f97 --- /dev/null +++ b/sound/soc/codecs/wm9081.c | |||
@@ -0,0 +1,1534 @@ | |||
1 | /* | ||
2 | * wm9081.c -- WM9081 ALSA SoC Audio driver | ||
3 | * | ||
4 | * Author: Mark Brown | ||
5 | * | ||
6 | * Copyright 2009 Wolfson Microelectronics plc | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/moduleparam.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/pm.h> | ||
19 | #include <linux/i2c.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <sound/core.h> | ||
22 | #include <sound/pcm.h> | ||
23 | #include <sound/pcm_params.h> | ||
24 | #include <sound/soc.h> | ||
25 | #include <sound/soc-dapm.h> | ||
26 | #include <sound/initval.h> | ||
27 | #include <sound/tlv.h> | ||
28 | |||
29 | #include <sound/wm9081.h> | ||
30 | #include "wm9081.h" | ||
31 | |||
32 | static u16 wm9081_reg_defaults[] = { | ||
33 | 0x0000, /* R0 - Software Reset */ | ||
34 | 0x0000, /* R1 */ | ||
35 | 0x00B9, /* R2 - Analogue Lineout */ | ||
36 | 0x00B9, /* R3 - Analogue Speaker PGA */ | ||
37 | 0x0001, /* R4 - VMID Control */ | ||
38 | 0x0068, /* R5 - Bias Control 1 */ | ||
39 | 0x0000, /* R6 */ | ||
40 | 0x0000, /* R7 - Analogue Mixer */ | ||
41 | 0x0000, /* R8 - Anti Pop Control */ | ||
42 | 0x01DB, /* R9 - Analogue Speaker 1 */ | ||
43 | 0x0018, /* R10 - Analogue Speaker 2 */ | ||
44 | 0x0180, /* R11 - Power Management */ | ||
45 | 0x0000, /* R12 - Clock Control 1 */ | ||
46 | 0x0038, /* R13 - Clock Control 2 */ | ||
47 | 0x4000, /* R14 - Clock Control 3 */ | ||
48 | 0x0000, /* R15 */ | ||
49 | 0x0000, /* R16 - FLL Control 1 */ | ||
50 | 0x0200, /* R17 - FLL Control 2 */ | ||
51 | 0x0000, /* R18 - FLL Control 3 */ | ||
52 | 0x0204, /* R19 - FLL Control 4 */ | ||
53 | 0x0000, /* R20 - FLL Control 5 */ | ||
54 | 0x0000, /* R21 */ | ||
55 | 0x0000, /* R22 - Audio Interface 1 */ | ||
56 | 0x0002, /* R23 - Audio Interface 2 */ | ||
57 | 0x0008, /* R24 - Audio Interface 3 */ | ||
58 | 0x0022, /* R25 - Audio Interface 4 */ | ||
59 | 0x0000, /* R26 - Interrupt Status */ | ||
60 | 0x0006, /* R27 - Interrupt Status Mask */ | ||
61 | 0x0000, /* R28 - Interrupt Polarity */ | ||
62 | 0x0000, /* R29 - Interrupt Control */ | ||
63 | 0x00C0, /* R30 - DAC Digital 1 */ | ||
64 | 0x0008, /* R31 - DAC Digital 2 */ | ||
65 | 0x09AF, /* R32 - DRC 1 */ | ||
66 | 0x4201, /* R33 - DRC 2 */ | ||
67 | 0x0000, /* R34 - DRC 3 */ | ||
68 | 0x0000, /* R35 - DRC 4 */ | ||
69 | 0x0000, /* R36 */ | ||
70 | 0x0000, /* R37 */ | ||
71 | 0x0000, /* R38 - Write Sequencer 1 */ | ||
72 | 0x0000, /* R39 - Write Sequencer 2 */ | ||
73 | 0x0002, /* R40 - MW Slave 1 */ | ||
74 | 0x0000, /* R41 */ | ||
75 | 0x0000, /* R42 - EQ 1 */ | ||
76 | 0x0000, /* R43 - EQ 2 */ | ||
77 | 0x0FCA, /* R44 - EQ 3 */ | ||
78 | 0x0400, /* R45 - EQ 4 */ | ||
79 | 0x00B8, /* R46 - EQ 5 */ | ||
80 | 0x1EB5, /* R47 - EQ 6 */ | ||
81 | 0xF145, /* R48 - EQ 7 */ | ||
82 | 0x0B75, /* R49 - EQ 8 */ | ||
83 | 0x01C5, /* R50 - EQ 9 */ | ||
84 | 0x169E, /* R51 - EQ 10 */ | ||
85 | 0xF829, /* R52 - EQ 11 */ | ||
86 | 0x07AD, /* R53 - EQ 12 */ | ||
87 | 0x1103, /* R54 - EQ 13 */ | ||
88 | 0x1C58, /* R55 - EQ 14 */ | ||
89 | 0xF373, /* R56 - EQ 15 */ | ||
90 | 0x0A54, /* R57 - EQ 16 */ | ||
91 | 0x0558, /* R58 - EQ 17 */ | ||
92 | 0x0564, /* R59 - EQ 18 */ | ||
93 | 0x0559, /* R60 - EQ 19 */ | ||
94 | 0x4000, /* R61 - EQ 20 */ | ||
95 | }; | ||
96 | |||
97 | static struct { | ||
98 | int ratio; | ||
99 | int clk_sys_rate; | ||
100 | } clk_sys_rates[] = { | ||
101 | { 64, 0 }, | ||
102 | { 128, 1 }, | ||
103 | { 192, 2 }, | ||
104 | { 256, 3 }, | ||
105 | { 384, 4 }, | ||
106 | { 512, 5 }, | ||
107 | { 768, 6 }, | ||
108 | { 1024, 7 }, | ||
109 | { 1408, 8 }, | ||
110 | { 1536, 9 }, | ||
111 | }; | ||
112 | |||
113 | static struct { | ||
114 | int rate; | ||
115 | int sample_rate; | ||
116 | } sample_rates[] = { | ||
117 | { 8000, 0 }, | ||
118 | { 11025, 1 }, | ||
119 | { 12000, 2 }, | ||
120 | { 16000, 3 }, | ||
121 | { 22050, 4 }, | ||
122 | { 24000, 5 }, | ||
123 | { 32000, 6 }, | ||
124 | { 44100, 7 }, | ||
125 | { 48000, 8 }, | ||
126 | { 88200, 9 }, | ||
127 | { 96000, 10 }, | ||
128 | }; | ||
129 | |||
130 | static struct { | ||
131 | int div; /* *10 due to .5s */ | ||
132 | int bclk_div; | ||
133 | } bclk_divs[] = { | ||
134 | { 10, 0 }, | ||
135 | { 15, 1 }, | ||
136 | { 20, 2 }, | ||
137 | { 30, 3 }, | ||
138 | { 40, 4 }, | ||
139 | { 50, 5 }, | ||
140 | { 55, 6 }, | ||
141 | { 60, 7 }, | ||
142 | { 80, 8 }, | ||
143 | { 100, 9 }, | ||
144 | { 110, 10 }, | ||
145 | { 120, 11 }, | ||
146 | { 160, 12 }, | ||
147 | { 200, 13 }, | ||
148 | { 220, 14 }, | ||
149 | { 240, 15 }, | ||
150 | { 250, 16 }, | ||
151 | { 300, 17 }, | ||
152 | { 320, 18 }, | ||
153 | { 440, 19 }, | ||
154 | { 480, 20 }, | ||
155 | }; | ||
156 | |||
157 | struct wm9081_priv { | ||
158 | struct snd_soc_codec codec; | ||
159 | u16 reg_cache[WM9081_MAX_REGISTER + 1]; | ||
160 | int sysclk_source; | ||
161 | int mclk_rate; | ||
162 | int sysclk_rate; | ||
163 | int fs; | ||
164 | int bclk; | ||
165 | int master; | ||
166 | int fll_fref; | ||
167 | int fll_fout; | ||
168 | struct wm9081_retune_mobile_config *retune; | ||
169 | }; | ||
170 | |||
171 | static int wm9081_reg_is_volatile(int reg) | ||
172 | { | ||
173 | switch (reg) { | ||
174 | default: | ||
175 | return 0; | ||
176 | } | ||
177 | } | ||
178 | |||
179 | static unsigned int wm9081_read_reg_cache(struct snd_soc_codec *codec, | ||
180 | unsigned int reg) | ||
181 | { | ||
182 | u16 *cache = codec->reg_cache; | ||
183 | BUG_ON(reg > WM9081_MAX_REGISTER); | ||
184 | return cache[reg]; | ||
185 | } | ||
186 | |||
187 | static unsigned int wm9081_read_hw(struct snd_soc_codec *codec, u8 reg) | ||
188 | { | ||
189 | struct i2c_msg xfer[2]; | ||
190 | u16 data; | ||
191 | int ret; | ||
192 | struct i2c_client *client = codec->control_data; | ||
193 | |||
194 | BUG_ON(reg > WM9081_MAX_REGISTER); | ||
195 | |||
196 | /* Write register */ | ||
197 | xfer[0].addr = client->addr; | ||
198 | xfer[0].flags = 0; | ||
199 | xfer[0].len = 1; | ||
200 | xfer[0].buf = ® | ||
201 | |||
202 | /* Read data */ | ||
203 | xfer[1].addr = client->addr; | ||
204 | xfer[1].flags = I2C_M_RD; | ||
205 | xfer[1].len = 2; | ||
206 | xfer[1].buf = (u8 *)&data; | ||
207 | |||
208 | ret = i2c_transfer(client->adapter, xfer, 2); | ||
209 | if (ret != 2) { | ||
210 | dev_err(&client->dev, "i2c_transfer() returned %d\n", ret); | ||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | return (data >> 8) | ((data & 0xff) << 8); | ||
215 | } | ||
216 | |||
217 | static unsigned int wm9081_read(struct snd_soc_codec *codec, unsigned int reg) | ||
218 | { | ||
219 | if (wm9081_reg_is_volatile(reg)) | ||
220 | return wm9081_read_hw(codec, reg); | ||
221 | else | ||
222 | return wm9081_read_reg_cache(codec, reg); | ||
223 | } | ||
224 | |||
225 | static int wm9081_write(struct snd_soc_codec *codec, unsigned int reg, | ||
226 | unsigned int value) | ||
227 | { | ||
228 | u16 *cache = codec->reg_cache; | ||
229 | u8 data[3]; | ||
230 | |||
231 | BUG_ON(reg > WM9081_MAX_REGISTER); | ||
232 | |||
233 | if (!wm9081_reg_is_volatile(reg)) | ||
234 | cache[reg] = value; | ||
235 | |||
236 | data[0] = reg; | ||
237 | data[1] = value >> 8; | ||
238 | data[2] = value & 0x00ff; | ||
239 | |||
240 | if (codec->hw_write(codec->control_data, data, 3) == 3) | ||
241 | return 0; | ||
242 | else | ||
243 | return -EIO; | ||
244 | } | ||
245 | |||
246 | static int wm9081_reset(struct snd_soc_codec *codec) | ||
247 | { | ||
248 | return wm9081_write(codec, WM9081_SOFTWARE_RESET, 0); | ||
249 | } | ||
250 | |||
251 | static const DECLARE_TLV_DB_SCALE(drc_in_tlv, -4500, 75, 0); | ||
252 | static const DECLARE_TLV_DB_SCALE(drc_out_tlv, -2250, 75, 0); | ||
253 | static const DECLARE_TLV_DB_SCALE(drc_min_tlv, -1800, 600, 0); | ||
254 | static unsigned int drc_max_tlv[] = { | ||
255 | TLV_DB_RANGE_HEAD(4), | ||
256 | 0, 0, TLV_DB_SCALE_ITEM(1200, 0, 0), | ||
257 | 1, 1, TLV_DB_SCALE_ITEM(1800, 0, 0), | ||
258 | 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), | ||
259 | 3, 3, TLV_DB_SCALE_ITEM(3600, 0, 0), | ||
260 | }; | ||
261 | static const DECLARE_TLV_DB_SCALE(drc_qr_tlv, 1200, 600, 0); | ||
262 | static const DECLARE_TLV_DB_SCALE(drc_startup_tlv, -300, 50, 0); | ||
263 | |||
264 | static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); | ||
265 | |||
266 | static const DECLARE_TLV_DB_SCALE(in_tlv, -600, 600, 0); | ||
267 | static const DECLARE_TLV_DB_SCALE(dac_tlv, -7200, 75, 1); | ||
268 | static const DECLARE_TLV_DB_SCALE(out_tlv, -5700, 100, 0); | ||
269 | |||
270 | static const char *drc_high_text[] = { | ||
271 | "1", | ||
272 | "1/2", | ||
273 | "1/4", | ||
274 | "1/8", | ||
275 | "1/16", | ||
276 | "0", | ||
277 | }; | ||
278 | |||
279 | static const struct soc_enum drc_high = | ||
280 | SOC_ENUM_SINGLE(WM9081_DRC_3, 3, 6, drc_high_text); | ||
281 | |||
282 | static const char *drc_low_text[] = { | ||
283 | "1", | ||
284 | "1/2", | ||
285 | "1/4", | ||
286 | "1/8", | ||
287 | "0", | ||
288 | }; | ||
289 | |||
290 | static const struct soc_enum drc_low = | ||
291 | SOC_ENUM_SINGLE(WM9081_DRC_3, 0, 5, drc_low_text); | ||
292 | |||
293 | static const char *drc_atk_text[] = { | ||
294 | "181us", | ||
295 | "181us", | ||
296 | "363us", | ||
297 | "726us", | ||
298 | "1.45ms", | ||
299 | "2.9ms", | ||
300 | "5.8ms", | ||
301 | "11.6ms", | ||
302 | "23.2ms", | ||
303 | "46.4ms", | ||
304 | "92.8ms", | ||
305 | "185.6ms", | ||
306 | }; | ||
307 | |||
308 | static const struct soc_enum drc_atk = | ||
309 | SOC_ENUM_SINGLE(WM9081_DRC_2, 12, 12, drc_atk_text); | ||
310 | |||
311 | static const char *drc_dcy_text[] = { | ||
312 | "186ms", | ||
313 | "372ms", | ||
314 | "743ms", | ||
315 | "1.49s", | ||
316 | "2.97s", | ||
317 | "5.94s", | ||
318 | "11.89s", | ||
319 | "23.78s", | ||
320 | "47.56s", | ||
321 | }; | ||
322 | |||
323 | static const struct soc_enum drc_dcy = | ||
324 | SOC_ENUM_SINGLE(WM9081_DRC_2, 8, 9, drc_dcy_text); | ||
325 | |||
326 | static const char *drc_qr_dcy_text[] = { | ||
327 | "0.725ms", | ||
328 | "1.45ms", | ||
329 | "5.8ms", | ||
330 | }; | ||
331 | |||
332 | static const struct soc_enum drc_qr_dcy = | ||
333 | SOC_ENUM_SINGLE(WM9081_DRC_2, 4, 3, drc_qr_dcy_text); | ||
334 | |||
335 | static const char *dac_deemph_text[] = { | ||
336 | "None", | ||
337 | "32kHz", | ||
338 | "44.1kHz", | ||
339 | "48kHz", | ||
340 | }; | ||
341 | |||
342 | static const struct soc_enum dac_deemph = | ||
343 | SOC_ENUM_SINGLE(WM9081_DAC_DIGITAL_2, 1, 4, dac_deemph_text); | ||
344 | |||
345 | static const char *speaker_mode_text[] = { | ||
346 | "Class D", | ||
347 | "Class AB", | ||
348 | }; | ||
349 | |||
350 | static const struct soc_enum speaker_mode = | ||
351 | SOC_ENUM_SINGLE(WM9081_ANALOGUE_SPEAKER_2, 6, 2, speaker_mode_text); | ||
352 | |||
353 | static int speaker_mode_get(struct snd_kcontrol *kcontrol, | ||
354 | struct snd_ctl_elem_value *ucontrol) | ||
355 | { | ||
356 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
357 | unsigned int reg; | ||
358 | |||
359 | reg = wm9081_read(codec, WM9081_ANALOGUE_SPEAKER_2); | ||
360 | if (reg & WM9081_SPK_MODE) | ||
361 | ucontrol->value.integer.value[0] = 1; | ||
362 | else | ||
363 | ucontrol->value.integer.value[0] = 0; | ||
364 | |||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | /* | ||
369 | * Stop any attempts to change speaker mode while the speaker is enabled. | ||
370 | * | ||
371 | * We also have some special anti-pop controls dependant on speaker | ||
372 | * mode which must be changed along with the mode. | ||
373 | */ | ||
374 | static int speaker_mode_put(struct snd_kcontrol *kcontrol, | ||
375 | struct snd_ctl_elem_value *ucontrol) | ||
376 | { | ||
377 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
378 | unsigned int reg_pwr = wm9081_read(codec, WM9081_POWER_MANAGEMENT); | ||
379 | unsigned int reg2 = wm9081_read(codec, WM9081_ANALOGUE_SPEAKER_2); | ||
380 | |||
381 | /* Are we changing anything? */ | ||
382 | if (ucontrol->value.integer.value[0] == | ||
383 | ((reg2 & WM9081_SPK_MODE) != 0)) | ||
384 | return 0; | ||
385 | |||
386 | /* Don't try to change modes while enabled */ | ||
387 | if (reg_pwr & WM9081_SPK_ENA) | ||
388 | return -EINVAL; | ||
389 | |||
390 | if (ucontrol->value.integer.value[0]) { | ||
391 | /* Class AB */ | ||
392 | reg2 &= ~(WM9081_SPK_INV_MUTE | WM9081_OUT_SPK_CTRL); | ||
393 | reg2 |= WM9081_SPK_MODE; | ||
394 | } else { | ||
395 | /* Class D */ | ||
396 | reg2 |= WM9081_SPK_INV_MUTE | WM9081_OUT_SPK_CTRL; | ||
397 | reg2 &= ~WM9081_SPK_MODE; | ||
398 | } | ||
399 | |||
400 | wm9081_write(codec, WM9081_ANALOGUE_SPEAKER_2, reg2); | ||
401 | |||
402 | return 0; | ||
403 | } | ||
404 | |||
405 | static const struct snd_kcontrol_new wm9081_snd_controls[] = { | ||
406 | SOC_SINGLE_TLV("IN1 Volume", WM9081_ANALOGUE_MIXER, 1, 1, 1, in_tlv), | ||
407 | SOC_SINGLE_TLV("IN2 Volume", WM9081_ANALOGUE_MIXER, 3, 1, 1, in_tlv), | ||
408 | |||
409 | SOC_SINGLE_TLV("Playback Volume", WM9081_DAC_DIGITAL_1, 1, 96, 0, dac_tlv), | ||
410 | |||
411 | SOC_SINGLE("LINEOUT Switch", WM9081_ANALOGUE_LINEOUT, 7, 1, 1), | ||
412 | SOC_SINGLE("LINEOUT ZC Switch", WM9081_ANALOGUE_LINEOUT, 6, 1, 0), | ||
413 | SOC_SINGLE_TLV("LINEOUT Volume", WM9081_ANALOGUE_LINEOUT, 0, 63, 0, out_tlv), | ||
414 | |||
415 | SOC_SINGLE("DRC Switch", WM9081_DRC_1, 15, 1, 0), | ||
416 | SOC_ENUM("DRC High Slope", drc_high), | ||
417 | SOC_ENUM("DRC Low Slope", drc_low), | ||
418 | SOC_SINGLE_TLV("DRC Input Volume", WM9081_DRC_4, 5, 60, 1, drc_in_tlv), | ||
419 | SOC_SINGLE_TLV("DRC Output Volume", WM9081_DRC_4, 0, 30, 1, drc_out_tlv), | ||
420 | SOC_SINGLE_TLV("DRC Minimum Volume", WM9081_DRC_2, 2, 3, 1, drc_min_tlv), | ||
421 | SOC_SINGLE_TLV("DRC Maximum Volume", WM9081_DRC_2, 0, 3, 0, drc_max_tlv), | ||
422 | SOC_ENUM("DRC Attack", drc_atk), | ||
423 | SOC_ENUM("DRC Decay", drc_dcy), | ||
424 | SOC_SINGLE("DRC Quick Release Switch", WM9081_DRC_1, 2, 1, 0), | ||
425 | SOC_SINGLE_TLV("DRC Quick Release Volume", WM9081_DRC_2, 6, 3, 0, drc_qr_tlv), | ||
426 | SOC_ENUM("DRC Quick Release Decay", drc_qr_dcy), | ||
427 | SOC_SINGLE_TLV("DRC Startup Volume", WM9081_DRC_1, 6, 18, 0, drc_startup_tlv), | ||
428 | |||
429 | SOC_SINGLE("EQ Switch", WM9081_EQ_1, 0, 1, 0), | ||
430 | |||
431 | SOC_SINGLE("Speaker DC Volume", WM9081_ANALOGUE_SPEAKER_1, 3, 5, 0), | ||
432 | SOC_SINGLE("Speaker AC Volume", WM9081_ANALOGUE_SPEAKER_1, 0, 5, 0), | ||
433 | SOC_SINGLE("Speaker Switch", WM9081_ANALOGUE_SPEAKER_PGA, 7, 1, 1), | ||
434 | SOC_SINGLE("Speaker ZC Switch", WM9081_ANALOGUE_SPEAKER_PGA, 6, 1, 0), | ||
435 | SOC_SINGLE_TLV("Speaker Volume", WM9081_ANALOGUE_SPEAKER_PGA, 0, 63, 0, | ||
436 | out_tlv), | ||
437 | SOC_ENUM("DAC Deemphasis", dac_deemph), | ||
438 | SOC_ENUM_EXT("Speaker Mode", speaker_mode, speaker_mode_get, speaker_mode_put), | ||
439 | }; | ||
440 | |||
441 | static const struct snd_kcontrol_new wm9081_eq_controls[] = { | ||
442 | SOC_SINGLE_TLV("EQ1 Volume", WM9081_EQ_1, 11, 24, 0, eq_tlv), | ||
443 | SOC_SINGLE_TLV("EQ2 Volume", WM9081_EQ_1, 6, 24, 0, eq_tlv), | ||
444 | SOC_SINGLE_TLV("EQ3 Volume", WM9081_EQ_1, 1, 24, 0, eq_tlv), | ||
445 | SOC_SINGLE_TLV("EQ4 Volume", WM9081_EQ_2, 11, 24, 0, eq_tlv), | ||
446 | SOC_SINGLE_TLV("EQ5 Volume", WM9081_EQ_2, 6, 24, 0, eq_tlv), | ||
447 | }; | ||
448 | |||
449 | static const struct snd_kcontrol_new mixer[] = { | ||
450 | SOC_DAPM_SINGLE("IN1 Switch", WM9081_ANALOGUE_MIXER, 0, 1, 0), | ||
451 | SOC_DAPM_SINGLE("IN2 Switch", WM9081_ANALOGUE_MIXER, 2, 1, 0), | ||
452 | SOC_DAPM_SINGLE("Playback Switch", WM9081_ANALOGUE_MIXER, 4, 1, 0), | ||
453 | }; | ||
454 | |||
455 | static int speaker_event(struct snd_soc_dapm_widget *w, | ||
456 | struct snd_kcontrol *kcontrol, int event) | ||
457 | { | ||
458 | struct snd_soc_codec *codec = w->codec; | ||
459 | unsigned int reg = wm9081_read(codec, WM9081_POWER_MANAGEMENT); | ||
460 | |||
461 | switch (event) { | ||
462 | case SND_SOC_DAPM_POST_PMU: | ||
463 | reg |= WM9081_SPK_ENA; | ||
464 | break; | ||
465 | |||
466 | case SND_SOC_DAPM_PRE_PMD: | ||
467 | reg &= ~WM9081_SPK_ENA; | ||
468 | break; | ||
469 | } | ||
470 | |||
471 | wm9081_write(codec, WM9081_POWER_MANAGEMENT, reg); | ||
472 | |||
473 | return 0; | ||
474 | } | ||
475 | |||
476 | struct _fll_div { | ||
477 | u16 fll_fratio; | ||
478 | u16 fll_outdiv; | ||
479 | u16 fll_clk_ref_div; | ||
480 | u16 n; | ||
481 | u16 k; | ||
482 | }; | ||
483 | |||
484 | /* The size in bits of the FLL divide multiplied by 10 | ||
485 | * to allow rounding later */ | ||
486 | #define FIXED_FLL_SIZE ((1 << 16) * 10) | ||
487 | |||
488 | static struct { | ||
489 | unsigned int min; | ||
490 | unsigned int max; | ||
491 | u16 fll_fratio; | ||
492 | int ratio; | ||
493 | } fll_fratios[] = { | ||
494 | { 0, 64000, 4, 16 }, | ||
495 | { 64000, 128000, 3, 8 }, | ||
496 | { 128000, 256000, 2, 4 }, | ||
497 | { 256000, 1000000, 1, 2 }, | ||
498 | { 1000000, 13500000, 0, 1 }, | ||
499 | }; | ||
500 | |||
501 | static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, | ||
502 | unsigned int Fout) | ||
503 | { | ||
504 | u64 Kpart; | ||
505 | unsigned int K, Ndiv, Nmod, target; | ||
506 | unsigned int div; | ||
507 | int i; | ||
508 | |||
509 | /* Fref must be <=13.5MHz */ | ||
510 | div = 1; | ||
511 | while ((Fref / div) > 13500000) { | ||
512 | div *= 2; | ||
513 | |||
514 | if (div > 8) { | ||
515 | pr_err("Can't scale %dMHz input down to <=13.5MHz\n", | ||
516 | Fref); | ||
517 | return -EINVAL; | ||
518 | } | ||
519 | } | ||
520 | fll_div->fll_clk_ref_div = div / 2; | ||
521 | |||
522 | pr_debug("Fref=%u Fout=%u\n", Fref, Fout); | ||
523 | |||
524 | /* Apply the division for our remaining calculations */ | ||
525 | Fref /= div; | ||
526 | |||
527 | /* Fvco should be 90-100MHz; don't check the upper bound */ | ||
528 | div = 0; | ||
529 | target = Fout * 2; | ||
530 | while (target < 90000000) { | ||
531 | div++; | ||
532 | target *= 2; | ||
533 | if (div > 7) { | ||
534 | pr_err("Unable to find FLL_OUTDIV for Fout=%uHz\n", | ||
535 | Fout); | ||
536 | return -EINVAL; | ||
537 | } | ||
538 | } | ||
539 | fll_div->fll_outdiv = div; | ||
540 | |||
541 | pr_debug("Fvco=%dHz\n", target); | ||
542 | |||
543 | /* Find an appropraite FLL_FRATIO and factor it out of the target */ | ||
544 | for (i = 0; i < ARRAY_SIZE(fll_fratios); i++) { | ||
545 | if (fll_fratios[i].min <= Fref && Fref <= fll_fratios[i].max) { | ||
546 | fll_div->fll_fratio = fll_fratios[i].fll_fratio; | ||
547 | target /= fll_fratios[i].ratio; | ||
548 | break; | ||
549 | } | ||
550 | } | ||
551 | if (i == ARRAY_SIZE(fll_fratios)) { | ||
552 | pr_err("Unable to find FLL_FRATIO for Fref=%uHz\n", Fref); | ||
553 | return -EINVAL; | ||
554 | } | ||
555 | |||
556 | /* Now, calculate N.K */ | ||
557 | Ndiv = target / Fref; | ||
558 | |||
559 | fll_div->n = Ndiv; | ||
560 | Nmod = target % Fref; | ||
561 | pr_debug("Nmod=%d\n", Nmod); | ||
562 | |||
563 | /* Calculate fractional part - scale up so we can round. */ | ||
564 | Kpart = FIXED_FLL_SIZE * (long long)Nmod; | ||
565 | |||
566 | do_div(Kpart, Fref); | ||
567 | |||
568 | K = Kpart & 0xFFFFFFFF; | ||
569 | |||
570 | if ((K % 10) >= 5) | ||
571 | K += 5; | ||
572 | |||
573 | /* Move down to proper range now rounding is done */ | ||
574 | fll_div->k = K / 10; | ||
575 | |||
576 | pr_debug("N=%x K=%x FLL_FRATIO=%x FLL_OUTDIV=%x FLL_CLK_REF_DIV=%x\n", | ||
577 | fll_div->n, fll_div->k, | ||
578 | fll_div->fll_fratio, fll_div->fll_outdiv, | ||
579 | fll_div->fll_clk_ref_div); | ||
580 | |||
581 | return 0; | ||
582 | } | ||
583 | |||
584 | static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, | ||
585 | unsigned int Fref, unsigned int Fout) | ||
586 | { | ||
587 | struct wm9081_priv *wm9081 = codec->private_data; | ||
588 | u16 reg1, reg4, reg5; | ||
589 | struct _fll_div fll_div; | ||
590 | int ret; | ||
591 | int clk_sys_reg; | ||
592 | |||
593 | /* Any change? */ | ||
594 | if (Fref == wm9081->fll_fref && Fout == wm9081->fll_fout) | ||
595 | return 0; | ||
596 | |||
597 | /* Disable the FLL */ | ||
598 | if (Fout == 0) { | ||
599 | dev_dbg(codec->dev, "FLL disabled\n"); | ||
600 | wm9081->fll_fref = 0; | ||
601 | wm9081->fll_fout = 0; | ||
602 | |||
603 | return 0; | ||
604 | } | ||
605 | |||
606 | ret = fll_factors(&fll_div, Fref, Fout); | ||
607 | if (ret != 0) | ||
608 | return ret; | ||
609 | |||
610 | reg5 = wm9081_read(codec, WM9081_FLL_CONTROL_5); | ||
611 | reg5 &= ~WM9081_FLL_CLK_SRC_MASK; | ||
612 | |||
613 | switch (fll_id) { | ||
614 | case WM9081_SYSCLK_FLL_MCLK: | ||
615 | reg5 |= 0x1; | ||
616 | break; | ||
617 | |||
618 | default: | ||
619 | dev_err(codec->dev, "Unknown FLL ID %d\n", fll_id); | ||
620 | return -EINVAL; | ||
621 | } | ||
622 | |||
623 | /* Disable CLK_SYS while we reconfigure */ | ||
624 | clk_sys_reg = wm9081_read(codec, WM9081_CLOCK_CONTROL_3); | ||
625 | if (clk_sys_reg & WM9081_CLK_SYS_ENA) | ||
626 | wm9081_write(codec, WM9081_CLOCK_CONTROL_3, | ||
627 | clk_sys_reg & ~WM9081_CLK_SYS_ENA); | ||
628 | |||
629 | /* Any FLL configuration change requires that the FLL be | ||
630 | * disabled first. */ | ||
631 | reg1 = wm9081_read(codec, WM9081_FLL_CONTROL_1); | ||
632 | reg1 &= ~WM9081_FLL_ENA; | ||
633 | wm9081_write(codec, WM9081_FLL_CONTROL_1, reg1); | ||
634 | |||
635 | /* Apply the configuration */ | ||
636 | if (fll_div.k) | ||
637 | reg1 |= WM9081_FLL_FRAC_MASK; | ||
638 | else | ||
639 | reg1 &= ~WM9081_FLL_FRAC_MASK; | ||
640 | wm9081_write(codec, WM9081_FLL_CONTROL_1, reg1); | ||
641 | |||
642 | wm9081_write(codec, WM9081_FLL_CONTROL_2, | ||
643 | (fll_div.fll_outdiv << WM9081_FLL_OUTDIV_SHIFT) | | ||
644 | (fll_div.fll_fratio << WM9081_FLL_FRATIO_SHIFT)); | ||
645 | wm9081_write(codec, WM9081_FLL_CONTROL_3, fll_div.k); | ||
646 | |||
647 | reg4 = wm9081_read(codec, WM9081_FLL_CONTROL_4); | ||
648 | reg4 &= ~WM9081_FLL_N_MASK; | ||
649 | reg4 |= fll_div.n << WM9081_FLL_N_SHIFT; | ||
650 | wm9081_write(codec, WM9081_FLL_CONTROL_4, reg4); | ||
651 | |||
652 | reg5 &= ~WM9081_FLL_CLK_REF_DIV_MASK; | ||
653 | reg5 |= fll_div.fll_clk_ref_div << WM9081_FLL_CLK_REF_DIV_SHIFT; | ||
654 | wm9081_write(codec, WM9081_FLL_CONTROL_5, reg5); | ||
655 | |||
656 | /* Enable the FLL */ | ||
657 | wm9081_write(codec, WM9081_FLL_CONTROL_1, reg1 | WM9081_FLL_ENA); | ||
658 | |||
659 | /* Then bring CLK_SYS up again if it was disabled */ | ||
660 | if (clk_sys_reg & WM9081_CLK_SYS_ENA) | ||
661 | wm9081_write(codec, WM9081_CLOCK_CONTROL_3, clk_sys_reg); | ||
662 | |||
663 | dev_dbg(codec->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout); | ||
664 | |||
665 | wm9081->fll_fref = Fref; | ||
666 | wm9081->fll_fout = Fout; | ||
667 | |||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | static int configure_clock(struct snd_soc_codec *codec) | ||
672 | { | ||
673 | struct wm9081_priv *wm9081 = codec->private_data; | ||
674 | int new_sysclk, i, target; | ||
675 | unsigned int reg; | ||
676 | int ret = 0; | ||
677 | int mclkdiv = 0; | ||
678 | int fll = 0; | ||
679 | |||
680 | switch (wm9081->sysclk_source) { | ||
681 | case WM9081_SYSCLK_MCLK: | ||
682 | if (wm9081->mclk_rate > 12225000) { | ||
683 | mclkdiv = 1; | ||
684 | wm9081->sysclk_rate = wm9081->mclk_rate / 2; | ||
685 | } else { | ||
686 | wm9081->sysclk_rate = wm9081->mclk_rate; | ||
687 | } | ||
688 | wm9081_set_fll(codec, WM9081_SYSCLK_FLL_MCLK, 0, 0); | ||
689 | break; | ||
690 | |||
691 | case WM9081_SYSCLK_FLL_MCLK: | ||
692 | /* If we have a sample rate calculate a CLK_SYS that | ||
693 | * gives us a suitable DAC configuration, plus BCLK. | ||
694 | * Ideally we would check to see if we can clock | ||
695 | * directly from MCLK and only use the FLL if this is | ||
696 | * not the case, though care must be taken with free | ||
697 | * running mode. | ||
698 | */ | ||
699 | if (wm9081->master && wm9081->bclk) { | ||
700 | /* Make sure we can generate CLK_SYS and BCLK | ||
701 | * and that we've got 3MHz for optimal | ||
702 | * performance. */ | ||
703 | for (i = 0; i < ARRAY_SIZE(clk_sys_rates); i++) { | ||
704 | target = wm9081->fs * clk_sys_rates[i].ratio; | ||
705 | new_sysclk = target; | ||
706 | if (target >= wm9081->bclk && | ||
707 | target > 3000000) | ||
708 | break; | ||
709 | } | ||
710 | } else if (wm9081->fs) { | ||
711 | for (i = 0; i < ARRAY_SIZE(clk_sys_rates); i++) { | ||
712 | new_sysclk = clk_sys_rates[i].ratio | ||
713 | * wm9081->fs; | ||
714 | if (new_sysclk > 3000000) | ||
715 | break; | ||
716 | } | ||
717 | } else { | ||
718 | new_sysclk = 12288000; | ||
719 | } | ||
720 | |||
721 | ret = wm9081_set_fll(codec, WM9081_SYSCLK_FLL_MCLK, | ||
722 | wm9081->mclk_rate, new_sysclk); | ||
723 | if (ret == 0) { | ||
724 | wm9081->sysclk_rate = new_sysclk; | ||
725 | |||
726 | /* Switch SYSCLK over to FLL */ | ||
727 | fll = 1; | ||
728 | } else { | ||
729 | wm9081->sysclk_rate = wm9081->mclk_rate; | ||
730 | } | ||
731 | break; | ||
732 | |||
733 | default: | ||
734 | return -EINVAL; | ||
735 | } | ||
736 | |||
737 | reg = wm9081_read(codec, WM9081_CLOCK_CONTROL_1); | ||
738 | if (mclkdiv) | ||
739 | reg |= WM9081_MCLKDIV2; | ||
740 | else | ||
741 | reg &= ~WM9081_MCLKDIV2; | ||
742 | wm9081_write(codec, WM9081_CLOCK_CONTROL_1, reg); | ||
743 | |||
744 | reg = wm9081_read(codec, WM9081_CLOCK_CONTROL_3); | ||
745 | if (fll) | ||
746 | reg |= WM9081_CLK_SRC_SEL; | ||
747 | else | ||
748 | reg &= ~WM9081_CLK_SRC_SEL; | ||
749 | wm9081_write(codec, WM9081_CLOCK_CONTROL_3, reg); | ||
750 | |||
751 | dev_dbg(codec->dev, "CLK_SYS is %dHz\n", wm9081->sysclk_rate); | ||
752 | |||
753 | return ret; | ||
754 | } | ||
755 | |||
756 | static int clk_sys_event(struct snd_soc_dapm_widget *w, | ||
757 | struct snd_kcontrol *kcontrol, int event) | ||
758 | { | ||
759 | struct snd_soc_codec *codec = w->codec; | ||
760 | struct wm9081_priv *wm9081 = codec->private_data; | ||
761 | |||
762 | /* This should be done on init() for bypass paths */ | ||
763 | switch (wm9081->sysclk_source) { | ||
764 | case WM9081_SYSCLK_MCLK: | ||
765 | dev_dbg(codec->dev, "Using %dHz MCLK\n", wm9081->mclk_rate); | ||
766 | break; | ||
767 | case WM9081_SYSCLK_FLL_MCLK: | ||
768 | dev_dbg(codec->dev, "Using %dHz MCLK with FLL\n", | ||
769 | wm9081->mclk_rate); | ||
770 | break; | ||
771 | default: | ||
772 | dev_err(codec->dev, "System clock not configured\n"); | ||
773 | return -EINVAL; | ||
774 | } | ||
775 | |||
776 | switch (event) { | ||
777 | case SND_SOC_DAPM_PRE_PMU: | ||
778 | configure_clock(codec); | ||
779 | break; | ||
780 | |||
781 | case SND_SOC_DAPM_POST_PMD: | ||
782 | /* Disable the FLL if it's running */ | ||
783 | wm9081_set_fll(codec, 0, 0, 0); | ||
784 | break; | ||
785 | } | ||
786 | |||
787 | return 0; | ||
788 | } | ||
789 | |||
790 | static const struct snd_soc_dapm_widget wm9081_dapm_widgets[] = { | ||
791 | SND_SOC_DAPM_INPUT("IN1"), | ||
792 | SND_SOC_DAPM_INPUT("IN2"), | ||
793 | |||
794 | SND_SOC_DAPM_DAC("DAC", "HiFi Playback", WM9081_POWER_MANAGEMENT, 0, 0), | ||
795 | |||
796 | SND_SOC_DAPM_MIXER_NAMED_CTL("Mixer", SND_SOC_NOPM, 0, 0, | ||
797 | mixer, ARRAY_SIZE(mixer)), | ||
798 | |||
799 | SND_SOC_DAPM_PGA("LINEOUT PGA", WM9081_POWER_MANAGEMENT, 4, 0, NULL, 0), | ||
800 | |||
801 | SND_SOC_DAPM_PGA_E("Speaker PGA", WM9081_POWER_MANAGEMENT, 2, 0, NULL, 0, | ||
802 | speaker_event, | ||
803 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), | ||
804 | |||
805 | SND_SOC_DAPM_OUTPUT("LINEOUT"), | ||
806 | SND_SOC_DAPM_OUTPUT("SPKN"), | ||
807 | SND_SOC_DAPM_OUTPUT("SPKP"), | ||
808 | |||
809 | SND_SOC_DAPM_SUPPLY("CLK_SYS", WM9081_CLOCK_CONTROL_3, 0, 0, clk_sys_event, | ||
810 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
811 | SND_SOC_DAPM_SUPPLY("CLK_DSP", WM9081_CLOCK_CONTROL_3, 1, 0, NULL, 0), | ||
812 | SND_SOC_DAPM_SUPPLY("TOCLK", WM9081_CLOCK_CONTROL_3, 2, 0, NULL, 0), | ||
813 | }; | ||
814 | |||
815 | |||
816 | static const struct snd_soc_dapm_route audio_paths[] = { | ||
817 | { "DAC", NULL, "CLK_SYS" }, | ||
818 | { "DAC", NULL, "CLK_DSP" }, | ||
819 | |||
820 | { "Mixer", "IN1 Switch", "IN1" }, | ||
821 | { "Mixer", "IN2 Switch", "IN2" }, | ||
822 | { "Mixer", "Playback Switch", "DAC" }, | ||
823 | |||
824 | { "LINEOUT PGA", NULL, "Mixer" }, | ||
825 | { "LINEOUT PGA", NULL, "TOCLK" }, | ||
826 | { "LINEOUT PGA", NULL, "CLK_SYS" }, | ||
827 | |||
828 | { "LINEOUT", NULL, "LINEOUT PGA" }, | ||
829 | |||
830 | { "Speaker PGA", NULL, "Mixer" }, | ||
831 | { "Speaker PGA", NULL, "TOCLK" }, | ||
832 | { "Speaker PGA", NULL, "CLK_SYS" }, | ||
833 | |||
834 | { "SPKN", NULL, "Speaker PGA" }, | ||
835 | { "SPKP", NULL, "Speaker PGA" }, | ||
836 | }; | ||
837 | |||
838 | static int wm9081_set_bias_level(struct snd_soc_codec *codec, | ||
839 | enum snd_soc_bias_level level) | ||
840 | { | ||
841 | u16 reg; | ||
842 | |||
843 | switch (level) { | ||
844 | case SND_SOC_BIAS_ON: | ||
845 | break; | ||
846 | |||
847 | case SND_SOC_BIAS_PREPARE: | ||
848 | /* VMID=2*40k */ | ||
849 | reg = wm9081_read(codec, WM9081_VMID_CONTROL); | ||
850 | reg &= ~WM9081_VMID_SEL_MASK; | ||
851 | reg |= 0x2; | ||
852 | wm9081_write(codec, WM9081_VMID_CONTROL, reg); | ||
853 | |||
854 | /* Normal bias current */ | ||
855 | reg = wm9081_read(codec, WM9081_BIAS_CONTROL_1); | ||
856 | reg &= ~WM9081_STBY_BIAS_ENA; | ||
857 | wm9081_write(codec, WM9081_BIAS_CONTROL_1, reg); | ||
858 | break; | ||
859 | |||
860 | case SND_SOC_BIAS_STANDBY: | ||
861 | /* Initial cold start */ | ||
862 | if (codec->bias_level == SND_SOC_BIAS_OFF) { | ||
863 | /* Disable LINEOUT discharge */ | ||
864 | reg = wm9081_read(codec, WM9081_ANTI_POP_CONTROL); | ||
865 | reg &= ~WM9081_LINEOUT_DISCH; | ||
866 | wm9081_write(codec, WM9081_ANTI_POP_CONTROL, reg); | ||
867 | |||
868 | /* Select startup bias source */ | ||
869 | reg = wm9081_read(codec, WM9081_BIAS_CONTROL_1); | ||
870 | reg |= WM9081_BIAS_SRC | WM9081_BIAS_ENA; | ||
871 | wm9081_write(codec, WM9081_BIAS_CONTROL_1, reg); | ||
872 | |||
873 | /* VMID 2*4k; Soft VMID ramp enable */ | ||
874 | reg = wm9081_read(codec, WM9081_VMID_CONTROL); | ||
875 | reg |= WM9081_VMID_RAMP | 0x6; | ||
876 | wm9081_write(codec, WM9081_VMID_CONTROL, reg); | ||
877 | |||
878 | mdelay(100); | ||
879 | |||
880 | /* Normal bias enable & soft start off */ | ||
881 | reg |= WM9081_BIAS_ENA; | ||
882 | reg &= ~WM9081_VMID_RAMP; | ||
883 | wm9081_write(codec, WM9081_VMID_CONTROL, reg); | ||
884 | |||
885 | /* Standard bias source */ | ||
886 | reg = wm9081_read(codec, WM9081_BIAS_CONTROL_1); | ||
887 | reg &= ~WM9081_BIAS_SRC; | ||
888 | wm9081_write(codec, WM9081_BIAS_CONTROL_1, reg); | ||
889 | } | ||
890 | |||
891 | /* VMID 2*240k */ | ||
892 | reg = wm9081_read(codec, WM9081_BIAS_CONTROL_1); | ||
893 | reg &= ~WM9081_VMID_SEL_MASK; | ||
894 | reg |= 0x40; | ||
895 | wm9081_write(codec, WM9081_VMID_CONTROL, reg); | ||
896 | |||
897 | /* Standby bias current on */ | ||
898 | reg = wm9081_read(codec, WM9081_BIAS_CONTROL_1); | ||
899 | reg |= WM9081_STBY_BIAS_ENA; | ||
900 | wm9081_write(codec, WM9081_BIAS_CONTROL_1, reg); | ||
901 | break; | ||
902 | |||
903 | case SND_SOC_BIAS_OFF: | ||
904 | /* Startup bias source */ | ||
905 | reg = wm9081_read(codec, WM9081_BIAS_CONTROL_1); | ||
906 | reg |= WM9081_BIAS_SRC; | ||
907 | wm9081_write(codec, WM9081_BIAS_CONTROL_1, reg); | ||
908 | |||
909 | /* Disable VMID and biases with soft ramping */ | ||
910 | reg = wm9081_read(codec, WM9081_VMID_CONTROL); | ||
911 | reg &= ~(WM9081_VMID_SEL_MASK | WM9081_BIAS_ENA); | ||
912 | reg |= WM9081_VMID_RAMP; | ||
913 | wm9081_write(codec, WM9081_VMID_CONTROL, reg); | ||
914 | |||
915 | /* Actively discharge LINEOUT */ | ||
916 | reg = wm9081_read(codec, WM9081_ANTI_POP_CONTROL); | ||
917 | reg |= WM9081_LINEOUT_DISCH; | ||
918 | wm9081_write(codec, WM9081_ANTI_POP_CONTROL, reg); | ||
919 | break; | ||
920 | } | ||
921 | |||
922 | codec->bias_level = level; | ||
923 | |||
924 | return 0; | ||
925 | } | ||
926 | |||
927 | static int wm9081_set_dai_fmt(struct snd_soc_dai *dai, | ||
928 | unsigned int fmt) | ||
929 | { | ||
930 | struct snd_soc_codec *codec = dai->codec; | ||
931 | struct wm9081_priv *wm9081 = codec->private_data; | ||
932 | unsigned int aif2 = wm9081_read(codec, WM9081_AUDIO_INTERFACE_2); | ||
933 | |||
934 | aif2 &= ~(WM9081_AIF_BCLK_INV | WM9081_AIF_LRCLK_INV | | ||
935 | WM9081_BCLK_DIR | WM9081_LRCLK_DIR | WM9081_AIF_FMT_MASK); | ||
936 | |||
937 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
938 | case SND_SOC_DAIFMT_CBS_CFS: | ||
939 | wm9081->master = 0; | ||
940 | break; | ||
941 | case SND_SOC_DAIFMT_CBS_CFM: | ||
942 | aif2 |= WM9081_LRCLK_DIR; | ||
943 | wm9081->master = 1; | ||
944 | break; | ||
945 | case SND_SOC_DAIFMT_CBM_CFS: | ||
946 | aif2 |= WM9081_BCLK_DIR; | ||
947 | wm9081->master = 1; | ||
948 | break; | ||
949 | case SND_SOC_DAIFMT_CBM_CFM: | ||
950 | aif2 |= WM9081_LRCLK_DIR | WM9081_BCLK_DIR; | ||
951 | wm9081->master = 1; | ||
952 | break; | ||
953 | default: | ||
954 | return -EINVAL; | ||
955 | } | ||
956 | |||
957 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
958 | case SND_SOC_DAIFMT_DSP_B: | ||
959 | aif2 |= WM9081_AIF_LRCLK_INV; | ||
960 | case SND_SOC_DAIFMT_DSP_A: | ||
961 | aif2 |= 0x3; | ||
962 | break; | ||
963 | case SND_SOC_DAIFMT_I2S: | ||
964 | aif2 |= 0x2; | ||
965 | break; | ||
966 | case SND_SOC_DAIFMT_RIGHT_J: | ||
967 | break; | ||
968 | case SND_SOC_DAIFMT_LEFT_J: | ||
969 | aif2 |= 0x1; | ||
970 | break; | ||
971 | default: | ||
972 | return -EINVAL; | ||
973 | } | ||
974 | |||
975 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
976 | case SND_SOC_DAIFMT_DSP_A: | ||
977 | case SND_SOC_DAIFMT_DSP_B: | ||
978 | /* frame inversion not valid for DSP modes */ | ||
979 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
980 | case SND_SOC_DAIFMT_NB_NF: | ||
981 | break; | ||
982 | case SND_SOC_DAIFMT_IB_NF: | ||
983 | aif2 |= WM9081_AIF_BCLK_INV; | ||
984 | break; | ||
985 | default: | ||
986 | return -EINVAL; | ||
987 | } | ||
988 | break; | ||
989 | |||
990 | case SND_SOC_DAIFMT_I2S: | ||
991 | case SND_SOC_DAIFMT_RIGHT_J: | ||
992 | case SND_SOC_DAIFMT_LEFT_J: | ||
993 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
994 | case SND_SOC_DAIFMT_NB_NF: | ||
995 | break; | ||
996 | case SND_SOC_DAIFMT_IB_IF: | ||
997 | aif2 |= WM9081_AIF_BCLK_INV | WM9081_AIF_LRCLK_INV; | ||
998 | break; | ||
999 | case SND_SOC_DAIFMT_IB_NF: | ||
1000 | aif2 |= WM9081_AIF_BCLK_INV; | ||
1001 | break; | ||
1002 | case SND_SOC_DAIFMT_NB_IF: | ||
1003 | aif2 |= WM9081_AIF_LRCLK_INV; | ||
1004 | break; | ||
1005 | default: | ||
1006 | return -EINVAL; | ||
1007 | } | ||
1008 | break; | ||
1009 | default: | ||
1010 | return -EINVAL; | ||
1011 | } | ||
1012 | |||
1013 | wm9081_write(codec, WM9081_AUDIO_INTERFACE_2, aif2); | ||
1014 | |||
1015 | return 0; | ||
1016 | } | ||
1017 | |||
1018 | static int wm9081_hw_params(struct snd_pcm_substream *substream, | ||
1019 | struct snd_pcm_hw_params *params, | ||
1020 | struct snd_soc_dai *dai) | ||
1021 | { | ||
1022 | struct snd_soc_codec *codec = dai->codec; | ||
1023 | struct wm9081_priv *wm9081 = codec->private_data; | ||
1024 | int ret, i, best, best_val, cur_val; | ||
1025 | unsigned int clk_ctrl2, aif1, aif2, aif3, aif4; | ||
1026 | |||
1027 | clk_ctrl2 = wm9081_read(codec, WM9081_CLOCK_CONTROL_2); | ||
1028 | clk_ctrl2 &= ~(WM9081_CLK_SYS_RATE_MASK | WM9081_SAMPLE_RATE_MASK); | ||
1029 | |||
1030 | aif1 = wm9081_read(codec, WM9081_AUDIO_INTERFACE_1); | ||
1031 | |||
1032 | aif2 = wm9081_read(codec, WM9081_AUDIO_INTERFACE_2); | ||
1033 | aif2 &= ~WM9081_AIF_WL_MASK; | ||
1034 | |||
1035 | aif3 = wm9081_read(codec, WM9081_AUDIO_INTERFACE_3); | ||
1036 | aif3 &= ~WM9081_BCLK_DIV_MASK; | ||
1037 | |||
1038 | aif4 = wm9081_read(codec, WM9081_AUDIO_INTERFACE_4); | ||
1039 | aif4 &= ~WM9081_LRCLK_RATE_MASK; | ||
1040 | |||
1041 | /* What BCLK do we need? */ | ||
1042 | wm9081->fs = params_rate(params); | ||
1043 | wm9081->bclk = 2 * wm9081->fs; | ||
1044 | switch (params_format(params)) { | ||
1045 | case SNDRV_PCM_FORMAT_S16_LE: | ||
1046 | wm9081->bclk *= 16; | ||
1047 | break; | ||
1048 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
1049 | wm9081->bclk *= 20; | ||
1050 | aif2 |= 0x4; | ||
1051 | break; | ||
1052 | case SNDRV_PCM_FORMAT_S24_LE: | ||
1053 | wm9081->bclk *= 24; | ||
1054 | aif2 |= 0x8; | ||
1055 | break; | ||
1056 | case SNDRV_PCM_FORMAT_S32_LE: | ||
1057 | wm9081->bclk *= 32; | ||
1058 | aif2 |= 0xc; | ||
1059 | break; | ||
1060 | default: | ||
1061 | return -EINVAL; | ||
1062 | } | ||
1063 | |||
1064 | if (aif1 & WM9081_AIFDAC_TDM_MODE_MASK) { | ||
1065 | int slots = ((aif1 & WM9081_AIFDAC_TDM_MODE_MASK) >> | ||
1066 | WM9081_AIFDAC_TDM_MODE_SHIFT) + 1; | ||
1067 | wm9081->bclk *= slots; | ||
1068 | } | ||
1069 | |||
1070 | dev_dbg(codec->dev, "Target BCLK is %dHz\n", wm9081->bclk); | ||
1071 | |||
1072 | ret = configure_clock(codec); | ||
1073 | if (ret != 0) | ||
1074 | return ret; | ||
1075 | |||
1076 | /* Select nearest CLK_SYS_RATE */ | ||
1077 | best = 0; | ||
1078 | best_val = abs((wm9081->sysclk_rate / clk_sys_rates[0].ratio) | ||
1079 | - wm9081->fs); | ||
1080 | for (i = 1; i < ARRAY_SIZE(clk_sys_rates); i++) { | ||
1081 | cur_val = abs((wm9081->sysclk_rate / | ||
1082 | clk_sys_rates[i].ratio) - wm9081->fs);; | ||
1083 | if (cur_val < best_val) { | ||
1084 | best = i; | ||
1085 | best_val = cur_val; | ||
1086 | } | ||
1087 | } | ||
1088 | dev_dbg(codec->dev, "Selected CLK_SYS_RATIO of %d\n", | ||
1089 | clk_sys_rates[best].ratio); | ||
1090 | clk_ctrl2 |= (clk_sys_rates[best].clk_sys_rate | ||
1091 | << WM9081_CLK_SYS_RATE_SHIFT); | ||
1092 | |||
1093 | /* SAMPLE_RATE */ | ||
1094 | best = 0; | ||
1095 | best_val = abs(wm9081->fs - sample_rates[0].rate); | ||
1096 | for (i = 1; i < ARRAY_SIZE(sample_rates); i++) { | ||
1097 | /* Closest match */ | ||
1098 | cur_val = abs(wm9081->fs - sample_rates[i].rate); | ||
1099 | if (cur_val < best_val) { | ||
1100 | best = i; | ||
1101 | best_val = cur_val; | ||
1102 | } | ||
1103 | } | ||
1104 | dev_dbg(codec->dev, "Selected SAMPLE_RATE of %dHz\n", | ||
1105 | sample_rates[best].rate); | ||
1106 | clk_ctrl2 |= (sample_rates[best].sample_rate | ||
1107 | << WM9081_SAMPLE_RATE_SHIFT); | ||
1108 | |||
1109 | /* BCLK_DIV */ | ||
1110 | best = 0; | ||
1111 | best_val = INT_MAX; | ||
1112 | for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) { | ||
1113 | cur_val = ((wm9081->sysclk_rate * 10) / bclk_divs[i].div) | ||
1114 | - wm9081->bclk; | ||
1115 | if (cur_val < 0) /* Table is sorted */ | ||
1116 | break; | ||
1117 | if (cur_val < best_val) { | ||
1118 | best = i; | ||
1119 | best_val = cur_val; | ||
1120 | } | ||
1121 | } | ||
1122 | wm9081->bclk = (wm9081->sysclk_rate * 10) / bclk_divs[best].div; | ||
1123 | dev_dbg(codec->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", | ||
1124 | bclk_divs[best].div, wm9081->bclk); | ||
1125 | aif3 |= bclk_divs[best].bclk_div; | ||
1126 | |||
1127 | /* LRCLK is a simple fraction of BCLK */ | ||
1128 | dev_dbg(codec->dev, "LRCLK_RATE is %d\n", wm9081->bclk / wm9081->fs); | ||
1129 | aif4 |= wm9081->bclk / wm9081->fs; | ||
1130 | |||
1131 | /* Apply a ReTune Mobile configuration if it's in use */ | ||
1132 | if (wm9081->retune) { | ||
1133 | struct wm9081_retune_mobile_config *retune = wm9081->retune; | ||
1134 | struct wm9081_retune_mobile_setting *s; | ||
1135 | int eq1; | ||
1136 | |||
1137 | best = 0; | ||
1138 | best_val = abs(retune->configs[0].rate - wm9081->fs); | ||
1139 | for (i = 0; i < retune->num_configs; i++) { | ||
1140 | cur_val = abs(retune->configs[i].rate - wm9081->fs); | ||
1141 | if (cur_val < best_val) { | ||
1142 | best_val = cur_val; | ||
1143 | best = i; | ||
1144 | } | ||
1145 | } | ||
1146 | s = &retune->configs[best]; | ||
1147 | |||
1148 | dev_dbg(codec->dev, "ReTune Mobile %s tuned for %dHz\n", | ||
1149 | s->name, s->rate); | ||
1150 | |||
1151 | /* If the EQ is enabled then disable it while we write out */ | ||
1152 | eq1 = wm9081_read(codec, WM9081_EQ_1) & WM9081_EQ_ENA; | ||
1153 | if (eq1 & WM9081_EQ_ENA) | ||
1154 | wm9081_write(codec, WM9081_EQ_1, 0); | ||
1155 | |||
1156 | /* Write out the other values */ | ||
1157 | for (i = 1; i < ARRAY_SIZE(s->config); i++) | ||
1158 | wm9081_write(codec, WM9081_EQ_1 + i, s->config[i]); | ||
1159 | |||
1160 | eq1 |= (s->config[0] & ~WM9081_EQ_ENA); | ||
1161 | wm9081_write(codec, WM9081_EQ_1, eq1); | ||
1162 | } | ||
1163 | |||
1164 | wm9081_write(codec, WM9081_CLOCK_CONTROL_2, clk_ctrl2); | ||
1165 | wm9081_write(codec, WM9081_AUDIO_INTERFACE_2, aif2); | ||
1166 | wm9081_write(codec, WM9081_AUDIO_INTERFACE_3, aif3); | ||
1167 | wm9081_write(codec, WM9081_AUDIO_INTERFACE_4, aif4); | ||
1168 | |||
1169 | return 0; | ||
1170 | } | ||
1171 | |||
1172 | static int wm9081_digital_mute(struct snd_soc_dai *codec_dai, int mute) | ||
1173 | { | ||
1174 | struct snd_soc_codec *codec = codec_dai->codec; | ||
1175 | unsigned int reg; | ||
1176 | |||
1177 | reg = wm9081_read(codec, WM9081_DAC_DIGITAL_2); | ||
1178 | |||
1179 | if (mute) | ||
1180 | reg |= WM9081_DAC_MUTE; | ||
1181 | else | ||
1182 | reg &= ~WM9081_DAC_MUTE; | ||
1183 | |||
1184 | wm9081_write(codec, WM9081_DAC_DIGITAL_2, reg); | ||
1185 | |||
1186 | return 0; | ||
1187 | } | ||
1188 | |||
1189 | static int wm9081_set_sysclk(struct snd_soc_dai *codec_dai, | ||
1190 | int clk_id, unsigned int freq, int dir) | ||
1191 | { | ||
1192 | struct snd_soc_codec *codec = codec_dai->codec; | ||
1193 | struct wm9081_priv *wm9081 = codec->private_data; | ||
1194 | |||
1195 | switch (clk_id) { | ||
1196 | case WM9081_SYSCLK_MCLK: | ||
1197 | case WM9081_SYSCLK_FLL_MCLK: | ||
1198 | wm9081->sysclk_source = clk_id; | ||
1199 | wm9081->mclk_rate = freq; | ||
1200 | break; | ||
1201 | |||
1202 | default: | ||
1203 | return -EINVAL; | ||
1204 | } | ||
1205 | |||
1206 | return 0; | ||
1207 | } | ||
1208 | |||
1209 | static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, | ||
1210 | unsigned int mask, int slots) | ||
1211 | { | ||
1212 | struct snd_soc_codec *codec = dai->codec; | ||
1213 | unsigned int aif1 = wm9081_read(codec, WM9081_AUDIO_INTERFACE_1); | ||
1214 | |||
1215 | aif1 &= ~(WM9081_AIFDAC_TDM_SLOT_MASK | WM9081_AIFDAC_TDM_MODE_MASK); | ||
1216 | |||
1217 | if (slots < 1 || slots > 4) | ||
1218 | return -EINVAL; | ||
1219 | |||
1220 | aif1 |= (slots - 1) << WM9081_AIFDAC_TDM_MODE_SHIFT; | ||
1221 | |||
1222 | switch (mask) { | ||
1223 | case 1: | ||
1224 | break; | ||
1225 | case 2: | ||
1226 | aif1 |= 0x10; | ||
1227 | break; | ||
1228 | case 4: | ||
1229 | aif1 |= 0x20; | ||
1230 | break; | ||
1231 | case 8: | ||
1232 | aif1 |= 0x30; | ||
1233 | break; | ||
1234 | default: | ||
1235 | return -EINVAL; | ||
1236 | } | ||
1237 | |||
1238 | wm9081_write(codec, WM9081_AUDIO_INTERFACE_1, aif1); | ||
1239 | |||
1240 | return 0; | ||
1241 | } | ||
1242 | |||
1243 | #define WM9081_RATES SNDRV_PCM_RATE_8000_96000 | ||
1244 | |||
1245 | #define WM9081_FORMATS \ | ||
1246 | (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ | ||
1247 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) | ||
1248 | |||
1249 | static struct snd_soc_dai_ops wm9081_dai_ops = { | ||
1250 | .hw_params = wm9081_hw_params, | ||
1251 | .set_sysclk = wm9081_set_sysclk, | ||
1252 | .set_fmt = wm9081_set_dai_fmt, | ||
1253 | .digital_mute = wm9081_digital_mute, | ||
1254 | .set_tdm_slot = wm9081_set_tdm_slot, | ||
1255 | }; | ||
1256 | |||
1257 | /* We report two channels because the CODEC processes a stereo signal, even | ||
1258 | * though it is only capable of handling a mono output. | ||
1259 | */ | ||
1260 | struct snd_soc_dai wm9081_dai = { | ||
1261 | .name = "WM9081", | ||
1262 | .playback = { | ||
1263 | .stream_name = "HiFi Playback", | ||
1264 | .channels_min = 1, | ||
1265 | .channels_max = 2, | ||
1266 | .rates = WM9081_RATES, | ||
1267 | .formats = WM9081_FORMATS, | ||
1268 | }, | ||
1269 | .ops = &wm9081_dai_ops, | ||
1270 | }; | ||
1271 | EXPORT_SYMBOL_GPL(wm9081_dai); | ||
1272 | |||
1273 | |||
1274 | static struct snd_soc_codec *wm9081_codec; | ||
1275 | |||
1276 | static int wm9081_probe(struct platform_device *pdev) | ||
1277 | { | ||
1278 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
1279 | struct snd_soc_codec *codec; | ||
1280 | struct wm9081_priv *wm9081; | ||
1281 | int ret = 0; | ||
1282 | |||
1283 | if (wm9081_codec == NULL) { | ||
1284 | dev_err(&pdev->dev, "Codec device not registered\n"); | ||
1285 | return -ENODEV; | ||
1286 | } | ||
1287 | |||
1288 | socdev->card->codec = wm9081_codec; | ||
1289 | codec = wm9081_codec; | ||
1290 | wm9081 = codec->private_data; | ||
1291 | |||
1292 | /* register pcms */ | ||
1293 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
1294 | if (ret < 0) { | ||
1295 | dev_err(codec->dev, "failed to create pcms: %d\n", ret); | ||
1296 | goto pcm_err; | ||
1297 | } | ||
1298 | |||
1299 | snd_soc_add_controls(codec, wm9081_snd_controls, | ||
1300 | ARRAY_SIZE(wm9081_snd_controls)); | ||
1301 | if (!wm9081->retune) { | ||
1302 | dev_dbg(codec->dev, | ||
1303 | "No ReTune Mobile data, using normal EQ\n"); | ||
1304 | snd_soc_add_controls(codec, wm9081_eq_controls, | ||
1305 | ARRAY_SIZE(wm9081_eq_controls)); | ||
1306 | } | ||
1307 | |||
1308 | snd_soc_dapm_new_controls(codec, wm9081_dapm_widgets, | ||
1309 | ARRAY_SIZE(wm9081_dapm_widgets)); | ||
1310 | snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths)); | ||
1311 | snd_soc_dapm_new_widgets(codec); | ||
1312 | |||
1313 | ret = snd_soc_init_card(socdev); | ||
1314 | if (ret < 0) { | ||
1315 | dev_err(codec->dev, "failed to register card: %d\n", ret); | ||
1316 | goto card_err; | ||
1317 | } | ||
1318 | |||
1319 | return ret; | ||
1320 | |||
1321 | card_err: | ||
1322 | snd_soc_free_pcms(socdev); | ||
1323 | snd_soc_dapm_free(socdev); | ||
1324 | pcm_err: | ||
1325 | return ret; | ||
1326 | } | ||
1327 | |||
1328 | static int wm9081_remove(struct platform_device *pdev) | ||
1329 | { | ||
1330 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
1331 | |||
1332 | snd_soc_free_pcms(socdev); | ||
1333 | snd_soc_dapm_free(socdev); | ||
1334 | |||
1335 | return 0; | ||
1336 | } | ||
1337 | |||
1338 | #ifdef CONFIG_PM | ||
1339 | static int wm9081_suspend(struct platform_device *pdev, pm_message_t state) | ||
1340 | { | ||
1341 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
1342 | struct snd_soc_codec *codec = socdev->card->codec; | ||
1343 | |||
1344 | wm9081_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
1345 | |||
1346 | return 0; | ||
1347 | } | ||
1348 | |||
1349 | static int wm9081_resume(struct platform_device *pdev) | ||
1350 | { | ||
1351 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
1352 | struct snd_soc_codec *codec = socdev->card->codec; | ||
1353 | u16 *reg_cache = codec->reg_cache; | ||
1354 | int i; | ||
1355 | |||
1356 | for (i = 0; i < codec->reg_cache_size; i++) { | ||
1357 | if (i == WM9081_SOFTWARE_RESET) | ||
1358 | continue; | ||
1359 | |||
1360 | wm9081_write(codec, i, reg_cache[i]); | ||
1361 | } | ||
1362 | |||
1363 | wm9081_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
1364 | |||
1365 | return 0; | ||
1366 | } | ||
1367 | #else | ||
1368 | #define wm9081_suspend NULL | ||
1369 | #define wm9081_resume NULL | ||
1370 | #endif | ||
1371 | |||
1372 | struct snd_soc_codec_device soc_codec_dev_wm9081 = { | ||
1373 | .probe = wm9081_probe, | ||
1374 | .remove = wm9081_remove, | ||
1375 | .suspend = wm9081_suspend, | ||
1376 | .resume = wm9081_resume, | ||
1377 | }; | ||
1378 | EXPORT_SYMBOL_GPL(soc_codec_dev_wm9081); | ||
1379 | |||
1380 | static int wm9081_register(struct wm9081_priv *wm9081) | ||
1381 | { | ||
1382 | struct snd_soc_codec *codec = &wm9081->codec; | ||
1383 | int ret; | ||
1384 | u16 reg; | ||
1385 | |||
1386 | if (wm9081_codec) { | ||
1387 | dev_err(codec->dev, "Another WM9081 is registered\n"); | ||
1388 | ret = -EINVAL; | ||
1389 | goto err; | ||
1390 | } | ||
1391 | |||
1392 | mutex_init(&codec->mutex); | ||
1393 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
1394 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
1395 | |||
1396 | codec->private_data = wm9081; | ||
1397 | codec->name = "WM9081"; | ||
1398 | codec->owner = THIS_MODULE; | ||
1399 | codec->read = wm9081_read; | ||
1400 | codec->write = wm9081_write; | ||
1401 | codec->dai = &wm9081_dai; | ||
1402 | codec->num_dai = 1; | ||
1403 | codec->reg_cache_size = ARRAY_SIZE(wm9081->reg_cache); | ||
1404 | codec->reg_cache = &wm9081->reg_cache; | ||
1405 | codec->bias_level = SND_SOC_BIAS_OFF; | ||
1406 | codec->set_bias_level = wm9081_set_bias_level; | ||
1407 | |||
1408 | memcpy(codec->reg_cache, wm9081_reg_defaults, | ||
1409 | sizeof(wm9081_reg_defaults)); | ||
1410 | |||
1411 | reg = wm9081_read_hw(codec, WM9081_SOFTWARE_RESET); | ||
1412 | if (reg != 0x9081) { | ||
1413 | dev_err(codec->dev, "Device is not a WM9081: ID=0x%x\n", reg); | ||
1414 | ret = -EINVAL; | ||
1415 | goto err; | ||
1416 | } | ||
1417 | |||
1418 | ret = wm9081_reset(codec); | ||
1419 | if (ret < 0) { | ||
1420 | dev_err(codec->dev, "Failed to issue reset\n"); | ||
1421 | return ret; | ||
1422 | } | ||
1423 | |||
1424 | wm9081_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
1425 | |||
1426 | /* Enable zero cross by default */ | ||
1427 | reg = wm9081_read(codec, WM9081_ANALOGUE_LINEOUT); | ||
1428 | wm9081_write(codec, WM9081_ANALOGUE_LINEOUT, reg | WM9081_LINEOUTZC); | ||
1429 | reg = wm9081_read(codec, WM9081_ANALOGUE_SPEAKER_PGA); | ||
1430 | wm9081_write(codec, WM9081_ANALOGUE_SPEAKER_PGA, | ||
1431 | reg | WM9081_SPKPGAZC); | ||
1432 | |||
1433 | wm9081_dai.dev = codec->dev; | ||
1434 | |||
1435 | wm9081_codec = codec; | ||
1436 | |||
1437 | ret = snd_soc_register_codec(codec); | ||
1438 | if (ret != 0) { | ||
1439 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); | ||
1440 | return ret; | ||
1441 | } | ||
1442 | |||
1443 | ret = snd_soc_register_dai(&wm9081_dai); | ||
1444 | if (ret != 0) { | ||
1445 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); | ||
1446 | snd_soc_unregister_codec(codec); | ||
1447 | return ret; | ||
1448 | } | ||
1449 | |||
1450 | return 0; | ||
1451 | |||
1452 | err: | ||
1453 | kfree(wm9081); | ||
1454 | return ret; | ||
1455 | } | ||
1456 | |||
1457 | static void wm9081_unregister(struct wm9081_priv *wm9081) | ||
1458 | { | ||
1459 | wm9081_set_bias_level(&wm9081->codec, SND_SOC_BIAS_OFF); | ||
1460 | snd_soc_unregister_dai(&wm9081_dai); | ||
1461 | snd_soc_unregister_codec(&wm9081->codec); | ||
1462 | kfree(wm9081); | ||
1463 | wm9081_codec = NULL; | ||
1464 | } | ||
1465 | |||
1466 | static __devinit int wm9081_i2c_probe(struct i2c_client *i2c, | ||
1467 | const struct i2c_device_id *id) | ||
1468 | { | ||
1469 | struct wm9081_priv *wm9081; | ||
1470 | struct snd_soc_codec *codec; | ||
1471 | |||
1472 | wm9081 = kzalloc(sizeof(struct wm9081_priv), GFP_KERNEL); | ||
1473 | if (wm9081 == NULL) | ||
1474 | return -ENOMEM; | ||
1475 | |||
1476 | codec = &wm9081->codec; | ||
1477 | codec->hw_write = (hw_write_t)i2c_master_send; | ||
1478 | wm9081->retune = i2c->dev.platform_data; | ||
1479 | |||
1480 | i2c_set_clientdata(i2c, wm9081); | ||
1481 | codec->control_data = i2c; | ||
1482 | |||
1483 | codec->dev = &i2c->dev; | ||
1484 | |||
1485 | return wm9081_register(wm9081); | ||
1486 | } | ||
1487 | |||
1488 | static __devexit int wm9081_i2c_remove(struct i2c_client *client) | ||
1489 | { | ||
1490 | struct wm9081_priv *wm9081 = i2c_get_clientdata(client); | ||
1491 | wm9081_unregister(wm9081); | ||
1492 | return 0; | ||
1493 | } | ||
1494 | |||
1495 | static const struct i2c_device_id wm9081_i2c_id[] = { | ||
1496 | { "wm9081", 0 }, | ||
1497 | { } | ||
1498 | }; | ||
1499 | MODULE_DEVICE_TABLE(i2c, wm9081_i2c_id); | ||
1500 | |||
1501 | static struct i2c_driver wm9081_i2c_driver = { | ||
1502 | .driver = { | ||
1503 | .name = "wm9081", | ||
1504 | .owner = THIS_MODULE, | ||
1505 | }, | ||
1506 | .probe = wm9081_i2c_probe, | ||
1507 | .remove = __devexit_p(wm9081_i2c_remove), | ||
1508 | .id_table = wm9081_i2c_id, | ||
1509 | }; | ||
1510 | |||
1511 | static int __init wm9081_modinit(void) | ||
1512 | { | ||
1513 | int ret; | ||
1514 | |||
1515 | ret = i2c_add_driver(&wm9081_i2c_driver); | ||
1516 | if (ret != 0) { | ||
1517 | printk(KERN_ERR "Failed to register WM9081 I2C driver: %d\n", | ||
1518 | ret); | ||
1519 | } | ||
1520 | |||
1521 | return ret; | ||
1522 | } | ||
1523 | module_init(wm9081_modinit); | ||
1524 | |||
1525 | static void __exit wm9081_exit(void) | ||
1526 | { | ||
1527 | i2c_del_driver(&wm9081_i2c_driver); | ||
1528 | } | ||
1529 | module_exit(wm9081_exit); | ||
1530 | |||
1531 | |||
1532 | MODULE_DESCRIPTION("ASoC WM9081 driver"); | ||
1533 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | ||
1534 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/wm9081.h b/sound/soc/codecs/wm9081.h new file mode 100644 index 000000000000..42d3bc757021 --- /dev/null +++ b/sound/soc/codecs/wm9081.h | |||
@@ -0,0 +1,787 @@ | |||
1 | #ifndef WM9081_H | ||
2 | #define WM9081_H | ||
3 | |||
4 | /* | ||
5 | * wm9081.c -- WM9081 ALSA SoC Audio driver | ||
6 | * | ||
7 | * Author: Mark Brown | ||
8 | * | ||
9 | * Copyright 2009 Wolfson Microelectronics plc | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #include <sound/soc.h> | ||
17 | |||
18 | extern struct snd_soc_dai wm9081_dai; | ||
19 | extern struct snd_soc_codec_device soc_codec_dev_wm9081; | ||
20 | |||
21 | /* | ||
22 | * SYSCLK sources | ||
23 | */ | ||
24 | #define WM9081_SYSCLK_MCLK 1 /* Use MCLK without FLL */ | ||
25 | #define WM9081_SYSCLK_FLL_MCLK 2 /* Use MCLK, enabling FLL if required */ | ||
26 | |||
27 | /* | ||
28 | * Register values. | ||
29 | */ | ||
30 | #define WM9081_SOFTWARE_RESET 0x00 | ||
31 | #define WM9081_ANALOGUE_LINEOUT 0x02 | ||
32 | #define WM9081_ANALOGUE_SPEAKER_PGA 0x03 | ||
33 | #define WM9081_VMID_CONTROL 0x04 | ||
34 | #define WM9081_BIAS_CONTROL_1 0x05 | ||
35 | #define WM9081_ANALOGUE_MIXER 0x07 | ||
36 | #define WM9081_ANTI_POP_CONTROL 0x08 | ||
37 | #define WM9081_ANALOGUE_SPEAKER_1 0x09 | ||
38 | #define WM9081_ANALOGUE_SPEAKER_2 0x0A | ||
39 | #define WM9081_POWER_MANAGEMENT 0x0B | ||
40 | #define WM9081_CLOCK_CONTROL_1 0x0C | ||
41 | #define WM9081_CLOCK_CONTROL_2 0x0D | ||
42 | #define WM9081_CLOCK_CONTROL_3 0x0E | ||
43 | #define WM9081_FLL_CONTROL_1 0x10 | ||
44 | #define WM9081_FLL_CONTROL_2 0x11 | ||
45 | #define WM9081_FLL_CONTROL_3 0x12 | ||
46 | #define WM9081_FLL_CONTROL_4 0x13 | ||
47 | #define WM9081_FLL_CONTROL_5 0x14 | ||
48 | #define WM9081_AUDIO_INTERFACE_1 0x16 | ||
49 | #define WM9081_AUDIO_INTERFACE_2 0x17 | ||
50 | #define WM9081_AUDIO_INTERFACE_3 0x18 | ||
51 | #define WM9081_AUDIO_INTERFACE_4 0x19 | ||
52 | #define WM9081_INTERRUPT_STATUS 0x1A | ||
53 | #define WM9081_INTERRUPT_STATUS_MASK 0x1B | ||
54 | #define WM9081_INTERRUPT_POLARITY 0x1C | ||
55 | #define WM9081_INTERRUPT_CONTROL 0x1D | ||
56 | #define WM9081_DAC_DIGITAL_1 0x1E | ||
57 | #define WM9081_DAC_DIGITAL_2 0x1F | ||
58 | #define WM9081_DRC_1 0x20 | ||
59 | #define WM9081_DRC_2 0x21 | ||
60 | #define WM9081_DRC_3 0x22 | ||
61 | #define WM9081_DRC_4 0x23 | ||
62 | #define WM9081_WRITE_SEQUENCER_1 0x26 | ||
63 | #define WM9081_WRITE_SEQUENCER_2 0x27 | ||
64 | #define WM9081_MW_SLAVE_1 0x28 | ||
65 | #define WM9081_EQ_1 0x2A | ||
66 | #define WM9081_EQ_2 0x2B | ||
67 | #define WM9081_EQ_3 0x2C | ||
68 | #define WM9081_EQ_4 0x2D | ||
69 | #define WM9081_EQ_5 0x2E | ||
70 | #define WM9081_EQ_6 0x2F | ||
71 | #define WM9081_EQ_7 0x30 | ||
72 | #define WM9081_EQ_8 0x31 | ||
73 | #define WM9081_EQ_9 0x32 | ||
74 | #define WM9081_EQ_10 0x33 | ||
75 | #define WM9081_EQ_11 0x34 | ||
76 | #define WM9081_EQ_12 0x35 | ||
77 | #define WM9081_EQ_13 0x36 | ||
78 | #define WM9081_EQ_14 0x37 | ||
79 | #define WM9081_EQ_15 0x38 | ||
80 | #define WM9081_EQ_16 0x39 | ||
81 | #define WM9081_EQ_17 0x3A | ||
82 | #define WM9081_EQ_18 0x3B | ||
83 | #define WM9081_EQ_19 0x3C | ||
84 | #define WM9081_EQ_20 0x3D | ||
85 | |||
86 | #define WM9081_REGISTER_COUNT 55 | ||
87 | #define WM9081_MAX_REGISTER 0x3D | ||
88 | |||
89 | /* | ||
90 | * Field Definitions. | ||
91 | */ | ||
92 | |||
93 | /* | ||
94 | * R0 (0x00) - Software Reset | ||
95 | */ | ||
96 | #define WM9081_SW_RST_DEV_ID1_MASK 0xFFFF /* SW_RST_DEV_ID1 - [15:0] */ | ||
97 | #define WM9081_SW_RST_DEV_ID1_SHIFT 0 /* SW_RST_DEV_ID1 - [15:0] */ | ||
98 | #define WM9081_SW_RST_DEV_ID1_WIDTH 16 /* SW_RST_DEV_ID1 - [15:0] */ | ||
99 | |||
100 | /* | ||
101 | * R2 (0x02) - Analogue Lineout | ||
102 | */ | ||
103 | #define WM9081_LINEOUT_MUTE 0x0080 /* LINEOUT_MUTE */ | ||
104 | #define WM9081_LINEOUT_MUTE_MASK 0x0080 /* LINEOUT_MUTE */ | ||
105 | #define WM9081_LINEOUT_MUTE_SHIFT 7 /* LINEOUT_MUTE */ | ||
106 | #define WM9081_LINEOUT_MUTE_WIDTH 1 /* LINEOUT_MUTE */ | ||
107 | #define WM9081_LINEOUTZC 0x0040 /* LINEOUTZC */ | ||
108 | #define WM9081_LINEOUTZC_MASK 0x0040 /* LINEOUTZC */ | ||
109 | #define WM9081_LINEOUTZC_SHIFT 6 /* LINEOUTZC */ | ||
110 | #define WM9081_LINEOUTZC_WIDTH 1 /* LINEOUTZC */ | ||
111 | #define WM9081_LINEOUT_VOL_MASK 0x003F /* LINEOUT_VOL - [5:0] */ | ||
112 | #define WM9081_LINEOUT_VOL_SHIFT 0 /* LINEOUT_VOL - [5:0] */ | ||
113 | #define WM9081_LINEOUT_VOL_WIDTH 6 /* LINEOUT_VOL - [5:0] */ | ||
114 | |||
115 | /* | ||
116 | * R3 (0x03) - Analogue Speaker PGA | ||
117 | */ | ||
118 | #define WM9081_SPKPGA_MUTE 0x0080 /* SPKPGA_MUTE */ | ||
119 | #define WM9081_SPKPGA_MUTE_MASK 0x0080 /* SPKPGA_MUTE */ | ||
120 | #define WM9081_SPKPGA_MUTE_SHIFT 7 /* SPKPGA_MUTE */ | ||
121 | #define WM9081_SPKPGA_MUTE_WIDTH 1 /* SPKPGA_MUTE */ | ||
122 | #define WM9081_SPKPGAZC 0x0040 /* SPKPGAZC */ | ||
123 | #define WM9081_SPKPGAZC_MASK 0x0040 /* SPKPGAZC */ | ||
124 | #define WM9081_SPKPGAZC_SHIFT 6 /* SPKPGAZC */ | ||
125 | #define WM9081_SPKPGAZC_WIDTH 1 /* SPKPGAZC */ | ||
126 | #define WM9081_SPKPGA_VOL_MASK 0x003F /* SPKPGA_VOL - [5:0] */ | ||
127 | #define WM9081_SPKPGA_VOL_SHIFT 0 /* SPKPGA_VOL - [5:0] */ | ||
128 | #define WM9081_SPKPGA_VOL_WIDTH 6 /* SPKPGA_VOL - [5:0] */ | ||
129 | |||
130 | /* | ||
131 | * R4 (0x04) - VMID Control | ||
132 | */ | ||
133 | #define WM9081_VMID_BUF_ENA 0x0020 /* VMID_BUF_ENA */ | ||
134 | #define WM9081_VMID_BUF_ENA_MASK 0x0020 /* VMID_BUF_ENA */ | ||
135 | #define WM9081_VMID_BUF_ENA_SHIFT 5 /* VMID_BUF_ENA */ | ||
136 | #define WM9081_VMID_BUF_ENA_WIDTH 1 /* VMID_BUF_ENA */ | ||
137 | #define WM9081_VMID_RAMP 0x0008 /* VMID_RAMP */ | ||
138 | #define WM9081_VMID_RAMP_MASK 0x0008 /* VMID_RAMP */ | ||
139 | #define WM9081_VMID_RAMP_SHIFT 3 /* VMID_RAMP */ | ||
140 | #define WM9081_VMID_RAMP_WIDTH 1 /* VMID_RAMP */ | ||
141 | #define WM9081_VMID_SEL_MASK 0x0006 /* VMID_SEL - [2:1] */ | ||
142 | #define WM9081_VMID_SEL_SHIFT 1 /* VMID_SEL - [2:1] */ | ||
143 | #define WM9081_VMID_SEL_WIDTH 2 /* VMID_SEL - [2:1] */ | ||
144 | #define WM9081_VMID_FAST_ST 0x0001 /* VMID_FAST_ST */ | ||
145 | #define WM9081_VMID_FAST_ST_MASK 0x0001 /* VMID_FAST_ST */ | ||
146 | #define WM9081_VMID_FAST_ST_SHIFT 0 /* VMID_FAST_ST */ | ||
147 | #define WM9081_VMID_FAST_ST_WIDTH 1 /* VMID_FAST_ST */ | ||
148 | |||
149 | /* | ||
150 | * R5 (0x05) - Bias Control 1 | ||
151 | */ | ||
152 | #define WM9081_BIAS_SRC 0x0040 /* BIAS_SRC */ | ||
153 | #define WM9081_BIAS_SRC_MASK 0x0040 /* BIAS_SRC */ | ||
154 | #define WM9081_BIAS_SRC_SHIFT 6 /* BIAS_SRC */ | ||
155 | #define WM9081_BIAS_SRC_WIDTH 1 /* BIAS_SRC */ | ||
156 | #define WM9081_STBY_BIAS_LVL 0x0020 /* STBY_BIAS_LVL */ | ||
157 | #define WM9081_STBY_BIAS_LVL_MASK 0x0020 /* STBY_BIAS_LVL */ | ||
158 | #define WM9081_STBY_BIAS_LVL_SHIFT 5 /* STBY_BIAS_LVL */ | ||
159 | #define WM9081_STBY_BIAS_LVL_WIDTH 1 /* STBY_BIAS_LVL */ | ||
160 | #define WM9081_STBY_BIAS_ENA 0x0010 /* STBY_BIAS_ENA */ | ||
161 | #define WM9081_STBY_BIAS_ENA_MASK 0x0010 /* STBY_BIAS_ENA */ | ||
162 | #define WM9081_STBY_BIAS_ENA_SHIFT 4 /* STBY_BIAS_ENA */ | ||
163 | #define WM9081_STBY_BIAS_ENA_WIDTH 1 /* STBY_BIAS_ENA */ | ||
164 | #define WM9081_BIAS_LVL_MASK 0x000C /* BIAS_LVL - [3:2] */ | ||
165 | #define WM9081_BIAS_LVL_SHIFT 2 /* BIAS_LVL - [3:2] */ | ||
166 | #define WM9081_BIAS_LVL_WIDTH 2 /* BIAS_LVL - [3:2] */ | ||
167 | #define WM9081_BIAS_ENA 0x0002 /* BIAS_ENA */ | ||
168 | #define WM9081_BIAS_ENA_MASK 0x0002 /* BIAS_ENA */ | ||
169 | #define WM9081_BIAS_ENA_SHIFT 1 /* BIAS_ENA */ | ||
170 | #define WM9081_BIAS_ENA_WIDTH 1 /* BIAS_ENA */ | ||
171 | #define WM9081_STARTUP_BIAS_ENA 0x0001 /* STARTUP_BIAS_ENA */ | ||
172 | #define WM9081_STARTUP_BIAS_ENA_MASK 0x0001 /* STARTUP_BIAS_ENA */ | ||
173 | #define WM9081_STARTUP_BIAS_ENA_SHIFT 0 /* STARTUP_BIAS_ENA */ | ||
174 | #define WM9081_STARTUP_BIAS_ENA_WIDTH 1 /* STARTUP_BIAS_ENA */ | ||
175 | |||
176 | /* | ||
177 | * R7 (0x07) - Analogue Mixer | ||
178 | */ | ||
179 | #define WM9081_DAC_SEL 0x0010 /* DAC_SEL */ | ||
180 | #define WM9081_DAC_SEL_MASK 0x0010 /* DAC_SEL */ | ||
181 | #define WM9081_DAC_SEL_SHIFT 4 /* DAC_SEL */ | ||
182 | #define WM9081_DAC_SEL_WIDTH 1 /* DAC_SEL */ | ||
183 | #define WM9081_IN2_VOL 0x0008 /* IN2_VOL */ | ||
184 | #define WM9081_IN2_VOL_MASK 0x0008 /* IN2_VOL */ | ||
185 | #define WM9081_IN2_VOL_SHIFT 3 /* IN2_VOL */ | ||
186 | #define WM9081_IN2_VOL_WIDTH 1 /* IN2_VOL */ | ||
187 | #define WM9081_IN2_ENA 0x0004 /* IN2_ENA */ | ||
188 | #define WM9081_IN2_ENA_MASK 0x0004 /* IN2_ENA */ | ||
189 | #define WM9081_IN2_ENA_SHIFT 2 /* IN2_ENA */ | ||
190 | #define WM9081_IN2_ENA_WIDTH 1 /* IN2_ENA */ | ||
191 | #define WM9081_IN1_VOL 0x0002 /* IN1_VOL */ | ||
192 | #define WM9081_IN1_VOL_MASK 0x0002 /* IN1_VOL */ | ||
193 | #define WM9081_IN1_VOL_SHIFT 1 /* IN1_VOL */ | ||
194 | #define WM9081_IN1_VOL_WIDTH 1 /* IN1_VOL */ | ||
195 | #define WM9081_IN1_ENA 0x0001 /* IN1_ENA */ | ||
196 | #define WM9081_IN1_ENA_MASK 0x0001 /* IN1_ENA */ | ||
197 | #define WM9081_IN1_ENA_SHIFT 0 /* IN1_ENA */ | ||
198 | #define WM9081_IN1_ENA_WIDTH 1 /* IN1_ENA */ | ||
199 | |||
200 | /* | ||
201 | * R8 (0x08) - Anti Pop Control | ||
202 | */ | ||
203 | #define WM9081_LINEOUT_DISCH 0x0004 /* LINEOUT_DISCH */ | ||
204 | #define WM9081_LINEOUT_DISCH_MASK 0x0004 /* LINEOUT_DISCH */ | ||
205 | #define WM9081_LINEOUT_DISCH_SHIFT 2 /* LINEOUT_DISCH */ | ||
206 | #define WM9081_LINEOUT_DISCH_WIDTH 1 /* LINEOUT_DISCH */ | ||
207 | #define WM9081_LINEOUT_VROI 0x0002 /* LINEOUT_VROI */ | ||
208 | #define WM9081_LINEOUT_VROI_MASK 0x0002 /* LINEOUT_VROI */ | ||
209 | #define WM9081_LINEOUT_VROI_SHIFT 1 /* LINEOUT_VROI */ | ||
210 | #define WM9081_LINEOUT_VROI_WIDTH 1 /* LINEOUT_VROI */ | ||
211 | #define WM9081_LINEOUT_CLAMP 0x0001 /* LINEOUT_CLAMP */ | ||
212 | #define WM9081_LINEOUT_CLAMP_MASK 0x0001 /* LINEOUT_CLAMP */ | ||
213 | #define WM9081_LINEOUT_CLAMP_SHIFT 0 /* LINEOUT_CLAMP */ | ||
214 | #define WM9081_LINEOUT_CLAMP_WIDTH 1 /* LINEOUT_CLAMP */ | ||
215 | |||
216 | /* | ||
217 | * R9 (0x09) - Analogue Speaker 1 | ||
218 | */ | ||
219 | #define WM9081_SPK_DCGAIN_MASK 0x0038 /* SPK_DCGAIN - [5:3] */ | ||
220 | #define WM9081_SPK_DCGAIN_SHIFT 3 /* SPK_DCGAIN - [5:3] */ | ||
221 | #define WM9081_SPK_DCGAIN_WIDTH 3 /* SPK_DCGAIN - [5:3] */ | ||
222 | #define WM9081_SPK_ACGAIN_MASK 0x0007 /* SPK_ACGAIN - [2:0] */ | ||
223 | #define WM9081_SPK_ACGAIN_SHIFT 0 /* SPK_ACGAIN - [2:0] */ | ||
224 | #define WM9081_SPK_ACGAIN_WIDTH 3 /* SPK_ACGAIN - [2:0] */ | ||
225 | |||
226 | /* | ||
227 | * R10 (0x0A) - Analogue Speaker 2 | ||
228 | */ | ||
229 | #define WM9081_SPK_MODE 0x0040 /* SPK_MODE */ | ||
230 | #define WM9081_SPK_MODE_MASK 0x0040 /* SPK_MODE */ | ||
231 | #define WM9081_SPK_MODE_SHIFT 6 /* SPK_MODE */ | ||
232 | #define WM9081_SPK_MODE_WIDTH 1 /* SPK_MODE */ | ||
233 | #define WM9081_SPK_INV_MUTE 0x0010 /* SPK_INV_MUTE */ | ||
234 | #define WM9081_SPK_INV_MUTE_MASK 0x0010 /* SPK_INV_MUTE */ | ||
235 | #define WM9081_SPK_INV_MUTE_SHIFT 4 /* SPK_INV_MUTE */ | ||
236 | #define WM9081_SPK_INV_MUTE_WIDTH 1 /* SPK_INV_MUTE */ | ||
237 | #define WM9081_OUT_SPK_CTRL 0x0008 /* OUT_SPK_CTRL */ | ||
238 | #define WM9081_OUT_SPK_CTRL_MASK 0x0008 /* OUT_SPK_CTRL */ | ||
239 | #define WM9081_OUT_SPK_CTRL_SHIFT 3 /* OUT_SPK_CTRL */ | ||
240 | #define WM9081_OUT_SPK_CTRL_WIDTH 1 /* OUT_SPK_CTRL */ | ||
241 | |||
242 | /* | ||
243 | * R11 (0x0B) - Power Management | ||
244 | */ | ||
245 | #define WM9081_TSHUT_ENA 0x0100 /* TSHUT_ENA */ | ||
246 | #define WM9081_TSHUT_ENA_MASK 0x0100 /* TSHUT_ENA */ | ||
247 | #define WM9081_TSHUT_ENA_SHIFT 8 /* TSHUT_ENA */ | ||
248 | #define WM9081_TSHUT_ENA_WIDTH 1 /* TSHUT_ENA */ | ||
249 | #define WM9081_TSENSE_ENA 0x0080 /* TSENSE_ENA */ | ||
250 | #define WM9081_TSENSE_ENA_MASK 0x0080 /* TSENSE_ENA */ | ||
251 | #define WM9081_TSENSE_ENA_SHIFT 7 /* TSENSE_ENA */ | ||
252 | #define WM9081_TSENSE_ENA_WIDTH 1 /* TSENSE_ENA */ | ||
253 | #define WM9081_TEMP_SHUT 0x0040 /* TEMP_SHUT */ | ||
254 | #define WM9081_TEMP_SHUT_MASK 0x0040 /* TEMP_SHUT */ | ||
255 | #define WM9081_TEMP_SHUT_SHIFT 6 /* TEMP_SHUT */ | ||
256 | #define WM9081_TEMP_SHUT_WIDTH 1 /* TEMP_SHUT */ | ||
257 | #define WM9081_LINEOUT_ENA 0x0010 /* LINEOUT_ENA */ | ||
258 | #define WM9081_LINEOUT_ENA_MASK 0x0010 /* LINEOUT_ENA */ | ||
259 | #define WM9081_LINEOUT_ENA_SHIFT 4 /* LINEOUT_ENA */ | ||
260 | #define WM9081_LINEOUT_ENA_WIDTH 1 /* LINEOUT_ENA */ | ||
261 | #define WM9081_SPKPGA_ENA 0x0004 /* SPKPGA_ENA */ | ||
262 | #define WM9081_SPKPGA_ENA_MASK 0x0004 /* SPKPGA_ENA */ | ||
263 | #define WM9081_SPKPGA_ENA_SHIFT 2 /* SPKPGA_ENA */ | ||
264 | #define WM9081_SPKPGA_ENA_WIDTH 1 /* SPKPGA_ENA */ | ||
265 | #define WM9081_SPK_ENA 0x0002 /* SPK_ENA */ | ||
266 | #define WM9081_SPK_ENA_MASK 0x0002 /* SPK_ENA */ | ||
267 | #define WM9081_SPK_ENA_SHIFT 1 /* SPK_ENA */ | ||
268 | #define WM9081_SPK_ENA_WIDTH 1 /* SPK_ENA */ | ||
269 | #define WM9081_DAC_ENA 0x0001 /* DAC_ENA */ | ||
270 | #define WM9081_DAC_ENA_MASK 0x0001 /* DAC_ENA */ | ||
271 | #define WM9081_DAC_ENA_SHIFT 0 /* DAC_ENA */ | ||
272 | #define WM9081_DAC_ENA_WIDTH 1 /* DAC_ENA */ | ||
273 | |||
274 | /* | ||
275 | * R12 (0x0C) - Clock Control 1 | ||
276 | */ | ||
277 | #define WM9081_CLK_OP_DIV_MASK 0x1C00 /* CLK_OP_DIV - [12:10] */ | ||
278 | #define WM9081_CLK_OP_DIV_SHIFT 10 /* CLK_OP_DIV - [12:10] */ | ||
279 | #define WM9081_CLK_OP_DIV_WIDTH 3 /* CLK_OP_DIV - [12:10] */ | ||
280 | #define WM9081_CLK_TO_DIV_MASK 0x0300 /* CLK_TO_DIV - [9:8] */ | ||
281 | #define WM9081_CLK_TO_DIV_SHIFT 8 /* CLK_TO_DIV - [9:8] */ | ||
282 | #define WM9081_CLK_TO_DIV_WIDTH 2 /* CLK_TO_DIV - [9:8] */ | ||
283 | #define WM9081_MCLKDIV2 0x0080 /* MCLKDIV2 */ | ||
284 | #define WM9081_MCLKDIV2_MASK 0x0080 /* MCLKDIV2 */ | ||
285 | #define WM9081_MCLKDIV2_SHIFT 7 /* MCLKDIV2 */ | ||
286 | #define WM9081_MCLKDIV2_WIDTH 1 /* MCLKDIV2 */ | ||
287 | |||
288 | /* | ||
289 | * R13 (0x0D) - Clock Control 2 | ||
290 | */ | ||
291 | #define WM9081_CLK_SYS_RATE_MASK 0x00F0 /* CLK_SYS_RATE - [7:4] */ | ||
292 | #define WM9081_CLK_SYS_RATE_SHIFT 4 /* CLK_SYS_RATE - [7:4] */ | ||
293 | #define WM9081_CLK_SYS_RATE_WIDTH 4 /* CLK_SYS_RATE - [7:4] */ | ||
294 | #define WM9081_SAMPLE_RATE_MASK 0x000F /* SAMPLE_RATE - [3:0] */ | ||
295 | #define WM9081_SAMPLE_RATE_SHIFT 0 /* SAMPLE_RATE - [3:0] */ | ||
296 | #define WM9081_SAMPLE_RATE_WIDTH 4 /* SAMPLE_RATE - [3:0] */ | ||
297 | |||
298 | /* | ||
299 | * R14 (0x0E) - Clock Control 3 | ||
300 | */ | ||
301 | #define WM9081_CLK_SRC_SEL 0x2000 /* CLK_SRC_SEL */ | ||
302 | #define WM9081_CLK_SRC_SEL_MASK 0x2000 /* CLK_SRC_SEL */ | ||
303 | #define WM9081_CLK_SRC_SEL_SHIFT 13 /* CLK_SRC_SEL */ | ||
304 | #define WM9081_CLK_SRC_SEL_WIDTH 1 /* CLK_SRC_SEL */ | ||
305 | #define WM9081_CLK_OP_ENA 0x0020 /* CLK_OP_ENA */ | ||
306 | #define WM9081_CLK_OP_ENA_MASK 0x0020 /* CLK_OP_ENA */ | ||
307 | #define WM9081_CLK_OP_ENA_SHIFT 5 /* CLK_OP_ENA */ | ||
308 | #define WM9081_CLK_OP_ENA_WIDTH 1 /* CLK_OP_ENA */ | ||
309 | #define WM9081_CLK_TO_ENA 0x0004 /* CLK_TO_ENA */ | ||
310 | #define WM9081_CLK_TO_ENA_MASK 0x0004 /* CLK_TO_ENA */ | ||
311 | #define WM9081_CLK_TO_ENA_SHIFT 2 /* CLK_TO_ENA */ | ||
312 | #define WM9081_CLK_TO_ENA_WIDTH 1 /* CLK_TO_ENA */ | ||
313 | #define WM9081_CLK_DSP_ENA 0x0002 /* CLK_DSP_ENA */ | ||
314 | #define WM9081_CLK_DSP_ENA_MASK 0x0002 /* CLK_DSP_ENA */ | ||
315 | #define WM9081_CLK_DSP_ENA_SHIFT 1 /* CLK_DSP_ENA */ | ||
316 | #define WM9081_CLK_DSP_ENA_WIDTH 1 /* CLK_DSP_ENA */ | ||
317 | #define WM9081_CLK_SYS_ENA 0x0001 /* CLK_SYS_ENA */ | ||
318 | #define WM9081_CLK_SYS_ENA_MASK 0x0001 /* CLK_SYS_ENA */ | ||
319 | #define WM9081_CLK_SYS_ENA_SHIFT 0 /* CLK_SYS_ENA */ | ||
320 | #define WM9081_CLK_SYS_ENA_WIDTH 1 /* CLK_SYS_ENA */ | ||
321 | |||
322 | /* | ||
323 | * R16 (0x10) - FLL Control 1 | ||
324 | */ | ||
325 | #define WM9081_FLL_HOLD 0x0008 /* FLL_HOLD */ | ||
326 | #define WM9081_FLL_HOLD_MASK 0x0008 /* FLL_HOLD */ | ||
327 | #define WM9081_FLL_HOLD_SHIFT 3 /* FLL_HOLD */ | ||
328 | #define WM9081_FLL_HOLD_WIDTH 1 /* FLL_HOLD */ | ||
329 | #define WM9081_FLL_FRAC 0x0004 /* FLL_FRAC */ | ||
330 | #define WM9081_FLL_FRAC_MASK 0x0004 /* FLL_FRAC */ | ||
331 | #define WM9081_FLL_FRAC_SHIFT 2 /* FLL_FRAC */ | ||
332 | #define WM9081_FLL_FRAC_WIDTH 1 /* FLL_FRAC */ | ||
333 | #define WM9081_FLL_ENA 0x0001 /* FLL_ENA */ | ||
334 | #define WM9081_FLL_ENA_MASK 0x0001 /* FLL_ENA */ | ||
335 | #define WM9081_FLL_ENA_SHIFT 0 /* FLL_ENA */ | ||
336 | #define WM9081_FLL_ENA_WIDTH 1 /* FLL_ENA */ | ||
337 | |||
338 | /* | ||
339 | * R17 (0x11) - FLL Control 2 | ||
340 | */ | ||
341 | #define WM9081_FLL_OUTDIV_MASK 0x0700 /* FLL_OUTDIV - [10:8] */ | ||
342 | #define WM9081_FLL_OUTDIV_SHIFT 8 /* FLL_OUTDIV - [10:8] */ | ||
343 | #define WM9081_FLL_OUTDIV_WIDTH 3 /* FLL_OUTDIV - [10:8] */ | ||
344 | #define WM9081_FLL_CTRL_RATE_MASK 0x0070 /* FLL_CTRL_RATE - [6:4] */ | ||
345 | #define WM9081_FLL_CTRL_RATE_SHIFT 4 /* FLL_CTRL_RATE - [6:4] */ | ||
346 | #define WM9081_FLL_CTRL_RATE_WIDTH 3 /* FLL_CTRL_RATE - [6:4] */ | ||
347 | #define WM9081_FLL_FRATIO_MASK 0x0007 /* FLL_FRATIO - [2:0] */ | ||
348 | #define WM9081_FLL_FRATIO_SHIFT 0 /* FLL_FRATIO - [2:0] */ | ||
349 | #define WM9081_FLL_FRATIO_WIDTH 3 /* FLL_FRATIO - [2:0] */ | ||
350 | |||
351 | /* | ||
352 | * R18 (0x12) - FLL Control 3 | ||
353 | */ | ||
354 | #define WM9081_FLL_K_MASK 0xFFFF /* FLL_K - [15:0] */ | ||
355 | #define WM9081_FLL_K_SHIFT 0 /* FLL_K - [15:0] */ | ||
356 | #define WM9081_FLL_K_WIDTH 16 /* FLL_K - [15:0] */ | ||
357 | |||
358 | /* | ||
359 | * R19 (0x13) - FLL Control 4 | ||
360 | */ | ||
361 | #define WM9081_FLL_N_MASK 0x7FE0 /* FLL_N - [14:5] */ | ||
362 | #define WM9081_FLL_N_SHIFT 5 /* FLL_N - [14:5] */ | ||
363 | #define WM9081_FLL_N_WIDTH 10 /* FLL_N - [14:5] */ | ||
364 | #define WM9081_FLL_GAIN_MASK 0x000F /* FLL_GAIN - [3:0] */ | ||
365 | #define WM9081_FLL_GAIN_SHIFT 0 /* FLL_GAIN - [3:0] */ | ||
366 | #define WM9081_FLL_GAIN_WIDTH 4 /* FLL_GAIN - [3:0] */ | ||
367 | |||
368 | /* | ||
369 | * R20 (0x14) - FLL Control 5 | ||
370 | */ | ||
371 | #define WM9081_FLL_CLK_REF_DIV_MASK 0x0018 /* FLL_CLK_REF_DIV - [4:3] */ | ||
372 | #define WM9081_FLL_CLK_REF_DIV_SHIFT 3 /* FLL_CLK_REF_DIV - [4:3] */ | ||
373 | #define WM9081_FLL_CLK_REF_DIV_WIDTH 2 /* FLL_CLK_REF_DIV - [4:3] */ | ||
374 | #define WM9081_FLL_CLK_SRC_MASK 0x0003 /* FLL_CLK_SRC - [1:0] */ | ||
375 | #define WM9081_FLL_CLK_SRC_SHIFT 0 /* FLL_CLK_SRC - [1:0] */ | ||
376 | #define WM9081_FLL_CLK_SRC_WIDTH 2 /* FLL_CLK_SRC - [1:0] */ | ||
377 | |||
378 | /* | ||
379 | * R22 (0x16) - Audio Interface 1 | ||
380 | */ | ||
381 | #define WM9081_AIFDAC_CHAN 0x0040 /* AIFDAC_CHAN */ | ||
382 | #define WM9081_AIFDAC_CHAN_MASK 0x0040 /* AIFDAC_CHAN */ | ||
383 | #define WM9081_AIFDAC_CHAN_SHIFT 6 /* AIFDAC_CHAN */ | ||
384 | #define WM9081_AIFDAC_CHAN_WIDTH 1 /* AIFDAC_CHAN */ | ||
385 | #define WM9081_AIFDAC_TDM_SLOT_MASK 0x0030 /* AIFDAC_TDM_SLOT - [5:4] */ | ||
386 | #define WM9081_AIFDAC_TDM_SLOT_SHIFT 4 /* AIFDAC_TDM_SLOT - [5:4] */ | ||
387 | #define WM9081_AIFDAC_TDM_SLOT_WIDTH 2 /* AIFDAC_TDM_SLOT - [5:4] */ | ||
388 | #define WM9081_AIFDAC_TDM_MODE_MASK 0x000C /* AIFDAC_TDM_MODE - [3:2] */ | ||
389 | #define WM9081_AIFDAC_TDM_MODE_SHIFT 2 /* AIFDAC_TDM_MODE - [3:2] */ | ||
390 | #define WM9081_AIFDAC_TDM_MODE_WIDTH 2 /* AIFDAC_TDM_MODE - [3:2] */ | ||
391 | #define WM9081_DAC_COMP 0x0002 /* DAC_COMP */ | ||
392 | #define WM9081_DAC_COMP_MASK 0x0002 /* DAC_COMP */ | ||
393 | #define WM9081_DAC_COMP_SHIFT 1 /* DAC_COMP */ | ||
394 | #define WM9081_DAC_COMP_WIDTH 1 /* DAC_COMP */ | ||
395 | #define WM9081_DAC_COMPMODE 0x0001 /* DAC_COMPMODE */ | ||
396 | #define WM9081_DAC_COMPMODE_MASK 0x0001 /* DAC_COMPMODE */ | ||
397 | #define WM9081_DAC_COMPMODE_SHIFT 0 /* DAC_COMPMODE */ | ||
398 | #define WM9081_DAC_COMPMODE_WIDTH 1 /* DAC_COMPMODE */ | ||
399 | |||
400 | /* | ||
401 | * R23 (0x17) - Audio Interface 2 | ||
402 | */ | ||
403 | #define WM9081_AIF_TRIS 0x0200 /* AIF_TRIS */ | ||
404 | #define WM9081_AIF_TRIS_MASK 0x0200 /* AIF_TRIS */ | ||
405 | #define WM9081_AIF_TRIS_SHIFT 9 /* AIF_TRIS */ | ||
406 | #define WM9081_AIF_TRIS_WIDTH 1 /* AIF_TRIS */ | ||
407 | #define WM9081_DAC_DAT_INV 0x0100 /* DAC_DAT_INV */ | ||
408 | #define WM9081_DAC_DAT_INV_MASK 0x0100 /* DAC_DAT_INV */ | ||
409 | #define WM9081_DAC_DAT_INV_SHIFT 8 /* DAC_DAT_INV */ | ||
410 | #define WM9081_DAC_DAT_INV_WIDTH 1 /* DAC_DAT_INV */ | ||
411 | #define WM9081_AIF_BCLK_INV 0x0080 /* AIF_BCLK_INV */ | ||
412 | #define WM9081_AIF_BCLK_INV_MASK 0x0080 /* AIF_BCLK_INV */ | ||
413 | #define WM9081_AIF_BCLK_INV_SHIFT 7 /* AIF_BCLK_INV */ | ||
414 | #define WM9081_AIF_BCLK_INV_WIDTH 1 /* AIF_BCLK_INV */ | ||
415 | #define WM9081_BCLK_DIR 0x0040 /* BCLK_DIR */ | ||
416 | #define WM9081_BCLK_DIR_MASK 0x0040 /* BCLK_DIR */ | ||
417 | #define WM9081_BCLK_DIR_SHIFT 6 /* BCLK_DIR */ | ||
418 | #define WM9081_BCLK_DIR_WIDTH 1 /* BCLK_DIR */ | ||
419 | #define WM9081_LRCLK_DIR 0x0020 /* LRCLK_DIR */ | ||
420 | #define WM9081_LRCLK_DIR_MASK 0x0020 /* LRCLK_DIR */ | ||
421 | #define WM9081_LRCLK_DIR_SHIFT 5 /* LRCLK_DIR */ | ||
422 | #define WM9081_LRCLK_DIR_WIDTH 1 /* LRCLK_DIR */ | ||
423 | #define WM9081_AIF_LRCLK_INV 0x0010 /* AIF_LRCLK_INV */ | ||
424 | #define WM9081_AIF_LRCLK_INV_MASK 0x0010 /* AIF_LRCLK_INV */ | ||
425 | #define WM9081_AIF_LRCLK_INV_SHIFT 4 /* AIF_LRCLK_INV */ | ||
426 | #define WM9081_AIF_LRCLK_INV_WIDTH 1 /* AIF_LRCLK_INV */ | ||
427 | #define WM9081_AIF_WL_MASK 0x000C /* AIF_WL - [3:2] */ | ||
428 | #define WM9081_AIF_WL_SHIFT 2 /* AIF_WL - [3:2] */ | ||
429 | #define WM9081_AIF_WL_WIDTH 2 /* AIF_WL - [3:2] */ | ||
430 | #define WM9081_AIF_FMT_MASK 0x0003 /* AIF_FMT - [1:0] */ | ||
431 | #define WM9081_AIF_FMT_SHIFT 0 /* AIF_FMT - [1:0] */ | ||
432 | #define WM9081_AIF_FMT_WIDTH 2 /* AIF_FMT - [1:0] */ | ||
433 | |||
434 | /* | ||
435 | * R24 (0x18) - Audio Interface 3 | ||
436 | */ | ||
437 | #define WM9081_BCLK_DIV_MASK 0x001F /* BCLK_DIV - [4:0] */ | ||
438 | #define WM9081_BCLK_DIV_SHIFT 0 /* BCLK_DIV - [4:0] */ | ||
439 | #define WM9081_BCLK_DIV_WIDTH 5 /* BCLK_DIV - [4:0] */ | ||
440 | |||
441 | /* | ||
442 | * R25 (0x19) - Audio Interface 4 | ||
443 | */ | ||
444 | #define WM9081_LRCLK_RATE_MASK 0x07FF /* LRCLK_RATE - [10:0] */ | ||
445 | #define WM9081_LRCLK_RATE_SHIFT 0 /* LRCLK_RATE - [10:0] */ | ||
446 | #define WM9081_LRCLK_RATE_WIDTH 11 /* LRCLK_RATE - [10:0] */ | ||
447 | |||
448 | /* | ||
449 | * R26 (0x1A) - Interrupt Status | ||
450 | */ | ||
451 | #define WM9081_WSEQ_BUSY_EINT 0x0004 /* WSEQ_BUSY_EINT */ | ||
452 | #define WM9081_WSEQ_BUSY_EINT_MASK 0x0004 /* WSEQ_BUSY_EINT */ | ||
453 | #define WM9081_WSEQ_BUSY_EINT_SHIFT 2 /* WSEQ_BUSY_EINT */ | ||
454 | #define WM9081_WSEQ_BUSY_EINT_WIDTH 1 /* WSEQ_BUSY_EINT */ | ||
455 | #define WM9081_TSHUT_EINT 0x0001 /* TSHUT_EINT */ | ||
456 | #define WM9081_TSHUT_EINT_MASK 0x0001 /* TSHUT_EINT */ | ||
457 | #define WM9081_TSHUT_EINT_SHIFT 0 /* TSHUT_EINT */ | ||
458 | #define WM9081_TSHUT_EINT_WIDTH 1 /* TSHUT_EINT */ | ||
459 | |||
460 | /* | ||
461 | * R27 (0x1B) - Interrupt Status Mask | ||
462 | */ | ||
463 | #define WM9081_IM_WSEQ_BUSY_EINT 0x0004 /* IM_WSEQ_BUSY_EINT */ | ||
464 | #define WM9081_IM_WSEQ_BUSY_EINT_MASK 0x0004 /* IM_WSEQ_BUSY_EINT */ | ||
465 | #define WM9081_IM_WSEQ_BUSY_EINT_SHIFT 2 /* IM_WSEQ_BUSY_EINT */ | ||
466 | #define WM9081_IM_WSEQ_BUSY_EINT_WIDTH 1 /* IM_WSEQ_BUSY_EINT */ | ||
467 | #define WM9081_IM_TSHUT_EINT 0x0001 /* IM_TSHUT_EINT */ | ||
468 | #define WM9081_IM_TSHUT_EINT_MASK 0x0001 /* IM_TSHUT_EINT */ | ||
469 | #define WM9081_IM_TSHUT_EINT_SHIFT 0 /* IM_TSHUT_EINT */ | ||
470 | #define WM9081_IM_TSHUT_EINT_WIDTH 1 /* IM_TSHUT_EINT */ | ||
471 | |||
472 | /* | ||
473 | * R28 (0x1C) - Interrupt Polarity | ||
474 | */ | ||
475 | #define WM9081_TSHUT_INV 0x0001 /* TSHUT_INV */ | ||
476 | #define WM9081_TSHUT_INV_MASK 0x0001 /* TSHUT_INV */ | ||
477 | #define WM9081_TSHUT_INV_SHIFT 0 /* TSHUT_INV */ | ||
478 | #define WM9081_TSHUT_INV_WIDTH 1 /* TSHUT_INV */ | ||
479 | |||
480 | /* | ||
481 | * R29 (0x1D) - Interrupt Control | ||
482 | */ | ||
483 | #define WM9081_IRQ_POL 0x8000 /* IRQ_POL */ | ||
484 | #define WM9081_IRQ_POL_MASK 0x8000 /* IRQ_POL */ | ||
485 | #define WM9081_IRQ_POL_SHIFT 15 /* IRQ_POL */ | ||
486 | #define WM9081_IRQ_POL_WIDTH 1 /* IRQ_POL */ | ||
487 | #define WM9081_IRQ_OP_CTRL 0x0001 /* IRQ_OP_CTRL */ | ||
488 | #define WM9081_IRQ_OP_CTRL_MASK 0x0001 /* IRQ_OP_CTRL */ | ||
489 | #define WM9081_IRQ_OP_CTRL_SHIFT 0 /* IRQ_OP_CTRL */ | ||
490 | #define WM9081_IRQ_OP_CTRL_WIDTH 1 /* IRQ_OP_CTRL */ | ||
491 | |||
492 | /* | ||
493 | * R30 (0x1E) - DAC Digital 1 | ||
494 | */ | ||
495 | #define WM9081_DAC_VOL_MASK 0x00FF /* DAC_VOL - [7:0] */ | ||
496 | #define WM9081_DAC_VOL_SHIFT 0 /* DAC_VOL - [7:0] */ | ||
497 | #define WM9081_DAC_VOL_WIDTH 8 /* DAC_VOL - [7:0] */ | ||
498 | |||
499 | /* | ||
500 | * R31 (0x1F) - DAC Digital 2 | ||
501 | */ | ||
502 | #define WM9081_DAC_MUTERATE 0x0400 /* DAC_MUTERATE */ | ||
503 | #define WM9081_DAC_MUTERATE_MASK 0x0400 /* DAC_MUTERATE */ | ||
504 | #define WM9081_DAC_MUTERATE_SHIFT 10 /* DAC_MUTERATE */ | ||
505 | #define WM9081_DAC_MUTERATE_WIDTH 1 /* DAC_MUTERATE */ | ||
506 | #define WM9081_DAC_MUTEMODE 0x0200 /* DAC_MUTEMODE */ | ||
507 | #define WM9081_DAC_MUTEMODE_MASK 0x0200 /* DAC_MUTEMODE */ | ||
508 | #define WM9081_DAC_MUTEMODE_SHIFT 9 /* DAC_MUTEMODE */ | ||
509 | #define WM9081_DAC_MUTEMODE_WIDTH 1 /* DAC_MUTEMODE */ | ||
510 | #define WM9081_DAC_MUTE 0x0008 /* DAC_MUTE */ | ||
511 | #define WM9081_DAC_MUTE_MASK 0x0008 /* DAC_MUTE */ | ||
512 | #define WM9081_DAC_MUTE_SHIFT 3 /* DAC_MUTE */ | ||
513 | #define WM9081_DAC_MUTE_WIDTH 1 /* DAC_MUTE */ | ||
514 | #define WM9081_DEEMPH_MASK 0x0006 /* DEEMPH - [2:1] */ | ||
515 | #define WM9081_DEEMPH_SHIFT 1 /* DEEMPH - [2:1] */ | ||
516 | #define WM9081_DEEMPH_WIDTH 2 /* DEEMPH - [2:1] */ | ||
517 | |||
518 | /* | ||
519 | * R32 (0x20) - DRC 1 | ||
520 | */ | ||
521 | #define WM9081_DRC_ENA 0x8000 /* DRC_ENA */ | ||
522 | #define WM9081_DRC_ENA_MASK 0x8000 /* DRC_ENA */ | ||
523 | #define WM9081_DRC_ENA_SHIFT 15 /* DRC_ENA */ | ||
524 | #define WM9081_DRC_ENA_WIDTH 1 /* DRC_ENA */ | ||
525 | #define WM9081_DRC_STARTUP_GAIN_MASK 0x07C0 /* DRC_STARTUP_GAIN - [10:6] */ | ||
526 | #define WM9081_DRC_STARTUP_GAIN_SHIFT 6 /* DRC_STARTUP_GAIN - [10:6] */ | ||
527 | #define WM9081_DRC_STARTUP_GAIN_WIDTH 5 /* DRC_STARTUP_GAIN - [10:6] */ | ||
528 | #define WM9081_DRC_FF_DLY 0x0020 /* DRC_FF_DLY */ | ||
529 | #define WM9081_DRC_FF_DLY_MASK 0x0020 /* DRC_FF_DLY */ | ||
530 | #define WM9081_DRC_FF_DLY_SHIFT 5 /* DRC_FF_DLY */ | ||
531 | #define WM9081_DRC_FF_DLY_WIDTH 1 /* DRC_FF_DLY */ | ||
532 | #define WM9081_DRC_QR 0x0004 /* DRC_QR */ | ||
533 | #define WM9081_DRC_QR_MASK 0x0004 /* DRC_QR */ | ||
534 | #define WM9081_DRC_QR_SHIFT 2 /* DRC_QR */ | ||
535 | #define WM9081_DRC_QR_WIDTH 1 /* DRC_QR */ | ||
536 | #define WM9081_DRC_ANTICLIP 0x0002 /* DRC_ANTICLIP */ | ||
537 | #define WM9081_DRC_ANTICLIP_MASK 0x0002 /* DRC_ANTICLIP */ | ||
538 | #define WM9081_DRC_ANTICLIP_SHIFT 1 /* DRC_ANTICLIP */ | ||
539 | #define WM9081_DRC_ANTICLIP_WIDTH 1 /* DRC_ANTICLIP */ | ||
540 | |||
541 | /* | ||
542 | * R33 (0x21) - DRC 2 | ||
543 | */ | ||
544 | #define WM9081_DRC_ATK_MASK 0xF000 /* DRC_ATK - [15:12] */ | ||
545 | #define WM9081_DRC_ATK_SHIFT 12 /* DRC_ATK - [15:12] */ | ||
546 | #define WM9081_DRC_ATK_WIDTH 4 /* DRC_ATK - [15:12] */ | ||
547 | #define WM9081_DRC_DCY_MASK 0x0F00 /* DRC_DCY - [11:8] */ | ||
548 | #define WM9081_DRC_DCY_SHIFT 8 /* DRC_DCY - [11:8] */ | ||
549 | #define WM9081_DRC_DCY_WIDTH 4 /* DRC_DCY - [11:8] */ | ||
550 | #define WM9081_DRC_QR_THR_MASK 0x00C0 /* DRC_QR_THR - [7:6] */ | ||
551 | #define WM9081_DRC_QR_THR_SHIFT 6 /* DRC_QR_THR - [7:6] */ | ||
552 | #define WM9081_DRC_QR_THR_WIDTH 2 /* DRC_QR_THR - [7:6] */ | ||
553 | #define WM9081_DRC_QR_DCY_MASK 0x0030 /* DRC_QR_DCY - [5:4] */ | ||
554 | #define WM9081_DRC_QR_DCY_SHIFT 4 /* DRC_QR_DCY - [5:4] */ | ||
555 | #define WM9081_DRC_QR_DCY_WIDTH 2 /* DRC_QR_DCY - [5:4] */ | ||
556 | #define WM9081_DRC_MINGAIN_MASK 0x000C /* DRC_MINGAIN - [3:2] */ | ||
557 | #define WM9081_DRC_MINGAIN_SHIFT 2 /* DRC_MINGAIN - [3:2] */ | ||
558 | #define WM9081_DRC_MINGAIN_WIDTH 2 /* DRC_MINGAIN - [3:2] */ | ||
559 | #define WM9081_DRC_MAXGAIN_MASK 0x0003 /* DRC_MAXGAIN - [1:0] */ | ||
560 | #define WM9081_DRC_MAXGAIN_SHIFT 0 /* DRC_MAXGAIN - [1:0] */ | ||
561 | #define WM9081_DRC_MAXGAIN_WIDTH 2 /* DRC_MAXGAIN - [1:0] */ | ||
562 | |||
563 | /* | ||
564 | * R34 (0x22) - DRC 3 | ||
565 | */ | ||
566 | #define WM9081_DRC_HI_COMP_MASK 0x0038 /* DRC_HI_COMP - [5:3] */ | ||
567 | #define WM9081_DRC_HI_COMP_SHIFT 3 /* DRC_HI_COMP - [5:3] */ | ||
568 | #define WM9081_DRC_HI_COMP_WIDTH 3 /* DRC_HI_COMP - [5:3] */ | ||
569 | #define WM9081_DRC_LO_COMP_MASK 0x0007 /* DRC_LO_COMP - [2:0] */ | ||
570 | #define WM9081_DRC_LO_COMP_SHIFT 0 /* DRC_LO_COMP - [2:0] */ | ||
571 | #define WM9081_DRC_LO_COMP_WIDTH 3 /* DRC_LO_COMP - [2:0] */ | ||
572 | |||
573 | /* | ||
574 | * R35 (0x23) - DRC 4 | ||
575 | */ | ||
576 | #define WM9081_DRC_KNEE_IP_MASK 0x07E0 /* DRC_KNEE_IP - [10:5] */ | ||
577 | #define WM9081_DRC_KNEE_IP_SHIFT 5 /* DRC_KNEE_IP - [10:5] */ | ||
578 | #define WM9081_DRC_KNEE_IP_WIDTH 6 /* DRC_KNEE_IP - [10:5] */ | ||
579 | #define WM9081_DRC_KNEE_OP_MASK 0x001F /* DRC_KNEE_OP - [4:0] */ | ||
580 | #define WM9081_DRC_KNEE_OP_SHIFT 0 /* DRC_KNEE_OP - [4:0] */ | ||
581 | #define WM9081_DRC_KNEE_OP_WIDTH 5 /* DRC_KNEE_OP - [4:0] */ | ||
582 | |||
583 | /* | ||
584 | * R38 (0x26) - Write Sequencer 1 | ||
585 | */ | ||
586 | #define WM9081_WSEQ_ENA 0x8000 /* WSEQ_ENA */ | ||
587 | #define WM9081_WSEQ_ENA_MASK 0x8000 /* WSEQ_ENA */ | ||
588 | #define WM9081_WSEQ_ENA_SHIFT 15 /* WSEQ_ENA */ | ||
589 | #define WM9081_WSEQ_ENA_WIDTH 1 /* WSEQ_ENA */ | ||
590 | #define WM9081_WSEQ_ABORT 0x0200 /* WSEQ_ABORT */ | ||
591 | #define WM9081_WSEQ_ABORT_MASK 0x0200 /* WSEQ_ABORT */ | ||
592 | #define WM9081_WSEQ_ABORT_SHIFT 9 /* WSEQ_ABORT */ | ||
593 | #define WM9081_WSEQ_ABORT_WIDTH 1 /* WSEQ_ABORT */ | ||
594 | #define WM9081_WSEQ_START 0x0100 /* WSEQ_START */ | ||
595 | #define WM9081_WSEQ_START_MASK 0x0100 /* WSEQ_START */ | ||
596 | #define WM9081_WSEQ_START_SHIFT 8 /* WSEQ_START */ | ||
597 | #define WM9081_WSEQ_START_WIDTH 1 /* WSEQ_START */ | ||
598 | #define WM9081_WSEQ_START_INDEX_MASK 0x007F /* WSEQ_START_INDEX - [6:0] */ | ||
599 | #define WM9081_WSEQ_START_INDEX_SHIFT 0 /* WSEQ_START_INDEX - [6:0] */ | ||
600 | #define WM9081_WSEQ_START_INDEX_WIDTH 7 /* WSEQ_START_INDEX - [6:0] */ | ||
601 | |||
602 | /* | ||
603 | * R39 (0x27) - Write Sequencer 2 | ||
604 | */ | ||
605 | #define WM9081_WSEQ_CURRENT_INDEX_MASK 0x07F0 /* WSEQ_CURRENT_INDEX - [10:4] */ | ||
606 | #define WM9081_WSEQ_CURRENT_INDEX_SHIFT 4 /* WSEQ_CURRENT_INDEX - [10:4] */ | ||
607 | #define WM9081_WSEQ_CURRENT_INDEX_WIDTH 7 /* WSEQ_CURRENT_INDEX - [10:4] */ | ||
608 | #define WM9081_WSEQ_BUSY 0x0001 /* WSEQ_BUSY */ | ||
609 | #define WM9081_WSEQ_BUSY_MASK 0x0001 /* WSEQ_BUSY */ | ||
610 | #define WM9081_WSEQ_BUSY_SHIFT 0 /* WSEQ_BUSY */ | ||
611 | #define WM9081_WSEQ_BUSY_WIDTH 1 /* WSEQ_BUSY */ | ||
612 | |||
613 | /* | ||
614 | * R40 (0x28) - MW Slave 1 | ||
615 | */ | ||
616 | #define WM9081_SPI_CFG 0x0020 /* SPI_CFG */ | ||
617 | #define WM9081_SPI_CFG_MASK 0x0020 /* SPI_CFG */ | ||
618 | #define WM9081_SPI_CFG_SHIFT 5 /* SPI_CFG */ | ||
619 | #define WM9081_SPI_CFG_WIDTH 1 /* SPI_CFG */ | ||
620 | #define WM9081_SPI_4WIRE 0x0010 /* SPI_4WIRE */ | ||
621 | #define WM9081_SPI_4WIRE_MASK 0x0010 /* SPI_4WIRE */ | ||
622 | #define WM9081_SPI_4WIRE_SHIFT 4 /* SPI_4WIRE */ | ||
623 | #define WM9081_SPI_4WIRE_WIDTH 1 /* SPI_4WIRE */ | ||
624 | #define WM9081_ARA_ENA 0x0008 /* ARA_ENA */ | ||
625 | #define WM9081_ARA_ENA_MASK 0x0008 /* ARA_ENA */ | ||
626 | #define WM9081_ARA_ENA_SHIFT 3 /* ARA_ENA */ | ||
627 | #define WM9081_ARA_ENA_WIDTH 1 /* ARA_ENA */ | ||
628 | #define WM9081_AUTO_INC 0x0002 /* AUTO_INC */ | ||
629 | #define WM9081_AUTO_INC_MASK 0x0002 /* AUTO_INC */ | ||
630 | #define WM9081_AUTO_INC_SHIFT 1 /* AUTO_INC */ | ||
631 | #define WM9081_AUTO_INC_WIDTH 1 /* AUTO_INC */ | ||
632 | |||
633 | /* | ||
634 | * R42 (0x2A) - EQ 1 | ||
635 | */ | ||
636 | #define WM9081_EQ_B1_GAIN_MASK 0xF800 /* EQ_B1_GAIN - [15:11] */ | ||
637 | #define WM9081_EQ_B1_GAIN_SHIFT 11 /* EQ_B1_GAIN - [15:11] */ | ||
638 | #define WM9081_EQ_B1_GAIN_WIDTH 5 /* EQ_B1_GAIN - [15:11] */ | ||
639 | #define WM9081_EQ_B2_GAIN_MASK 0x07C0 /* EQ_B2_GAIN - [10:6] */ | ||
640 | #define WM9081_EQ_B2_GAIN_SHIFT 6 /* EQ_B2_GAIN - [10:6] */ | ||
641 | #define WM9081_EQ_B2_GAIN_WIDTH 5 /* EQ_B2_GAIN - [10:6] */ | ||
642 | #define WM9081_EQ_B4_GAIN_MASK 0x003E /* EQ_B4_GAIN - [5:1] */ | ||
643 | #define WM9081_EQ_B4_GAIN_SHIFT 1 /* EQ_B4_GAIN - [5:1] */ | ||
644 | #define WM9081_EQ_B4_GAIN_WIDTH 5 /* EQ_B4_GAIN - [5:1] */ | ||
645 | #define WM9081_EQ_ENA 0x0001 /* EQ_ENA */ | ||
646 | #define WM9081_EQ_ENA_MASK 0x0001 /* EQ_ENA */ | ||
647 | #define WM9081_EQ_ENA_SHIFT 0 /* EQ_ENA */ | ||
648 | #define WM9081_EQ_ENA_WIDTH 1 /* EQ_ENA */ | ||
649 | |||
650 | /* | ||
651 | * R43 (0x2B) - EQ 2 | ||
652 | */ | ||
653 | #define WM9081_EQ_B3_GAIN_MASK 0xF800 /* EQ_B3_GAIN - [15:11] */ | ||
654 | #define WM9081_EQ_B3_GAIN_SHIFT 11 /* EQ_B3_GAIN - [15:11] */ | ||
655 | #define WM9081_EQ_B3_GAIN_WIDTH 5 /* EQ_B3_GAIN - [15:11] */ | ||
656 | #define WM9081_EQ_B5_GAIN_MASK 0x07C0 /* EQ_B5_GAIN - [10:6] */ | ||
657 | #define WM9081_EQ_B5_GAIN_SHIFT 6 /* EQ_B5_GAIN - [10:6] */ | ||
658 | #define WM9081_EQ_B5_GAIN_WIDTH 5 /* EQ_B5_GAIN - [10:6] */ | ||
659 | |||
660 | /* | ||
661 | * R44 (0x2C) - EQ 3 | ||
662 | */ | ||
663 | #define WM9081_EQ_B1_A_MASK 0xFFFF /* EQ_B1_A - [15:0] */ | ||
664 | #define WM9081_EQ_B1_A_SHIFT 0 /* EQ_B1_A - [15:0] */ | ||
665 | #define WM9081_EQ_B1_A_WIDTH 16 /* EQ_B1_A - [15:0] */ | ||
666 | |||
667 | /* | ||
668 | * R45 (0x2D) - EQ 4 | ||
669 | */ | ||
670 | #define WM9081_EQ_B1_B_MASK 0xFFFF /* EQ_B1_B - [15:0] */ | ||
671 | #define WM9081_EQ_B1_B_SHIFT 0 /* EQ_B1_B - [15:0] */ | ||
672 | #define WM9081_EQ_B1_B_WIDTH 16 /* EQ_B1_B - [15:0] */ | ||
673 | |||
674 | /* | ||
675 | * R46 (0x2E) - EQ 5 | ||
676 | */ | ||
677 | #define WM9081_EQ_B1_PG_MASK 0xFFFF /* EQ_B1_PG - [15:0] */ | ||
678 | #define WM9081_EQ_B1_PG_SHIFT 0 /* EQ_B1_PG - [15:0] */ | ||
679 | #define WM9081_EQ_B1_PG_WIDTH 16 /* EQ_B1_PG - [15:0] */ | ||
680 | |||
681 | /* | ||
682 | * R47 (0x2F) - EQ 6 | ||
683 | */ | ||
684 | #define WM9081_EQ_B2_A_MASK 0xFFFF /* EQ_B2_A - [15:0] */ | ||
685 | #define WM9081_EQ_B2_A_SHIFT 0 /* EQ_B2_A - [15:0] */ | ||
686 | #define WM9081_EQ_B2_A_WIDTH 16 /* EQ_B2_A - [15:0] */ | ||
687 | |||
688 | /* | ||
689 | * R48 (0x30) - EQ 7 | ||
690 | */ | ||
691 | #define WM9081_EQ_B2_B_MASK 0xFFFF /* EQ_B2_B - [15:0] */ | ||
692 | #define WM9081_EQ_B2_B_SHIFT 0 /* EQ_B2_B - [15:0] */ | ||
693 | #define WM9081_EQ_B2_B_WIDTH 16 /* EQ_B2_B - [15:0] */ | ||
694 | |||
695 | /* | ||
696 | * R49 (0x31) - EQ 8 | ||
697 | */ | ||
698 | #define WM9081_EQ_B2_C_MASK 0xFFFF /* EQ_B2_C - [15:0] */ | ||
699 | #define WM9081_EQ_B2_C_SHIFT 0 /* EQ_B2_C - [15:0] */ | ||
700 | #define WM9081_EQ_B2_C_WIDTH 16 /* EQ_B2_C - [15:0] */ | ||
701 | |||
702 | /* | ||
703 | * R50 (0x32) - EQ 9 | ||
704 | */ | ||
705 | #define WM9081_EQ_B2_PG_MASK 0xFFFF /* EQ_B2_PG - [15:0] */ | ||
706 | #define WM9081_EQ_B2_PG_SHIFT 0 /* EQ_B2_PG - [15:0] */ | ||
707 | #define WM9081_EQ_B2_PG_WIDTH 16 /* EQ_B2_PG - [15:0] */ | ||
708 | |||
709 | /* | ||
710 | * R51 (0x33) - EQ 10 | ||
711 | */ | ||
712 | #define WM9081_EQ_B4_A_MASK 0xFFFF /* EQ_B4_A - [15:0] */ | ||
713 | #define WM9081_EQ_B4_A_SHIFT 0 /* EQ_B4_A - [15:0] */ | ||
714 | #define WM9081_EQ_B4_A_WIDTH 16 /* EQ_B4_A - [15:0] */ | ||
715 | |||
716 | /* | ||
717 | * R52 (0x34) - EQ 11 | ||
718 | */ | ||
719 | #define WM9081_EQ_B4_B_MASK 0xFFFF /* EQ_B4_B - [15:0] */ | ||
720 | #define WM9081_EQ_B4_B_SHIFT 0 /* EQ_B4_B - [15:0] */ | ||
721 | #define WM9081_EQ_B4_B_WIDTH 16 /* EQ_B4_B - [15:0] */ | ||
722 | |||
723 | /* | ||
724 | * R53 (0x35) - EQ 12 | ||
725 | */ | ||
726 | #define WM9081_EQ_B4_C_MASK 0xFFFF /* EQ_B4_C - [15:0] */ | ||
727 | #define WM9081_EQ_B4_C_SHIFT 0 /* EQ_B4_C - [15:0] */ | ||
728 | #define WM9081_EQ_B4_C_WIDTH 16 /* EQ_B4_C - [15:0] */ | ||
729 | |||
730 | /* | ||
731 | * R54 (0x36) - EQ 13 | ||
732 | */ | ||
733 | #define WM9081_EQ_B4_PG_MASK 0xFFFF /* EQ_B4_PG - [15:0] */ | ||
734 | #define WM9081_EQ_B4_PG_SHIFT 0 /* EQ_B4_PG - [15:0] */ | ||
735 | #define WM9081_EQ_B4_PG_WIDTH 16 /* EQ_B4_PG - [15:0] */ | ||
736 | |||
737 | /* | ||
738 | * R55 (0x37) - EQ 14 | ||
739 | */ | ||
740 | #define WM9081_EQ_B3_A_MASK 0xFFFF /* EQ_B3_A - [15:0] */ | ||
741 | #define WM9081_EQ_B3_A_SHIFT 0 /* EQ_B3_A - [15:0] */ | ||
742 | #define WM9081_EQ_B3_A_WIDTH 16 /* EQ_B3_A - [15:0] */ | ||
743 | |||
744 | /* | ||
745 | * R56 (0x38) - EQ 15 | ||
746 | */ | ||
747 | #define WM9081_EQ_B3_B_MASK 0xFFFF /* EQ_B3_B - [15:0] */ | ||
748 | #define WM9081_EQ_B3_B_SHIFT 0 /* EQ_B3_B - [15:0] */ | ||
749 | #define WM9081_EQ_B3_B_WIDTH 16 /* EQ_B3_B - [15:0] */ | ||
750 | |||
751 | /* | ||
752 | * R57 (0x39) - EQ 16 | ||
753 | */ | ||
754 | #define WM9081_EQ_B3_C_MASK 0xFFFF /* EQ_B3_C - [15:0] */ | ||
755 | #define WM9081_EQ_B3_C_SHIFT 0 /* EQ_B3_C - [15:0] */ | ||
756 | #define WM9081_EQ_B3_C_WIDTH 16 /* EQ_B3_C - [15:0] */ | ||
757 | |||
758 | /* | ||
759 | * R58 (0x3A) - EQ 17 | ||
760 | */ | ||
761 | #define WM9081_EQ_B3_PG_MASK 0xFFFF /* EQ_B3_PG - [15:0] */ | ||
762 | #define WM9081_EQ_B3_PG_SHIFT 0 /* EQ_B3_PG - [15:0] */ | ||
763 | #define WM9081_EQ_B3_PG_WIDTH 16 /* EQ_B3_PG - [15:0] */ | ||
764 | |||
765 | /* | ||
766 | * R59 (0x3B) - EQ 18 | ||
767 | */ | ||
768 | #define WM9081_EQ_B5_A_MASK 0xFFFF /* EQ_B5_A - [15:0] */ | ||
769 | #define WM9081_EQ_B5_A_SHIFT 0 /* EQ_B5_A - [15:0] */ | ||
770 | #define WM9081_EQ_B5_A_WIDTH 16 /* EQ_B5_A - [15:0] */ | ||
771 | |||
772 | /* | ||
773 | * R60 (0x3C) - EQ 19 | ||
774 | */ | ||
775 | #define WM9081_EQ_B5_B_MASK 0xFFFF /* EQ_B5_B - [15:0] */ | ||
776 | #define WM9081_EQ_B5_B_SHIFT 0 /* EQ_B5_B - [15:0] */ | ||
777 | #define WM9081_EQ_B5_B_WIDTH 16 /* EQ_B5_B - [15:0] */ | ||
778 | |||
779 | /* | ||
780 | * R61 (0x3D) - EQ 20 | ||
781 | */ | ||
782 | #define WM9081_EQ_B5_PG_MASK 0xFFFF /* EQ_B5_PG - [15:0] */ | ||
783 | #define WM9081_EQ_B5_PG_SHIFT 0 /* EQ_B5_PG - [15:0] */ | ||
784 | #define WM9081_EQ_B5_PG_WIDTH 16 /* EQ_B5_PG - [15:0] */ | ||
785 | |||
786 | |||
787 | #endif | ||
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index c2d1a7a18fa3..fa88b463e71f 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c | |||
@@ -282,14 +282,14 @@ struct snd_soc_dai wm9705_dai[] = { | |||
282 | .channels_min = 1, | 282 | .channels_min = 1, |
283 | .channels_max = 2, | 283 | .channels_max = 2, |
284 | .rates = WM9705_AC97_RATES, | 284 | .rates = WM9705_AC97_RATES, |
285 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 285 | .formats = SND_SOC_STD_AC97_FMTS, |
286 | }, | 286 | }, |
287 | .capture = { | 287 | .capture = { |
288 | .stream_name = "HiFi Capture", | 288 | .stream_name = "HiFi Capture", |
289 | .channels_min = 1, | 289 | .channels_min = 1, |
290 | .channels_max = 2, | 290 | .channels_max = 2, |
291 | .rates = WM9705_AC97_RATES, | 291 | .rates = WM9705_AC97_RATES, |
292 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 292 | .formats = SND_SOC_STD_AC97_FMTS, |
293 | }, | 293 | }, |
294 | .ops = &wm9705_dai_ops, | 294 | .ops = &wm9705_dai_ops, |
295 | }, | 295 | }, |
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 765cf1e7369e..1fd4e88f50cf 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c | |||
@@ -534,13 +534,13 @@ struct snd_soc_dai wm9712_dai[] = { | |||
534 | .channels_min = 1, | 534 | .channels_min = 1, |
535 | .channels_max = 2, | 535 | .channels_max = 2, |
536 | .rates = WM9712_AC97_RATES, | 536 | .rates = WM9712_AC97_RATES, |
537 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 537 | .formats = SND_SOC_STD_AC97_FMTS,}, |
538 | .capture = { | 538 | .capture = { |
539 | .stream_name = "HiFi Capture", | 539 | .stream_name = "HiFi Capture", |
540 | .channels_min = 1, | 540 | .channels_min = 1, |
541 | .channels_max = 2, | 541 | .channels_max = 2, |
542 | .rates = WM9712_AC97_RATES, | 542 | .rates = WM9712_AC97_RATES, |
543 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 543 | .formats = SND_SOC_STD_AC97_FMTS,}, |
544 | .ops = &wm9712_dai_ops_hifi, | 544 | .ops = &wm9712_dai_ops_hifi, |
545 | }, | 545 | }, |
546 | { | 546 | { |
@@ -550,7 +550,7 @@ struct snd_soc_dai wm9712_dai[] = { | |||
550 | .channels_min = 1, | 550 | .channels_min = 1, |
551 | .channels_max = 1, | 551 | .channels_max = 1, |
552 | .rates = WM9712_AC97_RATES, | 552 | .rates = WM9712_AC97_RATES, |
553 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 553 | .formats = SND_SOC_STD_AC97_FMTS,}, |
554 | .ops = &wm9712_dai_ops_aux, | 554 | .ops = &wm9712_dai_ops_aux, |
555 | } | 555 | } |
556 | }; | 556 | }; |
@@ -585,6 +585,8 @@ static int wm9712_reset(struct snd_soc_codec *codec, int try_warm) | |||
585 | } | 585 | } |
586 | 586 | ||
587 | soc_ac97_ops.reset(codec->ac97); | 587 | soc_ac97_ops.reset(codec->ac97); |
588 | if (soc_ac97_ops.warm_reset) | ||
589 | soc_ac97_ops.warm_reset(codec->ac97); | ||
588 | if (ac97_read(codec, 0) != wm9712_reg[0]) | 590 | if (ac97_read(codec, 0) != wm9712_reg[0]) |
589 | goto err; | 591 | goto err; |
590 | return 0; | 592 | return 0; |
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index 523bad077fa0..abed37acf787 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c | |||
@@ -189,6 +189,26 @@ SOC_SINGLE("3D Lower Cut-off Switch", AC97_REC_GAIN_MIC, 4, 1, 0), | |||
189 | SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1), | 189 | SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1), |
190 | }; | 190 | }; |
191 | 191 | ||
192 | static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w, | ||
193 | struct snd_kcontrol *kcontrol, int event) | ||
194 | { | ||
195 | struct snd_soc_codec *codec = w->codec; | ||
196 | u16 status, rate; | ||
197 | |||
198 | BUG_ON(event != SND_SOC_DAPM_PRE_PMD); | ||
199 | |||
200 | /* Gracefully shut down the voice interface. */ | ||
201 | status = ac97_read(codec, AC97_EXTENDED_MID) | 0x1000; | ||
202 | rate = ac97_read(codec, AC97_HANDSET_RATE) & 0xF0FF; | ||
203 | ac97_write(codec, AC97_HANDSET_RATE, rate | 0x0200); | ||
204 | schedule_timeout_interruptible(msecs_to_jiffies(1)); | ||
205 | ac97_write(codec, AC97_HANDSET_RATE, rate | 0x0F00); | ||
206 | ac97_write(codec, AC97_EXTENDED_MID, status); | ||
207 | |||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | |||
192 | /* We have to create a fake left and right HP mixers because | 212 | /* We have to create a fake left and right HP mixers because |
193 | * the codec only has a single control that is shared by both channels. | 213 | * the codec only has a single control that is shared by both channels. |
194 | * This makes it impossible to determine the audio path using the current | 214 | * This makes it impossible to determine the audio path using the current |
@@ -400,7 +420,8 @@ SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), | |||
400 | SND_SOC_DAPM_MIXER("HP Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), | 420 | SND_SOC_DAPM_MIXER("HP Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), |
401 | SND_SOC_DAPM_MIXER("Line Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), | 421 | SND_SOC_DAPM_MIXER("Line Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), |
402 | SND_SOC_DAPM_MIXER("Capture Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), | 422 | SND_SOC_DAPM_MIXER("Capture Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), |
403 | SND_SOC_DAPM_DAC("Voice DAC", "Voice Playback", AC97_EXTENDED_MID, 12, 1), | 423 | SND_SOC_DAPM_DAC_E("Voice DAC", "Voice Playback", AC97_EXTENDED_MID, 12, 1, |
424 | wm9713_voice_shutdown, SND_SOC_DAPM_PRE_PMD), | ||
404 | SND_SOC_DAPM_DAC("Aux DAC", "Aux Playback", AC97_EXTENDED_MID, 11, 1), | 425 | SND_SOC_DAPM_DAC("Aux DAC", "Aux Playback", AC97_EXTENDED_MID, 11, 1), |
405 | SND_SOC_DAPM_PGA("Left ADC", AC97_EXTENDED_MID, 5, 1, NULL, 0), | 426 | SND_SOC_DAPM_PGA("Left ADC", AC97_EXTENDED_MID, 5, 1, NULL, 0), |
406 | SND_SOC_DAPM_PGA("Right ADC", AC97_EXTENDED_MID, 4, 1, NULL, 0), | 427 | SND_SOC_DAPM_PGA("Right ADC", AC97_EXTENDED_MID, 4, 1, NULL, 0), |
@@ -689,7 +710,7 @@ static void pll_factors(struct _pll_div *pll_div, unsigned int source) | |||
689 | Ndiv = target / source; | 710 | Ndiv = target / source; |
690 | if ((Ndiv < 5) || (Ndiv > 12)) | 711 | if ((Ndiv < 5) || (Ndiv > 12)) |
691 | printk(KERN_WARNING | 712 | printk(KERN_WARNING |
692 | "WM9713 PLL N value %d out of recommended range!\n", | 713 | "WM9713 PLL N value %u out of recommended range!\n", |
693 | Ndiv); | 714 | Ndiv); |
694 | 715 | ||
695 | pll_div->n = Ndiv; | 716 | pll_div->n = Ndiv; |
@@ -936,21 +957,6 @@ static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream, | |||
936 | return 0; | 957 | return 0; |
937 | } | 958 | } |
938 | 959 | ||
939 | static void wm9713_voiceshutdown(struct snd_pcm_substream *substream, | ||
940 | struct snd_soc_dai *dai) | ||
941 | { | ||
942 | struct snd_soc_codec *codec = dai->codec; | ||
943 | u16 status, rate; | ||
944 | |||
945 | /* Gracefully shut down the voice interface. */ | ||
946 | status = ac97_read(codec, AC97_EXTENDED_STATUS) | 0x1000; | ||
947 | rate = ac97_read(codec, AC97_HANDSET_RATE) & 0xF0FF; | ||
948 | ac97_write(codec, AC97_HANDSET_RATE, rate | 0x0200); | ||
949 | schedule_timeout_interruptible(msecs_to_jiffies(1)); | ||
950 | ac97_write(codec, AC97_HANDSET_RATE, rate | 0x0F00); | ||
951 | ac97_write(codec, AC97_EXTENDED_MID, status); | ||
952 | } | ||
953 | |||
954 | static int ac97_hifi_prepare(struct snd_pcm_substream *substream, | 960 | static int ac97_hifi_prepare(struct snd_pcm_substream *substream, |
955 | struct snd_soc_dai *dai) | 961 | struct snd_soc_dai *dai) |
956 | { | 962 | { |
@@ -1019,7 +1025,6 @@ static struct snd_soc_dai_ops wm9713_dai_ops_aux = { | |||
1019 | 1025 | ||
1020 | static struct snd_soc_dai_ops wm9713_dai_ops_voice = { | 1026 | static struct snd_soc_dai_ops wm9713_dai_ops_voice = { |
1021 | .hw_params = wm9713_pcm_hw_params, | 1027 | .hw_params = wm9713_pcm_hw_params, |
1022 | .shutdown = wm9713_voiceshutdown, | ||
1023 | .set_clkdiv = wm9713_set_dai_clkdiv, | 1028 | .set_clkdiv = wm9713_set_dai_clkdiv, |
1024 | .set_pll = wm9713_set_dai_pll, | 1029 | .set_pll = wm9713_set_dai_pll, |
1025 | .set_fmt = wm9713_set_dai_fmt, | 1030 | .set_fmt = wm9713_set_dai_fmt, |
@@ -1035,13 +1040,13 @@ struct snd_soc_dai wm9713_dai[] = { | |||
1035 | .channels_min = 1, | 1040 | .channels_min = 1, |
1036 | .channels_max = 2, | 1041 | .channels_max = 2, |
1037 | .rates = WM9713_RATES, | 1042 | .rates = WM9713_RATES, |
1038 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 1043 | .formats = SND_SOC_STD_AC97_FMTS,}, |
1039 | .capture = { | 1044 | .capture = { |
1040 | .stream_name = "HiFi Capture", | 1045 | .stream_name = "HiFi Capture", |
1041 | .channels_min = 1, | 1046 | .channels_min = 1, |
1042 | .channels_max = 2, | 1047 | .channels_max = 2, |
1043 | .rates = WM9713_RATES, | 1048 | .rates = WM9713_RATES, |
1044 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 1049 | .formats = SND_SOC_STD_AC97_FMTS,}, |
1045 | .ops = &wm9713_dai_ops_hifi, | 1050 | .ops = &wm9713_dai_ops_hifi, |
1046 | }, | 1051 | }, |
1047 | { | 1052 | { |
@@ -1051,7 +1056,7 @@ struct snd_soc_dai wm9713_dai[] = { | |||
1051 | .channels_min = 1, | 1056 | .channels_min = 1, |
1052 | .channels_max = 1, | 1057 | .channels_max = 1, |
1053 | .rates = WM9713_RATES, | 1058 | .rates = WM9713_RATES, |
1054 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 1059 | .formats = SND_SOC_STD_AC97_FMTS,}, |
1055 | .ops = &wm9713_dai_ops_aux, | 1060 | .ops = &wm9713_dai_ops_aux, |
1056 | }, | 1061 | }, |
1057 | { | 1062 | { |
@@ -1069,6 +1074,7 @@ struct snd_soc_dai wm9713_dai[] = { | |||
1069 | .rates = WM9713_PCM_RATES, | 1074 | .rates = WM9713_PCM_RATES, |
1070 | .formats = WM9713_PCM_FORMATS,}, | 1075 | .formats = WM9713_PCM_FORMATS,}, |
1071 | .ops = &wm9713_dai_ops_voice, | 1076 | .ops = &wm9713_dai_ops_voice, |
1077 | .symmetric_rates = 1, | ||
1072 | }, | 1078 | }, |
1073 | }; | 1079 | }; |
1074 | EXPORT_SYMBOL_GPL(wm9713_dai); | 1080 | EXPORT_SYMBOL_GPL(wm9713_dai); |
diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig index bd7392c9657e..411a710be660 100644 --- a/sound/soc/davinci/Kconfig +++ b/sound/soc/davinci/Kconfig | |||
@@ -10,13 +10,14 @@ config SND_DAVINCI_SOC_I2S | |||
10 | tristate | 10 | tristate |
11 | 11 | ||
12 | config SND_DAVINCI_SOC_EVM | 12 | config SND_DAVINCI_SOC_EVM |
13 | tristate "SoC Audio support for DaVinci EVM" | 13 | tristate "SoC Audio support for DaVinci DM6446 or DM355 EVM" |
14 | depends on SND_DAVINCI_SOC && MACH_DAVINCI_EVM | 14 | depends on SND_DAVINCI_SOC |
15 | depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM | ||
15 | select SND_DAVINCI_SOC_I2S | 16 | select SND_DAVINCI_SOC_I2S |
16 | select SND_SOC_TLV320AIC3X | 17 | select SND_SOC_TLV320AIC3X |
17 | help | 18 | help |
18 | Say Y if you want to add support for SoC audio on TI | 19 | Say Y if you want to add support for SoC audio on TI |
19 | DaVinci EVM platform. | 20 | DaVinci DM6446 or DM355 EVM platforms. |
20 | 21 | ||
21 | config SND_DAVINCI_SOC_SFFSDR | 22 | config SND_DAVINCI_SOC_SFFSDR |
22 | tristate "SoC Audio support for SFFSDR" | 23 | tristate "SoC Audio support for SFFSDR" |
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 9b90b347007c..58fd1cbedd88 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c | |||
@@ -20,7 +20,11 @@ | |||
20 | #include <sound/soc-dapm.h> | 20 | #include <sound/soc-dapm.h> |
21 | 21 | ||
22 | #include <asm/dma.h> | 22 | #include <asm/dma.h> |
23 | #include <mach/hardware.h> | 23 | #include <asm/mach-types.h> |
24 | |||
25 | #include <mach/asp.h> | ||
26 | #include <mach/edma.h> | ||
27 | #include <mach/mux.h> | ||
24 | 28 | ||
25 | #include "../codecs/tlv320aic3x.h" | 29 | #include "../codecs/tlv320aic3x.h" |
26 | #include "davinci-pcm.h" | 30 | #include "davinci-pcm.h" |
@@ -150,7 +154,7 @@ static struct snd_soc_card snd_soc_card_evm = { | |||
150 | 154 | ||
151 | /* evm audio private data */ | 155 | /* evm audio private data */ |
152 | static struct aic3x_setup_data evm_aic3x_setup = { | 156 | static struct aic3x_setup_data evm_aic3x_setup = { |
153 | .i2c_bus = 0, | 157 | .i2c_bus = 1, |
154 | .i2c_address = 0x1b, | 158 | .i2c_address = 0x1b, |
155 | }; | 159 | }; |
156 | 160 | ||
@@ -161,36 +165,73 @@ static struct snd_soc_device evm_snd_devdata = { | |||
161 | .codec_data = &evm_aic3x_setup, | 165 | .codec_data = &evm_aic3x_setup, |
162 | }; | 166 | }; |
163 | 167 | ||
168 | /* DM6446 EVM uses ASP0; line-out is a pair of RCA jacks */ | ||
164 | static struct resource evm_snd_resources[] = { | 169 | static struct resource evm_snd_resources[] = { |
165 | { | 170 | { |
166 | .start = DAVINCI_MCBSP_BASE, | 171 | .start = DAVINCI_ASP0_BASE, |
167 | .end = DAVINCI_MCBSP_BASE + SZ_8K - 1, | 172 | .end = DAVINCI_ASP0_BASE + SZ_8K - 1, |
168 | .flags = IORESOURCE_MEM, | 173 | .flags = IORESOURCE_MEM, |
169 | }, | 174 | }, |
170 | }; | 175 | }; |
171 | 176 | ||
172 | static struct evm_snd_platform_data evm_snd_data = { | 177 | static struct evm_snd_platform_data evm_snd_data = { |
173 | .tx_dma_ch = DM644X_DMACH_MCBSP_TX, | 178 | .tx_dma_ch = DAVINCI_DMA_ASP0_TX, |
174 | .rx_dma_ch = DM644X_DMACH_MCBSP_RX, | 179 | .rx_dma_ch = DAVINCI_DMA_ASP0_RX, |
180 | }; | ||
181 | |||
182 | /* DM335 EVM uses ASP1; line-out is a stereo mini-jack */ | ||
183 | static struct resource dm335evm_snd_resources[] = { | ||
184 | { | ||
185 | .start = DAVINCI_ASP1_BASE, | ||
186 | .end = DAVINCI_ASP1_BASE + SZ_8K - 1, | ||
187 | .flags = IORESOURCE_MEM, | ||
188 | }, | ||
189 | }; | ||
190 | |||
191 | static struct evm_snd_platform_data dm335evm_snd_data = { | ||
192 | .tx_dma_ch = DAVINCI_DMA_ASP1_TX, | ||
193 | .rx_dma_ch = DAVINCI_DMA_ASP1_RX, | ||
175 | }; | 194 | }; |
176 | 195 | ||
177 | static struct platform_device *evm_snd_device; | 196 | static struct platform_device *evm_snd_device; |
178 | 197 | ||
179 | static int __init evm_init(void) | 198 | static int __init evm_init(void) |
180 | { | 199 | { |
200 | struct resource *resources; | ||
201 | unsigned num_resources; | ||
202 | struct evm_snd_platform_data *data; | ||
203 | int index; | ||
181 | int ret; | 204 | int ret; |
182 | 205 | ||
183 | evm_snd_device = platform_device_alloc("soc-audio", 0); | 206 | if (machine_is_davinci_evm()) { |
207 | davinci_cfg_reg(DM644X_MCBSP); | ||
208 | |||
209 | resources = evm_snd_resources; | ||
210 | num_resources = ARRAY_SIZE(evm_snd_resources); | ||
211 | data = &evm_snd_data; | ||
212 | index = 0; | ||
213 | } else if (machine_is_davinci_dm355_evm()) { | ||
214 | /* we don't use ASP1 IRQs, or we'd need to mux them ... */ | ||
215 | davinci_cfg_reg(DM355_EVT8_ASP1_TX); | ||
216 | davinci_cfg_reg(DM355_EVT9_ASP1_RX); | ||
217 | |||
218 | resources = dm335evm_snd_resources; | ||
219 | num_resources = ARRAY_SIZE(dm335evm_snd_resources); | ||
220 | data = &dm335evm_snd_data; | ||
221 | index = 1; | ||
222 | } else | ||
223 | return -EINVAL; | ||
224 | |||
225 | evm_snd_device = platform_device_alloc("soc-audio", index); | ||
184 | if (!evm_snd_device) | 226 | if (!evm_snd_device) |
185 | return -ENOMEM; | 227 | return -ENOMEM; |
186 | 228 | ||
187 | platform_set_drvdata(evm_snd_device, &evm_snd_devdata); | 229 | platform_set_drvdata(evm_snd_device, &evm_snd_devdata); |
188 | evm_snd_devdata.dev = &evm_snd_device->dev; | 230 | evm_snd_devdata.dev = &evm_snd_device->dev; |
189 | platform_device_add_data(evm_snd_device, &evm_snd_data, | 231 | platform_device_add_data(evm_snd_device, data, sizeof(*data)); |
190 | sizeof(evm_snd_data)); | ||
191 | 232 | ||
192 | ret = platform_device_add_resources(evm_snd_device, evm_snd_resources, | 233 | ret = platform_device_add_resources(evm_snd_device, resources, |
193 | ARRAY_SIZE(evm_snd_resources)); | 234 | num_resources); |
194 | if (ret) { | 235 | if (ret) { |
195 | platform_device_put(evm_snd_device); | 236 | platform_device_put(evm_snd_device); |
196 | return ret; | 237 | return ret; |
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index ffdb9439d3d8..b1ea52fc83c7 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c | |||
@@ -24,6 +24,26 @@ | |||
24 | 24 | ||
25 | #include "davinci-pcm.h" | 25 | #include "davinci-pcm.h" |
26 | 26 | ||
27 | |||
28 | /* | ||
29 | * NOTE: terminology here is confusing. | ||
30 | * | ||
31 | * - This driver supports the "Audio Serial Port" (ASP), | ||
32 | * found on dm6446, dm355, and other DaVinci chips. | ||
33 | * | ||
34 | * - But it labels it a "Multi-channel Buffered Serial Port" | ||
35 | * (McBSP) as on older chips like the dm642 ... which was | ||
36 | * backward-compatible, possibly explaining that confusion. | ||
37 | * | ||
38 | * - OMAP chips have a controller called McBSP, which is | ||
39 | * incompatible with the DaVinci flavor of McBSP. | ||
40 | * | ||
41 | * - Newer DaVinci chips have a controller called McASP, | ||
42 | * incompatible with ASP and with either McBSP. | ||
43 | * | ||
44 | * In short: this uses ASP to implement I2S, not McBSP. | ||
45 | * And it won't be the only DaVinci implemention of I2S. | ||
46 | */ | ||
27 | #define DAVINCI_MCBSP_DRR_REG 0x00 | 47 | #define DAVINCI_MCBSP_DRR_REG 0x00 |
28 | #define DAVINCI_MCBSP_DXR_REG 0x04 | 48 | #define DAVINCI_MCBSP_DXR_REG 0x04 |
29 | #define DAVINCI_MCBSP_SPCR_REG 0x08 | 49 | #define DAVINCI_MCBSP_SPCR_REG 0x08 |
@@ -421,7 +441,7 @@ static int davinci_i2s_probe(struct platform_device *pdev, | |||
421 | { | 441 | { |
422 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 442 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
423 | struct snd_soc_card *card = socdev->card; | 443 | struct snd_soc_card *card = socdev->card; |
424 | struct snd_soc_dai *cpu_dai = card->dai_link[pdev->id].cpu_dai; | 444 | struct snd_soc_dai *cpu_dai = card->dai_link->cpu_dai; |
425 | struct davinci_mcbsp_dev *dev; | 445 | struct davinci_mcbsp_dev *dev; |
426 | struct resource *mem, *ioarea; | 446 | struct resource *mem, *ioarea; |
427 | struct evm_snd_platform_data *pdata; | 447 | struct evm_snd_platform_data *pdata; |
@@ -448,7 +468,7 @@ static int davinci_i2s_probe(struct platform_device *pdev, | |||
448 | 468 | ||
449 | cpu_dai->private_data = dev; | 469 | cpu_dai->private_data = dev; |
450 | 470 | ||
451 | dev->clk = clk_get(&pdev->dev, "McBSPCLK"); | 471 | dev->clk = clk_get(&pdev->dev, NULL); |
452 | if (IS_ERR(dev->clk)) { | 472 | if (IS_ERR(dev->clk)) { |
453 | ret = -ENODEV; | 473 | ret = -ENODEV; |
454 | goto err_free_mem; | 474 | goto err_free_mem; |
@@ -483,7 +503,7 @@ static void davinci_i2s_remove(struct platform_device *pdev, | |||
483 | { | 503 | { |
484 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 504 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
485 | struct snd_soc_card *card = socdev->card; | 505 | struct snd_soc_card *card = socdev->card; |
486 | struct snd_soc_dai *cpu_dai = card->dai_link[pdev->id].cpu_dai; | 506 | struct snd_soc_dai *cpu_dai = card->dai_link->cpu_dai; |
487 | struct davinci_mcbsp_dev *dev = cpu_dai->private_data; | 507 | struct davinci_mcbsp_dev *dev = cpu_dai->private_data; |
488 | struct resource *mem; | 508 | struct resource *mem; |
489 | 509 | ||
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index 7af3b5b3a53d..a05996588489 100644 --- a/sound/soc/davinci/davinci-pcm.c +++ b/sound/soc/davinci/davinci-pcm.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <sound/soc.h> | 22 | #include <sound/soc.h> |
23 | 23 | ||
24 | #include <asm/dma.h> | 24 | #include <asm/dma.h> |
25 | #include <mach/edma.h> | ||
25 | 26 | ||
26 | #include "davinci-pcm.h" | 27 | #include "davinci-pcm.h" |
27 | 28 | ||
@@ -51,7 +52,7 @@ struct davinci_runtime_data { | |||
51 | spinlock_t lock; | 52 | spinlock_t lock; |
52 | int period; /* current DMA period */ | 53 | int period; /* current DMA period */ |
53 | int master_lch; /* Master DMA channel */ | 54 | int master_lch; /* Master DMA channel */ |
54 | int slave_lch; /* Slave DMA channel */ | 55 | int slave_lch; /* linked parameter RAM reload slot */ |
55 | struct davinci_pcm_dma_params *params; /* DMA params */ | 56 | struct davinci_pcm_dma_params *params; /* DMA params */ |
56 | }; | 57 | }; |
57 | 58 | ||
@@ -90,18 +91,18 @@ static void davinci_pcm_enqueue_dma(struct snd_pcm_substream *substream) | |||
90 | dst_bidx = data_type; | 91 | dst_bidx = data_type; |
91 | } | 92 | } |
92 | 93 | ||
93 | davinci_set_dma_src_params(lch, src, INCR, W8BIT); | 94 | edma_set_src(lch, src, INCR, W8BIT); |
94 | davinci_set_dma_dest_params(lch, dst, INCR, W8BIT); | 95 | edma_set_dest(lch, dst, INCR, W8BIT); |
95 | davinci_set_dma_src_index(lch, src_bidx, 0); | 96 | edma_set_src_index(lch, src_bidx, 0); |
96 | davinci_set_dma_dest_index(lch, dst_bidx, 0); | 97 | edma_set_dest_index(lch, dst_bidx, 0); |
97 | davinci_set_dma_transfer_params(lch, data_type, count, 1, 0, ASYNC); | 98 | edma_set_transfer_params(lch, data_type, count, 1, 0, ASYNC); |
98 | 99 | ||
99 | prtd->period++; | 100 | prtd->period++; |
100 | if (unlikely(prtd->period >= runtime->periods)) | 101 | if (unlikely(prtd->period >= runtime->periods)) |
101 | prtd->period = 0; | 102 | prtd->period = 0; |
102 | } | 103 | } |
103 | 104 | ||
104 | static void davinci_pcm_dma_irq(int lch, u16 ch_status, void *data) | 105 | static void davinci_pcm_dma_irq(unsigned lch, u16 ch_status, void *data) |
105 | { | 106 | { |
106 | struct snd_pcm_substream *substream = data; | 107 | struct snd_pcm_substream *substream = data; |
107 | struct davinci_runtime_data *prtd = substream->runtime->private_data; | 108 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
@@ -125,7 +126,7 @@ static int davinci_pcm_dma_request(struct snd_pcm_substream *substream) | |||
125 | struct davinci_runtime_data *prtd = substream->runtime->private_data; | 126 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
126 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 127 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
127 | struct davinci_pcm_dma_params *dma_data = rtd->dai->cpu_dai->dma_data; | 128 | struct davinci_pcm_dma_params *dma_data = rtd->dai->cpu_dai->dma_data; |
128 | int tcc = TCC_ANY; | 129 | struct edmacc_param p_ram; |
129 | int ret; | 130 | int ret; |
130 | 131 | ||
131 | if (!dma_data) | 132 | if (!dma_data) |
@@ -134,22 +135,34 @@ static int davinci_pcm_dma_request(struct snd_pcm_substream *substream) | |||
134 | prtd->params = dma_data; | 135 | prtd->params = dma_data; |
135 | 136 | ||
136 | /* Request master DMA channel */ | 137 | /* Request master DMA channel */ |
137 | ret = davinci_request_dma(prtd->params->channel, prtd->params->name, | 138 | ret = edma_alloc_channel(prtd->params->channel, |
138 | davinci_pcm_dma_irq, substream, | 139 | davinci_pcm_dma_irq, substream, |
139 | &prtd->master_lch, &tcc, EVENTQ_0); | 140 | EVENTQ_0); |
140 | if (ret) | 141 | if (ret < 0) |
141 | return ret; | 142 | return ret; |
143 | prtd->master_lch = ret; | ||
142 | 144 | ||
143 | /* Request slave DMA channel */ | 145 | /* Request parameter RAM reload slot */ |
144 | ret = davinci_request_dma(PARAM_ANY, "Link", | 146 | ret = edma_alloc_slot(EDMA_SLOT_ANY); |
145 | NULL, NULL, &prtd->slave_lch, &tcc, EVENTQ_0); | 147 | if (ret < 0) { |
146 | if (ret) { | 148 | edma_free_channel(prtd->master_lch); |
147 | davinci_free_dma(prtd->master_lch); | ||
148 | return ret; | 149 | return ret; |
149 | } | 150 | } |
150 | 151 | prtd->slave_lch = ret; | |
151 | /* Link slave DMA channel in loopback */ | 152 | |
152 | davinci_dma_link_lch(prtd->slave_lch, prtd->slave_lch); | 153 | /* Issue transfer completion IRQ when the channel completes a |
154 | * transfer, then always reload from the same slot (by a kind | ||
155 | * of loopback link). The completion IRQ handler will update | ||
156 | * the reload slot with a new buffer. | ||
157 | * | ||
158 | * REVISIT save p_ram here after setting up everything except | ||
159 | * the buffer and its length (ccnt) ... use it as a template | ||
160 | * so davinci_pcm_enqueue_dma() takes less time in IRQ. | ||
161 | */ | ||
162 | edma_read_slot(prtd->slave_lch, &p_ram); | ||
163 | p_ram.opt |= TCINTEN | EDMA_TCC(prtd->master_lch); | ||
164 | p_ram.link_bcntrld = prtd->slave_lch << 5; | ||
165 | edma_write_slot(prtd->slave_lch, &p_ram); | ||
153 | 166 | ||
154 | return 0; | 167 | return 0; |
155 | } | 168 | } |
@@ -165,12 +178,12 @@ static int davinci_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
165 | case SNDRV_PCM_TRIGGER_START: | 178 | case SNDRV_PCM_TRIGGER_START: |
166 | case SNDRV_PCM_TRIGGER_RESUME: | 179 | case SNDRV_PCM_TRIGGER_RESUME: |
167 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 180 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
168 | davinci_start_dma(prtd->master_lch); | 181 | edma_start(prtd->master_lch); |
169 | break; | 182 | break; |
170 | case SNDRV_PCM_TRIGGER_STOP: | 183 | case SNDRV_PCM_TRIGGER_STOP: |
171 | case SNDRV_PCM_TRIGGER_SUSPEND: | 184 | case SNDRV_PCM_TRIGGER_SUSPEND: |
172 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 185 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
173 | davinci_stop_dma(prtd->master_lch); | 186 | edma_stop(prtd->master_lch); |
174 | break; | 187 | break; |
175 | default: | 188 | default: |
176 | ret = -EINVAL; | 189 | ret = -EINVAL; |
@@ -185,14 +198,14 @@ static int davinci_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
185 | static int davinci_pcm_prepare(struct snd_pcm_substream *substream) | 198 | static int davinci_pcm_prepare(struct snd_pcm_substream *substream) |
186 | { | 199 | { |
187 | struct davinci_runtime_data *prtd = substream->runtime->private_data; | 200 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
188 | struct paramentry_descriptor temp; | 201 | struct edmacc_param temp; |
189 | 202 | ||
190 | prtd->period = 0; | 203 | prtd->period = 0; |
191 | davinci_pcm_enqueue_dma(substream); | 204 | davinci_pcm_enqueue_dma(substream); |
192 | 205 | ||
193 | /* Get slave channel dma params for master channel startup */ | 206 | /* Copy self-linked parameter RAM entry into master channel */ |
194 | davinci_get_dma_params(prtd->slave_lch, &temp); | 207 | edma_read_slot(prtd->slave_lch, &temp); |
195 | davinci_set_dma_params(prtd->master_lch, &temp); | 208 | edma_write_slot(prtd->master_lch, &temp); |
196 | 209 | ||
197 | return 0; | 210 | return 0; |
198 | } | 211 | } |
@@ -208,7 +221,7 @@ davinci_pcm_pointer(struct snd_pcm_substream *substream) | |||
208 | 221 | ||
209 | spin_lock(&prtd->lock); | 222 | spin_lock(&prtd->lock); |
210 | 223 | ||
211 | davinci_dma_getposition(prtd->master_lch, &src, &dst); | 224 | edma_get_position(prtd->master_lch, &src, &dst); |
212 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 225 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
213 | count = src - runtime->dma_addr; | 226 | count = src - runtime->dma_addr; |
214 | else | 227 | else |
@@ -253,10 +266,10 @@ static int davinci_pcm_close(struct snd_pcm_substream *substream) | |||
253 | struct snd_pcm_runtime *runtime = substream->runtime; | 266 | struct snd_pcm_runtime *runtime = substream->runtime; |
254 | struct davinci_runtime_data *prtd = runtime->private_data; | 267 | struct davinci_runtime_data *prtd = runtime->private_data; |
255 | 268 | ||
256 | davinci_dma_unlink_lch(prtd->slave_lch, prtd->slave_lch); | 269 | edma_unlink(prtd->slave_lch); |
257 | 270 | ||
258 | davinci_free_dma(prtd->slave_lch); | 271 | edma_free_slot(prtd->slave_lch); |
259 | davinci_free_dma(prtd->master_lch); | 272 | edma_free_channel(prtd->master_lch); |
260 | 273 | ||
261 | kfree(prtd); | 274 | kfree(prtd); |
262 | 275 | ||
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 9fc908283371..5dbebf82249c 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig | |||
@@ -1,5 +1,8 @@ | |||
1 | config SND_SOC_OF_SIMPLE | 1 | config SND_SOC_OF_SIMPLE |
2 | tristate | 2 | tristate |
3 | |||
4 | config SND_MPC52xx_DMA | ||
5 | tristate | ||
3 | 6 | ||
4 | # ASoC platform support for the Freescale MPC8610 SOC. This compiles drivers | 7 | # ASoC platform support for the Freescale MPC8610 SOC. This compiles drivers |
5 | # for the SSI and the Elo DMA controller. You will still need to select | 8 | # for the SSI and the Elo DMA controller. You will still need to select |
@@ -22,7 +25,34 @@ config SND_SOC_MPC8610_HPCD | |||
22 | config SND_SOC_MPC5200_I2S | 25 | config SND_SOC_MPC5200_I2S |
23 | tristate "Freescale MPC5200 PSC in I2S mode driver" | 26 | tristate "Freescale MPC5200 PSC in I2S mode driver" |
24 | depends on PPC_MPC52xx && PPC_BESTCOMM | 27 | depends on PPC_MPC52xx && PPC_BESTCOMM |
25 | select SND_SOC_OF_SIMPLE | 28 | select SND_MPC52xx_DMA |
26 | select PPC_BESTCOMM_GEN_BD | 29 | select PPC_BESTCOMM_GEN_BD |
27 | help | 30 | help |
28 | Say Y here to support the MPC5200 PSCs in I2S mode. | 31 | Say Y here to support the MPC5200 PSCs in I2S mode. |
32 | |||
33 | config SND_SOC_MPC5200_AC97 | ||
34 | tristate "Freescale MPC5200 PSC in AC97 mode driver" | ||
35 | depends on PPC_MPC52xx && PPC_BESTCOMM | ||
36 | select AC97_BUS | ||
37 | select SND_MPC52xx_DMA | ||
38 | select PPC_BESTCOMM_GEN_BD | ||
39 | help | ||
40 | Say Y here to support the MPC5200 PSCs in AC97 mode. | ||
41 | |||
42 | config SND_MPC52xx_SOC_PCM030 | ||
43 | tristate "SoC AC97 Audio support for Phytec pcm030 and WM9712" | ||
44 | depends on PPC_MPC5200_SIMPLE && BROKEN | ||
45 | select SND_SOC_MPC5200_AC97 | ||
46 | select SND_SOC_WM9712 | ||
47 | help | ||
48 | Say Y if you want to add support for sound on the Phytec pcm030 | ||
49 | baseboard. | ||
50 | |||
51 | config SND_MPC52xx_SOC_EFIKA | ||
52 | tristate "SoC AC97 Audio support for bbplan Efika and STAC9766" | ||
53 | depends on PPC_EFIKA && BROKEN | ||
54 | select SND_SOC_MPC5200_AC97 | ||
55 | select SND_SOC_STAC9766 | ||
56 | help | ||
57 | Say Y if you want to add support for sound on the Efika. | ||
58 | |||
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index f85134c86387..a83a73967ec6 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile | |||
@@ -10,5 +10,12 @@ snd-soc-fsl-ssi-objs := fsl_ssi.o | |||
10 | snd-soc-fsl-dma-objs := fsl_dma.o | 10 | snd-soc-fsl-dma-objs := fsl_dma.o |
11 | obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o | 11 | obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o |
12 | 12 | ||
13 | # MPC5200 Platform Support | ||
14 | obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o | ||
13 | obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o | 15 | obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o |
16 | obj-$(CONFIG_SND_SOC_MPC5200_AC97) += mpc5200_psc_ac97.o | ||
17 | |||
18 | # MPC5200 Machine Support | ||
19 | obj-$(CONFIG_SND_MPC52xx_SOC_PCM030) += pcm030-audio-fabric.o | ||
20 | obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o | ||
14 | 21 | ||
diff --git a/sound/soc/fsl/efika-audio-fabric.c b/sound/soc/fsl/efika-audio-fabric.c new file mode 100644 index 000000000000..85b0e7569504 --- /dev/null +++ b/sound/soc/fsl/efika-audio-fabric.c | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * Efika driver for the PSC of the Freescale MPC52xx | ||
3 | * configured as AC97 interface | ||
4 | * | ||
5 | * Copyright 2008 Jon Smirl, Digispeaker | ||
6 | * Author: Jon Smirl <jonsmirl@gmail.com> | ||
7 | * | ||
8 | * This file is licensed under the terms of the GNU General Public License | ||
9 | * version 2. This program is licensed "as is" without any warranty of any | ||
10 | * kind, whether express or implied. | ||
11 | */ | ||
12 | |||
13 | #include <linux/init.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/device.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/of_device.h> | ||
19 | #include <linux/of_platform.h> | ||
20 | #include <linux/dma-mapping.h> | ||
21 | |||
22 | #include <sound/core.h> | ||
23 | #include <sound/pcm.h> | ||
24 | #include <sound/pcm_params.h> | ||
25 | #include <sound/initval.h> | ||
26 | #include <sound/soc.h> | ||
27 | #include <sound/soc-of-simple.h> | ||
28 | |||
29 | #include "mpc5200_dma.h" | ||
30 | #include "mpc5200_psc_ac97.h" | ||
31 | #include "../codecs/stac9766.h" | ||
32 | |||
33 | static struct snd_soc_device device; | ||
34 | static struct snd_soc_card card; | ||
35 | |||
36 | static struct snd_soc_dai_link efika_fabric_dai[] = { | ||
37 | { | ||
38 | .name = "AC97", | ||
39 | .stream_name = "AC97 Analog", | ||
40 | .codec_dai = &stac9766_dai[STAC9766_DAI_AC97_ANALOG], | ||
41 | .cpu_dai = &psc_ac97_dai[MPC5200_AC97_NORMAL], | ||
42 | }, | ||
43 | { | ||
44 | .name = "AC97", | ||
45 | .stream_name = "AC97 IEC958", | ||
46 | .codec_dai = &stac9766_dai[STAC9766_DAI_AC97_DIGITAL], | ||
47 | .cpu_dai = &psc_ac97_dai[MPC5200_AC97_SPDIF], | ||
48 | }, | ||
49 | }; | ||
50 | |||
51 | static __init int efika_fabric_init(void) | ||
52 | { | ||
53 | struct platform_device *pdev; | ||
54 | int rc; | ||
55 | |||
56 | if (!machine_is_compatible("bplan,efika")) | ||
57 | return -ENODEV; | ||
58 | |||
59 | card.platform = &mpc5200_audio_dma_platform; | ||
60 | card.name = "Efika"; | ||
61 | card.dai_link = efika_fabric_dai; | ||
62 | card.num_links = ARRAY_SIZE(efika_fabric_dai); | ||
63 | |||
64 | device.card = &card; | ||
65 | device.codec_dev = &soc_codec_dev_stac9766; | ||
66 | |||
67 | pdev = platform_device_alloc("soc-audio", 1); | ||
68 | if (!pdev) { | ||
69 | pr_err("efika_fabric_init: platform_device_alloc() failed\n"); | ||
70 | return -ENODEV; | ||
71 | } | ||
72 | |||
73 | platform_set_drvdata(pdev, &device); | ||
74 | device.dev = &pdev->dev; | ||
75 | |||
76 | rc = platform_device_add(pdev); | ||
77 | if (rc) { | ||
78 | pr_err("efika_fabric_init: platform_device_add() failed\n"); | ||
79 | return -ENODEV; | ||
80 | } | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | module_init(efika_fabric_init); | ||
85 | |||
86 | |||
87 | MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); | ||
88 | MODULE_DESCRIPTION(DRV_NAME ": mpc5200 Efika fabric driver"); | ||
89 | MODULE_LICENSE("GPL"); | ||
90 | |||
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 3711d8454d96..93f0f38a32c9 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c | |||
@@ -375,18 +375,14 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, | |||
375 | struct snd_pcm_runtime *first_runtime = | 375 | struct snd_pcm_runtime *first_runtime = |
376 | ssi_private->first_stream->runtime; | 376 | ssi_private->first_stream->runtime; |
377 | 377 | ||
378 | if (!first_runtime->rate || !first_runtime->sample_bits) { | 378 | if (!first_runtime->sample_bits) { |
379 | dev_err(substream->pcm->card->dev, | 379 | dev_err(substream->pcm->card->dev, |
380 | "set sample rate and size in %s stream first\n", | 380 | "set sample size in %s stream first\n", |
381 | substream->stream == SNDRV_PCM_STREAM_PLAYBACK | 381 | substream->stream == SNDRV_PCM_STREAM_PLAYBACK |
382 | ? "capture" : "playback"); | 382 | ? "capture" : "playback"); |
383 | return -EAGAIN; | 383 | return -EAGAIN; |
384 | } | 384 | } |
385 | 385 | ||
386 | snd_pcm_hw_constraint_minmax(substream->runtime, | ||
387 | SNDRV_PCM_HW_PARAM_RATE, | ||
388 | first_runtime->rate, first_runtime->rate); | ||
389 | |||
390 | /* If we're in synchronous mode, then we need to constrain | 386 | /* If we're in synchronous mode, then we need to constrain |
391 | * the sample size as well. We don't support independent sample | 387 | * the sample size as well. We don't support independent sample |
392 | * rates in asynchronous mode. | 388 | * rates in asynchronous mode. |
@@ -674,7 +670,7 @@ struct snd_soc_dai *fsl_ssi_create_dai(struct fsl_ssi_info *ssi_info) | |||
674 | ssi_private->dev = ssi_info->dev; | 670 | ssi_private->dev = ssi_info->dev; |
675 | ssi_private->asynchronous = ssi_info->asynchronous; | 671 | ssi_private->asynchronous = ssi_info->asynchronous; |
676 | 672 | ||
677 | ssi_private->dev->driver_data = fsl_ssi_dai; | 673 | dev_set_drvdata(ssi_private->dev, fsl_ssi_dai); |
678 | 674 | ||
679 | /* Initialize the the device_attribute structure */ | 675 | /* Initialize the the device_attribute structure */ |
680 | dev_attr->attr.name = "ssi-stats"; | 676 | dev_attr->attr.name = "ssi-stats"; |
@@ -693,6 +689,7 @@ struct snd_soc_dai *fsl_ssi_create_dai(struct fsl_ssi_info *ssi_info) | |||
693 | fsl_ssi_dai->name = ssi_private->name; | 689 | fsl_ssi_dai->name = ssi_private->name; |
694 | fsl_ssi_dai->id = ssi_info->id; | 690 | fsl_ssi_dai->id = ssi_info->id; |
695 | fsl_ssi_dai->dev = ssi_info->dev; | 691 | fsl_ssi_dai->dev = ssi_info->dev; |
692 | fsl_ssi_dai->symmetric_rates = 1; | ||
696 | 693 | ||
697 | ret = snd_soc_register_dai(fsl_ssi_dai); | 694 | ret = snd_soc_register_dai(fsl_ssi_dai); |
698 | if (ret != 0) { | 695 | if (ret != 0) { |
diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c new file mode 100644 index 000000000000..efec33a1c5bd --- /dev/null +++ b/sound/soc/fsl/mpc5200_dma.c | |||
@@ -0,0 +1,564 @@ | |||
1 | /* | ||
2 | * Freescale MPC5200 PSC DMA | ||
3 | * ALSA SoC Platform driver | ||
4 | * | ||
5 | * Copyright (C) 2008 Secret Lab Technologies Ltd. | ||
6 | * Copyright (C) 2009 Jon Smirl, Digispeaker | ||
7 | */ | ||
8 | |||
9 | #include <linux/module.h> | ||
10 | #include <linux/of_device.h> | ||
11 | |||
12 | #include <sound/soc.h> | ||
13 | |||
14 | #include <sysdev/bestcomm/bestcomm.h> | ||
15 | #include <sysdev/bestcomm/gen_bd.h> | ||
16 | #include <asm/mpc52xx_psc.h> | ||
17 | |||
18 | #include "mpc5200_dma.h" | ||
19 | |||
20 | /* | ||
21 | * Interrupt handlers | ||
22 | */ | ||
23 | static irqreturn_t psc_dma_status_irq(int irq, void *_psc_dma) | ||
24 | { | ||
25 | struct psc_dma *psc_dma = _psc_dma; | ||
26 | struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; | ||
27 | u16 isr; | ||
28 | |||
29 | isr = in_be16(®s->mpc52xx_psc_isr); | ||
30 | |||
31 | /* Playback underrun error */ | ||
32 | if (psc_dma->playback.active && (isr & MPC52xx_PSC_IMR_TXEMP)) | ||
33 | psc_dma->stats.underrun_count++; | ||
34 | |||
35 | /* Capture overrun error */ | ||
36 | if (psc_dma->capture.active && (isr & MPC52xx_PSC_IMR_ORERR)) | ||
37 | psc_dma->stats.overrun_count++; | ||
38 | |||
39 | out_8(®s->command, MPC52xx_PSC_RST_ERR_STAT); | ||
40 | |||
41 | return IRQ_HANDLED; | ||
42 | } | ||
43 | |||
44 | /** | ||
45 | * psc_dma_bcom_enqueue_next_buffer - Enqueue another audio buffer | ||
46 | * @s: pointer to stream private data structure | ||
47 | * | ||
48 | * Enqueues another audio period buffer into the bestcomm queue. | ||
49 | * | ||
50 | * Note: The routine must only be called when there is space available in | ||
51 | * the queue. Otherwise the enqueue will fail and the audio ring buffer | ||
52 | * will get out of sync | ||
53 | */ | ||
54 | static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s) | ||
55 | { | ||
56 | struct bcom_bd *bd; | ||
57 | |||
58 | /* Prepare and enqueue the next buffer descriptor */ | ||
59 | bd = bcom_prepare_next_buffer(s->bcom_task); | ||
60 | bd->status = s->period_bytes; | ||
61 | bd->data[0] = s->period_next_pt; | ||
62 | bcom_submit_next_buffer(s->bcom_task, NULL); | ||
63 | |||
64 | /* Update for next period */ | ||
65 | s->period_next_pt += s->period_bytes; | ||
66 | if (s->period_next_pt >= s->period_end) | ||
67 | s->period_next_pt = s->period_start; | ||
68 | } | ||
69 | |||
70 | static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s) | ||
71 | { | ||
72 | while (s->appl_ptr < s->runtime->control->appl_ptr) { | ||
73 | |||
74 | if (bcom_queue_full(s->bcom_task)) | ||
75 | return; | ||
76 | |||
77 | s->appl_ptr += s->period_size; | ||
78 | |||
79 | psc_dma_bcom_enqueue_next_buffer(s); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | /* Bestcomm DMA irq handler */ | ||
84 | static irqreturn_t psc_dma_bcom_irq_tx(int irq, void *_psc_dma_stream) | ||
85 | { | ||
86 | struct psc_dma_stream *s = _psc_dma_stream; | ||
87 | |||
88 | spin_lock(&s->psc_dma->lock); | ||
89 | /* For each finished period, dequeue the completed period buffer | ||
90 | * and enqueue a new one in it's place. */ | ||
91 | while (bcom_buffer_done(s->bcom_task)) { | ||
92 | bcom_retrieve_buffer(s->bcom_task, NULL, NULL); | ||
93 | |||
94 | s->period_current_pt += s->period_bytes; | ||
95 | if (s->period_current_pt >= s->period_end) | ||
96 | s->period_current_pt = s->period_start; | ||
97 | } | ||
98 | psc_dma_bcom_enqueue_tx(s); | ||
99 | spin_unlock(&s->psc_dma->lock); | ||
100 | |||
101 | /* If the stream is active, then also inform the PCM middle layer | ||
102 | * of the period finished event. */ | ||
103 | if (s->active) | ||
104 | snd_pcm_period_elapsed(s->stream); | ||
105 | |||
106 | return IRQ_HANDLED; | ||
107 | } | ||
108 | |||
109 | static irqreturn_t psc_dma_bcom_irq_rx(int irq, void *_psc_dma_stream) | ||
110 | { | ||
111 | struct psc_dma_stream *s = _psc_dma_stream; | ||
112 | |||
113 | spin_lock(&s->psc_dma->lock); | ||
114 | /* For each finished period, dequeue the completed period buffer | ||
115 | * and enqueue a new one in it's place. */ | ||
116 | while (bcom_buffer_done(s->bcom_task)) { | ||
117 | bcom_retrieve_buffer(s->bcom_task, NULL, NULL); | ||
118 | |||
119 | s->period_current_pt += s->period_bytes; | ||
120 | if (s->period_current_pt >= s->period_end) | ||
121 | s->period_current_pt = s->period_start; | ||
122 | |||
123 | psc_dma_bcom_enqueue_next_buffer(s); | ||
124 | } | ||
125 | spin_unlock(&s->psc_dma->lock); | ||
126 | |||
127 | /* If the stream is active, then also inform the PCM middle layer | ||
128 | * of the period finished event. */ | ||
129 | if (s->active) | ||
130 | snd_pcm_period_elapsed(s->stream); | ||
131 | |||
132 | return IRQ_HANDLED; | ||
133 | } | ||
134 | |||
135 | static int psc_dma_hw_free(struct snd_pcm_substream *substream) | ||
136 | { | ||
137 | snd_pcm_set_runtime_buffer(substream, NULL); | ||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | * psc_dma_trigger: start and stop the DMA transfer. | ||
143 | * | ||
144 | * This function is called by ALSA to start, stop, pause, and resume the DMA | ||
145 | * transfer of data. | ||
146 | */ | ||
147 | static int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd) | ||
148 | { | ||
149 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
150 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | ||
151 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
152 | struct psc_dma_stream *s; | ||
153 | struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; | ||
154 | u16 imr; | ||
155 | unsigned long flags; | ||
156 | int i; | ||
157 | |||
158 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
159 | s = &psc_dma->capture; | ||
160 | else | ||
161 | s = &psc_dma->playback; | ||
162 | |||
163 | dev_dbg(psc_dma->dev, "psc_dma_trigger(substream=%p, cmd=%i)" | ||
164 | " stream_id=%i\n", | ||
165 | substream, cmd, substream->pstr->stream); | ||
166 | |||
167 | switch (cmd) { | ||
168 | case SNDRV_PCM_TRIGGER_START: | ||
169 | s->period_bytes = frames_to_bytes(runtime, | ||
170 | runtime->period_size); | ||
171 | s->period_start = virt_to_phys(runtime->dma_area); | ||
172 | s->period_end = s->period_start + | ||
173 | (s->period_bytes * runtime->periods); | ||
174 | s->period_next_pt = s->period_start; | ||
175 | s->period_current_pt = s->period_start; | ||
176 | s->period_size = runtime->period_size; | ||
177 | s->active = 1; | ||
178 | |||
179 | /* track appl_ptr so that we have a better chance of detecting | ||
180 | * end of stream and not over running it. | ||
181 | */ | ||
182 | s->runtime = runtime; | ||
183 | s->appl_ptr = s->runtime->control->appl_ptr - | ||
184 | (runtime->period_size * runtime->periods); | ||
185 | |||
186 | /* Fill up the bestcomm bd queue and enable DMA. | ||
187 | * This will begin filling the PSC's fifo. | ||
188 | */ | ||
189 | spin_lock_irqsave(&psc_dma->lock, flags); | ||
190 | |||
191 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) { | ||
192 | bcom_gen_bd_rx_reset(s->bcom_task); | ||
193 | for (i = 0; i < runtime->periods; i++) | ||
194 | if (!bcom_queue_full(s->bcom_task)) | ||
195 | psc_dma_bcom_enqueue_next_buffer(s); | ||
196 | } else { | ||
197 | bcom_gen_bd_tx_reset(s->bcom_task); | ||
198 | psc_dma_bcom_enqueue_tx(s); | ||
199 | } | ||
200 | |||
201 | bcom_enable(s->bcom_task); | ||
202 | spin_unlock_irqrestore(&psc_dma->lock, flags); | ||
203 | |||
204 | out_8(®s->command, MPC52xx_PSC_RST_ERR_STAT); | ||
205 | |||
206 | break; | ||
207 | |||
208 | case SNDRV_PCM_TRIGGER_STOP: | ||
209 | s->active = 0; | ||
210 | |||
211 | spin_lock_irqsave(&psc_dma->lock, flags); | ||
212 | bcom_disable(s->bcom_task); | ||
213 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
214 | bcom_gen_bd_rx_reset(s->bcom_task); | ||
215 | else | ||
216 | bcom_gen_bd_tx_reset(s->bcom_task); | ||
217 | spin_unlock_irqrestore(&psc_dma->lock, flags); | ||
218 | |||
219 | break; | ||
220 | |||
221 | default: | ||
222 | dev_dbg(psc_dma->dev, "invalid command\n"); | ||
223 | return -EINVAL; | ||
224 | } | ||
225 | |||
226 | /* Update interrupt enable settings */ | ||
227 | imr = 0; | ||
228 | if (psc_dma->playback.active) | ||
229 | imr |= MPC52xx_PSC_IMR_TXEMP; | ||
230 | if (psc_dma->capture.active) | ||
231 | imr |= MPC52xx_PSC_IMR_ORERR; | ||
232 | out_be16(®s->isr_imr.imr, psc_dma->imr | imr); | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | |||
237 | |||
238 | /* --------------------------------------------------------------------- | ||
239 | * The PSC DMA 'ASoC platform' driver | ||
240 | * | ||
241 | * Can be referenced by an 'ASoC machine' driver | ||
242 | * This driver only deals with the audio bus; it doesn't have any | ||
243 | * interaction with the attached codec | ||
244 | */ | ||
245 | |||
246 | static const struct snd_pcm_hardware psc_dma_hardware = { | ||
247 | .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | | ||
248 | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
249 | SNDRV_PCM_INFO_BATCH, | ||
250 | .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE | | ||
251 | SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE, | ||
252 | .rate_min = 8000, | ||
253 | .rate_max = 48000, | ||
254 | .channels_min = 1, | ||
255 | .channels_max = 2, | ||
256 | .period_bytes_max = 1024 * 1024, | ||
257 | .period_bytes_min = 32, | ||
258 | .periods_min = 2, | ||
259 | .periods_max = 256, | ||
260 | .buffer_bytes_max = 2 * 1024 * 1024, | ||
261 | .fifo_size = 512, | ||
262 | }; | ||
263 | |||
264 | static int psc_dma_open(struct snd_pcm_substream *substream) | ||
265 | { | ||
266 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
267 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
268 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | ||
269 | struct psc_dma_stream *s; | ||
270 | int rc; | ||
271 | |||
272 | dev_dbg(psc_dma->dev, "psc_dma_open(substream=%p)\n", substream); | ||
273 | |||
274 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
275 | s = &psc_dma->capture; | ||
276 | else | ||
277 | s = &psc_dma->playback; | ||
278 | |||
279 | snd_soc_set_runtime_hwparams(substream, &psc_dma_hardware); | ||
280 | |||
281 | rc = snd_pcm_hw_constraint_integer(runtime, | ||
282 | SNDRV_PCM_HW_PARAM_PERIODS); | ||
283 | if (rc < 0) { | ||
284 | dev_err(substream->pcm->card->dev, "invalid buffer size\n"); | ||
285 | return rc; | ||
286 | } | ||
287 | |||
288 | s->stream = substream; | ||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static int psc_dma_close(struct snd_pcm_substream *substream) | ||
293 | { | ||
294 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
295 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | ||
296 | struct psc_dma_stream *s; | ||
297 | |||
298 | dev_dbg(psc_dma->dev, "psc_dma_close(substream=%p)\n", substream); | ||
299 | |||
300 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
301 | s = &psc_dma->capture; | ||
302 | else | ||
303 | s = &psc_dma->playback; | ||
304 | |||
305 | if (!psc_dma->playback.active && | ||
306 | !psc_dma->capture.active) { | ||
307 | |||
308 | /* Disable all interrupts and reset the PSC */ | ||
309 | out_be16(&psc_dma->psc_regs->isr_imr.imr, psc_dma->imr); | ||
310 | out_8(&psc_dma->psc_regs->command, 4 << 4); /* reset error */ | ||
311 | } | ||
312 | s->stream = NULL; | ||
313 | return 0; | ||
314 | } | ||
315 | |||
316 | static snd_pcm_uframes_t | ||
317 | psc_dma_pointer(struct snd_pcm_substream *substream) | ||
318 | { | ||
319 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
320 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | ||
321 | struct psc_dma_stream *s; | ||
322 | dma_addr_t count; | ||
323 | |||
324 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
325 | s = &psc_dma->capture; | ||
326 | else | ||
327 | s = &psc_dma->playback; | ||
328 | |||
329 | count = s->period_current_pt - s->period_start; | ||
330 | |||
331 | return bytes_to_frames(substream->runtime, count); | ||
332 | } | ||
333 | |||
334 | static int | ||
335 | psc_dma_hw_params(struct snd_pcm_substream *substream, | ||
336 | struct snd_pcm_hw_params *params) | ||
337 | { | ||
338 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); | ||
339 | |||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | static struct snd_pcm_ops psc_dma_ops = { | ||
344 | .open = psc_dma_open, | ||
345 | .close = psc_dma_close, | ||
346 | .hw_free = psc_dma_hw_free, | ||
347 | .ioctl = snd_pcm_lib_ioctl, | ||
348 | .pointer = psc_dma_pointer, | ||
349 | .trigger = psc_dma_trigger, | ||
350 | .hw_params = psc_dma_hw_params, | ||
351 | }; | ||
352 | |||
353 | static u64 psc_dma_dmamask = 0xffffffff; | ||
354 | static int psc_dma_new(struct snd_card *card, struct snd_soc_dai *dai, | ||
355 | struct snd_pcm *pcm) | ||
356 | { | ||
357 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; | ||
358 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | ||
359 | size_t size = psc_dma_hardware.buffer_bytes_max; | ||
360 | int rc = 0; | ||
361 | |||
362 | dev_dbg(rtd->socdev->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", | ||
363 | card, dai, pcm); | ||
364 | |||
365 | if (!card->dev->dma_mask) | ||
366 | card->dev->dma_mask = &psc_dma_dmamask; | ||
367 | if (!card->dev->coherent_dma_mask) | ||
368 | card->dev->coherent_dma_mask = 0xffffffff; | ||
369 | |||
370 | if (pcm->streams[0].substream) { | ||
371 | rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev, | ||
372 | size, &pcm->streams[0].substream->dma_buffer); | ||
373 | if (rc) | ||
374 | goto playback_alloc_err; | ||
375 | } | ||
376 | |||
377 | if (pcm->streams[1].substream) { | ||
378 | rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev, | ||
379 | size, &pcm->streams[1].substream->dma_buffer); | ||
380 | if (rc) | ||
381 | goto capture_alloc_err; | ||
382 | } | ||
383 | |||
384 | if (rtd->socdev->card->codec->ac97) | ||
385 | rtd->socdev->card->codec->ac97->private_data = psc_dma; | ||
386 | |||
387 | return 0; | ||
388 | |||
389 | capture_alloc_err: | ||
390 | if (pcm->streams[0].substream) | ||
391 | snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer); | ||
392 | |||
393 | playback_alloc_err: | ||
394 | dev_err(card->dev, "Cannot allocate buffer(s)\n"); | ||
395 | |||
396 | return -ENOMEM; | ||
397 | } | ||
398 | |||
399 | static void psc_dma_free(struct snd_pcm *pcm) | ||
400 | { | ||
401 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; | ||
402 | struct snd_pcm_substream *substream; | ||
403 | int stream; | ||
404 | |||
405 | dev_dbg(rtd->socdev->dev, "psc_dma_free(pcm=%p)\n", pcm); | ||
406 | |||
407 | for (stream = 0; stream < 2; stream++) { | ||
408 | substream = pcm->streams[stream].substream; | ||
409 | if (substream) { | ||
410 | snd_dma_free_pages(&substream->dma_buffer); | ||
411 | substream->dma_buffer.area = NULL; | ||
412 | substream->dma_buffer.addr = 0; | ||
413 | } | ||
414 | } | ||
415 | } | ||
416 | |||
417 | struct snd_soc_platform mpc5200_audio_dma_platform = { | ||
418 | .name = "mpc5200-psc-audio", | ||
419 | .pcm_ops = &psc_dma_ops, | ||
420 | .pcm_new = &psc_dma_new, | ||
421 | .pcm_free = &psc_dma_free, | ||
422 | }; | ||
423 | EXPORT_SYMBOL_GPL(mpc5200_audio_dma_platform); | ||
424 | |||
425 | int mpc5200_audio_dma_create(struct of_device *op) | ||
426 | { | ||
427 | phys_addr_t fifo; | ||
428 | struct psc_dma *psc_dma; | ||
429 | struct resource res; | ||
430 | int size, irq, rc; | ||
431 | const __be32 *prop; | ||
432 | void __iomem *regs; | ||
433 | |||
434 | /* Fetch the registers and IRQ of the PSC */ | ||
435 | irq = irq_of_parse_and_map(op->node, 0); | ||
436 | if (of_address_to_resource(op->node, 0, &res)) { | ||
437 | dev_err(&op->dev, "Missing reg property\n"); | ||
438 | return -ENODEV; | ||
439 | } | ||
440 | regs = ioremap(res.start, 1 + res.end - res.start); | ||
441 | if (!regs) { | ||
442 | dev_err(&op->dev, "Could not map registers\n"); | ||
443 | return -ENODEV; | ||
444 | } | ||
445 | |||
446 | /* Allocate and initialize the driver private data */ | ||
447 | psc_dma = kzalloc(sizeof *psc_dma, GFP_KERNEL); | ||
448 | if (!psc_dma) { | ||
449 | iounmap(regs); | ||
450 | return -ENOMEM; | ||
451 | } | ||
452 | |||
453 | /* Get the PSC ID */ | ||
454 | prop = of_get_property(op->node, "cell-index", &size); | ||
455 | if (!prop || size < sizeof *prop) | ||
456 | return -ENODEV; | ||
457 | |||
458 | spin_lock_init(&psc_dma->lock); | ||
459 | psc_dma->id = be32_to_cpu(*prop); | ||
460 | psc_dma->irq = irq; | ||
461 | psc_dma->psc_regs = regs; | ||
462 | psc_dma->fifo_regs = regs + sizeof *psc_dma->psc_regs; | ||
463 | psc_dma->dev = &op->dev; | ||
464 | psc_dma->playback.psc_dma = psc_dma; | ||
465 | psc_dma->capture.psc_dma = psc_dma; | ||
466 | snprintf(psc_dma->name, sizeof psc_dma->name, "PSC%u", psc_dma->id); | ||
467 | |||
468 | /* Find the address of the fifo data registers and setup the | ||
469 | * DMA tasks */ | ||
470 | fifo = res.start + offsetof(struct mpc52xx_psc, buffer.buffer_32); | ||
471 | psc_dma->capture.bcom_task = | ||
472 | bcom_psc_gen_bd_rx_init(psc_dma->id, 10, fifo, 512); | ||
473 | psc_dma->playback.bcom_task = | ||
474 | bcom_psc_gen_bd_tx_init(psc_dma->id, 10, fifo); | ||
475 | if (!psc_dma->capture.bcom_task || | ||
476 | !psc_dma->playback.bcom_task) { | ||
477 | dev_err(&op->dev, "Could not allocate bestcomm tasks\n"); | ||
478 | iounmap(regs); | ||
479 | kfree(psc_dma); | ||
480 | return -ENODEV; | ||
481 | } | ||
482 | |||
483 | /* Disable all interrupts and reset the PSC */ | ||
484 | out_be16(&psc_dma->psc_regs->isr_imr.imr, psc_dma->imr); | ||
485 | /* reset receiver */ | ||
486 | out_8(&psc_dma->psc_regs->command, MPC52xx_PSC_RST_RX); | ||
487 | /* reset transmitter */ | ||
488 | out_8(&psc_dma->psc_regs->command, MPC52xx_PSC_RST_TX); | ||
489 | /* reset error */ | ||
490 | out_8(&psc_dma->psc_regs->command, MPC52xx_PSC_RST_ERR_STAT); | ||
491 | /* reset mode */ | ||
492 | out_8(&psc_dma->psc_regs->command, MPC52xx_PSC_SEL_MODE_REG_1); | ||
493 | |||
494 | /* Set up mode register; | ||
495 | * First write: RxRdy (FIFO Alarm) generates rx FIFO irq | ||
496 | * Second write: register Normal mode for non loopback | ||
497 | */ | ||
498 | out_8(&psc_dma->psc_regs->mode, 0); | ||
499 | out_8(&psc_dma->psc_regs->mode, 0); | ||
500 | |||
501 | /* Set the TX and RX fifo alarm thresholds */ | ||
502 | out_be16(&psc_dma->fifo_regs->rfalarm, 0x100); | ||
503 | out_8(&psc_dma->fifo_regs->rfcntl, 0x4); | ||
504 | out_be16(&psc_dma->fifo_regs->tfalarm, 0x100); | ||
505 | out_8(&psc_dma->fifo_regs->tfcntl, 0x7); | ||
506 | |||
507 | /* Lookup the IRQ numbers */ | ||
508 | psc_dma->playback.irq = | ||
509 | bcom_get_task_irq(psc_dma->playback.bcom_task); | ||
510 | psc_dma->capture.irq = | ||
511 | bcom_get_task_irq(psc_dma->capture.bcom_task); | ||
512 | |||
513 | rc = request_irq(psc_dma->irq, &psc_dma_status_irq, IRQF_SHARED, | ||
514 | "psc-dma-status", psc_dma); | ||
515 | rc |= request_irq(psc_dma->capture.irq, | ||
516 | &psc_dma_bcom_irq_rx, IRQF_SHARED, | ||
517 | "psc-dma-capture", &psc_dma->capture); | ||
518 | rc |= request_irq(psc_dma->playback.irq, | ||
519 | &psc_dma_bcom_irq_tx, IRQF_SHARED, | ||
520 | "psc-dma-playback", &psc_dma->playback); | ||
521 | if (rc) { | ||
522 | free_irq(psc_dma->irq, psc_dma); | ||
523 | free_irq(psc_dma->capture.irq, | ||
524 | &psc_dma->capture); | ||
525 | free_irq(psc_dma->playback.irq, | ||
526 | &psc_dma->playback); | ||
527 | return -ENODEV; | ||
528 | } | ||
529 | |||
530 | /* Save what we've done so it can be found again later */ | ||
531 | dev_set_drvdata(&op->dev, psc_dma); | ||
532 | |||
533 | /* Tell the ASoC OF helpers about it */ | ||
534 | return snd_soc_register_platform(&mpc5200_audio_dma_platform); | ||
535 | } | ||
536 | EXPORT_SYMBOL_GPL(mpc5200_audio_dma_create); | ||
537 | |||
538 | int mpc5200_audio_dma_destroy(struct of_device *op) | ||
539 | { | ||
540 | struct psc_dma *psc_dma = dev_get_drvdata(&op->dev); | ||
541 | |||
542 | dev_dbg(&op->dev, "mpc5200_audio_dma_destroy()\n"); | ||
543 | |||
544 | snd_soc_unregister_platform(&mpc5200_audio_dma_platform); | ||
545 | |||
546 | bcom_gen_bd_rx_release(psc_dma->capture.bcom_task); | ||
547 | bcom_gen_bd_tx_release(psc_dma->playback.bcom_task); | ||
548 | |||
549 | /* Release irqs */ | ||
550 | free_irq(psc_dma->irq, psc_dma); | ||
551 | free_irq(psc_dma->capture.irq, &psc_dma->capture); | ||
552 | free_irq(psc_dma->playback.irq, &psc_dma->playback); | ||
553 | |||
554 | iounmap(psc_dma->psc_regs); | ||
555 | kfree(psc_dma); | ||
556 | dev_set_drvdata(&op->dev, NULL); | ||
557 | |||
558 | return 0; | ||
559 | } | ||
560 | EXPORT_SYMBOL_GPL(mpc5200_audio_dma_destroy); | ||
561 | |||
562 | MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); | ||
563 | MODULE_DESCRIPTION("Freescale MPC5200 PSC in DMA mode ASoC Driver"); | ||
564 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h new file mode 100644 index 000000000000..2000803f06a7 --- /dev/null +++ b/sound/soc/fsl/mpc5200_dma.h | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * Freescale MPC5200 Audio DMA driver | ||
3 | */ | ||
4 | |||
5 | #ifndef __SOUND_SOC_FSL_MPC5200_DMA_H__ | ||
6 | #define __SOUND_SOC_FSL_MPC5200_DMA_H__ | ||
7 | |||
8 | #define PSC_STREAM_NAME_LEN 32 | ||
9 | |||
10 | /** | ||
11 | * psc_ac97_stream - Data specific to a single stream (playback or capture) | ||
12 | * @active: flag indicating if the stream is active | ||
13 | * @psc_dma: pointer back to parent psc_dma data structure | ||
14 | * @bcom_task: bestcomm task structure | ||
15 | * @irq: irq number for bestcomm task | ||
16 | * @period_start: physical address of start of DMA region | ||
17 | * @period_end: physical address of end of DMA region | ||
18 | * @period_next_pt: physical address of next DMA buffer to enqueue | ||
19 | * @period_bytes: size of DMA period in bytes | ||
20 | */ | ||
21 | struct psc_dma_stream { | ||
22 | struct snd_pcm_runtime *runtime; | ||
23 | snd_pcm_uframes_t appl_ptr; | ||
24 | |||
25 | int active; | ||
26 | struct psc_dma *psc_dma; | ||
27 | struct bcom_task *bcom_task; | ||
28 | int irq; | ||
29 | struct snd_pcm_substream *stream; | ||
30 | dma_addr_t period_start; | ||
31 | dma_addr_t period_end; | ||
32 | dma_addr_t period_next_pt; | ||
33 | dma_addr_t period_current_pt; | ||
34 | int period_bytes; | ||
35 | int period_size; | ||
36 | }; | ||
37 | |||
38 | /** | ||
39 | * psc_dma - Private driver data | ||
40 | * @name: short name for this device ("PSC0", "PSC1", etc) | ||
41 | * @psc_regs: pointer to the PSC's registers | ||
42 | * @fifo_regs: pointer to the PSC's FIFO registers | ||
43 | * @irq: IRQ of this PSC | ||
44 | * @dev: struct device pointer | ||
45 | * @dai: the CPU DAI for this device | ||
46 | * @sicr: Base value used in serial interface control register; mode is ORed | ||
47 | * with this value. | ||
48 | * @playback: Playback stream context data | ||
49 | * @capture: Capture stream context data | ||
50 | */ | ||
51 | struct psc_dma { | ||
52 | char name[32]; | ||
53 | struct mpc52xx_psc __iomem *psc_regs; | ||
54 | struct mpc52xx_psc_fifo __iomem *fifo_regs; | ||
55 | unsigned int irq; | ||
56 | struct device *dev; | ||
57 | spinlock_t lock; | ||
58 | u32 sicr; | ||
59 | uint sysclk; | ||
60 | int imr; | ||
61 | int id; | ||
62 | unsigned int slots; | ||
63 | |||
64 | /* per-stream data */ | ||
65 | struct psc_dma_stream playback; | ||
66 | struct psc_dma_stream capture; | ||
67 | |||
68 | /* Statistics */ | ||
69 | struct { | ||
70 | unsigned long overrun_count; | ||
71 | unsigned long underrun_count; | ||
72 | } stats; | ||
73 | }; | ||
74 | |||
75 | int mpc5200_audio_dma_create(struct of_device *op); | ||
76 | int mpc5200_audio_dma_destroy(struct of_device *op); | ||
77 | |||
78 | extern struct snd_soc_platform mpc5200_audio_dma_platform; | ||
79 | |||
80 | #endif /* __SOUND_SOC_FSL_MPC5200_DMA_H__ */ | ||
diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c new file mode 100644 index 000000000000..794a247b3eb5 --- /dev/null +++ b/sound/soc/fsl/mpc5200_psc_ac97.c | |||
@@ -0,0 +1,329 @@ | |||
1 | /* | ||
2 | * linux/sound/mpc5200-ac97.c -- AC97 support for the Freescale MPC52xx chip. | ||
3 | * | ||
4 | * Copyright (C) 2009 Jon Smirl, Digispeaker | ||
5 | * Author: Jon Smirl <jonsmirl@gmail.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/of_device.h> | ||
14 | #include <linux/of_platform.h> | ||
15 | |||
16 | #include <sound/pcm.h> | ||
17 | #include <sound/pcm_params.h> | ||
18 | #include <sound/soc.h> | ||
19 | |||
20 | #include <asm/time.h> | ||
21 | #include <asm/delay.h> | ||
22 | #include <asm/mpc52xx_psc.h> | ||
23 | |||
24 | #include "mpc5200_dma.h" | ||
25 | #include "mpc5200_psc_ac97.h" | ||
26 | |||
27 | #define DRV_NAME "mpc5200-psc-ac97" | ||
28 | |||
29 | /* ALSA only supports a single AC97 device so static is recommend here */ | ||
30 | static struct psc_dma *psc_dma; | ||
31 | |||
32 | static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) | ||
33 | { | ||
34 | int status; | ||
35 | unsigned int val; | ||
36 | |||
37 | /* Wait for command send status zero = ready */ | ||
38 | status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) & | ||
39 | MPC52xx_PSC_SR_CMDSEND), 100, 0); | ||
40 | if (status == 0) { | ||
41 | pr_err("timeout on ac97 bus (rdy)\n"); | ||
42 | return -ENODEV; | ||
43 | } | ||
44 | /* Send the read */ | ||
45 | out_be32(&psc_dma->psc_regs->ac97_cmd, (1<<31) | ((reg & 0x7f) << 24)); | ||
46 | |||
47 | /* Wait for the answer */ | ||
48 | status = spin_event_timeout((in_be16(&psc_dma->psc_regs->sr_csr.status) & | ||
49 | MPC52xx_PSC_SR_DATA_VAL), 100, 0); | ||
50 | if (status == 0) { | ||
51 | pr_err("timeout on ac97 read (val) %x\n", | ||
52 | in_be16(&psc_dma->psc_regs->sr_csr.status)); | ||
53 | return -ENODEV; | ||
54 | } | ||
55 | /* Get the data */ | ||
56 | val = in_be32(&psc_dma->psc_regs->ac97_data); | ||
57 | if (((val >> 24) & 0x7f) != reg) { | ||
58 | pr_err("reg echo error on ac97 read\n"); | ||
59 | return -ENODEV; | ||
60 | } | ||
61 | val = (val >> 8) & 0xffff; | ||
62 | |||
63 | return (unsigned short) val; | ||
64 | } | ||
65 | |||
66 | static void psc_ac97_write(struct snd_ac97 *ac97, | ||
67 | unsigned short reg, unsigned short val) | ||
68 | { | ||
69 | int status; | ||
70 | |||
71 | /* Wait for command status zero = ready */ | ||
72 | status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) & | ||
73 | MPC52xx_PSC_SR_CMDSEND), 100, 0); | ||
74 | if (status == 0) { | ||
75 | pr_err("timeout on ac97 bus (write)\n"); | ||
76 | return; | ||
77 | } | ||
78 | /* Write data */ | ||
79 | out_be32(&psc_dma->psc_regs->ac97_cmd, | ||
80 | ((reg & 0x7f) << 24) | (val << 8)); | ||
81 | } | ||
82 | |||
83 | static void psc_ac97_warm_reset(struct snd_ac97 *ac97) | ||
84 | { | ||
85 | struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; | ||
86 | |||
87 | out_be32(®s->sicr, psc_dma->sicr | MPC52xx_PSC_SICR_AWR); | ||
88 | udelay(3); | ||
89 | out_be32(®s->sicr, psc_dma->sicr); | ||
90 | } | ||
91 | |||
92 | static void psc_ac97_cold_reset(struct snd_ac97 *ac97) | ||
93 | { | ||
94 | struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; | ||
95 | |||
96 | /* Do a cold reset */ | ||
97 | out_8(®s->op1, MPC52xx_PSC_OP_RES); | ||
98 | udelay(10); | ||
99 | out_8(®s->op0, MPC52xx_PSC_OP_RES); | ||
100 | udelay(50); | ||
101 | psc_ac97_warm_reset(ac97); | ||
102 | } | ||
103 | |||
104 | struct snd_ac97_bus_ops soc_ac97_ops = { | ||
105 | .read = psc_ac97_read, | ||
106 | .write = psc_ac97_write, | ||
107 | .reset = psc_ac97_cold_reset, | ||
108 | .warm_reset = psc_ac97_warm_reset, | ||
109 | }; | ||
110 | EXPORT_SYMBOL_GPL(soc_ac97_ops); | ||
111 | |||
112 | static int psc_ac97_hw_analog_params(struct snd_pcm_substream *substream, | ||
113 | struct snd_pcm_hw_params *params, | ||
114 | struct snd_soc_dai *cpu_dai) | ||
115 | { | ||
116 | struct psc_dma *psc_dma = cpu_dai->private_data; | ||
117 | |||
118 | dev_dbg(psc_dma->dev, "%s(substream=%p) p_size=%i p_bytes=%i" | ||
119 | " periods=%i buffer_size=%i buffer_bytes=%i channels=%i" | ||
120 | " rate=%i format=%i\n", | ||
121 | __func__, substream, params_period_size(params), | ||
122 | params_period_bytes(params), params_periods(params), | ||
123 | params_buffer_size(params), params_buffer_bytes(params), | ||
124 | params_channels(params), params_rate(params), | ||
125 | params_format(params)); | ||
126 | |||
127 | |||
128 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) { | ||
129 | if (params_channels(params) == 1) | ||
130 | psc_dma->slots |= 0x00000100; | ||
131 | else | ||
132 | psc_dma->slots |= 0x00000300; | ||
133 | } else { | ||
134 | if (params_channels(params) == 1) | ||
135 | psc_dma->slots |= 0x01000000; | ||
136 | else | ||
137 | psc_dma->slots |= 0x03000000; | ||
138 | } | ||
139 | out_be32(&psc_dma->psc_regs->ac97_slots, psc_dma->slots); | ||
140 | |||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static int psc_ac97_hw_digital_params(struct snd_pcm_substream *substream, | ||
145 | struct snd_pcm_hw_params *params, | ||
146 | struct snd_soc_dai *cpu_dai) | ||
147 | { | ||
148 | struct psc_dma *psc_dma = cpu_dai->private_data; | ||
149 | |||
150 | if (params_channels(params) == 1) | ||
151 | out_be32(&psc_dma->psc_regs->ac97_slots, 0x01000000); | ||
152 | else | ||
153 | out_be32(&psc_dma->psc_regs->ac97_slots, 0x03000000); | ||
154 | |||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | static int psc_ac97_trigger(struct snd_pcm_substream *substream, int cmd, | ||
159 | struct snd_soc_dai *dai) | ||
160 | { | ||
161 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
162 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; | ||
163 | |||
164 | switch (cmd) { | ||
165 | case SNDRV_PCM_TRIGGER_STOP: | ||
166 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
167 | psc_dma->slots &= 0xFFFF0000; | ||
168 | else | ||
169 | psc_dma->slots &= 0x0000FFFF; | ||
170 | |||
171 | out_be32(&psc_dma->psc_regs->ac97_slots, psc_dma->slots); | ||
172 | break; | ||
173 | } | ||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | static int psc_ac97_probe(struct platform_device *pdev, | ||
178 | struct snd_soc_dai *cpu_dai) | ||
179 | { | ||
180 | struct psc_dma *psc_dma = cpu_dai->private_data; | ||
181 | struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; | ||
182 | |||
183 | /* Go */ | ||
184 | out_8(®s->command, MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE); | ||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | /* --------------------------------------------------------------------- | ||
189 | * ALSA SoC Bindings | ||
190 | * | ||
191 | * - Digital Audio Interface (DAI) template | ||
192 | * - create/destroy dai hooks | ||
193 | */ | ||
194 | |||
195 | /** | ||
196 | * psc_ac97_dai_template: template CPU Digital Audio Interface | ||
197 | */ | ||
198 | static struct snd_soc_dai_ops psc_ac97_analog_ops = { | ||
199 | .hw_params = psc_ac97_hw_analog_params, | ||
200 | .trigger = psc_ac97_trigger, | ||
201 | }; | ||
202 | |||
203 | static struct snd_soc_dai_ops psc_ac97_digital_ops = { | ||
204 | .hw_params = psc_ac97_hw_digital_params, | ||
205 | }; | ||
206 | |||
207 | struct snd_soc_dai psc_ac97_dai[] = { | ||
208 | { | ||
209 | .name = "AC97", | ||
210 | .ac97_control = 1, | ||
211 | .probe = psc_ac97_probe, | ||
212 | .playback = { | ||
213 | .channels_min = 1, | ||
214 | .channels_max = 6, | ||
215 | .rates = SNDRV_PCM_RATE_8000_48000, | ||
216 | .formats = SNDRV_PCM_FMTBIT_S32_BE, | ||
217 | }, | ||
218 | .capture = { | ||
219 | .channels_min = 1, | ||
220 | .channels_max = 2, | ||
221 | .rates = SNDRV_PCM_RATE_8000_48000, | ||
222 | .formats = SNDRV_PCM_FMTBIT_S32_BE, | ||
223 | }, | ||
224 | .ops = &psc_ac97_analog_ops, | ||
225 | }, | ||
226 | { | ||
227 | .name = "SPDIF", | ||
228 | .ac97_control = 1, | ||
229 | .playback = { | ||
230 | .channels_min = 1, | ||
231 | .channels_max = 2, | ||
232 | .rates = SNDRV_PCM_RATE_32000 | \ | ||
233 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, | ||
234 | .formats = SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE, | ||
235 | }, | ||
236 | .ops = &psc_ac97_digital_ops, | ||
237 | } }; | ||
238 | EXPORT_SYMBOL_GPL(psc_ac97_dai); | ||
239 | |||
240 | |||
241 | |||
242 | /* --------------------------------------------------------------------- | ||
243 | * OF platform bus binding code: | ||
244 | * - Probe/remove operations | ||
245 | * - OF device match table | ||
246 | */ | ||
247 | static int __devinit psc_ac97_of_probe(struct of_device *op, | ||
248 | const struct of_device_id *match) | ||
249 | { | ||
250 | int rc, i; | ||
251 | struct snd_ac97 ac97; | ||
252 | struct mpc52xx_psc __iomem *regs; | ||
253 | |||
254 | rc = mpc5200_audio_dma_create(op); | ||
255 | if (rc != 0) | ||
256 | return rc; | ||
257 | |||
258 | for (i = 0; i < ARRAY_SIZE(psc_ac97_dai); i++) | ||
259 | psc_ac97_dai[i].dev = &op->dev; | ||
260 | |||
261 | rc = snd_soc_register_dais(psc_ac97_dai, ARRAY_SIZE(psc_ac97_dai)); | ||
262 | if (rc != 0) { | ||
263 | dev_err(&op->dev, "Failed to register DAI\n"); | ||
264 | return rc; | ||
265 | } | ||
266 | |||
267 | psc_dma = dev_get_drvdata(&op->dev); | ||
268 | regs = psc_dma->psc_regs; | ||
269 | ac97.private_data = psc_dma; | ||
270 | |||
271 | for (i = 0; i < ARRAY_SIZE(psc_ac97_dai); i++) | ||
272 | psc_ac97_dai[i].private_data = psc_dma; | ||
273 | |||
274 | psc_dma->imr = 0; | ||
275 | out_be16(&psc_dma->psc_regs->isr_imr.imr, psc_dma->imr); | ||
276 | |||
277 | /* Configure the serial interface mode to AC97 */ | ||
278 | psc_dma->sicr = MPC52xx_PSC_SICR_SIM_AC97 | MPC52xx_PSC_SICR_ENAC97; | ||
279 | out_be32(®s->sicr, psc_dma->sicr); | ||
280 | |||
281 | /* No slots active */ | ||
282 | out_be32(®s->ac97_slots, 0x00000000); | ||
283 | |||
284 | return 0; | ||
285 | } | ||
286 | |||
287 | static int __devexit psc_ac97_of_remove(struct of_device *op) | ||
288 | { | ||
289 | return mpc5200_audio_dma_destroy(op); | ||
290 | } | ||
291 | |||
292 | /* Match table for of_platform binding */ | ||
293 | static struct of_device_id psc_ac97_match[] __devinitdata = { | ||
294 | { .compatible = "fsl,mpc5200-psc-ac97", }, | ||
295 | { .compatible = "fsl,mpc5200b-psc-ac97", }, | ||
296 | {} | ||
297 | }; | ||
298 | MODULE_DEVICE_TABLE(of, psc_ac97_match); | ||
299 | |||
300 | static struct of_platform_driver psc_ac97_driver = { | ||
301 | .match_table = psc_ac97_match, | ||
302 | .probe = psc_ac97_of_probe, | ||
303 | .remove = __devexit_p(psc_ac97_of_remove), | ||
304 | .driver = { | ||
305 | .name = "mpc5200-psc-ac97", | ||
306 | .owner = THIS_MODULE, | ||
307 | }, | ||
308 | }; | ||
309 | |||
310 | /* --------------------------------------------------------------------- | ||
311 | * Module setup and teardown; simply register the of_platform driver | ||
312 | * for the PSC in AC97 mode. | ||
313 | */ | ||
314 | static int __init psc_ac97_init(void) | ||
315 | { | ||
316 | return of_register_platform_driver(&psc_ac97_driver); | ||
317 | } | ||
318 | module_init(psc_ac97_init); | ||
319 | |||
320 | static void __exit psc_ac97_exit(void) | ||
321 | { | ||
322 | of_unregister_platform_driver(&psc_ac97_driver); | ||
323 | } | ||
324 | module_exit(psc_ac97_exit); | ||
325 | |||
326 | MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); | ||
327 | MODULE_DESCRIPTION("mpc5200 AC97 module"); | ||
328 | MODULE_LICENSE("GPL"); | ||
329 | |||
diff --git a/sound/soc/fsl/mpc5200_psc_ac97.h b/sound/soc/fsl/mpc5200_psc_ac97.h new file mode 100644 index 000000000000..4bc18c35c369 --- /dev/null +++ b/sound/soc/fsl/mpc5200_psc_ac97.h | |||
@@ -0,0 +1,15 @@ | |||
1 | /* | ||
2 | * Freescale MPC5200 PSC in AC97 mode | ||
3 | * ALSA SoC Digital Audio Interface (DAI) driver | ||
4 | * | ||
5 | */ | ||
6 | |||
7 | #ifndef __SOUND_SOC_FSL_MPC52xx_PSC_AC97_H__ | ||
8 | #define __SOUND_SOC_FSL_MPC52xx_PSC_AC97_H__ | ||
9 | |||
10 | extern struct snd_soc_dai psc_ac97_dai[]; | ||
11 | |||
12 | #define MPC5200_AC97_NORMAL 0 | ||
13 | #define MPC5200_AC97_SPDIF 1 | ||
14 | |||
15 | #endif /* __SOUND_SOC_FSL_MPC52xx_PSC_AC97_H__ */ | ||
diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c index 1111c710118a..ce8de90fb94a 100644 --- a/sound/soc/fsl/mpc5200_psc_i2s.c +++ b/sound/soc/fsl/mpc5200_psc_i2s.c | |||
@@ -3,31 +3,21 @@ | |||
3 | * ALSA SoC Digital Audio Interface (DAI) driver | 3 | * ALSA SoC Digital Audio Interface (DAI) driver |
4 | * | 4 | * |
5 | * Copyright (C) 2008 Secret Lab Technologies Ltd. | 5 | * Copyright (C) 2008 Secret Lab Technologies Ltd. |
6 | * Copyright (C) 2009 Jon Smirl, Digispeaker | ||
6 | */ | 7 | */ |
7 | 8 | ||
8 | #include <linux/init.h> | ||
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/interrupt.h> | ||
11 | #include <linux/device.h> | ||
12 | #include <linux/delay.h> | ||
13 | #include <linux/of_device.h> | 10 | #include <linux/of_device.h> |
14 | #include <linux/of_platform.h> | 11 | #include <linux/of_platform.h> |
15 | #include <linux/dma-mapping.h> | ||
16 | 12 | ||
17 | #include <sound/core.h> | ||
18 | #include <sound/pcm.h> | 13 | #include <sound/pcm.h> |
19 | #include <sound/pcm_params.h> | 14 | #include <sound/pcm_params.h> |
20 | #include <sound/initval.h> | ||
21 | #include <sound/soc.h> | 15 | #include <sound/soc.h> |
22 | #include <sound/soc-of-simple.h> | ||
23 | 16 | ||
24 | #include <sysdev/bestcomm/bestcomm.h> | ||
25 | #include <sysdev/bestcomm/gen_bd.h> | ||
26 | #include <asm/mpc52xx_psc.h> | 17 | #include <asm/mpc52xx_psc.h> |
27 | 18 | ||
28 | MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); | 19 | #include "mpc5200_psc_i2s.h" |
29 | MODULE_DESCRIPTION("Freescale MPC5200 PSC in I2S mode ASoC Driver"); | 20 | #include "mpc5200_dma.h" |
30 | MODULE_LICENSE("GPL"); | ||
31 | 21 | ||
32 | /** | 22 | /** |
33 | * PSC_I2S_RATES: sample rates supported by the I2S | 23 | * PSC_I2S_RATES: sample rates supported by the I2S |
@@ -44,191 +34,17 @@ MODULE_LICENSE("GPL"); | |||
44 | * PSC_I2S_FORMATS: audio formats supported by the PSC I2S mode | 34 | * PSC_I2S_FORMATS: audio formats supported by the PSC I2S mode |
45 | */ | 35 | */ |
46 | #define PSC_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE | \ | 36 | #define PSC_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE | \ |
47 | SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S24_BE | \ | 37 | SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE) |
48 | SNDRV_PCM_FMTBIT_S32_BE) | ||
49 | |||
50 | /** | ||
51 | * psc_i2s_stream - Data specific to a single stream (playback or capture) | ||
52 | * @active: flag indicating if the stream is active | ||
53 | * @psc_i2s: pointer back to parent psc_i2s data structure | ||
54 | * @bcom_task: bestcomm task structure | ||
55 | * @irq: irq number for bestcomm task | ||
56 | * @period_start: physical address of start of DMA region | ||
57 | * @period_end: physical address of end of DMA region | ||
58 | * @period_next_pt: physical address of next DMA buffer to enqueue | ||
59 | * @period_bytes: size of DMA period in bytes | ||
60 | */ | ||
61 | struct psc_i2s_stream { | ||
62 | int active; | ||
63 | struct psc_i2s *psc_i2s; | ||
64 | struct bcom_task *bcom_task; | ||
65 | int irq; | ||
66 | struct snd_pcm_substream *stream; | ||
67 | dma_addr_t period_start; | ||
68 | dma_addr_t period_end; | ||
69 | dma_addr_t period_next_pt; | ||
70 | dma_addr_t period_current_pt; | ||
71 | int period_bytes; | ||
72 | }; | ||
73 | |||
74 | /** | ||
75 | * psc_i2s - Private driver data | ||
76 | * @name: short name for this device ("PSC0", "PSC1", etc) | ||
77 | * @psc_regs: pointer to the PSC's registers | ||
78 | * @fifo_regs: pointer to the PSC's FIFO registers | ||
79 | * @irq: IRQ of this PSC | ||
80 | * @dev: struct device pointer | ||
81 | * @dai: the CPU DAI for this device | ||
82 | * @sicr: Base value used in serial interface control register; mode is ORed | ||
83 | * with this value. | ||
84 | * @playback: Playback stream context data | ||
85 | * @capture: Capture stream context data | ||
86 | */ | ||
87 | struct psc_i2s { | ||
88 | char name[32]; | ||
89 | struct mpc52xx_psc __iomem *psc_regs; | ||
90 | struct mpc52xx_psc_fifo __iomem *fifo_regs; | ||
91 | unsigned int irq; | ||
92 | struct device *dev; | ||
93 | struct snd_soc_dai dai; | ||
94 | spinlock_t lock; | ||
95 | u32 sicr; | ||
96 | |||
97 | /* per-stream data */ | ||
98 | struct psc_i2s_stream playback; | ||
99 | struct psc_i2s_stream capture; | ||
100 | |||
101 | /* Statistics */ | ||
102 | struct { | ||
103 | int overrun_count; | ||
104 | int underrun_count; | ||
105 | } stats; | ||
106 | }; | ||
107 | |||
108 | /* | ||
109 | * Interrupt handlers | ||
110 | */ | ||
111 | static irqreturn_t psc_i2s_status_irq(int irq, void *_psc_i2s) | ||
112 | { | ||
113 | struct psc_i2s *psc_i2s = _psc_i2s; | ||
114 | struct mpc52xx_psc __iomem *regs = psc_i2s->psc_regs; | ||
115 | u16 isr; | ||
116 | |||
117 | isr = in_be16(®s->mpc52xx_psc_isr); | ||
118 | |||
119 | /* Playback underrun error */ | ||
120 | if (psc_i2s->playback.active && (isr & MPC52xx_PSC_IMR_TXEMP)) | ||
121 | psc_i2s->stats.underrun_count++; | ||
122 | |||
123 | /* Capture overrun error */ | ||
124 | if (psc_i2s->capture.active && (isr & MPC52xx_PSC_IMR_ORERR)) | ||
125 | psc_i2s->stats.overrun_count++; | ||
126 | |||
127 | out_8(®s->command, 4 << 4); /* reset the error status */ | ||
128 | |||
129 | return IRQ_HANDLED; | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * psc_i2s_bcom_enqueue_next_buffer - Enqueue another audio buffer | ||
134 | * @s: pointer to stream private data structure | ||
135 | * | ||
136 | * Enqueues another audio period buffer into the bestcomm queue. | ||
137 | * | ||
138 | * Note: The routine must only be called when there is space available in | ||
139 | * the queue. Otherwise the enqueue will fail and the audio ring buffer | ||
140 | * will get out of sync | ||
141 | */ | ||
142 | static void psc_i2s_bcom_enqueue_next_buffer(struct psc_i2s_stream *s) | ||
143 | { | ||
144 | struct bcom_bd *bd; | ||
145 | |||
146 | /* Prepare and enqueue the next buffer descriptor */ | ||
147 | bd = bcom_prepare_next_buffer(s->bcom_task); | ||
148 | bd->status = s->period_bytes; | ||
149 | bd->data[0] = s->period_next_pt; | ||
150 | bcom_submit_next_buffer(s->bcom_task, NULL); | ||
151 | |||
152 | /* Update for next period */ | ||
153 | s->period_next_pt += s->period_bytes; | ||
154 | if (s->period_next_pt >= s->period_end) | ||
155 | s->period_next_pt = s->period_start; | ||
156 | } | ||
157 | |||
158 | /* Bestcomm DMA irq handler */ | ||
159 | static irqreturn_t psc_i2s_bcom_irq(int irq, void *_psc_i2s_stream) | ||
160 | { | ||
161 | struct psc_i2s_stream *s = _psc_i2s_stream; | ||
162 | |||
163 | /* For each finished period, dequeue the completed period buffer | ||
164 | * and enqueue a new one in it's place. */ | ||
165 | while (bcom_buffer_done(s->bcom_task)) { | ||
166 | bcom_retrieve_buffer(s->bcom_task, NULL, NULL); | ||
167 | s->period_current_pt += s->period_bytes; | ||
168 | if (s->period_current_pt >= s->period_end) | ||
169 | s->period_current_pt = s->period_start; | ||
170 | psc_i2s_bcom_enqueue_next_buffer(s); | ||
171 | bcom_enable(s->bcom_task); | ||
172 | } | ||
173 | |||
174 | /* If the stream is active, then also inform the PCM middle layer | ||
175 | * of the period finished event. */ | ||
176 | if (s->active) | ||
177 | snd_pcm_period_elapsed(s->stream); | ||
178 | |||
179 | return IRQ_HANDLED; | ||
180 | } | ||
181 | |||
182 | /** | ||
183 | * psc_i2s_startup: create a new substream | ||
184 | * | ||
185 | * This is the first function called when a stream is opened. | ||
186 | * | ||
187 | * If this is the first stream open, then grab the IRQ and program most of | ||
188 | * the PSC registers. | ||
189 | */ | ||
190 | static int psc_i2s_startup(struct snd_pcm_substream *substream, | ||
191 | struct snd_soc_dai *dai) | ||
192 | { | ||
193 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
194 | struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data; | ||
195 | int rc; | ||
196 | |||
197 | dev_dbg(psc_i2s->dev, "psc_i2s_startup(substream=%p)\n", substream); | ||
198 | |||
199 | if (!psc_i2s->playback.active && | ||
200 | !psc_i2s->capture.active) { | ||
201 | /* Setup the IRQs */ | ||
202 | rc = request_irq(psc_i2s->irq, &psc_i2s_status_irq, IRQF_SHARED, | ||
203 | "psc-i2s-status", psc_i2s); | ||
204 | rc |= request_irq(psc_i2s->capture.irq, | ||
205 | &psc_i2s_bcom_irq, IRQF_SHARED, | ||
206 | "psc-i2s-capture", &psc_i2s->capture); | ||
207 | rc |= request_irq(psc_i2s->playback.irq, | ||
208 | &psc_i2s_bcom_irq, IRQF_SHARED, | ||
209 | "psc-i2s-playback", &psc_i2s->playback); | ||
210 | if (rc) { | ||
211 | free_irq(psc_i2s->irq, psc_i2s); | ||
212 | free_irq(psc_i2s->capture.irq, | ||
213 | &psc_i2s->capture); | ||
214 | free_irq(psc_i2s->playback.irq, | ||
215 | &psc_i2s->playback); | ||
216 | return -ENODEV; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | return 0; | ||
221 | } | ||
222 | 38 | ||
223 | static int psc_i2s_hw_params(struct snd_pcm_substream *substream, | 39 | static int psc_i2s_hw_params(struct snd_pcm_substream *substream, |
224 | struct snd_pcm_hw_params *params, | 40 | struct snd_pcm_hw_params *params, |
225 | struct snd_soc_dai *dai) | 41 | struct snd_soc_dai *dai) |
226 | { | 42 | { |
227 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 43 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
228 | struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data; | 44 | struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data; |
229 | u32 mode; | 45 | u32 mode; |
230 | 46 | ||
231 | dev_dbg(psc_i2s->dev, "%s(substream=%p) p_size=%i p_bytes=%i" | 47 | dev_dbg(psc_dma->dev, "%s(substream=%p) p_size=%i p_bytes=%i" |
232 | " periods=%i buffer_size=%i buffer_bytes=%i\n", | 48 | " periods=%i buffer_size=%i buffer_bytes=%i\n", |
233 | __func__, substream, params_period_size(params), | 49 | __func__, substream, params_period_size(params), |
234 | params_period_bytes(params), params_periods(params), | 50 | params_period_bytes(params), params_periods(params), |
@@ -248,175 +64,15 @@ static int psc_i2s_hw_params(struct snd_pcm_substream *substream, | |||
248 | mode = MPC52xx_PSC_SICR_SIM_CODEC_32; | 64 | mode = MPC52xx_PSC_SICR_SIM_CODEC_32; |
249 | break; | 65 | break; |
250 | default: | 66 | default: |
251 | dev_dbg(psc_i2s->dev, "invalid format\n"); | 67 | dev_dbg(psc_dma->dev, "invalid format\n"); |
252 | return -EINVAL; | ||
253 | } | ||
254 | out_be32(&psc_i2s->psc_regs->sicr, psc_i2s->sicr | mode); | ||
255 | |||
256 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); | ||
257 | |||
258 | return 0; | ||
259 | } | ||
260 | |||
261 | static int psc_i2s_hw_free(struct snd_pcm_substream *substream, | ||
262 | struct snd_soc_dai *dai) | ||
263 | { | ||
264 | snd_pcm_set_runtime_buffer(substream, NULL); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | /** | ||
269 | * psc_i2s_trigger: start and stop the DMA transfer. | ||
270 | * | ||
271 | * This function is called by ALSA to start, stop, pause, and resume the DMA | ||
272 | * transfer of data. | ||
273 | */ | ||
274 | static int psc_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | ||
275 | struct snd_soc_dai *dai) | ||
276 | { | ||
277 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
278 | struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data; | ||
279 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
280 | struct psc_i2s_stream *s; | ||
281 | struct mpc52xx_psc __iomem *regs = psc_i2s->psc_regs; | ||
282 | u16 imr; | ||
283 | u8 psc_cmd; | ||
284 | unsigned long flags; | ||
285 | |||
286 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
287 | s = &psc_i2s->capture; | ||
288 | else | ||
289 | s = &psc_i2s->playback; | ||
290 | |||
291 | dev_dbg(psc_i2s->dev, "psc_i2s_trigger(substream=%p, cmd=%i)" | ||
292 | " stream_id=%i\n", | ||
293 | substream, cmd, substream->pstr->stream); | ||
294 | |||
295 | switch (cmd) { | ||
296 | case SNDRV_PCM_TRIGGER_START: | ||
297 | s->period_bytes = frames_to_bytes(runtime, | ||
298 | runtime->period_size); | ||
299 | s->period_start = virt_to_phys(runtime->dma_area); | ||
300 | s->period_end = s->period_start + | ||
301 | (s->period_bytes * runtime->periods); | ||
302 | s->period_next_pt = s->period_start; | ||
303 | s->period_current_pt = s->period_start; | ||
304 | s->active = 1; | ||
305 | |||
306 | /* First; reset everything */ | ||
307 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) { | ||
308 | out_8(®s->command, MPC52xx_PSC_RST_RX); | ||
309 | out_8(®s->command, MPC52xx_PSC_RST_ERR_STAT); | ||
310 | } else { | ||
311 | out_8(®s->command, MPC52xx_PSC_RST_TX); | ||
312 | out_8(®s->command, MPC52xx_PSC_RST_ERR_STAT); | ||
313 | } | ||
314 | |||
315 | /* Next, fill up the bestcomm bd queue and enable DMA. | ||
316 | * This will begin filling the PSC's fifo. */ | ||
317 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
318 | bcom_gen_bd_rx_reset(s->bcom_task); | ||
319 | else | ||
320 | bcom_gen_bd_tx_reset(s->bcom_task); | ||
321 | while (!bcom_queue_full(s->bcom_task)) | ||
322 | psc_i2s_bcom_enqueue_next_buffer(s); | ||
323 | bcom_enable(s->bcom_task); | ||
324 | |||
325 | /* Due to errata in the i2s mode; need to line up enabling | ||
326 | * the transmitter with a transition on the frame sync | ||
327 | * line */ | ||
328 | |||
329 | spin_lock_irqsave(&psc_i2s->lock, flags); | ||
330 | /* first make sure it is low */ | ||
331 | while ((in_8(®s->ipcr_acr.ipcr) & 0x80) != 0) | ||
332 | ; | ||
333 | /* then wait for the transition to high */ | ||
334 | while ((in_8(®s->ipcr_acr.ipcr) & 0x80) == 0) | ||
335 | ; | ||
336 | /* Finally, enable the PSC. | ||
337 | * Receiver must always be enabled; even when we only want | ||
338 | * transmit. (see 15.3.2.3 of MPC5200B User's Guide) */ | ||
339 | psc_cmd = MPC52xx_PSC_RX_ENABLE; | ||
340 | if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
341 | psc_cmd |= MPC52xx_PSC_TX_ENABLE; | ||
342 | out_8(®s->command, psc_cmd); | ||
343 | spin_unlock_irqrestore(&psc_i2s->lock, flags); | ||
344 | |||
345 | break; | ||
346 | |||
347 | case SNDRV_PCM_TRIGGER_STOP: | ||
348 | /* Turn off the PSC */ | ||
349 | s->active = 0; | ||
350 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) { | ||
351 | if (!psc_i2s->playback.active) { | ||
352 | out_8(®s->command, 2 << 4); /* reset rx */ | ||
353 | out_8(®s->command, 3 << 4); /* reset tx */ | ||
354 | out_8(®s->command, 4 << 4); /* reset err */ | ||
355 | } | ||
356 | } else { | ||
357 | out_8(®s->command, 3 << 4); /* reset tx */ | ||
358 | out_8(®s->command, 4 << 4); /* reset err */ | ||
359 | if (!psc_i2s->capture.active) | ||
360 | out_8(®s->command, 2 << 4); /* reset rx */ | ||
361 | } | ||
362 | |||
363 | bcom_disable(s->bcom_task); | ||
364 | while (!bcom_queue_empty(s->bcom_task)) | ||
365 | bcom_retrieve_buffer(s->bcom_task, NULL, NULL); | ||
366 | |||
367 | break; | ||
368 | |||
369 | default: | ||
370 | dev_dbg(psc_i2s->dev, "invalid command\n"); | ||
371 | return -EINVAL; | 68 | return -EINVAL; |
372 | } | 69 | } |
373 | 70 | out_be32(&psc_dma->psc_regs->sicr, psc_dma->sicr | mode); | |
374 | /* Update interrupt enable settings */ | ||
375 | imr = 0; | ||
376 | if (psc_i2s->playback.active) | ||
377 | imr |= MPC52xx_PSC_IMR_TXEMP; | ||
378 | if (psc_i2s->capture.active) | ||
379 | imr |= MPC52xx_PSC_IMR_ORERR; | ||
380 | out_be16(®s->isr_imr.imr, imr); | ||
381 | 71 | ||
382 | return 0; | 72 | return 0; |
383 | } | 73 | } |
384 | 74 | ||
385 | /** | 75 | /** |
386 | * psc_i2s_shutdown: shutdown the data transfer on a stream | ||
387 | * | ||
388 | * Shutdown the PSC if there are no other substreams open. | ||
389 | */ | ||
390 | static void psc_i2s_shutdown(struct snd_pcm_substream *substream, | ||
391 | struct snd_soc_dai *dai) | ||
392 | { | ||
393 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
394 | struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data; | ||
395 | |||
396 | dev_dbg(psc_i2s->dev, "psc_i2s_shutdown(substream=%p)\n", substream); | ||
397 | |||
398 | /* | ||
399 | * If this is the last active substream, disable the PSC and release | ||
400 | * the IRQ. | ||
401 | */ | ||
402 | if (!psc_i2s->playback.active && | ||
403 | !psc_i2s->capture.active) { | ||
404 | |||
405 | /* Disable all interrupts and reset the PSC */ | ||
406 | out_be16(&psc_i2s->psc_regs->isr_imr.imr, 0); | ||
407 | out_8(&psc_i2s->psc_regs->command, 3 << 4); /* reset tx */ | ||
408 | out_8(&psc_i2s->psc_regs->command, 2 << 4); /* reset rx */ | ||
409 | out_8(&psc_i2s->psc_regs->command, 1 << 4); /* reset mode */ | ||
410 | out_8(&psc_i2s->psc_regs->command, 4 << 4); /* reset error */ | ||
411 | |||
412 | /* Release irqs */ | ||
413 | free_irq(psc_i2s->irq, psc_i2s); | ||
414 | free_irq(psc_i2s->capture.irq, &psc_i2s->capture); | ||
415 | free_irq(psc_i2s->playback.irq, &psc_i2s->playback); | ||
416 | } | ||
417 | } | ||
418 | |||
419 | /** | ||
420 | * psc_i2s_set_sysclk: set the clock frequency and direction | 76 | * psc_i2s_set_sysclk: set the clock frequency and direction |
421 | * | 77 | * |
422 | * This function is called by the machine driver to tell us what the clock | 78 | * This function is called by the machine driver to tell us what the clock |
@@ -433,8 +89,8 @@ static void psc_i2s_shutdown(struct snd_pcm_substream *substream, | |||
433 | static int psc_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, | 89 | static int psc_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, |
434 | int clk_id, unsigned int freq, int dir) | 90 | int clk_id, unsigned int freq, int dir) |
435 | { | 91 | { |
436 | struct psc_i2s *psc_i2s = cpu_dai->private_data; | 92 | struct psc_dma *psc_dma = cpu_dai->private_data; |
437 | dev_dbg(psc_i2s->dev, "psc_i2s_set_sysclk(cpu_dai=%p, dir=%i)\n", | 93 | dev_dbg(psc_dma->dev, "psc_i2s_set_sysclk(cpu_dai=%p, dir=%i)\n", |
438 | cpu_dai, dir); | 94 | cpu_dai, dir); |
439 | return (dir == SND_SOC_CLOCK_IN) ? 0 : -EINVAL; | 95 | return (dir == SND_SOC_CLOCK_IN) ? 0 : -EINVAL; |
440 | } | 96 | } |
@@ -452,8 +108,8 @@ static int psc_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, | |||
452 | */ | 108 | */ |
453 | static int psc_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int format) | 109 | static int psc_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int format) |
454 | { | 110 | { |
455 | struct psc_i2s *psc_i2s = cpu_dai->private_data; | 111 | struct psc_dma *psc_dma = cpu_dai->private_data; |
456 | dev_dbg(psc_i2s->dev, "psc_i2s_set_fmt(cpu_dai=%p, format=%i)\n", | 112 | dev_dbg(psc_dma->dev, "psc_i2s_set_fmt(cpu_dai=%p, format=%i)\n", |
457 | cpu_dai, format); | 113 | cpu_dai, format); |
458 | return (format == SND_SOC_DAIFMT_I2S) ? 0 : -EINVAL; | 114 | return (format == SND_SOC_DAIFMT_I2S) ? 0 : -EINVAL; |
459 | } | 115 | } |
@@ -469,16 +125,13 @@ static int psc_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int format) | |||
469 | * psc_i2s_dai_template: template CPU Digital Audio Interface | 125 | * psc_i2s_dai_template: template CPU Digital Audio Interface |
470 | */ | 126 | */ |
471 | static struct snd_soc_dai_ops psc_i2s_dai_ops = { | 127 | static struct snd_soc_dai_ops psc_i2s_dai_ops = { |
472 | .startup = psc_i2s_startup, | ||
473 | .hw_params = psc_i2s_hw_params, | 128 | .hw_params = psc_i2s_hw_params, |
474 | .hw_free = psc_i2s_hw_free, | ||
475 | .shutdown = psc_i2s_shutdown, | ||
476 | .trigger = psc_i2s_trigger, | ||
477 | .set_sysclk = psc_i2s_set_sysclk, | 129 | .set_sysclk = psc_i2s_set_sysclk, |
478 | .set_fmt = psc_i2s_set_fmt, | 130 | .set_fmt = psc_i2s_set_fmt, |
479 | }; | 131 | }; |
480 | 132 | ||
481 | static struct snd_soc_dai psc_i2s_dai_template = { | 133 | struct snd_soc_dai psc_i2s_dai[] = {{ |
134 | .name = "I2S", | ||
482 | .playback = { | 135 | .playback = { |
483 | .channels_min = 2, | 136 | .channels_min = 2, |
484 | .channels_max = 2, | 137 | .channels_max = 2, |
@@ -492,223 +145,8 @@ static struct snd_soc_dai psc_i2s_dai_template = { | |||
492 | .formats = PSC_I2S_FORMATS, | 145 | .formats = PSC_I2S_FORMATS, |
493 | }, | 146 | }, |
494 | .ops = &psc_i2s_dai_ops, | 147 | .ops = &psc_i2s_dai_ops, |
495 | }; | 148 | } }; |
496 | 149 | EXPORT_SYMBOL_GPL(psc_i2s_dai); | |
497 | /* --------------------------------------------------------------------- | ||
498 | * The PSC I2S 'ASoC platform' driver | ||
499 | * | ||
500 | * Can be referenced by an 'ASoC machine' driver | ||
501 | * This driver only deals with the audio bus; it doesn't have any | ||
502 | * interaction with the attached codec | ||
503 | */ | ||
504 | |||
505 | static const struct snd_pcm_hardware psc_i2s_pcm_hardware = { | ||
506 | .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | | ||
507 | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
508 | SNDRV_PCM_INFO_BATCH, | ||
509 | .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE | | ||
510 | SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE, | ||
511 | .rate_min = 8000, | ||
512 | .rate_max = 48000, | ||
513 | .channels_min = 2, | ||
514 | .channels_max = 2, | ||
515 | .period_bytes_max = 1024 * 1024, | ||
516 | .period_bytes_min = 32, | ||
517 | .periods_min = 2, | ||
518 | .periods_max = 256, | ||
519 | .buffer_bytes_max = 2 * 1024 * 1024, | ||
520 | .fifo_size = 0, | ||
521 | }; | ||
522 | |||
523 | static int psc_i2s_pcm_open(struct snd_pcm_substream *substream) | ||
524 | { | ||
525 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
526 | struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data; | ||
527 | struct psc_i2s_stream *s; | ||
528 | |||
529 | dev_dbg(psc_i2s->dev, "psc_i2s_pcm_open(substream=%p)\n", substream); | ||
530 | |||
531 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
532 | s = &psc_i2s->capture; | ||
533 | else | ||
534 | s = &psc_i2s->playback; | ||
535 | |||
536 | snd_soc_set_runtime_hwparams(substream, &psc_i2s_pcm_hardware); | ||
537 | |||
538 | s->stream = substream; | ||
539 | return 0; | ||
540 | } | ||
541 | |||
542 | static int psc_i2s_pcm_close(struct snd_pcm_substream *substream) | ||
543 | { | ||
544 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
545 | struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data; | ||
546 | struct psc_i2s_stream *s; | ||
547 | |||
548 | dev_dbg(psc_i2s->dev, "psc_i2s_pcm_close(substream=%p)\n", substream); | ||
549 | |||
550 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
551 | s = &psc_i2s->capture; | ||
552 | else | ||
553 | s = &psc_i2s->playback; | ||
554 | |||
555 | s->stream = NULL; | ||
556 | return 0; | ||
557 | } | ||
558 | |||
559 | static snd_pcm_uframes_t | ||
560 | psc_i2s_pcm_pointer(struct snd_pcm_substream *substream) | ||
561 | { | ||
562 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
563 | struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data; | ||
564 | struct psc_i2s_stream *s; | ||
565 | dma_addr_t count; | ||
566 | |||
567 | if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
568 | s = &psc_i2s->capture; | ||
569 | else | ||
570 | s = &psc_i2s->playback; | ||
571 | |||
572 | count = s->period_current_pt - s->period_start; | ||
573 | |||
574 | return bytes_to_frames(substream->runtime, count); | ||
575 | } | ||
576 | |||
577 | static struct snd_pcm_ops psc_i2s_pcm_ops = { | ||
578 | .open = psc_i2s_pcm_open, | ||
579 | .close = psc_i2s_pcm_close, | ||
580 | .ioctl = snd_pcm_lib_ioctl, | ||
581 | .pointer = psc_i2s_pcm_pointer, | ||
582 | }; | ||
583 | |||
584 | static u64 psc_i2s_pcm_dmamask = 0xffffffff; | ||
585 | static int psc_i2s_pcm_new(struct snd_card *card, struct snd_soc_dai *dai, | ||
586 | struct snd_pcm *pcm) | ||
587 | { | ||
588 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; | ||
589 | size_t size = psc_i2s_pcm_hardware.buffer_bytes_max; | ||
590 | int rc = 0; | ||
591 | |||
592 | dev_dbg(rtd->socdev->dev, "psc_i2s_pcm_new(card=%p, dai=%p, pcm=%p)\n", | ||
593 | card, dai, pcm); | ||
594 | |||
595 | if (!card->dev->dma_mask) | ||
596 | card->dev->dma_mask = &psc_i2s_pcm_dmamask; | ||
597 | if (!card->dev->coherent_dma_mask) | ||
598 | card->dev->coherent_dma_mask = 0xffffffff; | ||
599 | |||
600 | if (pcm->streams[0].substream) { | ||
601 | rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->dev, size, | ||
602 | &pcm->streams[0].substream->dma_buffer); | ||
603 | if (rc) | ||
604 | goto playback_alloc_err; | ||
605 | } | ||
606 | |||
607 | if (pcm->streams[1].substream) { | ||
608 | rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->dev, size, | ||
609 | &pcm->streams[1].substream->dma_buffer); | ||
610 | if (rc) | ||
611 | goto capture_alloc_err; | ||
612 | } | ||
613 | |||
614 | return 0; | ||
615 | |||
616 | capture_alloc_err: | ||
617 | if (pcm->streams[0].substream) | ||
618 | snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer); | ||
619 | playback_alloc_err: | ||
620 | dev_err(card->dev, "Cannot allocate buffer(s)\n"); | ||
621 | return -ENOMEM; | ||
622 | } | ||
623 | |||
624 | static void psc_i2s_pcm_free(struct snd_pcm *pcm) | ||
625 | { | ||
626 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; | ||
627 | struct snd_pcm_substream *substream; | ||
628 | int stream; | ||
629 | |||
630 | dev_dbg(rtd->socdev->dev, "psc_i2s_pcm_free(pcm=%p)\n", pcm); | ||
631 | |||
632 | for (stream = 0; stream < 2; stream++) { | ||
633 | substream = pcm->streams[stream].substream; | ||
634 | if (substream) { | ||
635 | snd_dma_free_pages(&substream->dma_buffer); | ||
636 | substream->dma_buffer.area = NULL; | ||
637 | substream->dma_buffer.addr = 0; | ||
638 | } | ||
639 | } | ||
640 | } | ||
641 | |||
642 | struct snd_soc_platform psc_i2s_pcm_soc_platform = { | ||
643 | .name = "mpc5200-psc-audio", | ||
644 | .pcm_ops = &psc_i2s_pcm_ops, | ||
645 | .pcm_new = &psc_i2s_pcm_new, | ||
646 | .pcm_free = &psc_i2s_pcm_free, | ||
647 | }; | ||
648 | |||
649 | /* --------------------------------------------------------------------- | ||
650 | * Sysfs attributes for debugging | ||
651 | */ | ||
652 | |||
653 | static ssize_t psc_i2s_status_show(struct device *dev, | ||
654 | struct device_attribute *attr, char *buf) | ||
655 | { | ||
656 | struct psc_i2s *psc_i2s = dev_get_drvdata(dev); | ||
657 | |||
658 | return sprintf(buf, "status=%.4x sicr=%.8x rfnum=%i rfstat=0x%.4x " | ||
659 | "tfnum=%i tfstat=0x%.4x\n", | ||
660 | in_be16(&psc_i2s->psc_regs->sr_csr.status), | ||
661 | in_be32(&psc_i2s->psc_regs->sicr), | ||
662 | in_be16(&psc_i2s->fifo_regs->rfnum) & 0x1ff, | ||
663 | in_be16(&psc_i2s->fifo_regs->rfstat), | ||
664 | in_be16(&psc_i2s->fifo_regs->tfnum) & 0x1ff, | ||
665 | in_be16(&psc_i2s->fifo_regs->tfstat)); | ||
666 | } | ||
667 | |||
668 | static int *psc_i2s_get_stat_attr(struct psc_i2s *psc_i2s, const char *name) | ||
669 | { | ||
670 | if (strcmp(name, "playback_underrun") == 0) | ||
671 | return &psc_i2s->stats.underrun_count; | ||
672 | if (strcmp(name, "capture_overrun") == 0) | ||
673 | return &psc_i2s->stats.overrun_count; | ||
674 | |||
675 | return NULL; | ||
676 | } | ||
677 | |||
678 | static ssize_t psc_i2s_stat_show(struct device *dev, | ||
679 | struct device_attribute *attr, char *buf) | ||
680 | { | ||
681 | struct psc_i2s *psc_i2s = dev_get_drvdata(dev); | ||
682 | int *attrib; | ||
683 | |||
684 | attrib = psc_i2s_get_stat_attr(psc_i2s, attr->attr.name); | ||
685 | if (!attrib) | ||
686 | return 0; | ||
687 | |||
688 | return sprintf(buf, "%i\n", *attrib); | ||
689 | } | ||
690 | |||
691 | static ssize_t psc_i2s_stat_store(struct device *dev, | ||
692 | struct device_attribute *attr, | ||
693 | const char *buf, | ||
694 | size_t count) | ||
695 | { | ||
696 | struct psc_i2s *psc_i2s = dev_get_drvdata(dev); | ||
697 | int *attrib; | ||
698 | |||
699 | attrib = psc_i2s_get_stat_attr(psc_i2s, attr->attr.name); | ||
700 | if (!attrib) | ||
701 | return 0; | ||
702 | |||
703 | *attrib = simple_strtoul(buf, NULL, 0); | ||
704 | return count; | ||
705 | } | ||
706 | |||
707 | static DEVICE_ATTR(status, 0644, psc_i2s_status_show, NULL); | ||
708 | static DEVICE_ATTR(playback_underrun, 0644, psc_i2s_stat_show, | ||
709 | psc_i2s_stat_store); | ||
710 | static DEVICE_ATTR(capture_overrun, 0644, psc_i2s_stat_show, | ||
711 | psc_i2s_stat_store); | ||
712 | 150 | ||
713 | /* --------------------------------------------------------------------- | 151 | /* --------------------------------------------------------------------- |
714 | * OF platform bus binding code: | 152 | * OF platform bus binding code: |
@@ -718,150 +156,65 @@ static DEVICE_ATTR(capture_overrun, 0644, psc_i2s_stat_show, | |||
718 | static int __devinit psc_i2s_of_probe(struct of_device *op, | 156 | static int __devinit psc_i2s_of_probe(struct of_device *op, |
719 | const struct of_device_id *match) | 157 | const struct of_device_id *match) |
720 | { | 158 | { |
721 | phys_addr_t fifo; | 159 | int rc; |
722 | struct psc_i2s *psc_i2s; | 160 | struct psc_dma *psc_dma; |
723 | struct resource res; | 161 | struct mpc52xx_psc __iomem *regs; |
724 | int size, psc_id, irq, rc; | ||
725 | const __be32 *prop; | ||
726 | void __iomem *regs; | ||
727 | |||
728 | dev_dbg(&op->dev, "probing psc i2s device\n"); | ||
729 | |||
730 | /* Get the PSC ID */ | ||
731 | prop = of_get_property(op->node, "cell-index", &size); | ||
732 | if (!prop || size < sizeof *prop) | ||
733 | return -ENODEV; | ||
734 | psc_id = be32_to_cpu(*prop); | ||
735 | |||
736 | /* Fetch the registers and IRQ of the PSC */ | ||
737 | irq = irq_of_parse_and_map(op->node, 0); | ||
738 | if (of_address_to_resource(op->node, 0, &res)) { | ||
739 | dev_err(&op->dev, "Missing reg property\n"); | ||
740 | return -ENODEV; | ||
741 | } | ||
742 | regs = ioremap(res.start, 1 + res.end - res.start); | ||
743 | if (!regs) { | ||
744 | dev_err(&op->dev, "Could not map registers\n"); | ||
745 | return -ENODEV; | ||
746 | } | ||
747 | 162 | ||
748 | /* Allocate and initialize the driver private data */ | 163 | rc = mpc5200_audio_dma_create(op); |
749 | psc_i2s = kzalloc(sizeof *psc_i2s, GFP_KERNEL); | 164 | if (rc != 0) |
750 | if (!psc_i2s) { | 165 | return rc; |
751 | iounmap(regs); | 166 | |
752 | return -ENOMEM; | 167 | rc = snd_soc_register_dais(psc_i2s_dai, ARRAY_SIZE(psc_i2s_dai)); |
753 | } | 168 | if (rc != 0) { |
754 | spin_lock_init(&psc_i2s->lock); | 169 | pr_err("Failed to register DAI\n"); |
755 | psc_i2s->irq = irq; | 170 | return 0; |
756 | psc_i2s->psc_regs = regs; | ||
757 | psc_i2s->fifo_regs = regs + sizeof *psc_i2s->psc_regs; | ||
758 | psc_i2s->dev = &op->dev; | ||
759 | psc_i2s->playback.psc_i2s = psc_i2s; | ||
760 | psc_i2s->capture.psc_i2s = psc_i2s; | ||
761 | snprintf(psc_i2s->name, sizeof psc_i2s->name, "PSC%u", psc_id+1); | ||
762 | |||
763 | /* Fill out the CPU DAI structure */ | ||
764 | memcpy(&psc_i2s->dai, &psc_i2s_dai_template, sizeof psc_i2s->dai); | ||
765 | psc_i2s->dai.private_data = psc_i2s; | ||
766 | psc_i2s->dai.name = psc_i2s->name; | ||
767 | psc_i2s->dai.id = psc_id; | ||
768 | |||
769 | /* Find the address of the fifo data registers and setup the | ||
770 | * DMA tasks */ | ||
771 | fifo = res.start + offsetof(struct mpc52xx_psc, buffer.buffer_32); | ||
772 | psc_i2s->capture.bcom_task = | ||
773 | bcom_psc_gen_bd_rx_init(psc_id, 10, fifo, 512); | ||
774 | psc_i2s->playback.bcom_task = | ||
775 | bcom_psc_gen_bd_tx_init(psc_id, 10, fifo); | ||
776 | if (!psc_i2s->capture.bcom_task || | ||
777 | !psc_i2s->playback.bcom_task) { | ||
778 | dev_err(&op->dev, "Could not allocate bestcomm tasks\n"); | ||
779 | iounmap(regs); | ||
780 | kfree(psc_i2s); | ||
781 | return -ENODEV; | ||
782 | } | 171 | } |
783 | 172 | ||
784 | /* Disable all interrupts and reset the PSC */ | 173 | psc_dma = dev_get_drvdata(&op->dev); |
785 | out_be16(&psc_i2s->psc_regs->isr_imr.imr, 0); | 174 | regs = psc_dma->psc_regs; |
786 | out_8(&psc_i2s->psc_regs->command, 3 << 4); /* reset transmitter */ | ||
787 | out_8(&psc_i2s->psc_regs->command, 2 << 4); /* reset receiver */ | ||
788 | out_8(&psc_i2s->psc_regs->command, 1 << 4); /* reset mode */ | ||
789 | out_8(&psc_i2s->psc_regs->command, 4 << 4); /* reset error */ | ||
790 | 175 | ||
791 | /* Configure the serial interface mode; defaulting to CODEC8 mode */ | 176 | /* Configure the serial interface mode; defaulting to CODEC8 mode */ |
792 | psc_i2s->sicr = MPC52xx_PSC_SICR_DTS1 | MPC52xx_PSC_SICR_I2S | | 177 | psc_dma->sicr = MPC52xx_PSC_SICR_DTS1 | MPC52xx_PSC_SICR_I2S | |
793 | MPC52xx_PSC_SICR_CLKPOL; | 178 | MPC52xx_PSC_SICR_CLKPOL; |
794 | if (of_get_property(op->node, "fsl,cellslave", NULL)) | 179 | out_be32(&psc_dma->psc_regs->sicr, |
795 | psc_i2s->sicr |= MPC52xx_PSC_SICR_CELLSLAVE | | 180 | psc_dma->sicr | MPC52xx_PSC_SICR_SIM_CODEC_8); |
796 | MPC52xx_PSC_SICR_GENCLK; | ||
797 | out_be32(&psc_i2s->psc_regs->sicr, | ||
798 | psc_i2s->sicr | MPC52xx_PSC_SICR_SIM_CODEC_8); | ||
799 | 181 | ||
800 | /* Check for the codec handle. If it is not present then we | 182 | /* Check for the codec handle. If it is not present then we |
801 | * are done */ | 183 | * are done */ |
802 | if (!of_get_property(op->node, "codec-handle", NULL)) | 184 | if (!of_get_property(op->node, "codec-handle", NULL)) |
803 | return 0; | 185 | return 0; |
804 | 186 | ||
805 | /* Set up mode register; | 187 | /* Due to errata in the dma mode; need to line up enabling |
806 | * First write: RxRdy (FIFO Alarm) generates rx FIFO irq | 188 | * the transmitter with a transition on the frame sync |
807 | * Second write: register Normal mode for non loopback | 189 | * line */ |
808 | */ | 190 | |
809 | out_8(&psc_i2s->psc_regs->mode, 0); | 191 | /* first make sure it is low */ |
810 | out_8(&psc_i2s->psc_regs->mode, 0); | 192 | while ((in_8(®s->ipcr_acr.ipcr) & 0x80) != 0) |
811 | 193 | ; | |
812 | /* Set the TX and RX fifo alarm thresholds */ | 194 | /* then wait for the transition to high */ |
813 | out_be16(&psc_i2s->fifo_regs->rfalarm, 0x100); | 195 | while ((in_8(®s->ipcr_acr.ipcr) & 0x80) == 0) |
814 | out_8(&psc_i2s->fifo_regs->rfcntl, 0x4); | 196 | ; |
815 | out_be16(&psc_i2s->fifo_regs->tfalarm, 0x100); | 197 | /* Finally, enable the PSC. |
816 | out_8(&psc_i2s->fifo_regs->tfcntl, 0x7); | 198 | * Receiver must always be enabled; even when we only want |
817 | 199 | * transmit. (see 15.3.2.3 of MPC5200B User's Guide) */ | |
818 | /* Lookup the IRQ numbers */ | 200 | |
819 | psc_i2s->playback.irq = | 201 | /* Go */ |
820 | bcom_get_task_irq(psc_i2s->playback.bcom_task); | 202 | out_8(&psc_dma->psc_regs->command, |
821 | psc_i2s->capture.irq = | 203 | MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE); |
822 | bcom_get_task_irq(psc_i2s->capture.bcom_task); | ||
823 | |||
824 | /* Save what we've done so it can be found again later */ | ||
825 | dev_set_drvdata(&op->dev, psc_i2s); | ||
826 | |||
827 | /* Register the SYSFS files */ | ||
828 | rc = device_create_file(psc_i2s->dev, &dev_attr_status); | ||
829 | rc |= device_create_file(psc_i2s->dev, &dev_attr_capture_overrun); | ||
830 | rc |= device_create_file(psc_i2s->dev, &dev_attr_playback_underrun); | ||
831 | if (rc) | ||
832 | dev_info(psc_i2s->dev, "error creating sysfs files\n"); | ||
833 | |||
834 | snd_soc_register_platform(&psc_i2s_pcm_soc_platform); | ||
835 | |||
836 | /* Tell the ASoC OF helpers about it */ | ||
837 | of_snd_soc_register_platform(&psc_i2s_pcm_soc_platform, op->node, | ||
838 | &psc_i2s->dai); | ||
839 | 204 | ||
840 | return 0; | 205 | return 0; |
206 | |||
841 | } | 207 | } |
842 | 208 | ||
843 | static int __devexit psc_i2s_of_remove(struct of_device *op) | 209 | static int __devexit psc_i2s_of_remove(struct of_device *op) |
844 | { | 210 | { |
845 | struct psc_i2s *psc_i2s = dev_get_drvdata(&op->dev); | 211 | return mpc5200_audio_dma_destroy(op); |
846 | |||
847 | dev_dbg(&op->dev, "psc_i2s_remove()\n"); | ||
848 | |||
849 | snd_soc_unregister_platform(&psc_i2s_pcm_soc_platform); | ||
850 | |||
851 | bcom_gen_bd_rx_release(psc_i2s->capture.bcom_task); | ||
852 | bcom_gen_bd_tx_release(psc_i2s->playback.bcom_task); | ||
853 | |||
854 | iounmap(psc_i2s->psc_regs); | ||
855 | iounmap(psc_i2s->fifo_regs); | ||
856 | kfree(psc_i2s); | ||
857 | dev_set_drvdata(&op->dev, NULL); | ||
858 | |||
859 | return 0; | ||
860 | } | 212 | } |
861 | 213 | ||
862 | /* Match table for of_platform binding */ | 214 | /* Match table for of_platform binding */ |
863 | static struct of_device_id psc_i2s_match[] __devinitdata = { | 215 | static struct of_device_id psc_i2s_match[] __devinitdata = { |
864 | { .compatible = "fsl,mpc5200-psc-i2s", }, | 216 | { .compatible = "fsl,mpc5200-psc-i2s", }, |
217 | { .compatible = "fsl,mpc5200b-psc-i2s", }, | ||
865 | {} | 218 | {} |
866 | }; | 219 | }; |
867 | MODULE_DEVICE_TABLE(of, psc_i2s_match); | 220 | MODULE_DEVICE_TABLE(of, psc_i2s_match); |
@@ -892,4 +245,7 @@ static void __exit psc_i2s_exit(void) | |||
892 | } | 245 | } |
893 | module_exit(psc_i2s_exit); | 246 | module_exit(psc_i2s_exit); |
894 | 247 | ||
248 | MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); | ||
249 | MODULE_DESCRIPTION("Freescale MPC5200 PSC in I2S mode ASoC Driver"); | ||
250 | MODULE_LICENSE("GPL"); | ||
895 | 251 | ||
diff --git a/sound/soc/fsl/mpc5200_psc_i2s.h b/sound/soc/fsl/mpc5200_psc_i2s.h new file mode 100644 index 000000000000..ce55e070fdf3 --- /dev/null +++ b/sound/soc/fsl/mpc5200_psc_i2s.h | |||
@@ -0,0 +1,12 @@ | |||
1 | /* | ||
2 | * Freescale MPC5200 PSC in I2S mode | ||
3 | * ALSA SoC Digital Audio Interface (DAI) driver | ||
4 | * | ||
5 | */ | ||
6 | |||
7 | #ifndef __SOUND_SOC_FSL_MPC52xx_PSC_I2S_H__ | ||
8 | #define __SOUND_SOC_FSL_MPC52xx_PSC_I2S_H__ | ||
9 | |||
10 | extern struct snd_soc_dai psc_i2s_dai[]; | ||
11 | |||
12 | #endif /* __SOUND_SOC_FSL_MPC52xx_PSC_I2S_H__ */ | ||
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c new file mode 100644 index 000000000000..8766f7a3893d --- /dev/null +++ b/sound/soc/fsl/pcm030-audio-fabric.c | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * Phytec pcm030 driver for the PSC of the Freescale MPC52xx | ||
3 | * configured as AC97 interface | ||
4 | * | ||
5 | * Copyright 2008 Jon Smirl, Digispeaker | ||
6 | * Author: Jon Smirl <jonsmirl@gmail.com> | ||
7 | * | ||
8 | * This file is licensed under the terms of the GNU General Public License | ||
9 | * version 2. This program is licensed "as is" without any warranty of any | ||
10 | * kind, whether express or implied. | ||
11 | */ | ||
12 | |||
13 | #include <linux/init.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/device.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/of_device.h> | ||
19 | #include <linux/of_platform.h> | ||
20 | #include <linux/dma-mapping.h> | ||
21 | |||
22 | #include <sound/core.h> | ||
23 | #include <sound/pcm.h> | ||
24 | #include <sound/pcm_params.h> | ||
25 | #include <sound/initval.h> | ||
26 | #include <sound/soc.h> | ||
27 | #include <sound/soc-of-simple.h> | ||
28 | |||
29 | #include "mpc5200_dma.h" | ||
30 | #include "mpc5200_psc_ac97.h" | ||
31 | #include "../codecs/wm9712.h" | ||
32 | |||
33 | static struct snd_soc_device device; | ||
34 | static struct snd_soc_card card; | ||
35 | |||
36 | static struct snd_soc_dai_link pcm030_fabric_dai[] = { | ||
37 | { | ||
38 | .name = "AC97", | ||
39 | .stream_name = "AC97 Analog", | ||
40 | .codec_dai = &wm9712_dai[WM9712_DAI_AC97_HIFI], | ||
41 | .cpu_dai = &psc_ac97_dai[MPC5200_AC97_NORMAL], | ||
42 | }, | ||
43 | { | ||
44 | .name = "AC97", | ||
45 | .stream_name = "AC97 IEC958", | ||
46 | .codec_dai = &wm9712_dai[WM9712_DAI_AC97_AUX], | ||
47 | .cpu_dai = &psc_ac97_dai[MPC5200_AC97_SPDIF], | ||
48 | }, | ||
49 | }; | ||
50 | |||
51 | static __init int pcm030_fabric_init(void) | ||
52 | { | ||
53 | struct platform_device *pdev; | ||
54 | int rc; | ||
55 | |||
56 | if (!machine_is_compatible("phytec,pcm030")) | ||
57 | return -ENODEV; | ||
58 | |||
59 | card.platform = &mpc5200_audio_dma_platform; | ||
60 | card.name = "pcm030"; | ||
61 | card.dai_link = pcm030_fabric_dai; | ||
62 | card.num_links = ARRAY_SIZE(pcm030_fabric_dai); | ||
63 | |||
64 | device.card = &card; | ||
65 | device.codec_dev = &soc_codec_dev_wm9712; | ||
66 | |||
67 | pdev = platform_device_alloc("soc-audio", 1); | ||
68 | if (!pdev) { | ||
69 | pr_err("pcm030_fabric_init: platform_device_alloc() failed\n"); | ||
70 | return -ENODEV; | ||
71 | } | ||
72 | |||
73 | platform_set_drvdata(pdev, &device); | ||
74 | device.dev = &pdev->dev; | ||
75 | |||
76 | rc = platform_device_add(pdev); | ||
77 | if (rc) { | ||
78 | pr_err("pcm030_fabric_init: platform_device_add() failed\n"); | ||
79 | return -ENODEV; | ||
80 | } | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | module_init(pcm030_fabric_init); | ||
85 | |||
86 | |||
87 | MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); | ||
88 | MODULE_DESCRIPTION(DRV_NAME ": mpc5200 pcm030 fabric driver"); | ||
89 | MODULE_LICENSE("GPL"); | ||
90 | |||
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 675732e724d5..b771238662b6 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig | |||
@@ -39,6 +39,14 @@ config SND_OMAP_SOC_OMAP2EVM | |||
39 | help | 39 | help |
40 | Say Y if you want to add support for SoC audio on the omap2evm board. | 40 | Say Y if you want to add support for SoC audio on the omap2evm board. |
41 | 41 | ||
42 | config SND_OMAP_SOC_OMAP3EVM | ||
43 | tristate "SoC Audio support for OMAP3EVM board" | ||
44 | depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3EVM | ||
45 | select SND_OMAP_SOC_MCBSP | ||
46 | select SND_SOC_TWL4030 | ||
47 | help | ||
48 | Say Y if you want to add support for SoC audio on the omap3evm board. | ||
49 | |||
42 | config SND_OMAP_SOC_SDP3430 | 50 | config SND_OMAP_SOC_SDP3430 |
43 | tristate "SoC Audio support for Texas Instruments SDP3430" | 51 | tristate "SoC Audio support for Texas Instruments SDP3430" |
44 | depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_3430SDP | 52 | depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_3430SDP |
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 0c9e4ac37660..a37f49862389 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile | |||
@@ -10,6 +10,7 @@ snd-soc-n810-objs := n810.o | |||
10 | snd-soc-osk5912-objs := osk5912.o | 10 | snd-soc-osk5912-objs := osk5912.o |
11 | snd-soc-overo-objs := overo.o | 11 | snd-soc-overo-objs := overo.o |
12 | snd-soc-omap2evm-objs := omap2evm.o | 12 | snd-soc-omap2evm-objs := omap2evm.o |
13 | snd-soc-omap3evm-objs := omap3evm.o | ||
13 | snd-soc-sdp3430-objs := sdp3430.o | 14 | snd-soc-sdp3430-objs := sdp3430.o |
14 | snd-soc-omap3pandora-objs := omap3pandora.o | 15 | snd-soc-omap3pandora-objs := omap3pandora.o |
15 | snd-soc-omap3beagle-objs := omap3beagle.o | 16 | snd-soc-omap3beagle-objs := omap3beagle.o |
@@ -18,6 +19,7 @@ obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o | |||
18 | obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o | 19 | obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o |
19 | obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o | 20 | obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o |
20 | obj-$(CONFIG_MACH_OMAP2EVM) += snd-soc-omap2evm.o | 21 | obj-$(CONFIG_MACH_OMAP2EVM) += snd-soc-omap2evm.o |
22 | obj-$(CONFIG_MACH_OMAP3EVM) += snd-soc-omap3evm.o | ||
21 | obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o | 23 | obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o |
22 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o | 24 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o |
23 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o | 25 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o |
diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 91ef17992de5..b60b1dfbc435 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c | |||
@@ -383,10 +383,9 @@ static int __init n810_soc_init(void) | |||
383 | clk_set_parent(sys_clkout2_src, func96m_clk); | 383 | clk_set_parent(sys_clkout2_src, func96m_clk); |
384 | clk_set_rate(sys_clkout2, 12000000); | 384 | clk_set_rate(sys_clkout2, 12000000); |
385 | 385 | ||
386 | if (gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) | 386 | BUG_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) || |
387 | BUG(); | 387 | (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0)); |
388 | if (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0) | 388 | |
389 | BUG(); | ||
390 | gpio_direction_output(N810_HEADSET_AMP_GPIO, 0); | 389 | gpio_direction_output(N810_HEADSET_AMP_GPIO, 0); |
391 | gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0); | 390 | gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0); |
392 | 391 | ||
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 912614283848..a5d46a7b196a 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
@@ -215,8 +215,9 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
215 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); | 215 | struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); |
216 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; | 216 | struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; |
217 | int dma, bus_id = mcbsp_data->bus_id, id = cpu_dai->id; | 217 | int dma, bus_id = mcbsp_data->bus_id, id = cpu_dai->id; |
218 | int wlen, channels; | 218 | int wlen, channels, wpf; |
219 | unsigned long port; | 219 | unsigned long port; |
220 | unsigned int format; | ||
220 | 221 | ||
221 | if (cpu_class_is_omap1()) { | 222 | if (cpu_class_is_omap1()) { |
222 | dma = omap1_dma_reqs[bus_id][substream->stream]; | 223 | dma = omap1_dma_reqs[bus_id][substream->stream]; |
@@ -244,18 +245,24 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
244 | return 0; | 245 | return 0; |
245 | } | 246 | } |
246 | 247 | ||
247 | channels = params_channels(params); | 248 | format = mcbsp_data->fmt & SND_SOC_DAIFMT_FORMAT_MASK; |
249 | wpf = channels = params_channels(params); | ||
248 | switch (channels) { | 250 | switch (channels) { |
249 | case 2: | 251 | case 2: |
250 | /* Use dual-phase frames */ | 252 | if (format == SND_SOC_DAIFMT_I2S) { |
251 | regs->rcr2 |= RPHASE; | 253 | /* Use dual-phase frames */ |
252 | regs->xcr2 |= XPHASE; | 254 | regs->rcr2 |= RPHASE; |
255 | regs->xcr2 |= XPHASE; | ||
256 | /* Set 1 word per (McBSP) frame for phase1 and phase2 */ | ||
257 | wpf--; | ||
258 | regs->rcr2 |= RFRLEN2(wpf - 1); | ||
259 | regs->xcr2 |= XFRLEN2(wpf - 1); | ||
260 | } | ||
253 | case 1: | 261 | case 1: |
254 | /* Set 1 word per (McBSP) frame */ | 262 | case 4: |
255 | regs->rcr2 |= RFRLEN2(1 - 1); | 263 | /* Set word per (McBSP) frame for phase1 */ |
256 | regs->rcr1 |= RFRLEN1(1 - 1); | 264 | regs->rcr1 |= RFRLEN1(wpf - 1); |
257 | regs->xcr2 |= XFRLEN2(1 - 1); | 265 | regs->xcr1 |= XFRLEN1(wpf - 1); |
258 | regs->xcr1 |= XFRLEN1(1 - 1); | ||
259 | break; | 266 | break; |
260 | default: | 267 | default: |
261 | /* Unsupported number of channels */ | 268 | /* Unsupported number of channels */ |
@@ -277,11 +284,12 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
277 | } | 284 | } |
278 | 285 | ||
279 | /* Set FS period and length in terms of bit clock periods */ | 286 | /* Set FS period and length in terms of bit clock periods */ |
280 | switch (mcbsp_data->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | 287 | switch (format) { |
281 | case SND_SOC_DAIFMT_I2S: | 288 | case SND_SOC_DAIFMT_I2S: |
282 | regs->srgr2 |= FPER(wlen * 2 - 1); | 289 | regs->srgr2 |= FPER(wlen * channels - 1); |
283 | regs->srgr1 |= FWID(wlen - 1); | 290 | regs->srgr1 |= FWID(wlen - 1); |
284 | break; | 291 | break; |
292 | case SND_SOC_DAIFMT_DSP_A: | ||
285 | case SND_SOC_DAIFMT_DSP_B: | 293 | case SND_SOC_DAIFMT_DSP_B: |
286 | regs->srgr2 |= FPER(wlen * channels - 1); | 294 | regs->srgr2 |= FPER(wlen * channels - 1); |
287 | regs->srgr1 |= FWID(0); | 295 | regs->srgr1 |= FWID(0); |
@@ -326,6 +334,13 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
326 | regs->rcr2 |= RDATDLY(1); | 334 | regs->rcr2 |= RDATDLY(1); |
327 | regs->xcr2 |= XDATDLY(1); | 335 | regs->xcr2 |= XDATDLY(1); |
328 | break; | 336 | break; |
337 | case SND_SOC_DAIFMT_DSP_A: | ||
338 | /* 1-bit data delay */ | ||
339 | regs->rcr2 |= RDATDLY(1); | ||
340 | regs->xcr2 |= XDATDLY(1); | ||
341 | /* Invert FS polarity configuration */ | ||
342 | temp_fmt ^= SND_SOC_DAIFMT_NB_IF; | ||
343 | break; | ||
329 | case SND_SOC_DAIFMT_DSP_B: | 344 | case SND_SOC_DAIFMT_DSP_B: |
330 | /* 0-bit data delay */ | 345 | /* 0-bit data delay */ |
331 | regs->rcr2 |= RDATDLY(0); | 346 | regs->rcr2 |= RDATDLY(0); |
@@ -492,13 +507,13 @@ static struct snd_soc_dai_ops omap_mcbsp_dai_ops = { | |||
492 | .id = (link_id), \ | 507 | .id = (link_id), \ |
493 | .playback = { \ | 508 | .playback = { \ |
494 | .channels_min = 1, \ | 509 | .channels_min = 1, \ |
495 | .channels_max = 2, \ | 510 | .channels_max = 4, \ |
496 | .rates = OMAP_MCBSP_RATES, \ | 511 | .rates = OMAP_MCBSP_RATES, \ |
497 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ | 512 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ |
498 | }, \ | 513 | }, \ |
499 | .capture = { \ | 514 | .capture = { \ |
500 | .channels_min = 1, \ | 515 | .channels_min = 1, \ |
501 | .channels_max = 2, \ | 516 | .channels_max = 4, \ |
502 | .rates = OMAP_MCBSP_RATES, \ | 517 | .rates = OMAP_MCBSP_RATES, \ |
503 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ | 518 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ |
504 | }, \ | 519 | }, \ |
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 07cf7f46b584..6454e15f7d28 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c | |||
@@ -87,8 +87,10 @@ static int omap_pcm_hw_params(struct snd_pcm_substream *substream, | |||
87 | struct omap_pcm_dma_data *dma_data = rtd->dai->cpu_dai->dma_data; | 87 | struct omap_pcm_dma_data *dma_data = rtd->dai->cpu_dai->dma_data; |
88 | int err = 0; | 88 | int err = 0; |
89 | 89 | ||
90 | /* return if this is a bufferless transfer e.g. | ||
91 | * codec <--> BT codec or GSM modem -- lg FIXME */ | ||
90 | if (!dma_data) | 92 | if (!dma_data) |
91 | return -ENODEV; | 93 | return 0; |
92 | 94 | ||
93 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); | 95 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); |
94 | runtime->dma_bytes = params_buffer_bytes(params); | 96 | runtime->dma_bytes = params_buffer_bytes(params); |
@@ -134,6 +136,11 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream) | |||
134 | struct omap_pcm_dma_data *dma_data = prtd->dma_data; | 136 | struct omap_pcm_dma_data *dma_data = prtd->dma_data; |
135 | struct omap_dma_channel_params dma_params; | 137 | struct omap_dma_channel_params dma_params; |
136 | 138 | ||
139 | /* return if this is a bufferless transfer e.g. | ||
140 | * codec <--> BT codec or GSM modem -- lg FIXME */ | ||
141 | if (!prtd->dma_data) | ||
142 | return 0; | ||
143 | |||
137 | memset(&dma_params, 0, sizeof(dma_params)); | 144 | memset(&dma_params, 0, sizeof(dma_params)); |
138 | /* | 145 | /* |
139 | * Note: Regardless of interface data formats supported by OMAP McBSP | 146 | * Note: Regardless of interface data formats supported by OMAP McBSP |
diff --git a/sound/soc/omap/omap2evm.c b/sound/soc/omap/omap2evm.c index 0c2322dcf02a..027e1a40f8a1 100644 --- a/sound/soc/omap/omap2evm.c +++ b/sound/soc/omap/omap2evm.c | |||
@@ -86,7 +86,7 @@ static struct snd_soc_dai_link omap2evm_dai = { | |||
86 | .name = "TWL4030", | 86 | .name = "TWL4030", |
87 | .stream_name = "TWL4030", | 87 | .stream_name = "TWL4030", |
88 | .cpu_dai = &omap_mcbsp_dai[0], | 88 | .cpu_dai = &omap_mcbsp_dai[0], |
89 | .codec_dai = &twl4030_dai, | 89 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], |
90 | .ops = &omap2evm_ops, | 90 | .ops = &omap2evm_ops, |
91 | }; | 91 | }; |
92 | 92 | ||
diff --git a/sound/soc/omap/omap3beagle.c b/sound/soc/omap/omap3beagle.c index fd24a4acd2f5..b0cff9f33b7e 100644 --- a/sound/soc/omap/omap3beagle.c +++ b/sound/soc/omap/omap3beagle.c | |||
@@ -41,23 +41,33 @@ static int omap3beagle_hw_params(struct snd_pcm_substream *substream, | |||
41 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 41 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
42 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | 42 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; |
43 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | 43 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; |
44 | unsigned int fmt; | ||
44 | int ret; | 45 | int ret; |
45 | 46 | ||
47 | switch (params_channels(params)) { | ||
48 | case 2: /* Stereo I2S mode */ | ||
49 | fmt = SND_SOC_DAIFMT_I2S | | ||
50 | SND_SOC_DAIFMT_NB_NF | | ||
51 | SND_SOC_DAIFMT_CBM_CFM; | ||
52 | break; | ||
53 | case 4: /* Four channel TDM mode */ | ||
54 | fmt = SND_SOC_DAIFMT_DSP_A | | ||
55 | SND_SOC_DAIFMT_IB_NF | | ||
56 | SND_SOC_DAIFMT_CBM_CFM; | ||
57 | break; | ||
58 | default: | ||
59 | return -EINVAL; | ||
60 | } | ||
61 | |||
46 | /* Set codec DAI configuration */ | 62 | /* Set codec DAI configuration */ |
47 | ret = snd_soc_dai_set_fmt(codec_dai, | 63 | ret = snd_soc_dai_set_fmt(codec_dai, fmt); |
48 | SND_SOC_DAIFMT_I2S | | ||
49 | SND_SOC_DAIFMT_NB_NF | | ||
50 | SND_SOC_DAIFMT_CBM_CFM); | ||
51 | if (ret < 0) { | 64 | if (ret < 0) { |
52 | printk(KERN_ERR "can't set codec DAI configuration\n"); | 65 | printk(KERN_ERR "can't set codec DAI configuration\n"); |
53 | return ret; | 66 | return ret; |
54 | } | 67 | } |
55 | 68 | ||
56 | /* Set cpu DAI configuration */ | 69 | /* Set cpu DAI configuration */ |
57 | ret = snd_soc_dai_set_fmt(cpu_dai, | 70 | ret = snd_soc_dai_set_fmt(cpu_dai, fmt); |
58 | SND_SOC_DAIFMT_I2S | | ||
59 | SND_SOC_DAIFMT_NB_NF | | ||
60 | SND_SOC_DAIFMT_CBM_CFM); | ||
61 | if (ret < 0) { | 71 | if (ret < 0) { |
62 | printk(KERN_ERR "can't set cpu DAI configuration\n"); | 72 | printk(KERN_ERR "can't set cpu DAI configuration\n"); |
63 | return ret; | 73 | return ret; |
@@ -83,7 +93,7 @@ static struct snd_soc_dai_link omap3beagle_dai = { | |||
83 | .name = "TWL4030", | 93 | .name = "TWL4030", |
84 | .stream_name = "TWL4030", | 94 | .stream_name = "TWL4030", |
85 | .cpu_dai = &omap_mcbsp_dai[0], | 95 | .cpu_dai = &omap_mcbsp_dai[0], |
86 | .codec_dai = &twl4030_dai, | 96 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], |
87 | .ops = &omap3beagle_ops, | 97 | .ops = &omap3beagle_ops, |
88 | }; | 98 | }; |
89 | 99 | ||
diff --git a/sound/soc/omap/omap3evm.c b/sound/soc/omap/omap3evm.c new file mode 100644 index 000000000000..9114c263077b --- /dev/null +++ b/sound/soc/omap/omap3evm.c | |||
@@ -0,0 +1,147 @@ | |||
1 | /* | ||
2 | * omap3evm.c -- ALSA SoC support for OMAP3 EVM | ||
3 | * | ||
4 | * Author: Anuj Aggarwal <anuj.aggarwal@ti.com> | ||
5 | * | ||
6 | * Based on sound/soc/omap/beagle.c by Steve Sakoman | ||
7 | * | ||
8 | * Copyright (C) 2008 Texas Instruments, Incorporated | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation version 2. | ||
13 | * | ||
14 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, | ||
15 | * whether express or implied; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | */ | ||
19 | |||
20 | #include <linux/clk.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <sound/core.h> | ||
23 | #include <sound/pcm.h> | ||
24 | #include <sound/soc.h> | ||
25 | #include <sound/soc-dapm.h> | ||
26 | |||
27 | #include <asm/mach-types.h> | ||
28 | #include <mach/hardware.h> | ||
29 | #include <mach/gpio.h> | ||
30 | #include <mach/mcbsp.h> | ||
31 | |||
32 | #include "omap-mcbsp.h" | ||
33 | #include "omap-pcm.h" | ||
34 | #include "../codecs/twl4030.h" | ||
35 | |||
36 | static int omap3evm_hw_params(struct snd_pcm_substream *substream, | ||
37 | struct snd_pcm_hw_params *params) | ||
38 | { | ||
39 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
40 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
41 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
42 | int ret; | ||
43 | |||
44 | /* Set codec DAI configuration */ | ||
45 | ret = snd_soc_dai_set_fmt(codec_dai, | ||
46 | SND_SOC_DAIFMT_I2S | | ||
47 | SND_SOC_DAIFMT_NB_NF | | ||
48 | SND_SOC_DAIFMT_CBM_CFM); | ||
49 | if (ret < 0) { | ||
50 | printk(KERN_ERR "Can't set codec DAI configuration\n"); | ||
51 | return ret; | ||
52 | } | ||
53 | |||
54 | /* Set cpu DAI configuration */ | ||
55 | ret = snd_soc_dai_set_fmt(cpu_dai, | ||
56 | SND_SOC_DAIFMT_I2S | | ||
57 | SND_SOC_DAIFMT_NB_NF | | ||
58 | SND_SOC_DAIFMT_CBM_CFM); | ||
59 | if (ret < 0) { | ||
60 | printk(KERN_ERR "Can't set cpu DAI configuration\n"); | ||
61 | return ret; | ||
62 | } | ||
63 | |||
64 | /* Set the codec system clock for DAC and ADC */ | ||
65 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000, | ||
66 | SND_SOC_CLOCK_IN); | ||
67 | if (ret < 0) { | ||
68 | printk(KERN_ERR "Can't set codec system clock\n"); | ||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static struct snd_soc_ops omap3evm_ops = { | ||
76 | .hw_params = omap3evm_hw_params, | ||
77 | }; | ||
78 | |||
79 | /* Digital audio interface glue - connects codec <--> CPU */ | ||
80 | static struct snd_soc_dai_link omap3evm_dai = { | ||
81 | .name = "TWL4030", | ||
82 | .stream_name = "TWL4030", | ||
83 | .cpu_dai = &omap_mcbsp_dai[0], | ||
84 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], | ||
85 | .ops = &omap3evm_ops, | ||
86 | }; | ||
87 | |||
88 | /* Audio machine driver */ | ||
89 | static struct snd_soc_card snd_soc_omap3evm = { | ||
90 | .name = "omap3evm", | ||
91 | .platform = &omap_soc_platform, | ||
92 | .dai_link = &omap3evm_dai, | ||
93 | .num_links = 1, | ||
94 | }; | ||
95 | |||
96 | /* Audio subsystem */ | ||
97 | static struct snd_soc_device omap3evm_snd_devdata = { | ||
98 | .card = &snd_soc_omap3evm, | ||
99 | .codec_dev = &soc_codec_dev_twl4030, | ||
100 | }; | ||
101 | |||
102 | static struct platform_device *omap3evm_snd_device; | ||
103 | |||
104 | static int __init omap3evm_soc_init(void) | ||
105 | { | ||
106 | int ret; | ||
107 | |||
108 | if (!machine_is_omap3evm()) { | ||
109 | pr_err("Not OMAP3 EVM!\n"); | ||
110 | return -ENODEV; | ||
111 | } | ||
112 | pr_info("OMAP3 EVM SoC init\n"); | ||
113 | |||
114 | omap3evm_snd_device = platform_device_alloc("soc-audio", -1); | ||
115 | if (!omap3evm_snd_device) { | ||
116 | printk(KERN_ERR "Platform device allocation failed\n"); | ||
117 | return -ENOMEM; | ||
118 | } | ||
119 | |||
120 | platform_set_drvdata(omap3evm_snd_device, &omap3evm_snd_devdata); | ||
121 | omap3evm_snd_devdata.dev = &omap3evm_snd_device->dev; | ||
122 | *(unsigned int *)omap3evm_dai.cpu_dai->private_data = 1; | ||
123 | |||
124 | ret = platform_device_add(omap3evm_snd_device); | ||
125 | if (ret) | ||
126 | goto err1; | ||
127 | |||
128 | return 0; | ||
129 | |||
130 | err1: | ||
131 | printk(KERN_ERR "Unable to add platform device\n"); | ||
132 | platform_device_put(omap3evm_snd_device); | ||
133 | |||
134 | return ret; | ||
135 | } | ||
136 | |||
137 | static void __exit omap3evm_soc_exit(void) | ||
138 | { | ||
139 | platform_device_unregister(omap3evm_snd_device); | ||
140 | } | ||
141 | |||
142 | module_init(omap3evm_soc_init); | ||
143 | module_exit(omap3evm_soc_exit); | ||
144 | |||
145 | MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>"); | ||
146 | MODULE_DESCRIPTION("ALSA SoC OMAP3 EVM"); | ||
147 | MODULE_LICENSE("GPLv2"); | ||
diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index fe282d4ef422..ad219aaf7cb8 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c | |||
@@ -228,14 +228,14 @@ static struct snd_soc_dai_link omap3pandora_dai[] = { | |||
228 | .name = "PCM1773", | 228 | .name = "PCM1773", |
229 | .stream_name = "HiFi Out", | 229 | .stream_name = "HiFi Out", |
230 | .cpu_dai = &omap_mcbsp_dai[0], | 230 | .cpu_dai = &omap_mcbsp_dai[0], |
231 | .codec_dai = &twl4030_dai, | 231 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], |
232 | .ops = &omap3pandora_out_ops, | 232 | .ops = &omap3pandora_out_ops, |
233 | .init = omap3pandora_out_init, | 233 | .init = omap3pandora_out_init, |
234 | }, { | 234 | }, { |
235 | .name = "TWL4030", | 235 | .name = "TWL4030", |
236 | .stream_name = "Line/Mic In", | 236 | .stream_name = "Line/Mic In", |
237 | .cpu_dai = &omap_mcbsp_dai[1], | 237 | .cpu_dai = &omap_mcbsp_dai[1], |
238 | .codec_dai = &twl4030_dai, | 238 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], |
239 | .ops = &omap3pandora_in_ops, | 239 | .ops = &omap3pandora_in_ops, |
240 | .init = omap3pandora_in_init, | 240 | .init = omap3pandora_in_init, |
241 | } | 241 | } |
diff --git a/sound/soc/omap/overo.c b/sound/soc/omap/overo.c index a72dc4e159e5..ec4f8fd8b3a2 100644 --- a/sound/soc/omap/overo.c +++ b/sound/soc/omap/overo.c | |||
@@ -83,7 +83,7 @@ static struct snd_soc_dai_link overo_dai = { | |||
83 | .name = "TWL4030", | 83 | .name = "TWL4030", |
84 | .stream_name = "TWL4030", | 84 | .stream_name = "TWL4030", |
85 | .cpu_dai = &omap_mcbsp_dai[0], | 85 | .cpu_dai = &omap_mcbsp_dai[0], |
86 | .codec_dai = &twl4030_dai, | 86 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], |
87 | .ops = &overo_ops, | 87 | .ops = &overo_ops, |
88 | }; | 88 | }; |
89 | 89 | ||
diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index 10f1c867f11d..b719e5db4f57 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c | |||
@@ -84,6 +84,49 @@ static struct snd_soc_ops sdp3430_ops = { | |||
84 | .hw_params = sdp3430_hw_params, | 84 | .hw_params = sdp3430_hw_params, |
85 | }; | 85 | }; |
86 | 86 | ||
87 | static int sdp3430_hw_voice_params(struct snd_pcm_substream *substream, | ||
88 | struct snd_pcm_hw_params *params) | ||
89 | { | ||
90 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
91 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
92 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
93 | int ret; | ||
94 | |||
95 | /* Set codec DAI configuration */ | ||
96 | ret = snd_soc_dai_set_fmt(codec_dai, | ||
97 | SND_SOC_DAIFMT_DSP_A | | ||
98 | SND_SOC_DAIFMT_IB_NF | | ||
99 | SND_SOC_DAIFMT_CBS_CFM); | ||
100 | if (ret) { | ||
101 | printk(KERN_ERR "can't set codec DAI configuration\n"); | ||
102 | return ret; | ||
103 | } | ||
104 | |||
105 | /* Set cpu DAI configuration */ | ||
106 | ret = snd_soc_dai_set_fmt(cpu_dai, | ||
107 | SND_SOC_DAIFMT_DSP_A | | ||
108 | SND_SOC_DAIFMT_IB_NF | | ||
109 | SND_SOC_DAIFMT_CBM_CFM); | ||
110 | if (ret < 0) { | ||
111 | printk(KERN_ERR "can't set cpu DAI configuration\n"); | ||
112 | return ret; | ||
113 | } | ||
114 | |||
115 | /* Set the codec system clock for DAC and ADC */ | ||
116 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000, | ||
117 | SND_SOC_CLOCK_IN); | ||
118 | if (ret < 0) { | ||
119 | printk(KERN_ERR "can't set codec system clock\n"); | ||
120 | return ret; | ||
121 | } | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | static struct snd_soc_ops sdp3430_voice_ops = { | ||
127 | .hw_params = sdp3430_hw_voice_params, | ||
128 | }; | ||
129 | |||
87 | /* Headset jack */ | 130 | /* Headset jack */ |
88 | static struct snd_soc_jack hs_jack; | 131 | static struct snd_soc_jack hs_jack; |
89 | 132 | ||
@@ -192,28 +235,58 @@ static int sdp3430_twl4030_init(struct snd_soc_codec *codec) | |||
192 | return ret; | 235 | return ret; |
193 | } | 236 | } |
194 | 237 | ||
238 | static int sdp3430_twl4030_voice_init(struct snd_soc_codec *codec) | ||
239 | { | ||
240 | unsigned short reg; | ||
241 | |||
242 | /* Enable voice interface */ | ||
243 | reg = codec->read(codec, TWL4030_REG_VOICE_IF); | ||
244 | reg |= TWL4030_VIF_DIN_EN | TWL4030_VIF_DOUT_EN | TWL4030_VIF_EN; | ||
245 | codec->write(codec, TWL4030_REG_VOICE_IF, reg); | ||
246 | |||
247 | return 0; | ||
248 | } | ||
249 | |||
250 | |||
195 | /* Digital audio interface glue - connects codec <--> CPU */ | 251 | /* Digital audio interface glue - connects codec <--> CPU */ |
196 | static struct snd_soc_dai_link sdp3430_dai = { | 252 | static struct snd_soc_dai_link sdp3430_dai[] = { |
197 | .name = "TWL4030", | 253 | { |
198 | .stream_name = "TWL4030", | 254 | .name = "TWL4030 I2S", |
199 | .cpu_dai = &omap_mcbsp_dai[0], | 255 | .stream_name = "TWL4030 Audio", |
200 | .codec_dai = &twl4030_dai, | 256 | .cpu_dai = &omap_mcbsp_dai[0], |
201 | .init = sdp3430_twl4030_init, | 257 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], |
202 | .ops = &sdp3430_ops, | 258 | .init = sdp3430_twl4030_init, |
259 | .ops = &sdp3430_ops, | ||
260 | }, | ||
261 | { | ||
262 | .name = "TWL4030 PCM", | ||
263 | .stream_name = "TWL4030 Voice", | ||
264 | .cpu_dai = &omap_mcbsp_dai[1], | ||
265 | .codec_dai = &twl4030_dai[TWL4030_DAI_VOICE], | ||
266 | .init = sdp3430_twl4030_voice_init, | ||
267 | .ops = &sdp3430_voice_ops, | ||
268 | }, | ||
203 | }; | 269 | }; |
204 | 270 | ||
205 | /* Audio machine driver */ | 271 | /* Audio machine driver */ |
206 | static struct snd_soc_card snd_soc_sdp3430 = { | 272 | static struct snd_soc_card snd_soc_sdp3430 = { |
207 | .name = "SDP3430", | 273 | .name = "SDP3430", |
208 | .platform = &omap_soc_platform, | 274 | .platform = &omap_soc_platform, |
209 | .dai_link = &sdp3430_dai, | 275 | .dai_link = sdp3430_dai, |
210 | .num_links = 1, | 276 | .num_links = ARRAY_SIZE(sdp3430_dai), |
277 | }; | ||
278 | |||
279 | /* twl4030 setup */ | ||
280 | static struct twl4030_setup_data twl4030_setup = { | ||
281 | .ramp_delay_value = 3, | ||
282 | .sysclk = 26000, | ||
211 | }; | 283 | }; |
212 | 284 | ||
213 | /* Audio subsystem */ | 285 | /* Audio subsystem */ |
214 | static struct snd_soc_device sdp3430_snd_devdata = { | 286 | static struct snd_soc_device sdp3430_snd_devdata = { |
215 | .card = &snd_soc_sdp3430, | 287 | .card = &snd_soc_sdp3430, |
216 | .codec_dev = &soc_codec_dev_twl4030, | 288 | .codec_dev = &soc_codec_dev_twl4030, |
289 | .codec_data = &twl4030_setup, | ||
217 | }; | 290 | }; |
218 | 291 | ||
219 | static struct platform_device *sdp3430_snd_device; | 292 | static struct platform_device *sdp3430_snd_device; |
@@ -236,7 +309,8 @@ static int __init sdp3430_soc_init(void) | |||
236 | 309 | ||
237 | platform_set_drvdata(sdp3430_snd_device, &sdp3430_snd_devdata); | 310 | platform_set_drvdata(sdp3430_snd_device, &sdp3430_snd_devdata); |
238 | sdp3430_snd_devdata.dev = &sdp3430_snd_device->dev; | 311 | sdp3430_snd_devdata.dev = &sdp3430_snd_device->dev; |
239 | *(unsigned int *)sdp3430_dai.cpu_dai->private_data = 1; /* McBSP2 */ | 312 | *(unsigned int *)sdp3430_dai[0].cpu_dai->private_data = 1; /* McBSP2 */ |
313 | *(unsigned int *)sdp3430_dai[1].cpu_dai->private_data = 2; /* McBSP3 */ | ||
240 | 314 | ||
241 | ret = platform_device_add(sdp3430_snd_device); | 315 | ret = platform_device_add(sdp3430_snd_device); |
242 | if (ret) | 316 | if (ret) |
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index ad8a10fe6298..dcd163a4ee9a 100644 --- a/sound/soc/pxa/Kconfig +++ b/sound/soc/pxa/Kconfig | |||
@@ -89,13 +89,13 @@ config SND_PXA2XX_SOC_E800 | |||
89 | Toshiba e800 PDA | 89 | Toshiba e800 PDA |
90 | 90 | ||
91 | config SND_PXA2XX_SOC_EM_X270 | 91 | config SND_PXA2XX_SOC_EM_X270 |
92 | tristate "SoC Audio support for CompuLab EM-x270" | 92 | tristate "SoC Audio support for CompuLab EM-x270, eXeda and CM-X300" |
93 | depends on SND_PXA2XX_SOC && MACH_EM_X270 | 93 | depends on SND_PXA2XX_SOC && MACH_EM_X270 |
94 | select SND_PXA2XX_SOC_AC97 | 94 | select SND_PXA2XX_SOC_AC97 |
95 | select SND_SOC_WM9712 | 95 | select SND_SOC_WM9712 |
96 | help | 96 | help |
97 | Say Y if you want to add support for SoC audio on | 97 | Say Y if you want to add support for SoC audio on |
98 | CompuLab EM-x270. | 98 | CompuLab EM-x270, eXeda and CM-X300 machines. |
99 | 99 | ||
100 | config SND_PXA2XX_SOC_PALM27X | 100 | config SND_PXA2XX_SOC_PALM27X |
101 | bool "SoC Audio support for Palm T|X, T5 and LifeDrive" | 101 | bool "SoC Audio support for Palm T|X, T5 and LifeDrive" |
@@ -134,3 +134,12 @@ config SND_PXA2XX_SOC_MIOA701 | |||
134 | help | 134 | help |
135 | Say Y if you want to add support for SoC audio on the | 135 | Say Y if you want to add support for SoC audio on the |
136 | MIO A701. | 136 | MIO A701. |
137 | |||
138 | config SND_PXA2XX_SOC_IMOTE2 | ||
139 | tristate "SoC Audio support for IMote 2" | ||
140 | depends on SND_PXA2XX_SOC && MACH_INTELMOTE2 | ||
141 | select SND_PXA2XX_SOC_I2S | ||
142 | select SND_SOC_WM8940 | ||
143 | help | ||
144 | Say Y if you want to add support for SoC audio on the | ||
145 | IMote 2. | ||
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile index 4b90c3ccae45..6e096b480335 100644 --- a/sound/soc/pxa/Makefile +++ b/sound/soc/pxa/Makefile | |||
@@ -22,6 +22,7 @@ snd-soc-palm27x-objs := palm27x.o | |||
22 | snd-soc-zylonite-objs := zylonite.o | 22 | snd-soc-zylonite-objs := zylonite.o |
23 | snd-soc-magician-objs := magician.o | 23 | snd-soc-magician-objs := magician.o |
24 | snd-soc-mioa701-objs := mioa701_wm9713.o | 24 | snd-soc-mioa701-objs := mioa701_wm9713.o |
25 | snd-soc-imote2-objs := imote2.o | ||
25 | 26 | ||
26 | obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o | 27 | obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o |
27 | obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o | 28 | obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o |
@@ -35,3 +36,4 @@ obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o | |||
35 | obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o | 36 | obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o |
36 | obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o | 37 | obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o |
37 | obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o | 38 | obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o |
39 | obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o | ||
diff --git a/sound/soc/pxa/em-x270.c b/sound/soc/pxa/em-x270.c index 949be9c2a01b..f4756e4025fd 100644 --- a/sound/soc/pxa/em-x270.c +++ b/sound/soc/pxa/em-x270.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * em-x270.c -- SoC audio for EM-X270 | 2 | * SoC audio driver for EM-X270, eXeda and CM-X300 |
3 | * | 3 | * |
4 | * Copyright 2007 CompuLab, Ltd. | 4 | * Copyright 2007, 2009 CompuLab, Ltd. |
5 | * | 5 | * |
6 | * Author: Mike Rapoport <mike@compulab.co.il> | 6 | * Author: Mike Rapoport <mike@compulab.co.il> |
7 | * | 7 | * |
@@ -68,7 +68,8 @@ static int __init em_x270_init(void) | |||
68 | { | 68 | { |
69 | int ret; | 69 | int ret; |
70 | 70 | ||
71 | if (!machine_is_em_x270()) | 71 | if (!(machine_is_em_x270() || machine_is_exeda() |
72 | || machine_is_cm_x300())) | ||
72 | return -ENODEV; | 73 | return -ENODEV; |
73 | 74 | ||
74 | em_x270_snd_device = platform_device_alloc("soc-audio", -1); | 75 | em_x270_snd_device = platform_device_alloc("soc-audio", -1); |
@@ -95,5 +96,5 @@ module_exit(em_x270_exit); | |||
95 | 96 | ||
96 | /* Module information */ | 97 | /* Module information */ |
97 | MODULE_AUTHOR("Mike Rapoport"); | 98 | MODULE_AUTHOR("Mike Rapoport"); |
98 | MODULE_DESCRIPTION("ALSA SoC EM-X270"); | 99 | MODULE_DESCRIPTION("ALSA SoC EM-X270, eXeda and CM-X300"); |
99 | MODULE_LICENSE("GPL"); | 100 | MODULE_LICENSE("GPL"); |
diff --git a/sound/soc/pxa/imote2.c b/sound/soc/pxa/imote2.c new file mode 100644 index 000000000000..405587a01160 --- /dev/null +++ b/sound/soc/pxa/imote2.c | |||
@@ -0,0 +1,114 @@ | |||
1 | |||
2 | #include <linux/module.h> | ||
3 | #include <sound/soc.h> | ||
4 | |||
5 | #include <asm/mach-types.h> | ||
6 | |||
7 | #include "../codecs/wm8940.h" | ||
8 | #include "pxa2xx-i2s.h" | ||
9 | #include "pxa2xx-pcm.h" | ||
10 | |||
11 | static int imote2_asoc_hw_params(struct snd_pcm_substream *substream, | ||
12 | struct snd_pcm_hw_params *params) | ||
13 | { | ||
14 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
15 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
16 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
17 | unsigned int clk = 0; | ||
18 | int ret; | ||
19 | |||
20 | switch (params_rate(params)) { | ||
21 | case 8000: | ||
22 | case 16000: | ||
23 | case 48000: | ||
24 | case 96000: | ||
25 | clk = 12288000; | ||
26 | break; | ||
27 | case 11025: | ||
28 | case 22050: | ||
29 | case 44100: | ||
30 | clk = 11289600; | ||
31 | break; | ||
32 | } | ||
33 | |||
34 | /* set codec DAI configuration */ | ||
35 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | ||
36 | | SND_SOC_DAIFMT_NB_NF | ||
37 | | SND_SOC_DAIFMT_CBS_CFS); | ||
38 | if (ret < 0) | ||
39 | return ret; | ||
40 | |||
41 | /* CPU should be clock master */ | ||
42 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | ||
43 | | SND_SOC_DAIFMT_NB_NF | ||
44 | | SND_SOC_DAIFMT_CBS_CFS); | ||
45 | if (ret < 0) | ||
46 | return ret; | ||
47 | |||
48 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, clk, | ||
49 | SND_SOC_CLOCK_IN); | ||
50 | if (ret < 0) | ||
51 | return ret; | ||
52 | |||
53 | /* set the I2S system clock as input (unused) */ | ||
54 | ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, clk, | ||
55 | SND_SOC_CLOCK_OUT); | ||
56 | |||
57 | return ret; | ||
58 | } | ||
59 | |||
60 | static struct snd_soc_ops imote2_asoc_ops = { | ||
61 | .hw_params = imote2_asoc_hw_params, | ||
62 | }; | ||
63 | |||
64 | static struct snd_soc_dai_link imote2_dai = { | ||
65 | .name = "WM8940", | ||
66 | .stream_name = "WM8940", | ||
67 | .cpu_dai = &pxa_i2s_dai, | ||
68 | .codec_dai = &wm8940_dai, | ||
69 | .ops = &imote2_asoc_ops, | ||
70 | }; | ||
71 | |||
72 | static struct snd_soc_card snd_soc_imote2 = { | ||
73 | .name = "Imote2", | ||
74 | .platform = &pxa2xx_soc_platform, | ||
75 | .dai_link = &imote2_dai, | ||
76 | .num_links = 1, | ||
77 | }; | ||
78 | |||
79 | static struct snd_soc_device imote2_snd_devdata = { | ||
80 | .card = &snd_soc_imote2, | ||
81 | .codec_dev = &soc_codec_dev_wm8940, | ||
82 | }; | ||
83 | |||
84 | static struct platform_device *imote2_snd_device; | ||
85 | |||
86 | static int __init imote2_asoc_init(void) | ||
87 | { | ||
88 | int ret; | ||
89 | |||
90 | if (!machine_is_intelmote2()) | ||
91 | return -ENODEV; | ||
92 | imote2_snd_device = platform_device_alloc("soc-audio", -1); | ||
93 | if (!imote2_snd_device) | ||
94 | return -ENOMEM; | ||
95 | |||
96 | platform_set_drvdata(imote2_snd_device, &imote2_snd_devdata); | ||
97 | imote2_snd_devdata.dev = &imote2_snd_device->dev; | ||
98 | ret = platform_device_add(imote2_snd_device); | ||
99 | if (ret) | ||
100 | platform_device_put(imote2_snd_device); | ||
101 | |||
102 | return ret; | ||
103 | } | ||
104 | module_init(imote2_asoc_init); | ||
105 | |||
106 | static void __exit imote2_asoc_exit(void) | ||
107 | { | ||
108 | platform_device_unregister(imote2_snd_device); | ||
109 | } | ||
110 | module_exit(imote2_asoc_exit); | ||
111 | |||
112 | MODULE_AUTHOR("Jonathan Cameron"); | ||
113 | MODULE_DESCRIPTION("ALSA SoC Imote 2"); | ||
114 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/pxa/magician.c b/sound/soc/pxa/magician.c index 0625c342a1c9..326955dea36c 100644 --- a/sound/soc/pxa/magician.c +++ b/sound/soc/pxa/magician.c | |||
@@ -106,7 +106,7 @@ static int magician_playback_hw_params(struct snd_pcm_substream *substream, | |||
106 | /* 513156 Hz ~= _2_ * 8000 Hz * 32 (+0.23%) */ | 106 | /* 513156 Hz ~= _2_ * 8000 Hz * 32 (+0.23%) */ |
107 | acds = PXA_SSP_CLK_AUDIO_DIV_16; | 107 | acds = PXA_SSP_CLK_AUDIO_DIV_16; |
108 | break; | 108 | break; |
109 | case 32: | 109 | default: /* 32 */ |
110 | /* 1026312 Hz ~= _2_ * 8000 Hz * 64 (+0.23%) */ | 110 | /* 1026312 Hz ~= _2_ * 8000 Hz * 64 (+0.23%) */ |
111 | acds = PXA_SSP_CLK_AUDIO_DIV_8; | 111 | acds = PXA_SSP_CLK_AUDIO_DIV_8; |
112 | } | 112 | } |
@@ -118,7 +118,7 @@ static int magician_playback_hw_params(struct snd_pcm_substream *substream, | |||
118 | /* 351375 Hz ~= 11025 Hz * 32 (-0.41%) */ | 118 | /* 351375 Hz ~= 11025 Hz * 32 (-0.41%) */ |
119 | acds = PXA_SSP_CLK_AUDIO_DIV_4; | 119 | acds = PXA_SSP_CLK_AUDIO_DIV_4; |
120 | break; | 120 | break; |
121 | case 32: | 121 | default: /* 32 */ |
122 | /* 702750 Hz ~= 11025 Hz * 64 (-0.41%) */ | 122 | /* 702750 Hz ~= 11025 Hz * 64 (-0.41%) */ |
123 | acds = PXA_SSP_CLK_AUDIO_DIV_2; | 123 | acds = PXA_SSP_CLK_AUDIO_DIV_2; |
124 | } | 124 | } |
@@ -130,7 +130,7 @@ static int magician_playback_hw_params(struct snd_pcm_substream *substream, | |||
130 | /* 702750 Hz ~= 22050 Hz * 32 (-0.41%) */ | 130 | /* 702750 Hz ~= 22050 Hz * 32 (-0.41%) */ |
131 | acds = PXA_SSP_CLK_AUDIO_DIV_2; | 131 | acds = PXA_SSP_CLK_AUDIO_DIV_2; |
132 | break; | 132 | break; |
133 | case 32: | 133 | default: /* 32 */ |
134 | /* 1405500 Hz ~= 22050 Hz * 64 (-0.41%) */ | 134 | /* 1405500 Hz ~= 22050 Hz * 64 (-0.41%) */ |
135 | acds = PXA_SSP_CLK_AUDIO_DIV_1; | 135 | acds = PXA_SSP_CLK_AUDIO_DIV_1; |
136 | } | 136 | } |
@@ -142,7 +142,7 @@ static int magician_playback_hw_params(struct snd_pcm_substream *substream, | |||
142 | /* 1405500 Hz ~= 44100 Hz * 32 (-0.41%) */ | 142 | /* 1405500 Hz ~= 44100 Hz * 32 (-0.41%) */ |
143 | acds = PXA_SSP_CLK_AUDIO_DIV_2; | 143 | acds = PXA_SSP_CLK_AUDIO_DIV_2; |
144 | break; | 144 | break; |
145 | case 32: | 145 | default: /* 32 */ |
146 | /* 2811000 Hz ~= 44100 Hz * 64 (-0.41%) */ | 146 | /* 2811000 Hz ~= 44100 Hz * 64 (-0.41%) */ |
147 | acds = PXA_SSP_CLK_AUDIO_DIV_1; | 147 | acds = PXA_SSP_CLK_AUDIO_DIV_1; |
148 | } | 148 | } |
@@ -154,19 +154,20 @@ static int magician_playback_hw_params(struct snd_pcm_substream *substream, | |||
154 | /* 1529375 Hz ~= 48000 Hz * 32 (-0.44%) */ | 154 | /* 1529375 Hz ~= 48000 Hz * 32 (-0.44%) */ |
155 | acds = PXA_SSP_CLK_AUDIO_DIV_2; | 155 | acds = PXA_SSP_CLK_AUDIO_DIV_2; |
156 | break; | 156 | break; |
157 | case 32: | 157 | default: /* 32 */ |
158 | /* 3058750 Hz ~= 48000 Hz * 64 (-0.44%) */ | 158 | /* 3058750 Hz ~= 48000 Hz * 64 (-0.44%) */ |
159 | acds = PXA_SSP_CLK_AUDIO_DIV_1; | 159 | acds = PXA_SSP_CLK_AUDIO_DIV_1; |
160 | } | 160 | } |
161 | break; | 161 | break; |
162 | case 96000: | 162 | case 96000: |
163 | default: | ||
163 | acps = 12235000; | 164 | acps = 12235000; |
164 | switch (width) { | 165 | switch (width) { |
165 | case 16: | 166 | case 16: |
166 | /* 3058750 Hz ~= 96000 Hz * 32 (-0.44%) */ | 167 | /* 3058750 Hz ~= 96000 Hz * 32 (-0.44%) */ |
167 | acds = PXA_SSP_CLK_AUDIO_DIV_1; | 168 | acds = PXA_SSP_CLK_AUDIO_DIV_1; |
168 | break; | 169 | break; |
169 | case 32: | 170 | default: /* 32 */ |
170 | /* 6117500 Hz ~= 96000 Hz * 64 (-0.44%) */ | 171 | /* 6117500 Hz ~= 96000 Hz * 64 (-0.44%) */ |
171 | acds = PXA_SSP_CLK_AUDIO_DIV_2; | 172 | acds = PXA_SSP_CLK_AUDIO_DIV_2; |
172 | div4 = PXA_SSP_CLK_SCDB_1; | 173 | div4 = PXA_SSP_CLK_SCDB_1; |
@@ -183,7 +184,7 @@ static int magician_playback_hw_params(struct snd_pcm_substream *substream, | |||
183 | 184 | ||
184 | /* set cpu DAI configuration */ | 185 | /* set cpu DAI configuration */ |
185 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A | | 186 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A | |
186 | SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBS_CFS); | 187 | SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_CBS_CFS); |
187 | if (ret < 0) | 188 | if (ret < 0) |
188 | return ret; | 189 | return ret; |
189 | 190 | ||
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 286be31545df..19c45409d94c 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c | |||
@@ -50,139 +50,6 @@ struct ssp_priv { | |||
50 | #endif | 50 | #endif |
51 | }; | 51 | }; |
52 | 52 | ||
53 | #define PXA2xx_SSP1_BASE 0x41000000 | ||
54 | #define PXA27x_SSP2_BASE 0x41700000 | ||
55 | #define PXA27x_SSP3_BASE 0x41900000 | ||
56 | #define PXA3xx_SSP4_BASE 0x41a00000 | ||
57 | |||
58 | static struct pxa2xx_pcm_dma_params pxa_ssp1_pcm_mono_out = { | ||
59 | .name = "SSP1 PCM Mono out", | ||
60 | .dev_addr = PXA2xx_SSP1_BASE + SSDR, | ||
61 | .drcmr = &DRCMR(14), | ||
62 | .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | | ||
63 | DCMD_BURST16 | DCMD_WIDTH2, | ||
64 | }; | ||
65 | |||
66 | static struct pxa2xx_pcm_dma_params pxa_ssp1_pcm_mono_in = { | ||
67 | .name = "SSP1 PCM Mono in", | ||
68 | .dev_addr = PXA2xx_SSP1_BASE + SSDR, | ||
69 | .drcmr = &DRCMR(13), | ||
70 | .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | | ||
71 | DCMD_BURST16 | DCMD_WIDTH2, | ||
72 | }; | ||
73 | |||
74 | static struct pxa2xx_pcm_dma_params pxa_ssp1_pcm_stereo_out = { | ||
75 | .name = "SSP1 PCM Stereo out", | ||
76 | .dev_addr = PXA2xx_SSP1_BASE + SSDR, | ||
77 | .drcmr = &DRCMR(14), | ||
78 | .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | | ||
79 | DCMD_BURST16 | DCMD_WIDTH4, | ||
80 | }; | ||
81 | |||
82 | static struct pxa2xx_pcm_dma_params pxa_ssp1_pcm_stereo_in = { | ||
83 | .name = "SSP1 PCM Stereo in", | ||
84 | .dev_addr = PXA2xx_SSP1_BASE + SSDR, | ||
85 | .drcmr = &DRCMR(13), | ||
86 | .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | | ||
87 | DCMD_BURST16 | DCMD_WIDTH4, | ||
88 | }; | ||
89 | |||
90 | static struct pxa2xx_pcm_dma_params pxa_ssp2_pcm_mono_out = { | ||
91 | .name = "SSP2 PCM Mono out", | ||
92 | .dev_addr = PXA27x_SSP2_BASE + SSDR, | ||
93 | .drcmr = &DRCMR(16), | ||
94 | .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | | ||
95 | DCMD_BURST16 | DCMD_WIDTH2, | ||
96 | }; | ||
97 | |||
98 | static struct pxa2xx_pcm_dma_params pxa_ssp2_pcm_mono_in = { | ||
99 | .name = "SSP2 PCM Mono in", | ||
100 | .dev_addr = PXA27x_SSP2_BASE + SSDR, | ||
101 | .drcmr = &DRCMR(15), | ||
102 | .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | | ||
103 | DCMD_BURST16 | DCMD_WIDTH2, | ||
104 | }; | ||
105 | |||
106 | static struct pxa2xx_pcm_dma_params pxa_ssp2_pcm_stereo_out = { | ||
107 | .name = "SSP2 PCM Stereo out", | ||
108 | .dev_addr = PXA27x_SSP2_BASE + SSDR, | ||
109 | .drcmr = &DRCMR(16), | ||
110 | .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | | ||
111 | DCMD_BURST16 | DCMD_WIDTH4, | ||
112 | }; | ||
113 | |||
114 | static struct pxa2xx_pcm_dma_params pxa_ssp2_pcm_stereo_in = { | ||
115 | .name = "SSP2 PCM Stereo in", | ||
116 | .dev_addr = PXA27x_SSP2_BASE + SSDR, | ||
117 | .drcmr = &DRCMR(15), | ||
118 | .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | | ||
119 | DCMD_BURST16 | DCMD_WIDTH4, | ||
120 | }; | ||
121 | |||
122 | static struct pxa2xx_pcm_dma_params pxa_ssp3_pcm_mono_out = { | ||
123 | .name = "SSP3 PCM Mono out", | ||
124 | .dev_addr = PXA27x_SSP3_BASE + SSDR, | ||
125 | .drcmr = &DRCMR(67), | ||
126 | .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | | ||
127 | DCMD_BURST16 | DCMD_WIDTH2, | ||
128 | }; | ||
129 | |||
130 | static struct pxa2xx_pcm_dma_params pxa_ssp3_pcm_mono_in = { | ||
131 | .name = "SSP3 PCM Mono in", | ||
132 | .dev_addr = PXA27x_SSP3_BASE + SSDR, | ||
133 | .drcmr = &DRCMR(66), | ||
134 | .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | | ||
135 | DCMD_BURST16 | DCMD_WIDTH2, | ||
136 | }; | ||
137 | |||
138 | static struct pxa2xx_pcm_dma_params pxa_ssp3_pcm_stereo_out = { | ||
139 | .name = "SSP3 PCM Stereo out", | ||
140 | .dev_addr = PXA27x_SSP3_BASE + SSDR, | ||
141 | .drcmr = &DRCMR(67), | ||
142 | .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | | ||
143 | DCMD_BURST16 | DCMD_WIDTH4, | ||
144 | }; | ||
145 | |||
146 | static struct pxa2xx_pcm_dma_params pxa_ssp3_pcm_stereo_in = { | ||
147 | .name = "SSP3 PCM Stereo in", | ||
148 | .dev_addr = PXA27x_SSP3_BASE + SSDR, | ||
149 | .drcmr = &DRCMR(66), | ||
150 | .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | | ||
151 | DCMD_BURST16 | DCMD_WIDTH4, | ||
152 | }; | ||
153 | |||
154 | static struct pxa2xx_pcm_dma_params pxa_ssp4_pcm_mono_out = { | ||
155 | .name = "SSP4 PCM Mono out", | ||
156 | .dev_addr = PXA3xx_SSP4_BASE + SSDR, | ||
157 | .drcmr = &DRCMR(67), | ||
158 | .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | | ||
159 | DCMD_BURST16 | DCMD_WIDTH2, | ||
160 | }; | ||
161 | |||
162 | static struct pxa2xx_pcm_dma_params pxa_ssp4_pcm_mono_in = { | ||
163 | .name = "SSP4 PCM Mono in", | ||
164 | .dev_addr = PXA3xx_SSP4_BASE + SSDR, | ||
165 | .drcmr = &DRCMR(66), | ||
166 | .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | | ||
167 | DCMD_BURST16 | DCMD_WIDTH2, | ||
168 | }; | ||
169 | |||
170 | static struct pxa2xx_pcm_dma_params pxa_ssp4_pcm_stereo_out = { | ||
171 | .name = "SSP4 PCM Stereo out", | ||
172 | .dev_addr = PXA3xx_SSP4_BASE + SSDR, | ||
173 | .drcmr = &DRCMR(67), | ||
174 | .dcmd = DCMD_INCSRCADDR | DCMD_FLOWTRG | | ||
175 | DCMD_BURST16 | DCMD_WIDTH4, | ||
176 | }; | ||
177 | |||
178 | static struct pxa2xx_pcm_dma_params pxa_ssp4_pcm_stereo_in = { | ||
179 | .name = "SSP4 PCM Stereo in", | ||
180 | .dev_addr = PXA3xx_SSP4_BASE + SSDR, | ||
181 | .drcmr = &DRCMR(66), | ||
182 | .dcmd = DCMD_INCTRGADDR | DCMD_FLOWSRC | | ||
183 | DCMD_BURST16 | DCMD_WIDTH4, | ||
184 | }; | ||
185 | |||
186 | static void dump_registers(struct ssp_device *ssp) | 53 | static void dump_registers(struct ssp_device *ssp) |
187 | { | 54 | { |
188 | dev_dbg(&ssp->pdev->dev, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n", | 55 | dev_dbg(&ssp->pdev->dev, "SSCR0 0x%08x SSCR1 0x%08x SSTO 0x%08x\n", |
@@ -194,25 +61,33 @@ static void dump_registers(struct ssp_device *ssp) | |||
194 | ssp_read_reg(ssp, SSACD)); | 61 | ssp_read_reg(ssp, SSACD)); |
195 | } | 62 | } |
196 | 63 | ||
197 | static struct pxa2xx_pcm_dma_params *ssp_dma_params[4][4] = { | 64 | struct pxa2xx_pcm_dma_data { |
198 | { | 65 | struct pxa2xx_pcm_dma_params params; |
199 | &pxa_ssp1_pcm_mono_out, &pxa_ssp1_pcm_mono_in, | 66 | char name[20]; |
200 | &pxa_ssp1_pcm_stereo_out, &pxa_ssp1_pcm_stereo_in, | ||
201 | }, | ||
202 | { | ||
203 | &pxa_ssp2_pcm_mono_out, &pxa_ssp2_pcm_mono_in, | ||
204 | &pxa_ssp2_pcm_stereo_out, &pxa_ssp2_pcm_stereo_in, | ||
205 | }, | ||
206 | { | ||
207 | &pxa_ssp3_pcm_mono_out, &pxa_ssp3_pcm_mono_in, | ||
208 | &pxa_ssp3_pcm_stereo_out, &pxa_ssp3_pcm_stereo_in, | ||
209 | }, | ||
210 | { | ||
211 | &pxa_ssp4_pcm_mono_out, &pxa_ssp4_pcm_mono_in, | ||
212 | &pxa_ssp4_pcm_stereo_out, &pxa_ssp4_pcm_stereo_in, | ||
213 | }, | ||
214 | }; | 67 | }; |
215 | 68 | ||
69 | static struct pxa2xx_pcm_dma_params * | ||
70 | ssp_get_dma_params(struct ssp_device *ssp, int width4, int out) | ||
71 | { | ||
72 | struct pxa2xx_pcm_dma_data *dma; | ||
73 | |||
74 | dma = kzalloc(sizeof(struct pxa2xx_pcm_dma_data), GFP_KERNEL); | ||
75 | if (dma == NULL) | ||
76 | return NULL; | ||
77 | |||
78 | snprintf(dma->name, 20, "SSP%d PCM %s %s", ssp->port_id, | ||
79 | width4 ? "32-bit" : "16-bit", out ? "out" : "in"); | ||
80 | |||
81 | dma->params.name = dma->name; | ||
82 | dma->params.drcmr = &DRCMR(out ? ssp->drcmr_tx : ssp->drcmr_rx); | ||
83 | dma->params.dcmd = (out ? (DCMD_INCSRCADDR | DCMD_FLOWTRG) : | ||
84 | (DCMD_INCTRGADDR | DCMD_FLOWSRC)) | | ||
85 | (width4 ? DCMD_WIDTH4 : DCMD_WIDTH2) | DCMD_BURST16; | ||
86 | dma->params.dev_addr = ssp->phys_base + SSDR; | ||
87 | |||
88 | return &dma->params; | ||
89 | } | ||
90 | |||
216 | static int pxa_ssp_startup(struct snd_pcm_substream *substream, | 91 | static int pxa_ssp_startup(struct snd_pcm_substream *substream, |
217 | struct snd_soc_dai *dai) | 92 | struct snd_soc_dai *dai) |
218 | { | 93 | { |
@@ -227,6 +102,11 @@ static int pxa_ssp_startup(struct snd_pcm_substream *substream, | |||
227 | clk_enable(priv->dev.ssp->clk); | 102 | clk_enable(priv->dev.ssp->clk); |
228 | ssp_disable(&priv->dev); | 103 | ssp_disable(&priv->dev); |
229 | } | 104 | } |
105 | |||
106 | if (cpu_dai->dma_data) { | ||
107 | kfree(cpu_dai->dma_data); | ||
108 | cpu_dai->dma_data = NULL; | ||
109 | } | ||
230 | return ret; | 110 | return ret; |
231 | } | 111 | } |
232 | 112 | ||
@@ -241,6 +121,11 @@ static void pxa_ssp_shutdown(struct snd_pcm_substream *substream, | |||
241 | ssp_disable(&priv->dev); | 121 | ssp_disable(&priv->dev); |
242 | clk_disable(priv->dev.ssp->clk); | 122 | clk_disable(priv->dev.ssp->clk); |
243 | } | 123 | } |
124 | |||
125 | if (cpu_dai->dma_data) { | ||
126 | kfree(cpu_dai->dma_data); | ||
127 | cpu_dai->dma_data = NULL; | ||
128 | } | ||
244 | } | 129 | } |
245 | 130 | ||
246 | #ifdef CONFIG_PM | 131 | #ifdef CONFIG_PM |
@@ -323,7 +208,7 @@ static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | |||
323 | ~(SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS); | 208 | ~(SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS); |
324 | 209 | ||
325 | dev_dbg(&ssp->pdev->dev, | 210 | dev_dbg(&ssp->pdev->dev, |
326 | "pxa_ssp_set_dai_sysclk id: %d, clk_id %d, freq %d\n", | 211 | "pxa_ssp_set_dai_sysclk id: %d, clk_id %d, freq %u\n", |
327 | cpu_dai->id, clk_id, freq); | 212 | cpu_dai->id, clk_id, freq); |
328 | 213 | ||
329 | switch (clk_id) { | 214 | switch (clk_id) { |
@@ -472,7 +357,7 @@ static int pxa_ssp_set_dai_pll(struct snd_soc_dai *cpu_dai, | |||
472 | ssacd |= (0x6 << 4); | 357 | ssacd |= (0x6 << 4); |
473 | 358 | ||
474 | dev_dbg(&ssp->pdev->dev, | 359 | dev_dbg(&ssp->pdev->dev, |
475 | "Using SSACDD %x to supply %dHz\n", | 360 | "Using SSACDD %x to supply %uHz\n", |
476 | val, freq_out); | 361 | val, freq_out); |
477 | break; | 362 | break; |
478 | } | 363 | } |
@@ -589,7 +474,10 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
589 | case SND_SOC_DAIFMT_NB_IF: | 474 | case SND_SOC_DAIFMT_NB_IF: |
590 | break; | 475 | break; |
591 | case SND_SOC_DAIFMT_IB_IF: | 476 | case SND_SOC_DAIFMT_IB_IF: |
592 | sspsp |= SSPSP_SCMODE(3); | 477 | sspsp |= SSPSP_SCMODE(2); |
478 | break; | ||
479 | case SND_SOC_DAIFMT_IB_NF: | ||
480 | sspsp |= SSPSP_SCMODE(2) | SSPSP_SFRMP; | ||
593 | break; | 481 | break; |
594 | default: | 482 | default: |
595 | return -EINVAL; | 483 | return -EINVAL; |
@@ -606,7 +494,13 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, | |||
606 | case SND_SOC_DAIFMT_NB_NF: | 494 | case SND_SOC_DAIFMT_NB_NF: |
607 | sspsp |= SSPSP_SFRMP; | 495 | sspsp |= SSPSP_SFRMP; |
608 | break; | 496 | break; |
497 | case SND_SOC_DAIFMT_NB_IF: | ||
498 | break; | ||
609 | case SND_SOC_DAIFMT_IB_IF: | 499 | case SND_SOC_DAIFMT_IB_IF: |
500 | sspsp |= SSPSP_SCMODE(2); | ||
501 | break; | ||
502 | case SND_SOC_DAIFMT_IB_NF: | ||
503 | sspsp |= SSPSP_SCMODE(2) | SSPSP_SFRMP; | ||
610 | break; | 504 | break; |
611 | default: | 505 | default: |
612 | return -EINVAL; | 506 | return -EINVAL; |
@@ -644,25 +538,23 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream, | |||
644 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | 538 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; |
645 | struct ssp_priv *priv = cpu_dai->private_data; | 539 | struct ssp_priv *priv = cpu_dai->private_data; |
646 | struct ssp_device *ssp = priv->dev.ssp; | 540 | struct ssp_device *ssp = priv->dev.ssp; |
647 | int dma = 0, chn = params_channels(params); | 541 | int chn = params_channels(params); |
648 | u32 sscr0; | 542 | u32 sscr0; |
649 | u32 sspsp; | 543 | u32 sspsp; |
650 | int width = snd_pcm_format_physical_width(params_format(params)); | 544 | int width = snd_pcm_format_physical_width(params_format(params)); |
651 | int ttsa = ssp_read_reg(ssp, SSTSA) & 0xf; | 545 | int ttsa = ssp_read_reg(ssp, SSTSA) & 0xf; |
652 | 546 | ||
653 | /* select correct DMA params */ | 547 | /* generate correct DMA params */ |
654 | if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) | 548 | if (cpu_dai->dma_data) |
655 | dma = 1; /* capture DMA offset is 1,3 */ | 549 | kfree(cpu_dai->dma_data); |
550 | |||
656 | /* Network mode with one active slot (ttsa == 1) can be used | 551 | /* Network mode with one active slot (ttsa == 1) can be used |
657 | * to force 16-bit frame width on the wire (for S16_LE), even | 552 | * to force 16-bit frame width on the wire (for S16_LE), even |
658 | * with two channels. Use 16-bit DMA transfers for this case. | 553 | * with two channels. Use 16-bit DMA transfers for this case. |
659 | */ | 554 | */ |
660 | if (((chn == 2) && (ttsa != 1)) || (width == 32)) | 555 | cpu_dai->dma_data = ssp_get_dma_params(ssp, |
661 | dma += 2; /* 32-bit DMA offset is 2, 16-bit is 0 */ | 556 | ((chn == 2) && (ttsa != 1)) || (width == 32), |
662 | 557 | substream->stream == SNDRV_PCM_STREAM_PLAYBACK); | |
663 | cpu_dai->dma_data = ssp_dma_params[cpu_dai->id][dma]; | ||
664 | |||
665 | dev_dbg(&ssp->pdev->dev, "pxa_ssp_hw_params: dma %d\n", dma); | ||
666 | 558 | ||
667 | /* we can only change the settings if the port is not in use */ | 559 | /* we can only change the settings if the port is not in use */ |
668 | if (ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) | 560 | if (ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) |
diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c index 2f4b6e489b78..4743e262895d 100644 --- a/sound/soc/pxa/pxa2xx-i2s.c +++ b/sound/soc/pxa/pxa2xx-i2s.c | |||
@@ -106,10 +106,8 @@ static int pxa2xx_i2s_startup(struct snd_pcm_substream *substream, | |||
106 | if (IS_ERR(clk_i2s)) | 106 | if (IS_ERR(clk_i2s)) |
107 | return PTR_ERR(clk_i2s); | 107 | return PTR_ERR(clk_i2s); |
108 | 108 | ||
109 | if (!cpu_dai->active) { | 109 | if (!cpu_dai->active) |
110 | SACR0 |= SACR0_RST; | ||
111 | SACR0 = 0; | 110 | SACR0 = 0; |
112 | } | ||
113 | 111 | ||
114 | return 0; | 112 | return 0; |
115 | } | 113 | } |
@@ -178,9 +176,7 @@ static int pxa2xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
178 | 176 | ||
179 | /* is port used by another stream */ | 177 | /* is port used by another stream */ |
180 | if (!(SACR0 & SACR0_ENB)) { | 178 | if (!(SACR0 & SACR0_ENB)) { |
181 | |||
182 | SACR0 = 0; | 179 | SACR0 = 0; |
183 | SACR1 = 0; | ||
184 | if (pxa_i2s.master) | 180 | if (pxa_i2s.master) |
185 | SACR0 |= SACR0_BCKD; | 181 | SACR0 |= SACR0_BCKD; |
186 | 182 | ||
@@ -226,6 +222,10 @@ static int pxa2xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
226 | 222 | ||
227 | switch (cmd) { | 223 | switch (cmd) { |
228 | case SNDRV_PCM_TRIGGER_START: | 224 | case SNDRV_PCM_TRIGGER_START: |
225 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
226 | SACR1 &= ~SACR1_DRPL; | ||
227 | else | ||
228 | SACR1 &= ~SACR1_DREC; | ||
229 | SACR0 |= SACR0_ENB; | 229 | SACR0 |= SACR0_ENB; |
230 | break; | 230 | break; |
231 | case SNDRV_PCM_TRIGGER_RESUME: | 231 | case SNDRV_PCM_TRIGGER_RESUME: |
@@ -252,21 +252,16 @@ static void pxa2xx_i2s_shutdown(struct snd_pcm_substream *substream, | |||
252 | SAIMR &= ~SAIMR_RFS; | 252 | SAIMR &= ~SAIMR_RFS; |
253 | } | 253 | } |
254 | 254 | ||
255 | if (SACR1 & (SACR1_DREC | SACR1_DRPL)) { | 255 | if ((SACR1 & (SACR1_DREC | SACR1_DRPL)) == (SACR1_DREC | SACR1_DRPL)) { |
256 | SACR0 &= ~SACR0_ENB; | 256 | SACR0 &= ~SACR0_ENB; |
257 | pxa_i2s_wait(); | 257 | pxa_i2s_wait(); |
258 | clk_disable(clk_i2s); | 258 | clk_disable(clk_i2s); |
259 | } | 259 | } |
260 | |||
261 | clk_put(clk_i2s); | ||
262 | } | 260 | } |
263 | 261 | ||
264 | #ifdef CONFIG_PM | 262 | #ifdef CONFIG_PM |
265 | static int pxa2xx_i2s_suspend(struct snd_soc_dai *dai) | 263 | static int pxa2xx_i2s_suspend(struct snd_soc_dai *dai) |
266 | { | 264 | { |
267 | if (!dai->active) | ||
268 | return 0; | ||
269 | |||
270 | /* store registers */ | 265 | /* store registers */ |
271 | pxa_i2s.sacr0 = SACR0; | 266 | pxa_i2s.sacr0 = SACR0; |
272 | pxa_i2s.sacr1 = SACR1; | 267 | pxa_i2s.sacr1 = SACR1; |
@@ -281,16 +276,14 @@ static int pxa2xx_i2s_suspend(struct snd_soc_dai *dai) | |||
281 | 276 | ||
282 | static int pxa2xx_i2s_resume(struct snd_soc_dai *dai) | 277 | static int pxa2xx_i2s_resume(struct snd_soc_dai *dai) |
283 | { | 278 | { |
284 | if (!dai->active) | ||
285 | return 0; | ||
286 | |||
287 | pxa_i2s_wait(); | 279 | pxa_i2s_wait(); |
288 | 280 | ||
289 | SACR0 = pxa_i2s.sacr0 &= ~SACR0_ENB; | 281 | SACR0 = pxa_i2s.sacr0 & ~SACR0_ENB; |
290 | SACR1 = pxa_i2s.sacr1; | 282 | SACR1 = pxa_i2s.sacr1; |
291 | SAIMR = pxa_i2s.saimr; | 283 | SAIMR = pxa_i2s.saimr; |
292 | SADIV = pxa_i2s.sadiv; | 284 | SADIV = pxa_i2s.sadiv; |
293 | SACR0 |= SACR0_ENB; | 285 | |
286 | SACR0 = pxa_i2s.sacr0; | ||
294 | 287 | ||
295 | return 0; | 288 | return 0; |
296 | } | 289 | } |
@@ -329,6 +322,7 @@ struct snd_soc_dai pxa_i2s_dai = { | |||
329 | .rates = PXA2XX_I2S_RATES, | 322 | .rates = PXA2XX_I2S_RATES, |
330 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 323 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, |
331 | .ops = &pxa_i2s_dai_ops, | 324 | .ops = &pxa_i2s_dai_ops, |
325 | .symmetric_rates = 1, | ||
332 | }; | 326 | }; |
333 | 327 | ||
334 | EXPORT_SYMBOL_GPL(pxa_i2s_dai); | 328 | EXPORT_SYMBOL_GPL(pxa_i2s_dai); |
@@ -346,6 +340,19 @@ static int pxa2xx_i2s_probe(struct platform_device *dev) | |||
346 | if (ret != 0) | 340 | if (ret != 0) |
347 | clk_put(clk_i2s); | 341 | clk_put(clk_i2s); |
348 | 342 | ||
343 | /* | ||
344 | * PXA Developer's Manual: | ||
345 | * If SACR0[ENB] is toggled in the middle of a normal operation, | ||
346 | * the SACR0[RST] bit must also be set and cleared to reset all | ||
347 | * I2S controller registers. | ||
348 | */ | ||
349 | SACR0 = SACR0_RST; | ||
350 | SACR0 = 0; | ||
351 | /* Make sure RPL and REC are disabled */ | ||
352 | SACR1 = SACR1_DRPL | SACR1_DREC; | ||
353 | /* Along with FIFO servicing */ | ||
354 | SAIMR &= ~(SAIMR_RFS | SAIMR_TFS); | ||
355 | |||
349 | return ret; | 356 | return ret; |
350 | } | 357 | } |
351 | 358 | ||
diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 289fadf60b10..906709e6dd5f 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c | |||
@@ -345,9 +345,11 @@ static void lm4857_write_regs(void) | |||
345 | static int lm4857_get_reg(struct snd_kcontrol *kcontrol, | 345 | static int lm4857_get_reg(struct snd_kcontrol *kcontrol, |
346 | struct snd_ctl_elem_value *ucontrol) | 346 | struct snd_ctl_elem_value *ucontrol) |
347 | { | 347 | { |
348 | int reg = kcontrol->private_value & 0xFF; | 348 | struct soc_mixer_control *mc = |
349 | int shift = (kcontrol->private_value >> 8) & 0x0F; | 349 | (struct soc_mixer_control *)kcontrol->private_value; |
350 | int mask = (kcontrol->private_value >> 16) & 0xFF; | 350 | int reg = mc->reg; |
351 | int shift = mc->shift; | ||
352 | int mask = mc->max; | ||
351 | 353 | ||
352 | pr_debug("Entered %s\n", __func__); | 354 | pr_debug("Entered %s\n", __func__); |
353 | 355 | ||
@@ -358,9 +360,11 @@ static int lm4857_get_reg(struct snd_kcontrol *kcontrol, | |||
358 | static int lm4857_set_reg(struct snd_kcontrol *kcontrol, | 360 | static int lm4857_set_reg(struct snd_kcontrol *kcontrol, |
359 | struct snd_ctl_elem_value *ucontrol) | 361 | struct snd_ctl_elem_value *ucontrol) |
360 | { | 362 | { |
361 | int reg = kcontrol->private_value & 0xFF; | 363 | struct soc_mixer_control *mc = |
362 | int shift = (kcontrol->private_value >> 8) & 0x0F; | 364 | (struct soc_mixer_control *)kcontrol->private_value; |
363 | int mask = (kcontrol->private_value >> 16) & 0xFF; | 365 | int reg = mc->reg; |
366 | int shift = mc->shift; | ||
367 | int mask = mc->max; | ||
364 | 368 | ||
365 | if (((lm4857_regs[reg] >> shift) & mask) == | 369 | if (((lm4857_regs[reg] >> shift) & mask) == |
366 | ucontrol->value.integer.value[0]) | 370 | ucontrol->value.integer.value[0]) |
diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c index ab680aac3fcb..1a283170ca92 100644 --- a/sound/soc/s3c24xx/s3c-i2s-v2.c +++ b/sound/soc/s3c24xx/s3c-i2s-v2.c | |||
@@ -37,6 +37,20 @@ | |||
37 | 37 | ||
38 | #include "s3c-i2s-v2.h" | 38 | #include "s3c-i2s-v2.h" |
39 | 39 | ||
40 | #undef S3C_IIS_V2_SUPPORTED | ||
41 | |||
42 | #if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413) | ||
43 | #define S3C_IIS_V2_SUPPORTED | ||
44 | #endif | ||
45 | |||
46 | #ifdef CONFIG_PLAT_S3C64XX | ||
47 | #define S3C_IIS_V2_SUPPORTED | ||
48 | #endif | ||
49 | |||
50 | #ifndef S3C_IIS_V2_SUPPORTED | ||
51 | #error Unsupported CPU model | ||
52 | #endif | ||
53 | |||
40 | #define S3C2412_I2S_DEBUG_CON 0 | 54 | #define S3C2412_I2S_DEBUG_CON 0 |
41 | 55 | ||
42 | static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai) | 56 | static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai) |
@@ -75,7 +89,7 @@ static inline void dbg_showcon(const char *fn, u32 con) | |||
75 | 89 | ||
76 | 90 | ||
77 | /* Turn on or off the transmission path. */ | 91 | /* Turn on or off the transmission path. */ |
78 | void s3c2412_snd_txctrl(struct s3c_i2sv2_info *i2s, int on) | 92 | static void s3c2412_snd_txctrl(struct s3c_i2sv2_info *i2s, int on) |
79 | { | 93 | { |
80 | void __iomem *regs = i2s->regs; | 94 | void __iomem *regs = i2s->regs; |
81 | u32 fic, con, mod; | 95 | u32 fic, con, mod; |
@@ -105,7 +119,9 @@ void s3c2412_snd_txctrl(struct s3c_i2sv2_info *i2s, int on) | |||
105 | break; | 119 | break; |
106 | 120 | ||
107 | default: | 121 | default: |
108 | dev_err(i2s->dev, "TXEN: Invalid MODE in IISMOD\n"); | 122 | dev_err(i2s->dev, "TXEN: Invalid MODE %x in IISMOD\n", |
123 | mod & S3C2412_IISMOD_MODE_MASK); | ||
124 | break; | ||
109 | } | 125 | } |
110 | 126 | ||
111 | writel(con, regs + S3C2412_IISCON); | 127 | writel(con, regs + S3C2412_IISCON); |
@@ -132,7 +148,9 @@ void s3c2412_snd_txctrl(struct s3c_i2sv2_info *i2s, int on) | |||
132 | break; | 148 | break; |
133 | 149 | ||
134 | default: | 150 | default: |
135 | dev_err(i2s->dev, "TXDIS: Invalid MODE in IISMOD\n"); | 151 | dev_err(i2s->dev, "TXDIS: Invalid MODE %x in IISMOD\n", |
152 | mod & S3C2412_IISMOD_MODE_MASK); | ||
153 | break; | ||
136 | } | 154 | } |
137 | 155 | ||
138 | writel(mod, regs + S3C2412_IISMOD); | 156 | writel(mod, regs + S3C2412_IISMOD); |
@@ -143,9 +161,8 @@ void s3c2412_snd_txctrl(struct s3c_i2sv2_info *i2s, int on) | |||
143 | dbg_showcon(__func__, con); | 161 | dbg_showcon(__func__, con); |
144 | pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); | 162 | pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); |
145 | } | 163 | } |
146 | EXPORT_SYMBOL_GPL(s3c2412_snd_txctrl); | ||
147 | 164 | ||
148 | void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) | 165 | static void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) |
149 | { | 166 | { |
150 | void __iomem *regs = i2s->regs; | 167 | void __iomem *regs = i2s->regs; |
151 | u32 fic, con, mod; | 168 | u32 fic, con, mod; |
@@ -175,7 +192,8 @@ void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) | |||
175 | break; | 192 | break; |
176 | 193 | ||
177 | default: | 194 | default: |
178 | dev_err(i2s->dev, "RXEN: Invalid MODE in IISMOD\n"); | 195 | dev_err(i2s->dev, "RXEN: Invalid MODE %x in IISMOD\n", |
196 | mod & S3C2412_IISMOD_MODE_MASK); | ||
179 | } | 197 | } |
180 | 198 | ||
181 | writel(mod, regs + S3C2412_IISMOD); | 199 | writel(mod, regs + S3C2412_IISMOD); |
@@ -199,7 +217,8 @@ void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) | |||
199 | break; | 217 | break; |
200 | 218 | ||
201 | default: | 219 | default: |
202 | dev_err(i2s->dev, "RXEN: Invalid MODE in IISMOD\n"); | 220 | dev_err(i2s->dev, "RXDIS: Invalid MODE %x in IISMOD\n", |
221 | mod & S3C2412_IISMOD_MODE_MASK); | ||
203 | } | 222 | } |
204 | 223 | ||
205 | writel(con, regs + S3C2412_IISCON); | 224 | writel(con, regs + S3C2412_IISCON); |
@@ -209,7 +228,6 @@ void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) | |||
209 | fic = readl(regs + S3C2412_IISFIC); | 228 | fic = readl(regs + S3C2412_IISFIC); |
210 | pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); | 229 | pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); |
211 | } | 230 | } |
212 | EXPORT_SYMBOL_GPL(s3c2412_snd_rxctrl); | ||
213 | 231 | ||
214 | /* | 232 | /* |
215 | * Wait for the LR signal to allow synchronisation to the L/R clock | 233 | * Wait for the LR signal to allow synchronisation to the L/R clock |
@@ -266,7 +284,7 @@ static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai, | |||
266 | */ | 284 | */ |
267 | #define IISMOD_MASTER_MASK (1 << 11) | 285 | #define IISMOD_MASTER_MASK (1 << 11) |
268 | #define IISMOD_SLAVE (1 << 11) | 286 | #define IISMOD_SLAVE (1 << 11) |
269 | #define IISMOD_MASTER (0x0) | 287 | #define IISMOD_MASTER (0 << 11) |
270 | #endif | 288 | #endif |
271 | 289 | ||
272 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 290 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
@@ -281,7 +299,7 @@ static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai, | |||
281 | iismod |= IISMOD_MASTER; | 299 | iismod |= IISMOD_MASTER; |
282 | break; | 300 | break; |
283 | default: | 301 | default: |
284 | pr_debug("unknwon master/slave format\n"); | 302 | pr_err("unknwon master/slave format\n"); |
285 | return -EINVAL; | 303 | return -EINVAL; |
286 | } | 304 | } |
287 | 305 | ||
@@ -298,7 +316,7 @@ static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai, | |||
298 | iismod |= S3C2412_IISMOD_SDF_IIS; | 316 | iismod |= S3C2412_IISMOD_SDF_IIS; |
299 | break; | 317 | break; |
300 | default: | 318 | default: |
301 | pr_debug("Unknown data format\n"); | 319 | pr_err("Unknown data format\n"); |
302 | return -EINVAL; | 320 | return -EINVAL; |
303 | } | 321 | } |
304 | 322 | ||
@@ -327,6 +345,7 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream, | |||
327 | iismod = readl(i2s->regs + S3C2412_IISMOD); | 345 | iismod = readl(i2s->regs + S3C2412_IISMOD); |
328 | pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); | 346 | pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); |
329 | 347 | ||
348 | #if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413) | ||
330 | switch (params_format(params)) { | 349 | switch (params_format(params)) { |
331 | case SNDRV_PCM_FORMAT_S8: | 350 | case SNDRV_PCM_FORMAT_S8: |
332 | iismod |= S3C2412_IISMOD_8BIT; | 351 | iismod |= S3C2412_IISMOD_8BIT; |
@@ -335,6 +354,25 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream, | |||
335 | iismod &= ~S3C2412_IISMOD_8BIT; | 354 | iismod &= ~S3C2412_IISMOD_8BIT; |
336 | break; | 355 | break; |
337 | } | 356 | } |
357 | #endif | ||
358 | |||
359 | #ifdef CONFIG_PLAT_S3C64XX | ||
360 | iismod &= ~0x606; | ||
361 | /* Sample size */ | ||
362 | switch (params_format(params)) { | ||
363 | case SNDRV_PCM_FORMAT_S8: | ||
364 | /* 8 bit sample, 16fs BCLK */ | ||
365 | iismod |= 0x2004; | ||
366 | break; | ||
367 | case SNDRV_PCM_FORMAT_S16_LE: | ||
368 | /* 16 bit sample, 32fs BCLK */ | ||
369 | break; | ||
370 | case SNDRV_PCM_FORMAT_S24_LE: | ||
371 | /* 24 bit sample, 48fs BCLK */ | ||
372 | iismod |= 0x4002; | ||
373 | break; | ||
374 | } | ||
375 | #endif | ||
338 | 376 | ||
339 | writel(iismod, i2s->regs + S3C2412_IISMOD); | 377 | writel(iismod, i2s->regs + S3C2412_IISMOD); |
340 | pr_debug("%s: w: IISMOD: %x\n", __func__, iismod); | 378 | pr_debug("%s: w: IISMOD: %x\n", __func__, iismod); |
@@ -489,6 +527,8 @@ int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, | |||
489 | unsigned int best_rate = 0; | 527 | unsigned int best_rate = 0; |
490 | unsigned int best_deviation = INT_MAX; | 528 | unsigned int best_deviation = INT_MAX; |
491 | 529 | ||
530 | pr_debug("Input clock rate %ldHz\n", clkrate); | ||
531 | |||
492 | if (fstab == NULL) | 532 | if (fstab == NULL) |
493 | fstab = iis_fs_tab; | 533 | fstab = iis_fs_tab; |
494 | 534 | ||
@@ -507,7 +547,7 @@ int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, | |||
507 | actual = clkrate / (fsdiv * div); | 547 | actual = clkrate / (fsdiv * div); |
508 | deviation = actual - rate; | 548 | deviation = actual - rate; |
509 | 549 | ||
510 | printk(KERN_DEBUG "%dfs: div %d => result %d, deviation %d\n", | 550 | printk(KERN_DEBUG "%ufs: div %u => result %u, deviation %d\n", |
511 | fsdiv, div, actual, deviation); | 551 | fsdiv, div, actual, deviation); |
512 | 552 | ||
513 | deviation = abs(deviation); | 553 | deviation = abs(deviation); |
@@ -523,7 +563,7 @@ int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, | |||
523 | break; | 563 | break; |
524 | } | 564 | } |
525 | 565 | ||
526 | printk(KERN_DEBUG "best: fs=%d, div=%d, rate=%d\n", | 566 | printk(KERN_DEBUG "best: fs=%u, div=%u, rate=%u\n", |
527 | best_fs, best_div, best_rate); | 567 | best_fs, best_div, best_rate); |
528 | 568 | ||
529 | info->fs_div = best_fs; | 569 | info->fs_div = best_fs; |
@@ -539,12 +579,31 @@ int s3c_i2sv2_probe(struct platform_device *pdev, | |||
539 | unsigned long base) | 579 | unsigned long base) |
540 | { | 580 | { |
541 | struct device *dev = &pdev->dev; | 581 | struct device *dev = &pdev->dev; |
582 | unsigned int iismod; | ||
542 | 583 | ||
543 | i2s->dev = dev; | 584 | i2s->dev = dev; |
544 | 585 | ||
545 | /* record our i2s structure for later use in the callbacks */ | 586 | /* record our i2s structure for later use in the callbacks */ |
546 | dai->private_data = i2s; | 587 | dai->private_data = i2s; |
547 | 588 | ||
589 | if (!base) { | ||
590 | struct resource *res = platform_get_resource(pdev, | ||
591 | IORESOURCE_MEM, | ||
592 | 0); | ||
593 | if (!res) { | ||
594 | dev_err(dev, "Unable to get register resource\n"); | ||
595 | return -ENXIO; | ||
596 | } | ||
597 | |||
598 | if (!request_mem_region(res->start, resource_size(res), | ||
599 | "s3c64xx-i2s-v4")) { | ||
600 | dev_err(dev, "Unable to request register region\n"); | ||
601 | return -EBUSY; | ||
602 | } | ||
603 | |||
604 | base = res->start; | ||
605 | } | ||
606 | |||
548 | i2s->regs = ioremap(base, 0x100); | 607 | i2s->regs = ioremap(base, 0x100); |
549 | if (i2s->regs == NULL) { | 608 | if (i2s->regs == NULL) { |
550 | dev_err(dev, "cannot ioremap registers\n"); | 609 | dev_err(dev, "cannot ioremap registers\n"); |
@@ -560,12 +619,16 @@ int s3c_i2sv2_probe(struct platform_device *pdev, | |||
560 | 619 | ||
561 | clk_enable(i2s->iis_pclk); | 620 | clk_enable(i2s->iis_pclk); |
562 | 621 | ||
622 | /* Mark ourselves as in TXRX mode so we can run through our cleanup | ||
623 | * process without warnings. */ | ||
624 | iismod = readl(i2s->regs + S3C2412_IISMOD); | ||
625 | iismod |= S3C2412_IISMOD_MODE_TXRX; | ||
626 | writel(iismod, i2s->regs + S3C2412_IISMOD); | ||
563 | s3c2412_snd_txctrl(i2s, 0); | 627 | s3c2412_snd_txctrl(i2s, 0); |
564 | s3c2412_snd_rxctrl(i2s, 0); | 628 | s3c2412_snd_rxctrl(i2s, 0); |
565 | 629 | ||
566 | return 0; | 630 | return 0; |
567 | } | 631 | } |
568 | |||
569 | EXPORT_SYMBOL_GPL(s3c_i2sv2_probe); | 632 | EXPORT_SYMBOL_GPL(s3c_i2sv2_probe); |
570 | 633 | ||
571 | #ifdef CONFIG_PM | 634 | #ifdef CONFIG_PM |
diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c index b7e0b3f0bfc8..168a088ba761 100644 --- a/sound/soc/s3c24xx/s3c2412-i2s.c +++ b/sound/soc/s3c24xx/s3c2412-i2s.c | |||
@@ -120,7 +120,7 @@ static int s3c2412_i2s_probe(struct platform_device *pdev, | |||
120 | 120 | ||
121 | s3c2412_i2s.iis_cclk = clk_get(&pdev->dev, "i2sclk"); | 121 | s3c2412_i2s.iis_cclk = clk_get(&pdev->dev, "i2sclk"); |
122 | if (s3c2412_i2s.iis_cclk == NULL) { | 122 | if (s3c2412_i2s.iis_cclk == NULL) { |
123 | pr_debug("failed to get i2sclk clock\n"); | 123 | pr_err("failed to get i2sclk clock\n"); |
124 | iounmap(s3c2412_i2s.regs); | 124 | iounmap(s3c2412_i2s.regs); |
125 | return -ENODEV; | 125 | return -ENODEV; |
126 | } | 126 | } |
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.c b/sound/soc/s3c24xx/s3c64xx-i2s.c index 33c5de7e255f..3c06c401d0fb 100644 --- a/sound/soc/s3c24xx/s3c64xx-i2s.c +++ b/sound/soc/s3c24xx/s3c64xx-i2s.c | |||
@@ -108,48 +108,19 @@ static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, | |||
108 | return 0; | 108 | return 0; |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | struct clk *s3c64xx_i2s_get_clock(struct snd_soc_dai *dai) | |
112 | unsigned long s3c64xx_i2s_get_clockrate(struct snd_soc_dai *dai) | ||
113 | { | 112 | { |
114 | struct s3c_i2sv2_info *i2s = to_info(dai); | 113 | struct s3c_i2sv2_info *i2s = to_info(dai); |
115 | 114 | ||
116 | return clk_get_rate(i2s->iis_cclk); | 115 | return i2s->iis_cclk; |
117 | } | 116 | } |
118 | EXPORT_SYMBOL_GPL(s3c64xx_i2s_get_clockrate); | 117 | EXPORT_SYMBOL_GPL(s3c64xx_i2s_get_clock); |
119 | 118 | ||
120 | static int s3c64xx_i2s_probe(struct platform_device *pdev, | 119 | static int s3c64xx_i2s_probe(struct platform_device *pdev, |
121 | struct snd_soc_dai *dai) | 120 | struct snd_soc_dai *dai) |
122 | { | 121 | { |
123 | struct device *dev = &pdev->dev; | ||
124 | struct s3c_i2sv2_info *i2s; | ||
125 | int ret; | ||
126 | |||
127 | dev_dbg(dev, "%s: probing dai %d\n", __func__, pdev->id); | ||
128 | |||
129 | if (pdev->id < 0 || pdev->id > ARRAY_SIZE(s3c64xx_i2s)) { | ||
130 | dev_err(dev, "id %d out of range\n", pdev->id); | ||
131 | return -EINVAL; | ||
132 | } | ||
133 | |||
134 | i2s = &s3c64xx_i2s[pdev->id]; | ||
135 | |||
136 | ret = s3c_i2sv2_probe(pdev, dai, i2s, | ||
137 | pdev->id ? S3C64XX_PA_IIS1 : S3C64XX_PA_IIS0); | ||
138 | if (ret) | ||
139 | return ret; | ||
140 | |||
141 | i2s->dma_capture = &s3c64xx_i2s_pcm_stereo_in[pdev->id]; | ||
142 | i2s->dma_playback = &s3c64xx_i2s_pcm_stereo_out[pdev->id]; | ||
143 | |||
144 | i2s->iis_cclk = clk_get(dev, "audio-bus"); | ||
145 | if (IS_ERR(i2s->iis_cclk)) { | ||
146 | dev_err(dev, "failed to get audio-bus"); | ||
147 | iounmap(i2s->regs); | ||
148 | return -ENODEV; | ||
149 | } | ||
150 | |||
151 | /* configure GPIO for i2s port */ | 122 | /* configure GPIO for i2s port */ |
152 | switch (pdev->id) { | 123 | switch (dai->id) { |
153 | case 0: | 124 | case 0: |
154 | s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_I2S0_CLK); | 125 | s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_I2S0_CLK); |
155 | s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_I2S0_CDCLK); | 126 | s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_I2S0_CDCLK); |
@@ -175,41 +146,122 @@ static int s3c64xx_i2s_probe(struct platform_device *pdev, | |||
175 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) | 146 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) |
176 | 147 | ||
177 | #define S3C64XX_I2S_FMTS \ | 148 | #define S3C64XX_I2S_FMTS \ |
178 | (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE) | 149 | (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |\ |
150 | SNDRV_PCM_FMTBIT_S24_LE) | ||
179 | 151 | ||
180 | static struct snd_soc_dai_ops s3c64xx_i2s_dai_ops = { | 152 | static struct snd_soc_dai_ops s3c64xx_i2s_dai_ops = { |
181 | .set_sysclk = s3c64xx_i2s_set_sysclk, | 153 | .set_sysclk = s3c64xx_i2s_set_sysclk, |
182 | }; | 154 | }; |
183 | 155 | ||
184 | struct snd_soc_dai s3c64xx_i2s_dai = { | 156 | struct snd_soc_dai s3c64xx_i2s_dai[] = { |
185 | .name = "s3c64xx-i2s", | 157 | { |
186 | .id = 0, | 158 | .name = "s3c64xx-i2s", |
187 | .probe = s3c64xx_i2s_probe, | 159 | .id = 0, |
188 | .playback = { | 160 | .probe = s3c64xx_i2s_probe, |
189 | .channels_min = 2, | 161 | .playback = { |
190 | .channels_max = 2, | 162 | .channels_min = 2, |
191 | .rates = S3C64XX_I2S_RATES, | 163 | .channels_max = 2, |
192 | .formats = S3C64XX_I2S_FMTS, | 164 | .rates = S3C64XX_I2S_RATES, |
165 | .formats = S3C64XX_I2S_FMTS, | ||
166 | }, | ||
167 | .capture = { | ||
168 | .channels_min = 2, | ||
169 | .channels_max = 2, | ||
170 | .rates = S3C64XX_I2S_RATES, | ||
171 | .formats = S3C64XX_I2S_FMTS, | ||
172 | }, | ||
173 | .ops = &s3c64xx_i2s_dai_ops, | ||
174 | .symmetric_rates = 1, | ||
193 | }, | 175 | }, |
194 | .capture = { | 176 | { |
195 | .channels_min = 2, | 177 | .name = "s3c64xx-i2s", |
196 | .channels_max = 2, | 178 | .id = 1, |
197 | .rates = S3C64XX_I2S_RATES, | 179 | .probe = s3c64xx_i2s_probe, |
198 | .formats = S3C64XX_I2S_FMTS, | 180 | .playback = { |
181 | .channels_min = 2, | ||
182 | .channels_max = 2, | ||
183 | .rates = S3C64XX_I2S_RATES, | ||
184 | .formats = S3C64XX_I2S_FMTS, | ||
185 | }, | ||
186 | .capture = { | ||
187 | .channels_min = 2, | ||
188 | .channels_max = 2, | ||
189 | .rates = S3C64XX_I2S_RATES, | ||
190 | .formats = S3C64XX_I2S_FMTS, | ||
191 | }, | ||
192 | .ops = &s3c64xx_i2s_dai_ops, | ||
193 | .symmetric_rates = 1, | ||
199 | }, | 194 | }, |
200 | .ops = &s3c64xx_i2s_dai_ops, | ||
201 | }; | 195 | }; |
202 | EXPORT_SYMBOL_GPL(s3c64xx_i2s_dai); | 196 | EXPORT_SYMBOL_GPL(s3c64xx_i2s_dai); |
203 | 197 | ||
198 | static __devinit int s3c64xx_iis_dev_probe(struct platform_device *pdev) | ||
199 | { | ||
200 | struct s3c_i2sv2_info *i2s; | ||
201 | struct snd_soc_dai *dai; | ||
202 | int ret; | ||
203 | |||
204 | if (pdev->id >= ARRAY_SIZE(s3c64xx_i2s)) { | ||
205 | dev_err(&pdev->dev, "id %d out of range\n", pdev->id); | ||
206 | return -EINVAL; | ||
207 | } | ||
208 | |||
209 | i2s = &s3c64xx_i2s[pdev->id]; | ||
210 | dai = &s3c64xx_i2s_dai[pdev->id]; | ||
211 | dai->dev = &pdev->dev; | ||
212 | |||
213 | i2s->dma_capture = &s3c64xx_i2s_pcm_stereo_in[pdev->id]; | ||
214 | i2s->dma_playback = &s3c64xx_i2s_pcm_stereo_out[pdev->id]; | ||
215 | |||
216 | i2s->iis_cclk = clk_get(&pdev->dev, "audio-bus"); | ||
217 | if (IS_ERR(i2s->iis_cclk)) { | ||
218 | dev_err(&pdev->dev, "failed to get audio-bus\n"); | ||
219 | ret = PTR_ERR(i2s->iis_cclk); | ||
220 | goto err; | ||
221 | } | ||
222 | |||
223 | ret = s3c_i2sv2_probe(pdev, dai, i2s, 0); | ||
224 | if (ret) | ||
225 | goto err_clk; | ||
226 | |||
227 | ret = s3c_i2sv2_register_dai(dai); | ||
228 | if (ret != 0) | ||
229 | goto err_i2sv2; | ||
230 | |||
231 | return 0; | ||
232 | |||
233 | err_i2sv2: | ||
234 | /* Not implemented for I2Sv2 core yet */ | ||
235 | err_clk: | ||
236 | clk_put(i2s->iis_cclk); | ||
237 | err: | ||
238 | return ret; | ||
239 | } | ||
240 | |||
241 | static __devexit int s3c64xx_iis_dev_remove(struct platform_device *pdev) | ||
242 | { | ||
243 | dev_err(&pdev->dev, "Device removal not yet supported\n"); | ||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | static struct platform_driver s3c64xx_iis_driver = { | ||
248 | .probe = s3c64xx_iis_dev_probe, | ||
249 | .remove = s3c64xx_iis_dev_remove, | ||
250 | .driver = { | ||
251 | .name = "s3c64xx-iis", | ||
252 | .owner = THIS_MODULE, | ||
253 | }, | ||
254 | }; | ||
255 | |||
204 | static int __init s3c64xx_i2s_init(void) | 256 | static int __init s3c64xx_i2s_init(void) |
205 | { | 257 | { |
206 | return s3c_i2sv2_register_dai(&s3c64xx_i2s_dai); | 258 | return platform_driver_register(&s3c64xx_iis_driver); |
207 | } | 259 | } |
208 | module_init(s3c64xx_i2s_init); | 260 | module_init(s3c64xx_i2s_init); |
209 | 261 | ||
210 | static void __exit s3c64xx_i2s_exit(void) | 262 | static void __exit s3c64xx_i2s_exit(void) |
211 | { | 263 | { |
212 | snd_soc_unregister_dai(&s3c64xx_i2s_dai); | 264 | platform_driver_unregister(&s3c64xx_iis_driver); |
213 | } | 265 | } |
214 | module_exit(s3c64xx_i2s_exit); | 266 | module_exit(s3c64xx_i2s_exit); |
215 | 267 | ||
@@ -217,6 +269,3 @@ module_exit(s3c64xx_i2s_exit); | |||
217 | MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); | 269 | MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); |
218 | MODULE_DESCRIPTION("S3C64XX I2S SoC Interface"); | 270 | MODULE_DESCRIPTION("S3C64XX I2S SoC Interface"); |
219 | MODULE_LICENSE("GPL"); | 271 | MODULE_LICENSE("GPL"); |
220 | |||
221 | |||
222 | |||
diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.h b/sound/soc/s3c24xx/s3c64xx-i2s.h index b7ffe3c38b66..02148cee2613 100644 --- a/sound/soc/s3c24xx/s3c64xx-i2s.h +++ b/sound/soc/s3c24xx/s3c64xx-i2s.h | |||
@@ -15,6 +15,8 @@ | |||
15 | #ifndef __SND_SOC_S3C24XX_S3C64XX_I2S_H | 15 | #ifndef __SND_SOC_S3C24XX_S3C64XX_I2S_H |
16 | #define __SND_SOC_S3C24XX_S3C64XX_I2S_H __FILE__ | 16 | #define __SND_SOC_S3C24XX_S3C64XX_I2S_H __FILE__ |
17 | 17 | ||
18 | struct clk; | ||
19 | |||
18 | #include "s3c-i2s-v2.h" | 20 | #include "s3c-i2s-v2.h" |
19 | 21 | ||
20 | #define S3C64XX_DIV_BCLK S3C_I2SV2_DIV_BCLK | 22 | #define S3C64XX_DIV_BCLK S3C_I2SV2_DIV_BCLK |
@@ -24,8 +26,8 @@ | |||
24 | #define S3C64XX_CLKSRC_PCLK (0) | 26 | #define S3C64XX_CLKSRC_PCLK (0) |
25 | #define S3C64XX_CLKSRC_MUX (1) | 27 | #define S3C64XX_CLKSRC_MUX (1) |
26 | 28 | ||
27 | extern struct snd_soc_dai s3c64xx_i2s_dai; | 29 | extern struct snd_soc_dai s3c64xx_i2s_dai[]; |
28 | 30 | ||
29 | extern unsigned long s3c64xx_i2s_get_clockrate(struct snd_soc_dai *cpu_dai); | 31 | extern struct clk *s3c64xx_i2s_get_clock(struct snd_soc_dai *dai); |
30 | 32 | ||
31 | #endif /* __SND_SOC_S3C24XX_S3C64XX_I2S_H */ | 33 | #endif /* __SND_SOC_S3C24XX_S3C64XX_I2S_H */ |
diff --git a/sound/soc/s6000/Kconfig b/sound/soc/s6000/Kconfig new file mode 100644 index 000000000000..c74eb3d4a47c --- /dev/null +++ b/sound/soc/s6000/Kconfig | |||
@@ -0,0 +1,19 @@ | |||
1 | config SND_S6000_SOC | ||
2 | tristate "SoC Audio for the Stretch s6000 family" | ||
3 | depends on XTENSA_VARIANT_S6000 | ||
4 | help | ||
5 | Say Y or M if you want to add support for codecs attached to | ||
6 | s6000 family chips. You will also need to select the platform | ||
7 | to support below. | ||
8 | |||
9 | config SND_S6000_SOC_I2S | ||
10 | tristate | ||
11 | |||
12 | config SND_S6000_SOC_S6IPCAM | ||
13 | tristate "SoC Audio support for Stretch 6105 IP Camera" | ||
14 | depends on SND_S6000_SOC && XTENSA_PLATFORM_S6105 | ||
15 | select SND_S6000_SOC_I2S | ||
16 | select SND_SOC_TLV320AIC3X | ||
17 | help | ||
18 | Say Y if you want to add support for SoC audio on the | ||
19 | Stretch s6105 IP Camera Reference Design. | ||
diff --git a/sound/soc/s6000/Makefile b/sound/soc/s6000/Makefile new file mode 100644 index 000000000000..7a613612e010 --- /dev/null +++ b/sound/soc/s6000/Makefile | |||
@@ -0,0 +1,11 @@ | |||
1 | # s6000 Platform Support | ||
2 | snd-soc-s6000-objs := s6000-pcm.o | ||
3 | snd-soc-s6000-i2s-objs := s6000-i2s.o | ||
4 | |||
5 | obj-$(CONFIG_SND_S6000_SOC) += snd-soc-s6000.o | ||
6 | obj-$(CONFIG_SND_S6000_SOC_I2S) += snd-soc-s6000-i2s.o | ||
7 | |||
8 | # s6105 Machine Support | ||
9 | snd-soc-s6ipcam-objs := s6105-ipcam.o | ||
10 | |||
11 | obj-$(CONFIG_SND_S6000_SOC_S6IPCAM) += snd-soc-s6ipcam.o | ||
diff --git a/sound/soc/s6000/s6000-i2s.c b/sound/soc/s6000/s6000-i2s.c new file mode 100644 index 000000000000..c5cda187ecab --- /dev/null +++ b/sound/soc/s6000/s6000-i2s.c | |||
@@ -0,0 +1,629 @@ | |||
1 | /* | ||
2 | * ALSA SoC I2S Audio Layer for the Stretch S6000 family | ||
3 | * | ||
4 | * Author: Daniel Gloeckner, <dg@emlix.com> | ||
5 | * Copyright: (C) 2009 emlix GmbH <info@emlix.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/init.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/device.h> | ||
15 | #include <linux/delay.h> | ||
16 | #include <linux/clk.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/io.h> | ||
19 | |||
20 | #include <sound/core.h> | ||
21 | #include <sound/pcm.h> | ||
22 | #include <sound/pcm_params.h> | ||
23 | #include <sound/initval.h> | ||
24 | #include <sound/soc.h> | ||
25 | |||
26 | #include "s6000-i2s.h" | ||
27 | #include "s6000-pcm.h" | ||
28 | |||
29 | struct s6000_i2s_dev { | ||
30 | dma_addr_t sifbase; | ||
31 | u8 __iomem *scbbase; | ||
32 | unsigned int wide; | ||
33 | unsigned int channel_in; | ||
34 | unsigned int channel_out; | ||
35 | unsigned int lines_in; | ||
36 | unsigned int lines_out; | ||
37 | struct s6000_pcm_dma_params dma_params; | ||
38 | }; | ||
39 | |||
40 | #define S6_I2S_INTERRUPT_STATUS 0x00 | ||
41 | #define S6_I2S_INT_OVERRUN 1 | ||
42 | #define S6_I2S_INT_UNDERRUN 2 | ||
43 | #define S6_I2S_INT_ALIGNMENT 4 | ||
44 | #define S6_I2S_INTERRUPT_ENABLE 0x04 | ||
45 | #define S6_I2S_INTERRUPT_RAW 0x08 | ||
46 | #define S6_I2S_INTERRUPT_CLEAR 0x0C | ||
47 | #define S6_I2S_INTERRUPT_SET 0x10 | ||
48 | #define S6_I2S_MODE 0x20 | ||
49 | #define S6_I2S_DUAL 0 | ||
50 | #define S6_I2S_WIDE 1 | ||
51 | #define S6_I2S_TX_DEFAULT 0x24 | ||
52 | #define S6_I2S_DATA_CFG(c) (0x40 + 0x10 * (c)) | ||
53 | #define S6_I2S_IN 0 | ||
54 | #define S6_I2S_OUT 1 | ||
55 | #define S6_I2S_UNUSED 2 | ||
56 | #define S6_I2S_INTERFACE_CFG(c) (0x44 + 0x10 * (c)) | ||
57 | #define S6_I2S_DIV_MASK 0x001fff | ||
58 | #define S6_I2S_16BIT 0x000000 | ||
59 | #define S6_I2S_20BIT 0x002000 | ||
60 | #define S6_I2S_24BIT 0x004000 | ||
61 | #define S6_I2S_32BIT 0x006000 | ||
62 | #define S6_I2S_BITS_MASK 0x006000 | ||
63 | #define S6_I2S_MEM_16BIT 0x000000 | ||
64 | #define S6_I2S_MEM_32BIT 0x008000 | ||
65 | #define S6_I2S_MEM_MASK 0x008000 | ||
66 | #define S6_I2S_CHANNELS_SHIFT 16 | ||
67 | #define S6_I2S_CHANNELS_MASK 0x030000 | ||
68 | #define S6_I2S_SCK_IN 0x000000 | ||
69 | #define S6_I2S_SCK_OUT 0x040000 | ||
70 | #define S6_I2S_SCK_DIR 0x040000 | ||
71 | #define S6_I2S_WS_IN 0x000000 | ||
72 | #define S6_I2S_WS_OUT 0x080000 | ||
73 | #define S6_I2S_WS_DIR 0x080000 | ||
74 | #define S6_I2S_LEFT_FIRST 0x000000 | ||
75 | #define S6_I2S_RIGHT_FIRST 0x100000 | ||
76 | #define S6_I2S_FIRST 0x100000 | ||
77 | #define S6_I2S_CUR_SCK 0x200000 | ||
78 | #define S6_I2S_CUR_WS 0x400000 | ||
79 | #define S6_I2S_ENABLE(c) (0x48 + 0x10 * (c)) | ||
80 | #define S6_I2S_DISABLE_IF 0x02 | ||
81 | #define S6_I2S_ENABLE_IF 0x03 | ||
82 | #define S6_I2S_IS_BUSY 0x04 | ||
83 | #define S6_I2S_DMA_ACTIVE 0x08 | ||
84 | #define S6_I2S_IS_ENABLED 0x10 | ||
85 | |||
86 | #define S6_I2S_NUM_LINES 4 | ||
87 | |||
88 | #define S6_I2S_SIF_PORT0 0x0000000 | ||
89 | #define S6_I2S_SIF_PORT1 0x0000080 /* docs say 0x0000010 */ | ||
90 | |||
91 | static inline void s6_i2s_write_reg(struct s6000_i2s_dev *dev, int reg, u32 val) | ||
92 | { | ||
93 | writel(val, dev->scbbase + reg); | ||
94 | } | ||
95 | |||
96 | static inline u32 s6_i2s_read_reg(struct s6000_i2s_dev *dev, int reg) | ||
97 | { | ||
98 | return readl(dev->scbbase + reg); | ||
99 | } | ||
100 | |||
101 | static inline void s6_i2s_mod_reg(struct s6000_i2s_dev *dev, int reg, | ||
102 | u32 mask, u32 val) | ||
103 | { | ||
104 | val ^= s6_i2s_read_reg(dev, reg) & ~mask; | ||
105 | s6_i2s_write_reg(dev, reg, val); | ||
106 | } | ||
107 | |||
108 | static void s6000_i2s_start_channel(struct s6000_i2s_dev *dev, int channel) | ||
109 | { | ||
110 | int i, j, cur, prev; | ||
111 | |||
112 | /* | ||
113 | * Wait for WCLK to toggle 5 times before enabling the channel | ||
114 | * s6000 Family Datasheet 3.6.4: | ||
115 | * "At least two cycles of WS must occur between commands | ||
116 | * to disable or enable the interface" | ||
117 | */ | ||
118 | j = 0; | ||
119 | prev = ~S6_I2S_CUR_WS; | ||
120 | for (i = 1000000; --i && j < 6; ) { | ||
121 | cur = s6_i2s_read_reg(dev, S6_I2S_INTERFACE_CFG(channel)) | ||
122 | & S6_I2S_CUR_WS; | ||
123 | if (prev != cur) { | ||
124 | prev = cur; | ||
125 | j++; | ||
126 | } | ||
127 | } | ||
128 | if (j < 6) | ||
129 | printk(KERN_WARNING "s6000-i2s: timeout waiting for WCLK\n"); | ||
130 | |||
131 | s6_i2s_write_reg(dev, S6_I2S_ENABLE(channel), S6_I2S_ENABLE_IF); | ||
132 | } | ||
133 | |||
134 | static void s6000_i2s_stop_channel(struct s6000_i2s_dev *dev, int channel) | ||
135 | { | ||
136 | s6_i2s_write_reg(dev, S6_I2S_ENABLE(channel), S6_I2S_DISABLE_IF); | ||
137 | } | ||
138 | |||
139 | static void s6000_i2s_start(struct snd_pcm_substream *substream) | ||
140 | { | ||
141 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
142 | struct s6000_i2s_dev *dev = rtd->dai->cpu_dai->private_data; | ||
143 | int channel; | ||
144 | |||
145 | channel = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? | ||
146 | dev->channel_out : dev->channel_in; | ||
147 | |||
148 | s6000_i2s_start_channel(dev, channel); | ||
149 | } | ||
150 | |||
151 | static void s6000_i2s_stop(struct snd_pcm_substream *substream) | ||
152 | { | ||
153 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
154 | struct s6000_i2s_dev *dev = rtd->dai->cpu_dai->private_data; | ||
155 | int channel; | ||
156 | |||
157 | channel = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? | ||
158 | dev->channel_out : dev->channel_in; | ||
159 | |||
160 | s6000_i2s_stop_channel(dev, channel); | ||
161 | } | ||
162 | |||
163 | static int s6000_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | ||
164 | int after) | ||
165 | { | ||
166 | switch (cmd) { | ||
167 | case SNDRV_PCM_TRIGGER_START: | ||
168 | case SNDRV_PCM_TRIGGER_RESUME: | ||
169 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
170 | if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) ^ !after) | ||
171 | s6000_i2s_start(substream); | ||
172 | break; | ||
173 | case SNDRV_PCM_TRIGGER_STOP: | ||
174 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
175 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
176 | if (!after) | ||
177 | s6000_i2s_stop(substream); | ||
178 | } | ||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | static unsigned int s6000_i2s_int_sources(struct s6000_i2s_dev *dev) | ||
183 | { | ||
184 | unsigned int pending; | ||
185 | pending = s6_i2s_read_reg(dev, S6_I2S_INTERRUPT_RAW); | ||
186 | pending &= S6_I2S_INT_ALIGNMENT | | ||
187 | S6_I2S_INT_UNDERRUN | | ||
188 | S6_I2S_INT_OVERRUN; | ||
189 | s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_CLEAR, pending); | ||
190 | |||
191 | return pending; | ||
192 | } | ||
193 | |||
194 | static unsigned int s6000_i2s_check_xrun(struct snd_soc_dai *cpu_dai) | ||
195 | { | ||
196 | struct s6000_i2s_dev *dev = cpu_dai->private_data; | ||
197 | unsigned int errors; | ||
198 | unsigned int ret; | ||
199 | |||
200 | errors = s6000_i2s_int_sources(dev); | ||
201 | if (likely(!errors)) | ||
202 | return 0; | ||
203 | |||
204 | ret = 0; | ||
205 | if (errors & S6_I2S_INT_ALIGNMENT) | ||
206 | printk(KERN_ERR "s6000-i2s: WCLK misaligned\n"); | ||
207 | if (errors & S6_I2S_INT_UNDERRUN) | ||
208 | ret |= 1 << SNDRV_PCM_STREAM_PLAYBACK; | ||
209 | if (errors & S6_I2S_INT_OVERRUN) | ||
210 | ret |= 1 << SNDRV_PCM_STREAM_CAPTURE; | ||
211 | return ret; | ||
212 | } | ||
213 | |||
214 | static void s6000_i2s_wait_disabled(struct s6000_i2s_dev *dev) | ||
215 | { | ||
216 | int channel; | ||
217 | int n = 50; | ||
218 | for (channel = 0; channel < 2; channel++) { | ||
219 | while (--n >= 0) { | ||
220 | int v = s6_i2s_read_reg(dev, S6_I2S_ENABLE(channel)); | ||
221 | if ((v & S6_I2S_IS_ENABLED) | ||
222 | || !(v & (S6_I2S_DMA_ACTIVE | S6_I2S_IS_BUSY))) | ||
223 | break; | ||
224 | udelay(20); | ||
225 | } | ||
226 | } | ||
227 | if (n < 0) | ||
228 | printk(KERN_WARNING "s6000-i2s: timeout disabling interfaces"); | ||
229 | } | ||
230 | |||
231 | static int s6000_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, | ||
232 | unsigned int fmt) | ||
233 | { | ||
234 | struct s6000_i2s_dev *dev = cpu_dai->private_data; | ||
235 | u32 w; | ||
236 | |||
237 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
238 | case SND_SOC_DAIFMT_CBM_CFM: | ||
239 | w = S6_I2S_SCK_IN | S6_I2S_WS_IN; | ||
240 | break; | ||
241 | case SND_SOC_DAIFMT_CBS_CFM: | ||
242 | w = S6_I2S_SCK_OUT | S6_I2S_WS_IN; | ||
243 | break; | ||
244 | case SND_SOC_DAIFMT_CBM_CFS: | ||
245 | w = S6_I2S_SCK_IN | S6_I2S_WS_OUT; | ||
246 | break; | ||
247 | case SND_SOC_DAIFMT_CBS_CFS: | ||
248 | w = S6_I2S_SCK_OUT | S6_I2S_WS_OUT; | ||
249 | break; | ||
250 | default: | ||
251 | return -EINVAL; | ||
252 | } | ||
253 | |||
254 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
255 | case SND_SOC_DAIFMT_NB_NF: | ||
256 | w |= S6_I2S_LEFT_FIRST; | ||
257 | break; | ||
258 | case SND_SOC_DAIFMT_NB_IF: | ||
259 | w |= S6_I2S_RIGHT_FIRST; | ||
260 | break; | ||
261 | default: | ||
262 | return -EINVAL; | ||
263 | } | ||
264 | |||
265 | s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(0), | ||
266 | S6_I2S_FIRST | S6_I2S_WS_DIR | S6_I2S_SCK_DIR, w); | ||
267 | s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(1), | ||
268 | S6_I2S_FIRST | S6_I2S_WS_DIR | S6_I2S_SCK_DIR, w); | ||
269 | |||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | static int s6000_i2s_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) | ||
274 | { | ||
275 | struct s6000_i2s_dev *dev = dai->private_data; | ||
276 | |||
277 | if (!div || (div & 1) || div > (S6_I2S_DIV_MASK + 1) * 2) | ||
278 | return -EINVAL; | ||
279 | |||
280 | s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(div_id), | ||
281 | S6_I2S_DIV_MASK, div / 2 - 1); | ||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | static int s6000_i2s_hw_params(struct snd_pcm_substream *substream, | ||
286 | struct snd_pcm_hw_params *params, | ||
287 | struct snd_soc_dai *dai) | ||
288 | { | ||
289 | struct s6000_i2s_dev *dev = dai->private_data; | ||
290 | int interf; | ||
291 | u32 w = 0; | ||
292 | |||
293 | if (dev->wide) | ||
294 | interf = 0; | ||
295 | else { | ||
296 | w |= (((params_channels(params) - 2) / 2) | ||
297 | << S6_I2S_CHANNELS_SHIFT) & S6_I2S_CHANNELS_MASK; | ||
298 | interf = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
299 | ? dev->channel_out : dev->channel_in; | ||
300 | } | ||
301 | |||
302 | switch (params_format(params)) { | ||
303 | case SNDRV_PCM_FORMAT_S16_LE: | ||
304 | w |= S6_I2S_16BIT | S6_I2S_MEM_16BIT; | ||
305 | break; | ||
306 | case SNDRV_PCM_FORMAT_S32_LE: | ||
307 | w |= S6_I2S_32BIT | S6_I2S_MEM_32BIT; | ||
308 | break; | ||
309 | default: | ||
310 | printk(KERN_WARNING "s6000-i2s: unsupported PCM format %x\n", | ||
311 | params_format(params)); | ||
312 | return -EINVAL; | ||
313 | } | ||
314 | |||
315 | if (s6_i2s_read_reg(dev, S6_I2S_INTERFACE_CFG(interf)) | ||
316 | & S6_I2S_IS_ENABLED) { | ||
317 | printk(KERN_ERR "s6000-i2s: interface already enabled\n"); | ||
318 | return -EBUSY; | ||
319 | } | ||
320 | |||
321 | s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(interf), | ||
322 | S6_I2S_CHANNELS_MASK|S6_I2S_MEM_MASK|S6_I2S_BITS_MASK, | ||
323 | w); | ||
324 | |||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | static int s6000_i2s_dai_probe(struct platform_device *pdev, | ||
329 | struct snd_soc_dai *dai) | ||
330 | { | ||
331 | struct s6000_i2s_dev *dev = dai->private_data; | ||
332 | struct s6000_snd_platform_data *pdata = pdev->dev.platform_data; | ||
333 | |||
334 | if (!pdata) | ||
335 | return -EINVAL; | ||
336 | |||
337 | dev->wide = pdata->wide; | ||
338 | dev->channel_in = pdata->channel_in; | ||
339 | dev->channel_out = pdata->channel_out; | ||
340 | dev->lines_in = pdata->lines_in; | ||
341 | dev->lines_out = pdata->lines_out; | ||
342 | |||
343 | s6_i2s_write_reg(dev, S6_I2S_MODE, | ||
344 | dev->wide ? S6_I2S_WIDE : S6_I2S_DUAL); | ||
345 | |||
346 | if (dev->wide) { | ||
347 | int i; | ||
348 | |||
349 | if (dev->lines_in + dev->lines_out > S6_I2S_NUM_LINES) | ||
350 | return -EINVAL; | ||
351 | |||
352 | dev->channel_in = 0; | ||
353 | dev->channel_out = 1; | ||
354 | dai->capture.channels_min = 2 * dev->lines_in; | ||
355 | dai->capture.channels_max = dai->capture.channels_min; | ||
356 | dai->playback.channels_min = 2 * dev->lines_out; | ||
357 | dai->playback.channels_max = dai->playback.channels_min; | ||
358 | |||
359 | for (i = 0; i < dev->lines_out; i++) | ||
360 | s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(i), S6_I2S_OUT); | ||
361 | |||
362 | for (; i < S6_I2S_NUM_LINES - dev->lines_in; i++) | ||
363 | s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(i), | ||
364 | S6_I2S_UNUSED); | ||
365 | |||
366 | for (; i < S6_I2S_NUM_LINES; i++) | ||
367 | s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(i), S6_I2S_IN); | ||
368 | } else { | ||
369 | unsigned int cfg[2] = {S6_I2S_UNUSED, S6_I2S_UNUSED}; | ||
370 | |||
371 | if (dev->lines_in > 1 || dev->lines_out > 1) | ||
372 | return -EINVAL; | ||
373 | |||
374 | dai->capture.channels_min = 2 * dev->lines_in; | ||
375 | dai->capture.channels_max = 8 * dev->lines_in; | ||
376 | dai->playback.channels_min = 2 * dev->lines_out; | ||
377 | dai->playback.channels_max = 8 * dev->lines_out; | ||
378 | |||
379 | if (dev->lines_in) | ||
380 | cfg[dev->channel_in] = S6_I2S_IN; | ||
381 | if (dev->lines_out) | ||
382 | cfg[dev->channel_out] = S6_I2S_OUT; | ||
383 | |||
384 | s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(0), cfg[0]); | ||
385 | s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(1), cfg[1]); | ||
386 | } | ||
387 | |||
388 | if (dev->lines_out) { | ||
389 | if (dev->lines_in) { | ||
390 | if (!dev->dma_params.dma_out) | ||
391 | return -ENODEV; | ||
392 | } else { | ||
393 | dev->dma_params.dma_out = dev->dma_params.dma_in; | ||
394 | dev->dma_params.dma_in = 0; | ||
395 | } | ||
396 | } | ||
397 | dev->dma_params.sif_in = dev->sifbase + (dev->channel_in ? | ||
398 | S6_I2S_SIF_PORT1 : S6_I2S_SIF_PORT0); | ||
399 | dev->dma_params.sif_out = dev->sifbase + (dev->channel_out ? | ||
400 | S6_I2S_SIF_PORT1 : S6_I2S_SIF_PORT0); | ||
401 | dev->dma_params.same_rate = pdata->same_rate | pdata->wide; | ||
402 | return 0; | ||
403 | } | ||
404 | |||
405 | #define S6000_I2S_RATES (SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_5512 | \ | ||
406 | SNDRV_PCM_RATE_8000_192000) | ||
407 | #define S6000_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE) | ||
408 | |||
409 | static struct snd_soc_dai_ops s6000_i2s_dai_ops = { | ||
410 | .set_fmt = s6000_i2s_set_dai_fmt, | ||
411 | .set_clkdiv = s6000_i2s_set_clkdiv, | ||
412 | .hw_params = s6000_i2s_hw_params, | ||
413 | }; | ||
414 | |||
415 | struct snd_soc_dai s6000_i2s_dai = { | ||
416 | .name = "s6000-i2s", | ||
417 | .id = 0, | ||
418 | .probe = s6000_i2s_dai_probe, | ||
419 | .playback = { | ||
420 | .channels_min = 2, | ||
421 | .channels_max = 8, | ||
422 | .formats = S6000_I2S_FORMATS, | ||
423 | .rates = S6000_I2S_RATES, | ||
424 | .rate_min = 0, | ||
425 | .rate_max = 1562500, | ||
426 | }, | ||
427 | .capture = { | ||
428 | .channels_min = 2, | ||
429 | .channels_max = 8, | ||
430 | .formats = S6000_I2S_FORMATS, | ||
431 | .rates = S6000_I2S_RATES, | ||
432 | .rate_min = 0, | ||
433 | .rate_max = 1562500, | ||
434 | }, | ||
435 | .ops = &s6000_i2s_dai_ops, | ||
436 | } | ||
437 | EXPORT_SYMBOL_GPL(s6000_i2s_dai); | ||
438 | |||
439 | static int __devinit s6000_i2s_probe(struct platform_device *pdev) | ||
440 | { | ||
441 | struct s6000_i2s_dev *dev; | ||
442 | struct resource *scbmem, *sifmem, *region, *dma1, *dma2; | ||
443 | u8 __iomem *mmio; | ||
444 | int ret; | ||
445 | |||
446 | scbmem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
447 | if (!scbmem) { | ||
448 | dev_err(&pdev->dev, "no mem resource?\n"); | ||
449 | ret = -ENODEV; | ||
450 | goto err_release_none; | ||
451 | } | ||
452 | |||
453 | region = request_mem_region(scbmem->start, | ||
454 | scbmem->end - scbmem->start + 1, | ||
455 | pdev->name); | ||
456 | if (!region) { | ||
457 | dev_err(&pdev->dev, "I2S SCB region already claimed\n"); | ||
458 | ret = -EBUSY; | ||
459 | goto err_release_none; | ||
460 | } | ||
461 | |||
462 | mmio = ioremap(scbmem->start, scbmem->end - scbmem->start + 1); | ||
463 | if (!mmio) { | ||
464 | dev_err(&pdev->dev, "can't ioremap SCB region\n"); | ||
465 | ret = -ENOMEM; | ||
466 | goto err_release_scb; | ||
467 | } | ||
468 | |||
469 | sifmem = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
470 | if (!sifmem) { | ||
471 | dev_err(&pdev->dev, "no second mem resource?\n"); | ||
472 | ret = -ENODEV; | ||
473 | goto err_release_map; | ||
474 | } | ||
475 | |||
476 | region = request_mem_region(sifmem->start, | ||
477 | sifmem->end - sifmem->start + 1, | ||
478 | pdev->name); | ||
479 | if (!region) { | ||
480 | dev_err(&pdev->dev, "I2S SIF region already claimed\n"); | ||
481 | ret = -EBUSY; | ||
482 | goto err_release_map; | ||
483 | } | ||
484 | |||
485 | dma1 = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
486 | if (!dma1) { | ||
487 | dev_err(&pdev->dev, "no dma resource?\n"); | ||
488 | ret = -ENODEV; | ||
489 | goto err_release_sif; | ||
490 | } | ||
491 | |||
492 | region = request_mem_region(dma1->start, dma1->end - dma1->start + 1, | ||
493 | pdev->name); | ||
494 | if (!region) { | ||
495 | dev_err(&pdev->dev, "I2S DMA region already claimed\n"); | ||
496 | ret = -EBUSY; | ||
497 | goto err_release_sif; | ||
498 | } | ||
499 | |||
500 | dma2 = platform_get_resource(pdev, IORESOURCE_DMA, 1); | ||
501 | if (dma2) { | ||
502 | region = request_mem_region(dma2->start, | ||
503 | dma2->end - dma2->start + 1, | ||
504 | pdev->name); | ||
505 | if (!region) { | ||
506 | dev_err(&pdev->dev, | ||
507 | "I2S DMA region already claimed\n"); | ||
508 | ret = -EBUSY; | ||
509 | goto err_release_dma1; | ||
510 | } | ||
511 | } | ||
512 | |||
513 | dev = kzalloc(sizeof(struct s6000_i2s_dev), GFP_KERNEL); | ||
514 | if (!dev) { | ||
515 | ret = -ENOMEM; | ||
516 | goto err_release_dma2; | ||
517 | } | ||
518 | |||
519 | s6000_i2s_dai.dev = &pdev->dev; | ||
520 | s6000_i2s_dai.private_data = dev; | ||
521 | s6000_i2s_dai.dma_data = &dev->dma_params; | ||
522 | |||
523 | dev->sifbase = sifmem->start; | ||
524 | dev->scbbase = mmio; | ||
525 | |||
526 | s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_ENABLE, 0); | ||
527 | s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_CLEAR, | ||
528 | S6_I2S_INT_ALIGNMENT | | ||
529 | S6_I2S_INT_UNDERRUN | | ||
530 | S6_I2S_INT_OVERRUN); | ||
531 | |||
532 | s6000_i2s_stop_channel(dev, 0); | ||
533 | s6000_i2s_stop_channel(dev, 1); | ||
534 | s6000_i2s_wait_disabled(dev); | ||
535 | |||
536 | dev->dma_params.check_xrun = s6000_i2s_check_xrun; | ||
537 | dev->dma_params.trigger = s6000_i2s_trigger; | ||
538 | dev->dma_params.dma_in = dma1->start; | ||
539 | dev->dma_params.dma_out = dma2 ? dma2->start : 0; | ||
540 | dev->dma_params.irq = platform_get_irq(pdev, 0); | ||
541 | if (dev->dma_params.irq < 0) { | ||
542 | dev_err(&pdev->dev, "no irq resource?\n"); | ||
543 | ret = -ENODEV; | ||
544 | goto err_release_dev; | ||
545 | } | ||
546 | |||
547 | s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_ENABLE, | ||
548 | S6_I2S_INT_ALIGNMENT | | ||
549 | S6_I2S_INT_UNDERRUN | | ||
550 | S6_I2S_INT_OVERRUN); | ||
551 | |||
552 | ret = snd_soc_register_dai(&s6000_i2s_dai); | ||
553 | if (ret) | ||
554 | goto err_release_dev; | ||
555 | |||
556 | return 0; | ||
557 | |||
558 | err_release_dev: | ||
559 | kfree(dev); | ||
560 | err_release_dma2: | ||
561 | if (dma2) | ||
562 | release_mem_region(dma2->start, dma2->end - dma2->start + 1); | ||
563 | err_release_dma1: | ||
564 | release_mem_region(dma1->start, dma1->end - dma1->start + 1); | ||
565 | err_release_sif: | ||
566 | release_mem_region(sifmem->start, (sifmem->end - sifmem->start) + 1); | ||
567 | err_release_map: | ||
568 | iounmap(mmio); | ||
569 | err_release_scb: | ||
570 | release_mem_region(scbmem->start, (scbmem->end - scbmem->start) + 1); | ||
571 | err_release_none: | ||
572 | return ret; | ||
573 | } | ||
574 | |||
575 | static void __devexit s6000_i2s_remove(struct platform_device *pdev) | ||
576 | { | ||
577 | struct s6000_i2s_dev *dev = s6000_i2s_dai.private_data; | ||
578 | struct resource *region; | ||
579 | void __iomem *mmio = dev->scbbase; | ||
580 | |||
581 | snd_soc_unregister_dai(&s6000_i2s_dai); | ||
582 | |||
583 | s6000_i2s_stop_channel(dev, 0); | ||
584 | s6000_i2s_stop_channel(dev, 1); | ||
585 | |||
586 | s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_ENABLE, 0); | ||
587 | s6000_i2s_dai.private_data = 0; | ||
588 | kfree(dev); | ||
589 | |||
590 | region = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
591 | release_mem_region(region->start, region->end - region->start + 1); | ||
592 | |||
593 | region = platform_get_resource(pdev, IORESOURCE_DMA, 1); | ||
594 | if (region) | ||
595 | release_mem_region(region->start, | ||
596 | region->end - region->start + 1); | ||
597 | |||
598 | region = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
599 | release_mem_region(region->start, (region->end - region->start) + 1); | ||
600 | |||
601 | iounmap(mmio); | ||
602 | region = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
603 | release_mem_region(region->start, (region->end - region->start) + 1); | ||
604 | } | ||
605 | |||
606 | static struct platform_driver s6000_i2s_driver = { | ||
607 | .probe = s6000_i2s_probe, | ||
608 | .remove = __devexit_p(s6000_i2s_remove), | ||
609 | .driver = { | ||
610 | .name = "s6000-i2s", | ||
611 | .owner = THIS_MODULE, | ||
612 | }, | ||
613 | }; | ||
614 | |||
615 | static int __init s6000_i2s_init(void) | ||
616 | { | ||
617 | return platform_driver_register(&s6000_i2s_driver); | ||
618 | } | ||
619 | module_init(s6000_i2s_init); | ||
620 | |||
621 | static void __exit s6000_i2s_exit(void) | ||
622 | { | ||
623 | platform_driver_unregister(&s6000_i2s_driver); | ||
624 | } | ||
625 | module_exit(s6000_i2s_exit); | ||
626 | |||
627 | MODULE_AUTHOR("Daniel Gloeckner"); | ||
628 | MODULE_DESCRIPTION("Stretch s6000 family I2S SoC Interface"); | ||
629 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/s6000/s6000-i2s.h b/sound/soc/s6000/s6000-i2s.h new file mode 100644 index 000000000000..2375fdfe6dba --- /dev/null +++ b/sound/soc/s6000/s6000-i2s.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * ALSA SoC I2S Audio Layer for the Stretch s6000 family | ||
3 | * | ||
4 | * Author: Daniel Gloeckner, <dg@emlix.com> | ||
5 | * Copyright: (C) 2009 emlix GmbH <info@emlix.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef _S6000_I2S_H | ||
13 | #define _S6000_I2S_H | ||
14 | |||
15 | extern struct snd_soc_dai s6000_i2s_dai; | ||
16 | |||
17 | struct s6000_snd_platform_data { | ||
18 | int lines_in; | ||
19 | int lines_out; | ||
20 | int channel_in; | ||
21 | int channel_out; | ||
22 | int wide; | ||
23 | int same_rate; | ||
24 | }; | ||
25 | #endif | ||
diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c new file mode 100644 index 000000000000..83b8028e209d --- /dev/null +++ b/sound/soc/s6000/s6000-pcm.c | |||
@@ -0,0 +1,497 @@ | |||
1 | /* | ||
2 | * ALSA PCM interface for the Stetch s6000 family | ||
3 | * | ||
4 | * Author: Daniel Gloeckner, <dg@emlix.com> | ||
5 | * Copyright: (C) 2009 emlix GmbH <info@emlix.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/slab.h> | ||
16 | #include <linux/dma-mapping.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | |||
19 | #include <sound/core.h> | ||
20 | #include <sound/pcm.h> | ||
21 | #include <sound/pcm_params.h> | ||
22 | #include <sound/soc.h> | ||
23 | |||
24 | #include <asm/dma.h> | ||
25 | #include <variant/dmac.h> | ||
26 | |||
27 | #include "s6000-pcm.h" | ||
28 | |||
29 | #define S6_PCM_PREALLOCATE_SIZE (96 * 1024) | ||
30 | #define S6_PCM_PREALLOCATE_MAX (2048 * 1024) | ||
31 | |||
32 | static struct snd_pcm_hardware s6000_pcm_hardware = { | ||
33 | .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
34 | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | | ||
35 | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_JOINT_DUPLEX), | ||
36 | .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE), | ||
37 | .rates = (SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_5512 | \ | ||
38 | SNDRV_PCM_RATE_8000_192000), | ||
39 | .rate_min = 0, | ||
40 | .rate_max = 1562500, | ||
41 | .channels_min = 2, | ||
42 | .channels_max = 8, | ||
43 | .buffer_bytes_max = 0x7ffffff0, | ||
44 | .period_bytes_min = 16, | ||
45 | .period_bytes_max = 0xfffff0, | ||
46 | .periods_min = 2, | ||
47 | .periods_max = 1024, /* no limit */ | ||
48 | .fifo_size = 0, | ||
49 | }; | ||
50 | |||
51 | struct s6000_runtime_data { | ||
52 | spinlock_t lock; | ||
53 | int period; /* current DMA period */ | ||
54 | }; | ||
55 | |||
56 | static void s6000_pcm_enqueue_dma(struct snd_pcm_substream *substream) | ||
57 | { | ||
58 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
59 | struct s6000_runtime_data *prtd = runtime->private_data; | ||
60 | struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; | ||
61 | struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; | ||
62 | int channel; | ||
63 | unsigned int period_size; | ||
64 | unsigned int dma_offset; | ||
65 | dma_addr_t dma_pos; | ||
66 | dma_addr_t src, dst; | ||
67 | |||
68 | period_size = snd_pcm_lib_period_bytes(substream); | ||
69 | dma_offset = prtd->period * period_size; | ||
70 | dma_pos = runtime->dma_addr + dma_offset; | ||
71 | |||
72 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
73 | src = dma_pos; | ||
74 | dst = par->sif_out; | ||
75 | channel = par->dma_out; | ||
76 | } else { | ||
77 | src = par->sif_in; | ||
78 | dst = dma_pos; | ||
79 | channel = par->dma_in; | ||
80 | } | ||
81 | |||
82 | if (!s6dmac_channel_enabled(DMA_MASK_DMAC(channel), | ||
83 | DMA_INDEX_CHNL(channel))) | ||
84 | return; | ||
85 | |||
86 | if (s6dmac_fifo_full(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel))) { | ||
87 | printk(KERN_ERR "s6000-pcm: fifo full\n"); | ||
88 | return; | ||
89 | } | ||
90 | |||
91 | BUG_ON(period_size & 15); | ||
92 | s6dmac_put_fifo(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel), | ||
93 | src, dst, period_size); | ||
94 | |||
95 | prtd->period++; | ||
96 | if (unlikely(prtd->period >= runtime->periods)) | ||
97 | prtd->period = 0; | ||
98 | } | ||
99 | |||
100 | static irqreturn_t s6000_pcm_irq(int irq, void *data) | ||
101 | { | ||
102 | struct snd_pcm *pcm = data; | ||
103 | struct snd_soc_pcm_runtime *runtime = pcm->private_data; | ||
104 | struct s6000_pcm_dma_params *params = runtime->dai->cpu_dai->dma_data; | ||
105 | struct s6000_runtime_data *prtd; | ||
106 | unsigned int has_xrun; | ||
107 | int i, ret = IRQ_NONE; | ||
108 | u32 channel[2] = { | ||
109 | [SNDRV_PCM_STREAM_PLAYBACK] = params->dma_out, | ||
110 | [SNDRV_PCM_STREAM_CAPTURE] = params->dma_in | ||
111 | }; | ||
112 | |||
113 | has_xrun = params->check_xrun(runtime->dai->cpu_dai); | ||
114 | |||
115 | for (i = 0; i < ARRAY_SIZE(channel); ++i) { | ||
116 | struct snd_pcm_substream *substream = pcm->streams[i].substream; | ||
117 | unsigned int pending; | ||
118 | |||
119 | if (!channel[i]) | ||
120 | continue; | ||
121 | |||
122 | if (unlikely(has_xrun & (1 << i)) && | ||
123 | substream->runtime && | ||
124 | snd_pcm_running(substream)) { | ||
125 | dev_dbg(pcm->dev, "xrun\n"); | ||
126 | snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); | ||
127 | ret = IRQ_HANDLED; | ||
128 | } | ||
129 | |||
130 | pending = s6dmac_int_sources(DMA_MASK_DMAC(channel[i]), | ||
131 | DMA_INDEX_CHNL(channel[i])); | ||
132 | |||
133 | if (pending & 1) { | ||
134 | ret = IRQ_HANDLED; | ||
135 | if (likely(substream->runtime && | ||
136 | snd_pcm_running(substream))) { | ||
137 | snd_pcm_period_elapsed(substream); | ||
138 | dev_dbg(pcm->dev, "period elapsed %x %x\n", | ||
139 | s6dmac_cur_src(DMA_MASK_DMAC(channel[i]), | ||
140 | DMA_INDEX_CHNL(channel[i])), | ||
141 | s6dmac_cur_dst(DMA_MASK_DMAC(channel[i]), | ||
142 | DMA_INDEX_CHNL(channel[i]))); | ||
143 | prtd = substream->runtime->private_data; | ||
144 | spin_lock(&prtd->lock); | ||
145 | s6000_pcm_enqueue_dma(substream); | ||
146 | spin_unlock(&prtd->lock); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | if (unlikely(pending & ~7)) { | ||
151 | if (pending & (1 << 3)) | ||
152 | printk(KERN_WARNING | ||
153 | "s6000-pcm: DMA %x Underflow\n", | ||
154 | channel[i]); | ||
155 | if (pending & (1 << 4)) | ||
156 | printk(KERN_WARNING | ||
157 | "s6000-pcm: DMA %x Overflow\n", | ||
158 | channel[i]); | ||
159 | if (pending & 0x1e0) | ||
160 | printk(KERN_WARNING | ||
161 | "s6000-pcm: DMA %x Master Error " | ||
162 | "(mask %x)\n", | ||
163 | channel[i], pending >> 5); | ||
164 | |||
165 | } | ||
166 | } | ||
167 | |||
168 | return ret; | ||
169 | } | ||
170 | |||
171 | static int s6000_pcm_start(struct snd_pcm_substream *substream) | ||
172 | { | ||
173 | struct s6000_runtime_data *prtd = substream->runtime->private_data; | ||
174 | struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; | ||
175 | struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; | ||
176 | unsigned long flags; | ||
177 | int srcinc; | ||
178 | u32 dma; | ||
179 | |||
180 | spin_lock_irqsave(&prtd->lock, flags); | ||
181 | |||
182 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
183 | srcinc = 1; | ||
184 | dma = par->dma_out; | ||
185 | } else { | ||
186 | srcinc = 0; | ||
187 | dma = par->dma_in; | ||
188 | } | ||
189 | s6dmac_enable_chan(DMA_MASK_DMAC(dma), DMA_INDEX_CHNL(dma), | ||
190 | 1 /* priority 1 (0 is max) */, | ||
191 | 0 /* peripheral requests w/o xfer length mode */, | ||
192 | srcinc /* source address increment */, | ||
193 | srcinc^1 /* destination address increment */, | ||
194 | 0 /* chunksize 0 (skip impossible on this dma) */, | ||
195 | 0 /* source skip after chunk (impossible) */, | ||
196 | 0 /* destination skip after chunk (impossible) */, | ||
197 | 4 /* 16 byte burst size */, | ||
198 | -1 /* don't conserve bandwidth */, | ||
199 | 0 /* low watermark irq descriptor theshold */, | ||
200 | 0 /* disable hardware timestamps */, | ||
201 | 1 /* enable channel */); | ||
202 | |||
203 | s6000_pcm_enqueue_dma(substream); | ||
204 | s6000_pcm_enqueue_dma(substream); | ||
205 | |||
206 | spin_unlock_irqrestore(&prtd->lock, flags); | ||
207 | |||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | static int s6000_pcm_stop(struct snd_pcm_substream *substream) | ||
212 | { | ||
213 | struct s6000_runtime_data *prtd = substream->runtime->private_data; | ||
214 | struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; | ||
215 | struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; | ||
216 | unsigned long flags; | ||
217 | u32 channel; | ||
218 | |||
219 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
220 | channel = par->dma_out; | ||
221 | else | ||
222 | channel = par->dma_in; | ||
223 | |||
224 | s6dmac_set_terminal_count(DMA_MASK_DMAC(channel), | ||
225 | DMA_INDEX_CHNL(channel), 0); | ||
226 | |||
227 | spin_lock_irqsave(&prtd->lock, flags); | ||
228 | |||
229 | s6dmac_disable_chan(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel)); | ||
230 | |||
231 | spin_unlock_irqrestore(&prtd->lock, flags); | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static int s6000_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
237 | { | ||
238 | struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; | ||
239 | struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; | ||
240 | int ret; | ||
241 | |||
242 | ret = par->trigger(substream, cmd, 0); | ||
243 | if (ret < 0) | ||
244 | return ret; | ||
245 | |||
246 | switch (cmd) { | ||
247 | case SNDRV_PCM_TRIGGER_START: | ||
248 | case SNDRV_PCM_TRIGGER_RESUME: | ||
249 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
250 | ret = s6000_pcm_start(substream); | ||
251 | break; | ||
252 | case SNDRV_PCM_TRIGGER_STOP: | ||
253 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
254 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
255 | ret = s6000_pcm_stop(substream); | ||
256 | break; | ||
257 | default: | ||
258 | ret = -EINVAL; | ||
259 | } | ||
260 | if (ret < 0) | ||
261 | return ret; | ||
262 | |||
263 | return par->trigger(substream, cmd, 1); | ||
264 | } | ||
265 | |||
266 | static int s6000_pcm_prepare(struct snd_pcm_substream *substream) | ||
267 | { | ||
268 | struct s6000_runtime_data *prtd = substream->runtime->private_data; | ||
269 | |||
270 | prtd->period = 0; | ||
271 | |||
272 | return 0; | ||
273 | } | ||
274 | |||
275 | static snd_pcm_uframes_t s6000_pcm_pointer(struct snd_pcm_substream *substream) | ||
276 | { | ||
277 | struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; | ||
278 | struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; | ||
279 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
280 | struct s6000_runtime_data *prtd = runtime->private_data; | ||
281 | unsigned long flags; | ||
282 | unsigned int offset; | ||
283 | dma_addr_t count; | ||
284 | |||
285 | spin_lock_irqsave(&prtd->lock, flags); | ||
286 | |||
287 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
288 | count = s6dmac_cur_src(DMA_MASK_DMAC(par->dma_out), | ||
289 | DMA_INDEX_CHNL(par->dma_out)); | ||
290 | else | ||
291 | count = s6dmac_cur_dst(DMA_MASK_DMAC(par->dma_in), | ||
292 | DMA_INDEX_CHNL(par->dma_in)); | ||
293 | |||
294 | count -= runtime->dma_addr; | ||
295 | |||
296 | spin_unlock_irqrestore(&prtd->lock, flags); | ||
297 | |||
298 | offset = bytes_to_frames(runtime, count); | ||
299 | if (unlikely(offset >= runtime->buffer_size)) | ||
300 | offset = 0; | ||
301 | |||
302 | return offset; | ||
303 | } | ||
304 | |||
305 | static int s6000_pcm_open(struct snd_pcm_substream *substream) | ||
306 | { | ||
307 | struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; | ||
308 | struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; | ||
309 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
310 | struct s6000_runtime_data *prtd; | ||
311 | int ret; | ||
312 | |||
313 | snd_soc_set_runtime_hwparams(substream, &s6000_pcm_hardware); | ||
314 | |||
315 | ret = snd_pcm_hw_constraint_step(runtime, 0, | ||
316 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 16); | ||
317 | if (ret < 0) | ||
318 | return ret; | ||
319 | ret = snd_pcm_hw_constraint_step(runtime, 0, | ||
320 | SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 16); | ||
321 | if (ret < 0) | ||
322 | return ret; | ||
323 | ret = snd_pcm_hw_constraint_integer(runtime, | ||
324 | SNDRV_PCM_HW_PARAM_PERIODS); | ||
325 | if (ret < 0) | ||
326 | return ret; | ||
327 | |||
328 | if (par->same_rate) { | ||
329 | int rate; | ||
330 | spin_lock(&par->lock); /* needed? */ | ||
331 | rate = par->rate; | ||
332 | spin_unlock(&par->lock); | ||
333 | if (rate != -1) { | ||
334 | ret = snd_pcm_hw_constraint_minmax(runtime, | ||
335 | SNDRV_PCM_HW_PARAM_RATE, | ||
336 | rate, rate); | ||
337 | if (ret < 0) | ||
338 | return ret; | ||
339 | } | ||
340 | } | ||
341 | |||
342 | prtd = kzalloc(sizeof(struct s6000_runtime_data), GFP_KERNEL); | ||
343 | if (prtd == NULL) | ||
344 | return -ENOMEM; | ||
345 | |||
346 | spin_lock_init(&prtd->lock); | ||
347 | |||
348 | runtime->private_data = prtd; | ||
349 | |||
350 | return 0; | ||
351 | } | ||
352 | |||
353 | static int s6000_pcm_close(struct snd_pcm_substream *substream) | ||
354 | { | ||
355 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
356 | struct s6000_runtime_data *prtd = runtime->private_data; | ||
357 | |||
358 | kfree(prtd); | ||
359 | |||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | static int s6000_pcm_hw_params(struct snd_pcm_substream *substream, | ||
364 | struct snd_pcm_hw_params *hw_params) | ||
365 | { | ||
366 | struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; | ||
367 | struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; | ||
368 | int ret; | ||
369 | ret = snd_pcm_lib_malloc_pages(substream, | ||
370 | params_buffer_bytes(hw_params)); | ||
371 | if (ret < 0) { | ||
372 | printk(KERN_WARNING "s6000-pcm: allocation of memory failed\n"); | ||
373 | return ret; | ||
374 | } | ||
375 | |||
376 | if (par->same_rate) { | ||
377 | spin_lock(&par->lock); | ||
378 | if (par->rate == -1 || | ||
379 | !(par->in_use & ~(1 << substream->stream))) { | ||
380 | par->rate = params_rate(hw_params); | ||
381 | par->in_use |= 1 << substream->stream; | ||
382 | } else if (params_rate(hw_params) != par->rate) { | ||
383 | snd_pcm_lib_free_pages(substream); | ||
384 | par->in_use &= ~(1 << substream->stream); | ||
385 | ret = -EBUSY; | ||
386 | } | ||
387 | spin_unlock(&par->lock); | ||
388 | } | ||
389 | return ret; | ||
390 | } | ||
391 | |||
392 | static int s6000_pcm_hw_free(struct snd_pcm_substream *substream) | ||
393 | { | ||
394 | struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; | ||
395 | struct s6000_pcm_dma_params *par = soc_runtime->dai->cpu_dai->dma_data; | ||
396 | |||
397 | spin_lock(&par->lock); | ||
398 | par->in_use &= ~(1 << substream->stream); | ||
399 | if (!par->in_use) | ||
400 | par->rate = -1; | ||
401 | spin_unlock(&par->lock); | ||
402 | |||
403 | return snd_pcm_lib_free_pages(substream); | ||
404 | } | ||
405 | |||
406 | static struct snd_pcm_ops s6000_pcm_ops = { | ||
407 | .open = s6000_pcm_open, | ||
408 | .close = s6000_pcm_close, | ||
409 | .ioctl = snd_pcm_lib_ioctl, | ||
410 | .hw_params = s6000_pcm_hw_params, | ||
411 | .hw_free = s6000_pcm_hw_free, | ||
412 | .trigger = s6000_pcm_trigger, | ||
413 | .prepare = s6000_pcm_prepare, | ||
414 | .pointer = s6000_pcm_pointer, | ||
415 | }; | ||
416 | |||
417 | static void s6000_pcm_free(struct snd_pcm *pcm) | ||
418 | { | ||
419 | struct snd_soc_pcm_runtime *runtime = pcm->private_data; | ||
420 | struct s6000_pcm_dma_params *params = runtime->dai->cpu_dai->dma_data; | ||
421 | |||
422 | free_irq(params->irq, pcm); | ||
423 | snd_pcm_lib_preallocate_free_for_all(pcm); | ||
424 | } | ||
425 | |||
426 | static u64 s6000_pcm_dmamask = DMA_32BIT_MASK; | ||
427 | |||
428 | static int s6000_pcm_new(struct snd_card *card, | ||
429 | struct snd_soc_dai *dai, struct snd_pcm *pcm) | ||
430 | { | ||
431 | struct snd_soc_pcm_runtime *runtime = pcm->private_data; | ||
432 | struct s6000_pcm_dma_params *params = runtime->dai->cpu_dai->dma_data; | ||
433 | int res; | ||
434 | |||
435 | if (!card->dev->dma_mask) | ||
436 | card->dev->dma_mask = &s6000_pcm_dmamask; | ||
437 | if (!card->dev->coherent_dma_mask) | ||
438 | card->dev->coherent_dma_mask = DMA_32BIT_MASK; | ||
439 | |||
440 | if (params->dma_in) { | ||
441 | s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_in), | ||
442 | DMA_INDEX_CHNL(params->dma_in)); | ||
443 | s6dmac_int_sources(DMA_MASK_DMAC(params->dma_in), | ||
444 | DMA_INDEX_CHNL(params->dma_in)); | ||
445 | } | ||
446 | |||
447 | if (params->dma_out) { | ||
448 | s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_out), | ||
449 | DMA_INDEX_CHNL(params->dma_out)); | ||
450 | s6dmac_int_sources(DMA_MASK_DMAC(params->dma_out), | ||
451 | DMA_INDEX_CHNL(params->dma_out)); | ||
452 | } | ||
453 | |||
454 | res = request_irq(params->irq, s6000_pcm_irq, IRQF_SHARED, | ||
455 | s6000_soc_platform.name, pcm); | ||
456 | if (res) { | ||
457 | printk(KERN_ERR "s6000-pcm couldn't get IRQ\n"); | ||
458 | return res; | ||
459 | } | ||
460 | |||
461 | res = snd_pcm_lib_preallocate_pages_for_all(pcm, | ||
462 | SNDRV_DMA_TYPE_DEV, | ||
463 | card->dev, | ||
464 | S6_PCM_PREALLOCATE_SIZE, | ||
465 | S6_PCM_PREALLOCATE_MAX); | ||
466 | if (res) | ||
467 | printk(KERN_WARNING "s6000-pcm: preallocation failed\n"); | ||
468 | |||
469 | spin_lock_init(¶ms->lock); | ||
470 | params->in_use = 0; | ||
471 | params->rate = -1; | ||
472 | return 0; | ||
473 | } | ||
474 | |||
475 | struct snd_soc_platform s6000_soc_platform = { | ||
476 | .name = "s6000-audio", | ||
477 | .pcm_ops = &s6000_pcm_ops, | ||
478 | .pcm_new = s6000_pcm_new, | ||
479 | .pcm_free = s6000_pcm_free, | ||
480 | }; | ||
481 | EXPORT_SYMBOL_GPL(s6000_soc_platform); | ||
482 | |||
483 | static int __init s6000_pcm_init(void) | ||
484 | { | ||
485 | return snd_soc_register_platform(&s6000_soc_platform); | ||
486 | } | ||
487 | module_init(s6000_pcm_init); | ||
488 | |||
489 | static void __exit s6000_pcm_exit(void) | ||
490 | { | ||
491 | snd_soc_unregister_platform(&s6000_soc_platform); | ||
492 | } | ||
493 | module_exit(s6000_pcm_exit); | ||
494 | |||
495 | MODULE_AUTHOR("Daniel Gloeckner"); | ||
496 | MODULE_DESCRIPTION("Stretch s6000 family PCM DMA module"); | ||
497 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/s6000/s6000-pcm.h b/sound/soc/s6000/s6000-pcm.h new file mode 100644 index 000000000000..96f23f6f52bf --- /dev/null +++ b/sound/soc/s6000/s6000-pcm.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * ALSA PCM interface for the Stretch s6000 family | ||
3 | * | ||
4 | * Author: Daniel Gloeckner, <dg@emlix.com> | ||
5 | * Copyright: (C) 2009 emlix GmbH <info@emlix.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef _S6000_PCM_H | ||
13 | #define _S6000_PCM_H | ||
14 | |||
15 | struct snd_soc_dai; | ||
16 | struct snd_pcm_substream; | ||
17 | |||
18 | struct s6000_pcm_dma_params { | ||
19 | unsigned int (*check_xrun)(struct snd_soc_dai *cpu_dai); | ||
20 | int (*trigger)(struct snd_pcm_substream *substream, int cmd, int after); | ||
21 | dma_addr_t sif_in; | ||
22 | dma_addr_t sif_out; | ||
23 | u32 dma_in; | ||
24 | u32 dma_out; | ||
25 | int irq; | ||
26 | int same_rate; | ||
27 | |||
28 | spinlock_t lock; | ||
29 | int in_use; | ||
30 | int rate; | ||
31 | }; | ||
32 | |||
33 | extern struct snd_soc_platform s6000_soc_platform; | ||
34 | |||
35 | #endif | ||
diff --git a/sound/soc/s6000/s6105-ipcam.c b/sound/soc/s6000/s6105-ipcam.c new file mode 100644 index 000000000000..b5f95f9781c1 --- /dev/null +++ b/sound/soc/s6000/s6105-ipcam.c | |||
@@ -0,0 +1,244 @@ | |||
1 | /* | ||
2 | * ASoC driver for Stretch s6105 IP camera platform | ||
3 | * | ||
4 | * Author: Daniel Gloeckner, <dg@emlix.com> | ||
5 | * Copyright: (C) 2009 emlix GmbH <info@emlix.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/moduleparam.h> | ||
14 | #include <linux/timer.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <sound/core.h> | ||
18 | #include <sound/pcm.h> | ||
19 | #include <sound/soc.h> | ||
20 | #include <sound/soc-dapm.h> | ||
21 | |||
22 | #include <variant/dmac.h> | ||
23 | |||
24 | #include "../codecs/tlv320aic3x.h" | ||
25 | #include "s6000-pcm.h" | ||
26 | #include "s6000-i2s.h" | ||
27 | |||
28 | #define S6105_CAM_CODEC_CLOCK 12288000 | ||
29 | |||
30 | static int s6105_hw_params(struct snd_pcm_substream *substream, | ||
31 | struct snd_pcm_hw_params *params) | ||
32 | { | ||
33 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
34 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
35 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
36 | int ret = 0; | ||
37 | |||
38 | /* set codec DAI configuration */ | ||
39 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | | ||
40 | SND_SOC_DAIFMT_CBM_CFM); | ||
41 | if (ret < 0) | ||
42 | return ret; | ||
43 | |||
44 | /* set cpu DAI configuration */ | ||
45 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM | | ||
46 | SND_SOC_DAIFMT_NB_NF); | ||
47 | if (ret < 0) | ||
48 | return ret; | ||
49 | |||
50 | /* set the codec system clock */ | ||
51 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, S6105_CAM_CODEC_CLOCK, | ||
52 | SND_SOC_CLOCK_OUT); | ||
53 | if (ret < 0) | ||
54 | return ret; | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static struct snd_soc_ops s6105_ops = { | ||
60 | .hw_params = s6105_hw_params, | ||
61 | }; | ||
62 | |||
63 | /* s6105 machine dapm widgets */ | ||
64 | static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { | ||
65 | SND_SOC_DAPM_LINE("Audio Out Differential", NULL), | ||
66 | SND_SOC_DAPM_LINE("Audio Out Stereo", NULL), | ||
67 | SND_SOC_DAPM_LINE("Audio In", NULL), | ||
68 | }; | ||
69 | |||
70 | /* s6105 machine audio_mapnections to the codec pins */ | ||
71 | static const struct snd_soc_dapm_route audio_map[] = { | ||
72 | /* Audio Out connected to HPLOUT, HPLCOM, HPROUT */ | ||
73 | {"Audio Out Differential", NULL, "HPLOUT"}, | ||
74 | {"Audio Out Differential", NULL, "HPLCOM"}, | ||
75 | {"Audio Out Stereo", NULL, "HPLOUT"}, | ||
76 | {"Audio Out Stereo", NULL, "HPROUT"}, | ||
77 | |||
78 | /* Audio In connected to LINE1L, LINE1R */ | ||
79 | {"LINE1L", NULL, "Audio In"}, | ||
80 | {"LINE1R", NULL, "Audio In"}, | ||
81 | }; | ||
82 | |||
83 | static int output_type_info(struct snd_kcontrol *kcontrol, | ||
84 | struct snd_ctl_elem_info *uinfo) | ||
85 | { | ||
86 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
87 | uinfo->count = 1; | ||
88 | uinfo->value.enumerated.items = 2; | ||
89 | if (uinfo->value.enumerated.item) { | ||
90 | uinfo->value.enumerated.item = 1; | ||
91 | strcpy(uinfo->value.enumerated.name, "HPLOUT/HPROUT"); | ||
92 | } else { | ||
93 | strcpy(uinfo->value.enumerated.name, "HPLOUT/HPLCOM"); | ||
94 | } | ||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | static int output_type_get(struct snd_kcontrol *kcontrol, | ||
99 | struct snd_ctl_elem_value *ucontrol) | ||
100 | { | ||
101 | ucontrol->value.enumerated.item[0] = kcontrol->private_value; | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | static int output_type_put(struct snd_kcontrol *kcontrol, | ||
106 | struct snd_ctl_elem_value *ucontrol) | ||
107 | { | ||
108 | struct snd_soc_codec *codec = kcontrol->private_data; | ||
109 | unsigned int val = (ucontrol->value.enumerated.item[0] != 0); | ||
110 | char *differential = "Audio Out Differential"; | ||
111 | char *stereo = "Audio Out Stereo"; | ||
112 | |||
113 | if (kcontrol->private_value == val) | ||
114 | return 0; | ||
115 | kcontrol->private_value = val; | ||
116 | snd_soc_dapm_disable_pin(codec, val ? differential : stereo); | ||
117 | snd_soc_dapm_sync(codec); | ||
118 | snd_soc_dapm_enable_pin(codec, val ? stereo : differential); | ||
119 | snd_soc_dapm_sync(codec); | ||
120 | |||
121 | return 1; | ||
122 | } | ||
123 | |||
124 | static const struct snd_kcontrol_new audio_out_mux = { | ||
125 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
126 | .name = "Master Output Mux", | ||
127 | .index = 0, | ||
128 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, | ||
129 | .info = output_type_info, | ||
130 | .get = output_type_get, | ||
131 | .put = output_type_put, | ||
132 | .private_value = 1 /* default to stereo */ | ||
133 | }; | ||
134 | |||
135 | /* Logic for a aic3x as connected on the s6105 ip camera ref design */ | ||
136 | static int s6105_aic3x_init(struct snd_soc_codec *codec) | ||
137 | { | ||
138 | /* Add s6105 specific widgets */ | ||
139 | snd_soc_dapm_new_controls(codec, aic3x_dapm_widgets, | ||
140 | ARRAY_SIZE(aic3x_dapm_widgets)); | ||
141 | |||
142 | /* Set up s6105 specific audio path audio_map */ | ||
143 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | ||
144 | |||
145 | /* not present */ | ||
146 | snd_soc_dapm_nc_pin(codec, "MONO_LOUT"); | ||
147 | snd_soc_dapm_nc_pin(codec, "LINE2L"); | ||
148 | snd_soc_dapm_nc_pin(codec, "LINE2R"); | ||
149 | |||
150 | /* not connected */ | ||
151 | snd_soc_dapm_nc_pin(codec, "MIC3L"); /* LINE2L on this chip */ | ||
152 | snd_soc_dapm_nc_pin(codec, "MIC3R"); /* LINE2R on this chip */ | ||
153 | snd_soc_dapm_nc_pin(codec, "LLOUT"); | ||
154 | snd_soc_dapm_nc_pin(codec, "RLOUT"); | ||
155 | snd_soc_dapm_nc_pin(codec, "HPRCOM"); | ||
156 | |||
157 | /* always connected */ | ||
158 | snd_soc_dapm_enable_pin(codec, "Audio In"); | ||
159 | |||
160 | /* must correspond to audio_out_mux.private_value initializer */ | ||
161 | snd_soc_dapm_disable_pin(codec, "Audio Out Differential"); | ||
162 | snd_soc_dapm_sync(codec); | ||
163 | snd_soc_dapm_enable_pin(codec, "Audio Out Stereo"); | ||
164 | |||
165 | snd_soc_dapm_sync(codec); | ||
166 | |||
167 | snd_ctl_add(codec->card, snd_ctl_new1(&audio_out_mux, codec)); | ||
168 | |||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | /* s6105 digital audio interface glue - connects codec <--> CPU */ | ||
173 | static struct snd_soc_dai_link s6105_dai = { | ||
174 | .name = "TLV320AIC31", | ||
175 | .stream_name = "AIC31", | ||
176 | .cpu_dai = &s6000_i2s_dai, | ||
177 | .codec_dai = &aic3x_dai, | ||
178 | .init = s6105_aic3x_init, | ||
179 | .ops = &s6105_ops, | ||
180 | }; | ||
181 | |||
182 | /* s6105 audio machine driver */ | ||
183 | static struct snd_soc_card snd_soc_card_s6105 = { | ||
184 | .name = "Stretch IP Camera", | ||
185 | .platform = &s6000_soc_platform, | ||
186 | .dai_link = &s6105_dai, | ||
187 | .num_links = 1, | ||
188 | }; | ||
189 | |||
190 | /* s6105 audio private data */ | ||
191 | static struct aic3x_setup_data s6105_aic3x_setup = { | ||
192 | .i2c_bus = 0, | ||
193 | .i2c_address = 0x18, | ||
194 | }; | ||
195 | |||
196 | /* s6105 audio subsystem */ | ||
197 | static struct snd_soc_device s6105_snd_devdata = { | ||
198 | .card = &snd_soc_card_s6105, | ||
199 | .codec_dev = &soc_codec_dev_aic3x, | ||
200 | .codec_data = &s6105_aic3x_setup, | ||
201 | }; | ||
202 | |||
203 | static struct s6000_snd_platform_data __initdata s6105_snd_data = { | ||
204 | .wide = 0, | ||
205 | .channel_in = 0, | ||
206 | .channel_out = 1, | ||
207 | .lines_in = 1, | ||
208 | .lines_out = 1, | ||
209 | .same_rate = 1, | ||
210 | }; | ||
211 | |||
212 | static struct platform_device *s6105_snd_device; | ||
213 | |||
214 | static int __init s6105_init(void) | ||
215 | { | ||
216 | int ret; | ||
217 | |||
218 | s6105_snd_device = platform_device_alloc("soc-audio", -1); | ||
219 | if (!s6105_snd_device) | ||
220 | return -ENOMEM; | ||
221 | |||
222 | platform_set_drvdata(s6105_snd_device, &s6105_snd_devdata); | ||
223 | s6105_snd_devdata.dev = &s6105_snd_device->dev; | ||
224 | platform_device_add_data(s6105_snd_device, &s6105_snd_data, | ||
225 | sizeof(s6105_snd_data)); | ||
226 | |||
227 | ret = platform_device_add(s6105_snd_device); | ||
228 | if (ret) | ||
229 | platform_device_put(s6105_snd_device); | ||
230 | |||
231 | return ret; | ||
232 | } | ||
233 | |||
234 | static void __exit s6105_exit(void) | ||
235 | { | ||
236 | platform_device_unregister(s6105_snd_device); | ||
237 | } | ||
238 | |||
239 | module_init(s6105_init); | ||
240 | module_exit(s6105_exit); | ||
241 | |||
242 | MODULE_AUTHOR("Daniel Gloeckner"); | ||
243 | MODULE_DESCRIPTION("Stretch s6105 IP camera ASoC driver"); | ||
244 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/sh/ssi.c b/sound/soc/sh/ssi.c index 56fa0872abbb..b378096cadb1 100644 --- a/sound/soc/sh/ssi.c +++ b/sound/soc/sh/ssi.c | |||
@@ -145,7 +145,7 @@ static int ssi_hw_params(struct snd_pcm_substream *substream, | |||
145 | recv = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 0 : 1; | 145 | recv = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 0 : 1; |
146 | 146 | ||
147 | pr_debug("ssi_hw_params() enter\nssicr was %08lx\n", ssicr); | 147 | pr_debug("ssi_hw_params() enter\nssicr was %08lx\n", ssicr); |
148 | pr_debug("bits: %d channels: %d\n", bits, channels); | 148 | pr_debug("bits: %u channels: %u\n", bits, channels); |
149 | 149 | ||
150 | ssicr &= ~(CR_TRMD | CR_CHNL_MASK | CR_DWL_MASK | CR_PDTA | | 150 | ssicr &= ~(CR_TRMD | CR_CHNL_MASK | CR_DWL_MASK | CR_PDTA | |
151 | CR_SWL_MASK); | 151 | CR_SWL_MASK); |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 99712f652d0d..1d70829464ef 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -113,6 +113,35 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec) | |||
113 | } | 113 | } |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream) | ||
117 | { | ||
118 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
119 | struct snd_soc_device *socdev = rtd->socdev; | ||
120 | struct snd_soc_card *card = socdev->card; | ||
121 | struct snd_soc_dai_link *machine = rtd->dai; | ||
122 | struct snd_soc_dai *cpu_dai = machine->cpu_dai; | ||
123 | struct snd_soc_dai *codec_dai = machine->codec_dai; | ||
124 | int ret; | ||
125 | |||
126 | if (codec_dai->symmetric_rates || cpu_dai->symmetric_rates || | ||
127 | machine->symmetric_rates) { | ||
128 | dev_dbg(card->dev, "Symmetry forces %dHz rate\n", | ||
129 | machine->rate); | ||
130 | |||
131 | ret = snd_pcm_hw_constraint_minmax(substream->runtime, | ||
132 | SNDRV_PCM_HW_PARAM_RATE, | ||
133 | machine->rate, | ||
134 | machine->rate); | ||
135 | if (ret < 0) { | ||
136 | dev_err(card->dev, | ||
137 | "Unable to apply rate symmetry constraint: %d\n", ret); | ||
138 | return ret; | ||
139 | } | ||
140 | } | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | |||
116 | /* | 145 | /* |
117 | * Called by ALSA when a PCM substream is opened, the runtime->hw record is | 146 | * Called by ALSA when a PCM substream is opened, the runtime->hw record is |
118 | * then initialized and any private data can be allocated. This also calls | 147 | * then initialized and any private data can be allocated. This also calls |
@@ -221,6 +250,13 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
221 | goto machine_err; | 250 | goto machine_err; |
222 | } | 251 | } |
223 | 252 | ||
253 | /* Symmetry only applies if we've already got an active stream. */ | ||
254 | if (cpu_dai->active || codec_dai->active) { | ||
255 | ret = soc_pcm_apply_symmetry(substream); | ||
256 | if (ret != 0) | ||
257 | goto machine_err; | ||
258 | } | ||
259 | |||
224 | pr_debug("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name); | 260 | pr_debug("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name); |
225 | pr_debug("asoc: rate mask 0x%x\n", runtime->hw.rates); | 261 | pr_debug("asoc: rate mask 0x%x\n", runtime->hw.rates); |
226 | pr_debug("asoc: min ch %d max ch %d\n", runtime->hw.channels_min, | 262 | pr_debug("asoc: min ch %d max ch %d\n", runtime->hw.channels_min, |
@@ -263,7 +299,6 @@ static void close_delayed_work(struct work_struct *work) | |||
263 | { | 299 | { |
264 | struct snd_soc_card *card = container_of(work, struct snd_soc_card, | 300 | struct snd_soc_card *card = container_of(work, struct snd_soc_card, |
265 | delayed_work.work); | 301 | delayed_work.work); |
266 | struct snd_soc_device *socdev = card->socdev; | ||
267 | struct snd_soc_codec *codec = card->codec; | 302 | struct snd_soc_codec *codec = card->codec; |
268 | struct snd_soc_dai *codec_dai; | 303 | struct snd_soc_dai *codec_dai; |
269 | int i; | 304 | int i; |
@@ -279,27 +314,10 @@ static void close_delayed_work(struct work_struct *work) | |||
279 | 314 | ||
280 | /* are we waiting on this codec DAI stream */ | 315 | /* are we waiting on this codec DAI stream */ |
281 | if (codec_dai->pop_wait == 1) { | 316 | if (codec_dai->pop_wait == 1) { |
282 | |||
283 | /* Reduce power if no longer active */ | ||
284 | if (codec->active == 0) { | ||
285 | pr_debug("pop wq D1 %s %s\n", codec->name, | ||
286 | codec_dai->playback.stream_name); | ||
287 | snd_soc_dapm_set_bias_level(socdev, | ||
288 | SND_SOC_BIAS_PREPARE); | ||
289 | } | ||
290 | |||
291 | codec_dai->pop_wait = 0; | 317 | codec_dai->pop_wait = 0; |
292 | snd_soc_dapm_stream_event(codec, | 318 | snd_soc_dapm_stream_event(codec, |
293 | codec_dai->playback.stream_name, | 319 | codec_dai->playback.stream_name, |
294 | SND_SOC_DAPM_STREAM_STOP); | 320 | SND_SOC_DAPM_STREAM_STOP); |
295 | |||
296 | /* Fall into standby if no longer active */ | ||
297 | if (codec->active == 0) { | ||
298 | pr_debug("pop wq D3 %s %s\n", codec->name, | ||
299 | codec_dai->playback.stream_name); | ||
300 | snd_soc_dapm_set_bias_level(socdev, | ||
301 | SND_SOC_BIAS_STANDBY); | ||
302 | } | ||
303 | } | 321 | } |
304 | } | 322 | } |
305 | mutex_unlock(&pcm_mutex); | 323 | mutex_unlock(&pcm_mutex); |
@@ -363,10 +381,6 @@ static int soc_codec_close(struct snd_pcm_substream *substream) | |||
363 | snd_soc_dapm_stream_event(codec, | 381 | snd_soc_dapm_stream_event(codec, |
364 | codec_dai->capture.stream_name, | 382 | codec_dai->capture.stream_name, |
365 | SND_SOC_DAPM_STREAM_STOP); | 383 | SND_SOC_DAPM_STREAM_STOP); |
366 | |||
367 | if (codec->active == 0 && codec_dai->pop_wait == 0) | ||
368 | snd_soc_dapm_set_bias_level(socdev, | ||
369 | SND_SOC_BIAS_STANDBY); | ||
370 | } | 384 | } |
371 | 385 | ||
372 | mutex_unlock(&pcm_mutex); | 386 | mutex_unlock(&pcm_mutex); |
@@ -431,36 +445,16 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
431 | cancel_delayed_work(&card->delayed_work); | 445 | cancel_delayed_work(&card->delayed_work); |
432 | } | 446 | } |
433 | 447 | ||
434 | /* do we need to power up codec */ | 448 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
435 | if (codec->bias_level != SND_SOC_BIAS_ON) { | 449 | snd_soc_dapm_stream_event(codec, |
436 | snd_soc_dapm_set_bias_level(socdev, | 450 | codec_dai->playback.stream_name, |
437 | SND_SOC_BIAS_PREPARE); | 451 | SND_SOC_DAPM_STREAM_START); |
438 | 452 | else | |
439 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 453 | snd_soc_dapm_stream_event(codec, |
440 | snd_soc_dapm_stream_event(codec, | 454 | codec_dai->capture.stream_name, |
441 | codec_dai->playback.stream_name, | 455 | SND_SOC_DAPM_STREAM_START); |
442 | SND_SOC_DAPM_STREAM_START); | ||
443 | else | ||
444 | snd_soc_dapm_stream_event(codec, | ||
445 | codec_dai->capture.stream_name, | ||
446 | SND_SOC_DAPM_STREAM_START); | ||
447 | |||
448 | snd_soc_dapm_set_bias_level(socdev, SND_SOC_BIAS_ON); | ||
449 | snd_soc_dai_digital_mute(codec_dai, 0); | ||
450 | |||
451 | } else { | ||
452 | /* codec already powered - power on widgets */ | ||
453 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
454 | snd_soc_dapm_stream_event(codec, | ||
455 | codec_dai->playback.stream_name, | ||
456 | SND_SOC_DAPM_STREAM_START); | ||
457 | else | ||
458 | snd_soc_dapm_stream_event(codec, | ||
459 | codec_dai->capture.stream_name, | ||
460 | SND_SOC_DAPM_STREAM_START); | ||
461 | 456 | ||
462 | snd_soc_dai_digital_mute(codec_dai, 0); | 457 | snd_soc_dai_digital_mute(codec_dai, 0); |
463 | } | ||
464 | 458 | ||
465 | out: | 459 | out: |
466 | mutex_unlock(&pcm_mutex); | 460 | mutex_unlock(&pcm_mutex); |
@@ -521,6 +515,8 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
521 | } | 515 | } |
522 | } | 516 | } |
523 | 517 | ||
518 | machine->rate = params_rate(params); | ||
519 | |||
524 | out: | 520 | out: |
525 | mutex_unlock(&pcm_mutex); | 521 | mutex_unlock(&pcm_mutex); |
526 | return ret; | 522 | return ret; |
@@ -632,6 +628,12 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state) | |||
632 | struct snd_soc_codec *codec = card->codec; | 628 | struct snd_soc_codec *codec = card->codec; |
633 | int i; | 629 | int i; |
634 | 630 | ||
631 | /* If the initialization of this soc device failed, there is no codec | ||
632 | * associated with it. Just bail out in this case. | ||
633 | */ | ||
634 | if (!codec) | ||
635 | return 0; | ||
636 | |||
635 | /* Due to the resume being scheduled into a workqueue we could | 637 | /* Due to the resume being scheduled into a workqueue we could |
636 | * suspend before that's finished - wait for it to complete. | 638 | * suspend before that's finished - wait for it to complete. |
637 | */ | 639 | */ |
@@ -954,6 +956,9 @@ static int soc_remove(struct platform_device *pdev) | |||
954 | struct snd_soc_platform *platform = card->platform; | 956 | struct snd_soc_platform *platform = card->platform; |
955 | struct snd_soc_codec_device *codec_dev = socdev->codec_dev; | 957 | struct snd_soc_codec_device *codec_dev = socdev->codec_dev; |
956 | 958 | ||
959 | if (!card->instantiated) | ||
960 | return 0; | ||
961 | |||
957 | run_delayed_work(&card->delayed_work); | 962 | run_delayed_work(&card->delayed_work); |
958 | 963 | ||
959 | if (platform->remove) | 964 | if (platform->remove) |
@@ -1331,6 +1336,7 @@ int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid) | |||
1331 | return ret; | 1336 | return ret; |
1332 | } | 1337 | } |
1333 | 1338 | ||
1339 | codec->socdev = socdev; | ||
1334 | codec->card->dev = socdev->dev; | 1340 | codec->card->dev = socdev->dev; |
1335 | codec->card->private_data = codec; | 1341 | codec->card->private_data = codec; |
1336 | strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver)); | 1342 | strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver)); |
@@ -1383,6 +1389,9 @@ int snd_soc_init_card(struct snd_soc_device *socdev) | |||
1383 | snprintf(codec->card->longname, sizeof(codec->card->longname), | 1389 | snprintf(codec->card->longname, sizeof(codec->card->longname), |
1384 | "%s (%s)", card->name, codec->name); | 1390 | "%s (%s)", card->name, codec->name); |
1385 | 1391 | ||
1392 | /* Make sure all DAPM widgets are instantiated */ | ||
1393 | snd_soc_dapm_new_widgets(codec); | ||
1394 | |||
1386 | ret = snd_card_register(codec->card); | 1395 | ret = snd_card_register(codec->card); |
1387 | if (ret < 0) { | 1396 | if (ret < 0) { |
1388 | printk(KERN_ERR "asoc: failed to register soundcard for %s\n", | 1397 | printk(KERN_ERR "asoc: failed to register soundcard for %s\n", |
@@ -1741,7 +1750,7 @@ int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, | |||
1741 | { | 1750 | { |
1742 | int max = kcontrol->private_value; | 1751 | int max = kcontrol->private_value; |
1743 | 1752 | ||
1744 | if (max == 1) | 1753 | if (max == 1 && !strstr(kcontrol->id.name, " Volume")) |
1745 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | 1754 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
1746 | else | 1755 | else |
1747 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 1756 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
@@ -1771,7 +1780,7 @@ int snd_soc_info_volsw(struct snd_kcontrol *kcontrol, | |||
1771 | unsigned int shift = mc->shift; | 1780 | unsigned int shift = mc->shift; |
1772 | unsigned int rshift = mc->rshift; | 1781 | unsigned int rshift = mc->rshift; |
1773 | 1782 | ||
1774 | if (max == 1) | 1783 | if (max == 1 && !strstr(kcontrol->id.name, " Volume")) |
1775 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | 1784 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
1776 | else | 1785 | else |
1777 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 1786 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
@@ -1878,7 +1887,7 @@ int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol, | |||
1878 | (struct soc_mixer_control *)kcontrol->private_value; | 1887 | (struct soc_mixer_control *)kcontrol->private_value; |
1879 | int max = mc->max; | 1888 | int max = mc->max; |
1880 | 1889 | ||
1881 | if (max == 1) | 1890 | if (max == 1 && !strstr(kcontrol->id.name, " Volume")) |
1882 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | 1891 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
1883 | else | 1892 | else |
1884 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 1893 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
@@ -2062,7 +2071,7 @@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8); | |||
2062 | int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, | 2071 | int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, |
2063 | unsigned int freq, int dir) | 2072 | unsigned int freq, int dir) |
2064 | { | 2073 | { |
2065 | if (dai->ops->set_sysclk) | 2074 | if (dai->ops && dai->ops->set_sysclk) |
2066 | return dai->ops->set_sysclk(dai, clk_id, freq, dir); | 2075 | return dai->ops->set_sysclk(dai, clk_id, freq, dir); |
2067 | else | 2076 | else |
2068 | return -EINVAL; | 2077 | return -EINVAL; |
@@ -2082,7 +2091,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk); | |||
2082 | int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, | 2091 | int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, |
2083 | int div_id, int div) | 2092 | int div_id, int div) |
2084 | { | 2093 | { |
2085 | if (dai->ops->set_clkdiv) | 2094 | if (dai->ops && dai->ops->set_clkdiv) |
2086 | return dai->ops->set_clkdiv(dai, div_id, div); | 2095 | return dai->ops->set_clkdiv(dai, div_id, div); |
2087 | else | 2096 | else |
2088 | return -EINVAL; | 2097 | return -EINVAL; |
@@ -2101,7 +2110,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv); | |||
2101 | int snd_soc_dai_set_pll(struct snd_soc_dai *dai, | 2110 | int snd_soc_dai_set_pll(struct snd_soc_dai *dai, |
2102 | int pll_id, unsigned int freq_in, unsigned int freq_out) | 2111 | int pll_id, unsigned int freq_in, unsigned int freq_out) |
2103 | { | 2112 | { |
2104 | if (dai->ops->set_pll) | 2113 | if (dai->ops && dai->ops->set_pll) |
2105 | return dai->ops->set_pll(dai, pll_id, freq_in, freq_out); | 2114 | return dai->ops->set_pll(dai, pll_id, freq_in, freq_out); |
2106 | else | 2115 | else |
2107 | return -EINVAL; | 2116 | return -EINVAL; |
@@ -2117,7 +2126,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll); | |||
2117 | */ | 2126 | */ |
2118 | int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | 2127 | int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
2119 | { | 2128 | { |
2120 | if (dai->ops->set_fmt) | 2129 | if (dai->ops && dai->ops->set_fmt) |
2121 | return dai->ops->set_fmt(dai, fmt); | 2130 | return dai->ops->set_fmt(dai, fmt); |
2122 | else | 2131 | else |
2123 | return -EINVAL; | 2132 | return -EINVAL; |
@@ -2136,7 +2145,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt); | |||
2136 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, | 2145 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, |
2137 | unsigned int mask, int slots) | 2146 | unsigned int mask, int slots) |
2138 | { | 2147 | { |
2139 | if (dai->ops->set_sysclk) | 2148 | if (dai->ops && dai->ops->set_tdm_slot) |
2140 | return dai->ops->set_tdm_slot(dai, mask, slots); | 2149 | return dai->ops->set_tdm_slot(dai, mask, slots); |
2141 | else | 2150 | else |
2142 | return -EINVAL; | 2151 | return -EINVAL; |
@@ -2152,7 +2161,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot); | |||
2152 | */ | 2161 | */ |
2153 | int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate) | 2162 | int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate) |
2154 | { | 2163 | { |
2155 | if (dai->ops->set_sysclk) | 2164 | if (dai->ops && dai->ops->set_tristate) |
2156 | return dai->ops->set_tristate(dai, tristate); | 2165 | return dai->ops->set_tristate(dai, tristate); |
2157 | else | 2166 | else |
2158 | return -EINVAL; | 2167 | return -EINVAL; |
@@ -2168,7 +2177,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate); | |||
2168 | */ | 2177 | */ |
2169 | int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute) | 2178 | int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute) |
2170 | { | 2179 | { |
2171 | if (dai->ops->digital_mute) | 2180 | if (dai->ops && dai->ops->digital_mute) |
2172 | return dai->ops->digital_mute(dai, mute); | 2181 | return dai->ops->digital_mute(dai, mute); |
2173 | else | 2182 | else |
2174 | return -EINVAL; | 2183 | return -EINVAL; |
@@ -2349,6 +2358,39 @@ void snd_soc_unregister_platform(struct snd_soc_platform *platform) | |||
2349 | } | 2358 | } |
2350 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); | 2359 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); |
2351 | 2360 | ||
2361 | static u64 codec_format_map[] = { | ||
2362 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE, | ||
2363 | SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE, | ||
2364 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE, | ||
2365 | SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_U24_BE, | ||
2366 | SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE, | ||
2367 | SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE, | ||
2368 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3BE, | ||
2369 | SNDRV_PCM_FMTBIT_U24_3LE | SNDRV_PCM_FMTBIT_U24_3BE, | ||
2370 | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE, | ||
2371 | SNDRV_PCM_FMTBIT_U20_3LE | SNDRV_PCM_FMTBIT_U20_3BE, | ||
2372 | SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE, | ||
2373 | SNDRV_PCM_FMTBIT_U18_3LE | SNDRV_PCM_FMTBIT_U18_3BE, | ||
2374 | SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE, | ||
2375 | SNDRV_PCM_FMTBIT_FLOAT64_LE | SNDRV_PCM_FMTBIT_FLOAT64_BE, | ||
2376 | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE | ||
2377 | | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE, | ||
2378 | }; | ||
2379 | |||
2380 | /* Fix up the DAI formats for endianness: codecs don't actually see | ||
2381 | * the endianness of the data but we're using the CPU format | ||
2382 | * definitions which do need to include endianness so we ensure that | ||
2383 | * codec DAIs always have both big and little endian variants set. | ||
2384 | */ | ||
2385 | static void fixup_codec_formats(struct snd_soc_pcm_stream *stream) | ||
2386 | { | ||
2387 | int i; | ||
2388 | |||
2389 | for (i = 0; i < ARRAY_SIZE(codec_format_map); i++) | ||
2390 | if (stream->formats & codec_format_map[i]) | ||
2391 | stream->formats |= codec_format_map[i]; | ||
2392 | } | ||
2393 | |||
2352 | /** | 2394 | /** |
2353 | * snd_soc_register_codec - Register a codec with the ASoC core | 2395 | * snd_soc_register_codec - Register a codec with the ASoC core |
2354 | * | 2396 | * |
@@ -2356,6 +2398,8 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); | |||
2356 | */ | 2398 | */ |
2357 | int snd_soc_register_codec(struct snd_soc_codec *codec) | 2399 | int snd_soc_register_codec(struct snd_soc_codec *codec) |
2358 | { | 2400 | { |
2401 | int i; | ||
2402 | |||
2359 | if (!codec->name) | 2403 | if (!codec->name) |
2360 | return -EINVAL; | 2404 | return -EINVAL; |
2361 | 2405 | ||
@@ -2365,6 +2409,11 @@ int snd_soc_register_codec(struct snd_soc_codec *codec) | |||
2365 | 2409 | ||
2366 | INIT_LIST_HEAD(&codec->list); | 2410 | INIT_LIST_HEAD(&codec->list); |
2367 | 2411 | ||
2412 | for (i = 0; i < codec->num_dai; i++) { | ||
2413 | fixup_codec_formats(&codec->dai[i].playback); | ||
2414 | fixup_codec_formats(&codec->dai[i].capture); | ||
2415 | } | ||
2416 | |||
2368 | mutex_lock(&client_mutex); | 2417 | mutex_lock(&client_mutex); |
2369 | list_add(&codec->list, &codec_list); | 2418 | list_add(&codec->list, &codec_list); |
2370 | snd_soc_instantiate_cards(); | 2419 | snd_soc_instantiate_cards(); |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 735903a74675..21c69074aa17 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * Features: | 12 | * Features: |
13 | * o Changes power status of internal codec blocks depending on the | 13 | * o Changes power status of internal codec blocks depending on the |
14 | * dynamic configuration of codec internal audio paths and active | 14 | * dynamic configuration of codec internal audio paths and active |
15 | * DAC's/ADC's. | 15 | * DACs/ADCs. |
16 | * o Platform power domain - can support external components i.e. amps and | 16 | * o Platform power domain - can support external components i.e. amps and |
17 | * mic/meadphone insertion events. | 17 | * mic/meadphone insertion events. |
18 | * o Automatic Mic Bias support | 18 | * o Automatic Mic Bias support |
@@ -52,23 +52,21 @@ | |||
52 | 52 | ||
53 | /* dapm power sequences - make this per codec in the future */ | 53 | /* dapm power sequences - make this per codec in the future */ |
54 | static int dapm_up_seq[] = { | 54 | static int dapm_up_seq[] = { |
55 | snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic, | 55 | snd_soc_dapm_pre, snd_soc_dapm_supply, snd_soc_dapm_micbias, |
56 | snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac, | 56 | snd_soc_dapm_mic, snd_soc_dapm_mux, snd_soc_dapm_value_mux, |
57 | snd_soc_dapm_mixer, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_pga, | 57 | snd_soc_dapm_dac, snd_soc_dapm_mixer, snd_soc_dapm_mixer_named_ctl, |
58 | snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_post | 58 | snd_soc_dapm_pga, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, |
59 | snd_soc_dapm_post | ||
59 | }; | 60 | }; |
60 | 61 | ||
61 | static int dapm_down_seq[] = { | 62 | static int dapm_down_seq[] = { |
62 | snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, | 63 | snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, |
63 | snd_soc_dapm_pga, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_mixer, | 64 | snd_soc_dapm_pga, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_mixer, |
64 | snd_soc_dapm_dac, snd_soc_dapm_mic, snd_soc_dapm_micbias, | 65 | snd_soc_dapm_dac, snd_soc_dapm_mic, snd_soc_dapm_micbias, |
65 | snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_post | 66 | snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_supply, |
67 | snd_soc_dapm_post | ||
66 | }; | 68 | }; |
67 | 69 | ||
68 | static int dapm_status = 1; | ||
69 | module_param(dapm_status, int, 0); | ||
70 | MODULE_PARM_DESC(dapm_status, "enable DPM sysfs entries"); | ||
71 | |||
72 | static void pop_wait(u32 pop_time) | 70 | static void pop_wait(u32 pop_time) |
73 | { | 71 | { |
74 | if (pop_time) | 72 | if (pop_time) |
@@ -96,6 +94,48 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget( | |||
96 | return kmemdup(_widget, sizeof(*_widget), GFP_KERNEL); | 94 | return kmemdup(_widget, sizeof(*_widget), GFP_KERNEL); |
97 | } | 95 | } |
98 | 96 | ||
97 | /** | ||
98 | * snd_soc_dapm_set_bias_level - set the bias level for the system | ||
99 | * @socdev: audio device | ||
100 | * @level: level to configure | ||
101 | * | ||
102 | * Configure the bias (power) levels for the SoC audio device. | ||
103 | * | ||
104 | * Returns 0 for success else error. | ||
105 | */ | ||
106 | static int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev, | ||
107 | enum snd_soc_bias_level level) | ||
108 | { | ||
109 | struct snd_soc_card *card = socdev->card; | ||
110 | struct snd_soc_codec *codec = socdev->card->codec; | ||
111 | int ret = 0; | ||
112 | |||
113 | switch (level) { | ||
114 | case SND_SOC_BIAS_ON: | ||
115 | dev_dbg(socdev->dev, "Setting full bias\n"); | ||
116 | break; | ||
117 | case SND_SOC_BIAS_PREPARE: | ||
118 | dev_dbg(socdev->dev, "Setting bias prepare\n"); | ||
119 | break; | ||
120 | case SND_SOC_BIAS_STANDBY: | ||
121 | dev_dbg(socdev->dev, "Setting standby bias\n"); | ||
122 | break; | ||
123 | case SND_SOC_BIAS_OFF: | ||
124 | dev_dbg(socdev->dev, "Setting bias off\n"); | ||
125 | break; | ||
126 | default: | ||
127 | dev_err(socdev->dev, "Setting invalid bias %d\n", level); | ||
128 | return -EINVAL; | ||
129 | } | ||
130 | |||
131 | if (card->set_bias_level) | ||
132 | ret = card->set_bias_level(card, level); | ||
133 | if (ret == 0 && codec->set_bias_level) | ||
134 | ret = codec->set_bias_level(codec, level); | ||
135 | |||
136 | return ret; | ||
137 | } | ||
138 | |||
99 | /* set up initial codec paths */ | 139 | /* set up initial codec paths */ |
100 | static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | 140 | static void dapm_set_path_status(struct snd_soc_dapm_widget *w, |
101 | struct snd_soc_dapm_path *p, int i) | 141 | struct snd_soc_dapm_path *p, int i) |
@@ -165,6 +205,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | |||
165 | case snd_soc_dapm_dac: | 205 | case snd_soc_dapm_dac: |
166 | case snd_soc_dapm_micbias: | 206 | case snd_soc_dapm_micbias: |
167 | case snd_soc_dapm_vmid: | 207 | case snd_soc_dapm_vmid: |
208 | case snd_soc_dapm_supply: | ||
168 | p->connect = 1; | 209 | p->connect = 1; |
169 | break; | 210 | break; |
170 | /* does effect routing - dynamically connected */ | 211 | /* does effect routing - dynamically connected */ |
@@ -179,7 +220,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | |||
179 | } | 220 | } |
180 | } | 221 | } |
181 | 222 | ||
182 | /* connect mux widget to it's interconnecting audio paths */ | 223 | /* connect mux widget to its interconnecting audio paths */ |
183 | static int dapm_connect_mux(struct snd_soc_codec *codec, | 224 | static int dapm_connect_mux(struct snd_soc_codec *codec, |
184 | struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, | 225 | struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, |
185 | struct snd_soc_dapm_path *path, const char *control_name, | 226 | struct snd_soc_dapm_path *path, const char *control_name, |
@@ -202,7 +243,7 @@ static int dapm_connect_mux(struct snd_soc_codec *codec, | |||
202 | return -ENODEV; | 243 | return -ENODEV; |
203 | } | 244 | } |
204 | 245 | ||
205 | /* connect mixer widget to it's interconnecting audio paths */ | 246 | /* connect mixer widget to its interconnecting audio paths */ |
206 | static int dapm_connect_mixer(struct snd_soc_codec *codec, | 247 | static int dapm_connect_mixer(struct snd_soc_codec *codec, |
207 | struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, | 248 | struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, |
208 | struct snd_soc_dapm_path *path, const char *control_name) | 249 | struct snd_soc_dapm_path *path, const char *control_name) |
@@ -357,8 +398,9 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, | |||
357 | path->long_name); | 398 | path->long_name); |
358 | ret = snd_ctl_add(codec->card, path->kcontrol); | 399 | ret = snd_ctl_add(codec->card, path->kcontrol); |
359 | if (ret < 0) { | 400 | if (ret < 0) { |
360 | printk(KERN_ERR "asoc: failed to add dapm kcontrol %s\n", | 401 | printk(KERN_ERR "asoc: failed to add dapm kcontrol %s: %d\n", |
361 | path->long_name); | 402 | path->long_name, |
403 | ret); | ||
362 | kfree(path->long_name); | 404 | kfree(path->long_name); |
363 | path->long_name = NULL; | 405 | path->long_name = NULL; |
364 | return ret; | 406 | return ret; |
@@ -434,6 +476,9 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget) | |||
434 | struct snd_soc_dapm_path *path; | 476 | struct snd_soc_dapm_path *path; |
435 | int con = 0; | 477 | int con = 0; |
436 | 478 | ||
479 | if (widget->id == snd_soc_dapm_supply) | ||
480 | return 0; | ||
481 | |||
437 | if (widget->id == snd_soc_dapm_adc && widget->active) | 482 | if (widget->id == snd_soc_dapm_adc && widget->active) |
438 | return 1; | 483 | return 1; |
439 | 484 | ||
@@ -470,6 +515,9 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget) | |||
470 | struct snd_soc_dapm_path *path; | 515 | struct snd_soc_dapm_path *path; |
471 | int con = 0; | 516 | int con = 0; |
472 | 517 | ||
518 | if (widget->id == snd_soc_dapm_supply) | ||
519 | return 0; | ||
520 | |||
473 | /* active stream ? */ | 521 | /* active stream ? */ |
474 | if (widget->id == snd_soc_dapm_dac && widget->active) | 522 | if (widget->id == snd_soc_dapm_dac && widget->active) |
475 | return 1; | 523 | return 1; |
@@ -521,84 +569,12 @@ int dapm_reg_event(struct snd_soc_dapm_widget *w, | |||
521 | } | 569 | } |
522 | EXPORT_SYMBOL_GPL(dapm_reg_event); | 570 | EXPORT_SYMBOL_GPL(dapm_reg_event); |
523 | 571 | ||
524 | /* | 572 | /* Standard power change method, used to apply power changes to most |
525 | * Scan a single DAPM widget for a complete audio path and update the | 573 | * widgets. |
526 | * power status appropriately. | ||
527 | */ | 574 | */ |
528 | static int dapm_power_widget(struct snd_soc_codec *codec, int event, | 575 | static int dapm_generic_apply_power(struct snd_soc_dapm_widget *w) |
529 | struct snd_soc_dapm_widget *w) | ||
530 | { | 576 | { |
531 | int in, out, power_change, power, ret; | 577 | int ret; |
532 | |||
533 | /* vmid - no action */ | ||
534 | if (w->id == snd_soc_dapm_vmid) | ||
535 | return 0; | ||
536 | |||
537 | /* active ADC */ | ||
538 | if (w->id == snd_soc_dapm_adc && w->active) { | ||
539 | in = is_connected_input_ep(w); | ||
540 | dapm_clear_walk(w->codec); | ||
541 | w->power = (in != 0) ? 1 : 0; | ||
542 | dapm_update_bits(w); | ||
543 | return 0; | ||
544 | } | ||
545 | |||
546 | /* active DAC */ | ||
547 | if (w->id == snd_soc_dapm_dac && w->active) { | ||
548 | out = is_connected_output_ep(w); | ||
549 | dapm_clear_walk(w->codec); | ||
550 | w->power = (out != 0) ? 1 : 0; | ||
551 | dapm_update_bits(w); | ||
552 | return 0; | ||
553 | } | ||
554 | |||
555 | /* pre and post event widgets */ | ||
556 | if (w->id == snd_soc_dapm_pre) { | ||
557 | if (!w->event) | ||
558 | return 0; | ||
559 | |||
560 | if (event == SND_SOC_DAPM_STREAM_START) { | ||
561 | ret = w->event(w, | ||
562 | NULL, SND_SOC_DAPM_PRE_PMU); | ||
563 | if (ret < 0) | ||
564 | return ret; | ||
565 | } else if (event == SND_SOC_DAPM_STREAM_STOP) { | ||
566 | ret = w->event(w, | ||
567 | NULL, SND_SOC_DAPM_PRE_PMD); | ||
568 | if (ret < 0) | ||
569 | return ret; | ||
570 | } | ||
571 | return 0; | ||
572 | } | ||
573 | if (w->id == snd_soc_dapm_post) { | ||
574 | if (!w->event) | ||
575 | return 0; | ||
576 | |||
577 | if (event == SND_SOC_DAPM_STREAM_START) { | ||
578 | ret = w->event(w, | ||
579 | NULL, SND_SOC_DAPM_POST_PMU); | ||
580 | if (ret < 0) | ||
581 | return ret; | ||
582 | } else if (event == SND_SOC_DAPM_STREAM_STOP) { | ||
583 | ret = w->event(w, | ||
584 | NULL, SND_SOC_DAPM_POST_PMD); | ||
585 | if (ret < 0) | ||
586 | return ret; | ||
587 | } | ||
588 | return 0; | ||
589 | } | ||
590 | |||
591 | /* all other widgets */ | ||
592 | in = is_connected_input_ep(w); | ||
593 | dapm_clear_walk(w->codec); | ||
594 | out = is_connected_output_ep(w); | ||
595 | dapm_clear_walk(w->codec); | ||
596 | power = (out != 0 && in != 0) ? 1 : 0; | ||
597 | power_change = (w->power == power) ? 0 : 1; | ||
598 | w->power = power; | ||
599 | |||
600 | if (!power_change) | ||
601 | return 0; | ||
602 | 578 | ||
603 | /* call any power change event handlers */ | 579 | /* call any power change event handlers */ |
604 | if (w->event) | 580 | if (w->event) |
@@ -607,7 +583,7 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event, | |||
607 | w->name, w->event_flags); | 583 | w->name, w->event_flags); |
608 | 584 | ||
609 | /* power up pre event */ | 585 | /* power up pre event */ |
610 | if (power && w->event && | 586 | if (w->power && w->event && |
611 | (w->event_flags & SND_SOC_DAPM_PRE_PMU)) { | 587 | (w->event_flags & SND_SOC_DAPM_PRE_PMU)) { |
612 | ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU); | 588 | ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU); |
613 | if (ret < 0) | 589 | if (ret < 0) |
@@ -615,7 +591,7 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event, | |||
615 | } | 591 | } |
616 | 592 | ||
617 | /* power down pre event */ | 593 | /* power down pre event */ |
618 | if (!power && w->event && | 594 | if (!w->power && w->event && |
619 | (w->event_flags & SND_SOC_DAPM_PRE_PMD)) { | 595 | (w->event_flags & SND_SOC_DAPM_PRE_PMD)) { |
620 | ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD); | 596 | ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD); |
621 | if (ret < 0) | 597 | if (ret < 0) |
@@ -623,17 +599,17 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event, | |||
623 | } | 599 | } |
624 | 600 | ||
625 | /* Lower PGA volume to reduce pops */ | 601 | /* Lower PGA volume to reduce pops */ |
626 | if (w->id == snd_soc_dapm_pga && !power) | 602 | if (w->id == snd_soc_dapm_pga && !w->power) |
627 | dapm_set_pga(w, power); | 603 | dapm_set_pga(w, w->power); |
628 | 604 | ||
629 | dapm_update_bits(w); | 605 | dapm_update_bits(w); |
630 | 606 | ||
631 | /* Raise PGA volume to reduce pops */ | 607 | /* Raise PGA volume to reduce pops */ |
632 | if (w->id == snd_soc_dapm_pga && power) | 608 | if (w->id == snd_soc_dapm_pga && w->power) |
633 | dapm_set_pga(w, power); | 609 | dapm_set_pga(w, w->power); |
634 | 610 | ||
635 | /* power up post event */ | 611 | /* power up post event */ |
636 | if (power && w->event && | 612 | if (w->power && w->event && |
637 | (w->event_flags & SND_SOC_DAPM_POST_PMU)) { | 613 | (w->event_flags & SND_SOC_DAPM_POST_PMU)) { |
638 | ret = w->event(w, | 614 | ret = w->event(w, |
639 | NULL, SND_SOC_DAPM_POST_PMU); | 615 | NULL, SND_SOC_DAPM_POST_PMU); |
@@ -642,7 +618,7 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event, | |||
642 | } | 618 | } |
643 | 619 | ||
644 | /* power down post event */ | 620 | /* power down post event */ |
645 | if (!power && w->event && | 621 | if (!w->power && w->event && |
646 | (w->event_flags & SND_SOC_DAPM_POST_PMD)) { | 622 | (w->event_flags & SND_SOC_DAPM_POST_PMD)) { |
647 | ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD); | 623 | ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD); |
648 | if (ret < 0) | 624 | if (ret < 0) |
@@ -652,6 +628,116 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event, | |||
652 | return 0; | 628 | return 0; |
653 | } | 629 | } |
654 | 630 | ||
631 | /* Generic check to see if a widget should be powered. | ||
632 | */ | ||
633 | static int dapm_generic_check_power(struct snd_soc_dapm_widget *w) | ||
634 | { | ||
635 | int in, out; | ||
636 | |||
637 | in = is_connected_input_ep(w); | ||
638 | dapm_clear_walk(w->codec); | ||
639 | out = is_connected_output_ep(w); | ||
640 | dapm_clear_walk(w->codec); | ||
641 | return out != 0 && in != 0; | ||
642 | } | ||
643 | |||
644 | /* Check to see if an ADC has power */ | ||
645 | static int dapm_adc_check_power(struct snd_soc_dapm_widget *w) | ||
646 | { | ||
647 | int in; | ||
648 | |||
649 | if (w->active) { | ||
650 | in = is_connected_input_ep(w); | ||
651 | dapm_clear_walk(w->codec); | ||
652 | return in != 0; | ||
653 | } else { | ||
654 | return dapm_generic_check_power(w); | ||
655 | } | ||
656 | } | ||
657 | |||
658 | /* Check to see if a DAC has power */ | ||
659 | static int dapm_dac_check_power(struct snd_soc_dapm_widget *w) | ||
660 | { | ||
661 | int out; | ||
662 | |||
663 | if (w->active) { | ||
664 | out = is_connected_output_ep(w); | ||
665 | dapm_clear_walk(w->codec); | ||
666 | return out != 0; | ||
667 | } else { | ||
668 | return dapm_generic_check_power(w); | ||
669 | } | ||
670 | } | ||
671 | |||
672 | /* Check to see if a power supply is needed */ | ||
673 | static int dapm_supply_check_power(struct snd_soc_dapm_widget *w) | ||
674 | { | ||
675 | struct snd_soc_dapm_path *path; | ||
676 | int power = 0; | ||
677 | |||
678 | /* Check if one of our outputs is connected */ | ||
679 | list_for_each_entry(path, &w->sinks, list_source) { | ||
680 | if (path->sink && path->sink->power_check && | ||
681 | path->sink->power_check(path->sink)) { | ||
682 | power = 1; | ||
683 | break; | ||
684 | } | ||
685 | } | ||
686 | |||
687 | dapm_clear_walk(w->codec); | ||
688 | |||
689 | return power; | ||
690 | } | ||
691 | |||
692 | /* | ||
693 | * Scan a single DAPM widget for a complete audio path and update the | ||
694 | * power status appropriately. | ||
695 | */ | ||
696 | static int dapm_power_widget(struct snd_soc_codec *codec, int event, | ||
697 | struct snd_soc_dapm_widget *w) | ||
698 | { | ||
699 | int ret; | ||
700 | |||
701 | switch (w->id) { | ||
702 | case snd_soc_dapm_pre: | ||
703 | if (!w->event) | ||
704 | return 0; | ||
705 | |||
706 | if (event == SND_SOC_DAPM_STREAM_START) { | ||
707 | ret = w->event(w, | ||
708 | NULL, SND_SOC_DAPM_PRE_PMU); | ||
709 | if (ret < 0) | ||
710 | return ret; | ||
711 | } else if (event == SND_SOC_DAPM_STREAM_STOP) { | ||
712 | ret = w->event(w, | ||
713 | NULL, SND_SOC_DAPM_PRE_PMD); | ||
714 | if (ret < 0) | ||
715 | return ret; | ||
716 | } | ||
717 | return 0; | ||
718 | |||
719 | case snd_soc_dapm_post: | ||
720 | if (!w->event) | ||
721 | return 0; | ||
722 | |||
723 | if (event == SND_SOC_DAPM_STREAM_START) { | ||
724 | ret = w->event(w, | ||
725 | NULL, SND_SOC_DAPM_POST_PMU); | ||
726 | if (ret < 0) | ||
727 | return ret; | ||
728 | } else if (event == SND_SOC_DAPM_STREAM_STOP) { | ||
729 | ret = w->event(w, | ||
730 | NULL, SND_SOC_DAPM_POST_PMD); | ||
731 | if (ret < 0) | ||
732 | return ret; | ||
733 | } | ||
734 | return 0; | ||
735 | |||
736 | default: | ||
737 | return dapm_generic_apply_power(w); | ||
738 | } | ||
739 | } | ||
740 | |||
655 | /* | 741 | /* |
656 | * Scan each dapm widget for complete audio path. | 742 | * Scan each dapm widget for complete audio path. |
657 | * A complete path is a route that has valid endpoints i.e.:- | 743 | * A complete path is a route that has valid endpoints i.e.:- |
@@ -663,31 +749,102 @@ static int dapm_power_widget(struct snd_soc_codec *codec, int event, | |||
663 | */ | 749 | */ |
664 | static int dapm_power_widgets(struct snd_soc_codec *codec, int event) | 750 | static int dapm_power_widgets(struct snd_soc_codec *codec, int event) |
665 | { | 751 | { |
752 | struct snd_soc_device *socdev = codec->socdev; | ||
666 | struct snd_soc_dapm_widget *w; | 753 | struct snd_soc_dapm_widget *w; |
667 | int i, c = 1, *seq = NULL, ret = 0; | 754 | int ret = 0; |
668 | 755 | int i, power; | |
669 | /* do we have a sequenced stream event */ | 756 | int sys_power = 0; |
670 | if (event == SND_SOC_DAPM_STREAM_START) { | 757 | |
671 | c = ARRAY_SIZE(dapm_up_seq); | 758 | INIT_LIST_HEAD(&codec->up_list); |
672 | seq = dapm_up_seq; | 759 | INIT_LIST_HEAD(&codec->down_list); |
673 | } else if (event == SND_SOC_DAPM_STREAM_STOP) { | 760 | |
674 | c = ARRAY_SIZE(dapm_down_seq); | 761 | /* Check which widgets we need to power and store them in |
675 | seq = dapm_down_seq; | 762 | * lists indicating if they should be powered up or down. |
763 | */ | ||
764 | list_for_each_entry(w, &codec->dapm_widgets, list) { | ||
765 | switch (w->id) { | ||
766 | case snd_soc_dapm_pre: | ||
767 | list_add_tail(&codec->down_list, &w->power_list); | ||
768 | break; | ||
769 | case snd_soc_dapm_post: | ||
770 | list_add_tail(&codec->up_list, &w->power_list); | ||
771 | break; | ||
772 | |||
773 | default: | ||
774 | if (!w->power_check) | ||
775 | continue; | ||
776 | |||
777 | power = w->power_check(w); | ||
778 | if (power) | ||
779 | sys_power = 1; | ||
780 | |||
781 | if (w->power == power) | ||
782 | continue; | ||
783 | |||
784 | if (power) | ||
785 | list_add_tail(&w->power_list, &codec->up_list); | ||
786 | else | ||
787 | list_add_tail(&w->power_list, | ||
788 | &codec->down_list); | ||
789 | |||
790 | w->power = power; | ||
791 | break; | ||
792 | } | ||
676 | } | 793 | } |
677 | 794 | ||
678 | for (i = 0; i < c; i++) { | 795 | /* If we're changing to all on or all off then prepare */ |
679 | list_for_each_entry(w, &codec->dapm_widgets, list) { | 796 | if ((sys_power && codec->bias_level == SND_SOC_BIAS_STANDBY) || |
797 | (!sys_power && codec->bias_level == SND_SOC_BIAS_ON)) { | ||
798 | ret = snd_soc_dapm_set_bias_level(socdev, | ||
799 | SND_SOC_BIAS_PREPARE); | ||
800 | if (ret != 0) | ||
801 | pr_err("Failed to prepare bias: %d\n", ret); | ||
802 | } | ||
680 | 803 | ||
804 | /* Power down widgets first; try to avoid amplifying pops. */ | ||
805 | for (i = 0; i < ARRAY_SIZE(dapm_down_seq); i++) { | ||
806 | list_for_each_entry(w, &codec->down_list, power_list) { | ||
681 | /* is widget in stream order */ | 807 | /* is widget in stream order */ |
682 | if (seq && seq[i] && w->id != seq[i]) | 808 | if (w->id != dapm_down_seq[i]) |
683 | continue; | 809 | continue; |
684 | 810 | ||
685 | ret = dapm_power_widget(codec, event, w); | 811 | ret = dapm_power_widget(codec, event, w); |
686 | if (ret != 0) | 812 | if (ret != 0) |
687 | return ret; | 813 | pr_err("Failed to power down %s: %d\n", |
814 | w->name, ret); | ||
688 | } | 815 | } |
689 | } | 816 | } |
690 | 817 | ||
818 | /* Now power up. */ | ||
819 | for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++) { | ||
820 | list_for_each_entry(w, &codec->up_list, power_list) { | ||
821 | /* is widget in stream order */ | ||
822 | if (w->id != dapm_up_seq[i]) | ||
823 | continue; | ||
824 | |||
825 | ret = dapm_power_widget(codec, event, w); | ||
826 | if (ret != 0) | ||
827 | pr_err("Failed to power up %s: %d\n", | ||
828 | w->name, ret); | ||
829 | } | ||
830 | } | ||
831 | |||
832 | /* If we just powered the last thing off drop to standby bias */ | ||
833 | if (codec->bias_level == SND_SOC_BIAS_PREPARE && !sys_power) { | ||
834 | ret = snd_soc_dapm_set_bias_level(socdev, | ||
835 | SND_SOC_BIAS_STANDBY); | ||
836 | if (ret != 0) | ||
837 | pr_err("Failed to apply standby bias: %d\n", ret); | ||
838 | } | ||
839 | |||
840 | /* If we just powered up then move to active bias */ | ||
841 | if (codec->bias_level == SND_SOC_BIAS_PREPARE && sys_power) { | ||
842 | ret = snd_soc_dapm_set_bias_level(socdev, | ||
843 | SND_SOC_BIAS_ON); | ||
844 | if (ret != 0) | ||
845 | pr_err("Failed to apply active bias: %d\n", ret); | ||
846 | } | ||
847 | |||
691 | return 0; | 848 | return 0; |
692 | } | 849 | } |
693 | 850 | ||
@@ -723,6 +880,7 @@ static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action) | |||
723 | case snd_soc_dapm_pga: | 880 | case snd_soc_dapm_pga: |
724 | case snd_soc_dapm_mixer: | 881 | case snd_soc_dapm_mixer: |
725 | case snd_soc_dapm_mixer_named_ctl: | 882 | case snd_soc_dapm_mixer_named_ctl: |
883 | case snd_soc_dapm_supply: | ||
726 | if (w->name) { | 884 | if (w->name) { |
727 | in = is_connected_input_ep(w); | 885 | in = is_connected_input_ep(w); |
728 | dapm_clear_walk(w->codec); | 886 | dapm_clear_walk(w->codec); |
@@ -851,6 +1009,7 @@ static ssize_t dapm_widget_show(struct device *dev, | |||
851 | case snd_soc_dapm_pga: | 1009 | case snd_soc_dapm_pga: |
852 | case snd_soc_dapm_mixer: | 1010 | case snd_soc_dapm_mixer: |
853 | case snd_soc_dapm_mixer_named_ctl: | 1011 | case snd_soc_dapm_mixer_named_ctl: |
1012 | case snd_soc_dapm_supply: | ||
854 | if (w->name) | 1013 | if (w->name) |
855 | count += sprintf(buf + count, "%s: %s\n", | 1014 | count += sprintf(buf + count, "%s: %s\n", |
856 | w->name, w->power ? "On":"Off"); | 1015 | w->name, w->power ? "On":"Off"); |
@@ -883,16 +1042,12 @@ static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); | |||
883 | 1042 | ||
884 | int snd_soc_dapm_sys_add(struct device *dev) | 1043 | int snd_soc_dapm_sys_add(struct device *dev) |
885 | { | 1044 | { |
886 | if (!dapm_status) | ||
887 | return 0; | ||
888 | return device_create_file(dev, &dev_attr_dapm_widget); | 1045 | return device_create_file(dev, &dev_attr_dapm_widget); |
889 | } | 1046 | } |
890 | 1047 | ||
891 | static void snd_soc_dapm_sys_remove(struct device *dev) | 1048 | static void snd_soc_dapm_sys_remove(struct device *dev) |
892 | { | 1049 | { |
893 | if (dapm_status) { | 1050 | device_remove_file(dev, &dev_attr_dapm_widget); |
894 | device_remove_file(dev, &dev_attr_dapm_widget); | ||
895 | } | ||
896 | } | 1051 | } |
897 | 1052 | ||
898 | /* free all dapm widgets and resources */ | 1053 | /* free all dapm widgets and resources */ |
@@ -1015,6 +1170,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec, | |||
1015 | case snd_soc_dapm_vmid: | 1170 | case snd_soc_dapm_vmid: |
1016 | case snd_soc_dapm_pre: | 1171 | case snd_soc_dapm_pre: |
1017 | case snd_soc_dapm_post: | 1172 | case snd_soc_dapm_post: |
1173 | case snd_soc_dapm_supply: | ||
1018 | list_add(&path->list, &codec->dapm_paths); | 1174 | list_add(&path->list, &codec->dapm_paths); |
1019 | list_add(&path->list_sink, &wsink->sources); | 1175 | list_add(&path->list_sink, &wsink->sources); |
1020 | list_add(&path->list_source, &wsource->sinks); | 1176 | list_add(&path->list_source, &wsource->sinks); |
@@ -1108,15 +1264,22 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec) | |||
1108 | case snd_soc_dapm_switch: | 1264 | case snd_soc_dapm_switch: |
1109 | case snd_soc_dapm_mixer: | 1265 | case snd_soc_dapm_mixer: |
1110 | case snd_soc_dapm_mixer_named_ctl: | 1266 | case snd_soc_dapm_mixer_named_ctl: |
1267 | w->power_check = dapm_generic_check_power; | ||
1111 | dapm_new_mixer(codec, w); | 1268 | dapm_new_mixer(codec, w); |
1112 | break; | 1269 | break; |
1113 | case snd_soc_dapm_mux: | 1270 | case snd_soc_dapm_mux: |
1114 | case snd_soc_dapm_value_mux: | 1271 | case snd_soc_dapm_value_mux: |
1272 | w->power_check = dapm_generic_check_power; | ||
1115 | dapm_new_mux(codec, w); | 1273 | dapm_new_mux(codec, w); |
1116 | break; | 1274 | break; |
1117 | case snd_soc_dapm_adc: | 1275 | case snd_soc_dapm_adc: |
1276 | w->power_check = dapm_adc_check_power; | ||
1277 | break; | ||
1118 | case snd_soc_dapm_dac: | 1278 | case snd_soc_dapm_dac: |
1279 | w->power_check = dapm_dac_check_power; | ||
1280 | break; | ||
1119 | case snd_soc_dapm_pga: | 1281 | case snd_soc_dapm_pga: |
1282 | w->power_check = dapm_generic_check_power; | ||
1120 | dapm_new_pga(codec, w); | 1283 | dapm_new_pga(codec, w); |
1121 | break; | 1284 | break; |
1122 | case snd_soc_dapm_input: | 1285 | case snd_soc_dapm_input: |
@@ -1126,6 +1289,10 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec) | |||
1126 | case snd_soc_dapm_hp: | 1289 | case snd_soc_dapm_hp: |
1127 | case snd_soc_dapm_mic: | 1290 | case snd_soc_dapm_mic: |
1128 | case snd_soc_dapm_line: | 1291 | case snd_soc_dapm_line: |
1292 | w->power_check = dapm_generic_check_power; | ||
1293 | break; | ||
1294 | case snd_soc_dapm_supply: | ||
1295 | w->power_check = dapm_supply_check_power; | ||
1129 | case snd_soc_dapm_vmid: | 1296 | case snd_soc_dapm_vmid: |
1130 | case snd_soc_dapm_pre: | 1297 | case snd_soc_dapm_pre: |
1131 | case snd_soc_dapm_post: | 1298 | case snd_soc_dapm_post: |
@@ -1626,35 +1793,11 @@ int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, | |||
1626 | EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event); | 1793 | EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event); |
1627 | 1794 | ||
1628 | /** | 1795 | /** |
1629 | * snd_soc_dapm_set_bias_level - set the bias level for the system | ||
1630 | * @socdev: audio device | ||
1631 | * @level: level to configure | ||
1632 | * | ||
1633 | * Configure the bias (power) levels for the SoC audio device. | ||
1634 | * | ||
1635 | * Returns 0 for success else error. | ||
1636 | */ | ||
1637 | int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev, | ||
1638 | enum snd_soc_bias_level level) | ||
1639 | { | ||
1640 | struct snd_soc_card *card = socdev->card; | ||
1641 | struct snd_soc_codec *codec = socdev->card->codec; | ||
1642 | int ret = 0; | ||
1643 | |||
1644 | if (card->set_bias_level) | ||
1645 | ret = card->set_bias_level(card, level); | ||
1646 | if (ret == 0 && codec->set_bias_level) | ||
1647 | ret = codec->set_bias_level(codec, level); | ||
1648 | |||
1649 | return ret; | ||
1650 | } | ||
1651 | |||
1652 | /** | ||
1653 | * snd_soc_dapm_enable_pin - enable pin. | 1796 | * snd_soc_dapm_enable_pin - enable pin. |
1654 | * @codec: SoC codec | 1797 | * @codec: SoC codec |
1655 | * @pin: pin name | 1798 | * @pin: pin name |
1656 | * | 1799 | * |
1657 | * Enables input/output pin and it's parents or children widgets iff there is | 1800 | * Enables input/output pin and its parents or children widgets iff there is |
1658 | * a valid audio route and active audio stream. | 1801 | * a valid audio route and active audio stream. |
1659 | * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to | 1802 | * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to |
1660 | * do any widget power switching. | 1803 | * do any widget power switching. |
@@ -1670,7 +1813,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin); | |||
1670 | * @codec: SoC codec | 1813 | * @codec: SoC codec |
1671 | * @pin: pin name | 1814 | * @pin: pin name |
1672 | * | 1815 | * |
1673 | * Disables input/output pin and it's parents or children widgets. | 1816 | * Disables input/output pin and its parents or children widgets. |
1674 | * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to | 1817 | * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to |
1675 | * do any widget power switching. | 1818 | * do any widget power switching. |
1676 | */ | 1819 | */ |
diff --git a/sound/soc/txx9/Kconfig b/sound/soc/txx9/Kconfig new file mode 100644 index 000000000000..ebc9327eae71 --- /dev/null +++ b/sound/soc/txx9/Kconfig | |||
@@ -0,0 +1,29 @@ | |||
1 | ## | ||
2 | ## TXx9 ACLC | ||
3 | ## | ||
4 | config SND_SOC_TXX9ACLC | ||
5 | tristate "SoC Audio for TXx9" | ||
6 | depends on HAS_TXX9_ACLC && TXX9_DMAC | ||
7 | help | ||
8 | This option enables support for the AC Link Controllers in TXx9 SoC. | ||
9 | |||
10 | config HAS_TXX9_ACLC | ||
11 | bool | ||
12 | |||
13 | config SND_SOC_TXX9ACLC_AC97 | ||
14 | tristate | ||
15 | select AC97_BUS | ||
16 | select SND_AC97_CODEC | ||
17 | select SND_SOC_AC97_BUS | ||
18 | |||
19 | |||
20 | ## | ||
21 | ## Boards | ||
22 | ## | ||
23 | config SND_SOC_TXX9ACLC_GENERIC | ||
24 | tristate "Generic TXx9 ACLC sound machine" | ||
25 | depends on SND_SOC_TXX9ACLC | ||
26 | select SND_SOC_TXX9ACLC_AC97 | ||
27 | select SND_SOC_AC97_CODEC | ||
28 | help | ||
29 | This is a generic AC97 sound machine for use in TXx9 based systems. | ||
diff --git a/sound/soc/txx9/Makefile b/sound/soc/txx9/Makefile new file mode 100644 index 000000000000..551f16c0c4f9 --- /dev/null +++ b/sound/soc/txx9/Makefile | |||
@@ -0,0 +1,11 @@ | |||
1 | # Platform | ||
2 | snd-soc-txx9aclc-objs := txx9aclc.o | ||
3 | snd-soc-txx9aclc-ac97-objs := txx9aclc-ac97.o | ||
4 | |||
5 | obj-$(CONFIG_SND_SOC_TXX9ACLC) += snd-soc-txx9aclc.o | ||
6 | obj-$(CONFIG_SND_SOC_TXX9ACLC_AC97) += snd-soc-txx9aclc-ac97.o | ||
7 | |||
8 | # Machine | ||
9 | snd-soc-txx9aclc-generic-objs := txx9aclc-generic.o | ||
10 | |||
11 | obj-$(CONFIG_SND_SOC_TXX9ACLC_GENERIC) += snd-soc-txx9aclc-generic.o | ||
diff --git a/sound/soc/txx9/txx9aclc-ac97.c b/sound/soc/txx9/txx9aclc-ac97.c new file mode 100644 index 000000000000..0f83bdb9b16f --- /dev/null +++ b/sound/soc/txx9/txx9aclc-ac97.c | |||
@@ -0,0 +1,255 @@ | |||
1 | /* | ||
2 | * TXx9 ACLC AC97 driver | ||
3 | * | ||
4 | * Copyright (C) 2009 Atsushi Nemoto | ||
5 | * | ||
6 | * Based on RBTX49xx patch from CELF patch archive. | ||
7 | * (C) Copyright TOSHIBA CORPORATION 2004-2006 | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/init.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <sound/core.h> | ||
20 | #include <sound/pcm.h> | ||
21 | #include <sound/soc.h> | ||
22 | #include "txx9aclc.h" | ||
23 | |||
24 | #define AC97_DIR \ | ||
25 | (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE) | ||
26 | |||
27 | #define AC97_RATES \ | ||
28 | SNDRV_PCM_RATE_8000_48000 | ||
29 | |||
30 | #ifdef __BIG_ENDIAN | ||
31 | #define AC97_FMTS SNDRV_PCM_FMTBIT_S16_BE | ||
32 | #else | ||
33 | #define AC97_FMTS SNDRV_PCM_FMTBIT_S16_LE | ||
34 | #endif | ||
35 | |||
36 | static DECLARE_WAIT_QUEUE_HEAD(ac97_waitq); | ||
37 | |||
38 | /* REVISIT: How to find txx9aclc_soc_device from snd_ac97? */ | ||
39 | static struct txx9aclc_soc_device *txx9aclc_soc_dev; | ||
40 | |||
41 | static int txx9aclc_regready(struct txx9aclc_soc_device *dev) | ||
42 | { | ||
43 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
44 | |||
45 | return __raw_readl(drvdata->base + ACINTSTS) & ACINT_REGACCRDY; | ||
46 | } | ||
47 | |||
48 | /* AC97 controller reads codec register */ | ||
49 | static unsigned short txx9aclc_ac97_read(struct snd_ac97 *ac97, | ||
50 | unsigned short reg) | ||
51 | { | ||
52 | struct txx9aclc_soc_device *dev = txx9aclc_soc_dev; | ||
53 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
54 | void __iomem *base = drvdata->base; | ||
55 | u32 dat; | ||
56 | |||
57 | if (!(__raw_readl(base + ACINTSTS) & ACINT_CODECRDY(ac97->num))) | ||
58 | return 0xffff; | ||
59 | reg |= ac97->num << 7; | ||
60 | dat = (reg << ACREGACC_REG_SHIFT) | ACREGACC_READ; | ||
61 | __raw_writel(dat, base + ACREGACC); | ||
62 | __raw_writel(ACINT_REGACCRDY, base + ACINTEN); | ||
63 | if (!wait_event_timeout(ac97_waitq, txx9aclc_regready(dev), HZ)) { | ||
64 | __raw_writel(ACINT_REGACCRDY, base + ACINTDIS); | ||
65 | dev_err(dev->soc_dev.dev, "ac97 read timeout (reg %#x)\n", reg); | ||
66 | dat = 0xffff; | ||
67 | goto done; | ||
68 | } | ||
69 | dat = __raw_readl(base + ACREGACC); | ||
70 | if (((dat >> ACREGACC_REG_SHIFT) & 0xff) != reg) { | ||
71 | dev_err(dev->soc_dev.dev, "reg mismatch %x with %x\n", | ||
72 | dat, reg); | ||
73 | dat = 0xffff; | ||
74 | goto done; | ||
75 | } | ||
76 | dat = (dat >> ACREGACC_DAT_SHIFT) & 0xffff; | ||
77 | done: | ||
78 | __raw_writel(ACINT_REGACCRDY, base + ACINTDIS); | ||
79 | return dat; | ||
80 | } | ||
81 | |||
82 | /* AC97 controller writes to codec register */ | ||
83 | static void txx9aclc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | ||
84 | unsigned short val) | ||
85 | { | ||
86 | struct txx9aclc_soc_device *dev = txx9aclc_soc_dev; | ||
87 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
88 | void __iomem *base = drvdata->base; | ||
89 | |||
90 | __raw_writel(((reg | (ac97->num << 7)) << ACREGACC_REG_SHIFT) | | ||
91 | (val << ACREGACC_DAT_SHIFT), | ||
92 | base + ACREGACC); | ||
93 | __raw_writel(ACINT_REGACCRDY, base + ACINTEN); | ||
94 | if (!wait_event_timeout(ac97_waitq, txx9aclc_regready(dev), HZ)) { | ||
95 | dev_err(dev->soc_dev.dev, | ||
96 | "ac97 write timeout (reg %#x)\n", reg); | ||
97 | } | ||
98 | __raw_writel(ACINT_REGACCRDY, base + ACINTDIS); | ||
99 | } | ||
100 | |||
101 | static void txx9aclc_ac97_cold_reset(struct snd_ac97 *ac97) | ||
102 | { | ||
103 | struct txx9aclc_soc_device *dev = txx9aclc_soc_dev; | ||
104 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
105 | void __iomem *base = drvdata->base; | ||
106 | u32 ready = ACINT_CODECRDY(ac97->num) | ACINT_REGACCRDY; | ||
107 | |||
108 | __raw_writel(ACCTL_ENLINK, base + ACCTLDIS); | ||
109 | mmiowb(); | ||
110 | udelay(1); | ||
111 | __raw_writel(ACCTL_ENLINK, base + ACCTLEN); | ||
112 | /* wait for primary codec ready status */ | ||
113 | __raw_writel(ready, base + ACINTEN); | ||
114 | if (!wait_event_timeout(ac97_waitq, | ||
115 | (__raw_readl(base + ACINTSTS) & ready) == ready, | ||
116 | HZ)) { | ||
117 | dev_err(&ac97->dev, "primary codec is not ready " | ||
118 | "(status %#x)\n", | ||
119 | __raw_readl(base + ACINTSTS)); | ||
120 | } | ||
121 | __raw_writel(ACINT_REGACCRDY, base + ACINTSTS); | ||
122 | __raw_writel(ready, base + ACINTDIS); | ||
123 | } | ||
124 | |||
125 | /* AC97 controller operations */ | ||
126 | struct snd_ac97_bus_ops soc_ac97_ops = { | ||
127 | .read = txx9aclc_ac97_read, | ||
128 | .write = txx9aclc_ac97_write, | ||
129 | .reset = txx9aclc_ac97_cold_reset, | ||
130 | }; | ||
131 | EXPORT_SYMBOL_GPL(soc_ac97_ops); | ||
132 | |||
133 | static irqreturn_t txx9aclc_ac97_irq(int irq, void *dev_id) | ||
134 | { | ||
135 | struct txx9aclc_plat_drvdata *drvdata = dev_id; | ||
136 | void __iomem *base = drvdata->base; | ||
137 | |||
138 | __raw_writel(__raw_readl(base + ACINTMSTS), base + ACINTDIS); | ||
139 | wake_up(&ac97_waitq); | ||
140 | return IRQ_HANDLED; | ||
141 | } | ||
142 | |||
143 | static int txx9aclc_ac97_probe(struct platform_device *pdev, | ||
144 | struct snd_soc_dai *dai) | ||
145 | { | ||
146 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
147 | struct txx9aclc_soc_device *dev = | ||
148 | container_of(socdev, struct txx9aclc_soc_device, soc_dev); | ||
149 | |||
150 | dev->aclc_pdev = to_platform_device(dai->dev); | ||
151 | txx9aclc_soc_dev = dev; | ||
152 | return 0; | ||
153 | } | ||
154 | |||
155 | static void txx9aclc_ac97_remove(struct platform_device *pdev, | ||
156 | struct snd_soc_dai *dai) | ||
157 | { | ||
158 | struct platform_device *aclc_pdev = to_platform_device(dai->dev); | ||
159 | struct txx9aclc_plat_drvdata *drvdata = platform_get_drvdata(aclc_pdev); | ||
160 | |||
161 | /* disable AC-link */ | ||
162 | __raw_writel(ACCTL_ENLINK, drvdata->base + ACCTLDIS); | ||
163 | txx9aclc_soc_dev = NULL; | ||
164 | } | ||
165 | |||
166 | struct snd_soc_dai txx9aclc_ac97_dai = { | ||
167 | .name = "txx9aclc_ac97", | ||
168 | .ac97_control = 1, | ||
169 | .probe = txx9aclc_ac97_probe, | ||
170 | .remove = txx9aclc_ac97_remove, | ||
171 | .playback = { | ||
172 | .rates = AC97_RATES, | ||
173 | .formats = AC97_FMTS, | ||
174 | .channels_min = 2, | ||
175 | .channels_max = 2, | ||
176 | }, | ||
177 | .capture = { | ||
178 | .rates = AC97_RATES, | ||
179 | .formats = AC97_FMTS, | ||
180 | .channels_min = 2, | ||
181 | .channels_max = 2, | ||
182 | }, | ||
183 | }; | ||
184 | EXPORT_SYMBOL_GPL(txx9aclc_ac97_dai); | ||
185 | |||
186 | static int __devinit txx9aclc_ac97_dev_probe(struct platform_device *pdev) | ||
187 | { | ||
188 | struct txx9aclc_plat_drvdata *drvdata; | ||
189 | struct resource *r; | ||
190 | int err; | ||
191 | int irq; | ||
192 | |||
193 | irq = platform_get_irq(pdev, 0); | ||
194 | if (irq < 0) | ||
195 | return irq; | ||
196 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
197 | if (!r) | ||
198 | return -EBUSY; | ||
199 | |||
200 | if (!devm_request_mem_region(&pdev->dev, r->start, resource_size(r), | ||
201 | dev_name(&pdev->dev))) | ||
202 | return -EBUSY; | ||
203 | |||
204 | drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); | ||
205 | if (!drvdata) | ||
206 | return -ENOMEM; | ||
207 | platform_set_drvdata(pdev, drvdata); | ||
208 | drvdata->physbase = r->start; | ||
209 | if (sizeof(drvdata->physbase) > sizeof(r->start) && | ||
210 | r->start >= TXX9_DIRECTMAP_BASE && | ||
211 | r->start < TXX9_DIRECTMAP_BASE + 0x400000) | ||
212 | drvdata->physbase |= 0xf00000000ull; | ||
213 | drvdata->base = devm_ioremap(&pdev->dev, r->start, resource_size(r)); | ||
214 | if (!drvdata->base) | ||
215 | return -EBUSY; | ||
216 | err = devm_request_irq(&pdev->dev, irq, txx9aclc_ac97_irq, | ||
217 | IRQF_DISABLED, dev_name(&pdev->dev), drvdata); | ||
218 | if (err < 0) | ||
219 | return err; | ||
220 | |||
221 | txx9aclc_ac97_dai.dev = &pdev->dev; | ||
222 | return snd_soc_register_dai(&txx9aclc_ac97_dai); | ||
223 | } | ||
224 | |||
225 | static int __devexit txx9aclc_ac97_dev_remove(struct platform_device *pdev) | ||
226 | { | ||
227 | snd_soc_unregister_dai(&txx9aclc_ac97_dai); | ||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static struct platform_driver txx9aclc_ac97_driver = { | ||
232 | .probe = txx9aclc_ac97_dev_probe, | ||
233 | .remove = __devexit_p(txx9aclc_ac97_dev_remove), | ||
234 | .driver = { | ||
235 | .name = "txx9aclc-ac97", | ||
236 | .owner = THIS_MODULE, | ||
237 | }, | ||
238 | }; | ||
239 | |||
240 | static int __init txx9aclc_ac97_init(void) | ||
241 | { | ||
242 | return platform_driver_register(&txx9aclc_ac97_driver); | ||
243 | } | ||
244 | |||
245 | static void __exit txx9aclc_ac97_exit(void) | ||
246 | { | ||
247 | platform_driver_unregister(&txx9aclc_ac97_driver); | ||
248 | } | ||
249 | |||
250 | module_init(txx9aclc_ac97_init); | ||
251 | module_exit(txx9aclc_ac97_exit); | ||
252 | |||
253 | MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); | ||
254 | MODULE_DESCRIPTION("TXx9 ACLC AC97 driver"); | ||
255 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/txx9/txx9aclc-generic.c b/sound/soc/txx9/txx9aclc-generic.c new file mode 100644 index 000000000000..3175de9a92cb --- /dev/null +++ b/sound/soc/txx9/txx9aclc-generic.c | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | * Generic TXx9 ACLC machine driver | ||
3 | * | ||
4 | * Copyright (C) 2009 Atsushi Nemoto | ||
5 | * | ||
6 | * Based on RBTX49xx patch from CELF patch archive. | ||
7 | * (C) Copyright TOSHIBA CORPORATION 2004-2006 | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | * This is a very generic AC97 sound machine driver for boards which | ||
14 | * have (AC97) audio at ACLC (e.g. RBTX49XX boards). | ||
15 | */ | ||
16 | |||
17 | #include <linux/module.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <sound/core.h> | ||
20 | #include <sound/pcm.h> | ||
21 | #include <sound/soc.h> | ||
22 | #include "../codecs/ac97.h" | ||
23 | #include "txx9aclc.h" | ||
24 | |||
25 | static struct snd_soc_dai_link txx9aclc_generic_dai = { | ||
26 | .name = "AC97", | ||
27 | .stream_name = "AC97 HiFi", | ||
28 | .cpu_dai = &txx9aclc_ac97_dai, | ||
29 | .codec_dai = &ac97_dai, | ||
30 | }; | ||
31 | |||
32 | static struct snd_soc_card txx9aclc_generic_card = { | ||
33 | .name = "Generic TXx9 ACLC Audio", | ||
34 | .platform = &txx9aclc_soc_platform, | ||
35 | .dai_link = &txx9aclc_generic_dai, | ||
36 | .num_links = 1, | ||
37 | }; | ||
38 | |||
39 | static struct txx9aclc_soc_device txx9aclc_generic_soc_device = { | ||
40 | .soc_dev = { | ||
41 | .card = &txx9aclc_generic_card, | ||
42 | .codec_dev = &soc_codec_dev_ac97, | ||
43 | }, | ||
44 | }; | ||
45 | |||
46 | static int __init txx9aclc_generic_probe(struct platform_device *pdev) | ||
47 | { | ||
48 | struct txx9aclc_soc_device *dev = &txx9aclc_generic_soc_device; | ||
49 | struct platform_device *soc_pdev; | ||
50 | int ret; | ||
51 | |||
52 | soc_pdev = platform_device_alloc("soc-audio", -1); | ||
53 | if (!soc_pdev) | ||
54 | return -ENOMEM; | ||
55 | platform_set_drvdata(soc_pdev, &dev->soc_dev); | ||
56 | dev->soc_dev.dev = &soc_pdev->dev; | ||
57 | ret = platform_device_add(soc_pdev); | ||
58 | if (ret) { | ||
59 | platform_device_put(soc_pdev); | ||
60 | return ret; | ||
61 | } | ||
62 | platform_set_drvdata(pdev, soc_pdev); | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | static int __exit txx9aclc_generic_remove(struct platform_device *pdev) | ||
67 | { | ||
68 | struct platform_device *soc_pdev = platform_get_drvdata(pdev); | ||
69 | |||
70 | platform_device_unregister(soc_pdev); | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static struct platform_driver txx9aclc_generic_driver = { | ||
75 | .remove = txx9aclc_generic_remove, | ||
76 | .driver = { | ||
77 | .name = "txx9aclc-generic", | ||
78 | .owner = THIS_MODULE, | ||
79 | }, | ||
80 | }; | ||
81 | |||
82 | static int __init txx9aclc_generic_init(void) | ||
83 | { | ||
84 | return platform_driver_probe(&txx9aclc_generic_driver, | ||
85 | txx9aclc_generic_probe); | ||
86 | } | ||
87 | |||
88 | static void __exit txx9aclc_generic_exit(void) | ||
89 | { | ||
90 | platform_driver_unregister(&txx9aclc_generic_driver); | ||
91 | } | ||
92 | |||
93 | module_init(txx9aclc_generic_init); | ||
94 | module_exit(txx9aclc_generic_exit); | ||
95 | |||
96 | MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); | ||
97 | MODULE_DESCRIPTION("Generic TXx9 ACLC ALSA SoC audio driver"); | ||
98 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c new file mode 100644 index 000000000000..fa336616152e --- /dev/null +++ b/sound/soc/txx9/txx9aclc.c | |||
@@ -0,0 +1,430 @@ | |||
1 | /* | ||
2 | * Generic TXx9 ACLC platform driver | ||
3 | * | ||
4 | * Copyright (C) 2009 Atsushi Nemoto | ||
5 | * | ||
6 | * Based on RBTX49xx patch from CELF patch archive. | ||
7 | * (C) Copyright TOSHIBA CORPORATION 2004-2006 | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/scatterlist.h> | ||
18 | #include <sound/core.h> | ||
19 | #include <sound/pcm.h> | ||
20 | #include <sound/pcm_params.h> | ||
21 | #include <sound/soc.h> | ||
22 | #include "txx9aclc.h" | ||
23 | |||
24 | static const struct snd_pcm_hardware txx9aclc_pcm_hardware = { | ||
25 | /* | ||
26 | * REVISIT: SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | ||
27 | * needs more works for noncoherent MIPS. | ||
28 | */ | ||
29 | .info = SNDRV_PCM_INFO_INTERLEAVED | | ||
30 | SNDRV_PCM_INFO_BATCH | | ||
31 | SNDRV_PCM_INFO_PAUSE, | ||
32 | #ifdef __BIG_ENDIAN | ||
33 | .formats = SNDRV_PCM_FMTBIT_S16_BE, | ||
34 | #else | ||
35 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
36 | #endif | ||
37 | .period_bytes_min = 1024, | ||
38 | .period_bytes_max = 8 * 1024, | ||
39 | .periods_min = 2, | ||
40 | .periods_max = 4096, | ||
41 | .buffer_bytes_max = 32 * 1024, | ||
42 | }; | ||
43 | |||
44 | static int txx9aclc_pcm_hw_params(struct snd_pcm_substream *substream, | ||
45 | struct snd_pcm_hw_params *params) | ||
46 | { | ||
47 | struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); | ||
48 | struct snd_soc_device *socdev = rtd->socdev; | ||
49 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
50 | struct txx9aclc_dmadata *dmadata = runtime->private_data; | ||
51 | int ret; | ||
52 | |||
53 | ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); | ||
54 | if (ret < 0) | ||
55 | return ret; | ||
56 | |||
57 | dev_dbg(socdev->dev, | ||
58 | "runtime->dma_area = %#lx dma_addr = %#lx dma_bytes = %zd " | ||
59 | "runtime->min_align %ld\n", | ||
60 | (unsigned long)runtime->dma_area, | ||
61 | (unsigned long)runtime->dma_addr, runtime->dma_bytes, | ||
62 | runtime->min_align); | ||
63 | dev_dbg(socdev->dev, | ||
64 | "periods %d period_bytes %d stream %d\n", | ||
65 | params_periods(params), params_period_bytes(params), | ||
66 | substream->stream); | ||
67 | |||
68 | dmadata->substream = substream; | ||
69 | dmadata->pos = 0; | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | static int txx9aclc_pcm_hw_free(struct snd_pcm_substream *substream) | ||
74 | { | ||
75 | return snd_pcm_lib_free_pages(substream); | ||
76 | } | ||
77 | |||
78 | static int txx9aclc_pcm_prepare(struct snd_pcm_substream *substream) | ||
79 | { | ||
80 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
81 | struct txx9aclc_dmadata *dmadata = runtime->private_data; | ||
82 | |||
83 | dmadata->dma_addr = runtime->dma_addr; | ||
84 | dmadata->buffer_bytes = snd_pcm_lib_buffer_bytes(substream); | ||
85 | dmadata->period_bytes = snd_pcm_lib_period_bytes(substream); | ||
86 | |||
87 | if (dmadata->buffer_bytes == dmadata->period_bytes) { | ||
88 | dmadata->frag_bytes = dmadata->period_bytes >> 1; | ||
89 | dmadata->frags = 2; | ||
90 | } else { | ||
91 | dmadata->frag_bytes = dmadata->period_bytes; | ||
92 | dmadata->frags = dmadata->buffer_bytes / dmadata->period_bytes; | ||
93 | } | ||
94 | dmadata->frag_count = 0; | ||
95 | dmadata->pos = 0; | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static void txx9aclc_dma_complete(void *arg) | ||
100 | { | ||
101 | struct txx9aclc_dmadata *dmadata = arg; | ||
102 | unsigned long flags; | ||
103 | |||
104 | /* dma completion handler cannot submit new operations */ | ||
105 | spin_lock_irqsave(&dmadata->dma_lock, flags); | ||
106 | if (dmadata->frag_count >= 0) { | ||
107 | dmadata->dmacount--; | ||
108 | BUG_ON(dmadata->dmacount < 0); | ||
109 | tasklet_schedule(&dmadata->tasklet); | ||
110 | } | ||
111 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); | ||
112 | } | ||
113 | |||
114 | static struct dma_async_tx_descriptor * | ||
115 | txx9aclc_dma_submit(struct txx9aclc_dmadata *dmadata, dma_addr_t buf_dma_addr) | ||
116 | { | ||
117 | struct dma_chan *chan = dmadata->dma_chan; | ||
118 | struct dma_async_tx_descriptor *desc; | ||
119 | struct scatterlist sg; | ||
120 | |||
121 | sg_init_table(&sg, 1); | ||
122 | sg_set_page(&sg, pfn_to_page(PFN_DOWN(buf_dma_addr)), | ||
123 | dmadata->frag_bytes, buf_dma_addr & (PAGE_SIZE - 1)); | ||
124 | sg_dma_address(&sg) = buf_dma_addr; | ||
125 | desc = chan->device->device_prep_slave_sg(chan, &sg, 1, | ||
126 | dmadata->substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? | ||
127 | DMA_TO_DEVICE : DMA_FROM_DEVICE, | ||
128 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | ||
129 | if (!desc) { | ||
130 | dev_err(&chan->dev->device, "cannot prepare slave dma\n"); | ||
131 | return NULL; | ||
132 | } | ||
133 | desc->callback = txx9aclc_dma_complete; | ||
134 | desc->callback_param = dmadata; | ||
135 | desc->tx_submit(desc); | ||
136 | return desc; | ||
137 | } | ||
138 | |||
139 | #define NR_DMA_CHAIN 2 | ||
140 | |||
141 | static void txx9aclc_dma_tasklet(unsigned long data) | ||
142 | { | ||
143 | struct txx9aclc_dmadata *dmadata = (struct txx9aclc_dmadata *)data; | ||
144 | struct dma_chan *chan = dmadata->dma_chan; | ||
145 | struct dma_async_tx_descriptor *desc; | ||
146 | struct snd_pcm_substream *substream = dmadata->substream; | ||
147 | u32 ctlbit = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? | ||
148 | ACCTL_AUDODMA : ACCTL_AUDIDMA; | ||
149 | int i; | ||
150 | unsigned long flags; | ||
151 | |||
152 | spin_lock_irqsave(&dmadata->dma_lock, flags); | ||
153 | if (dmadata->frag_count < 0) { | ||
154 | struct txx9aclc_soc_device *dev = | ||
155 | container_of(dmadata, struct txx9aclc_soc_device, | ||
156 | dmadata[substream->stream]); | ||
157 | struct txx9aclc_plat_drvdata *drvdata = | ||
158 | txx9aclc_get_plat_drvdata(dev); | ||
159 | void __iomem *base = drvdata->base; | ||
160 | |||
161 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); | ||
162 | chan->device->device_terminate_all(chan); | ||
163 | /* first time */ | ||
164 | for (i = 0; i < NR_DMA_CHAIN; i++) { | ||
165 | desc = txx9aclc_dma_submit(dmadata, | ||
166 | dmadata->dma_addr + i * dmadata->frag_bytes); | ||
167 | if (!desc) | ||
168 | return; | ||
169 | } | ||
170 | dmadata->dmacount = NR_DMA_CHAIN; | ||
171 | chan->device->device_issue_pending(chan); | ||
172 | spin_lock_irqsave(&dmadata->dma_lock, flags); | ||
173 | __raw_writel(ctlbit, base + ACCTLEN); | ||
174 | dmadata->frag_count = NR_DMA_CHAIN % dmadata->frags; | ||
175 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); | ||
176 | return; | ||
177 | } | ||
178 | BUG_ON(dmadata->dmacount >= NR_DMA_CHAIN); | ||
179 | while (dmadata->dmacount < NR_DMA_CHAIN) { | ||
180 | dmadata->dmacount++; | ||
181 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); | ||
182 | desc = txx9aclc_dma_submit(dmadata, | ||
183 | dmadata->dma_addr + | ||
184 | dmadata->frag_count * dmadata->frag_bytes); | ||
185 | if (!desc) | ||
186 | return; | ||
187 | chan->device->device_issue_pending(chan); | ||
188 | |||
189 | spin_lock_irqsave(&dmadata->dma_lock, flags); | ||
190 | dmadata->frag_count++; | ||
191 | dmadata->frag_count %= dmadata->frags; | ||
192 | dmadata->pos += dmadata->frag_bytes; | ||
193 | dmadata->pos %= dmadata->buffer_bytes; | ||
194 | if ((dmadata->frag_count * dmadata->frag_bytes) % | ||
195 | dmadata->period_bytes == 0) | ||
196 | snd_pcm_period_elapsed(substream); | ||
197 | } | ||
198 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); | ||
199 | } | ||
200 | |||
201 | static int txx9aclc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
202 | { | ||
203 | struct txx9aclc_dmadata *dmadata = substream->runtime->private_data; | ||
204 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
205 | struct txx9aclc_soc_device *dev = | ||
206 | container_of(rtd->socdev, struct txx9aclc_soc_device, soc_dev); | ||
207 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
208 | void __iomem *base = drvdata->base; | ||
209 | unsigned long flags; | ||
210 | int ret = 0; | ||
211 | u32 ctlbit = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? | ||
212 | ACCTL_AUDODMA : ACCTL_AUDIDMA; | ||
213 | |||
214 | spin_lock_irqsave(&dmadata->dma_lock, flags); | ||
215 | switch (cmd) { | ||
216 | case SNDRV_PCM_TRIGGER_START: | ||
217 | dmadata->frag_count = -1; | ||
218 | tasklet_schedule(&dmadata->tasklet); | ||
219 | break; | ||
220 | case SNDRV_PCM_TRIGGER_STOP: | ||
221 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
222 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
223 | __raw_writel(ctlbit, base + ACCTLDIS); | ||
224 | break; | ||
225 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
226 | case SNDRV_PCM_TRIGGER_RESUME: | ||
227 | __raw_writel(ctlbit, base + ACCTLEN); | ||
228 | break; | ||
229 | default: | ||
230 | ret = -EINVAL; | ||
231 | } | ||
232 | spin_unlock_irqrestore(&dmadata->dma_lock, flags); | ||
233 | return ret; | ||
234 | } | ||
235 | |||
236 | static snd_pcm_uframes_t | ||
237 | txx9aclc_pcm_pointer(struct snd_pcm_substream *substream) | ||
238 | { | ||
239 | struct txx9aclc_dmadata *dmadata = substream->runtime->private_data; | ||
240 | |||
241 | return bytes_to_frames(substream->runtime, dmadata->pos); | ||
242 | } | ||
243 | |||
244 | static int txx9aclc_pcm_open(struct snd_pcm_substream *substream) | ||
245 | { | ||
246 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
247 | struct txx9aclc_soc_device *dev = | ||
248 | container_of(rtd->socdev, struct txx9aclc_soc_device, soc_dev); | ||
249 | struct txx9aclc_dmadata *dmadata = &dev->dmadata[substream->stream]; | ||
250 | int ret; | ||
251 | |||
252 | ret = snd_soc_set_runtime_hwparams(substream, &txx9aclc_pcm_hardware); | ||
253 | if (ret) | ||
254 | return ret; | ||
255 | /* ensure that buffer size is a multiple of period size */ | ||
256 | ret = snd_pcm_hw_constraint_integer(substream->runtime, | ||
257 | SNDRV_PCM_HW_PARAM_PERIODS); | ||
258 | if (ret < 0) | ||
259 | return ret; | ||
260 | substream->runtime->private_data = dmadata; | ||
261 | return 0; | ||
262 | } | ||
263 | |||
264 | static int txx9aclc_pcm_close(struct snd_pcm_substream *substream) | ||
265 | { | ||
266 | struct txx9aclc_dmadata *dmadata = substream->runtime->private_data; | ||
267 | struct dma_chan *chan = dmadata->dma_chan; | ||
268 | |||
269 | dmadata->frag_count = -1; | ||
270 | chan->device->device_terminate_all(chan); | ||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | static struct snd_pcm_ops txx9aclc_pcm_ops = { | ||
275 | .open = txx9aclc_pcm_open, | ||
276 | .close = txx9aclc_pcm_close, | ||
277 | .ioctl = snd_pcm_lib_ioctl, | ||
278 | .hw_params = txx9aclc_pcm_hw_params, | ||
279 | .hw_free = txx9aclc_pcm_hw_free, | ||
280 | .prepare = txx9aclc_pcm_prepare, | ||
281 | .trigger = txx9aclc_pcm_trigger, | ||
282 | .pointer = txx9aclc_pcm_pointer, | ||
283 | }; | ||
284 | |||
285 | static void txx9aclc_pcm_free_dma_buffers(struct snd_pcm *pcm) | ||
286 | { | ||
287 | snd_pcm_lib_preallocate_free_for_all(pcm); | ||
288 | } | ||
289 | |||
290 | static int txx9aclc_pcm_new(struct snd_card *card, struct snd_soc_dai *dai, | ||
291 | struct snd_pcm *pcm) | ||
292 | { | ||
293 | return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | ||
294 | card->dev, 64 * 1024, 4 * 1024 * 1024); | ||
295 | } | ||
296 | |||
297 | static bool filter(struct dma_chan *chan, void *param) | ||
298 | { | ||
299 | struct txx9aclc_dmadata *dmadata = param; | ||
300 | char devname[BUS_ID_SIZE + 2]; | ||
301 | |||
302 | sprintf(devname, "%s.%d", dmadata->dma_res->name, | ||
303 | (int)dmadata->dma_res->start); | ||
304 | if (strcmp(dev_name(chan->device->dev), devname) == 0) { | ||
305 | chan->private = &dmadata->dma_slave; | ||
306 | return true; | ||
307 | } | ||
308 | return false; | ||
309 | } | ||
310 | |||
311 | static int txx9aclc_dma_init(struct txx9aclc_soc_device *dev, | ||
312 | struct txx9aclc_dmadata *dmadata) | ||
313 | { | ||
314 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
315 | struct txx9dmac_slave *ds = &dmadata->dma_slave; | ||
316 | dma_cap_mask_t mask; | ||
317 | |||
318 | spin_lock_init(&dmadata->dma_lock); | ||
319 | |||
320 | ds->reg_width = sizeof(u32); | ||
321 | if (dmadata->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
322 | ds->tx_reg = drvdata->physbase + ACAUDODAT; | ||
323 | ds->rx_reg = 0; | ||
324 | } else { | ||
325 | ds->tx_reg = 0; | ||
326 | ds->rx_reg = drvdata->physbase + ACAUDIDAT; | ||
327 | } | ||
328 | |||
329 | /* Try to grab a DMA channel */ | ||
330 | dma_cap_zero(mask); | ||
331 | dma_cap_set(DMA_SLAVE, mask); | ||
332 | dmadata->dma_chan = dma_request_channel(mask, filter, dmadata); | ||
333 | if (!dmadata->dma_chan) { | ||
334 | dev_err(dev->soc_dev.dev, | ||
335 | "DMA channel for %s is not available\n", | ||
336 | dmadata->stream == SNDRV_PCM_STREAM_PLAYBACK ? | ||
337 | "playback" : "capture"); | ||
338 | return -EBUSY; | ||
339 | } | ||
340 | tasklet_init(&dmadata->tasklet, txx9aclc_dma_tasklet, | ||
341 | (unsigned long)dmadata); | ||
342 | return 0; | ||
343 | } | ||
344 | |||
345 | static int txx9aclc_pcm_probe(struct platform_device *pdev) | ||
346 | { | ||
347 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
348 | struct txx9aclc_soc_device *dev = | ||
349 | container_of(socdev, struct txx9aclc_soc_device, soc_dev); | ||
350 | struct resource *r; | ||
351 | int i; | ||
352 | int ret; | ||
353 | |||
354 | dev->dmadata[0].stream = SNDRV_PCM_STREAM_PLAYBACK; | ||
355 | dev->dmadata[1].stream = SNDRV_PCM_STREAM_CAPTURE; | ||
356 | for (i = 0; i < 2; i++) { | ||
357 | r = platform_get_resource(dev->aclc_pdev, IORESOURCE_DMA, i); | ||
358 | if (!r) { | ||
359 | ret = -EBUSY; | ||
360 | goto exit; | ||
361 | } | ||
362 | dev->dmadata[i].dma_res = r; | ||
363 | ret = txx9aclc_dma_init(dev, &dev->dmadata[i]); | ||
364 | if (ret) | ||
365 | goto exit; | ||
366 | } | ||
367 | return 0; | ||
368 | |||
369 | exit: | ||
370 | for (i = 0; i < 2; i++) { | ||
371 | if (dev->dmadata[i].dma_chan) | ||
372 | dma_release_channel(dev->dmadata[i].dma_chan); | ||
373 | dev->dmadata[i].dma_chan = NULL; | ||
374 | } | ||
375 | return ret; | ||
376 | } | ||
377 | |||
378 | static int txx9aclc_pcm_remove(struct platform_device *pdev) | ||
379 | { | ||
380 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
381 | struct txx9aclc_soc_device *dev = | ||
382 | container_of(socdev, struct txx9aclc_soc_device, soc_dev); | ||
383 | struct txx9aclc_plat_drvdata *drvdata = txx9aclc_get_plat_drvdata(dev); | ||
384 | void __iomem *base = drvdata->base; | ||
385 | int i; | ||
386 | |||
387 | /* disable all FIFO DMAs */ | ||
388 | __raw_writel(ACCTL_AUDODMA | ACCTL_AUDIDMA, base + ACCTLDIS); | ||
389 | /* dummy R/W to clear pending DMAREQ if any */ | ||
390 | __raw_writel(__raw_readl(base + ACAUDIDAT), base + ACAUDODAT); | ||
391 | |||
392 | for (i = 0; i < 2; i++) { | ||
393 | struct txx9aclc_dmadata *dmadata = &dev->dmadata[i]; | ||
394 | struct dma_chan *chan = dmadata->dma_chan; | ||
395 | if (chan) { | ||
396 | dmadata->frag_count = -1; | ||
397 | chan->device->device_terminate_all(chan); | ||
398 | dma_release_channel(chan); | ||
399 | } | ||
400 | dev->dmadata[i].dma_chan = NULL; | ||
401 | } | ||
402 | return 0; | ||
403 | } | ||
404 | |||
405 | struct snd_soc_platform txx9aclc_soc_platform = { | ||
406 | .name = "txx9aclc-audio", | ||
407 | .probe = txx9aclc_pcm_probe, | ||
408 | .remove = txx9aclc_pcm_remove, | ||
409 | .pcm_ops = &txx9aclc_pcm_ops, | ||
410 | .pcm_new = txx9aclc_pcm_new, | ||
411 | .pcm_free = txx9aclc_pcm_free_dma_buffers, | ||
412 | }; | ||
413 | EXPORT_SYMBOL_GPL(txx9aclc_soc_platform); | ||
414 | |||
415 | static int __init txx9aclc_soc_platform_init(void) | ||
416 | { | ||
417 | return snd_soc_register_platform(&txx9aclc_soc_platform); | ||
418 | } | ||
419 | |||
420 | static void __exit txx9aclc_soc_platform_exit(void) | ||
421 | { | ||
422 | snd_soc_unregister_platform(&txx9aclc_soc_platform); | ||
423 | } | ||
424 | |||
425 | module_init(txx9aclc_soc_platform_init); | ||
426 | module_exit(txx9aclc_soc_platform_exit); | ||
427 | |||
428 | MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); | ||
429 | MODULE_DESCRIPTION("TXx9 ACLC Audio DMA driver"); | ||
430 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/txx9/txx9aclc.h b/sound/soc/txx9/txx9aclc.h new file mode 100644 index 000000000000..6769aab41b33 --- /dev/null +++ b/sound/soc/txx9/txx9aclc.h | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * TXx9 SoC AC Link Controller | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #ifndef __TXX9ACLC_H | ||
10 | #define __TXX9ACLC_H | ||
11 | |||
12 | #include <linux/interrupt.h> | ||
13 | #include <asm/txx9/dmac.h> | ||
14 | |||
15 | #define ACCTLEN 0x00 /* control enable */ | ||
16 | #define ACCTLDIS 0x04 /* control disable */ | ||
17 | #define ACCTL_ENLINK 0x00000001 /* enable/disable AC-link */ | ||
18 | #define ACCTL_AUDODMA 0x00000100 /* AUDODMA enable/disable */ | ||
19 | #define ACCTL_AUDIDMA 0x00001000 /* AUDIDMA enable/disable */ | ||
20 | #define ACCTL_AUDOEHLT 0x00010000 /* AUDO error halt | ||
21 | enable/disable */ | ||
22 | #define ACCTL_AUDIEHLT 0x00100000 /* AUDI error halt | ||
23 | enable/disable */ | ||
24 | #define ACREGACC 0x08 /* codec register access */ | ||
25 | #define ACREGACC_DAT_SHIFT 0 /* data field */ | ||
26 | #define ACREGACC_REG_SHIFT 16 /* address field */ | ||
27 | #define ACREGACC_CODECID_SHIFT 24 /* CODEC ID field */ | ||
28 | #define ACREGACC_READ 0x80000000 /* CODEC read */ | ||
29 | #define ACREGACC_WRITE 0x00000000 /* CODEC write */ | ||
30 | #define ACINTSTS 0x10 /* interrupt status */ | ||
31 | #define ACINTMSTS 0x14 /* interrupt masked status */ | ||
32 | #define ACINTEN 0x18 /* interrupt enable */ | ||
33 | #define ACINTDIS 0x1c /* interrupt disable */ | ||
34 | #define ACINT_CODECRDY(n) (0x00000001 << (n)) /* CODECn ready */ | ||
35 | #define ACINT_REGACCRDY 0x00000010 /* ACREGACC ready */ | ||
36 | #define ACINT_AUDOERR 0x00000100 /* AUDO underrun error */ | ||
37 | #define ACINT_AUDIERR 0x00001000 /* AUDI overrun error */ | ||
38 | #define ACDMASTS 0x80 /* DMA request status */ | ||
39 | #define ACDMA_AUDO 0x00000001 /* AUDODMA pending */ | ||
40 | #define ACDMA_AUDI 0x00000010 /* AUDIDMA pending */ | ||
41 | #define ACAUDODAT 0xa0 /* audio out data */ | ||
42 | #define ACAUDIDAT 0xb0 /* audio in data */ | ||
43 | #define ACREVID 0xfc /* revision ID */ | ||
44 | |||
45 | struct txx9aclc_dmadata { | ||
46 | struct resource *dma_res; | ||
47 | struct txx9dmac_slave dma_slave; | ||
48 | struct dma_chan *dma_chan; | ||
49 | struct tasklet_struct tasklet; | ||
50 | spinlock_t dma_lock; | ||
51 | int stream; /* SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE */ | ||
52 | struct snd_pcm_substream *substream; | ||
53 | unsigned long pos; | ||
54 | dma_addr_t dma_addr; | ||
55 | unsigned long buffer_bytes; | ||
56 | unsigned long period_bytes; | ||
57 | unsigned long frag_bytes; | ||
58 | int frags; | ||
59 | int frag_count; | ||
60 | int dmacount; | ||
61 | }; | ||
62 | |||
63 | struct txx9aclc_plat_drvdata { | ||
64 | void __iomem *base; | ||
65 | u64 physbase; | ||
66 | }; | ||
67 | |||
68 | struct txx9aclc_soc_device { | ||
69 | struct snd_soc_device soc_dev; | ||
70 | struct platform_device *aclc_pdev; /* for ioresources, drvdata */ | ||
71 | struct txx9aclc_dmadata dmadata[2]; | ||
72 | }; | ||
73 | |||
74 | static inline struct txx9aclc_plat_drvdata *txx9aclc_get_plat_drvdata( | ||
75 | struct txx9aclc_soc_device *sdev) | ||
76 | { | ||
77 | return platform_get_drvdata(sdev->aclc_pdev); | ||
78 | } | ||
79 | |||
80 | extern struct snd_soc_platform txx9aclc_soc_platform; | ||
81 | extern struct snd_soc_dai txx9aclc_ac97_dai; | ||
82 | |||
83 | #endif /* __TXX9ACLC_H */ | ||
diff --git a/sound/synth/Makefile b/sound/synth/Makefile index e99fd76caa17..11eb06ac2eca 100644 --- a/sound/synth/Makefile +++ b/sound/synth/Makefile | |||
@@ -5,16 +5,8 @@ | |||
5 | 5 | ||
6 | snd-util-mem-objs := util_mem.o | 6 | snd-util-mem-objs := util_mem.o |
7 | 7 | ||
8 | # | ||
9 | # this function returns: | ||
10 | # "m" - CONFIG_SND_SEQUENCER is m | ||
11 | # <empty string> - CONFIG_SND_SEQUENCER is undefined | ||
12 | # otherwise parameter #1 value | ||
13 | # | ||
14 | sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1))) | ||
15 | |||
16 | # Toplevel Module Dependency | 8 | # Toplevel Module Dependency |
17 | obj-$(CONFIG_SND_EMU10K1) += snd-util-mem.o | 9 | obj-$(CONFIG_SND_EMU10K1) += snd-util-mem.o |
18 | obj-$(CONFIG_SND_TRIDENT) += snd-util-mem.o | 10 | obj-$(CONFIG_SND_TRIDENT) += snd-util-mem.o |
19 | obj-$(call sequencer,$(CONFIG_SND_SBAWE)) += snd-util-mem.o | 11 | obj-$(CONFIG_SND_SBAWE_SEQ) += snd-util-mem.o |
20 | obj-$(call sequencer,$(CONFIG_SND)) += emux/ | 12 | obj-$(CONFIG_SND_SEQUENCER) += emux/ |
diff --git a/sound/synth/emux/Makefile b/sound/synth/emux/Makefile index b69035240cf6..328594e6152d 100644 --- a/sound/synth/emux/Makefile +++ b/sound/synth/emux/Makefile | |||
@@ -7,14 +7,6 @@ snd-emux-synth-objs := emux.o emux_synth.o emux_seq.o emux_nrpn.o \ | |||
7 | emux_effect.o emux_proc.o emux_hwdep.o soundfont.o \ | 7 | emux_effect.o emux_proc.o emux_hwdep.o soundfont.o \ |
8 | $(if $(CONFIG_SND_SEQUENCER_OSS),emux_oss.o) | 8 | $(if $(CONFIG_SND_SEQUENCER_OSS),emux_oss.o) |
9 | 9 | ||
10 | # | ||
11 | # this function returns: | ||
12 | # "m" - CONFIG_SND_SEQUENCER is m | ||
13 | # <empty string> - CONFIG_SND_SEQUENCER is undefined | ||
14 | # otherwise parameter #1 value | ||
15 | # | ||
16 | sequencer = $(if $(subst y,,$(CONFIG_SND_SEQUENCER)),$(if $(1),m),$(if $(CONFIG_SND_SEQUENCER),$(1))) | ||
17 | |||
18 | # Toplevel Module Dependencies | 10 | # Toplevel Module Dependencies |
19 | obj-$(call sequencer,$(CONFIG_SND_SBAWE)) += snd-emux-synth.o | 11 | obj-$(CONFIG_SND_SBAWE_SEQ) += snd-emux-synth.o |
20 | obj-$(call sequencer,$(CONFIG_SND_EMU10K1)) += snd-emux-synth.o | 12 | obj-$(CONFIG_SND_EMU10K1_SEQ) += snd-emux-synth.o |
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index b13ce767ac72..b14451342166 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c | |||
@@ -42,10 +42,10 @@ | |||
42 | (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) | 42 | (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) |
43 | 43 | ||
44 | static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { | 44 | static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { |
45 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 45 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
46 | SNDRV_PCM_INFO_BLOCK_TRANSFER), | 46 | SNDRV_PCM_INFO_BLOCK_TRANSFER), |
47 | .formats = SNDRV_PCM_FMTBIT_S24_3BE, | 47 | .formats = SNDRV_PCM_FMTBIT_S24_3BE, |
48 | .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | | 48 | .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | |
49 | SNDRV_PCM_RATE_96000), | 49 | SNDRV_PCM_RATE_96000), |
50 | .rate_min = 44100, | 50 | .rate_min = 44100, |
51 | .rate_max = 0, /* will overwrite later */ | 51 | .rate_max = 0, /* will overwrite later */ |
@@ -68,7 +68,7 @@ activate_substream(struct snd_usb_caiaqdev *dev, | |||
68 | dev->sub_capture[sub->number] = sub; | 68 | dev->sub_capture[sub->number] = sub; |
69 | } | 69 | } |
70 | 70 | ||
71 | static void | 71 | static void |
72 | deactivate_substream(struct snd_usb_caiaqdev *dev, | 72 | deactivate_substream(struct snd_usb_caiaqdev *dev, |
73 | struct snd_pcm_substream *sub) | 73 | struct snd_pcm_substream *sub) |
74 | { | 74 | { |
@@ -118,7 +118,7 @@ static int stream_start(struct snd_usb_caiaqdev *dev) | |||
118 | return -EPIPE; | 118 | return -EPIPE; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | 124 | ||
@@ -129,7 +129,7 @@ static void stream_stop(struct snd_usb_caiaqdev *dev) | |||
129 | debug("%s(%p)\n", __func__, dev); | 129 | debug("%s(%p)\n", __func__, dev); |
130 | if (!dev->streaming) | 130 | if (!dev->streaming) |
131 | return; | 131 | return; |
132 | 132 | ||
133 | dev->streaming = 0; | 133 | dev->streaming = 0; |
134 | 134 | ||
135 | for (i = 0; i < N_URBS; i++) { | 135 | for (i = 0; i < N_URBS; i++) { |
@@ -154,7 +154,7 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) | |||
154 | debug("%s(%p)\n", __func__, substream); | 154 | debug("%s(%p)\n", __func__, substream); |
155 | if (all_substreams_zero(dev->sub_playback) && | 155 | if (all_substreams_zero(dev->sub_playback) && |
156 | all_substreams_zero(dev->sub_capture)) { | 156 | all_substreams_zero(dev->sub_capture)) { |
157 | /* when the last client has stopped streaming, | 157 | /* when the last client has stopped streaming, |
158 | * all sample rates are allowed again */ | 158 | * all sample rates are allowed again */ |
159 | stream_stop(dev); | 159 | stream_stop(dev); |
160 | dev->pcm_info.rates = dev->samplerates; | 160 | dev->pcm_info.rates = dev->samplerates; |
@@ -194,7 +194,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
194 | struct snd_pcm_runtime *runtime = substream->runtime; | 194 | struct snd_pcm_runtime *runtime = substream->runtime; |
195 | 195 | ||
196 | debug("%s(%p)\n", __func__, substream); | 196 | debug("%s(%p)\n", __func__, substream); |
197 | 197 | ||
198 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 198 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
199 | dev->period_out_count[index] = BYTES_PER_SAMPLE + 1; | 199 | dev->period_out_count[index] = BYTES_PER_SAMPLE + 1; |
200 | dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; | 200 | dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; |
@@ -205,19 +205,19 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
205 | 205 | ||
206 | if (dev->streaming) | 206 | if (dev->streaming) |
207 | return 0; | 207 | return 0; |
208 | 208 | ||
209 | /* the first client that opens a stream defines the sample rate | 209 | /* the first client that opens a stream defines the sample rate |
210 | * setting for all subsequent calls, until the last client closed. */ | 210 | * setting for all subsequent calls, until the last client closed. */ |
211 | for (i=0; i < ARRAY_SIZE(rates); i++) | 211 | for (i=0; i < ARRAY_SIZE(rates); i++) |
212 | if (runtime->rate == rates[i]) | 212 | if (runtime->rate == rates[i]) |
213 | dev->pcm_info.rates = 1 << i; | 213 | dev->pcm_info.rates = 1 << i; |
214 | 214 | ||
215 | snd_pcm_limit_hw_rates(runtime); | 215 | snd_pcm_limit_hw_rates(runtime); |
216 | 216 | ||
217 | bytes_per_sample = BYTES_PER_SAMPLE; | 217 | bytes_per_sample = BYTES_PER_SAMPLE; |
218 | if (dev->spec.data_alignment == 2) | 218 | if (dev->spec.data_alignment == 2) |
219 | bytes_per_sample++; | 219 | bytes_per_sample++; |
220 | 220 | ||
221 | bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) | 221 | bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) |
222 | * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams; | 222 | * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams; |
223 | 223 | ||
@@ -232,7 +232,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
232 | ret = stream_start(dev); | 232 | ret = stream_start(dev); |
233 | if (ret) | 233 | if (ret) |
234 | return ret; | 234 | return ret; |
235 | 235 | ||
236 | dev->output_running = 0; | 236 | dev->output_running = 0; |
237 | wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ); | 237 | wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ); |
238 | if (!dev->output_running) { | 238 | if (!dev->output_running) { |
@@ -273,7 +273,7 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub) | |||
273 | return SNDRV_PCM_POS_XRUN; | 273 | return SNDRV_PCM_POS_XRUN; |
274 | 274 | ||
275 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) | 275 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) |
276 | return bytes_to_frames(sub->runtime, | 276 | return bytes_to_frames(sub->runtime, |
277 | dev->audio_out_buf_pos[index]); | 277 | dev->audio_out_buf_pos[index]); |
278 | else | 278 | else |
279 | return bytes_to_frames(sub->runtime, | 279 | return bytes_to_frames(sub->runtime, |
@@ -291,7 +291,7 @@ static struct snd_pcm_ops snd_usb_caiaq_ops = { | |||
291 | .trigger = snd_usb_caiaq_pcm_trigger, | 291 | .trigger = snd_usb_caiaq_pcm_trigger, |
292 | .pointer = snd_usb_caiaq_pcm_pointer | 292 | .pointer = snd_usb_caiaq_pcm_pointer |
293 | }; | 293 | }; |
294 | 294 | ||
295 | static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, | 295 | static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, |
296 | struct snd_pcm_substream **subs) | 296 | struct snd_pcm_substream **subs) |
297 | { | 297 | { |
@@ -333,7 +333,7 @@ static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev, | |||
333 | struct snd_pcm_runtime *rt = sub->runtime; | 333 | struct snd_pcm_runtime *rt = sub->runtime; |
334 | char *audio_buf = rt->dma_area; | 334 | char *audio_buf = rt->dma_area; |
335 | int sz = frames_to_bytes(rt, rt->buffer_size); | 335 | int sz = frames_to_bytes(rt, rt->buffer_size); |
336 | audio_buf[dev->audio_in_buf_pos[stream]++] | 336 | audio_buf[dev->audio_in_buf_pos[stream]++] |
337 | = usb_buf[i]; | 337 | = usb_buf[i]; |
338 | dev->period_in_count[stream]++; | 338 | dev->period_in_count[stream]++; |
339 | if (dev->audio_in_buf_pos[stream] == sz) | 339 | if (dev->audio_in_buf_pos[stream] == sz) |
@@ -354,14 +354,14 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev, | |||
354 | 354 | ||
355 | for (i = 0; i < iso->actual_length;) { | 355 | for (i = 0; i < iso->actual_length;) { |
356 | if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { | 356 | if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { |
357 | for (stream = 0; | 357 | for (stream = 0; |
358 | stream < dev->n_streams; | 358 | stream < dev->n_streams; |
359 | stream++, i++) { | 359 | stream++, i++) { |
360 | if (dev->first_packet) | 360 | if (dev->first_packet) |
361 | continue; | 361 | continue; |
362 | 362 | ||
363 | check_byte = MAKE_CHECKBYTE(dev, stream, i); | 363 | check_byte = MAKE_CHECKBYTE(dev, stream, i); |
364 | 364 | ||
365 | if ((usb_buf[i] & 0x3f) != check_byte) | 365 | if ((usb_buf[i] & 0x3f) != check_byte) |
366 | dev->input_panic = 1; | 366 | dev->input_panic = 1; |
367 | 367 | ||
@@ -410,21 +410,21 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev, | |||
410 | } | 410 | } |
411 | 411 | ||
412 | if ((dev->input_panic || dev->output_panic) && !dev->warned) { | 412 | if ((dev->input_panic || dev->output_panic) && !dev->warned) { |
413 | debug("streaming error detected %s %s\n", | 413 | debug("streaming error detected %s %s\n", |
414 | dev->input_panic ? "(input)" : "", | 414 | dev->input_panic ? "(input)" : "", |
415 | dev->output_panic ? "(output)" : ""); | 415 | dev->output_panic ? "(output)" : ""); |
416 | dev->warned = 1; | 416 | dev->warned = 1; |
417 | } | 417 | } |
418 | } | 418 | } |
419 | 419 | ||
420 | static void fill_out_urb(struct snd_usb_caiaqdev *dev, | 420 | static void fill_out_urb(struct snd_usb_caiaqdev *dev, |
421 | struct urb *urb, | 421 | struct urb *urb, |
422 | const struct usb_iso_packet_descriptor *iso) | 422 | const struct usb_iso_packet_descriptor *iso) |
423 | { | 423 | { |
424 | unsigned char *usb_buf = urb->transfer_buffer + iso->offset; | 424 | unsigned char *usb_buf = urb->transfer_buffer + iso->offset; |
425 | struct snd_pcm_substream *sub; | 425 | struct snd_pcm_substream *sub; |
426 | int stream, i; | 426 | int stream, i; |
427 | 427 | ||
428 | for (i = 0; i < iso->length;) { | 428 | for (i = 0; i < iso->length;) { |
429 | for (stream = 0; stream < dev->n_streams; stream++, i++) { | 429 | for (stream = 0; stream < dev->n_streams; stream++, i++) { |
430 | sub = dev->sub_playback[stream]; | 430 | sub = dev->sub_playback[stream]; |
@@ -444,7 +444,7 @@ static void fill_out_urb(struct snd_usb_caiaqdev *dev, | |||
444 | 444 | ||
445 | /* fill in the check bytes */ | 445 | /* fill in the check bytes */ |
446 | if (dev->spec.data_alignment == 2 && | 446 | if (dev->spec.data_alignment == 2 && |
447 | i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == | 447 | i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == |
448 | (dev->n_streams * CHANNELS_PER_STREAM)) | 448 | (dev->n_streams * CHANNELS_PER_STREAM)) |
449 | for (stream = 0; stream < dev->n_streams; stream++, i++) | 449 | for (stream = 0; stream < dev->n_streams; stream++, i++) |
450 | usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i); | 450 | usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i); |
@@ -453,7 +453,7 @@ static void fill_out_urb(struct snd_usb_caiaqdev *dev, | |||
453 | 453 | ||
454 | static void read_completed(struct urb *urb) | 454 | static void read_completed(struct urb *urb) |
455 | { | 455 | { |
456 | struct snd_usb_caiaq_cb_info *info = urb->context; | 456 | struct snd_usb_caiaq_cb_info *info = urb->context; |
457 | struct snd_usb_caiaqdev *dev; | 457 | struct snd_usb_caiaqdev *dev; |
458 | struct urb *out; | 458 | struct urb *out; |
459 | int frame, len, send_it = 0, outframe = 0; | 459 | int frame, len, send_it = 0, outframe = 0; |
@@ -478,7 +478,7 @@ static void read_completed(struct urb *urb) | |||
478 | out->iso_frame_desc[outframe].length = len; | 478 | out->iso_frame_desc[outframe].length = len; |
479 | out->iso_frame_desc[outframe].actual_length = 0; | 479 | out->iso_frame_desc[outframe].actual_length = 0; |
480 | out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame; | 480 | out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame; |
481 | 481 | ||
482 | if (len > 0) { | 482 | if (len > 0) { |
483 | spin_lock(&dev->spinlock); | 483 | spin_lock(&dev->spinlock); |
484 | fill_out_urb(dev, out, &out->iso_frame_desc[outframe]); | 484 | fill_out_urb(dev, out, &out->iso_frame_desc[outframe]); |
@@ -497,14 +497,14 @@ static void read_completed(struct urb *urb) | |||
497 | out->transfer_flags = URB_ISO_ASAP; | 497 | out->transfer_flags = URB_ISO_ASAP; |
498 | usb_submit_urb(out, GFP_ATOMIC); | 498 | usb_submit_urb(out, GFP_ATOMIC); |
499 | } | 499 | } |
500 | 500 | ||
501 | /* re-submit inbound urb */ | 501 | /* re-submit inbound urb */ |
502 | for (frame = 0; frame < FRAMES_PER_URB; frame++) { | 502 | for (frame = 0; frame < FRAMES_PER_URB; frame++) { |
503 | urb->iso_frame_desc[frame].offset = BYTES_PER_FRAME * frame; | 503 | urb->iso_frame_desc[frame].offset = BYTES_PER_FRAME * frame; |
504 | urb->iso_frame_desc[frame].length = BYTES_PER_FRAME; | 504 | urb->iso_frame_desc[frame].length = BYTES_PER_FRAME; |
505 | urb->iso_frame_desc[frame].actual_length = 0; | 505 | urb->iso_frame_desc[frame].actual_length = 0; |
506 | } | 506 | } |
507 | 507 | ||
508 | urb->number_of_packets = FRAMES_PER_URB; | 508 | urb->number_of_packets = FRAMES_PER_URB; |
509 | urb->transfer_flags = URB_ISO_ASAP; | 509 | urb->transfer_flags = URB_ISO_ASAP; |
510 | usb_submit_urb(urb, GFP_ATOMIC); | 510 | usb_submit_urb(urb, GFP_ATOMIC); |
@@ -528,7 +528,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
528 | struct usb_device *usb_dev = dev->chip.dev; | 528 | struct usb_device *usb_dev = dev->chip.dev; |
529 | unsigned int pipe; | 529 | unsigned int pipe; |
530 | 530 | ||
531 | pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? | 531 | pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? |
532 | usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) : | 532 | usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) : |
533 | usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE); | 533 | usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE); |
534 | 534 | ||
@@ -547,25 +547,25 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
547 | return urbs; | 547 | return urbs; |
548 | } | 548 | } |
549 | 549 | ||
550 | urbs[i]->transfer_buffer = | 550 | urbs[i]->transfer_buffer = |
551 | kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); | 551 | kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); |
552 | if (!urbs[i]->transfer_buffer) { | 552 | if (!urbs[i]->transfer_buffer) { |
553 | log("unable to kmalloc() transfer buffer, OOM!?\n"); | 553 | log("unable to kmalloc() transfer buffer, OOM!?\n"); |
554 | *ret = -ENOMEM; | 554 | *ret = -ENOMEM; |
555 | return urbs; | 555 | return urbs; |
556 | } | 556 | } |
557 | 557 | ||
558 | for (frame = 0; frame < FRAMES_PER_URB; frame++) { | 558 | for (frame = 0; frame < FRAMES_PER_URB; frame++) { |
559 | struct usb_iso_packet_descriptor *iso = | 559 | struct usb_iso_packet_descriptor *iso = |
560 | &urbs[i]->iso_frame_desc[frame]; | 560 | &urbs[i]->iso_frame_desc[frame]; |
561 | 561 | ||
562 | iso->offset = BYTES_PER_FRAME * frame; | 562 | iso->offset = BYTES_PER_FRAME * frame; |
563 | iso->length = BYTES_PER_FRAME; | 563 | iso->length = BYTES_PER_FRAME; |
564 | } | 564 | } |
565 | 565 | ||
566 | urbs[i]->dev = usb_dev; | 566 | urbs[i]->dev = usb_dev; |
567 | urbs[i]->pipe = pipe; | 567 | urbs[i]->pipe = pipe; |
568 | urbs[i]->transfer_buffer_length = FRAMES_PER_URB | 568 | urbs[i]->transfer_buffer_length = FRAMES_PER_URB |
569 | * BYTES_PER_FRAME; | 569 | * BYTES_PER_FRAME; |
570 | urbs[i]->context = &dev->data_cb_info[i]; | 570 | urbs[i]->context = &dev->data_cb_info[i]; |
571 | urbs[i]->interval = 1; | 571 | urbs[i]->interval = 1; |
@@ -589,7 +589,7 @@ static void free_urbs(struct urb **urbs) | |||
589 | for (i = 0; i < N_URBS; i++) { | 589 | for (i = 0; i < N_URBS; i++) { |
590 | if (!urbs[i]) | 590 | if (!urbs[i]) |
591 | continue; | 591 | continue; |
592 | 592 | ||
593 | usb_kill_urb(urbs[i]); | 593 | usb_kill_urb(urbs[i]); |
594 | kfree(urbs[i]->transfer_buffer); | 594 | kfree(urbs[i]->transfer_buffer); |
595 | usb_free_urb(urbs[i]); | 595 | usb_free_urb(urbs[i]); |
@@ -602,11 +602,11 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
602 | { | 602 | { |
603 | int i, ret; | 603 | int i, ret; |
604 | 604 | ||
605 | dev->n_audio_in = max(dev->spec.num_analog_audio_in, | 605 | dev->n_audio_in = max(dev->spec.num_analog_audio_in, |
606 | dev->spec.num_digital_audio_in) / | 606 | dev->spec.num_digital_audio_in) / |
607 | CHANNELS_PER_STREAM; | 607 | CHANNELS_PER_STREAM; |
608 | dev->n_audio_out = max(dev->spec.num_analog_audio_out, | 608 | dev->n_audio_out = max(dev->spec.num_analog_audio_out, |
609 | dev->spec.num_digital_audio_out) / | 609 | dev->spec.num_digital_audio_out) / |
610 | CHANNELS_PER_STREAM; | 610 | CHANNELS_PER_STREAM; |
611 | dev->n_streams = max(dev->n_audio_in, dev->n_audio_out); | 611 | dev->n_streams = max(dev->n_audio_in, dev->n_audio_out); |
612 | 612 | ||
@@ -619,7 +619,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
619 | return -EINVAL; | 619 | return -EINVAL; |
620 | } | 620 | } |
621 | 621 | ||
622 | ret = snd_pcm_new(dev->chip.card, dev->product_name, 0, | 622 | ret = snd_pcm_new(dev->chip.card, dev->product_name, 0, |
623 | dev->n_audio_out, dev->n_audio_in, &dev->pcm); | 623 | dev->n_audio_out, dev->n_audio_in, &dev->pcm); |
624 | 624 | ||
625 | if (ret < 0) { | 625 | if (ret < 0) { |
@@ -632,7 +632,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
632 | 632 | ||
633 | memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); | 633 | memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); |
634 | memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); | 634 | memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); |
635 | 635 | ||
636 | memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware, | 636 | memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware, |
637 | sizeof(snd_usb_caiaq_pcm_hardware)); | 637 | sizeof(snd_usb_caiaq_pcm_hardware)); |
638 | 638 | ||
@@ -651,9 +651,9 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
651 | break; | 651 | break; |
652 | } | 652 | } |
653 | 653 | ||
654 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, | 654 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, |
655 | &snd_usb_caiaq_ops); | 655 | &snd_usb_caiaq_ops); |
656 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, | 656 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, |
657 | &snd_usb_caiaq_ops); | 657 | &snd_usb_caiaq_ops); |
658 | 658 | ||
659 | snd_pcm_lib_preallocate_pages_for_all(dev->pcm, | 659 | snd_pcm_lib_preallocate_pages_for_all(dev->pcm, |
@@ -662,7 +662,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
662 | MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); | 662 | MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); |
663 | 663 | ||
664 | dev->data_cb_info = | 664 | dev->data_cb_info = |
665 | kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, | 665 | kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, |
666 | GFP_KERNEL); | 666 | GFP_KERNEL); |
667 | 667 | ||
668 | if (!dev->data_cb_info) | 668 | if (!dev->data_cb_info) |
@@ -672,14 +672,14 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
672 | dev->data_cb_info[i].dev = dev; | 672 | dev->data_cb_info[i].dev = dev; |
673 | dev->data_cb_info[i].index = i; | 673 | dev->data_cb_info[i].index = i; |
674 | } | 674 | } |
675 | 675 | ||
676 | dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret); | 676 | dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret); |
677 | if (ret < 0) { | 677 | if (ret < 0) { |
678 | kfree(dev->data_cb_info); | 678 | kfree(dev->data_cb_info); |
679 | free_urbs(dev->data_urbs_in); | 679 | free_urbs(dev->data_urbs_in); |
680 | return ret; | 680 | return ret; |
681 | } | 681 | } |
682 | 682 | ||
683 | dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret); | 683 | dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret); |
684 | if (ret < 0) { | 684 | if (ret < 0) { |
685 | kfree(dev->data_cb_info); | 685 | kfree(dev->data_cb_info); |
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index 515de1cd2a3e..22406245a98b 100644 --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include "input.h" | 35 | #include "input.h" |
36 | 36 | ||
37 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); | 37 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); |
38 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.14"); | 38 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.16"); |
39 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
40 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," | 40 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," |
41 | "{Native Instruments, RigKontrol3}," | 41 | "{Native Instruments, RigKontrol3}," |
@@ -79,7 +79,7 @@ static struct usb_device_id snd_usb_id_table[] = { | |||
79 | { | 79 | { |
80 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, | 80 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, |
81 | .idVendor = USB_VID_NATIVEINSTRUMENTS, | 81 | .idVendor = USB_VID_NATIVEINSTRUMENTS, |
82 | .idProduct = USB_PID_RIGKONTROL2 | 82 | .idProduct = USB_PID_RIGKONTROL2 |
83 | }, | 83 | }, |
84 | { | 84 | { |
85 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, | 85 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, |
@@ -197,7 +197,7 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, | |||
197 | 197 | ||
198 | if (buffer && len > 0) | 198 | if (buffer && len > 0) |
199 | memcpy(dev->ep1_out_buf+1, buffer, len); | 199 | memcpy(dev->ep1_out_buf+1, buffer, len); |
200 | 200 | ||
201 | dev->ep1_out_buf[0] = command; | 201 | dev->ep1_out_buf[0] = command; |
202 | return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), | 202 | return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), |
203 | dev->ep1_out_buf, len+1, &actual_len, 200); | 203 | dev->ep1_out_buf, len+1, &actual_len, 200); |
@@ -208,7 +208,7 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | |||
208 | { | 208 | { |
209 | int ret; | 209 | int ret; |
210 | char tmp[5]; | 210 | char tmp[5]; |
211 | 211 | ||
212 | switch (rate) { | 212 | switch (rate) { |
213 | case 44100: tmp[0] = SAMPLERATE_44100; break; | 213 | case 44100: tmp[0] = SAMPLERATE_44100; break; |
214 | case 48000: tmp[0] = SAMPLERATE_48000; break; | 214 | case 48000: tmp[0] = SAMPLERATE_48000; break; |
@@ -237,12 +237,12 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | |||
237 | 237 | ||
238 | if (ret) | 238 | if (ret) |
239 | return ret; | 239 | return ret; |
240 | 240 | ||
241 | if (!wait_event_timeout(dev->ep1_wait_queue, | 241 | if (!wait_event_timeout(dev->ep1_wait_queue, |
242 | dev->audio_parm_answer >= 0, HZ)) | 242 | dev->audio_parm_answer >= 0, HZ)) |
243 | return -EPIPE; | 243 | return -EPIPE; |
244 | 244 | ||
245 | if (dev->audio_parm_answer != 1) | 245 | if (dev->audio_parm_answer != 1) |
246 | debug("unable to set the device's audio params\n"); | 246 | debug("unable to set the device's audio params\n"); |
247 | else | 247 | else |
248 | dev->bpp = bpp; | 248 | dev->bpp = bpp; |
@@ -250,8 +250,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | |||
250 | return dev->audio_parm_answer == 1 ? 0 : -EINVAL; | 250 | return dev->audio_parm_answer == 1 ? 0 : -EINVAL; |
251 | } | 251 | } |
252 | 252 | ||
253 | int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, | 253 | int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *dev, |
254 | int digital, int analog, int erp) | 254 | int digital, int analog, int erp) |
255 | { | 255 | { |
256 | char tmp[3] = { digital, analog, erp }; | 256 | char tmp[3] = { digital, analog, erp }; |
257 | return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, | 257 | return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, |
@@ -262,7 +262,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) | |||
262 | { | 262 | { |
263 | int ret; | 263 | int ret; |
264 | char val[4]; | 264 | char val[4]; |
265 | 265 | ||
266 | /* device-specific startup specials */ | 266 | /* device-specific startup specials */ |
267 | switch (dev->chip.usb_id) { | 267 | switch (dev->chip.usb_id) { |
268 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 268 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
@@ -314,7 +314,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) | |||
314 | dev->control_state, 1); | 314 | dev->control_state, 1); |
315 | break; | 315 | break; |
316 | } | 316 | } |
317 | 317 | ||
318 | if (dev->spec.num_analog_audio_out + | 318 | if (dev->spec.num_analog_audio_out + |
319 | dev->spec.num_analog_audio_in + | 319 | dev->spec.num_analog_audio_in + |
320 | dev->spec.num_digital_audio_out + | 320 | dev->spec.num_digital_audio_out + |
@@ -323,7 +323,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) | |||
323 | if (ret < 0) | 323 | if (ret < 0) |
324 | log("Unable to set up audio system (ret=%d)\n", ret); | 324 | log("Unable to set up audio system (ret=%d)\n", ret); |
325 | } | 325 | } |
326 | 326 | ||
327 | if (dev->spec.num_midi_in + | 327 | if (dev->spec.num_midi_in + |
328 | dev->spec.num_midi_out > 0) { | 328 | dev->spec.num_midi_out > 0) { |
329 | ret = snd_usb_caiaq_midi_init(dev); | 329 | ret = snd_usb_caiaq_midi_init(dev); |
@@ -363,7 +363,7 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) | |||
363 | if (devnum >= SNDRV_CARDS) | 363 | if (devnum >= SNDRV_CARDS) |
364 | return -ENODEV; | 364 | return -ENODEV; |
365 | 365 | ||
366 | err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, | 366 | err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, |
367 | sizeof(struct snd_usb_caiaqdev), &card); | 367 | sizeof(struct snd_usb_caiaqdev), &card); |
368 | if (err < 0) | 368 | if (err < 0) |
369 | return err; | 369 | return err; |
@@ -382,11 +382,11 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) | |||
382 | 382 | ||
383 | static int __devinit init_card(struct snd_usb_caiaqdev *dev) | 383 | static int __devinit init_card(struct snd_usb_caiaqdev *dev) |
384 | { | 384 | { |
385 | char *c; | 385 | char *c, usbpath[32]; |
386 | struct usb_device *usb_dev = dev->chip.dev; | 386 | struct usb_device *usb_dev = dev->chip.dev; |
387 | struct snd_card *card = dev->chip.card; | 387 | struct snd_card *card = dev->chip.card; |
388 | int err, len; | 388 | int err, len; |
389 | 389 | ||
390 | if (usb_set_interface(usb_dev, 0, 1) != 0) { | 390 | if (usb_set_interface(usb_dev, 0, 1) != 0) { |
391 | log("can't set alt interface.\n"); | 391 | log("can't set alt interface.\n"); |
392 | return -EIO; | 392 | return -EIO; |
@@ -395,19 +395,19 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev) | |||
395 | usb_init_urb(&dev->ep1_in_urb); | 395 | usb_init_urb(&dev->ep1_in_urb); |
396 | usb_init_urb(&dev->midi_out_urb); | 396 | usb_init_urb(&dev->midi_out_urb); |
397 | 397 | ||
398 | usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, | 398 | usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, |
399 | usb_rcvbulkpipe(usb_dev, 0x1), | 399 | usb_rcvbulkpipe(usb_dev, 0x1), |
400 | dev->ep1_in_buf, EP1_BUFSIZE, | 400 | dev->ep1_in_buf, EP1_BUFSIZE, |
401 | usb_ep1_command_reply_dispatch, dev); | 401 | usb_ep1_command_reply_dispatch, dev); |
402 | 402 | ||
403 | usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, | 403 | usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, |
404 | usb_sndbulkpipe(usb_dev, 0x1), | 404 | usb_sndbulkpipe(usb_dev, 0x1), |
405 | dev->midi_out_buf, EP1_BUFSIZE, | 405 | dev->midi_out_buf, EP1_BUFSIZE, |
406 | snd_usb_caiaq_midi_output_done, dev); | 406 | snd_usb_caiaq_midi_output_done, dev); |
407 | 407 | ||
408 | init_waitqueue_head(&dev->ep1_wait_queue); | 408 | init_waitqueue_head(&dev->ep1_wait_queue); |
409 | init_waitqueue_head(&dev->prepare_wait_queue); | 409 | init_waitqueue_head(&dev->prepare_wait_queue); |
410 | 410 | ||
411 | if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) | 411 | if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) |
412 | return -EIO; | 412 | return -EIO; |
413 | 413 | ||
@@ -420,47 +420,52 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev) | |||
420 | 420 | ||
421 | usb_string(usb_dev, usb_dev->descriptor.iManufacturer, | 421 | usb_string(usb_dev, usb_dev->descriptor.iManufacturer, |
422 | dev->vendor_name, CAIAQ_USB_STR_LEN); | 422 | dev->vendor_name, CAIAQ_USB_STR_LEN); |
423 | 423 | ||
424 | usb_string(usb_dev, usb_dev->descriptor.iProduct, | 424 | usb_string(usb_dev, usb_dev->descriptor.iProduct, |
425 | dev->product_name, CAIAQ_USB_STR_LEN); | 425 | dev->product_name, CAIAQ_USB_STR_LEN); |
426 | 426 | ||
427 | usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, | 427 | strlcpy(card->driver, MODNAME, sizeof(card->driver)); |
428 | dev->serial, CAIAQ_USB_STR_LEN); | 428 | strlcpy(card->shortname, dev->product_name, sizeof(card->shortname)); |
429 | 429 | strlcpy(card->mixername, dev->product_name, sizeof(card->mixername)); | |
430 | /* terminate serial string at first white space occurence */ | 430 | |
431 | c = strchr(dev->serial, ' '); | 431 | /* if the id was not passed as module option, fill it with a shortened |
432 | if (c) | 432 | * version of the product string which does not contain any |
433 | *c = '\0'; | 433 | * whitespaces */ |
434 | 434 | ||
435 | strcpy(card->driver, MODNAME); | 435 | if (*card->id == '\0') { |
436 | strcpy(card->shortname, dev->product_name); | 436 | char id[sizeof(card->id)]; |
437 | 437 | ||
438 | len = snprintf(card->longname, sizeof(card->longname), | 438 | memset(id, 0, sizeof(id)); |
439 | "%s %s (serial %s, ", | 439 | |
440 | dev->vendor_name, dev->product_name, dev->serial); | 440 | for (c = card->shortname, len = 0; |
441 | 441 | *c && len < sizeof(card->id); c++) | |
442 | if (len < sizeof(card->longname) - 2) | 442 | if (*c != ' ') |
443 | len += usb_make_path(usb_dev, card->longname + len, | 443 | id[len++] = *c; |
444 | sizeof(card->longname) - len); | 444 | |
445 | 445 | snd_card_set_id(card, id); | |
446 | card->longname[len++] = ')'; | 446 | } |
447 | card->longname[len] = '\0'; | 447 | |
448 | usb_make_path(usb_dev, usbpath, sizeof(usbpath)); | ||
449 | snprintf(card->longname, sizeof(card->longname), | ||
450 | "%s %s (%s)", | ||
451 | dev->vendor_name, dev->product_name, usbpath); | ||
452 | |||
448 | setup_card(dev); | 453 | setup_card(dev); |
449 | return 0; | 454 | return 0; |
450 | } | 455 | } |
451 | 456 | ||
452 | static int __devinit snd_probe(struct usb_interface *intf, | 457 | static int __devinit snd_probe(struct usb_interface *intf, |
453 | const struct usb_device_id *id) | 458 | const struct usb_device_id *id) |
454 | { | 459 | { |
455 | int ret; | 460 | int ret; |
456 | struct snd_card *card; | 461 | struct snd_card *card; |
457 | struct usb_device *device = interface_to_usbdev(intf); | 462 | struct usb_device *device = interface_to_usbdev(intf); |
458 | 463 | ||
459 | ret = create_card(device, &card); | 464 | ret = create_card(device, &card); |
460 | 465 | ||
461 | if (ret < 0) | 466 | if (ret < 0) |
462 | return ret; | 467 | return ret; |
463 | 468 | ||
464 | usb_set_intfdata(intf, card); | 469 | usb_set_intfdata(intf, card); |
465 | ret = init_card(caiaqdev(card)); | 470 | ret = init_card(caiaqdev(card)); |
466 | if (ret < 0) { | 471 | if (ret < 0) { |
@@ -468,7 +473,7 @@ static int __devinit snd_probe(struct usb_interface *intf, | |||
468 | snd_card_free(card); | 473 | snd_card_free(card); |
469 | return ret; | 474 | return ret; |
470 | } | 475 | } |
471 | 476 | ||
472 | return 0; | 477 | return 0; |
473 | } | 478 | } |
474 | 479 | ||
@@ -489,10 +494,10 @@ static void snd_disconnect(struct usb_interface *intf) | |||
489 | snd_usb_caiaq_input_free(dev); | 494 | snd_usb_caiaq_input_free(dev); |
490 | #endif | 495 | #endif |
491 | snd_usb_caiaq_audio_free(dev); | 496 | snd_usb_caiaq_audio_free(dev); |
492 | 497 | ||
493 | usb_kill_urb(&dev->ep1_in_urb); | 498 | usb_kill_urb(&dev->ep1_in_urb); |
494 | usb_kill_urb(&dev->midi_out_urb); | 499 | usb_kill_urb(&dev->midi_out_urb); |
495 | 500 | ||
496 | snd_card_free(card); | 501 | snd_card_free(card); |
497 | usb_reset_device(interface_to_usbdev(intf)); | 502 | usb_reset_device(interface_to_usbdev(intf)); |
498 | } | 503 | } |
diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h index 4cce1ad7493d..ece73514854e 100644 --- a/sound/usb/caiaq/device.h +++ b/sound/usb/caiaq/device.h | |||
@@ -81,7 +81,6 @@ struct snd_usb_caiaqdev { | |||
81 | 81 | ||
82 | char vendor_name[CAIAQ_USB_STR_LEN]; | 82 | char vendor_name[CAIAQ_USB_STR_LEN]; |
83 | char product_name[CAIAQ_USB_STR_LEN]; | 83 | char product_name[CAIAQ_USB_STR_LEN]; |
84 | char serial[CAIAQ_USB_STR_LEN]; | ||
85 | 84 | ||
86 | int n_streams, n_audio_in, n_audio_out; | 85 | int n_streams, n_audio_in, n_audio_out; |
87 | int streaming, first_packet, output_running; | 86 | int streaming, first_packet, output_running; |
diff --git a/sound/usb/caiaq/midi.c b/sound/usb/caiaq/midi.c index 8fa8cd88d763..538e8c00d31a 100644 --- a/sound/usb/caiaq/midi.c +++ b/sound/usb/caiaq/midi.c | |||
@@ -40,7 +40,7 @@ static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *subst | |||
40 | 40 | ||
41 | if (!dev) | 41 | if (!dev) |
42 | return; | 42 | return; |
43 | 43 | ||
44 | dev->midi_receive_substream = up ? substream : NULL; | 44 | dev->midi_receive_substream = up ? substream : NULL; |
45 | } | 45 | } |
46 | 46 | ||
@@ -64,18 +64,18 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev, | |||
64 | struct snd_rawmidi_substream *substream) | 64 | struct snd_rawmidi_substream *substream) |
65 | { | 65 | { |
66 | int len, ret; | 66 | int len, ret; |
67 | 67 | ||
68 | dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; | 68 | dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; |
69 | dev->midi_out_buf[1] = 0; /* port */ | 69 | dev->midi_out_buf[1] = 0; /* port */ |
70 | len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3, | 70 | len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3, |
71 | EP1_BUFSIZE - 3); | 71 | EP1_BUFSIZE - 3); |
72 | 72 | ||
73 | if (len <= 0) | 73 | if (len <= 0) |
74 | return; | 74 | return; |
75 | 75 | ||
76 | dev->midi_out_buf[2] = len; | 76 | dev->midi_out_buf[2] = len; |
77 | dev->midi_out_urb.transfer_buffer_length = len+3; | 77 | dev->midi_out_urb.transfer_buffer_length = len+3; |
78 | 78 | ||
79 | ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC); | 79 | ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC); |
80 | if (ret < 0) | 80 | if (ret < 0) |
81 | log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," | 81 | log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," |
@@ -88,7 +88,7 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev, | |||
88 | static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) | 88 | static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) |
89 | { | 89 | { |
90 | struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; | 90 | struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; |
91 | 91 | ||
92 | if (up) { | 92 | if (up) { |
93 | dev->midi_out_substream = substream; | 93 | dev->midi_out_substream = substream; |
94 | if (!dev->midi_out_active) | 94 | if (!dev->midi_out_active) |
@@ -113,12 +113,12 @@ static struct snd_rawmidi_ops snd_usb_caiaq_midi_input = | |||
113 | .trigger = snd_usb_caiaq_midi_input_trigger, | 113 | .trigger = snd_usb_caiaq_midi_input_trigger, |
114 | }; | 114 | }; |
115 | 115 | ||
116 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, | 116 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, |
117 | int port, const char *buf, int len) | 117 | int port, const char *buf, int len) |
118 | { | 118 | { |
119 | if (!dev->midi_receive_substream) | 119 | if (!dev->midi_receive_substream) |
120 | return; | 120 | return; |
121 | 121 | ||
122 | snd_rawmidi_receive(dev->midi_receive_substream, buf, len); | 122 | snd_rawmidi_receive(dev->midi_receive_substream, buf, len); |
123 | } | 123 | } |
124 | 124 | ||
@@ -142,16 +142,16 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) | |||
142 | 142 | ||
143 | if (device->spec.num_midi_out > 0) { | 143 | if (device->spec.num_midi_out > 0) { |
144 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT; | 144 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT; |
145 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, | 145 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, |
146 | &snd_usb_caiaq_midi_output); | 146 | &snd_usb_caiaq_midi_output); |
147 | } | 147 | } |
148 | 148 | ||
149 | if (device->spec.num_midi_in > 0) { | 149 | if (device->spec.num_midi_in > 0) { |
150 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; | 150 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; |
151 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, | 151 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, |
152 | &snd_usb_caiaq_midi_input); | 152 | &snd_usb_caiaq_midi_input); |
153 | } | 153 | } |
154 | 154 | ||
155 | device->rmidi = rmidi; | 155 | device->rmidi = rmidi; |
156 | 156 | ||
157 | return 0; | 157 | return 0; |
@@ -160,7 +160,7 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) | |||
160 | void snd_usb_caiaq_midi_output_done(struct urb* urb) | 160 | void snd_usb_caiaq_midi_output_done(struct urb* urb) |
161 | { | 161 | { |
162 | struct snd_usb_caiaqdev *dev = urb->context; | 162 | struct snd_usb_caiaqdev *dev = urb->context; |
163 | 163 | ||
164 | dev->midi_out_active = 0; | 164 | dev->midi_out_active = 0; |
165 | if (urb->status != 0) | 165 | if (urb->status != 0) |
166 | return; | 166 | return; |
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 823296d7d578..c7b902358b7b 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -627,6 +627,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
627 | subs->hwptr_done += offs; | 627 | subs->hwptr_done += offs; |
628 | if (subs->hwptr_done >= runtime->buffer_size) | 628 | if (subs->hwptr_done >= runtime->buffer_size) |
629 | subs->hwptr_done -= runtime->buffer_size; | 629 | subs->hwptr_done -= runtime->buffer_size; |
630 | runtime->delay += offs; | ||
630 | spin_unlock_irqrestore(&subs->lock, flags); | 631 | spin_unlock_irqrestore(&subs->lock, flags); |
631 | urb->transfer_buffer_length = offs * stride; | 632 | urb->transfer_buffer_length = offs * stride; |
632 | if (period_elapsed) | 633 | if (period_elapsed) |
@@ -636,12 +637,22 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
636 | 637 | ||
637 | /* | 638 | /* |
638 | * process after playback data complete | 639 | * process after playback data complete |
639 | * - nothing to do | 640 | * - decrease the delay count again |
640 | */ | 641 | */ |
641 | static int retire_playback_urb(struct snd_usb_substream *subs, | 642 | static int retire_playback_urb(struct snd_usb_substream *subs, |
642 | struct snd_pcm_runtime *runtime, | 643 | struct snd_pcm_runtime *runtime, |
643 | struct urb *urb) | 644 | struct urb *urb) |
644 | { | 645 | { |
646 | unsigned long flags; | ||
647 | int stride = runtime->frame_bits >> 3; | ||
648 | int processed = urb->transfer_buffer_length / stride; | ||
649 | |||
650 | spin_lock_irqsave(&subs->lock, flags); | ||
651 | if (processed > runtime->delay) | ||
652 | runtime->delay = 0; | ||
653 | else | ||
654 | runtime->delay -= processed; | ||
655 | spin_unlock_irqrestore(&subs->lock, flags); | ||
645 | return 0; | 656 | return 0; |
646 | } | 657 | } |
647 | 658 | ||
@@ -1520,6 +1531,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) | |||
1520 | subs->hwptr_done = 0; | 1531 | subs->hwptr_done = 0; |
1521 | subs->transfer_done = 0; | 1532 | subs->transfer_done = 0; |
1522 | subs->phase = 0; | 1533 | subs->phase = 0; |
1534 | runtime->delay = 0; | ||
1523 | 1535 | ||
1524 | /* clear urbs (to be sure) */ | 1536 | /* clear urbs (to be sure) */ |
1525 | deactivate_urbs(subs, 0, 1); | 1537 | deactivate_urbs(subs, 0, 1); |
@@ -3279,6 +3291,25 @@ static int snd_usb_cm106_boot_quirk(struct usb_device *dev) | |||
3279 | return snd_usb_cm106_write_int_reg(dev, 2, 0x8004); | 3291 | return snd_usb_cm106_write_int_reg(dev, 2, 0x8004); |
3280 | } | 3292 | } |
3281 | 3293 | ||
3294 | /* | ||
3295 | * C-Media CM6206 is based on CM106 with two additional | ||
3296 | * registers that are not documented in the data sheet. | ||
3297 | * Values here are chosen based on sniffing USB traffic | ||
3298 | * under Windows. | ||
3299 | */ | ||
3300 | static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) | ||
3301 | { | ||
3302 | int err, reg; | ||
3303 | int val[] = {0x200c, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000}; | ||
3304 | |||
3305 | for (reg = 0; reg < ARRAY_SIZE(val); reg++) { | ||
3306 | err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]); | ||
3307 | if (err < 0) | ||
3308 | return err; | ||
3309 | } | ||
3310 | |||
3311 | return err; | ||
3312 | } | ||
3282 | 3313 | ||
3283 | /* | 3314 | /* |
3284 | * Setup quirks | 3315 | * Setup quirks |
@@ -3347,7 +3378,7 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip, | |||
3347 | [QUIRK_MIDI_YAMAHA] = snd_usb_create_midi_interface, | 3378 | [QUIRK_MIDI_YAMAHA] = snd_usb_create_midi_interface, |
3348 | [QUIRK_MIDI_MIDIMAN] = snd_usb_create_midi_interface, | 3379 | [QUIRK_MIDI_MIDIMAN] = snd_usb_create_midi_interface, |
3349 | [QUIRK_MIDI_NOVATION] = snd_usb_create_midi_interface, | 3380 | [QUIRK_MIDI_NOVATION] = snd_usb_create_midi_interface, |
3350 | [QUIRK_MIDI_RAW] = snd_usb_create_midi_interface, | 3381 | [QUIRK_MIDI_FASTLANE] = snd_usb_create_midi_interface, |
3351 | [QUIRK_MIDI_EMAGIC] = snd_usb_create_midi_interface, | 3382 | [QUIRK_MIDI_EMAGIC] = snd_usb_create_midi_interface, |
3352 | [QUIRK_MIDI_CME] = snd_usb_create_midi_interface, | 3383 | [QUIRK_MIDI_CME] = snd_usb_create_midi_interface, |
3353 | [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, | 3384 | [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, |
@@ -3565,6 +3596,12 @@ static void *snd_usb_audio_probe(struct usb_device *dev, | |||
3565 | goto __err_val; | 3596 | goto __err_val; |
3566 | } | 3597 | } |
3567 | 3598 | ||
3599 | /* C-Media CM6206 / CM106-Like Sound Device */ | ||
3600 | if (id == USB_ID(0x0d8c, 0x0102)) { | ||
3601 | if (snd_usb_cm6206_boot_quirk(dev) < 0) | ||
3602 | goto __err_val; | ||
3603 | } | ||
3604 | |||
3568 | /* | 3605 | /* |
3569 | * found a config. now register to ALSA | 3606 | * found a config. now register to ALSA |
3570 | */ | 3607 | */ |
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 36e4f7a29adc..8e7f78941ba6 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h | |||
@@ -153,7 +153,7 @@ enum quirk_type { | |||
153 | QUIRK_MIDI_YAMAHA, | 153 | QUIRK_MIDI_YAMAHA, |
154 | QUIRK_MIDI_MIDIMAN, | 154 | QUIRK_MIDI_MIDIMAN, |
155 | QUIRK_MIDI_NOVATION, | 155 | QUIRK_MIDI_NOVATION, |
156 | QUIRK_MIDI_RAW, | 156 | QUIRK_MIDI_FASTLANE, |
157 | QUIRK_MIDI_EMAGIC, | 157 | QUIRK_MIDI_EMAGIC, |
158 | QUIRK_MIDI_CME, | 158 | QUIRK_MIDI_CME, |
159 | QUIRK_MIDI_US122L, | 159 | QUIRK_MIDI_US122L, |
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index 26bad373fe65..2fb35cc22a30 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c | |||
@@ -1778,8 +1778,18 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip, | |||
1778 | umidi->usb_protocol_ops = &snd_usbmidi_novation_ops; | 1778 | umidi->usb_protocol_ops = &snd_usbmidi_novation_ops; |
1779 | err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); | 1779 | err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); |
1780 | break; | 1780 | break; |
1781 | case QUIRK_MIDI_RAW: | 1781 | case QUIRK_MIDI_FASTLANE: |
1782 | umidi->usb_protocol_ops = &snd_usbmidi_raw_ops; | 1782 | umidi->usb_protocol_ops = &snd_usbmidi_raw_ops; |
1783 | /* | ||
1784 | * Interface 1 contains isochronous endpoints, but with the same | ||
1785 | * numbers as in interface 0. Since it is interface 1 that the | ||
1786 | * USB core has most recently seen, these descriptors are now | ||
1787 | * associated with the endpoint numbers. This will foul up our | ||
1788 | * attempts to submit bulk/interrupt URBs to the endpoints in | ||
1789 | * interface 0, so we have to make sure that the USB core looks | ||
1790 | * again at interface 0 by calling usb_set_interface() on it. | ||
1791 | */ | ||
1792 | usb_set_interface(umidi->chip->dev, 0, 0); | ||
1783 | err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); | 1793 | err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); |
1784 | break; | 1794 | break; |
1785 | case QUIRK_MIDI_EMAGIC: | 1795 | case QUIRK_MIDI_EMAGIC: |
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h index 647ef5029651..f0f7624f9178 100644 --- a/sound/usb/usbquirks.h +++ b/sound/usb/usbquirks.h | |||
@@ -1470,6 +1470,41 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
1470 | } | 1470 | } |
1471 | }, | 1471 | }, |
1472 | { | 1472 | { |
1473 | /* Edirol M-16DX */ | ||
1474 | /* FIXME: This quirk gives a good-working capture stream but the | ||
1475 | * playback seems problematic because of lacking of sync | ||
1476 | * with capture stream. It needs to sync with the capture | ||
1477 | * clock. As now, you'll get frequent sound distortions | ||
1478 | * via the playback. | ||
1479 | */ | ||
1480 | USB_DEVICE(0x0582, 0x00c4), | ||
1481 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
1482 | .ifnum = QUIRK_ANY_INTERFACE, | ||
1483 | .type = QUIRK_COMPOSITE, | ||
1484 | .data = (const struct snd_usb_audio_quirk[]) { | ||
1485 | { | ||
1486 | .ifnum = 0, | ||
1487 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
1488 | }, | ||
1489 | { | ||
1490 | .ifnum = 1, | ||
1491 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
1492 | }, | ||
1493 | { | ||
1494 | .ifnum = 2, | ||
1495 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
1496 | .data = & (const struct snd_usb_midi_endpoint_info) { | ||
1497 | .out_cables = 0x0001, | ||
1498 | .in_cables = 0x0001 | ||
1499 | } | ||
1500 | }, | ||
1501 | { | ||
1502 | .ifnum = -1 | ||
1503 | } | ||
1504 | } | ||
1505 | } | ||
1506 | }, | ||
1507 | { | ||
1473 | /* BOSS GT-10 */ | 1508 | /* BOSS GT-10 */ |
1474 | USB_DEVICE(0x0582, 0x00da), | 1509 | USB_DEVICE(0x0582, 0x00da), |
1475 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | 1510 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { |
@@ -1868,7 +1903,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
1868 | .data = & (const struct snd_usb_audio_quirk[]) { | 1903 | .data = & (const struct snd_usb_audio_quirk[]) { |
1869 | { | 1904 | { |
1870 | .ifnum = 0, | 1905 | .ifnum = 0, |
1871 | .type = QUIRK_MIDI_RAW | 1906 | .type = QUIRK_MIDI_FASTLANE |
1872 | }, | 1907 | }, |
1873 | { | 1908 | { |
1874 | .ifnum = 1, | 1909 | .ifnum = 1, |
@@ -1951,6 +1986,14 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
1951 | } | 1986 | } |
1952 | }, | 1987 | }, |
1953 | { | 1988 | { |
1989 | USB_DEVICE(0x0ccd, 0x0028), | ||
1990 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
1991 | .vendor_name = "TerraTec", | ||
1992 | .product_name = "Aureon 5.1 MkII", | ||
1993 | .ifnum = QUIRK_NO_INTERFACE | ||
1994 | } | ||
1995 | }, | ||
1996 | { | ||
1954 | USB_DEVICE(0x0ccd, 0x0035), | 1997 | USB_DEVICE(0x0ccd, 0x0035), |
1955 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | 1998 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { |
1956 | .vendor_name = "Miditech", | 1999 | .vendor_name = "Miditech", |