Message ID | 20231031-kms-hdmi-connector-state-v3-12-328b0fae43a7@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp373734vqg; Tue, 31 Oct 2023 09:51:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFshISti68U/Mm99YMhD4MlY0XbU09nNuukkNbFteUMG5NCU+bYhzOUBs0ubsznDyMzo15v X-Received: by 2002:a17:902:f990:b0:1cc:1ee2:d41d with SMTP id ky16-20020a170902f99000b001cc1ee2d41dmr9221968plb.39.1698771060589; Tue, 31 Oct 2023 09:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698771060; cv=none; d=google.com; s=arc-20160816; b=epAk2nRdwkCaN4pu0DrrETuoQDVDoJ7SxAZJBjpPK7qjgyjO9jr2APyda8Z94DPQdI 82AY40GuSB2nQpdZl0nHNxC188baij/FJzPr01ShsDU4LQvMeQeuDo4bEL5+QqDoKe7B xLFJNQjfl/ng9mkc4lEBnV9YEu7U1c2BsWEbP24yW3dBJ4pHSQ3JNYO5ZOD8AZMzmhFy YSYJsIDkRV5HDi5hKiFAxtH7HQr4aEgNrAOciFkwdeorX4xVMrWvanh5SIvbozv9C59I isKUNv9OagElycfH/xNWfmLk7apll0r5AjhHVeLuOAfcqIS4+nquoQNci6beI2p9Sdmb yndg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=G2PLDMNDUp6+9Cx0oKFbV1U5FfZoO/YziUYPDfpBk6s=; fh=e6/uyeFf2k7v8JUtB6fPyaAS5iN3eSA1hjtg35V2Rzw=; b=Zbc69MzXIWxSOm0I9IkP11V+VWUGmIcXpPqTWK3Znxi87mbFX79/+pZHYstB5Yhw/T R02efzEs84R5fP+CITtU5jMckz1k4ALqLVKkXkr1fZMfRPIWa1JXggCS1dPDREo5zDIH bplt/DMW3UWNB2jEDqv75zHPgoiSbsdDRc8zk9uO3Z8wda85vMipzKAm74Cwkcoj83ye cPWxDax9T01pg+38pcrRMzId1NvL4aoB1mdM0jxNngajFHFmYGSelHoxncANpBRAzKyw hXAPCO4IBlnjIkwJcdATwWCJ3yXgVqAnyuiRj6BdxrUA8asCVrK7i/mQkHCgr+DqrN/w 0VKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=foPiBi5t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id y18-20020a63ce12000000b00578bd92e502si1185486pgf.558.2023.10.31.09.51.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:51:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=foPiBi5t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A0AEE8044384; Tue, 31 Oct 2023 09:50:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346905AbjJaQti (ORCPT <rfc822;chrisjones.unixmen@gmail.com> + 33 others); Tue, 31 Oct 2023 12:49:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346511AbjJaQtL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 31 Oct 2023 12:49:11 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 873CFA2; Tue, 31 Oct 2023 09:49:09 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3B26C433C9; Tue, 31 Oct 2023 16:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698770949; bh=BW2baC+EjniG/ZZH9QzIRlNDubJbbQk6ybbnPB50Z5U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=foPiBi5tPK2qTQLqdUEbrq5fITRnjIv79P//Y6PBhDgB8bRdvMO7XMWaLyEEIHMQk N4vRb7dx/NnkKE0WNCXQt3J38y0RrIJjEF2RGnuA3d4+uatLVBdnsLrnczbY7OIGn9 SS9br04QPi18yqrSp+Rn/0UBCMvLuZ56wSoNEa6TL7XgPQKZIkFG2Jlorp4GAM6kMh bNOoOP9VTQdB6Tp6eL2V/9lhCj0OcEual2DEgThYaEWcXgAiXwcYmdrqtfvxD4jEsP zz8HzlZ2TkzTFdFlnZVAGGuG58mDsOIzsG2IFdj6Zu2qgCAW4ppLRqa3OHbNa/+YBa Rf2jo6iP5sw0g== From: Maxime Ripard <mripard@kernel.org> Date: Tue, 31 Oct 2023 17:48:25 +0100 Subject: [PATCH RFC v3 12/37] drm/connector: hdmi: Create Infoframe DebugFS entries MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231031-kms-hdmi-connector-state-v3-12-328b0fae43a7@kernel.org> References: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@kernel.org> In-Reply-To: <20231031-kms-hdmi-connector-state-v3-0-328b0fae43a7@kernel.org> To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Emma Anholt <emma@anholt.net>, Jonathan Corbet <corbet@lwn.net>, Sandy Huang <hjc@rock-chips.com>, =?utf-8?q?Heiko_St=C3=BCbner?= <heiko@sntech.de>, Chen-Yu Tsai <wens@csie.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org> Cc: Hans Verkuil <hverkuil@xs4all.nl>, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Maxime Ripard <mripard@kernel.org> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4166; i=mripard@kernel.org; h=from:subject:message-id; bh=BW2baC+EjniG/ZZH9QzIRlNDubJbbQk6ybbnPB50Z5U=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmO+ve+vV6x5PiqefFl2psNJZjdl/C2hqwUFLyj5dj9y 7J6Wc31jlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAEzESpaRYZ+U+WkrMZfiadnm cdY7Z0ouXCNfaLtWrYH7qGxJwPlJVYwM986vumbxYAaPnvt7hh2L67p7y59VSNxr2rLOpNDHMlC WCQA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:50:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781290563293645231 X-GMAIL-MSGID: 1781290563293645231 |
Series |
drm/connector: Create HDMI Connector infrastructure
|
|
Commit Message
Maxime Ripard
Oct. 31, 2023, 4:48 p.m. UTC
There has been some discussions recently about the infoframes sent by
drivers and if they were properly generated.
In parallel, there's been some interest in creating an infoframe-decode
tool similar to edid-decode.
Both would be much easier if we were to expose the infoframes programmed
in the hardware. It won't be perfect since we have no guarantee that
it's actually what goes through the wire, but it's the best we can do.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/gpu/drm/drm_debugfs.c | 110 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
Comments
Hi Maxime, Thank you for posting v3, this time it runs fine on my RPi 4, thank you for fixing that. I'll start working on a conformity checker for this. I have a few remarks: On 31/10/2023 17:48, Maxime Ripard wrote: > There has been some discussions recently about the infoframes sent by > drivers and if they were properly generated. > > In parallel, there's been some interest in creating an infoframe-decode > tool similar to edid-decode. > > Both would be much easier if we were to expose the infoframes programmed > in the hardware. It won't be perfect since we have no guarantee that > it's actually what goes through the wire, but it's the best we can do. > > Signed-off-by: Maxime Ripard <mripard@kernel.org> > --- > drivers/gpu/drm/drm_debugfs.c | 110 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 110 insertions(+) > > diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c > index 2de43ff3ce0a..3c65b1d3f926 100644 > --- a/drivers/gpu/drm/drm_debugfs.c > +++ b/drivers/gpu/drm/drm_debugfs.c > @@ -538,6 +538,114 @@ static const struct file_operations drm_connector_fops = { > .write = connector_write > }; > > +struct debugfs_wrapper { > + struct drm_connector *connector; > + struct drm_connector_hdmi_infoframe *frame; > +}; > + > +#define HDMI_MAX_INFOFRAME_SIZE 29 > + > +static ssize_t > +infoframe_read(struct file *filp, char __user *ubuf, size_t count, loff_t *ppos) > +{ > + const struct debugfs_wrapper *wrapper = filp->private_data; > + struct drm_connector *connector = wrapper->connector; > + struct drm_connector_hdmi_infoframe *infoframe = wrapper->frame; > + union hdmi_infoframe *frame = &infoframe->data; > + u8 buf[HDMI_MAX_INFOFRAME_SIZE]; > + ssize_t len = 0; > + > + mutex_lock(&connector->hdmi.infoframes.lock); > + > + if (!infoframe->set) > + goto out; > + > + len = hdmi_infoframe_pack(frame, buf, sizeof(buf)); > + if (len < 0) > + goto out; > + > + len = simple_read_from_buffer(ubuf, count, ppos, buf, len); > + > +out: > + mutex_unlock(&connector->hdmi.infoframes.lock); > + return len; > +} > + > +static const struct file_operations infoframe_fops = { > + .owner = THIS_MODULE, > + .open = simple_open, > + .read = infoframe_read, > +}; > + > +static int create_hdmi_infoframe_file(struct drm_connector *connector, > + struct dentry *parent, > + const char *filename, > + struct drm_connector_hdmi_infoframe *frame) > +{ > + struct drm_device *dev = connector->dev; > + struct debugfs_wrapper *wrapper; > + struct dentry *file; > + > + wrapper = drmm_kzalloc(dev, sizeof(*wrapper), GFP_KERNEL); > + if (!wrapper) > + return -ENOMEM; > + > + wrapper->connector = connector; > + wrapper->frame = frame; > + > + file = debugfs_create_file(filename, 0400, parent, wrapper, &infoframe_fops); > + if (IS_ERR(file)) > + return PTR_ERR(file); > + > + return 0; > +} > + > +#define CREATE_HDMI_INFOFRAME_FILE(c, p, i) \ > + create_hdmi_infoframe_file(c, p, #i, &(c)->hdmi.infoframes.i) > + > +static int create_hdmi_infoframe_files(struct drm_connector *connector, > + struct dentry *parent) > +{ > + int ret; > + > + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, audio); > + if (ret) > + return ret; > + > + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, avi); > + if (ret) > + return ret; > + > + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, drm); Hmm, I had to look into the code to figure out that 'drm' stands for Dynamic Range and Mastering InfoFrame. While entirely correct, it is also very confusing in the context of the 'drm' subsystem. I am not quite certain what the best approach is here. Internally in the drm code it is talking about 'hdr' or 'hdr metadata', but that's a bit confusing as well since there is also an HDR Dynamic Metadata Extended InfoFrame defined in CTA-861, even though support for that is not (yet) implemented in drm. At minimum there should be a comment in the code explaining what drm stands for in this context. One option to consider is renaming this file to hdr_drm, thus indicating that this is HDR related. > + if (ret) > + return ret; > + > + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, spd); > + if (ret) > + return ret; > + > + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, vendor); There may be multiple vendor specific InfoFrames in the future, so how would that be handled? Perhaps add a comment here that currently only one vendor specific InfoFrame is supported, but suggest how to handle multiple VSIFs in the future. What would actually be nice (although probably not that easy to fix) is if the name of the file would be "vendor-XXXXXX' where 'XXXXXX' is the IEEE OUI number. Regards, Hans > + if (ret) > + return ret; > + > + return 0; > +} > + > +static void hdmi_debugfs_add(struct drm_connector *connector) > +{ > + struct dentry *dir; > + > + if (!(connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || > + connector->connector_type == DRM_MODE_CONNECTOR_HDMIB)) > + return; > + > + dir = debugfs_create_dir("infoframes", connector->debugfs_entry); > + if (IS_ERR(dir)) > + return; > + > + create_hdmi_infoframe_files(connector, dir); > +} > + > void drm_debugfs_connector_add(struct drm_connector *connector) > { > struct drm_minor *minor = connector->dev->primary; > @@ -565,6 +673,8 @@ void drm_debugfs_connector_add(struct drm_connector *connector) > debugfs_create_file("output_bpc", 0444, root, connector, > &output_bpc_fops); > > + hdmi_debugfs_add(connector); > + > if (connector->funcs->debugfs_init) > connector->funcs->debugfs_init(connector, root); > } >
Hi Hans, On Fri, Nov 03, 2023 at 10:05:18AM +0100, Hans Verkuil wrote: > Hi Maxime, > > Thank you for posting v3, this time it runs fine on my RPi 4, thank you for > fixing that. > > I'll start working on a conformity checker for this. Awesome :) > > +static int create_hdmi_infoframe_files(struct drm_connector *connector, > > + struct dentry *parent) > > +{ > > + int ret; > > + > > + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, audio); > > + if (ret) > > + return ret; > > + > > + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, avi); > > + if (ret) > > + return ret; > > + > > + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, drm); > > Hmm, I had to look into the code to figure out that 'drm' stands for > Dynamic Range and Mastering InfoFrame. While entirely correct, it is > also very confusing in the context of the 'drm' subsystem. > > I am not quite certain what the best approach is here. > > Internally in the drm code it is talking about 'hdr' or 'hdr metadata', > but that's a bit confusing as well since there is also an HDR Dynamic > Metadata Extended InfoFrame defined in CTA-861, even though support for > that is not (yet) implemented in drm. > > At minimum there should be a comment in the code explaining what drm > stands for in this context. > > One option to consider is renaming this file to hdr_drm, thus indicating > that this is HDR related. I ended up doing both, thanks for the suggestion > > + if (ret) > > + return ret; > > + > > + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, spd); > > + if (ret) > > + return ret; > > + > > + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, vendor); > > There may be multiple vendor specific InfoFrames in the future, so how > would that be handled? Perhaps add a comment here that currently only one > vendor specific InfoFrame is supported, but suggest how to handle multiple > VSIFs in the future. > > What would actually be nice (although probably not that easy to fix) is if > the name of the file would be "vendor-XXXXXX' where 'XXXXXX' is the IEEE OUI > number. I guess it's not entirely clear to me what that would look like. In order for the framework to create the debugfs files, we would need some enumeration mechanism (probably through a callback?), and then the driver would generate the entire content of that file. Which makes me question whether the framework should be initialised at all? Maybe the simpler would be to just have drivers maintain their own debugfs files and storing the content in their own, private, structure. Maxime
On 06/11/2023 15:44, Maxime Ripard wrote: > Hi Hans, > > On Fri, Nov 03, 2023 at 10:05:18AM +0100, Hans Verkuil wrote: >> Hi Maxime, >> >> Thank you for posting v3, this time it runs fine on my RPi 4, thank you for >> fixing that. >> >> I'll start working on a conformity checker for this. > > Awesome :) And anyone who is interested can find the work-in-progress for that here: git://linuxtv.org/hverkuil/edid-decode.git Use the -I option to point to the file containing the infoframe to parse it. Later it will also check the conformity of the infoframe against the display's EDID. That's why this is part of edid-decode since you need an EDID parser to verify if the InfoFrames are also conform the standards. > >>> +static int create_hdmi_infoframe_files(struct drm_connector *connector, >>> + struct dentry *parent) >>> +{ >>> + int ret; >>> + >>> + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, audio); >>> + if (ret) >>> + return ret; >>> + >>> + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, avi); >>> + if (ret) >>> + return ret; >>> + >>> + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, drm); >> >> Hmm, I had to look into the code to figure out that 'drm' stands for >> Dynamic Range and Mastering InfoFrame. While entirely correct, it is >> also very confusing in the context of the 'drm' subsystem. >> >> I am not quite certain what the best approach is here. >> >> Internally in the drm code it is talking about 'hdr' or 'hdr metadata', >> but that's a bit confusing as well since there is also an HDR Dynamic >> Metadata Extended InfoFrame defined in CTA-861, even though support for >> that is not (yet) implemented in drm. >> >> At minimum there should be a comment in the code explaining what drm >> stands for in this context. >> >> One option to consider is renaming this file to hdr_drm, thus indicating >> that this is HDR related. > > I ended up doing both, thanks for the suggestion > >>> + if (ret) >>> + return ret; >>> + >>> + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, spd); >>> + if (ret) >>> + return ret; >>> + >>> + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, vendor); >> >> There may be multiple vendor specific InfoFrames in the future, so how >> would that be handled? Perhaps add a comment here that currently only one >> vendor specific InfoFrame is supported, but suggest how to handle multiple >> VSIFs in the future. >> >> What would actually be nice (although probably not that easy to fix) is if >> the name of the file would be "vendor-XXXXXX' where 'XXXXXX' is the IEEE OUI >> number. > > I guess it's not entirely clear to me what that would look like. In > order for the framework to create the debugfs files, we would need some > enumeration mechanism (probably through a callback?), and then the > driver would generate the entire content of that file. > > Which makes me question whether the framework should be initialised at > all? Maybe the simpler would be to just have drivers maintain their own > debugfs files and storing the content in their own, private, structure. It's a good question. And I also would like to use this for HDMI receivers (so using it in the media subsystem). Let me try and find some time this week or next week to dig into this a bit more and see if I can implement it on the media side as well. See what would be the best approach here. It would not surprise me if the debugfs part should move to video/hdmi.c since that's already used by both drm and media. Regards, Hans > > Maxime
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 2de43ff3ce0a..3c65b1d3f926 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -538,6 +538,114 @@ static const struct file_operations drm_connector_fops = { .write = connector_write }; +struct debugfs_wrapper { + struct drm_connector *connector; + struct drm_connector_hdmi_infoframe *frame; +}; + +#define HDMI_MAX_INFOFRAME_SIZE 29 + +static ssize_t +infoframe_read(struct file *filp, char __user *ubuf, size_t count, loff_t *ppos) +{ + const struct debugfs_wrapper *wrapper = filp->private_data; + struct drm_connector *connector = wrapper->connector; + struct drm_connector_hdmi_infoframe *infoframe = wrapper->frame; + union hdmi_infoframe *frame = &infoframe->data; + u8 buf[HDMI_MAX_INFOFRAME_SIZE]; + ssize_t len = 0; + + mutex_lock(&connector->hdmi.infoframes.lock); + + if (!infoframe->set) + goto out; + + len = hdmi_infoframe_pack(frame, buf, sizeof(buf)); + if (len < 0) + goto out; + + len = simple_read_from_buffer(ubuf, count, ppos, buf, len); + +out: + mutex_unlock(&connector->hdmi.infoframes.lock); + return len; +} + +static const struct file_operations infoframe_fops = { + .owner = THIS_MODULE, + .open = simple_open, + .read = infoframe_read, +}; + +static int create_hdmi_infoframe_file(struct drm_connector *connector, + struct dentry *parent, + const char *filename, + struct drm_connector_hdmi_infoframe *frame) +{ + struct drm_device *dev = connector->dev; + struct debugfs_wrapper *wrapper; + struct dentry *file; + + wrapper = drmm_kzalloc(dev, sizeof(*wrapper), GFP_KERNEL); + if (!wrapper) + return -ENOMEM; + + wrapper->connector = connector; + wrapper->frame = frame; + + file = debugfs_create_file(filename, 0400, parent, wrapper, &infoframe_fops); + if (IS_ERR(file)) + return PTR_ERR(file); + + return 0; +} + +#define CREATE_HDMI_INFOFRAME_FILE(c, p, i) \ + create_hdmi_infoframe_file(c, p, #i, &(c)->hdmi.infoframes.i) + +static int create_hdmi_infoframe_files(struct drm_connector *connector, + struct dentry *parent) +{ + int ret; + + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, audio); + if (ret) + return ret; + + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, avi); + if (ret) + return ret; + + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, drm); + if (ret) + return ret; + + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, spd); + if (ret) + return ret; + + ret = CREATE_HDMI_INFOFRAME_FILE(connector, parent, vendor); + if (ret) + return ret; + + return 0; +} + +static void hdmi_debugfs_add(struct drm_connector *connector) +{ + struct dentry *dir; + + if (!(connector->connector_type == DRM_MODE_CONNECTOR_HDMIA || + connector->connector_type == DRM_MODE_CONNECTOR_HDMIB)) + return; + + dir = debugfs_create_dir("infoframes", connector->debugfs_entry); + if (IS_ERR(dir)) + return; + + create_hdmi_infoframe_files(connector, dir); +} + void drm_debugfs_connector_add(struct drm_connector *connector) { struct drm_minor *minor = connector->dev->primary; @@ -565,6 +673,8 @@ void drm_debugfs_connector_add(struct drm_connector *connector) debugfs_create_file("output_bpc", 0444, root, connector, &output_bpc_fops); + hdmi_debugfs_add(connector); + if (connector->funcs->debugfs_init) connector->funcs->debugfs_init(connector, root); }