From patchwork Fri Jul 5 04:26:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 11032737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39C35138D for ; Fri, 5 Jul 2019 14:21:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26CF72864B for ; Fri, 5 Jul 2019 14:21:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16BB028867; Fri, 5 Jul 2019 14:21:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C3F32864B for ; Fri, 5 Jul 2019 14:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rgcx+M5u3eJczjSSwzYC3Xhkt97MiCKzHS9c6hmBjZc=; b=BDKcHgeNocbfxi 94OXuwvwUgfWqiAcVDOypNS1PXFPdXr8zdEdT/QYyTd1tRC/yFTLhZboKXEy5uHnCsa+bRnNZykiG JLUvMf2IkQlPBq4WacVAVv4Q4ho86JuWDui/9lUbpojVjaBprGw2Ik7E2NbSpO+pSlEj+64sAyiyr /NlEpNdBJf5VHQOoYQA4kC55uQp/58d4NdwwwFSb/upKbobaQd+E8rmKYUgAUkLToL1SOergj8Upq +mgYw7rWwASVJObNnGiqGO9dEo3YftgtwkzBIFF3WUgtQY+D30lxkshoVfK5ibTk1rsmZkCQ3UFFb BPOcpCE3OfPb+lZaLEXQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hjP56-0006RV-LV; Fri, 05 Jul 2019 14:20:56 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hjP4e-0005xM-OB for linux-rockchip@bombadil.infradead.org; Fri, 05 Jul 2019 14:20:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+3G7gaXEJuSaVZO7JAbYh3wKp+iQz6Nh9jSGcVM+k6U=; b=P7maXdYA/cSEVY4O9ponIxSCGt 2Af89EUeErCZxsW0GVgK7DEU7roTDfvf0EhfHysO4qG5jNuNH3PIzh8pksmax7nDZqfUDaDtRisRM 0ze14KeZ9EsuVjM4ytXCqPm33F75/M473wN3CpwXm3GcFScub88V+Uf1vz7WgyCv4gBnT0ItkubGi pYyDGZFt/R7P3FcPtz8J2JusYVydmoVp9VCzyVurmX7VdXjXPFKsGsWgODafgY3k1E2T4WSLu8hvY ipHzNKrXQS7Z+z9OOA/8iISxyf10gZ0MHXDzJR1eTF6K5bmJy4gCc1+W+IHdTfy5nEmrR6yinDrA6 ctDbH1Ng==; Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by casper.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hjFq8-0006aO-2V for linux-rockchip@lists.infradead.org; Fri, 05 Jul 2019 04:28:53 +0000 Received: by mail-pf1-x441.google.com with SMTP id m30so3718510pff.8 for ; Thu, 04 Jul 2019 21:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+3G7gaXEJuSaVZO7JAbYh3wKp+iQz6Nh9jSGcVM+k6U=; b=nMtfntFDTuoSfK9/VFf/q1vvFv3BHdF9zSOETr3vqyb6NzVWs4/fbfev94T09R+aUd 3vNBcFB033ya7IZyhwEjfeccLxwKb4rNzeYxICCdJ6mDfnK8h5MLTINtR+qH1dqoaGr8 WFkvrCy91KPXVRYCKm4om3V826Sg44F5rrCGA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+3G7gaXEJuSaVZO7JAbYh3wKp+iQz6Nh9jSGcVM+k6U=; b=P1/tXoDZaHx6Qlrh7DghLf1lunJKFsQMgkWwp7C7fMVPwouypCkueAT8hlG/tVfbW/ eGtB/NPVjUmfVt24Nqia8wCOXqkPK4yqFYlyAJuzb7/ensd44lqiSFVLv/iFQVfC95Qk X8jfupIL/aPgvkqnZypD3nWnGjZA/hpmLf/CjSBRBY2P0h4nYOYk0dhPLlCB2CC+suq6 MxnASuFy2naEA9rNKol5BjE6QY+Geyc35SPnKnQHAD/sHF9LkyyCt22EyOMyGfve1xOg 3QXB/PI2u9Lql6mWYCB7svnFG9awtNjO021ucmNNvIHDFA+h0tXxAER5p0I2XUvMGxap oSHg== X-Gm-Message-State: APjAAAUXaaH2xBmukZgTXQAinX4SaYerjKQpXZbHfFZoVGFI/DI7x0gN VO0EivAr8z6WRon5SM0HqGdzog== X-Google-Smtp-Source: APXvYqxo3SdDzWV2z9ih0ZiNNE3HnS7c3zDkLrVJE1fvL3y0/NYA0aJNny09tyDNEaQonEEmk3XdTw== X-Received: by 2002:a65:430a:: with SMTP id j10mr2429110pgq.374.1562300804603; Thu, 04 Jul 2019 21:26:44 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id b29sm17718645pfr.159.2019.07.04.21.26.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 21:26:44 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Subject: [PATCH 1/4] ASoC: hdmi-codec: Add an op to set callback function for plug event Date: Fri, 5 Jul 2019 12:26:20 +0800 Message-Id: <20190705042623.129541-2-cychiang@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190705042623.129541-1-cychiang@chromium.org> References: <20190705042623.129541-1-cychiang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190705_052852_123424_E133D66E X-CRM114-Status: GOOD ( 19.10 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, dianders@chromium.org, Heiko Stuebner , linux-rockchip@lists.infradead.org, David Airlie , dri-devel@lists.freedesktop.org, Takashi Iwai , Liam Girdwood , tzungbi@chromium.org, Jaroslav Kysela , Hans Verkuil , Andrzej Hajda , Russell King , Mark Brown , Laurent Pinchart , Daniel Vetter , dgreid@chromium.org, linux-arm-kernel@lists.infradead.org, Cheng-Yi Chiang Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add an op in hdmi_codec_ops so codec driver can register callback function to handle plug event. Driver in DRM can use this callback function to report connector status. Signed-off-by: Cheng-Yi Chiang --- include/sound/hdmi-codec.h | 16 +++++++++++ sound/soc/codecs/hdmi-codec.c | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index 7fea496f1f34..26c02abb8eba 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -47,6 +47,9 @@ struct hdmi_codec_params { int channels; }; +typedef void (*hdmi_codec_plugged_cb)(struct platform_device *dev, + bool plugged); + struct hdmi_codec_pdata; struct hdmi_codec_ops { /* @@ -88,6 +91,13 @@ struct hdmi_codec_ops { */ int (*get_dai_id)(struct snd_soc_component *comment, struct device_node *endpoint); + + /* + * Hook callback function to handle connector plug event. + * Optional + */ + int (*hook_plugged_cb)(struct device *dev, void *data, + hdmi_codec_plugged_cb fn); }; /* HDMI codec initalization data */ @@ -99,6 +109,12 @@ struct hdmi_codec_pdata { void *data; }; +struct snd_soc_component; +struct snd_soc_jack; + +int hdmi_codec_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *jack); + #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec" #endif /* __HDMI_CODEC_H__ */ diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 0bf1c8cad108..5e7075f78c38 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -274,6 +275,8 @@ struct hdmi_codec_priv { struct snd_pcm_chmap *chmap_info; unsigned int chmap_idx; struct mutex lock; + struct snd_soc_jack *jack; + unsigned int jack_status; }; static const struct snd_soc_dapm_widget hdmi_widgets[] = { @@ -663,6 +666,55 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai) return 0; } +static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp, + unsigned int jack_status) +{ + if (!hcp->jack) + return; + + if (jack_status != hcp->jack_status) { + snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT); + hcp->jack_status = jack_status; + } +} + +static void plugged_cb(struct platform_device *pdev, bool plugged) +{ + struct platform_device *codec_pdev = platform_get_drvdata(pdev); + struct hdmi_codec_priv *hcp = platform_get_drvdata(codec_pdev); + + if (plugged) + hdmi_codec_jack_report(hcp, SND_JACK_LINEOUT); + else + hdmi_codec_jack_report(hcp, 0); +} + +/** + * hdmi_codec_set_jack_detect - register HDMI plugged callback + * @component: the hdmi-codec instance + * @jack: ASoC jack to report (dis)connection events on + */ +int hdmi_codec_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *jack) +{ + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + int ret; + + if (hcp->hcd.ops->hook_plugged_cb) { + hcp->jack = jack; + ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, + hcp->hcd.data, + plugged_cb); + if (ret) { + hcp->jack = NULL; + return ret; + } + return 0; + } + return -EOPNOTSUPP; +} +EXPORT_SYMBOL_GPL(hdmi_codec_set_jack_detect); + static int hdmi_dai_spdif_probe(struct snd_soc_dai *dai) { struct hdmi_codec_daifmt *cf = dai->playback_dma_data; From patchwork Fri Jul 5 04:26:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 11032717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D35F13B1 for ; Fri, 5 Jul 2019 14:15:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A0CA28A44 for ; Fri, 5 Jul 2019 14:15:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D1AD28A4C; Fri, 5 Jul 2019 14:15:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A0D2528A44 for ; Fri, 5 Jul 2019 14:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IWnuS29/nyqOFcWkSxQOYd/Q8K80FQhrtz/mn+Iz5o4=; b=LydeOrBfcw9R0I mLcPDOtxTwIRTkij9BVLvYuTUYYNHfKCklT5/tbhfM6SjNA71YllAARlxVLVbFT7/V/PK/mahiDe8 xGSVAo/0zIrMrq2UXrGTMi86noyBqRmSraBJHR4xq8qD39aSKMuRnN8HscHrwlzQEvuceaK6NVx7X sTWOuGv1GjJkGy2gEVAdiXx21FI/i8vdfAhaRv8Evfgwb3vayeK6zIWvoIC8VrKyrRkrCGb729YIs WpygqFI226D2PXkFSKWs7PNnkYBT6FvJDw3WDx/iZdxE9z/MCiXVSfyfUxmzUPKF4WoFH8UioRloM r9nyq14m+BYV5YhIPvnA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hjOzm-0000UV-AV; Fri, 05 Jul 2019 14:15:26 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hjOzl-0000TV-Ea for linux-rockchip@bombadil.infradead.org; Fri, 05 Jul 2019 14:15:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FfAso7efMu/aA+eHOC+kWuha2DdRu+sIyUVZpYri0wk=; b=rRs0b7GDzwA5oCDF97aQF4c1AV W36T3BtWG570sOGKNpSfqAhCDNZYevK8iXuT6V7AXm6VnJuKOoNRbjJA/l5+SuSfKVl7oVuWCwERt iQFU/Pf0EIQTV9RRrwTQzx/IYQeef7LJCykMl/5pufsVbGd8Rr4dQaKn+Y3bxZOoBvYSaR7GEaCgj 1TSuPoZTKmHwyHnolOVax/FDMB0NIUp95b20XpKQPIU8fxIpSvO4oFQHT+wyfVI8Sel27fMlrxEaF I6vglvaVmdDAxTcpE3/gJ0hMTTvS6/ChB6SBNuWN1fjKginycA5w/07zpRS6eobtFyJ2sxXNvI9ob mMkfHCSg==; Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by casper.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hjFqD-0006ax-T2 for linux-rockchip@lists.infradead.org; Fri, 05 Jul 2019 04:28:59 +0000 Received: by mail-pg1-x541.google.com with SMTP id c13so3701086pgg.3 for ; Thu, 04 Jul 2019 21:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FfAso7efMu/aA+eHOC+kWuha2DdRu+sIyUVZpYri0wk=; b=NQaaID67Y+LZwPST2LvJBza5Z0GadFPix/sAuAKZfbGHz2qYjWAokPh73WmpEZVBX+ ovAj5OC9r9vmp+giPJWm6aGtvcx9wCAxNasdbMQrs46bEhkDxQItAQ/gc7xQSOMGIiwi y1c+dcnmFLnIFj+8Cj21PpTCMX3HNEnakazQg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FfAso7efMu/aA+eHOC+kWuha2DdRu+sIyUVZpYri0wk=; b=WfmY6eMD0yFi9quX93RVTq0a1ey52gzd15+b0j2/MTpNMW3U56s+DveOG/Ww/06lqp YKCwNaaYGVanHwkCHs+epB2IX5j9gBcN6v7NPIwLC+jfnU6D0cQLr2Cw8zJf1EFIwdmt Rh2yA7K9hdiMlBaA6IHcLIr+YUEpxTJADWWQZ8XNwnTa4BxWj4hkIwBUXzLqoB0tYQsb ATGN2Yv70mSsnTaggAw4/QiOrmUV5CnXdcBzcUl/XANWxO5sS9F0nA5IK4tCfawLhqmW jXq/MW7P5Hw0hq8qbTU/3xyDfKqShLz+UufwvKxrWMyekAcfyITO/d0ZjJtTgHDPVBjx zWow== X-Gm-Message-State: APjAAAVQXvLbKdmPrA5vsG364oJ5LESpfCRFm/VNydaqxz72oNuEuoLT zmT8PKbJz576lDYtuJa6jbK1RQ== X-Google-Smtp-Source: APXvYqwZbL+s761iX960bRQQcsfHBESYYHX6caI+DhUbiPV9OOsTfm5vhRVAxh6UChQM0IMk+bwDTw== X-Received: by 2002:a63:24c1:: with SMTP id k184mr2425512pgk.120.1562300810605; Thu, 04 Jul 2019 21:26:50 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id h2sm6126547pgs.17.2019.07.04.21.26.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 21:26:50 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Subject: [PATCH 2/4] drm: bridge: dw-hdmi: Report connector status using callback Date: Fri, 5 Jul 2019 12:26:21 +0800 Message-Id: <20190705042623.129541-3-cychiang@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190705042623.129541-1-cychiang@chromium.org> References: <20190705042623.129541-1-cychiang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190705_052858_014428_EABF75A6 X-CRM114-Status: GOOD ( 18.89 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, dianders@chromium.org, Heiko Stuebner , linux-rockchip@lists.infradead.org, David Airlie , dri-devel@lists.freedesktop.org, Takashi Iwai , Liam Girdwood , tzungbi@chromium.org, Jaroslav Kysela , Hans Verkuil , Andrzej Hajda , Russell King , Mark Brown , Laurent Pinchart , Daniel Vetter , dgreid@chromium.org, linux-arm-kernel@lists.infradead.org, Cheng-Yi Chiang Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Allow codec driver register callback function for plug event. The callback registration flow: dw-hdmi <--- hw-hdmi-i2s-audio <--- hdmi-codec dw-hdmi-i2s-audio implements hook_plugged_cb op so codec driver can register the callback. dw-hdmi implements set_plugged_cb op so platform device can register the callback. When connector plug/unplug event happens, report this event using the callback. Make sure that audio and drm are using the single source of truth for connector status. Signed-off-by: Cheng-Yi Chiang --- .../gpu/drm/bridge/synopsys/dw-hdmi-audio.h | 3 ++ .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 10 ++++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 34 ++++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h index 63b5756f463b..f523c590984e 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h @@ -2,6 +2,8 @@ #ifndef DW_HDMI_AUDIO_H #define DW_HDMI_AUDIO_H +#include + struct dw_hdmi; struct dw_hdmi_audio_data { @@ -17,6 +19,7 @@ struct dw_hdmi_i2s_audio_data { void (*write)(struct dw_hdmi *hdmi, u8 val, int offset); u8 (*read)(struct dw_hdmi *hdmi, int offset); + int (*set_plugged_cb)(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn); }; #endif diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c index 5cbb71a866d5..7b93cf05c985 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c @@ -104,10 +104,20 @@ static int dw_hdmi_i2s_get_dai_id(struct snd_soc_component *component, return -EINVAL; } +static int dw_hdmi_i2s_hook_plugged_cb(struct device *dev, void *data, + hdmi_codec_plugged_cb fn) +{ + struct dw_hdmi_i2s_audio_data *audio = data; + struct dw_hdmi *hdmi = audio->hdmi; + + return audio->set_plugged_cb(hdmi, fn); +} + static struct hdmi_codec_ops dw_hdmi_i2s_ops = { .hw_params = dw_hdmi_i2s_hw_params, .audio_shutdown = dw_hdmi_i2s_audio_shutdown, .get_dai_id = dw_hdmi_i2s_get_dai_id, + .hook_plugged_cb = dw_hdmi_i2s_hook_plugged_cb, }; static int snd_dw_hdmi_probe(struct platform_device *pdev) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 045b1b13fd0e..c69a399fc7ca 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include @@ -185,6 +187,9 @@ struct dw_hdmi { void (*disable_audio)(struct dw_hdmi *hdmi); struct cec_notifier *cec_notifier; + + hdmi_codec_plugged_cb plugged_cb; + enum drm_connector_status last_connector_result; }; #define HDMI_IH_PHY_STAT0_RX_SENSE \ @@ -209,6 +214,17 @@ static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset) return val; } +static int hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn) +{ + mutex_lock(&hdmi->mutex); + hdmi->plugged_cb = fn; + if (hdmi->audio && !IS_ERR(hdmi->audio)) + fn(hdmi->audio, + hdmi->last_connector_result == connector_status_connected); + mutex_unlock(&hdmi->mutex); + return 0; +} + static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg) { regmap_update_bits(hdmi->regm, reg << hdmi->reg_shift, mask, data); @@ -2044,6 +2060,7 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) { struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, connector); + enum drm_connector_status result; mutex_lock(&hdmi->mutex); hdmi->force = DRM_FORCE_UNSPECIFIED; @@ -2051,7 +2068,20 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) dw_hdmi_update_phy_mask(hdmi); mutex_unlock(&hdmi->mutex); - return hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data); + result = hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data); + + mutex_lock(&hdmi->mutex); + if (result != hdmi->last_connector_result) { + dev_dbg(hdmi->dev, "read_hpd result: %d", result); + if (hdmi->plugged_cb && hdmi->audio && !IS_ERR(hdmi->audio)) { + hdmi->plugged_cb(hdmi->audio, + result == connector_status_connected); + hdmi->last_connector_result = result; + } + } + mutex_unlock(&hdmi->mutex); + + return result; } static int dw_hdmi_connector_get_modes(struct drm_connector *connector) @@ -2460,6 +2490,7 @@ __dw_hdmi_probe(struct platform_device *pdev, hdmi->rxsense = true; hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE); hdmi->mc_clkdis = 0x7f; + hdmi->last_connector_result = connector_status_disconnected; mutex_init(&hdmi->mutex); mutex_init(&hdmi->audio_mutex); @@ -2653,6 +2684,7 @@ __dw_hdmi_probe(struct platform_device *pdev, audio.hdmi = hdmi; audio.write = hdmi_writeb; audio.read = hdmi_readb; + audio.set_plugged_cb = hdmi_set_plugged_cb; hdmi->enable_audio = dw_hdmi_i2s_audio_enable; hdmi->disable_audio = dw_hdmi_i2s_audio_disable; From patchwork Fri Jul 5 04:26:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 11032721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CC8A14C0 for ; Fri, 5 Jul 2019 14:16:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15C8828A44 for ; Fri, 5 Jul 2019 14:16:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07B5028A4B; Fri, 5 Jul 2019 14:16:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 728EF28A44 for ; Fri, 5 Jul 2019 14:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SI3ftfxOqybg3sYzT86pImPBBCJgFpBVeenEa+tKx7s=; b=h+9RpR/dJtIJKL 57sZ8xJtKGH2A+hPwu1wTkRVBLUItfEzW/y4uXNz0rlGZrRfk+Y9sLO3Oth8kCTCBD6S6s0ddt/X8 q6Uw/2ZEST/VOX3RwaNEhtsAzibVMgCYOoazHpfjaac1vOltEkaF3X9TKEr68qvBQJCCQaDqNWh3Z 1kqRk2jX/clL94dPnOzrNtyr83JEqPNAv7dFvmNeY41H0UYxdIaOxaOt3kuD+03EvIDW5hQ2OJqlv C+O+PYu6YNTu3U4RX4tCYW5s36PtNYHZ8epic3Ju6oaaKYSh0rcJyDRaMRFiIzj1kjnuJPcsASNRt e37E8JvI1g5s1gU01doA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hjP0l-0001PT-Uy; Fri, 05 Jul 2019 14:16:28 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hjP0Y-00019S-Sb for linux-rockchip@bombadil.infradead.org; Fri, 05 Jul 2019 14:16:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4oIAHqq3UAUgpkR6sSucT+BzHp65oe00yNkTNIs4JdE=; b=OzGPnLPyvT94FiCmzyx1CSLm56 H1Ixnmq2UUrKoP+QShIeKkg+JPUuUeqTgtXTIcTfsJM86kIwSq/tzmDkIcJIz1RXF0y6MxXthuW/w oKYle8Qgv4vFWLonhmXIOM14GrT6Q6xOW7X67rPGayvGIxR8L34AcoS/jiXx14bpGuvwHWCUcn5il E1R99o0yvmJL/gIswIvSIk3f69DIgx69JvOMDL1qdWJtdAdr4RPUqhzZS7u5aoWgsCJGxicx9ziUp H3J7v/2ethqx+Fc5feE4hDEdw3DT0/1wETcm+5EJ73XKZor6HZFyoXkS+jC2lpUj/kX+o/dXePnIF WUlCyaIw==; Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by casper.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hjFqK-0006ba-9j for linux-rockchip@lists.infradead.org; Fri, 05 Jul 2019 04:29:06 +0000 Received: by mail-pf1-x441.google.com with SMTP id r7so3728779pfl.3 for ; Thu, 04 Jul 2019 21:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4oIAHqq3UAUgpkR6sSucT+BzHp65oe00yNkTNIs4JdE=; b=PwtIvDAmfgaG2RBqXzjf8+M8mWQHmaESJw+WjrLtjyzCMr7uJP8QXAwrnIAQw02Bfv bELs8zuHqAN2moN7tm8uK39+ff6heLfG3Wi4oSEcGrTiQwi7FqQK5xLIdwuSyEW3DHJG jGFaGnVtdPGHSlNGT7+HOCmR7JE6TwiNUXnuE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4oIAHqq3UAUgpkR6sSucT+BzHp65oe00yNkTNIs4JdE=; b=V4UWCFfeFHukxILq/gzQDxuMaSothuQ2WBPw6XleIgXUH2HbqbN91Rk/avUyrJfODq 1efGnbLPu5jWAVrJbnjhAlQy9yMLJMACQcDQfQEc1o4rJXQplGxfxZIlbvmTF59QUoYc EtLRt3wGZ/GCuQShyd/dYNZgmjxaDWiWyCRxTTyU2TEuhofeKupGIKDToAopxVtZf86h XxokCXZvlAC4jehp/fpFI3IlEfRZ+RqvrZivy2VReS8gBSpzd9JwFhjRKu0fun3t90iE akaZHNBxqVcaqGMzY5MwzYjoZ2wzj5JA0iqJbWgtTmq/zM8v+5+D2ErdfIY4gAyaESM9 sOpQ== X-Gm-Message-State: APjAAAWaSRHEVapBxMj3lpcUxkLiTtitzUJroF2FDHBjndfR50dbfR93 CNmDJXxdetk7EVOS/lzF+aYL+Q== X-Google-Smtp-Source: APXvYqxsi0uwEYB9vZCqMNCKrk5F1sjDC5678yF7q3XtYhh8tXIEweUWv0+w8blJUeCj5tsfQhpMFg== X-Received: by 2002:a63:60cc:: with SMTP id u195mr2331509pgb.13.1562300817276; Thu, 04 Jul 2019 21:26:57 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id cx22sm6962871pjb.25.2019.07.04.21.26.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 21:26:56 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Subject: [PATCH 3/4] ASoC: rockchip_max98090: Add dai_link for HDMI Date: Fri, 5 Jul 2019 12:26:22 +0800 Message-Id: <20190705042623.129541-4-cychiang@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190705042623.129541-1-cychiang@chromium.org> References: <20190705042623.129541-1-cychiang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190705_052904_458917_FC144081 X-CRM114-Status: GOOD ( 19.93 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, dianders@chromium.org, Heiko Stuebner , linux-rockchip@lists.infradead.org, David Airlie , dri-devel@lists.freedesktop.org, Takashi Iwai , Liam Girdwood , tzungbi@chromium.org, Jaroslav Kysela , Hans Verkuil , Andrzej Hajda , Russell King , Mark Brown , Laurent Pinchart , Daniel Vetter , dgreid@chromium.org, linux-arm-kernel@lists.infradead.org, Cheng-Yi Chiang Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use two dai_links. One for HDMI and one for max98090. With this setup, audio can play to speaker and HDMI selectively. Signed-off-by: Cheng-Yi Chiang --- sound/soc/rockchip/rockchip_max98090.c | 91 +++++++++++++++++++------- 1 file changed, 68 insertions(+), 23 deletions(-) diff --git a/sound/soc/rockchip/rockchip_max98090.c b/sound/soc/rockchip/rockchip_max98090.c index c5fc24675a33..195309d1225a 100644 --- a/sound/soc/rockchip/rockchip_max98090.c +++ b/sound/soc/rockchip/rockchip_max98090.c @@ -41,6 +41,7 @@ static const struct snd_soc_dapm_widget rk_dapm_widgets[] = { SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_MIC("Int Mic", NULL), SND_SOC_DAPM_SPK("Speaker", NULL), + SND_SOC_DAPM_LINE("HDMI", NULL), }; static const struct snd_soc_dapm_route rk_audio_map[] = { @@ -52,6 +53,7 @@ static const struct snd_soc_dapm_route rk_audio_map[] = { {"Headphone", NULL, "HPR"}, {"Speaker", NULL, "SPKL"}, {"Speaker", NULL, "SPKR"}, + {"HDMI", NULL, "TX"}, }; static const struct snd_kcontrol_new rk_mc_controls[] = { @@ -59,6 +61,7 @@ static const struct snd_kcontrol_new rk_mc_controls[] = { SOC_DAPM_PIN_SWITCH("Headset Mic"), SOC_DAPM_PIN_SWITCH("Int Mic"), SOC_DAPM_PIN_SWITCH("Speaker"), + SOC_DAPM_PIN_SWITCH("HDMI"), }; static int rk_aif1_hw_params(struct snd_pcm_substream *substream, @@ -92,38 +95,59 @@ static int rk_aif1_hw_params(struct snd_pcm_substream *substream, ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, SND_SOC_CLOCK_OUT); - if (ret < 0) { - dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret); + if (ret && ret != -ENOTSUPP) { + dev_err(cpu_dai->dev, "Can't set cpu dai clock %d\n", ret); return ret; } ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, SND_SOC_CLOCK_IN); - if (ret < 0) { - dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret); + if (ret && ret != -ENOTSUPP) { + dev_err(codec_dai->dev, "Can't set codec dai clock %d\n", ret); return ret; } - return ret; + return 0; } static const struct snd_soc_ops rk_aif1_ops = { .hw_params = rk_aif1_hw_params, }; -SND_SOC_DAILINK_DEFS(hifi, +SND_SOC_DAILINK_DEFS(analog, DAILINK_COMP_ARRAY(COMP_EMPTY()), DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "HiFi")), DAILINK_COMP_ARRAY(COMP_EMPTY())); -static struct snd_soc_dai_link rk_dailink = { - .name = "max98090", - .stream_name = "Audio", - .ops = &rk_aif1_ops, - /* set max98090 as slave */ - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS, - SND_SOC_DAILINK_REG(hifi), +SND_SOC_DAILINK_DEFS(hdmi, + DAILINK_COMP_ARRAY(COMP_EMPTY()), + DAILINK_COMP_ARRAY(COMP_CODEC("hdmi-audio-codec.3.auto", "i2s-hifi")), + DAILINK_COMP_ARRAY(COMP_EMPTY())); + +enum { + DAILINK_MAX98090, + DAILINK_HDMI, +}; + +/* max98090 and HDMI codec dai_link */ +static struct snd_soc_dai_link rk_dailinks[] = { + [DAILINK_MAX98090] = { + .name = "max98090", + .stream_name = "Analog", + .ops = &rk_aif1_ops, + /* set max98090 as slave */ + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + SND_SOC_DAILINK_REG(analog), + }, + [DAILINK_HDMI] = { + .name = "HDMI", + .stream_name = "HDMI", + .ops = &rk_aif1_ops, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + SND_SOC_DAILINK_REG(hdmi), + } }; static int rk_98090_headset_init(struct snd_soc_component *component); @@ -136,8 +160,8 @@ static struct snd_soc_aux_dev rk_98090_headset_dev = { static struct snd_soc_card snd_soc_card_rk = { .name = "ROCKCHIP-I2S", .owner = THIS_MODULE, - .dai_link = &rk_dailink, - .num_links = 1, + .dai_link = rk_dailinks, + .num_links = ARRAY_SIZE(rk_dailinks), .aux_dev = &rk_98090_headset_dev, .num_aux_devs = 1, .dapm_widgets = rk_dapm_widgets, @@ -173,27 +197,48 @@ static int snd_rk_mc_probe(struct platform_device *pdev) int ret = 0; struct snd_soc_card *card = &snd_soc_card_rk; struct device_node *np = pdev->dev.of_node; + struct device_node *np_analog; + struct device_node *np_cpu; + struct of_phandle_args args; /* register the soc card */ card->dev = &pdev->dev; - rk_dailink.codecs->of_node = of_parse_phandle(np, - "rockchip,audio-codec", 0); - if (!rk_dailink.codecs->of_node) { + np_analog = of_parse_phandle(np, "rockchip,audio-codec", 0); + if (!np_analog) { dev_err(&pdev->dev, "Property 'rockchip,audio-codec' missing or invalid\n"); return -EINVAL; } + rk_dailinks[DAILINK_MAX98090].codecs->of_node = np_analog; + + ret = of_parse_phandle_with_fixed_args(np, "rockchip,audio-codec", + 0, 0, &args); + if (ret) { + dev_err(&pdev->dev, + "Unable to parse property 'rockchip,audio-codec'\n"); + return ret; + } + + ret = snd_soc_get_dai_name( + &args, &rk_dailinks[DAILINK_MAX98090].codecs->dai_name); + if (ret) { + dev_err(&pdev->dev, "Unable to get codec dai_name\n"); + return ret; + } + + np_cpu = of_parse_phandle(np, "rockchip,i2s-controller", 0); - rk_dailink.cpus->of_node = of_parse_phandle(np, - "rockchip,i2s-controller", 0); - if (!rk_dailink.cpus->of_node) { + if (!np_cpu) { dev_err(&pdev->dev, "Property 'rockchip,i2s-controller' missing or invalid\n"); return -EINVAL; } - rk_dailink.platforms->of_node = rk_dailink.cpus->of_node; + rk_dailinks[DAILINK_MAX98090].cpus->of_node = np_cpu; + rk_dailinks[DAILINK_MAX98090].platforms->of_node = np_cpu; + rk_dailinks[DAILINK_HDMI].cpus->of_node = np_cpu; + rk_dailinks[DAILINK_HDMI].platforms->of_node = np_cpu; rk_98090_headset_dev.codec_of_node = of_parse_phandle(np, "rockchip,headset-codec", 0); From patchwork Fri Jul 5 04:26:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 11032715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 442B313B1 for ; Fri, 5 Jul 2019 14:13:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 325E528A44 for ; Fri, 5 Jul 2019 14:13:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 262AB28A4B; Fri, 5 Jul 2019 14:13:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BEFD928A44 for ; Fri, 5 Jul 2019 14:13:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yWrBsV3ZJyoCzTeBseNyWHNpHFvWnTm2W+hs+mAv7tg=; b=up2V7HyYw4+Ksl uX/mGqpByLM24YHyU98rr+t2WRlPIJfNpY/GEOziVAe+E6jr1sfVy3SjQQHmcelXbzIP/1fZuKOhb 6yUOv6DFYhqcoxPlLkG/HgOz6j+lEwTkmy9OjdnQaD+Oe8hQSX5qSJg5sZtK2Z3CydgEA2JC1p9NY iyEGIhGDRtO0AwsdclkvradCpz5VTVjNV2ARO0/UPFDE96UKyXhBb4G6wJUja2f1iCPdpiOwcSdvQ xHAo6PfYDH4bFRPGGgJ5Sgsk6HrXNVdvi0v7tJ1rWEDcWN+LhFy4aZ06G8NK+ZYIQkRKYFNNoJJss nTrz3H6jj4YOMLom5Ojw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hjOxi-0006oV-3i; Fri, 05 Jul 2019 14:13:18 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hjOxh-0006oM-5p for linux-rockchip@bombadil.infradead.org; Fri, 05 Jul 2019 14:13:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Mt+OhzkdZXuABUeOm3oIQQxV+A0uMRzmq60uCRJmAJE=; b=moyaN+3hdSeOz55pQvQpMorrZh 76HS8vs3T+xA6ucLyhhDGRpMN7m1Ov+ehf38PjYha4lthP8hebo96kV8X5oVEvxM4AAGKC8v4vnVm XIiltUyJYl7JeR7lkITak1w4Lem3Bt4KVp8SfcBsoItNNoGGCyz+98aCQV9R0LsN9yQYSwtOhZa97 Qcw31Ob5Ii57OSaZHGaloQKNTU7DcZaKY6Hvlz5+w7nGCpDmA+3ux4kHOhEqhAVZSWQzp7x940OiN yWBUu/CUOqeHn9s+BCX98FujYX55XI733C/AAIIMoMGXMaPAAd2IzZhkR83c6WskzwcJVopfOlR8H WgFHvDpg==; Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by casper.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hjFqQ-0006cX-IP for linux-rockchip@lists.infradead.org; Fri, 05 Jul 2019 04:29:12 +0000 Received: by mail-pf1-x442.google.com with SMTP id t16so3711376pfe.11 for ; Thu, 04 Jul 2019 21:29:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mt+OhzkdZXuABUeOm3oIQQxV+A0uMRzmq60uCRJmAJE=; b=Hbexc+aCBum/RZ12dI3r5/XyzyiK+MvJQgQ2XO3/HVioP3PM/nCddAlz1xrMohN7M1 S0TUfchH1at/5Y1i17XhZAcSUqCKCip2aybO7YsuTVjIwJXSYImaa+d0n/+JHH0FYNkL NI0/aW8eXuQCvg6kpGPrNaIfIBqJ7QUDBMvFM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mt+OhzkdZXuABUeOm3oIQQxV+A0uMRzmq60uCRJmAJE=; b=IZPBGq98WIGXbwbPJ+HDG4LgvEzz9EnJQAl/4Hj96XUV2hnsfp2Tt5LngV7oOjmFQu knHJ/jStrIXBh4hhbsTqT6xcBmQfjEyG/xwNwKYNe8J05KYSvE1iGwekNvhEOHgKkV0s VpNb/ycGE0VJ7cWXgQlHem81iIvF4xcsOxp+u9Gxvb3DvaulLxY7Jb74kfBlKWkU5vZm c+x7gmYZJjAqMoonWtoTJOJdPI3B0rq+IaJF68EtvlU8wz6BzgDtmYcDkOjnAnEqDUuT 11HjV9wGWjy5Lv91M+zlMCprKFFdgN+MnRJGIxtUtq1+fAZxSyOjOR4yDbNGu90etJ97 ZAlg== X-Gm-Message-State: APjAAAUd2HscyTzAkGdVkRy3c1rcLYyZ1/rPR0hiFb5qKvS+NM4e0kdT HXJzzy+xFxDF6UDRjSEONP7gig== X-Google-Smtp-Source: APXvYqywd4tkamYO1Fai6BvXNjXkhsYojIRkBX4/rKYkl5GdlfV7TnbJIDpy2ZVfWAPldm8d1RwzHA== X-Received: by 2002:a17:90a:8d86:: with SMTP id d6mr2081909pjo.94.1562300823498; Thu, 04 Jul 2019 21:27:03 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id t10sm6811920pjr.13.2019.07.04.21.27.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2019 21:27:02 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Subject: [PATCH 4/4] ASoC: rockchip_max98090: Add HDMI jack support Date: Fri, 5 Jul 2019 12:26:23 +0800 Message-Id: <20190705042623.129541-5-cychiang@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190705042623.129541-1-cychiang@chromium.org> References: <20190705042623.129541-1-cychiang@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190705_052910_625358_9AF48459 X-CRM114-Status: GOOD ( 13.73 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, dianders@chromium.org, Heiko Stuebner , linux-rockchip@lists.infradead.org, David Airlie , dri-devel@lists.freedesktop.org, Takashi Iwai , Liam Girdwood , tzungbi@chromium.org, Jaroslav Kysela , Hans Verkuil , Andrzej Hajda , Russell King , Mark Brown , Laurent Pinchart , Daniel Vetter , dgreid@chromium.org, linux-arm-kernel@lists.infradead.org, Cheng-Yi Chiang Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In machine driver, create a jack and let hdmi-codec report jack status. Signed-off-by: Cheng-Yi Chiang --- sound/soc/rockchip/rockchip_max98090.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sound/soc/rockchip/rockchip_max98090.c b/sound/soc/rockchip/rockchip_max98090.c index 195309d1225a..c0e430ca4d12 100644 --- a/sound/soc/rockchip/rockchip_max98090.c +++ b/sound/soc/rockchip/rockchip_max98090.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "rockchip_i2s.h" #include "../codecs/ts3a227e.h" @@ -129,6 +130,25 @@ enum { DAILINK_HDMI, }; +static struct snd_soc_jack rk_hdmi_jack; + +static int rk_hdmi_init(struct snd_soc_pcm_runtime *runtime) +{ + struct snd_soc_card *card = runtime->card; + struct snd_soc_component *component = runtime->codec_dai->component; + int ret; + + /* enable jack detection */ + ret = snd_soc_card_jack_new(card, "HDMI Jack", SND_JACK_LINEOUT, + &rk_hdmi_jack, NULL, 0); + if (ret) { + dev_err(card->dev, "Can't new HDMI Jack %d\n", ret); + return ret; + } + + return hdmi_codec_set_jack_detect(component, &rk_hdmi_jack); +} + /* max98090 and HDMI codec dai_link */ static struct snd_soc_dai_link rk_dailinks[] = { [DAILINK_MAX98090] = { @@ -146,6 +166,7 @@ static struct snd_soc_dai_link rk_dailinks[] = { .ops = &rk_aif1_ops, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, + .init = rk_hdmi_init, SND_SOC_DAILINK_REG(hdmi), } };