From: Jani Nikula <jani.nikula@linux.intel.com>
To: Dylan Semler <dylan.semler@gmail.com>
Cc: dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH v3 1/2] drm: Enhance EDID quirks to explicitly set a mode
Date: Mon, 25 Mar 2013 19:29:55 +0200 [thread overview]
Message-ID: <87mwtrpeuk.fsf@intel.com> (raw)
In-Reply-To: <CA+Zg9BoijrOnhB9Rt1aa2K+B+4QSEUsSS0x2gUvUpLMMCjoCPQ@mail.gmail.com>
On Mon, 25 Mar 2013, Dylan Semler <dylan.semler@gmail.com> wrote:
> On Mon, Mar 25, 2013 at 9:41 AM, Jani Nikula <jani.nikula@linux.intel.com>
> wrote:
>>
>>
>> Hi, please find some review comments inline.
>>
>
> You make some good points, thanks.
>
>> On Sat, 23 Mar 2013, Dylan Semler <dylan.semler@gmail.com> wrote:
>> >
>> > +/* Add an explicit mode based on a quirk
>> > + */
>> > +static int
>> > +do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
>> > + int vdisplay, int vrefresh, bool reduced)
>>
>> Nitpick: This adds one mode, not many _modes_.
>
> sure, I'll fix.
>
>
>> > +
>> > + /* loop through the probed modes and clear the preferred bit */
>> > + list_for_each_entry_safe(cur_mode, t, &connector->probed_modes,
> head)
>> > + cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED;
>>
>> You're not deleting entries, so list_for_each_entry() would suffice,
>> getting rid of the temp variable.
>>
>
> I was going to use this but I wasn't sure if I understood all of the
> differences between the two. I opted for _safe because I noticed it's used
> in
> edid_fixup_preferred() even though that routine doesn't remove entries
> either.
> I'll fix it.
>
>> > +
>> > + mode = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, reduced,
> 0, 0);
>>
>> You could
>>
>> if (!mode)
>> return 0;
>>
>> here and get rid of the num_modes variable.
>
> Yes, you're right. I went with
>
> if (mode) {
> ...
> return 1;
> }
> else
> return 0;
Note that you should use braces in all branches if one branch requires
them. See Documentation/CodingStyle.
>
> I would naively expect this to be better. Is there a reason to prefer if
> (!mode)?
Just a personal preference of checking errors and bailing out early, and
handling the happy day scenario at the top indentation level. I won't
insist.
BR,
Jani.
>
>> > +static int
>> > +add_force_quirk_modes(struct drm_connector *connector, struct edid
> *edid,
>> > + u32 quirks)
>> > +{
>> > + struct edid_quirk_force_mode *quirk_mode;
>> > + int i, num_modes = 0;
>> > +
>> > + for (i = 0; i < ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
>> > + quirk_mode = &edid_quirk_force_mode_list[i];
>> > +
>> > + if (edid_vendor(edid, quirk_mode->vendor) &&
>> > + (EDID_PRODUCT_ID(edid) == quirk_mode->product_id)) {
>> > + num_modes = do_force_quirk_modes(connector,
>> > + quirk_mode->hdisplay,
>> > + quirk_mode->vdisplay,
>> > + quirk_mode->vrefresh,
>> > + quirk_mode->reduced);
>>
>> I was wondering why you don't bail out here. Maybe you want to be able
>> to add more than one quirk mode? In that case you should +=, not = the
>> num_modes.
>>
>> (Note that then do_force_quirk_modes makes the last one in the array the
>> preferred mode, clearing the DRM_MODE_TYPE_PREFERRED from the previously
>> added quirk modes.)
>
> I thought about whether multiple forced modes would ever be needed. I can't
> imagine it would but it's easy enough to allow for it so we might as well
> implement it now.
>
> I think we'd want for it to be clear which of the forced modes will be used
> and
> so the current behavior of making the last one in the array preferred may be
> the best. I will add a comment by the edid_quirk_force_mode_list describing
> this.
>
>
>> > @@ -2803,6 +2879,8 @@ int drm_add_edid_modes(struct drm_connector
> *connector, struct edid *edid)
>> >
>> > if (quirks & (EDID_QUIRK_PREFER_LARGE_60 |
> EDID_QUIRK_PREFER_LARGE_75))
>> > edid_fixup_preferred(connector, quirks);
>> > + if (quirks & EDID_QUIRK_FORCE_MODE)
>> > + num_modes += add_force_quirk_modes(connector, edid,
> quirks);
>>
>> You don't use quirks within add_force_quirk_modes() for anything.
>
> good point. I'll remove it.
>
>
> Thanks,
> Dylan
next prev parent reply other threads:[~2013-03-25 17:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-22 23:08 [PATCH v3 0/2] Enhance EDID quirks to allow forcing a mode Dylan Semler
2013-03-22 23:08 ` [PATCH v3 1/2] drm: Enhance EDID quirks to explicitly set " Dylan Semler
2013-03-25 13:41 ` Jani Nikula
2013-03-25 17:01 ` Dylan Semler
2013-03-25 17:29 ` Jani Nikula [this message]
2013-03-22 23:08 ` [PATCH v3 2/2] drm: Add EDID force quirk for MMT Monitor2Go HD+ Dylan Semler
2013-03-23 12:56 ` [PATCH v3 0/2] Enhance EDID quirks to allow forcing a mode 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=87mwtrpeuk.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=dylan.semler@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.