| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Audio support for PS3 |
|---|
| 3 | 4 | * Copyright (C) 2007 Sony Computer Entertainment Inc. |
|---|
| 4 | 5 | * All rights reserved. |
|---|
| 5 | 6 | * Copyright 2006, 2007 Sony Corporation |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License |
|---|
| 9 | | - * as published by the Free Software Foundation; version 2 of the Licence. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program; if not, write to the Free Software |
|---|
| 18 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | 7 | */ |
|---|
| 20 | 8 | |
|---|
| 21 | 9 | #include <linux/dma-mapping.h> |
|---|
| .. | .. |
|---|
| 233 | 221 | int fill_stages, dma_ch, stage; |
|---|
| 234 | 222 | enum snd_ps3_ch ch; |
|---|
| 235 | 223 | uint32_t ch0_kick_event = 0; /* initialize to mute gcc */ |
|---|
| 236 | | - void *start_vaddr; |
|---|
| 237 | 224 | unsigned long irqsave; |
|---|
| 238 | 225 | int silent = 0; |
|---|
| 239 | 226 | |
|---|
| 240 | 227 | switch (filltype) { |
|---|
| 241 | 228 | case SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL: |
|---|
| 242 | 229 | silent = 1; |
|---|
| 243 | | - /* intentionally fall thru */ |
|---|
| 230 | + fallthrough; |
|---|
| 244 | 231 | case SND_PS3_DMA_FILLTYPE_FIRSTFILL: |
|---|
| 245 | 232 | ch0_kick_event = PS3_AUDIO_KICK_EVENT_ALWAYS; |
|---|
| 246 | 233 | break; |
|---|
| 247 | 234 | |
|---|
| 248 | 235 | case SND_PS3_DMA_FILLTYPE_SILENT_RUNNING: |
|---|
| 249 | 236 | silent = 1; |
|---|
| 250 | | - /* intentionally fall thru */ |
|---|
| 237 | + fallthrough; |
|---|
| 251 | 238 | case SND_PS3_DMA_FILLTYPE_RUNNING: |
|---|
| 252 | 239 | ch0_kick_event = PS3_AUDIO_KICK_EVENT_SERIALOUT0_EMPTY; |
|---|
| 253 | 240 | break; |
|---|
| .. | .. |
|---|
| 257 | 244 | fill_stages = 4; |
|---|
| 258 | 245 | spin_lock_irqsave(&card->dma_lock, irqsave); |
|---|
| 259 | 246 | for (ch = 0; ch < 2; ch++) { |
|---|
| 260 | | - start_vaddr = card->dma_next_transfer_vaddr[0]; |
|---|
| 261 | 247 | for (stage = 0; stage < fill_stages; stage++) { |
|---|
| 262 | 248 | dma_ch = stage * 2 + ch; |
|---|
| 263 | 249 | if (silent) |
|---|
| .. | .. |
|---|
| 526 | 512 | { |
|---|
| 527 | 513 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 528 | 514 | struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); |
|---|
| 529 | | - int pcm_index; |
|---|
| 530 | 515 | |
|---|
| 531 | | - pcm_index = substream->pcm->device; |
|---|
| 532 | 516 | /* to retrieve substream/runtime in interrupt handler */ |
|---|
| 533 | 517 | card->substream = substream; |
|---|
| 534 | 518 | |
|---|
| .. | .. |
|---|
| 549 | 533 | /* mute on */ |
|---|
| 550 | 534 | snd_ps3_mute(1); |
|---|
| 551 | 535 | return 0; |
|---|
| 552 | | -}; |
|---|
| 553 | | - |
|---|
| 554 | | -static int snd_ps3_pcm_hw_params(struct snd_pcm_substream *substream, |
|---|
| 555 | | - struct snd_pcm_hw_params *hw_params) |
|---|
| 556 | | -{ |
|---|
| 557 | | - size_t size; |
|---|
| 558 | | - |
|---|
| 559 | | - /* alloc transport buffer */ |
|---|
| 560 | | - size = params_buffer_bytes(hw_params); |
|---|
| 561 | | - snd_pcm_lib_malloc_pages(substream, size); |
|---|
| 562 | | - return 0; |
|---|
| 563 | | -}; |
|---|
| 564 | | - |
|---|
| 565 | | -static int snd_ps3_pcm_hw_free(struct snd_pcm_substream *substream) |
|---|
| 566 | | -{ |
|---|
| 567 | | - return snd_pcm_lib_free_pages(substream); |
|---|
| 568 | 536 | }; |
|---|
| 569 | 537 | |
|---|
| 570 | 538 | static int snd_ps3_delay_to_bytes(struct snd_pcm_substream *substream, |
|---|
| .. | .. |
|---|
| 644 | 612 | int cmd) |
|---|
| 645 | 613 | { |
|---|
| 646 | 614 | struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); |
|---|
| 647 | | - int ret = 0; |
|---|
| 648 | 615 | |
|---|
| 649 | 616 | switch (cmd) { |
|---|
| 650 | 617 | case SNDRV_PCM_TRIGGER_START: |
|---|
| .. | .. |
|---|
| 681 | 648 | |
|---|
| 682 | 649 | } |
|---|
| 683 | 650 | |
|---|
| 684 | | - return ret; |
|---|
| 651 | + return 0; |
|---|
| 685 | 652 | }; |
|---|
| 686 | 653 | |
|---|
| 687 | 654 | /* |
|---|
| .. | .. |
|---|
| 748 | 715 | return 0; |
|---|
| 749 | 716 | } |
|---|
| 750 | 717 | |
|---|
| 751 | | -static struct snd_kcontrol_new spdif_ctls[] = { |
|---|
| 718 | +static const struct snd_kcontrol_new spdif_ctls[] = { |
|---|
| 752 | 719 | { |
|---|
| 753 | 720 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
|---|
| 754 | 721 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
|---|
| .. | .. |
|---|
| 775 | 742 | static const struct snd_pcm_ops snd_ps3_pcm_spdif_ops = { |
|---|
| 776 | 743 | .open = snd_ps3_pcm_open, |
|---|
| 777 | 744 | .close = snd_ps3_pcm_close, |
|---|
| 778 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 779 | | - .hw_params = snd_ps3_pcm_hw_params, |
|---|
| 780 | | - .hw_free = snd_ps3_pcm_hw_free, |
|---|
| 781 | 745 | .prepare = snd_ps3_pcm_prepare, |
|---|
| 782 | 746 | .trigger = snd_ps3_pcm_trigger, |
|---|
| 783 | 747 | .pointer = snd_ps3_pcm_pointer, |
|---|
| .. | .. |
|---|
| 962 | 926 | PAGE_SHIFT, /* use system page size */ |
|---|
| 963 | 927 | 0, /* dma type; not used */ |
|---|
| 964 | 928 | NULL, |
|---|
| 965 | | - _ALIGN_UP(SND_PS3_DMA_REGION_SIZE, PAGE_SIZE)); |
|---|
| 929 | + ALIGN(SND_PS3_DMA_REGION_SIZE, PAGE_SIZE)); |
|---|
| 966 | 930 | dev->d_region->ioid = PS3_AUDIO_IOID; |
|---|
| 967 | 931 | |
|---|
| 968 | 932 | ret = ps3_dma_region_create(dev->d_region); |
|---|
| .. | .. |
|---|
| 1024 | 988 | |
|---|
| 1025 | 989 | the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED; |
|---|
| 1026 | 990 | /* pre-alloc PCM DMA buffer*/ |
|---|
| 1027 | | - ret = snd_pcm_lib_preallocate_pages_for_all(the_card.pcm, |
|---|
| 1028 | | - SNDRV_DMA_TYPE_DEV, |
|---|
| 1029 | | - &dev->core, |
|---|
| 1030 | | - SND_PS3_PCM_PREALLOC_SIZE, |
|---|
| 1031 | | - SND_PS3_PCM_PREALLOC_SIZE); |
|---|
| 1032 | | - if (ret < 0) { |
|---|
| 1033 | | - pr_info("%s: prealloc failed\n", __func__); |
|---|
| 1034 | | - goto clean_card; |
|---|
| 1035 | | - } |
|---|
| 991 | + snd_pcm_set_managed_buffer_all(the_card.pcm, |
|---|
| 992 | + SNDRV_DMA_TYPE_DEV, |
|---|
| 993 | + &dev->core, |
|---|
| 994 | + SND_PS3_PCM_PREALLOC_SIZE, |
|---|
| 995 | + SND_PS3_PCM_PREALLOC_SIZE); |
|---|
| 1036 | 996 | |
|---|
| 1037 | 997 | /* |
|---|
| 1038 | 998 | * allocate null buffer |
|---|