forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/sound/x86/intel_hdmi_audio.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * intel_hdmi_audio.c - Intel HDMI audio driver
34 *
....@@ -7,15 +8,6 @@
78 * Vaibhav Agarwal <vaibhav.agarwal@intel.com>
89 * Jerome Anand <jerome.anand@intel.com>
910 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License as published by
13
- * the Free Software Foundation; version 2 of the License.
14
- *
15
- * This program is distributed in the hope that it will be useful, but
16
- * WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
- * General Public License for more details.
1911 *
2012 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2113 * ALSA driver for Intel HDMI audio
....@@ -30,7 +22,6 @@
3022 #include <linux/pm_runtime.h>
3123 #include <linux/dma-mapping.h>
3224 #include <linux/delay.h>
33
-#include <asm/set_memory.h>
3425 #include <sound/core.h>
3526 #include <sound/asoundef.h>
3627 #include <sound/pcm.h>
....@@ -1141,28 +1132,13 @@
11411132 struct snd_pcm_hw_params *hw_params)
11421133 {
11431134 struct snd_intelhad *intelhaddata;
1144
- unsigned long addr;
1145
- int pages, buf_size, retval;
1135
+ int buf_size;
11461136
11471137 intelhaddata = snd_pcm_substream_chip(substream);
11481138 buf_size = params_buffer_bytes(hw_params);
1149
- retval = snd_pcm_lib_malloc_pages(substream, buf_size);
1150
- if (retval < 0)
1151
- return retval;
11521139 dev_dbg(intelhaddata->dev, "%s:allocated memory = %d\n",
11531140 __func__, buf_size);
1154
- /* mark the pages as uncached region */
1155
- addr = (unsigned long) substream->runtime->dma_area;
1156
- pages = (substream->runtime->dma_bytes + PAGE_SIZE - 1) / PAGE_SIZE;
1157
- retval = set_memory_uc(addr, pages);
1158
- if (retval) {
1159
- dev_err(intelhaddata->dev, "set_memory_uc failed.Error:%d\n",
1160
- retval);
1161
- return retval;
1162
- }
1163
- memset(substream->runtime->dma_area, 0, buf_size);
1164
-
1165
- return retval;
1141
+ return 0;
11661142 }
11671143
11681144 /*
....@@ -1171,20 +1147,10 @@
11711147 static int had_pcm_hw_free(struct snd_pcm_substream *substream)
11721148 {
11731149 struct snd_intelhad *intelhaddata;
1174
- unsigned long addr;
1175
- u32 pages;
11761150
11771151 intelhaddata = snd_pcm_substream_chip(substream);
11781152 had_do_reset(intelhaddata);
11791153
1180
- /* mark back the pages as cached/writeback region before the free */
1181
- if (substream->runtime->dma_area != NULL) {
1182
- addr = (unsigned long) substream->runtime->dma_area;
1183
- pages = (substream->runtime->dma_bytes + PAGE_SIZE - 1) /
1184
- PAGE_SIZE;
1185
- set_memory_wb(addr, pages);
1186
- return snd_pcm_lib_free_pages(substream);
1187
- }
11881154 return 0;
11891155 }
11901156
....@@ -1310,7 +1276,7 @@
13101276 {
13111277 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
13121278 return remap_pfn_range(vma, vma->vm_start,
1313
- substream->dma_buffer.addr >> PAGE_SHIFT,
1279
+ substream->runtime->dma_addr >> PAGE_SHIFT,
13141280 vma->vm_end - vma->vm_start, vma->vm_page_prot);
13151281 }
13161282
....@@ -1320,7 +1286,6 @@
13201286 static const struct snd_pcm_ops had_pcm_ops = {
13211287 .open = had_pcm_open,
13221288 .close = had_pcm_close,
1323
- .ioctl = snd_pcm_lib_ioctl,
13241289 .hw_params = had_pcm_hw_params,
13251290 .hw_free = had_pcm_hw_free,
13261291 .prepare = had_pcm_prepare,
....@@ -1671,39 +1636,12 @@
16711636 * PM callbacks
16721637 */
16731638
1674
-static int hdmi_lpe_audio_runtime_suspend(struct device *dev)
1675
-{
1676
- struct snd_intelhad_card *card_ctx = dev_get_drvdata(dev);
1677
- int port;
1678
-
1679
- for_each_port(card_ctx, port) {
1680
- struct snd_intelhad *ctx = &card_ctx->pcm_ctx[port];
1681
- struct snd_pcm_substream *substream;
1682
-
1683
- substream = had_substream_get(ctx);
1684
- if (substream) {
1685
- snd_pcm_suspend(substream);
1686
- had_substream_put(ctx);
1687
- }
1688
- }
1689
-
1690
- return 0;
1691
-}
1692
-
16931639 static int __maybe_unused hdmi_lpe_audio_suspend(struct device *dev)
16941640 {
16951641 struct snd_intelhad_card *card_ctx = dev_get_drvdata(dev);
1696
- int err;
16971642
1698
- err = hdmi_lpe_audio_runtime_suspend(dev);
1699
- if (!err)
1700
- snd_power_change_state(card_ctx->card, SNDRV_CTL_POWER_D3hot);
1701
- return err;
1702
-}
1643
+ snd_power_change_state(card_ctx->card, SNDRV_CTL_POWER_D3hot);
17031644
1704
-static int hdmi_lpe_audio_runtime_resume(struct device *dev)
1705
-{
1706
- pm_runtime_mark_last_busy(dev);
17071645 return 0;
17081646 }
17091647
....@@ -1711,8 +1649,10 @@
17111649 {
17121650 struct snd_intelhad_card *card_ctx = dev_get_drvdata(dev);
17131651
1714
- hdmi_lpe_audio_runtime_resume(dev);
1652
+ pm_runtime_mark_last_busy(dev);
1653
+
17151654 snd_power_change_state(card_ctx->card, SNDRV_CTL_POWER_D0);
1655
+
17161656 return 0;
17171657 }
17181658
....@@ -1764,10 +1704,8 @@
17641704
17651705 /* get resources */
17661706 irq = platform_get_irq(pdev, 0);
1767
- if (irq < 0) {
1768
- dev_err(&pdev->dev, "Could not get irq resource: %d\n", irq);
1707
+ if (irq < 0)
17691708 return irq;
1770
- }
17711709
17721710 res_mmio = platform_get_resource(pdev, IORESOURCE_MEM, 0);
17731711 if (!res_mmio) {
....@@ -1813,7 +1751,7 @@
18131751 __func__, (unsigned int)res_mmio->start,
18141752 (unsigned int)res_mmio->end);
18151753
1816
- card_ctx->mmio_start = ioremap_nocache(res_mmio->start,
1754
+ card_ctx->mmio_start = ioremap(res_mmio->start,
18171755 (size_t)(resource_size(res_mmio)));
18181756 if (!card_ctx->mmio_start) {
18191757 dev_err(&pdev->dev, "Could not get ioremap\n");
....@@ -1859,9 +1797,9 @@
18591797 /* allocate dma pages;
18601798 * try to allocate 600k buffer as default which is large enough
18611799 */
1862
- snd_pcm_lib_preallocate_pages_for_all(pcm,
1863
- SNDRV_DMA_TYPE_DEV, NULL,
1864
- HAD_DEFAULT_BUFFER, HAD_MAX_BUFFER);
1800
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_UC,
1801
+ card->dev, HAD_DEFAULT_BUFFER,
1802
+ HAD_MAX_BUFFER);
18651803
18661804 /* create controls */
18671805 for (i = 0; i < ARRAY_SIZE(had_controls); i++) {
....@@ -1930,8 +1868,6 @@
19301868
19311869 static const struct dev_pm_ops hdmi_lpe_audio_pm = {
19321870 SET_SYSTEM_SLEEP_PM_OPS(hdmi_lpe_audio_suspend, hdmi_lpe_audio_resume)
1933
- SET_RUNTIME_PM_OPS(hdmi_lpe_audio_runtime_suspend,
1934
- hdmi_lpe_audio_runtime_resume, NULL)
19351871 };
19361872
19371873 static struct platform_driver hdmi_lpe_audio_driver = {