From: rmk+kernel@arm.linux.org.uk (Russell King)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC 01/13] ASoC: kirkwood: merge struct kirkwood_dma_priv with struct kirkwood_dma_data
Date: Sun, 04 Aug 2013 20:22:03 +0100 [thread overview]
Message-ID: <E1V63sR-0004lC-0g@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20130804192136.GK23006@n2100.arm.linux.org.uk>
Merge these two structures together; nothing other than the I2S and
DMA driver makes use of struct kirkwood_dma_data, and it's not like
struct kirkwood_dma_data is really just used to convey DMA specific
data to the backend; it's more a general shared structure between the
two halves.
This will later allow kirkwood-dma.c and kirkwood-i2s.c to be merged
together.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
sound/soc/kirkwood/kirkwood-dma.c | 76 +++++++++++--------------------------
sound/soc/kirkwood/kirkwood.h | 2 +
2 files changed, 24 insertions(+), 54 deletions(-)
diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c
index d3d4bdc..112c262 100644
--- a/sound/soc/kirkwood/kirkwood-dma.c
+++ b/sound/soc/kirkwood/kirkwood-dma.c
@@ -33,11 +33,11 @@
SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE | \
SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE)
-struct kirkwood_dma_priv {
- struct snd_pcm_substream *play_stream;
- struct snd_pcm_substream *rec_stream;
- struct kirkwood_dma_data *data;
-};
+static struct kirkwood_dma_data *kirkwood_priv(struct snd_pcm_substream *subs)
+{
+ struct snd_soc_pcm_runtime *soc_runtime = subs->private_data;
+ return snd_soc_dai_get_drvdata(soc_runtime->cpu_dai);
+}
static struct snd_pcm_hardware kirkwood_dma_snd_hw = {
.info = (SNDRV_PCM_INFO_INTERLEAVED |
@@ -63,8 +63,7 @@ static u64 kirkwood_dma_dmamask = DMA_BIT_MASK(32);
static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id)
{
- struct kirkwood_dma_priv *prdata = dev_id;
- struct kirkwood_dma_data *priv = prdata->data;
+ struct kirkwood_dma_data *priv = dev_id;
unsigned long mask, status, cause;
mask = readl(priv->io + KIRKWOOD_INT_MASK);
@@ -89,10 +88,10 @@ static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id)
writel(status, priv->io + KIRKWOOD_INT_CAUSE);
if (status & KIRKWOOD_INT_CAUSE_PLAY_BYTES)
- snd_pcm_period_elapsed(prdata->play_stream);
+ snd_pcm_period_elapsed(priv->substream_play);
if (status & KIRKWOOD_INT_CAUSE_REC_BYTES)
- snd_pcm_period_elapsed(prdata->rec_stream);
+ snd_pcm_period_elapsed(priv->substream_rec);
return IRQ_HANDLED;
}
@@ -126,15 +125,10 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
{
int err;
struct snd_pcm_runtime *runtime = substream->runtime;
- struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
- struct snd_soc_platform *platform = soc_runtime->platform;
- struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
- struct kirkwood_dma_data *priv;
- struct kirkwood_dma_priv *prdata = snd_soc_platform_get_drvdata(platform);
+ struct kirkwood_dma_data *priv = kirkwood_priv(substream);
const struct mbus_dram_target_info *dram;
unsigned long addr;
- priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
snd_soc_set_runtime_hwparams(substream, &kirkwood_dma_snd_hw);
/* Ensure that all constraints linked to dma burst are fulfilled */
@@ -157,21 +151,11 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
if (err < 0)
return err;
- if (prdata == NULL) {
- prdata = kzalloc(sizeof(struct kirkwood_dma_priv), GFP_KERNEL);
- if (prdata == NULL)
- return -ENOMEM;
-
- prdata->data = priv;
-
+ if (!priv->substream_play && !priv->substream_rec) {
err = request_irq(priv->irq, kirkwood_dma_irq, IRQF_SHARED,
- "kirkwood-i2s", prdata);
- if (err) {
- kfree(prdata);
+ "kirkwood-i2s", priv);
+ if (err)
return -EBUSY;
- }
-
- snd_soc_platform_set_drvdata(platform, prdata);
/*
* Enable Error interrupts. We're only ack'ing them but
@@ -183,11 +167,11 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
dram = mv_mbus_dram_info();
addr = substream->dma_buffer.addr;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- prdata->play_stream = substream;
+ priv->substream_play = substream;
kirkwood_dma_conf_mbus_windows(priv->io,
KIRKWOOD_PLAYBACK_WIN, addr, dram);
} else {
- prdata->rec_stream = substream;
+ priv->substream_rec = substream;
kirkwood_dma_conf_mbus_windows(priv->io,
KIRKWOOD_RECORD_WIN, addr, dram);
}
@@ -197,27 +181,19 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
static int kirkwood_dma_close(struct snd_pcm_substream *substream)
{
- struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
- struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
- struct snd_soc_platform *platform = soc_runtime->platform;
- struct kirkwood_dma_priv *prdata = snd_soc_platform_get_drvdata(platform);
- struct kirkwood_dma_data *priv;
-
- priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
+ struct kirkwood_dma_data *priv = kirkwood_priv(substream);
- if (!prdata || !priv)
+ if (!priv)
return 0;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
- prdata->play_stream = NULL;
+ priv->substream_play = NULL;
else
- prdata->rec_stream = NULL;
+ priv->substream_rec = NULL;
- if (!prdata->play_stream && !prdata->rec_stream) {
+ if (!priv->substream_play && !priv->substream_rec) {
writel(0, priv->io + KIRKWOOD_ERR_MASK);
- free_irq(priv->irq, prdata);
- kfree(prdata);
- snd_soc_platform_set_drvdata(platform, NULL);
+ free_irq(priv->irq, priv);
}
return 0;
@@ -243,13 +219,9 @@ static int kirkwood_dma_hw_free(struct snd_pcm_substream *substream)
static int kirkwood_dma_prepare(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
- struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
- struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
- struct kirkwood_dma_data *priv;
+ struct kirkwood_dma_data *priv = kirkwood_priv(substream);
unsigned long size, count;
- priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
-
/* compute buffer size in term of "words" as requested in specs */
size = frames_to_bytes(runtime, runtime->buffer_size);
size = (size>>2)-1;
@@ -272,13 +244,9 @@ static int kirkwood_dma_prepare(struct snd_pcm_substream *substream)
static snd_pcm_uframes_t kirkwood_dma_pointer(struct snd_pcm_substream
*substream)
{
- struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
- struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
- struct kirkwood_dma_data *priv;
+ struct kirkwood_dma_data *priv = kirkwood_priv(substream);
snd_pcm_uframes_t count;
- priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
-
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
count = bytes_to_frames(substream->runtime,
readl(priv->io + KIRKWOOD_PLAY_BYTE_COUNT));
diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h
index 4d92637..10a3aaa 100644
--- a/sound/soc/kirkwood/kirkwood.h
+++ b/sound/soc/kirkwood/kirkwood.h
@@ -129,6 +129,8 @@ struct kirkwood_dma_data {
struct clk *extclk;
uint32_t ctl_play;
uint32_t ctl_rec;
+ struct snd_pcm_substream *substream_play;
+ struct snd_pcm_substream *substream_rec;
int irq;
int burst;
};
--
1.7.4.4
next prev parent reply other threads:[~2013-08-04 19:22 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-04 19:21 [PATCH RFC 00/13] Adding SPDIF support to kirkwood-i2s Russell King - ARM Linux
2013-08-04 19:22 ` Russell King [this message]
2013-08-05 14:49 ` [PATCH RFC 01/13] ASoC: kirkwood: merge struct kirkwood_dma_priv with struct kirkwood_dma_data Mark Brown
2013-08-04 19:23 ` [PATCH RFC 02/13] ASoC: kirkwood: use devm_clk_get() for the external clock Russell King
2013-08-05 16:16 ` Mark Brown
2013-08-04 19:24 ` [PATCH RFC 03/13] ASoC: avoid duplicated DAI routes Russell King
2013-08-05 16:18 ` Mark Brown
2013-08-04 19:25 ` [PATCH RFC 04/13] ASoC: HACK: avoid creating duplicated widgets Russell King
2013-08-04 19:26 ` [PATCH RFC 05/13] ASoC: kirkwood: provide KIRKWOOD_PLAYCTL_ENABLE_MASK Russell King
2013-08-05 17:03 ` Mark Brown
2013-08-04 19:27 ` [PATCH RFC 06/13] ASoC: kirkwood: combine kirkwood-i2s and kirkwood-dma drivers Russell King
2013-08-05 10:13 ` Jean-Francois Moine
2013-08-05 10:20 ` Russell King - ARM Linux
2013-08-05 17:04 ` Mark Brown
2013-08-04 19:28 ` [PATCH RFC 07/13] ASoC: kirkwood: move calculation of max buffer size to kirkwood.h Russell King
2013-08-05 17:07 ` Mark Brown
2013-08-04 19:29 ` [PATCH RFC 08/13] ASoC: kirkwood: add DAPM widgets for input and output routing Russell King
2013-08-04 19:30 ` [PATCH RFC 09/13] ASoC: kirkwood-openrd: add DAPM links between codec and cpu DAI Russell King
2013-08-04 19:31 ` [PATCH RFC 10/13] ASoC: kirkwood-t5325: " Russell King
2013-08-05 11:27 ` Mark Brown
2013-08-05 11:33 ` Russell King - ARM Linux
2013-08-05 14:40 ` Mark Brown
2013-08-05 14:56 ` Russell King - ARM Linux
2013-08-05 20:32 ` Russell King - ARM Linux
2013-08-05 22:06 ` Mark Brown
2013-08-05 23:30 ` Russell King - ARM Linux
2013-08-06 13:32 ` Mark Brown
2013-08-10 16:11 ` Russell King - ARM Linux
2013-08-10 21:13 ` Russell King - ARM Linux
2013-08-12 7:40 ` [alsa-devel] " Liam Girdwood
2013-08-12 8:28 ` Russell King - ARM Linux
2013-08-13 14:59 ` Liam Girdwood
2013-08-20 10:25 ` Russell King - ARM Linux
2013-08-20 11:44 ` Mark Brown
2013-08-20 11:49 ` Russell King - ARM Linux
2013-08-20 13:31 ` Russell King - ARM Linux
2013-08-20 18:50 ` Mark Brown
2013-08-20 20:18 ` Russell King - ARM Linux
2013-08-22 19:22 ` Liam Girdwood
2013-08-22 20:16 ` Russell King - ARM Linux
2013-08-23 12:13 ` Liam Girdwood
2013-08-23 12:58 ` Russell King - ARM Linux
2013-08-23 16:58 ` Mark Brown
2013-08-23 17:45 ` Russell King - ARM Linux
2013-08-28 1:22 ` Mark Brown
[not found] ` <CAOyKLY_mQzPxHAg2RFSMY89uxp-0-OAf6fC=gVY0i+pQhv4iHQ@mail.gmail.com>
2013-08-30 11:27 ` Russell King - ARM Linux
2013-08-30 16:10 ` Russell King - ARM Linux
2013-08-11 12:36 ` Mark Brown
2013-08-04 19:32 ` [PATCH RFC 11/13] ASoC: spdif_transceiver: add output pin widget Russell King
2013-08-05 11:33 ` Mark Brown
2013-08-04 19:33 ` [PATCH RFC 12/13] ASoC: kirkwood: add SPDIF output support Russell King
2013-08-04 19:34 ` [PATCH RFC 13/13] ASoC: kirkwood: add IEC958 channel status support Russell King
2013-08-04 21:45 ` [PATCH RFC 00/13] Adding SPDIF support to kirkwood-i2s Sebastian Hesselbarth
2013-08-05 8:43 ` Thomas Petazzoni
2013-08-05 8:53 ` Russell King - ARM Linux
2013-08-05 9:06 ` Thomas Petazzoni
2013-08-05 11:59 ` Mark Brown
2013-08-05 13:06 ` Sebastian Hesselbarth
2013-08-05 14:07 ` Mark Brown
2013-08-05 15:04 ` Sebastian Hesselbarth
2013-08-05 16:59 ` Mark Brown
2013-08-05 18:14 ` Sebastian Hesselbarth
2013-08-05 18:59 ` Mark Brown
2013-08-05 22:47 ` [alsa-devel] " Stephen Warren
2013-08-05 14:10 ` Lars-Peter Clausen
2013-08-05 15:03 ` Mark Brown
2013-08-06 0:02 ` Kuninori Morimoto
2013-08-30 7:20 ` Kuninori Morimoto
2013-08-30 8:26 ` Lars-Peter Clausen
2013-08-30 9:56 ` Mark Brown
2013-08-05 14:59 ` Russell King - ARM Linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1V63sR-0004lC-0g@rmk-PC.arm.linux.org.uk \
--to=rmk+kernel@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).