From: Jani Nikula <jani.nikula@linux.intel.com>
To: Jim Bride <jim.bride@linux.intel.com>, intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v2 1/3] drm/edid: Add drm_edid_get_monitor_name()
Date: Fri, 08 Apr 2016 12:35:53 +0300 [thread overview]
Message-ID: <87r3egv3wm.fsf@intel.com> (raw)
In-Reply-To: <1460050239-11770-1-git-send-email-jim.bride@linux.intel.com>
On Thu, 07 Apr 2016, Jim Bride <jim.bride@linux.intel.com> wrote:
> In order to include monitor name information in debugfs
> output we needed to add a function that would extract the
> monitor name from the EDID, and that function needed to
> reside in the file where the rest of the EDID helper
> functions are implemented.
>
> v2: Refactor to have drm_edid_get_monitor_name() and drm_edid_to_eld()
> use a common helper function to extract the monitor name from the
> edid. [Jani] + rebase.
>
> cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Jim Bride <jim.bride@linux.intel.com>
> ---
> drivers/gpu/drm/drm_edid.c | 50 +++++++++++++++++++++++++++++++++++++---------
> include/drm/drm_crtc.h | 2 ++
> 2 files changed, 43 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 558ef9f..daf53df 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3293,6 +3293,45 @@ monitor_name(struct detailed_timing *t, void *data)
> *(u8 **)data = t->data.other_data.data.str.str;
> }
>
> +static int get_monitor_name(struct edid *edid, char name[13])
> +{
> + char *edid_name = NULL;
> + int mnl;
> +
> + if (!edid || !name)
> + return 0;
> +
> + drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
> + for (mnl = 0; edid_name && mnl < 13; mnl++) {
> + if (edid_name[mnl] == 0x0a)
> + break;
> +
> + name[mnl] = edid_name[mnl];
> + }
> +
> + return mnl;
> +}
> +
> +/**
> + * drm_edid_get_monitor_name - fetch the monitor name from the edid
> + * @edid: monitor EDID information
> + * @name: pointer to a character array to hold the name of the monitor
> + * @bufsize: The size of the name buffer (should be at least 13 chars.)
> + *
> + */
> +void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize)
> +{
> + int name_length = -1;
> +
> + if (bufsize < 13)
> + return;
> +
> + name_length = get_monitor_name(edid, name);
> + if (name_length)
> + name[name_length] = '\0';
I was thinking something along the lines of:
char buf[13];
int len;
if (bufsize <= 0)
return;
len = min(get_monitor_name(edid, buf), bufsize - 1);
memcpy(name, buf, len);
name[len] = '\0';
BR,
Jani.
> +}
> +EXPORT_SYMBOL(drm_edid_get_monitor_name);
> +
> /**
> * drm_edid_to_eld - build ELD from EDID
> * @connector: connector corresponding to the HDMI/DP sink
> @@ -3306,7 +3345,6 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
> {
> uint8_t *eld = connector->eld;
> u8 *cea;
> - u8 *name;
> u8 *db;
> int total_sad_count = 0;
> int mnl;
> @@ -3320,14 +3358,8 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
> return;
> }
>
> - name = NULL;
> - drm_for_each_detailed_block((u8 *)edid, monitor_name, &name);
> - /* max: 13 bytes EDID, 16 bytes ELD */
> - for (mnl = 0; name && mnl < 13; mnl++) {
> - if (name[mnl] == 0x0a)
> - break;
> - eld[20 + mnl] = name[mnl];
> - }
> + mnl = get_monitor_name(edid, eld + 20);
> +
> eld[4] = (cea[1] << 5) | mnl;
> DRM_DEBUG_KMS("ELD monitor %s\n", eld + 20);
>
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 8cb377c..6d46842 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -2500,6 +2500,8 @@ extern int drm_edid_header_is_valid(const u8 *raw_edid);
> extern bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
> bool *edid_corrupt);
> extern bool drm_edid_is_valid(struct edid *edid);
> +extern void drm_edid_get_monitor_name(struct edid *edid, char *name,
> + int buflen);
>
> extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> char topology[8]);
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-04-08 9:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1459887821-8142-1-git-send-email-jim.bride@linux.intel.com>
2016-04-05 20:23 ` [PATCH 1/3] drm/edid: Add drm_edid_get_monitor_name() Jim Bride
2016-04-06 8:35 ` Jani Nikula
2016-04-06 17:03 ` Jim Bride
2016-04-05 20:23 ` [PATCH 2/3] drm/dp/mst: Enhance DP MST debugfs output Jim Bride
2016-04-07 17:30 ` [PATCH v2 1/3] drm/edid: Add drm_edid_get_monitor_name() Jim Bride
2016-04-08 9:35 ` Jani Nikula [this message]
2016-04-07 17:30 ` [PATCH v2 2/3] drm/dp/mst: Enhance DP MST debugfs output Jim Bride
2016-04-08 9:44 ` Jani Nikula
2016-04-11 16:14 ` [PATCH v3 1/3] drm/edid: Add drm_edid_get_monitor_name() Jim Bride
2016-04-12 9:30 ` Jani Nikula
2016-04-11 16:14 ` [PATCH v3 2/3] drm/dp/mst: Enhance DP MST debugfs output Jim Bride
2016-04-14 6:47 ` Jani Nikula
2016-04-14 7:37 ` Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r3egv3wm.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jim.bride@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox