From patchwork Fri Jan 14 20:16:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 12713951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 649D1C433EF for ; Fri, 14 Jan 2022 20:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vAiuNPIu7HBYRD+b+Rvj/5+LmmSXTqRQLkAh7QNKWC0=; b=o1yUSMtq37pwxk Qjks02tb+mDrwoZm6waVr+CVPULjKdYcr9MES9N3Cql6TaBx8yYkcvNg2RlmFcNiPR/Mi47ROHVvK hS8S9hDAF+ldT+XzW7JC5heXv7TMrrwr/hAs19sxeYnfb9VhjfLCCrhsS0XmSKy7pIifTcQMnZbeY IByViMgcPUtN7QRU9lHE4xz3BZqKFUkzSqqMVAhE3gOklMGwFFlkKXNmETS4lWhnwWkS9ZsSM0yxw kOPI3JowUV6OMKLmhB5xo67GpFzeEHH7IarjoBoKtaP5Mz88wNreLnBRZWVIyjzZ20sS0PsgOdJYz ARKvsYHeKkddHcAibcBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8T0y-00A9wX-Ko; Fri, 14 Jan 2022 20:17:36 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n8T0d-00A9pL-Pb for linux-arm-kernel@lists.infradead.org; Fri, 14 Jan 2022 20:17:17 +0000 Received: by mail-pg1-x52b.google.com with SMTP id r135so477260pgr.6 for ; Fri, 14 Jan 2022 12:17:15 -0800 (PST) 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=WzNR7uSNnSdg4hsXrt3ZJe57Rjz9RsU1uoLFUYgup5s=; b=CrBAAcV6rcqYR96Cru/pA8UOx2tnvMIIOfcqFcAownzSFPyuPgvkhzfxi/+POTmI6F s3dystHa98fH+SbgMv8XKpF0nN2hyQmJRb/usWgQVAeEMKkFbOl1RLbU6G0QKyJYa1cp atbPBFu4vpIdYe+oAsO4YZx7Pu3BhgN/ev32M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WzNR7uSNnSdg4hsXrt3ZJe57Rjz9RsU1uoLFUYgup5s=; b=Mh7P3vBJ7IYCoz2FD/25Wg77KNWLZqXBQxhRtnSAiLrbUD8+ig7pH9i6pmQFLm0dq/ j+hQgBuKvuGYHYQsk5oYJ4aK99KvpEIcato83mltV1YL2GLAngTw2gqoAjKE+97VvNHl 5n52Zv8DDdaPuAU2rK3g8TYyNjfink+xE87mBp+PApbn9RytojKF3mUaZvjXwe1WygmA Z9Sf5yFSfLNVTJpWUtGrXy3E6w7jbeLhDpwZJvVUgGYEeuW0is2D6eoEN8ScKU1g+DVR XBuI53uAo7Ut6S6qjJLTUgDEpF8diIUCgxWELoRHMdma+D6HtEt3FHGVITgDz9gESaq7 zZiA== X-Gm-Message-State: AOAM531TRh2EDZUFcI82bdCctM7AIIDnnEeJiq/Wp/4PgNUjvPndBBD9 QeZidVqVd3cDdQvgK7GtMbAAKA== X-Google-Smtp-Source: ABdhPJyHj22cXTGtfbh2J7pBTC9HY1zTyXX803MbP2uAPR8gM88DcF40tdq9nbUgQqifT6xthI1Ncw== X-Received: by 2002:a63:4620:: with SMTP id t32mr3538422pga.531.1642191435052; Fri, 14 Jan 2022 12:17:15 -0800 (PST) Received: from localhost ([2620:15c:202:201:76ab:ede1:503d:1c39]) by smtp.gmail.com with UTF8SMTPSA id p50sm5982690pfw.51.2022.01.14.12.17.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Jan 2022 12:17:14 -0800 (PST) From: Brian Norris To: Heiko Stuebner , Liam Girdwood , Mark Brown , David Airlie , Daniel Vetter Cc: alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Sandy Huang , linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, Rob Herring , linux-kernel@vger.kernel.org, Lin Huang , Brian Norris Subject: [PATCH 2/3] drm/rockchip: cdn-dp: Support HDMI codec plug-change callback Date: Fri, 14 Jan 2022 12:16:51 -0800 Message-Id: <20220114121515.2.I20d754a1228aa5c51a18c8eb15a2c60dec25b639@changeid> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220114201652.3875838-1-briannorris@chromium.org> References: <20220114201652.3875838-1-briannorris@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220114_121715_895219_3259F444 X-CRM114-Status: GOOD ( 16.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some audio servers like to monitor a jack device (perhaps combined with EDID, for audio-presence info) to determine DP/HDMI audio presence. Signed-off-by: Brian Norris --- drivers/gpu/drm/rockchip/cdn-dp-core.c | 28 ++++++++++++++++++++++++++ drivers/gpu/drm/rockchip/cdn-dp-core.h | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c index 16497c31d9f9..edd6a1fc46cd 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-core.c +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c @@ -586,6 +586,13 @@ static bool cdn_dp_check_link_status(struct cdn_dp_device *dp) return drm_dp_channel_eq_ok(link_status, min(port->lanes, sink_lanes)); } +static void cdn_dp_audio_handle_plugged_change(struct cdn_dp_device *dp, + bool plugged) +{ + if (dp->codec_dev) + dp->plugged_cb(dp->codec_dev, plugged); +} + static void cdn_dp_encoder_enable(struct drm_encoder *encoder) { struct cdn_dp_device *dp = encoder_to_dp(encoder); @@ -641,6 +648,9 @@ static void cdn_dp_encoder_enable(struct drm_encoder *encoder) DRM_DEV_ERROR(dp->dev, "Failed to valid video %d\n", ret); goto out; } + + cdn_dp_audio_handle_plugged_change(dp, true); + out: mutex_unlock(&dp->lock); } @@ -651,6 +661,8 @@ static void cdn_dp_encoder_disable(struct drm_encoder *encoder) int ret; mutex_lock(&dp->lock); + cdn_dp_audio_handle_plugged_change(dp, false); + if (dp->active) { ret = cdn_dp_disable(dp); if (ret) { @@ -846,11 +858,27 @@ static int cdn_dp_audio_get_eld(struct device *dev, void *data, return 0; } +static int cdn_dp_audio_hook_plugged_cb(struct device *dev, void *data, + hdmi_codec_plugged_cb fn, + struct device *codec_dev) +{ + struct cdn_dp_device *dp = dev_get_drvdata(dev); + + mutex_lock(&dp->lock); + dp->plugged_cb = fn; + dp->codec_dev = codec_dev; + cdn_dp_audio_handle_plugged_change(dp, dp->connected); + mutex_unlock(&dp->lock); + + return 0; +} + static const struct hdmi_codec_ops audio_codec_ops = { .hw_params = cdn_dp_audio_hw_params, .audio_shutdown = cdn_dp_audio_shutdown, .mute_stream = cdn_dp_audio_mute_stream, .get_eld = cdn_dp_audio_get_eld, + .hook_plugged_cb = cdn_dp_audio_hook_plugged_cb, .no_capture_mute = 1, }; diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.h b/drivers/gpu/drm/rockchip/cdn-dp-core.h index 81ac9b658a70..d808a9de45ed 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-core.h +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "rockchip_drm_drv.h" @@ -101,5 +102,8 @@ struct cdn_dp_device { u8 dpcd[DP_RECEIVER_CAP_SIZE]; bool sink_has_audio; + + hdmi_codec_plugged_cb plugged_cb; + struct device *codec_dev; }; #endif /* _CDN_DP_CORE_H */