Skip to content

Commit ffb83e8

Browse files
morimotobroonie
authored andcommitted
ASoC: fsi: use SNDRV_DMA_TYPE_DEV for sound buffer
Current fsi driver is using SNDRV_DMA_TYPE_CONTINUOUS for snd_pcm_lib_preallocate_pages_for_all(). But, it came from original dma-sh7760.c, and no longer needed. This patch exchange its parameter, and removed original dma mapping and un-needed dma_sync_single_xxx() from driver. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@linaro.org>
1 parent 6f2a06c commit ffb83e8

5 files changed

Lines changed: 17 additions & 37 deletions

File tree

‎arch/arm/mach-shmobile/board-armadillo800eva.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,8 @@ static struct platform_device fsi_wm8978_device = {
998998
.id = 0,
999999
.dev = {
10001000
.platform_data = &fsi_wm8978_info,
1001+
.coherent_dma_mask = DMA_BIT_MASK(32),
1002+
.dma_mask = &fsi_wm8978_device.dev.coherent_dma_mask,
10011003
},
10021004
};
10031005

@@ -1021,6 +1023,8 @@ static struct platform_device fsi_hdmi_device = {
10211023
.id = 1,
10221024
.dev = {
10231025
.platform_data = &fsi2_hdmi_info,
1026+
.coherent_dma_mask = DMA_BIT_MASK(32),
1027+
.dma_mask = &fsi_hdmi_device.dev.coherent_dma_mask,
10241028
},
10251029
};
10261030

‎arch/arm/mach-shmobile/board-kzm9g.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ static struct platform_device fsi_ak4648_device = {
603603
.name = "asoc-simple-card",
604604
.dev = {
605605
.platform_data = &fsi2_ak4648_info,
606+
.coherent_dma_mask = DMA_BIT_MASK(32),
607+
.dma_mask = &fsi_ak4648_device.dev.coherent_dma_mask,
606608
},
607609
};
608610

‎arch/arm/mach-shmobile/board-mackerel.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ static struct platform_device fsi_hdmi_device = {
523523
.id = 1,
524524
.dev = {
525525
.platform_data = &fsi2_hdmi_info,
526+
.coherent_dma_mask = DMA_BIT_MASK(32),
527+
.dma_mask = &fsi_hdmi_device.dev.coherent_dma_mask,
526528
},
527529
};
528530

@@ -919,6 +921,8 @@ static struct platform_device fsi_ak4643_device = {
919921
.name = "asoc-simple-card",
920922
.dev = {
921923
.platform_data = &fsi2_ak4643_info,
924+
.coherent_dma_mask = DMA_BIT_MASK(32),
925+
.dma_mask = &fsi_ak4643_device.dev.coherent_dma_mask,
922926
},
923927
};
924928

‎arch/sh/boards/mach-ecovec24/setup.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,8 @@ static struct platform_device fsi_da7210_device = {
874874
.name = "asoc-simple-card",
875875
.dev = {
876876
.platform_data = &fsi_da7210_info,
877+
.coherent_dma_mask = DMA_BIT_MASK(32),
878+
.dma_mask = &fsi_da7210_device.dev.coherent_dma_mask,
877879
},
878880
};
879881

‎sound/soc/sh/fsi.c‎

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ struct fsi_stream {
233233
*/
234234
struct dma_chan *chan;
235235
struct work_struct work;
236-
dma_addr_t dma;
237236
int dma_id;
238237
int loop_cnt;
239238
int additional_pos;
@@ -1279,11 +1278,6 @@ static irqreturn_t fsi_interrupt(int irq, void *data)
12791278
*/
12801279
static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io)
12811280
{
1282-
struct snd_pcm_runtime *runtime = io->substream->runtime;
1283-
struct snd_soc_dai *dai = fsi_get_dai(io->substream);
1284-
enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ?
1285-
DMA_TO_DEVICE : DMA_FROM_DEVICE;
1286-
12871281
/*
12881282
* 24bit data : 24bit bus / package in back
12891283
* 16bit data : 16bit bus / stream mode
@@ -1293,19 +1287,7 @@ static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io)
12931287

12941288
io->loop_cnt = 2; /* push 1st, 2nd period first, then 3rd, 4th... */
12951289
io->additional_pos = 0;
1296-
io->dma = dma_map_single(dai->dev, runtime->dma_area,
1297-
snd_pcm_lib_buffer_bytes(io->substream), dir);
1298-
return 0;
1299-
}
1300-
1301-
static int fsi_dma_quit(struct fsi_priv *fsi, struct fsi_stream *io)
1302-
{
1303-
struct snd_soc_dai *dai = fsi_get_dai(io->substream);
1304-
enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ?
1305-
DMA_TO_DEVICE : DMA_FROM_DEVICE;
13061290

1307-
dma_unmap_single(dai->dev, io->dma,
1308-
snd_pcm_lib_buffer_bytes(io->substream), dir);
13091291
return 0;
13101292
}
13111293

@@ -1317,20 +1299,15 @@ static dma_addr_t fsi_dma_get_area(struct fsi_stream *io, int additional)
13171299
if (period >= runtime->periods)
13181300
period = 0;
13191301

1320-
return io->dma + samples_to_bytes(runtime, period * io->period_samples);
1302+
return runtime->dma_addr +
1303+
samples_to_bytes(runtime, period * io->period_samples);
13211304
}
13221305

13231306
static void fsi_dma_complete(void *data)
13241307
{
13251308
struct fsi_stream *io = (struct fsi_stream *)data;
13261309
struct fsi_priv *fsi = fsi_stream_to_priv(io);
13271310
struct snd_pcm_runtime *runtime = io->substream->runtime;
1328-
struct snd_soc_dai *dai = fsi_get_dai(io->substream);
1329-
enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ?
1330-
DMA_TO_DEVICE : DMA_FROM_DEVICE;
1331-
1332-
dma_sync_single_for_cpu(dai->dev, fsi_dma_get_area(io, 0),
1333-
samples_to_bytes(runtime, io->period_samples), dir);
13341311

13351312
io->buff_sample_pos += io->period_samples;
13361313
io->period_pos++;
@@ -1369,8 +1346,6 @@ static void fsi_dma_do_work(struct work_struct *work)
13691346
for (i = 0; i < io->loop_cnt; i++) {
13701347
buf = fsi_dma_get_area(io, io->additional_pos);
13711348

1372-
dma_sync_single_for_device(dai->dev, buf, len, dir);
1373-
13741349
desc = dmaengine_prep_slave_single(io->chan, buf, len, dir,
13751350
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
13761351
if (!desc) {
@@ -1495,7 +1470,6 @@ static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io)
14951470

14961471
static struct fsi_stream_handler fsi_dma_push_handler = {
14971472
.init = fsi_dma_init,
1498-
.quit = fsi_dma_quit,
14991473
.probe = fsi_dma_probe,
15001474
.transfer = fsi_dma_transfer,
15011475
.remove = fsi_dma_remove,
@@ -1850,16 +1824,10 @@ static void fsi_pcm_free(struct snd_pcm *pcm)
18501824

18511825
static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd)
18521826
{
1853-
struct snd_pcm *pcm = rtd->pcm;
1854-
1855-
/*
1856-
* dont use SNDRV_DMA_TYPE_DEV, since it will oops the SH kernel
1857-
* in MMAP mode (i.e. aplay -M)
1858-
*/
18591827
return snd_pcm_lib_preallocate_pages_for_all(
1860-
pcm,
1861-
SNDRV_DMA_TYPE_CONTINUOUS,
1862-
snd_dma_continuous_data(GFP_KERNEL),
1828+
rtd->pcm,
1829+
SNDRV_DMA_TYPE_DEV,
1830+
rtd->card->snd_card->dev,
18631831
PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
18641832
}
18651833

0 commit comments

Comments
 (0)