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: 105430 Delivered-To: patches@linaro.org Received: by 10.140.91.77 with SMTP id y71csp9817qgd; Tue, 13 Jun 2017 14:59:57 -0700 (PDT) X-Received: by 10.107.46.135 with SMTP id u7mr3000269iou.10.1497391197258; Tue, 13 Jun 2017 14:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497391197; cv=none; d=google.com; s=arc-20160816; b=Np69r32vEbJkCnLHxpwCY2KJpsKY0e/sOorI+lw99UXP6SXXh9Tn3FVIKCrl6fqOHS JuChSG/KLUjEMVlix2zyZOWn/hjL3FzTD25oqaWZXqsXiNJeSMrTRZZmUgjyezkThdOh pFGNtYDW7oSq+si9M2TkqLrxVhAFX8K0smmlpFdcuF9iYm4CXzsDasnPdLh2zYLgZART Ag5+FfEx/9EiRWHsvz2ea9kwKd1aut0bntRRBHIqcjZ5iJi73LnNdkfX9eKtfMMBBy6k SoDwGhmmFDoehRVRfXBpTEYoRivig59mhawLHMwicFLKUGUggs/PvO8c4fvD1i3VHApc XKHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=HSlnga3I0HX3UQog3CZ8UlTbhIhr12wNplrlkAvuyJQ=; b=zZO7EKZKGSE4217qcFPBusqEq9qsSp7vdjAZZ1lQ1TqoDnhvtZGl3pzOv2zKajXr0W /sEGWktD5/gR2q2zXHYcfI7hPpKU8KGtoeyXa/amXLGpyPp9jRpq3BYioxvSV5J6eeAd E9T3zslkHyvV5FT3yB8o4SpI4+OkXdPK3jknHBubxHeu/rgLWJMRmWRV2LDfrf9yk04I 4HOkwFal/GhyEL2tUBgBEoc/mPemViOuKAL2cLCasesCz36SKAVTC3UmTdOaLZfhxcZ0 kv4p5XnhwvIZqvTWmZPJ26RutPWMlJdyX9baP4Lv30Uex1ekIzSUj4ZmlA8Ytcf8GUUl S32A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:4001:c06::229 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-io0-x229.google.com (mail-io0-x229.google.com. [2607:f8b0:4001:c06::229]) by mx.google.com with ESMTPS id m8si1362952ioa.179.2017.06.13.14.59.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 14:59:57 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:4001:c06::229 as permitted sender) client-ip=2607:f8b0:4001:c06::229; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:4001:c06::229 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-io0-x229.google.com with SMTP id y77so82215939ioe.3 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=DUez3+z1iGrNoTEQsvxiabg4NNK83aQSBJPU5pntrCKNBmmlGjhQM/dk0zU52grH6Q o/pR/LQORknjG7/U8hxda4w2Qb8HUOitif6wHX83ZZDbP18RI4UJJ1d2EmPAbUl4MV4e lMlZdrEhM3oWZTlQBBrs1ildxh3dhO89Iz5knRx8M+evjKrf6tS+/iStTGJSBnM+JYzU sikDQpTYCDw+W7hjDiG/mu3HsZP2+TaGGY0VpTu876+snmnIcTNW77Ol/moXZh6OFnlN 9zVf/3PCaqRmoVRx4MFFXC2wFLSjMGO3FYvTp5pJqks8Uxuw3XUgDEpzU6AOxGvjXWi4 hOFA== X-Gm-Message-State: AKS2vOx15m1XsD71GgpEmavRghKAiggAkYlrAkErYoj0xE/jLt/kP0sw IF1a1JPdhvJj48wLnKk= X-Received: by 10.107.155.140 with SMTP id d134mr2744267ioe.88.1497391196797; Tue, 13 Jun 2017 14:59:56 -0700 (PDT) Return-Path: 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 Cc: John Stultz , Kuninori Morimoto , Archit Taneja , Mark Brown , Rob Herring , David Airlie , Lars-Peter Clausen , Linux-ALSA , dri-devel@lists.freedesktop.org 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 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(+) -- 2.7.4 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 = {