From patchwork Thu Mar 17 10:03:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 8609611 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8FDC39F44D for ; Thu, 17 Mar 2016 10:05:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B757B20108 for ; Thu, 17 Mar 2016 10:05:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA87020149 for ; Thu, 17 Mar 2016 10:05:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935537AbcCQKFR (ORCPT ); Thu, 17 Mar 2016 06:05:17 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:54361 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935538AbcCQKFP (ORCPT ); Thu, 17 Mar 2016 06:05:15 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id u2HA4DIt000348; Thu, 17 Mar 2016 05:04:13 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u2HA4DSV009279; Thu, 17 Mar 2016 05:04:13 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Thu, 17 Mar 2016 05:04:12 -0500 Received: from imryr.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u2HA3wWQ010471; Thu, 17 Mar 2016 05:04:09 -0500 From: Jyri Sarha To: , , , , , CC: , , , , , , , , , Jyri Sarha Subject: [PATCH v7 3/6] ASoC: hdmi-codec: Add audio abort() callback for video side to use Date: Thu, 17 Mar 2016 12:03:45 +0200 Message-ID: <47206922b9580db740fcdf2d09186a27d1e5f1bf.1458207661.git.jsarha@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;