diff mbox

[15/16] drm/mgag200: Reject modes when h-parameters are no multiple of 8

Message ID 1374066449-21714-16-git-send-email-eich@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Egbert Eich July 17, 2013, 1:07 p.m. UTC
Matrox hardware only supports modes whose horizontal parameters are
multiples of 8. This rules out a mode like 1366x768 for example.

Signed-off-by: Egbert Eich <eich@suse.com>
---
 drivers/gpu/drm/mgag200/mgag200_mode.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Dave Airlie July 23, 2013, 5:46 a.m. UTC | #1
On Wed, Jul 17, 2013 at 11:07 PM, Egbert Eich <eich@suse.com> wrote:
> Matrox hardware only supports modes whose horizontal parameters are
> multiples of 8. This rules out a mode like 1366x768 for example.
>
> Signed-off-by: Egbert Eich <eich@suse.com>

I'd like to get a second opinion from ajax for where this should be
dealt with, though this is probably okay.

Dave.
Adam Jackson July 23, 2013, 3:30 p.m. UTC | #2
On Tue, 2013-07-23 at 15:46 +1000, Dave Airlie wrote:
> On Wed, Jul 17, 2013 at 11:07 PM, Egbert Eich <eich@suse.com> wrote:
> > Matrox hardware only supports modes whose horizontal parameters are
> > multiples of 8. This rules out a mode like 1366x768 for example.
> >
> > Signed-off-by: Egbert Eich <eich@suse.com>
> 
> I'd like to get a second opinion from ajax for where this should be
> dealt with, though this is probably okay.

Patch seems like it's in the right place to me.

- ajax
Daniel Vetter July 23, 2013, 6:07 p.m. UTC | #3
On Tue, Jul 23, 2013 at 5:30 PM, Adam Jackson <ajax@redhat.com> wrote:
> On Tue, 2013-07-23 at 15:46 +1000, Dave Airlie wrote:
>> On Wed, Jul 17, 2013 at 11:07 PM, Egbert Eich <eich@suse.com> wrote:
>> > Matrox hardware only supports modes whose horizontal parameters are
>> > multiples of 8. This rules out a mode like 1366x768 for example.
>> >
>> > Signed-off-by: Egbert Eich <eich@suse.com>
>>
>> I'd like to get a second opinion from ajax for where this should be
>> dealt with, though this is probably okay.
>
> Patch seems like it's in the right place to me.

->mode_valid is only used when parsing the list of modes obtained from
the EDID. Userspace can still add new modes of its own and force the
kernel to use them. To plug that gap mgag200 also needs to reject any
modes in the crtc_helper->mode_fixup callback.

I've pondered whether we should unify these too callers, e.g. by using
the ->mode_fixup function from ->mode_valid with a fake adjusted_mode.
But I never got around to that ...
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
diff mbox

Patch

diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index 503a414..0bb0e1e 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -1491,6 +1491,10 @@  static int mga_vga_mode_valid(struct drm_connector *connector,
 	int bpp = 32;
 	int i = 0;
 
+	if (mode->hdisplay % 8 || mode->hsync_start % 8 ||
+	    mode->hsync_end % 8 || mode->htotal % 8)
+		return MODE_H_ILLEGAL;
+
 	if (IS_G200_SE(mdev)) {
 		if (mdev->unique_rev_id == 0x01) {
 			if (mode->hdisplay > 1600)