From patchwork Mon Jun 3 04:32:45 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: 10972299 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 6051476 for ; Mon, 3 Jun 2019 04:35:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CB8E2873E for ; Mon, 3 Jun 2019 04:35:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4057228789; Mon, 3 Jun 2019 04:35:11 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 3DDCA2873E for ; Mon, 3 Jun 2019 04:35:10 +0000 (UTC) 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 D2D9D1654; Mon, 3 Jun 2019 06:34:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D2D9D1654 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1559536507; bh=19/Q7mEfA1QigzVMII3nPPhdG97Q/SpSOXEcturttxE=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WApcHGvvENfPatogCQUHv8JsJh7NvBxeEJRty4cgQ607xULXKW0TzHezm5RfA62Pz BJzWkzHWn5eyaSqCdvXspz7Wv+J29egvGrdRgqFV27P3KOASbDSTmgFLiOIjTOGYew SOoJFCt8f6oJPzgE5AO5QH4RHDV0bge3JVmhpbJo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 84D19F89717; Mon, 3 Jun 2019 06:33:35 +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 E990DF8971F; Mon, 3 Jun 2019 06:33:32 +0200 (CEST) Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 B665AF896EE for ; Mon, 3 Jun 2019 06:33:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B665AF896EE Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="P6sxjq2j" Received: by mail-pg1-x544.google.com with SMTP id w34so7494826pga.12 for ; Sun, 02 Jun 2019 21:33:29 -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=2Kwlb/5SiHsOyNhbzKStBJCJEYsXKEdQeHEGccB6G4g=; b=P6sxjq2jhBsuLFH1QG7yv4BIJAceIkzfv21qakj+ocuLcqfruJgk8Nknotu7hXPdaC EQcrUw8uZQZtGwzDPMO+UKmcFiYcFtWe24y7eP0FnYNYU9Oeb7vNiFUhp8MUd4YT8VaQ MaqS3sJXoC3FphFKT1F25QPEx3fflQgHYxwRo= 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=2Kwlb/5SiHsOyNhbzKStBJCJEYsXKEdQeHEGccB6G4g=; b=oTcgrqRupxswFQG8ycIbc0HJVDYcLSc5ZDrQ6TzF2jJ/mui1idkODC12QPrlT7jkxc UjifWw2uTnpRIuEgkAS8l5t2SdI09WMpN8tb5usWzXs4RQobhElzVJtKUHXNuuRIf8Jd ZSqNElcCCmTAwmlx6KmC1cmfOm4UrUMIFWpk4yTG3mHy6FgtyYEwlIYIZ3UmQTWkLxeY /gBVNYrFTV0D+m7WmzLpZ09bRU3VXUcmx3UvpSBrzWOkzM7kN7Mz9P1ogYUpEbufXU3s kICqYZ7XeYpMru4WlSF9AV1BeYx2uKLnjX6viMVgUSLeeRErd6gL0ZJinyj7z51fChOE XUjg== X-Gm-Message-State: APjAAAV8DsMxqx8aAmsaUegE4teXGpn8Xfvi1+TmPFcFZX3oY4OFNun5 Qhr+xSaVzO9RqR3l7Bb0MwPPRw== X-Google-Smtp-Source: APXvYqwnwggViSS4JCbJAT4hNQZ/yjlwEWzdESELTSgpREOdMiTdp8VpKcMTR6NQXz/c1G1TpHLexA== X-Received: by 2002:a63:18e:: with SMTP id 136mr25981553pgb.277.1559536407123; Sun, 02 Jun 2019 21:33:27 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id h12sm2623108pfr.38.2019.06.02.21.33.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 21:33:26 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Mon, 3 Jun 2019 12:32:45 +0800 Message-Id: <20190603043251.226549-2-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 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , Laurent Pinchart , Cheng-Yi Chiang , Takashi Iwai , linux-rockchip@lists.infradead.org, Hans Verkuil , dgreid@chromium.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org, tzungbi@chromium.org, Philipp Zabel , Bartlomiej Zolnierkiewicz , Russell King , Rob Herring , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , dianders@chromium.org, Mark Brown , Daniel Vetter Subject: [alsa-devel] [PATCH 1/7] video: add HDMI state notifier 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Add support for HDMI hotplug and EDID notifiers, which is used to convey information from HDMI drivers to their CEC and audio counterparts. Based on an earlier version from Russell King: https://patchwork.kernel.org/patch/9277043/ The hdmi_notifier is a reference counted object containing the HDMI state of an HDMI device. When a new notifier is registered the current state will be reported to that notifier at registration time. Based on Hans Verkuil's patch: https://patchwork.kernel.org/patch/9472521/ Modified by Cheng-Yi Chiang: - Add a section in MAINTAINER. - Changes connected and has_eld to bitfield of unsigned int. - Other minor fixes to pass checkpatch.pl --strict checks. Signed-off-by: Hans Verkuil Acked-by: Philipp Zabel Signed-off-by: Cheng-Yi Chiang --- The original patch is at https://lore.kernel.org/linux-arm-kernel/20161213150813.37966-2-hverkuil@xs4all.nl MAINTAINERS | 6 ++ drivers/video/Kconfig | 3 + drivers/video/Makefile | 1 + drivers/video/hdmi-notifier.c | 145 ++++++++++++++++++++++++++++++++++ include/linux/hdmi-notifier.h | 112 ++++++++++++++++++++++++++ 5 files changed, 267 insertions(+) create mode 100644 drivers/video/hdmi-notifier.c create mode 100644 include/linux/hdmi-notifier.h diff --git a/MAINTAINERS b/MAINTAINERS index 5cfbea4ce575..ffb7376f9509 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16676,6 +16676,12 @@ W: https://linuxtv.org S: Maintained F: drivers/media/platform/vicodec/* +VIDEO FRAMEWORK +M: Hans Verkuil +L: linux-media@vger.kernel.org +F: drivers/video/hdmi-notifier.* +S: Maintained + VIDEO MULTIPLEXER DRIVER M: Philipp Zabel L: linux-media@vger.kernel.org diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 83d3d271ca15..000ba9bc0ae7 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -34,6 +34,9 @@ config VIDEOMODE_HELPERS config HDMI bool +config HDMI_NOTIFIERS + bool + endif # HAS_IOMEM if VT diff --git a/drivers/video/Makefile b/drivers/video/Makefile index df7650adede9..eff4736102ca 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_VGASTATE) += vgastate.o obj-$(CONFIG_HDMI) += hdmi.o +obj-$(CONFIG_HDMI_NOTIFIERS) += hdmi-notifier.o obj-$(CONFIG_VT) += console/ obj-$(CONFIG_FB_STI) += console/ diff --git a/drivers/video/hdmi-notifier.c b/drivers/video/hdmi-notifier.c new file mode 100644 index 000000000000..d1eedf661648 --- /dev/null +++ b/drivers/video/hdmi-notifier.c @@ -0,0 +1,145 @@ +// SPDX-License-Identifier: GPL-2.0 +/* hdmi-notifier.c - notify interested parties of (dis)connect and EDID + * events + * + * Copyright 2016 Russell King + * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. + * All rights reserved. + */ + +#include +#include +#include +#include +#include + +static LIST_HEAD(hdmi_notifiers); +static DEFINE_MUTEX(hdmi_notifiers_lock); + +struct hdmi_notifier *hdmi_notifier_get(struct device *dev) +{ + struct hdmi_notifier *n; + + mutex_lock(&hdmi_notifiers_lock); + list_for_each_entry(n, &hdmi_notifiers, head) { + if (n->dev == dev) { + mutex_unlock(&hdmi_notifiers_lock); + kref_get(&n->kref); + return n; + } + } + n = kzalloc(sizeof(*n), GFP_KERNEL); + if (!n) + goto unlock; + n->dev = dev; + mutex_init(&n->lock); + BLOCKING_INIT_NOTIFIER_HEAD(&n->notifiers); + kref_init(&n->kref); + list_add_tail(&n->head, &hdmi_notifiers); +unlock: + mutex_unlock(&hdmi_notifiers_lock); + return n; +} +EXPORT_SYMBOL_GPL(hdmi_notifier_get); + +static void hdmi_notifier_release(struct kref *kref) +{ + struct hdmi_notifier *n = + container_of(kref, struct hdmi_notifier, kref); + + mutex_lock(&hdmi_notifiers_lock); + list_del(&n->head); + mutex_unlock(&hdmi_notifiers_lock); + kfree(n->edid); + kfree(n); +} + +void hdmi_notifier_put(struct hdmi_notifier *n) +{ + kref_put(&n->kref, hdmi_notifier_release); +} +EXPORT_SYMBOL_GPL(hdmi_notifier_put); + +int hdmi_notifier_register(struct hdmi_notifier *n, struct notifier_block *nb) +{ + int ret = blocking_notifier_chain_register(&n->notifiers, nb); + + if (ret) + return ret; + kref_get(&n->kref); + mutex_lock(&n->lock); + if (n->connected) { + blocking_notifier_call_chain(&n->notifiers, HDMI_CONNECTED, n); + if (n->edid_size) + blocking_notifier_call_chain(&n->notifiers, + HDMI_NEW_EDID, n); + if (n->has_eld) + blocking_notifier_call_chain(&n->notifiers, + HDMI_NEW_ELD, n); + } + mutex_unlock(&n->lock); + return 0; +} +EXPORT_SYMBOL_GPL(hdmi_notifier_register); + +int hdmi_notifier_unregister(struct hdmi_notifier *n, struct notifier_block *nb) +{ + int ret = blocking_notifier_chain_unregister(&n->notifiers, nb); + + if (ret == 0) + hdmi_notifier_put(n); + return ret; +} +EXPORT_SYMBOL_GPL(hdmi_notifier_unregister); + +void hdmi_event_connect(struct hdmi_notifier *n) +{ + mutex_lock(&n->lock); + n->connected = true; + blocking_notifier_call_chain(&n->notifiers, HDMI_CONNECTED, n); + mutex_unlock(&n->lock); +} +EXPORT_SYMBOL_GPL(hdmi_event_connect); + +void hdmi_event_disconnect(struct hdmi_notifier *n) +{ + mutex_lock(&n->lock); + n->connected = false; + n->has_eld = false; + n->edid_size = 0; + blocking_notifier_call_chain(&n->notifiers, HDMI_DISCONNECTED, n); + mutex_unlock(&n->lock); +} +EXPORT_SYMBOL_GPL(hdmi_event_disconnect); + +int hdmi_event_new_edid(struct hdmi_notifier *n, const void *edid, size_t size) +{ + mutex_lock(&n->lock); + if (n->edid_allocated_size < size) { + void *p = kmalloc(size, GFP_KERNEL); + + if (!p) { + mutex_unlock(&n->lock); + return -ENOMEM; + } + kfree(n->edid); + n->edid = p; + n->edid_allocated_size = size; + } + memcpy(n->edid, edid, size); + n->edid_size = size; + blocking_notifier_call_chain(&n->notifiers, HDMI_NEW_EDID, n); + mutex_unlock(&n->lock); + return 0; +} +EXPORT_SYMBOL_GPL(hdmi_event_new_edid); + +void hdmi_event_new_eld(struct hdmi_notifier *n, const u8 eld[128]) +{ + mutex_lock(&n->lock); + memcpy(n->eld, eld, sizeof(n->eld)); + n->has_eld = true; + blocking_notifier_call_chain(&n->notifiers, HDMI_NEW_ELD, n); + mutex_unlock(&n->lock); +} +EXPORT_SYMBOL_GPL(hdmi_event_new_eld); diff --git a/include/linux/hdmi-notifier.h b/include/linux/hdmi-notifier.h new file mode 100644 index 000000000000..c8f35110e3e3 --- /dev/null +++ b/include/linux/hdmi-notifier.h @@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: GPL-2.0 + * hdmi-notifier.h - notify interested parties of (dis)connect and EDID + * events + * + * Copyright 2016 Russell King + * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. + * All rights reserved. + */ + +#ifndef LINUX_HDMI_NOTIFIER_H +#define LINUX_HDMI_NOTIFIER_H + +#include +#include +#include + +enum { + HDMI_CONNECTED, + HDMI_DISCONNECTED, + HDMI_NEW_EDID, + HDMI_NEW_ELD, +}; + +struct device; + +struct hdmi_notifier { + /* Lock to protect callback registration and notification. */ + struct mutex lock; + struct list_head head; + struct kref kref; + struct blocking_notifier_head notifiers; + struct device *dev; + + /* Current state */ + unsigned int connected : 1; + unsigned int has_eld : 1; + unsigned char eld[128]; + void *edid; + size_t edid_size; + size_t edid_allocated_size; +}; + +/** + * hdmi_notifier_get - find or create a new hdmi_notifier for the given device. + * @dev: device that sends the events. + * + * If a notifier for device @dev already exists, then increase the refcount + * and return that notifier. + * + * If it doesn't exist, then allocate a new notifier struct and return a + * pointer to that new struct. + * + * Return NULL if the memory could not be allocated. + */ +struct hdmi_notifier *hdmi_notifier_get(struct device *dev); + +/** + * hdmi_notifier_put - decrease refcount and delete when the refcount reaches 0. + * @n: notifier + */ +void hdmi_notifier_put(struct hdmi_notifier *n); + +/** + * hdmi_notifier_register - register the notifier with the notifier_block. + * @n: the HDMI notifier + * @nb: the notifier_block + */ +int hdmi_notifier_register(struct hdmi_notifier *n, struct notifier_block *nb); + +/** + * hdmi_notifier_unregister - unregister the notifier with the notifier_block. + * @n: the HDMI notifier + * @nb: the notifier_block + */ +int hdmi_notifier_unregister(struct hdmi_notifier *n, + struct notifier_block *nb); + +/** + * hdmi_event_connect - send a connect event. + * @n: the HDMI notifier + * + * Send an HDMI_CONNECTED event to any registered parties. + */ +void hdmi_event_connect(struct hdmi_notifier *n); + +/** + * hdmi_event_disconnect - send a disconnect event. + * @n: the HDMI notifier + * + * Send an HDMI_DISCONNECTED event to any registered parties. + */ +void hdmi_event_disconnect(struct hdmi_notifier *n); + +/** + * hdmi_event_new_edid - send a new EDID event. + * @n: the HDMI notifier + * + * Send an HDMI_NEW_EDID event to any registered parties. + * This function will make a copy the EDID so it can return -ENOMEM if + * no memory could be allocated. + */ +int hdmi_event_new_edid(struct hdmi_notifier *n, const void *edid, size_t size); + +/** + * hdmi_event_new_eld - send a new ELD event. + * @n: the HDMI notifier + * + * Send an HDMI_NEW_ELD event to any registered parties. + */ +void hdmi_event_new_eld(struct hdmi_notifier *n, const u8 eld[128]); + +#endif From patchwork Mon Jun 3 04:32:46 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: 10972301 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 CD8CA76 for ; Mon, 3 Jun 2019 04:36:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B53F228789 for ; Mon, 3 Jun 2019 04:36:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2B3E287B7; Mon, 3 Jun 2019 04:36:02 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 C1D5128789 for ; Mon, 3 Jun 2019 04:36:01 +0000 (UTC) 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 13D961688; Mon, 3 Jun 2019 06:35:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 13D961688 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1559536560; bh=KJC/uNUzVoOwDt1PDt3hgbFlPSi/hLAdPFCtPclsAbM=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lB/ATz69nOzOFqEHVi48VHYVJCFROVJrWujsXGEw6EjSOvt8gaNSp4jllpvKhZzEI t9xIwMrwhfRcYz2n9vvFgWGUMK5xohnNFM8v4ZkJc8vC7nr2jkCcOqVpvcL9pRLhFe EAZ0B0t4lLUE4vM9ApouZkZdFhNNPUiGy1APickg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DA9A2F89738; Mon, 3 Jun 2019 06:33:43 +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 B358DF89739; Mon, 3 Jun 2019 06:33:41 +0200 (CEST) Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (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 7B5BDF89735 for ; Mon, 3 Jun 2019 06:33:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7B5BDF89735 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KJJ1x0++" Received: by mail-pl1-x643.google.com with SMTP id g21so6474815plq.0 for ; Sun, 02 Jun 2019 21:33:37 -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=THpWWd94tGmQN+NdFGT3/k0LHquClB5/KK663N0sln0=; b=KJJ1x0++tPXhvMrHIIn+IkJ/vK8nkc8NHbB2D6JxfEvO7fQ7JvXfP5vQQym4cUZid7 eXWRl+urkk59DTsjUfW4h8UzpjNysutkrDV8SjNkxUyhnoYvWF9oflHr5Gj4oI4wI2dE aKzJPUU63kjAbR5g+z6/OO2IamS68nQduWMvM= 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=THpWWd94tGmQN+NdFGT3/k0LHquClB5/KK663N0sln0=; b=KeImZ7qEIddszF9R2QWjsdpSqb9tr2DujIWWixPwpNM2UskHEb+E4+94lxAB69heZs aG+qJNcc6mE4dIzxTlncbkgeEi4D+CDLP++MgR6t+rIWdogWF77vshmawJ/RRMGMmp6x GNPOdktziTktbXEFgMyzb/gy1pNdNB2u12wmGTbZdjMVoVH8p4e/A/aPhM2qTyMJUKk3 BhCa04vn4wQpotpcoFCiU4X89BKwvEft5a9ffAsAQV42pVmQ3vqQ9+Zgs+doT7mrt4zt +Apj1Ut3kOgNIYXHaG2D8BD8f+435ejKgUCIaJQgnSFFmZLAb6hEc2u1EoDmBfxlJ2mf 3mhQ== X-Gm-Message-State: APjAAAWegpw2doBsExvOe0qZh+vBi4+tN+KgviYn/NaN4bd4KmTAb4XP BDUqzOwt/cs8Q2rgVXfGTV0Hsw== X-Google-Smtp-Source: APXvYqwws/fG+++4fl7pwkP7whHCh5KwVv/jHX0W+ARw9Qav4UnXZIe+8/mlxxK/nHoVLY0RrHtTyw== X-Received: by 2002:a17:902:7591:: with SMTP id j17mr27660314pll.200.1559536416450; Sun, 02 Jun 2019 21:33:36 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id i25sm13348782pfr.73.2019.06.02.21.33.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 21:33:35 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Mon, 3 Jun 2019 12:32:46 +0800 Message-Id: <20190603043251.226549-3-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 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , 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, Philipp Zabel , Bartlomiej Zolnierkiewicz , Russell King , Rob Herring , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , dianders@chromium.org, Mark Brown , Daniel Vetter Subject: [alsa-devel] [PATCH 2/7] ASoC: hdmi-codec: use HDMI state notifier to add 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Philipp Zabel Use HDMI connection / disconnection notifications to update an ALSA jack object. Also make a copy of the ELD block after every change. This was posted by Philipp Zabel at https://patchwork.kernel.org/patch/9430747/ Modified by Cheng-Yi Chiang: - Fix the conflict of removed hdmi_codec_remove ops. - Other minor fix for the conflict with latest hdmi-codec on ASoC for-next tree. Signed-off-by: Philipp Zabel Signed-off-by: Cheng-Yi Chiang --- The original patch is at https://patchwork.kernel.org/patch/9430747/ I could not find the LKML link for the patch. include/sound/hdmi-codec.h | 7 +++ sound/soc/codecs/Kconfig | 1 + sound/soc/codecs/hdmi-codec.c | 104 +++++++++++++++++++++++++++++++++- 3 files changed, 110 insertions(+), 2 deletions(-) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index 9483c55f871b..4fa39c93363f 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -107,6 +107,13 @@ struct hdmi_codec_pdata { void *data; }; +struct snd_soc_component; +struct snd_soc_jack; + +int hdmi_codec_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *jack, + struct device *dev); + #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec" #endif /* __HDMI_CODEC_H__ */ diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 8f577258080b..f5f6dd04234c 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -639,6 +639,7 @@ config SND_SOC_HDMI_CODEC select SND_PCM_ELD select SND_PCM_IEC958 select HDMI + select HDMI_NOTIFIERS config SND_SOC_ES7134 tristate "Everest Semi ES7134 CODEC" diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 6a0cc8d7e141..fe796a7475a5 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -12,9 +12,12 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ +#include #include +#include #include #include +#include #include #include #include @@ -282,6 +285,13 @@ struct hdmi_codec_priv { struct snd_pcm_chmap *chmap_info; unsigned int chmap_idx; struct mutex lock; + struct snd_soc_jack *jack; + /* Lock to protect setting and getting eld. */ + struct mutex eld_lock; + struct device *dev; + struct hdmi_notifier *notifier; + struct notifier_block nb; + unsigned int jack_status; }; static const struct snd_soc_dapm_widget hdmi_widgets[] = { @@ -308,7 +318,9 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + mutex_lock(&hcp->eld_lock); memcpy(ucontrol->value.bytes.data, hcp->eld, sizeof(hcp->eld)); + mutex_unlock(&hcp->eld_lock); return 0; } @@ -393,7 +405,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); - int ret = 0; + int ret; ret = mutex_trylock(&hcp->lock); if (!ret) { @@ -408,9 +420,9 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, } if (hcp->hcd.ops->get_eld) { + mutex_lock(&hcp->eld_lock); ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data, hcp->eld, sizeof(hcp->eld)); - if (!ret) { ret = snd_pcm_hw_constraint_eld(substream->runtime, hcp->eld); @@ -419,6 +431,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, } /* Select chmap supported */ hdmi_codec_eld_chmap(hcp); + mutex_unlock(&hcp->eld_lock); } return 0; @@ -747,6 +760,77 @@ static const struct snd_soc_component_driver hdmi_driver = { .non_legacy_dai_naming = 1, }; +static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp, + unsigned int jack_status) +{ + if (!hcp->jack) + return; + + if (jack_status != hcp->jack_status) { + snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT); + hcp->jack_status = jack_status; + } +} + +static int hdmi_codec_notify(struct notifier_block *nb, unsigned long event, + void *data) +{ + struct hdmi_codec_priv *hcp = container_of(nb, struct hdmi_codec_priv, + nb); + struct hdmi_notifier *n = data; + + if (!hcp->jack) + return NOTIFY_OK; + + switch (event) { + case HDMI_NEW_ELD: + mutex_lock(&hcp->eld_lock); + memcpy(hcp->eld, n->eld, sizeof(hcp->eld)); + mutex_unlock(&hcp->eld_lock); + /* fall through */ + case HDMI_CONNECTED: + hdmi_codec_jack_report(hcp, SND_JACK_LINEOUT); + break; + case HDMI_DISCONNECTED: + hdmi_codec_jack_report(hcp, 0); + break; + } + + return NOTIFY_OK; +} + +/** + * hdmi_codec_set_jack_detect - register HDMI state notifier callback + * @component: the hdmi-codec instance + * @jack: ASoC jack to report (dis)connection events on + * @dev: hdmi_notifier device, usually HDMI_TX or CEC device + */ +int hdmi_codec_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *jack, + struct device *dev) +{ + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + int ret; + + hcp->notifier = hdmi_notifier_get(dev); + if (!hcp->notifier) + return -ENOMEM; + + hcp->jack = jack; + hcp->nb.notifier_call = hdmi_codec_notify; + ret = hdmi_notifier_register(hcp->notifier, &hcp->nb); + if (ret) + goto err_notifier_put; + + return 0; + +err_notifier_put: + hdmi_notifier_put(hcp->notifier); + hcp->notifier = NULL; + return ret; +} +EXPORT_SYMBOL_GPL(hdmi_codec_set_jack_detect); + static int hdmi_codec_probe(struct platform_device *pdev) { struct hdmi_codec_pdata *hcd = pdev->dev.platform_data; @@ -774,6 +858,7 @@ static int hdmi_codec_probe(struct platform_device *pdev) hcp->hcd = *hcd; mutex_init(&hcp->lock); + mutex_init(&hcp->eld_lock); daidrv = devm_kcalloc(dev, dai_count, sizeof(*daidrv), GFP_KERNEL); if (!daidrv) @@ -797,6 +882,20 @@ static int hdmi_codec_probe(struct platform_device *pdev) __func__, ret); return ret; } + + hcp->dev = dev; + + return 0; +} + +static int hdmi_codec_remove(struct platform_device *pdev) +{ + struct hdmi_codec_priv *hcp = platform_get_drvdata(pdev); + + if (hcp->notifier) { + hdmi_notifier_unregister(hcp->notifier, &hcp->nb); + hdmi_notifier_put(hcp->notifier); + } return 0; } @@ -805,6 +904,7 @@ static struct platform_driver hdmi_codec_driver = { .name = HDMI_CODEC_DRV_NAME, }, .probe = hdmi_codec_probe, + .remove = hdmi_codec_remove, }; module_platform_driver(hdmi_codec_driver); From patchwork Mon Jun 3 04:32: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: 10972303 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 F0F2F6C5 for ; Mon, 3 Jun 2019 04:36:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD3F328789 for ; Mon, 3 Jun 2019 04:36:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF509287B7; Mon, 3 Jun 2019 04:36:42 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 24F9A28789 for ; Mon, 3 Jun 2019 04:36:42 +0000 (UTC) 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 6AB7C1692; Mon, 3 Jun 2019 06:35:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6AB7C1692 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1559536600; bh=tDULDZAzo+95uqfvkmNWWSgD1/d6rI0zYo/X1VwYuW8=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=i5nUAci/K07kmspSJWrx3qZJyHqrvb0/KyPPdA6LFyty7xXfhmpsu3pzsWKYULPRd ltICFO4WdJb6VADTirxXmVCoALLFmojN1hXqOIqXgKlUQXT/ME7ZHzQB6PAPKu1S7I Wn2tdljmaps3DkCsY/jiSmDIlue50s/zQEvJU5P0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0D392F8973D; Mon, 3 Jun 2019 06:33:51 +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 357B0F8973F; Mon, 3 Jun 2019 06:33:49 +0200 (CEST) Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (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 608B9F8973A for ; Mon, 3 Jun 2019 06:33:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 608B9F8973A Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kedjugWk" Received: by mail-pg1-x542.google.com with SMTP id 83so694219pgg.8 for ; Sun, 02 Jun 2019 21:33: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=MaZJTXi3Kb+zP1LdC2+ckQjoA/4H+fjgGV1LvJAeRMw=; b=kedjugWkJGjbZv4u3cVdp4XDkL/2UujV324hi4xDMTOTYbHYPbUnOtVV/E696ygI4t cYwfGz01X+eBCKlr5xigVC+q17FBxGkqMRIQmN2Tb9LkEM0x9vaOqC8GKJiYJv2aslY2 TItexnk2xcMcs/1c/Ex771hoN5UH0dq13eh48= 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=MaZJTXi3Kb+zP1LdC2+ckQjoA/4H+fjgGV1LvJAeRMw=; b=d5adP5acwCpsdcMmiMHXnmwPRqgP5PU9kCw5d/fqr6SE+wJ3uxwS6mI4TL9CADUuSo /PF8nFFK8jo/aF5kByUeL53oAQxlVIZqEiL+retLKPaiIqHp/31jCsQ9FjQdCglgzfG5 GS0sJNlLuUWjhXvyyfxS1YynEB6S6u6mK+lBEJo39Bh8l+29sNBJhWpuO2Sb2b1jo7/+ /HMHiM3j5S2KyF+Dj/bJTPzlfx4p3jKS6QPQce4NEe/lmXsYR9asdiymWxQoYeex5iTz u1bFon21sIDPc7wTt7SoX/iO1afAku4WF/P0E1M9fA4XizqMa4JLOLknW4+L27FSSDtX Uljw== X-Gm-Message-State: APjAAAUiFv64XTk5Nse9Bl7g88o7SJocWT2/Da/CYzCmE5WTSVHraWGt o8EVCGrCaxDQJtaMW4VbDVg41A== X-Google-Smtp-Source: APXvYqwQPHtm3t6nVseAhWV9BUbWtxWUQBMFPxBiyn3rh2KIclbVwhWbmFhQyEfEQ9mmHbprMFiaUg== X-Received: by 2002:a17:90a:a789:: with SMTP id f9mr27039120pjq.20.1559536424466; Sun, 02 Jun 2019 21:33:44 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id m11sm10827627pjv.21.2019.06.02.21.33.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 21:33:43 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Mon, 3 Jun 2019 12:32:47 +0800 Message-Id: <20190603043251.226549-4-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 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , 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, Philipp Zabel , Bartlomiej Zolnierkiewicz , Russell King , Rob Herring , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , dianders@chromium.org, Mark Brown , Daniel Vetter Subject: [alsa-devel] [PATCH 3/7] drm/bridge/synopsys: dw-hdmi: Add HDMI notifier 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" X-Virus-Scanned: ClamAV using ClamSMTP Use hdmi-notifier to notify codec driver that there is HDMI plug/unplug event. Signed-off-by: Cheng-Yi Chiang --- drivers/gpu/drm/bridge/synopsys/Kconfig | 1 + drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 28 +++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/Kconfig b/drivers/gpu/drm/bridge/synopsys/Kconfig index 3cc53b44186e..43192d9d7357 100644 --- a/drivers/gpu/drm/bridge/synopsys/Kconfig +++ b/drivers/gpu/drm/bridge/synopsys/Kconfig @@ -3,6 +3,7 @@ config DRM_DW_HDMI select DRM_KMS_HELPER select REGMAP_MMIO select CEC_CORE if CEC_NOTIFIER + select HDMI_NOTIFIERS config DRM_DW_HDMI_AHB_AUDIO tristate "Synopsys Designware AHB Audio interface" diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index ab7968c8f6a2..53701921eb1f 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -190,6 +191,7 @@ struct dw_hdmi { void (*disable_audio)(struct dw_hdmi *hdmi); struct cec_notifier *cec_notifier; + struct hdmi_notifier *hdmi_notifier; }; #define HDMI_IH_PHY_STAT0_RX_SENSE \ @@ -2301,8 +2303,15 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) } if (intr_stat & HDMI_IH_PHY_STAT0_HPD) { - dev_dbg(hdmi->dev, "EVENT=%s\n", - phy_int_pol & HDMI_PHY_HPD ? "plugin" : "plugout"); + if (phy_int_pol & HDMI_PHY_HPD) { + dev_dbg(hdmi->dev, "EVENT=plugin\n"); + if (hdmi->hdmi_notifier) + hdmi_event_connect(hdmi->hdmi_notifier); + } else { + dev_dbg(hdmi->dev, "EVENT=plugout\n"); + if (hdmi->hdmi_notifier) + hdmi_event_disconnect(hdmi->hdmi_notifier); + } if (hdmi->bridge.dev) drm_helper_hpd_irq_event(hdmi->bridge.dev); } @@ -2606,6 +2615,12 @@ __dw_hdmi_probe(struct platform_device *pdev, goto err_iahb; } + hdmi->hdmi_notifier = hdmi_notifier_get(dev); + if (!hdmi->hdmi_notifier) { + ret = -ENOMEM; + goto err_iahb; + } + /* * To prevent overflows in HDMI_IH_FC_STAT2, set the clk regenerator * N and cts values before enabling phy @@ -2696,6 +2711,9 @@ __dw_hdmi_probe(struct platform_device *pdev, if (hdmi->cec_notifier) cec_notifier_put(hdmi->cec_notifier); + if (hdmi->hdmi_notifier) + hdmi_notifier_put(hdmi->hdmi_notifier); + clk_disable_unprepare(hdmi->iahb_clk); if (hdmi->cec_clk) clk_disable_unprepare(hdmi->cec_clk); @@ -2709,6 +2727,9 @@ __dw_hdmi_probe(struct platform_device *pdev, static void __dw_hdmi_remove(struct dw_hdmi *hdmi) { + if (hdmi->hdmi_notifier) + hdmi_event_disconnect(hdmi->hdmi_notifier); + if (hdmi->audio && !IS_ERR(hdmi->audio)) platform_device_unregister(hdmi->audio); if (!IS_ERR(hdmi->cec)) @@ -2720,6 +2741,9 @@ static void __dw_hdmi_remove(struct dw_hdmi *hdmi) if (hdmi->cec_notifier) cec_notifier_put(hdmi->cec_notifier); + if (hdmi->hdmi_notifier) + hdmi_notifier_put(hdmi->hdmi_notifier); + clk_disable_unprepare(hdmi->iahb_clk); clk_disable_unprepare(hdmi->isfr_clk); if (hdmi->cec_clk) From patchwork Mon Jun 3 04:32: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: 10972305 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 9784B6C5 for ; Mon, 3 Jun 2019 04:37:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81E2928789 for ; Mon, 3 Jun 2019 04:37:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74402287B7; Mon, 3 Jun 2019 04:37:24 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 A57AD28789 for ; Mon, 3 Jun 2019 04:37:23 +0000 (UTC) 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 0B0761687; Mon, 3 Jun 2019 06:36:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0B0761687 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1559536642; bh=WMSvswmN7C+y0AS8J4d12zIFzXzipDSMOnHbgfhACwM=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Yh3A0wN+UU/5xphX00tHIrZ83wQ+da7JIwhiyZFXxwtBvI6QaOdp73QbP86/4a5vx tteAEnMOvrtJWCK8E/TSS1erUR9z/+veQynlJb+8B8OctImcxNxYQc/lnCjbrYrPGL bNpUBgftEP1ksHDWNBLkRuV0ZG1iOI8HUXusETx0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3BAF1F89744; Mon, 3 Jun 2019 06:33:58 +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 84315F89745; Mon, 3 Jun 2019 06:33:56 +0200 (CEST) Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (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 46678F89743 for ; Mon, 3 Jun 2019 06:33:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 46678F89743 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="aS63RSB2" Received: by mail-pf1-x443.google.com with SMTP id y11so9796584pfm.13 for ; Sun, 02 Jun 2019 21:33:52 -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=VNhIPfCzhvP16fqORSEWqfVMPdXyoyqEWF63uuLSDrk=; b=aS63RSB2MNke62PjJpoyae9QYgwadmzCHxyo/akbQ6j0njb7Qvs1M42x05Nl+STv4N aT36WXdgX14k/02Uu5lOtg0gDcVzgC82+oI2MDXRTP2djZfNlQBgktFTbm0TIYz9LeEM UQxXP76qGTfkBpPvYmVsorx3tFk+XkOps4S8Q= 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=VNhIPfCzhvP16fqORSEWqfVMPdXyoyqEWF63uuLSDrk=; b=qYTjoWfMPDQHh+rVCSf8t3YfavtjFo+d8KWMZfN9erRFSWfQEafik8YvSJ3ephMcJh aL8PKKwM0sQxNld4mx/HcsfSZQ6IxQQJoVCkrg+YKYjYjbIBde0GIihu/fFVOf+ay1LL uCALSc/mu0kxRwRdIofUSq+W4XYEtZ5QU70cUFsLS4EoE4Vy/J3bYXj8N9fNmk5lgpwU pOFxG+lEs9Qct6WECoHyYDo7ZBQh0/TTEH7DRR4kfs5cIDzviP7Uj3wQ8KTVfoPf/yTZ xb7eMcgItFjN2J6XWnAxExXcN2Yeaoz5ytRWwEAjlsnadGbxFfCGY7RJSUF+GJeHOAxp HPeQ== X-Gm-Message-State: APjAAAVC9ZjCyTcyr1tbMUQUuSIZjw1V5NbhDxWhl4a/G5KgJ4pDnlB6 OIgv2rYa2OEDen5GVz1CO1tZuQ== X-Google-Smtp-Source: APXvYqxCKuyRQ2X1UulsfHVItZDlh+50qnG+L/5rSS2nM2O2Kzttw7fu9DPtrRkmFky1mxn3GQpxbw== X-Received: by 2002:a65:5302:: with SMTP id m2mr15280720pgq.266.1559536431198; Sun, 02 Jun 2019 21:33:51 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id g22sm13550306pfo.28.2019.06.02.21.33.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 21:33:50 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Mon, 3 Jun 2019 12:32:48 +0800 Message-Id: <20190603043251.226549-5-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 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , 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, Philipp Zabel , Bartlomiej Zolnierkiewicz , Russell King , Rob Herring , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , dianders@chromium.org, Mark Brown , Daniel Vetter Subject: [alsa-devel] [PATCH 4/7] 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" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- sound/soc/rockchip/rockchip_max98090.c | 82 +++++++++++++++++++------- 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/sound/soc/rockchip/rockchip_max98090.c b/sound/soc/rockchip/rockchip_max98090.c index 789d6f1e2b5f..2dd247670c7a 100644 --- a/sound/soc/rockchip/rockchip_max98090.c +++ b/sound/soc/rockchip/rockchip_max98090.c @@ -53,6 +53,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[] = { @@ -64,6 +65,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[] = { @@ -71,6 +73,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, @@ -104,33 +107,48 @@ 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 && ret != -ENOTSUPP) { + dev_err(cpu_dai->dev, "Can't set cpu dai clock %d\n", ret); return ret; } 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 && ret != -ENOTSUPP) { + 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, }; -static struct snd_soc_dai_link rk_dailink = { - .name = "max98090", - .stream_name = "Audio", - .codec_dai_name = "HiFi", - .ops = &rk_aif1_ops, - /* set max98090 as slave */ - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS, +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, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + }, + [DAILINK_HDMI] = { + .name = "HDMI", + .stream_name = "HDMI", + .codec_name = "hdmi-audio-codec.3.auto", + .codec_dai_name = "i2s-hifi", + .ops = &rk_aif1_ops, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + } }; static int rk_98090_headset_init(struct snd_soc_component *component); @@ -143,8 +161,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, @@ -180,27 +198,47 @@ 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_cpu; + struct of_phandle_args args; /* register the soc card */ card->dev = &pdev->dev; - rk_dailink.codec_of_node = of_parse_phandle(np, - "rockchip,audio-codec", 0); - if (!rk_dailink.codec_of_node) { + rk_dailinks[DAILINK_MAX98090].codec_of_node = + of_parse_phandle(np, "rockchip,audio-codec", 0); + if (!rk_dailinks[DAILINK_MAX98090].codec_of_node) { dev_err(&pdev->dev, "Property 'rockchip,audio-codec' missing or invalid\n"); return -EINVAL; } - rk_dailink.cpu_of_node = of_parse_phandle(np, - "rockchip,i2s-controller", 0); - if (!rk_dailink.cpu_of_node) { + 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].codec_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); + + if (!np_cpu) { dev_err(&pdev->dev, "Property 'rockchip,i2s-controller' missing or invalid\n"); return -EINVAL; } - rk_dailink.platform_of_node = rk_dailink.cpu_of_node; + rk_dailinks[DAILINK_MAX98090].cpu_of_node = np_cpu; + rk_dailinks[DAILINK_MAX98090].platform_of_node = np_cpu; + rk_dailinks[DAILINK_HDMI].cpu_of_node = np_cpu; + rk_dailinks[DAILINK_HDMI].platform_of_node = np_cpu; rk_98090_headset_dev.codec_of_node = of_parse_phandle(np, "rockchip,headset-codec", 0); From patchwork Mon Jun 3 04:32: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: 10972307 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 04D3476 for ; Mon, 3 Jun 2019 04:37:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E63DF28789 for ; Mon, 3 Jun 2019 04:37:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9B15287B7; Mon, 3 Jun 2019 04:37:54 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 3C25328789 for ; Mon, 3 Jun 2019 04:37:54 +0000 (UTC) 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 9A34B83E; Mon, 3 Jun 2019 06:37:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9A34B83E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1559536672; bh=l6Z3bi55lTJApvzfJzNldMrWTx+GCieddaQWIG/mbEk=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WIxbT2f0cs0IP1ORiNFVDzrPARPQQfih/dTD1sXUdeGk1RDFEzE29CFYrrVEwbqjQ YyS260MMwXvU57NNxweleMKdJGtYW6nfSNdXTEJJAFo9RYB/InojOwwCoYsMRRjTlk Wle7FDMmH5jSRiSYdlBItKI7c77oaLKA7IPyL2LA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 77ACEF89749; Mon, 3 Jun 2019 06:34:05 +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 2AE7CF8974A; Mon, 3 Jun 2019 06:34:03 +0200 (CEST) Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (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 1189DF89748 for ; Mon, 3 Jun 2019 06:33:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1189DF89748 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="RQSvUzIg" Received: by mail-pf1-x442.google.com with SMTP id x15so26012pfq.0 for ; Sun, 02 Jun 2019 21:33:59 -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=3pFTY68CYf0vqkaIF9RkUPvim3fj+DjvxB3baTxp4Mk=; b=RQSvUzIgUKgIsNlQFm+7zwJeVC5MSGMQ7g3/DtHR16ldFiUtk0+JARXtgZwEjl9tbN 9hWW1p5DfY6fy/aBLs4Yymn5h3QUKDGbkoEPEt1I/+q7XpVzAK46qrqE/1RGqPuPtlv2 oTdErhd/k+QH1OsnOMAFqzaVQi6I8u9i9UvY8= 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=3pFTY68CYf0vqkaIF9RkUPvim3fj+DjvxB3baTxp4Mk=; b=DWqEOj18qfuuX9cEp441T46F3+fs7kbrCm/0MDV6HVSh65Y9TQQyT7TXxiGnChkaNc HauTVZx+zp+GhBjLSTyjO81uJvITjT1LVYtjkjD9uQ4o0y2MYQZxUXuYHZnqtATPly3i 9NPYYLsRCKWV4qnFbCnrSK/xp8h8vOkSsxc/vZ3OAtB6VMQMNsa/uqwj799RrYJ9w3XC aOihdXDT2Wb+DVXvDh0eVcUp9PTvZv00ItMIMctzkCE926bOFUsupizQK3cGuhGdL03r Bc24HWXOumJbNmQPqxk+WqoE9MUbK8TyjZ4FzaaejF22/Jokcl9vYV1Qbp4Gsd/oX2si gpPA== X-Gm-Message-State: APjAAAViQWtMSDLyrxKhnwwKphqSHqxwGWX0VgLF7HsQnU02BHxLMZi1 YqOID1FEvadTUx/ZWwL01PHdXw== X-Google-Smtp-Source: APXvYqzy0pOcm1foPAUC6fqZXlzM7mUcjUylak9ZglBCN1Q2GIU98tYWPiPis4kHfvZEn5RQOneLLw== X-Received: by 2002:a17:90a:730b:: with SMTP id m11mr27194254pjk.89.1559536438112; Sun, 02 Jun 2019 21:33:58 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id j23sm13509733pff.90.2019.06.02.21.33.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 21:33:57 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Mon, 3 Jun 2019 12:32:49 +0800 Message-Id: <20190603043251.226549-6-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 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , 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, Philipp Zabel , Bartlomiej Zolnierkiewicz , Russell King , Rob Herring , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , dianders@chromium.org, Mark Brown , Daniel Vetter Subject: [alsa-devel] [PATCH 5/7] ASoC: rockchip: rockchip-max98090: Add node 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" X-Virus-Scanned: ClamAV using ClamSMTP Let user specify HDMI node so machine driver can use it to let codec driver register callback on correct hdmi-notifier. Signed-off-by: Cheng-Yi Chiang Acked-by: Rob Herring --- 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..dae57c14864e 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: The phandle of HDMI node for HDMI jack detection Example: @@ -16,4 +17,5 @@ sound { rockchip,i2s-controller = <&i2s>; rockchip,audio-codec = <&max98090>; rockchip,headset-codec = <&headsetcodec>; + rockchip,hdmi= <&hdmi>; }; 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: 10972309 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 BCEC576 for ; Mon, 3 Jun 2019 04:38:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAA0828789 for ; Mon, 3 Jun 2019 04:38:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DE0C287B7; Mon, 3 Jun 2019 04:38:45 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 E4E5328789 for ; Mon, 3 Jun 2019 04:38:44 +0000 (UTC) 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 1EAEE16A2; Mon, 3 Jun 2019 06:37:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1EAEE16A2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1559536723; bh=dEYlVWDWufCCSXiax8SAKFiSCnYK2S523RLx0Z70Kqs=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MNFibX4Je0i6T3YxM0hbRBuKSKFwJpCeAk5S1z5hg8on/cqSjuNTIk8M/VjFkXwPe 8xpckUXYXZasm8yEbWYWRAg3e4nN77USavrn1/VOjD3bib4D06EV/W0uKqyzLqT4gv r7yiobhtbag7d4K+IsJY1cY/DvCRTC9bfNGP2DnE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 392B8F89755; Mon, 3 Jun 2019 06:34:12 +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 EA267F89756; Mon, 3 Jun 2019 06:34:09 +0200 (CEST) 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 D1E6AF89752 for ; Mon, 3 Jun 2019 06:34:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D1E6AF89752 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Hfq6ax4j" Received: by mail-pl1-x642.google.com with SMTP id g69so6465583plb.7 for ; Sun, 02 Jun 2019 21:34:06 -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=Cjn+fe9pHSnglvx4T5q/xNRom5yt6XJeMvAMIuyqpGU=; b=Hfq6ax4j9v67eMl3jzhORUV9xlodMxfyEB5jUFylBnMvGjbup0xltWak92wPnYo8jT z0URgg2rd1r5wg+Oy3xrddVqdvePsxYBMv74zKntc+d+vjFpS0hNfzpdzd1s9AT5d4X1 i8E4gAcDkyjhrEy5aOZTU8DXTpX6OpurnFU4Q= 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=gcqMGirgqYjhHk+oXpndIA5cFP49RunY88btCtKP3aYhDpL3MyNjS43xgu7NcKBIHS MJW6djKCxp/g0xRvnPEZSc9Cn6JC4Bg85YZXr9IfdqPafhDq5QAnJQNcV9nRmxG6k6jV XoCFuQ29CUkds36nMUTLUqpySkx4O7A84b1w0vtlTpYfCbYnfn0go9HuacufXMQ3kCvI 5TsTSCEGK0UOsgBfyi4yLwAcl6tXTEBJtrZOeyhaUEXCQzWmEkRE4nVwaKW5bAmG4jhp YypB+Bl5Snfab+nFrTRZQ34GCOiVOVHCH+a80G4R4soD3W2FTPLLuO2T/ri47ZabfJz9 1uOQ== X-Gm-Message-State: APjAAAWLZt02hOEpBvqS7nbRWtKOfaI1/kqeFTZ265P8eSykCI2kxDnK v6XYwtCXXDEPdNenb9fgSxIWqg== 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 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 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , 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, Philipp Zabel , Bartlomiej Zolnierkiewicz , Russell King , Rob Herring , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , dianders@chromium.org, Mark Brown , Daniel Vetter Subject: [alsa-devel] [PATCH 6/7] 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" 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, From patchwork Mon Jun 3 04:32:51 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: 10972315 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 9E0226C5 for ; Mon, 3 Jun 2019 04:39:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D2C628789 for ; Mon, 3 Jun 2019 04:39:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FBE6287B7; Mon, 3 Jun 2019 04:39:27 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 BB99528789 for ; Mon, 3 Jun 2019 04:39:26 +0000 (UTC) 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 0EDD51694; Mon, 3 Jun 2019 06:38:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0EDD51694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1559536765; bh=qZCSPwwxrMcQy+P4NPvZgRQ6rhq119CQ7LNlRvwVJSA=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Dr+SOz5lAzH4P4SwWKxrGI6YBeasuidC+i7mCVPk5lNloq/9c/PWpRwShLK0+zJa8 X24CaEcuxDM7G4i+NaBLh0lXnivAmBruLYFItapWHBIcp2ZvjqzupzvAadGKhJOJnc Z7bLT4COy6EjILacaCG7lyznALeh1vsRPEeseWdg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EAD28F8975A; Mon, 3 Jun 2019 06:34:17 +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 46A30F8975B; Mon, 3 Jun 2019 06:34:16 +0200 (CEST) Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (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 7035AF89759 for ; Mon, 3 Jun 2019 06:34:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7035AF89759 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="W0HFUAGE" Received: by mail-pg1-x543.google.com with SMTP id a3so119998pgb.3 for ; Sun, 02 Jun 2019 21:34:12 -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=b/qy0C/+qIVS4p/9C8coL0gczc7xGffHcCTpl84Pnik=; b=W0HFUAGEBlitH2BpXUVE7tLd15Ng5l2TZqjITWduI3EGWRg3JKMe0MjJis9TBvMp02 4awA3xZDrtX56bGXOH5ZQ3oEimCGvzikfQPZANnHJau89l5kDDX0gPAAvlPieYi8kSIP TwDl7/UAUwCplFr2sy8k4qBf+wMfpuYAoO41w= 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=b/qy0C/+qIVS4p/9C8coL0gczc7xGffHcCTpl84Pnik=; b=GaernyOYYBkFxpqj9wzYsWaI8CdTsq3QfnkZKTrGVO5VGBzIbdrJbqkl2LW4XdGaiy 7nk4ooKje9jM42GfACoytpwb+Dnof4YBJpwSF5Eu6bYDmr+Pkh64Wzn/lbqcHixB8sWu Vpm35fyNYSEr52ln3HOPmo21NnkK7r/qYCQPKFl0f77lYNHM2g2CZpWC1IRj4wBlI7qy s4+Fe1gjSmgERfXAErwgGxiwQ8Q7nUOzF2ZxtWkKiD//8N3BXYNNAtftQqEv3ukWgRCd 3waXCdbBl8uFfo1inbPBQAueg7fOsdaEHYxdcVRouObA0R63+XGGeKz05ZpgXE0S9jhj YCOQ== X-Gm-Message-State: APjAAAW1mdN1N8cCAO7dbifuPPE0XvQLlxRdzuE8vNW8Wpj+2xyFuOYn /1fCnUX/LcOn0zUACQA0NzI4NA== X-Google-Smtp-Source: APXvYqyNg+8OlIDr5Hr5hFnNgwXQAuI+ahu2SvEr6XII+hIpaqZoSlyKPzFn5UBfI4WiO1Ahj/0G/w== X-Received: by 2002:a62:6145:: with SMTP id v66mr28539820pfb.144.1559536451549; Sun, 02 Jun 2019 21:34:11 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id e20sm11842630pfi.35.2019.06.02.21.34.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 21:34:10 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Mon, 3 Jun 2019 12:32:51 +0800 Message-Id: <20190603043251.226549-8-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 Cc: alsa-devel@alsa-project.org, Heiko Stuebner , David Airlie , dri-devel@lists.freedesktop.org, Liam Girdwood , Hans Verkuil , Andrzej Hajda , 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, Philipp Zabel , Bartlomiej Zolnierkiewicz , Russell King , Rob Herring , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , dianders@chromium.org, Mark Brown , Daniel Vetter Subject: [alsa-devel] [PATCH 7/7] ARM: dts: rockchip: Specify HDMI node to sound card node 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" X-Virus-Scanned: ClamAV using ClamSMTP Sound card needs HDMI node in order to register jack callback on HDMI notifier. Signed-off-by: Cheng-Yi Chiang --- arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi b/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi index 445270aa136e..096ba4e96db2 100644 --- a/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi +++ b/arch/arm/boot/dts/rk3288-veyron-analog-audio.dtsi @@ -14,6 +14,7 @@ rockchip,model = "VEYRON-I2S"; rockchip,i2s-controller = <&i2s>; rockchip,audio-codec = <&max98090>; + rockchip,hdmi= <&hdmi>; rockchip,hp-det-gpios = <&gpio6 RK_PA5 GPIO_ACTIVE_HIGH>; rockchip,mic-det-gpios = <&gpio6 RK_PB3 GPIO_ACTIVE_LOW>; rockchip,headset-codec = <&headsetcodec>;