From: Jim Bride <jim.bride@linux.intel.com>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/3] drm/edid: Add drm_edid_get_monitor_name()
Date: Wed, 6 Apr 2016 10:03:33 -0700 [thread overview]
Message-ID: <20160406170333.GB16291@shiv> (raw)
In-Reply-To: <87fuuzxhgf.fsf@intel.com>
On Wed, Apr 06, 2016 at 11:35:44AM +0300, Jani Nikula wrote:
> On Tue, 05 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.
> >
> > cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Jim Bride <jim.bride@linux.intel.com>
> > ---
> > drivers/gpu/drm/drm_edid.c | 28 ++++++++++++++++++++++++++++
> > include/drm/drm_crtc.h | 1 +
> > 2 files changed, 29 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 558ef9f..fc69a46 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -3569,6 +3569,34 @@ struct drm_connector *drm_select_eld(struct drm_encoder *encoder)
> > EXPORT_SYMBOL(drm_select_eld);
> >
> > /**
> > + * drm_edid_get_monitor_name - fetch the monitor name from the edid
> > + * @edid: monitor EDID information
> > + * @name: pointer to a character array of at least 13 chars to hold the name
>
> Mixed feelings about "at least 13 chars". It might be simpler for this
> one thing, but I hate to see this assumption of "at least 13 chars" get
> spread around in patch 2 to where it's no longer obvious where this
> requirement comes from.
>
> Seeing that this is mostly copy-paste from drm_edid_to_eld(), I think
> this patch should be an abstraction of that code to a separate function.
Yeah, I see what you mean. Writing something that works with both this
use and drm_edid_to_eld() for the name parsing makes sense.
> > + *
> > + * Return: True if the name could be extracted, false otherwise
> > + */
> > +bool drm_edid_get_monitor_name(struct edid *edid, char *name)
> > +{
> > + char *edid_name = NULL;
> > + int mnl;
> > +
> > + if (!edid || !name)
> > + return false;
> > +
> > + drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
> > + for (mnl = 0; edid_name && mnl < 13; mnl++) {
> > + if (edid_name[mnl] == 0x0a) {
> > + name[mnl] = '\0';
>
> Depending on edid_name you might not terminate the string. And, in fact,
> if you make this an abstraction for drm_edid_to_eld(), you might be
> better off *not* terminating, which OTOH is not nice for your other use
> in patch 2.
>
> So how about first adding an internal abstraction:
>
> static int get_monitor_name(struct edid *edid, char name[13])
>
> which does *not* terminate the string, and returns length, 0 for
> edid_name == NULL. Works nicely for drm_edid_to_eld().
>
> Then you could add the external interface on top of that:
>
> static void drm_edid_get_monitor_name(struct edid *edid, char *buf, int bufsize)
>
> which would always terminate the string (assuming bufsize > 0), even on
> errors so you can get rid of the return value. This simplifies your
> follow up code, and if we later on need more robust error handling, it's
> easy to add the return value.
Seems reasonable; I'll update the patch.
Jim
> BR,
> Jani.
>
>
> > + break;
> > + }
> > + name[mnl] = edid_name[mnl];
> > + }
> > +
> > + return mnl ? true : false;
> > +}
> > +EXPORT_SYMBOL(drm_edid_get_monitor_name);
> > +
> > +/**
> > * drm_detect_hdmi_monitor - detect whether monitor is HDMI
> > * @edid: monitor EDID information
> > *
> > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> > index 8cb377c..2590168 100644
> > --- a/include/drm/drm_crtc.h
> > +++ b/include/drm/drm_crtc.h
> > @@ -2500,6 +2500,7 @@ 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 bool drm_edid_get_monitor_name(struct edid *edid, char *name);
> >
> > extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> > char topology[8]);
>
> --
> Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-04-06 17:03 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 20:23 [PATCH 0/3] Minor i915_dp_mst_info output enhancements Jim Bride
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 [this message]
2016-04-05 20:23 ` [PATCH 2/3] drm/dp/mst: Enhance DP MST debugfs output Jim Bride
2016-04-05 20:23 ` [PATCH 3/3] drm/i915/dp/mst: Add source port info to " Jim Bride
2016-04-06 7:54 ` ✗ Fi.CI.BAT: failure for Minor i915_dp_mst_info output enhancements Patchwork
2016-04-07 17:30 ` [PATCH v2 1/3] drm/edid: Add drm_edid_get_monitor_name() Jim Bride
2016-04-08 9:35 ` [Intel-gfx] " Jani Nikula
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-07 17:30 ` [PATCH v2 3/3] drm/i915/dp/mst: Add source port info to " Jim Bride
2016-04-08 8:34 ` ✗ Fi.CI.BAT: failure for Minor i915_dp_mst_info output enhancements (rev2) Patchwork
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
2016-04-11 16:14 ` [PATCH v3 3/3] drm/i915/dp/mst: Add source port info to " Jim Bride
2016-04-12 9:36 ` Jani Nikula
2016-04-11 16:36 ` ✗ Fi.CI.BAT: failure for Minor i915_dp_mst_info output enhancements (rev4) Patchwork
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=20160406170333.GB16291@shiv \
--to=jim.bride@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@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