Changeset 703 for GPL/trunk/alsa-kernel/pci/trident
- Timestamp:
- Sep 26, 2021, 6:18:40 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 5 edited
-
. (modified) (1 prop)
-
alsa-kernel/pci/trident/trident.c (modified) (4 diffs)
-
alsa-kernel/pci/trident/trident.h (modified) (1 diff)
-
alsa-kernel/pci/trident/trident_main.c (modified) (19 diffs)
-
alsa-kernel/pci/trident/trident_memory.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-next merged: 696-702
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/trident/trident.c
r695 r703 77 77 return err; 78 78 79 if ((err = snd_trident_create(card, pci, 80 pcm_channels[dev], 81 ((pci->vendor << 16) | pci->device) == TRIDENT_DEVICE_ID_SI7018 ? 1 : 2, 82 wavetable_size[dev], 83 &trident)) < 0) { 79 err = snd_trident_create(card, pci, 80 pcm_channels[dev], 81 ((pci->vendor << 16) | pci->device) == TRIDENT_DEVICE_ID_SI7018 ? 1 : 2, 82 wavetable_size[dev], 83 &trident); 84 if (err < 0) { 84 85 snd_card_free(card); 85 86 return err; … … 110 111 card->shortname, trident->port, trident->irq); 111 112 112 if ((err = snd_trident_pcm(trident, pcm_dev++)) < 0) { 113 err = snd_trident_pcm(trident, pcm_dev++); 114 if (err < 0) { 113 115 snd_card_free(card); 114 116 return err; … … 117 119 case TRIDENT_DEVICE_ID_DX: 118 120 case TRIDENT_DEVICE_ID_NX: 119 if ((err = snd_trident_foldback_pcm(trident, pcm_dev++)) < 0) { 121 err = snd_trident_foldback_pcm(trident, pcm_dev++); 122 if (err < 0) { 120 123 snd_card_free(card); 121 124 return err; … … 124 127 } 125 128 if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) { 126 if ((err = snd_trident_spdif_pcm(trident, pcm_dev++)) < 0) { 129 err = snd_trident_spdif_pcm(trident, pcm_dev++); 130 if (err < 0) { 127 131 snd_card_free(card); 128 132 return err; 129 133 } 130 134 } 131 if (trident->device != TRIDENT_DEVICE_ID_SI7018 && 132 (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE, 133 trident->midi_port, 134 MPU401_INFO_INTEGRATED | 135 MPU401_INFO_IRQ_HOOK, 136 -1, &trident->rmidi)) < 0) { 137 snd_card_free(card); 138 return err; 135 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { 136 err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE, 137 trident->midi_port, 138 MPU401_INFO_INTEGRATED | 139 MPU401_INFO_IRQ_HOOK, 140 -1, &trident->rmidi); 141 if (err < 0) { 142 snd_card_free(card); 143 return err; 144 } 139 145 } 140 146 141 147 snd_trident_create_gameport(trident); 142 148 143 if ((err = snd_card_register(card)) < 0) { 149 err = snd_card_register(card); 150 if (err < 0) { 144 151 snd_card_free(card); 145 152 return err; -
GPL/trunk/alsa-kernel/pci/trident/trident.h
r679 r703 252 252 __le32 *entries; /* 16k-aligned TLB table */ 253 253 dma_addr_t entries_dmaaddr; /* 16k-aligned PCI address to TLB table */ 254 unsigned long * shadow_entries; /* shadow entries with virtual addresses */255 254 struct snd_dma_buffer buffer; 256 255 struct snd_util_memhdr * memhdr; /* page allocation list */ -
GPL/trunk/alsa-kernel/pci/trident/trident_main.c
r695 r703 2132 2132 int err; 2133 2133 2134 if ((err = snd_pcm_new(trident->card, "trident_dx_nx", device, trident->ChanPCM, 1, &pcm)) < 0) 2134 err = snd_pcm_new(trident->card, "trident_dx_nx", device, trident->ChanPCM, 1, &pcm); 2135 if (err < 0) 2135 2136 return err; 2136 2137 … … 2191 2192 if (trident->device == TRIDENT_DEVICE_ID_NX) 2192 2193 num_chan = 4; 2193 if ((err = snd_pcm_new(trident->card, "trident_dx_nx", device, 0, num_chan, &foldback)) < 0) 2194 err = snd_pcm_new(trident->card, "trident_dx_nx", device, 0, num_chan, &foldback); 2195 if (err < 0) 2194 2196 return err; 2195 2197 … … 2241 2243 int err; 2242 2244 2243 if ((err = snd_pcm_new(trident->card, "trident_dx_nx IEC958", device, 1, 0, &spdif)) < 0) 2245 err = snd_pcm_new(trident->card, "trident_dx_nx IEC958", device, 1, 0, &spdif); 2246 if (err < 0) 2244 2247 return err; 2245 2248 … … 2934 2937 return -ENOMEM; 2935 2938 2936 if ((err = snd_ac97_bus(trident->card, 0, &ops, NULL, &trident->ac97_bus)) < 0) 2939 err = snd_ac97_bus(trident->card, 0, &ops, NULL, &trident->ac97_bus); 2940 if (err < 0) 2937 2941 goto __out; 2938 2942 … … 2942 2946 2943 2947 __again: 2944 if ((err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97)) < 0) { 2948 err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97); 2949 if (err < 0) { 2945 2950 if (trident->device == TRIDENT_DEVICE_ID_SI7018) { 2946 if ((err = snd_trident_sis_reset(trident)) < 0) 2951 err = snd_trident_sis_reset(trident); 2952 if (err < 0) 2947 2953 goto __out; 2948 2954 if (retries-- > 0) … … 2975 2981 2976 2982 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { 2977 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_trident_vol_wave_control, trident))) < 0) 2983 kctl = snd_ctl_new1(&snd_trident_vol_wave_control, trident); 2984 err = snd_ctl_add(card, kctl); 2985 if (err < 0) 2978 2986 goto __out; 2979 2987 kctl->put(kctl, uctl); 2980 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_trident_vol_music_control, trident))) < 0) 2988 kctl = snd_ctl_new1(&snd_trident_vol_music_control, trident); 2989 err = snd_ctl_add(card, kctl); 2990 if (err < 0) 2981 2991 goto __out; 2982 2992 kctl->put(kctl, uctl); … … 2992 3002 tmix->voice = NULL; 2993 3003 } 2994 if ((trident->ctl_vol = snd_ctl_new1(&snd_trident_pcm_vol_control, trident)) == NULL) 3004 trident->ctl_vol = snd_ctl_new1(&snd_trident_pcm_vol_control, trident); 3005 if (!trident->ctl_vol) 2995 3006 goto __nomem; 2996 if ((err = snd_ctl_add(card, trident->ctl_vol))) 3007 err = snd_ctl_add(card, trident->ctl_vol); 3008 if (err) 2997 3009 goto __out; 2998 3010 2999 if ((trident->ctl_pan = snd_ctl_new1(&snd_trident_pcm_pan_control, trident)) == NULL) 3011 trident->ctl_pan = snd_ctl_new1(&snd_trident_pcm_pan_control, trident); 3012 if (!trident->ctl_pan) 3000 3013 goto __nomem; 3001 if ((err = snd_ctl_add(card, trident->ctl_pan))) 3014 err = snd_ctl_add(card, trident->ctl_pan); 3015 if (err) 3002 3016 goto __out; 3003 3017 3004 if ((trident->ctl_rvol = snd_ctl_new1(&snd_trident_pcm_rvol_control, trident)) == NULL) 3018 trident->ctl_rvol = snd_ctl_new1(&snd_trident_pcm_rvol_control, trident); 3019 if (!trident->ctl_rvol) 3005 3020 goto __nomem; 3006 if ((err = snd_ctl_add(card, trident->ctl_rvol))) 3021 err = snd_ctl_add(card, trident->ctl_rvol); 3022 if (err) 3007 3023 goto __out; 3008 3024 3009 if ((trident->ctl_cvol = snd_ctl_new1(&snd_trident_pcm_cvol_control, trident)) == NULL) 3025 trident->ctl_cvol = snd_ctl_new1(&snd_trident_pcm_cvol_control, trident); 3026 if (!trident->ctl_cvol) 3010 3027 goto __nomem; 3011 if ((err = snd_ctl_add(card, trident->ctl_cvol))) 3028 err = snd_ctl_add(card, trident->ctl_cvol); 3029 if (err) 3012 3030 goto __out; 3013 3031 3014 3032 if (trident->device == TRIDENT_DEVICE_ID_NX) { 3015 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_trident_ac97_rear_control, trident))) < 0) 3033 kctl = snd_ctl_new1(&snd_trident_ac97_rear_control, trident); 3034 err = snd_ctl_add(card, kctl); 3035 if (err < 0) 3016 3036 goto __out; 3017 3037 kctl->put(kctl, uctl); … … 3029 3049 kctl->id.index++; 3030 3050 idx = kctl->id.index; 3031 if ((err = snd_ctl_add(card, kctl)) < 0) 3051 err = snd_ctl_add(card, kctl); 3052 if (err < 0) 3032 3053 goto __out; 3033 3054 kctl->put(kctl, uctl); … … 3040 3061 kctl->id.index = idx; 3041 3062 kctl->id.device = pcm_spdif_device; 3042 if ((err = snd_ctl_add(card, kctl)) < 0) 3063 err = snd_ctl_add(card, kctl); 3064 if (err < 0) 3043 3065 goto __out; 3044 3066 … … 3050 3072 kctl->id.index = idx; 3051 3073 kctl->id.device = pcm_spdif_device; 3052 if ((err = snd_ctl_add(card, kctl)) < 0) 3074 err = snd_ctl_add(card, kctl); 3075 if (err < 0) 3053 3076 goto __out; 3054 3077 … … 3060 3083 kctl->id.index = idx; 3061 3084 kctl->id.device = pcm_spdif_device; 3062 if ((err = snd_ctl_add(card, kctl)) < 0) 3085 err = snd_ctl_add(card, kctl); 3086 if (err < 0) 3063 3087 goto __out; 3064 3088 trident->spdif_pcm_ctl = kctl; … … 3320 3344 trident->tlb.entries = (__le32 *)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4); 3321 3345 trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4); 3322 /* allocate shadow TLB page table (virtual addresses) */3323 trident->tlb.shadow_entries =3324 vmalloc(array_size(SNDRV_TRIDENT_MAX_PAGES,3325 sizeof(unsigned long)));3326 if (!trident->tlb.shadow_entries)3327 return -ENOMEM;3328 3346 3329 3347 /* allocate and setup silent page and initialise TLB entries */ … … 3334 3352 } 3335 3353 memset(trident->tlb.silent_page.area, 0, SNDRV_TRIDENT_PAGE_SIZE); 3336 for (i = 0; i < SNDRV_TRIDENT_MAX_PAGES; i++) {3354 for (i = 0; i < SNDRV_TRIDENT_MAX_PAGES; i++) 3337 3355 trident->tlb.entries[i] = cpu_to_le32(trident->tlb.silent_page.addr & ~(SNDRV_TRIDENT_PAGE_SIZE-1)); 3338 trident->tlb.shadow_entries[i] = (unsigned long)trident->tlb.silent_page.area;3339 }3340 3356 3341 3357 /* use emu memory block manager code to manage tlb page allocation */ … … 3462 3478 int err; 3463 3479 3464 if ((err = snd_trident_sis_reset(trident)) < 0) 3480 err = snd_trident_sis_reset(trident); 3481 if (err < 0) 3465 3482 return err; 3466 3483 … … 3507 3524 3508 3525 /* enable PCI device */ 3509 if ((err = pci_enable_device(pci)) < 0) 3526 err = pci_enable_device(pci); 3527 if (err < 0) 3510 3528 return err; 3511 3529 /* check, if we can restrict PCI DMA transfers to 30 bits */ … … 3541 3559 pci_set_master(pci); 3542 3560 3543 if ((err = pci_request_regions(pci, "Trident Audio")) < 0) { 3561 err = pci_request_regions(pci, "Trident Audio"); 3562 if (err < 0) { 3544 3563 kfree(trident); 3545 3564 pci_disable_device(pci); … … 3561 3580 trident->tlb.buffer.area = NULL; 3562 3581 if (trident->device == TRIDENT_DEVICE_ID_NX) { 3563 if ((err = snd_trident_tlb_alloc(trident)) < 0) { 3582 err = snd_trident_tlb_alloc(trident); 3583 if (err < 0) { 3564 3584 snd_trident_free(trident); 3565 3585 return err; … … 3589 3609 } 3590 3610 3591 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, trident, &ops)) < 0) { 3611 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, trident, &ops); 3612 if (err < 0) { 3592 3613 snd_trident_free(trident); 3593 3614 return err; 3594 3615 } 3595 3616 3596 if ((err = snd_trident_mixer(trident, pcm_spdif_device)) < 0) 3617 err = snd_trident_mixer(trident, pcm_spdif_device); 3618 if (err < 0) 3597 3619 return err; 3598 3620 … … 3648 3670 if (trident->tlb.silent_page.area) 3649 3671 snd_dma_free_pages(&trident->tlb.silent_page); 3650 vfree(trident->tlb.shadow_entries);3651 3672 snd_dma_free_pages(&trident->tlb.buffer); 3652 3673 } -
GPL/trunk/alsa-kernel/pci/trident/trident_memory.c
r679 r703 20 20 * aligned pages in others 21 21 */ 22 #define __set_tlb_bus(trident,page,ptr,addr) \ 23 do { (trident)->tlb.entries[page] = cpu_to_le32((addr) & ~(SNDRV_TRIDENT_PAGE_SIZE-1)); \ 24 (trident)->tlb.shadow_entries[page] = (ptr); } while (0) 25 #define __tlb_to_ptr(trident,page) \ 26 (void*)((trident)->tlb.shadow_entries[page]) 22 #define __set_tlb_bus(trident,page,addr) \ 23 (trident)->tlb.entries[page] = cpu_to_le32((addr) & ~(SNDRV_TRIDENT_PAGE_SIZE-1)) 27 24 #define __tlb_to_addr(trident,page) \ 28 25 (dma_addr_t)le32_to_cpu((trident->tlb.entries[page]) & ~(SNDRV_TRIDENT_PAGE_SIZE - 1)) … … 33 30 #define MAX_ALIGN_PAGES SNDRV_TRIDENT_MAX_PAGES /* maxmium aligned pages */ 34 31 /* fill TLB entrie(s) corresponding to page with ptr */ 35 #define set_tlb_bus(trident,page, ptr,addr) __set_tlb_bus(trident,page,ptr,addr)32 #define set_tlb_bus(trident,page,addr) __set_tlb_bus(trident,page,addr) 36 33 /* fill TLB entrie(s) corresponding to page with silence pointer */ 37 #define set_silent_tlb(trident,page) __set_tlb_bus(trident, page, (unsigned long)trident->tlb.silent_page.area,trident->tlb.silent_page.addr)34 #define set_silent_tlb(trident,page) __set_tlb_bus(trident, page, trident->tlb.silent_page.addr) 38 35 /* get aligned page from offset address */ 39 36 #define get_aligned_page(offset) ((offset) >> 12) 40 37 /* get offset address from aligned page */ 41 38 #define aligned_page_offset(page) ((page) << 12) 42 /* get buffer address from aligned page */43 #define page_to_ptr(trident,page) __tlb_to_ptr(trident, page)44 39 /* get PCI physical address from aligned page */ 45 40 #define page_to_addr(trident,page) __tlb_to_addr(trident, page) … … 51 46 #define get_aligned_page(offset) ((offset) >> 13) 52 47 #define aligned_page_offset(page) ((page) << 13) 53 #define page_to_ptr(trident,page) __tlb_to_ptr(trident, (page) << 1)54 48 #define page_to_addr(trident,page) __tlb_to_addr(trident, (page) << 1) 55 49 56 50 /* fill TLB entries -- we need to fill two entries */ 57 51 static inline void set_tlb_bus(struct snd_trident *trident, int page, 58 unsigned long ptr,dma_addr_t addr)52 dma_addr_t addr) 59 53 { 60 54 page <<= 1; 61 __set_tlb_bus(trident, page, ptr,addr);62 __set_tlb_bus(trident, page+1, ptr + SNDRV_TRIDENT_PAGE_SIZE,addr + SNDRV_TRIDENT_PAGE_SIZE);55 __set_tlb_bus(trident, page, addr); 56 __set_tlb_bus(trident, page+1, addr + SNDRV_TRIDENT_PAGE_SIZE); 63 57 } 64 58 static inline void set_silent_tlb(struct snd_trident *trident, int page) 65 59 { 66 60 page <<= 1; 67 __set_tlb_bus(trident, page, (unsigned long)trident->tlb.silent_page.area,trident->tlb.silent_page.addr);68 __set_tlb_bus(trident, page+1, (unsigned long)trident->tlb.silent_page.area,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); 69 63 } 70 64 … … 81 75 #define get_aligned_page(offset) ((offset) / ALIGN_PAGE_SIZE) 82 76 #define aligned_page_offset(page) ((page) * ALIGN_PAGE_SIZE) 83 #define page_to_ptr(trident,page) __tlb_to_ptr(trident, (page) * UNIT_PAGES)84 77 #define page_to_addr(trident,page) __tlb_to_addr(trident, (page) * UNIT_PAGES) 85 78 86 79 /* fill TLB entries -- UNIT_PAGES entries must be filled */ 87 80 static inline void set_tlb_bus(struct snd_trident *trident, int page, 88 unsigned long ptr,dma_addr_t addr)81 dma_addr_t addr) 89 82 { 90 83 int i; 91 84 page *= UNIT_PAGES; 92 85 for (i = 0; i < UNIT_PAGES; i++, page++) { 93 __set_tlb_bus(trident, page, ptr, addr); 94 ptr += SNDRV_TRIDENT_PAGE_SIZE; 86 __set_tlb_bus(trident, page, addr); 95 87 addr += SNDRV_TRIDENT_PAGE_SIZE; 96 88 } … … 101 93 page *= UNIT_PAGES; 102 94 for (i = 0; i < UNIT_PAGES; i++, page++) 103 __set_tlb_bus(trident, page, (unsigned long)trident->tlb.silent_page.area,trident->tlb.silent_page.addr);95 __set_tlb_bus(trident, page, trident->tlb.silent_page.addr); 104 96 } 105 97 106 98 #endif /* PAGE_SIZE */ 107 108 /* calculate buffer pointer from offset address */109 static inline void *offset_ptr(struct snd_trident *trident, int offset)110 {111 char *ptr;112 ptr = page_to_ptr(trident, get_aligned_page(offset));113 ptr += offset % ALIGN_PAGE_SIZE;114 return (void*)ptr;115 }116 99 117 100 /* first and last (aligned) pages of memory block */ … … 204 187 unsigned long ofs = idx << PAGE_SHIFT; 205 188 dma_addr_t addr = snd_pcm_sgbuf_get_addr(substream, ofs); 206 unsigned long ptr = (unsigned long)207 snd_pcm_sgbuf_get_ptr(substream, ofs);208 189 if (! is_valid_page(addr)) { 209 190 __snd_util_mem_free(hdr, blk); … … 211 192 return NULL; 212 193 } 213 set_tlb_bus(trident, page, ptr,addr);194 set_tlb_bus(trident, page, addr); 214 195 } 215 196 mutex_unlock(&hdr->block_mutex); … … 229 210 struct snd_pcm_runtime *runtime = substream->runtime; 230 211 dma_addr_t addr; 231 unsigned long ptr;232 212 233 213 #pragma disable_message (136) … … 250 230 /* set TLB entries */ 251 231 addr = runtime->dma_addr; 252 ptr = (unsigned long)runtime->dma_area;253 232 for (page = firstpg(blk); page <= lastpg(blk); page++, 254 ptr += SNDRV_TRIDENT_PAGE_SIZE,addr += SNDRV_TRIDENT_PAGE_SIZE) {233 addr += SNDRV_TRIDENT_PAGE_SIZE) { 255 234 if (! is_valid_page(addr)) { 256 235 __snd_util_mem_free(hdr, blk); … … 258 237 return NULL; 259 238 } 260 set_tlb_bus(trident, page, ptr,addr);239 set_tlb_bus(trident, page, addr); 261 240 } 262 241 mutex_unlock(&hdr->block_mutex);
Note:
See TracChangeset
for help on using the changeset viewer.
