hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/xtensa/xtfpga-i2s.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Xtfpga I2S controller driver
34 *
45 * Copyright (c) 2014 Cadence Design Systems Inc.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
96 */
107
118 #include <linux/clk.h>
....@@ -368,29 +365,31 @@
368365 .fifo_size = 16,
369366 };
370367
371
-static int xtfpga_pcm_open(struct snd_pcm_substream *substream)
368
+static int xtfpga_pcm_open(struct snd_soc_component *component,
369
+ struct snd_pcm_substream *substream)
372370 {
373371 struct snd_pcm_runtime *runtime = substream->runtime;
374
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
372
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
375373 void *p;
376374
377375 snd_soc_set_runtime_hwparams(substream, &xtfpga_pcm_hardware);
378
- p = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
376
+ p = snd_soc_dai_get_dma_data(asoc_rtd_to_cpu(rtd, 0), substream);
379377 runtime->private_data = p;
380378
381379 return 0;
382380 }
383381
384
-static int xtfpga_pcm_close(struct snd_pcm_substream *substream)
382
+static int xtfpga_pcm_close(struct snd_soc_component *component,
383
+ struct snd_pcm_substream *substream)
385384 {
386385 synchronize_rcu();
387386 return 0;
388387 }
389388
390
-static int xtfpga_pcm_hw_params(struct snd_pcm_substream *substream,
389
+static int xtfpga_pcm_hw_params(struct snd_soc_component *component,
390
+ struct snd_pcm_substream *substream,
391391 struct snd_pcm_hw_params *hw_params)
392392 {
393
- int ret;
394393 struct snd_pcm_runtime *runtime = substream->runtime;
395394 struct xtfpga_i2s *i2s = runtime->private_data;
396395 unsigned channels = params_channels(hw_params);
....@@ -422,12 +421,11 @@
422421 return -EINVAL;
423422 }
424423
425
- ret = snd_pcm_lib_malloc_pages(substream,
426
- params_buffer_bytes(hw_params));
427
- return ret;
424
+ return 0;
428425 }
429426
430
-static int xtfpga_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
427
+static int xtfpga_pcm_trigger(struct snd_soc_component *component,
428
+ struct snd_pcm_substream *substream, int cmd)
431429 {
432430 int ret = 0;
433431 struct snd_pcm_runtime *runtime = substream->runtime;
....@@ -455,7 +453,8 @@
455453 return ret;
456454 }
457455
458
-static snd_pcm_uframes_t xtfpga_pcm_pointer(struct snd_pcm_substream *substream)
456
+static snd_pcm_uframes_t xtfpga_pcm_pointer(struct snd_soc_component *component,
457
+ struct snd_pcm_substream *substream)
459458 {
460459 struct snd_pcm_runtime *runtime = substream->runtime;
461460 struct xtfpga_i2s *i2s = runtime->private_data;
....@@ -464,29 +463,25 @@
464463 return pos < runtime->buffer_size ? pos : 0;
465464 }
466465
467
-static int xtfpga_pcm_new(struct snd_soc_pcm_runtime *rtd)
466
+static int xtfpga_pcm_new(struct snd_soc_component *component,
467
+ struct snd_soc_pcm_runtime *rtd)
468468 {
469469 struct snd_card *card = rtd->card->snd_card;
470470 size_t size = xtfpga_pcm_hardware.buffer_bytes_max;
471471
472
- return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
473
- SNDRV_DMA_TYPE_DEV,
474
- card->dev, size, size);
472
+ snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV,
473
+ card->dev, size, size);
474
+ return 0;
475475 }
476
-
477
-static const struct snd_pcm_ops xtfpga_pcm_ops = {
478
- .open = xtfpga_pcm_open,
479
- .close = xtfpga_pcm_close,
480
- .ioctl = snd_pcm_lib_ioctl,
481
- .hw_params = xtfpga_pcm_hw_params,
482
- .trigger = xtfpga_pcm_trigger,
483
- .pointer = xtfpga_pcm_pointer,
484
-};
485476
486477 static const struct snd_soc_component_driver xtfpga_i2s_component = {
487478 .name = DRV_NAME,
488
- .pcm_new = xtfpga_pcm_new,
489
- .ops = &xtfpga_pcm_ops,
479
+ .open = xtfpga_pcm_open,
480
+ .close = xtfpga_pcm_close,
481
+ .hw_params = xtfpga_pcm_hw_params,
482
+ .trigger = xtfpga_pcm_trigger,
483
+ .pointer = xtfpga_pcm_pointer,
484
+ .pcm_construct = xtfpga_pcm_new,
490485 };
491486
492487 static const struct snd_soc_dai_ops xtfpga_i2s_dai_ops = {
....@@ -534,7 +529,6 @@
534529 static int xtfpga_i2s_probe(struct platform_device *pdev)
535530 {
536531 struct xtfpga_i2s *i2s;
537
- struct resource *mem;
538532 int err, irq;
539533
540534 i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL);
....@@ -546,8 +540,7 @@
546540 i2s->dev = &pdev->dev;
547541 dev_dbg(&pdev->dev, "dev: %p, i2s: %p\n", &pdev->dev, i2s);
548542
549
- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
550
- i2s->regs = devm_ioremap_resource(&pdev->dev, mem);
543
+ i2s->regs = devm_platform_ioremap_resource(pdev, 0);
551544 if (IS_ERR(i2s->regs)) {
552545 err = PTR_ERR(i2s->regs);
553546 goto err;
....@@ -575,7 +568,6 @@
575568
576569 irq = platform_get_irq(pdev, 0);
577570 if (irq < 0) {
578
- dev_err(&pdev->dev, "No IRQ resource\n");
579571 err = irq;
580572 goto err;
581573 }