| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for DBRI sound chip found on Sparcs. |
|---|
| 3 | 4 | * Copyright (C) 2004, 2005 Martin Habets (mhabets@users.sourceforge.net) |
|---|
| .. | .. |
|---|
| 21 | 22 | * - Data sheet of the T7903, a newer but very similar ISA bus equivalent |
|---|
| 22 | 23 | * available from the Lucent (formerly AT&T microelectronics) home |
|---|
| 23 | 24 | * page. |
|---|
| 24 | | - * - http://www.freesoft.org/Linux/DBRI/ |
|---|
| 25 | + * - https://www.freesoft.org/Linux/DBRI/ |
|---|
| 25 | 26 | * - MMCODEC: Crystal Semiconductor CS4215 16 bit Multimedia Audio Codec |
|---|
| 26 | 27 | * Interfaces: CHI, Audio In & Out, 2 bits parallel |
|---|
| 27 | 28 | * Documentation: from the Crystal Semiconductor home page. |
|---|
| .. | .. |
|---|
| 103 | 104 | MODULE_PARM_DESC(dbri_debug, "Debug value for Sun DBRI soundcard."); |
|---|
| 104 | 105 | |
|---|
| 105 | 106 | #ifdef DBRI_DEBUG |
|---|
| 106 | | -static char *cmds[] = { |
|---|
| 107 | +static const char * const cmds[] = { |
|---|
| 107 | 108 | "WAIT", "PAUSE", "JUMP", "IIQ", "REX", "SDP", "CDP", "DTS", |
|---|
| 108 | 109 | "SSP", "CHI", "NT", "TE", "CDEC", "TEST", "CDM", "RESRV" |
|---|
| 109 | 110 | }; |
|---|
| .. | .. |
|---|
| 579 | 580 | switch (len) { |
|---|
| 580 | 581 | case 32: |
|---|
| 581 | 582 | b = ((b & 0xffff0000) >> 16) | ((b & 0x0000ffff) << 16); |
|---|
| 583 | + fallthrough; |
|---|
| 582 | 584 | case 16: |
|---|
| 583 | 585 | b = ((b & 0xff00ff00) >> 8) | ((b & 0x00ff00ff) << 8); |
|---|
| 586 | + fallthrough; |
|---|
| 584 | 587 | case 8: |
|---|
| 585 | 588 | b = ((b & 0xf0f0f0f0) >> 4) | ((b & 0x0f0f0f0f) << 4); |
|---|
| 589 | + fallthrough; |
|---|
| 586 | 590 | case 4: |
|---|
| 587 | 591 | b = ((b & 0xcccccccc) >> 2) | ((b & 0x33333333) << 2); |
|---|
| 592 | + fallthrough; |
|---|
| 588 | 593 | case 2: |
|---|
| 589 | 594 | b = ((b & 0xaaaaaaaa) >> 1) | ((b & 0x55555555) << 1); |
|---|
| 590 | 595 | case 1: |
|---|
| .. | .. |
|---|
| 615 | 620 | while another can be executed. The scheme works by adding two WAIT commands |
|---|
| 616 | 621 | after each sent batch of commands. When the next batch is prepared it is |
|---|
| 617 | 622 | added after the WAIT commands then the WAITs are replaced with single JUMP |
|---|
| 618 | | -command to the new batch. The the DBRI is forced to reread the last WAIT |
|---|
| 623 | +command to the new batch. Then the DBRI is forced to reread the last WAIT |
|---|
| 619 | 624 | command (replaced by the JUMP by then). If the DBRI is still executing |
|---|
| 620 | 625 | previous commands the request to reread the WAIT command is ignored. |
|---|
| 621 | 626 | |
|---|
| .. | .. |
|---|
| 2094 | 2099 | if (ret != 0) |
|---|
| 2095 | 2100 | return ret; |
|---|
| 2096 | 2101 | |
|---|
| 2097 | | - if ((ret = snd_pcm_lib_malloc_pages(substream, |
|---|
| 2098 | | - params_buffer_bytes(hw_params))) < 0) { |
|---|
| 2099 | | - printk(KERN_ERR "malloc_pages failed with %d\n", ret); |
|---|
| 2100 | | - return ret; |
|---|
| 2101 | | - } |
|---|
| 2102 | | - |
|---|
| 2103 | 2102 | /* hw_params can get called multiple times. Only map the DMA once. |
|---|
| 2104 | 2103 | */ |
|---|
| 2105 | 2104 | if (info->dvma_buffer == 0) { |
|---|
| .. | .. |
|---|
| 2146 | 2145 | info->pipe = -1; |
|---|
| 2147 | 2146 | } |
|---|
| 2148 | 2147 | |
|---|
| 2149 | | - return snd_pcm_lib_free_pages(substream); |
|---|
| 2148 | + return 0; |
|---|
| 2150 | 2149 | } |
|---|
| 2151 | 2150 | |
|---|
| 2152 | 2151 | static int snd_dbri_prepare(struct snd_pcm_substream *substream) |
|---|
| .. | .. |
|---|
| 2216 | 2215 | static const struct snd_pcm_ops snd_dbri_ops = { |
|---|
| 2217 | 2216 | .open = snd_dbri_open, |
|---|
| 2218 | 2217 | .close = snd_dbri_close, |
|---|
| 2219 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 2220 | 2218 | .hw_params = snd_dbri_hw_params, |
|---|
| 2221 | 2219 | .hw_free = snd_dbri_hw_free, |
|---|
| 2222 | 2220 | .prepare = snd_dbri_prepare, |
|---|
| .. | .. |
|---|
| 2243 | 2241 | pcm->info_flags = 0; |
|---|
| 2244 | 2242 | strcpy(pcm->name, card->shortname); |
|---|
| 2245 | 2243 | |
|---|
| 2246 | | - if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, |
|---|
| 2247 | | - SNDRV_DMA_TYPE_CONTINUOUS, |
|---|
| 2248 | | - snd_dma_continuous_data(GFP_KERNEL), |
|---|
| 2249 | | - 64 * 1024, 64 * 1024)) < 0) |
|---|
| 2250 | | - return err; |
|---|
| 2251 | | - |
|---|
| 2244 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, |
|---|
| 2245 | + NULL, 64 * 1024, 64 * 1024); |
|---|
| 2252 | 2246 | return 0; |
|---|
| 2253 | 2247 | } |
|---|
| 2254 | 2248 | |
|---|
| .. | .. |
|---|
| 2416 | 2410 | .private_value = (entry) | ((shift) << 8) | ((mask) << 16) | \ |
|---|
| 2417 | 2411 | ((invert) << 24) }, |
|---|
| 2418 | 2412 | |
|---|
| 2419 | | -static struct snd_kcontrol_new dbri_controls[] = { |
|---|
| 2413 | +static const struct snd_kcontrol_new dbri_controls[] = { |
|---|
| 2420 | 2414 | { |
|---|
| 2421 | 2415 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
|---|
| 2422 | 2416 | .name = "Playback Volume", |
|---|
| .. | .. |
|---|
| 2510 | 2504 | static void snd_dbri_proc(struct snd_card *card) |
|---|
| 2511 | 2505 | { |
|---|
| 2512 | 2506 | struct snd_dbri *dbri = card->private_data; |
|---|
| 2513 | | - struct snd_info_entry *entry; |
|---|
| 2514 | 2507 | |
|---|
| 2515 | | - if (!snd_card_proc_new(card, "regs", &entry)) |
|---|
| 2516 | | - snd_info_set_text_ops(entry, dbri, dbri_regs_read); |
|---|
| 2517 | | - |
|---|
| 2508 | + snd_card_ro_proc_new(card, "regs", dbri, dbri_regs_read); |
|---|
| 2518 | 2509 | #ifdef DBRI_DEBUG |
|---|
| 2519 | | - if (!snd_card_proc_new(card, "debug", &entry)) { |
|---|
| 2520 | | - snd_info_set_text_ops(entry, dbri, dbri_debug_read); |
|---|
| 2521 | | - entry->mode = S_IFREG | 0444; /* Readable only. */ |
|---|
| 2522 | | - } |
|---|
| 2510 | + snd_card_ro_proc_new(card, "debug", dbri, dbri_debug_read); |
|---|
| 2523 | 2511 | #endif |
|---|
| 2524 | 2512 | } |
|---|
| 2525 | 2513 | |
|---|
| .. | .. |
|---|
| 2541 | 2529 | dbri->op = op; |
|---|
| 2542 | 2530 | dbri->irq = irq; |
|---|
| 2543 | 2531 | |
|---|
| 2544 | | - dbri->dma = dma_zalloc_coherent(&op->dev, sizeof(struct dbri_dma), |
|---|
| 2545 | | - &dbri->dma_dvma, GFP_KERNEL); |
|---|
| 2532 | + dbri->dma = dma_alloc_coherent(&op->dev, sizeof(struct dbri_dma), |
|---|
| 2533 | + &dbri->dma_dvma, GFP_KERNEL); |
|---|
| 2546 | 2534 | if (!dbri->dma) |
|---|
| 2547 | 2535 | return -ENOMEM; |
|---|
| 2548 | 2536 | |
|---|