hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/sound/atmel/ac97c.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Driver for Atmel AC97C
34 *
45 * Copyright (C) 2005-2009 Atmel Corporation
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published by
8
- * the Free Software Foundation.
96 */
107 #include <linux/clk.h>
118 #include <linux/delay.h>
....@@ -162,12 +159,6 @@
162159 struct snd_pcm_hw_params *hw_params)
163160 {
164161 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
165
- int retval;
166
-
167
- retval = snd_pcm_lib_malloc_pages(substream,
168
- params_buffer_bytes(hw_params));
169
- if (retval < 0)
170
- return retval;
171162
172163 /* Set restrictions to params. */
173164 mutex_lock(&opened_mutex);
....@@ -175,19 +166,13 @@
175166 chip->cur_format = params_format(hw_params);
176167 mutex_unlock(&opened_mutex);
177168
178
- return retval;
169
+ return 0;
179170 }
180171
181172 static int atmel_ac97c_capture_hw_params(struct snd_pcm_substream *substream,
182173 struct snd_pcm_hw_params *hw_params)
183174 {
184175 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
185
- int retval;
186
-
187
- retval = snd_pcm_lib_malloc_pages(substream,
188
- params_buffer_bytes(hw_params));
189
- if (retval < 0)
190
- return retval;
191176
192177 /* Set restrictions to params. */
193178 mutex_lock(&opened_mutex);
....@@ -195,7 +180,7 @@
195180 chip->cur_format = params_format(hw_params);
196181 mutex_unlock(&opened_mutex);
197182
198
- return retval;
183
+ return 0;
199184 }
200185
201186 static int atmel_ac97c_playback_prepare(struct snd_pcm_substream *substream)
....@@ -234,7 +219,7 @@
234219 switch (runtime->format) {
235220 case SNDRV_PCM_FORMAT_S16_LE:
236221 break;
237
- case SNDRV_PCM_FORMAT_S16_BE: /* fall through */
222
+ case SNDRV_PCM_FORMAT_S16_BE:
238223 word &= ~(AC97C_CMR_CEM_LITTLE);
239224 break;
240225 default:
....@@ -316,7 +301,7 @@
316301 switch (runtime->format) {
317302 case SNDRV_PCM_FORMAT_S16_LE:
318303 break;
319
- case SNDRV_PCM_FORMAT_S16_BE: /* fall through */
304
+ case SNDRV_PCM_FORMAT_S16_BE:
320305 word &= ~(AC97C_CMR_CEM_LITTLE);
321306 break;
322307 default:
....@@ -371,14 +356,14 @@
371356 camr = ac97c_readl(chip, CAMR);
372357
373358 switch (cmd) {
374
- case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: /* fall through */
375
- case SNDRV_PCM_TRIGGER_RESUME: /* fall through */
359
+ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
360
+ case SNDRV_PCM_TRIGGER_RESUME:
376361 case SNDRV_PCM_TRIGGER_START:
377362 ptcr = ATMEL_PDC_TXTEN;
378363 camr |= AC97C_CMR_CENA | AC97C_CSR_ENDTX;
379364 break;
380
- case SNDRV_PCM_TRIGGER_PAUSE_PUSH: /* fall through */
381
- case SNDRV_PCM_TRIGGER_SUSPEND: /* fall through */
365
+ case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
366
+ case SNDRV_PCM_TRIGGER_SUSPEND:
382367 case SNDRV_PCM_TRIGGER_STOP:
383368 ptcr |= ATMEL_PDC_TXTDIS;
384369 if (chip->opened <= 1)
....@@ -403,14 +388,14 @@
403388 ptcr = readl(chip->regs + ATMEL_PDC_PTSR);
404389
405390 switch (cmd) {
406
- case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: /* fall through */
407
- case SNDRV_PCM_TRIGGER_RESUME: /* fall through */
391
+ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
392
+ case SNDRV_PCM_TRIGGER_RESUME:
408393 case SNDRV_PCM_TRIGGER_START:
409394 ptcr = ATMEL_PDC_RXTEN;
410395 camr |= AC97C_CMR_CENA | AC97C_CSR_ENDRX;
411396 break;
412
- case SNDRV_PCM_TRIGGER_PAUSE_PUSH: /* fall through */
413
- case SNDRV_PCM_TRIGGER_SUSPEND: /* fall through */
397
+ case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
398
+ case SNDRV_PCM_TRIGGER_SUSPEND:
414399 case SNDRV_PCM_TRIGGER_STOP:
415400 ptcr |= ATMEL_PDC_RXTDIS;
416401 if (chip->opened <= 1)
....@@ -462,9 +447,7 @@
462447 static const struct snd_pcm_ops atmel_ac97_playback_ops = {
463448 .open = atmel_ac97c_playback_open,
464449 .close = atmel_ac97c_playback_close,
465
- .ioctl = snd_pcm_lib_ioctl,
466450 .hw_params = atmel_ac97c_playback_hw_params,
467
- .hw_free = snd_pcm_lib_free_pages,
468451 .prepare = atmel_ac97c_playback_prepare,
469452 .trigger = atmel_ac97c_playback_trigger,
470453 .pointer = atmel_ac97c_playback_pointer,
....@@ -473,9 +456,7 @@
473456 static const struct snd_pcm_ops atmel_ac97_capture_ops = {
474457 .open = atmel_ac97c_capture_open,
475458 .close = atmel_ac97c_capture_close,
476
- .ioctl = snd_pcm_lib_ioctl,
477459 .hw_params = atmel_ac97c_capture_hw_params,
478
- .hw_free = snd_pcm_lib_free_pages,
479460 .prepare = atmel_ac97c_capture_prepare,
480461 .trigger = atmel_ac97c_capture_trigger,
481462 .pointer = atmel_ac97c_capture_pointer,
....@@ -494,12 +475,12 @@
494475 struct snd_pcm_runtime *runtime;
495476 int offset, next_period, block_size;
496477 dev_dbg(&chip->pdev->dev, "channel A event%s%s%s%s%s%s\n",
497
- casr & AC97C_CSR_OVRUN ? " OVRUN" : "",
498
- casr & AC97C_CSR_RXRDY ? " RXRDY" : "",
499
- casr & AC97C_CSR_UNRUN ? " UNRUN" : "",
500
- casr & AC97C_CSR_TXEMPTY ? " TXEMPTY" : "",
501
- casr & AC97C_CSR_TXRDY ? " TXRDY" : "",
502
- !casr ? " NONE" : "");
478
+ (casr & AC97C_CSR_OVRUN) ? " OVRUN" : "",
479
+ (casr & AC97C_CSR_RXRDY) ? " RXRDY" : "",
480
+ (casr & AC97C_CSR_UNRUN) ? " UNRUN" : "",
481
+ (casr & AC97C_CSR_TXEMPTY) ? " TXEMPTY" : "",
482
+ (casr & AC97C_CSR_TXRDY) ? " TXRDY" : "",
483
+ !casr ? " NONE" : "");
503484 if ((casr & camr) & AC97C_CSR_ENDTX) {
504485 runtime = chip->playback_substream->runtime;
505486 block_size = frames_to_bytes(runtime, runtime->period_size);
....@@ -540,11 +521,11 @@
540521
541522 if (sr & AC97C_SR_COEVT) {
542523 dev_info(&chip->pdev->dev, "codec channel event%s%s%s%s%s\n",
543
- cosr & AC97C_CSR_OVRUN ? " OVRUN" : "",
544
- cosr & AC97C_CSR_RXRDY ? " RXRDY" : "",
545
- cosr & AC97C_CSR_TXEMPTY ? " TXEMPTY" : "",
546
- cosr & AC97C_CSR_TXRDY ? " TXRDY" : "",
547
- !cosr ? " NONE" : "");
524
+ (cosr & AC97C_CSR_OVRUN) ? " OVRUN" : "",
525
+ (cosr & AC97C_CSR_RXRDY) ? " RXRDY" : "",
526
+ (cosr & AC97C_CSR_TXEMPTY) ? " TXEMPTY" : "",
527
+ (cosr & AC97C_CSR_TXRDY) ? " TXRDY" : "",
528
+ !cosr ? " NONE" : "");
548529 retval = IRQ_HANDLED;
549530 }
550531
....@@ -603,11 +584,9 @@
603584 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &atmel_ac97_capture_ops);
604585 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_ac97_playback_ops);
605586
606
- retval = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
587
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
607588 &chip->pdev->dev, hw.periods_min * hw.period_bytes_min,
608589 hw.buffer_bytes_max);
609
- if (retval)
610
- return retval;
611590
612591 pcm->private_data = chip;
613592 pcm->info_flags = 0;
....@@ -723,7 +702,7 @@
723702 struct atmel_ac97c *chip;
724703 struct resource *regs;
725704 struct clk *pclk;
726
- static struct snd_ac97_bus_ops ops = {
705
+ static const struct snd_ac97_bus_ops ops = {
727706 .write = atmel_ac97c_write,
728707 .read = atmel_ac97c_read,
729708 };