All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jyri Sarha <jsarha-l0cyMroinI0@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	airlied-cv59FeDIM0c@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	bcousson-rdvid1DuHRBWk0Htik3J/w@public.gmane.org,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org
Cc: tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org,
	broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	liam.r.girdwood-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
	peter.ujfalusi-l0cyMroinI0@public.gmane.org,
	tomi.valkeinen-l0cyMroinI0@public.gmane.org,
	moinejf-GANU6spQydw@public.gmane.org,
	arnaud.pouliquen-qxv4g6HH51o@public.gmane.org,
	rmk+kernel-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
	Jyri Sarha <jsarha-l0cyMroinI0@public.gmane.org>
Subject: [PATCH RFC v5 3/8] ASoC: hdmi-codec: Add audio abort() callback for video side to use
Date: Wed, 17 Feb 2016 16:49:04 +0200	[thread overview]
Message-ID: <9aed642926bee8c108b82e243ed0ef3e810db50f.1455720381.git.jsarha@ti.com> (raw)
In-Reply-To: <cover.1455720381.git.jsarha-l0cyMroinI0@public.gmane.org>

Add audio abort() callback, that is provided at audio stream start,
for video side. This is for video side to use in case there is a
pressing need to tear down the audio playback for some reason.

Signed-off-by: Jyri Sarha <jsarha-l0cyMroinI0@public.gmane.org>
---
 include/sound/hdmi-codec.h    |  8 ++++++--
 sound/soc/codecs/hdmi-codec.c | 20 +++++++++++++++++++-
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index fc3a481..15fe70f 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -55,10 +55,14 @@ struct hdmi_codec_params {
 
 struct hdmi_codec_ops {
 	/*
-	 * Called when ASoC starts an audio stream setup.
+	 * Called when ASoC starts an audio stream setup. The call
+	 * provides an audio abort callback for stoping an ongoing
+	 * stream from video side driver if the HDMI audio becomes
+	 * unavailable.
 	 * Optional
 	 */
-	int (*audio_startup)(struct device *dev);
+	int (*audio_startup)(struct device *dev,
+			     void (*abort_cb)(struct device *dev));
 
 	/*
 	 * Configures HDMI-encoder for audio stream.
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index bc47b9a..cc08097 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -47,6 +47,23 @@ enum {
 	DAI_ID_SPDIF,
 };
 
+static void hdmi_codec_abort(struct device *dev)
+{
+	struct hdmi_codec_priv *hcp = dev_get_drvdata(dev);
+
+	dev_dbg(dev, "%s()\n", __func__);
+
+	mutex_lock(&hcp->current_stream_lock);
+	if (hcp->current_stream && hcp->current_stream->runtime &&
+	    snd_pcm_running(hcp->current_stream)) {
+		dev_info(dev, "HDMI audio playback aborted\n");
+		snd_pcm_stream_lock_irq(hcp->current_stream);
+		snd_pcm_stop(hcp->current_stream, SNDRV_PCM_STATE_DISCONNECTED);
+		snd_pcm_stream_unlock_irq(hcp->current_stream);
+	}
+	mutex_unlock(&hcp->current_stream_lock);
+}
+
 static int hdmi_codec_new_stream(struct snd_pcm_substream *substream,
 				 struct snd_soc_dai *dai)
 {
@@ -78,7 +95,8 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
 		return ret;
 
 	if (hcp->hcd.ops->audio_startup) {
-		ret = hcp->hcd.ops->audio_startup(dai->dev->parent);
+		ret = hcp->hcd.ops->audio_startup(dai->dev->parent,
+						  hdmi_codec_abort);
 		if (ret) {
 			mutex_lock(&hcp->current_stream_lock);
 			hcp->current_stream = NULL;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-02-17 14:49 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17 14:49 [PATCH RFC v5 0/8] Implement generic ASoC HDMI codec and use it in tda998x Jyri Sarha
2016-02-17 14:49 ` [PATCH RFC v5 1/8] ALSA: pcm: add IEC958 channel status helper for hw_params Jyri Sarha
2016-02-17 14:49 ` [PATCH RFC v5 2/8] ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders Jyri Sarha
2016-02-22 14:22   ` Arnaud Pouliquen
2016-03-08 16:59   ` Arnaud Pouliquen
     [not found] ` <cover.1455720381.git.jsarha-l0cyMroinI0@public.gmane.org>
2016-02-17 14:49   ` Jyri Sarha [this message]
2016-02-17 14:49 ` [PATCH RFC v5 4/8] drm/i2c: tda998x: Add support of a DT graph of ports Jyri Sarha
     [not found]   ` <842e221030a0b14bc862790eb2f5bc97bb29c012.1455720381.git.jsarha-l0cyMroinI0@public.gmane.org>
2016-02-18 14:35     ` Rob Herring
2016-02-18 15:18       ` Jean-Francois Moine
2016-02-18 15:32         ` Russell King - ARM Linux
2016-02-25 13:42       ` Jyri Sarha
     [not found]         ` <56CF04DA.8080905-l0cyMroinI0@public.gmane.org>
2016-02-26  0:43           ` Russell King - ARM Linux
2016-02-26 10:14             ` Jyri Sarha
2016-02-26 11:21               ` Russell King - ARM Linux
2016-02-29 10:36                 ` Jyri Sarha
2016-03-01 14:26                   ` Alternative binding proposal for tda998x audio (Was: Re: [PATCH RFC v5 4/8] drm/i2c: tda998x: Add support of a DT graph of ports) Jyri Sarha
2016-03-01 15:35                     ` Jean-Francois Moine
2016-03-01 15:51                       ` Jyri Sarha
2016-03-01 16:16                         ` Jean-Francois Moine
2016-03-01 18:29                           ` Jyri Sarha
     [not found]                             ` <56D5DF7D.7090608-l0cyMroinI0@public.gmane.org>
2016-03-01 19:26                               ` Jean-Francois Moine
2016-03-02  8:34                                 ` Jyri Sarha
     [not found]                           ` <20160301171630.630a47dc00060645f89bb8ab-GANU6spQydw@public.gmane.org>
2016-03-02  4:29                             ` Mark Brown
2016-02-17 14:49 ` [PATCH RFC v5 5/8] drm/i2c: tda998x: Remove include/sound/tda998x.h and fix graph parsing Jyri Sarha
2016-02-17 14:49 ` [PATCH RFC v5 6/8] drm/i2c: tda998x: Improve tda998x_configure_audio() audio related pdata Jyri Sarha
2016-02-17 14:49 ` [PATCH RFC v5 7/8] drm/i2c: tda998x: Register ASoC HDMI codec for audio functionality Jyri Sarha
2016-02-17 14:49 ` [PATCH RFC v5 8/8] ARM: dts: am335x-boneblack: Add HDMI audio support Jyri Sarha
2016-02-17 19:36   ` Robert Nelson

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=9aed642926bee8c108b82e243ed0ef3e810db50f.1455720381.git.jsarha@ti.com \
    --to=jsarha-l0cymroini0@public.gmane.org \
    --cc=airlied-cv59FeDIM0c@public.gmane.org \
    --cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
    --cc=arnaud.pouliquen-qxv4g6HH51o@public.gmane.org \
    --cc=bcousson-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=liam.r.girdwood-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=moinejf-GANU6spQydw@public.gmane.org \
    --cc=peter.ujfalusi-l0cyMroinI0@public.gmane.org \
    --cc=rmk+kernel-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
    --cc=tomi.valkeinen-l0cyMroinI0@public.gmane.org \
    --cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.