From patchwork Tue Oct 22 11:45:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 11205905 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4C48112B for ; Wed, 23 Oct 2019 08:11:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BC1182173B for ; Wed, 23 Oct 2019 08:11:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC1182173B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7969A6E9B8; Wed, 23 Oct 2019 08:11:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-vk1-xa4a.google.com (mail-vk1-xa4a.google.com [IPv6:2607:f8b0:4864:20::a4a]) by gabe.freedesktop.org (Postfix) with ESMTPS id F2F596E5F0 for ; Tue, 22 Oct 2019 11:46:50 +0000 (UTC) Received: by mail-vk1-xa4a.google.com with SMTP id a7so7489332vkg.2 for ; Tue, 22 Oct 2019 04:46:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=q90rWJEkGm2l9nI3fLz2Cj+itxcilYQDCfUCXu1yWQg=; b=B6pHRixskO/t/2Mt2ftsMSCIV1Zz1yNMEmnK7aKwETwCKddQP9M0OVA5fq/PqCEfxo RiTf6BWf8c6ytxcQNsphO2lQ+BflH/BfA/pMvne5nq4F00jMh7oDV2LYdEXATfR4q/Yn Sse0zwIXGIbjCrpJMHQETo838euqYuRF/EEq100fTzCvO8VYuUiIOC5Akh+L5wRyPDa0 KYch2qbsEoLsijU+/sr2DLOWYUqcfnY3DWTTcYJ2buyyyxZorDyMIH39Nzub0u9eVeC1 8veg0w9YdG7XT7Y6HKAIq+1JM3c0RICb610LzaYlvZKJT2htJgzcGI+vsETtMOKX78fr WlzA== X-Gm-Message-State: APjAAAUFkWJjg40KNF58b0eTKhOtHjgG5HEVBhRHt4qKAOi5s43G9LsY IlVl+oRZCy/VJcb67THNM/3rkGxsuSnU X-Google-Smtp-Source: APXvYqzsB+mP+SYK0nkZDI+E5ctlzYSDa2qZV3FsZvCzlBqBSD0WoJVKv1DehaXyYVIbfl0rJsvRLOUyAOTG X-Received: by 2002:a67:8841:: with SMTP id k62mr1532968vsd.101.1571744809794; Tue, 22 Oct 2019 04:46:49 -0700 (PDT) Date: Tue, 22 Oct 2019 19:45:00 +0800 In-Reply-To: <20191022114505.196852-1-tzungbi@google.com> Message-Id: <20191022193301.1.I3039014cf259de5e4d6315fc05dff111591a0901@changeid> Mime-Version: 1.0 References: <20191022114505.196852-1-tzungbi@google.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog Subject: [PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator From: Tzung-Bi Shih To: broonie@kernel.org, robh+dt@kernel.org, narmstrong@baylibre.com X-Mailman-Approved-At: Wed, 23 Oct 2019 08:09:38 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=q90rWJEkGm2l9nI3fLz2Cj+itxcilYQDCfUCXu1yWQg=; b=fvUU4X0Sib4BfXVWA9CPePFVHefO+pH8Ci8fFdRiFSB5iTPQA+ra5mL+VLYXS7IZNR zt4DCioEFPM6+qZU7/V76QviJtdzE8pWUIIYz25OGqu8fcCg/ad/mBFD0X3VMj6iE6sl 5e5jBG8G1FjxHr/xlaM66aihrErDmJqsgHtVlTctEF8nGdpQyh3/iGguis1EpaVIXxFc r9FVu8lnN5mq2/lZJKIog6SciWR7ePKbkaMVHBwIX4gQOmsutILG/GhOmCeRGTxxkxUJ a75pPUwAB59Lx1guwRD0KIOKxiPcMXxt31Pn9IJzZN9q+c/Rv4tOuPJCaKinGj7AQDa0 0CQg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, cychiang@google.com, jonas@kwiboo.se, allen.chen@ite.com.tw, jernej.skrabec@siol.net, dri-devel@lists.freedesktop.org, Laurent.pinchart@ideasonboard.com, tzungbi@google.com, dgreid@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" HDMI codec may be also interested in PCM triggers. Add PCM trigger operator. Signed-off-by: Tzung-Bi Shih --- include/sound/hdmi-codec.h | 13 +++++++++++++ sound/soc/codecs/hdmi-codec.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index 83b17682e01c..9de462ef170d 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -50,6 +50,13 @@ struct hdmi_codec_params { typedef void (*hdmi_codec_plugged_cb)(struct device *dev, bool plugged); +enum { + HDMI_CODEC_TRIGGER_EVENT_STOP, + HDMI_CODEC_TRIGGER_EVENT_START, + HDMI_CODEC_TRIGGER_EVENT_SUSPEND, + HDMI_CODEC_TRIGGER_EVENT_RESUME, +}; + struct hdmi_codec_pdata; struct hdmi_codec_ops { /* @@ -66,6 +73,12 @@ struct hdmi_codec_ops { struct hdmi_codec_daifmt *fmt, struct hdmi_codec_params *hparms); + /* + * PCM trigger callback. + * Optional + */ + int (*trigger)(struct device *dev, int event); + /* * Shuts down the audio stream. * Mandatory diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index b5fd8f08726e..1ba2fa26ba03 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -565,12 +565,42 @@ static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute) return 0; } +static int hdmi_codec_trigger(struct snd_pcm_substream *substream, int cmd, + struct snd_soc_dai *dai) +{ + struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + int event; + + if (!hcp->hcd.ops->trigger) + return 0; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_STOP: + event = HDMI_CODEC_TRIGGER_EVENT_STOP; + break; + case SNDRV_PCM_TRIGGER_START: + event = HDMI_CODEC_TRIGGER_EVENT_START; + break; + case SNDRV_PCM_TRIGGER_SUSPEND: + event = HDMI_CODEC_TRIGGER_EVENT_SUSPEND; + break; + case SNDRV_PCM_TRIGGER_RESUME: + event = HDMI_CODEC_TRIGGER_EVENT_RESUME; + break; + default: + return -EINVAL; + } + + return hcp->hcd.ops->trigger(dai->dev->parent, event); +} + static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = { .startup = hdmi_codec_startup, .shutdown = hdmi_codec_shutdown, .hw_params = hdmi_codec_hw_params, .set_fmt = hdmi_codec_i2s_set_fmt, .digital_mute = hdmi_codec_digital_mute, + .trigger = hdmi_codec_trigger, }; static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { @@ -578,6 +608,7 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { .shutdown = hdmi_codec_shutdown, .hw_params = hdmi_codec_hw_params, .digital_mute = hdmi_codec_digital_mute, + .trigger = hdmi_codec_trigger, }; #define HDMI_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\