From: Chris Wilson Subject: Re: [PATCHv2] drm: fb_helper: prefer to use mode, which is not DRM_MODE_TYPE_USERDEF Date: Mon, 20 Apr 2015 10:46:08 +0100 Message-ID: <20150420094608.GD25451@nuc-i3427.alporthouse.com> References: <1429477553-10294-1-git-send-email-rd@radekdostal.com> <1429507593-21172-1-git-send-email-rd@radekdostal.com> <20150420090929.GC25451@nuc-i3427.alporthouse.com> <5534C884.8080101@radekdostal.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Content-Disposition: inline In-Reply-To: <5534C884.8080101@radekdostal.com> Sender: linux-kernel-owner@vger.kernel.org To: Radek =?iso-8859-1?Q?Dost=E1l?= Cc: airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org List-Id: dri-devel@lists.freedesktop.org On Mon, Apr 20, 2015 at 11:36:04AM +0200, Radek Dost=E1l wrote: > Hi Chris, >=20 > On 04/20/2015 11:09 AM, Chris Wilson wrote: > > The EDID modes should be earlier in the list, and so higher priorit= y > > than the cmdline mode. The only instance I see that breaking down i= s if > > the mode gets created by drm_pick_cmdline_mode, i.e. >=20 > indeed at the beginning the command line mode is added to the end of = the > list, but later on it seems to me that all modes are reordered based = on > the resolution and clock and than mode generated by > drm_helper_probe_add_cmdline_mode gets upper in the list as it has > higher clock value. Please see attached output of dmesg. Ah thanks, drm_mode_sort()! diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 213b11e..9c8357f 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -1127,6 +1127,7 @@ static int drm_mode_compare(void *priv, struct li= st_head *lh_a, struct list_head ((a->type & DRM_MODE_TYPE_PREFERRED) !=3D 0); if (diff) return diff; + diff =3D b->hdisplay * b->vdisplay - a->hdisplay * a->vdisplay; if (diff) return diff; @@ -1136,7 +1137,16 @@ static int drm_mode_compare(void *priv, struct l= ist_head *lh_a, struct list_head return diff; =20 diff =3D b->clock - a->clock; - return diff; + if (diff) + return diff; + + /* sort user-defined modes after reported modes of same resolut= ion */ + diff =3D ((a->type & DRM_MODE_TYPE_USERDEF) !=3D 0) - + ((b->type & DRM_MODE_TYPE_USERDEF) !=3D 0); + if (diff) + return diff; + + return 0; } Perhaps? -Chris --=20 Chris Wilson, Intel Open Source Technology Centre