From patchwork Thu Sep 19 13:54:47 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: 11152483 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 3C93716B1 for ; Thu, 19 Sep 2019 13:57:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 C416321D7C for ; Thu, 19 Sep 2019 13:56:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="F17iNLeH"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="L3xnzMqM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C416321D7C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D1F3C1673; Thu, 19 Sep 2019 15:56:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D1F3C1673 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1568901417; bh=sMSca0CjsKO2LQdCqtLtUoZVOh0BlsrpcCK2Mccosjk=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=F17iNLeHnXkjy/TgRSXt7xdiME93DNhcQyRYV5ZctVqsKoMvg5K+cSYgqIK5otbK4 qO7ucx82+d6NKrH3WReHZz1/xI+m/TmUrXzUXdCTnbIIOkTjQsc9R+lwdx5V3MA3nk sviWiiEUj1PtxA0G0FJbbtzP3AhJXfcsBuS/jntA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6FA67F8048F; Thu, 19 Sep 2019 15:55:22 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 698FCF80528; Thu, 19 Sep 2019 15:55:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id ACE1CF8048F for ; Thu, 19 Sep 2019 15:55:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz ACE1CF8048F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="L3xnzMqM" Received: by mail-pl1-x642.google.com with SMTP id t10so1665410plr.8 for ; Thu, 19 Sep 2019 06:55:18 -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=a8fpKw2ued4D0BZtPXoBVbNaINT07QEPJ3+f6qSFqa0=; b=L3xnzMqMl5yATf7M8qV3dWBYtjqKLuwX1Z3V7xTT2T52JQu8zb3X8z7wgB27Hv7+zw 7d7//09xdWXHnMy6rt5OZR6bYguQushN/1G2CF/WNp0g2kC0fYkhjDOxwq7wJZU/h4U2 1h8g9NWrpFYQKAlCsR15nsj2KdmkJcRDkx/HU= 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=a8fpKw2ued4D0BZtPXoBVbNaINT07QEPJ3+f6qSFqa0=; b=YF2dJXqjA1GDVISe+L6l6Oi2rPfQltFEpQcnmfF+BC+lvnJBbEUaozWP4G/lGH37fL SkDu8dzjz1erUjZ52WMXR90xBFSibOvtnd3bWUDaidWkeX34etoOjCJ8Lv7semQeZIxV 2ffuIa8nTYsONdxGCqny8yidxH4KtaGTOytDfx2DzotbGli09v5LWl4oHbX12/+G7R8D Q0Jb2Y22WCu7uIb/qEsMl6vrmIf+vvIfyNr75mxIwCX0UPoBlsBWbood5SaW+wzRLmrG 31fQUoUxtmbaaiAosAroCxnkHbN+iqJ74fHrlUnbuyizlCY8YlPfw+vz7v41Wi57fG28 7CjA== X-Gm-Message-State: APjAAAUlH1Z5jhCFkByo3RqJ4z+YZ22BQjEBA1TRFexvYclUQorsAdZz tidlhSjU8GYODez0G7xC8ogP6g== X-Google-Smtp-Source: APXvYqwp/2TQufUSfLqYQLxa2fqjbMxVmjcEjDy2r6KC/qOWN70beD9FMRtpPPoNm2+pPppS6B/+wg== X-Received: by 2002:a17:902:b402:: with SMTP id x2mr2003221plr.17.1568901316467; Thu, 19 Sep 2019 06:55:16 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:79b4:bd83:e4a5:a720]) by smtp.gmail.com with ESMTPSA id w187sm8259292pgw.88.2019.09.19.06.55.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Sep 2019 06:55:15 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Thu, 19 Sep 2019 21:54:47 +0800 Message-Id: <20190919135450.62309-2-cychiang@chromium.org> X-Mailer: git-send-email 2.23.0.237.gc6a4ce50a0-goog In-Reply-To: <20190919135450.62309-1-cychiang@chromium.org> References: <20190919135450.62309-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , Neil Armstrong , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , Laurent Pinchart , Jerome Brunet , Takashi Iwai , linux-rockchip@lists.infradead.org, dgreid@chromium.org, Cheng-Yi Chiang , tzungbi@chromium.org, Jonas Karlman , Russell King , Mark Brown , linux-arm-kernel@lists.infradead.org, Jernej Skrabec , dianders@chromium.org, Daniel Vetter Subject: [alsa-devel] [PATCH v7 1/4] drm: bridge: dw-hdmi: Report connector status using callback X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 exports a function dw_hdmi_set_plugged_cb 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 --- .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 11 +++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 41 ++++++++++++++++++- include/drm/bridge/dw_hdmi.h | 4 ++ 3 files changed, 55 insertions(+), 1 deletion(-) 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 20f4f92dd866..d7e65c869415 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c @@ -160,12 +160,23 @@ 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 device *codec_dev) +{ + struct dw_hdmi_i2s_audio_data *audio = data; + struct dw_hdmi *hdmi = audio->hdmi; + + return dw_hdmi_set_plugged_cb(hdmi, fn, codec_dev); +} + static struct hdmi_codec_ops dw_hdmi_i2s_ops = { .hw_params = dw_hdmi_i2s_hw_params, .audio_startup = dw_hdmi_i2s_audio_startup, .audio_shutdown = dw_hdmi_i2s_audio_shutdown, .get_eld = dw_hdmi_i2s_get_eld, .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 aa7efd4da1c8..7ffe8ed675ff 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -193,6 +193,10 @@ struct dw_hdmi { struct mutex cec_notifier_mutex; struct cec_notifier *cec_notifier; + + hdmi_codec_plugged_cb plugged_cb; + struct device *codec_dev; + enum drm_connector_status last_connector_result; }; #define HDMI_IH_PHY_STAT0_RX_SENSE \ @@ -217,6 +221,28 @@ static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset) return val; } +static void handle_plugged_change(struct dw_hdmi *hdmi, bool plugged) +{ + if (hdmi->plugged_cb && hdmi->codec_dev) + hdmi->plugged_cb(hdmi->codec_dev, plugged); +} + +int dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn, + struct device *codec_dev) +{ + bool plugged; + + mutex_lock(&hdmi->mutex); + hdmi->plugged_cb = fn; + hdmi->codec_dev = codec_dev; + plugged = hdmi->last_connector_result == connector_status_connected; + handle_plugged_change(hdmi, plugged); + mutex_unlock(&hdmi->mutex); + + return 0; +} +EXPORT_SYMBOL_GPL(dw_hdmi_set_plugged_cb); + 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); @@ -2183,6 +2209,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; @@ -2190,7 +2217,18 @@ 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); + handle_plugged_change(hdmi, + 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) @@ -2641,6 +2679,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); diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index 4b3e863c4f8a..45a05e97e78a 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -6,6 +6,8 @@ #ifndef __DW_HDMI__ #define __DW_HDMI__ +#include + struct drm_connector; struct drm_display_mode; struct drm_encoder; @@ -154,6 +156,8 @@ void dw_hdmi_resume(struct dw_hdmi *hdmi); void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense); +int dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn, + struct device *codec_dev); void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate); void dw_hdmi_set_channel_count(struct dw_hdmi *hdmi, unsigned int cnt); void dw_hdmi_set_channel_status(struct dw_hdmi *hdmi, u8 *channel_status); From patchwork Thu Sep 19 13:54:48 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: 11152489 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 80C3716B1 for ; Thu, 19 Sep 2019 13:57:46 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 165632196E for ; Thu, 19 Sep 2019 13:57:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="GskLI/iV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iWJDh8Ao" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 165632196E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 559DA167B; Thu, 19 Sep 2019 15:56:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 559DA167B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1568901464; bh=cOfcExrkyCAERzSFmXJQbcP8wvf+n36bA8F8PxLVy2U=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GskLI/iVCsz5ZVRitCC6iN70wgjJ6E1EDbCJCeT015CNRK8pS9Ym2rcirdCGt1nQi NfXrynarrH9GiXVUpkRlu2/KA9h/KJvXRSV5xey3urvM63MnTmRPFl0bRd6lVtZ6uw 1OwrdYAqbLcznruPoCutDkQBMI7hXnRPnpevPcng= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6CA67F805FA; Thu, 19 Sep 2019 15:55:30 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6C6CFF805FB; Thu, 19 Sep 2019 15:55:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C5494F805F7 for ; Thu, 19 Sep 2019 15:55:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C5494F805F7 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iWJDh8Ao" Received: by mail-pg1-x541.google.com with SMTP id u72so1946520pgb.10 for ; Thu, 19 Sep 2019 06:55:26 -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=hcI+2qu3SHO1kkNhBRtR499gEhJVXFuDOb0iaJPJu1o=; b=iWJDh8AorH8nEJumZm/WKDcQuo+qYc151hnc2ynZHB08lu8t45FcSFc3XK8W4mnp1c T3000UZZfeJmfDdnixCbXHBmimTrjln/Z/hDuuTKRAyWMnJ9IL3M2Pgs8uVYZ8Okmtj9 olBky5YGCY5LZ6wfafMKw7O8qXwRl3ZWMAZ34= 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=hcI+2qu3SHO1kkNhBRtR499gEhJVXFuDOb0iaJPJu1o=; b=DvjS5AnIr2zO1IibCTXijK5AcW1XS+75H+0weWyEUNiekhVjN5KriIQwKNyRdnJjoj LILRTamzqPtaAH0jmIJ7p4rlSeytCAsEutwOk0ao+5faIxEIDiJWAXNzL0vde62FqFcp uVGPVX1XSR1pzhYZ6bHoJpmgMC7n8wyLed+ycjseu+q9igfJtuiHFsskqcQuLXxIyUE2 cpHgZ8oebWvhGnJ1DpB6+NglbrupUOpg8UEdFDyjjkmq/aJ/u/SNiyjz8LMUdET/byWw s/x1etRvWqNG3OtW3neg/KYHoVRDCTWGjg7eBwCoYWC823gmeVi1XNyg7g9gLWmylYcu Vaog== X-Gm-Message-State: APjAAAVJ9tkbw5Sm0uJ5dWXQQ/TCC6cCfx0i+lsQ92xTAVoKgvlrTjrF 7m7ILz9GchomrtjlJMNg421L1g== X-Google-Smtp-Source: APXvYqxyO8jD+PyDoTHkQIAYtp40Pex0/Mt27q7YWzADpFPuYqtJNqaFngWeKrfqiIca+BqjDGsIqA== X-Received: by 2002:aa7:8acf:: with SMTP id b15mr4201816pfd.191.1568901324804; Thu, 19 Sep 2019 06:55:24 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:79b4:bd83:e4a5:a720]) by smtp.gmail.com with ESMTPSA id q88sm6395907pjq.9.2019.09.19.06.55.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Sep 2019 06:55:24 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Thu, 19 Sep 2019 21:54:48 +0800 Message-Id: <20190919135450.62309-3-cychiang@chromium.org> X-Mailer: git-send-email 2.23.0.237.gc6a4ce50a0-goog In-Reply-To: <20190919135450.62309-1-cychiang@chromium.org> References: <20190919135450.62309-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , Neil Armstrong , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , Laurent Pinchart , Jerome Brunet , Takashi Iwai , linux-rockchip@lists.infradead.org, dgreid@chromium.org, Cheng-Yi Chiang , tzungbi@chromium.org, Jonas Karlman , Russell King , Mark Brown , linux-arm-kernel@lists.infradead.org, Jernej Skrabec , dianders@chromium.org, Daniel Vetter Subject: [alsa-devel] [PATCH v7 2/4] ASoC: rockchip-max98090: Add description for rockchip, hdmi-codec X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add support for HDMI codec in rockchip-max98090. Let user specify HDMI device node in DTS so machine driver can find hdmi-codec device node for codec DAI. Signed-off-by: Cheng-Yi Chiang --- Documentation/devicetree/bindings/sound/rockchip-max98090.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/rockchip-max98090.txt b/Documentation/devicetree/bindings/sound/rockchip-max98090.txt index a805aa99ad75..97fc838458f7 100644 --- a/Documentation/devicetree/bindings/sound/rockchip-max98090.txt +++ b/Documentation/devicetree/bindings/sound/rockchip-max98090.txt @@ -7,6 +7,7 @@ Required properties: connected to the CODEC - rockchip,audio-codec: The phandle of the MAX98090 audio codec - rockchip,headset-codec: The phandle of Ext chip for jack detection +- rockchip,hdmi-codec: The phandle of HDMI device for HDMI codec. Example: @@ -16,4 +17,5 @@ sound { rockchip,i2s-controller = <&i2s>; rockchip,audio-codec = <&max98090>; rockchip,headset-codec = <&headsetcodec>; + rockchip,hdmi-codec = <&hdmi>; }; From patchwork Thu Sep 19 13:54:49 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: 11152493 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 58A9F16B1 for ; Thu, 19 Sep 2019 13:58:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 DE38521D7C for ; Thu, 19 Sep 2019 13:58:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="bbstDkcm"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="BXokyWSE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE38521D7C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 202D31675; Thu, 19 Sep 2019 15:57:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 202D31675 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1568901488; bh=XHxTXChHidjlChUTDeS9bVMzqeqMd/8qIHpEqolmLUk=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bbstDkcmG+HEHNkPrzZqCkuUZykzFfJMloqPXogpBUmaYtVHhyuVXsNZYVWu48dtI 7d3ySa3nO1/z4RA88SQTbdNWmDkX1k9qB0IhBHhKzOS+I5XWacRIX8M6gOQMxle4Za ecz/cOCAmbp6CUPIVhAf4tTvwiSxc1K3UAo/qNZk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6C20EF80600; Thu, 19 Sep 2019 15:55:39 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id D8984F8060D; Thu, 19 Sep 2019 15:55:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 30B98F805FF for ; Thu, 19 Sep 2019 15:55:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 30B98F805FF Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="BXokyWSE" Received: by mail-pl1-x641.google.com with SMTP id 4so1654589pld.10 for ; Thu, 19 Sep 2019 06:55:34 -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=ZIDYLu7ca97k4A/5V7MzuGF5gFCfwb0cYG7NrgVReLI=; b=BXokyWSEnoB+eLndxVit4ZfhwMTJl878NpORNWM6vv513KsPPeqI8v+oC4Xbg1+/jg hv56oRBzAHbTEXNnJ3NNjcS4JzFR9+287D41TcTm/hYSISRRerlS2+Bso5eWW1zT0Efz g/8DazqSzzVgfdbnctQLiakvQJCyCK3XIWrhU= 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=ZIDYLu7ca97k4A/5V7MzuGF5gFCfwb0cYG7NrgVReLI=; b=Y9s99J2+YcHHKe1XVCHM23v1dUwP81doSDF7gH30OE51yXJOc/p82/3I7NLiaVjoQg 4zwi2AYs7lhzjSrTMXoGhVHhHqoXtNn1tAu0TTAJodx6cbtKWFyUSvwqh0fff0/fBNG+ 3czJ3azi3ShxvohYhDhjq6hQ+5or9hyNl6t3XPi1di774rb7TwcyLaYVb0roayy99fAi NBK/DToJmHPo2eyuMM/YJe0eDfSJO77Jirvx/9iDwcDnKK92boWbyFABMvsQ6ZEQekwF mzFQzX07brwgu1bmuRJ8cgbakrQsz+IvV7iBFW6f/v+/OKzTbfqvkljwqgnvRtv15y5z bHpw== X-Gm-Message-State: APjAAAXj/eVM7hLv+3+Db7NjsQxmh/qxXeFyqJJucP9yB5tBXDWRY5EZ SNlLy0WSQNOxkoLHTj/pRIxjDQ== X-Google-Smtp-Source: APXvYqzKxS83hU+NxkyGPf3KK78zAWXF1bg49KAnScv/gCyw9MSc0ZklNNw3qvhxcocI53QORY7yVg== X-Received: by 2002:a17:902:7596:: with SMTP id j22mr10208368pll.280.1568901333378; Thu, 19 Sep 2019 06:55:33 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:79b4:bd83:e4a5:a720]) by smtp.gmail.com with ESMTPSA id h9sm7468913pgh.51.2019.09.19.06.55.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Sep 2019 06:55:32 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Thu, 19 Sep 2019 21:54:49 +0800 Message-Id: <20190919135450.62309-4-cychiang@chromium.org> X-Mailer: git-send-email 2.23.0.237.gc6a4ce50a0-goog In-Reply-To: <20190919135450.62309-1-cychiang@chromium.org> References: <20190919135450.62309-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , Neil Armstrong , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , Laurent Pinchart , Jerome Brunet , Takashi Iwai , linux-rockchip@lists.infradead.org, dgreid@chromium.org, Cheng-Yi Chiang , tzungbi@chromium.org, Jonas Karlman , Russell King , Mark Brown , linux-arm-kernel@lists.infradead.org, Jernej Skrabec , dianders@chromium.org, Daniel Vetter Subject: [alsa-devel] [PATCH v7 3/4] ASoC: rockchip_max98090: Add dai_link for HDMI X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 --- .../boot/dts/rk3288-veyron-analog-audio.dtsi | 1 + sound/soc/rockchip/rockchip_max98090.c | 129 ++++++++++++++---- 2 files changed, 103 insertions(+), 27 deletions(-) diff --git a/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi b/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi index 445270aa136e..51208d161d65 100644 --- a/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi +++ b/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi @@ -17,6 +17,7 @@ rockchip,hp-det-gpios = <&gpio6 RK_PA5 GPIO_ACTIVE_HIGH>; rockchip,mic-det-gpios = <&gpio6 RK_PB3 GPIO_ACTIVE_LOW>; rockchip,headset-codec = <&headsetcodec>; + rockchip,hdmi-codec = <&hdmi>; }; }; diff --git a/sound/soc/rockchip/rockchip_max98090.c b/sound/soc/rockchip/rockchip_max98090.c index c5fc24675a33..6c217492bb30 100644 --- a/sound/soc/rockchip/rockchip_max98090.c +++ b/sound/soc/rockchip/rockchip_max98090.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,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 +54,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 +62,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 +96,63 @@ 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) { + dev_err(cpu_dai->dev, "Can't set cpu dai clock %d\n", ret); return ret; } + /* HDMI codec dai does not need to set sysclk. */ + if (!strcmp(rtd->dai_link->name, "HDMI")) + return 0; + 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) { + 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, - 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(analog, + DAILINK_COMP_ARRAY(COMP_EMPTY()), + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "HiFi")), + DAILINK_COMP_ARRAY(COMP_EMPTY())); + +SND_SOC_DAILINK_DEFS(hdmi, + DAILINK_COMP_ARRAY(COMP_EMPTY()), + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "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 +165,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 +202,73 @@ 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 device_node *np_hdmi_codec; + 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; + np_hdmi_codec = of_parse_phandle(np, "rockchip,hdmi-codec", 0); + if (!np_hdmi_codec) { + dev_err(&pdev->dev, + "Property 'rockchip,hdmi-codec' missing or invalid\n"); + return -EINVAL; + } + + rk_dailinks[DAILINK_HDMI].codecs->of_node = np_hdmi_codec; + + ret = of_parse_phandle_with_fixed_args(np, "rockchip,hdmi-codec", + 0, 0, &args); + if (ret) { + dev_err(&pdev->dev, + "Unable to parse property 'rockchip,hdmi-codec'\n"); + return ret; + } + + ret = snd_soc_get_dai_name( + &args, &rk_dailinks[DAILINK_HDMI].codecs->dai_name); + if (ret) { + dev_err(&pdev->dev, "Unable to get hdmi codec dai_name\n"); + return ret; + } + + 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 Thu Sep 19 13:54:50 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: 11152495 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 652A016B1 for ; Thu, 19 Sep 2019 13:59:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 EE80D2196E for ; Thu, 19 Sep 2019 13:59:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="lgkLeAQc"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="VvascM4p" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE80D2196E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3B5AD1680; Thu, 19 Sep 2019 15:58:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3B5AD1680 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1568901540; bh=37v8KWnk7IRAn+/PVJvDncD9aqKLCY4A3QH3FK5k9a8=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lgkLeAQco5SkU5KqDeoViGwQtTrmGCSk0aYDcdyQy3Cux2h9ftGKOeivw8GU3ll4u wSnfV+EpJP13MFa80JLuR4S1gZqcmlnuncMo+52RQ5BBhh6OSJV0+zEpgOYuzmb3KG hxooKCEcV3dlCW90KCXyoAsg+m3X7ICcYvZSlrs4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E54B7F80638; Thu, 19 Sep 2019 15:55:49 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 66922F80639; Thu, 19 Sep 2019 15:55:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C4448F80637 for ; Thu, 19 Sep 2019 15:55:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C4448F80637 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="VvascM4p" Received: by mail-pf1-x444.google.com with SMTP id y72so2374916pfb.12 for ; Thu, 19 Sep 2019 06:55: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=YvltAwcazfPUXLVaME+JgA9zHiL2aoA68dvUhBxJ+k0=; b=VvascM4pkKU4F95ti9Bl2ciow4VSlKqVRkoSZam4Zy8pNf/KevJdJe7PbSc5A8Vbei 5rjN7aU8GqL4jAo2r4eOUtchAoARXaF/M/SDOimb4RwY4uw62x+wPKDT3kX7ps/g8kyT nKD1WRtYLJOSDO6M0MwbYowZ0jXZKtt1qrzFM= 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=YvltAwcazfPUXLVaME+JgA9zHiL2aoA68dvUhBxJ+k0=; b=NN2+UGPVYIuitVAuy3ec5RDTs5stDQCtkwL4PLHbZS4eEBwoEvDc6cJXB/FFDDBpnR ROBA134H2nVBTlXrEZDWOniA0ZwEDPsUAkrgzOyosNcpZQUWFQ9y28wx/9V/F2184QNH O1yEqCyss5GJBXxkTxRJfNb/YQl3jsXgjNcmB89Bn8ywtO2UTXTBinXFVHo/5YT5AirU eJMwgD/H5Y8J1WRs8A4G6N6Ji49G5QN3MH35jz9hnjpugLLhQZu6OLaFobjfPQnLbnR5 QuiGut5wJPVjtbFy2zMIMlm3wh7nAM265dOaclSwXd1M/8/tir1N4v/J1Jn1WTgD1KkC G/QQ== X-Gm-Message-State: APjAAAW4zZHErtGNLOtli08zMD7mXOTCc5yszp7hTKQ9+GmoAgb+rXxE rHarAblzQTSxdEPbVvw1Wk+TCg== X-Google-Smtp-Source: APXvYqxuqnv1/cDU4+3U+mf3SnkxxpRBvj/VkJDXLtzVeqncPGK5Xr2EZWZwOmm3tU9s2WzYUgipeQ== X-Received: by 2002:a65:4189:: with SMTP id a9mr8987692pgq.399.1568901343986; Thu, 19 Sep 2019 06:55:43 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:79b4:bd83:e4a5:a720]) by smtp.gmail.com with ESMTPSA id j16sm7633402pje.6.2019.09.19.06.55.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Sep 2019 06:55:43 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Thu, 19 Sep 2019 21:54:50 +0800 Message-Id: <20190919135450.62309-5-cychiang@chromium.org> X-Mailer: git-send-email 2.23.0.237.gc6a4ce50a0-goog In-Reply-To: <20190919135450.62309-1-cychiang@chromium.org> References: <20190919135450.62309-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , Neil Armstrong , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , Laurent Pinchart , Jerome Brunet , Takashi Iwai , linux-rockchip@lists.infradead.org, dgreid@chromium.org, Cheng-Yi Chiang , tzungbi@chromium.org, Jonas Karlman , Russell King , Mark Brown , linux-arm-kernel@lists.infradead.org, Jernej Skrabec , dianders@chromium.org, Daniel Vetter Subject: [alsa-devel] [PATCH v7 4/4] ASoC: rockchip_max98090: Add HDMI jack support X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" In machine driver, create a jack and let hdmi-codec report jack status. Signed-off-by: Cheng-Yi Chiang --- sound/soc/rockchip/Kconfig | 3 ++- sound/soc/rockchip/rockchip_max98090.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig index b43657e6e655..d610b553ea3b 100644 --- a/sound/soc/rockchip/Kconfig +++ b/sound/soc/rockchip/Kconfig @@ -40,9 +40,10 @@ config SND_SOC_ROCKCHIP_MAX98090 select SND_SOC_ROCKCHIP_I2S select SND_SOC_MAX98090 select SND_SOC_TS3A227E + select SND_SOC_HDMI_CODEC help Say Y or M here if you want to add support for SoC audio on Rockchip - boards using the MAX98090 codec, such as Veyron. + boards using the MAX98090 codec and HDMI codec, such as Veyron. config SND_SOC_ROCKCHIP_RT5645 tristate "ASoC support for Rockchip boards using a RT5645/RT5650 codec" diff --git a/sound/soc/rockchip/rockchip_max98090.c b/sound/soc/rockchip/rockchip_max98090.c index 6c217492bb30..11cf252e8391 100644 --- a/sound/soc/rockchip/rockchip_max98090.c +++ b/sound/soc/rockchip/rockchip_max98090.c @@ -134,6 +134,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] = { @@ -151,6 +170,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), } };