From: Anssi Hannula Subject: Re: [PATCH 5/5] drm/edid: Decode 3-byte CVT codes from EDID 1.4 Date: Sun, 3 Jan 2010 18:10:08 +0200 Message-ID: <201001031810.08719.anssi.hannula@iki.fi> References: <1259880280-17593-1-git-send-email-ajax@redhat.com> <1259880280-17593-4-git-send-email-ajax@redhat.com> <1259880280-17593-5-git-send-email-ajax@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1259880280-17593-5-git-send-email-ajax@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.sourceforge.net To: Adam Jackson Cc: dri-devel@lists.sourceforge.net List-Id: dri-devel@lists.freedesktop.org Adam Jackson wrote: > +static int drm_cvt_modes(struct drm_connector *connector, > + struct detailed_timing *timing) > +{ > + int i, j, modes = 0; > + struct drm_display_mode *newmode; > + struct drm_device *dev = connector->dev; > + struct cvt_timing *cvt; > + const int rates[] = { 60, 85, 75, 60, 50 }; > + > + for (i = 0; i < 4; i++) { > + int width, height; > + cvt = &(timing->data.other_data.data.cvt[i]); > + > + height = (cvt->code[0] + ((cvt->code[1] & 0xf0) << 8) + 1) * 2; > + switch (cvt->code[1] & 0xc0) { Is it just me, or do the above two lines look very wrong? 1) Height can never be between 512 and 8194. 2) Same bits are used for height and aspect ratio. > + case 0x00: > + width = height * 4 / 3; > + break; > + case 0x40: > + width = height * 16 / 9; > + break; > + case 0x80: > + width = height * 16 / 10; > + break; > + case 0xc0: > + width = height * 15 / 9; > + break; > + } > + > + for (j = 1; j < 5; j++) { > + if (cvt->code[2] & (1 << j)) { > + newmode = drm_cvt_mode(dev, width, height, > + rates[j], j == 0, > + false, false); > + if (newmode) { > + drm_mode_probed_add(connector, newmode); > + modes++; > + } > + } > + } > + } > + > + return modes; > +} -- Anssi Hannula ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev --