summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2018-08-08 16:38:36 -0400
committerTakashi Iwai <tiwai@suse.de>2018-08-28 07:56:49 -0400
commit87246f7fd572f9c3db752708730d68cc9eb08d72 (patch)
tree64dcaf1eca9ee0f38b3bb1b0f0682185455e0f58
parent4985ddbf1edb06f0dc4ae22e9886bde267925e6c (diff)
ALSA: intel_hdmi: Use the new non-cached allocation
The HDMI LPE audio driver requires the non-cached page allocations for its buffers. With the recent support of SNDRV_DMA_TYPE_DEV_UC type, we can reduce lots of codes in the driver side and let the memalloc core doing it properly. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/x86/intel_hdmi_audio.c29
1 files changed, 3 insertions, 26 deletions
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index fa7dca5a68c8..83d76c345940 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -30,7 +30,6 @@
30#include <linux/pm_runtime.h> 30#include <linux/pm_runtime.h>
31#include <linux/dma-mapping.h> 31#include <linux/dma-mapping.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <asm/set_memory.h>
34#include <sound/core.h> 33#include <sound/core.h>
35#include <sound/asoundef.h> 34#include <sound/asoundef.h>
36#include <sound/pcm.h> 35#include <sound/pcm.h>
@@ -1141,8 +1140,7 @@ static int had_pcm_hw_params(struct snd_pcm_substream *substream,
1141 struct snd_pcm_hw_params *hw_params) 1140 struct snd_pcm_hw_params *hw_params)
1142{ 1141{
1143 struct snd_intelhad *intelhaddata; 1142 struct snd_intelhad *intelhaddata;
1144 unsigned long addr; 1143 int buf_size, retval;
1145 int pages, buf_size, retval;
1146 1144
1147 intelhaddata = snd_pcm_substream_chip(substream); 1145 intelhaddata = snd_pcm_substream_chip(substream);
1148 buf_size = params_buffer_bytes(hw_params); 1146 buf_size = params_buffer_bytes(hw_params);
@@ -1151,17 +1149,6 @@ static int had_pcm_hw_params(struct snd_pcm_substream *substream,
1151 return retval; 1149 return retval;
1152 dev_dbg(intelhaddata->dev, "%s:allocated memory = %d\n", 1150 dev_dbg(intelhaddata->dev, "%s:allocated memory = %d\n",
1153 __func__, buf_size); 1151 __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; 1152 return retval;
1166} 1153}
1167 1154
@@ -1171,21 +1158,11 @@ static int had_pcm_hw_params(struct snd_pcm_substream *substream,
1171static int had_pcm_hw_free(struct snd_pcm_substream *substream) 1158static int had_pcm_hw_free(struct snd_pcm_substream *substream)
1172{ 1159{
1173 struct snd_intelhad *intelhaddata; 1160 struct snd_intelhad *intelhaddata;
1174 unsigned long addr;
1175 u32 pages;
1176 1161
1177 intelhaddata = snd_pcm_substream_chip(substream); 1162 intelhaddata = snd_pcm_substream_chip(substream);
1178 had_do_reset(intelhaddata); 1163 had_do_reset(intelhaddata);
1179 1164
1180 /* mark back the pages as cached/writeback region before the free */ 1165 return snd_pcm_lib_free_pages(substream);
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 }
1188 return 0;
1189} 1166}
1190 1167
1191/* 1168/*
@@ -1860,7 +1837,7 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
1860 * try to allocate 600k buffer as default which is large enough 1837 * try to allocate 600k buffer as default which is large enough
1861 */ 1838 */
1862 snd_pcm_lib_preallocate_pages_for_all(pcm, 1839 snd_pcm_lib_preallocate_pages_for_all(pcm,
1863 SNDRV_DMA_TYPE_DEV, NULL, 1840 SNDRV_DMA_TYPE_DEV_UC, NULL,
1864 HAD_DEFAULT_BUFFER, HAD_MAX_BUFFER); 1841 HAD_DEFAULT_BUFFER, HAD_MAX_BUFFER);
1865 1842
1866 /* create controls */ 1843 /* create controls */