Changeset 717
- Timestamp:
- Aug 7, 2022, 6:11:12 PM (3 years ago)
- Location:
- GPL/trunk
- Files:
-
- 109 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-next merged: 710-716
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/core/info.c
r679 r717 17 17 #include <linux/proc_fs.h> 18 18 #include <linux/mutex.h> 19 #include <stdarg.h>20 19 21 20 int snd_info_check_reserved_words(const char *str) -
GPL/trunk/alsa-kernel/core/init.c
r703 r717 139 139 EXPORT_SYMBOL_GPL(snd_device_initialize); 140 140 141 static int snd_card_init(struct snd_card *card, struct device *parent, 142 int idx, const char *xid, struct module *module, 143 size_t extra_size); 141 144 static int snd_card_do_free(struct snd_card *card); 142 145 static const struct attribute_group card_dev_attr_group; … … 168 171 struct snd_card *card; 169 172 int err; 170 #ifdef CONFIG_SND_DEBUG171 char name[8];172 #endif173 173 174 174 if (snd_BUG_ON(!card_ret)) … … 181 181 if (!card) 182 182 return -ENOMEM; 183 184 err = snd_card_init(card, parent, idx, xid, module, extra_size); 185 if (err < 0) { 186 kfree(card); 187 return err; 188 } 189 190 *card_ret = card; 191 return 0; 192 } 193 EXPORT_SYMBOL(snd_card_new); 194 195 static void __snd_card_release(struct device *dev, void *data) 196 { 197 snd_card_free(data); 198 } 199 200 /** 201 * snd_devm_card_new - managed snd_card object creation 202 * @parent: the parent device object 203 * @idx: card index (address) [0 ... (SNDRV_CARDS-1)] 204 * @xid: card identification (ASCII string) 205 * @module: top level module for locking 206 * @extra_size: allocate this extra size after the main soundcard structure 207 * @card_ret: the pointer to store the created card instance 208 * 209 * This function works like snd_card_new() but manages the allocated resource 210 * via devres, i.e. you don't need to free explicitly. 211 * 212 * When a snd_card object is created with this function and registered via 213 * snd_card_register(), the very first devres action to call snd_card_free() 214 * is added automatically. In that way, the resource disconnection is assured 215 * at first, then released in the expected order. 216 * 217 * If an error happens at the probe before snd_card_register() is called and 218 * there have been other devres resources, you'd need to free the card manually 219 * via snd_card_free() call in the error; otherwise it may lead to UAF due to 220 * devres call orders. You can use snd_card_free_on_error() helper for 221 * handling it more easily. 222 */ 223 int snd_devm_card_new(struct device *parent, int idx, const char *xid, 224 struct module *module, size_t extra_size, 225 struct snd_card **card_ret) 226 { 227 struct snd_card *card; 228 int err; 229 230 *card_ret = NULL; 231 card = devres_alloc(__snd_card_release, sizeof(*card) + extra_size, 232 GFP_KERNEL); 233 if (!card) 234 return -ENOMEM; 235 card->managed = true; 236 err = snd_card_init(card, parent, idx, xid, module, extra_size); 237 if (err < 0) { 238 devres_free(card); 239 return err; 240 } 241 devres_add(parent, card); 242 243 *card_ret = card; 244 return 0; 245 } 246 EXPORT_SYMBOL_GPL(snd_devm_card_new); 247 248 /** 249 * snd_card_free_on_error - a small helper for handling devm probe errors 250 * @dev: the managed device object 251 * @ret: the return code from the probe callback 252 * 253 * This function handles the explicit snd_card_free() call at the error from 254 * the probe callback. It's just a small helper for simplifying the error 255 * handling with the managed devices. 256 */ 257 int snd_card_free_on_error(struct device *dev, int ret) 258 { 259 struct snd_card *card; 260 261 if (!ret) 262 return 0; 263 card = devres_find(dev, __snd_card_release, NULL, NULL); 264 if (card) 265 snd_card_free(card); 266 return ret; 267 } 268 EXPORT_SYMBOL_GPL(snd_card_free_on_error); 269 270 static int snd_card_init(struct snd_card *card, struct device *parent, 271 int idx, const char *xid, struct module *module, 272 size_t extra_size) 273 { 274 int err; 275 #ifdef CONFIG_SND_DEBUG 276 char name[8]; 277 #endif 278 183 279 if (extra_size > 0) 184 280 card->private_data = (char *)card + sizeof(struct snd_card); … … 202 298 dev_err(parent, "cannot find the slot for index %d (range 0-%i), error: %d\n", 203 299 idx, snd_ecards_limit - 1, err); 204 kfree(card);205 300 return err; 206 301 } … … 261 356 card->debugfs_root = debugfs_create_dir(name, sound_debugfs_root); 262 357 #endif 263 264 *card_ret = card;265 358 return 0; 266 359 … … 271 364 return err; 272 365 } 273 EXPORT_SYMBOL(snd_card_new);274 366 275 367 /** … … 489 581 static int snd_card_do_free(struct snd_card *card) 490 582 { 583 card->releasing = true; 491 584 #if IS_ENABLED(CONFIG_SND_MIXER_OSS) 492 585 if (snd_mixer_oss_notify_callback) … … 506 599 if (card->release_completion) 507 600 complete(card->release_completion); 508 kfree(card); 601 if (!card->managed) 602 kfree(card); 509 603 return 0; 510 604 } … … 546 640 DECLARE_COMPLETION_ONSTACK(released); 547 641 int ret; 642 643 /* The call of snd_card_free() is allowed from various code paths; 644 * a manual call from the driver and the call via devres_free, and 645 * we need to avoid double-free. Moreover, the release via devres 646 * may call snd_card_free() twice due to its nature, we need to have 647 * the check here at the beginning. 648 */ 649 if (card->releasing) 650 return 0; 548 651 549 652 card->release_completion = &released; … … 755 858 EXPORT_SYMBOL_GPL(snd_card_add_dev_attr); 756 859 860 static void trigger_card_free(void *data) 861 { 862 snd_card_free(data); 863 } 864 757 865 /** 758 866 * snd_card_register - register the soundcard … … 778 886 return err; 779 887 card->registered = true; 888 } else { 889 if (card->managed) 890 devm_remove_action(card->dev, trigger_card_free, card); 891 } 892 893 if (card->managed) { 894 err = devm_add_action(card->dev, trigger_card_free, card); 895 if (err < 0) 896 return err; 780 897 } 781 898 -
GPL/trunk/alsa-kernel/core/jack.c
r695 r717 43 43 struct snd_jack *jack = device->device_data; 44 44 45 if (!jack->input_dev) 45 mutex_lock(&jack->input_dev_lock); 46 if (!jack->input_dev) { 47 mutex_unlock(&jack->input_dev_lock); 46 48 return 0; 49 } 47 50 48 51 /* If the input device is registered with the input subsystem … … 53 56 input_free_device(jack->input_dev); 54 57 jack->input_dev = NULL; 58 mutex_unlock(&jack->input_dev_lock); 55 59 #endif /* CONFIG_SND_JACK_INPUT_DEV */ 56 60 return 0; … … 63 67 struct snd_jack_kctl *jack_kctl, *tmp_jack_kctl; 64 68 69 down_write(&card->controls_rwsem); 65 70 list_for_each_entry_safe(jack_kctl, tmp_jack_kctl, &jack->kctl_list, list, struct snd_jack_kctl) { 66 71 list_del_init(&jack_kctl->list); 67 72 snd_ctl_remove(card, jack_kctl->kctl); 68 73 } 74 up_write(&card->controls_rwsem); 75 69 76 if (jack->private_free) 70 77 jack->private_free(jack); … … 88 95 card->shortname, jack->id); 89 96 90 if (!jack->input_dev) 97 mutex_lock(&jack->input_dev_lock); 98 if (!jack->input_dev) { 99 mutex_unlock(&jack->input_dev_lock); 91 100 return 0; 101 } 92 102 93 103 jack->input_dev->name = jack->name; … … 114 124 jack->registered = 1; 115 125 126 mutex_unlock(&jack->input_dev_lock); 116 127 return err; 117 128 } … … 510 521 511 522 jack->id = kstrdup(id, GFP_KERNEL); 512 513 /* don't creat input device for phantom jack */ 523 if (jack->id == NULL) { 524 kfree(jack); 525 return -ENOMEM; 526 } 527 528 #ifdef CONFIG_SND_JACK_INPUT_DEV 529 mutex_init(&jack->input_dev_lock); 530 531 /* don't create input device for phantom jack */ 514 532 if (!phantom_jack) { 515 #ifdef CONFIG_SND_JACK_INPUT_DEV516 533 int i; 517 534 … … 531 548 jack_switch_types[i]); 532 549 550 } 533 551 #endif /* CONFIG_SND_JACK_INPUT_DEV */ 534 }535 552 536 553 err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); … … 572 589 { 573 590 WARN_ON(jack->registered); 574 if (!jack->input_dev) 591 mutex_lock(&jack->input_dev_lock); 592 if (!jack->input_dev) { 593 mutex_unlock(&jack->input_dev_lock); 575 594 return; 595 } 576 596 577 597 jack->input_dev->dev.parent = parent; 598 mutex_unlock(&jack->input_dev_lock); 578 599 } 579 600 EXPORT_SYMBOL(snd_jack_set_parent); … … 623 644 /** 624 645 * snd_jack_report - Report the current status of a jack 646 * Note: This function uses mutexes and should be called from a 647 * context which can sleep (such as a workqueue). 625 648 * 626 649 * @jack: The jack to report status for … … 648 671 649 672 #ifdef CONFIG_SND_JACK_INPUT_DEV 650 if (!jack->input_dev) 673 mutex_lock(&jack->input_dev_lock); 674 if (!jack->input_dev) { 675 mutex_unlock(&jack->input_dev_lock); 651 676 return; 677 } 652 678 653 679 for (i = 0; i < ARRAY_SIZE(jack->key); i++) { … … 669 695 670 696 input_sync(jack->input_dev); 697 mutex_unlock(&jack->input_dev_lock); 671 698 #endif /* CONFIG_SND_JACK_INPUT_DEV */ 672 699 } -
GPL/trunk/alsa-kernel/core/memalloc.c
r703 r717 44 44 gfp_flags); 45 45 #ifdef CONFIG_X86 46 if (dmab->area && dmab->dev.type == SNDRV_DMA_TYPE_DEV_ UC)46 if (dmab->area && dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC) 47 47 set_memory_wc((unsigned long)dmab->area, 48 48 PAGE_ALIGN(size) >> PAGE_SHIFT); … … 71 71 { 72 72 #ifdef CONFIG_X86 73 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_ UC)73 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC) 74 74 set_memory_wb((unsigned long)dmab->area, 75 75 PAGE_ALIGN(dmab->bytes) >> PAGE_SHIFT); … … 204 204 #endif /* CONFIG_GENERIC_ALLOCATOR */ 205 205 case SNDRV_DMA_TYPE_DEV: 206 case SNDRV_DMA_TYPE_DEV_ UC:206 case SNDRV_DMA_TYPE_DEV_WC: 207 207 #ifndef TARGET_OS2 208 208 snd_malloc_dev_pages(dmab, size); … … 214 214 #ifdef CONFIG_SND_DMA_SGBUF 215 215 case SNDRV_DMA_TYPE_DEV_SG: 216 case SNDRV_DMA_TYPE_DEV_ UC_SG:216 case SNDRV_DMA_TYPE_DEV_WC_SG: 217 217 snd_malloc_sgbuf_pages(device, size, dmab, NULL); 218 218 break; … … 286 286 #endif /* CONFIG_GENERIC_ALLOCATOR */ 287 287 case SNDRV_DMA_TYPE_DEV: 288 case SNDRV_DMA_TYPE_DEV_ UC:288 case SNDRV_DMA_TYPE_DEV_WC: 289 289 #ifndef TARGET_OS2 290 290 snd_free_dev_pages(dmab); … … 296 296 #ifdef CONFIG_SND_DMA_SGBUF 297 297 case SNDRV_DMA_TYPE_DEV_SG: 298 case SNDRV_DMA_TYPE_DEV_ UC_SG:298 case SNDRV_DMA_TYPE_DEV_WC_SG: 299 299 snd_free_sgbuf_pages(dmab); 300 300 break; … … 337 337 } 338 338 #endif 339 340 /* called by devres */ 341 static void __snd_release_pages(struct device *dev, void *res) 342 { 343 snd_dma_free_pages(res); 344 } 345 346 /** 347 * snd_devm_alloc_pages - allocate the buffer and manage with devres 348 * @dev: the device pointer 349 * @type: the DMA buffer type 350 * @size: the buffer size to allocate 351 * 352 * Allocate buffer pages depending on the given type and manage using devres. 353 * The pages will be released automatically at the device removal. 354 * 355 * Unlike snd_dma_alloc_pages(), this function requires the real device pointer, 356 * hence it can't work with SNDRV_DMA_TYPE_CONTINUOUS or 357 * SNDRV_DMA_TYPE_VMALLOC type. 358 * 359 * The function returns the snd_dma_buffer object at success, or NULL if failed. 360 */ 361 struct snd_dma_buffer * 362 snd_devm_alloc_pages(struct device *dev, int type, size_t size) 363 { 364 struct snd_dma_buffer *dmab; 365 int err; 366 367 if (WARN_ON(type == SNDRV_DMA_TYPE_CONTINUOUS || 368 type == SNDRV_DMA_TYPE_VMALLOC)) 369 return NULL; 370 371 dmab = devres_alloc(__snd_release_pages, sizeof(*dmab), GFP_KERNEL); 372 if (!dmab) 373 return NULL; 374 375 err = snd_dma_alloc_pages(type, dev, size, dmab); 376 if (err < 0) { 377 devres_free(dmab); 378 return NULL; 379 } 380 381 devres_add(dev, dmab); 382 return dmab; 383 } 384 EXPORT_SYMBOL_GPL(snd_devm_alloc_pages); -
GPL/trunk/alsa-kernel/core/memalloc_local.h
r703 r717 4 4 5 5 struct snd_malloc_ops { 6 int(*alloc)(struct snd_dma_buffer *dmab, size_t size);6 void *(*alloc)(struct snd_dma_buffer *dmab, size_t size); 7 7 void (*free)(struct snd_dma_buffer *dmab); 8 8 dma_addr_t (*get_addr)(struct snd_dma_buffer *dmab, size_t offset); -
GPL/trunk/alsa-kernel/core/misc.c
r679 r717 113 113 const struct snd_pci_quirk *q; 114 114 115 for (q = list; q->subvendor ; q++) {115 for (q = list; q->subvendor || q->subdevice; q++) { 116 116 if (q->subvendor != vendor) 117 117 continue; -
GPL/trunk/alsa-kernel/core/oss/pcm_oss.c
r703 r717 152 152 * Return the maximum value for field PAR. 153 153 */ 154 static unsignedint154 static int 155 155 snd_pcm_hw_param_value_max(const struct snd_pcm_hw_params *params, 156 156 snd_pcm_hw_param_t var, int *dir) … … 691 691 struct snd_pcm_hw_params *slave_params) 692 692 { 693 size_t s; 694 size_t oss_buffer_size, oss_period_size, oss_periods; 695 size_t min_period_size, max_period_size; 693 ssize_t s; 694 ssize_t oss_buffer_size; 695 ssize_t oss_period_size, oss_periods; 696 ssize_t min_period_size, max_period_size; 696 697 struct snd_pcm_runtime *runtime = substream->runtime; 697 698 size_t oss_frame_size; … … 700 701 params_channels(oss_params) / 8; 701 702 703 oss_buffer_size = snd_pcm_hw_param_value_max(slave_params, 704 SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 705 NULL); 706 if (oss_buffer_size <= 0) 707 return -EINVAL; 702 708 oss_buffer_size = snd_pcm_plug_client_size(substream, 703 snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, NULL)) * oss_frame_size;704 if ( !oss_buffer_size)709 oss_buffer_size * oss_frame_size); 710 if (oss_buffer_size <= 0) 705 711 return -EINVAL; 706 712 oss_buffer_size = rounddown_pow_of_two(oss_buffer_size); … … 739 745 min_period_size = snd_pcm_plug_client_size(substream, 740 746 snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL)); 741 if (min_period_size ) {747 if (min_period_size > 0) { 742 748 min_period_size *= oss_frame_size; 743 749 min_period_size = roundup_pow_of_two(min_period_size); … … 748 754 max_period_size = snd_pcm_plug_client_size(substream, 749 755 snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL)); 750 if (max_period_size ) {756 if (max_period_size > 0) { 751 757 max_period_size *= oss_frame_size; 752 758 max_period_size = rounddown_pow_of_two(max_period_size); … … 762 768 763 769 s = snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIODS, NULL); 764 if ( runtime->oss.maxfrags && s > runtime->oss.maxfrags)770 if (s > 0 && runtime->oss.maxfrags && s > runtime->oss.maxfrags) 765 771 s = runtime->oss.maxfrags; 766 772 if (oss_periods > s) … … 778 784 if (oss_period_size < 16) 779 785 return -EINVAL; 786 787 /* don't allocate too large period; 1MB period must be enough */ 788 if (oss_period_size > 1024 * 1024) 789 return -ENOMEM; 790 780 791 runtime->oss.period_bytes = oss_period_size; 781 792 runtime->oss.period_frames = 1; … … 888 899 goto failure; 889 900 } 890 choose_rate(substream, sparams, runtime->oss.rate); 891 snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_CHANNELS, runtime->oss.channels, NULL); 901 902 err = choose_rate(substream, sparams, runtime->oss.rate); 903 if (err < 0) 904 goto failure; 905 err = snd_pcm_hw_param_near(substream, sparams, 906 SNDRV_PCM_HW_PARAM_CHANNELS, 907 runtime->oss.channels, NULL); 908 if (err < 0) 909 goto failure; 892 910 893 911 format = snd_pcm_oss_format_from(runtime->oss.format); … … 1040 1058 } 1041 1059 #endif 1042 oss_period_size *= oss_frame_size; 1043 1044 oss_buffer_size = oss_period_size * runtime->oss.periods; 1045 if (oss_buffer_size < 0) { 1060 oss_period_size = array_size(oss_period_size, oss_frame_size); 1061 oss_buffer_size = array_size(oss_period_size, runtime->oss.periods); 1062 if (oss_buffer_size <= 0) { 1046 1063 err = -EINVAL; 1047 1064 goto failure; … … 1970 1987 return -EINVAL; 1971 1988 fragshift = val & 0xffff; 1972 if (fragshift >= 31)1989 if (fragshift >= 25) /* should be large enough */ 1973 1990 return -EINVAL; 1974 1991 runtime->oss.fragshift = fragshift; … … 2066 2083 2067 2084 #ifdef OSS_DEBUG 2068 p cm_dbg(substream->pcm,"pcm_oss: trigger = 0x%x\n", trigger);2085 pr_debug("pcm_oss: trigger = 0x%x\n", trigger); 2069 2086 #endif 2070 2087 -
GPL/trunk/alsa-kernel/core/pcm.c
r703 r717 818 818 { 819 819 if (pstr->chmap_kctl) { 820 snd_ctl_remove(pstr->pcm->card, pstr->chmap_kctl); 820 struct snd_card *card = pstr->pcm->card; 821 822 down_write(&card->controls_rwsem); 823 snd_ctl_remove(card, pstr->chmap_kctl); 824 up_write(&card->controls_rwsem); 821 825 pstr->chmap_kctl = NULL; 822 826 } … … 973 977 974 978 runtime->status->state = SNDRV_PCM_STATE_OPEN; 979 mutex_init(&runtime->buffer_mutex); 980 atomic_set(&runtime->buffer_accessing, 0); 975 981 976 982 substream->runtime = runtime; … … 1006 1012 substream->runtime = NULL; 1007 1013 } 1014 mutex_destroy(&runtime->buffer_mutex); 1008 1015 kfree(runtime); 1009 1016 put_pid(substream->pid); -
GPL/trunk/alsa-kernel/core/pcm_lib.c
r703 r717 2303 2303 goto _end_unlock; 2304 2304 } 2305 #ifndef TARGET_OS2 2306 if (!atomic_inc_unless_negative(&runtime->buffer_accessing)) { 2307 err = -EBUSY; 2308 goto _end_unlock; 2309 } 2310 #endif 2305 2311 snd_pcm_stream_unlock_irq(substream); 2306 2312 err = writer(substream, appl_ofs, data, offset, frames, 2307 2313 transfer); 2308 2314 snd_pcm_stream_lock_irq(substream); 2315 #ifndef TARGET_OS2 2316 atomic_dec(&runtime->buffer_accessing); 2317 #endif 2309 2318 if (err < 0) 2310 2319 goto _end_unlock; -
GPL/trunk/alsa-kernel/core/pcm_memory.c
r703 r717 68 68 * the minimum size is snd_minimum_buffer. it should be power of 2. 69 69 */ 70 static int preallocate_pcm_pages(struct snd_pcm_substream *substream, size_t size) 70 static int preallocate_pcm_pages(struct snd_pcm_substream *substream, 71 size_t size, bool no_fallback) 71 72 { 72 73 struct snd_dma_buffer *dmab = &substream->dma_buffer; … … 80 81 if (err != -ENOMEM) 81 82 return err; 83 if (no_fallback) 84 break; 82 85 size >>= 1; 83 86 } while (size >= snd_minimum_buffer); … … 87 90 substream->stream ? 'c' : 'p', substream->number, 88 91 substream->pcm->name, orig_size); 89 return 0;92 return -ENOMEM; 90 93 } 91 94 … … 156 159 struct snd_dma_buffer new_dmab; 157 160 161 mutex_lock(&substream->pcm->open_mutex); 158 162 if (substream->runtime) { 159 163 buffer->error = -EBUSY; 160 return;164 goto unlock; 161 165 } 162 166 if (!snd_info_get_line(buffer, line, sizeof(line))) { … … 165 169 if ((size != 0 && size < 8192) || size > substream->dma_max) { 166 170 buffer->error = -EINVAL; 167 return;171 goto unlock; 168 172 } 169 173 if (substream->dma_buffer.bytes == size) 170 return;174 goto unlock; 171 175 memset(&new_dmab, 0, sizeof(new_dmab)); 172 176 new_dmab.dev = substream->dma_buffer.dev; … … 181 185 substream->stream ? 'c' : 'p', substream->number, 182 186 substream->pcm->name, size); 183 return;187 goto unlock; 184 188 } 185 189 substream->buffer_bytes_max = size; … … 193 197 buffer->error = -EINVAL; 194 198 } 199 unlock: 200 mutex_unlock(&substream->pcm->open_mutex); 195 201 } 196 202 … … 223 229 * pre-allocate the buffer and create a proc file for the substream 224 230 */ 225 static voidpreallocate_pages(struct snd_pcm_substream *substream,231 static int preallocate_pages(struct snd_pcm_substream *substream, 226 232 int type, struct device *data, 227 233 size_t size, size_t max, bool managed) 228 234 { 235 int err; 236 229 237 if (snd_BUG_ON(substream->dma_buffer.dev.type)) 230 return ;238 return -EINVAL; 231 239 232 240 substream->dma_buffer.dev.type = type; 233 241 substream->dma_buffer.dev.dev = data; 234 242 235 if (size > 0 && preallocate_dma && substream->number < maximum_substreams) 236 preallocate_pcm_pages(substream, size); 243 if (size > 0) { 244 if (!max) { 245 /* no fallback, only also inform -ENOMEM */ 246 err = preallocate_pcm_pages(substream, size, true); 247 if (err < 0) 248 return err; 249 } else if (preallocate_dma && 250 substream->number < maximum_substreams) { 251 err = preallocate_pcm_pages(substream, size, false); 252 if (err < 0 && err != -ENOMEM) 253 return err; 254 } 255 } 237 256 238 257 if (substream->dma_buffer.bytes > 0) … … 243 262 if (managed) 244 263 substream->managed_buffer_alloc = 1; 245 } 246 247 static void preallocate_pages_for_all(struct snd_pcm *pcm, int type, 264 return 0; 265 } 266 267 static int preallocate_pages_for_all(struct snd_pcm *pcm, int type, 248 268 void *data, size_t size, size_t max, 249 269 bool managed) 250 270 { 251 271 struct snd_pcm_substream *substream; 252 int stream; 253 254 for_each_pcm_substream(pcm, stream, substream) 255 preallocate_pages(substream, type, data, size, max, managed); 272 int stream, err; 273 274 for_each_pcm_substream(pcm, stream, substream) { 275 err = preallocate_pages(substream, type, data, size, max, managed); 276 if (err < 0) 277 return err; 278 } 279 return 0; 256 280 } 257 281 … … 310 334 * turns on the runtime buffer_changed flag for drivers changing their h/w 311 335 * parameters accordingly. 312 */ 313 void snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type, 336 * 337 * When @size is non-zero and @max is zero, this tries to allocate for only 338 * the exact buffer size without fallback, and may return -ENOMEM. 339 * Otherwise, the function tries to allocate smaller chunks if the allocation 340 * fails. This is the behavior of snd_pcm_set_fixed_buffer(). 341 * 342 * When both @size and @max are zero, the function only sets up the buffer 343 * for later dynamic allocations. It's used typically for buffers with 344 * SNDRV_DMA_TYPE_VMALLOC type. 345 * 346 * Upon successful buffer allocation and setup, the function returns 0. 347 */ 348 int snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type, 314 349 struct device *data, size_t size, size_t max) 315 350 { 316 preallocate_pages(substream, type, data, size, max, true);351 return preallocate_pages(substream, type, data, size, max, true); 317 352 } 318 353 EXPORT_SYMBOL(snd_pcm_set_managed_buffer); … … 330 365 * type and size, and set the managed_buffer_alloc flag to each substream. 331 366 */ 332 voidsnd_pcm_set_managed_buffer_all(struct snd_pcm *pcm, int type,333 334 335 { 336 preallocate_pages_for_all(pcm, type, data, size, max, true);367 int snd_pcm_set_managed_buffer_all(struct snd_pcm *pcm, int type, 368 struct device *data, 369 size_t size, size_t max) 370 { 371 return preallocate_pages_for_all(pcm, type, data, size, max, true); 337 372 } 338 373 EXPORT_SYMBOL(snd_pcm_set_managed_buffer_all); … … 377 412 dmab = &substream->dma_buffer; /* use the pre-allocated buffer */ 378 413 } else { 414 /* dma_max=0 means the fixed size preallocation */ 415 if (substream->dma_buffer.area && !substream->dma_max) 416 return -ENOMEM; 379 417 dmab = kzalloc(sizeof(*dmab), GFP_KERNEL); 380 418 if (! dmab) … … 409 447 int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) 410 448 { 411 struct snd_card *card = substream->pcm->card;412 449 struct snd_pcm_runtime *runtime; 413 450 … … 418 455 return 0; 419 456 if (runtime->dma_buffer_p != &substream->dma_buffer) { 457 struct snd_card *card = substream->pcm->card; 458 420 459 /* it's a newly allocated buffer. release it now. */ 421 460 do_free_pages(card, runtime->dma_buffer_p); -
GPL/trunk/alsa-kernel/core/pcm_misc.c
r703 r717 434 434 width = pcm_formats[(INT)format].phys; /* physical width */ 435 435 pat = pcm_formats[(INT)format].silence; 436 if (! width)436 if (!width || !pat) 437 437 return -EINVAL; 438 438 /* signed or 1 byte data */ -
GPL/trunk/alsa-kernel/core/pcm_native.c
r703 r717 248 248 static bool hw_support_mmap(struct snd_pcm_substream *substream) 249 249 { 250 struct snd_dma_buffer *dmabuf; 251 250 252 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP)) 251 253 return false; … … 254 256 return true; 255 257 256 switch (substream->dma_buffer.dev.type) { 258 dmabuf = snd_pcm_get_dma_buf(substream); 259 if (!dmabuf) 260 dmabuf = &substream->dma_buffer; 261 switch (dmabuf->dev.type) { 257 262 case SNDRV_DMA_TYPE_UNKNOWN: 258 263 /* we can't know the device, so just assume that the driver does … … 264 269 return true; 265 270 default: 266 return dma_can_mmap( substream->dma_buffer.dev.dev);271 return dma_can_mmap(dmabuf->dev.dev); 267 272 } 268 273 } … … 672 677 } 673 678 679 /* acquire buffer_mutex; if it's in r/w operation, return -EBUSY, otherwise 680 * block the further r/w operations 681 */ 682 static int snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime) 683 { 684 #ifndef TARGET_OS2 685 if (!atomic_dec_unless_positive(&runtime->buffer_accessing)) 686 return -EBUSY; 687 #endif 688 mutex_lock(&runtime->buffer_mutex); 689 return 0; /* keep buffer_mutex, unlocked by below */ 690 } 691 692 /* release buffer_mutex and clear r/w access flag */ 693 static void snd_pcm_buffer_access_unlock(struct snd_pcm_runtime *runtime) 694 { 695 mutex_unlock(&runtime->buffer_mutex); 696 atomic_inc(&runtime->buffer_accessing); 697 } 698 699 #if IS_ENABLED(CONFIG_SND_PCM_OSS) 700 #define is_oss_stream(substream) ((substream)->oss.oss) 701 #else 702 #define is_oss_stream(substream) false 703 #endif 704 674 705 static int snd_pcm_hw_params(struct snd_pcm_substream *substream, 675 706 struct snd_pcm_hw_params *params) … … 683 714 return -ENXIO; 684 715 runtime = substream->runtime; 716 err = snd_pcm_buffer_access_lock(runtime); 717 if (err < 0) 718 return err; 685 719 snd_pcm_stream_lock_irq(substream); 686 720 switch (runtime->status->state) { … … 688 722 case SNDRV_PCM_STATE_SETUP: 689 723 case SNDRV_PCM_STATE_PREPARED: 724 if (!is_oss_stream(substream) && 725 atomic_read(&substream->mmap_count)) 726 err = -EBADFD; 690 727 break; 691 728 default: 692 snd_pcm_stream_unlock_irq(substream);693 return -EBADFD;729 err = -EBADFD; 730 break; 694 731 } 695 732 snd_pcm_stream_unlock_irq(substream); 696 #if IS_ENABLED(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS) 697 if (!substream->oss.oss) 698 #endif 699 if (atomic_read(&substream->mmap_count)) 700 return -EBADFD; 733 if (err) 734 goto unlock; 701 735 702 736 snd_pcm_sync_stop(substream, true); … … 786 820 cpu_latency_qos_add_request(&substream->latency_pm_qos_req, 787 821 usecs); 788 return0;822 err = 0; 789 823 _error: 790 /* hardware might be unusable from this time, 791 so we force application to retry to set 792 the correct hardware parameter settings */ 793 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); 794 if (substream->ops->hw_free != NULL) 795 substream->ops->hw_free(substream); 796 if (substream->managed_buffer_alloc) 797 snd_pcm_lib_free_pages(substream); 824 if (err) { 825 /* hardware might be unusable from this time, 826 * so we force application to retry to set 827 * the correct hardware parameter settings 828 */ 829 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); 830 if (substream->ops->hw_free != NULL) 831 substream->ops->hw_free(substream); 832 if (substream->managed_buffer_alloc) 833 snd_pcm_lib_free_pages(substream); 834 } 835 unlock: 836 snd_pcm_buffer_access_unlock(runtime); 798 837 return err; 799 838 } … … 835 874 { 836 875 struct snd_pcm_runtime *runtime; 837 int result ;876 int result = 0; 838 877 839 878 if (PCM_RUNTIME_CHECK(substream)) 840 879 return -ENXIO; 841 880 runtime = substream->runtime; 881 result = snd_pcm_buffer_access_lock(runtime); 882 if (result < 0) 883 return result; 842 884 snd_pcm_stream_lock_irq(substream); 843 885 switch (runtime->status->state) { 844 886 case SNDRV_PCM_STATE_SETUP: 845 887 case SNDRV_PCM_STATE_PREPARED: 888 if (atomic_read(&substream->mmap_count)) 889 result = -EBADFD; 846 890 break; 847 891 default: 848 snd_pcm_stream_unlock_irq(substream);849 return -EBADFD;892 result = -EBADFD; 893 break; 850 894 } 851 895 snd_pcm_stream_unlock_irq(substream); 852 if ( atomic_read(&substream->mmap_count))853 return -EBADFD;896 if (result) 897 goto unlock; 854 898 result = do_hw_free(substream); 855 899 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); 856 900 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); 901 unlock: 902 snd_pcm_buffer_access_unlock(runtime); 857 903 return result; 858 904 } … … 1181 1227 struct snd_pcm_substream *substream, 1182 1228 snd_pcm_state_t state, 1183 bool do_lock)1229 bool stream_lock) 1184 1230 { 1185 1231 struct snd_pcm_substream *s = NULL; … … 1188 1234 1189 1235 snd_pcm_group_for_each_entry(s, substream) { 1190 if (do_lock && s != substream) { 1191 if (s->pcm->nonatomic) 1236 if (s != substream) { 1237 if (!stream_lock) 1238 mutex_lock_nested(&s->runtime->buffer_mutex, depth); 1239 else if (s->pcm->nonatomic) 1192 1240 mutex_lock_nested(&s->self_group.mutex, depth); 1193 1241 else … … 1217 1265 } 1218 1266 _unlock: 1219 if (do_lock) { 1220 /* unlock streams */ 1221 snd_pcm_group_for_each_entry(s1, substream) { 1222 if (s1 != substream) { 1223 if (s1->pcm->nonatomic) 1224 mutex_unlock(&s1->self_group.mutex); 1225 else 1226 spin_unlock(&s1->self_group.lock); 1227 } 1228 if (s1 == s) /* end */ 1229 break; 1267 /* unlock streams */ 1268 snd_pcm_group_for_each_entry(s1, substream) { 1269 if (s1 != substream) { 1270 if (!stream_lock) 1271 mutex_unlock(&s1->runtime->buffer_mutex); 1272 else if (s1->pcm->nonatomic) 1273 mutex_unlock(&s1->self_group.mutex); 1274 else 1275 spin_unlock(&s1->self_group.lock); 1230 1276 } 1277 if (s1 == s) /* end */ 1278 break; 1231 1279 } 1232 1280 return res; … … 1358 1406 /* Guarantee the group members won't change during non-atomic action */ 1359 1407 down_read(&snd_pcm_link_rwsem); 1408 res = snd_pcm_buffer_access_lock(substream->runtime); 1409 if (res < 0) 1410 goto unlock; 1360 1411 if (snd_pcm_stream_linked(substream)) 1361 1412 res = snd_pcm_action_group(ops, substream, state, false); 1362 1413 else 1363 1414 res = snd_pcm_action_single(ops, substream, state); 1415 snd_pcm_buffer_access_unlock(substream->runtime); 1416 unlock: 1364 1417 up_read(&snd_pcm_link_rwsem); 1365 1418 return res; … … 1851 1904 if (err < 0) 1852 1905 return err; 1906 snd_pcm_stream_lock_irq(substream); 1853 1907 runtime->hw_ptr_base = 0; 1854 1908 runtime->hw_ptr_interrupt = runtime->status->hw_ptr - … … 1856 1910 runtime->silence_start = runtime->status->hw_ptr; 1857 1911 runtime->silence_filled = 0; 1912 snd_pcm_stream_unlock_irq(substream); 1858 1913 return 0; 1859 1914 } … … 1863 1918 { 1864 1919 struct snd_pcm_runtime *runtime = substream->runtime; 1920 snd_pcm_stream_lock_irq(substream); 1865 1921 runtime->control->appl_ptr = runtime->status->hw_ptr; 1866 1922 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 1867 1923 runtime->silence_size > 0) 1868 1924 snd_pcm_playback_silence(substream, ULONG_MAX); 1925 snd_pcm_stream_unlock_irq(substream); 1869 1926 } 1870 1927 … … 3666 3723 static bool pcm_status_mmap_allowed(struct snd_pcm_file *pcm_file) 3667 3724 { 3725 /* If drivers require the explicit sync (typically for non-coherent 3726 * pages), we have to disable the mmap of status and control data 3727 * to enforce the control via SYNC_PTR ioctl. 3728 */ 3729 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) 3730 return false; 3668 3731 /* See pcm_control_mmap_allowed() below. 3669 3732 * Since older alsa-lib requires both status and control mmaps to be … … 3679 3742 { 3680 3743 if (pcm_file->no_compat_mmap) 3744 return false; 3745 /* see above */ 3746 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) 3681 3747 return false; 3682 3748 /* Disallow the control mmap when SYNC_APPLPTR flag is set; -
GPL/trunk/alsa-kernel/core/rawmidi.c
r703 r717 465 465 goto __error; 466 466 } 467 rawmidi_file->user_pversion = 0; 467 468 init_waitqueue_entry(&wait, current); 468 469 add_wait_queue(&rmidi->open_wait, &wait); … … 894 895 } 895 896 } 897 case SNDRV_RAWMIDI_IOCTL_USER_PVERSION: 898 if (get_user(rfile->user_pversion, (unsigned int __user *)arg)) 899 return -EFAULT; 900 return 0; 901 896 902 case SNDRV_RAWMIDI_IOCTL_PARAMS: 897 903 { … … 900 906 if (copy_from_user(¶ms, argp, sizeof(struct snd_rawmidi_params))) 901 907 return -EFAULT; 908 if (rfile->user_pversion < SNDRV_PROTOCOL_VERSION(2, 0, 2)) { 909 params.mode = 0; 910 memset(params.reserved, 0, sizeof(params.reserved)); 911 } 902 912 switch (params.stream) { 903 913 case SNDRV_RAWMIDI_STREAM_OUTPUT: -
GPL/trunk/alsa-kernel/core/seq/seq_dummy.c
r703 r717 21 21 The routing can be done via aconnect program in alsa-utils. 22 22 23 Each client has a static client number 62(= SNDRV_SEQ_CLIENT_DUMMY).23 Each client has a static client number 14 (= SNDRV_SEQ_CLIENT_DUMMY). 24 24 If you want to auto-load this module, you may add the following alias 25 25 in your /etc/conf.modules file. 26 26 27 alias snd-seq-client- 62snd-seq-dummy28 29 The module is loaded on demand for client 62, or /proc/asound/seq/27 alias snd-seq-client-14 snd-seq-dummy 28 29 The module is loaded on demand for client 14, or /proc/asound/seq/ 30 30 is accessed. If you don't need this module to be loaded, alias 31 snd-seq-client- 62as "off". This will help modprobe.31 snd-seq-client-14 as "off". This will help modprobe. 32 32 33 33 The number of ports to be created can be specified via the module -
GPL/trunk/alsa-kernel/core/seq/seq_queue.c
r703 r717 236 236 /* -------------------------------------------------------- */ 237 237 238 #define MAX_CELL_PROCESSES_IN_QUEUE 1000 239 238 240 void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop) 239 241 { … … 242 244 snd_seq_tick_time_t cur_tick; 243 245 snd_seq_real_time_t cur_time; 246 int processed = 0; 244 247 245 248 if (q == NULL) … … 264 267 break; 265 268 snd_seq_dispatch_event(cell, atomic, hop); 269 if (++processed >= MAX_CELL_PROCESSES_IN_QUEUE) 270 goto out; /* the rest processed at the next batch */ 266 271 } 267 272 … … 273 278 break; 274 279 snd_seq_dispatch_event(cell, atomic, hop); 275 } 276 280 if (++processed >= MAX_CELL_PROCESSES_IN_QUEUE) 281 goto out; /* the rest processed at the next batch */ 282 } 283 284 out: 277 285 /* free lock */ 278 286 spin_lock_irqsave(&q->check_lock, flags); 279 287 if (q->check_again) { 280 288 q->check_again = 0; 281 spin_unlock_irqrestore(&q->check_lock, flags); 282 goto __again; 289 if (processed < MAX_CELL_PROCESSES_IN_QUEUE) { 290 spin_unlock_irqrestore(&q->check_lock, flags); 291 goto __again; 292 } 283 293 } 284 294 q->check_blocked = 0; -
GPL/trunk/alsa-kernel/core/seq_device.c
r695 r717 157 157 158 158 cancel_autoload_drivers(); 159 if (dev->private_free) 160 dev->private_free(dev); 159 161 put_device(&dev->dev); 160 162 return 0; … … 184 186 static void snd_seq_dev_release(struct device *dev) 185 187 { 186 struct snd_seq_device *sdev = to_seq_dev(dev); 187 188 if (sdev->private_free) 189 sdev->private_free(sdev); 190 kfree(sdev); 188 kfree(to_seq_dev(dev)); 191 189 } 192 190 -
GPL/trunk/alsa-kernel/core/sgbuf.c
r703 r717 53 53 54 54 tmpb.dev.type = SNDRV_DMA_TYPE_DEV; 55 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_ UC_SG)56 tmpb.dev.type = SNDRV_DMA_TYPE_DEV_ UC;55 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG) 56 tmpb.dev.type = SNDRV_DMA_TYPE_DEV_WC; 57 57 tmpb.dev.dev = sgbuf->dev; 58 58 for (i = 0; i < sgbuf->pages; i++) { … … 134 134 if (! sgbuf) 135 135 return NULL; 136 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_ UC_SG) {137 type = SNDRV_DMA_TYPE_DEV_ UC;136 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG) { 137 type = SNDRV_DMA_TYPE_DEV_WC; 138 138 #ifdef pgprot_noncached 139 139 prot = pgprot_noncached(PAGE_KERNEL); -
GPL/trunk/alsa-kernel/core/timer.c
r695 r717 626 626 return -EINVAL; 627 627 spin_lock_irqsave(&timer->lock, flags); 628 list_del_init(&timeri->ack_list); 629 list_del_init(&timeri->active_list); 628 630 if (!(timeri->flags & (SNDRV_TIMER_IFLG_RUNNING | 629 631 SNDRV_TIMER_IFLG_START))) { … … 631 633 goto unlock; 632 634 } 633 list_del_init(&timeri->ack_list);634 list_del_init(&timeri->active_list);635 635 if (timer->card && timer->card->shutdown) 636 636 goto unlock; … … 667 667 { 668 668 unsigned long flags; 669 bool running; 669 670 670 671 spin_lock_irqsave(&slave_active_lock, flags); 671 if (!(timeri->flags & SNDRV_TIMER_IFLG_RUNNING)) { 672 spin_unlock_irqrestore(&slave_active_lock, flags); 673 return -EBUSY; 674 } 672 running = timeri->flags & SNDRV_TIMER_IFLG_RUNNING; 675 673 timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING; 676 674 if (timeri->timer) { … … 678 676 list_del_init(&timeri->ack_list); 679 677 list_del_init(&timeri->active_list); 680 snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP : 681 SNDRV_TIMER_EVENT_PAUSE); 678 if (running) 679 snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP : 680 SNDRV_TIMER_EVENT_PAUSE); 682 681 spin_unlock(&timeri->timer->lock); 683 682 } 684 683 spin_unlock_irqrestore(&slave_active_lock, flags); 685 return 0;684 return running ? 0 : -EBUSY; 686 685 } 687 686 -
GPL/trunk/alsa-kernel/drivers/mpu401/mpu401.c
r703 r717 72 72 73 73 *rcard = NULL; 74 err = snd_ card_new(devptr, index[dev], id[dev], THIS_MODULE,75 74 err = snd_devm_card_new(devptr, index[dev], id[dev], THIS_MODULE, 75 0, &card); 76 76 if (err < 0) 77 77 return err; … … 89 89 if (err < 0) { 90 90 printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); 91 goto _err;91 return err; 92 92 } 93 93 94 94 *rcard = card; 95 95 return 0; 96 97 _err:98 snd_card_free(card);99 return err;100 96 } 101 97 … … 118 114 return err; 119 115 err = snd_card_register(card); 120 if (err < 0) { 121 snd_card_free(card); 122 return err; 123 } 116 if (err < 0) 117 return err; 124 118 platform_set_drvdata(devptr, card); 125 return 0;126 }127 128 static int snd_mpu401_remove(struct platform_device *devptr)129 {130 snd_card_free(platform_get_drvdata(devptr));131 119 return 0; 132 120 } … … 136 124 static struct platform_driver snd_mpu401_driver = { 137 125 .probe = snd_mpu401_probe, 138 .remove = snd_mpu401_remove,139 126 .driver = { 140 127 .name = SND_MPU401_DRIVER, … … 197 184 return err; 198 185 err = snd_card_register(card); 199 if (err < 0) { 200 snd_card_free(card); 186 if (err < 0) 201 187 return err; 202 }203 188 pnp_set_drvdata(pnp_dev, card); 204 189 snd_mpu401_devices++; … … 209 194 } 210 195 211 static void snd_mpu401_pnp_remove(struct pnp_dev *dev)212 {213 struct snd_card *card = (struct snd_card *) pnp_get_drvdata(dev);214 215 snd_card_disconnect(card);216 snd_card_free_when_closed(card);217 }218 219 196 static struct pnp_driver snd_mpu401_pnp_driver = { 220 197 .name = "mpu401", 221 198 .id_table = snd_mpu401_pnpids, 222 199 .probe = snd_mpu401_pnp_probe, 223 .remove = snd_mpu401_pnp_remove,224 200 }; 225 201 #else -
GPL/trunk/alsa-kernel/drivers/opl3/opl3_midi.c
r703 r717 401 401 if (instr_4op) { 402 402 vp2 = &opl3->voices[voice + 3]; 403 if (vp ->state > 0) {403 if (vp2->state > 0) { 404 404 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + 405 405 voice_offset + 3); -
GPL/trunk/alsa-kernel/hda/ext/hdac_ext_stream.c
r695 r717 107 107 EXPORT_SYMBOL_GPL(snd_hdac_stream_free_all); 108 108 109 /** 110 * snd_hdac_ext_stream_decouple - decouple the hdac stream 111 * @bus: HD-audio core bus 112 * @stream: HD-audio ext core stream object to initialize 113 * @decouple: flag to decouple 114 */ 115 void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, 116 struct hdac_ext_stream *stream, bool decouple) 109 void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus, 110 struct hdac_ext_stream *stream, 111 bool decouple) 117 112 { 118 113 struct hdac_stream *hstream = &stream->hstream; … … 120 115 int mask = AZX_PPCTL_PROCEN(hstream->index); 121 116 122 spin_lock_irq(&bus->reg_lock);123 117 val = readw(bus->ppcap + AZX_REG_PP_PPCTL) & mask; 124 118 … … 129 123 130 124 stream->decoupled = decouple; 125 } 126 EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_decouple_locked); 127 128 /** 129 * snd_hdac_ext_stream_decouple - decouple the hdac stream 130 * @bus: HD-audio core bus 131 * @stream: HD-audio ext core stream object to initialize 132 * @decouple: flag to decouple 133 */ 134 void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, 135 struct hdac_ext_stream *stream, bool decouple) 136 { 137 spin_lock_irq(&bus->reg_lock); 138 snd_hdac_ext_stream_decouple_locked(bus, stream, decouple); 131 139 spin_unlock_irq(&bus->reg_lock); 132 140 } … … 253 261 } 254 262 263 spin_lock_irq(&bus->reg_lock); 255 264 list_for_each_entry(stream, &bus->stream_list, list) { 256 265 struct hdac_ext_stream *hstream = container_of(stream, … … 267 276 268 277 if (!hstream->link_locked) { 269 snd_hdac_ext_stream_decouple (bus, hstream, true);278 snd_hdac_ext_stream_decouple_locked(bus, hstream, true); 270 279 res = hstream; 271 280 break; … … 273 282 } 274 283 if (res) { 275 spin_lock_irq(&bus->reg_lock);276 284 res->link_locked = 1; 277 285 res->link_substream = substream; 278 spin_unlock_irq(&bus->reg_lock);279 }286 } 287 spin_unlock_irq(&bus->reg_lock); 280 288 return res; 281 289 } … … 293 301 } 294 302 303 spin_lock_irq(&bus->reg_lock); 295 304 list_for_each_entry(stream, &bus->stream_list, list) { 296 305 struct hdac_ext_stream *hstream = container_of(stream, … … 302 311 if (!stream->opened) { 303 312 if (!hstream->decoupled) 304 snd_hdac_ext_stream_decouple (bus, hstream, true);313 snd_hdac_ext_stream_decouple_locked(bus, hstream, true); 305 314 res = hstream; 306 315 break; … … 308 317 } 309 318 if (res) { 310 spin_lock_irq(&bus->reg_lock);311 319 res->hstream.opened = 1; 312 320 res->hstream.running = 0; 313 321 res->hstream.substream = substream; 314 spin_unlock_irq(&bus->reg_lock);315 }322 } 323 spin_unlock_irq(&bus->reg_lock); 316 324 317 325 return res; … … 379 387 380 388 case HDAC_EXT_STREAM_TYPE_HOST: 389 spin_lock_irq(&bus->reg_lock); 381 390 if (stream->decoupled && !stream->link_locked) 382 snd_hdac_ext_stream_decouple(bus, stream, false); 391 snd_hdac_ext_stream_decouple_locked(bus, stream, false); 392 spin_unlock_irq(&bus->reg_lock); 383 393 snd_hdac_stream_release(&stream->hstream); 384 394 break; 385 395 386 396 case HDAC_EXT_STREAM_TYPE_LINK: 397 spin_lock_irq(&bus->reg_lock); 387 398 if (stream->decoupled && !stream->hstream.opened) 388 snd_hdac_ext_stream_decouple(bus, stream, false); 389 spin_lock_irq(&bus->reg_lock); 399 snd_hdac_ext_stream_decouple_locked(bus, stream, false); 390 400 stream->link_locked = 0; 391 401 stream->link_substream = NULL; -
GPL/trunk/alsa-kernel/hda/hdac_controller.c
r695 r717 428 428 goto skip_reset; 429 429 430 /* clear STATESTS */ 431 snd_hdac_chip_writew(bus, STATESTS, STATESTS_INT_MASK); 430 /* clear STATESTS if not in reset */ 431 if (snd_hdac_chip_readb(bus, GCTL) & AZX_GCTL_RESET) 432 snd_hdac_chip_writew(bus, STATESTS, STATESTS_INT_MASK); 432 433 433 434 /* reset controller */ -
GPL/trunk/alsa-kernel/hda/hdac_device.c
r629 r717 675 675 { 0x17e8, "Chrontel" }, 676 676 { 0x1854, "LG" }, 677 { 0x19e5, "Huawei" }, 677 678 { 0x1aec, "Wolfson Microelectronics" }, 678 679 { 0x1af4, "QEMU" }, -
GPL/trunk/alsa-kernel/hda/hdac_stream.c
r695 r717 302 302 (substream->stream + 1); 303 303 304 spin_lock_irq(&bus->reg_lock); 304 305 list_for_each_entry(azx_dev, &bus->stream_list, list, struct hdac_stream) { 305 306 if (azx_dev->direction != substream->stream) … … 315 316 } 316 317 if (res) { 317 spin_lock_irq(&bus->reg_lock);318 318 res->opened = 1; 319 319 res->running = 0; 320 320 res->assigned_key = key; 321 321 res->substream = substream; 322 spin_unlock_irq(&bus->reg_lock);323 }322 } 323 spin_unlock_irq(&bus->reg_lock); 324 324 return res; 325 325 } … … 539 539 cc->mask = CLOCKSOURCE_MASK(32); 540 540 541 #ifndef TARGET_OS2 542 /* 543 * Calculate the optimal mult/shift values. The counter wraps 544 * around after ~178.9 seconds. 545 */ 546 clocks_calc_mult_shift(&cc->mult, &cc->shift, 24000000, 547 NSEC_PER_SEC, 178); 548 #else 541 549 /* 542 550 * Converting from 24 MHz to ns means applying a 125/3 factor. … … 551 559 cc->mult = 125; /* saturation after 195 years */ 552 560 cc->shift = 0; 553 561 #endif 554 562 nsec = 0; /* audio time is elapsed time since trigger */ 555 563 timecounter_init(tc, cc, nsec); -
GPL/trunk/alsa-kernel/include/sound/compress_driver.h
r695 r717 166 166 167 167 /* compress device register APIs */ 168 int snd_compress_register(struct snd_compr *device);169 int snd_compress_deregister(struct snd_compr *device);170 168 int snd_compress_new(struct snd_card *card, int device, 171 169 int type, const char *id, struct snd_compr *compr); -
GPL/trunk/alsa-kernel/include/sound/core.h
r703 r717 121 121 const struct attribute_group *dev_groups[4]; /* assigned sysfs attr */ 122 122 bool registered; /* card_dev is registered? */ 123 bool managed; /* managed via devres */ 124 bool releasing; /* during card free process */ 123 125 int sync_irq; /* assigned irq, used for PCM sync */ 124 126 wait_queue_head_t remove_sleep; … … 278 280 struct module *module, int extra_size, 279 281 struct snd_card **card_ret); 282 int snd_devm_card_new(struct device *parent, int idx, const char *xid, 283 struct module *module, size_t extra_size, 284 struct snd_card **card_ret); 280 285 281 286 int snd_card_disconnect(struct snd_card *card); … … 283 288 int snd_card_free(struct snd_card *card); 284 289 int snd_card_free_when_closed(struct snd_card *card); 290 int snd_card_free_on_error(struct device *dev, int ret); 285 291 void snd_card_set_id(struct snd_card *card, const char *id); 286 292 int snd_card_register(struct snd_card *card); … … 328 334 void snd_dma_disable(unsigned long dma); 329 335 unsigned int snd_dma_pointer(unsigned long dma, unsigned int size); 336 int snd_devm_request_dma(struct device *dev, int dma, const char *name); 330 337 #endif 331 338 -
GPL/trunk/alsa-kernel/include/sound/emu10k1.h
r679 r717 1702 1702 struct snd_dma_buffer ptb_pages; /* page table pages */ 1703 1703 struct snd_dma_device p16v_dma_dev; 1704 struct snd_dma_buffer p16v_buffer;1704 struct snd_dma_buffer *p16v_buffer; 1705 1705 1706 1706 struct snd_util_memhdr *memhdr; /* page allocation list */ … … 1797 1797 long max_cache_bytes, 1798 1798 int enable_ir, 1799 uint subsystem, 1800 struct snd_emu10k1 ** remu); 1799 uint subsystem); 1801 1800 1802 1801 int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device); … … 1804 1803 int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device); 1805 1804 int snd_p16v_pcm(struct snd_emu10k1 *emu, int device); 1806 int snd_p16v_free(struct snd_emu10k1 * emu);1807 1805 int snd_p16v_mixer(struct snd_emu10k1 * emu); 1808 1806 int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device); -
GPL/trunk/alsa-kernel/include/sound/emu8000.h
r679 r717 57 57 unsigned long port2; /* Port usually at base+0x400 */ 58 58 unsigned long port3; /* Port usually at base+0x800 */ 59 struct resource *res_port1;60 struct resource *res_port2;61 struct resource *res_port3;62 59 unsigned short last_reg;/* Last register command */ 63 60 spinlock_t reg_lock; -
GPL/trunk/alsa-kernel/include/sound/hda_codec.h
r695 r717 9 9 #define __SOUND_HDA_CODEC_H 10 10 11 #include <linux/ kref.h>11 #include <linux/refcount.h> 12 12 #include <linux/mod_devicetable.h> 13 13 #include <sound/info.h> … … 115 115 int (*check_power_status)(struct hda_codec *codec, hda_nid_t nid); 116 116 #endif 117 void (*reboot_notify)(struct hda_codec *codec);118 117 void (*stream_pm)(struct hda_codec *codec, hda_nid_t nid, bool on); 119 118 }; … … 168 167 /* private: */ 169 168 struct hda_codec *codec; 170 struct kref kref;171 169 struct list_head list; 170 unsigned int disconnected:1; 172 171 }; 173 172 … … 189 188 /* PCM to create, set by patch_ops.build_pcms callback */ 190 189 struct list_head pcm_list_head; 190 refcount_t pcm_ref; 191 wait_queue_head_t remove_sleep; 191 192 192 193 /* codec specific info */ … … 226 227 227 228 /* misc flags */ 229 unsigned int configured:1; /* codec was configured */ 228 230 unsigned int in_freeing:1; /* being released */ 229 231 unsigned int registered:1; /* codec was registered */ … … 423 425 static inline void snd_hda_codec_pcm_get(struct hda_pcm *pcm) 424 426 { 425 kref_get(&pcm->kref);427 refcount_inc(&pcm->codec->pcm_ref); 426 428 } 427 429 void snd_hda_codec_pcm_put(struct hda_pcm *pcm); -
GPL/trunk/alsa-kernel/include/sound/hdaudio_ext.h
r695 r717 52 52 * @link_locked: link is locked 53 53 * @link_prepared: link is prepared 54 * link_substream: link substream54 * @link_substream: link substream 55 55 */ 56 56 struct hdac_ext_stream { … … 89 89 int type); 90 90 void snd_hdac_ext_stream_release(struct hdac_ext_stream *azx_dev, int type); 91 void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus, 92 struct hdac_ext_stream *azx_dev, bool decouple); 91 93 void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, 92 94 struct hdac_ext_stream *azx_dev, bool decouple); -
GPL/trunk/alsa-kernel/include/sound/jack.h
r695 r717 63 63 #ifdef CONFIG_SND_JACK_INPUT_DEV 64 64 struct input_dev *input_dev; 65 struct mutex input_dev_lock; 65 66 int registered; 66 67 int type; -
GPL/trunk/alsa-kernel/include/sound/memalloc.h
r703 r717 32 32 #define SNDRV_DMA_TYPE_CONTINUOUS 1 /* continuous no-DMA memory */ 33 33 #define SNDRV_DMA_TYPE_DEV 2 /* generic device continuous */ 34 #define SNDRV_DMA_TYPE_DEV_ UC 5 /* continuous non-cahced */34 #define SNDRV_DMA_TYPE_DEV_WC 5 /* continuous write-combined */ 35 35 #ifdef CONFIG_SND_DMA_SGBUF 36 36 #define SNDRV_DMA_TYPE_DEV_SG 3 /* generic device SG-buffer */ 37 #define SNDRV_DMA_TYPE_DEV_ UC_SG 6 /* SG non-cached */37 #define SNDRV_DMA_TYPE_DEV_WC_SG 6 /* SG write-combined */ 38 38 #else 39 39 #define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_DEV /* no SG-buf support */ 40 #define SNDRV_DMA_TYPE_DEV_ UC_SG SNDRV_DMA_TYPE_DEV_UC40 #define SNDRV_DMA_TYPE_DEV_WC_SG SNDRV_DMA_TYPE_DEV_WC 41 41 #endif 42 42 #ifdef CONFIG_GENERIC_ALLOCATOR … … 80 80 unsigned int ofs, unsigned int size); 81 81 82 /* device-managed memory allocator */ 83 struct snd_dma_buffer *snd_devm_alloc_pages(struct device *dev, int type, 84 size_t size); 85 #ifdef TARGET_OS2 86 int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab); 87 void *snd_malloc_sgbuf_pages(struct device *device, 88 size_t size, struct snd_dma_buffer *dmab, 89 size_t *res_size); 90 91 #endif 82 92 #endif /* __SOUND_MEMALLOC_H */ 83 93 -
GPL/trunk/alsa-kernel/include/sound/pcm.h
r703 r717 399 399 struct fasync_struct *fasync; 400 400 bool stop_operating; /* sync_stop will be called */ 401 struct mutex buffer_mutex; /* protect for buffer changes */ 402 atomic_t buffer_accessing; /* >0: in r/w operation, <0: blocked */ 401 403 402 404 /* -- private section -- */ … … 1225 1227 int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream); 1226 1228 1227 void snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type, 1228 struct device *data, size_t size, size_t max); 1229 void snd_pcm_set_managed_buffer_all(struct snd_pcm *pcm, int type, 1230 struct device *data, 1231 size_t size, size_t max); 1229 int snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type, 1230 struct device *data, size_t size, size_t max); 1231 int snd_pcm_set_managed_buffer_all(struct snd_pcm *pcm, int type, 1232 struct device *data, 1233 size_t size, size_t max); 1234 1235 /** 1236 * snd_pcm_set_fixed_buffer - Preallocate and set up the fixed size PCM buffer 1237 * @substream: the pcm substream instance 1238 * @type: DMA type (SNDRV_DMA_TYPE_*) 1239 * @data: DMA type dependent data 1240 * @size: the requested pre-allocation size in bytes 1241 * 1242 * This is a variant of snd_pcm_set_managed_buffer(), but this pre-allocates 1243 * only the given sized buffer and doesn't allow re-allocation nor dynamic 1244 * allocation of a larger buffer unlike the standard one. 1245 * The function may return -ENOMEM error, hence the caller must check it. 1246 */ 1247 static inline int __must_check 1248 snd_pcm_set_fixed_buffer(struct snd_pcm_substream *substream, int type, 1249 struct device *data, size_t size) 1250 { 1251 return snd_pcm_set_managed_buffer(substream, type, data, size, 0); 1252 } 1253 1254 /** 1255 * snd_pcm_set_fixed_buffer_all - Preallocate and set up the fixed size PCM buffer 1256 * @pcm: the pcm instance 1257 * @type: DMA type (SNDRV_DMA_TYPE_*) 1258 * @data: DMA type dependent data 1259 * @size: the requested pre-allocation size in bytes 1260 * 1261 * Apply the set up of the fixed buffer via snd_pcm_set_fixed_buffer() for 1262 * all substream. If any of allocation fails, it returns -ENOMEM, hence the 1263 * caller must check the return value. 1264 */ 1265 static inline int __must_check 1266 snd_pcm_set_fixed_buffer_all(struct snd_pcm *pcm, int type, 1267 struct device *data, size_t size) 1268 { 1269 return snd_pcm_set_managed_buffer_all(pcm, type, data, size, 0); 1270 } 1232 1271 1233 1272 int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream, -
GPL/trunk/alsa-kernel/include/sound/pxa2xx-lib.h
r679 r717 15 15 extern int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream, 16 16 struct snd_pcm_hw_params *params); 17 extern int pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream);18 17 extern int pxa2xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd); 19 18 extern snd_pcm_uframes_t pxa2xx_pcm_pointer(struct snd_pcm_substream *substream); … … 21 20 extern int pxa2xx_pcm_open(struct snd_pcm_substream *substream); 22 21 extern int pxa2xx_pcm_close(struct snd_pcm_substream *substream); 23 extern int pxa2xx_pcm_mmap(struct snd_pcm_substream *substream, 24 struct vm_area_struct *vma); 25 extern int pxa2xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream); 26 extern void pxa2xx_pcm_free_dma_buffers(struct snd_pcm *pcm); 27 extern void pxa2xx_soc_pcm_free(struct snd_soc_component *component, 28 struct snd_pcm *pcm); 22 extern int pxa2xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm); 29 23 extern int pxa2xx_soc_pcm_new(struct snd_soc_component *component, 30 24 struct snd_soc_pcm_runtime *rtd); … … 36 30 struct snd_pcm_substream *substream, 37 31 struct snd_pcm_hw_params *params); 38 extern int pxa2xx_soc_pcm_hw_free(struct snd_soc_component *component,39 struct snd_pcm_substream *substream);40 32 extern int pxa2xx_soc_pcm_prepare(struct snd_soc_component *component, 41 33 struct snd_pcm_substream *substream); … … 45 37 pxa2xx_soc_pcm_pointer(struct snd_soc_component *component, 46 38 struct snd_pcm_substream *substream); 47 extern int pxa2xx_soc_pcm_mmap(struct snd_soc_component *component,48 struct snd_pcm_substream *substream,49 struct vm_area_struct *vma);50 39 51 40 /* AC97 */ -
GPL/trunk/alsa-kernel/include/sound/rawmidi.h
r703 r717 99 99 struct snd_rawmidi_substream *input; 100 100 struct snd_rawmidi_substream *output; 101 unsigned int user_pversion; /* supported protocol version */ 101 102 }; 102 103 -
GPL/trunk/alsa-kernel/include/sound/soc-topology.h
r703 r717 189 189 #else 190 190 191 static inline int snd_soc_tplg_component_remove(struct snd_soc_component *comp, 192 u32 index) 191 static inline int snd_soc_tplg_component_remove(struct snd_soc_component *comp) 193 192 { 194 193 return 0; -
GPL/trunk/alsa-kernel/include/sound/sof.h
r695 r717 102 102 103 103 int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd); 104 int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd); 104 105 105 106 #endif -
GPL/trunk/alsa-kernel/include/sound/version.h
r703 r717 1 1 /* include/version.h */ 2 #define CONFIG_SND_VERSION "5.1 4.7"2 #define CONFIG_SND_VERSION "5.15.59" 3 3 #define CONFIG_SND_DATE "" -
GPL/trunk/alsa-kernel/include/uapi/sound/asound.h
r703 r717 81 81 ****************************************************************************/ 82 82 83 #define AES_IEC958_STATUS_SIZE 24 84 83 85 struct snd_aes_iec958 { 84 unsigned char status[ 24];/* AES/IEC958 channel status bits */86 unsigned char status[AES_IEC958_STATUS_SIZE]; /* AES/IEC958 channel status bits */ 85 87 unsigned char subcode[147]; /* AES/IEC958 subcode bits */ 86 88 unsigned char pad; /* nothing */ … … 324 326 #define SNDRV_PCM_INFO_HAS_LINK_ESTIMATED_ATIME 0x04000000 /* report estimated link audio time */ 325 327 #define SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME 0x08000000 /* report synchronized audio/system time */ 328 #define SNDRV_PCM_INFO_EXPLICIT_SYNC 0x10000000 /* needs explicit sync of pointers and data */ 326 329 327 330 #define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */ … … 825 828 #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int) 826 829 #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info) 830 #define SNDRV_RAWMIDI_IOCTL_USER_PVERSION _IOW('W', 0x02, int) 827 831 #define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params) 828 832 #define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status) -
GPL/trunk/alsa-kernel/isa/sb/sb_common.c
r703 r717 169 169 } 170 170 171 static int snd_sbdsp_free(struct snd_sb *chip)172 {173 release_and_free_resource(chip->res_port);174 if (chip->irq >= 0)175 free_irq(chip->irq, (void *) chip);176 #ifdef CONFIG_ISA177 if (chip->dma8 >= 0) {178 disable_dma(chip->dma8);179 free_dma(chip->dma8);180 }181 if (chip->dma16 >= 0 && chip->dma16 != chip->dma8) {182 disable_dma(chip->dma16);183 free_dma(chip->dma16);184 }185 #endif186 kfree(chip);187 return 0;188 }189 190 static int snd_sbdsp_dev_free(struct snd_device *device)191 {192 struct snd_sb *chip = device->device_data;193 return snd_sbdsp_free(chip);194 }195 196 171 int snd_sbdsp_create(struct snd_card *card, 197 172 unsigned long port, … … 205 180 struct snd_sb *chip; 206 181 int err; 207 static const struct snd_device_ops ops = {208 .dev_free = snd_sbdsp_dev_free,209 };210 182 211 183 if (snd_BUG_ON(!r_chip)) 212 184 return -EINVAL; 213 185 *r_chip = NULL; 214 chip = kzalloc(sizeof(*chip), GFP_KERNEL);215 if ( chip == NULL)186 chip = devm_kzalloc(card->dev, sizeof(*chip), GFP_KERNEL); 187 if (!chip) 216 188 return -ENOMEM; 217 189 spin_lock_init(&chip->reg_lock); … … 224 196 chip->port = port; 225 197 226 if ( request_irq(irq, irq_handler,227 (hardware == SB_HW_ALS4000 ||228 hardware == SB_HW_CS5530) ?229 IRQF_SHARED : 0,230 "SoundBlaster", (void *) chip)) {198 if (devm_request_irq(card->dev, irq, irq_handler, 199 (hardware == SB_HW_ALS4000 || 200 hardware == SB_HW_CS5530) ? 201 IRQF_SHARED : 0, 202 "SoundBlaster", (void *) chip)) { 231 203 snd_printk(KERN_ERR "sb: can't grab irq %d\n", irq); 232 snd_sbdsp_free(chip);233 204 return -EBUSY; 234 205 } … … 239 210 goto __skip_allocation; 240 211 241 chip->res_port = request_region(port, 16, "SoundBlaster"); 212 chip->res_port = devm_request_region(card->dev, port, 16, 213 "SoundBlaster"); 242 214 if (!chip->res_port) { 243 215 snd_printk(KERN_ERR "sb: can't grab port 0x%lx\n", port); 244 snd_sbdsp_free(chip);245 216 return -EBUSY; 246 217 } 247 218 248 219 #ifdef CONFIG_ISA 249 if (dma8 >= 0 && request_dma(dma8, "SoundBlaster - 8bit")) { 220 if (dma8 >= 0 && snd_devm_request_dma(card->dev, dma8, 221 "SoundBlaster - 8bit")) { 250 222 snd_printk(KERN_ERR "sb: can't grab DMA8 %d\n", dma8); 251 snd_sbdsp_free(chip);252 223 return -EBUSY; 253 224 } … … 257 228 /* no duplex */ 258 229 dma16 = -1; 259 } else if (request_dma(dma16, "SoundBlaster - 16bit")) { 230 } else if (snd_devm_request_dma(card->dev, dma16, 231 "SoundBlaster - 16bit")) { 260 232 snd_printk(KERN_ERR "sb: can't grab DMA16 %d\n", dma16); 261 snd_sbdsp_free(chip);262 233 return -EBUSY; 263 234 } … … 270 241 chip->hardware = hardware; 271 242 err = snd_sbdsp_probe(chip); 272 if (err < 0) { 273 snd_sbdsp_free(chip); 243 if (err < 0) 274 244 return err; 275 }276 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);277 if (err < 0) {278 snd_sbdsp_free(chip);279 return err;280 }281 245 *r_chip = chip; 282 246 return 0; -
GPL/trunk/alsa-kernel/pci/ac97/ac97_codec.c
r703 r717 947 947 948 948 mutex_lock(&ac97->page_mutex); 949 ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31);950 ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31);949 ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31); 950 ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); 951 951 mutex_unlock(&ac97->page_mutex); 952 952 return 0; -
GPL/trunk/alsa-kernel/pci/ali5451/ali5451.c
r695 r717 1918 1918 #endif /* CONFIG_PM_SLEEP */ 1919 1919 1920 static int snd_ali_free(struct snd_ali * codec) 1921 { 1920 static void snd_ali_free(struct snd_card *card) 1921 { 1922 struct snd_ali *codec = card->private_data; 1923 1922 1924 if (codec->hw_initialized) 1923 1925 snd_ali_disable_address_interrupt(codec); 1924 if (codec->irq >= 0)1925 free_irq(codec->irq, codec);1926 if (codec->port)1927 pci_release_regions(codec->pci);1928 pci_disable_device(codec->pci);1929 #ifdef CONFIG_PM_SLEEP1930 kfree(codec->image);1931 #endif1932 1926 pci_dev_put(codec->pci_m1533); 1933 1927 pci_dev_put(codec->pci_m7101); 1934 kfree(codec);1935 return 0;1936 1928 } 1937 1929 … … 2021 2013 codec->port = pci_resource_start(codec->pci, 0); 2022 2014 2023 if (request_irq(codec->pci->irq, snd_ali_card_interrupt, 2024 IRQF_SHARED, KBUILD_MODNAME, codec)) { 2015 if (devm_request_irq(&codec->pci->dev, codec->pci->irq, 2016 snd_ali_card_interrupt, 2017 IRQF_SHARED, KBUILD_MODNAME, codec)) { 2025 2018 dev_err(codec->card->dev, "Unable to request irq.\n"); 2026 2019 return -EBUSY; … … 2031 2024 return 0; 2032 2025 } 2033 static int snd_ali_dev_free(struct snd_device *device)2034 {2035 struct snd_ali *codec = device->device_data;2036 snd_ali_free(codec);2037 return 0;2038 }2039 2026 2040 2027 static int snd_ali_create(struct snd_card *card, 2041 2028 struct pci_dev *pci, 2042 2029 int pcm_streams, 2043 int spdif_support, 2044 struct snd_ali **r_ali) 2045 { 2046 struct snd_ali *codec; 2030 int spdif_support) 2031 { 2032 struct snd_ali *codec = card->private_data; 2047 2033 int i, err; 2048 2034 unsigned short cmdw; 2049 static const struct snd_device_ops ops = {2050 .dev_free = snd_ali_dev_free,2051 };2052 2053 *r_ali = NULL;2054 2035 2055 2036 dev_dbg(card->dev, "creating ...\n"); 2056 2037 2057 2038 /* enable PCI device */ 2058 err = pci _enable_device(pci);2039 err = pcim_enable_device(pci); 2059 2040 if (err < 0) 2060 2041 return err; … … 2063 2044 dev_err(card->dev, 2064 2045 "architecture does not support 31bit PCI busmaster DMA\n"); 2065 pci_disable_device(pci);2066 2046 return -ENXIO; 2067 }2068 2069 codec = kzalloc(sizeof(*codec), GFP_KERNEL);2070 if (!codec) {2071 pci_disable_device(pci);2072 return -ENOMEM;2073 2047 } 2074 2048 … … 2097 2071 pci_write_config_word(pci, PCI_COMMAND, cmdw); 2098 2072 } 2099 pci_set_master(pci); 2100 2101 if (snd_ali_resources(codec)) { 2102 snd_ali_free(codec); 2073 2074 if (snd_ali_resources(codec)) 2103 2075 return -EBUSY; 2104 }2076 card->private_free = snd_ali_free; 2105 2077 2106 2078 codec->synth.chmap = 0; … … 2129 2101 if (!codec->pci_m1533) { 2130 2102 dev_err(card->dev, "cannot find ALi 1533 chip.\n"); 2131 snd_ali_free(codec);2132 2103 return -ENODEV; 2133 2104 } … … 2136 2107 if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) { 2137 2108 dev_err(card->dev, "cannot find ALi 7101 chip.\n"); 2138 snd_ali_free(codec);2139 2109 return -ENODEV; 2140 }2141 2142 dev_dbg(card->dev, "snd_device_new is called.\n");2143 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops);2144 if (err < 0) {2145 snd_ali_free(codec);2146 return err;2147 2110 } 2148 2111 … … 2158 2121 2159 2122 #ifdef CONFIG_PM_SLEEP 2160 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); 2123 codec->image = devm_kmalloc(&pci->dev, sizeof(*codec->image), 2124 GFP_KERNEL); 2161 2125 if (!codec->image) 2162 2126 dev_warn(card->dev, "can't allocate apm buffer\n"); … … 2165 2129 snd_ali_enable_address_interrupt(codec); 2166 2130 codec->hw_initialized = 1; 2167 2168 *r_ali = codec;2169 dev_dbg(card->dev, "created.\n");2170 2131 return 0; 2171 2132 } 2172 2133 2173 static int snd_ali_probe(struct pci_dev *pci,2174 const struct pci_device_id *pci_id)2134 static int __snd_ali_probe(struct pci_dev *pci, 2135 const struct pci_device_id *pci_id) 2175 2136 { 2176 2137 struct snd_card *card; … … 2180 2141 dev_dbg(&pci->dev, "probe ...\n"); 2181 2142 2182 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); 2143 err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE, 2144 sizeof(*codec), &card); 2183 2145 if (err < 0) 2184 2146 return err; 2185 2186 err = snd_ali_create(card, pci, pcm_channels, spdif, &codec); 2147 codec = card->private_data; 2148 2149 err = snd_ali_create(card, pci, pcm_channels, spdif); 2187 2150 if (err < 0) 2188 goto error; 2189 card->private_data = codec; 2151 return err; 2190 2152 2191 2153 dev_dbg(&pci->dev, "mixer building ...\n"); 2192 2154 err = snd_ali_mixer(codec); 2193 2155 if (err < 0) 2194 goto error;2156 return err; 2195 2157 2196 2158 dev_dbg(&pci->dev, "pcm building ...\n"); 2197 2159 err = snd_ali_build_pcms(codec); 2198 2160 if (err < 0) 2199 goto error;2161 return err; 2200 2162 2201 2163 snd_ali_proc_init(codec); … … 2210 2172 err = snd_card_register(card); 2211 2173 if (err < 0) 2212 goto error;2174 return err; 2213 2175 2214 2176 pci_set_drvdata(pci, card); 2215 2177 return 0; 2216 2217 error: 2218 snd_card_free(card); 2219 return err; 2220 } 2221 2222 static void snd_ali_remove(struct pci_dev *pci) 2223 { 2224 snd_card_free(pci_get_drvdata(pci)); 2178 } 2179 2180 static int snd_ali_probe(struct pci_dev *pci, 2181 const struct pci_device_id *pci_id) 2182 { 2183 return snd_card_free_on_error(&pci->dev, __snd_ali_probe(pci, pci_id)); 2225 2184 } 2226 2185 … … 2229 2188 .id_table = snd_ali_ids, 2230 2189 .probe = snd_ali_probe, 2231 .remove = snd_ali_remove,2232 2190 .driver = { 2233 2191 .pm = ALI_PM_OPS, -
GPL/trunk/alsa-kernel/pci/als4000.c
r703 r717 750 750 if (joystick_port[dev] == 1) { /* auto-detect */ 751 751 for (io_port = 0x200; io_port <= 0x218; io_port += 8) { 752 r = request_region(io_port, 8, "ALS4000 gameport"); 752 r = devm_request_region(&acard->pci->dev, io_port, 8, 753 "ALS4000 gameport"); 753 754 if (r) 754 755 break; … … 756 757 } else { 757 758 io_port = joystick_port[dev]; 758 r = request_region(io_port, 8, "ALS4000 gameport"); 759 r = devm_request_region(&acard->pci->dev, io_port, 8, 760 "ALS4000 gameport"); 759 761 } 760 762 … … 767 769 if (!gp) { 768 770 dev_err(&acard->pci->dev, "cannot allocate memory for gameport\n"); 769 release_and_free_resource(r);770 771 return -ENOMEM; 771 772 } … … 775 776 gameport_set_dev_parent(gp, &acard->pci->dev); 776 777 gp->io = io_port; 777 gameport_set_port_data(gp, r);778 778 779 779 /* Enable legacy joystick port */ … … 788 788 { 789 789 if (acard->gameport) { 790 struct resource *r = gameport_get_port_data(acard->gameport);791 792 790 gameport_unregister_port(acard->gameport); 793 791 acard->gameport = NULL; … … 795 793 /* disable joystick */ 796 794 snd_als4000_set_addr(acard->iobase, 0, 0, 0, 0); 797 798 release_and_free_resource(r);799 795 } 800 796 } … … 812 808 /* free resources */ 813 809 snd_als4000_free_gameport(acard); 814 pci_release_regions(acard->pci); 815 pci_disable_device(acard->pci); 816 } 817 818 static int snd_card_als4000_probe(struct pci_dev *pci, 819 const struct pci_device_id *pci_id) 810 } 811 812 static int __snd_card_als4000_probe(struct pci_dev *pci, 813 const struct pci_device_id *pci_id) 820 814 { 821 815 static int dev; … … 836 830 837 831 /* enable PCI device */ 838 err = pci _enable_device(pci);832 err = pcim_enable_device(pci); 839 833 if (err < 0) 840 834 return err; … … 843 837 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) { 844 838 dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n"); 845 pci_disable_device(pci);846 839 return -ENXIO; 847 840 } 848 841 849 842 err = pci_request_regions(pci, "ALS4000"); 850 if (err < 0) { 851 pci_disable_device(pci); 843 if (err < 0) 852 844 return err; 853 }854 845 iobase = pci_resource_start(pci, 0); 855 846 … … 858 849 pci_set_master(pci); 859 850 860 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 861 sizeof(*acard) /* private_data: acard */, 862 &card); 863 if (err < 0) { 864 pci_release_regions(pci); 865 pci_disable_device(pci); 851 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 852 sizeof(*acard) /* private_data: acard */, 853 &card); 854 if (err < 0) 866 855 return err; 867 }868 856 869 857 acard = card->private_data; … … 885 873 &chip); 886 874 if (err < 0) 887 goto out_err;875 return err; 888 876 acard->chip = chip; 889 877 … … 906 894 dev_err(&pci->dev, "no MPU-401 device at 0x%lx?\n", 907 895 iobase + ALS4K_IOB_30_MIDI_DATA); 908 goto out_err;896 return err; 909 897 } 910 898 /* FIXME: ALS4000 has interesting MPU401 configuration features … … 916 904 err = snd_als4000_pcm(chip, 0); 917 905 if (err < 0) 918 goto out_err;906 return err; 919 907 920 908 err = snd_sbmixer_new(chip); 921 909 if (err < 0) 922 goto out_err;910 return err; 923 911 924 912 if (snd_opl3_create(card, … … 932 920 err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); 933 921 if (err < 0) 934 goto out_err;922 return err; 935 923 } 936 924 … … 939 927 err = snd_card_register(card); 940 928 if (err < 0) 941 goto out_err;929 return err; 942 930 943 931 pci_set_drvdata(pci, card); 944 932 dev++; 945 err = 0; 946 goto out; 947 948 out_err: 949 snd_card_free(card); 950 951 out: 952 return err; 953 } 954 955 static void snd_card_als4000_remove(struct pci_dev *pci) 956 { 957 snd_card_free(pci_get_drvdata(pci)); 933 return 0; 934 } 935 936 static int snd_card_als4000_probe(struct pci_dev *pci, 937 const struct pci_device_id *pci_id) 938 { 939 return snd_card_free_on_error(&pci->dev, __snd_card_als4000_probe(pci, pci_id)); 958 940 } 959 941 … … 1000 982 .id_table = snd_als4000_ids, 1001 983 .probe = snd_card_als4000_probe, 1002 .remove = snd_card_als4000_remove,1003 984 .driver = { 1004 985 .pm = SND_ALS4000_PM_OPS, -
GPL/trunk/alsa-kernel/pci/atiixp.c
r703 r717 1541 1541 */ 1542 1542 1543 static int snd_atiixp_free(struct atiixp *chip) 1544 { 1545 if (chip->irq < 0) 1546 goto __hw_end; 1547 snd_atiixp_chip_stop(chip); 1548 1549 __hw_end: 1550 if (chip->irq >= 0) 1551 free_irq(chip->irq, chip); 1552 iounmap(chip->remap_addr); 1553 pci_release_regions(chip->pci); 1554 pci_disable_device(chip->pci); 1555 kfree(chip); 1556 return 0; 1557 } 1558 1559 static int snd_atiixp_dev_free(struct snd_device *device) 1560 { 1561 struct atiixp *chip = device->device_data; 1562 return snd_atiixp_free(chip); 1543 static void snd_atiixp_free(struct snd_card *card) 1544 { 1545 snd_atiixp_chip_stop(card->private_data); 1563 1546 } 1564 1547 … … 1566 1549 * constructor for chip instance 1567 1550 */ 1568 static int snd_atiixp_create(struct snd_card *card, 1569 struct pci_dev *pci, 1570 struct atiixp **r_chip) 1571 { 1572 static const struct snd_device_ops ops = { 1573 .dev_free = snd_atiixp_dev_free, 1574 }; 1575 struct atiixp *chip; 1551 static int snd_atiixp_init(struct snd_card *card, struct pci_dev *pci) 1552 { 1553 struct atiixp *chip = card->private_data; 1576 1554 int err; 1577 1555 1578 err = pci _enable_device(pci);1556 err = pcim_enable_device(pci); 1579 1557 if (err < 0) 1580 1558 return err; 1581 1582 chip = kzalloc(sizeof(*chip), GFP_KERNEL);1583 if (chip == NULL) {1584 pci_disable_device(pci);1585 return -ENOMEM;1586 }1587 1559 1588 1560 spin_lock_init(&chip->reg_lock); … … 1591 1563 chip->pci = pci; 1592 1564 chip->irq = -1; 1565 #ifndef TARGET_OS2 1566 err = pcim_iomap_regions(pci, 1 << 0, "ATI IXP AC97"); 1567 if (err < 0) 1568 return err; 1569 #else 1593 1570 err = pci_request_regions(pci, "ATI IXP AC97"); 1594 1571 if (err < 0) { … … 1597 1574 return err; 1598 1575 } 1576 #endif 1599 1577 chip->addr = pci_resource_start(pci, 0); 1578 #ifndef TARGET_OS2 1579 chip->remap_addr = pcim_iomap_table(pci)[0]; 1580 #else 1600 1581 chip->remap_addr = pci_ioremap_bar(pci, 0); 1601 if (chip->remap_addr == NULL) { 1602 dev_err(card->dev, "AC'97 space ioremap problem\n"); 1603 snd_atiixp_free(chip); 1604 return -EIO; 1605 } 1606 1607 if (request_irq(pci->irq, snd_atiixp_interrupt, IRQF_SHARED, 1608 KBUILD_MODNAME, chip)) { 1582 #endif 1583 if (devm_request_irq(&pci->dev, pci->irq, snd_atiixp_interrupt, 1584 IRQF_SHARED, KBUILD_MODNAME, chip)) { 1609 1585 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 1610 snd_atiixp_free(chip);1611 1586 return -EBUSY; 1612 1587 } 1613 1588 chip->irq = pci->irq; 1614 1589 card->sync_irq = chip->irq; 1590 card->private_free = snd_atiixp_free; 1615 1591 pci_set_master(pci); 1616 1592 1617 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 1618 if (err < 0) { 1619 snd_atiixp_free(chip); 1620 return err; 1621 } 1622 1623 *r_chip = chip; 1624 return 0; 1625 } 1626 1627 1628 static int snd_atiixp_probe(struct pci_dev *pci, 1629 const struct pci_device_id *pci_id) 1593 return 0; 1594 } 1595 1596 1597 static int __snd_atiixp_probe(struct pci_dev *pci, 1598 const struct pci_device_id *pci_id) 1630 1599 { 1631 1600 struct snd_card *card; … … 1633 1602 int err; 1634 1603 1635 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); 1604 err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE, 1605 sizeof(*chip), &card); 1636 1606 if (err < 0) 1637 1607 return err; 1608 chip = card->private_data; 1638 1609 1639 1610 strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA"); 1640 1611 strcpy(card->shortname, "ATI IXP"); 1641 err = snd_atiixp_ create(card, pci, &chip);1612 err = snd_atiixp_init(card, pci); 1642 1613 if (err < 0) 1643 goto __error; 1644 card->private_data = chip; 1614 return err; 1645 1615 1646 1616 err = snd_atiixp_aclink_reset(chip); 1647 1617 if (err < 0) 1648 goto __error;1618 return err; 1649 1619 1650 1620 chip->spdif_over_aclink = spdif_aclink; … … 1652 1622 err = snd_atiixp_mixer_new(chip, ac97_clock, ac97_quirk); 1653 1623 if (err < 0) 1654 goto __error;1624 return err; 1655 1625 1656 1626 err = snd_atiixp_pcm_new(chip); 1657 1627 if (err < 0) 1658 goto __error;1628 return err; 1659 1629 1660 1630 snd_atiixp_proc_init(chip); … … 1674 1644 err = snd_card_register(card); 1675 1645 if (err < 0) 1676 goto __error;1646 return err; 1677 1647 1678 1648 pci_set_drvdata(pci, card); 1679 1649 return 0; 1680 1681 __error: 1682 snd_card_free(card); 1683 return err; 1684 } 1685 1686 static void snd_atiixp_remove(struct pci_dev *pci) 1687 { 1688 snd_card_free(pci_get_drvdata(pci)); 1650 } 1651 1652 static int snd_atiixp_probe(struct pci_dev *pci, 1653 const struct pci_device_id *pci_id) 1654 { 1655 return snd_card_free_on_error(&pci->dev, __snd_atiixp_probe(pci, pci_id)); 1689 1656 } 1690 1657 … … 1693 1660 .id_table = snd_atiixp_ids, 1694 1661 .probe = snd_atiixp_probe, 1695 .remove = snd_atiixp_remove,1696 1662 .driver = { 1697 1663 .pm = SND_ATIIXP_PM_OPS, -
GPL/trunk/alsa-kernel/pci/au88x0/au88x0.c
r703 r717 124 124 // component-destructor 125 125 // (see "Management of Cards and Components") 126 static int snd_vortex_dev_free(struct snd_device *device)127 { 128 vortex_t *vortex = device->device_data;126 static void snd_vortex_free(struct snd_card *card) 127 { 128 vortex_t *vortex = card->private_data; 129 129 130 130 vortex_gameport_unregister(vortex); 131 131 vortex_core_shutdown(vortex); 132 // Take down PCI interface.133 free_irq(vortex->irq, vortex);134 iounmap(vortex->mmio);135 pci_release_regions(vortex->pci_dev);136 pci_disable_device(vortex->pci_dev);137 kfree(vortex);138 139 return 0;140 132 } 141 133 … … 143 135 // (see "Management of Cards and Components") 144 136 static int 145 snd_vortex_create(struct snd_card *card, struct pci_dev *pci , vortex_t ** rchip)146 { 147 vortex_t *chip ;137 snd_vortex_create(struct snd_card *card, struct pci_dev *pci) 138 { 139 vortex_t *chip = card->private_data; 148 140 int err; 149 static const struct snd_device_ops ops = {150 .dev_free = snd_vortex_dev_free,151 };152 153 *rchip = NULL;154 141 155 142 // check PCI availability (DMA). 156 err = pci _enable_device(pci);143 err = pcim_enable_device(pci); 157 144 if (err < 0) 158 145 return err; 159 146 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) { 160 147 dev_err(card->dev, "error to set DMA mask\n"); 161 pci_disable_device(pci);162 148 return -ENXIO; 163 }164 165 chip = kzalloc(sizeof(*chip), GFP_KERNEL);166 if (chip == NULL) {167 pci_disable_device(pci);168 return -ENOMEM;169 149 } 170 150 … … 173 153 // initialize the stuff 174 154 chip->pci_dev = pci; 175 chip->io = pci_resource_start(pci, 0);176 155 chip->vendor = pci->vendor; 177 156 chip->device = pci->device; … … 182 161 // Get MMIO area 183 162 // 184 err = pci _request_regions(pci, CARD_NAME_SHORT);163 err = pcim_iomap_regions(pci, 1 << 0, CARD_NAME_SHORT); 185 164 if (err) 186 goto regions_out; 187 188 chip->mmio = pci_ioremap_bar(pci, 0); 189 if (!chip->mmio) { 190 dev_err(card->dev, "MMIO area remap failed.\n"); 191 err = -ENOMEM; 192 goto ioremap_out; 193 } 165 return err; 166 167 chip->io = pci_resource_start(pci, 0); 168 chip->mmio = pcim_iomap_table(pci)[0]; 194 169 195 170 /* Init audio core. … … 199 174 if (err) { 200 175 dev_err(card->dev, "hw core init failed\n"); 201 goto core_out;202 } 203 204 err = request_irq(pci->irq, vortex_interrupt,205 IRQF_SHARED, KBUILD_MODNAME, chip);176 return err; 177 } 178 179 err = devm_request_irq(&pci->dev, pci->irq, vortex_interrupt, 180 IRQF_SHARED, KBUILD_MODNAME, chip); 206 181 if (err) { 207 182 dev_err(card->dev, "cannot grab irq\n"); 208 goto irq_out;183 return err; 209 184 } 210 185 chip->irq = pci->irq; 211 186 card->sync_irq = chip->irq; 187 card->private_free = snd_vortex_free; 212 188 213 189 pci_set_master(pci); 214 190 // End of PCI setup. 215 216 // Register alsa root device.217 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);218 if (err < 0)219 goto alloc_out;220 221 *rchip = chip;222 223 191 return 0; 224 225 alloc_out:226 free_irq(chip->irq, chip);227 irq_out:228 vortex_core_shutdown(chip);229 core_out:230 iounmap(chip->mmio);231 ioremap_out:232 pci_release_regions(chip->pci_dev);233 regions_out:234 pci_disable_device(chip->pci_dev);235 //FIXME: this not the right place to unregister the gameport236 vortex_gameport_unregister(chip);237 kfree(chip);238 return err;239 192 } 240 193 241 194 // constructor -- see "Constructor" sub-section 242 195 static int 243 snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)196 __snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 244 197 { 245 198 static int dev; … … 256 209 } 257 210 // (2) 258 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 259 0, &card); 260 if (err < 0) 261 return err; 211 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 212 sizeof(*chip), &card); 213 if (err < 0) 214 return err; 215 chip = card->private_data; 262 216 263 217 // (3) 264 err = snd_vortex_create(card, pci, &chip); 265 if (err < 0) { 266 snd_card_free(card); 267 return err; 268 } 218 err = snd_vortex_create(card, pci); 219 if (err < 0) 220 return err; 269 221 snd_vortex_workaround(pci, pcifix[dev]); 270 222 … … 277 229 // (4) Alloc components. 278 230 err = snd_vortex_mixer(chip); 279 if (err < 0) { 280 snd_card_free(card); 281 return err; 282 } 231 if (err < 0) 232 return err; 283 233 // ADB pcm. 284 234 err = snd_vortex_new_pcm(chip, VORTEX_PCM_ADB, NR_PCM); 285 if (err < 0) { 286 snd_card_free(card); 287 return err; 288 } 235 if (err < 0) 236 return err; 289 237 #ifndef CHIP_AU8820 290 238 // ADB SPDIF 291 239 err = snd_vortex_new_pcm(chip, VORTEX_PCM_SPDIF, 1); 292 if (err < 0) { 293 snd_card_free(card); 294 return err; 295 } 240 if (err < 0) 241 return err; 296 242 // A3D 297 243 err = snd_vortex_new_pcm(chip, VORTEX_PCM_A3D, NR_A3D); 298 if (err < 0) { 299 snd_card_free(card); 300 return err; 301 } 244 if (err < 0) 245 return err; 302 246 #endif 303 247 /* 304 248 // ADB I2S 305 249 if ((err = snd_vortex_new_pcm(chip, VORTEX_PCM_I2S, 1)) < 0) { 306 snd_card_free(card);307 250 return err; 308 251 } … … 311 254 // WT pcm. 312 255 err = snd_vortex_new_pcm(chip, VORTEX_PCM_WT, NR_WT); 313 if (err < 0) { 314 snd_card_free(card); 315 return err; 316 } 256 if (err < 0) 257 return err; 317 258 #endif 318 259 err = snd_vortex_midi(chip); 319 if (err < 0) { 320 snd_card_free(card); 321 return err; 322 } 260 if (err < 0) 261 return err; 323 262 324 263 vortex_gameport_register(chip); … … 343 282 // (5) 344 283 err = pci_read_config_word(pci, PCI_DEVICE_ID, &chip->device); 345 if (err < 0) { 346 snd_card_free(card); 347 return err; 348 } 284 if (err < 0) 285 return err; 349 286 err = pci_read_config_word(pci, PCI_VENDOR_ID, &chip->vendor); 350 if (err < 0) { 351 snd_card_free(card); 352 return err; 353 } 287 if (err < 0) 288 return err; 354 289 chip->rev = pci->revision; 355 290 #ifdef CHIP_AU8830 … … 360 295 dev_alert(card->dev, 361 296 "Please email the results of 'lspci -vv' to openvortex-dev@nongnu.org.\n"); 362 snd_card_free(card); 363 err = -ENODEV; 364 return err; 297 return -ENODEV; 365 298 } 366 299 #endif … … 368 301 // (6) 369 302 err = snd_card_register(card); 370 if (err < 0) { 371 snd_card_free(card); 372 return err; 373 } 303 if (err < 0) 304 return err; 374 305 // (7) 375 306 pci_set_drvdata(pci, card); … … 380 311 } 381 312 382 // destructor -- see "Destructor" sub-section 383 s tatic void snd_vortex_remove(struct pci_dev *pci)384 { 385 snd_card_free(pci_get_drvdata(pci));313 static int 314 snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 315 { 316 return snd_card_free_on_error(&pci->dev, __snd_vortex_probe(pci, pci_id)); 386 317 } 387 318 … … 391 322 .id_table = snd_vortex_ids, 392 323 .probe = snd_vortex_probe, 393 .remove = snd_vortex_remove,394 324 }; 395 325 -
GPL/trunk/alsa-kernel/pci/bt87x.c
r703 r717 666 666 }; 667 667 668 static int snd_bt87x_free(struct snd_bt87x *chip) 669 { 670 if (chip->mmio) 671 snd_bt87x_stop(chip); 672 if (chip->irq >= 0) 673 free_irq(chip->irq, chip); 674 iounmap(chip->mmio); 675 pci_release_regions(chip->pci); 676 pci_disable_device(chip->pci); 677 kfree(chip); 678 return 0; 679 } 680 681 static int snd_bt87x_dev_free(struct snd_device *device) 682 { 683 struct snd_bt87x *chip = device->device_data; 684 return snd_bt87x_free(chip); 668 static void snd_bt87x_free(struct snd_card *card) 669 { 670 struct snd_bt87x *chip = card->private_data; 671 672 snd_bt87x_stop(chip); 685 673 } 686 674 … … 704 692 705 693 static int snd_bt87x_create(struct snd_card *card, 706 struct pci_dev *pci, 707 struct snd_bt87x **rchip) 708 { 709 struct snd_bt87x *chip; 694 struct pci_dev *pci) 695 { 696 struct snd_bt87x *chip = card->private_data; 710 697 int err; 711 static const struct snd_device_ops ops = { 712 .dev_free = snd_bt87x_dev_free 713 }; 714 715 *rchip = NULL; 716 717 err = pci_enable_device(pci); 698 699 err = pcim_enable_device(pci); 718 700 if (err < 0) 719 701 return err; 720 702 721 chip = kzalloc(sizeof(*chip), GFP_KERNEL);722 if (!chip) {723 pci_disable_device(pci);724 return -ENOMEM;725 }726 703 chip->card = card; 727 704 chip->pci = pci; … … 729 706 spin_lock_init(&chip->reg_lock); 730 707 708 #ifndef TARGET_OS2 709 err = pcim_iomap_regions(pci, 1 << 0, "Bt87x audio"); 710 if (err < 0) 711 return err; 712 chip->mmio = pcim_iomap_table(pci)[0]; 713 #else 731 714 err = pci_request_regions(pci, "Bt87x audio"); 732 715 if (err < 0) { … … 736 719 } 737 720 chip->mmio = pci_ioremap_bar(pci, 0); 738 if (!chip->mmio) { 739 dev_err(card->dev, "cannot remap io memory\n"); 740 err = -ENOMEM; 741 goto fail; 742 } 743 721 #endif 744 722 chip->reg_control = CTL_A_PWRDN | CTL_DA_ES2 | 745 723 CTL_PKTP_16 | (15 << CTL_DA_SDR_SHIFT); … … 749 727 snd_bt87x_writel(chip, REG_INT_STAT, MY_INTERRUPTS); 750 728 751 err = request_irq(pci->irq, snd_bt87x_interrupt, IRQF_SHARED,752 KBUILD_MODNAME, chip);729 err = devm_request_irq(&pci->dev, pci->irq, snd_bt87x_interrupt, 730 IRQF_SHARED, KBUILD_MODNAME, chip); 753 731 if (err < 0) { 754 732 dev_err(card->dev, "cannot grab irq %d\n", pci->irq); 755 goto fail;733 return err; 756 734 } 757 735 chip->irq = pci->irq; 758 736 card->sync_irq = chip->irq; 737 card->private_free = snd_bt87x_free; 759 738 pci_set_master(pci); 760 739 761 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 762 if (err < 0) 763 goto fail; 764 765 *rchip = chip; 766 return 0; 767 768 fail: 769 snd_bt87x_free(chip); 770 return err; 740 return 0; 771 741 } 772 742 … … 854 824 } 855 825 856 static int snd_bt87x_probe(struct pci_dev *pci,857 const struct pci_device_id *pci_id)826 static int __snd_bt87x_probe(struct pci_dev *pci, 827 const struct pci_device_id *pci_id) 858 828 { 859 829 static int dev; … … 878 848 } 879 849 880 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,881 0, &card);850 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 851 sizeof(*chip), &card); 882 852 if (err < 0) 883 853 return err; 884 885 err = snd_bt87x_create(card, pci, &chip); 854 chip = card->private_data; 855 856 err = snd_bt87x_create(card, pci); 886 857 if (err < 0) 887 goto _error;858 return err; 888 859 889 860 memcpy(&chip->board, &snd_bt87x_boards[boardid], sizeof(chip->board)); … … 897 868 err = snd_bt87x_pcm(chip, DEVICE_DIGITAL, "Bt87x Digital"); 898 869 if (err < 0) 899 goto _error;870 return err; 900 871 } 901 872 if (!chip->board.no_analog) { 902 873 err = snd_bt87x_pcm(chip, DEVICE_ANALOG, "Bt87x Analog"); 903 874 if (err < 0) 904 goto _error;875 return err; 905 876 err = snd_ctl_add(card, snd_ctl_new1( 906 877 &snd_bt87x_capture_volume, chip)); 907 878 if (err < 0) 908 goto _error;879 return err; 909 880 err = snd_ctl_add(card, snd_ctl_new1( 910 881 &snd_bt87x_capture_boost, chip)); 911 882 if (err < 0) 912 goto _error;883 return err; 913 884 err = snd_ctl_add(card, snd_ctl_new1( 914 885 &snd_bt87x_capture_source, chip)); 915 886 if (err < 0) 916 goto _error;887 return err; 917 888 } 918 889 dev_info(card->dev, "bt87x%d: Using board %d, %sanalog, %sdigital " … … 930 901 err = snd_card_register(card); 931 902 if (err < 0) 932 goto _error;903 return err; 933 904 934 905 pci_set_drvdata(pci, card); 935 906 ++dev; 936 907 return 0; 937 938 _error: 939 snd_card_free(card); 940 return err; 941 } 942 943 static void snd_bt87x_remove(struct pci_dev *pci) 944 { 945 snd_card_free(pci_get_drvdata(pci)); 908 } 909 910 static int snd_bt87x_probe(struct pci_dev *pci, 911 const struct pci_device_id *pci_id) 912 { 913 return snd_card_free_on_error(&pci->dev, __snd_bt87x_probe(pci, pci_id)); 946 914 } 947 915 … … 958 926 .id_table = snd_bt87x_ids, 959 927 .probe = snd_bt87x_probe, 960 .remove = snd_bt87x_remove,961 928 }; 962 929 -
GPL/trunk/alsa-kernel/pci/ca0106/ca0106.h
r679 r717 668 668 669 669 unsigned long port; 670 struct resource *res_port;671 670 int irq; 672 671 … … 689 688 int capture_mic_line_in; 690 689 691 struct snd_dma_buffer buffer;690 struct snd_dma_buffer *buffer; 692 691 693 692 struct snd_ca_midi midi; -
GPL/trunk/alsa-kernel/pci/ca0106/ca0106_main.c
r703 r717 723 723 struct snd_ca0106_pcm *epcm = runtime->private_data; 724 724 int channel = epcm->channel_id; 725 u32 *table_base = (u32 *)(emu->buffer .area+(8*16*channel));725 u32 *table_base = (u32 *)(emu->buffer->area+(8*16*channel)); 726 726 u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); 727 727 u32 hcfg_mask = HCFG_PLAYBACK_S32_LE; … … 751 751 dev_dbg(emu->card->dev, 752 752 "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n", 753 emu->buffer .addr, emu->buffer.area, emu->buffer.bytes);753 emu->buffer->addr, emu->buffer->area, emu->buffer->bytes); 754 754 #endif /* debug */ 755 755 /* Rate can be set per channel. */ … … 801 801 snd_ca0106_ptr_write(emu, 0x71, 0, reg71); 802 802 803 /* FIXME: Check emu->buffer .size before actually writing to it. */803 /* FIXME: Check emu->buffer->size before actually writing to it. */ 804 804 for(i=0; i < runtime->periods; i++) { 805 805 table_base[i*2] = runtime->dma_addr + (i * period_size_bytes); … … 807 807 } 808 808 809 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_ADDR, channel, emu->buffer .addr+(8*16*channel));809 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_ADDR, channel, emu->buffer->addr+(8*16*channel)); 810 810 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19); 811 811 snd_ca0106_ptr_write(emu, PLAYBACK_LIST_PTR, channel, 0); … … 858 858 dev_dbg(emu->card->dev, 859 859 "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n", 860 emu->buffer .addr, emu->buffer.area, emu->buffer.bytes);860 emu->buffer->addr, emu->buffer->area, emu->buffer->bytes); 861 861 #endif /* debug */ 862 862 /* reg71 controls ADC rate. */ … … 1188 1188 static void ca0106_stop_chip(struct snd_ca0106 *chip); 1189 1189 1190 static int snd_ca0106_free(struct snd_ca0106 *chip) 1191 { 1192 if (chip->res_port != NULL) { 1193 /* avoid access to already used hardware */ 1194 ca0106_stop_chip(chip); 1195 } 1196 if (chip->irq >= 0) 1197 free_irq(chip->irq, chip); 1198 // release the data 1199 #if 1 1200 if (chip->buffer.area) 1201 snd_dma_free_pages(&chip->buffer); 1202 #endif 1203 1204 // release the i/o port 1205 release_and_free_resource(chip->res_port); 1206 1207 pci_disable_device(chip->pci); 1208 kfree(chip); 1209 return 0; 1210 } 1211 1212 static int snd_ca0106_dev_free(struct snd_device *device) 1213 { 1214 struct snd_ca0106 *chip = device->device_data; 1215 return snd_ca0106_free(chip); 1190 static void snd_ca0106_free(struct snd_card *card) 1191 { 1192 struct snd_ca0106 *chip = card->private_data; 1193 1194 ca0106_stop_chip(chip); 1216 1195 } 1217 1196 … … 1599 1578 1600 1579 static int snd_ca0106_create(int dev, struct snd_card *card, 1601 struct pci_dev *pci, 1602 struct snd_ca0106 **rchip) 1603 { 1604 struct snd_ca0106 *chip; 1580 struct pci_dev *pci) 1581 { 1582 struct snd_ca0106 *chip = card->private_data; 1605 1583 const struct snd_ca0106_details *c; 1606 1584 int err; 1607 static const struct snd_device_ops ops = { 1608 .dev_free = snd_ca0106_dev_free, 1609 }; 1610 1611 *rchip = NULL; 1612 1613 err = pci_enable_device(pci); 1585 1586 err = pcim_enable_device(pci); 1614 1587 if (err < 0) 1615 1588 return err; 1616 1589 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) { 1617 1590 dev_err(card->dev, "error to set 32bit mask DMA\n"); 1618 pci_disable_device(pci);1619 1591 return -ENXIO; 1620 }1621 1622 chip = kzalloc(sizeof(*chip), GFP_KERNEL);1623 if (chip == NULL) {1624 pci_disable_device(pci);1625 return -ENOMEM;1626 1592 } 1627 1593 … … 1632 1598 spin_lock_init(&chip->emu_lock); 1633 1599 1600 err = pci_request_regions(pci, "snd_ca0106"); 1601 if (err < 0) 1602 return err; 1634 1603 chip->port = pci_resource_start(pci, 0); 1635 chip->res_port = request_region(chip->port, 0x20, "snd_ca0106"); 1636 if (!chip->res_port) { 1637 snd_ca0106_free(chip); 1638 dev_err(card->dev, "cannot allocate the port\n"); 1639 return -EBUSY; 1640 } 1641 1642 if (request_irq(pci->irq, snd_ca0106_interrupt, 1643 IRQF_SHARED, KBUILD_MODNAME, chip)) { 1644 snd_ca0106_free(chip); 1604 1605 if (devm_request_irq(&pci->dev, pci->irq, snd_ca0106_interrupt, 1606 IRQF_SHARED, KBUILD_MODNAME, chip)) { 1645 1607 dev_err(card->dev, "cannot grab irq\n"); 1646 1608 return -EBUSY; … … 1650 1612 1651 1613 /* This stores the periods table. */ 1652 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 1653 1024, &chip->buffer) < 0) { 1654 snd_ca0106_free(chip); 1614 chip->buffer = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, 1024); 1615 if (!chip->buffer) 1655 1616 return -ENOMEM; 1656 }1657 1658 1617 pci_set_master(pci); 1659 1618 /* read serial */ … … 1683 1642 1684 1643 ca0106_init_chip(chip, 0); 1685 1686 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);1687 if (err < 0) {1688 snd_ca0106_free(chip);1689 return err;1690 }1691 *rchip = chip;1692 1644 return 0; 1693 1645 } … … 1777 1729 1778 1730 1779 static int snd_ca0106_probe(struct pci_dev *pci,1780 1731 static int __snd_ca0106_probe(struct pci_dev *pci, 1732 const struct pci_device_id *pci_id) 1781 1733 { 1782 1734 static int dev; … … 1792 1744 } 1793 1745 1794 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,1795 0, &card);1746 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1747 sizeof(*chip), &card); 1796 1748 if (err < 0) 1797 1749 return err; 1798 1799 err = snd_ca0106_create(dev, card, pci, &chip); 1750 chip = card->private_data; 1751 1752 err = snd_ca0106_create(dev, card, pci); 1800 1753 if (err < 0) 1801 goto error;1802 card->private_ data = chip;1754 return err; 1755 card->private_free = snd_ca0106_free; 1803 1756 1804 1757 for (i = 0; i < 4; i++) { 1805 1758 err = snd_ca0106_pcm(chip, i); 1806 1759 if (err < 0) 1807 goto error;1760 return err; 1808 1761 } 1809 1762 … … 1812 1765 err = snd_ca0106_ac97(chip); 1813 1766 if (err < 0) 1814 goto error;1767 return err; 1815 1768 } 1816 1769 err = snd_ca0106_mixer(chip); 1817 1770 if (err < 0) 1818 goto error;1771 return err; 1819 1772 1820 1773 dev_dbg(card->dev, "probe for MIDI channel A ..."); 1821 1774 err = snd_ca0106_midi(chip, CA0106_MIDI_CHAN_A); 1822 1775 if (err < 0) 1823 goto error;1776 return err; 1824 1777 dev_dbg(card->dev, " done.\n"); 1825 1778 … … 1830 1783 err = snd_card_register(card); 1831 1784 if (err < 0) 1832 goto error;1785 return err; 1833 1786 1834 1787 pci_set_drvdata(pci, card); 1835 1788 dev++; 1836 1789 return 0; 1837 1838 error: 1839 snd_card_free(card); 1840 return err; 1841 } 1842 1843 static void snd_ca0106_remove(struct pci_dev *pci) 1844 { 1845 snd_card_free(pci_get_drvdata(pci)); 1790 } 1791 1792 static int snd_ca0106_probe(struct pci_dev *pci, 1793 const struct pci_device_id *pci_id) 1794 { 1795 return snd_card_free_on_error(&pci->dev, __snd_ca0106_probe(pci, pci_id)); 1846 1796 } 1847 1797 … … 1899 1849 .id_table = snd_ca0106_ids, 1900 1850 .probe = snd_ca0106_probe, 1901 .remove = snd_ca0106_remove,1902 1851 .driver = { 1903 1852 .pm = SND_CA0106_PM_OPS, -
GPL/trunk/alsa-kernel/pci/cmipci.c
r703 r717 308 308 #define CM_MICGAINZ_SHIFT 0 309 309 310 #define CM_REG_MIXER3 0x24311 310 #define CM_REG_AUX_VOL 0x26 312 311 #define CM_VAUXL_MASK 0xf0 … … 2873 2872 for (i = 0; ports[i]; i++) { 2874 2873 io_port = ports[i]; 2875 r = request_region(io_port, 1, "CMIPCI gameport"); 2874 r = devm_request_region(&cm->pci->dev, io_port, 1, 2875 "CMIPCI gameport"); 2876 2876 if (r) 2877 2877 break; … … 2879 2879 } else { 2880 2880 io_port = joystick_port[dev]; 2881 r = request_region(io_port, 1, "CMIPCI gameport"); 2881 r = devm_request_region(&cm->pci->dev, io_port, 1, 2882 "CMIPCI gameport"); 2882 2883 } 2883 2884 … … 2890 2891 if (!gp) { 2891 2892 dev_err(cm->card->dev, "cannot allocate memory for gameport\n"); 2892 release_and_free_resource(r);2893 2893 return -ENOMEM; 2894 2894 } … … 2897 2897 gameport_set_dev_parent(gp, &cm->pci->dev); 2898 2898 gp->io = io_port; 2899 gameport_set_port_data(gp, r);2900 2899 2901 2900 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); … … 2909 2908 { 2910 2909 if (cm->gameport) { 2911 struct resource *r = gameport_get_port_data(cm->gameport);2912 2913 2910 gameport_unregister_port(cm->gameport); 2914 2911 cm->gameport = NULL; 2915 2912 2916 2913 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); 2917 release_and_free_resource(r);2918 2914 } 2919 2915 } … … 2923 2919 #endif 2924 2920 2925 static int snd_cmipci_free(struct cmipci *cm) 2926 { 2927 if (cm->irq >= 0) { 2928 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN); 2929 snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_ENSPDOUT); 2930 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); /* disable ints */ 2931 snd_cmipci_ch_reset(cm, CM_CH_PLAY); 2932 snd_cmipci_ch_reset(cm, CM_CH_CAPT); 2933 snd_cmipci_write(cm, CM_REG_FUNCTRL0, 0); /* disable channels */ 2934 snd_cmipci_write(cm, CM_REG_FUNCTRL1, 0); 2935 2936 /* reset mixer */ 2937 snd_cmipci_mixer_write(cm, 0, 0); 2938 2939 free_irq(cm->irq, cm); 2940 } 2921 static void snd_cmipci_free(struct snd_card *card) 2922 { 2923 struct cmipci *cm = card->private_data; 2924 2925 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN); 2926 snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_ENSPDOUT); 2927 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); /* disable ints */ 2928 snd_cmipci_ch_reset(cm, CM_CH_PLAY); 2929 snd_cmipci_ch_reset(cm, CM_CH_CAPT); 2930 snd_cmipci_write(cm, CM_REG_FUNCTRL0, 0); /* disable channels */ 2931 snd_cmipci_write(cm, CM_REG_FUNCTRL1, 0); 2932 2933 /* reset mixer */ 2934 snd_cmipci_mixer_write(cm, 0, 0); 2941 2935 2942 2936 snd_cmipci_free_gameport(cm); 2943 pci_release_regions(cm->pci);2944 pci_disable_device(cm->pci);2945 kfree(cm);2946 return 0;2947 }2948 2949 static int snd_cmipci_dev_free(struct snd_device *device)2950 {2951 struct cmipci *cm = device->device_data;2952 return snd_cmipci_free(cm);2953 2937 } 2954 2938 … … 3009 2993 3010 2994 static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, 3011 int dev , struct cmipci **rcmipci)3012 { 3013 struct cmipci *cm ;2995 int dev) 2996 { 2997 struct cmipci *cm = card->private_data; 3014 2998 int err; 3015 static const struct snd_device_ops ops = {3016 .dev_free = snd_cmipci_dev_free,3017 };3018 2999 unsigned int val; 3019 3000 long iomidi = 0; … … 3026 3007 }; 3027 3008 3028 *rcmipci = NULL; 3029 3030 err = pci_enable_device(pci); 3009 err = pcim_enable_device(pci); 3031 3010 if (err < 0) 3032 3011 return err; 3033 3034 cm = kzalloc(sizeof(*cm), GFP_KERNEL);3035 if (cm == NULL) {3036 pci_disable_device(pci);3037 return -ENOMEM;3038 }3039 3012 3040 3013 spin_lock_init(&cm->reg_lock); … … 3049 3022 3050 3023 err = pci_request_regions(pci, card->driver); 3051 if (err < 0) { 3052 kfree(cm); 3053 pci_disable_device(pci); 3024 if (err < 0) 3054 3025 return err; 3055 }3056 3026 cm->iobase = pci_resource_start(pci, 0); 3057 3027 3058 if ( request_irq(pci->irq, snd_cmipci_interrupt,3059 IRQF_SHARED, KBUILD_MODNAME, cm)) {3028 if (devm_request_irq(&pci->dev, pci->irq, snd_cmipci_interrupt, 3029 IRQF_SHARED, KBUILD_MODNAME, cm)) { 3060 3030 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 3061 snd_cmipci_free(cm);3062 3031 return -EBUSY; 3063 3032 } 3064 3033 cm->irq = pci->irq; 3065 3034 card->sync_irq = cm->irq; 3035 card->private_free = snd_cmipci_free; 3066 3036 3067 3037 pci_set_master(cm->pci); … … 3163 3133 card->shortname, modelstr, cm->iobase, cm->irq); 3164 3134 3165 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cm, &ops);3166 if (err < 0) {3167 snd_cmipci_free(cm);3168 return err;3169 }3170 3171 3135 if (cm->chip_version >= 39) { 3172 3136 val = snd_cmipci_read_b(cm, CM_REG_MPU_PCI + 1); … … 3261 3225 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); 3262 3226 3263 *rcmipci = cm;3264 3227 return 0; 3265 3228 } … … 3285 3248 } 3286 3249 3287 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,3288 0, &card);3250 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 3251 sizeof(*cm), &card); 3289 3252 if (err < 0) 3290 3253 return err; 3254 cm = card->private_data; 3291 3255 3292 3256 switch (pci->device) { … … 3304 3268 } 3305 3269 3306 err = snd_cmipci_create(card, pci, dev , &cm);3270 err = snd_cmipci_create(card, pci, dev); 3307 3271 if (err < 0) 3308 goto free_card; 3309 3310 card->private_data = cm; 3272 goto error; 3311 3273 3312 3274 err = snd_card_register(card); 3313 3275 if (err < 0) 3314 goto free_card;3276 goto error; 3315 3277 3316 3278 pci_set_drvdata(pci, card); … … 3318 3280 return 0; 3319 3281 3320 free_card:3282 error: 3321 3283 snd_card_free(card); 3322 3284 return err; 3323 3285 } 3324 3286 3325 static void snd_cmipci_remove(struct pci_dev *pci)3326 {3327 snd_card_free(pci_get_drvdata(pci));3328 }3329 3330 3331 3287 #ifdef CONFIG_PM_SLEEP 3332 3288 /* … … 3335 3291 static const unsigned char saved_regs[] = { 3336 3292 CM_REG_FUNCTRL1, CM_REG_CHFORMAT, CM_REG_LEGACY_CTRL, CM_REG_MISC_CTRL, 3337 CM_REG_MIXER0, CM_REG_MIXER1, CM_REG_MIXER2, CM_REG_ MIXER3, CM_REG_PLL,3293 CM_REG_MIXER0, CM_REG_MIXER1, CM_REG_MIXER2, CM_REG_AUX_VOL, CM_REG_PLL, 3338 3294 CM_REG_CH0_FRAME1, CM_REG_CH0_FRAME2, 3339 3295 CM_REG_CH1_FRAME1, CM_REG_CH1_FRAME2, CM_REG_EXT_MISC, … … 3403 3359 .id_table = snd_cmipci_ids, 3404 3360 .probe = snd_cmipci_probe, 3405 .remove = snd_cmipci_remove,3406 3361 .driver = { 3407 3362 .pm = SND_CMIPCI_PM_OPS, -
GPL/trunk/alsa-kernel/pci/cs4281.c
r703 r717 1272 1272 #endif /* IS_REACHABLE(CONFIG_GAMEPORT) */ 1273 1273 1274 static int snd_cs4281_free(struct cs4281 *chip) 1275 { 1274 static void snd_cs4281_free(struct snd_card *card) 1275 { 1276 struct cs4281 *chip = card->private_data; 1277 1276 1278 snd_cs4281_free_gameport(chip); 1277 1279 … … 1282 1284 /* Sound System Power Management - Turn Everything OFF */ 1283 1285 snd_cs4281_pokeBA0(chip, BA0_SSPM, 0); 1284 /* PCI interface - D3 state */1285 pci_set_power_state(chip->pci, PCI_D3hot);1286 1287 if (chip->irq >= 0)1288 free_irq(chip->irq, chip);1289 iounmap(chip->ba0);1290 iounmap(chip->ba1);1291 pci_release_regions(chip->pci);1292 pci_disable_device(chip->pci);1293 1294 kfree(chip);1295 return 0;1296 }1297 1298 static int snd_cs4281_dev_free(struct snd_device *device)1299 {1300 struct cs4281 *chip = device->device_data;1301 return snd_cs4281_free(chip);1302 1286 } 1303 1287 … … 1306 1290 static int snd_cs4281_create(struct snd_card *card, 1307 1291 struct pci_dev *pci, 1308 struct cs4281 **rchip,1309 1292 int dual_codec) 1310 1293 { 1311 struct cs4281 *chip; 1312 unsigned int tmp; 1294 struct cs4281 *chip = card->private_data; 1313 1295 int err; 1314 static const struct snd_device_ops ops = { 1315 .dev_free = snd_cs4281_dev_free, 1316 }; 1317 1318 *rchip = NULL; 1319 err = pci_enable_device(pci); 1296 1297 err = pcim_enable_device(pci); 1320 1298 if (err < 0) 1321 1299 return err; 1322 chip = kzalloc(sizeof(*chip), GFP_KERNEL);1323 if (chip == NULL) {1324 pci_disable_device(pci);1325 return -ENOMEM;1326 }1327 1300 spin_lock_init(&chip->reg_lock); 1328 1301 chip->card = card; … … 1336 1309 chip->dual_codec = dual_codec; 1337 1310 1311 #ifndef TARGET_OS2 1312 err = pcim_iomap_regions(pci, 0x03, "CS4281"); /* 2 BARs */ 1313 if (err < 0) 1314 return err; 1315 #else 1338 1316 err = pci_request_regions(pci, "CS4281"); 1339 1317 if (err < 0) { … … 1342 1320 return err; 1343 1321 } 1322 #endif 1344 1323 chip->ba0_addr = pci_resource_start(pci, 0); 1345 1324 chip->ba1_addr = pci_resource_start(pci, 1); 1346 1325 1326 #ifndef TARGET_OS2 1327 chip->ba0 = pcim_iomap_table(pci)[0]; 1328 chip->ba1 = pcim_iomap_table(pci)[1]; 1329 #else 1347 1330 chip->ba0 = pci_ioremap_bar(pci, 0); 1348 1331 chip->ba1 = pci_ioremap_bar(pci, 1); 1349 if (!chip->ba0 || !chip->ba1) { 1350 snd_cs4281_free(chip); 1351 return -ENOMEM; 1352 } 1353 1354 if (request_irq(pci->irq, snd_cs4281_interrupt, IRQF_SHARED, 1355 KBUILD_MODNAME, chip)) { 1332 #endif 1333 if (devm_request_irq(&pci->dev, pci->irq, snd_cs4281_interrupt, 1334 IRQF_SHARED, KBUILD_MODNAME, chip)) { 1356 1335 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 1357 snd_cs4281_free(chip);1358 1336 return -ENOMEM; 1359 1337 } 1360 1338 chip->irq = pci->irq; 1361 1339 card->sync_irq = chip->irq; 1362 1363 tmp = snd_cs4281_chip_init(chip); 1364 if (tmp) { 1365 snd_cs4281_free(chip); 1366 return tmp; 1367 } 1368 1369 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 1370 if (err < 0) { 1371 snd_cs4281_free(chip); 1340 card->private_free = snd_cs4281_free; 1341 1342 err = snd_cs4281_chip_init(chip); 1343 if (err) 1372 1344 return err; 1373 }1374 1345 1375 1346 snd_cs4281_proc_init(chip); 1376 1377 *rchip = chip;1378 1347 return 0; 1379 1348 } … … 1875 1844 } 1876 1845 1877 static int snd_cs4281_probe(struct pci_dev *pci,1878 const struct pci_device_id *pci_id)1846 static int __snd_cs4281_probe(struct pci_dev *pci, 1847 const struct pci_device_id *pci_id) 1879 1848 { 1880 1849 static int dev; … … 1891 1860 } 1892 1861 1893 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,1894 0, &card);1862 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1863 sizeof(*chip), &card); 1895 1864 if (err < 0) 1896 1865 return err; 1897 1898 err = snd_cs4281_create(card, pci, &chip, dual_codec[dev]); 1899 if (err < 0) {1900 snd_card_free(card);1866 chip = card->private_data; 1867 1868 err = snd_cs4281_create(card, pci, dual_codec[dev]); 1869 if (err < 0) 1901 1870 return err; 1902 }1903 card->private_data = chip;1904 1871 1905 1872 err = snd_cs4281_mixer(chip); 1906 if (err < 0) { 1907 snd_card_free(card); 1873 if (err < 0) 1908 1874 return err; 1909 }1910 1875 err = snd_cs4281_pcm(chip, 0); 1911 if (err < 0) { 1912 snd_card_free(card); 1876 if (err < 0) 1913 1877 return err; 1914 }1915 1878 err = snd_cs4281_midi(chip, 0); 1916 if (err < 0) { 1917 snd_card_free(card); 1879 if (err < 0) 1918 1880 return err; 1919 }1920 1881 err = snd_opl3_new(card, OPL3_HW_OPL3_CS4281, &opl3); 1921 if (err < 0) { 1922 snd_card_free(card); 1882 if (err < 0) 1923 1883 return err; 1924 }1925 1884 opl3->private_data = chip; 1926 1885 opl3->command = snd_cs4281_opl3_command; 1927 1886 snd_opl3_init(opl3); 1928 1887 err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); 1929 if (err < 0) { 1930 snd_card_free(card); 1888 if (err < 0) 1931 1889 return err; 1932 }1933 1890 snd_cs4281_create_gameport(chip); 1934 1891 strcpy(card->driver, "CS4281"); … … 1940 1897 1941 1898 err = snd_card_register(card); 1942 if (err < 0) { 1943 snd_card_free(card); 1899 if (err < 0) 1944 1900 return err; 1945 }1946 1901 1947 1902 pci_set_drvdata(pci, card); … … 1950 1905 } 1951 1906 1952 static void snd_cs4281_remove(struct pci_dev *pci) 1953 { 1954 snd_card_free(pci_get_drvdata(pci)); 1907 static int snd_cs4281_probe(struct pci_dev *pci, 1908 const struct pci_device_id *pci_id) 1909 { 1910 return snd_card_free_on_error(&pci->dev, __snd_cs4281_probe(pci, pci_id)); 1955 1911 } 1956 1912 … … 2058 2014 .id_table = snd_cs4281_ids, 2059 2015 .probe = snd_cs4281_probe, 2060 .remove = snd_cs4281_remove,2061 2016 .driver = { 2062 2017 .pm = CS4281_PM_OPS, -
GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx.c
r703 r717 74 74 } 75 75 76 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,77 0, &card);76 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 77 sizeof(*chip), &card); 78 78 if (err < 0) 79 79 return err; 80 chip = card->private_data; 80 81 err = snd_cs46xx_create(card, pci, 81 external_amp[dev], thinkpad[dev], 82 &chip); 83 if (err < 0) { 84 snd_card_free(card); 85 return err; 86 } 82 external_amp[dev], thinkpad[dev]); 83 if (err < 0) 84 goto error; 87 85 card->private_data = chip; 88 86 chip->accept_valid = mmap_valid[dev]; 89 87 err = snd_cs46xx_pcm(chip, 0); 90 if (err < 0) { 91 snd_card_free(card); 92 return err; 93 } 88 if (err < 0) 89 goto error; 94 90 #ifdef CONFIG_SND_CS46XX_NEW_DSP 95 91 err = snd_cs46xx_pcm_rear(chip, 1); 96 if (err < 0) { 97 snd_card_free(card); 98 return err; 99 } 92 if (err < 0) 93 goto error; 100 94 err = snd_cs46xx_pcm_iec958(chip, 2); 101 if (err < 0) { 102 snd_card_free(card); 103 return err; 104 } 95 if (err < 0) 96 goto error; 105 97 #endif 106 98 err = snd_cs46xx_mixer(chip, 2); 107 if (err < 0) { 108 snd_card_free(card); 109 return err; 110 } 99 if (err < 0) 100 goto error; 111 101 #ifdef CONFIG_SND_CS46XX_NEW_DSP 112 102 if (chip->nr_ac97_codecs ==2) { 113 103 err = snd_cs46xx_pcm_center_lfe(chip, 3); 114 if (err < 0) { 115 snd_card_free(card); 116 return err; 117 } 104 if (err < 0) 105 goto error; 118 106 } 119 107 #endif 120 108 err = snd_cs46xx_midi(chip, 0); 121 if (err < 0) { 122 snd_card_free(card); 123 return err; 124 } 109 if (err < 0) 110 goto error; 125 111 err = snd_cs46xx_start_dsp(chip); 126 if (err < 0) { 127 snd_card_free(card); 128 return err; 129 } 130 112 if (err < 0) 113 goto error; 131 114 132 115 snd_cs46xx_gameport(chip); … … 141 124 142 125 err = snd_card_register(card); 143 if (err < 0) { 144 snd_card_free(card); 145 return err; 146 } 126 if (err < 0) 127 goto error; 147 128 148 129 pci_set_drvdata(pci, card); 149 130 dev++; 150 131 return 0; 151 }152 132 153 static void snd_card_cs46xx_remove(struct pci_dev *pci) 154 { 155 snd_card_free(pci_get_drvdata(pci));133 error: 134 snd_card_free(card); 135 return err; 156 136 } 157 137 … … 160 140 .id_table = snd_cs46xx_ids, 161 141 .probe = snd_card_cs46xx_probe, 162 .remove = snd_card_cs46xx_remove,163 142 #ifdef CONFIG_PM_SLEEP 164 143 .driver = { -
GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx.h
r679 r717 1636 1636 void __iomem *remap_addr; 1637 1637 unsigned long size; 1638 struct resource *resource;1639 1638 }; 1640 1639 … … 1719 1718 int snd_cs46xx_create(struct snd_card *card, 1720 1719 struct pci_dev *pci, 1721 int external_amp, int thinkpad, 1722 struct snd_cs46xx **rcodec); 1720 int external_amp, int thinkpad); 1723 1721 extern const struct dev_pm_ops snd_cs46xx_pm; 1724 1722 -
GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx_lib.c
r703 r717 1126 1126 if (runtime->dma_area != cpcm->hw_buf.area) 1127 1127 snd_pcm_lib_free_pages(substream); 1128 runtime->dma_area = cpcm->hw_buf.area; 1129 runtime->dma_addr = cpcm->hw_buf.addr; 1130 runtime->dma_bytes = cpcm->hw_buf.bytes; 1128 snd_pcm_set_runtime_buffer(substream, &cpcm->hw_buf); 1131 1129 1132 1130 … … 1148 1146 1149 1147 } else { 1150 if (runtime->dma_area == cpcm->hw_buf.area) { 1151 runtime->dma_area = NULL; 1152 runtime->dma_addr = 0; 1153 runtime->dma_bytes = 0; 1154 } 1148 if (runtime->dma_area == cpcm->hw_buf.area) 1149 snd_pcm_set_runtime_buffer(substream, NULL); 1155 1150 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1156 1151 if (err < 0) { … … 1201 1196 snd_pcm_lib_free_pages(substream); 1202 1197 1203 runtime->dma_area = NULL; 1204 runtime->dma_addr = 0; 1205 runtime->dma_bytes = 0; 1198 snd_pcm_set_runtime_buffer(substream, NULL); 1206 1199 1207 1200 return 0; … … 1292 1285 if (runtime->dma_area != chip->capt.hw_buf.area) 1293 1286 snd_pcm_lib_free_pages(substream); 1294 runtime->dma_area = chip->capt.hw_buf.area; 1295 runtime->dma_addr = chip->capt.hw_buf.addr; 1296 runtime->dma_bytes = chip->capt.hw_buf.bytes; 1287 snd_pcm_set_runtime_buffer(substream, &chip->capt.hw_buf); 1297 1288 substream->ops = &snd_cs46xx_capture_ops; 1298 1289 } else { 1299 if (runtime->dma_area == chip->capt.hw_buf.area) { 1300 runtime->dma_area = NULL; 1301 runtime->dma_addr = 0; 1302 runtime->dma_bytes = 0; 1303 } 1290 if (runtime->dma_area == chip->capt.hw_buf.area) 1291 snd_pcm_set_runtime_buffer(substream, NULL); 1304 1292 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1305 1293 if (err < 0) … … 1318 1306 if (runtime->dma_area != chip->capt.hw_buf.area) 1319 1307 snd_pcm_lib_free_pages(substream); 1320 runtime->dma_area = NULL; 1321 runtime->dma_addr = 0; 1322 runtime->dma_bytes = 0; 1308 snd_pcm_set_runtime_buffer(substream, NULL); 1323 1309 1324 1310 return 0; … … 1870 1856 * Mixer routines 1871 1857 */ 1872 static void snd_cs46xx_mixer_free_ac97_bus(struct snd_ac97_bus *bus)1873 {1874 struct snd_cs46xx *chip = bus->private_data;1875 1876 chip->ac97_bus = NULL;1877 }1878 1879 1858 static void snd_cs46xx_mixer_free_ac97(struct snd_ac97 *ac97) 1880 1859 { … … 2492 2471 if (err < 0) 2493 2472 return err; 2494 chip->ac97_bus->private_free = snd_cs46xx_mixer_free_ac97_bus;2495 2473 2496 2474 if (cs46xx_detect_codec(chip, CS46XX_PRIMARY_CODEC_INDEX) < 0) … … 2918 2896 2919 2897 2920 static int snd_cs46xx_free(struct snd_cs46xx *chip) 2921 { 2898 static void snd_cs46xx_free(struct snd_card *card) 2899 { 2900 struct snd_cs46xx *chip = card->private_data; 2901 #ifdef CONFIG_SND_CS46XX_NEW_DSP 2922 2902 int idx; 2923 2924 if (snd_BUG_ON(!chip)) 2925 return -EINVAL; 2903 #endif 2926 2904 2927 2905 if (chip->active_ctrl) … … 2935 2913 snd_cs46xx_proc_done(chip); 2936 2914 2937 if (chip->region.idx[0].resource) 2938 snd_cs46xx_hw_stop(chip); 2939 2940 if (chip->irq >= 0) 2941 free_irq(chip->irq, chip); 2915 snd_cs46xx_hw_stop(chip); 2942 2916 2943 2917 if (chip->active_ctrl) 2944 2918 chip->active_ctrl(chip, -chip->amplifier); 2945 2946 for (idx = 0; idx < 5; idx++) {2947 struct snd_cs46xx_region *region = &chip->region.idx[idx];2948 2949 iounmap(region->remap_addr);2950 release_and_free_resource(region->resource);2951 }2952 2919 2953 2920 #ifdef CONFIG_SND_CS46XX_NEW_DSP … … 2961 2928 vfree(chip->ba1); 2962 2929 #endif 2963 2964 #ifdef CONFIG_PM_SLEEP2965 kfree(chip->saved_regs);2966 #endif2967 2968 pci_disable_device(chip->pci);2969 kfree(chip);2970 return 0;2971 }2972 2973 static int snd_cs46xx_dev_free(struct snd_device *device)2974 {2975 struct snd_cs46xx *chip = device->device_data;2976 return snd_cs46xx_free(chip);2977 2930 } 2978 2931 … … 3873 3826 int snd_cs46xx_create(struct snd_card *card, 3874 3827 struct pci_dev *pci, 3875 int external_amp, int thinkpad, 3876 struct snd_cs46xx **rchip) 3877 { 3878 struct snd_cs46xx *chip; 3828 int external_amp, int thinkpad) 3829 { 3830 struct snd_cs46xx *chip = card->private_data; 3879 3831 int err, idx; 3880 3832 struct snd_cs46xx_region *region; 3881 3833 struct cs_card_type *cp; 3882 3834 u16 ss_card, ss_vendor; 3883 static const struct snd_device_ops ops = {3884 .dev_free = snd_cs46xx_dev_free,3885 };3886 3835 3887 *rchip = NULL;3888 3889 3836 /* enable PCI device */ 3890 err = pci _enable_device(pci);3837 err = pcim_enable_device(pci); 3891 3838 if (err < 0) 3892 3839 return err; 3893 3840 3894 chip = kzalloc(sizeof(*chip), GFP_KERNEL);3895 if (chip == NULL) {3896 pci_disable_device(pci);3897 return -ENOMEM;3898 }3899 3841 spin_lock_init(&chip->reg_lock); 3900 3842 #ifdef CONFIG_SND_CS46XX_NEW_DSP … … 3904 3846 chip->pci = pci; 3905 3847 chip->irq = -1; 3848 3849 err = pci_request_regions(pci, "CS46xx"); 3850 if (err < 0) 3851 return err; 3906 3852 chip->ba0_addr = pci_resource_start(pci, 0); 3907 3853 chip->ba1_addr = pci_resource_start(pci, 1); … … 3911 3857 "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n", 3912 3858 chip->ba0_addr, chip->ba1_addr); 3913 snd_cs46xx_free(chip);3914 3859 return -ENOMEM; 3915 3860 } … … 3983 3928 for (idx = 0; idx < 5; idx++) { 3984 3929 region = &chip->region.idx[idx]; 3985 region->resource = request_mem_region(region->base, region->size, 3986 region->name); 3987 if (!region->resource) { 3988 dev_err(chip->card->dev, 3989 "unable to request memory region 0x%lx-0x%lx\n", 3990 region->base, region->base + region->size - 1); 3991 snd_cs46xx_free(chip); 3992 return -EBUSY; 3993 } 3994 region->remap_addr = ioremap(region->base, region->size); 3930 region->remap_addr = devm_ioremap(&pci->dev, region->base, 3931 region->size); 3995 3932 if (region->remap_addr == NULL) { 3996 3933 dev_err(chip->card->dev, 3997 3934 "%s ioremap problem\n", region->name); 3998 snd_cs46xx_free(chip);3999 3935 return -ENOMEM; 4000 3936 } 4001 3937 } 4002 3938 4003 if ( request_irq(pci->irq, snd_cs46xx_interrupt, IRQF_SHARED,4004 KBUILD_MODNAME, chip)) {3939 if (devm_request_irq(&pci->dev, pci->irq, snd_cs46xx_interrupt, 3940 IRQF_SHARED, KBUILD_MODNAME, chip)) { 4005 3941 dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq); 4006 snd_cs46xx_free(chip);4007 3942 return -EBUSY; 4008 3943 } 4009 3944 chip->irq = pci->irq; 4010 3945 card->sync_irq = chip->irq; 3946 card->private_free = snd_cs46xx_free; 4011 3947 4012 3948 #ifdef CONFIG_SND_CS46XX_NEW_DSP 4013 3949 chip->dsp_spos_instance = cs46xx_dsp_spos_create(chip); 4014 if (chip->dsp_spos_instance == NULL) { 4015 snd_cs46xx_free(chip); 3950 if (!chip->dsp_spos_instance) 4016 3951 return -ENOMEM; 4017 }4018 3952 #endif 4019 3953 4020 3954 err = snd_cs46xx_chip_init(chip); 4021 if (err < 0) { 4022 snd_cs46xx_free(chip); 3955 if (err < 0) 4023 3956 return err; 4024 }4025 4026 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);4027 if (err < 0) {4028 snd_cs46xx_free(chip);4029 return err;4030 }4031 3957 4032 3958 snd_cs46xx_proc_init(card, chip); 4033 3959 4034 3960 #ifdef CONFIG_PM_SLEEP 4035 chip->saved_regs = kmalloc_array(ARRAY_SIZE(saved_regs),4036 sizeof(*chip->saved_regs),4037 GFP_KERNEL);4038 if (!chip->saved_regs) {4039 snd_cs46xx_free(chip);3961 chip->saved_regs = devm_kmalloc_array(&pci->dev, 3962 ARRAY_SIZE(saved_regs), 3963 sizeof(*chip->saved_regs), 3964 GFP_KERNEL); 3965 if (!chip->saved_regs) 4040 3966 return -ENOMEM; 4041 }4042 3967 #endif 4043 3968 4044 3969 chip->active_ctrl(chip, -1); /* disable CLKRUN */ 4045 4046 *rchip = chip; 4047 return 0; 4048 } 3970 return 0; 3971 } -
GPL/trunk/alsa-kernel/pci/cs5530.c
r679 r717 70 70 MODULE_DEVICE_TABLE(pci, snd_cs5530_ids); 71 71 72 static int snd_cs5530_free(struct snd_cs5530 *chip)73 {74 pci_release_regions(chip->pci);75 pci_disable_device(chip->pci);76 kfree(chip);77 return 0;78 }79 80 static int snd_cs5530_dev_free(struct snd_device *device)81 {82 struct snd_cs5530 *chip = device->device_data;83 return snd_cs5530_free(chip);84 }85 86 static void snd_cs5530_remove(struct pci_dev *pci)87 {88 snd_card_free(pci_get_drvdata(pci));89 }90 91 72 static u8 snd_cs5530_mixer_read(unsigned long io, u8 reg) 92 73 { … … 99 80 100 81 static int snd_cs5530_create(struct snd_card *card, 101 struct pci_dev *pci, 102 struct snd_cs5530 **rchip) 82 struct pci_dev *pci) 103 83 { 104 struct snd_cs5530 *chip ;84 struct snd_cs5530 *chip = card->private_data; 105 85 unsigned long sb_base; 106 86 u8 irq, dma8, dma16 = 0; … … 109 89 int err; 110 90 111 static const struct snd_device_ops ops = { 112 .dev_free = snd_cs5530_dev_free, 113 }; 114 *rchip = NULL; 115 116 err = pci_enable_device(pci); 91 err = pcim_enable_device(pci); 117 92 if (err < 0) 118 93 return err; 119 120 chip = kzalloc(sizeof(*chip), GFP_KERNEL);121 if (chip == NULL) {122 pci_disable_device(pci);123 return -ENOMEM;124 }125 94 126 95 chip->card = card; 127 96 chip->pci = pci; 128 97 129 err = pci_request_regions(pci, "CS5530"); 130 if (err < 0) { 131 kfree(chip); 132 pci_disable_device(pci); 133 return err; 134 } 98 err = pcim_iomap_regions(pci, 1 << 0, "CS5530"); 99 if (err < 0) 100 return err; 135 101 chip->pci_base = pci_resource_start(pci, 0); 136 102 #ifndef TARGET_OS2 103 mem = pcim_iomap_table(pci)[0]; 104 #else 137 105 mem = pci_ioremap_bar(pci, 0); 138 if (mem == NULL) { 139 snd_cs5530_free(chip); 140 return -EBUSY; 141 } 142 106 #endif 143 107 map = readw(mem + 0x18); 144 iounmap(mem);145 108 146 109 /* Map bits … … 159 122 else { 160 123 dev_err(card->dev, "Could not find XpressAudio!\n"); 161 snd_cs5530_free(chip);162 124 return -ENODEV; 163 125 } … … 179 141 else { 180 142 dev_err(card->dev, "No 16bit DMA enabled\n"); 181 snd_cs5530_free(chip);182 143 return -ENODEV; 183 144 } … … 191 152 else { 192 153 dev_err(card->dev, "No 8bit DMA enabled\n"); 193 snd_cs5530_free(chip);194 154 return -ENODEV; 195 155 } … … 205 165 else { 206 166 dev_err(card->dev, "SoundBlaster IRQ not set\n"); 207 snd_cs5530_free(chip);208 167 return -ENODEV; 209 168 } … … 215 174 if (err < 0) { 216 175 dev_err(card->dev, "Could not create SoundBlaster\n"); 217 snd_cs5530_free(chip);218 176 return err; 219 177 } … … 222 180 if (err < 0) { 223 181 dev_err(card->dev, "Could not create PCM\n"); 224 snd_cs5530_free(chip);225 182 return err; 226 183 } … … 229 186 if (err < 0) { 230 187 dev_err(card->dev, "Could not create Mixer\n"); 231 snd_cs5530_free(chip); 232 return err; 233 } 234 235 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 236 if (err < 0) { 237 snd_cs5530_free(chip); 238 return err; 239 } 240 241 *rchip = chip; 188 return err; 189 } 190 242 191 return 0; 243 192 } … … 248 197 static int dev; 249 198 struct snd_card *card; 250 struct snd_cs5530 *chip = NULL;199 struct snd_cs5530 *chip; 251 200 int err; 252 201 … … 258 207 } 259 208 260 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 261 0, &card); 262 263 if (err < 0) 264 return err; 265 266 err = snd_cs5530_create(card, pci, &chip); 267 if (err < 0) { 268 snd_card_free(card); 269 return err; 270 } 209 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 210 sizeof(*chip), &card); 211 if (err < 0) 212 return err; 213 chip = card->private_data; 214 215 err = snd_cs5530_create(card, pci); 216 if (err < 0) 217 return err; 271 218 272 219 strcpy(card->driver, "CS5530"); … … 275 222 276 223 err = snd_card_register(card); 277 if (err < 0) { 278 snd_card_free(card); 279 return err; 280 } 224 if (err < 0) 225 return err; 281 226 pci_set_drvdata(pci, card); 282 227 dev++; … … 288 233 .id_table = snd_cs5530_ids, 289 234 .probe = snd_cs5530_probe, 290 .remove = snd_cs5530_remove,291 235 }; 292 236 -
GPL/trunk/alsa-kernel/pci/cs5535audio/cs5535audio.c
r703 r717 242 242 } 243 243 244 static int snd_cs5535audio_free(struct cs5535audio *cs5535au) 245 { 246 pci_set_power_state(cs5535au->pci, PCI_D3hot); 247 248 if (cs5535au->irq >= 0) 249 free_irq(cs5535au->irq, cs5535au); 250 251 pci_release_regions(cs5535au->pci); 252 pci_disable_device(cs5535au->pci); 253 kfree(cs5535au); 254 return 0; 255 } 256 257 static int snd_cs5535audio_dev_free(struct snd_device *device) 258 { 259 struct cs5535audio *cs5535au = device->device_data; 260 return snd_cs5535audio_free(cs5535au); 244 static void snd_cs5535audio_free(struct snd_card *card) 245 { 246 olpc_quirks_cleanup(); 261 247 } 262 248 263 249 static int snd_cs5535audio_create(struct snd_card *card, 264 struct pci_dev *pci, 265 struct cs5535audio **rcs5535au) 266 { 267 struct cs5535audio *cs5535au; 268 250 struct pci_dev *pci) 251 { 252 struct cs5535audio *cs5535au = card->private_data; 269 253 int err; 270 static const struct snd_device_ops ops = { 271 .dev_free = snd_cs5535audio_dev_free, 272 }; 273 274 *rcs5535au = NULL; 275 err = pci_enable_device(pci); 254 255 err = pcim_enable_device(pci); 276 256 if (err < 0) 277 257 return err; … … 279 259 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) { 280 260 dev_warn(card->dev, "unable to get 32bit dma\n"); 281 err = -ENXIO; 282 goto pcifail; 283 } 284 285 cs5535au = kzalloc(sizeof(*cs5535au), GFP_KERNEL); 286 if (cs5535au == NULL) { 287 err = -ENOMEM; 288 goto pcifail; 261 return -ENXIO; 289 262 } 290 263 … … 295 268 296 269 err = pci_request_regions(pci, "CS5535 Audio"); 297 if (err < 0) { 298 kfree(cs5535au); 299 goto pcifail; 300 } 270 if (err < 0) 271 return err; 301 272 302 273 cs5535au->port = pci_resource_start(pci, 0); 303 274 304 if ( request_irq(pci->irq, snd_cs5535audio_interrupt,305 IRQF_SHARED, KBUILD_MODNAME, cs5535au)) {275 if (devm_request_irq(&pci->dev, pci->irq, snd_cs5535audio_interrupt, 276 IRQF_SHARED, KBUILD_MODNAME, cs5535au)) { 306 277 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 307 err = -EBUSY; 308 goto sndfail; 278 return -EBUSY; 309 279 } 310 280 … … 313 283 pci_set_master(pci); 314 284 315 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cs5535au, &ops);316 if (err < 0)317 goto sndfail;318 319 *rcs5535au = cs5535au;320 285 return 0; 321 322 sndfail: /* leave the device alive, just kill the snd */ 323 snd_cs5535audio_free(cs5535au); 324 return err; 325 326 pcifail: 327 pci_disable_device(pci); 328 return err; 329 } 330 331 static int snd_cs5535audio_probe(struct pci_dev *pci, 332 const struct pci_device_id *pci_id) 286 } 287 288 static int __snd_cs5535audio_probe(struct pci_dev *pci, 289 const struct pci_device_id *pci_id) 333 290 { 334 291 static int dev; … … 344 301 } 345 302 346 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,347 0, &card);348 if (err < 0) 349 return err; 350 351 err = snd_cs5535audio_create(card, pci, &cs5535au);352 if (err < 0) 353 goto probefail_out;354 355 card->private_data = cs5535au;303 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 304 sizeof(*cs5535au), &card); 305 if (err < 0) 306 return err; 307 cs5535au = card->private_data; 308 card->private_free = snd_cs5535audio_free; 309 310 err = snd_cs5535audio_create(card, pci); 311 if (err < 0) 312 return err; 356 313 357 314 err = snd_cs5535audio_mixer(cs5535au); 358 315 if (err < 0) 359 goto probefail_out;316 return err; 360 317 361 318 err = snd_cs5535audio_pcm(cs5535au); 362 319 if (err < 0) 363 goto probefail_out;320 return err; 364 321 365 322 strcpy(card->driver, DRIVER_NAME); … … 372 329 err = snd_card_register(card); 373 330 if (err < 0) 374 goto probefail_out;331 return err; 375 332 376 333 pci_set_drvdata(pci, card); 377 334 dev++; 378 335 return 0; 379 380 probefail_out: 381 snd_card_free(card); 382 return err; 383 } 384 385 static void snd_cs5535audio_remove(struct pci_dev *pci) 386 { 387 olpc_quirks_cleanup(); 388 snd_card_free(pci_get_drvdata(pci)); 336 } 337 338 static int snd_cs5535audio_probe(struct pci_dev *pci, 339 const struct pci_device_id *pci_id) 340 { 341 return snd_card_free_on_error(&pci->dev, __snd_cs5535audio_probe(pci, pci_id)); 389 342 } 390 343 … … 393 346 .id_table = snd_cs5535audio_ids, 394 347 .probe = snd_cs5535audio_probe, 395 .remove = snd_cs5535audio_remove,396 348 #ifdef CONFIG_PM_SLEEP 397 349 .driver = { -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1.c
r703 r717 114 114 } 115 115 116 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 117 0, &card); 118 if (err < 0) 119 return err; 116 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 117 sizeof(*emu), &card); 118 if (err < 0) 119 return err; 120 emu = card->private_data; 121 120 122 if (max_buffer_size[dev] < 32) 121 123 max_buffer_size[dev] = 32; … … 124 126 err = snd_emu10k1_create(card, pci, extin[dev], extout[dev], 125 127 (long)max_buffer_size[dev] * 1024 * 1024, 126 enable_ir[dev], subsystem[dev], 127 &emu); 128 if (err < 0) 129 goto error; 130 card->private_data = emu; 128 enable_ir[dev], subsystem[dev]); 129 if (err < 0) 130 return err; 131 131 emu->delay_pcm_irq = delay_pcm_irq[dev] & 0x1f; 132 132 err = snd_emu10k1_pcm(emu, 0); 133 133 if (err < 0) 134 goto error;134 return err; 135 135 err = snd_emu10k1_pcm_mic(emu, 1); 136 136 if (err < 0) 137 goto error;137 return err; 138 138 err = snd_emu10k1_pcm_efx(emu, 2); 139 139 if (err < 0) 140 goto error;140 return err; 141 141 /* This stores the periods table. */ 142 142 if (emu->card_capabilities->ca0151_chip) { /* P16V */ 143 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 144 1024, &emu->p16v_buffer); 145 if (err < 0) 146 goto error; 147 } 148 143 emu->p16v_buffer = 144 snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, 1024); 145 if (!emu->p16v_buffer) 146 return -ENOMEM; 147 } 149 148 err = snd_emu10k1_mixer(emu, 0, 3); 150 149 if (err < 0) 151 goto error;150 return err; 152 151 153 152 err = snd_emu10k1_timer(emu, 0); 154 153 if (err < 0) 155 goto error;154 return err; 156 155 157 156 err = snd_emu10k1_pcm_multi(emu, 3); 158 157 if (err < 0) 159 goto error;158 return err; 160 159 if (emu->card_capabilities->ca0151_chip) { /* P16V */ 161 160 err = snd_p16v_pcm(emu, 4); 162 161 if (err < 0) 163 goto error;162 return err; 164 163 } 165 164 if (emu->audigy) { 166 165 err = snd_emu10k1_audigy_midi(emu); 167 166 if (err < 0) 168 goto error;167 return err; 169 168 } else { 170 169 err = snd_emu10k1_midi(emu); 171 170 if (err < 0) 172 goto error;171 return err; 173 172 } 174 173 err = snd_emu10k1_fx8010_new(emu, 0); 175 174 if (err < 0) 176 goto error;175 return err; 177 176 #ifdef ENABLE_SYNTH 178 177 if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, … … 202 201 err = snd_card_register(card); 203 202 if (err < 0) 204 goto error;203 return err; 205 204 206 205 if (emu->card_capabilities->emu_model) … … 210 209 dev++; 211 210 return 0; 212 213 error:214 snd_card_free(card);215 return err;216 211 } 217 218 static void snd_card_emu10k1_remove(struct pci_dev *pci)219 {220 snd_card_free(pci_get_drvdata(pci));221 }222 223 212 224 213 #ifdef CONFIG_PM_SLEEP … … 278 267 .id_table = snd_emu10k1_ids, 279 268 .probe = snd_card_emu10k1_probe, 280 .remove = snd_card_emu10k1_remove,281 269 .driver = { 282 270 .pm = SND_EMU10K1_PM_OPS, -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_main.c
r695 r717 1252 1252 #endif 1253 1253 1254 static int snd_emu10k1_free(struct snd_emu10k1 *emu)1254 static void snd_emu10k1_free(struct snd_card *card) 1255 1255 { 1256 struct snd_emu10k1 *emu = card->private_data; 1257 1256 1258 if (emu->port) { /* avoid access to already used hardware */ 1257 1259 snd_emu10k1_fx8010_tram_setup(emu, 0); … … 1266 1268 release_firmware(emu->firmware); 1267 1269 release_firmware(emu->dock_fw); 1268 if (emu->irq >= 0)1269 free_irq(emu->irq, emu);1270 1270 snd_util_memhdr_free(emu->memhdr); 1271 1271 if (emu->silent_page.area) … … 1278 1278 free_pm_buffer(emu); 1279 1279 #endif 1280 if (emu->port)1281 pci_release_regions(emu->pci);1282 if (emu->card_capabilities->ca0151_chip) /* P16V */1283 snd_p16v_free(emu);1284 pci_disable_device(emu->pci);1285 kfree(emu);1286 return 0;1287 }1288 1289 static int snd_emu10k1_dev_free(struct snd_device *device)1290 {1291 struct snd_emu10k1 *emu = device->device_data;1292 return snd_emu10k1_free(emu);1293 1280 } 1294 1281 … … 1792 1779 long max_cache_bytes, 1793 1780 int enable_ir, 1794 uint subsystem, 1795 struct snd_emu10k1 **remu) 1781 uint subsystem) 1796 1782 { 1797 struct snd_emu10k1 *emu ;1783 struct snd_emu10k1 *emu = card->private_data; 1798 1784 int idx, err; 1799 1785 int is_audigy; … … 1802 1788 unsigned int silent_page; 1803 1789 const struct snd_emu_chip_details *c; 1804 static const struct snd_device_ops ops = {1805 .dev_free = snd_emu10k1_dev_free,1806 };1807 1808 *remu = NULL;1809 1790 1810 1791 /* enable PCI device */ 1811 err = pci _enable_device(pci);1792 err = pcim_enable_device(pci); 1812 1793 if (err < 0) 1813 1794 return err; 1814 1795 1815 emu = kzalloc(sizeof(*emu), GFP_KERNEL); 1816 if (emu == NULL) { 1817 pci_disable_device(pci); 1818 return -ENOMEM; 1819 } 1796 card->private_free = snd_emu10k1_free; 1820 1797 emu->card = card; 1821 1798 spin_lock_init(&emu->reg_lock); … … 1864 1841 if (c->vendor == 0) { 1865 1842 dev_err(card->dev, "emu10k1: Card not recognised\n"); 1866 kfree(emu);1867 pci_disable_device(pci);1868 1843 return -ENOENT; 1869 1844 } … … 1897 1872 "architecture does not support PCI busmaster DMA with mask 0x%lx\n", 1898 1873 emu->dma_mask); 1899 kfree(emu);1900 pci_disable_device(pci);1901 1874 return -ENXIO; 1902 1875 } … … 1907 1880 1908 1881 err = pci_request_regions(pci, "EMU10K1"); 1909 if (err < 0) { 1910 kfree(emu); 1911 pci_disable_device(pci); 1882 if (err < 0) 1912 1883 return err; 1913 }1914 1884 emu->port = pci_resource_start(pci, 0); 1915 1885 … … 1919 1889 MAXPAGES0); 1920 1890 if (snd_emu10k1_alloc_pages_maybe_wider(emu, page_table_size, 1921 &emu->ptb_pages) < 0) { 1922 err = -ENOMEM; 1923 goto error; 1924 } 1891 &emu->ptb_pages) < 0) 1892 return -ENOMEM; 1925 1893 dev_dbg(card->dev, "page table address range is %.8lx:%.8lx\n", 1926 1894 (unsigned long)emu->ptb_pages.addr, … … 1937 1905 sizeof(unsigned long)); 1938 1906 #endif 1939 if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { 1940 err = -ENOMEM; 1941 goto error; 1942 } 1907 1908 if (!emu->page_ptr_table || !emu->page_addr_table) 1909 return -ENOMEM; 1943 1910 1944 1911 if (snd_emu10k1_alloc_pages_maybe_wider(emu, EMUPAGESIZE, 1945 &emu->silent_page) < 0) { 1946 err = -ENOMEM; 1947 goto error; 1948 } 1912 &emu->silent_page) < 0) 1913 return -ENOMEM; 1949 1914 dev_dbg(card->dev, "silent page range is %.8lx:%.8lx\n", 1950 1915 (unsigned long)emu->silent_page.addr, … … 1953 1918 1954 1919 emu->memhdr = snd_util_memhdr_new(emu->max_cache_pages * PAGE_SIZE); 1955 if (emu->memhdr == NULL) { 1956 err = -ENOMEM; 1957 goto error; 1958 } 1920 if (!emu->memhdr) 1921 return -ENOMEM; 1959 1922 emu->memhdr->block_extra_size = sizeof(struct snd_emu10k1_memblk) - 1960 1923 sizeof(struct snd_util_memblk); … … 1974 1937 err = snd_emu10k1_cardbus_init(emu); 1975 1938 if (err < 0) 1976 goto error;1939 return err; 1977 1940 } 1978 1941 if (emu->card_capabilities->ecard) { 1979 1942 err = snd_emu10k1_ecard_init(emu); 1980 1943 if (err < 0) 1981 goto error;1944 return err; 1982 1945 } else if (emu->card_capabilities->emu_model) { 1983 1946 err = snd_emu10k1_emu1010_init(emu); 1984 if (err < 0) { 1985 snd_emu10k1_free(emu); 1947 if (err < 0) 1986 1948 return err; 1987 }1988 1949 } else { 1989 1950 /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version … … 1999 1960 2000 1961 /* irq handler must be registered after I/O ports are activated */ 2001 if (request_irq(pci->irq, snd_emu10k1_interrupt, IRQF_SHARED, 2002 KBUILD_MODNAME, emu)) { 2003 err = -EBUSY; 2004 goto error; 2005 } 1962 if (devm_request_irq(&pci->dev, pci->irq, snd_emu10k1_interrupt, 1963 IRQF_SHARED, KBUILD_MODNAME, emu)) 1964 return -EBUSY; 2006 1965 emu->irq = pci->irq; 2007 1966 card->sync_irq = emu->irq; … … 2042 2001 err = snd_emu10k1_init(emu, enable_ir, 0); 2043 2002 if (err < 0) 2044 goto error;2003 return err; 2045 2004 #ifdef CONFIG_PM_SLEEP 2046 2005 err = alloc_pm_buffer(emu); 2047 2006 if (err < 0) 2048 goto error;2007 return err; 2049 2008 #endif 2050 2009 … … 2052 2011 err = snd_emu10k1_init_efx(emu); 2053 2012 if (err < 0) 2054 goto error;2013 return err; 2055 2014 snd_emu10k1_audio_enable(emu); 2056 2057 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops);2058 if (err < 0)2059 goto error;2060 2015 2061 2016 #ifdef CONFIG_SND_PROC_FS 2062 2017 snd_emu10k1_proc_init(emu); 2063 2018 #endif 2064 2065 *remu = emu;2066 2019 return 0; 2067 2068 error:2069 snd_emu10k1_free(emu);2070 return err;2071 2020 } 2072 2021 -
GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1x.c
r703 r717 220 220 221 221 unsigned long port; 222 struct resource *res_port;223 222 int irq; 224 223 … … 237 236 u32 spdif_bits[3]; // SPDIF out setup 238 237 239 struct snd_dma_buffer dma_buffer;238 struct snd_dma_buffer *dma_buffer; 240 239 241 240 struct emu10k1x_midi midi; … … 446 445 struct emu10k1x_pcm *epcm = runtime->private_data; 447 446 int voice = epcm->voice->number; 448 u32 *table_base = (u32 *)(emu->dma_buffer .area+1024*voice);447 u32 *table_base = (u32 *)(emu->dma_buffer->area+1024*voice); 449 448 u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); 450 449 int i; … … 455 454 } 456 455 457 snd_emu10k1x_ptr_write(emu, PLAYBACK_LIST_ADDR, voice, emu->dma_buffer .addr+1024*voice);456 snd_emu10k1x_ptr_write(emu, PLAYBACK_LIST_ADDR, voice, emu->dma_buffer->addr+1024*voice); 458 457 snd_emu10k1x_ptr_write(emu, PLAYBACK_LIST_SIZE, voice, (runtime->periods - 1) << 19); 459 458 snd_emu10k1x_ptr_write(emu, PLAYBACK_LIST_PTR, voice, 0); … … 741 740 } 742 741 743 static int snd_emu10k1x_free(struct emu10k1x *chip) 744 { 742 static void snd_emu10k1x_free(struct snd_card *card) 743 { 744 struct emu10k1x *chip = card->private_data; 745 745 746 snd_emu10k1x_ptr_write(chip, TRIGGER_CHANNEL, 0, 0); 746 747 // disable interrupts … … 748 749 // disable audio 749 750 outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); 750 751 /* release the irq */752 if (chip->irq >= 0)753 free_irq(chip->irq, chip);754 755 // release the i/o port756 release_and_free_resource(chip->res_port);757 758 // release the DMA759 if (chip->dma_buffer.area) {760 snd_dma_free_pages(&chip->dma_buffer);761 }762 763 pci_disable_device(chip->pci);764 765 // release the data766 kfree(chip);767 return 0;768 }769 770 static int snd_emu10k1x_dev_free(struct snd_device *device)771 {772 struct emu10k1x *chip = device->device_data;773 return snd_emu10k1x_free(chip);774 751 } 775 752 … … 889 866 890 867 static int snd_emu10k1x_create(struct snd_card *card, 891 struct pci_dev *pci, 892 struct emu10k1x **rchip) 893 { 894 struct emu10k1x *chip; 868 struct pci_dev *pci) 869 { 870 struct emu10k1x *chip = card->private_data; 895 871 int err; 896 872 int ch; 897 static const struct snd_device_ops ops = { 898 .dev_free = snd_emu10k1x_dev_free, 899 }; 900 901 *rchip = NULL; 902 903 err = pci_enable_device(pci); 873 874 err = pcim_enable_device(pci); 904 875 if (err < 0) 905 876 return err; … … 907 878 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28)) < 0) { 908 879 dev_err(card->dev, "error to set 28bit mask DMA\n"); 909 pci_disable_device(pci);910 880 return -ENXIO; 911 }912 913 chip = kzalloc(sizeof(*chip), GFP_KERNEL);914 if (chip == NULL) {915 pci_disable_device(pci);916 return -ENOMEM;917 881 } 918 882 … … 924 888 spin_lock_init(&chip->voice_lock); 925 889 890 err = pci_request_regions(pci, "EMU10K1X"); 891 if (err < 0) 892 return err; 926 893 chip->port = pci_resource_start(pci, 0); 927 chip->res_port = request_region(chip->port, 8, "EMU10K1X"); 928 if (!chip->res_port) { 929 dev_err(card->dev, "cannot allocate the port 0x%lx\n", 930 chip->port); 931 snd_emu10k1x_free(chip); 932 return -EBUSY; 933 } 934 935 if (request_irq(pci->irq, snd_emu10k1x_interrupt, 936 IRQF_SHARED, KBUILD_MODNAME, chip)) { 894 895 if (devm_request_irq(&pci->dev, pci->irq, snd_emu10k1x_interrupt, 896 IRQF_SHARED, KBUILD_MODNAME, chip)) { 937 897 dev_err(card->dev, "cannot grab irq %d\n", pci->irq); 938 snd_emu10k1x_free(chip);939 898 return -EBUSY; 940 899 } 941 900 chip->irq = pci->irq; 942 901 card->sync_irq = chip->irq; 902 card->private_free = snd_emu10k1x_free; 943 903 944 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev,945 4 * 1024, &chip->dma_buffer) < 0) {946 snd_emu10k1x_free(chip);904 chip->dma_buffer = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, 905 4 * 1024); 906 if (!chip->dma_buffer) 947 907 return -ENOMEM; 948 }949 908 950 909 pci_set_master(pci); … … 1006 965 outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG); 1007 966 1008 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);1009 if (err < 0) {1010 snd_emu10k1x_free(chip);1011 return err;1012 }1013 *rchip = chip;1014 967 return 0; 1015 968 } … … 1546 1499 } 1547 1500 1548 static int snd_emu10k1x_probe(struct pci_dev *pci,1549 1501 static int __snd_emu10k1x_probe(struct pci_dev *pci, 1502 const struct pci_device_id *pci_id) 1550 1503 { 1551 1504 static int dev; … … 1561 1514 } 1562 1515 1563 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1564 0, &card); 1565 if (err < 0) 1566 return err; 1567 1568 err = snd_emu10k1x_create(card, pci, &chip); 1569 if (err < 0) { 1570 snd_card_free(card); 1571 return err; 1572 } 1516 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1517 sizeof(*chip), &card); 1518 if (err < 0) 1519 return err; 1520 chip = card->private_data; 1521 1522 err = snd_emu10k1x_create(card, pci); 1523 if (err < 0) 1524 return err; 1573 1525 1574 1526 err = snd_emu10k1x_pcm(chip, 0); 1575 if (err < 0) { 1576 snd_card_free(card); 1577 return err; 1578 } 1527 if (err < 0) 1528 return err; 1579 1529 err = snd_emu10k1x_pcm(chip, 1); 1580 if (err < 0) { 1581 snd_card_free(card); 1582 return err; 1583 } 1530 if (err < 0) 1531 return err; 1584 1532 err = snd_emu10k1x_pcm(chip, 2); 1585 if (err < 0) { 1586 snd_card_free(card); 1587 return err; 1588 } 1533 if (err < 0) 1534 return err; 1589 1535 1590 1536 err = snd_emu10k1x_ac97(chip); 1591 if (err < 0) { 1592 snd_card_free(card); 1593 return err; 1594 } 1537 if (err < 0) 1538 return err; 1595 1539 1596 1540 err = snd_emu10k1x_mixer(chip); 1597 if (err < 0) { 1598 snd_card_free(card); 1599 return err; 1600 } 1541 if (err < 0) 1542 return err; 1601 1543 1602 1544 err = snd_emu10k1x_midi(chip); 1603 if (err < 0) { 1604 snd_card_free(card); 1605 return err; 1606 } 1545 if (err < 0) 1546 return err; 1607 1547 1608 1548 snd_emu10k1x_proc_init(chip); … … 1614 1554 1615 1555 err = snd_card_register(card); 1616 if (err < 0) { 1617 snd_card_free(card); 1618 return err; 1619 } 1556 if (err < 0) 1557 return err; 1620 1558 1621 1559 pci_set_drvdata(pci, card); … … 1624 1562 } 1625 1563 1626 static void snd_emu10k1x_remove(struct pci_dev *pci) 1627 { 1628 snd_card_free(pci_get_drvdata(pci)); 1564 static int snd_emu10k1x_probe(struct pci_dev *pci, 1565 const struct pci_device_id *pci_id) 1566 { 1567 return snd_card_free_on_error(&pci->dev, __snd_emu10k1x_probe(pci, pci_id)); 1629 1568 } 1630 1569 … … 1641 1580 .id_table = snd_emu10k1x_ids, 1642 1581 .probe = snd_emu10k1x_probe, 1643 .remove = snd_emu10k1x_remove,1644 1582 }; 1645 1583 -
GPL/trunk/alsa-kernel/pci/emu10k1/p16v.c
r703 r717 291 291 struct snd_pcm_runtime *runtime = substream->runtime; 292 292 int channel = substream->pcm->device - emu->p16v_device_offset; 293 u32 *table_base = (u32 *)(emu->p16v_buffer .area+(8*16*channel));293 u32 *table_base = (u32 *)(emu->p16v_buffer->area+(8*16*channel)); 294 294 u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); 295 295 int i; … … 309 309 dev_dbg(emu->card->dev, 310 310 "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n", 311 emu->p16v_buffer .addr, emu->p16v_buffer.area,312 emu->p16v_buffer .bytes);311 emu->p16v_buffer->addr, emu->p16v_buffer->area, 312 emu->p16v_buffer->bytes); 313 313 #endif /* debug */ 314 314 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel); … … 334 334 } 335 335 336 snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_ADDR, channel, emu->p16v_buffer .addr+(8*16*channel));336 snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_ADDR, channel, emu->p16v_buffer->addr+(8*16*channel)); 337 337 snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19); 338 338 snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_PTR, channel, 0); … … 567 567 .pointer = snd_p16v_pcm_pointer_capture, 568 568 }; 569 570 571 int snd_p16v_free(struct snd_emu10k1 *chip)572 {573 // release the data574 if (chip->p16v_buffer.area) {575 snd_dma_free_pages(&chip->p16v_buffer);576 /*577 dev_dbg(chip->card->dev, "period lables free: %p\n",578 &chip->p16v_buffer);579 */580 }581 return 0;582 }583 569 584 570 int snd_p16v_pcm(struct snd_emu10k1 *emu, int device) -
GPL/trunk/alsa-kernel/pci/ens1370.c
r703 r717 418 418 419 419 #ifdef CHIP1370 420 struct snd_dma_buffer dma_bug;420 struct snd_dma_buffer *dma_bug; 421 421 #endif 422 422 … … 1876 1876 */ 1877 1877 1878 static int snd_ensoniq_free(struct ensoniq *ensoniq) 1879 { 1878 static void snd_ensoniq_free(struct snd_card *card) 1879 { 1880 struct ensoniq *ensoniq = card->private_data; 1881 1880 1882 snd_ensoniq_free_gameport(ensoniq); 1881 if (ensoniq->irq < 0)1882 goto __hw_end;1883 1883 #ifdef CHIP1370 1884 1884 outl(ES_1370_SERR_DISABLE, ES_REG(ensoniq, CONTROL)); /* switch everything off */ … … 1888 1888 outl(0, ES_REG(ensoniq, SERIAL)); /* clear serial interface */ 1889 1889 #endif 1890 pci_set_power_state(ensoniq->pci, PCI_D3hot);1891 __hw_end:1892 #ifdef CHIP13701893 if (ensoniq->dma_bug.area)1894 snd_dma_free_pages(&ensoniq->dma_bug);1895 #endif1896 if (ensoniq->irq >= 0)1897 free_irq(ensoniq->irq, ensoniq);1898 pci_release_regions(ensoniq->pci);1899 pci_disable_device(ensoniq->pci);1900 kfree(ensoniq);1901 return 0;1902 }1903 1904 static int snd_ensoniq_dev_free(struct snd_device *device)1905 {1906 struct ensoniq *ensoniq = device->device_data;1907 return snd_ensoniq_free(ensoniq);1908 1890 } 1909 1891 … … 1939 1921 outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); 1940 1922 outl(ES_MEM_PAGEO(ES_PAGE_ADC), ES_REG(ensoniq, MEM_PAGE)); 1941 outl(ensoniq->dma_bug .addr, ES_REG(ensoniq, PHANTOM_FRAME));1923 outl(ensoniq->dma_bug->addr, ES_REG(ensoniq, PHANTOM_FRAME)); 1942 1924 outl(0, ES_REG(ensoniq, PHANTOM_COUNT)); 1943 1925 #else … … 2036 2018 2037 2019 static int snd_ensoniq_create(struct snd_card *card, 2038 struct pci_dev *pci, 2039 struct ensoniq **rensoniq) 2040 { 2041 struct ensoniq *ensoniq; 2020 struct pci_dev *pci) 2021 { 2022 struct ensoniq *ensoniq = card->private_data; 2042 2023 int err; 2043 static const struct snd_device_ops ops = { 2044 .dev_free = snd_ensoniq_dev_free, 2045 }; 2046 2047 *rensoniq = NULL; 2048 err = pci_enable_device(pci); 2024 2025 err = pcim_enable_device(pci); 2049 2026 if (err < 0) 2050 2027 return err; 2051 ensoniq = kzalloc(sizeof(*ensoniq), GFP_KERNEL);2052 if (ensoniq == NULL) {2053 pci_disable_device(pci);2054 return -ENOMEM;2055 }2056 2028 spin_lock_init(&ensoniq->reg_lock); 2057 2029 mutex_init(&ensoniq->src_mutex); … … 2060 2032 ensoniq->irq = -1; 2061 2033 err = pci_request_regions(pci, "Ensoniq AudioPCI"); 2062 if (err < 0) { 2063 kfree(ensoniq); 2064 pci_disable_device(pci); 2034 if (err < 0) 2065 2035 return err; 2066 }2067 2036 ensoniq->port = pci_resource_start(pci, 0); 2037 #ifndef TARGET_OS2 2038 if (devm_request_irq(&pci->dev, pci->irq, snd_audiopci_interrupt, 2039 IRQF_SHARED, KBUILD_MODNAME, ensoniq)) { 2040 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 2041 return -EBUSY; 2042 } 2043 #else 2068 2044 if (request_irq(pci->irq, snd_audiopci_interrupt, IRQF_SHARED, 2069 2045 KBUILD_MODNAME, ensoniq)) { 2070 2046 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 2071 snd_ensoniq_free( ensoniq);2047 snd_ensoniq_free(card); 2072 2048 return -EBUSY; 2073 2049 } 2050 #endif 2074 2051 ensoniq->irq = pci->irq; 2075 2052 card->sync_irq = ensoniq->irq; 2076 2053 #ifdef CHIP1370 2077 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 2078 16, &ensoniq->dma_bug) < 0) { 2079 dev_err(card->dev, "unable to allocate space for phantom area - dma_bug\n"); 2080 snd_ensoniq_free(ensoniq); 2081 return -EBUSY; 2082 } 2054 ensoniq->dma_bug = 2055 snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, 16); 2056 if (!ensoniq->dma_bug) 2057 return -ENOMEM; 2083 2058 #endif 2084 2059 pci_set_master(pci); … … 2107 2082 #endif 2108 2083 2084 card->private_free = snd_ensoniq_free; 2109 2085 snd_ensoniq_chip_init(ensoniq); 2110 2086 2111 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ensoniq, &ops);2112 if (err < 0) {2113 snd_ensoniq_free(ensoniq);2114 return err;2115 }2116 2117 2087 snd_ensoniq_proc_init(ensoniq); 2118 2119 *rensoniq = ensoniq;2120 2088 return 0; 2121 2089 } … … 2353 2321 } 2354 2322 2355 static int snd_audiopci_probe(struct pci_dev *pci,2356 2323 static int __snd_audiopci_probe(struct pci_dev *pci, 2324 const struct pci_device_id *pci_id) 2357 2325 { 2358 2326 static int dev; … … 2368 2336 } 2369 2337 2370 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,2371 0, &card);2338 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 2339 sizeof(*ensoniq), &card); 2372 2340 if (err < 0) 2373 2341 return err; 2374 2375 err = snd_ensoniq_create(card, pci, &ensoniq); 2376 if (err < 0) {2377 snd_card_free(card);2342 ensoniq = card->private_data; 2343 2344 err = snd_ensoniq_create(card, pci); 2345 if (err < 0) 2378 2346 return err; 2379 }2380 card->private_data = ensoniq;2381 2347 2382 2348 #ifdef CHIP1370 2383 2349 err = snd_ensoniq_1370_mixer(ensoniq); 2384 if (err < 0) { 2385 snd_card_free(card); 2350 if (err < 0) 2386 2351 return err; 2387 }2388 2352 #endif 2389 2353 #ifdef CHIP1371 2390 2354 err = snd_ensoniq_1371_mixer(ensoniq, spdif[dev], lineio[dev]); 2391 if (err < 0) { 2392 snd_card_free(card); 2355 if (err < 0) 2393 2356 return err; 2394 }2395 2357 #endif 2396 2358 err = snd_ensoniq_pcm(ensoniq, 0); 2397 if (err < 0) { 2398 snd_card_free(card); 2359 if (err < 0) 2399 2360 return err; 2400 }2401 2361 err = snd_ensoniq_pcm2(ensoniq, 1); 2402 if (err < 0) { 2403 snd_card_free(card); 2362 if (err < 0) 2404 2363 return err; 2405 }2406 2364 err = snd_ensoniq_midi(ensoniq, 0); 2407 if (err < 0) { 2408 snd_card_free(card); 2365 if (err < 0) 2409 2366 return err; 2410 }2411 2367 2412 2368 snd_ensoniq_create_gameport(ensoniq, dev); … … 2422 2378 2423 2379 err = snd_card_register(card); 2424 if (err < 0) { 2425 snd_card_free(card); 2380 if (err < 0) 2426 2381 return err; 2427 }2428 2382 2429 2383 pci_set_drvdata(pci, card); … … 2432 2386 } 2433 2387 2434 static void snd_audiopci_remove(struct pci_dev *pci) 2435 { 2436 snd_card_free(pci_get_drvdata(pci)); 2388 static int snd_audiopci_probe(struct pci_dev *pci, 2389 const struct pci_device_id *pci_id) 2390 { 2391 return snd_card_free_on_error(&pci->dev, __snd_audiopci_probe(pci, pci_id)); 2437 2392 } 2438 2393 … … 2441 2396 .id_table = snd_audiopci_ids, 2442 2397 .probe = snd_audiopci_probe, 2443 .remove = snd_audiopci_remove,2444 2398 .driver = { 2445 2399 .pm = SND_ENSONIQ_PM_OPS, -
GPL/trunk/alsa-kernel/pci/es1938.c
r703 r717 1557 1557 #endif /* SUPPORT_JOYSTICK */ 1558 1558 1559 static int snd_es1938_free(struct es1938 *chip) 1560 { 1559 static void snd_es1938_free(struct snd_card *card) 1560 { 1561 struct es1938 *chip = card->private_data; 1562 1561 1563 /* disable irqs */ 1562 1564 outb(0x00, SLIO_REG(chip, IRQCONTROL)); … … 1568 1570 if (chip->irq >= 0) 1569 1571 free_irq(chip->irq, chip); 1570 pci_release_regions(chip->pci);1571 pci_disable_device(chip->pci);1572 kfree(chip);1573 return 0;1574 }1575 1576 static int snd_es1938_dev_free(struct snd_device *device)1577 {1578 struct es1938 *chip = device->device_data;1579 return snd_es1938_free(chip);1580 1572 } 1581 1573 1582 1574 static int snd_es1938_create(struct snd_card *card, 1583 struct pci_dev *pci, 1584 struct es1938 **rchip) 1585 { 1586 struct es1938 *chip; 1575 struct pci_dev *pci) 1576 { 1577 struct es1938 *chip = card->private_data; 1587 1578 int err; 1588 static const struct snd_device_ops ops = {1589 .dev_free = snd_es1938_dev_free,1590 };1591 1592 *rchip = NULL;1593 1579 1594 1580 /* enable PCI device */ 1595 err = pci _enable_device(pci);1581 err = pcim_enable_device(pci); 1596 1582 if (err < 0) 1597 1583 return err; … … 1600 1586 dev_err(card->dev, 1601 1587 "architecture does not support 24bit PCI busmaster DMA\n"); 1602 pci_disable_device(pci);1603 1588 return -ENXIO; 1604 1589 } 1605 1590 1606 chip = kzalloc(sizeof(*chip), GFP_KERNEL);1607 if (chip == NULL) {1608 pci_disable_device(pci);1609 return -ENOMEM;1610 }1611 1591 spin_lock_init(&chip->reg_lock); 1612 1592 spin_lock_init(&chip->mixer_lock); … … 1615 1595 chip->irq = -1; 1616 1596 err = pci_request_regions(pci, "ESS Solo-1"); 1617 if (err < 0) { 1618 kfree(chip); 1619 pci_disable_device(pci); 1597 if (err < 0) 1620 1598 return err; 1621 }1622 1599 chip->io_port = pci_resource_start(pci, 0); 1623 1600 chip->sb_port = pci_resource_start(pci, 1); … … 1625 1602 chip->mpu_port = pci_resource_start(pci, 3); 1626 1603 chip->game_port = pci_resource_start(pci, 4); 1604 /* still use non-managed irq handler as it's re-acquired at PM resume */ 1627 1605 if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED, 1628 1606 KBUILD_MODNAME, chip)) { 1629 1607 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 1630 snd_es1938_free(chip);1631 1608 return -EBUSY; 1632 1609 } 1633 1610 chip->irq = pci->irq; 1634 1611 card->sync_irq = chip->irq; 1612 card->private_free = snd_es1938_free; 1635 1613 dev_dbg(card->dev, 1636 1614 "create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n", … … 1640 1618 1641 1619 snd_es1938_chip_init(chip); 1642 1643 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);1644 if (err < 0) {1645 snd_es1938_free(chip);1646 return err;1647 }1648 1649 *rchip = chip;1650 1620 return 0; 1651 1621 } … … 1782 1752 1783 1753 1784 static int snd_es1938_probe(struct pci_dev *pci,1785 const struct pci_device_id *pci_id)1754 static int __snd_es1938_probe(struct pci_dev *pci, 1755 const struct pci_device_id *pci_id) 1786 1756 { 1787 1757 static int dev; … … 1798 1768 } 1799 1769 1800 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,1801 0, &card);1770 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1771 sizeof(*chip), &card); 1802 1772 if (err < 0) 1803 1773 return err; 1804 for (idx = 0; idx < 5; idx++) { 1774 chip = card->private_data; 1775 1776 for (idx = 0; idx < 5; idx++) 1805 1777 if (pci_resource_start(pci, idx) == 0 || 1806 !(pci_resource_flags(pci, idx) & IORESOURCE_IO)) { 1807 snd_card_free(card); 1808 return -ENODEV; 1809 } 1810 } 1811 err = snd_es1938_create(card, pci, &chip); 1812 if (err < 0) { 1813 snd_card_free(card); 1778 !(pci_resource_flags(pci, idx) & IORESOURCE_IO)) 1779 return -ENODEV; 1780 1781 err = snd_es1938_create(card, pci); 1782 if (err < 0) 1814 1783 return err; 1815 }1816 card->private_data = chip;1817 1784 1818 1785 strcpy(card->driver, "ES1938"); … … 1824 1791 1825 1792 err = snd_es1938_new_pcm(chip, 0); 1826 if (err < 0) { 1827 snd_card_free(card); 1793 if (err < 0) 1828 1794 return err; 1829 }1830 1795 err = snd_es1938_mixer(chip); 1831 if (err < 0) { 1832 snd_card_free(card); 1796 if (err < 0) 1833 1797 return err; 1834 }1835 1798 if (snd_opl3_create(card, 1836 1799 SLSB_REG(chip, FMLOWADDR), … … 1841 1804 } else { 1842 1805 err = snd_opl3_timer_new(opl3, 0, 1); 1843 if (err < 0) { 1844 snd_card_free(card); 1806 if (err < 0) 1845 1807 return err; 1846 }1847 1808 err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); 1848 if (err < 0) { 1849 snd_card_free(card); 1809 if (err < 0) 1850 1810 return err; 1851 }1852 1811 } 1853 1812 if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, … … 1865 1824 1866 1825 err = snd_card_register(card); 1867 if (err < 0) { 1868 snd_card_free(card); 1826 if (err < 0) 1869 1827 return err; 1870 }1871 1828 1872 1829 pci_set_drvdata(pci, card); … … 1875 1832 } 1876 1833 1877 static void snd_es1938_remove(struct pci_dev *pci) 1878 { 1879 snd_card_free(pci_get_drvdata(pci)); 1834 static int snd_es1938_probe(struct pci_dev *pci, 1835 const struct pci_device_id *pci_id) 1836 { 1837 return snd_card_free_on_error(&pci->dev, __snd_es1938_probe(pci, pci_id)); 1880 1838 } 1881 1839 … … 1884 1842 .id_table = snd_es1938_ids, 1885 1843 .probe = snd_es1938_probe, 1886 .remove = snd_es1938_remove,1887 1844 .driver = { 1888 1845 .pm = ES1938_PM_OPS, -
GPL/trunk/alsa-kernel/pci/es1968.c
r703 r717 2479 2479 return -ENODEV; 2480 2480 2481 r = request_region(JOYSTICK_ADDR, 8, "ES1968 gameport"); 2481 r = devm_request_region(&chip->pci->dev, JOYSTICK_ADDR, 8, 2482 "ES1968 gameport"); 2482 2483 if (!r) 2483 2484 return -EBUSY; … … 2487 2488 dev_err(chip->card->dev, 2488 2489 "cannot allocate memory for gameport\n"); 2489 release_and_free_resource(r);2490 2490 return -ENOMEM; 2491 2491 } … … 2498 2498 gameport_set_dev_parent(gp, &chip->pci->dev); 2499 2499 gp->io = JOYSTICK_ADDR; 2500 gameport_set_port_data(gp, r);2501 2500 2502 2501 gameport_register_port(gp); … … 2508 2507 { 2509 2508 if (chip->gameport) { 2510 struct resource *r = gameport_get_port_data(chip->gameport);2511 2512 2509 gameport_unregister_port(chip->gameport); 2513 2510 chip->gameport = NULL; 2514 2515 release_and_free_resource(r);2516 2511 } 2517 2512 } … … 2527 2522 int err; 2528 2523 2529 input_dev = input_allocate_device();2524 input_dev = devm_input_allocate_device(&chip->pci->dev); 2530 2525 if (!input_dev) 2531 2526 return -ENOMEM; … … 2547 2542 2548 2543 err = input_register_device(input_dev); 2549 if (err) { 2550 input_free_device(input_dev); 2544 if (err) 2551 2545 return err; 2552 }2553 2546 2554 2547 chip->input_dev = input_dev; … … 2634 2627 #endif 2635 2628 2636 static int snd_es1968_free(struct es1968 *chip) 2637 { 2629 static void snd_es1968_free(struct snd_card *card) 2630 { 2631 struct es1968 *chip = card->private_data; 2632 2638 2633 cancel_work_sync(&chip->hwvol_work); 2639 #ifdef CONFIG_SND_ES1968_INPUT2640 if (chip->input_dev)2641 input_unregister_device(chip->input_dev);2642 #endif2643 2634 2644 2635 if (chip->io_port) { … … 2652 2643 #endif 2653 2644 2654 if (chip->irq >= 0)2655 free_irq(chip->irq, chip);2656 2645 snd_es1968_free_gameport(chip); 2657 pci_release_regions(chip->pci);2658 pci_disable_device(chip->pci);2659 kfree(chip);2660 return 0;2661 }2662 2663 static int snd_es1968_dev_free(struct snd_device *device)2664 {2665 struct es1968 *chip = device->device_data;2666 return snd_es1968_free(chip);2667 2646 } 2668 2647 … … 2694 2673 int chip_type, 2695 2674 int do_pm, 2696 int radio_nr, 2697 struct es1968 **chip_ret) 2698 { 2699 static const struct snd_device_ops ops = { 2700 .dev_free = snd_es1968_dev_free, 2701 }; 2702 struct es1968 *chip; 2675 int radio_nr) 2676 { 2677 struct es1968 *chip = card->private_data; 2703 2678 int i, err; 2704 2679 2705 *chip_ret = NULL;2706 2707 2680 /* enable PCI device */ 2708 err = pci _enable_device(pci);2681 err = pcim_enable_device(pci); 2709 2682 if (err < 0) 2710 2683 return err; … … 2713 2686 dev_err(card->dev, 2714 2687 "architecture does not support 28bit PCI busmaster DMA\n"); 2715 pci_disable_device(pci);2716 2688 return -ENXIO; 2717 }2718 2719 chip = kzalloc(sizeof(*chip), GFP_KERNEL);2720 if (! chip) {2721 pci_disable_device(pci);2722 return -ENOMEM;2723 2689 } 2724 2690 … … 2739 2705 2740 2706 err = pci_request_regions(pci, "ESS Maestro"); 2741 if (err < 0) { 2742 kfree(chip); 2743 pci_disable_device(pci); 2707 if (err < 0) 2744 2708 return err; 2745 }2746 2709 chip->io_port = pci_resource_start(pci, 0); 2747 if ( request_irq(pci->irq, snd_es1968_interrupt, IRQF_SHARED,2748 KBUILD_MODNAME, chip)) {2710 if (devm_request_irq(&pci->dev, pci->irq, snd_es1968_interrupt, 2711 IRQF_SHARED, KBUILD_MODNAME, chip)) { 2749 2712 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 2750 snd_es1968_free(chip);2751 2713 return -EBUSY; 2752 2714 } 2753 2715 chip->irq = pci->irq; 2754 2716 card->sync_irq = chip->irq; 2717 card->private_free = snd_es1968_free; 2755 2718 2756 2719 /* Clear Maestro_map */ … … 2786 2749 snd_es1968_chip_init(chip); 2787 2750 2788 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);2789 if (err < 0) {2790 snd_es1968_free(chip);2791 return err;2792 }2793 2794 2751 #ifdef CONFIG_SND_ES1968_RADIO 2795 2752 /* don't play with GPIOs on laptops */ 2796 2753 if (chip->pci->subsystem_vendor != 0x125d) 2797 goto no_radio;2754 return 0; 2798 2755 err = v4l2_device_register(&pci->dev, &chip->v4l2_dev); 2799 if (err < 0) { 2800 snd_es1968_free(chip); 2756 if (err < 0) 2801 2757 return err; 2802 }2803 2758 chip->tea.v4l2_dev = &chip->v4l2_dev; 2804 2759 chip->tea.private_data = chip; … … 2816 2771 } 2817 2772 } 2818 no_radio:2819 2773 #endif 2820 2821 *chip_ret = chip;2822 2823 2774 return 0; 2824 2775 } … … 2827 2778 /* 2828 2779 */ 2829 static int snd_es1968_probe(struct pci_dev *pci,2830 const struct pci_device_id *pci_id)2780 static int __snd_es1968_probe(struct pci_dev *pci, 2781 const struct pci_device_id *pci_id) 2831 2782 { 2832 2783 static int dev; … … 2843 2794 } 2844 2795 2845 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,2846 0, &card);2796 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 2797 sizeof(*chip), &card); 2847 2798 if (err < 0) 2848 2799 return err; 2800 chip = card->private_data; 2849 2801 2850 2802 if (total_bufsize[dev] < 128) … … 2858 2810 pci_id->driver_data, 2859 2811 use_pm[dev], 2860 radio_nr[dev], 2861 &chip); 2862 if (err < 0) { 2863 snd_card_free(card); 2812 radio_nr[dev]); 2813 if (err < 0) 2864 2814 return err; 2865 }2866 card->private_data = chip;2867 2815 2868 2816 switch (chip->type) { … … 2882 2830 2883 2831 err = snd_es1968_pcm(chip, 0); 2884 if (err < 0) { 2885 snd_card_free(card); 2832 if (err < 0) 2886 2833 return err; 2887 }2888 2834 2889 2835 err = snd_es1968_mixer(chip); 2890 if (err < 0) { 2891 snd_card_free(card); 2836 if (err < 0) 2892 2837 return err; 2893 }2894 2838 2895 2839 if (enable_mpu[dev] == 2) { … … 2934 2878 2935 2879 err = snd_card_register(card); 2936 if (err < 0) { 2937 snd_card_free(card); 2880 if (err < 0) 2938 2881 return err; 2939 }2940 2882 pci_set_drvdata(pci, card); 2941 2883 dev++; … … 2943 2885 } 2944 2886 2945 static void snd_es1968_remove(struct pci_dev *pci) 2946 { 2947 snd_card_free(pci_get_drvdata(pci)); 2887 static int snd_es1968_probe(struct pci_dev *pci, 2888 const struct pci_device_id *pci_id) 2889 { 2890 return snd_card_free_on_error(&pci->dev, __snd_es1968_probe(pci, pci_id)); 2948 2891 } 2949 2892 … … 2952 2895 .id_table = snd_es1968_ids, 2953 2896 .probe = snd_es1968_probe, 2954 .remove = snd_es1968_remove,2955 2897 .driver = { 2956 2898 .pm = ES1968_PM_OPS, -
GPL/trunk/alsa-kernel/pci/fm801.c
r703 r717 1037 1037 }; 1038 1038 1039 static void snd_fm801_mixer_free_ac97_bus(struct snd_ac97_bus *bus)1040 {1041 struct fm801 *chip = bus->private_data;1042 chip->ac97_bus = NULL;1043 }1044 1045 static void snd_fm801_mixer_free_ac97(struct snd_ac97 *ac97)1046 {1047 struct fm801 *chip = ac97->private_data;1048 if (ac97->num == 0) {1049 chip->ac97 = NULL;1050 } else {1051 chip->ac97_sec = NULL;1052 }1053 }1054 1055 1039 static int snd_fm801_mixer(struct fm801 *chip) 1056 1040 { … … 1066 1050 if (err < 0) 1067 1051 return err; 1068 chip->ac97_bus->private_free = snd_fm801_mixer_free_ac97_bus;1069 1052 1070 1053 memset(&ac97, 0, sizeof(ac97)); 1071 1054 ac97.private_data = chip; 1072 ac97.private_free = snd_fm801_mixer_free_ac97;1073 1055 err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97); 1074 1056 if (err < 0) … … 1186 1168 } 1187 1169 1188 static int snd_fm801_free(struct fm801 *chip) 1189 { 1170 static void snd_fm801_free(struct snd_card *card) 1171 { 1172 struct fm801 *chip = card->private_data; 1190 1173 unsigned short cmdw; 1191 1192 if (chip->irq < 0)1193 goto __end_hw;1194 1174 1195 1175 /* interrupt setup - mask everything */ … … 1198 1178 fm801_writew(chip, IRQ_MASK, cmdw); 1199 1179 1200 devm_free_irq(chip->dev, chip->irq, chip);1201 1202 __end_hw:1203 1180 #ifdef CONFIG_SND_FM801_TEA575X_BOOL 1204 1181 if (!(chip->tea575x_tuner & TUNER_DISABLED)) { … … 1207 1184 } 1208 1185 #endif 1209 return 0; 1210 } 1211 1212 static int snd_fm801_dev_free(struct snd_device *device) 1213 { 1214 struct fm801 *chip = device->device_data; 1215 return snd_fm801_free(chip); 1216 } 1186 } 1187 1217 1188 1218 1189 static int snd_fm801_create(struct snd_card *card, 1219 1190 struct pci_dev *pci, 1220 1191 int tea575x_tuner, 1221 int radio_nr, 1222 struct fm801 **rchip) 1223 { 1224 struct fm801 *chip; 1192 int radio_nr) 1193 { 1194 struct fm801 *chip = card->private_data; 1225 1195 int err; 1226 static const struct snd_device_ops ops = { 1227 .dev_free = snd_fm801_dev_free, 1228 }; 1229 1230 *rchip = NULL; 1196 1231 1197 #ifndef TARGET_OS2 1232 1198 err = pcim_enable_device(pci); 1233 1199 if (err < 0) 1234 1200 return err; 1235 chip = devm_kzalloc(&pci->dev, sizeof(*chip), GFP_KERNEL);1236 1201 #else 1237 1202 if ((err = pci_enable_device(pci)) < 0) 1238 1203 return err; 1239 chip = kzalloc(sizeof(*chip), GFP_KERNEL);1240 1204 #endif 1241 if (chip == NULL)1242 return -ENOMEM;1243 1205 spin_lock_init(&chip->reg_lock); 1244 1206 chip->card = card; … … 1277 1239 #endif 1278 1240 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 1279 snd_fm801_free(chip);1280 1241 return -EBUSY; 1281 1242 } … … 1285 1246 } 1286 1247 1248 card->private_free = snd_fm801_free; 1287 1249 snd_fm801_chip_init(chip); 1288 1289 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);1290 if (err < 0) {1291 snd_fm801_free(chip);1292 return err;1293 }1294 1250 1295 1251 #ifdef CONFIG_SND_FM801_TEA575X_BOOL 1296 1252 err = v4l2_device_register(&pci->dev, &chip->v4l2_dev); 1297 if (err < 0) { 1298 snd_fm801_free(chip); 1299 return err; 1300 } 1253 if (err < 0) 1254 return err; 1301 1255 chip->tea.v4l2_dev = &chip->v4l2_dev; 1302 1256 chip->tea.radio_nr = radio_nr; … … 1308 1262 if (snd_tea575x_init(&chip->tea, THIS_MODULE)) { 1309 1263 dev_err(card->dev, "TEA575x radio not found\n"); 1310 snd_fm801_free(chip);1311 1264 return -ENODEV; 1312 1265 } … … 1336 1289 } 1337 1290 #endif 1338 1339 *rchip = chip; 1340 return 0; 1341 } 1342 1343 static int snd_card_fm801_probe(struct pci_dev *pci, 1344 const struct pci_device_id *pci_id) 1291 return 0; 1292 } 1293 1294 static int __snd_card_fm801_probe(struct pci_dev *pci, 1295 const struct pci_device_id *pci_id) 1345 1296 { 1346 1297 static int dev; … … 1357 1308 } 1358 1309 1359 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1360 0, &card); 1361 if (err < 0) 1362 return err; 1363 err = snd_fm801_create(card, pci, tea575x_tuner[dev], radio_nr[dev], &chip); 1364 if (err < 0) { 1365 snd_card_free(card); 1366 return err; 1367 } 1368 card->private_data = chip; 1310 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1311 sizeof(*chip), &card); 1312 if (err < 0) 1313 return err; 1314 chip = card->private_data; 1315 err = snd_fm801_create(card, pci, tea575x_tuner[dev], radio_nr[dev]); 1316 if (err < 0) 1317 return err; 1369 1318 1370 1319 strcpy(card->driver, "FM801"); … … 1378 1327 1379 1328 err = snd_fm801_pcm(chip, 0); 1380 if (err < 0) { 1381 snd_card_free(card); 1382 return err; 1383 } 1329 if (err < 0) 1330 return err; 1384 1331 err = snd_fm801_mixer(chip); 1385 if (err < 0) { 1386 snd_card_free(card); 1387 return err; 1388 } 1332 if (err < 0) 1333 return err; 1389 1334 err = snd_mpu401_uart_new(card, 0, MPU401_HW_FM801, 1390 1335 chip->port + FM801_MPU401_DATA, … … 1392 1337 MPU401_INFO_IRQ_HOOK, 1393 1338 -1, &chip->rmidi); 1394 if (err < 0) { 1395 snd_card_free(card); 1396 return err; 1397 } 1339 if (err < 0) 1340 return err; 1398 1341 err = snd_opl3_create(card, chip->port + FM801_OPL3_BANK0, 1399 1342 chip->port + FM801_OPL3_BANK1, 1400 1343 OPL3_HW_OPL3_FM801, 1, &opl3); 1401 if (err < 0) { 1402 snd_card_free(card); 1403 return err; 1404 } 1344 if (err < 0) 1345 return err; 1405 1346 err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); 1406 if (err < 0) { 1407 snd_card_free(card); 1408 return err; 1409 } 1347 if (err < 0) 1348 return err; 1410 1349 1411 1350 __fm801_tuner_only: 1412 1351 err = snd_card_register(card); 1413 if (err < 0) { 1414 snd_card_free(card); 1415 return err; 1416 } 1352 if (err < 0) 1353 return err; 1417 1354 pci_set_drvdata(pci, card); 1418 1355 dev++; … … 1420 1357 } 1421 1358 1422 static void snd_card_fm801_remove(struct pci_dev *pci) 1423 { 1424 snd_card_free(pci_get_drvdata(pci)); 1359 static int snd_card_fm801_probe(struct pci_dev *pci, 1360 const struct pci_device_id *pci_id) 1361 { 1362 return snd_card_free_on_error(&pci->dev, __snd_card_fm801_probe(pci, pci_id)); 1425 1363 } 1426 1364 … … 1492 1430 .id_table = snd_fm801_ids, 1493 1431 .probe = snd_card_fm801_probe, 1494 .remove = snd_card_fm801_remove,1495 1432 .driver = { 1496 1433 .pm = SND_FM801_PM_OPS, -
GPL/trunk/alsa-kernel/pci/hda/hda_auto_parser.c
r695 r717 828 828 } 829 829 830 static voidapply_fixup(struct hda_codec *codec, int id, int action, int depth)830 void __snd_hda_apply_fixup(struct hda_codec *codec, int id, int action, int depth) 831 831 { 832 832 const char *modelname = codec->fixup_name; … … 838 838 break; 839 839 if (fix->chained_before) 840 apply_fixup(codec, fix->chain_id, action, depth + 1);840 __snd_hda_apply_fixup(codec, fix->chain_id, action, depth + 1); 841 841 842 842 switch (fix->type) { … … 879 879 } 880 880 } 881 EXPORT_SYMBOL_GPL(__snd_hda_apply_fixup); 881 882 882 883 /** … … 888 889 { 889 890 if (codec->fixup_list) 890 apply_fixup(codec, codec->fixup_id, action, 0);891 __snd_hda_apply_fixup(codec, codec->fixup_id, action, 0); 891 892 } 892 893 EXPORT_SYMBOL_GPL(snd_hda_apply_fixup); … … 976 977 * 977 978 * The function tries to find the matching model name at first, if given. 979 * If the model string contains the SSID alias, try to look up with the given 980 * alias ID. 978 981 * If nothing matched, try to look up the PCI SSID. 979 982 * If still nothing matched, try to look up the codec SSID. … … 987 990 int id = HDA_FIXUP_ID_NOT_SET; 988 991 const char *name = NULL; 992 const char *type = NULL; 993 unsigned int vendor, device; 989 994 990 995 if (codec->fixup_id != HDA_FIXUP_ID_NOT_SET) … … 993 998 /* when model=nofixup is given, don't pick up any fixups */ 994 999 if (codec->modelname && !strcmp(codec->modelname, "nofixup")) { 995 codec->fixup_list = NULL; 996 codec->fixup_name = NULL; 997 codec->fixup_id = HDA_FIXUP_ID_NO_FIXUP; 1000 id = HDA_FIXUP_ID_NO_FIXUP; 1001 fixlist = NULL; 998 1002 codec_dbg(codec, "%s: picked no fixup (nofixup specified)\n", 999 1003 codec->core.chip_name); 1000 return; 1001 } 1002 1004 goto found; 1005 } 1006 1007 /* match with the model name string */ 1003 1008 if (codec->modelname && models) { 1004 1009 while (models->name) { 1005 1010 if (!strcmp(codec->modelname, models->name)) { 1006 codec->fixup_id = models->id; 1007 codec->fixup_name = models->name; 1008 codec->fixup_list = fixlist; 1011 id = models->id; 1012 name = models->name; 1009 1013 codec_dbg(codec, "%s: picked fixup %s (model specified)\n", 1010 1014 codec->core.chip_name, codec->fixup_name); 1011 return;1015 goto found; 1012 1016 } 1013 1017 models++; 1014 1018 } 1015 1019 } 1016 if (quirk) { 1017 q = snd_pci_quirk_lookup(codec->bus->pci, quirk); 1020 1021 if (!quirk) 1022 return; 1023 1024 /* match with the SSID alias given by the model string "XXXX:YYYY" */ 1025 if (codec->modelname && 1026 sscanf(codec->modelname, "%04x:%04x", &vendor, &device) == 2) { 1027 q = snd_pci_quirk_lookup_id(vendor, device, quirk); 1018 1028 if (q) { 1019 id = q->value; 1029 type = "alias SSID"; 1030 goto found_device; 1031 } 1032 } 1033 1034 /* match with the PCI SSID */ 1035 q = snd_pci_quirk_lookup(codec->bus->pci, quirk); 1036 if (q) { 1037 type = "PCI SSID"; 1038 goto found_device; 1039 } 1040 1041 /* match with the codec SSID */ 1042 q = snd_pci_quirk_lookup_id(codec->core.subsystem_id >> 16, 1043 codec->core.subsystem_id & 0xffff, 1044 quirk); 1045 if (q) { 1046 type = "codec SSID"; 1047 goto found_device; 1048 } 1049 1050 return; /* no matching */ 1051 1052 found_device: 1053 id = q->value; 1020 1054 #ifdef CONFIG_SND_DEBUG_VERBOSE 1021 name = q->name; 1022 codec_dbg(codec, "%s: picked fixup %s (PCI SSID%s)\n", 1023 codec->core.chip_name, name, q->subdevice_mask ? "" : " - vendor generic"); 1055 name = q->name; 1024 1056 #endif 1025 } 1026 } 1027 if (id < 0 && quirk) { 1028 for (q = quirk; q->subvendor || q->subdevice; q++) { 1029 unsigned int vendorid = 1030 q->subdevice | (q->subvendor << 16); 1031 unsigned int mask = 0xffff0000 | q->subdevice_mask; 1032 if ((codec->core.subsystem_id & mask) == (vendorid & mask)) { 1033 id = q->value; 1034 #ifdef CONFIG_SND_DEBUG_VERBOSE 1035 name = q->name; 1036 codec_dbg(codec, "%s: picked fixup %s (codec SSID)\n", 1037 codec->core.chip_name, name); 1038 #endif 1039 break; 1040 } 1041 } 1042 } 1043 1057 codec_dbg(codec, "%s: picked fixup %s for %s %04x:%04x\n", 1058 codec->core.chip_name, name ? name : "", 1059 type, q->subvendor, q->subdevice); 1060 found: 1044 1061 codec->fixup_id = id; 1045 if (id >= 0) { 1046 codec->fixup_list = fixlist; 1047 codec->fixup_name = name; 1048 } 1062 codec->fixup_list = fixlist; 1063 codec->fixup_name = name; 1049 1064 } 1050 1065 EXPORT_SYMBOL_GPL(snd_hda_pick_fixup); -
GPL/trunk/alsa-kernel/pci/hda/hda_bind.c
r703 r717 159 159 } 160 160 161 refcount_dec(&codec->pcm_ref); 162 snd_hda_codec_disconnect_pcms(codec); 163 wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref)); 164 snd_power_sync_ref(codec->bus->card); 165 161 166 if (codec->patch_ops.free) 162 167 codec->patch_ops.free(codec); … … 168 173 static void hda_codec_driver_shutdown(struct device *dev) 169 174 { 170 struct hda_codec *codec = dev_to_hda_codec(dev); 171 172 if (!pm_runtime_suspended(dev)) { 173 if (codec->patch_ops.reboot_notify) 174 codec->patch_ops.reboot_notify(codec); 175 snd_hda_codec_display_power(codec, false); 176 } 175 snd_hda_codec_shutdown(dev_to_hda_codec(dev)); 177 176 } 178 177 … … 309 308 int err; 310 309 310 if (codec->configured) 311 return 0; 312 311 313 if (is_generic_config(codec)) 312 314 codec->probe_id = HDA_CODEC_ID_GENERIC; … … 314 316 codec->probe_id = 0; 315 317 316 err = snd_hdac_device_register(&codec->core); 317 if (err < 0) 318 return err; 318 if (!device_is_registered(&codec->core.dev)) { 319 err = snd_hdac_device_register(&codec->core); 320 if (err < 0) 321 return err; 322 } 319 323 320 324 if (!codec->preset) … … 323 327 err = codec_bind_generic(codec); 324 328 if (err < 0) { 325 codec_ err(codec, "Unable to bind the codec\n");326 goto error;329 codec_dbg(codec, "Unable to bind the codec\n"); 330 return err; 327 331 } 328 332 } 329 333 330 return 0; 331 332 error: 333 snd_hdac_device_unregister(&codec->core); 334 return err; 334 codec->configured = 1; 335 return 0; 335 336 } 336 337 EXPORT_SYMBOL_GPL(snd_hda_codec_configure); -
GPL/trunk/alsa-kernel/pci/hda/hda_codec.c
r703 r717 712 712 * PCM device 713 713 */ 714 static void release_pcm(struct kref *kref)715 {716 struct hda_pcm *pcm = container_of(kref, struct hda_pcm, kref);717 #ifndef TARGET_OS2718 /* don't do this on OS/2 - results in the device being free'd and can't be re-opened */719 if (pcm->pcm)720 snd_device_free(pcm->codec->card, pcm->pcm);721 #endif722 clear_bit(pcm->device, pcm->codec->bus->pcm_dev_bits);723 kfree(pcm->name);724 kfree(pcm);725 }726 714 727 715 void snd_hda_codec_pcm_put(struct hda_pcm *pcm) 728 716 { 729 kref_put(&pcm->kref, release_pcm); 717 if (refcount_dec_and_test(&pcm->codec->pcm_ref)) 718 wake_up(&pcm->codec->remove_sleep); 730 719 } 731 720 EXPORT_SYMBOL_GPL(snd_hda_codec_pcm_put); … … 742 731 743 732 pcm->codec = codec; 744 kref_init(&pcm->kref);745 733 va_start(args, fmt); 746 734 pcm->name = kvasprintf(GFP_KERNEL, fmt, args); … … 752 740 753 741 list_add_tail(&pcm->list, &codec->pcm_list_head); 742 refcount_inc(&codec->pcm_ref); 754 743 return pcm; 755 744 } … … 759 748 * codec destructor 760 749 */ 761 static void codec_release_pcms(struct hda_codec *codec) 762 { 763 struct hda_pcm *pcm, *n; 764 765 list_for_each_entry_safe(pcm, n, &codec->pcm_list_head, list, struct hda_pcm) { 766 list_del_init(&pcm->list); 750 void snd_hda_codec_disconnect_pcms(struct hda_codec *codec) 751 { 752 struct hda_pcm *pcm; 753 754 list_for_each_entry(pcm, &codec->pcm_list_head, list, struct hda_pcm) { 755 if (pcm->disconnected) 756 continue; 767 757 if (pcm->pcm) 768 758 snd_device_disconnect(codec->card, pcm->pcm); 769 759 snd_hda_codec_pcm_put(pcm); 760 pcm->disconnected = 1; 761 } 762 } 763 764 static void codec_release_pcms(struct hda_codec *codec) 765 { 766 struct hda_pcm *pcm, *n; 767 768 list_for_each_entry_safe(pcm, n, &codec->pcm_list_head, list, struct hda_pcm) { 769 list_del(&pcm->list); 770 #ifndef TARGET_OS2 771 /* don't do this on OS/2 - results in the device being free'd and can't be re-opened */ 772 if (pcm->pcm) 773 snd_device_free(pcm->codec->card, pcm->pcm); 774 #endif 775 clear_bit(pcm->device, pcm->codec->bus->pcm_dev_bits); 776 kfree(pcm->name); 777 kfree(pcm); 770 778 } 771 779 } … … 780 788 } 781 789 790 snd_hda_codec_disconnect_pcms(codec); 782 791 cancel_delayed_work_sync(&codec->jackpoll_work); 783 792 if (!codec->in_freeing) … … 802 811 remove_conn_list(codec); 803 812 snd_hdac_regmap_exit(&codec->core); 813 codec->configured = 0; 814 refcount_set(&codec->pcm_ref, 1); /* reset refcount */ 804 815 } 805 816 EXPORT_SYMBOL_GPL(snd_hda_codec_cleanup_for_unbind); … … 968 979 INIT_LIST_HEAD(&codec->conn_list); 969 980 INIT_LIST_HEAD(&codec->pcm_list_head); 981 refcount_set(&codec->pcm_ref, 1); 982 init_waitqueue_head(&codec->remove_sleep); 970 983 971 984 INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work); … … 1737 1750 int i; 1738 1751 struct hda_nid_item *items = codec->mixers.list; 1752 1753 down_write(&codec->card->controls_rwsem); 1739 1754 for (i = 0; i < codec->mixers.used; i++) 1740 1755 snd_ctl_remove(codec->card, items[i].kctl); 1756 up_write(&codec->card->controls_rwsem); 1741 1757 snd_array_free(&codec->mixers); 1742 1758 snd_array_free(&codec->nids); … … 2998 3014 NULL) 2999 3015 }; 3016 3017 /* suspend the codec at shutdown; called from driver's shutdown callback */ 3018 void snd_hda_codec_shutdown(struct hda_codec *codec) 3019 { 3020 struct hda_pcm *cpcm; 3021 3022 /* Skip the shutdown if codec is not registered */ 3023 if (!codec->registered) 3024 return; 3025 3026 list_for_each_entry(cpcm, &codec->pcm_list_head, list, struct hda_pcm) 3027 snd_pcm_suspend_all(cpcm->pcm); 3028 3029 pm_runtime_force_suspend(hda_codec_dev(codec)); 3030 pm_runtime_disable(hda_codec_dev(codec)); 3031 } 3000 3032 3001 3033 /* -
GPL/trunk/alsa-kernel/pci/hda/hda_controller.c
r695 r717 26 26 #include <sound/initval.h> 27 27 #include "hda_controller.h" 28 #include "hda_local.h" 28 29 29 30 #ifndef TARGET_OS2 … … 523 524 524 525 nsec = timecounter_read(&azx_dev->core.tc); 525 nsec = div_u64(nsec, 3); /* can be optimized */526 526 if (audio_tstamp_config->report_delay) 527 527 nsec = azx_adjust_codec_delay(substream, nsec); … … 690 690 } 691 691 692 #ifndef TARGET_OS2693 static int azx_pcm_mmap(struct snd_pcm_substream *substream,694 struct vm_area_struct *area)695 {696 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);697 struct azx *chip = apcm->chip;698 if (chip->ops->pcm_mmap_prepare)699 chip->ops->pcm_mmap_prepare(substream, area);700 return snd_pcm_lib_default_mmap(substream, area);701 }702 #else703 #define azx_pcm_mmap NULL704 #endif705 706 692 static const struct snd_pcm_ops azx_pcm_ops = { 707 693 .open = azx_pcm_open, … … 713 699 .pointer = azx_pcm_pointer, 714 700 .get_time_info = azx_get_time_info, 715 .mmap = azx_pcm_mmap,716 701 }; 717 702 … … 778 763 size = MAX_PREALLOC_SIZE; 779 764 if (chip->uc_buffer) 780 type = SNDRV_DMA_TYPE_DEV_ UC_SG;765 type = SNDRV_DMA_TYPE_DEV_WC_SG; 781 766 snd_pcm_set_managed_buffer_all(pcm, type, chip->card->dev, 782 767 size, MAX_PREALLOC_SIZE); … … 1293 1278 { 1294 1279 struct hda_codec *codec, *next; 1295 1296 /* use _safe version here since snd_hda_codec_configure() deregisters 1297 * the device upon error and deletes itself from the bus list. 1298 */ 1299 list_for_each_codec_safe(codec, next, &chip->bus) { 1300 snd_hda_codec_configure(codec); 1301 } 1302 1303 if (!azx_bus(chip)->num_codecs) 1304 return -ENODEV; 1305 return 0; 1280 int success = 0; 1281 1282 list_for_each_codec(codec, &chip->bus) { 1283 if (!snd_hda_codec_configure(codec)) 1284 success++; 1285 } 1286 1287 if (success) { 1288 /* unregister failed codecs if any codec has been probed */ 1289 list_for_each_codec_safe(codec, next, &chip->bus) { 1290 if (!codec->configured) { 1291 codec_err(codec, "Unable to configure, disabling\n"); 1292 snd_hdac_device_unregister(&codec->core); 1293 } 1294 } 1295 } 1296 1297 return success ? 0 : -ENODEV; 1306 1298 } 1307 1299 EXPORT_SYMBOL_GPL(azx_codec_configure); -
GPL/trunk/alsa-kernel/pci/hda/hda_controller.h
r679 r717 42 42 #define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */ 43 43 #define AZX_DCAPS_PM_RUNTIME (1 << 26) /* runtime PM support */ 44 /* 27 unused */44 #define AZX_DCAPS_RETRY_PROBE (1 << 27) /* retry probe if no codec is configured */ 45 45 #define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28) /* CORBRP clears itself after reset */ 46 46 #define AZX_DCAPS_NO_MSI64 (1 << 29) /* Stick to 32-bit MSIs */ … … 75 75 /* Disable msi if supported, PCI only */ 76 76 int (*disable_msi_reset_irq)(struct azx *); 77 void (*pcm_mmap_prepare)(struct snd_pcm_substream *substream,78 struct vm_area_struct *area);79 77 /* Check if current position is acceptable */ 80 78 int (*position_check)(struct azx *chip, struct azx_dev *azx_dev); … … 142 140 unsigned int uc_buffer:1; /* non-cached pages for stream buffers */ 143 141 unsigned int align_buffer_size:1; 144 unsigned int region_requested:1;145 142 unsigned int disabled:1; /* disabled by vga_switcheroo */ 146 143 unsigned int pm_prepared:1; -
GPL/trunk/alsa-kernel/pci/hda/hda_generic.c
r703 r717 95 95 snd_array_free(&spec->paths); 96 96 snd_array_free(&spec->loopback_list); 97 #ifdef CONFIG_SND_HDA_GENERIC_LEDS 98 if (spec->led_cdevs[LED_AUDIO_MUTE]) 99 led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MUTE]); 100 if (spec->led_cdevs[LED_AUDIO_MICMUTE]) 101 led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MICMUTE]); 102 #endif 97 103 } 98 104 … … 3934 3940 bool micmute) 3935 3941 { 3942 struct hda_gen_spec *spec = codec->spec; 3936 3943 struct led_classdev *cdev; 3944 int idx = micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE; 3945 int err; 3937 3946 3938 3947 cdev = devm_kzalloc(&codec->core.dev, sizeof(*cdev), GFP_KERNEL); … … 3944 3953 cdev->default_trigger = micmute ? "audio-micmute" : "audio-mute"; 3945 3954 cdev->brightness_set_blocking = callback; 3946 cdev->brightness = ledtrig_audio_get( micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE);3955 cdev->brightness = ledtrig_audio_get(idx); 3947 3956 cdev->flags = LED_CORE_SUSPENDRESUME; 3948 3957 3949 return devm_led_classdev_register(&codec->core.dev, cdev); 3958 err = led_classdev_register(&codec->core.dev, cdev); 3959 if (err < 0) 3960 return err; 3961 spec->led_cdevs[idx] = cdev; 3962 return 0; 3950 3963 } 3951 3964 … … 6016 6029 EXPORT_SYMBOL_GPL(snd_hda_gen_free); 6017 6030 6018 /**6019 * snd_hda_gen_reboot_notify - Make codec enter D3 before rebooting6020 * @codec: the HDA codec6021 *6022 * This can be put as patch_ops reboot_notify function.6023 */6024 void snd_hda_gen_reboot_notify(struct hda_codec *codec)6025 {6026 /* Make the codec enter D3 to avoid spurious noises from the internal6027 * speaker during (and after) reboot6028 */6029 snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);6030 snd_hda_codec_write(codec, codec->core.afg, 0,6031 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);6032 msleep(10);6033 }6034 EXPORT_SYMBOL_GPL(snd_hda_gen_reboot_notify);6035 6036 6031 #ifdef CONFIG_PM 6037 6032 /** … … 6061 6056 .free = snd_hda_gen_free, 6062 6057 .unsol_event = snd_hda_jack_unsol_event, 6063 .reboot_notify = snd_hda_gen_reboot_notify,6064 6058 #ifdef CONFIG_PM 6065 6059 .check_power_status = snd_hda_gen_check_power_status, -
GPL/trunk/alsa-kernel/pci/hda/hda_generic.h
r695 r717 295 295 void (*mic_autoswitch_hook)(struct hda_codec *codec, 296 296 struct hda_jack_callback *cb); 297 298 /* leds */ 299 struct led_classdev *led_cdevs[NUM_AUDIO_LEDS]; 297 300 }; 298 301 … … 325 328 int snd_hda_gen_build_controls(struct hda_codec *codec); 326 329 int snd_hda_gen_build_pcms(struct hda_codec *codec); 327 void snd_hda_gen_reboot_notify(struct hda_codec *codec);328 330 329 331 /* standard jack event callbacks */ -
GPL/trunk/alsa-kernel/pci/hda/hda_intel.c
r703 r717 326 326 #define AZX_DCAPS_PRESET_AMD_SB \ 327 327 (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_AMD_WORKAROUND |\ 328 AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME) 328 AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME |\ 329 AZX_DCAPS_RETRY_PROBE) 329 330 330 331 /* quirks for Nvidia */ … … 353 354 ((pci)->device == 0x0d0c) || \ 354 355 ((pci)->device == 0x160c) || \ 355 ((pci)->device == 0x490d)) 356 ((pci)->device == 0x490d) || \ 357 ((pci)->device == 0x4f90) || \ 358 ((pci)->device == 0x4f91) || \ 359 ((pci)->device == 0x4f92)) 356 360 357 361 #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98) … … 656 660 * data is processed. So, we need to process it afterwords in a 657 661 * workqueue. 662 * 663 * Returns 1 if OK to proceed, 0 for delay handling, -1 for skipping update 658 664 */ 659 665 static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) 660 666 { 661 667 struct snd_pcm_substream *substream = azx_dev->core.substream; 668 struct snd_pcm_runtime *runtime = substream->runtime; 662 669 int stream = substream->stream; 663 670 u32 wallclk; 664 671 unsigned int pos; 672 snd_pcm_uframes_t hwptr, target; 665 673 666 674 wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk; … … 706 714 return chip->bdl_pos_adj ? 0 : -1; 707 715 azx_dev->core.start_wallclk += wallclk; 716 717 if (azx_dev->core.no_period_wakeup) 718 return 1; /* OK, no need to check period boundary */ 719 720 if (runtime->hw_ptr_base != runtime->hw_ptr_interrupt) 721 return 1; /* OK, already in hwptr updating process */ 722 723 /* check whether the period gets really elapsed */ 724 pos = bytes_to_frames(runtime, pos); 725 hwptr = runtime->hw_ptr_base + pos; 726 if (hwptr < runtime->status->hw_ptr) 727 hwptr += runtime->buffer_size; 728 target = runtime->hw_ptr_interrupt + runtime->period_size; 729 if (hwptr < target) { 730 /* too early wakeup, process it later */ 731 return chip->bdl_pos_adj ? 0 : -1; 732 } 733 708 734 return 1; /* OK, it's fine */ 709 735 } … … 882 908 /* just read back the calculated value in the above */ 883 909 return substream->runtime->delay; 884 }885 886 static unsigned int azx_skl_get_dpib_pos(struct azx *chip,887 struct azx_dev *azx_dev)888 {889 return _snd_hdac_chip_readl(azx_bus(chip),890 AZX_REG_VS_SDXDPIB_XBASE +891 (AZX_REG_VS_SDXDPIB_XINTERVAL *892 azx_dev->core.index));893 }894 895 /* get the current DMA position with correction on SKL+ chips */896 static unsigned int azx_get_pos_skl(struct azx *chip, struct azx_dev *azx_dev)897 {898 /* DPIB register gives a more accurate position for playback */899 if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK)900 return azx_skl_get_dpib_pos(chip, azx_dev);901 902 /* For capture, we need to read posbuf, but it requires a delay903 * for the possible boundary overlap; the read of DPIB fetches the904 * actual posbuf905 */906 udelay(20);907 azx_skl_get_dpib_pos(chip, azx_dev);908 return azx_get_pos_posbuf(chip, azx_dev);909 910 } 910 911 … … 1407 1408 if (bus->irq >= 0) 1408 1409 free_irq(bus->irq, (void*)chip); 1409 if (chip->msi)1410 pci_disable_msi(chip->pci);1411 #ifdef TARGET_OS21412 iounmap((void *)bus->remap_addr);1413 #else1414 iounmap(bus->remap_addr);1415 #endif1416 1410 1417 1411 azx_free_stream_pages(chip); … … 1419 1413 snd_hdac_bus_exit(bus); 1420 1414 1421 if (chip->region_requested)1422 pci_release_regions(chip->pci);1423 1424 pci_disable_device(chip->pci);1425 1415 #ifdef CONFIG_SND_HDA_PATCH_LOADER 1426 1416 release_firmware(chip->fw); … … 1617 1607 [POS_FIX_VIACOMBO] = azx_via_get_position, 1618 1608 [POS_FIX_COMBO] = azx_get_pos_lpib, 1619 [POS_FIX_SKL] = azx_get_pos_ skl,1609 [POS_FIX_SKL] = azx_get_pos_posbuf, 1620 1610 [POS_FIX_FIFO] = azx_get_pos_fifo, 1621 1611 }; … … 1655 1645 SND_PCI_QUIRK(0x1043, 0x1262, "ASUS W5Fm", 0x103), 1656 1646 SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103), 1647 SND_PCI_QUIRK(0x1558, 0x0351, "Schenker Dock 15", 0x105), 1657 1648 /* WinFast VP200 H (Teradici) user reported broken communication */ 1658 1649 SND_PCI_QUIRK(0x3a21, 0x040d, "WinFast VP200 H", 0x101), … … 1768 1759 static void azx_probe_work(struct work_struct *work) 1769 1760 { 1770 struct hda_intel *hda = container_of(work, struct hda_intel, probe_work );1761 struct hda_intel *hda = container_of(work, struct hda_intel, probe_work.work); 1771 1762 azx_probe_continue(&hda->chip); 1772 1763 } … … 1820 1811 hda = kzalloc(sizeof(*hda), GFP_KERNEL); 1821 1812 #endif 1822 if (!hda) { 1823 pci_disable_device(pci); 1824 return -ENOMEM; 1825 } 1813 if (!hda) 1814 return -ENOMEM; 1826 1815 1827 1816 chip = &hda->chip; … … 1844 1833 assign_position_fix(chip, check_position_fix(chip, position_fix[dev])); 1845 1834 1846 check_probe_mask(chip, dev);1847 1848 1835 if (single_cmd < 0) /* allow fallback to single_cmd at errors */ 1849 1836 chip->fallback_to_single_cmd = 1; … … 1859 1846 1860 1847 err = azx_bus_init(chip, model[dev]); 1861 if (err < 0) { 1862 pci_disable_device(pci); 1848 if (err < 0) 1863 1849 return err; 1864 }1865 1850 1866 1851 /* use the non-cached pages in non-snoop mode */ 1867 1852 if (!azx_snoop(chip)) 1868 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_ UC;1853 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC; 1869 1854 1870 1855 if (chip->driver_type == AZX_DRIVER_NVIDIA) { … … 1872 1857 chip->bus.core.needs_damn_long_delay = 1; 1873 1858 } 1859 1860 check_probe_mask(chip, dev); 1874 1861 1875 1862 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); … … 1881 1868 1882 1869 /* continue probing in work context as may trigger request module */ 1883 INIT_ WORK(&hda->probe_work, azx_probe_work);1870 INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work); 1884 1871 1885 1872 *rchip = chip; … … 1908 1895 #endif 1909 1896 1897 #ifndef TARGET_OS2 1898 err = pcim_iomap_regions(pci, 1 << 0, "ICH HD audio"); 1899 #else 1910 1900 err = pci_request_regions(pci, "ICH HD audio"); 1901 #endif 1911 1902 if (err < 0) 1912 1903 return err; 1913 chip->region_requested = 1;1914 1904 1915 1905 bus->addr = pci_resource_start(pci, 0); 1906 #ifndef TARGET_OS2 1907 bus->remap_addr = pcim_iomap_table(pci)[0]; 1908 #else 1916 1909 bus->remap_addr = pci_ioremap_bar(pci, 0); 1917 if (bus->remap_addr == NULL) { 1918 dev_err(card->dev, "ioremap error\n"); 1919 return -ENXIO; 1920 } 1921 1910 #endif 1922 1911 if (chip->driver_type == AZX_DRIVER_SKL) 1923 1912 snd_hdac_bus_parse_capabilities(bus); … … 2101 2090 } 2102 2091 2103 static void pcm_mmap_prepare(struct snd_pcm_substream *substream,2104 struct vm_area_struct *area)2105 {2106 #ifdef CONFIG_X862107 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);2108 struct azx *chip = apcm->chip;2109 if (chip->uc_buffer)2110 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);2111 #endif2112 }2113 2114 2092 /* Denylist for skipping the whole probe: 2115 2093 * some HD-audio PCI entries are exposed without any codecs, and such devices … … 2125 2103 static const struct hda_controller_ops pci_hda_ops = { 2126 2104 .disable_msi_reset_irq = disable_msi_reset_irq, 2127 .pcm_mmap_prepare = pcm_mmap_prepare,2128 2105 .position_check = azx_position_check, 2129 2106 }; … … 2219 2196 #else 2220 2197 if (schedule_probe) 2221 schedule_ work(&hda->probe_work);2198 schedule_delayed_work(&hda->probe_work, 0); 2222 2199 #endif 2223 2200 … … 2306 2283 int err; 2307 2284 2285 if (chip->disabled || hda->init_failed) 2286 return -EIO; 2287 if (hda->probe_retry) 2288 goto probe_retry; 2289 2308 2290 to_hda_bus(bus)->bus_probing = 1; 2309 2291 hda->probe_continued = 1; … … 2367 2349 } 2368 2350 #endif 2351 2352 probe_retry: 2369 2353 if (bus->codec_mask && !(probe_only[dev] & 1)) { 2370 2354 err = azx_codec_configure(chip); 2371 if (err < 0) 2355 if (err) { 2356 if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) && 2357 ++hda->probe_retry < 60) { 2358 schedule_delayed_work(&hda->probe_work, 2359 msecs_to_jiffies(1000)); 2360 return 0; /* keep things up */ 2361 } 2362 dev_err(chip->card->dev, "Cannot probe codecs, giving up\n"); 2372 2363 goto out_free; 2364 } 2373 2365 } 2374 2366 … … 2392 2384 out_free: 2393 2385 if (err < 0) { 2394 azx_free(chip); 2386 pci_set_drvdata(pci, NULL); 2387 snd_card_free(chip->card); 2395 2388 return err; 2396 2389 } … … 2400 2393 complete_all(&hda->probe_wait); 2401 2394 to_hda_bus(bus)->bus_probing = 0; 2395 hda->probe_retry = 0; 2402 2396 return 0; 2403 2397 } … … 2425 2419 */ 2426 2420 device_unlock(&pci->dev); 2427 cancel_ work_sync(&hda->probe_work);2421 cancel_delayed_work_sync(&hda->probe_work); 2428 2422 device_lock(&pci->dev); 2429 2423 … … 2534 2528 /* DG1 */ 2535 2529 { PCI_DEVICE(0x8086, 0x490d), 2530 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, 2531 /* DG2 */ 2532 { PCI_DEVICE(0x8086, 0x4f90), 2533 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, 2534 { PCI_DEVICE(0x8086, 0x4f91), 2535 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, 2536 { PCI_DEVICE(0x8086, 0x4f92), 2536 2537 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, 2537 2538 /* Alderlake-S */ -
GPL/trunk/alsa-kernel/pci/hda/hda_intel.h
r679 r717 15 15 /* sync probing */ 16 16 struct completion probe_wait; 17 struct work_structprobe_work;17 struct delayed_work probe_work; 18 18 19 19 /* card list (for power_save trigger) */ … … 31 31 32 32 bool need_i915_power:1; /* the hda controller needs i915 power */ 33 34 int probe_retry; /* being probe-retry */ 33 35 }; 34 36 -
GPL/trunk/alsa-kernel/pci/hda/hda_local.h
r703 r717 138 138 void snd_hda_codec_register(struct hda_codec *codec); 139 139 void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec); 140 void snd_hda_codec_disconnect_pcms(struct hda_codec *codec); 140 141 141 142 #define snd_hda_regmap_sync(codec) snd_hdac_regmap_sync(&(codec)->core) … … 364 365 const struct hda_pintbl *cfg); 365 366 void snd_hda_apply_fixup(struct hda_codec *codec, int action); 367 void __snd_hda_apply_fixup(struct hda_codec *codec, int id, int action, int depth); 366 368 void snd_hda_pick_fixup(struct hda_codec *codec, 367 369 const struct hda_model_fixup *models, … … 453 455 for ((nid) = (codec)->core.start_nid; (nid) < (codec)->core.end_nid; (nid)++) 454 456 457 /* Set the codec power_state flag to indicate to allow unsol event handling; 458 * see hda_codec_unsol_event() in hda_bind.c. Calling this might confuse the 459 * state tracking, so use with care. 460 */ 461 static inline void snd_hda_codec_allow_unsol_events(struct hda_codec *codec) 462 { 463 codec->core.dev.power.power_state = PMSG_ON; 464 } 465 455 466 /* 456 467 * get widget capabilities … … 629 640 hda_nid_t nid, 630 641 unsigned int power_state); 642 643 void snd_hda_codec_shutdown(struct hda_codec *codec); 631 644 632 645 /* -
GPL/trunk/alsa-kernel/pci/hda/patch_analog.c
r679 r717 76 76 #endif 77 77 78 78 #ifdef CONFIG_PM 79 79 static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front, 80 80 hda_nid_t hp) … … 116 116 } 117 117 118 static void ad198x_shutup(struct hda_codec *codec)118 static int ad198x_suspend(struct hda_codec *codec) 119 119 { 120 120 snd_hda_shutup_pins(codec); 121 121 ad198x_power_eapd(codec); 122 }123 124 #ifdef CONFIG_PM125 static int ad198x_suspend(struct hda_codec *codec)126 {127 ad198x_shutup(codec);128 122 return 0; 129 123 } … … 172 166 .suspend = ad198x_suspend, 173 167 #endif 174 .reboot_notify = ad198x_shutup,175 168 }; 176 169 -
GPL/trunk/alsa-kernel/pci/hda/patch_ca0132.c
r703 r717 2276 2276 { 2277 2277 struct ca0132_spec *spec = codec->spec; 2278 int status = -1;2278 int status; 2279 2279 unsigned int scp_send_size = 0; 2280 2280 unsigned int total_size; … … 9782 9782 } 9783 9783 9784 static void ca0132_reboot_notify(struct hda_codec *codec)9785 {9786 codec->patch_ops.free(codec);9787 }9788 9789 9784 #ifdef CONFIG_PM 9790 9785 static int ca0132_suspend(struct hda_codec *codec) … … 9806 9801 .suspend = ca0132_suspend, 9807 9802 #endif 9808 .reboot_notify = ca0132_reboot_notify,9809 9803 }; 9810 9804 -
GPL/trunk/alsa-kernel/pci/hda/patch_cirrus.c
r695 r717 10 10 #include <linux/module.h> 11 11 #include <sound/core.h> 12 #include <linux/mutex.h>13 12 #include <linux/pci.h> 14 13 #include <sound/tlv.h> … … 26 25 */ 27 26 28 #define CS42L42_HP_CH (2U)29 #define CS42L42_HS_MIC_CH (1U)30 31 27 struct cs_spec { 32 28 struct hda_gen_spec gen; … … 47 43 int (*spdif_sw_put)(struct snd_kcontrol *kcontrol, 48 44 struct snd_ctl_elem_value *ucontrol); 49 50 unsigned int cs42l42_hp_jack_in:1;51 unsigned int cs42l42_mic_jack_in:1;52 unsigned int cs42l42_volume_init:1;53 char cs42l42_hp_volume[CS42L42_HP_CH];54 char cs42l42_hs_mic_volume[CS42L42_HS_MIC_CH];55 56 struct mutex cs8409_i2c_mux;57 58 /* verb exec op override */59 int (*exec_verb)(struct hdac_device *dev, unsigned int cmd,60 unsigned int flags, unsigned int *res);61 45 }; 62 46 … … 570 554 .chain_id = CS420X_GPIO_13, 571 555 }, 572 #if def TARGET_OS2xxx556 #ifndef TARGET_OS2 573 557 [CS420X_MBP81] = { 574 558 .type = HDA_FIXUP_VERBS, … … 1246 1230 } 1247 1231 1248 /* Cirrus Logic CS8409 HDA bridge with1249 * companion codec CS42L421250 */1251 #define CS8409_VENDOR_NID 0x471252 1253 #define CS8409_CS42L42_HP_PIN_NID 0x241254 #define CS8409_CS42L42_SPK_PIN_NID 0x2c1255 #define CS8409_CS42L42_AMIC_PIN_NID 0x341256 #define CS8409_CS42L42_DMIC_PIN_NID 0x441257 #define CS8409_CS42L42_DMIC_ADC_PIN_NID 0x221258 1259 #define CS42L42_HSDET_AUTO_DONE 0x021260 #define CS42L42_HSTYPE_MASK 0x031261 1262 #define CS42L42_JACK_INSERTED 0x0C1263 #define CS42L42_JACK_REMOVED 0x001264 1265 #define GPIO3_INT (1 << 3)1266 #define GPIO4_INT (1 << 4)1267 #define GPIO5_INT (1 << 5)1268 1269 #define CS42L42_I2C_ADDR (0x48 << 1)1270 1271 #define CIR_I2C_ADDR 0x00591272 #define CIR_I2C_DATA 0x005A1273 #define CIR_I2C_CTRL 0x005B1274 #define CIR_I2C_STATUS 0x005C1275 #define CIR_I2C_QWRITE 0x005D1276 #define CIR_I2C_QREAD 0x005E1277 1278 #define CS8409_CS42L42_HP_VOL_REAL_MIN (-63)1279 #define CS8409_CS42L42_HP_VOL_REAL_MAX (0)1280 #define CS8409_CS42L42_AMIC_VOL_REAL_MIN (-97)1281 #define CS8409_CS42L42_AMIC_VOL_REAL_MAX (12)1282 #define CS8409_CS42L42_REG_HS_VOLUME_CHA (0x2301)1283 #define CS8409_CS42L42_REG_HS_VOLUME_CHB (0x2303)1284 #define CS8409_CS42L42_REG_AMIC_VOLUME (0x1D03)1285 1286 struct cs8409_i2c_param {1287 unsigned int addr;1288 unsigned int reg;1289 };1290 1291 struct cs8409_cir_param {1292 unsigned int nid;1293 unsigned int cir;1294 unsigned int coeff;1295 };1296 1297 enum {1298 CS8409_BULLSEYE,1299 CS8409_WARLOCK,1300 CS8409_CYBORG,1301 CS8409_FIXUPS,1302 };1303 1304 static void cs8409_cs42l42_fixups(struct hda_codec *codec,1305 const struct hda_fixup *fix, int action);1306 static int cs8409_cs42l42_exec_verb(struct hdac_device *dev,1307 unsigned int cmd, unsigned int flags, unsigned int *res);1308 1309 /* Dell Inspiron models with cs8409/cs42l42 */1310 static const struct hda_model_fixup cs8409_models[] = {1311 { .id = CS8409_BULLSEYE, .name = "bullseye" },1312 { .id = CS8409_WARLOCK, .name = "warlock" },1313 { .id = CS8409_CYBORG, .name = "cyborg" },1314 {0}1315 };1316 1317 /* Dell Inspiron platforms1318 * with cs8409 bridge and cs42l42 codec1319 */1320 static const struct snd_pci_quirk cs8409_fixup_tbl[] = {1321 SND_PCI_QUIRK(0x1028, 0x0A11, "Bullseye", CS8409_BULLSEYE),1322 SND_PCI_QUIRK(0x1028, 0x0A12, "Bullseye", CS8409_BULLSEYE),1323 SND_PCI_QUIRK(0x1028, 0x0A23, "Bullseye", CS8409_BULLSEYE),1324 SND_PCI_QUIRK(0x1028, 0x0A24, "Bullseye", CS8409_BULLSEYE),1325 SND_PCI_QUIRK(0x1028, 0x0A25, "Bullseye", CS8409_BULLSEYE),1326 SND_PCI_QUIRK(0x1028, 0x0A29, "Bullseye", CS8409_BULLSEYE),1327 SND_PCI_QUIRK(0x1028, 0x0A2A, "Bullseye", CS8409_BULLSEYE),1328 SND_PCI_QUIRK(0x1028, 0x0A2B, "Bullseye", CS8409_BULLSEYE),1329 SND_PCI_QUIRK(0x1028, 0x0AB0, "Warlock", CS8409_WARLOCK),1330 SND_PCI_QUIRK(0x1028, 0x0AB2, "Warlock", CS8409_WARLOCK),1331 SND_PCI_QUIRK(0x1028, 0x0AB1, "Warlock", CS8409_WARLOCK),1332 SND_PCI_QUIRK(0x1028, 0x0AB3, "Warlock", CS8409_WARLOCK),1333 SND_PCI_QUIRK(0x1028, 0x0AB4, "Warlock", CS8409_WARLOCK),1334 SND_PCI_QUIRK(0x1028, 0x0AB5, "Warlock", CS8409_WARLOCK),1335 SND_PCI_QUIRK(0x1028, 0x0AD9, "Warlock", CS8409_WARLOCK),1336 SND_PCI_QUIRK(0x1028, 0x0ADA, "Warlock", CS8409_WARLOCK),1337 SND_PCI_QUIRK(0x1028, 0x0ADB, "Warlock", CS8409_WARLOCK),1338 SND_PCI_QUIRK(0x1028, 0x0ADC, "Warlock", CS8409_WARLOCK),1339 SND_PCI_QUIRK(0x1028, 0x0AF4, "Warlock", CS8409_WARLOCK),1340 SND_PCI_QUIRK(0x1028, 0x0AF5, "Warlock", CS8409_WARLOCK),1341 SND_PCI_QUIRK(0x1028, 0x0A77, "Cyborg", CS8409_CYBORG),1342 SND_PCI_QUIRK(0x1028, 0x0A78, "Cyborg", CS8409_CYBORG),1343 SND_PCI_QUIRK(0x1028, 0x0A79, "Cyborg", CS8409_CYBORG),1344 SND_PCI_QUIRK(0x1028, 0x0A7A, "Cyborg", CS8409_CYBORG),1345 SND_PCI_QUIRK(0x1028, 0x0A7D, "Cyborg", CS8409_CYBORG),1346 SND_PCI_QUIRK(0x1028, 0x0A7E, "Cyborg", CS8409_CYBORG),1347 SND_PCI_QUIRK(0x1028, 0x0A7F, "Cyborg", CS8409_CYBORG),1348 SND_PCI_QUIRK(0x1028, 0x0A80, "Cyborg", CS8409_CYBORG),1349 SND_PCI_QUIRK(0x1028, 0x0ADF, "Cyborg", CS8409_CYBORG),1350 SND_PCI_QUIRK(0x1028, 0x0AE0, "Cyborg", CS8409_CYBORG),1351 SND_PCI_QUIRK(0x1028, 0x0AE1, "Cyborg", CS8409_CYBORG),1352 SND_PCI_QUIRK(0x1028, 0x0AE2, "Cyborg", CS8409_CYBORG),1353 SND_PCI_QUIRK(0x1028, 0x0AE9, "Cyborg", CS8409_CYBORG),1354 SND_PCI_QUIRK(0x1028, 0x0AEA, "Cyborg", CS8409_CYBORG),1355 SND_PCI_QUIRK(0x1028, 0x0AEB, "Cyborg", CS8409_CYBORG),1356 SND_PCI_QUIRK(0x1028, 0x0AEC, "Cyborg", CS8409_CYBORG),1357 SND_PCI_QUIRK(0x1028, 0x0AED, "Cyborg", CS8409_CYBORG),1358 SND_PCI_QUIRK(0x1028, 0x0AEE, "Cyborg", CS8409_CYBORG),1359 SND_PCI_QUIRK(0x1028, 0x0AEF, "Cyborg", CS8409_CYBORG),1360 SND_PCI_QUIRK(0x1028, 0x0AF0, "Cyborg", CS8409_CYBORG),1361 {0} /* terminator */1362 };1363 1364 static const struct hda_verb cs8409_cs42l42_init_verbs[] = {1365 { 0x01, AC_VERB_SET_GPIO_WAKE_MASK, 0x0018 }, /* WAKE from GPIO 3,4 */1366 { 0x47, AC_VERB_SET_PROC_STATE, 0x0001 }, /* Enable VPW processing */1367 { 0x47, AC_VERB_SET_COEF_INDEX, 0x0002 }, /* Configure GPIO 6,7 */1368 { 0x47, AC_VERB_SET_PROC_COEF, 0x0080 }, /* I2C mode */1369 { 0x47, AC_VERB_SET_COEF_INDEX, 0x005b }, /* Set I2C bus speed */1370 { 0x47, AC_VERB_SET_PROC_COEF, 0x0200 }, /* 100kHz I2C_STO = 2 */1371 {0} /* terminator */1372 };1373 1374 static const struct hda_pintbl cs8409_cs42l42_pincfgs[] = {1375 { 0x24, 0x042120f0 }, /* ASP-1-TX */1376 { 0x34, 0x04a12050 }, /* ASP-1-RX */1377 { 0x2c, 0x901000f0 }, /* ASP-2-TX */1378 { 0x44, 0x90a00090 }, /* DMIC-1 */1379 {0} /* terminator */1380 };1381 1382 static const struct hda_fixup cs8409_fixups[] = {1383 [CS8409_BULLSEYE] = {1384 .type = HDA_FIXUP_PINS,1385 .v.pins = cs8409_cs42l42_pincfgs,1386 .chained = true,1387 .chain_id = CS8409_FIXUPS,1388 },1389 [CS8409_WARLOCK] = {1390 .type = HDA_FIXUP_PINS,1391 .v.pins = cs8409_cs42l42_pincfgs,1392 .chained = true,1393 .chain_id = CS8409_FIXUPS,1394 },1395 [CS8409_CYBORG] = {1396 .type = HDA_FIXUP_PINS,1397 .v.pins = cs8409_cs42l42_pincfgs,1398 .chained = true,1399 .chain_id = CS8409_FIXUPS,1400 },1401 [CS8409_FIXUPS] = {1402 .type = HDA_FIXUP_FUNC,1403 .v.func = cs8409_cs42l42_fixups,1404 },1405 };1406 1407 /* Vendor specific HW configuration for CS42L42 */1408 static const struct cs8409_i2c_param cs42l42_init_reg_seq[] = {1409 { 0x1010, 0xB0 },1410 { 0x1D01, 0x00 },1411 { 0x1D02, 0x06 },1412 { 0x1D03, 0x00 },1413 { 0x1107, 0x01 },1414 { 0x1009, 0x02 },1415 { 0x1007, 0x03 },1416 { 0x1201, 0x00 },1417 { 0x1208, 0x13 },1418 { 0x1205, 0xFF },1419 { 0x1206, 0x00 },1420 { 0x1207, 0x20 },1421 { 0x1202, 0x0D },1422 { 0x2A02, 0x02 },1423 { 0x2A03, 0x00 },1424 { 0x2A04, 0x00 },1425 { 0x2A05, 0x02 },1426 { 0x2A06, 0x00 },1427 { 0x2A07, 0x20 },1428 { 0x2A08, 0x02 },1429 { 0x2A09, 0x00 },1430 { 0x2A0A, 0x80 },1431 { 0x2A0B, 0x02 },1432 { 0x2A0C, 0x00 },1433 { 0x2A0D, 0xA0 },1434 { 0x2A01, 0x0C },1435 { 0x2902, 0x01 },1436 { 0x2903, 0x02 },1437 { 0x2904, 0x00 },1438 { 0x2905, 0x00 },1439 { 0x2901, 0x01 },1440 { 0x1101, 0x0A },1441 { 0x1102, 0x84 },1442 { 0x2301, 0x00 },1443 { 0x2303, 0x00 },1444 { 0x2302, 0x3f },1445 { 0x2001, 0x03 },1446 { 0x1B75, 0xB6 },1447 { 0x1B73, 0xC2 },1448 { 0x1129, 0x01 },1449 { 0x1121, 0xF3 },1450 { 0x1103, 0x20 },1451 { 0x1105, 0x00 },1452 { 0x1112, 0xC0 },1453 { 0x1113, 0x80 },1454 { 0x1C03, 0xC0 },1455 { 0x1105, 0x00 },1456 { 0x1112, 0xC0 },1457 { 0x1101, 0x02 },1458 {0} /* Terminator */1459 };1460 1461 /* Vendor specific hw configuration for CS8409 */1462 static const struct cs8409_cir_param cs8409_cs42l42_hw_cfg[] = {1463 { 0x47, 0x00, 0xb008 }, /* +PLL1/2_EN, +I2C_EN */1464 { 0x47, 0x01, 0x0002 }, /* ASP1/2_EN=0, ASP1_STP=1 */1465 { 0x47, 0x02, 0x0a80 }, /* ASP1/2_BUS_IDLE=10, +GPIO_I2C */1466 { 0x47, 0x19, 0x0800 }, /* ASP1.A: TX.LAP=0, TX.LSZ=24 bits, TX.LCS=0 */1467 { 0x47, 0x1a, 0x0820 }, /* ASP1.A: TX.RAP=0, TX.RSZ=24 bits, TX.RCS=32 */1468 { 0x47, 0x29, 0x0800 }, /* ASP2.A: TX.LAP=0, TX.LSZ=24 bits, TX.LCS=0 */1469 { 0x47, 0x2a, 0x2800 }, /* ASP2.A: TX.RAP=1, TX.RSZ=24 bits, TX.RCS=0 */1470 { 0x47, 0x39, 0x0800 }, /* ASP1.A: RX.LAP=0, RX.LSZ=24 bits, RX.LCS=0 */1471 { 0x47, 0x3a, 0x0800 }, /* ASP1.A: RX.RAP=0, RX.RSZ=24 bits, RX.RCS=0 */1472 { 0x47, 0x03, 0x8000 }, /* ASP1: LCHI = 00h */1473 { 0x47, 0x04, 0x28ff }, /* ASP1: MC/SC_SRCSEL=PLL1, LCPR=FFh */1474 { 0x47, 0x05, 0x0062 }, /* ASP1: MCEN=0, FSD=011, SCPOL_IN/OUT=0, SCDIV=1:4 */1475 { 0x47, 0x06, 0x801f }, /* ASP2: LCHI=1Fh */1476 { 0x47, 0x07, 0x283f }, /* ASP2: MC/SC_SRCSEL=PLL1, LCPR=3Fh */1477 { 0x47, 0x08, 0x805c }, /* ASP2: 5050=1, MCEN=0, FSD=010, SCPOL_IN/OUT=1, SCDIV=1:16 */1478 { 0x47, 0x09, 0x0023 }, /* DMIC1_MO=10b, DMIC1/2_SR=1 */1479 { 0x47, 0x0a, 0x0000 }, /* ASP1/2_BEEP=0 */1480 { 0x47, 0x01, 0x0062 }, /* ASP1/2_EN=1, ASP1_STP=1 */1481 { 0x47, 0x00, 0x9008 }, /* -PLL2_EN */1482 { 0x47, 0x68, 0x0000 }, /* TX2.A: pre-scale att.=0 dB */1483 { 0x47, 0x82, 0xfc03 }, /* ASP1/2_xxx_EN=1, ASP1/2_MCLK_EN=0, DMIC1_SCL_EN=1 */1484 { 0x47, 0xc0, 0x9999 }, /* test mode on */1485 { 0x47, 0xc5, 0x0000 }, /* GPIO hysteresis = 30 us */1486 { 0x47, 0xc0, 0x0000 }, /* test mode off */1487 {0} /* Terminator */1488 };1489 1490 static const struct cs8409_cir_param cs8409_cs42l42_bullseye_atn[] = {1491 { 0x47, 0x65, 0x4000 }, /* EQ_SEL=1, EQ1/2_EN=0 */1492 { 0x47, 0x64, 0x4000 }, /* +EQ_ACC */1493 { 0x47, 0x65, 0x4010 }, /* +EQ2_EN */1494 { 0x47, 0x63, 0x0647 }, /* EQ_DATA_HI=0x0647 */1495 { 0x47, 0x64, 0xc0c7 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=0, EQ_DATA_LO=0x67 */1496 { 0x47, 0x63, 0x0647 }, /* EQ_DATA_HI=0x0647 */1497 { 0x47, 0x64, 0xc1c7 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=1, EQ_DATA_LO=0x67 */1498 { 0x47, 0x63, 0xf370 }, /* EQ_DATA_HI=0xf370 */1499 { 0x47, 0x64, 0xc271 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=2, EQ_DATA_LO=0x71 */1500 { 0x47, 0x63, 0x1ef8 }, /* EQ_DATA_HI=0x1ef8 */1501 { 0x47, 0x64, 0xc348 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=3, EQ_DATA_LO=0x48 */1502 { 0x47, 0x63, 0xc110 }, /* EQ_DATA_HI=0xc110 */1503 { 0x47, 0x64, 0xc45a }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=4, EQ_DATA_LO=0x5a */1504 { 0x47, 0x63, 0x1f29 }, /* EQ_DATA_HI=0x1f29 */1505 { 0x47, 0x64, 0xc574 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=5, EQ_DATA_LO=0x74 */1506 { 0x47, 0x63, 0x1d7a }, /* EQ_DATA_HI=0x1d7a */1507 { 0x47, 0x64, 0xc653 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=6, EQ_DATA_LO=0x53 */1508 { 0x47, 0x63, 0xc38c }, /* EQ_DATA_HI=0xc38c */1509 { 0x47, 0x64, 0xc714 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=7, EQ_DATA_LO=0x14 */1510 { 0x47, 0x63, 0x1ca3 }, /* EQ_DATA_HI=0x1ca3 */1511 { 0x47, 0x64, 0xc8c7 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=8, EQ_DATA_LO=0xc7 */1512 { 0x47, 0x63, 0xc38c }, /* EQ_DATA_HI=0xc38c */1513 { 0x47, 0x64, 0xc914 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=9, EQ_DATA_LO=0x14 */1514 { 0x47, 0x64, 0x0000 }, /* -EQ_ACC, -EQ_WRT */1515 {0} /* Terminator */1516 };1517 1518 /**1519 * cs8409_enable_i2c_clock - Enable I2C clocks1520 * @codec: the codec instance1521 * @enable: Enable or disable I2C clocks1522 *1523 * Enable or Disable I2C clocks.1524 */1525 static void cs8409_enable_i2c_clock(struct hda_codec *codec, unsigned int enable)1526 {1527 unsigned int retval;1528 unsigned int newval;1529 1530 retval = cs_vendor_coef_get(codec, 0x0);1531 newval = (enable) ? (retval | 0x8) : (retval & 0xfffffff7);1532 cs_vendor_coef_set(codec, 0x0, newval);1533 }1534 1535 /**1536 * cs8409_i2c_wait_complete - Wait for I2C transaction1537 * @codec: the codec instance1538 *1539 * Wait for I2C transaction to complete.1540 * Return -1 if transaction wait times out.1541 */1542 static int cs8409_i2c_wait_complete(struct hda_codec *codec)1543 {1544 int repeat = 5;1545 unsigned int retval;1546 1547 do {1548 retval = cs_vendor_coef_get(codec, CIR_I2C_STATUS);1549 if ((retval & 0x18) != 0x18) {1550 usleep_range(2000, 4000);1551 --repeat;1552 } else1553 return 0;1554 1555 } while (repeat);1556 1557 return -1;1558 }1559 1560 /**1561 * cs8409_i2c_read - CS8409 I2C Read.1562 * @codec: the codec instance1563 * @i2c_address: I2C Address1564 * @i2c_reg: Register to read1565 * @paged: Is a paged transaction1566 *1567 * CS8409 I2C Read.1568 * Returns negative on error, otherwise returns read value in bits 0-7.1569 */1570 static int cs8409_i2c_read(struct hda_codec *codec,1571 unsigned int i2c_address,1572 unsigned int i2c_reg,1573 unsigned int paged)1574 {1575 unsigned int i2c_reg_data;1576 unsigned int read_data;1577 1578 cs8409_enable_i2c_clock(codec, 1);1579 cs_vendor_coef_set(codec, CIR_I2C_ADDR, i2c_address);1580 1581 if (paged) {1582 cs_vendor_coef_set(codec, CIR_I2C_QWRITE, i2c_reg >> 8);1583 if (cs8409_i2c_wait_complete(codec) < 0) {1584 codec_err(codec,1585 "%s() Paged Transaction Failed 0x%02x : 0x%04x\n",1586 __func__, i2c_address, i2c_reg);1587 return -EIO;1588 }1589 }1590 1591 i2c_reg_data = (i2c_reg << 8) & 0x0ffff;1592 cs_vendor_coef_set(codec, CIR_I2C_QREAD, i2c_reg_data);1593 if (cs8409_i2c_wait_complete(codec) < 0) {1594 codec_err(codec, "%s() Transaction Failed 0x%02x : 0x%04x\n",1595 __func__, i2c_address, i2c_reg);1596 return -EIO;1597 }1598 1599 /* Register in bits 15-8 and the data in 7-0 */1600 read_data = cs_vendor_coef_get(codec, CIR_I2C_QREAD);1601 1602 cs8409_enable_i2c_clock(codec, 0);1603 1604 return read_data & 0x0ff;1605 }1606 1607 /**1608 * cs8409_i2c_write - CS8409 I2C Write.1609 * @codec: the codec instance1610 * @i2c_address: I2C Address1611 * @i2c_reg: Register to write to1612 * @i2c_data: Data to write1613 * @paged: Is a paged transaction1614 *1615 * CS8409 I2C Write.1616 * Returns negative on error, otherwise returns 0.1617 */1618 static int cs8409_i2c_write(struct hda_codec *codec,1619 unsigned int i2c_address, unsigned int i2c_reg,1620 unsigned int i2c_data,1621 unsigned int paged)1622 {1623 unsigned int i2c_reg_data;1624 1625 cs8409_enable_i2c_clock(codec, 1);1626 cs_vendor_coef_set(codec, CIR_I2C_ADDR, i2c_address);1627 1628 if (paged) {1629 cs_vendor_coef_set(codec, CIR_I2C_QWRITE, i2c_reg >> 8);1630 if (cs8409_i2c_wait_complete(codec) < 0) {1631 codec_err(codec,1632 "%s() Paged Transaction Failed 0x%02x : 0x%04x\n",1633 __func__, i2c_address, i2c_reg);1634 return -EIO;1635 }1636 }1637 1638 i2c_reg_data = ((i2c_reg << 8) & 0x0ff00) | (i2c_data & 0x0ff);1639 cs_vendor_coef_set(codec, CIR_I2C_QWRITE, i2c_reg_data);1640 1641 if (cs8409_i2c_wait_complete(codec) < 0) {1642 codec_err(codec, "%s() Transaction Failed 0x%02x : 0x%04x\n",1643 __func__, i2c_address, i2c_reg);1644 return -EIO;1645 }1646 1647 cs8409_enable_i2c_clock(codec, 0);1648 1649 return 0;1650 }1651 1652 static int cs8409_cs42l42_volume_info(struct snd_kcontrol *kcontrol,1653 struct snd_ctl_elem_info *uinfo)1654 {1655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);1656 u16 nid = get_amp_nid(kcontrol);1657 u8 chs = get_amp_channels(kcontrol);1658 1659 codec_dbg(codec, "%s() nid: %d\n", __func__, nid);1660 switch (nid) {1661 case CS8409_CS42L42_HP_PIN_NID:1662 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;1663 uinfo->count = chs == 3 ? 2 : 1;1664 uinfo->value.integer.min = CS8409_CS42L42_HP_VOL_REAL_MIN;1665 uinfo->value.integer.max = CS8409_CS42L42_HP_VOL_REAL_MAX;1666 break;1667 case CS8409_CS42L42_AMIC_PIN_NID:1668 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;1669 uinfo->count = chs == 3 ? 2 : 1;1670 uinfo->value.integer.min = CS8409_CS42L42_AMIC_VOL_REAL_MIN;1671 uinfo->value.integer.max = CS8409_CS42L42_AMIC_VOL_REAL_MAX;1672 break;1673 default:1674 break;1675 }1676 return 0;1677 }1678 1679 static void cs8409_cs42l42_update_volume(struct hda_codec *codec)1680 {1681 struct cs_spec *spec = codec->spec;1682 int data;1683 1684 mutex_lock(&spec->cs8409_i2c_mux);1685 data = cs8409_i2c_read(codec, CS42L42_I2C_ADDR,1686 CS8409_CS42L42_REG_HS_VOLUME_CHA, 1);1687 if (data >= 0)1688 spec->cs42l42_hp_volume[0] = -data;1689 else1690 spec->cs42l42_hp_volume[0] = CS8409_CS42L42_HP_VOL_REAL_MIN;1691 data = cs8409_i2c_read(codec, CS42L42_I2C_ADDR,1692 CS8409_CS42L42_REG_HS_VOLUME_CHB, 1);1693 if (data >= 0)1694 spec->cs42l42_hp_volume[1] = -data;1695 else1696 spec->cs42l42_hp_volume[1] = CS8409_CS42L42_HP_VOL_REAL_MIN;1697 data = cs8409_i2c_read(codec, CS42L42_I2C_ADDR,1698 CS8409_CS42L42_REG_AMIC_VOLUME, 1);1699 if (data >= 0)1700 spec->cs42l42_hs_mic_volume[0] = -data;1701 else1702 spec->cs42l42_hs_mic_volume[0] = CS8409_CS42L42_AMIC_VOL_REAL_MIN;1703 mutex_unlock(&spec->cs8409_i2c_mux);1704 spec->cs42l42_volume_init = 1;1705 }1706 1707 static int cs8409_cs42l42_volume_get(struct snd_kcontrol *kcontrol,1708 struct snd_ctl_elem_value *ucontrol)1709 {1710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);1711 struct cs_spec *spec = codec->spec;1712 hda_nid_t nid = get_amp_nid(kcontrol);1713 int chs = get_amp_channels(kcontrol);1714 long *valp = ucontrol->value.integer.value;1715 1716 if (!spec->cs42l42_volume_init) {1717 snd_hda_power_up(codec);1718 cs8409_cs42l42_update_volume(codec);1719 snd_hda_power_down(codec);1720 }1721 switch (nid) {1722 case CS8409_CS42L42_HP_PIN_NID:1723 if (chs & BIT(0))1724 *valp++ = spec->cs42l42_hp_volume[0];1725 if (chs & BIT(1))1726 *valp++ = spec->cs42l42_hp_volume[1];1727 break;1728 case CS8409_CS42L42_AMIC_PIN_NID:1729 if (chs & BIT(0))1730 *valp++ = spec->cs42l42_hs_mic_volume[0];1731 break;1732 default:1733 break;1734 }1735 return 0;1736 }1737 1738 static int cs8409_cs42l42_volume_put(struct snd_kcontrol *kcontrol,1739 struct snd_ctl_elem_value *ucontrol)1740 {1741 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);1742 struct cs_spec *spec = codec->spec;1743 hda_nid_t nid = get_amp_nid(kcontrol);1744 int chs = get_amp_channels(kcontrol);1745 long *valp = ucontrol->value.integer.value;1746 int change = 0;1747 char vol;1748 1749 snd_hda_power_up(codec);1750 switch (nid) {1751 case CS8409_CS42L42_HP_PIN_NID:1752 mutex_lock(&spec->cs8409_i2c_mux);1753 if (chs & BIT(0)) {1754 vol = -(*valp);1755 change = cs8409_i2c_write(codec, CS42L42_I2C_ADDR,1756 CS8409_CS42L42_REG_HS_VOLUME_CHA, vol, 1);1757 valp++;1758 }1759 if (chs & BIT(1)) {1760 vol = -(*valp);1761 change |= cs8409_i2c_write(codec, CS42L42_I2C_ADDR,1762 CS8409_CS42L42_REG_HS_VOLUME_CHB, vol, 1);1763 }1764 mutex_unlock(&spec->cs8409_i2c_mux);1765 break;1766 case CS8409_CS42L42_AMIC_PIN_NID:1767 mutex_lock(&spec->cs8409_i2c_mux);1768 if (chs & BIT(0)) {1769 change = cs8409_i2c_write(1770 codec, CS42L42_I2C_ADDR,1771 CS8409_CS42L42_REG_AMIC_VOLUME, (char)*valp, 1);1772 valp++;1773 }1774 mutex_unlock(&spec->cs8409_i2c_mux);1775 break;1776 default:1777 break;1778 }1779 cs8409_cs42l42_update_volume(codec);1780 snd_hda_power_down(codec);1781 return change;1782 }1783 1784 static const DECLARE_TLV_DB_SCALE(1785 cs8409_cs42l42_hp_db_scale,1786 CS8409_CS42L42_HP_VOL_REAL_MIN * 100, 100, 1);1787 1788 static const DECLARE_TLV_DB_SCALE(1789 cs8409_cs42l42_amic_db_scale,1790 CS8409_CS42L42_AMIC_VOL_REAL_MIN * 100, 100, 1);1791 1792 static const struct snd_kcontrol_new cs8409_cs42l42_hp_volume_mixer = {1793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,1794 .index = 0,1795 .name = "Headphone Playback Volume",1796 .subdevice = (HDA_SUBDEV_AMP_FLAG | HDA_SUBDEV_NID_FLAG),1797 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE1798 | SNDRV_CTL_ELEM_ACCESS_TLV_READ),1799 .info = cs8409_cs42l42_volume_info,1800 .get = cs8409_cs42l42_volume_get,1801 .put = cs8409_cs42l42_volume_put,1802 .tlv = { .p = cs8409_cs42l42_hp_db_scale },1803 .private_value = HDA_COMPOSE_AMP_VAL(1804 CS8409_CS42L42_HP_PIN_NID, 3, 0, HDA_OUTPUT)1805 | HDA_AMP_VAL_MIN_MUTE1806 };1807 1808 static const struct snd_kcontrol_new cs8409_cs42l42_amic_volume_mixer = {1809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,1810 .index = 0,1811 .name = "Mic Capture Volume",1812 .subdevice = (HDA_SUBDEV_AMP_FLAG | HDA_SUBDEV_NID_FLAG),1813 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE1814 | SNDRV_CTL_ELEM_ACCESS_TLV_READ),1815 .info = cs8409_cs42l42_volume_info,1816 .get = cs8409_cs42l42_volume_get,1817 .put = cs8409_cs42l42_volume_put,1818 .tlv = { .p = cs8409_cs42l42_amic_db_scale },1819 .private_value = HDA_COMPOSE_AMP_VAL(1820 CS8409_CS42L42_AMIC_PIN_NID, 1, 0, HDA_INPUT)1821 | HDA_AMP_VAL_MIN_MUTE1822 };1823 1824 /* Assert/release RTS# line to CS42L42 */1825 static void cs8409_cs42l42_reset(struct hda_codec *codec)1826 {1827 struct cs_spec *spec = codec->spec;1828 1829 /* Assert RTS# line */1830 snd_hda_codec_write(codec,1831 codec->core.afg, 0, AC_VERB_SET_GPIO_DATA, 0);1832 /* wait ~10ms */1833 usleep_range(10000, 15000);1834 /* Release RTS# line */1835 snd_hda_codec_write(codec,1836 codec->core.afg, 0, AC_VERB_SET_GPIO_DATA, GPIO5_INT);1837 /* wait ~10ms */1838 usleep_range(10000, 15000);1839 1840 mutex_lock(&spec->cs8409_i2c_mux);1841 1842 /* Clear interrupts, by reading interrupt status registers */1843 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1308, 1);1844 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1309, 1);1845 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130A, 1);1846 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130F, 1);1847 1848 mutex_unlock(&spec->cs8409_i2c_mux);1849 1850 }1851 1852 /* Configure CS42L42 slave codec for jack autodetect */1853 static void cs8409_cs42l42_enable_jack_detect(struct hda_codec *codec)1854 {1855 struct cs_spec *spec = codec->spec;1856 1857 mutex_lock(&spec->cs8409_i2c_mux);1858 1859 /* Set TIP_SENSE_EN for analog front-end of tip sense. */1860 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b70, 0x0020, 1);1861 /* Clear WAKE# */1862 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b71, 0x0001, 1);1863 /* Wait ~2.5ms */1864 usleep_range(2500, 3000);1865 /* Set mode WAKE# output follows the combination logic directly */1866 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b71, 0x0020, 1);1867 /* Clear interrupts status */1868 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130f, 1);1869 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1b7b, 1);1870 /* Enable interrupt */1871 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1320, 0x03, 1);1872 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b79, 0x00, 1);1873 1874 mutex_unlock(&spec->cs8409_i2c_mux);1875 }1876 1877 /* Enable and run CS42L42 slave codec jack auto detect */1878 static void cs8409_cs42l42_run_jack_detect(struct hda_codec *codec)1879 {1880 struct cs_spec *spec = codec->spec;1881 1882 mutex_lock(&spec->cs8409_i2c_mux);1883 1884 /* Clear interrupts */1885 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1308, 1);1886 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1b77, 1);1887 1888 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1102, 0x87, 1);1889 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1f06, 0x86, 1);1890 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b74, 0x07, 1);1891 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x131b, 0x01, 1);1892 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1120, 0x80, 1);1893 /* Wait ~110ms*/1894 usleep_range(110000, 200000);1895 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x111f, 0x77, 1);1896 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1120, 0xc0, 1);1897 /* Wait ~10ms */1898 usleep_range(10000, 25000);1899 1900 mutex_unlock(&spec->cs8409_i2c_mux);1901 1902 }1903 1904 static void cs8409_cs42l42_reg_setup(struct hda_codec *codec)1905 {1906 const struct cs8409_i2c_param *seq = cs42l42_init_reg_seq;1907 struct cs_spec *spec = codec->spec;1908 1909 mutex_lock(&spec->cs8409_i2c_mux);1910 1911 for (; seq->addr; seq++)1912 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, seq->addr, seq->reg, 1);1913 1914 mutex_unlock(&spec->cs8409_i2c_mux);1915 1916 }1917 1918 /*1919 * In the case of CS8409 we do not have unsolicited events from NID's 0x241920 * and 0x34 where hs mic and hp are connected. Companion codec CS42L42 will1921 * generate interrupt via gpio 4 to notify jack events. We have to overwrite1922 * generic snd_hda_jack_unsol_event(), read CS42L42 jack detect status registers1923 * and then notify status via generic snd_hda_jack_unsol_event() call.1924 */1925 static void cs8409_jack_unsol_event(struct hda_codec *codec, unsigned int res)1926 {1927 struct cs_spec *spec = codec->spec;1928 int status_changed = 0;1929 int reg_cdc_status;1930 int reg_hs_status;1931 int reg_ts_status;1932 int type;1933 struct hda_jack_tbl *jk;1934 1935 /* jack_unsol_event() will be called every time gpio line changing state.1936 * In this case gpio4 line goes up as a result of reading interrupt status1937 * registers in previous cs8409_jack_unsol_event() call.1938 * We don't need to handle this event, ignoring...1939 */1940 if ((res & (1 << 4)))1941 return;1942 1943 mutex_lock(&spec->cs8409_i2c_mux);1944 1945 /* Read jack detect status registers */1946 reg_cdc_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1308, 1);1947 reg_hs_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1124, 1);1948 reg_ts_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130f, 1);1949 1950 /* Clear interrupts, by reading interrupt status registers */1951 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1b7b, 1);1952 1953 mutex_unlock(&spec->cs8409_i2c_mux);1954 1955 /* If status values are < 0, read error has occurred. */1956 if (reg_cdc_status < 0 || reg_hs_status < 0 || reg_ts_status < 0)1957 return;1958 1959 /* HSDET_AUTO_DONE */1960 if (reg_cdc_status & CS42L42_HSDET_AUTO_DONE) {1961 1962 type = ((reg_hs_status & CS42L42_HSTYPE_MASK) + 1);1963 /* CS42L42 reports optical jack as type 41964 * We don't handle optical jack1965 */1966 if (type != 4) {1967 if (!spec->cs42l42_hp_jack_in) {1968 status_changed = 1;1969 spec->cs42l42_hp_jack_in = 1;1970 }1971 /* type = 3 has no mic */1972 if ((!spec->cs42l42_mic_jack_in) && (type != 3)) {1973 status_changed = 1;1974 spec->cs42l42_mic_jack_in = 1;1975 }1976 } else {1977 if (spec->cs42l42_hp_jack_in || spec->cs42l42_mic_jack_in) {1978 status_changed = 1;1979 spec->cs42l42_hp_jack_in = 0;1980 spec->cs42l42_mic_jack_in = 0;1981 }1982 }1983 1984 } else {1985 /* TIP_SENSE INSERT/REMOVE */1986 switch (reg_ts_status) {1987 case CS42L42_JACK_INSERTED:1988 cs8409_cs42l42_run_jack_detect(codec);1989 break;1990 1991 case CS42L42_JACK_REMOVED:1992 if (spec->cs42l42_hp_jack_in || spec->cs42l42_mic_jack_in) {1993 status_changed = 1;1994 spec->cs42l42_hp_jack_in = 0;1995 spec->cs42l42_mic_jack_in = 0;1996 }1997 break;1998 1999 default:2000 /* jack in transition */2001 status_changed = 0;2002 break;2003 }2004 }2005 2006 if (status_changed) {2007 2008 snd_hda_set_pin_ctl(codec, CS8409_CS42L42_SPK_PIN_NID,2009 spec->cs42l42_hp_jack_in ? 0 : PIN_OUT);2010 2011 /* Report jack*/2012 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_HP_PIN_NID, 0);2013 if (jk) {2014 snd_hda_jack_unsol_event(codec,2015 (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & AC_UNSOL_RES_TAG);2016 }2017 /* Report jack*/2018 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_AMIC_PIN_NID, 0);2019 if (jk) {2020 snd_hda_jack_unsol_event(codec,2021 (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & AC_UNSOL_RES_TAG);2022 }2023 }2024 }2025 2026 #ifdef CONFIG_PM2027 /* Manage PDREF, when transition to D3hot */2028 static int cs8409_suspend(struct hda_codec *codec)2029 {2030 struct cs_spec *spec = codec->spec;2031 2032 mutex_lock(&spec->cs8409_i2c_mux);2033 /* Power down CS42L42 ASP/EQ/MIX/HP */2034 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1101, 0xfe, 1);2035 mutex_unlock(&spec->cs8409_i2c_mux);2036 /* Assert CS42L42 RTS# line */2037 snd_hda_codec_write(codec,2038 codec->core.afg, 0, AC_VERB_SET_GPIO_DATA, 0);2039 2040 snd_hda_shutup_pins(codec);2041 2042 return 0;2043 }2044 #endif2045 2046 /* Enable/Disable Unsolicited Response for gpio(s) 3,4 */2047 static void cs8409_enable_ur(struct hda_codec *codec, int flag)2048 {2049 /* GPIO4 INT# and GPIO3 WAKE# */2050 snd_hda_codec_write(codec, codec->core.afg,2051 0, AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK,2052 flag ? (GPIO3_INT | GPIO4_INT) : 0);2053 2054 snd_hda_codec_write(codec, codec->core.afg,2055 0, AC_VERB_SET_UNSOLICITED_ENABLE,2056 flag ? AC_UNSOL_ENABLED : 0);2057 2058 }2059 2060 /* Vendor specific HW configuration2061 * PLL, ASP, I2C, SPI, GPIOs, DMIC etc...2062 */2063 static void cs8409_cs42l42_hw_init(struct hda_codec *codec)2064 {2065 const struct cs8409_cir_param *seq = cs8409_cs42l42_hw_cfg;2066 const struct cs8409_cir_param *seq_bullseye = cs8409_cs42l42_bullseye_atn;2067 struct cs_spec *spec = codec->spec;2068 2069 if (spec->gpio_mask) {2070 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,2071 spec->gpio_mask);2072 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,2073 spec->gpio_dir);2074 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,2075 spec->gpio_data);2076 }2077 2078 for (; seq->nid; seq++)2079 cs_vendor_coef_set(codec, seq->cir, seq->coeff);2080 2081 if (codec->fixup_id == CS8409_BULLSEYE)2082 for (; seq_bullseye->nid; seq_bullseye++)2083 cs_vendor_coef_set(codec, seq_bullseye->cir, seq_bullseye->coeff);2084 2085 /* Disable Unsolicited Response during boot */2086 cs8409_enable_ur(codec, 0);2087 2088 /* Reset CS42L42 */2089 cs8409_cs42l42_reset(codec);2090 2091 /* Initialise CS42L42 companion codec */2092 cs8409_cs42l42_reg_setup(codec);2093 2094 if (codec->fixup_id == CS8409_WARLOCK ||2095 codec->fixup_id == CS8409_CYBORG) {2096 /* FULL_SCALE_VOL = 0 for Warlock / Cyborg */2097 mutex_lock(&spec->cs8409_i2c_mux);2098 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x2001, 0x01, 1);2099 mutex_unlock(&spec->cs8409_i2c_mux);2100 /* DMIC1_MO=00b, DMIC1/2_SR=1 */2101 cs_vendor_coef_set(codec, 0x09, 0x0003);2102 }2103 2104 /* Restore Volumes after Resume */2105 if (spec->cs42l42_volume_init) {2106 mutex_lock(&spec->cs8409_i2c_mux);2107 cs8409_i2c_write(codec, CS42L42_I2C_ADDR,2108 CS8409_CS42L42_REG_HS_VOLUME_CHA,2109 -spec->cs42l42_hp_volume[0],2110 1);2111 cs8409_i2c_write(codec, CS42L42_I2C_ADDR,2112 CS8409_CS42L42_REG_HS_VOLUME_CHB,2113 -spec->cs42l42_hp_volume[1],2114 1);2115 cs8409_i2c_write(codec, CS42L42_I2C_ADDR,2116 CS8409_CS42L42_REG_AMIC_VOLUME,2117 spec->cs42l42_hs_mic_volume[0],2118 1);2119 mutex_unlock(&spec->cs8409_i2c_mux);2120 }2121 2122 cs8409_cs42l42_update_volume(codec);2123 2124 cs8409_cs42l42_enable_jack_detect(codec);2125 2126 /* Enable Unsolicited Response */2127 cs8409_enable_ur(codec, 1);2128 }2129 2130 static int cs8409_cs42l42_init(struct hda_codec *codec)2131 {2132 int ret = snd_hda_gen_init(codec);2133 2134 if (!ret)2135 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);2136 2137 return ret;2138 }2139 2140 static const struct hda_codec_ops cs8409_cs42l42_patch_ops = {2141 .build_controls = cs_build_controls,2142 .build_pcms = snd_hda_gen_build_pcms,2143 .init = cs8409_cs42l42_init,2144 .free = cs_free,2145 .unsol_event = cs8409_jack_unsol_event,2146 #ifdef CONFIG_PM2147 .suspend = cs8409_suspend,2148 #endif2149 };2150 2151 static void cs8409_cs42l42_fixups(struct hda_codec *codec,2152 const struct hda_fixup *fix, int action)2153 {2154 struct cs_spec *spec = codec->spec;2155 int caps;2156 2157 switch (action) {2158 case HDA_FIXUP_ACT_PRE_PROBE:2159 snd_hda_add_verbs(codec, cs8409_cs42l42_init_verbs);2160 /* verb exec op override */2161 spec->exec_verb = codec->core.exec_verb;2162 codec->core.exec_verb = cs8409_cs42l42_exec_verb;2163 2164 mutex_init(&spec->cs8409_i2c_mux);2165 2166 codec->patch_ops = cs8409_cs42l42_patch_ops;2167 2168 spec->gen.suppress_auto_mute = 1;2169 spec->gen.no_primary_hp = 1;2170 spec->gen.suppress_vmaster = 1;2171 2172 /* GPIO 5 out, 3,4 in */2173 spec->gpio_dir = GPIO5_INT;2174 spec->gpio_data = 0;2175 spec->gpio_mask = 0x03f;2176 2177 spec->cs42l42_hp_jack_in = 0;2178 spec->cs42l42_mic_jack_in = 0;2179 2180 /* Basic initial sequence for specific hw configuration */2181 snd_hda_sequence_write(codec, cs8409_cs42l42_init_verbs);2182 2183 /* CS8409 is simple HDA bridge and intended to be used with a remote2184 * companion codec. Most of input/output PIN(s) have only basic2185 * capabilities. NID(s) 0x24 and 0x34 have only OUTC and INC2186 * capabilities and no presence detect capable (PDC) and call to2187 * snd_hda_gen_build_controls() will mark them as non detectable2188 * phantom jacks. However, in this configuration companion codec2189 * CS42L42 is connected to these pins and it has jack detect2190 * capabilities. We have to override pin capabilities,2191 * otherwise they will not be created as input devices.2192 */2193 caps = snd_hdac_read_parm(&codec->core, CS8409_CS42L42_HP_PIN_NID,2194 AC_PAR_PIN_CAP);2195 if (caps >= 0)2196 snd_hdac_override_parm(&codec->core,2197 CS8409_CS42L42_HP_PIN_NID, AC_PAR_PIN_CAP,2198 (caps | (AC_PINCAP_IMP_SENSE | AC_PINCAP_PRES_DETECT)));2199 2200 caps = snd_hdac_read_parm(&codec->core, CS8409_CS42L42_AMIC_PIN_NID,2201 AC_PAR_PIN_CAP);2202 if (caps >= 0)2203 snd_hdac_override_parm(&codec->core,2204 CS8409_CS42L42_AMIC_PIN_NID, AC_PAR_PIN_CAP,2205 (caps | (AC_PINCAP_IMP_SENSE | AC_PINCAP_PRES_DETECT)));2206 2207 snd_hda_override_wcaps(codec, CS8409_CS42L42_HP_PIN_NID,2208 (get_wcaps(codec, CS8409_CS42L42_HP_PIN_NID) | AC_WCAP_UNSOL_CAP));2209 2210 snd_hda_override_wcaps(codec, CS8409_CS42L42_AMIC_PIN_NID,2211 (get_wcaps(codec, CS8409_CS42L42_AMIC_PIN_NID) | AC_WCAP_UNSOL_CAP));2212 break;2213 case HDA_FIXUP_ACT_PROBE:2214 2215 /* Set initial DMIC volume to -26 dB */2216 snd_hda_codec_amp_init_stereo(codec, CS8409_CS42L42_DMIC_ADC_PIN_NID,2217 HDA_INPUT, 0, 0xff, 0x19);2218 snd_hda_gen_add_kctl(&spec->gen,2219 NULL, &cs8409_cs42l42_hp_volume_mixer);2220 snd_hda_gen_add_kctl(&spec->gen,2221 NULL, &cs8409_cs42l42_amic_volume_mixer);2222 cs8409_cs42l42_hw_init(codec);2223 snd_hda_codec_set_name(codec, "CS8409/CS42L42");2224 break;2225 case HDA_FIXUP_ACT_INIT:2226 cs8409_cs42l42_hw_init(codec);2227 fallthrough;2228 case HDA_FIXUP_ACT_BUILD:2229 /* Run jack auto detect first time on boot2230 * after controls have been added, to check if jack has2231 * been already plugged in.2232 * Run immediately after init.2233 */2234 cs8409_cs42l42_run_jack_detect(codec);2235 usleep_range(100000, 150000);2236 break;2237 default:2238 break;2239 }2240 }2241 2242 static int cs8409_cs42l42_exec_verb(struct hdac_device *dev,2243 unsigned int cmd, unsigned int flags, unsigned int *res)2244 {2245 struct hda_codec *codec = container_of(dev, struct hda_codec, core);2246 struct cs_spec *spec = codec->spec;2247 2248 unsigned int nid = ((cmd >> 20) & 0x07f);2249 unsigned int verb = ((cmd >> 8) & 0x0fff);2250 2251 /* CS8409 pins have no AC_PINSENSE_PRESENCE2252 * capabilities. We have to intercept 2 calls for pins 0x24 and 0x342253 * and return correct pin sense values for read_pin_sense() call from2254 * hda_jack based on CS42L42 jack detect status.2255 */2256 switch (nid) {2257 case CS8409_CS42L42_HP_PIN_NID:2258 if (verb == AC_VERB_GET_PIN_SENSE) {2259 *res = (spec->cs42l42_hp_jack_in) ? AC_PINSENSE_PRESENCE : 0;2260 return 0;2261 }2262 break;2263 2264 case CS8409_CS42L42_AMIC_PIN_NID:2265 if (verb == AC_VERB_GET_PIN_SENSE) {2266 *res = (spec->cs42l42_mic_jack_in) ? AC_PINSENSE_PRESENCE : 0;2267 return 0;2268 }2269 break;2270 2271 default:2272 break;2273 }2274 2275 return spec->exec_verb(dev, cmd, flags, res);2276 }2277 2278 static int patch_cs8409(struct hda_codec *codec)2279 {2280 int err;2281 2282 if (!cs_alloc_spec(codec, CS8409_VENDOR_NID))2283 return -ENOMEM;2284 2285 snd_hda_pick_fixup(codec,2286 cs8409_models, cs8409_fixup_tbl, cs8409_fixups);2287 2288 codec_dbg(codec, "Picked ID=%d, VID=%08x, DEV=%08x\n",2289 codec->fixup_id,2290 codec->bus->pci->subsystem_vendor,2291 codec->bus->pci->subsystem_device);2292 2293 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);2294 2295 err = cs_parse_auto_config(codec);2296 if (err < 0) {2297 cs_free(codec);2298 return err;2299 }2300 2301 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);2302 return 0;2303 }2304 2305 1232 /* 2306 1233 * patch entries … … 2312 1239 HDA_CODEC_ENTRY(0x10134210, "CS4210", patch_cs4210), 2313 1240 HDA_CODEC_ENTRY(0x10134213, "CS4213", patch_cs4213), 2314 HDA_CODEC_ENTRY(0x10138409, "CS8409", patch_cs8409),2315 1241 {0} /* terminator */ 2316 1242 }; -
GPL/trunk/alsa-kernel/pci/hda/patch_conexant.c
r695 r717 184 184 } 185 185 186 static void cx_auto_ reboot_notify(struct hda_codec *codec)186 static void cx_auto_shutdown(struct hda_codec *codec) 187 187 { 188 188 struct conexant_spec *spec = codec->spec; … … 191 191 from the internal speaker during (and after) reboot */ 192 192 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false); 193 snd_hda_gen_reboot_notify(codec);194 193 } 195 194 196 195 static void cx_auto_free(struct hda_codec *codec) 197 196 { 198 cx_auto_ reboot_notify(codec);197 cx_auto_shutdown(codec); 199 198 snd_hda_gen_free(codec); 200 199 } 200 201 #ifdef CONFIG_PM 202 static int cx_auto_suspend(struct hda_codec *codec) 203 { 204 cx_auto_shutdown(codec); 205 return 0; 206 } 207 #endif 201 208 202 209 static const struct hda_codec_ops cx_auto_patch_ops = { … … 204 211 .build_pcms = snd_hda_gen_build_pcms, 205 212 .init = cx_auto_init, 206 .reboot_notify = cx_auto_reboot_notify,207 213 .free = cx_auto_free, 208 214 .unsol_event = snd_hda_jack_unsol_event, 209 215 #ifdef CONFIG_PM 216 .suspend = cx_auto_suspend, 210 217 .check_power_status = snd_hda_gen_check_power_status, 211 218 #endif … … 998 1005 SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE), 999 1006 SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE), 1007 SND_PCI_QUIRK(0x103c, 0x82b4, "HP ProDesk 600 G3", CXT_FIXUP_HP_MIC_NO_PRESENCE), 1000 1008 SND_PCI_QUIRK(0x103c, 0x836e, "HP ProBook 455 G5", CXT_FIXUP_MUTE_LED_GPIO), 1001 1009 SND_PCI_QUIRK(0x103c, 0x837f, "HP ProBook 470 G5", CXT_FIXUP_MUTE_LED_GPIO), … … 1106 1114 cxt5051_fixups, cxt_fixups); 1107 1115 break; 1116 case 0x14f15098: 1117 codec->pin_amp_workaround = 1; 1118 spec->gen.mixer_nid = 0x22; 1119 spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO; 1120 snd_hda_pick_fixup(codec, cxt5066_fixup_models, 1121 cxt5066_fixups, cxt_fixups); 1122 break; 1108 1123 case 0x14f150f2: 1109 1124 codec->power_save_node = 1; … … 1126 1141 goto error; 1127 1142 1128 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);1143 err = cx_auto_parse_beep(codec); 1129 1144 if (err < 0) 1130 1145 goto error; 1131 1146 1132 err = cx_auto_parse_beep(codec);1147 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); 1133 1148 if (err < 0) 1134 1149 goto error; -
GPL/trunk/alsa-kernel/pci/hda/patch_hdmi.c
r709 r717 59 59 module_param(enable_silent_stream, bool, 0644); 60 60 MODULE_PARM_DESC(enable_silent_stream, "Enable Silent Stream for HDMI devices"); 61 62 static bool enable_all_pins; 63 module_param(enable_all_pins, bool, 0444); 64 MODULE_PARM_DESC(enable_all_pins, "Forcibly enable all pins"); 61 65 62 66 struct hdmi_spec_per_cvt { … … 1396 1400 last_try: 1397 1401 /* the last try; check the empty slots in pins */ 1398 for (i = 0; i < spec-> num_nids; i++) {1402 for (i = 0; i < spec->pcm_used; i++) { 1399 1403 if (!test_bit(i, &spec->pcm_bitmap)) 1400 1404 return i; … … 1626 1630 struct hdmi_spec *spec = codec->spec; 1627 1631 struct hdmi_eld *eld = &spec->temp_eld; 1632 struct device *dev = hda_codec_dev(codec); 1628 1633 hda_nid_t pin_nid = per_pin->pin_nid; 1629 1634 int dev_id = per_pin->dev_id; … … 1639 1644 int ret; 1640 1645 1646 #ifdef CONFIG_PM 1647 if (dev->power.runtime_status == RPM_SUSPENDING) 1648 return; 1649 #endif 1650 1641 1651 ret = snd_hda_power_up_pm(codec); 1642 if (ret < 0 && pm_runtime_suspended( hda_codec_dev(codec)))1652 if (ret < 0 && pm_runtime_suspended(dev)) 1643 1653 goto out; 1644 1654 … … 1972 1982 } 1973 1983 1984 if (enable_all_pins) 1985 spec->force_connect = true; 1986 1974 1987 q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); 1975 1988 … … 2269 2282 */ 2270 2283 2271 if (codec->mst_no_extra_pcms) 2284 if (spec->dyn_pcm_no_legacy && codec->mst_no_extra_pcms) 2285 pcm_num = spec->num_cvts; 2286 else if (codec->mst_no_extra_pcms) 2272 2287 pcm_num = spec->num_nids; 2273 2288 else … … 2965 2980 /* Intel Haswell and onwards; audio component with eld notifier */ 2966 2981 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, 2967 const int *port_map, int port_num, int dev_num) 2982 const int *port_map, int port_num, int dev_num, 2983 bool send_silent_stream) 2968 2984 { 2969 2985 struct hdmi_spec *spec; … … 2998 3014 * module param or Kconfig option 2999 3015 */ 3000 if ( enable_silent_stream)3016 if (send_silent_stream) 3001 3017 spec->send_silent_stream = true; 3002 3018 … … 3006 3022 static int patch_i915_hsw_hdmi(struct hda_codec *codec) 3007 3023 { 3008 return intel_hsw_common_init(codec, 0x08, NULL, 0, 3); 3024 return intel_hsw_common_init(codec, 0x08, NULL, 0, 3, 3025 enable_silent_stream); 3009 3026 } 3010 3027 3011 3028 static int patch_i915_glk_hdmi(struct hda_codec *codec) 3012 3029 { 3013 return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3); 3030 /* 3031 * Silent stream calls audio component .get_power() from 3032 * .pin_eld_notify(). On GLK this will deadlock in i915 due 3033 * to the audio vs. CDCLK workaround. 3034 */ 3035 return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3, false); 3014 3036 } 3015 3037 … … 3022 3044 static const int map[] = {0x0, 0x4, 0x6, 0x8, 0xa, 0xb}; 3023 3045 3024 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3); 3046 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3, 3047 enable_silent_stream); 3025 3048 } 3026 3049 … … 3034 3057 int ret; 3035 3058 3036 ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4); 3059 ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4, 3060 enable_silent_stream); 3037 3061 if (!ret) { 3038 3062 struct hdmi_spec *spec = codec->spec; … … 4398 4422 HDA_CODEC_ENTRY(0x80862814, "DG1 HDMI", patch_i915_tgl_hdmi), 4399 4423 HDA_CODEC_ENTRY(0x80862815, "Alderlake HDMI", patch_i915_tgl_hdmi), 4400 HDA_CODEC_ENTRY(0x8086281c, "Alderlake-P HDMI", patch_i915_tgl_hdmi),4401 4424 HDA_CODEC_ENTRY(0x80862816, "Rocketlake HDMI", patch_i915_tgl_hdmi), 4425 HDA_CODEC_ENTRY(0x80862819, "DG2 HDMI", patch_i915_tgl_hdmi), 4402 4426 HDA_CODEC_ENTRY(0x8086281a, "Jasperlake HDMI", patch_i915_icl_hdmi), 4403 4427 HDA_CODEC_ENTRY(0x8086281b, "Elkhartlake HDMI", patch_i915_icl_hdmi), 4428 HDA_CODEC_ENTRY(0x8086281c, "Alderlake-P HDMI", patch_i915_tgl_hdmi), 4404 4429 HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI", patch_generic_hdmi), 4405 4430 HDA_CODEC_ENTRY(0x80862882, "Valleyview2 HDMI", patch_i915_byt_hdmi), -
GPL/trunk/alsa-kernel/pci/hda/patch_realtek.c
r703 r717 103 103 struct alc_coef_led mute_led_coef; 104 104 struct alc_coef_led mic_led_coef; 105 struct mutex coef_mutex; 105 106 106 107 hda_nid_t headset_mic_pin; … … 115 116 #endif 116 117 void (*shutup)(struct hda_codec *codec); 117 void (*reboot_notify)(struct hda_codec *codec);118 118 119 119 int init_amp; … … 139 139 */ 140 140 141 static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, 142 unsigned int coef_idx) 141 static void coef_mutex_lock(struct hda_codec *codec) 142 { 143 struct alc_spec *spec = codec->spec; 144 145 snd_hda_power_up_pm(codec); 146 mutex_lock(&spec->coef_mutex); 147 } 148 149 static void coef_mutex_unlock(struct hda_codec *codec) 150 { 151 struct alc_spec *spec = codec->spec; 152 153 mutex_unlock(&spec->coef_mutex); 154 snd_hda_power_down_pm(codec); 155 } 156 157 static int __alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, 158 unsigned int coef_idx) 143 159 { 144 160 unsigned int val; … … 149 165 } 150 166 167 static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid, 168 unsigned int coef_idx) 169 { 170 unsigned int val; 171 172 coef_mutex_lock(codec); 173 val = __alc_read_coefex_idx(codec, nid, coef_idx); 174 coef_mutex_unlock(codec); 175 return val; 176 } 177 151 178 #define alc_read_coef_idx(codec, coef_idx) \ 152 179 alc_read_coefex_idx(codec, 0x20, coef_idx) 153 180 181 static void __alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, 182 unsigned int coef_idx, unsigned int coef_val) 183 { 184 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx); 185 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val); 186 } 187 154 188 static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, 155 189 unsigned int coef_idx, unsigned int coef_val) 156 190 { 157 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx); 158 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val); 191 coef_mutex_lock(codec); 192 __alc_write_coefex_idx(codec, nid, coef_idx, coef_val); 193 coef_mutex_unlock(codec); 159 194 } 160 195 161 196 #define alc_write_coef_idx(codec, coef_idx, coef_val) \ 162 197 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val) 198 199 static void __alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid, 200 unsigned int coef_idx, unsigned int mask, 201 unsigned int bits_set) 202 { 203 unsigned int val = __alc_read_coefex_idx(codec, nid, coef_idx); 204 205 if (val != -1) 206 __alc_write_coefex_idx(codec, nid, coef_idx, 207 (val & ~mask) | bits_set); 208 } 163 209 164 210 static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid, … … 166 212 unsigned int bits_set) 167 213 { 168 unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx); 169 170 if (val != -1) 171 alc_write_coefex_idx(codec, nid, coef_idx, 172 (val & ~mask) | bits_set); 214 coef_mutex_lock(codec); 215 __alc_update_coefex_idx(codec, nid, coef_idx, mask, bits_set); 216 coef_mutex_unlock(codec); 173 217 } 174 218 … … 203 247 const struct coef_fw *fw) 204 248 { 249 coef_mutex_lock(codec); 205 250 for (; fw->nid; fw++) { 206 251 if (fw->mask == (unsigned short)-1) 207 alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);252 __alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val); 208 253 else 209 alc_update_coefex_idx(codec, fw->nid, fw->idx, 210 fw->mask, fw->val); 211 } 254 __alc_update_coefex_idx(codec, fw->nid, fw->idx, 255 fw->mask, fw->val); 256 } 257 coef_mutex_unlock(codec); 212 258 } 213 259 … … 400 446 case 0x10ec0255: 401 447 case 0x10ec0256: 448 case 0x19e58326: 402 449 case 0x10ec0257: 403 450 case 0x10ec0282: … … 535 582 536 583 switch (codec->core.vendor_id) { 584 case 0x10ec0236: 585 case 0x10ec0256: 586 case 0x19e58326: 537 587 case 0x10ec0283: 538 588 case 0x10ec0286: … … 893 943 } 894 944 945 #define alc_free snd_hda_gen_free 946 947 #ifdef CONFIG_PM 895 948 static inline void alc_shutup(struct hda_codec *codec) 896 949 { … … 906 959 } 907 960 908 static void alc_reboot_notify(struct hda_codec *codec)909 {910 struct alc_spec *spec = codec->spec;911 912 if (spec && spec->reboot_notify)913 spec->reboot_notify(codec);914 else915 alc_shutup(codec);916 }917 918 #define alc_free snd_hda_gen_free919 920 #ifdef CONFIG_PM921 961 static void alc_power_eapd(struct hda_codec *codec) 922 962 { … … 932 972 return 0; 933 973 } 934 #endif 935 936 #ifdef CONFIG_PM 974 937 975 static int alc_resume(struct hda_codec *codec) 938 976 { … … 961 999 .check_power_status = snd_hda_gen_check_power_status, 962 1000 #endif 963 .reboot_notify = alc_reboot_notify,964 1001 }; 965 1002 … … 1167 1204 codec->forced_resume = 1; 1168 1205 codec->patch_ops = alc_patch_ops; 1206 mutex_init(&spec->coef_mutex); 1169 1207 1170 1208 err = alc_codec_rename_from_preset(codec); … … 2295 2333 ALC887_FIXUP_BASS_CHMAP, 2296 2334 ALC1220_FIXUP_GB_DUAL_CODECS, 2335 ALC1220_FIXUP_GB_X570, 2297 2336 ALC1220_FIXUP_CLEVO_P950, 2298 2337 ALC1220_FIXUP_CLEVO_PB51ED, … … 2300 2339 ALC887_FIXUP_ASUS_AUDIO, 2301 2340 ALC887_FIXUP_ASUS_HMIC, 2341 ALCS1200A_FIXUP_MIC_VREF, 2302 2342 }; 2303 2343 … … 2480 2520 "Rear-Panel Capture Switch" : 2481 2521 "Front-Panel Capture Switch"); 2522 break; 2523 } 2524 } 2525 2526 static void alc1220_fixup_gb_x570(struct hda_codec *codec, 2527 const struct hda_fixup *fix, 2528 int action) 2529 { 2530 static const hda_nid_t conn1[] = { 0x0c }; 2531 static const struct coef_fw gb_x570_coefs[] = { 2532 WRITE_COEF(0x07, 0x03c0), 2533 WRITE_COEF(0x1a, 0x01c1), 2534 WRITE_COEF(0x1b, 0x0202), 2535 WRITE_COEF(0x43, 0x3005), 2536 {0} 2537 }; 2538 2539 switch (action) { 2540 case HDA_FIXUP_ACT_PRE_PROBE: 2541 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1); 2542 snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1); 2543 break; 2544 case HDA_FIXUP_ACT_INIT: 2545 alc_process_coef_fw(codec, gb_x570_coefs); 2482 2546 break; 2483 2547 } … … 2972 3036 .v.func = alc1220_fixup_gb_dual_codecs, 2973 3037 }, 3038 [ALC1220_FIXUP_GB_X570] = { 3039 .type = HDA_FIXUP_FUNC, 3040 .v.func = alc1220_fixup_gb_x570, 3041 }, 2974 3042 [ALC1220_FIXUP_CLEVO_P950] = { 2975 3043 .type = HDA_FIXUP_FUNC, … … 3005 3073 .chain_id = ALC887_FIXUP_ASUS_AUDIO, 3006 3074 }, 3075 #ifdef TARGET_OS2xxx 3076 [ALCS1200A_FIXUP_MIC_VREF] = { 3077 .type = HDA_FIXUP_PINCTLS, 3078 .v.pins = (const struct hda_pintbl[]) { 3079 { 0x18, PIN_VREF50 }, /* rear mic */ 3080 { 0x19, PIN_VREF50 }, /* front mic */ 3081 {} 3082 } 3083 }, 3084 #endif 3007 3085 }; 3008 3086 … … 3042 3120 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS), 3043 3121 SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3), 3122 SND_PCI_QUIRK(0x1043, 0x8797, "ASUS TUF B550M-PLUS", ALCS1200A_FIXUP_MIC_VREF), 3044 3123 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP), 3045 3124 SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP), … … 3076 3155 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE), 3077 3156 SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS), 3078 SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_CLEVO_P950), 3079 SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_CLEVO_P950), 3157 SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_GB_X570), 3158 SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_GB_X570), 3159 SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXUP_GB_X570), 3080 3160 SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950), 3081 3161 SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950), … … 3094 3174 SND_PCI_QUIRK(0x1558, 0x65e1, "Clevo PB51[ED][DF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3095 3175 SND_PCI_QUIRK(0x1558, 0x65e5, "Clevo PC50D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3176 SND_PCI_QUIRK(0x1558, 0x65f1, "Clevo PC50HS", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3177 SND_PCI_QUIRK(0x1558, 0x65f5, "Clevo PD50PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3096 3178 SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3097 3179 SND_PCI_QUIRK(0x1558, 0x67e1, "Clevo PB71[DE][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3098 3180 SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3181 SND_PCI_QUIRK(0x1558, 0x67f1, "Clevo PC70H[PRS]", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3182 SND_PCI_QUIRK(0x1558, 0x67f5, "Clevo PD70PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3099 3183 SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3100 SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3184 SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170SM", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 3185 SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED), 3101 3186 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950), 3102 3187 SND_PCI_QUIRK(0x1558, 0x9506, "Clevo P955HQ", ALC1220_FIXUP_CLEVO_P950), … … 3149 3234 {.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"}, 3150 3235 {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"}, 3236 {.id = ALC1220_FIXUP_GB_X570, .name = "gb-x570"}, 3151 3237 {.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"}, 3152 3238 {0} … … 3697 3783 ALC269_TYPE_ALC215, 3698 3784 ALC269_TYPE_ALC225, 3785 ALC269_TYPE_ALC245, 3699 3786 ALC269_TYPE_ALC287, 3700 3787 ALC269_TYPE_ALC294, … … 3734 3821 case ALC269_TYPE_ALC215: 3735 3822 case ALC269_TYPE_ALC225: 3823 case ALC269_TYPE_ALC245: 3736 3824 case ALC269_TYPE_ALC287: 3737 3825 case ALC269_TYPE_ALC294: … … 3803 3891 case 0x10ec0236: 3804 3892 case 0x10ec0256: 3893 case 0x19e58326: 3805 3894 alc_write_coef_idx(codec, 0x48, 0x0); 3806 3895 alc_update_coef_idx(codec, 0x49, 0x0045, 0x0); … … 3831 3920 case 0x10ec0236: 3832 3921 case 0x10ec0256: 3922 case 0x19e58326: 3833 3923 alc_write_coef_idx(codec, 0x48, 0xd011); 3834 3924 alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045); … … 4184 4274 * when booting with headset plugged. So skip setting it for the codec alc257 4185 4275 */ 4186 if (codec->core.vendor_id != 0x10ec0257) 4276 if (codec->core.vendor_id != 0x10ec0236 && 4277 codec->core.vendor_id != 0x10ec0257) 4187 4278 alc_update_coef_idx(codec, 0x46, 0, 3 << 12); 4188 4279 … … 4262 4353 bool hp1_pin_sense, hp2_pin_sense; 4263 4354 4264 if (spec->codec_variant != ALC269_TYPE_ALC287) 4355 if (spec->codec_variant != ALC269_TYPE_ALC287 && 4356 spec->codec_variant != ALC269_TYPE_ALC245) 4265 4357 /* required only at boot or S3 and S4 resume time */ 4266 4358 #ifndef TARGET_OS2 … … 5025 5117 { 5026 5118 alc_fixup_hp_gpio_led(codec, action, 0x10, 0); 5119 } 5120 5121 static void alc245_fixup_hp_gpio_led(struct hda_codec *codec, 5122 const struct hda_fixup *fix, int action) 5123 { 5124 struct alc_spec *spec = codec->spec; 5125 5126 if (action == HDA_FIXUP_ACT_PRE_PROBE) 5127 spec->micmute_led_polarity = 1; 5128 alc_fixup_hp_gpio_led(codec, action, 0, 0x04); 5027 5129 } 5028 5130 … … 5501 5603 case 0x10ec0236: 5502 5604 case 0x10ec0256: 5605 case 0x19e58326: 5503 5606 alc_process_coef_fw(codec, coef0256); 5504 5607 break; … … 5616 5719 case 0x10ec0236: 5617 5720 case 0x10ec0256: 5721 case 0x19e58326: 5618 5722 alc_write_coef_idx(codec, 0x45, 0xc489); 5619 5723 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); … … 5766 5870 case 0x10ec0236: 5767 5871 case 0x10ec0256: 5872 case 0x19e58326: 5768 5873 alc_write_coef_idx(codec, 0x1b, 0x0e4b); 5769 5874 alc_write_coef_idx(codec, 0x45, 0xc089); … … 5865 5970 case 0x10ec0236: 5866 5971 case 0x10ec0256: 5972 case 0x19e58326: 5867 5973 alc_process_coef_fw(codec, coef0256); 5868 5974 break; … … 5979 6085 case 0x10ec0236: 5980 6086 case 0x10ec0256: 6087 case 0x19e58326: 5981 6088 alc_process_coef_fw(codec, coef0256); 5982 6089 break; … … 6080 6187 case 0x10ec0236: 6081 6188 case 0x10ec0256: 6189 case 0x19e58326: 6082 6190 alc_write_coef_idx(codec, 0x1b, 0x0e4b); 6083 6191 alc_write_coef_idx(codec, 0x06, 0x6104); … … 6376 6484 case 0x10ec0236: 6377 6485 case 0x10ec0256: 6486 case 0x19e58326: 6378 6487 alc_process_coef_fw(codec, alc256fw); 6379 6488 break; … … 6466 6575 6467 6576 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 6468 spec->reboot_notify = snd_hda_gen_reboot_notify; /* reduce noise */6469 6577 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; 6470 6578 codec->power_save_node = 0; /* avoid click noises */ … … 6980 7088 case 0x10ec0255: 6981 7089 case 0x10ec0256: 7090 case 0x19e58326: 6982 7091 alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */ 6983 7092 alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15); … … 7110 7219 #endif /* NOT_USED */ 7111 7220 7221 /* GPIO1 = amplifier on/off 7222 * GPIO3 = mic mute LED 7223 */ 7224 static void alc285_fixup_hp_spectre_x360_eb1(struct hda_codec *codec, 7225 const struct hda_fixup *fix, int action) 7226 { 7227 static const hda_nid_t conn[] = { 0x02 }; 7228 7229 struct alc_spec *spec = codec->spec; 7230 static const struct hda_pintbl pincfgs[] = { 7231 { 0x14, 0x90170110 }, /* front/high speakers */ 7232 { 0x17, 0x90170130 }, /* back/bass speakers */ 7233 {0} 7234 }; 7235 7236 //enable micmute led 7237 alc_fixup_hp_gpio_led(codec, action, 0x00, 0x04); 7238 7239 switch (action) { 7240 case HDA_FIXUP_ACT_PRE_PROBE: 7241 spec->micmute_led_polarity = 1; 7242 /* needed for amp of back speakers */ 7243 spec->gpio_mask |= 0x01; 7244 spec->gpio_dir |= 0x01; 7245 snd_hda_apply_pincfgs(codec, pincfgs); 7246 /* share DAC to have unified volume control */ 7247 snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn); 7248 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn); 7249 break; 7250 case HDA_FIXUP_ACT_INIT: 7251 /* need to toggle GPIO to enable the amp of back speakers */ 7252 alc_update_gpio_data(codec, 0x01, true); 7253 msleep(100); 7254 alc_update_gpio_data(codec, 0x01, false); 7255 break; 7256 } 7257 } 7258 7112 7259 static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec, 7113 7260 const struct hda_fixup *fix, int action) … … 7138 7285 } 7139 7286 7287 /* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */ 7288 static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec, 7289 const struct hda_fixup *fix, 7290 int action) 7291 { 7292 struct alc_spec *spec = codec->spec; 7293 7294 switch (action) { 7295 case HDA_FIXUP_ACT_PRE_PROBE: 7296 spec->gen.suppress_auto_mute = 1; 7297 break; 7298 } 7299 } 7300 7140 7301 /* for alc295_fixup_hp_top_speakers */ 7141 7302 #include "hp_x360_helper.c" … … 7143 7304 /* for alc285_fixup_ideapad_s740_coef() */ 7144 7305 #include "ideapad_s740_helper.c" 7306 7307 static const struct coef_fw alc256_fixup_set_coef_defaults_coefs[] = { 7308 WRITE_COEF(0x10, 0x0020), WRITE_COEF(0x24, 0x0000), 7309 WRITE_COEF(0x26, 0x0000), WRITE_COEF(0x29, 0x3000), 7310 WRITE_COEF(0x37, 0xfe05), WRITE_COEF(0x45, 0x5089), 7311 {0} 7312 }; 7313 7314 static void alc256_fixup_set_coef_defaults(struct hda_codec *codec, 7315 const struct hda_fixup *fix, 7316 int action) 7317 { 7318 /* 7319 * A certain other OS sets these coeffs to different values. On at least 7320 * one TongFang barebone these settings might survive even a cold 7321 * reboot. So to restore a clean slate the values are explicitly reset 7322 * to default here. Without this, the external microphone is always in a 7323 * plugged-in state, while the internal microphone is always in an 7324 * unplugged state, breaking the ability to use the internal microphone. 7325 */ 7326 alc_process_coef_fw(codec, alc256_fixup_set_coef_defaults_coefs); 7327 } 7328 7329 static const struct coef_fw alc233_fixup_no_audio_jack_coefs[] = { 7330 WRITE_COEF(0x1a, 0x9003), WRITE_COEF(0x1b, 0x0e2b), WRITE_COEF(0x37, 0xfe06), 7331 WRITE_COEF(0x38, 0x4981), WRITE_COEF(0x45, 0xd489), WRITE_COEF(0x46, 0x0074), 7332 WRITE_COEF(0x49, 0x0149), 7333 {0} 7334 }; 7335 7336 static void alc233_fixup_no_audio_jack(struct hda_codec *codec, 7337 const struct hda_fixup *fix, 7338 int action) 7339 { 7340 /* 7341 * The audio jack input and output is not detected on the ASRock NUC Box 7342 * 1100 series when cold booting without this fix. Warm rebooting from a 7343 * certain other OS makes the audio functional, as COEF settings are 7344 * preserved in this case. This fix sets these altered COEF values as 7345 * the default. 7346 */ 7347 alc_process_coef_fw(codec, alc233_fixup_no_audio_jack_coefs); 7348 } 7349 7350 static void alc256_fixup_mic_no_presence_and_resume(struct hda_codec *codec, 7351 const struct hda_fixup *fix, 7352 int action) 7353 { 7354 /* 7355 * The Clevo NJ51CU comes either with the ALC293 or the ALC256 codec, 7356 * but uses the 0x8686 subproduct id in both cases. The ALC256 codec 7357 * needs an additional quirk for sound working after suspend and resume. 7358 */ 7359 if (codec->core.vendor_id == 0x10ec0256) { 7360 alc_update_coef_idx(codec, 0x10, 1<<9, 0); 7361 snd_hda_codec_set_pincfg(codec, 0x19, 0x04a11120); 7362 } else { 7363 snd_hda_codec_set_pincfg(codec, 0x1a, 0x04a1113c); 7364 } 7365 } 7145 7366 7146 7367 enum { … … 7230 7451 ALC280_FIXUP_HP_9480M, 7231 7452 ALC245_FIXUP_HP_X360_AMP, 7453 ALC285_FIXUP_HP_SPECTRE_X360_EB1, 7232 7454 ALC288_FIXUP_DELL_HEADSET_MODE, 7233 7455 ALC288_FIXUP_DELL1_MIC_NO_PRESENCE, … … 7256 7478 ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, 7257 7479 ALC269_FIXUP_ATIV_BOOK_8, 7480 ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE, 7258 7481 ALC221_FIXUP_HP_MIC_NO_PRESENCE, 7259 7482 ALC256_FIXUP_ASUS_HEADSET_MODE, … … 7317 7540 ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF, 7318 7541 ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, 7542 ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, 7319 7543 ALC295_FIXUP_ASUS_MIC_NO_PRESENCE, 7320 7544 ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS, … … 7342 7566 ALC287_FIXUP_HP_GPIO_LED, 7343 7567 ALC256_FIXUP_HP_HEADSET_MIC, 7568 ALC245_FIXUP_HP_GPIO_LED, 7344 7569 ALC236_FIXUP_DELL_AIO_HEADSET_MIC, 7345 7570 ALC282_FIXUP_ACER_DISABLE_LINEOUT, … … 7355 7580 ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, 7356 7581 ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST, 7357 }; 7582 ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS, 7583 ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE, 7584 ALC287_FIXUP_YOGA7_14ITL_SPEAKERS, 7585 ALC298_FIXUP_LENOVO_C940_DUET7, 7586 ALC287_FIXUP_13S_GEN2_SPEAKERS, 7587 ALC256_FIXUP_SET_COEF_DEFAULTS, 7588 ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE, 7589 ALC233_FIXUP_NO_AUDIO_JACK, 7590 ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME, 7591 ALC285_FIXUP_LEGION_Y9000X_SPEAKERS, 7592 ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE, 7593 }; 7594 7595 #ifdef NOT_USED 7596 /* A special fixup for Lenovo C940 and Yoga Duet 7; 7597 * both have the very same PCI SSID, and we need to apply different fixups 7598 * depending on the codec ID 7599 */ 7600 static void alc298_fixup_lenovo_c940_duet7(struct hda_codec *codec, 7601 const struct hda_fixup *fix, 7602 int action) 7603 { 7604 int id; 7605 7606 if (codec->core.vendor_id == 0x10ec0298) 7607 id = ALC298_FIXUP_LENOVO_SPK_VOLUME; /* C940 */ 7608 else 7609 id = ALC287_FIXUP_YOGA7_14ITL_SPEAKERS; /* Duet 7 */ 7610 __snd_hda_apply_fixup(codec, id, action, 0); 7611 } 7612 #endif 7358 7613 7359 7614 #ifdef TARGET_OS2 … … 8248 8503 .type = HDA_FIXUP_FUNC, 8249 8504 .v.func = alc245_fixup_hp_x360_amp, 8505 .chained = true, 8506 .chain_id = ALC245_FIXUP_HP_GPIO_LED 8250 8507 }, 8251 8508 [ALC288_FIXUP_DELL_HEADSET_MODE] = { … … 8449 8706 }, 8450 8707 #ifdef TARGET_OS2xxx 8708 [ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE] = { 8709 .type = HDA_FIXUP_PINS, 8710 .v.pins = (const struct hda_pintbl[]) { 8711 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 8712 { 0x1a, 0x01813030 }, /* use as headphone mic, without its own jack detect */ 8713 { } 8714 }, 8715 .chained = true, 8716 .chain_id = ALC269_FIXUP_HEADSET_MODE 8717 }, 8451 8718 [ALC221_FIXUP_HP_MIC_NO_PRESENCE] = { 8452 8719 .type = HDA_FIXUP_PINS, … … 8948 9215 }, 8949 9216 }, 9217 [ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = { 9218 .type = HDA_FIXUP_VERBS, 9219 .v.verbs = (const struct hda_verb[]) { 9220 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08}, 9221 { 0x20, AC_VERB_SET_PROC_COEF, 0x2fcf}, 9222 { } 9223 }, 9224 }, 8950 9225 [ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = { 8951 9226 .type = HDA_FIXUP_PINS, … … 9227 9502 .v.func = alc285_fixup_hp_spectre_x360, 9228 9503 }, 9504 [ALC285_FIXUP_HP_SPECTRE_X360_EB1] = { 9505 .type = HDA_FIXUP_FUNC, 9506 .v.func = alc285_fixup_hp_spectre_x360_eb1 9507 }, 9229 9508 [ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = { 9230 9509 .type = HDA_FIXUP_FUNC, … … 9255 9534 .chained = true, 9256 9535 .chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF, 9536 }, 9537 [ALC285_FIXUP_LEGION_Y9000X_SPEAKERS] = { 9538 .type = HDA_FIXUP_FUNC, 9539 .v.func = alc285_fixup_ideapad_s740_coef, 9540 .chained = true, 9541 .chain_id = ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE, 9542 }, 9543 [ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE] = { 9544 .type = HDA_FIXUP_FUNC, 9545 .v.func = alc287_fixup_legion_15imhg05_speakers, 9546 .chained = true, 9547 .chain_id = ALC269_FIXUP_THINKPAD_ACPI, 9548 }, 9549 #ifdef TARGET_OS2xxx 9550 [ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = { 9551 .type = HDA_FIXUP_VERBS, 9552 //.v.verbs = legion_15imhg05_coefs, 9553 .v.verbs = (const struct hda_verb[]) { 9554 // set left speaker Legion 7i. 9555 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 9556 { 0x20, AC_VERB_SET_PROC_COEF, 0x41 }, 9557 9558 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 9559 { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, 9560 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9561 { 0x20, AC_VERB_SET_PROC_COEF, 0x1a }, 9562 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 9563 9564 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 9565 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 9566 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9567 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9568 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 9569 9570 // set right speaker Legion 7i. 9571 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 9572 { 0x20, AC_VERB_SET_PROC_COEF, 0x42 }, 9573 9574 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 9575 { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, 9576 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9577 { 0x20, AC_VERB_SET_PROC_COEF, 0x2a }, 9578 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 9579 9580 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 9581 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 9582 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9583 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9584 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 9585 {} 9586 }, 9587 .chained = true, 9588 .chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE, 9589 }, 9590 #endif 9591 [ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = { 9592 .type = HDA_FIXUP_FUNC, 9593 .v.func = alc287_fixup_legion_15imhg05_speakers, 9594 .chained = true, 9595 .chain_id = ALC269_FIXUP_HEADSET_MODE, 9596 }, 9597 #ifdef TARGET_OS2xxx 9598 [ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = { 9599 .type = HDA_FIXUP_VERBS, 9600 .v.verbs = (const struct hda_verb[]) { 9601 // set left speaker Yoga 7i. 9602 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 9603 { 0x20, AC_VERB_SET_PROC_COEF, 0x41 }, 9604 9605 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 9606 { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, 9607 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9608 { 0x20, AC_VERB_SET_PROC_COEF, 0x1a }, 9609 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 9610 9611 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 9612 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 9613 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9614 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9615 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 9616 9617 // set right speaker Yoga 7i. 9618 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 9619 { 0x20, AC_VERB_SET_PROC_COEF, 0x46 }, 9620 9621 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 9622 { 0x20, AC_VERB_SET_PROC_COEF, 0xc }, 9623 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9624 { 0x20, AC_VERB_SET_PROC_COEF, 0x2a }, 9625 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 9626 9627 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 9628 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 9629 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9630 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9631 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 9632 {} 9633 }, 9634 .chained = true, 9635 .chain_id = ALC269_FIXUP_HEADSET_MODE, 9636 }, 9637 [ALC298_FIXUP_LENOVO_C940_DUET7] = { 9638 .type = HDA_FIXUP_FUNC, 9639 .v.func = alc298_fixup_lenovo_c940_duet7, 9640 }, 9641 [ALC287_FIXUP_13S_GEN2_SPEAKERS] = { 9642 .type = HDA_FIXUP_VERBS, 9643 .v.verbs = (const struct hda_verb[]) { 9644 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 9645 { 0x20, AC_VERB_SET_PROC_COEF, 0x41 }, 9646 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 9647 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 9648 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9649 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9650 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 9651 { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 }, 9652 { 0x20, AC_VERB_SET_PROC_COEF, 0x42 }, 9653 { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 }, 9654 { 0x20, AC_VERB_SET_PROC_COEF, 0x2 }, 9655 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9656 { 0x20, AC_VERB_SET_PROC_COEF, 0x0 }, 9657 { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 }, 9658 {} 9659 }, 9660 .chained = true, 9661 .chain_id = ALC269_FIXUP_HEADSET_MODE, 9662 }, 9663 #endif 9664 [ALC256_FIXUP_SET_COEF_DEFAULTS] = { 9665 .type = HDA_FIXUP_FUNC, 9666 .v.func = alc256_fixup_set_coef_defaults, 9667 }, 9668 #ifdef TARGET_OS2xxx 9669 [ALC245_FIXUP_HP_GPIO_LED] = { 9670 .type = HDA_FIXUP_FUNC, 9671 .v.func = alc245_fixup_hp_gpio_led, 9672 }, 9673 [ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = { 9674 .type = HDA_FIXUP_PINS, 9675 .v.pins = (const struct hda_pintbl[]) { 9676 { 0x19, 0x03a11120 }, /* use as headset mic, without its own jack detect */ 9677 { } 9678 }, 9679 .chained = true, 9680 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, 9681 }, 9682 #endif 9683 [ALC233_FIXUP_NO_AUDIO_JACK] = { 9684 .type = HDA_FIXUP_FUNC, 9685 .v.func = alc233_fixup_no_audio_jack, 9686 }, 9687 [ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME] = { 9688 .type = HDA_FIXUP_FUNC, 9689 .v.func = alc256_fixup_mic_no_presence_and_resume, 9690 .chained = true, 9691 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC 9257 9692 }, 9258 9693 }; … … 9288 9723 SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), 9289 9724 SND_PCI_QUIRK(0x1025, 0x129c, "Acer SWIFT SF314-55", ALC256_FIXUP_ACER_HEADSET_MIC), 9725 SND_PCI_QUIRK(0x1025, 0x129d, "Acer SWIFT SF313-51", ALC256_FIXUP_ACER_MIC_NO_PRESENCE), 9290 9726 SND_PCI_QUIRK(0x1025, 0x1300, "Acer SWIFT SF314-56", ALC256_FIXUP_ACER_MIC_NO_PRESENCE), 9291 9727 SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), 9292 9728 SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC), 9293 9729 SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC), 9730 SND_PCI_QUIRK(0x1025, 0x141f, "Acer Spin SP513-54N", ALC255_FIXUP_ACER_MIC_NO_PRESENCE), 9294 9731 SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE), 9295 9732 SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE), 9296 9733 SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC), 9297 9734 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), 9735 SND_PCI_QUIRK(0x1028, 0x053c, "Dell Latitude E5430", ALC292_FIXUP_DELL_E7X), 9298 9736 SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS), 9299 9737 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X), … … 9347 9785 SND_PCI_QUIRK(0x1028, 0x0a58, "Dell", ALC255_FIXUP_DELL_HEADSET_MIC), 9348 9786 SND_PCI_QUIRK(0x1028, 0x0a61, "Dell XPS 15 9510", ALC289_FIXUP_DUAL_SPK), 9787 SND_PCI_QUIRK(0x1028, 0x0a62, "Dell Precision 5560", ALC289_FIXUP_DUAL_SPK), 9788 SND_PCI_QUIRK(0x1028, 0x0a9d, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE), 9789 SND_PCI_QUIRK(0x1028, 0x0a9e, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE), 9790 SND_PCI_QUIRK(0x1028, 0x0b19, "Dell XPS 15 9520", ALC289_FIXUP_DUAL_SPK), 9349 9791 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 9350 9792 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), … … 9406 9848 SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 9407 9849 SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 9850 SND_PCI_QUIRK(0x103c, 0x2b5e, "HP 288 Pro G2 MT", ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE), 9408 9851 SND_PCI_QUIRK(0x103c, 0x802e, "HP Z240 SFF", ALC221_FIXUP_HP_MIC_NO_PRESENCE), 9409 9852 SND_PCI_QUIRK(0x103c, 0x802f, "HP Z240", ALC221_FIXUP_HP_MIC_NO_PRESENCE), … … 9422 9865 SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3), 9423 9866 SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360), 9867 SND_PCI_QUIRK(0x103c, 0x860f, "HP ZBook 15 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT), 9424 9868 SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT), 9425 9869 SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED), … … 9428 9872 SND_PCI_QUIRK(0x103c, 0x8720, "HP EliteBook x360 1040 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), 9429 9873 SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED), 9874 SND_PCI_QUIRK(0x103c, 0x8728, "HP EliteBook 840 G7", ALC285_FIXUP_HP_GPIO_LED), 9430 9875 SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED), 9431 9876 SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), 9877 SND_PCI_QUIRK(0x103c, 0x8735, "HP ProBook 435 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), 9432 9878 SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT), 9433 9879 SND_PCI_QUIRK(0x103c, 0x8760, "HP", ALC285_FIXUP_HP_MUTE_LED), … … 9438 9884 SND_PCI_QUIRK(0x103c, 0x8783, "HP ZBook Fury 15 G7 Mobile Workstation", 9439 9885 ALC285_FIXUP_HP_GPIO_AMP_INIT), 9886 SND_PCI_QUIRK(0x103c, 0x8787, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED), 9887 SND_PCI_QUIRK(0x103c, 0x8788, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED), 9440 9888 SND_PCI_QUIRK(0x103c, 0x87c8, "HP", ALC287_FIXUP_HP_GPIO_LED), 9441 9889 SND_PCI_QUIRK(0x103c, 0x87e5, "HP ProBook 440 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED), … … 9449 9897 SND_PCI_QUIRK(0x103c, 0x8805, "HP ProBook 650 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED), 9450 9898 SND_PCI_QUIRK(0x103c, 0x880d, "HP EliteBook 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), 9899 SND_PCI_QUIRK(0x103c, 0x8811, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1), 9900 SND_PCI_QUIRK(0x103c, 0x8812, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1), 9451 9901 SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), 9452 9902 SND_PCI_QUIRK(0x103c, 0x8847, "HP EliteBook x360 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), … … 9462 9912 SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST), 9463 9913 SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED), 9914 SND_PCI_QUIRK(0x103c, 0x89aa, "HP EliteBook 630 G9", ALC236_FIXUP_HP_GPIO_LED), 9915 SND_PCI_QUIRK(0x103c, 0x89c3, "HP", ALC285_FIXUP_HP_GPIO_LED), 9916 SND_PCI_QUIRK(0x103c, 0x89ca, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), 9917 SND_PCI_QUIRK(0x103c, 0x8a78, "HP Dev One", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST), 9918 SND_PCI_QUIRK(0x103c, 0x8aa0, "HP ProBook 440 G9 (MB 8A9E)", ALC236_FIXUP_HP_GPIO_LED), 9919 SND_PCI_QUIRK(0x103c, 0x8aa3, "HP ProBook 450 G9 (MB 8AA1)", ALC236_FIXUP_HP_GPIO_LED), 9920 SND_PCI_QUIRK(0x103c, 0x8aa8, "HP EliteBook 640 G9 (MB 8AA6)", ALC236_FIXUP_HP_GPIO_LED), 9921 SND_PCI_QUIRK(0x103c, 0x8aab, "HP EliteBook 650 G9 (MB 8AA9)", ALC236_FIXUP_HP_GPIO_LED), 9464 9922 SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC), 9465 9923 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), … … 9487 9945 SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC), 9488 9946 SND_PCI_QUIRK(0x1043, 0x194e, "ASUS UX563FD", ALC294_FIXUP_ASUS_HPE), 9947 SND_PCI_QUIRK(0x1043, 0x1970, "ASUS UX550VE", ALC289_FIXUP_ASUS_GA401), 9489 9948 SND_PCI_QUIRK(0x1043, 0x1982, "ASUS B1400CEPE", ALC256_FIXUP_ASUS_HPE), 9490 9949 SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE), … … 9502 9961 SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401), 9503 9962 SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401), 9963 SND_PCI_QUIRK(0x1043, 0x1d42, "ASUS Zephyrus G14 2022", ALC289_FIXUP_ASUS_GA401), 9964 SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401), 9504 9965 SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2), 9505 9966 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), … … 9534 9995 SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET), 9535 9996 SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET), 9997 SND_PCI_QUIRK(0x144d, 0xc832, "Samsung Galaxy Book Flex Alpha (NP730QCJ)", ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET), 9536 9998 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC), 9537 9999 SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC), … … 9550 10012 SND_PCI_QUIRK(0x1558, 0x40c1, "Clevo NL40[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9551 10013 SND_PCI_QUIRK(0x1558, 0x40d1, "Clevo NL41DU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 10014 SND_PCI_QUIRK(0x1558, 0x5015, "Clevo NH5[58]H[HJK]Q", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 10015 SND_PCI_QUIRK(0x1558, 0x5017, "Clevo NH7[79]H[HJK]Q", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9552 10016 SND_PCI_QUIRK(0x1558, 0x50a3, "Clevo NJ51GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9553 10017 SND_PCI_QUIRK(0x1558, 0x50b3, "Clevo NK50S[BEZ]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), … … 9555 10019 SND_PCI_QUIRK(0x1558, 0x50b8, "Clevo NK50SZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9556 10020 SND_PCI_QUIRK(0x1558, 0x50d5, "Clevo NP50D5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 10021 SND_PCI_QUIRK(0x1558, 0x50e1, "Clevo NH5[58]HPQ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 10022 SND_PCI_QUIRK(0x1558, 0x50e2, "Clevo NH7[79]HPQ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9557 10023 SND_PCI_QUIRK(0x1558, 0x50f0, "Clevo NH50A[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9558 10024 SND_PCI_QUIRK(0x1558, 0x50f2, "Clevo NH50E[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), … … 9569 10035 SND_PCI_QUIRK(0x1558, 0x70f4, "Clevo NH77EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9570 10036 SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 10037 SND_PCI_QUIRK(0x1558, 0x7716, "Clevo NS50PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 10038 SND_PCI_QUIRK(0x1558, 0x7718, "Clevo L140PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9571 10039 SND_PCI_QUIRK(0x1558, 0x8228, "Clevo NR40BU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9572 10040 SND_PCI_QUIRK(0x1558, 0x8520, "Clevo NH50D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), … … 9580 10048 SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[57][0-9]RZ[Q]", ALC269_FIXUP_DMIC), 9581 10049 SND_PCI_QUIRK(0x1558, 0x8668, "Clevo NP50B[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 10050 SND_PCI_QUIRK(0x1558, 0x866d, "Clevo NP5[05]PN[HJK]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 10051 SND_PCI_QUIRK(0x1558, 0x867c, "Clevo NP7[01]PNP", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 10052 SND_PCI_QUIRK(0x1558, 0x867d, "Clevo NP7[01]PN[HJK]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9582 10053 SND_PCI_QUIRK(0x1558, 0x8680, "Clevo NJ50LU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9583 SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC2 93_FIXUP_SYSTEM76_MIC_NO_PRESENCE),10054 SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME), 9584 10055 SND_PCI_QUIRK(0x1558, 0x8a20, "Clevo NH55DCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), 9585 10056 SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), … … 9647 10118 SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC), 9648 10119 SND_PCI_QUIRK(0x17aa, 0x31af, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340), 9649 SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME), 10120 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo Yoga DuetITL 2021", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 10121 SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS), 10122 SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940 / Yoga Duet 7", ALC298_FIXUP_LENOVO_C940_DUET7), 10123 SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS), 10124 SND_PCI_QUIRK(0x17aa, 0x3820, "Yoga Duet 7 13ITL6", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 10125 SND_PCI_QUIRK(0x17aa, 0x3824, "Legion Y9000X 2020", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS), 9650 10126 SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF), 10127 SND_PCI_QUIRK(0x17aa, 0x3834, "Lenovo IdeaPad Slim 9i 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 10128 SND_PCI_QUIRK(0x17aa, 0x383d, "Legion Y9000X 2019", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS), 9651 10129 SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP), 10130 SND_PCI_QUIRK(0x17aa, 0x384a, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 10131 SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 10132 SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 9652 10133 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), 9653 10134 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), … … 9669 10150 SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), 9670 10151 SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), 10152 SND_PCI_QUIRK(0x17aa, 0x508b, "Thinkpad X12 Gen 1", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS), 9671 10153 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 9672 10154 SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), 9673 10155 SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK), 9674 10156 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), 10157 SND_PCI_QUIRK(0x1849, 0x1233, "ASRock NUC Box 1100", ALC233_FIXUP_NO_AUDIO_JACK), 9675 10158 SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS), 9676 10159 SND_PCI_QUIRK(0x1b35, 0x1235, "CZC B20", ALC269_FIXUP_CZC_B20), … … 9680 10163 SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802), 9681 10164 SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X), 10165 SND_PCI_QUIRK(0x1d05, 0x1132, "TongFang PHxTxX1", ALC256_FIXUP_SET_COEF_DEFAULTS), 10166 SND_PCI_QUIRK(0x1d05, 0x1096, "TongFang GMxMRxx", ALC269_FIXUP_NO_SHUTUP), 10167 SND_PCI_QUIRK(0x1d05, 0x1100, "TongFang GKxNRxx", ALC269_FIXUP_NO_SHUTUP), 10168 SND_PCI_QUIRK(0x1d05, 0x1111, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP), 10169 SND_PCI_QUIRK(0x1d05, 0x1119, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP), 10170 SND_PCI_QUIRK(0x1d05, 0x1129, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP), 10171 SND_PCI_QUIRK(0x1d05, 0x1147, "TongFang GMxTGxx", ALC269_FIXUP_NO_SHUTUP), 10172 SND_PCI_QUIRK(0x1d05, 0x115c, "TongFang GMxTGxx", ALC269_FIXUP_NO_SHUTUP), 10173 SND_PCI_QUIRK(0x1d05, 0x121b, "TongFang GMxAGxx", ALC269_FIXUP_NO_SHUTUP), 9682 10174 SND_PCI_QUIRK(0x1d72, 0x1602, "RedmiBook", ALC255_FIXUP_XIAOMI_HEADSET_MIC), 9683 10175 SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE), 9684 10176 SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC), 10177 SND_PCI_QUIRK(0x1d72, 0x1945, "Redmi G", ALC256_FIXUP_ASUS_HEADSET_MIC), 9685 10178 SND_PCI_QUIRK(0x1d72, 0x1947, "RedmiBook Air", ALC255_FIXUP_XIAOMI_HEADSET_MIC), 9686 10179 SND_PCI_QUIRK(0x8086, 0x2074, "Intel NUC 8", ALC233_FIXUP_INTEL_NUC8_DMIC), … … 9860 10353 {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"}, 9861 10354 {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"}, 10355 {.id = ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc256-samsung-headphone"}, 9862 10356 {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"}, 9863 10357 {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"}, … … 9865 10359 {.id = ALC295_FIXUP_HP_OMEN, .name = "alc295-hp-omen"}, 9866 10360 {.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"}, 10361 {.id = ALC285_FIXUP_HP_SPECTRE_X360_EB1, .name = "alc285-hp-spectre-x360-eb1"}, 9867 10362 {.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"}, 9868 10363 {.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"}, 9869 10364 {.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"}, 10365 {.id = ALC285_FIXUP_HP_GPIO_AMP_INIT, .name = "alc285-hp-amp-init"}, 9870 10366 {0} 9871 10367 }; … … 10463 10959 case 0x10ec0236: 10464 10960 case 0x10ec0256: 10961 case 0x19e58326: 10465 10962 spec->codec_variant = ALC269_TYPE_ALC256; 10466 10963 spec->shutup = alc256_shutup; … … 10478 10975 case 0x10ec0285: 10479 10976 case 0x10ec0289: 10480 spec->codec_variant = ALC269_TYPE_ALC215; 10977 if (alc_get_coef0(codec) & 0x0010) 10978 spec->codec_variant = ALC269_TYPE_ALC245; 10979 else 10980 spec->codec_variant = ALC269_TYPE_ALC215; 10481 10981 spec->shutup = alc225_shutup; 10482 10982 spec->init_hook = alc225_init; … … 11020 11520 alc_write_coef_idx(codec, 0x19, 0xa054); 11021 11521 break; 11522 } 11523 } 11524 11525 static void alc897_hp_automute_hook(struct hda_codec *codec, 11526 struct hda_jack_callback *jack) 11527 { 11528 struct alc_spec *spec = codec->spec; 11529 int vref; 11530 11531 snd_hda_gen_hp_automute(codec, jack); 11532 vref = spec->gen.hp_jack_present ? (PIN_HP | AC_PINCTL_VREF_100) : PIN_HP; 11533 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 11534 vref); 11535 } 11536 11537 static void alc897_fixup_lenovo_headset_mic(struct hda_codec *codec, 11538 const struct hda_fixup *fix, int action) 11539 { 11540 struct alc_spec *spec = codec->spec; 11541 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 11542 spec->gen.hp_automute_hook = alc897_hp_automute_hook; 11022 11543 } 11023 11544 } … … 11100 11621 ALC662_FIXUP_ACER_X2660G_HEADSET_MODE, 11101 11622 ALC662_FIXUP_ACER_NITRO_HEADSET_MODE, 11623 ALC668_FIXUP_ASUS_NO_HEADSET_MIC, 11624 ALC668_FIXUP_HEADSET_MIC, 11625 ALC668_FIXUP_MIC_DET_COEF, 11626 ALC897_FIXUP_LENOVO_HEADSET_MIC, 11627 ALC897_FIXUP_HEADSET_MIC_PIN, 11628 ALC897_FIXUP_HP_HSMIC_VERB, 11102 11629 }; 11103 11630 … … 11666 12193 .chained = true, 11667 12194 .chain_id = ALC662_FIXUP_USI_FUNC 12195 }, 12196 [ALC668_FIXUP_ASUS_NO_HEADSET_MIC] = { 12197 .type = HDA_FIXUP_PINS, 12198 .v.pins = (const struct hda_pintbl[]) { 12199 { 0x1b, 0x04a1112c }, 12200 { } 12201 }, 12202 .chained = true, 12203 .chain_id = ALC668_FIXUP_HEADSET_MIC 12204 }, 12205 #endif 12206 [ALC668_FIXUP_HEADSET_MIC] = { 12207 .type = HDA_FIXUP_FUNC, 12208 .v.func = alc269_fixup_headset_mic, 12209 .chained = true, 12210 .chain_id = ALC668_FIXUP_MIC_DET_COEF 12211 }, 12212 #ifdef TARGET_OS2xxx 12213 [ALC668_FIXUP_MIC_DET_COEF] = { 12214 .type = HDA_FIXUP_VERBS, 12215 .v.verbs = (const struct hda_verb[]) { 12216 { 0x20, AC_VERB_SET_COEF_INDEX, 0x15 }, 12217 { 0x20, AC_VERB_SET_PROC_COEF, 0x0d60 }, 12218 {} 12219 }, 12220 }, 12221 #endif 12222 [ALC897_FIXUP_LENOVO_HEADSET_MIC] = { 12223 .type = HDA_FIXUP_FUNC, 12224 .v.func = alc897_fixup_lenovo_headset_mic, 12225 }, 12226 #ifdef TARGET_OS2xxx 12227 [ALC897_FIXUP_HEADSET_MIC_PIN] = { 12228 .type = HDA_FIXUP_PINS, 12229 .v.pins = (const struct hda_pintbl[]) { 12230 { 0x1a, 0x03a11050 }, 12231 { } 12232 }, 12233 .chained = true, 12234 .chain_id = ALC897_FIXUP_LENOVO_HEADSET_MIC 12235 }, 12236 [ALC897_FIXUP_HP_HSMIC_VERB] = { 12237 .type = HDA_FIXUP_PINS, 12238 .v.pins = (const struct hda_pintbl[]) { 12239 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 12240 { } 12241 }, 11668 12242 }, 11669 12243 #endif … … 11693 12267 SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 11694 12268 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), 12269 SND_PCI_QUIRK(0x103c, 0x8719, "HP", ALC897_FIXUP_HP_HSMIC_VERB), 11695 12270 SND_PCI_QUIRK(0x103c, 0x873e, "HP", ALC671_FIXUP_HP_HEADSET_MIC2), 12271 SND_PCI_QUIRK(0x103c, 0x877e, "HP 288 Pro G6", ALC671_FIXUP_HP_HEADSET_MIC2), 12272 SND_PCI_QUIRK(0x103c, 0x885f, "HP 288 Pro G8", ALC671_FIXUP_HP_HEADSET_MIC2), 11696 12273 SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE), 11697 12274 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50), … … 11703 12280 SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51), 11704 12281 SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51), 12282 SND_PCI_QUIRK(0x1043, 0x185d, "ASUS G551JW", ALC668_FIXUP_ASUS_NO_HEADSET_MIC), 11705 12283 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8), 11706 12284 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16), … … 11711 12289 SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE), 11712 12290 SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS), 12291 SND_PCI_QUIRK(0x17aa, 0x1057, "Lenovo P360", ALC897_FIXUP_HEADSET_MIC_PIN), 12292 SND_PCI_QUIRK(0x17aa, 0x32ca, "Lenovo ThinkCentre M80", ALC897_FIXUP_HEADSET_MIC_PIN), 12293 SND_PCI_QUIRK(0x17aa, 0x32cb, "Lenovo ThinkCentre M70", ALC897_FIXUP_HEADSET_MIC_PIN), 12294 SND_PCI_QUIRK(0x17aa, 0x32cf, "Lenovo ThinkCentre M950", ALC897_FIXUP_HEADSET_MIC_PIN), 12295 SND_PCI_QUIRK(0x17aa, 0x32f7, "Lenovo ThinkCentre M90", ALC897_FIXUP_HEADSET_MIC_PIN), 11713 12296 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), 11714 12297 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), … … 12069 12652 HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882), 12070 12653 HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882), 12654 HDA_CODEC_ENTRY(0x19e58326, "HW8326", patch_alc269), 12071 12655 {0} /* terminator */ 12072 12656 }; -
GPL/trunk/alsa-kernel/pci/hda/patch_sigmatel.c
r695 r717 4482 4482 } 4483 4483 4484 static void stac_shutup(struct hda_codec *codec)4485 {4486 struct sigmatel_spec *spec = codec->spec;4487 4488 snd_hda_shutup_pins(codec);4489 4490 if (spec->eapd_mask)4491 stac_gpio_set(codec, spec->gpio_mask,4492 spec->gpio_dir, spec->gpio_data &4493 ~spec->eapd_mask);4494 }4495 4496 4484 #define stac_free snd_hda_gen_free 4497 4485 … … 4546 4534 static int stac_suspend(struct hda_codec *codec) 4547 4535 { 4548 stac_shutup(codec); 4536 struct sigmatel_spec *spec = codec->spec; 4537 4538 snd_hda_shutup_pins(codec); 4539 4540 if (spec->eapd_mask) 4541 stac_gpio_set(codec, spec->gpio_mask, 4542 spec->gpio_dir, spec->gpio_data & 4543 ~spec->eapd_mask); 4544 4549 4545 return 0; 4550 4546 } … … 4562 4558 .suspend = stac_suspend, 4563 4559 #endif 4564 .reboot_notify = stac_shutup,4565 4560 }; 4566 4561 -
GPL/trunk/alsa-kernel/pci/hda/patch_via.c
r703 r717 529 529 return err; 530 530 531 err = auto_parse_beep(codec); 532 if (err < 0) 533 return err; 534 531 535 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); 532 if (err < 0)533 return err;534 535 err = auto_parse_beep(codec);536 536 if (err < 0) 537 537 return err; -
GPL/trunk/alsa-kernel/pci/intel8x0.c
r703 r717 382 382 383 383 u32 bdbars_count; 384 struct snd_dma_buffer bdbars;384 struct snd_dma_buffer *bdbars; 385 385 u32 int_sta_reg; /* interrupt status register */ 386 386 u32 int_sta_mask; /* interrupt status mask */ … … 1431 1431 1432 1432 #define intel8x0_dma_type(chip) \ 1433 ((chip)->fix_nocache ? SNDRV_DMA_TYPE_DEV_ UC : SNDRV_DMA_TYPE_DEV)1433 ((chip)->fix_nocache ? SNDRV_DMA_TYPE_DEV_WC : SNDRV_DMA_TYPE_DEV) 1434 1434 1435 1435 static int snd_intel8x0_pcm1(struct intel8x0 *chip, int device, … … 2534 2534 } 2535 2535 2536 static int snd_intel8x0_free(struct intel8x0 *chip) 2537 { 2536 static void snd_intel8x0_free(struct snd_card *card) 2537 { 2538 struct intel8x0 *chip = card->private_data; 2538 2539 unsigned int i; 2539 2540 … … 2558 2559 if (chip->irq >= 0) 2559 2560 free_irq(chip->irq, chip); 2560 if (chip->bdbars.area)2561 snd_dma_free_pages(&chip->bdbars);2562 if (chip->addr)2563 pci_iounmap(chip->pci, chip->addr);2564 if (chip->bmaddr)2565 pci_iounmap(chip->pci, chip->bmaddr);2566 pci_release_regions(chip->pci);2567 pci_disable_device(chip->pci);2568 kfree(chip);2569 return 0;2570 2561 } 2571 2562 … … 2666 2657 if (chip->ac97_bus->clock != 48000) 2667 2658 return; /* specified in module option */ 2659 if (chip->inside_vm && !ac97_clock) 2660 return; /* no measurement on VM */ 2668 2661 2669 2662 __again: … … 2854 2847 } 2855 2848 2856 static int snd_intel8x0_dev_free(struct snd_device *device)2857 {2858 struct intel8x0 *chip = device->device_data;2859 return snd_intel8x0_free(chip);2860 }2861 2862 2849 struct ich_reg_info { 2863 2850 unsigned int int_sta_mask; … … 2903 2890 } 2904 2891 2905 static int snd_intel8x0_create(struct snd_card *card, 2906 struct pci_dev *pci, 2907 unsigned long device_type, 2908 struct intel8x0 **r_intel8x0) 2909 { 2910 struct intel8x0 *chip; 2892 static int snd_intel8x0_init(struct snd_card *card, 2893 struct pci_dev *pci, 2894 unsigned long device_type) 2895 { 2896 struct intel8x0 *chip = card->private_data; 2911 2897 int err; 2912 2898 unsigned int i; 2913 2899 unsigned int int_sta_masks; 2914 2900 struct ichdev *ichdev; 2915 static const struct snd_device_ops ops = {2916 .dev_free = snd_intel8x0_dev_free,2917 };2918 2901 2919 2902 static const unsigned int bdbars[] = { … … 2948 2931 const struct ich_reg_info *tbl; 2949 2932 2950 *r_intel8x0 = NULL; 2951 2952 err = pci_enable_device(pci); 2933 err = pcim_enable_device(pci); 2953 2934 if (err < 0) 2954 2935 return err; 2955 2936 2956 chip = kzalloc(sizeof(*chip), GFP_KERNEL);2957 if (chip == NULL) {2958 pci_disable_device(pci);2959 return -ENOMEM;2960 }2961 2937 spin_lock_init(&chip->reg_lock); 2962 2938 chip->device_type = device_type; … … 2984 2960 2985 2961 err = pci_request_regions(pci, card->shortname); 2986 if (err < 0) { 2987 kfree(chip); 2988 pci_disable_device(pci); 2962 if (err < 0) 2989 2963 return err; 2990 }2991 2964 2992 2965 if (device_type == DEVICE_ALI) { 2993 2966 /* ALI5455 has no ac97 region */ 2994 chip->bmaddr = pci_iomap(pci, 0, 0); 2995 goto port_inited; 2996 } 2997 2998 if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) /* ICH4 and Nforce */ 2999 chip->addr = pci_iomap(pci, 2, 0); 3000 else 3001 chip->addr = pci_iomap(pci, 0, 0); 3002 if (!chip->addr) { 3003 dev_err(card->dev, "AC'97 space ioremap problem\n"); 3004 snd_intel8x0_free(chip); 3005 return -EIO; 3006 } 3007 if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) /* ICH4 */ 3008 chip->bmaddr = pci_iomap(pci, 3, 0); 3009 else 3010 chip->bmaddr = pci_iomap(pci, 1, 0); 3011 3012 port_inited: 3013 if (!chip->bmaddr) { 3014 dev_err(card->dev, "Controller space ioremap problem\n"); 3015 snd_intel8x0_free(chip); 3016 return -EIO; 3017 } 2967 chip->bmaddr = pcim_iomap(pci, 0, 0); 2968 } else { 2969 if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) /* ICH4 and Nforce */ 2970 chip->addr = pcim_iomap(pci, 2, 0); 2971 else 2972 chip->addr = pcim_iomap(pci, 0, 0); 2973 if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) /* ICH4 */ 2974 chip->bmaddr = pcim_iomap(pci, 3, 0); 2975 else 2976 chip->bmaddr = pcim_iomap(pci, 1, 0); 2977 } 2978 3018 2979 chip->bdbars_count = bdbars[device_type]; 3019 2980 … … 3051 3012 /* allocate buffer descriptor lists */ 3052 3013 /* the start of each lists must be aligned to 8 bytes */ 3053 if (snd_dma_alloc_pages(intel8x0_dma_type(chip), &pci->dev, 3054 chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2, 3055 &chip->bdbars) < 0) { 3056 snd_intel8x0_free(chip); 3057 dev_err(card->dev, "cannot allocate buffer descriptors\n"); 3014 chip->bdbars = snd_devm_alloc_pages(&pci->dev, intel8x0_dma_type(chip), 3015 chip->bdbars_count * sizeof(u32) * 3016 ICH_MAX_FRAGS * 2); 3017 if (!chip->bdbars) 3058 3018 return -ENOMEM; 3059 }3060 3019 /* tables must be aligned to 8 bytes here, but the kernel pages 3061 3020 are much bigger, so we don't care (on i386) */ … … 3063 3022 for (i = 0; i < chip->bdbars_count; i++) { 3064 3023 ichdev = &chip->ichd[i]; 3065 ichdev->bdbar = ((__le32 *)chip->bdbars .area) +3024 ichdev->bdbar = ((__le32 *)chip->bdbars->area) + 3066 3025 (i * ICH_MAX_FRAGS * 2); 3067 ichdev->bdbar_addr = chip->bdbars .addr +3026 ichdev->bdbar_addr = chip->bdbars->addr + 3068 3027 (i * sizeof(u32) * ICH_MAX_FRAGS * 2); 3069 3028 int_sta_masks |= ichdev->int_sta_mask; … … 3099 3058 3100 3059 err = snd_intel8x0_chip_init(chip, 1); 3101 if (err < 0) { 3102 snd_intel8x0_free(chip); 3060 if (err < 0) 3103 3061 return err; 3104 }3105 3062 3106 3063 /* request irq after initializaing int_sta_mask, etc */ 3064 /* NOTE: we don't use devm version here since it's released / 3065 * re-acquired in PM callbacks. 3066 * It's released explicitly in snd_intel8x0_free(), too. 3067 */ 3107 3068 if (request_irq(pci->irq, snd_intel8x0_interrupt, 3108 3069 IRQF_SHARED, KBUILD_MODNAME, chip)) { 3109 3070 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 3110 snd_intel8x0_free(chip);3111 3071 return -EBUSY; 3112 3072 } … … 3114 3074 card->sync_irq = chip->irq; 3115 3075 3116 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 3117 if (err < 0) { 3118 snd_intel8x0_free(chip); 3119 return err; 3120 } 3121 3122 *r_intel8x0 = chip; 3076 card->private_free = snd_intel8x0_free; 3077 3123 3078 return 0; 3124 3079 } … … 3178 3133 } 3179 3134 3180 static int snd_intel8x0_probe(struct pci_dev *pci,3181 3135 static int __snd_intel8x0_probe(struct pci_dev *pci, 3136 const struct pci_device_id *pci_id) 3182 3137 { 3183 3138 struct snd_card *card; … … 3186 3141 struct shortname_table *name; 3187 3142 3188 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); 3143 err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE, 3144 sizeof(*chip), &card); 3189 3145 if (err < 0) 3190 3146 return err; 3147 chip = card->private_data; 3191 3148 3192 3149 if (spdif_aclink < 0) … … 3222 3179 } 3223 3180 3224 err = snd_intel8x0_create(card, pci, pci_id->driver_data, &chip); 3225 if (err < 0) { 3226 snd_card_free(card); 3181 err = snd_intel8x0_init(card, pci, pci_id->driver_data); 3182 if (err < 0) 3227 3183 return err; 3228 }3229 card->private_data = chip;3230 3184 3231 3185 err = snd_intel8x0_mixer(chip, ac97_clock, ac97_quirk); 3232 if (err < 0) { 3233 snd_card_free(card); 3186 if (err < 0) 3234 3187 return err; 3235 }3236 3188 err = snd_intel8x0_pcm(chip); 3237 if (err < 0) { 3238 snd_card_free(card); 3189 if (err < 0) 3239 3190 return err; 3240 }3241 3191 3242 3192 snd_intel8x0_proc_init(chip); … … 3256 3206 3257 3207 err = snd_card_register(card); 3258 if (err < 0) { 3259 snd_card_free(card); 3208 if (err < 0) 3260 3209 return err; 3261 } 3210 3262 3211 pci_set_drvdata(pci, card); 3263 3212 return 0; 3264 3213 } 3265 3214 3266 static void snd_intel8x0_remove(struct pci_dev *pci) 3267 { 3268 snd_card_free(pci_get_drvdata(pci)); 3215 static int snd_intel8x0_probe(struct pci_dev *pci, 3216 const struct pci_device_id *pci_id) 3217 { 3218 return snd_card_free_on_error(&pci->dev, __snd_intel8x0_probe(pci, pci_id)); 3269 3219 } 3270 3220 … … 3273 3223 .id_table = snd_intel8x0_ids, 3274 3224 .probe = snd_intel8x0_probe, 3275 .remove = snd_intel8x0_remove,3276 3225 .driver = { 3277 3226 .pm = INTEL8X0_PM_OPS, -
GPL/trunk/alsa-kernel/pci/korg1212/korg1212.c
r703 r717 321 321 void __iomem *iobase; 322 322 323 struct snd_dma_buffer dma_dsp;324 struct snd_dma_bufferdma_play;325 struct snd_dma_bufferdma_rec;326 struct snd_dma_buffer dma_shared;323 struct snd_dma_buffer *dma_dsp; 324 struct snd_dma_buffer *dma_play; 325 struct snd_dma_buffer *dma_rec; 326 struct snd_dma_buffer *dma_shared; 327 327 328 328 u32 DataBufsSize; … … 1201 1201 1202 1202 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload, 1203 UpperWordSwap(korg1212->dma_dsp.addr),1204 1203 UpperWordSwap(korg1212->dma_dsp->addr), 1204 0, 0, 0); 1205 1205 if (rc) 1206 1206 K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n", … … 1383 1383 1384 1384 runtime->hw = snd_korg1212_playback_info; 1385 snd_pcm_set_runtime_buffer(substream, &korg1212->dma_play);1385 snd_pcm_set_runtime_buffer(substream, korg1212->dma_play); 1386 1386 1387 1387 spin_lock_irqsave(&korg1212->lock, flags); … … 1414 1414 1415 1415 runtime->hw = snd_korg1212_capture_info; 1416 snd_pcm_set_runtime_buffer(substream, &korg1212->dma_rec);1416 snd_pcm_set_runtime_buffer(substream, korg1212->dma_rec); 1417 1417 1418 1418 spin_lock_irqsave(&korg1212->lock, flags); … … 2081 2081 } 2082 2082 2083 static int 2084 snd_korg1212_free(struct snd_korg1212 *korg1212) 2085 { 2086 snd_korg1212_TurnOffIdleMonitor(korg1212); 2087 2088 if (korg1212->irq >= 0) { 2089 snd_korg1212_DisableCardInterrupts(korg1212); 2090 free_irq(korg1212->irq, korg1212); 2091 korg1212->irq = -1; 2092 } 2093 2094 if (korg1212->iobase != NULL) { 2095 iounmap(korg1212->iobase); 2096 korg1212->iobase = NULL; 2097 } 2098 2099 pci_release_regions(korg1212->pci); 2100 2101 // ---------------------------------------------------- 2102 // free up memory resources used for the DSP download. 2103 // ---------------------------------------------------- 2104 if (korg1212->dma_dsp.area) { 2105 snd_dma_free_pages(&korg1212->dma_dsp); 2106 korg1212->dma_dsp.area = NULL; 2107 } 2108 2109 #ifndef K1212_LARGEALLOC 2110 2111 // ------------------------------------------------------ 2112 // free up memory resources used for the Play/Rec Buffers 2113 // ------------------------------------------------------ 2114 if (korg1212->dma_play.area) { 2115 snd_dma_free_pages(&korg1212->dma_play); 2116 korg1212->dma_play.area = NULL; 2117 } 2118 2119 if (korg1212->dma_rec.area) { 2120 snd_dma_free_pages(&korg1212->dma_rec); 2121 korg1212->dma_rec.area = NULL; 2122 } 2123 2124 #endif 2125 2126 // ---------------------------------------------------- 2127 // free up memory resources used for the Shared Buffers 2128 // ---------------------------------------------------- 2129 if (korg1212->dma_shared.area) { 2130 snd_dma_free_pages(&korg1212->dma_shared); 2131 korg1212->dma_shared.area = NULL; 2132 } 2133 2134 pci_disable_device(korg1212->pci); 2135 kfree(korg1212); 2136 return 0; 2137 } 2138 2139 static int snd_korg1212_dev_free(struct snd_device *device) 2140 { 2141 struct snd_korg1212 *korg1212 = device->device_data; 2142 K1212_DEBUG_PRINTK("K1212_DEBUG: Freeing device\n"); 2143 return snd_korg1212_free(korg1212); 2144 } 2145 2146 static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, 2147 struct snd_korg1212 **rchip) 2083 static void 2084 snd_korg1212_free(struct snd_card *card) 2085 { 2086 struct snd_korg1212 *korg1212 = card->private_data; 2087 2088 snd_korg1212_TurnOffIdleMonitor(korg1212); 2089 snd_korg1212_DisableCardInterrupts(korg1212); 2090 } 2091 2092 static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci) 2148 2093 2149 2094 { 2150 2095 int err, rc; 2151 2096 unsigned int i; 2152 unsigned iomem_size;2097 __maybe_unused unsigned iomem_size; 2153 2098 __maybe_unused unsigned ioport_size; 2154 2099 __maybe_unused unsigned iomem2_size; 2155 struct snd_korg1212 * korg1212;2100 struct snd_korg1212 *korg1212 = card->private_data; 2156 2101 const struct firmware *dsp_code; 2157 2102 2158 static const struct snd_device_ops ops = { 2159 .dev_free = snd_korg1212_dev_free, 2160 }; 2161 2162 * rchip = NULL; 2163 err = pci_enable_device(pci); 2103 err = pcim_enable_device(pci); 2164 2104 if (err < 0) 2165 2105 return err; 2166 2167 korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL);2168 if (korg1212 == NULL) {2169 pci_disable_device(pci);2170 return -ENOMEM;2171 }2172 2106 2173 2107 korg1212->card = card; … … 2199 2133 korg1212->volumePhase[i] = 0; 2200 2134 2201 err = pci_request_regions(pci, "korg1212"); 2202 if (err < 0) { 2203 kfree(korg1212); 2204 pci_disable_device(pci); 2135 err = pcim_iomap_regions_request_all(pci, 1 << 0, "korg1212"); 2136 if (err < 0) 2205 2137 return err; 2206 }2207 2138 2208 2139 korg1212->iomem = pci_resource_start(korg1212->pci, 0); … … 2224 2155 stateName[korg1212->cardState]); 2225 2156 2226 korg1212->iobase = ioremap(korg1212->iomem, iomem_size); 2227 if (!korg1212->iobase) { 2228 snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem, 2229 korg1212->iomem + iomem_size - 1); 2230 snd_korg1212_free(korg1212); 2157 korg1212->iobase = pcim_iomap_table(pci)[0]; 2158 2159 err = devm_request_irq(&pci->dev, pci->irq, snd_korg1212_interrupt, 2160 IRQF_SHARED, 2161 KBUILD_MODNAME, korg1212); 2162 2163 if (err) { 2164 snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq); 2231 2165 return -EBUSY; 2232 2166 } 2233 2167 2234 err = request_irq(pci->irq, snd_korg1212_interrupt,2235 IRQF_SHARED,2236 KBUILD_MODNAME, korg1212);2237 2238 if (err) {2239 snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq);2240 snd_korg1212_free(korg1212);2241 return -EBUSY;2242 }2243 2244 2168 korg1212->irq = pci->irq; 2245 2169 card->sync_irq = korg1212->irq; 2170 card->private_free = snd_korg1212_free; 2246 2171 2247 2172 pci_set_master(korg1212->pci); … … 2282 2207 stateName[korg1212->cardState]); 2283 2208 2284 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 2285 sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) { 2286 snd_printk(KERN_ERR "korg1212: can not allocate shared buffer memory (%zd bytes)\n", sizeof(struct KorgSharedBuffer)); 2287 snd_korg1212_free(korg1212); 2288 return -ENOMEM; 2289 } 2290 korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area; 2291 korg1212->sharedBufferPhy = korg1212->dma_shared.addr; 2209 korg1212->dma_shared = snd_devm_alloc_pages(&pci->dev, 2210 SNDRV_DMA_TYPE_DEV, 2211 sizeof(struct KorgSharedBuffer)); 2212 if (!korg1212->dma_shared) 2213 return -ENOMEM; 2214 korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared->area; 2215 korg1212->sharedBufferPhy = korg1212->dma_shared->addr; 2292 2216 2293 2217 K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(struct KorgSharedBuffer)); 2294 2218 2295 2219 #ifndef K1212_LARGEALLOC 2296 2297 2220 korg1212->DataBufsSize = sizeof(struct KorgAudioBuffer) * kNumBuffers; 2298 2299 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 2300 korg1212->DataBufsSize, &korg1212->dma_play) < 0) { 2301 snd_printk(KERN_ERR "korg1212: can not allocate play data buffer memory (%d bytes)\n", korg1212->DataBufsSize); 2302 snd_korg1212_free(korg1212); 2303 return -ENOMEM; 2304 } 2305 korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area; 2306 korg1212->PlayDataPhy = korg1212->dma_play.addr; 2221 korg1212->dma_play = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, 2222 korg1212->DataBufsSize); 2223 if (!korg1212->dma_play) 2224 return -ENOMEM; 2225 2226 korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play->area; 2227 korg1212->PlayDataPhy = korg1212->dma_play->addr; 2307 2228 2308 2229 K1212_DEBUG_PRINTK("K1212_DEBUG: Play Data Area = 0x%p (0x%08x), %d bytes\n", 2309 2230 korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize); 2310 2231 2311 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 2312 korg1212->DataBufsSize, &korg1212->dma_rec) < 0) { 2313 snd_printk(KERN_ERR "korg1212: can not allocate record data buffer memory (%d bytes)\n", korg1212->DataBufsSize); 2314 snd_korg1212_free(korg1212); 2315 return -ENOMEM; 2316 } 2317 korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area; 2318 korg1212->RecDataPhy = korg1212->dma_rec.addr; 2232 korg1212->dma_rec = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, 2233 korg1212->DataBufsSize); 2234 if (!korg1212->dma_rec) 2235 return -ENOMEM; 2236 2237 korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec->area; 2238 korg1212->RecDataPhy = korg1212->dma_rec->addr; 2319 2239 2320 2240 K1212_DEBUG_PRINTK("K1212_DEBUG: Record Data Area = 0x%p (0x%08x), %d bytes\n", … … 2340 2260 if (err < 0) { 2341 2261 snd_printk(KERN_ERR "firmware not available\n"); 2342 snd_korg1212_free(korg1212);2343 2262 return err; 2344 2263 } 2345 2264 2346 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 2347 dsp_code->size, &korg1212->dma_dsp) < 0) { 2348 snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size); 2349 snd_korg1212_free(korg1212); 2265 korg1212->dma_dsp = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, 2266 dsp_code->size); 2267 if (!korg1212->dma_dsp) { 2350 2268 release_firmware(dsp_code); 2351 2352 2269 return -ENOMEM; 2270 } 2353 2271 2354 2272 K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n", 2355 korg1212->dma_dsp .area, korg1212->dma_dsp.addr, dsp_code->size,2273 korg1212->dma_dsp->area, korg1212->dma_dsp->addr, dsp_code->size, 2356 2274 stateName[korg1212->cardState]); 2357 2275 2358 memcpy(korg1212->dma_dsp .area, dsp_code->data, dsp_code->size);2276 memcpy(korg1212->dma_dsp->area, dsp_code->data, dsp_code->size); 2359 2277 2360 2278 release_firmware(dsp_code); … … 2365 2283 K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); 2366 2284 2367 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops);2368 if (err < 0) {2369 snd_korg1212_free(korg1212);2370 return err;2371 }2372 2373 2285 snd_korg1212_EnableCardInterrupts(korg1212); 2374 2286 … … 2412 2324 2413 2325 snd_korg1212_proc_init(korg1212); 2414 2415 * rchip = korg1212; 2326 2416 2327 return 0; 2417 2418 2328 } 2419 2329 … … 2438 2348 return -ENOENT; 2439 2349 } 2440 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,2441 0, &card);2350 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 2351 sizeof(*korg1212), &card); 2442 2352 if (err < 0) 2443 2353 return err; 2444 2445 err = snd_korg1212_create(card, pci, &korg1212); 2446 if (err < 0) { 2447 snd_card_free(card); 2448 return err; 2449 } 2354 korg1212 = card->private_data; 2355 2356 err = snd_korg1212_create(card, pci); 2357 if (err < 0) 2358 goto error; 2450 2359 2451 2360 strcpy(card->driver, "korg1212"); … … 2457 2366 2458 2367 err = snd_card_register(card); 2459 if (err < 0) { 2460 snd_card_free(card); 2461 return err; 2462 } 2368 if (err < 0) 2369 goto error; 2463 2370 pci_set_drvdata(pci, card); 2464 2371 dev++; 2465 2372 return 0; 2466 } 2467 2468 static void snd_korg1212_remove(struct pci_dev *pci) 2469 { 2470 snd_card_free(pci_get_drvdata(pci)); 2373 2374 error: 2375 snd_card_free(card); 2376 return err; 2471 2377 } 2472 2378 … … 2475 2381 .id_table = snd_korg1212_ids, 2476 2382 .probe = snd_korg1212_probe, 2477 .remove = snd_korg1212_remove,2478 2383 }; 2479 2384 -
GPL/trunk/alsa-kernel/pci/maestro3.c
r703 r717 2351 2351 */ 2352 2352 2353 static int snd_m3_free(struct snd_m3 *chip) 2354 { 2353 static void snd_m3_free(struct snd_card *card) 2354 { 2355 struct snd_m3 *chip = card->private_data; 2355 2356 struct m3_dma *s; 2356 2357 int i; 2357 2358 2358 2359 cancel_work_sync(&chip->hwvol_work); 2359 #ifdef CONFIG_SND_MAESTRO3_INPUT2360 if (chip->input_dev)2361 input_unregister_device(chip->input_dev);2362 #endif2363 2360 2364 2361 if (chip->substreams) { … … 2371 2368 } 2372 2369 spin_unlock_irq(&chip->reg_lock); 2373 kfree(chip->substreams);2374 2370 } 2375 2371 if (chip->iobase) { … … 2380 2376 vfree(chip->suspend_mem); 2381 2377 #endif 2382 2383 if (chip->irq >= 0)2384 free_irq(chip->irq, chip);2385 2386 if (chip->iobase)2387 pci_release_regions(chip->pci);2388 2389 2378 release_firmware(chip->assp_kernel_image); 2390 2379 release_firmware(chip->assp_minisrc_image); 2391 2392 pci_disable_device(chip->pci);2393 kfree(chip);2394 return 0;2395 2380 } 2396 2381 … … 2485 2470 int err; 2486 2471 2487 input_dev = input_allocate_device();2472 input_dev = devm_input_allocate_device(&chip->pci->dev); 2488 2473 if (!input_dev) 2489 2474 return -ENOMEM; … … 2505 2490 2506 2491 err = input_register_device(input_dev); 2507 if (err) { 2508 input_free_device(input_dev); 2492 if (err) 2509 2493 return err; 2510 }2511 2494 2512 2495 chip->input_dev = input_dev; … … 2517 2500 /* 2518 2501 */ 2519 2520 static int snd_m3_dev_free(struct snd_device *device)2521 {2522 struct snd_m3 *chip = device->device_data;2523 return snd_m3_free(chip);2524 }2525 2502 2526 2503 static int 2527 2504 snd_m3_create(struct snd_card *card, struct pci_dev *pci, 2528 2505 int enable_amp, 2529 int amp_gpio, 2530 struct snd_m3 **chip_ret) 2531 { 2532 struct snd_m3 *chip; 2506 int amp_gpio) 2507 { 2508 struct snd_m3 *chip = card->private_data; 2533 2509 int i, err; 2534 2510 const struct snd_pci_quirk *quirk; 2535 static const struct snd_device_ops ops = { 2536 .dev_free = snd_m3_dev_free, 2537 }; 2538 2539 *chip_ret = NULL; 2540 2541 if (pci_enable_device(pci)) 2511 2512 if (pcim_enable_device(pci)) 2542 2513 return -EIO; 2543 2514 … … 2546 2517 dev_err(card->dev, 2547 2518 "architecture does not support 28bit PCI busmaster DMA\n"); 2548 pci_disable_device(pci);2549 2519 return -ENXIO; 2550 }2551 2552 chip = kzalloc(sizeof(*chip), GFP_KERNEL);2553 if (chip == NULL) {2554 pci_disable_device(pci);2555 return -ENOMEM;2556 2520 } 2557 2521 … … 2571 2535 chip->irq = -1; 2572 2536 INIT_WORK(&chip->hwvol_work, snd_m3_update_hw_volume); 2537 card->private_free = snd_m3_free; 2573 2538 2574 2539 chip->external_amp = enable_amp; … … 2600 2565 2601 2566 chip->num_substreams = NR_DSPS; 2567 #ifndef TARGET_OS2 2568 chip->substreams = devm_kcalloc(&pci->dev, chip->num_substreams, 2569 sizeof(struct m3_dma), GFP_KERNEL); 2570 #else 2602 2571 chip->substreams = kcalloc(chip->num_substreams, sizeof(struct m3_dma), 2603 2572 GFP_KERNEL); 2604 if (chip->substreams == NULL) { 2605 kfree(chip); 2606 pci_disable_device(pci); 2573 #endif 2574 if (!chip->substreams) 2607 2575 return -ENOMEM; 2608 }2609 2576 2610 2577 err = request_firmware(&chip->assp_kernel_image, 2611 2578 "ess/maestro3_assp_kernel.fw", &pci->dev); 2612 2579 if (err < 0) 2613 goto free_chip;2580 return err; 2614 2581 2615 2582 err = request_firmware(&chip->assp_minisrc_image, 2616 2583 "ess/maestro3_assp_minisrc.fw", &pci->dev); 2617 2584 if (err < 0) 2618 goto free_chip;2585 return err; 2619 2586 2620 2587 err = pci_request_regions(pci, card->driver); 2621 2588 if (err < 0) 2622 goto free_chip;2589 return err; 2623 2590 2624 2591 chip->iobase = pci_resource_start(pci, 0); … … 2636 2603 snd_m3_hv_init(chip); 2637 2604 2605 #ifndef TARGET_OS2 2606 if (devm_request_irq(&pci->dev, pci->irq, snd_m3_interrupt, IRQF_SHARED, 2607 KBUILD_MODNAME, chip)) { 2608 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 2609 return -ENOMEM; 2610 } 2611 #else 2638 2612 if (request_irq(pci->irq, snd_m3_interrupt, IRQF_SHARED, 2639 2613 KBUILD_MODNAME, chip)) { 2640 2614 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 2641 err =-ENOMEM;2642 goto free_chip;2643 } 2615 return -ENOMEM; 2616 } 2617 #endif 2644 2618 chip->irq = pci->irq; 2645 2619 card->sync_irq = chip->irq; … … 2654 2628 #endif 2655 2629 2656 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);2657 if (err < 0)2658 goto free_chip;2659 2660 2630 err = snd_m3_mixer(chip); 2661 2631 if (err < 0) … … 2686 2656 snd_m3_assp_continue(chip); 2687 2657 2688 *chip_ret = chip;2689 2690 2658 return 0; 2691 2692 free_chip:2693 snd_m3_free(chip);2694 return err;2695 2659 } 2696 2660 … … 2698 2662 */ 2699 2663 static int 2700 snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)2664 __snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 2701 2665 { 2702 2666 static int dev; … … 2716 2680 } 2717 2681 2718 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,2719 0, &card);2682 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 2683 sizeof(*chip), &card); 2720 2684 if (err < 0) 2721 2685 return err; 2686 chip = card->private_data; 2722 2687 2723 2688 switch (pci->device) { … … 2735 2700 } 2736 2701 2737 err = snd_m3_create(card, pci, external_amp[dev], amp_gpio[dev] , &chip);2702 err = snd_m3_create(card, pci, external_amp[dev], amp_gpio[dev]); 2738 2703 if (err < 0) 2739 goto free_card; 2740 2741 card->private_data = chip; 2704 return err; 2742 2705 2743 2706 sprintf(card->shortname, "ESS %s PCI", card->driver); … … 2747 2710 err = snd_card_register(card); 2748 2711 if (err < 0) 2749 goto free_card;2712 return err; 2750 2713 2751 2714 #if 0 /* TODO: not supported yet */ … … 2762 2725 dev++; 2763 2726 return 0; 2764 2765 free_card: 2766 snd_card_free(card); 2767 return err; 2768 } 2769 2770 static void snd_m3_remove(struct pci_dev *pci) 2771 { 2772 snd_card_free(pci_get_drvdata(pci)); 2727 } 2728 2729 static int 2730 snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 2731 { 2732 return snd_card_free_on_error(&pci->dev, __snd_m3_probe(pci, pci_id)); 2773 2733 } 2774 2734 … … 2777 2737 .id_table = snd_m3_ids, 2778 2738 .probe = snd_m3_probe, 2779 .remove = snd_m3_remove,2780 2739 .driver = { 2781 2740 .pm = M3_PM_OPS, -
GPL/trunk/alsa-kernel/pci/nm256/nm256.c
r703 r717 198 198 199 199 void __iomem *cport; /* control port */ 200 struct resource *res_cport; /* its resource */201 200 unsigned long cport_addr; /* physical address */ 202 201 203 202 void __iomem *buffer; /* buffer */ 204 struct resource *res_buffer; /* its resource */205 203 unsigned long buffer_addr; /* buffer phyiscal address */ 206 204 … … 1318 1316 }; 1319 1317 1320 chip->ac97_regs = kcalloc(ARRAY_SIZE(nm256_ac97_init_val), 1321 sizeof(short), GFP_KERNEL); 1318 chip->ac97_regs = devm_kcalloc(chip->card->dev, 1319 ARRAY_SIZE(nm256_ac97_init_val), 1320 sizeof(short), GFP_KERNEL); 1322 1321 if (! chip->ac97_regs) 1323 1322 return -ENOMEM; … … 1442 1441 #endif /* CONFIG_PM_SLEEP */ 1443 1442 1444 static int snd_nm256_free(struct nm256 *chip) 1445 { 1443 static void snd_nm256_free(struct snd_card *card) 1444 { 1445 struct nm256 *chip = card->private_data; 1446 1446 1447 if (chip->streams[SNDRV_PCM_STREAM_PLAYBACK].running) 1447 1448 snd_nm256_playback_stop(chip); 1448 1449 if (chip->streams[SNDRV_PCM_STREAM_CAPTURE].running) 1449 1450 snd_nm256_capture_stop(chip); 1450 1451 if (chip->irq >= 0)1452 free_irq(chip->irq, chip);1453 1454 iounmap(chip->cport);1455 iounmap(chip->buffer);1456 release_and_free_resource(chip->res_cport);1457 release_and_free_resource(chip->res_buffer);1458 1459 pci_disable_device(chip->pci);1460 kfree(chip->ac97_regs);1461 kfree(chip);1462 return 0;1463 }1464 1465 static int snd_nm256_dev_free(struct snd_device *device)1466 {1467 struct nm256 *chip = device->device_data;1468 return snd_nm256_free(chip);1469 1451 } 1470 1452 1471 1453 static int 1472 snd_nm256_create(struct snd_card *card, struct pci_dev *pci, 1473 struct nm256 **chip_ret) 1474 { 1475 struct nm256 *chip; 1454 snd_nm256_create(struct snd_card *card, struct pci_dev *pci) 1455 { 1456 struct nm256 *chip = card->private_data; 1476 1457 int err, pval; 1477 static const struct snd_device_ops ops = {1478 .dev_free = snd_nm256_dev_free,1479 };1480 1458 u32 addr; 1481 1459 1482 *chip_ret = NULL; 1483 1484 err = pci_enable_device(pci); 1460 err = pcim_enable_device(pci); 1485 1461 if (err < 0) 1486 1462 return err; 1487 1488 chip = kzalloc(sizeof(*chip), GFP_KERNEL);1489 if (chip == NULL) {1490 pci_disable_device(pci);1491 return -ENOMEM;1492 }1493 1463 1494 1464 chip->card = card; … … 1513 1483 chip->cport_addr = pci_resource_start(pci, 1); 1514 1484 1485 err = pci_request_regions(pci, card->driver); 1486 if (err < 0) 1487 return err; 1488 1515 1489 /* Init the memory port info. */ 1516 1490 /* remap control port (#2) */ 1517 chip->res_cport = request_mem_region(chip->cport_addr, NM_PORT2_SIZE, 1518 card->driver); 1519 if (chip->res_cport == NULL) { 1520 dev_err(card->dev, "memory region 0x%lx (size 0x%x) busy\n", 1521 chip->cport_addr, NM_PORT2_SIZE); 1522 err = -EBUSY; 1523 goto __error; 1524 } 1525 chip->cport = ioremap(chip->cport_addr, NM_PORT2_SIZE); 1526 if (chip->cport == NULL) { 1491 chip->cport = devm_ioremap(&pci->dev, chip->cport_addr, NM_PORT2_SIZE); 1492 if (!chip->cport) { 1527 1493 dev_err(card->dev, "unable to map control port %lx\n", 1528 1494 chip->cport_addr); 1529 err = -ENOMEM; 1530 goto __error; 1495 return -ENOMEM; 1531 1496 } 1532 1497 … … 1544 1509 dev_err(card->dev, 1545 1510 "or try sb16, opl3sa2, or cs423x drivers instead.\n"); 1546 err = -ENXIO; 1547 goto __error; 1511 return -ENXIO; 1548 1512 } 1549 1513 } … … 1577 1541 err = snd_nm256_peek_for_sig(chip); 1578 1542 if (err < 0) 1579 goto __error;1543 return err; 1580 1544 } 1581 1545 … … 1586 1550 chip->buffer_start, chip->buffer_end); 1587 1551 1588 chip->res_buffer = request_mem_region(chip->buffer_addr, 1589 chip->buffer_size, 1590 card->driver); 1591 if (chip->res_buffer == NULL) { 1592 dev_err(card->dev, "buffer 0x%lx (size 0x%x) busy\n", 1593 chip->buffer_addr, chip->buffer_size); 1594 err = -EBUSY; 1595 goto __error; 1596 } 1597 chip->buffer = ioremap(chip->buffer_addr, chip->buffer_size); 1598 if (chip->buffer == NULL) { 1599 err = -ENOMEM; 1552 chip->buffer = devm_ioremap(&pci->dev, chip->buffer_addr, 1553 chip->buffer_size); 1554 if (!chip->buffer) { 1600 1555 dev_err(card->dev, "unable to map ring buffer at %lx\n", 1601 1556 chip->buffer_addr); 1602 goto __error;1557 return -ENOMEM; 1603 1558 } 1604 1559 … … 1625 1580 1626 1581 // pci_set_master(pci); /* needed? */ 1627 1628 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 1629 if (err < 0) 1630 goto __error; 1631 1632 *chip_ret = chip; 1633 return 0; 1634 1635 __error: 1636 snd_nm256_free(chip); 1637 return err; 1582 return 0; 1638 1583 } 1639 1584 … … 1678 1623 } 1679 1624 1680 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); 1625 err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE, 1626 sizeof(*chip), &card); 1681 1627 if (err < 0) 1682 1628 return err; 1629 chip = card->private_data; 1683 1630 1684 1631 switch (pci->device) { … … 1694 1641 default: 1695 1642 dev_err(&pci->dev, "invalid device id 0x%x\n", pci->device); 1696 snd_card_free(card);1697 1643 return -EINVAL; 1698 1644 } … … 1709 1655 if (capture_bufsize > 128) 1710 1656 capture_bufsize = 128; 1711 err = snd_nm256_create(card, pci, &chip); 1712 if (err < 0) { 1713 snd_card_free(card); 1657 err = snd_nm256_create(card, pci); 1658 if (err < 0) 1714 1659 return err; 1715 }1716 card->private_data = chip;1717 1660 1718 1661 if (reset_workaround) { … … 1727 1670 1728 1671 err = snd_nm256_pcm(chip, 0); 1729 if (err < 0) { 1730 snd_card_free(card); 1672 if (err < 0) 1731 1673 return err; 1732 }1733 1674 err = snd_nm256_mixer(chip); 1734 if (err < 0) { 1735 snd_card_free(card); 1675 if (err < 0) 1736 1676 return err; 1737 }1738 1677 1739 1678 sprintf(card->shortname, "NeoMagic %s", card->driver); … … 1743 1682 1744 1683 err = snd_card_register(card); 1745 if (err < 0) { 1746 snd_card_free(card); 1684 if (err < 0) 1747 1685 return err; 1748 }1686 card->private_free = snd_nm256_free; 1749 1687 1750 1688 pci_set_drvdata(pci, card); 1751 1689 return 0; 1752 1690 } 1753 1754 static void snd_nm256_remove(struct pci_dev *pci)1755 {1756 snd_card_free(pci_get_drvdata(pci));1757 }1758 1759 1691 1760 1692 static struct pci_driver nm256_driver = { … … 1762 1694 .id_table = snd_nm256_ids, 1763 1695 .probe = snd_nm256_probe, 1764 .remove = snd_nm256_remove,1765 1696 .driver = { 1766 1697 .pm = NM256_PM_OPS, -
GPL/trunk/alsa-kernel/pci/rme9652/hdsp.c
r703 r717 469 469 u32 io_loopback; /* output loopback channel states*/ 470 470 471 /* DMA buffers; those are copied instances from the original snd_dma_buf 472 * objects (which are managed via devres) for the address alignments 473 */ 471 474 struct snd_dma_buffer capture_dma_buf; 472 475 struct snd_dma_buffer playback_dma_buf; … … 566 569 }; 567 570 568 static int snd_hammerfall_get_buffer(struct pci_dev *pci, struct snd_dma_buffer *dmab, size_t size) 569 { 570 return snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, size, dmab); 571 } 572 573 static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci) 574 { 575 if (dmab->area) 576 snd_dma_free_pages(dmab); 577 } 578 571 static struct snd_dma_buffer * 572 snd_hammerfall_get_buffer(struct pci_dev *pci, size_t size) 573 { 574 return snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, size); 575 } 579 576 580 577 static const struct pci_device_id snd_hdsp_ids[] = { … … 3769 3766 } 3770 3767 3771 static void snd_hdsp_free_buffers(struct hdsp *hdsp)3772 {3773 snd_hammerfall_free_buffer(&hdsp->capture_dma_buf, hdsp->pci);3774 snd_hammerfall_free_buffer(&hdsp->playback_dma_buf, hdsp->pci);3775 }3776 3777 3768 static int snd_hdsp_initialize_memory(struct hdsp *hdsp) 3778 3769 { 3779 unsigned long pb_bus, cb_bus; 3780 3781 if (snd_hammerfall_get_buffer(hdsp->pci, &hdsp->capture_dma_buf, HDSP_DMA_AREA_BYTES) < 0 || 3782 snd_hammerfall_get_buffer(hdsp->pci, &hdsp->playback_dma_buf, HDSP_DMA_AREA_BYTES) < 0) { 3783 if (hdsp->capture_dma_buf.area) 3784 snd_dma_free_pages(&hdsp->capture_dma_buf); 3770 struct snd_dma_buffer *capture_dma, *playback_dma; 3771 3772 capture_dma = snd_hammerfall_get_buffer(hdsp->pci, HDSP_DMA_AREA_BYTES); 3773 playback_dma = snd_hammerfall_get_buffer(hdsp->pci, HDSP_DMA_AREA_BYTES); 3774 if (!capture_dma || !playback_dma) { 3785 3775 dev_err(hdsp->card->dev, 3786 3776 "%s: no buffers available\n", hdsp->card_name); … … 3788 3778 } 3789 3779 3780 /* copy to the own data for alignment */ 3781 hdsp->capture_dma_buf = *capture_dma; 3782 hdsp->playback_dma_buf = *playback_dma; 3783 3790 3784 /* Align to bus-space 64K boundary */ 3791 3792 cb_bus = ALIGN(hdsp->capture_dma_buf.addr, 0x10000ul); 3793 pb_bus = ALIGN(hdsp->playback_dma_buf.addr, 0x10000ul); 3785 hdsp->capture_dma_buf.addr = ALIGN(capture_dma->addr, 0x10000ul); 3786 hdsp->playback_dma_buf.addr = ALIGN(playback_dma->addr, 0x10000ul); 3794 3787 3795 3788 /* Tell the card where it is */ 3796 3797 hdsp_write(hdsp, HDSP_inputBufferAddress, cb_bus); 3798 hdsp_write(hdsp, HDSP_outputBufferAddress, pb_bus); 3799 3800 hdsp->capture_buffer = hdsp->capture_dma_buf.area + (cb_bus - hdsp->capture_dma_buf.addr); 3801 hdsp->playback_buffer = hdsp->playback_dma_buf.area + (pb_bus - hdsp->playback_dma_buf.addr); 3789 hdsp_write(hdsp, HDSP_inputBufferAddress, hdsp->capture_dma_buf.addr); 3790 hdsp_write(hdsp, HDSP_outputBufferAddress, hdsp->playback_dma_buf.addr); 3791 3792 hdsp->capture_dma_buf.area += hdsp->capture_dma_buf.addr - capture_dma->addr; 3793 hdsp->playback_dma_buf.area += hdsp->playback_dma_buf.addr - playback_dma->addr; 3794 hdsp->capture_buffer = hdsp->capture_dma_buf.area; 3795 hdsp->playback_buffer = hdsp->playback_dma_buf.area; 3802 3796 3803 3797 return 0; … … 4519 4513 4520 4514 runtime->hw = snd_hdsp_playback_subinfo; 4521 runtime->dma_area = hdsp->playback_buffer; 4522 runtime->dma_bytes = HDSP_DMA_AREA_BYTES; 4515 snd_pcm_set_runtime_buffer(substream, &hdsp->playback_dma_buf); 4523 4516 4524 4517 hdsp->playback_pid = current->pid; … … 4596 4589 4597 4590 runtime->hw = snd_hdsp_capture_subinfo; 4598 runtime->dma_area = hdsp->capture_buffer; 4599 runtime->dma_bytes = HDSP_DMA_AREA_BYTES; 4591 snd_pcm_set_runtime_buffer(substream, &hdsp->capture_dma_buf); 4600 4592 4601 4593 hdsp->capture_pid = current->pid; … … 5314 5306 } 5315 5307 5316 err = pci _enable_device(pci);5308 err = pcim_enable_device(pci); 5317 5309 if (err < 0) 5318 5310 return err; … … 5324 5316 return err; 5325 5317 hdsp->port = pci_resource_start(pci, 0); 5326 hdsp->iobase = ioremap(hdsp->port, HDSP_IO_EXTENT);5318 hdsp->iobase = devm_ioremap(&pci->dev, hdsp->port, HDSP_IO_EXTENT); 5327 5319 if (!hdsp->iobase) { 5328 5320 dev_err(hdsp->card->dev, "unable to remap region 0x%lx-0x%lx\n", … … 5331 5323 } 5332 5324 5333 if ( request_irq(pci->irq, snd_hdsp_interrupt, IRQF_SHARED,5334 KBUILD_MODNAME, hdsp)) {5325 if (devm_request_irq(&pci->dev, pci->irq, snd_hdsp_interrupt, 5326 IRQF_SHARED, KBUILD_MODNAME, hdsp)) { 5335 5327 dev_err(hdsp->card->dev, "unable to use IRQ %d\n", pci->irq); 5336 5328 return -EBUSY; … … 5412 5404 } 5413 5405 5414 static int snd_hdsp_free(struct hdsp *hdsp) 5415 { 5406 static void snd_hdsp_card_free(struct snd_card *card) 5407 { 5408 struct hdsp *hdsp = card->private_data; 5409 5416 5410 if (hdsp->port) { 5417 5411 /* stop the audio, and cancel all interrupts */ … … 5421 5415 } 5422 5416 5423 if (hdsp->irq >= 0)5424 free_irq(hdsp->irq, (void *)hdsp);5425 5426 snd_hdsp_free_buffers(hdsp);5427 5428 5417 release_firmware(hdsp->firmware); 5429 5418 vfree(hdsp->fw_uploaded); 5430 iounmap(hdsp->iobase);5431 5432 if (hdsp->port)5433 pci_release_regions(hdsp->pci);5434 5435 if (pci_is_enabled(hdsp->pci))5436 pci_disable_device(hdsp->pci);5437 return 0;5438 }5439 5440 static void snd_hdsp_card_free(struct snd_card *card)5441 {5442 struct hdsp *hdsp = card->private_data;5443 5444 if (hdsp)5445 snd_hdsp_free(hdsp);5446 5419 } 5447 5420 … … 5461 5434 } 5462 5435 5463 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,5464 5436 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 5437 sizeof(struct hdsp), &card); 5465 5438 if (err < 0) 5466 5439 return err; … … 5472 5445 err = snd_hdsp_create(card, hdsp); 5473 5446 if (err) 5474 goto free_card;5447 goto error; 5475 5448 5476 5449 strcpy(card->shortname, "Hammerfall DSP"); … … 5478 5451 hdsp->port, hdsp->irq); 5479 5452 err = snd_card_register(card); 5480 if (err) { 5481 free_card: 5482 snd_card_free(card); 5483 return err; 5484 } 5453 if (err) 5454 goto error; 5485 5455 pci_set_drvdata(pci, card); 5486 5456 dev++; 5487 5457 return 0; 5488 } 5489 5490 static void snd_hdsp_remove(struct pci_dev *pci) 5491 { 5492 snd_card_free(pci_get_drvdata(pci)); 5458 5459 error: 5460 snd_card_free(card); 5461 return err; 5493 5462 } 5494 5463 … … 5497 5466 .id_table = snd_hdsp_ids, 5498 5467 .probe = snd_hdsp_probe, 5499 .remove = snd_hdsp_remove,5500 5468 }; 5501 5469 -
GPL/trunk/alsa-kernel/pci/rme9652/hdspm.c
r695 r717 6576 6576 } 6577 6577 6578 err = pci _enable_device(pci);6578 err = pcim_enable_device(pci); 6579 6579 if (err < 0) 6580 6580 return err; … … 6582 6582 pci_set_master(hdspm->pci); 6583 6583 6584 err = pci _request_regions(pci, "hdspm");6584 err = pcim_iomap_regions(pci, 1 << 0, "hdspm"); 6585 6585 if (err < 0) 6586 6586 return err; … … 6588 6588 hdspm->port = pci_resource_start(pci, 0); 6589 6589 io_extent = pci_resource_len(pci, 0); 6590 6591 dev_dbg(card->dev, "grabbed memory region 0x%lx-0x%lx\n", 6592 hdspm->port, hdspm->port + io_extent - 1); 6593 6594 hdspm->iobase = ioremap(hdspm->port, io_extent); 6595 if (!hdspm->iobase) { 6596 dev_err(card->dev, "unable to remap region 0x%lx-0x%lx\n", 6597 hdspm->port, hdspm->port + io_extent - 1); 6598 return -EBUSY; 6599 } 6590 hdspm->iobase = pcim_iomap_table(pci)[0]; 6600 6591 dev_dbg(card->dev, "remapped region (0x%lx) 0x%lx-0x%lx\n", 6601 6592 (unsigned long)hdspm->iobase, hdspm->port, 6602 6593 hdspm->port + io_extent - 1); 6603 6594 6604 if ( request_irq(pci->irq, snd_hdspm_interrupt,6605 IRQF_SHARED, KBUILD_MODNAME, hdspm)) {6595 if (devm_request_irq(&pci->dev, pci->irq, snd_hdspm_interrupt, 6596 IRQF_SHARED, KBUILD_MODNAME, hdspm)) { 6606 6597 dev_err(card->dev, "unable to use IRQ %d\n", pci->irq); 6607 6598 return -EBUSY; … … 6615 6606 dev_dbg(card->dev, "kmalloc Mixer memory of %zd Bytes\n", 6616 6607 sizeof(*hdspm->mixer)); 6617 hdspm->mixer = kzalloc(sizeof(*hdspm->mixer), GFP_KERNEL);6608 hdspm->mixer = devm_kzalloc(&pci->dev, sizeof(*hdspm->mixer), GFP_KERNEL); 6618 6609 if (!hdspm->mixer) 6619 6610 return -ENOMEM; … … 6860 6851 6861 6852 6862 static int snd_hdspm_free(struct hdspm * hdspm) 6863 { 6853 static void snd_hdspm_card_free(struct snd_card *card) 6854 { 6855 struct hdspm *hdspm = card->private_data; 6864 6856 6865 6857 if (hdspm->port) { … … 6874 6866 hdspm->control_register); 6875 6867 } 6876 6877 if (hdspm->irq >= 0)6878 free_irq(hdspm->irq, (void *) hdspm);6879 6880 kfree(hdspm->mixer);6881 iounmap(hdspm->iobase);6882 6883 if (hdspm->port)6884 pci_release_regions(hdspm->pci);6885 6886 if (pci_is_enabled(hdspm->pci))6887 pci_disable_device(hdspm->pci);6888 return 0;6889 }6890 6891 6892 static void snd_hdspm_card_free(struct snd_card *card)6893 {6894 struct hdspm *hdspm = card->private_data;6895 6896 if (hdspm)6897 snd_hdspm_free(hdspm);6898 6868 } 6899 6869 … … 6914 6884 } 6915 6885 6916 err = snd_ card_new(&pci->dev, index[dev], id[dev],6917 6886 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], 6887 THIS_MODULE, sizeof(*hdspm), &card); 6918 6888 if (err < 0) 6919 6889 return err; … … 6926 6896 err = snd_hdspm_create(card, hdspm); 6927 6897 if (err < 0) 6928 goto free_card;6898 goto error; 6929 6899 6930 6900 if (hdspm->io_type != MADIface) { … … 6945 6915 err = snd_card_register(card); 6946 6916 if (err < 0) 6947 goto free_card;6917 goto error; 6948 6918 6949 6919 pci_set_drvdata(pci, card); … … 6952 6922 return 0; 6953 6923 6954 free_card:6924 error: 6955 6925 snd_card_free(card); 6956 6926 return err; 6957 }6958 6959 static void snd_hdspm_remove(struct pci_dev *pci)6960 {6961 snd_card_free(pci_get_drvdata(pci));6962 6927 } 6963 6928 … … 6966 6931 .id_table = snd_hdspm_ids, 6967 6932 .probe = snd_hdspm_probe, 6968 .remove = snd_hdspm_remove,6969 6933 }; 6970 6934 -
GPL/trunk/alsa-kernel/pci/rme9652/rme9652.c
r703 r717 209 209 unsigned char ss_channels; /* different for hammerfall/hammerfall-light */ 210 210 211 /* DMA buffers; those are copied instances from the original snd_dma_buf 212 * objects (which are managed via devres) for the address alignments 213 */ 211 214 struct snd_dma_buffer playback_dma_buf; 212 215 struct snd_dma_buffer capture_dma_buf; … … 276 279 }; 277 280 278 static int snd_hammerfall_get_buffer(struct pci_dev *pci, struct snd_dma_buffer *dmab, size_t size) 279 { 280 return snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, size, dmab); 281 } 282 283 static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci) 284 { 285 if (dmab->area) 286 snd_dma_free_pages(dmab); 287 } 288 281 static struct snd_dma_buffer * 282 snd_hammerfall_get_buffer(struct pci_dev *pci, size_t size) 283 { 284 return snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV, size); 285 } 289 286 290 287 static const struct pci_device_id snd_rme9652_ids[] = { … … 1716 1713 } 1717 1714 1718 static void snd_rme9652_free_buffers(struct snd_rme9652 *rme9652) 1719 { 1720 snd_hammerfall_free_buffer(&rme9652->capture_dma_buf, rme9652->pci); 1721 snd_hammerfall_free_buffer(&rme9652->playback_dma_buf, rme9652->pci); 1722 } 1723 1724 static int snd_rme9652_free(struct snd_rme9652 *rme9652) 1725 { 1715 static void snd_rme9652_card_free(struct snd_card *card) 1716 { 1717 struct snd_rme9652 *rme9652 = (struct snd_rme9652 *) card->private_data; 1718 1726 1719 if (rme9652->irq >= 0) 1727 1720 rme9652_stop(rme9652); 1728 snd_rme9652_free_buffers(rme9652);1729 1730 if (rme9652->irq >= 0)1731 free_irq(rme9652->irq, (void *)rme9652);1732 iounmap(rme9652->iobase);1733 if (rme9652->port)1734 pci_release_regions(rme9652->pci);1735 1736 if (pci_is_enabled(rme9652->pci))1737 pci_disable_device(rme9652->pci);1738 return 0;1739 1721 } 1740 1722 1741 1723 static int snd_rme9652_initialize_memory(struct snd_rme9652 *rme9652) 1742 1724 { 1743 unsigned long pb_bus, cb_bus; 1744 1745 if (snd_hammerfall_get_buffer(rme9652->pci, &rme9652->capture_dma_buf, RME9652_DMA_AREA_BYTES) < 0 || 1746 snd_hammerfall_get_buffer(rme9652->pci, &rme9652->playback_dma_buf, RME9652_DMA_AREA_BYTES) < 0) { 1747 if (rme9652->capture_dma_buf.area) 1748 snd_dma_free_pages(&rme9652->capture_dma_buf); 1725 struct snd_dma_buffer *capture_dma, *playback_dma; 1726 1727 capture_dma = snd_hammerfall_get_buffer(rme9652->pci, RME9652_DMA_AREA_BYTES); 1728 playback_dma = snd_hammerfall_get_buffer(rme9652->pci, RME9652_DMA_AREA_BYTES); 1729 if (!capture_dma || !playback_dma) { 1749 1730 dev_err(rme9652->card->dev, 1750 1731 "%s: no buffers available\n", rme9652->card_name); … … 1752 1733 } 1753 1734 1735 /* copy to the own data for alignment */ 1736 rme9652->capture_dma_buf = *capture_dma; 1737 rme9652->playback_dma_buf = *playback_dma; 1738 1754 1739 /* Align to bus-space 64K boundary */ 1755 1756 cb_bus = ALIGN(rme9652->capture_dma_buf.addr, 0x10000ul); 1757 pb_bus = ALIGN(rme9652->playback_dma_buf.addr, 0x10000ul); 1740 rme9652->capture_dma_buf.addr = ALIGN(capture_dma->addr, 0x10000ul); 1741 rme9652->playback_dma_buf.addr = ALIGN(playback_dma->addr, 0x10000ul); 1758 1742 1759 1743 /* Tell the card where it is */ 1760 1761 rme9652_write(rme9652, RME9652_rec_buffer, cb_bus); 1762 rme9652_write(rme9652, RME9652_play_buffer, pb_bus); 1763 1764 rme9652->capture_buffer = rme9652->capture_dma_buf.area + (cb_bus - rme9652->capture_dma_buf.addr); 1765 rme9652->playback_buffer = rme9652->playback_dma_buf.area + (pb_bus - rme9652->playback_dma_buf.addr); 1744 rme9652_write(rme9652, RME9652_rec_buffer, rme9652->capture_dma_buf.addr); 1745 rme9652_write(rme9652, RME9652_play_buffer, rme9652->playback_dma_buf.addr); 1746 1747 rme9652->capture_dma_buf.area += rme9652->capture_dma_buf.addr - capture_dma->addr; 1748 rme9652->playback_dma_buf.area += rme9652->playback_dma_buf.addr - playback_dma->addr; 1749 rme9652->capture_buffer = rme9652->capture_dma_buf.area; 1750 rme9652->playback_buffer = rme9652->playback_dma_buf.area; 1766 1751 1767 1752 return 0; … … 2280 2265 2281 2266 runtime->hw = snd_rme9652_playback_subinfo; 2282 runtime->dma_area = rme9652->playback_buffer; 2283 runtime->dma_bytes = RME9652_DMA_AREA_BYTES; 2267 snd_pcm_set_runtime_buffer(substream, &rme9652->playback_dma_buf); 2284 2268 2285 2269 if (rme9652->capture_substream == NULL) { … … 2340 2324 2341 2325 runtime->hw = snd_rme9652_capture_subinfo; 2342 runtime->dma_area = rme9652->capture_buffer; 2343 runtime->dma_bytes = RME9652_DMA_AREA_BYTES; 2326 snd_pcm_set_runtime_buffer(substream, &rme9652->capture_dma_buf); 2344 2327 2345 2328 if (rme9652->playback_substream == NULL) { … … 2453 2436 } 2454 2437 2455 err = pci _enable_device(pci);2438 err = pcim_enable_device(pci); 2456 2439 if (err < 0) 2457 2440 return err; … … 2463 2446 return err; 2464 2447 rme9652->port = pci_resource_start(pci, 0); 2465 rme9652->iobase = ioremap(rme9652->port, RME9652_IO_EXTENT);2448 rme9652->iobase = devm_ioremap(&pci->dev, rme9652->port, RME9652_IO_EXTENT); 2466 2449 if (rme9652->iobase == NULL) { 2467 2450 dev_err(card->dev, "unable to remap region 0x%lx-0x%lx\n", … … 2470 2453 } 2471 2454 2472 if ( request_irq(pci->irq, snd_rme9652_interrupt, IRQF_SHARED,2473 KBUILD_MODNAME, rme9652)) {2455 if (devm_request_irq(&pci->dev, pci->irq, snd_rme9652_interrupt, 2456 IRQF_SHARED, KBUILD_MODNAME, rme9652)) { 2474 2457 dev_err(card->dev, "unable to request IRQ %d\n", pci->irq); 2475 2458 return -EBUSY; … … 2563 2546 } 2564 2547 2565 static void snd_rme9652_card_free(struct snd_card *card)2566 {2567 struct snd_rme9652 *rme9652 = (struct snd_rme9652 *) card->private_data;2568 2569 if (rme9652)2570 snd_rme9652_free(rme9652);2571 }2572 2573 2548 static int snd_rme9652_probe(struct pci_dev *pci, 2574 2549 const struct pci_device_id *pci_id) … … 2586 2561 } 2587 2562 2588 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,2589 2563 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 2564 sizeof(struct snd_rme9652), &card); 2590 2565 2591 2566 if (err < 0) … … 2598 2573 err = snd_rme9652_create(card, rme9652, precise_ptr[dev]); 2599 2574 if (err) 2600 goto free_card;2575 goto error; 2601 2576 2602 2577 strcpy(card->shortname, rme9652->card_name); … … 2605 2580 card->shortname, rme9652->port, rme9652->irq); 2606 2581 err = snd_card_register(card); 2607 if (err) { 2608 free_card: 2609 snd_card_free(card); 2610 return err; 2611 } 2582 if (err) 2583 goto error; 2612 2584 pci_set_drvdata(pci, card); 2613 2585 dev++; 2614 2586 return 0; 2615 } 2616 2617 static void snd_rme9652_remove(struct pci_dev *pci) 2618 { 2619 snd_card_free(pci_get_drvdata(pci)); 2587 2588 error: 2589 snd_card_free(card); 2590 return err; 2620 2591 } 2621 2592 … … 2624 2595 .id_table = snd_rme9652_ids, 2625 2596 .probe = snd_rme9652_probe, 2626 .remove = snd_rme9652_remove,2627 2597 }; 2628 2598 -
GPL/trunk/alsa-kernel/pci/trident/trident.c
r703 r717 72 72 } 73 73 74 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,75 0, &card);74 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 75 sizeof(*trident), &card); 76 76 if (err < 0) 77 77 return err; 78 trident = card->private_data; 78 79 79 80 err = snd_trident_create(card, pci, 80 81 pcm_channels[dev], 81 82 ((pci->vendor << 16) | pci->device) == TRIDENT_DEVICE_ID_SI7018 ? 1 : 2, 82 wavetable_size[dev], 83 &trident); 84 if (err < 0) { 85 snd_card_free(card); 83 wavetable_size[dev]); 84 if (err < 0) 86 85 return err; 87 }88 card->private_data = trident;89 86 90 87 switch (trident->device) { … … 112 109 113 110 err = snd_trident_pcm(trident, pcm_dev++); 114 if (err < 0) { 115 snd_card_free(card); 111 if (err < 0) 116 112 return err; 117 }118 113 switch (trident->device) { 119 114 case TRIDENT_DEVICE_ID_DX: 120 115 case TRIDENT_DEVICE_ID_NX: 121 116 err = snd_trident_foldback_pcm(trident, pcm_dev++); 122 if (err < 0) { 123 snd_card_free(card); 117 if (err < 0) 124 118 return err; 125 }126 119 break; 127 120 } 128 121 if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) { 129 122 err = snd_trident_spdif_pcm(trident, pcm_dev++); 130 if (err < 0) { 131 snd_card_free(card); 123 if (err < 0) 132 124 return err; 133 }134 125 } 135 126 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { … … 139 130 MPU401_INFO_IRQ_HOOK, 140 131 -1, &trident->rmidi); 141 if (err < 0) { 142 snd_card_free(card); 132 if (err < 0) 143 133 return err; 144 }145 134 } 146 135 … … 148 137 149 138 err = snd_card_register(card); 150 if (err < 0) { 151 snd_card_free(card); 139 if (err < 0) 152 140 return err; 153 }154 141 pci_set_drvdata(pci, card); 155 142 dev++; 156 143 return 0; 157 }158 159 static void snd_trident_remove(struct pci_dev *pci)160 {161 snd_card_free(pci_get_drvdata(pci));162 144 } 163 145 … … 166 148 .id_table = snd_trident_ids, 167 149 .probe = snd_trident_probe, 168 .remove = snd_trident_remove,169 150 #ifdef CONFIG_PM_SLEEP 170 151 .driver = { -
GPL/trunk/alsa-kernel/pci/trident/trident.h
r703 r717 252 252 __le32 *entries; /* 16k-aligned TLB table */ 253 253 dma_addr_t entries_dmaaddr; /* 16k-aligned PCI address to TLB table */ 254 struct snd_dma_buffer buffer;254 struct snd_dma_buffer *buffer; 255 255 struct snd_util_memhdr * memhdr; /* page allocation list */ 256 struct snd_dma_buffer silent_page;256 struct snd_dma_buffer *silent_page; 257 257 }; 258 258 … … 401 401 int pcm_streams, 402 402 int pcm_spdif_device, 403 int max_wavetable_size, 404 struct snd_trident ** rtrident); 403 int max_wavetable_size); 405 404 int snd_trident_create_gameport(struct snd_trident *trident); 406 405 -
GPL/trunk/alsa-kernel/pci/trident/trident_main.c
r703 r717 47 47 static void snd_trident_clear_voices(struct snd_trident * trident, 48 48 unsigned short v_min, unsigned short v_max); 49 static int snd_trident_free(struct snd_trident *trident);49 static void snd_trident_free(struct snd_card *card); 50 50 51 51 /* … … 3312 3312 } 3313 3313 3314 static int snd_trident_dev_free(struct snd_device *device)3315 {3316 struct snd_trident *trident = device->device_data;3317 return snd_trident_free(trident);3318 }3319 3320 3314 /*--------------------------------------------------------------------------- 3321 3315 snd_trident_tlb_alloc … … 3337 3331 32kB region and correct offset when necessary */ 3338 3332 3339 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &trident->pci->dev, 3340 2 * SNDRV_TRIDENT_MAX_PAGES * 4, &trident->tlb.buffer) < 0) { 3333 trident->tlb.buffer = 3334 snd_devm_alloc_pages(&trident->pci->dev, SNDRV_DMA_TYPE_DEV, 3335 2 * SNDRV_TRIDENT_MAX_PAGES * 4); 3336 if (!trident->tlb.buffer) { 3341 3337 dev_err(trident->card->dev, "unable to allocate TLB buffer\n"); 3342 3338 return -ENOMEM; 3343 3339 } 3344 trident->tlb.entries = (__le32 *)ALIGN((unsigned long)trident->tlb.buffer .area, SNDRV_TRIDENT_MAX_PAGES * 4);3345 trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer .addr, SNDRV_TRIDENT_MAX_PAGES * 4);3340 trident->tlb.entries = (__le32 *)ALIGN((unsigned long)trident->tlb.buffer->area, SNDRV_TRIDENT_MAX_PAGES * 4); 3341 trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer->addr, SNDRV_TRIDENT_MAX_PAGES * 4); 3346 3342 3347 3343 /* allocate and setup silent page and initialise TLB entries */ 3348 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &trident->pci->dev, 3349 SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) { 3344 trident->tlb.silent_page = 3345 snd_devm_alloc_pages(&trident->pci->dev, SNDRV_DMA_TYPE_DEV, 3346 SNDRV_TRIDENT_PAGE_SIZE); 3347 if (!trident->tlb.silent_page) { 3350 3348 dev_err(trident->card->dev, "unable to allocate silent page\n"); 3351 3349 return -ENOMEM; 3352 3350 } 3353 memset(trident->tlb.silent_page .area, 0, SNDRV_TRIDENT_PAGE_SIZE);3351 memset(trident->tlb.silent_page->area, 0, SNDRV_TRIDENT_PAGE_SIZE); 3354 3352 for (i = 0; i < SNDRV_TRIDENT_MAX_PAGES; i++) 3355 trident->tlb.entries[i] = cpu_to_le32(trident->tlb.silent_page .addr & ~(SNDRV_TRIDENT_PAGE_SIZE-1));3353 trident->tlb.entries[i] = cpu_to_le32(trident->tlb.silent_page->addr & ~(SNDRV_TRIDENT_PAGE_SIZE-1)); 3356 3354 3357 3355 /* use emu memory block manager code to manage tlb page allocation */ … … 3510 3508 int pcm_streams, 3511 3509 int pcm_spdif_device, 3512 int max_wavetable_size, 3513 struct snd_trident ** rtrident) 3514 { 3515 struct snd_trident *trident; 3510 int max_wavetable_size) 3511 { 3512 struct snd_trident *trident = card->private_data; 3516 3513 int i, err; 3517 3514 struct snd_trident_voice *voice; 3518 3515 struct snd_trident_pcm_mixer *tmix; 3519 static const struct snd_device_ops ops = {3520 .dev_free = snd_trident_dev_free,3521 };3522 3523 *rtrident = NULL;3524 3516 3525 3517 /* enable PCI device */ 3526 err = pci _enable_device(pci);3518 err = pcim_enable_device(pci); 3527 3519 if (err < 0) 3528 3520 return err; … … 3531 3523 dev_err(card->dev, 3532 3524 "architecture does not support 30bit PCI busmaster DMA\n"); 3533 pci_disable_device(pci);3534 3525 return -ENXIO; 3535 3526 } 3536 3527 3537 trident = kzalloc(sizeof(*trident), GFP_KERNEL);3538 if (trident == NULL) {3539 pci_disable_device(pci);3540 return -ENOMEM;3541 }3542 3528 trident->device = (pci->vendor << 16) | pci->device; 3543 3529 trident->card = card; … … 3555 3541 trident->synth.max_size = max_wavetable_size * 1024; 3556 3542 trident->irq = -1; 3543 card->private_free = snd_trident_free; 3557 3544 3558 3545 trident->midi_port = TRID_REG(trident, T4D_MPU401_BASE); … … 3560 3547 3561 3548 err = pci_request_regions(pci, "Trident Audio"); 3562 if (err < 0) { 3563 kfree(trident); 3564 pci_disable_device(pci); 3549 if (err < 0) 3565 3550 return err; 3566 }3567 3551 trident->port = pci_resource_start(pci, 0); 3568 3552 3569 if ( request_irq(pci->irq, snd_trident_interrupt, IRQF_SHARED,3570 KBUILD_MODNAME, trident)) {3553 if (devm_request_irq(&pci->dev, pci->irq, snd_trident_interrupt, 3554 IRQF_SHARED, KBUILD_MODNAME, trident)) { 3571 3555 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 3572 snd_trident_free(trident);3573 3556 return -EBUSY; 3574 3557 } … … 3578 3561 /* allocate 16k-aligned TLB for NX cards */ 3579 3562 trident->tlb.entries = NULL; 3580 trident->tlb.buffer.area = NULL;3581 3563 if (trident->device == TRIDENT_DEVICE_ID_NX) { 3582 3564 err = snd_trident_tlb_alloc(trident); 3583 if (err < 0) { 3584 snd_trident_free(trident); 3565 if (err < 0) 3585 3566 return err; 3586 }3587 3567 } 3588 3568 … … 3604 3584 break; 3605 3585 } 3606 if (err < 0) { 3607 snd_trident_free(trident); 3586 if (err < 0) 3608 3587 return err; 3609 }3610 3611 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, trident, &ops);3612 if (err < 0) {3613 snd_trident_free(trident);3614 return err;3615 }3616 3588 3617 3589 err = snd_trident_mixer(trident, pcm_spdif_device); … … 3637 3609 3638 3610 snd_trident_proc_init(trident); 3639 *rtrident = trident;3640 3611 return 0; 3641 3612 } … … 3647 3618 the 4DWave card. 3648 3619 3649 Parameters: trident - device specific private data for 4DWave card3620 Parameters: card - card to release 3650 3621 3651 3622 Returns: None. … … 3653 3624 ---------------------------------------------------------------------------*/ 3654 3625 3655 static int snd_trident_free(struct snd_trident *trident) 3656 { 3626 static void snd_trident_free(struct snd_card *card) 3627 { 3628 struct snd_trident *trident = card->private_data; 3629 3657 3630 snd_trident_free_gameport(trident); 3658 3631 snd_trident_disable_eso(trident); … … 3663 3636 outl(0, TRID_REG(trident, SI_SERIAL_INTF_CTRL)); 3664 3637 } 3665 if (trident->irq >= 0) 3666 free_irq(trident->irq, trident); 3667 if (trident->tlb.buffer.area) { 3638 if (trident->tlb.buffer) { 3668 3639 outl(0, TRID_REG(trident, NX_TLBC)); 3669 3640 snd_util_memhdr_free(trident->tlb.memhdr); 3670 if (trident->tlb.silent_page.area) 3671 snd_dma_free_pages(&trident->tlb.silent_page); 3672 snd_dma_free_pages(&trident->tlb.buffer); 3673 } 3674 pci_release_regions(trident->pci); 3675 pci_disable_device(trident->pci); 3676 kfree(trident); 3677 return 0; 3641 } 3678 3642 } 3679 3643 -
GPL/trunk/alsa-kernel/pci/trident/trident_memory.c
r703 r717 32 32 #define set_tlb_bus(trident,page,addr) __set_tlb_bus(trident,page,addr) 33 33 /* fill TLB entrie(s) corresponding to page with silence pointer */ 34 #define set_silent_tlb(trident,page) __set_tlb_bus(trident, page, trident->tlb.silent_page .addr)34 #define set_silent_tlb(trident,page) __set_tlb_bus(trident, page, trident->tlb.silent_page->addr) 35 35 /* get aligned page from offset address */ 36 36 #define get_aligned_page(offset) ((offset) >> 12) … … 59 59 { 60 60 page <<= 1; 61 __set_tlb_bus(trident, page, trident->tlb.silent_page .addr);62 __set_tlb_bus(trident, page+1, trident->tlb.silent_page .addr);61 __set_tlb_bus(trident, page, trident->tlb.silent_page->addr); 62 __set_tlb_bus(trident, page+1, trident->tlb.silent_page->addr); 63 63 } 64 64 … … 93 93 page *= UNIT_PAGES; 94 94 for (i = 0; i < UNIT_PAGES; i++, page++) 95 __set_tlb_bus(trident, page, trident->tlb.silent_page .addr);95 __set_tlb_bus(trident, page, trident->tlb.silent_page->addr); 96 96 } 97 97 -
GPL/trunk/alsa-kernel/pci/via82xx.c
r703 r717 1916 1916 { 1917 1917 struct gameport *gp; 1918 struct resource *r;1919 1918 1920 1919 if (!joystick) 1921 1920 return -ENODEV; 1922 1921 1923 r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport");1924 if (!r) {1922 if (!devm_request_region(chip->card->dev, JOYSTICK_ADDR, 8, 1923 "VIA686 gameport")) { 1925 1924 dev_warn(chip->card->dev, "cannot reserve joystick port %#x\n", 1926 1925 JOYSTICK_ADDR); … … 1932 1931 dev_err(chip->card->dev, 1933 1932 "cannot allocate memory for gameport\n"); 1934 release_and_free_resource(r);1935 1933 return -ENOMEM; 1936 1934 } … … 1940 1938 gameport_set_dev_parent(gp, &chip->pci->dev); 1941 1939 gp->io = JOYSTICK_ADDR; 1942 gameport_set_port_data(gp, r);1943 1940 1944 1941 /* Enable legacy joystick port */ … … 1954 1951 { 1955 1952 if (chip->gameport) { 1956 struct resource *r = gameport_get_port_data(chip->gameport);1957 1958 1953 gameport_unregister_port(chip->gameport); 1959 1954 chip->gameport = NULL; 1960 release_and_free_resource(r);1961 1955 } 1962 1956 } … … 2068 2062 } 2069 2063 if (mpu_port >= 0x200) 2070 chip->mpu_res = request_region(mpu_port, 2, "VIA82xx MPU401"); 2064 chip->mpu_res = devm_request_region(&chip->pci->dev, mpu_port, 2065 2, "VIA82xx MPU401"); 2071 2066 if (chip->mpu_res) { 2072 2067 if (rev_h) … … 2307 2302 #endif /* CONFIG_PM_SLEEP */ 2308 2303 2309 static int snd_via82xx_free(struct via82xx *chip) 2310 { 2304 static void snd_via82xx_free(struct snd_card *card) 2305 { 2306 struct via82xx *chip = card->private_data; 2311 2307 unsigned int i; 2312 2308 2313 if (chip->irq < 0)2314 goto __end_hw;2315 2309 /* disable interrupts */ 2316 2310 for (i = 0; i < chip->num_devs; i++) 2317 2311 snd_via82xx_channel_reset(chip, &chip->devs[i]); 2318 2319 if (chip->irq >= 0)2320 free_irq(chip->irq, chip);2321 __end_hw:2322 release_and_free_resource(chip->mpu_res);2323 pci_release_regions(chip->pci);2324 2312 2325 2313 if (chip->chip_type == TYPE_VIA686) { … … 2328 2316 pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->old_legacy_cfg); 2329 2317 } 2330 pci_disable_device(chip->pci);2331 kfree(chip);2332 return 0;2333 }2334 2335 static int snd_via82xx_dev_free(struct snd_device *device)2336 {2337 struct via82xx *chip = device->device_data;2338 return snd_via82xx_free(chip);2339 2318 } 2340 2319 … … 2343 2322 int chip_type, 2344 2323 int revision, 2345 unsigned int ac97_clock, 2346 struct via82xx **r_via) 2347 { 2348 struct via82xx *chip; 2324 unsigned int ac97_clock) 2325 { 2326 struct via82xx *chip = card->private_data; 2349 2327 int err; 2350 static const struct snd_device_ops ops = { 2351 .dev_free = snd_via82xx_dev_free, 2352 }; 2353 2354 err = pci_enable_device(pci); 2328 2329 err = pcim_enable_device(pci); 2355 2330 if (err < 0) 2356 2331 return err; 2357 2358 chip = kzalloc(sizeof(*chip), GFP_KERNEL);2359 if (!chip) {2360 pci_disable_device(pci);2361 return -ENOMEM;2362 }2363 2332 2364 2333 chip->chip_type = chip_type; … … 2378 2347 2379 2348 err = pci_request_regions(pci, card->driver); 2380 if (err < 0) { 2381 kfree(chip); 2382 pci_disable_device(pci); 2349 if (err < 0) 2383 2350 return err; 2384 }2385 2351 chip->port = pci_resource_start(pci, 0); 2386 if ( request_irq(pci->irq,2387 chip_type == TYPE_VIA8233 ?2388 snd_via8233_interrupt :snd_via686_interrupt,2389 IRQF_SHARED,2390 KBUILD_MODNAME, chip)) {2352 if (devm_request_irq(&pci->dev, pci->irq, 2353 chip_type == TYPE_VIA8233 ? 2354 snd_via8233_interrupt : snd_via686_interrupt, 2355 IRQF_SHARED, 2356 KBUILD_MODNAME, chip)) { 2391 2357 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 2392 snd_via82xx_free(chip);2393 2358 return -EBUSY; 2394 2359 } 2395 2360 chip->irq = pci->irq; 2396 2361 card->sync_irq = chip->irq; 2362 card->private_free = snd_via82xx_free; 2397 2363 if (ac97_clock >= 8000 && ac97_clock <= 48000) 2398 2364 chip->ac97_clock = ac97_clock; 2399 2365 2400 2366 err = snd_via82xx_chip_init(chip); 2401 if (err < 0) { 2402 snd_via82xx_free(chip); 2367 if (err < 0) 2403 2368 return err; 2404 }2405 2406 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);2407 if (err < 0) {2408 snd_via82xx_free(chip);2409 return err;2410 }2411 2369 2412 2370 /* The 8233 ac97 controller does not implement the master bit … … 2414 2372 * We call pci_set_master here because it does not hurt. */ 2415 2373 pci_set_master(pci); 2416 2417 *r_via = chip;2418 2374 return 0; 2419 2375 } … … 2507 2463 }; 2508 2464 2509 static int snd_via82xx_probe(struct pci_dev *pci,2510 const struct pci_device_id *pci_id)2465 static int __snd_via82xx_probe(struct pci_dev *pci, 2466 const struct pci_device_id *pci_id) 2511 2467 { 2512 2468 struct snd_card *card; … … 2516 2472 int err; 2517 2473 2518 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); 2474 err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE, 2475 sizeof(*chip), &card); 2519 2476 if (err < 0) 2520 2477 return err; 2478 chip = card->private_data; 2521 2479 2522 2480 card_type = pci_id->driver_data; … … 2557 2515 default: 2558 2516 dev_err(card->dev, "invalid card type %d\n", card_type); 2559 err = -EINVAL; 2560 goto __error; 2517 return -EINVAL; 2561 2518 } 2562 2519 2563 2520 err = snd_via82xx_create(card, pci, chip_type, pci->revision, 2564 ac97_clock , &chip);2521 ac97_clock); 2565 2522 if (err < 0) 2566 goto __error; 2567 card->private_data = chip; 2523 return err; 2568 2524 err = snd_via82xx_mixer_new(chip, ac97_quirk); 2569 2525 if (err < 0) 2570 goto __error;2526 return err; 2571 2527 2572 2528 if (chip_type == TYPE_VIA686) { 2573 2529 err = snd_via686_pcm_new(chip); 2574 2530 if (err < 0) 2575 goto __error;2531 return err; 2576 2532 err = snd_via686_init_misc(chip); 2577 2533 if (err < 0) 2578 goto __error;2534 return err; 2579 2535 } else { 2580 2536 if (chip_type == TYPE_VIA8233A) { 2581 2537 err = snd_via8233a_pcm_new(chip); 2582 2538 if (err < 0) 2583 goto __error;2539 return err; 2584 2540 // chip->dxs_fixed = 1; /* FIXME: use 48k for DXS #3? */ 2585 2541 } else { 2586 2542 err = snd_via8233_pcm_new(chip); 2587 2543 if (err < 0) 2588 goto __error;2544 return err; 2589 2545 if (dxs_support == VIA_DXS_48K) 2590 2546 chip->dxs_fixed = 1; … … 2598 2554 err = snd_via8233_init_misc(chip); 2599 2555 if (err < 0) 2600 goto __error;2556 return err; 2601 2557 } 2602 2558 … … 2612 2568 2613 2569 err = snd_card_register(card); 2614 if (err < 0) { 2615 snd_card_free(card); 2570 if (err < 0) 2616 2571 return err; 2617 }2618 2572 pci_set_drvdata(pci, card); 2619 2573 return 0; 2620 2621 __error: 2622 snd_card_free(card); 2623 return err; 2624 } 2625 2626 static void snd_via82xx_remove(struct pci_dev *pci) 2627 { 2628 snd_card_free(pci_get_drvdata(pci)); 2574 } 2575 2576 static int snd_via82xx_probe(struct pci_dev *pci, 2577 const struct pci_device_id *pci_id) 2578 { 2579 return snd_card_free_on_error(&pci->dev, __snd_via82xx_probe(pci, pci_id)); 2629 2580 } 2630 2581 … … 2633 2584 .id_table = snd_via82xx_ids, 2634 2585 .probe = snd_via82xx_probe, 2635 .remove = snd_via82xx_remove,2636 2586 .driver = { 2637 2587 .pm = SND_VIA82XX_PM_OPS, -
GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci.c
r703 r717 110 110 111 111 if (!r) { 112 r = request_region(io_port, 1, "YMFPCI gameport"); 112 r = devm_request_region(&chip->pci->dev, io_port, 1, 113 "YMFPCI gameport"); 113 114 if (!r) { 114 115 dev_err(chip->card->dev, … … 122 123 dev_err(chip->card->dev, 123 124 "cannot allocate memory for gameport\n"); 124 release_and_free_resource(r);125 125 return -ENOMEM; 126 126 } … … 131 131 gameport_set_dev_parent(gp, &chip->pci->dev); 132 132 gp->io = io_port; 133 gameport_set_port_data(gp, r);134 133 135 134 if (chip->pci->device >= 0x0010) /* YMF 744/754 */ … … 147 146 { 148 147 if (chip->gameport) { 149 struct resource *r = gameport_get_port_data(chip->gameport);150 151 148 gameport_unregister_port(chip->gameport); 152 149 chip->gameport = NULL; 153 154 release_and_free_resource(r);155 150 } 156 151 } … … 181 176 182 177 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 183 0, &card); 184 if (err < 0) 185 return err; 178 sizeof(*chip), &card); 179 if (err < 0) 180 return err; 181 chip = card->private_data; 186 182 187 183 switch (pci_id->device) { … … 204 200 } 205 201 if (fm_port[dev] > 0) 206 fm_res = request_region(fm_port[dev], 4, "YMFPCI OPL3"); 202 fm_res = devm_request_region(&pci->dev, fm_port[dev], 203 4, "YMFPCI OPL3"); 207 204 if (fm_res) { 208 205 legacy_ctrl |= YMFPCI_LEGACY_FMEN; … … 214 211 } 215 212 if (mpu_port[dev] > 0) 216 mpu_res = request_region(mpu_port[dev], 2, "YMFPCI MPU401"); 213 mpu_res = devm_request_region(&pci->dev, mpu_port[dev], 214 2, "YMFPCI MPU401"); 217 215 if (mpu_res) { 218 216 legacy_ctrl |= YMFPCI_LEGACY_MEN; … … 228 226 } 229 227 if (fm_port[dev] > 0) 230 fm_res = request_region(fm_port[dev], 4, "YMFPCI OPL3"); 228 fm_res = devm_request_region(&pci->dev, fm_port[dev], 229 4, "YMFPCI OPL3"); 231 230 if (fm_res) { 232 231 legacy_ctrl |= YMFPCI_LEGACY_FMEN; … … 243 242 } 244 243 if (mpu_port[dev] > 0) 245 mpu_res = request_region(mpu_port[dev], 2, "YMFPCI MPU401"); 244 mpu_res = devm_request_region(&pci->dev, mpu_port[dev], 245 2, "YMFPCI MPU401"); 246 246 if (mpu_res) { 247 247 legacy_ctrl |= YMFPCI_LEGACY_MEN; … … 258 258 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); 259 259 pci_write_config_word(pci, PCIR_DSXG_ELEGACY, legacy_ctrl2); 260 err = snd_ymfpci_create(card, pci, old_legacy_ctrl, &chip); 261 if (err < 0) { 262 release_and_free_resource(mpu_res); 263 release_and_free_resource(fm_res); 264 goto free_card; 265 } 266 chip->fm_res = fm_res; 267 chip->mpu_res = mpu_res; 268 card->private_data = chip; 260 err = snd_ymfpci_create(card, pci, old_legacy_ctrl); 261 if (err < 0) 262 return err; 269 263 270 264 strcpy(card->driver, str); … … 276 270 err = snd_ymfpci_pcm(chip, 0); 277 271 if (err < 0) 278 goto free_card;272 return err; 279 273 280 274 err = snd_ymfpci_pcm_spdif(chip, 1); 281 275 if (err < 0) 282 goto free_card;276 return err; 283 277 284 278 err = snd_ymfpci_mixer(chip, rear_switch[dev]); 285 279 if (err < 0) 286 goto free_card;280 return err; 287 281 288 282 if (chip->ac97->ext_id & AC97_EI_SDAC) { 289 283 err = snd_ymfpci_pcm_4ch(chip, 2); 290 284 if (err < 0) 291 goto free_card;285 return err; 292 286 293 287 err = snd_ymfpci_pcm2(chip, 3); 294 288 if (err < 0) 295 goto free_card;289 return err; 296 290 } 297 291 err = snd_ymfpci_timer(chip, 0); 298 292 if (err < 0) 299 goto free_card;300 301 if ( chip->mpu_res) {293 return err; 294 295 if (mpu_res) { 302 296 err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI, 303 297 mpu_port[dev], … … 313 307 } 314 308 } 315 if ( chip->fm_res) {309 if (fm_res) { 316 310 err = snd_opl3_create(card, 317 311 fm_port[dev], … … 328 322 if (err < 0) { 329 323 dev_err(card->dev, "cannot create opl3 hwdep\n"); 330 goto free_card;324 return err; 331 325 } 332 326 } … … 337 331 err = snd_card_register(card); 338 332 if (err < 0) 339 goto free_card;333 return err; 340 334 341 335 pci_set_drvdata(pci, card); 342 336 dev++; 343 337 return 0; 344 345 free_card:346 snd_card_free(card);347 return err;348 }349 350 static void snd_card_ymfpci_remove(struct pci_dev *pci)351 {352 snd_card_free(pci_get_drvdata(pci));353 338 } 354 339 … … 357 342 .id_table = snd_ymfpci_ids, 358 343 .probe = snd_card_ymfpci_probe, 359 .remove = snd_card_ymfpci_remove,360 344 #ifdef CONFIG_PM_SLEEP 361 345 .driver = { -
GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci.h
r679 r717 276 276 unsigned long reg_area_phys; 277 277 void __iomem *reg_area_virt; 278 struct resource *res_reg_area;279 struct resource *fm_res;280 struct resource *mpu_res;281 278 282 279 unsigned short old_legacy_ctrl; … … 285 282 #endif 286 283 287 struct snd_dma_buffer work_ptr;284 struct snd_dma_buffer *work_ptr; 288 285 289 286 unsigned int bank_size_playback; … … 359 356 int snd_ymfpci_create(struct snd_card *card, 360 357 struct pci_dev *pci, 361 unsigned short old_legacy_ctrl, 362 struct snd_ymfpci ** rcodec); 358 unsigned short old_legacy_ctrl); 363 359 void snd_ymfpci_free_gameport(struct snd_ymfpci *chip); 364 360 -
GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci_main.c
r703 r717 2121 2121 /* work_ptr must be aligned to 256 bytes, but it's already 2122 2122 covered with the kernel page allocation mechanism */ 2123 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, 2124 size, &chip->work_ptr) < 0) 2123 chip->work_ptr = snd_devm_alloc_pages(&chip->pci->dev, 2124 SNDRV_DMA_TYPE_DEV, size); 2125 if (!chip->work_ptr) 2125 2126 return -ENOMEM; 2126 ptr = chip->work_ptr .area;2127 ptr_addr = chip->work_ptr .addr;2127 ptr = chip->work_ptr->area; 2128 ptr_addr = chip->work_ptr->addr; 2128 2129 memset(ptr, 0, size); /* for sure */ 2129 2130 … … 2170 2171 2171 2172 snd_BUG_ON(ptr + chip->work_size != 2172 chip->work_ptr .area + chip->work_ptr.bytes);2173 chip->work_ptr->area + chip->work_ptr->bytes); 2173 2174 2174 2175 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, chip->bank_base_playback_addr); … … 2201 2202 } 2202 2203 2203 static int snd_ymfpci_free(struct snd_ymfpci *chip) 2204 { 2204 static void snd_ymfpci_free(struct snd_card *card) 2205 { 2206 struct snd_ymfpci *chip = card->private_data; 2205 2207 u16 ctrl; 2206 2208 2207 if (snd_BUG_ON(!chip)) 2208 return -EINVAL; 2209 2210 if (chip->res_reg_area) { /* don't touch busy hardware */ 2211 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); 2212 snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0); 2213 snd_ymfpci_writel(chip, YDSXGR_LEGACYOUTVOL, 0); 2214 snd_ymfpci_writel(chip, YDSXGR_STATUS, ~0); 2215 snd_ymfpci_disable_dsp(chip); 2216 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, 0); 2217 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, 0); 2218 snd_ymfpci_writel(chip, YDSXGR_EFFCTRLBASE, 0); 2219 snd_ymfpci_writel(chip, YDSXGR_WORKBASE, 0); 2220 snd_ymfpci_writel(chip, YDSXGR_WORKSIZE, 0); 2221 ctrl = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); 2222 snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007); 2223 } 2209 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); 2210 snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0); 2211 snd_ymfpci_writel(chip, YDSXGR_LEGACYOUTVOL, 0); 2212 snd_ymfpci_writel(chip, YDSXGR_STATUS, ~0); 2213 snd_ymfpci_disable_dsp(chip); 2214 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, 0); 2215 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, 0); 2216 snd_ymfpci_writel(chip, YDSXGR_EFFCTRLBASE, 0); 2217 snd_ymfpci_writel(chip, YDSXGR_WORKBASE, 0); 2218 snd_ymfpci_writel(chip, YDSXGR_WORKSIZE, 0); 2219 ctrl = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); 2220 snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007); 2224 2221 2225 2222 snd_ymfpci_ac3_done(chip); 2226 2223 2227 /* Set PCI device to D3 state */2228 #if 02229 /* FIXME: temporarily disabled, otherwise we cannot fire up2230 * the chip again unless reboot. ACPI bug?2231 */2232 pci_set_power_state(chip->pci, PCI_D3hot);2233 #endif2234 2235 #ifdef CONFIG_PM_SLEEP2236 kfree(chip->saved_regs);2237 #endif2238 if (chip->irq >= 0)2239 free_irq(chip->irq, chip);2240 release_and_free_resource(chip->mpu_res);2241 release_and_free_resource(chip->fm_res);2242 2224 snd_ymfpci_free_gameport(chip); 2243 iounmap(chip->reg_area_virt); 2244 if (chip->work_ptr.area) 2245 snd_dma_free_pages(&chip->work_ptr); 2246 2247 release_and_free_resource(chip->res_reg_area); 2248 2225 2249 2226 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); 2250 2227 2251 pci_disable_device(chip->pci);2252 2228 release_firmware(chip->dsp_microcode); 2253 2229 release_firmware(chip->controller_microcode); 2254 kfree(chip);2255 return 0;2256 }2257 2258 static int snd_ymfpci_dev_free(struct snd_device *device)2259 {2260 struct snd_ymfpci *chip = device->device_data;2261 return snd_ymfpci_free(chip);2262 2230 } 2263 2231 … … 2351 2319 int snd_ymfpci_create(struct snd_card *card, 2352 2320 struct pci_dev *pci, 2353 unsigned short old_legacy_ctrl, 2354 struct snd_ymfpci **rchip) 2355 { 2356 struct snd_ymfpci *chip; 2321 unsigned short old_legacy_ctrl) 2322 { 2323 struct snd_ymfpci *chip = card->private_data; 2357 2324 int err; 2358 static const struct snd_device_ops ops = { 2359 .dev_free = snd_ymfpci_dev_free, 2360 }; 2361 2362 *rchip = NULL; 2363 2325 2364 2326 /* enable PCI device */ 2365 err = pci _enable_device(pci);2327 err = pcim_enable_device(pci); 2366 2328 if (err < 0) 2367 2329 return err; 2368 2330 2369 chip = kzalloc(sizeof(*chip), GFP_KERNEL);2370 if (chip == NULL) {2371 pci_disable_device(pci);2372 return -ENOMEM;2373 }2374 2331 chip->old_legacy_ctrl = old_legacy_ctrl; 2375 2332 spin_lock_init(&chip->reg_lock); … … 2382 2339 chip->device_id = pci->device; 2383 2340 chip->rev = pci->revision; 2341 2342 err = pci_request_regions(pci, "YMFPCI"); 2343 if (err < 0) 2344 return err; 2345 2384 2346 chip->reg_area_phys = pci_resource_start(pci, 0); 2385 chip->reg_area_virt = ioremap(chip->reg_area_phys, 0x8000); 2386 pci_set_master(pci); 2387 chip->src441_used = -1; 2388 2389 chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI"); 2390 if (!chip->res_reg_area) { 2347 chip->reg_area_virt = devm_ioremap(&pci->dev, chip->reg_area_phys, 0x8000); 2348 if (!chip->reg_area_virt) { 2391 2349 dev_err(chip->card->dev, 2392 2350 "unable to grab memory region 0x%lx-0x%lx\n", 2393 2351 chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); 2394 err = -EBUSY; 2395 goto free_chip; 2396 } 2397 if (request_irq(pci->irq, snd_ymfpci_interrupt, IRQF_SHARED, 2352 return -EBUSY; 2353 } 2354 pci_set_master(pci); 2355 chip->src441_used = -1; 2356 2357 if (devm_request_irq(&pci->dev, pci->irq, snd_ymfpci_interrupt, IRQF_SHARED, 2398 2358 KBUILD_MODNAME, chip)) { 2399 2359 dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq); 2400 err = -EBUSY; 2401 goto free_chip; 2360 return -EBUSY; 2402 2361 } 2403 2362 chip->irq = pci->irq; 2404 2363 card->sync_irq = chip->irq; 2364 card->private_free = snd_ymfpci_free; 2405 2365 2406 2366 snd_ymfpci_aclink_reset(pci); 2407 if (snd_ymfpci_codec_ready(chip, 0) < 0) { 2408 err = -EIO; 2409 goto free_chip; 2410 } 2367 if (snd_ymfpci_codec_ready(chip, 0) < 0) 2368 return -EIO; 2411 2369 2412 2370 err = snd_ymfpci_request_firmware(chip); 2413 2371 if (err < 0) { 2414 2372 dev_err(chip->card->dev, "firmware request failed: %d\n", err); 2415 goto free_chip;2373 return err; 2416 2374 } 2417 2375 snd_ymfpci_download_image(chip); … … 2419 2377 udelay(100); /* seems we need a delay after downloading image.. */ 2420 2378 2421 if (snd_ymfpci_memalloc(chip) < 0) { 2422 err = -EIO; 2423 goto free_chip; 2424 } 2379 if (snd_ymfpci_memalloc(chip) < 0) 2380 return -EIO; 2425 2381 2426 2382 err = snd_ymfpci_ac3_init(chip); 2427 2383 if (err < 0) 2428 goto free_chip;2384 return err; 2429 2385 2430 2386 #ifdef CONFIG_PM_SLEEP 2431 chip->saved_regs = kmalloc_array(YDSXGR_NUM_SAVED_REGS, sizeof(u32), 2432 GFP_KERNEL); 2433 if (chip->saved_regs == NULL) { 2434 err = -ENOMEM; 2435 goto free_chip; 2436 } 2387 chip->saved_regs = devm_kmalloc_array(&pci->dev, YDSXGR_NUM_SAVED_REGS, 2388 sizeof(u32), GFP_KERNEL); 2389 if (!chip->saved_regs) 2390 return -ENOMEM; 2437 2391 #endif 2438 2392 2439 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);2440 if (err < 0)2441 goto free_chip;2442 2443 2393 snd_ymfpci_proc_init(card, chip); 2444 2394 2445 *rchip = chip; 2446 return 0; 2447 2448 free_chip: 2449 snd_ymfpci_free(chip); 2450 return err; 2451 } 2395 return 0; 2396 } -
GPL/trunk/alsa-kernel/synth/emux/emux.c
r703 r717 95 95 emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice), 96 96 GFP_KERNEL); 97 if (emu-> voices == NULL)97 if (emu->name == NULL || emu->voices == NULL) 98 98 return -ENOMEM; 99 99 -
GPL/trunk/include/linux/device.h
r679 r717 290 290 /* debugging and troubleshooting/diagnostic helpers. */ 291 291 extern const char *dev_driver_string(const struct device *dev); 292 292 #define devm_kzalloc(A, B, C) kzalloc(B, C) 293 #define devm_kmalloc(A, B, C) kmalloc(B, C) 294 #define devm_kcalloc(A, B, C, D) kmalloc(B, C) 295 #define devm_kmalloc_array(A, B, C, D) kmalloc_array(B, C, D) 296 297 298 /* allows to add/remove a custom action to devres stack */ 299 int devm_add_action(struct device *dev, void (*action)(void *), void *data); 300 void devm_remove_action(struct device *dev, void (*action)(void *), void *data); 293 301 #endif /* _LINUX_DEVICE_H */ 294 302 -
GPL/trunk/include/linux/interrupt.h
r679 r717 154 154 155 155 static inline void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id) {} 156 #define devm_request_irq(A, B, C, D, E, F) request_irq(B, C, D, E, F) 157 156 158 #endif -
GPL/trunk/include/linux/io.h
r679 r717 7 7 #include <linux/err.h> 8 8 9 #define devm_ioremap(A, B, C) ioremap(B, C) 9 10 #endif /* _LINUX_IO_H */ -
GPL/trunk/include/linux/ioport.h
r679 r717 111 111 extern int autoirq_report(int waittime); 112 112 113 #define devm_request_region(A, B, C, D) request_region(B, C, D) 113 114 #endif /* _LINUX_IOPORT_H */ -
GPL/trunk/include/linux/leds.h
r679 r717 20 20 }; 21 21 22 enum led_audio { 23 LED_AUDIO_MUTE, /* master mute LED */ 24 LED_AUDIO_MICMUTE, /* mic mute LED */ 25 NUM_AUDIO_LEDS 26 }; 22 27 #endif /* _LINUX_LEDS_H */ -
GPL/trunk/include/linux/pci.h
r709 r717 770 770 771 771 #define dev_is_pci(d) (true) 772 772 int pcim_enable_device(struct pci_dev *pdev); 773 #define pcim_iomap pci_iomap 774 int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name); 773 775 #endif /* LINUX_PCI_H */ -
GPL/trunk/include/linux/pm.h
r689 r717 246 246 struct device * pm_parent; 247 247 struct list_head entry; 248 enum rpm_status runtime_status; 248 249 }; 249 250 -
GPL/trunk/include/linux/string.h
r679 r717 30 30 #define vmemdup_user memdup_user 31 31 #define scnprintf snprintf 32 ssize_t strscpy(char *dest, const char *src, size_t count); 33 32 34 #endif 33 35 -
GPL/trunk/lib32/devres.c
r679 r717 36 36 }; 37 37 38 #define devres_log(dev, node, op) do {} while (0) 39 38 40 /* 39 41 * Release functions for devres group. These callbacks are used only … … 75 77 76 78 #define devres_log(dev, node, op) do {} while (0) 79 80 static void add_dr(struct device *dev, struct devres_node *node) 81 { 82 devres_log(dev, node, "ADD"); 83 BUG_ON(!list_empty(&node->entry)); 84 //#ifndef TARGET_OS2 85 /* Traps here on OS/2 */ 86 list_add_tail(&node->entry, &dev->devres_head); 87 //#endif 88 } 89 90 /** 91 * devres_add - Register device resource 92 * @dev: Device to add resource to 93 * @res: Resource to register 94 * 95 * Register devres @res to @dev. @res should have been allocated 96 * using devres_alloc(). On driver detach, the associated release 97 * function will be invoked and devres will be freed automatically. 98 */ 99 void devres_add(struct device *dev, void *res) 100 { 101 /* Traps here on OS/2 */ 102 struct devres *dr = container_of(res, struct devres, data); 103 unsigned long flags; 104 spin_lock_irqsave(&dev->devres_lock, flags); 105 add_dr(dev, &dr->node); 106 spin_unlock_irqrestore(&dev->devres_lock, flags); 107 } 77 108 78 109 /** … … 273 304 return NULL; 274 305 } 306 307 /** 308 * devm_add_action() - add a custom action to list of managed resources 309 * @dev: Device that owns the action 310 * @action: Function that should be called 311 * @data: Pointer to data passed to @action implementation 312 * 313 * This adds a custom action to the list of managed resources so that 314 * it gets executed as part of standard resource unwinding. 315 */ 316 int devm_add_action(struct device *dev, void (*action)(void *), void *data) 317 { 318 return 0; 319 } 320 321 /** 322 * devm_remove_action() - removes previously added custom action 323 * @dev: Device that owns the action 324 * @action: Function implementing the action 325 * @data: Pointer to data passed to @action implementation 326 * 327 * Removes instance of @action previously added by devm_add_action(). 328 * Both action and data should match one of the existing entries. 329 */ 330 void devm_remove_action(struct device *dev, void (*action)(void *), void *data) 331 { 332 } -
GPL/trunk/lib32/driver.c
r679 r717 26 26 #include "base.h" 27 27 28 #define devres_log(dev, node, op) do {} while (0)29 30 struct devres_node {31 struct list_head entry;32 dr_release_t release;33 #ifdef CONFIG_DEBUG_DEVRES34 const char *name;35 size_t size;36 #endif37 };38 39 struct devres {40 struct devres_node node;41 /* -- 3 pointers */42 unsigned long long data[1]; /* guarantee ull alignment */43 };44 45 46 28 /** 47 29 * dev_set_name - set a device name … … 60 42 } 61 43 62 static void add_dr(struct device *dev, struct devres_node *node) 63 { 64 devres_log(dev, node, "ADD"); 65 BUG_ON(!list_empty(&node->entry)); 66 list_add_tail(&node->entry, &dev->devres_head); 67 } 68 69 /** 70 * devres_add - Register device resource 71 * @dev: Device to add resource to 72 * @res: Resource to register 73 * 74 * Register devres @res to @dev. @res should have been allocated 75 * using devres_alloc(). On driver detach, the associated release 76 * function will be invoked and devres will be freed automatically. 77 */ 78 void devres_add(struct device *dev, void *res) 79 { 80 struct devres *dr = container_of(res, struct devres, data); 81 unsigned long flags; 82 83 spin_lock_irqsave(&dev->devres_lock, flags); 84 add_dr(dev, &dr->node); 85 spin_unlock_irqrestore(&dev->devres_lock, flags); 86 } 44 87 45 88 46 static struct device *next_device(struct klist_iter *i) -
GPL/trunk/lib32/pci.c
r679 r717 455 455 456 456 /** 457 * pcim_enable_device - Managed pci_enable_device() 458 * @pdev: PCI device to be initialized 459 * 460 * Managed pci_enable_device(). 461 */ 462 int pcim_enable_device(struct pci_dev *pdev) 463 { 464 int rc; 465 466 rc = pci_enable_device(pdev); 467 return rc; 468 } 469 470 /** 457 471 * Initialize device before it's used by a driver. Ask low-level code 458 472 * to enable I/O and memory. Wake up the device if it was suspended.
Note:
See TracChangeset
for help on using the changeset viewer.