From patchwork Tue Jun 13 21:59:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 9784823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 68F836038E for ; Tue, 13 Jun 2017 22:00:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AA3128547 for ; Tue, 13 Jun 2017 22:00:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C93328560; Tue, 13 Jun 2017 22:00:04 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 E693E2853B for ; Tue, 13 Jun 2017 22:00:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 73FCE89F19; Tue, 13 Jun 2017 21:59:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-io0-x234.google.com (mail-io0-x234.google.com [IPv6:2607:f8b0:4001:c06::234]) by gabe.freedesktop.org (Postfix) with ESMTPS id 835B289F19 for ; Tue, 13 Jun 2017 21:59:57 +0000 (UTC) Received: by mail-io0-x234.google.com with SMTP id i7so82219215ioe.1 for ; Tue, 13 Jun 2017 14:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=HSlnga3I0HX3UQog3CZ8UlTbhIhr12wNplrlkAvuyJQ=; b=Nc3VWrWsFumsG7vIufNCOuhV0PwjxkXaJRMFuX9RaOvJnareZSG/xdiL1jPcS/TgVp FoB7O45dq6rrrfnD0dz60KPQObowK2UGmrb5ZAPmlXoZt/IMpzqWbx4X+vdsbKz3xsHm ohMBZ+u30jxQwOyUqxqWBfq5+G35QYLEmIID0= 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; bh=HSlnga3I0HX3UQog3CZ8UlTbhIhr12wNplrlkAvuyJQ=; b=UcUv1h1zlrZcxB6RDkmbacMj2HzwRseQjJh+OZfaTzN7QpXaR+iGNCKFy6/eabfFwK NIAZJSjUo0Y7Lhmo1sHSQc6l7GI/sB8+FwcbmdTqwVjHhs6V6npkOuoQVG61uS5n4pif Idj7JWDh2OCr2FF3vEA0Wg2ASTeRVetMOerLm7ftIU3UXKHXUCZhWPNIbbI8iM7XVIWt qPrZRoy/eBe2MQP7LZiZ60zgStmm5HPSyxDv6n5pGs+BFCzVj8refzZ18bTgk2x5dLnu osYd/i6ve9yfTOj4KHDcb7iy/sGTekY3nl4Z54DABEDeNBLGoQDlvcn0E1gMWXenwUe2 qPzg== X-Gm-Message-State: AKS2vOyOiq9NCtZEh7plQP+e3/oiM3D12H+FsfM4wkFaFjvgX1hqt4W6 OWd7gL2tGUtLuOuY X-Received: by 10.107.155.140 with SMTP id d134mr2744267ioe.88.1497391196797; Tue, 13 Jun 2017 14:59:56 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id i6sm6365905iti.20.2017.06.13.14.59.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Jun 2017 14:59:55 -0700 (PDT) From: John Stultz To: lkml Subject: [PATCH] drm: adv7511_audio: Add .get_dai_id callback to map port number to dai id Date: Tue, 13 Jun 2017 14:59:49 -0700 Message-Id: <1497391189-9301-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: Kuninori Morimoto , Mark Brown , Linux-ALSA , dri-devel@lists.freedesktop.org, Rob Herring X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP ALSA SoC needs to know connected DAI ID for probing. Using the new audio-card-graph approach, ports/endpoints are used to describe how the links are connected. Unfortunately, since ports/endpoints are used as well for video linkages, there are some issues mixing the port ids to the two (video and audio) namespaces. To solve this issue, this patch adds new .get_dai_id callback on hdmi_codec_ops. The will assume that HDMI audio out will be connected to reg = <2>. This will then be remapped to the ALSA SoC side will as DAI 0. Allowing the adv7511's hdmi audio support to be used with the audio-card-graph. Credit to Kuninori Morimoto who's patch to dw-hdmi-i2s-audio.c was what this was mostly copy-pasted from. Cc: Kuninori Morimoto Cc: Archit Taneja Cc: Mark Brown Cc: Rob Herring Cc: David Airlie Cc: Lars-Peter Clausen Cc: Linux-ALSA Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz --- .../bindings/display/bridge/adi,adv7511.txt | 8 ++++++++ drivers/gpu/drm/bridge/adv7511/adv7511_audio.c | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt index 00ea670..06668bc 100644 --- a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt +++ b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt @@ -78,6 +78,7 @@ graph bindings specified in Documentation/devicetree/bindings/graph.txt. remote endpoint phandle should be a reference to a valid mipi_dsi_host device node. - Video port 1 for the HDMI output +- Audio port 2 for the HDMI audio input Example @@ -112,5 +113,12 @@ Example remote-endpoint = <&hdmi_connector_in>; }; }; + + port@2 { + reg = <2>; + codec_endpoint: endpoint { + remote-endpoint = <&i2s0_cpu_endpoint>; + }; + }; }; }; diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c index cf92ebf..67469c2 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "adv7511.h" @@ -182,10 +183,31 @@ static void audio_shutdown(struct device *dev, void *data) { } +static int adv7511_hdmi_i2s_get_dai_id(struct snd_soc_component *component, + struct device_node *endpoint) +{ + struct of_endpoint of_ep; + int ret; + + ret = of_graph_parse_endpoint(endpoint, &of_ep); + if (ret < 0) + return ret; + + /* + * HDMI sound should be located as reg = <2> + * Then, it is sound port 0 + */ + if (of_ep.port == 2) + return 0; + + return -EINVAL; +} + static const struct hdmi_codec_ops adv7511_codec_ops = { .hw_params = adv7511_hdmi_hw_params, .audio_shutdown = audio_shutdown, .audio_startup = audio_startup, + .get_dai_id = adv7511_hdmi_i2s_get_dai_id, }; static struct hdmi_codec_pdata codec_data = {