Skip to content

Commit

Permalink
ASoC: Push workqueue data into snd_soc_card
Browse files Browse the repository at this point in the history
ASoC v2 does not use the struct snd_soc_device at runtime, using struct
snd_soc_card as the root of the card.  Begin removing data from
snd_soc_device by pushing the workqueue data into snd_soc_card, using a
backpointer to the snd_soc_device to keep things going for the time
being.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Mark Brown committed Dec 2, 2008
1 parent 0ecfe79 commit 6308419
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
7 changes: 5 additions & 2 deletions include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ struct snd_soc_card {
/* CPU <--> Codec DAI links */
struct snd_soc_dai_link *dai_link;
int num_links;

struct snd_soc_device *socdev;

struct delayed_work delayed_work;
struct work_struct deferred_resume_work;
};

/* SoC Device - the audio subsystem */
Expand All @@ -358,8 +363,6 @@ struct snd_soc_device {
struct snd_soc_platform *platform;
struct snd_soc_codec *codec;
struct snd_soc_codec_device *codec_dev;
struct delayed_work delayed_work;
struct work_struct deferred_resume_work;
void *codec_data;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_root;
Expand Down
33 changes: 20 additions & 13 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
*/
static void close_delayed_work(struct work_struct *work)
{
struct snd_soc_device *socdev =
container_of(work, struct snd_soc_device, delayed_work.work);
struct snd_soc_card *card = container_of(work, struct snd_soc_card,
delayed_work.work);
struct snd_soc_device *socdev = card->socdev;
struct snd_soc_codec *codec = socdev->codec;
struct snd_soc_dai *codec_dai;
int i;
Expand Down Expand Up @@ -299,6 +300,7 @@ static int soc_codec_close(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_device *socdev = rtd->socdev;
struct snd_soc_card *card = socdev->card;
struct snd_soc_dai_link *machine = rtd->dai;
struct snd_soc_platform *platform = socdev->platform;
struct snd_soc_dai *cpu_dai = machine->cpu_dai;
Expand Down Expand Up @@ -340,7 +342,7 @@ static int soc_codec_close(struct snd_pcm_substream *substream)
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
/* start delayed pop wq here for playback streams */
codec_dai->pop_wait = 1;
schedule_delayed_work(&socdev->delayed_work,
schedule_delayed_work(&card->delayed_work,
msecs_to_jiffies(pmdown_time));
} else {
/* capture streams can be powered down now */
Expand All @@ -366,6 +368,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_device *socdev = rtd->socdev;
struct snd_soc_card *card = socdev->card;
struct snd_soc_dai_link *machine = rtd->dai;
struct snd_soc_platform *platform = socdev->platform;
struct snd_soc_dai *cpu_dai = machine->cpu_dai;
Expand Down Expand Up @@ -411,7 +414,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
codec_dai->pop_wait) {
codec_dai->pop_wait = 0;
cancel_delayed_work(&socdev->delayed_work);
cancel_delayed_work(&card->delayed_work);
}

/* do we need to power up codec */
Expand Down Expand Up @@ -645,7 +648,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
}

/* close any waiting streams and save state */
run_delayed_work(&socdev->delayed_work);
run_delayed_work(&card->delayed_work);
codec->suspend_bias_level = codec->bias_level;

for (i = 0; i < codec->num_dai; i++) {
Expand Down Expand Up @@ -679,10 +682,10 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
*/
static void soc_resume_deferred(struct work_struct *work)
{
struct snd_soc_device *socdev = container_of(work,
struct snd_soc_device,
deferred_resume_work);
struct snd_soc_card *card = socdev->card;
struct snd_soc_card *card = container_of(work,
struct snd_soc_card,
deferred_resume_work);
struct snd_soc_device *socdev = card->socdev;
struct snd_soc_platform *platform = socdev->platform;
struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
struct snd_soc_codec *codec = socdev->codec;
Expand Down Expand Up @@ -746,10 +749,11 @@ static void soc_resume_deferred(struct work_struct *work)
static int soc_resume(struct platform_device *pdev)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
struct snd_soc_card *card = socdev->card;

dev_dbg(socdev->dev, "scheduling resume work\n");

if (!schedule_work(&socdev->deferred_resume_work))
if (!schedule_work(&card->deferred_resume_work))
dev_err(socdev->dev, "resume work item may be lost\n");

return 0;
Expand All @@ -769,6 +773,9 @@ static int soc_probe(struct platform_device *pdev)
struct snd_soc_platform *platform = socdev->platform;
struct snd_soc_codec_device *codec_dev = socdev->codec_dev;

/* Bodge while we push things out of socdev */
card->socdev = socdev;

if (card->probe) {
ret = card->probe(pdev);
if (ret < 0)
Expand Down Expand Up @@ -797,10 +804,10 @@ static int soc_probe(struct platform_device *pdev)
}

/* DAPM stream work */
INIT_DELAYED_WORK(&socdev->delayed_work, close_delayed_work);
INIT_DELAYED_WORK(&card->delayed_work, close_delayed_work);
#ifdef CONFIG_PM
/* deferred resume work */
INIT_WORK(&socdev->deferred_resume_work, soc_resume_deferred);
INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
#endif

return 0;
Expand Down Expand Up @@ -831,7 +838,7 @@ static int soc_remove(struct platform_device *pdev)
struct snd_soc_platform *platform = socdev->platform;
struct snd_soc_codec_device *codec_dev = socdev->codec_dev;

run_delayed_work(&socdev->delayed_work);
run_delayed_work(&card->delayed_work);

if (platform->remove)
platform->remove(pdev);
Expand Down

0 comments on commit 6308419

Please sign in to comment.