public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm: add support for additional stereo 3D modes
@ 2013-10-10 13:19 Thomas Wood
  2013-10-11 11:12 ` [Intel-gfx] " Ville Syrjälä
  2013-10-11 15:59 ` [PATCH] " Damien Lespiau
  0 siblings, 2 replies; 10+ messages in thread
From: Thomas Wood @ 2013-10-10 13:19 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

Parse the 3D_Structure_ALL and 3D_MASK fields of the HDMI Vendor
Specific Data Block to expose more stereo 3D modes.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 drivers/gpu/drm/drm_edid.c | 93 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 85 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 9e81609..b3949f9 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 *connector, u8 vic)
 	return 1;
 }
 
+static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
+			       const u8 *video_db, u8 video_len, u8 video_index)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_display_mode *newmode;
+	int modes = 0;
+	u8 cea_mode;
+
+	if (video_db == NULL || video_index > video_len)
+		return 0;
+
+	/* CEA modes are numbered 1..127 */
+	cea_mode = (video_db[video_index] & 127) - 1;
+	if (cea_mode >= ARRAY_SIZE(edid_cea_modes))
+		return 0;
+
+	if (structure & 1) {
+		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
+		if (newmode) {
+			newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING;
+			drm_mode_probed_add(connector, newmode);
+			modes++;
+		}
+	}
+	if (structure & (1 << 6)) {
+		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
+		if (newmode) {
+			newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM;
+			drm_mode_probed_add(connector, newmode);
+			modes++;
+		}
+	}
+	if (structure & (1 << 8)) {
+		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
+		if (newmode) {
+			newmode->flags = 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 *connector, 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 = 0, offset = 0, i;
+	int modes = 0, offset = 0, i, multi_present = 0;
 	u8 vic_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 += add_hdmi_mandatory_stereo_modes(connector);
 
+		/* 3D_Multi_present */
+		multi_present = (db[8 + offset] & 0x60) >> 5;
+	}
+
 	offset++;
 	vic_len = db[8 + offset] >> 5;
 
@@ -2702,6 +2753,28 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len)
 		modes += add_hdmi_mode(connector, vic);
 	}
 
+	offset += 1 + vic_len;
+
+	if ((multi_present == 1 || multi_present == 2) &&
+	    len >= (9 + offset)) {
+		/* 3D_Structure_ALL */
+		structure_all = (db[8 + offset] << 8) | db[9 + offset];
+
+		/* check if 3D_MASK is present */
+		if (multi_present == 2 && len >= 11 + offset)
+			mask = (db[10 + offset] << 8) | db[11 + offset];
+		else
+			mask = 0xffff;
+
+		for (i = 0; i < 16; i++) {
+			if (mask & (1 << i))
+				modes += add_3d_struct_modes(connector,
+							     structure_all,
+							     video_db,
+							     video_len, i);
+		}
+	}
+
 out:
 	return modes;
 }
@@ -2759,8 +2832,8 @@ static int
 add_cea_modes(struct drm_connector *connector, struct edid *edid)
 {
 	const u8 *cea = drm_find_cea_extension(edid);
-	const u8 *db, *hdmi = NULL;
-	u8 dbl, hdmi_len;
+	const u8 *db, *hdmi = NULL, *video = NULL;
+	u8 dbl, hdmi_len, video_len = 0;
 	int modes = 0;
 
 	if (cea && cea_revision(cea) >= 3) {
@@ -2773,8 +2846,11 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
 			db = &cea[i];
 			dbl = cea_db_payload_len(db);
 
-			if (cea_db_tag(db) == VIDEO_BLOCK)
-				modes += do_cea_modes(connector, db + 1, dbl);
+			if (cea_db_tag(db) == VIDEO_BLOCK) {
+				video = db + 1;
+				video_len = dbl;
+				modes += do_cea_modes(connector, video, dbl);
+			}
 			else if (cea_db_is_hdmi_vsdb(db)) {
 				hdmi = db;
 				hdmi_len = dbl;
@@ -2787,7 +2863,8 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
 	 * be patching their flags when the sink supports stereo 3D.
 	 */
 	if (hdmi)
-		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len);
+		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video,
+					    video_len);
 
 	return modes;
 }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Intel-gfx] [PATCH] drm: add support for additional stereo 3D modes
  2013-10-10 13:19 [PATCH] drm: add support for additional stereo 3D modes Thomas Wood
@ 2013-10-11 11:12 ` Ville Syrjälä
  2013-10-11 12:09   ` Damien Lespiau
  2013-10-15 17:25   ` Thomas Wood
  2013-10-11 15:59 ` [PATCH] " Damien Lespiau
  1 sibling, 2 replies; 10+ messages in thread
From: Ville Syrjälä @ 2013-10-11 11:12 UTC (permalink / raw)
  To: Thomas Wood; +Cc: intel-gfx, dri-devel

On Thu, Oct 10, 2013 at 02:19:15PM +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.
> 
> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 93 ++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 85 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 9e81609..b3949f9 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 *connector, u8 vic)
>  	return 1;
>  }
>  
> +static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
> +			       const u8 *video_db, u8 video_len, u8 video_index)
> +{
> +	struct drm_device *dev = connector->dev;
> +	struct drm_display_mode *newmode;
> +	int modes = 0;
> +	u8 cea_mode;
> +
> +	if (video_db == NULL || video_index > video_len)
> +		return 0;
> +
> +	/* CEA modes are numbered 1..127 */
> +	cea_mode = (video_db[video_index] & 127) - 1;
> +	if (cea_mode >= ARRAY_SIZE(edid_cea_modes))
> +		return 0;
> +
> +	if (structure & 1) {

Could use (1 << 0) for consistency.

I'm also wondering if some displays might include some of the mandatory
modes in 3D_Structure_ALL, and if so should we filter out the
duplicates?

> +		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
> +		if (newmode) {
> +			newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING;
> +			drm_mode_probed_add(connector, newmode);
> +			modes++;
> +		}
> +	}
> +	if (structure & (1 << 6)) {
> +		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
> +		if (newmode) {
> +			newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM;
> +			drm_mode_probed_add(connector, newmode);
> +			modes++;
> +		}
> +	}
> +	if (structure & (1 << 8)) {
> +		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
> +		if (newmode) {
> +			newmode->flags = 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 *connector, 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 = 0, offset = 0, i;
> +	int modes = 0, offset = 0, i, multi_present = 0;
>  	u8 vic_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 += add_hdmi_mandatory_stereo_modes(connector);
>  
> +		/* 3D_Multi_present */
> +		multi_present = (db[8 + offset] & 0x60) >> 5;
> +	}
> +
>  	offset++;
>  	vic_len = db[8 + offset] >> 5;
>  
> @@ -2702,6 +2753,28 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len)
>  		modes += add_hdmi_mode(connector, vic);
>  	}
>  
> +	offset += 1 + vic_len;
> +
> +	if ((multi_present == 1 || multi_present == 2) &&
> +	    len >= (9 + offset)) {

If multi_present==2 and len is too small for the mask, I think we should
skip adding the modes since the block is clearly incorrect/corrupted.

So maybe just something like this:
 if ((multi_present == 1 && len < (9 + offset)) ||
     (multi_present == 2 && len < (11 + offset)))
     goto out;

I would also add a similar check for HDMI_3D_LEN since that is
supposed to include the space required by 3D_Structure_ALL and 
3D_MASK. Or you could just check HDMI_3D_LEN against 'len' and bail
out if that doesn't fit. And then you could just check
3D_Structure_ALL and 3D_MASK against HDMI_3D_LEN.

> +		/* 3D_Structure_ALL */
> +		structure_all = (db[8 + offset] << 8) | db[9 + offset];
> +
> +		/* check if 3D_MASK is present */
> +		if (multi_present == 2 && len >= 11 + offset)
> +			mask = (db[10 + offset] << 8) | db[11 + offset];
> +		else
> +			mask = 0xffff;
> +
> +		for (i = 0; i < 16; i++) {
> +			if (mask & (1 << i))
> +				modes += add_3d_struct_modes(connector,
> +							     structure_all,
> +							     video_db,
> +							     video_len, i);
> +		}
> +	}
> +
>  out:
>  	return modes;
>  }
> @@ -2759,8 +2832,8 @@ static int
>  add_cea_modes(struct drm_connector *connector, struct edid *edid)
>  {
>  	const u8 *cea = drm_find_cea_extension(edid);
> -	const u8 *db, *hdmi = NULL;
> -	u8 dbl, hdmi_len;
> +	const u8 *db, *hdmi = NULL, *video = NULL;
> +	u8 dbl, hdmi_len, video_len = 0;
>  	int modes = 0;
>  
>  	if (cea && cea_revision(cea) >= 3) {
> @@ -2773,8 +2846,11 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
>  			db = &cea[i];
>  			dbl = cea_db_payload_len(db);
>  
> -			if (cea_db_tag(db) == VIDEO_BLOCK)
> -				modes += do_cea_modes(connector, db + 1, dbl);
> +			if (cea_db_tag(db) == VIDEO_BLOCK) {
> +				video = db + 1;
> +				video_len = dbl;
> +				modes += do_cea_modes(connector, video, dbl);
> +			}
>  			else if (cea_db_is_hdmi_vsdb(db)) {
>  				hdmi = db;
>  				hdmi_len = dbl;
> @@ -2787,7 +2863,8 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
>  	 * be patching their flags when the sink supports stereo 3D.
>  	 */
>  	if (hdmi)
> -		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len);
> +		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video,
> +					    video_len);
>  
>  	return modes;
>  }
> -- 
> 1.8.3.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm: add support for additional stereo 3D modes
  2013-10-11 11:12 ` [Intel-gfx] " Ville Syrjälä
@ 2013-10-11 12:09   ` Damien Lespiau
  2013-10-15 17:25   ` Thomas Wood
  1 sibling, 0 replies; 10+ messages in thread
From: Damien Lespiau @ 2013-10-11 12:09 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Thomas Wood, dri-devel

On Fri, Oct 11, 2013 at 02:12:14PM +0300, Ville Syrjälä wrote:
> On Thu, Oct 10, 2013 at 02:19:15PM +0100, Thomas Wood wrote:
> > +static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
> > +			       const u8 *video_db, u8 video_len, u8 video_index)
> > +{
> > +	struct drm_device *dev = connector->dev;
> > +	struct drm_display_mode *newmode;
> > +	int modes = 0;
> > +	u8 cea_mode;
> > +
> > +	if (video_db == NULL || video_index > video_len)
> > +		return 0;
> > +
> > +	/* CEA modes are numbered 1..127 */
> > +	cea_mode = (video_db[video_index] & 127) - 1;
> > +	if (cea_mode >= ARRAY_SIZE(edid_cea_modes))
> > +		return 0;
> > +
> > +	if (structure & 1) {
> 
> I'm also wondering if some displays might include some of the mandatory
> modes in 3D_Structure_ALL, and if so should we filter out the
> duplicates?

It can. Looks like drm_mode_connector_list_update() should be taking
care of the duplicated modes.

-- 
Damien

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm: add support for additional stereo 3D modes
  2013-10-10 13:19 [PATCH] drm: add support for additional stereo 3D modes Thomas Wood
  2013-10-11 11:12 ` [Intel-gfx] " Ville Syrjälä
@ 2013-10-11 15:59 ` Damien Lespiau
  1 sibling, 0 replies; 10+ messages in thread
From: Damien Lespiau @ 2013-10-11 15:59 UTC (permalink / raw)
  To: Thomas Wood; +Cc: intel-gfx, dri-devel

On Thu, Oct 10, 2013 at 02:19:15PM +0100, Thomas Wood wrote:
> +	if ((multi_present == 1 || multi_present == 2) &&

You could use the awesome binary literals gcc extension here and 0b01
and 0b10 to be even closer to the spec wording.

There's a precedent in drivers/watchdog/sunxi_wdt.c!

-- 
Damien

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] drm: add support for additional stereo 3D modes
  2013-10-11 11:12 ` [Intel-gfx] " Ville Syrjälä
  2013-10-11 12:09   ` Damien Lespiau
@ 2013-10-15 17:25   ` Thomas Wood
  2013-10-15 17:25     ` [PATCH v2] " Thomas Wood
  1 sibling, 1 reply; 10+ messages in thread
From: Thomas Wood @ 2013-10-15 17:25 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, dri-devel

On 11 October 2013 12:12, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Thu, Oct 10, 2013 at 02:19:15PM +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.
>>
>> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
>> ---
>>  drivers/gpu/drm/drm_edid.c | 93 ++++++++++++++++++++++++++++++++++++++++++----
>>  1 file changed, 85 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>> index 9e81609..b3949f9 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 *connector, u8 vic)
>>       return 1;
>>  }
>>
>> +static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
>> +                            const u8 *video_db, u8 video_len, u8 video_index)
>> +{
>> +     struct drm_device *dev = connector->dev;
>> +     struct drm_display_mode *newmode;
>> +     int modes = 0;
>> +     u8 cea_mode;
>> +
>> +     if (video_db == NULL || video_index > video_len)
>> +             return 0;
>> +
>> +     /* CEA modes are numbered 1..127 */
>> +     cea_mode = (video_db[video_index] & 127) - 1;
>> +     if (cea_mode >= ARRAY_SIZE(edid_cea_modes))
>> +             return 0;
>> +
>> +     if (structure & 1) {
>
> Could use (1 << 0) for consistency.

I've updated this for v2.

>
> I'm also wondering if some displays might include some of the mandatory
> modes in 3D_Structure_ALL, and if so should we filter out the
> duplicates?

As Damien mentioned, duplicates are filtered out later on.

>
>> +     if ((multi_present == 1 || multi_present == 2) &&
>> +         len >= (9 + offset)) {
>
> If multi_present==2 and len is too small for the mask, I think we should
> skip adding the modes since the block is clearly incorrect/corrupted.
>
> So maybe just something like this:
>  if ((multi_present == 1 && len < (9 + offset)) ||
>      (multi_present == 2 && len < (11 + offset)))
>      goto out;

I've added this check to v2 and also made sure multi_present is either 1 or 2
before continuing.

>
> I would also add a similar check for HDMI_3D_LEN since that is
> supposed to include the space required by 3D_Structure_ALL and
> 3D_MASK. Or you could just check HDMI_3D_LEN against 'len' and bail
> out if that doesn't fit. And then you could just check
> 3D_Structure_ALL and 3D_MASK against HDMI_3D_LEN.
>

I've added a check to ensure the value of HDMI_3D_LEN is large enough to
include 3D_Structure_ALL and 3D_MASK, if they are present.

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] drm: add support for additional stereo 3D modes
  2013-10-15 17:25   ` Thomas Wood
@ 2013-10-15 17:25     ` Thomas Wood
  2013-10-15 17:55       ` Ville Syrjälä
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Wood @ 2013-10-15 17:25 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, dri-devel

Parse the 3D_Structure_ALL and 3D_MASK fields of the HDMI Vendor
Specific Data Block to expose more stereo 3D modes.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 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 *connector, u8 vic)
 	return 1;
 }
 
+static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
+			       const u8 *video_db, u8 video_len, u8 video_index)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_display_mode *newmode;
+	int modes = 0;
+	u8 cea_mode;
+
+	if (video_db == NULL || video_index > video_len)
+		return 0;
+
+	/* CEA modes are numbered 1..127 */
+	cea_mode = (video_db[video_index] & 127) - 1;
+	if (cea_mode >= ARRAY_SIZE(edid_cea_modes))
+		return 0;
+
+	if (structure & (1 << 0)) {
+		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
+		if (newmode) {
+			newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING;
+			drm_mode_probed_add(connector, newmode);
+			modes++;
+		}
+	}
+	if (structure & (1 << 6)) {
+		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
+		if (newmode) {
+			newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM;
+			drm_mode_probed_add(connector, newmode);
+			modes++;
+		}
+	}
+	if (structure & (1 << 8)) {
+		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
+		if (newmode) {
+			newmode->flags = 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 *connector, 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 = 0, offset = 0, i;
-	u8 vic_len;
+	int modes = 0, offset = 0, i, multi_present = 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 += add_hdmi_mandatory_stereo_modes(connector);
 
+		/* 3D_Multi_present */
+		multi_present = (db[8 + offset] & 0x60) >> 5;
+	}
+
 	offset++;
 	vic_len = db[8 + offset] >> 5;
 
@@ -2702,6 +2753,38 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len)
 		modes += add_hdmi_mode(connector, vic);
 	}
 
+	if (!(multi_present == 1 || multi_present == 2))
+		goto out;
+
+	if ((multi_present == 1 && len < (9 + offset)) ||
+	    (multi_present == 2 && len < (11 + offset)))
+		goto out;
+
+	hdmi_3d_len = db[8 + offset] & 0x1f;
+
+	if ((multi_present == 1 && hdmi_3d_len < 2) ||
+	    (multi_present == 2 && hdmi_3d_len < 4))
+		goto out;
+
+	offset += 1 + vic_len;
+
+	/* 3D_Structure_ALL */
+	structure_all = (db[8 + offset] << 8) | db[9 + offset];
+
+	/* check if 3D_MASK is present */
+	if (multi_present == 2)
+		mask = (db[10 + offset] << 8) | db[11 + offset];
+	else
+		mask = 0xffff;
+
+	for (i = 0; i < 16; i++) {
+		if (mask & (1 << i))
+			modes += 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 = drm_find_cea_extension(edid);
-	const u8 *db, *hdmi = NULL;
-	u8 dbl, hdmi_len;
+	const u8 *db, *hdmi = NULL, *video = NULL;
+	u8 dbl, hdmi_len, video_len = 0;
 	int modes = 0;
 
 	if (cea && cea_revision(cea) >= 3) {
@@ -2773,8 +2856,11 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
 			db = &cea[i];
 			dbl = cea_db_payload_len(db);
 
-			if (cea_db_tag(db) == VIDEO_BLOCK)
-				modes += do_cea_modes(connector, db + 1, dbl);
+			if (cea_db_tag(db) == VIDEO_BLOCK) {
+				video = db + 1;
+				video_len = dbl;
+				modes += do_cea_modes(connector, video, dbl);
+			}
 			else if (cea_db_is_hdmi_vsdb(db)) {
 				hdmi = db;
 				hdmi_len = dbl;
@@ -2787,7 +2873,8 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
 	 * be patching their flags when the sink supports stereo 3D.
 	 */
 	if (hdmi)
-		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len);
+		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video,
+					    video_len);
 
 	return modes;
 }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] drm: add support for additional stereo 3D modes
  2013-10-15 17:25     ` [PATCH v2] " Thomas Wood
@ 2013-10-15 17:55       ` Ville Syrjälä
  2013-10-16 14:58         ` [PATCH v3] " Thomas Wood
  0 siblings, 1 reply; 10+ messages in thread
From: Ville Syrjälä @ 2013-10-15 17:55 UTC (permalink / raw)
  To: Thomas Wood; +Cc: intel-gfx, dri-devel

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 <thomas.wood@intel.com>
> ---
>  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 *connector, u8 vic)
>  	return 1;
>  }
>  
> +static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
> +			       const u8 *video_db, u8 video_len, u8 video_index)
> +{
> +	struct drm_device *dev = connector->dev;
> +	struct drm_display_mode *newmode;
> +	int modes = 0;
> +	u8 cea_mode;
> +
> +	if (video_db == NULL || video_index > video_len)
> +		return 0;
> +
> +	/* CEA modes are numbered 1..127 */
> +	cea_mode = (video_db[video_index] & 127) - 1;
> +	if (cea_mode >= ARRAY_SIZE(edid_cea_modes))
> +		return 0;
> +
> +	if (structure & (1 << 0)) {
> +		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
> +		if (newmode) {
> +			newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING;
> +			drm_mode_probed_add(connector, newmode);
> +			modes++;
> +		}
> +	}
> +	if (structure & (1 << 6)) {
> +		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
> +		if (newmode) {
> +			newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM;
> +			drm_mode_probed_add(connector, newmode);
> +			modes++;
> +		}
> +	}
> +	if (structure & (1 << 8)) {
> +		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
> +		if (newmode) {
> +			newmode->flags = 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 *connector, 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 = 0, offset = 0, i;
> -	u8 vic_len;
> +	int modes = 0, offset = 0, i, multi_present = 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 += add_hdmi_mandatory_stereo_modes(connector);
>  
> +		/* 3D_Multi_present */
> +		multi_present = (db[8 + offset] & 0x60) >> 5;
> +	}
> +
>  	offset++;
>  	vic_len = db[8 + offset] >> 5;
>  
> @@ -2702,6 +2753,38 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len)
>  		modes += add_hdmi_mode(connector, vic);
>  	}
>  
> +	if (!(multi_present == 1 || multi_present == 2))
> +		goto out;
> +
> +	if ((multi_present == 1 && len < (9 + offset)) ||
> +	    (multi_present == 2 && len < (11 + offset)))
> +		goto out;

These checks must happen after 'offset += 1 + vic_len'.

Otherwise it looks good to me.

> +
> +	hdmi_3d_len = db[8 + offset] & 0x1f;
> +
> +	if ((multi_present == 1 && hdmi_3d_len < 2) ||
> +	    (multi_present == 2 && hdmi_3d_len < 4))
> +		goto out;
> +
> +	offset += 1 + vic_len;
> +
> +	/* 3D_Structure_ALL */
> +	structure_all = (db[8 + offset] << 8) | db[9 + offset];
> +
> +	/* check if 3D_MASK is present */
> +	if (multi_present == 2)
> +		mask = (db[10 + offset] << 8) | db[11 + offset];
> +	else
> +		mask = 0xffff;
> +
> +	for (i = 0; i < 16; i++) {
> +		if (mask & (1 << i))
> +			modes += 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 = drm_find_cea_extension(edid);
> -	const u8 *db, *hdmi = NULL;
> -	u8 dbl, hdmi_len;
> +	const u8 *db, *hdmi = NULL, *video = NULL;
> +	u8 dbl, hdmi_len, video_len = 0;
>  	int modes = 0;
>  
>  	if (cea && cea_revision(cea) >= 3) {
> @@ -2773,8 +2856,11 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
>  			db = &cea[i];
>  			dbl = cea_db_payload_len(db);
>  
> -			if (cea_db_tag(db) == VIDEO_BLOCK)
> -				modes += do_cea_modes(connector, db + 1, dbl);
> +			if (cea_db_tag(db) == VIDEO_BLOCK) {
> +				video = db + 1;
> +				video_len = dbl;
> +				modes += do_cea_modes(connector, video, dbl);
> +			}
>  			else if (cea_db_is_hdmi_vsdb(db)) {
>  				hdmi = db;
>  				hdmi_len = dbl;
> @@ -2787,7 +2873,8 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
>  	 * be patching their flags when the sink supports stereo 3D.
>  	 */
>  	if (hdmi)
> -		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len);
> +		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video,
> +					    video_len);
>  
>  	return modes;
>  }
> -- 
> 1.8.3.1

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3] drm: add support for additional stereo 3D modes
  2013-10-15 17:55       ` Ville Syrjälä
@ 2013-10-16 14:58         ` Thomas Wood
  2013-10-16 15:07           ` Ville Syrjälä
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Wood @ 2013-10-16 14:58 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx, dri-devel

Parse the 3D_Structure_ALL and 3D_MASK fields of the HDMI Vendor
Specific Data Block to expose more stereo 3D modes.

v2: Use (1 << 0) for consistency. (Ville Syrjälä)
    Skip adding any modes if 3D_MASK is indicated as being present but
    the length only includes 3D_Structure_ALL. (Ville Syrjälä)
    Check that the value of HDMI_3D_LEN is large enough to include
    3D_Structure_ALL and 3D_MASK, if they are present. (Ville Syrjälä)
v3: Increment offset before the length checks. (Ville Syrjälä)

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 drivers/gpu/drm/drm_edid.c | 103 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 94 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 9e81609..f1764ec 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 *connector, u8 vic)
 	return 1;
 }
 
+static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
+			       const u8 *video_db, u8 video_len, u8 video_index)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_display_mode *newmode;
+	int modes = 0;
+	u8 cea_mode;
+
+	if (video_db == NULL || video_index > video_len)
+		return 0;
+
+	/* CEA modes are numbered 1..127 */
+	cea_mode = (video_db[video_index] & 127) - 1;
+	if (cea_mode >= ARRAY_SIZE(edid_cea_modes))
+		return 0;
+
+	if (structure & (1 << 0)) {
+		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
+		if (newmode) {
+			newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING;
+			drm_mode_probed_add(connector, newmode);
+			modes++;
+		}
+	}
+	if (structure & (1 << 6)) {
+		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
+		if (newmode) {
+			newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM;
+			drm_mode_probed_add(connector, newmode);
+			modes++;
+		}
+	}
+	if (structure & (1 << 8)) {
+		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
+		if (newmode) {
+			newmode->flags = 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 *connector, 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 = 0, offset = 0, i;
-	u8 vic_len;
+	int modes = 0, offset = 0, i, multi_present = 0;
+	u8 vic_len, hdmi_3d_len = 0;
+	u16 mask;
+	u16 structure_all;
 
 	if (len < 8)
 		goto out;
@@ -2689,11 +2736,16 @@ 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 += add_hdmi_mandatory_stereo_modes(connector);
 
+		/* 3D_Multi_present */
+		multi_present = (db[8 + offset] & 0x60) >> 5;
+	}
+
 	offset++;
 	vic_len = db[8 + offset] >> 5;
+	hdmi_3d_len = db[8 + offset] & 0x1f;
 
 	for (i = 0; i < vic_len && len >= (9 + offset + i); i++) {
 		u8 vic;
@@ -2701,6 +2753,35 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len)
 		vic = db[9 + offset + i];
 		modes += add_hdmi_mode(connector, vic);
 	}
+	offset += 1 + vic_len;
+
+	if (!(multi_present == 1 || multi_present == 2))
+		goto out;
+
+	if ((multi_present == 1 && len < (9 + offset)) ||
+	    (multi_present == 2 && len < (11 + offset)))
+		goto out;
+
+	if ((multi_present == 1 && hdmi_3d_len < 2) ||
+	    (multi_present == 2 && hdmi_3d_len < 4))
+		goto out;
+
+	/* 3D_Structure_ALL */
+	structure_all = (db[8 + offset] << 8) | db[9 + offset];
+
+	/* check if 3D_MASK is present */
+	if (multi_present == 2)
+		mask = (db[10 + offset] << 8) | db[11 + offset];
+	else
+		mask = 0xffff;
+
+	for (i = 0; i < 16; i++) {
+		if (mask & (1 << i))
+			modes += add_3d_struct_modes(connector,
+						     structure_all,
+						     video_db,
+						     video_len, i);
+	}
 
 out:
 	return modes;
@@ -2759,8 +2840,8 @@ static int
 add_cea_modes(struct drm_connector *connector, struct edid *edid)
 {
 	const u8 *cea = drm_find_cea_extension(edid);
-	const u8 *db, *hdmi = NULL;
-	u8 dbl, hdmi_len;
+	const u8 *db, *hdmi = NULL, *video = NULL;
+	u8 dbl, hdmi_len, video_len = 0;
 	int modes = 0;
 
 	if (cea && cea_revision(cea) >= 3) {
@@ -2773,8 +2854,11 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
 			db = &cea[i];
 			dbl = cea_db_payload_len(db);
 
-			if (cea_db_tag(db) == VIDEO_BLOCK)
-				modes += do_cea_modes(connector, db + 1, dbl);
+			if (cea_db_tag(db) == VIDEO_BLOCK) {
+				video = db + 1;
+				video_len = dbl;
+				modes += do_cea_modes(connector, video, dbl);
+			}
 			else if (cea_db_is_hdmi_vsdb(db)) {
 				hdmi = db;
 				hdmi_len = dbl;
@@ -2787,7 +2871,8 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
 	 * be patching their flags when the sink supports stereo 3D.
 	 */
 	if (hdmi)
-		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len);
+		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video,
+					    video_len);
 
 	return modes;
 }
-- 
1.8.3.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v3] drm: add support for additional stereo 3D modes
  2013-10-16 14:58         ` [PATCH v3] " Thomas Wood
@ 2013-10-16 15:07           ` Ville Syrjälä
  2013-10-16 17:48             ` Daniel Vetter
  0 siblings, 1 reply; 10+ messages in thread
From: Ville Syrjälä @ 2013-10-16 15:07 UTC (permalink / raw)
  To: Thomas Wood; +Cc: intel-gfx, dri-devel

On Wed, Oct 16, 2013 at 03:58:50PM +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.
> 
> v2: Use (1 << 0) for consistency. (Ville Syrjälä)
>     Skip adding any modes if 3D_MASK is indicated as being present but
>     the length only includes 3D_Structure_ALL. (Ville Syrjälä)
>     Check that the value of HDMI_3D_LEN is large enough to include
>     3D_Structure_ALL and 3D_MASK, if they are present. (Ville Syrjälä)
> v3: Increment offset before the length checks. (Ville Syrjälä)
> 
> Signed-off-by: Thomas Wood <thomas.wood@intel.com>

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 103 +++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 94 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 9e81609..f1764ec 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 *connector, u8 vic)
>  	return 1;
>  }
>  
> +static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
> +			       const u8 *video_db, u8 video_len, u8 video_index)
> +{
> +	struct drm_device *dev = connector->dev;
> +	struct drm_display_mode *newmode;
> +	int modes = 0;
> +	u8 cea_mode;
> +
> +	if (video_db == NULL || video_index > video_len)
> +		return 0;
> +
> +	/* CEA modes are numbered 1..127 */
> +	cea_mode = (video_db[video_index] & 127) - 1;
> +	if (cea_mode >= ARRAY_SIZE(edid_cea_modes))
> +		return 0;
> +
> +	if (structure & (1 << 0)) {
> +		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
> +		if (newmode) {
> +			newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING;
> +			drm_mode_probed_add(connector, newmode);
> +			modes++;
> +		}
> +	}
> +	if (structure & (1 << 6)) {
> +		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
> +		if (newmode) {
> +			newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM;
> +			drm_mode_probed_add(connector, newmode);
> +			modes++;
> +		}
> +	}
> +	if (structure & (1 << 8)) {
> +		newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
> +		if (newmode) {
> +			newmode->flags = 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 *connector, 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 = 0, offset = 0, i;
> -	u8 vic_len;
> +	int modes = 0, offset = 0, i, multi_present = 0;
> +	u8 vic_len, hdmi_3d_len = 0;
> +	u16 mask;
> +	u16 structure_all;
>  
>  	if (len < 8)
>  		goto out;
> @@ -2689,11 +2736,16 @@ 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 += add_hdmi_mandatory_stereo_modes(connector);
>  
> +		/* 3D_Multi_present */
> +		multi_present = (db[8 + offset] & 0x60) >> 5;
> +	}
> +
>  	offset++;
>  	vic_len = db[8 + offset] >> 5;
> +	hdmi_3d_len = db[8 + offset] & 0x1f;
>  
>  	for (i = 0; i < vic_len && len >= (9 + offset + i); i++) {
>  		u8 vic;
> @@ -2701,6 +2753,35 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len)
>  		vic = db[9 + offset + i];
>  		modes += add_hdmi_mode(connector, vic);
>  	}
> +	offset += 1 + vic_len;
> +
> +	if (!(multi_present == 1 || multi_present == 2))
> +		goto out;
> +
> +	if ((multi_present == 1 && len < (9 + offset)) ||
> +	    (multi_present == 2 && len < (11 + offset)))
> +		goto out;
> +
> +	if ((multi_present == 1 && hdmi_3d_len < 2) ||
> +	    (multi_present == 2 && hdmi_3d_len < 4))
> +		goto out;
> +
> +	/* 3D_Structure_ALL */
> +	structure_all = (db[8 + offset] << 8) | db[9 + offset];
> +
> +	/* check if 3D_MASK is present */
> +	if (multi_present == 2)
> +		mask = (db[10 + offset] << 8) | db[11 + offset];
> +	else
> +		mask = 0xffff;
> +
> +	for (i = 0; i < 16; i++) {
> +		if (mask & (1 << i))
> +			modes += add_3d_struct_modes(connector,
> +						     structure_all,
> +						     video_db,
> +						     video_len, i);
> +	}
>  
>  out:
>  	return modes;
> @@ -2759,8 +2840,8 @@ static int
>  add_cea_modes(struct drm_connector *connector, struct edid *edid)
>  {
>  	const u8 *cea = drm_find_cea_extension(edid);
> -	const u8 *db, *hdmi = NULL;
> -	u8 dbl, hdmi_len;
> +	const u8 *db, *hdmi = NULL, *video = NULL;
> +	u8 dbl, hdmi_len, video_len = 0;
>  	int modes = 0;
>  
>  	if (cea && cea_revision(cea) >= 3) {
> @@ -2773,8 +2854,11 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
>  			db = &cea[i];
>  			dbl = cea_db_payload_len(db);
>  
> -			if (cea_db_tag(db) == VIDEO_BLOCK)
> -				modes += do_cea_modes(connector, db + 1, dbl);
> +			if (cea_db_tag(db) == VIDEO_BLOCK) {
> +				video = db + 1;
> +				video_len = dbl;
> +				modes += do_cea_modes(connector, video, dbl);
> +			}
>  			else if (cea_db_is_hdmi_vsdb(db)) {
>  				hdmi = db;
>  				hdmi_len = dbl;
> @@ -2787,7 +2871,8 @@ add_cea_modes(struct drm_connector *connector, struct edid *edid)
>  	 * be patching their flags when the sink supports stereo 3D.
>  	 */
>  	if (hdmi)
> -		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len);
> +		modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video,
> +					    video_len);
>  
>  	return modes;
>  }
> -- 
> 1.8.3.1

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3] drm: add support for additional stereo 3D modes
  2013-10-16 15:07           ` Ville Syrjälä
@ 2013-10-16 17:48             ` Daniel Vetter
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Vetter @ 2013-10-16 17:48 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Thomas Wood, dri-devel

On Wed, Oct 16, 2013 at 06:07:30PM +0300, Ville Syrjälä wrote:
> On Wed, Oct 16, 2013 at 03:58:50PM +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.
> > 
> > v2: Use (1 << 0) for consistency. (Ville Syrjälä)
> >     Skip adding any modes if 3D_MASK is indicated as being present but
> >     the length only includes 3D_Structure_ALL. (Ville Syrjälä)
> >     Check that the value of HDMI_3D_LEN is large enough to include
> >     3D_Structure_ALL and 3D_MASK, if they are present. (Ville Syrjälä)
> > v3: Increment offset before the length checks. (Ville Syrjälä)
> > 
> > Signed-off-by: Thomas Wood <thomas.wood@intel.com>
> 
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Queued for -next, thanks for the patch.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-10-16 17:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-10 13:19 [PATCH] drm: add support for additional stereo 3D modes Thomas Wood
2013-10-11 11:12 ` [Intel-gfx] " Ville Syrjälä
2013-10-11 12:09   ` Damien Lespiau
2013-10-15 17:25   ` Thomas Wood
2013-10-15 17:25     ` [PATCH v2] " Thomas Wood
2013-10-15 17:55       ` Ville Syrjälä
2013-10-16 14:58         ` [PATCH v3] " Thomas Wood
2013-10-16 15:07           ` Ville Syrjälä
2013-10-16 17:48             ` Daniel Vetter
2013-10-11 15:59 ` [PATCH] " Damien Lespiau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox