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: 10972485 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 7062214DB for ; Mon, 3 Jun 2019 07:40:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CED128657 for ; Mon, 3 Jun 2019 07:40:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5142A287B1; Mon, 3 Jun 2019 07:40:51 +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 72151287A5 for ; Mon, 3 Jun 2019 07:40:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E48CD892A8; Mon, 3 Jun 2019 07:40:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id B36A4898C2 for ; Mon, 3 Jun 2019 04:33:27 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id e6so6259538pgd.9 for ; Sun, 02 Jun 2019 21:33:27 -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=2Kwlb/5SiHsOyNhbzKStBJCJEYsXKEdQeHEGccB6G4g=; b=Pnk5b677bh4rVNFvumhjTQ/0mlp/VLayVMatmxueytGSeZINCZV7tD2yF+aWL3328j OXqqfbdC0jYl3uy9zBQWsUjk31ssF/CVcmutcdqXHIq1S1eJPlXfKwtcmpDdUvRj1atF gV6IqhAeWxkjh426I4QCzKlq7MW2ic9qHSfRGCVa2Az2acs/5Ms3RGsZhHh5vun/nAdo KBy8tP+pjSaxnhd0gPvun+cpLJqdvR+N4VDIRZW3qr0N+RM9CkCm6/w49hnG+aOyXTqp NJDty+ypPXK7tFIspZW8YqUMsoPfbBW63g2O+dqjAcN46sj+aRJmoUtTQo3ghwa5bvQ8 SOKg== X-Gm-Message-State: APjAAAU95qQePcZBlJsnqejHDEAki4obgzmUuKlm+1ozXMUeEpk22Bsm yhrHbVh/81uR4p8thV8CXels7Q== 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 Subject: [PATCH 1/7] video: add HDMI state notifier support 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 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=2Kwlb/5SiHsOyNhbzKStBJCJEYsXKEdQeHEGccB6G4g=; b=P6sxjq2jhBsuLFH1QG7yv4BIJAceIkzfv21qakj+ocuLcqfruJgk8Nknotu7hXPdaC EQcrUw8uZQZtGwzDPMO+UKmcFiYcFtWe24y7eP0FnYNYU9Oeb7vNiFUhp8MUd4YT8VaQ MaqS3sJXoC3FphFKT1F25QPEx3fflQgHYxwRo= 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, Hans Verkuil , 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 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: 10972501 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 8A86314DB for ; Mon, 3 Jun 2019 07:41:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79D6328640 for ; Mon, 3 Jun 2019 07:41:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D660287A5; Mon, 3 Jun 2019 07:41:05 +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 D524528640 for ; Mon, 3 Jun 2019 07:41:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 24FFF896E4; Mon, 3 Jun 2019 07:40:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD77A89904 for ; Mon, 3 Jun 2019 04:33:36 +0000 (UTC) Received: by mail-pl1-x644.google.com with SMTP id go2so6444246plb.9 for ; Sun, 02 Jun 2019 21:33:36 -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=THpWWd94tGmQN+NdFGT3/k0LHquClB5/KK663N0sln0=; b=XNOZKXEpWUhsnFDfJMrJubOjKzeQUzvJku9mpva/vgDYrp9LZgRp1cqbDCzuKSc69W 5PSRv19p78+fcmfJb0ANUMqp4FT6WVmUMEV2CsNaIDa0DgNKgGgr+e9UPj9B3aj3MzIG OvWaUblIVpPYejGUCdnhv/HI4TzsprBNWB7z1AVOgFQpKV7oQvxF9wRqaWSVNDHJF/Rs V5UwgupV6U8YX2DoJmsvzvoN3XZTdJrpPy7cXkk/oadBGlpYzcw8PnOEpa2j/4Sdzx5p Mw18964FTxuV3lMPbu2q8i2d0EGqaBL6XiBoyAQyxJae43qRggPFd7fSQp8951UjXZQT m6mA== X-Gm-Message-State: APjAAAUL8o4iJa2XhefukKgM/2aiGW19OlMLkYc3N/P5dH12M1J9hSat wGhDPPVgwe40mfUPJxl36jhrFQ== 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 Subject: [PATCH 2/7] ASoC: hdmi-codec: use HDMI state notifier to add jack support 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 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=THpWWd94tGmQN+NdFGT3/k0LHquClB5/KK663N0sln0=; b=KJJ1x0++tPXhvMrHIIn+IkJ/vK8nkc8NHbB2D6JxfEvO7fQ7JvXfP5vQQym4cUZid7 eXWRl+urkk59DTsjUfW4h8UzpjNysutkrDV8SjNkxUyhnoYvWF9oflHr5Gj4oI4wI2dE aKzJPUU63kjAbR5g+z6/OO2IamS68nQduWMvM= 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 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: 10972503 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 F10D514DB for ; Mon, 3 Jun 2019 07:41:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E32BB286EC for ; Mon, 3 Jun 2019 07:41:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7784287A4; Mon, 3 Jun 2019 07:41:06 +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 750E228789 for ; Mon, 3 Jun 2019 07:41:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 48E1889700; Mon, 3 Jun 2019 07:40:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8299898BF for ; Mon, 3 Jun 2019 04:33:44 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id h2so4277522pgg.1 for ; Sun, 02 Jun 2019 21:33:44 -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=MaZJTXi3Kb+zP1LdC2+ckQjoA/4H+fjgGV1LvJAeRMw=; b=HJcX8p18t69fO+TyN6NB3itqQqbzV2MK3GX5moGUS8vpQVGwNTF9KaGYmMC9jzfabo saWdCuYK6rMX9b8wG9SnSQuCCnDk4+Dy9wVNv+4Ib+QywEKXUpx/FuSLilMym2V0yWQs cR/+9PmLfGN40l2kwvQLlveRTdFmnKq8JHb0gQsP2pDsLqh0JZrSFLm0J5KuzO8MWz2A cizrIWo4q/8vnf6KtIig/TTNQu+CPTraMbDPIlp4Gga/OKnuipCuZiT+FAWJAxB/eev8 UV5VDslZH3f7GaNTsEIbbAHRG713cRpJBZtTRfsVOl4KLbe8xKwxLVhQfwUEfk1s1B01 KrVA== X-Gm-Message-State: APjAAAUR8fvlr+kI+8+PQI3VAHvWKXpZBDLlzDf47f9GXWq3L0yo8VkO hDLlAJR/dbqWSmR0VmMv3Q+4+Q== 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 Subject: [PATCH 3/7] drm/bridge/synopsys: dw-hdmi: Add HDMI notifier support 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 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=MaZJTXi3Kb+zP1LdC2+ckQjoA/4H+fjgGV1LvJAeRMw=; b=kedjugWkJGjbZv4u3cVdp4XDkL/2UujV324hi4xDMTOTYbHYPbUnOtVV/E696ygI4t cYwfGz01X+eBCKlr5xigVC+q17FBxGkqMRIQmN2Tb9LkEM0x9vaOqC8GKJiYJv2aslY2 TItexnk2xcMcs/1c/Ex771hoN5UH0dq13eh48= 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 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: 10972509 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 0FEEB14DB for ; Mon, 3 Jun 2019 07:41:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 019CF288FD for ; Mon, 3 Jun 2019 07:41:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA3AF287AE; Mon, 3 Jun 2019 07:41:10 +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 77691287B1 for ; Mon, 3 Jun 2019 07:41:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 96F5B89718; Mon, 3 Jun 2019 07:40:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 924A2898C2 for ; Mon, 3 Jun 2019 04:33:51 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id r22so9813240pfh.9 for ; Sun, 02 Jun 2019 21:33:51 -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=VNhIPfCzhvP16fqORSEWqfVMPdXyoyqEWF63uuLSDrk=; b=mxhDMqRXpwiQdbKMwcXrG6vJW8CIcibGPvnKD813JQmF3xB3ZXjMCyAml1jRRcWTYX lH7981dc7mBpcLX9BPoIVVzOG3F8myrdIBYEZw+CUtQQdr5bGVqhiB8q/YQzOkQRptDV BW/A7Wwje+zfj6/UmrS4l5+lE5fEgQFB+DYz+szb0abanL1CktuWtRKtGO/y8JhH8mb9 PYBF4x3nOp9pVyzb+RAVJLTGp+qslxOgKc4dCTCMypqfrTm8IBkhf/M9tfRuwgiBYpME 5GSpmSo514wdw15fGHeqfDCF2DnF6WvOGjar+okxienz5S6FUaU3DCFJvldSfWSjfk6E OI2w== X-Gm-Message-State: APjAAAXXmKlbEWEBk0iO0/g3Vmz+QfmLTZbgWTvLnpziuJODZine6XUu XztjZvLlY7SLPq0yBJJ+BDXIaA== 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 Subject: [PATCH 4/7] ASoC: rockchip_max98090: Add dai_link for HDMI 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 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=VNhIPfCzhvP16fqORSEWqfVMPdXyoyqEWF63uuLSDrk=; b=aS63RSB2MNke62PjJpoyae9QYgwadmzCHxyo/akbQ6j0njb7Qvs1M42x05Nl+STv4N aT36WXdgX14k/02Uu5lOtg0gDcVzgC82+oI2MDXRTP2djZfNlQBgktFTbm0TIYz9LeEM UQxXP76qGTfkBpPvYmVsorx3tFk+XkOps4S8Q= 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 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: 10972507 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 8D7EE6C5 for ; Mon, 3 Jun 2019 07:41:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FABE287A5 for ; Mon, 3 Jun 2019 07:41:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73D212884B; Mon, 3 Jun 2019 07:41:09 +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 2E89D287A5 for ; Mon, 3 Jun 2019 07:41:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 491BA89709; Mon, 3 Jun 2019 07:40:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A88A898BF for ; Mon, 3 Jun 2019 04:33:58 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id t16so1000285pfe.11 for ; Sun, 02 Jun 2019 21:33:58 -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=3pFTY68CYf0vqkaIF9RkUPvim3fj+DjvxB3baTxp4Mk=; b=jdM6awCf3xMAlxUWgUMyiShW+rcCvncrbi007Rh1DxYSY5Ffp7G21lGgOr+KhP3NMR RojIrWesCo4bTCDJx663F+5TXNOcVwrOsChaiScdTE+HyKwTojwflFhpeZHMLvQjNHHf TPGZvVPGCYlDNSdYenAoFfxa3FpuDe8Sip3xJuIwRUZGE7IB7wsu+0ZC5mF/MtquFeTX X7vdHmxMCqECYVKj7aO3jz+fXsPGyIl3NblH59Aye1hlH2z6evSsL3GYOdUK7+MmAXGO zAGVVsBcGpMW0TURagsidTF+hkbTQIETTc9Manq5wIOu1xTqxKuW+2KVxpjXkAb7O3Uc kUQA== X-Gm-Message-State: APjAAAX2tr6MAaku8d07Rp54hXHtTVupc0jfCp1MHlSPjeZfbIOyj84K N+H/OHjcJ86S41LJyEgaMluO4Q== 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 Subject: [PATCH 5/7] ASoC: rockchip: rockchip-max98090: Add node for HDMI 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 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=3pFTY68CYf0vqkaIF9RkUPvim3fj+DjvxB3baTxp4Mk=; b=RQSvUzIgUKgIsNlQFm+7zwJeVC5MSGMQ7g3/DtHR16ldFiUtk0+JARXtgZwEjl9tbN 9hWW1p5DfY6fy/aBLs4Yymn5h3QUKDGbkoEPEt1I/+q7XpVzAK46qrqE/1RGqPuPtlv2 oTdErhd/k+QH1OsnOMAFqzaVQi6I8u9i9UvY8= 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 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: 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, 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: 10972483 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 E7C9714DB for ; Mon, 3 Jun 2019 07:40:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7BF02884B for ; Mon, 3 Jun 2019 07:40:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAC6F287AE; Mon, 3 Jun 2019 07:40:49 +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 834E8286D4 for ; Mon, 3 Jun 2019 07:40:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7E1589296; Mon, 3 Jun 2019 07:40:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id E97EA898C2 for ; Mon, 3 Jun 2019 04:34:11 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id n2so7505780pgp.11 for ; Sun, 02 Jun 2019 21:34:11 -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=b/qy0C/+qIVS4p/9C8coL0gczc7xGffHcCTpl84Pnik=; b=dn3mq0NCey6sOpkSyZKQTl3Zgd00GKSYTXLnyMzuhUard/6oL1/2hqhYwIpClLdBs5 zURtD7sT2WzPO6ghwi1E3j4C+3ZktxLg5N7oR+AySSBPcMaGhMi/vHsxyeVTINXS2uNP MuaQq1sKUFlDB8pi+CLFRLlxVPuAPAkAj9xflbjuqyiCiZgcpyuJH+8d+ESwNobJD9pA SXyfmyjLiE/m7iwpn7i38fk6DNb91m3YF4z+4t8kDLi7ZmjZT/IHTA65UXLGqeSQcRAO QSA0JZ4r04UcfkTmGpNltyKbKmFw9wGmWhi5bvombK/77XIUmdWRUbhN1oJPAWcKwE1t HdCQ== X-Gm-Message-State: APjAAAWWa9H1bzdYS8/ap53lmdCt5cWqvvrHrqIjueN+9ao1ferk4dg8 wQduhiA1dIbgyIfPkV8+emjx/A== 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 Subject: [PATCH 7/7] ARM: dts: rockchip: Specify HDMI node to sound card node 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 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=b/qy0C/+qIVS4p/9C8coL0gczc7xGffHcCTpl84Pnik=; b=W0HFUAGEBlitH2BpXUVE7tLd15Ng5l2TZqjITWduI3EGWRg3JKMe0MjJis9TBvMp02 4awA3xZDrtX56bGXOH5ZQ3oEimCGvzikfQPZANnHJau89l5kDDX0gPAAvlPieYi8kSIP TwDl7/UAUwCplFr2sy8k4qBf+wMfpuYAoO41w= 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 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>;