Changeset 679 for GPL/trunk/alsa-kernel/pci/emu10k1/p16v.c
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/emu10k1/p16v.c
r464 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> … … 70 71 * DAC: CS4382-K (8-channel, 24bit, 192Khz) 71 72 * 72 * This code was init ally based on code from ALSA's emu10k1x.c which is:73 * This code was initially based on code from ALSA's emu10k1x.c which is: 73 74 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> 74 *75 * This program is free software; you can redistribute it and/or modify76 * it under the terms of the GNU General Public License as published by77 * the Free Software Foundation; either version 2 of the License, or78 * (at your option) any later version.79 *80 * This program is distributed in the hope that it will be useful,81 * but WITHOUT ANY WARRANTY; without even the implied warranty of82 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the83 * GNU General Public License for more details.84 *85 * You should have received a copy of the GNU General Public License86 * along with this program; if not, write to the Free Software87 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA88 *89 75 */ 90 76 #include <linux/delay.h> … … 123 109 124 110 /* hardware definition */ 125 static struct snd_pcm_hardware snd_p16v_playback_hw = {111 static const struct snd_pcm_hardware snd_p16v_playback_hw = { 126 112 .info = SNDRV_PCM_INFO_MMAP | 127 113 SNDRV_PCM_INFO_INTERLEAVED | … … 144 130 }; 145 131 146 static struct snd_pcm_hardware snd_p16v_capture_hw = {132 static const struct snd_pcm_hardware snd_p16v_capture_hw = { 147 133 .info = (SNDRV_PCM_INFO_MMAP | 148 134 SNDRV_PCM_INFO_INTERLEAVED | … … 167 153 { 168 154 struct snd_emu10k1_pcm *epcm = runtime->private_data; 169 170 if (epcm) { 171 /* snd_printk(KERN_DEBUG "epcm free: %p\n", epcm); */ 172 kfree(epcm); 173 } 155 156 kfree(epcm); 174 157 } 175 158 … … 184 167 185 168 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 186 /* snd_printk(KERN_DEBUG"epcm kcalloc: %p\n", epcm); */169 /* dev_dbg(emu->card->dev, "epcm kcalloc: %p\n", epcm); */ 187 170 188 171 if (epcm == NULL) … … 191 174 epcm->substream = substream; 192 175 /* 193 snd_printk(KERN_DEBUG"epcm device=%d, channel_id=%d\n",176 dev_dbg(emu->card->dev, "epcm device=%d, channel_id=%d\n", 194 177 substream->pcm->device, channel_id); 195 178 */ … … 204 187 channel->use=1; 205 188 #if 0 /* debug */ 206 snd_printk(KERN_DEBUG189 dev_dbg(emu->card->dev, 207 190 "p16v: open channel_id=%d, channel=%p, use=0x%x\n", 208 191 channel_id, channel, channel->use); 209 printk(KERN_DEBUG"open:channel_id=%d, chip=%p, channel=%p\n",192 dev_dbg(emu->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n", 210 193 channel_id, chip, channel); 211 194 #endif /* debug */ … … 232 215 233 216 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 234 /* snd_printk(KERN_DEBUG"epcm kcalloc: %p\n", epcm); */217 /* dev_dbg(emu->card->dev, "epcm kcalloc: %p\n", epcm); */ 235 218 236 219 if (epcm == NULL) … … 239 222 epcm->substream = substream; 240 223 /* 241 snd_printk(KERN_DEBUG"epcm device=%d, channel_id=%d\n",224 dev_dbg(emu->card->dev, "epcm device=%d, channel_id=%d\n", 242 225 substream->pcm->device, channel_id); 243 226 */ … … 252 235 channel->use=1; 253 236 #if 0 /* debug */ 254 snd_printk(KERN_DEBUG237 dev_dbg(emu->card->dev, 255 238 "p16v: open channel_id=%d, channel=%p, use=0x%x\n", 256 239 channel_id, channel, channel->use); 257 printk(KERN_DEBUG"open:channel_id=%d, chip=%p, channel=%p\n",240 dev_dbg(emu->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n", 258 241 channel_id, chip, channel); 259 242 #endif /* debug */ … … 299 282 return snd_p16v_pcm_open_capture_channel(substream, 0); 300 283 } 301 302 /* hw_params callback */303 static int snd_p16v_pcm_hw_params_playback(struct snd_pcm_substream *substream,304 struct snd_pcm_hw_params *hw_params)305 {306 int result;307 result = snd_pcm_lib_malloc_pages(substream,308 params_buffer_bytes(hw_params));309 return result;310 }311 312 /* hw_params callback */313 static int snd_p16v_pcm_hw_params_capture(struct snd_pcm_substream *substream,314 struct snd_pcm_hw_params *hw_params)315 {316 int result;317 result = snd_pcm_lib_malloc_pages(substream,318 params_buffer_bytes(hw_params));319 return result;320 }321 322 323 /* hw_free callback */324 static int snd_p16v_pcm_hw_free_playback(struct snd_pcm_substream *substream)325 {326 int result;327 result = snd_pcm_lib_free_pages(substream);328 return result;329 }330 331 /* hw_free callback */332 static int snd_p16v_pcm_hw_free_capture(struct snd_pcm_substream *substream)333 {334 int result;335 result = snd_pcm_lib_free_pages(substream);336 return result;337 }338 339 284 340 285 /* prepare playback callback */ … … 350 295 351 296 #if 0 /* debug */ 352 snd_printk(KERN_DEBUG "prepare:channel_number=%d, rate=%d, " 297 dev_dbg(emu->card->dev, 298 "prepare:channel_number=%d, rate=%d, " 353 299 "format=0x%x, channels=%d, buffer_size=%ld, " 354 300 "period_size=%ld, periods=%u, frames_to_bytes=%d\n", … … 356 302 runtime->buffer_size, runtime->period_size, 357 303 runtime->periods, frames_to_bytes(runtime, 1)); 358 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n", 304 dev_dbg(emu->card->dev, 305 "dma_addr=%x, dma_area=%p, table_base=%p\n", 359 306 runtime->dma_addr, runtime->dma_area, table_base); 360 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n", 307 dev_dbg(emu->card->dev, 308 "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n", 361 309 emu->p16v_buffer.addr, emu->p16v_buffer.area, 362 310 emu->p16v_buffer.bytes); … … 406 354 407 355 /* 408 printk(KERN_DEBUG"prepare capture:channel_number=%d, rate=%d, "356 dev_dbg(emu->card->dev, "prepare capture:channel_number=%d, rate=%d, " 409 357 "format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, " 410 358 "frames_to_bytes=%d\n", … … 492 440 epcm = runtime->private_data; 493 441 channel = substream->pcm->device-emu->p16v_device_offset; 494 /* snd_printk(KERN_DEBUG"p16v channel=%d\n", channel); */442 /* dev_dbg(emu->card->dev, "p16v channel=%d\n", channel); */ 495 443 epcm->running = running; 496 444 basic |= (0x1<<channel); … … 498 446 snd_pcm_trigger_done(s, substream); 499 447 } 500 /* snd_printk(KERN_DEBUG"basic=0x%x, inte=0x%x\n", basic, inte); */448 /* dev_dbg(emu->card->dev, "basic=0x%x, inte=0x%x\n", basic, inte); */ 501 449 502 450 switch (cmd) { … … 589 537 if (ptr >= runtime->buffer_size) { 590 538 ptr -= runtime->buffer_size; 591 printk(KERN_WARNING"buffer capture limited!\n");539 dev_warn(emu->card->dev, "buffer capture limited!\n"); 592 540 } 593 541 /* 594 printk(KERN_DEBUG"ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "542 dev_dbg(emu->card->dev, "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, " 595 543 "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", 596 544 ptr1, ptr2, ptr, (int)runtime->buffer_size, … … 602 550 603 551 /* operators */ 604 static struct snd_pcm_ops snd_p16v_playback_front_ops = {552 static const struct snd_pcm_ops snd_p16v_playback_front_ops = { 605 553 .open = snd_p16v_pcm_open_playback_front, 606 554 .close = snd_p16v_pcm_close_playback, 607 .ioctl = snd_pcm_lib_ioctl,608 .hw_params = snd_p16v_pcm_hw_params_playback,609 .hw_free = snd_p16v_pcm_hw_free_playback,610 555 .prepare = snd_p16v_pcm_prepare_playback, 611 556 .trigger = snd_p16v_pcm_trigger_playback, … … 613 558 }; 614 559 615 static struct snd_pcm_ops snd_p16v_capture_ops = {560 static const struct snd_pcm_ops snd_p16v_capture_ops = { 616 561 .open = snd_p16v_pcm_open_capture, 617 562 .close = snd_p16v_pcm_close_capture, 618 .ioctl = snd_pcm_lib_ioctl,619 .hw_params = snd_p16v_pcm_hw_params_capture,620 .hw_free = snd_p16v_pcm_hw_free_capture,621 563 .prepare = snd_p16v_pcm_prepare_capture, 622 564 .trigger = snd_p16v_pcm_trigger_capture, … … 631 573 snd_dma_free_pages(&chip->p16v_buffer); 632 574 /* 633 snd_printk(KERN_DEBUG"period lables free: %p\n",575 dev_dbg(chip->card->dev, "period lables free: %p\n", 634 576 &chip->p16v_buffer); 635 577 */ … … 638 580 } 639 581 640 int __devinit snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm)582 int snd_p16v_pcm(struct snd_emu10k1 *emu, int device) 641 583 { 642 584 struct snd_pcm *pcm; … … 645 587 int capture=1; 646 588 647 /* snd_printk(KERN_DEBUG"snd_p16v_pcm called. device=%d\n", device); */589 /* dev_dbg(emu->card->dev, "snd_p16v_pcm called. device=%d\n", device); */ 648 590 emu->p16v_device_offset = device; 649 if (rpcm)650 *rpcm = NULL;651 591 652 592 if ((err = snd_pcm_new(emu->card, "p16v", device, 1, capture, &pcm)) < 0) … … 667 607 substream; 668 608 substream = substream->next) { 669 if ((err = snd_pcm_lib_preallocate_pages(substream, 670 SNDRV_DMA_TYPE_DEV, 671 snd_dma_pci_data(emu->pci), 672 ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0) 673 return err; 609 snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, 610 &emu->pci->dev, 611 (65536 - 64) * 8, 612 (65536 - 64) * 8); 674 613 /* 675 snd_printk(KERN_DEBUG614 dev_dbg(emu->card->dev, 676 615 "preallocate playback substream: err=%d\n", err); 677 616 */ … … 681 620 substream; 682 621 substream = substream->next) { 683 if ((err = snd_pcm_lib_preallocate_pages(substream, 684 SNDRV_DMA_TYPE_DEV, 685 snd_dma_pci_data(emu->pci), 686 65536 - 64, 65536 - 64)) < 0) 687 return err; 622 snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, 623 &emu->pci->dev, 624 65536 - 64, 65536 - 64); 688 625 /* 689 snd_printk(KERN_DEBUG626 dev_dbg(emu->card->dev, 690 627 "preallocate capture substream: err=%d\n", err); 691 628 */ 692 629 } 693 694 if (rpcm)695 *rpcm = pcm;696 630 697 631 return 0; … … 755 689 struct snd_ctl_elem_info *uinfo) 756 690 { 757 static c har *texts[8] = {691 static const char * const texts[8] = { 758 692 "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", 759 693 "CDIF", "FX", "AC97" 760 694 }; 761 695 762 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 763 uinfo->count = 1; 764 uinfo->value.enumerated.items = 8; 765 if (uinfo->value.enumerated.item > 7) 766 uinfo->value.enumerated.item = 7; 767 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 768 return 0; 696 return snd_ctl_enum_info(uinfo, 1, 8, texts); 769 697 } 770 698 … … 803 731 struct snd_ctl_elem_info *uinfo) 804 732 { 805 static char *texts[4] = { "0", "1", "2", "3", }; 806 807 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 808 uinfo->count = 1; 809 uinfo->value.enumerated.items = 4; 810 if (uinfo->value.enumerated.item > 3) 811 uinfo->value.enumerated.item = 3; 812 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 813 return 0; 733 static const char * const texts[4] = { "0", "1", "2", "3", }; 734 735 return snd_ctl_enum_info(uinfo, 1, 4, texts); 814 736 } 815 737 … … 855 777 } 856 778 857 static struct snd_kcontrol_new p16v_mixer_controls[] __devinitdata= {779 static const struct snd_kcontrol_new p16v_mixer_controls[] = { 858 780 P16V_VOL("HD Analog Front Playback Volume", PLAYBACK_VOLUME_MIXER9, 0), 859 781 P16V_VOL("HD Analog Rear Playback Volume", PLAYBACK_VOLUME_MIXER10, 1), … … 881 803 882 804 883 int __devinitsnd_p16v_mixer(struct snd_emu10k1 *emu)805 int snd_p16v_mixer(struct snd_emu10k1 *emu) 884 806 { 885 807 int i, err; … … 894 816 } 895 817 896 #ifdef CONFIG_PM 818 #ifdef CONFIG_PM_SLEEP 897 819 898 820 #define NUM_CHS 1 /* up to 4, but only first channel is used */ 899 821 900 int __devinit snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu) 901 { 822 int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu) 823 { 824 #ifdef TARGET_OS2 825 emu->p16v_saved = vmalloc(array_size(NUM_CHS * 4, 0x80)); 826 #else 902 827 emu->p16v_saved = vmalloc(NUM_CHS * 4 * 0x80); 828 #endif 903 829 if (! emu->p16v_saved) 904 830 return -ENOMEM;
Note:
See TracChangeset
for help on using the changeset viewer.