From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C694CC43218 for ; Tue, 11 Jun 2019 12:35:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7703B2089E for ; Tue, 11 Jun 2019 12:35:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="lMcsqsHd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389635AbfFKMfD (ORCPT ); Tue, 11 Jun 2019 08:35:03 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:36670 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388345AbfFKMfC (ORCPT ); Tue, 11 Jun 2019 08:35:02 -0400 Received: by mail-ed1-f66.google.com with SMTP id k21so16509725edq.3 for ; Tue, 11 Jun 2019 05:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Wv9ea3kHjJcEA5/XtR5OkO6T2tGIwfFOUhYzbpitJig=; b=lMcsqsHd6/kunk+NL3dIByz+ijuTvG4HrjFhIxDdmcEBUyVprXBwdjcB/WQU7Wgyur LupT464mVb8X+6AkUQnQ+v7kKcMPzRtp+e8U9bbdhfyPZfyAthrGHjaiO8MG7e+jX0np y4ef9i2R7lGyedbfr9xnnLvjP+XFSb0C+Ojqg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=Wv9ea3kHjJcEA5/XtR5OkO6T2tGIwfFOUhYzbpitJig=; b=K3ROYE/DkpZz6VsoYYwFvFhV0ww6CKZMXzV93btjrkoo2I2QUmQ+vpS/1d9+/tRgDw 3T7nNw7m5zbDemt355DSMVKUzsFpx9arovM8n0nYJ9K4//gmyxATWjbkPFDRjkEm57UI aFmJRIba/oNsVIxnmdPhhOVNP5soTiPxGoMcBVB464E5gTuZzjVmHA5ILu+4WNSWOEvW jH75j3Bxut/bBRQnKMBwbK5YR96N4PaXx759PTZHwS3wbzOFqUmrya8s+aBQbiU+SDxA palref1ZHr26zeMa4ODLAEjrqoTl33KMRG/GhePSu/+U4vB/BT9E6AWDNvSu2QTODS0V 0TQQ== X-Gm-Message-State: APjAAAUzv3OKSELqROZj07oZG2JRqEewKA1LAKztt/CSfLmzru/DYqIE rb/zMTEidRDKvAGG92u7oxCV4A== X-Google-Smtp-Source: APXvYqy1NjR8fIJd9daXqPCAqSZQkpYHir9meKQZkHcnUZMfPQL5Fo2hXSl6J6EZ+NXWFH5WuqrBqA== X-Received: by 2002:a50:8d84:: with SMTP id r4mr81164068edh.48.1560256499249; Tue, 11 Jun 2019 05:34:59 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id i2sm3658218edg.81.2019.06.11.05.34.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 11 Jun 2019 05:34:58 -0700 (PDT) Date: Tue, 11 Jun 2019 14:34:55 +0200 From: Daniel Vetter To: Cheng-yi Chiang Cc: Hans Verkuil , linux-kernel , Bartlomiej Zolnierkiewicz , Greg Kroah-Hartman , Philipp Zabel , Mark Brown , Liam Girdwood , Takashi Iwai , Jaroslav Kysela , Russell King , Andrzej Hajda , Laurent Pinchart , David Airlie , Rob Herring , Heiko Stuebner , Doug Anderson , Dylan Reid , tzungbi@chromium.org, linux-media@vger.kernel.org, "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, Dariusz Marcinkiewicz , Daniel Vetter Subject: Re: [PATCH 1/7] video: add HDMI state notifier support Message-ID: <20190611123455.GD2458@phenom.ffwll.local> Mail-Followup-To: Cheng-yi Chiang , Hans Verkuil , linux-kernel , Bartlomiej Zolnierkiewicz , Greg Kroah-Hartman , Philipp Zabel , Mark Brown , Liam Girdwood , Takashi Iwai , Jaroslav Kysela , Russell King , Andrzej Hajda , Laurent Pinchart , David Airlie , Rob Herring , Heiko Stuebner , Doug Anderson , Dylan Reid , tzungbi@chromium.org, linux-media@vger.kernel.org, "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, Dariusz Marcinkiewicz References: <20190603043251.226549-1-cychiang@chromium.org> <20190603043251.226549-2-cychiang@chromium.org> <41e7052b-a58c-5a8c-5d94-37237e0c2070@xs4all.nl> <20190603080931.GG21222@phenom.ffwll.local> <20190604072411.GP21222@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 4.14.0-3-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 11, 2019 at 08:10:38PM +0800, Cheng-yi Chiang wrote: > On Tue, Jun 4, 2019 at 3:24 PM Daniel Vetter wrote: > > > > On Tue, Jun 04, 2019 at 10:32:50AM +0800, Cheng-yi Chiang wrote: > > > On Mon, Jun 3, 2019 at 4:09 PM Daniel Vetter wrote: > > > > > > > > On Mon, Jun 03, 2019 at 09:45:49AM +0200, Hans Verkuil wrote: > > > > > On 6/3/19 6:32 AM, Cheng-Yi Chiang wrote: > > > > > > 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/ > > > > > > > > > > Erm, you are aware that this patch morphed into a CEC-specific notifier > > > > > found in drivers/media/cec/cec-notifier.c? > > > > > > > > > > I don't think it makes sense to have two notifier implementations in the kernel. > > > > > The original intention was to have the notifier deal with both CEC and ASoC > > > > > notifications, but there was not enough interest for the ASoC bits at the time > > > > > and it was dropped. > > > > > > > > > > I am planning changes to the cec-notifier API, I hope to work on that this > > > > > week. I'll CC you when I post those. Those might be a good starting point > > > > > to convert the cec-notifier to an hdmi-notifier as was originally intended. > > > > > > > > > > I've added your colleague Dariusz Marcinkiewicz to the CC list since he's been > > > > > working on some nice cec-notifier improvements as well. > > > > > > > > We also have some interfaces for drm/alsa interactions around hdmi > > > > already in drm/drm_audio_component.h, but it's not used by anything > > > > outside of i915. Imo we should extend that, not reinvent a new wheel. > > > > > > > Hi Daniel, > > > Thank you for the pointer. Looking at the ops, it seems that it is > > > specific to HDA. > > > I am not familiar with drm and HDA. I am not sure how applicable it > > > would be to report jack status to ASoC. > > > There is a use case in sound/soc/codecs/hdac_hdmi.c though so it > > > should be possible. > > > > Currently hda is the only user, but the idea was to make it more generic. > > Jack status in alsa is what drm calls connector status btw. > > > > So if we can take that as a baseline and extend it (probably needs some > > registration boilerplate and helpers to look up the right endpoint using > > of/dt for soc systems, we use component.c in i915/hda for this), that > > would be great I think. > > > > > > Another note: notifiers considered evil, imo. Gets the job done for one > > > > case, as soon as you have multiple devices and need to make sure you get > > > > the update for the right one it all comes crashing down. Please create an > > > > api which registers for updates from a specific device only, plus > > > > something that has real callbacks (like the drm_audio_component.h thing we > > > > started already). > > > > > > To clarify a bit, this hdmi-notifier indeed supports updating from a > > > specific device only. > > > hdmi_notifier_get takes a device and return the notifier. > > > > Hm I missed that, I thought it's global, so one of my usual notifier > > concerns addressed. > > > > > It seems that a major difference between drm_audio_components and > > > hdmi-notifier is that > > > drm_audio_components defines all supported ops in drm_audio_component_audio_ops. > > > On the other hand, hdmi-notifier passes different events using an enum > > > like HDMI_CONNECTED and let listener handle different events. > > > In this regard I agree with you that drm_audio_component is cleaner. > > > Anyway, I will look into it a bit more and see how it works. > > > > Yeah I think if we could combine the approach, i.e. notifier side for > > registration, some _ops structure for the actual notifications, then > > there's a solid interface. I just really don't like the opaque void * > > interface notifier provides, it encourages abuse way too much. > > > > Ofc the registration side would then no longer be based on the notifier > > datastructure, list_head (like cec-notifier.c) of registeres devices with > > their _ops structure should be enough. > > -Daniel > > Hi Daniel, > Yes, I agree the above statement that we should have a more solid interface. > > Hi Hans, > I am not sure if I missed the patch. > Do you have a estimated timeline for new cec-notifier interface you > are working on? > It seems that your PoC patch needs Dariusz's patch to work. > I would like to seek your advice on whether I can proceed without your > patch and Dariusz's patch. > > I looked through the patch from Dariusz > > https://lkml.org/lkml/2019/5/21/389 > > , and saw that you were thinking whether we should use cec-notifier > for both HDMI and CEC. > > https://lkml.org/lkml/2019/5/24/298 > > Could you please let me know your latest thought on whether we should > reuse cec-notifier? Nah, see later in that thread, I think cec and audio seem to be different use-cases. But definitely a good idea to sync with Dariusz, I forgot to pull the two threads together. Thanks for doing that. > I agree with you that I should not proceed with hdmi-notifier. Reasons include: > 1. Method like cec_notifier_parse_hdmi_phandle can be reused. It is > error prone to memory leak if it is implemented by user, like the > patch in hdmi-codec.c in this series did not handle the ref count. > 2. cec-notifier has a simpler implementation of register / unregister > because there is no call chain. I am not aware of the need for > hdmi-notifier to support a chain of callbacks. So I think that call > chain support can be removed. > > If I go ahead and add a new interface to register ops to handle > connector status report from cec-notifer, based on current > cec-notifier, do you think that would work ? > I think it might work if I add another cec_notifier object inside > dw-hdmi.c, but only for HDMI jack reporting, not for CEC related > reporting. > > And after some investigation, I realize that my requirement is even > simpler. I don't need hdmi_event_new_edid and hdmi_event_new_eld in my > use case. Yeah, connector status is how we started with the drm/alsa interface in i915 too, but later on had to extend it. I think eventually we'll need it all, that's why I suggested to use that as the interface between drm and alsa side, but augmented with some register/unregister and bind logic. > I just need to report the connector status from synopsys/dw-hdmi.c to > codecs/hdmi-codec.c for codec driver to update the jack status. > Do you think I can proceed in this direction ? Or do you prefer I wait > for a while and work on it based on your new patch. I think most important part here is that we sync across all the different people pushing for better drm/alsa integration. What the solution looks like in the end doesn't matter much imo, as long as we don't end up with 3 different things :-) Cheers, Daniel > > Thanks a lot! > > > > > > > > > > Thanks again! > > > > > > > -Daniel > > > > > > > > > > > > > > Regards, > > > > > > > > > > Hans > > > > > > > > > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > -- > > > > Daniel Vetter > > > > Software Engineer, Intel Corporation > > > > http://blog.ffwll.ch > > > > -- > > Daniel Vetter > > Software Engineer, Intel Corporation > > http://blog.ffwll.ch -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH 1/7] video: add HDMI state notifier support Date: Tue, 11 Jun 2019 14:34:55 +0200 Message-ID: <20190611123455.GD2458@phenom.ffwll.local> References: <20190603043251.226549-1-cychiang@chromium.org> <20190603043251.226549-2-cychiang@chromium.org> <41e7052b-a58c-5a8c-5d94-37237e0c2070@xs4all.nl> <20190603080931.GG21222@phenom.ffwll.local> <20190604072411.GP21222@phenom.ffwll.local> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Cheng-yi Chiang Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Liam Girdwood , David Airlie , dri-devel@lists.freedesktop.org, Takashi Iwai , Hans Verkuil , Laurent Pinchart , linux-rockchip@lists.infradead.org, Dylan Reid , 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 , Doug Anderson , linux-kernel , Mark Brown , Dariusz Marcinkiewicz List-Id: devicetree@vger.kernel.org T24gVHVlLCBKdW4gMTEsIDIwMTkgYXQgMDg6MTA6MzhQTSArMDgwMCwgQ2hlbmcteWkgQ2hpYW5n IHdyb3RlOgo+IE9uIFR1ZSwgSnVuIDQsIDIwMTkgYXQgMzoyNCBQTSBEYW5pZWwgVmV0dGVyIDxk YW5pZWxAZmZ3bGwuY2g+IHdyb3RlOgo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G9yYXRpb24KaHR0cDovL2Jsb2cuZmZ3bGwuY2gKX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVsIG1haWxpbmcgbGlzdApkcmktZGV2 ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlzdHMuZnJlZWRlc2t0b3Aub3JnL21h aWxtYW4vbGlzdGluZm8vZHJpLWRldmVs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0BF7C43218 for ; Tue, 11 Jun 2019 12:35:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 718C420673 for ; Tue, 11 Jun 2019 12:35:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sXQogp2J"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="lMcsqsHd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 718C420673 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Sf+CFKcB0BO0BiRGgRZkhq7dcdyJo5uB0tUHwdUoWnM=; b=sXQogp2JBcLwM7 2s6RFcgciEgcHN0QjC470OoUInnvbx07KZTutAY38gY1og3srtNnJmIH1yc0N6kg5u0ScAOz9Y2h4 fQ3j1q4xVwlTrwp2/UPEbIwwkBi4znvlS7vsQ3sfLpLtU3GbJ79K5dxtY3G55oNqz2sBeJqU4sSAt 69Bpk+7CwzL/L45pudsnVUo6JhJ0U/OtlKlsJH1gWQnyBrjRSWNz/ekXWEhZgth/5q7ogvCP94CLo OUCos4qnZVXKuXdOv4zNm3gNksLsKHs8sSDFb6FP/zftH9yajbQlJ3tMXHvZMhKh8fDd4j/LgO+hz Kf1TebgedWVCkAvj85kg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hafza-0002HU-Kb; Tue, 11 Jun 2019 12:35:10 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hafzR-0001BB-2c for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2019 12:35:07 +0000 Received: by mail-ed1-x542.google.com with SMTP id h9so19879365edr.0 for ; Tue, 11 Jun 2019 05:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Wv9ea3kHjJcEA5/XtR5OkO6T2tGIwfFOUhYzbpitJig=; b=lMcsqsHd6/kunk+NL3dIByz+ijuTvG4HrjFhIxDdmcEBUyVprXBwdjcB/WQU7Wgyur LupT464mVb8X+6AkUQnQ+v7kKcMPzRtp+e8U9bbdhfyPZfyAthrGHjaiO8MG7e+jX0np y4ef9i2R7lGyedbfr9xnnLvjP+XFSb0C+Ojqg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=Wv9ea3kHjJcEA5/XtR5OkO6T2tGIwfFOUhYzbpitJig=; b=NIcmpiOU4Q1IOz+93SM2yyH3EN78tZ3dGUIAwm/8EbeiSoVf8f3d9obtlTTZ2ixglV xW3dAs0a0X5v6HCVGSrQlU0+74z9y5zZ1+PEkdUFMsFIPkopjTMkxMvimuAQUpAxUJxg KVqvpi3kRSi+X/ITjNGIvMIzG6lgiM64fDyb66Wq2gSof8di19glMEtKcWdQDF9ervVy f9gNHYED9legFZIaOIWEW34brXf8V5WXB+6bciIpZ87dZFDnAqyPCOGUtCw1WsY7eygy KU12PBA+9ycfelSiacD0zue4UYJ4Tc+ZcECnCOnO81AbI8MGKmyseK9cfmuSpzqx1j3U mQlg== X-Gm-Message-State: APjAAAXsUeW9PYf1WhG9TiGsKX6GRw2dk/sNAe1nh9f+PP0VBfMq7OUh G2RmozUCAYiOr8+qTYwmFkc0YQ== X-Google-Smtp-Source: APXvYqy1NjR8fIJd9daXqPCAqSZQkpYHir9meKQZkHcnUZMfPQL5Fo2hXSl6J6EZ+NXWFH5WuqrBqA== X-Received: by 2002:a50:8d84:: with SMTP id r4mr81164068edh.48.1560256499249; Tue, 11 Jun 2019 05:34:59 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id i2sm3658218edg.81.2019.06.11.05.34.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 11 Jun 2019 05:34:58 -0700 (PDT) Date: Tue, 11 Jun 2019 14:34:55 +0200 From: Daniel Vetter To: Cheng-yi Chiang Subject: Re: [PATCH 1/7] video: add HDMI state notifier support Message-ID: <20190611123455.GD2458@phenom.ffwll.local> Mail-Followup-To: Cheng-yi Chiang , Hans Verkuil , linux-kernel , Bartlomiej Zolnierkiewicz , Greg Kroah-Hartman , Philipp Zabel , Mark Brown , Liam Girdwood , Takashi Iwai , Jaroslav Kysela , Russell King , Andrzej Hajda , Laurent Pinchart , David Airlie , Rob Herring , Heiko Stuebner , Doug Anderson , Dylan Reid , tzungbi@chromium.org, linux-media@vger.kernel.org, "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, Dariusz Marcinkiewicz References: <20190603043251.226549-1-cychiang@chromium.org> <20190603043251.226549-2-cychiang@chromium.org> <41e7052b-a58c-5a8c-5d94-37237e0c2070@xs4all.nl> <20190603080931.GG21222@phenom.ffwll.local> <20190604072411.GP21222@phenom.ffwll.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 4.14.0-3-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190611_053503_583179_D269FB3B X-CRM114-Status: GOOD ( 57.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , Heiko Stuebner , Liam Girdwood , David Airlie , dri-devel@lists.freedesktop.org, Takashi Iwai , Hans Verkuil , Andrzej Hajda , Laurent Pinchart , linux-rockchip@lists.infradead.org, Dylan Reid , linux-media@vger.kernel.org, devicetree@vger.kernel.org, tzungbi@chromium.org, Daniel Vetter , Bartlomiej Zolnierkiewicz , Russell King , Rob Herring , Jaroslav Kysela , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , Doug Anderson , linux-kernel , Mark Brown , Philipp Zabel , Dariusz Marcinkiewicz Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 11, 2019 at 08:10:38PM +0800, Cheng-yi Chiang wrote: > On Tue, Jun 4, 2019 at 3:24 PM Daniel Vetter wrote: > > > > On Tue, Jun 04, 2019 at 10:32:50AM +0800, Cheng-yi Chiang wrote: > > > On Mon, Jun 3, 2019 at 4:09 PM Daniel Vetter wrote: > > > > > > > > On Mon, Jun 03, 2019 at 09:45:49AM +0200, Hans Verkuil wrote: > > > > > On 6/3/19 6:32 AM, Cheng-Yi Chiang wrote: > > > > > > 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/ > > > > > > > > > > Erm, you are aware that this patch morphed into a CEC-specific notifier > > > > > found in drivers/media/cec/cec-notifier.c? > > > > > > > > > > I don't think it makes sense to have two notifier implementations in the kernel. > > > > > The original intention was to have the notifier deal with both CEC and ASoC > > > > > notifications, but there was not enough interest for the ASoC bits at the time > > > > > and it was dropped. > > > > > > > > > > I am planning changes to the cec-notifier API, I hope to work on that this > > > > > week. I'll CC you when I post those. Those might be a good starting point > > > > > to convert the cec-notifier to an hdmi-notifier as was originally intended. > > > > > > > > > > I've added your colleague Dariusz Marcinkiewicz to the CC list since he's been > > > > > working on some nice cec-notifier improvements as well. > > > > > > > > We also have some interfaces for drm/alsa interactions around hdmi > > > > already in drm/drm_audio_component.h, but it's not used by anything > > > > outside of i915. Imo we should extend that, not reinvent a new wheel. > > > > > > > Hi Daniel, > > > Thank you for the pointer. Looking at the ops, it seems that it is > > > specific to HDA. > > > I am not familiar with drm and HDA. I am not sure how applicable it > > > would be to report jack status to ASoC. > > > There is a use case in sound/soc/codecs/hdac_hdmi.c though so it > > > should be possible. > > > > Currently hda is the only user, but the idea was to make it more generic. > > Jack status in alsa is what drm calls connector status btw. > > > > So if we can take that as a baseline and extend it (probably needs some > > registration boilerplate and helpers to look up the right endpoint using > > of/dt for soc systems, we use component.c in i915/hda for this), that > > would be great I think. > > > > > > Another note: notifiers considered evil, imo. Gets the job done for one > > > > case, as soon as you have multiple devices and need to make sure you get > > > > the update for the right one it all comes crashing down. Please create an > > > > api which registers for updates from a specific device only, plus > > > > something that has real callbacks (like the drm_audio_component.h thing we > > > > started already). > > > > > > To clarify a bit, this hdmi-notifier indeed supports updating from a > > > specific device only. > > > hdmi_notifier_get takes a device and return the notifier. > > > > Hm I missed that, I thought it's global, so one of my usual notifier > > concerns addressed. > > > > > It seems that a major difference between drm_audio_components and > > > hdmi-notifier is that > > > drm_audio_components defines all supported ops in drm_audio_component_audio_ops. > > > On the other hand, hdmi-notifier passes different events using an enum > > > like HDMI_CONNECTED and let listener handle different events. > > > In this regard I agree with you that drm_audio_component is cleaner. > > > Anyway, I will look into it a bit more and see how it works. > > > > Yeah I think if we could combine the approach, i.e. notifier side for > > registration, some _ops structure for the actual notifications, then > > there's a solid interface. I just really don't like the opaque void * > > interface notifier provides, it encourages abuse way too much. > > > > Ofc the registration side would then no longer be based on the notifier > > datastructure, list_head (like cec-notifier.c) of registeres devices with > > their _ops structure should be enough. > > -Daniel > > Hi Daniel, > Yes, I agree the above statement that we should have a more solid interface. > > Hi Hans, > I am not sure if I missed the patch. > Do you have a estimated timeline for new cec-notifier interface you > are working on? > It seems that your PoC patch needs Dariusz's patch to work. > I would like to seek your advice on whether I can proceed without your > patch and Dariusz's patch. > > I looked through the patch from Dariusz > > https://lkml.org/lkml/2019/5/21/389 > > , and saw that you were thinking whether we should use cec-notifier > for both HDMI and CEC. > > https://lkml.org/lkml/2019/5/24/298 > > Could you please let me know your latest thought on whether we should > reuse cec-notifier? Nah, see later in that thread, I think cec and audio seem to be different use-cases. But definitely a good idea to sync with Dariusz, I forgot to pull the two threads together. Thanks for doing that. > I agree with you that I should not proceed with hdmi-notifier. Reasons include: > 1. Method like cec_notifier_parse_hdmi_phandle can be reused. It is > error prone to memory leak if it is implemented by user, like the > patch in hdmi-codec.c in this series did not handle the ref count. > 2. cec-notifier has a simpler implementation of register / unregister > because there is no call chain. I am not aware of the need for > hdmi-notifier to support a chain of callbacks. So I think that call > chain support can be removed. > > If I go ahead and add a new interface to register ops to handle > connector status report from cec-notifer, based on current > cec-notifier, do you think that would work ? > I think it might work if I add another cec_notifier object inside > dw-hdmi.c, but only for HDMI jack reporting, not for CEC related > reporting. > > And after some investigation, I realize that my requirement is even > simpler. I don't need hdmi_event_new_edid and hdmi_event_new_eld in my > use case. Yeah, connector status is how we started with the drm/alsa interface in i915 too, but later on had to extend it. I think eventually we'll need it all, that's why I suggested to use that as the interface between drm and alsa side, but augmented with some register/unregister and bind logic. > I just need to report the connector status from synopsys/dw-hdmi.c to > codecs/hdmi-codec.c for codec driver to update the jack status. > Do you think I can proceed in this direction ? Or do you prefer I wait > for a while and work on it based on your new patch. I think most important part here is that we sync across all the different people pushing for better drm/alsa integration. What the solution looks like in the end doesn't matter much imo, as long as we don't end up with 3 different things :-) Cheers, Daniel > > Thanks a lot! > > > > > > > > > > Thanks again! > > > > > > > -Daniel > > > > > > > > > > > > > > Regards, > > > > > > > > > > Hans > > > > > > > > > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > -- > > > > Daniel Vetter > > > > Software Engineer, Intel Corporation > > > > http://blog.ffwll.ch > > > > -- > > Daniel Vetter > > Software Engineer, Intel Corporation > > http://blog.ffwll.ch -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel