From: Adam Jackson Subject: RE: [PATCH] drm: Enable reading 3D capabilities of 3D monitor Date: Wed, 14 Dec 2011 10:23:23 -0500 Message-ID: <1323876203.24701.37.camel@atropine> References: <1323793232.10572.15.camel@atropine> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1510213489==" Return-path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTP id 943DE9E8AF for ; Wed, 14 Dec 2011 07:23:25 -0800 (PST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: "Kavuri, Sateesh" Cc: "dri-devel@lists.freedesktop.org" List-Id: dri-devel@lists.freedesktop.org --===============1510213489== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-nER18PCqAzK9U0L/xKvc" --=-nER18PCqAzK9U0L/xKvc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2011-12-14 at 13:04 +0000, Kavuri, Sateesh wrote: > + /* Data block offset in CEA extension block */ > + start_offset =3D 4; > + end_offset =3D edid_ext[2]; > + > + /* 3D vars */ > + int multi_present =3D 0; Pretty sure kernel style frowns upon mixed decls and code. > + /* > + * Because HDMI identifier is in Vendor Specific Block, > + * search it from all data blocks of CEA extension. > + */ > + for (i =3D start_offset; i < end_offset; > + /* Increased by data block len */ > + i +=3D ((edid_ext[i] & 0x1f) + 1)) { > + /* Find vendor specific block */ > + /* 6'th bit is the VIDEO_PRESENT bit */ > + if ( ((edid_ext[i] >> 5) =3D=3D VENDOR_BLOCK) && > + ((edid_ext[i+8] & 0x20) =3D=3D MONITOR_VIDEO_PRESENT) ) { This conditional will always be false: if ((x =3D=3D VENDOR_BLOCK) && ((y & 0x20) =3D=3D 0x01)) I suspect you want: #define MONITOR_VIDEO_PRESENT (1 << 6) ... if ((x =3D=3D VENDOR_BLOCK) && (y & MONITOR_VIDEO_PRESENT)) { ... > + hdmi_id =3D edid_ext[i + 1] | (edid_ext[i + 2] << 8) | > + edid_ext[i + 3] << 16; > + /* Find HDMI identifier */ > + if (hdmi_id =3D=3D HDMI_IDENTIFIER) > + is_hdmi =3D true; > + > + /* Check for the 3D_Present flag */ > + if ((edid_ext[i+13] >> 6) =3D=3D PANEL_SUPPORTS_3D) { > + caps =3D kmalloc(sizeof(struct drm_panel_3D_capabilities), GFP_KERNE= L); > + caps->panel_supports_3D =3D 1; > + } This will probably also not do what you want. Consider what happens if edid_ext[i+13] has (1 << 7) set. > + /* Check if 3D_Multi_present is set */ > + if ((edid_ext[i+13] & 0x60) =3D=3D 0x0) { > + multi_present =3D true; > + } Code and comment disagree. > + > + /* Collect 3D capabilities of the monitor */ > + int hdmi_3d_len =3D 0; > + int hdmi_vic_len =3D 0; > + hdmi_vic_len =3D (edid_ext[i+14] >> 0x05); > + hdmi_3d_len =3D ((edid_ext[i+14] << 0x03) >>0x03); > + int multi_val =3D edid_ext[i+13] & 0x6; Note: multi_val can only have the values {0, 2, 4, 6} now. > + if (multi_val =3D=3D 0x0) > + multi_present =3D NO_SPL_CAPS; > + else if (multi_val =3D=3D 0x1) > + multi_present =3D STRUCTURE_PRESENT; These two assignments (and the one above) are the only use of the multi_present variable, it's never used in a subsequent conditional or passed back to the caller. The 'else' here can never be true, as noted above. > + if ((multi_val =3D=3D STRUCTURE_PRESENT) ||=20 > + (multi_val =3D=3D STRUCTURE_MASK_PRESENT) ) { > + if (edid_ext[i+15+hdmi_vic_len] & (1 << 0)) > + caps->format |=3D (1 << 0); /* FRAME_PACKING */ > + if (edid_ext[i+15+hdmi_vic_len] & (1 << 1)) > + caps->format |=3D (1 << 1); /*FIELD_ALTERNATIVE */ > + if (edid_ext[i+15+hdmi_vic_len] & (1 << 2)) > + caps->format |=3D (1 << 2); /* LINE_ALTERNATIVE */ > + if (edid_ext[i+15+hdmi_vic_len] & 0x3) > + caps->format |=3D (1 << 3); /*SIDE_BY_SIDE_FULL */ > + if (edid_ext[i+15+hdmi_vic_len] & (1 << 4)) > + caps->format |=3D (1 << 4); /* L_DEPTH */ > + if (edid_ext[i+15+hdmi_vic_len] & 0x5) > + caps->format |=3D (1 << 5); /* L_DEPTH_GFX_GFX_DEPTH */ > + if (edid_ext[i+15+hdmi_vic_len] & 0x6) > + caps->format |=3D (1 << 6); /* TOP_BOTTOM */ > + if (edid_ext[i+14+hdmi_vic_len] & 0x7) > + caps->format |=3D (1 << 7); /* S_BY_S_HALF */ > + if (edid_ext[i+14+hdmi_vic_len] & (1 << 8)) > + caps->format |=3D (1 << 8); /* S_BY_S_HALF_QUINCUNX */ > + } Here you've made it clear that ->format is a bitfield, but the values should be in a header (so drivers can use them) and this code should only be using the symbolic names. > @@ -1675,6 +1783,7 @@ static void drm_add_display_info(struct edid *edid, > return; > =20 > info->cea_rev =3D edid_ext[1]; > + info->caps_3D=3D drm_detect_3D_monitor(edid); > } > =20 > /** Whitespace. > +/* Pre-defined 3D formats as per HDMI spec */ > +enum s3d_formats { > + FRAME_PACKING =3D 0x0, > + FIELD_ALTERNATIVE =3D 0x1, > + LINE_ALTERNATIVE =3D 0x2, > + SIDE_BY_SIDE_FULL =3D 0x3, > + L_DEPTH =3D 0x4, > + L_DEPTH_GFX_GFX_DEPTH =3D 0x5, > + TOP_BOTTOM =3D 0x6, /* 0x7 is reserved for future *= / > + SIDE_BY_SIDE_HALF =3D 0x8 /* 0x9 onwards is reserved for = future */ > +}; These don't match the bit shifts you used earlier. - ajax --=-nER18PCqAzK9U0L/xKvc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEABECAAYFAk7ov2sACgkQW4otUKDs0NP6FQCdHHlBQy5H1rRnLT4l0Cm3ZYcj dJoAnA09sMvReiH2H3CjoBrkzOSwaBcz =4pgQ -----END PGP SIGNATURE----- --=-nER18PCqAzK9U0L/xKvc-- --===============1510213489== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1510213489==--