From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Subject: Re: [PATCH v2] drm: add support for additional stereo 3D modes Date: Tue, 15 Oct 2013 20:55:54 +0300 Message-ID: <20131015175554.GP13047@intel.com> References: <20131011111214.GT13047@intel.com> <1381857927-3712-1-git-send-email-thomas.wood@intel.com> <1381857927-3712-2-git-send-email-thomas.wood@intel.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: <1381857927-3712-2-git-send-email-thomas.wood@intel.com> 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: Thomas Wood Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Tue, Oct 15, 2013 at 06:25:27PM +0100, Thomas Wood wrote: > Parse the 3D_Structure_ALL and 3D_MASK fields of the HDMI Vendor > Specific Data Block to expose more stereo 3D modes. > = Daniel likes to have the v2,v3,etc. changes listed here in the commit msg. > Signed-off-by: Thomas Wood > --- > drivers/gpu/drm/drm_edid.c | 105 +++++++++++++++++++++++++++++++++++++++= ++---- > 1 file changed, 96 insertions(+), 9 deletions(-) > = > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index 9e81609..456a694 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -2652,6 +2652,50 @@ static int add_hdmi_mode(struct drm_connector *con= nector, u8 vic) > return 1; > } > = > +static int add_3d_struct_modes(struct drm_connector *connector, u16 stru= cture, > + const u8 *video_db, u8 video_len, u8 video_index) > +{ > + struct drm_device *dev =3D connector->dev; > + struct drm_display_mode *newmode; > + int modes =3D 0; > + u8 cea_mode; > + > + if (video_db =3D=3D NULL || video_index > video_len) > + return 0; > + > + /* CEA modes are numbered 1..127 */ > + cea_mode =3D (video_db[video_index] & 127) - 1; > + if (cea_mode >=3D ARRAY_SIZE(edid_cea_modes)) > + return 0; > + > + if (structure & (1 << 0)) { > + newmode =3D drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); > + if (newmode) { > + newmode->flags |=3D DRM_MODE_FLAG_3D_FRAME_PACKING; > + drm_mode_probed_add(connector, newmode); > + modes++; > + } > + } > + if (structure & (1 << 6)) { > + newmode =3D drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); > + if (newmode) { > + newmode->flags |=3D DRM_MODE_FLAG_3D_TOP_AND_BOTTOM; > + drm_mode_probed_add(connector, newmode); > + modes++; > + } > + } > + if (structure & (1 << 8)) { > + newmode =3D drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); > + if (newmode) { > + newmode->flags =3D DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF; > + drm_mode_probed_add(connector, newmode); > + modes++; > + } > + } > + > + return modes; > +} > + > /* > * do_hdmi_vsdb_modes - Parse the HDMI Vendor Specific data block > * @connector: connector corresponding to the HDMI sink > @@ -2662,10 +2706,13 @@ static int add_hdmi_mode(struct drm_connector *co= nnector, u8 vic) > * also adds the stereo 3d modes when applicable. > */ > static int > -do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len) > +do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len, > + const u8 *video_db, u8 video_len) > { > - int modes =3D 0, offset =3D 0, i; > - u8 vic_len; > + int modes =3D 0, offset =3D 0, i, multi_present =3D 0; > + u8 vic_len, hdmi_3d_len; > + u16 mask; > + u16 structure_all; > = > if (len < 8) > goto out; > @@ -2689,9 +2736,13 @@ do_hdmi_vsdb_modes(struct drm_connector *connector= , const u8 *db, u8 len) > = > /* 3D_Present */ > offset++; > - if (db[8 + offset] & (1 << 7)) > + if (db[8 + offset] & (1 << 7)) { > modes +=3D add_hdmi_mandatory_stereo_modes(connector); > = > + /* 3D_Multi_present */ > + multi_present =3D (db[8 + offset] & 0x60) >> 5; > + } > + > offset++; > vic_len =3D db[8 + offset] >> 5; > = > @@ -2702,6 +2753,38 @@ do_hdmi_vsdb_modes(struct drm_connector *connector= , const u8 *db, u8 len) > modes +=3D add_hdmi_mode(connector, vic); > } > = > + if (!(multi_present =3D=3D 1 || multi_present =3D=3D 2)) > + goto out; > + > + if ((multi_present =3D=3D 1 && len < (9 + offset)) || > + (multi_present =3D=3D 2 && len < (11 + offset))) > + goto out; These checks must happen after 'offset +=3D 1 + vic_len'. Otherwise it looks good to me. > + > + hdmi_3d_len =3D db[8 + offset] & 0x1f; > + > + if ((multi_present =3D=3D 1 && hdmi_3d_len < 2) || > + (multi_present =3D=3D 2 && hdmi_3d_len < 4)) > + goto out; > + > + offset +=3D 1 + vic_len; > + > + /* 3D_Structure_ALL */ > + structure_all =3D (db[8 + offset] << 8) | db[9 + offset]; > + > + /* check if 3D_MASK is present */ > + if (multi_present =3D=3D 2) > + mask =3D (db[10 + offset] << 8) | db[11 + offset]; > + else > + mask =3D 0xffff; > + > + for (i =3D 0; i < 16; i++) { > + if (mask & (1 << i)) > + modes +=3D add_3d_struct_modes(connector, > + structure_all, > + video_db, > + video_len, i); > + } > + > out: > return modes; > } > @@ -2759,8 +2842,8 @@ static int > add_cea_modes(struct drm_connector *connector, struct edid *edid) > { > const u8 *cea =3D drm_find_cea_extension(edid); > - const u8 *db, *hdmi =3D NULL; > - u8 dbl, hdmi_len; > + const u8 *db, *hdmi =3D NULL, *video =3D NULL; > + u8 dbl, hdmi_len, video_len =3D 0; > int modes =3D 0; > = > if (cea && cea_revision(cea) >=3D 3) { > @@ -2773,8 +2856,11 @@ add_cea_modes(struct drm_connector *connector, str= uct edid *edid) > db =3D &cea[i]; > dbl =3D cea_db_payload_len(db); > = > - if (cea_db_tag(db) =3D=3D VIDEO_BLOCK) > - modes +=3D do_cea_modes(connector, db + 1, dbl); > + if (cea_db_tag(db) =3D=3D VIDEO_BLOCK) { > + video =3D db + 1; > + video_len =3D dbl; > + modes +=3D do_cea_modes(connector, video, dbl); > + } > else if (cea_db_is_hdmi_vsdb(db)) { > hdmi =3D db; > hdmi_len =3D dbl; > @@ -2787,7 +2873,8 @@ add_cea_modes(struct drm_connector *connector, stru= ct edid *edid) > * be patching their flags when the sink supports stereo 3D. > */ > if (hdmi) > - modes +=3D do_hdmi_vsdb_modes(connector, hdmi, hdmi_len); > + modes +=3D do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video, > + video_len); > = > return modes; > } > -- = > 1.8.3.1 -- = Ville Syrj=E4l=E4 Intel OTC