From patchwork Mon Jun 3 04:32: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: 10972493 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 A4CA06C5 for ; Mon, 3 Jun 2019 07:40:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9612528640 for ; Mon, 3 Jun 2019 07:40:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89B1B28827; Mon, 3 Jun 2019 07:40:58 +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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3185928640 for ; Mon, 3 Jun 2019 07:40:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E00F789650; Mon, 3 Jun 2019 07:40:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B61F898C2 for ; Mon, 3 Jun 2019 04:34:05 +0000 (UTC) Received: by mail-pl1-x641.google.com with SMTP id bh12so382079plb.4 for ; Sun, 02 Jun 2019 21:34:05 -0700 (PDT) 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=Cjn+fe9pHSnglvx4T5q/xNRom5yt6XJeMvAMIuyqpGU=; b=DcxwOZ/k5kOMfUoUEOpue1HEEMPftD1q0BedX+QXuTCSXYsHMJamygcX3Ij4cSkSXK orlQDKhJMAETE046qv/KssqK1mfUJ84/RzgsPIeJbtC4VVazn4xXrHbj8EWQzlxBVGvI u6ccrdUHFZoAtKl0jLO0Bld5KyMyXf4NPErNGNd/kNBjuuMnChVa4o7ANis23NMcAlO4 MjSR1mS2SZpatLTaSaa+Wo5vOPBhLbBqfvSHe/ES8vx68FXJbWnivcI0Aqw14V7VLw7W IVD2Pk6KN1rahhAgJxvtD+nushUcgvd13Hj6+5WnZYI7E0VTTNPMXatL4AP5VpGKrmLO kz1Q== X-Gm-Message-State: APjAAAX+NW7nhIejH9EsEXK1h5/Rj+L/JJmN/G276gsJVBnyOygTIocG ATThPmWoHTU0EmlWbNP+4d56Sw== X-Google-Smtp-Source: APXvYqwtsOJ5Pc96EE50WIzahRr4M7P5Cn839A0uqq7pGgYj7JP4xpqAWFOhLexsz8HaBDU7wChTEA== X-Received: by 2002:a17:902:9885:: with SMTP id s5mr27565604plp.102.1559536444754; Sun, 02 Jun 2019 21:34:04 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id r64sm16094840pfr.58.2019.06.02.21.34.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 21:34:04 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Subject: [PATCH 6/7] ASoC: rockchip_max98090: Add HDMI jack support Date: Mon, 3 Jun 2019 12:32:50 +0800 Message-Id: <20190603043251.226549-7-cychiang@chromium.org> X-Mailer: git-send-email 2.22.0.rc1.257.g3120a18244-goog In-Reply-To: <20190603043251.226549-1-cychiang@chromium.org> References: <20190603043251.226549-1-cychiang@chromium.org> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 03 Jun 2019 07:40:43 +0000 X-Mailman-Original-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=Cjn+fe9pHSnglvx4T5q/xNRom5yt6XJeMvAMIuyqpGU=; b=Hfq6ax4j9v67eMl3jzhORUV9xlodMxfyEB5jUFylBnMvGjbup0xltWak92wPnYo8jT z0URgg2rd1r5wg+Oy3xrddVqdvePsxYBMv74zKntc+d+vjFpS0hNfzpdzd1s9AT5d4X1 i8E4gAcDkyjhrEy5aOZTU8DXTpX6OpurnFU4Q= 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: alsa-devel@alsa-project.org, David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Laurent Pinchart , Cheng-Yi Chiang , Takashi Iwai , linux-rockchip@lists.infradead.org, dgreid@chromium.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, tzungbi@chromium.org, Bartlomiej Zolnierkiewicz , Russell King , Rob Herring , Jaroslav Kysela , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , dianders@chromium.org, Mark Brown Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/sound/soc/rockchip/rockchip_max98090.c b/sound/soc/rockchip/rockchip_max98090.c index 2dd247670c7a..17c50d9fbac1 100644 --- a/sound/soc/rockchip/rockchip_max98090.c +++ b/sound/soc/rockchip/rockchip_max98090.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include "rockchip_i2s.h" #include "../codecs/ts3a227e.h" @@ -131,6 +133,26 @@ 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; + struct device *hdmi_dev = snd_soc_card_get_drvdata(card); + 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, hdmi_dev); +} + /* max98090 and HDMI codec dai_link */ static struct snd_soc_dai_link rk_dailinks[] = { [DAILINK_MAX98090] = { @@ -148,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, } }; @@ -200,6 +223,8 @@ static int snd_rk_mc_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct device_node *np_cpu; struct of_phandle_args args; + struct device_node *np_hdmi; + struct platform_device *hdmi_pdev; /* register the soc card */ card->dev = &pdev->dev; @@ -248,6 +273,22 @@ static int snd_rk_mc_probe(struct platform_device *pdev) return -EINVAL; } + /* The hdmi device handles HDMI hotplug detection */ + np_hdmi = of_parse_phandle(np, "rockchip,hdmi", 0); + if (!np_hdmi) { + dev_err(&pdev->dev, "Failed to find HDMI node\n"); + return -EINVAL; + } + + hdmi_pdev = of_find_device_by_node(np_hdmi); + if (!hdmi_pdev) { + dev_err(&pdev->dev, "Waiting for HDMI device %s\n", + np_hdmi->full_name); + return -EPROBE_DEFER; + } + + snd_soc_card_set_drvdata(card, &hdmi_pdev->dev); + ret = snd_soc_of_parse_card_name(card, "rockchip,model"); if (ret) { dev_err(&pdev->dev,