[PATCH v4 0/2] Enhance EDID quirks to allow forcing a mode

2013-06-18 Thread Dylan Semler
Checking up on this patch from a few months back that I'd like to get
included..  Acked by Daniel Vetter[1] and Reviewed by Jani Nikula[2].
 However ajax has not yet provided comments.  Is this SOL without feedback
from ajax?

[1] http://lists.freedesktop.org/archives/dri-devel/2013-March/036457.html
[2] http://lists.freedesktop.org/archives/dri-devel/2013-April/036829.html


On Mon, Mar 25, 2013 at 5:58 PM, Dylan Semler wrote:

> Changes in this version
>  * rename do_force_quirk_modes() -> do_force_quirk_mode()
>  * use list_for_each_entry() instead of list_for_each_entry_safe() in
>do_force_quirk_mode()
>  * remove num_modes from do_force_quirk_mode(), just return 1 or 0 as
>appropriate
>  * remove unused quirks argument from add_force_quirk_modes()
>  * fixes to allow cases of forcing multiple modes
>  * adjusted comments to adhere closer to style guides
>
> Changes in version 3
>  * Uses drm_cvt_mode() instead of drm_gtf_mode() to build modeline
>  * Adds bool to specify reduced blanking to edid_quirk_force_mode
>  * Removes preferred bit from all other modes
>
> Changes in version 2
>  * none
>
> There is at least one monitor that doesn't report its native resolution
> in its EDID block.  This enhancement extends the EDID quirk logic to
> make monitors like this "just work".
>
> The first patch in this series sets up a new quirk list where monitors'
> correct width, height, refresh rate, and reduced blanking parameters are
> specified.  When a matching monitor is attached the full mode is
> calculated with drm_cvt_mode() and added to the connector.  The
> DRM_MODE_TYPE_PREFERRED bit is set on the new mode and unset from all
> other modes.
>
> The first patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.
> This bit needs to be set for the new quirk list described above to be
> checked.
>
> The second patch adds the offending monitor to the quirk lists.
>
> Dylan Semler (2):
>   drm: Enhance EDID quirks to explicitly set a mode
>   drm: Add EDID force quirk for MMT Monitor2Go HD+
>
>  drivers/gpu/drm/drm_edid.c | 89
> ++
>  1 file changed, 89 insertions(+)
>
> --
> 1.7.11.7
>
>
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130618/f791e077/attachment.html>


Re: [PATCH v4 0/2] Enhance EDID quirks to allow forcing a mode

2013-06-18 Thread Dylan Semler
Checking up on this patch from a few months back that I'd like to get
included..  Acked by Daniel Vetter[1] and Reviewed by Jani Nikula[2].
 However ajax has not yet provided comments.  Is this SOL without feedback
from ajax?

[1] http://lists.freedesktop.org/archives/dri-devel/2013-March/036457.html
[2] http://lists.freedesktop.org/archives/dri-devel/2013-April/036829.html


On Mon, Mar 25, 2013 at 5:58 PM, Dylan Semler dylan.sem...@gmail.comwrote:

 Changes in this version
  * rename do_force_quirk_modes() - do_force_quirk_mode()
  * use list_for_each_entry() instead of list_for_each_entry_safe() in
do_force_quirk_mode()
  * remove num_modes from do_force_quirk_mode(), just return 1 or 0 as
appropriate
  * remove unused quirks argument from add_force_quirk_modes()
  * fixes to allow cases of forcing multiple modes
  * adjusted comments to adhere closer to style guides

 Changes in version 3
  * Uses drm_cvt_mode() instead of drm_gtf_mode() to build modeline
  * Adds bool to specify reduced blanking to edid_quirk_force_mode
  * Removes preferred bit from all other modes

 Changes in version 2
  * none

 There is at least one monitor that doesn't report its native resolution
 in its EDID block.  This enhancement extends the EDID quirk logic to
 make monitors like this just work.

 The first patch in this series sets up a new quirk list where monitors'
 correct width, height, refresh rate, and reduced blanking parameters are
 specified.  When a matching monitor is attached the full mode is
 calculated with drm_cvt_mode() and added to the connector.  The
 DRM_MODE_TYPE_PREFERRED bit is set on the new mode and unset from all
 other modes.

 The first patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.
 This bit needs to be set for the new quirk list described above to be
 checked.

 The second patch adds the offending monitor to the quirk lists.

 Dylan Semler (2):
   drm: Enhance EDID quirks to explicitly set a mode
   drm: Add EDID force quirk for MMT Monitor2Go HD+

  drivers/gpu/drm/drm_edid.c | 89
 ++
  1 file changed, 89 insertions(+)

 --
 1.7.11.7


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


[PATCH v4 0/2] Enhance EDID quirks to allow forcing a mode

2013-04-03 Thread Dylan Semler
On Mon, Mar 25, 2013 at 5:58 PM, Dylan Semler 
wrote:
>
> Changes in this version
>  * rename do_force_quirk_modes() -> do_force_quirk_mode()
>  * use list_for_each_entry() instead of list_for_each_entry_safe() in
>do_force_quirk_mode()
>  * remove num_modes from do_force_quirk_mode(), just return 1 or 0 as
>appropriate
>  * remove unused quirks argument from add_force_quirk_modes()
>  * fixes to allow cases of forcing multiple modes
>  * adjusted comments to adhere closer to style guides
>
> Changes in version 3
>  * Uses drm_cvt_mode() instead of drm_gtf_mode() to build modeline
>  * Adds bool to specify reduced blanking to edid_quirk_force_mode
>  * Removes preferred bit from all other modes
>
> Changes in version 2
>  * none
>
> There is at least one monitor that doesn't report its native resolution
> in its EDID block.  This enhancement extends the EDID quirk logic to
> make monitors like this "just work".
>
> The first patch in this series sets up a new quirk list where monitors'
> correct width, height, refresh rate, and reduced blanking parameters are
> specified.  When a matching monitor is attached the full mode is
> calculated with drm_cvt_mode() and added to the connector.  The
> DRM_MODE_TYPE_PREFERRED bit is set on the new mode and unset from all
> other modes.
>
> The first patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.
> This bit needs to be set for the new quirk list described above to be
> checked.
>
> The second patch adds the offending monitor to the quirk lists.
>
> Dylan Semler (2):
>   drm: Enhance EDID quirks to explicitly set a mode
>   drm: Add EDID force quirk for MMT Monitor2Go HD+
>
>  drivers/gpu/drm/drm_edid.c | 89
++
>  1 file changed, 89 insertions(+)
>
> --
> 1.7.11.7
>

Version 3 was Acked by Daniel Vetter[1].  Any chance ajax can give his
comments?

[1] http://lists.freedesktop.org/archives/dri-devel/2013-March/036457.html
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130403/d150444a/attachment.html>


Re: [PATCH v4 0/2] Enhance EDID quirks to allow forcing a mode

2013-04-03 Thread Dylan Semler
On Mon, Mar 25, 2013 at 5:58 PM, Dylan Semler dylan.sem...@gmail.com
wrote:

 Changes in this version
  * rename do_force_quirk_modes() - do_force_quirk_mode()
  * use list_for_each_entry() instead of list_for_each_entry_safe() in
do_force_quirk_mode()
  * remove num_modes from do_force_quirk_mode(), just return 1 or 0 as
appropriate
  * remove unused quirks argument from add_force_quirk_modes()
  * fixes to allow cases of forcing multiple modes
  * adjusted comments to adhere closer to style guides

 Changes in version 3
  * Uses drm_cvt_mode() instead of drm_gtf_mode() to build modeline
  * Adds bool to specify reduced blanking to edid_quirk_force_mode
  * Removes preferred bit from all other modes

 Changes in version 2
  * none

 There is at least one monitor that doesn't report its native resolution
 in its EDID block.  This enhancement extends the EDID quirk logic to
 make monitors like this just work.

 The first patch in this series sets up a new quirk list where monitors'
 correct width, height, refresh rate, and reduced blanking parameters are
 specified.  When a matching monitor is attached the full mode is
 calculated with drm_cvt_mode() and added to the connector.  The
 DRM_MODE_TYPE_PREFERRED bit is set on the new mode and unset from all
 other modes.

 The first patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.
 This bit needs to be set for the new quirk list described above to be
 checked.

 The second patch adds the offending monitor to the quirk lists.

 Dylan Semler (2):
   drm: Enhance EDID quirks to explicitly set a mode
   drm: Add EDID force quirk for MMT Monitor2Go HD+

  drivers/gpu/drm/drm_edid.c | 89
++
  1 file changed, 89 insertions(+)

 --
 1.7.11.7


Version 3 was Acked by Daniel Vetter[1].  Any chance ajax can give his
comments?

[1] http://lists.freedesktop.org/archives/dri-devel/2013-March/036457.html
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 2/2] drm: Add EDID force quirk for MMT Monitor2Go HD+

2013-03-25 Thread Dylan Semler
Set the new EDID_QUIRK_FORCE_MODE bit for the MMT Monitor2Go HD+ monitor
and add it to the edid_quirk_force_mode_list.

Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index f8f3a4a..c747e08 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -109,6 +109,9 @@ static struct edid_quirk {
{ "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 |
  EDID_QUIRK_DETAILED_IN_CM },

+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, EDID_QUIRK_FORCE_MODE},
+
/* LG Philips LCD LP154W01-A5 */
{ "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
{ "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
@@ -143,6 +146,8 @@ static struct edid_quirk_force_mode {
int vrefresh;   /* refresh rate */
bool reduced;   /* reduce blanking */
 } edid_quirk_force_mode_list[] = {
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, 1600, 900, 60, 1 },
 };

 /*
-- 
1.7.11.7



[PATCH v4 1/2] drm: Enhance EDID quirks to explicitly set a mode

2013-03-25 Thread Dylan Semler
There is at least one monitor that doesn't report its native resolution
in its EDID block.  This enhancement extends the EDID quirk logic to
make monitors like this "just work".

This patch sets up a new quirk list where monitors' correct width,
height, refresh rate, and reduced blanking parameters are specified.
When a matching monitor is attached the full mode is calculated with
drm_cvt_mode() and added to the connector.  The DRM_MODE_TYPE_PREFERRED
bit is set on the new mode and unset from all other modes.

The patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.  This
bit needs to be set for the new quirk list discribed above to be
checked.

Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 77 ++
 1 file changed, 77 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..f8f3a4a 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1 << 6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1 << 7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1 << 8)

 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -128,6 +130,22 @@ static struct edid_quirk {
 };

 /*
+ * Displays that don't report a desired mode in their EDID block that cannot be
+ * resolved with a quirk from above are specified here.  If multiple modes need
+ * to be forced for the same display, the most preferred should be last; that
+ * is what the display will be initialized with.
+ */
+static struct edid_quirk_force_mode {
+   char vendor[4]; /* vendor ID */
+   int product_id; /* product ID */
+   int hdisplay;   /* horizontal resolution */
+   int vdisplay;   /* vertical resolution */
+   int vrefresh;   /* refresh rate */
+   bool reduced;   /* reduce blanking */
+} edid_quirk_force_mode_list[] = {
+};
+
+/*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
  */
@@ -2219,6 +2237,63 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }

+/*
+ * Add forced mode according to the matching quirk, set it as preferred,
+ * and remove the preferred bit from all other modes.
+ */
+static int
+do_force_quirk_mode(struct drm_connector *connector, int hdisplay,
+   int vdisplay, int vrefresh, bool reduced)
+{
+   struct drm_display_mode *mode, *cur_mode;
+   struct drm_device *dev = connector->dev;
+
+   if (hdisplay < 0)
+   return 0;
+   if (vdisplay < 0)
+   return 0;
+   if (vrefresh < 0)
+   return 0;
+
+   list_for_each_entry(cur_mode, >probed_modes, head)
+   cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED;
+
+   mode = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, reduced, 0, 0);
+
+   if (!mode)
+   return 0;
+
+   mode->type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   return 1;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID force mode quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i < ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = _quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode->vendor) &&
+   (EDID_PRODUCT_ID(edid) == quirk_mode->product_id))
+   num_modes += do_force_quirk_mode(connector,
+   quirk_mode->hdisplay,
+   quirk_mode->vdisplay,
+   quirk_mode->vrefresh,
+   quirk_mode->reduced);
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2878,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)

if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid);

drm_add_display_info(edid, >display_info);

-- 
1.7.11.7



[PATCH v4 0/2] Enhance EDID quirks to allow forcing a mode

2013-03-25 Thread Dylan Semler
Changes in this version
 * rename do_force_quirk_modes() -> do_force_quirk_mode()
 * use list_for_each_entry() instead of list_for_each_entry_safe() in
   do_force_quirk_mode()
 * remove num_modes from do_force_quirk_mode(), just return 1 or 0 as
   appropriate
 * remove unused quirks argument from add_force_quirk_modes()
 * fixes to allow cases of forcing multiple modes
 * adjusted comments to adhere closer to style guides

Changes in version 3
 * Uses drm_cvt_mode() instead of drm_gtf_mode() to build modeline
 * Adds bool to specify reduced blanking to edid_quirk_force_mode
 * Removes preferred bit from all other modes

Changes in version 2
 * none

There is at least one monitor that doesn't report its native resolution
in its EDID block.  This enhancement extends the EDID quirk logic to
make monitors like this "just work".

The first patch in this series sets up a new quirk list where monitors'
correct width, height, refresh rate, and reduced blanking parameters are
specified.  When a matching monitor is attached the full mode is
calculated with drm_cvt_mode() and added to the connector.  The
DRM_MODE_TYPE_PREFERRED bit is set on the new mode and unset from all
other modes.

The first patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.
This bit needs to be set for the new quirk list described above to be
checked.

The second patch adds the offending monitor to the quirk lists.

Dylan Semler (2):
  drm: Enhance EDID quirks to explicitly set a mode
  drm: Add EDID force quirk for MMT Monitor2Go HD+

 drivers/gpu/drm/drm_edid.c | 89 ++
 1 file changed, 89 insertions(+)

-- 
1.7.11.7



[PATCH v3 1/2] drm: Enhance EDID quirks to explicitly set a mode

2013-03-25 Thread Dylan Semler
On Mon, Mar 25, 2013 at 9:41 AM, Jani Nikula 
wrote:
>
>
> Hi, please find some review comments inline.
>

You make some good points, thanks.

> On Sat, 23 Mar 2013, Dylan Semler  wrote:
> >
> > +/* Add an explicit mode based on a quirk
> > + */
> > +static int
> > +do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
> > +  int vdisplay, int vrefresh, bool reduced)
>
> Nitpick: This adds one mode, not many _modes_.

sure, I'll fix.


> > +
> > + /* loop through the probed modes and clear the preferred bit */
> > + list_for_each_entry_safe(cur_mode, t, >probed_modes,
head)
> > + cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED;
>
> You're not deleting entries, so list_for_each_entry() would suffice,
> getting rid of the temp variable.
>

I was going to use this but I wasn't sure if I understood all of the
differences between the two.  I opted for _safe because I noticed it's used
in
edid_fixup_preferred() even though that routine doesn't remove entries
either.
I'll fix it.

> > +
> > + mode = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, reduced,
0, 0);
>
> You could
>
> if (!mode)
> return 0;
>
> here and get rid of the num_modes variable.

Yes, you're right.  I went with

if (mode) {
...
return 1;
}
else
return 0;

I would naively expect this to be better.  Is there a reason to prefer if
(!mode)?

> > +static int
> > +add_force_quirk_modes(struct drm_connector *connector, struct edid
*edid,
> > +   u32 quirks)
> > +{
> > + struct edid_quirk_force_mode *quirk_mode;
> > + int i, num_modes = 0;
> > +
> > + for (i = 0; i < ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
> > + quirk_mode = _quirk_force_mode_list[i];
> > +
> > + if (edid_vendor(edid, quirk_mode->vendor) &&
> > + (EDID_PRODUCT_ID(edid) == quirk_mode->product_id)) {
> > + num_modes = do_force_quirk_modes(connector,
> > + quirk_mode->hdisplay,
> > + quirk_mode->vdisplay,
> > + quirk_mode->vrefresh,
> > + quirk_mode->reduced);
>
> I was wondering why you don't bail out here. Maybe you want to be able
> to add more than one quirk mode? In that case you should +=, not = the
> num_modes.
>
> (Note that then do_force_quirk_modes makes the last one in the array the
> preferred mode, clearing the DRM_MODE_TYPE_PREFERRED from the previously
> added quirk modes.)

I thought about whether multiple forced modes would ever be needed.  I can't
imagine it would but it's easy enough to allow for it so we might as well
implement it now.

I think we'd want for it to be clear which of the forced modes will be used
and
so the current behavior of making the last one in the array preferred may be
the best.  I will add a comment by the edid_quirk_force_mode_list describing
this.


> > @@ -2803,6 +2879,8 @@ int drm_add_edid_modes(struct drm_connector
*connector, struct edid *edid)
> >
> >   if (quirks & (EDID_QUIRK_PREFER_LARGE_60 |
EDID_QUIRK_PREFER_LARGE_75))
> >   edid_fixup_preferred(connector, quirks);
> > + if (quirks & EDID_QUIRK_FORCE_MODE)
> > + num_modes += add_force_quirk_modes(connector, edid,
quirks);
>
> You don't use quirks within add_force_quirk_modes() for anything.

good point.  I'll remove it.


Thanks,
Dylan
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130325/9219dc95/attachment.html>


Re: [PATCH v3 1/2] drm: Enhance EDID quirks to explicitly set a mode

2013-03-25 Thread Dylan Semler
On Mon, Mar 25, 2013 at 9:41 AM, Jani Nikula jani.nik...@linux.intel.com
wrote:


 Hi, please find some review comments inline.


You make some good points, thanks.

 On Sat, 23 Mar 2013, Dylan Semler dylan.sem...@gmail.com wrote:
 
  +/* Add an explicit mode based on a quirk
  + */
  +static int
  +do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
  +  int vdisplay, int vrefresh, bool reduced)

 Nitpick: This adds one mode, not many _modes_.

sure, I'll fix.


  +
  + /* loop through the probed modes and clear the preferred bit */
  + list_for_each_entry_safe(cur_mode, t, connector-probed_modes,
head)
  + cur_mode-type = ~DRM_MODE_TYPE_PREFERRED;

 You're not deleting entries, so list_for_each_entry() would suffice,
 getting rid of the temp variable.


I was going to use this but I wasn't sure if I understood all of the
differences between the two.  I opted for _safe because I noticed it's used
in
edid_fixup_preferred() even though that routine doesn't remove entries
either.
I'll fix it.

  +
  + mode = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, reduced,
0, 0);

 You could

 if (!mode)
 return 0;

 here and get rid of the num_modes variable.

Yes, you're right.  I went with

if (mode) {
...
return 1;
}
else
return 0;

I would naively expect this to be better.  Is there a reason to prefer if
(!mode)?

  +static int
  +add_force_quirk_modes(struct drm_connector *connector, struct edid
*edid,
  +   u32 quirks)
  +{
  + struct edid_quirk_force_mode *quirk_mode;
  + int i, num_modes = 0;
  +
  + for (i = 0; i  ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
  + quirk_mode = edid_quirk_force_mode_list[i];
  +
  + if (edid_vendor(edid, quirk_mode-vendor) 
  + (EDID_PRODUCT_ID(edid) == quirk_mode-product_id)) {
  + num_modes = do_force_quirk_modes(connector,
  + quirk_mode-hdisplay,
  + quirk_mode-vdisplay,
  + quirk_mode-vrefresh,
  + quirk_mode-reduced);

 I was wondering why you don't bail out here. Maybe you want to be able
 to add more than one quirk mode? In that case you should +=, not = the
 num_modes.

 (Note that then do_force_quirk_modes makes the last one in the array the
 preferred mode, clearing the DRM_MODE_TYPE_PREFERRED from the previously
 added quirk modes.)

I thought about whether multiple forced modes would ever be needed.  I can't
imagine it would but it's easy enough to allow for it so we might as well
implement it now.

I think we'd want for it to be clear which of the forced modes will be used
and
so the current behavior of making the last one in the array preferred may be
the best.  I will add a comment by the edid_quirk_force_mode_list describing
this.


  @@ -2803,6 +2879,8 @@ int drm_add_edid_modes(struct drm_connector
*connector, struct edid *edid)
 
if (quirks  (EDID_QUIRK_PREFER_LARGE_60 |
EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
  + if (quirks  EDID_QUIRK_FORCE_MODE)
  + num_modes += add_force_quirk_modes(connector, edid,
quirks);

 You don't use quirks within add_force_quirk_modes() for anything.

good point.  I'll remove it.


Thanks,
Dylan
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 0/2] Enhance EDID quirks to allow forcing a mode

2013-03-25 Thread Dylan Semler
Changes in this version
 * rename do_force_quirk_modes() - do_force_quirk_mode()
 * use list_for_each_entry() instead of list_for_each_entry_safe() in
   do_force_quirk_mode()
 * remove num_modes from do_force_quirk_mode(), just return 1 or 0 as
   appropriate
 * remove unused quirks argument from add_force_quirk_modes()
 * fixes to allow cases of forcing multiple modes
 * adjusted comments to adhere closer to style guides

Changes in version 3
 * Uses drm_cvt_mode() instead of drm_gtf_mode() to build modeline
 * Adds bool to specify reduced blanking to edid_quirk_force_mode
 * Removes preferred bit from all other modes

Changes in version 2
 * none

There is at least one monitor that doesn't report its native resolution
in its EDID block.  This enhancement extends the EDID quirk logic to
make monitors like this just work.

The first patch in this series sets up a new quirk list where monitors'
correct width, height, refresh rate, and reduced blanking parameters are
specified.  When a matching monitor is attached the full mode is
calculated with drm_cvt_mode() and added to the connector.  The
DRM_MODE_TYPE_PREFERRED bit is set on the new mode and unset from all
other modes.

The first patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.
This bit needs to be set for the new quirk list described above to be
checked.

The second patch adds the offending monitor to the quirk lists.

Dylan Semler (2):
  drm: Enhance EDID quirks to explicitly set a mode
  drm: Add EDID force quirk for MMT Monitor2Go HD+

 drivers/gpu/drm/drm_edid.c | 89 ++
 1 file changed, 89 insertions(+)

-- 
1.7.11.7

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


[PATCH v4 1/2] drm: Enhance EDID quirks to explicitly set a mode

2013-03-25 Thread Dylan Semler
There is at least one monitor that doesn't report its native resolution
in its EDID block.  This enhancement extends the EDID quirk logic to
make monitors like this just work.

This patch sets up a new quirk list where monitors' correct width,
height, refresh rate, and reduced blanking parameters are specified.
When a matching monitor is attached the full mode is calculated with
drm_cvt_mode() and added to the connector.  The DRM_MODE_TYPE_PREFERRED
bit is set on the new mode and unset from all other modes.

The patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.  This
bit needs to be set for the new quirk list discribed above to be
checked.

Signed-off-by: Dylan Semler dylan.sem...@gmail.com
---
 drivers/gpu/drm/drm_edid.c | 77 ++
 1 file changed, 77 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..f8f3a4a 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1  6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1  7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1  8)
 
 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -128,6 +130,22 @@ static struct edid_quirk {
 };
 
 /*
+ * Displays that don't report a desired mode in their EDID block that cannot be
+ * resolved with a quirk from above are specified here.  If multiple modes need
+ * to be forced for the same display, the most preferred should be last; that
+ * is what the display will be initialized with.
+ */
+static struct edid_quirk_force_mode {
+   char vendor[4]; /* vendor ID */
+   int product_id; /* product ID */
+   int hdisplay;   /* horizontal resolution */
+   int vdisplay;   /* vertical resolution */
+   int vrefresh;   /* refresh rate */
+   bool reduced;   /* reduce blanking */
+} edid_quirk_force_mode_list[] = {
+};
+
+/*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
  */
@@ -2219,6 +2237,63 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }
 
+/*
+ * Add forced mode according to the matching quirk, set it as preferred,
+ * and remove the preferred bit from all other modes.
+ */
+static int
+do_force_quirk_mode(struct drm_connector *connector, int hdisplay,
+   int vdisplay, int vrefresh, bool reduced)
+{
+   struct drm_display_mode *mode, *cur_mode;
+   struct drm_device *dev = connector-dev;
+
+   if (hdisplay  0)
+   return 0;
+   if (vdisplay  0)
+   return 0;
+   if (vrefresh  0)
+   return 0;
+
+   list_for_each_entry(cur_mode, connector-probed_modes, head)
+   cur_mode-type = ~DRM_MODE_TYPE_PREFERRED;
+
+   mode = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, reduced, 0, 0);
+
+   if (!mode)
+   return 0;
+
+   mode-type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   return 1;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID force mode quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i  ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = edid_quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode-vendor) 
+   (EDID_PRODUCT_ID(edid) == quirk_mode-product_id))
+   num_modes += do_force_quirk_mode(connector,
+   quirk_mode-hdisplay,
+   quirk_mode-vdisplay,
+   quirk_mode-vrefresh,
+   quirk_mode-reduced);
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2878,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)
 
if (quirks  (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid);
 
drm_add_display_info(edid, connector-display_info);
 
-- 
1.7.11.7

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


[PATCH v3 2/2] drm: Add EDID force quirk for MMT Monitor2Go HD+

2013-03-22 Thread Dylan Semler
Set the new EDID_QUIRK_FORCE_MODE bit for the MMT Monitor2Go HD+ monitor
and add it to the edid_quirk_force_mode_list.

Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 38b8641..2f30be4 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -109,6 +109,9 @@ static struct edid_quirk {
{ "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 |
  EDID_QUIRK_DETAILED_IN_CM },

+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, EDID_QUIRK_FORCE_MODE},
+
/* LG Philips LCD LP154W01-A5 */
{ "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
{ "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
@@ -137,6 +140,8 @@ static struct edid_quirk_force_mode {
int vrefresh;
bool reduced;
 } edid_quirk_force_mode_list[] = {
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, 1600, 900, 60, 1 },
 };

 /*
-- 
1.7.11.7



[PATCH v3 1/2] drm: Enhance EDID quirks to explicitly set a mode

2013-03-22 Thread Dylan Semler
There is at least one monitor that doesn't report its native resolution
in its EDID block.  This enhancement extends the EDID quirk logic to
make monitors like this "just work".

This patch sets up a new quirk list where monitors' correct width,
height, refresh rate, and reduced blanking parameters are specified.
When a matching monitor is attached the full mode is calculated with
drm_cvt_mode() and added to the connector.  The DRM_MODE_TYPE_PREFERRED
bit is set on the new mode and unset from all other modes.

The patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.  This
bit needs to be set for the new quirk list discribed above to be
checked.

Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 78 ++
 1 file changed, 78 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..38b8641 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1 << 6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1 << 7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1 << 8)

 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -127,6 +129,16 @@ static struct edid_quirk {
{ "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
 };

+static struct edid_quirk_force_mode {
+   char vendor[4];
+   int product_id;
+   int hdisplay;
+   int vdisplay;
+   int vrefresh;
+   bool reduced;
+} edid_quirk_force_mode_list[] = {
+};
+
 /*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
@@ -2219,6 +2231,70 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }

+/* Add an explicit mode based on a quirk
+ */
+static int
+do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
+int vdisplay, int vrefresh, bool reduced)
+{
+   struct drm_display_mode *mode, *t, *cur_mode;
+   struct drm_device *dev = connector->dev;
+   int num_modes = 0;
+
+   /* sanity check display parameters */
+   if (hdisplay < 0)
+   return 0;
+   if (vdisplay < 0)
+   return 0;
+   if (vrefresh < 0)
+   return 0;
+
+   /* loop through the probed modes and clear the preferred bit */
+   list_for_each_entry_safe(cur_mode, t, >probed_modes, head)
+   cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED;
+
+   mode = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, reduced, 0, 0);
+
+   if (mode) {
+   mode->type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   num_modes++;
+   }
+   return num_modes;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ * @quirks: quirks to apply
+ *
+ * At least one monitor doesn't report its native resolution in its EDID block.
+ * Here we add the native mode according to this quirk
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
+ u32 quirks)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i < ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = _quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode->vendor) &&
+   (EDID_PRODUCT_ID(edid) == quirk_mode->product_id)) {
+   num_modes = do_force_quirk_modes(connector,
+   quirk_mode->hdisplay,
+   quirk_mode->vdisplay,
+   quirk_mode->vrefresh,
+   quirk_mode->reduced);
+   }
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2879,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)

if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (quirks & EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid, quirks);

drm_add_display_info(edid, >display_info);

-- 
1.7.11.7



[PATCH v3 0/2] Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
Changes in this version
 * Uses drm_cvt_mode() instead of drm_gtf_mode() to build modeline
 * Adds bool to specify reduced blanking to edid_quirk_force_mode
 * Removes preferred bit from all other modes

There is at least one monitor that doesn't report its native resolution
in its EDID block.  This enhancement extends the EDID quirk logic to
make monitors like this "just work".

The first patch in this series sets up a new quirk list where monitors'
correct width, height, refresh rate, and reduced blanking parameters are
specified.  When a matching monitor is attached the full mode is
calculated with drm_cvt_mode() and added to the connector.  The
DRM_MODE_TYPE_PREFERRED bit is set on the new mode and unset from all
other modes.

The first patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.
This bit needs to be set for the new quirk list discribed above to be
checked.

The second patch adds the offending monitor to the quirk lists.

Dylan Semler (2):
  drm: Enhance EDID quirks to explicitly set a mode
  drm: Add EDID force quirk for MMT Monitor2Go HD+

 drivers/gpu/drm/drm_edid.c | 83 ++
 1 file changed, 83 insertions(+)

-- 
1.7.11.7



Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 10:41 AM, Daniel Vetter  wrote:
>
> On Fri, Mar 22, 2013 at 3:02 PM, Dylan Semler 
wrote:
> > On Fri, Mar 22, 2013 at 9:50 AM, Alex Deucher 
> > wrote:
> >>
> >> That's odd.  Maybe it's actually in an extension block or something
like
> >> that?
> >
> > Yeah, I agree.  According to edid-decode
/sys/class/drm/card0-HDMI-A-1/edid
> > there's one extension block, but none of those modes are the native
> > resolution either.
>
> Hm, we only recently added support for E-EDID (i.e. more than 1 extension
> block). Have you checked whether latest kernels fare better?

I just tried booting with 3.9rc3 and my distro's latest package of
xorg-utils;
I get the same results.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130322/e8b9cd5a/attachment.html>


Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 9:50 AM, Alex Deucher  wrote:
>
> On Thu, Mar 21, 2013 at 5:42 PM, Dylan Semler 
wrote:
> > Oops.  I neglected to preface this with my motivation:  I have a new
> > monitor that doesn't report its native resolution in its EDID block.  It
> > seemed to me this calls for an EDID quirk, but the current quirk
> > infrastructure doesn't allow explicitly creating new modes.  So I set
out
> > to make a simple enhancement to allow specifying a new mode and then
> > setting it as preferred.
> >
>
> That's odd.  Maybe it's actually in an extension block or something like
> that?

Yeah, I agree.  According to edid-decode /sys/class/drm/card0-HDMI-A-1/edid
there's one extension block, but none of those modes are the native
resolution
either.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130322/905d4f65/attachment.html>


[PATCH v2 2/2] Adds EDID force mode quirk for MMT Monitor2Go HD+.

2013-03-22 Thread Dylan Semler
Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index b1036b5..b400971 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -109,6 +109,9 @@ static struct edid_quirk {
{ "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 |
  EDID_QUIRK_DETAILED_IN_CM },

+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, EDID_QUIRK_FORCE_MODE},
+
/* LG Philips LCD LP154W01-A5 */
{ "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
{ "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
@@ -136,6 +139,8 @@ static struct edid_quirk_force_mode {
int vdisplay;
int vrefresh;
 } edid_quirk_force_mode_list[] = {
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, 1600, 900, 60 },
 };

 /*
-- 
1.7.11.7



[PATCH v2 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block.

2013-03-22 Thread Dylan Semler
Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 72 ++
 1 file changed, 72 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..b1036b5 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1 << 6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1 << 7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1 << 8)

 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -127,6 +129,15 @@ static struct edid_quirk {
{ "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
 };

+static struct edid_quirk_force_mode {
+   char vendor[4];
+   int product_id;
+   int hdisplay;
+   int vdisplay;
+   int vrefresh;
+} edid_quirk_force_mode_list[] = {
+};
+
 /*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
@@ -2219,6 +2230,65 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }

+/* Add an explicit mode based on a quirk
+ */
+static int
+do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
+int vdisplay, int vrefresh)
+{
+   struct drm_display_mode *mode;
+   struct drm_device *dev = connector->dev;
+   int num_modes = 0;
+
+   /* sanity check display parameters */
+   if (hdisplay < 0)
+   return 0;
+   if (vdisplay < 0)
+   return 0;
+   if (vrefresh < 0)
+   return 0;
+
+   mode = drm_gtf_mode(dev, hdisplay, vdisplay, vrefresh, 0, 0);
+
+   if (mode) {
+   mode->type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   num_modes++;
+   }
+   return num_modes;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ * @quirks: quirks to apply
+ *
+ * At least one monitor doesn't report its native resolution in its EDID block.
+ * Here we add the native mode according to this quirk
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
+ u32 quirks)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i < ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = _quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode->vendor) &&
+   (EDID_PRODUCT_ID(edid) == quirk_mode->product_id)) {
+   num_modes = do_force_quirk_modes(connector,
+   quirk_mode->hdisplay,
+   quirk_mode->vdisplay,
+   quirk_mode->vrefresh);
+   }
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2873,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)

if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (quirks & EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid, quirks);

drm_add_display_info(edid, >display_info);

-- 
1.7.11.7



[PATCH v2 0/2] Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
Changes in this version
 * Fix missing commit messages in patch emails

These patches offer a fix for a monitor that doesn't report its native
resolution in its EDID.  The idea is setup a new quirk list with width, height,
and refresh rates for each monitor that needs this quirk.  If a monitor is
attached that matches one in this list, the full modeline is calculated with
drm_gtf_mode, the DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added
to the connector.

The patch also creates a new quirk bit:  EDID_QUIRK_FORCE_MODE.  This bit needs
to be set for the new quirk list discribed above to be checked.

Dylan Semler (2):
  Enhances EDID quirks to allow for specifying and preferring a mode
not reported in the EDID block.
  Adds EDID force mode quirk for MMT Monitor2Go HD+.

 drivers/gpu/drm/drm_edid.c | 77 ++
 1 file changed, 77 insertions(+)

-- 
1.7.11.7



Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 4:48 AM, Daniel Vetter  wrote:
>
> I think it'd be good to shovel these text blocks into the (currently
rather
> empty) commit messages of the patches. Since when reading old commits with
> e.g. git blame that's what people will read.

Yeah, I just noticed that.  For some reason my git format-patch didn't place
the commit messages above the signoff.  Here comes v2.
-- next part --
An HTML attachment was scrubbed...
URL: 



Re: Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 4:48 AM, Daniel Vetter dan...@ffwll.ch wrote:

 I think it'd be good to shovel these text blocks into the (currently
rather
 empty) commit messages of the patches. Since when reading old commits with
 e.g. git blame that's what people will read.

Yeah, I just noticed that.  For some reason my git format-patch didn't place
the commit messages above the signoff.  Here comes v2.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 0/2] Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
Changes in this version
 * Fix missing commit messages in patch emails

These patches offer a fix for a monitor that doesn't report its native
resolution in its EDID.  The idea is setup a new quirk list with width, height,
and refresh rates for each monitor that needs this quirk.  If a monitor is
attached that matches one in this list, the full modeline is calculated with
drm_gtf_mode, the DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added
to the connector.

The patch also creates a new quirk bit:  EDID_QUIRK_FORCE_MODE.  This bit needs
to be set for the new quirk list discribed above to be checked.

Dylan Semler (2):
  Enhances EDID quirks to allow for specifying and preferring a mode
not reported in the EDID block.
  Adds EDID force mode quirk for MMT Monitor2Go HD+.

 drivers/gpu/drm/drm_edid.c | 77 ++
 1 file changed, 77 insertions(+)

-- 
1.7.11.7

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


[PATCH v2 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block.

2013-03-22 Thread Dylan Semler
Signed-off-by: Dylan Semler dylan.sem...@gmail.com
---
 drivers/gpu/drm/drm_edid.c | 72 ++
 1 file changed, 72 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..b1036b5 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1  6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1  7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1  8)
 
 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -127,6 +129,15 @@ static struct edid_quirk {
{ VSC, 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
 };
 
+static struct edid_quirk_force_mode {
+   char vendor[4];
+   int product_id;
+   int hdisplay;
+   int vdisplay;
+   int vrefresh;
+} edid_quirk_force_mode_list[] = {
+};
+
 /*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
@@ -2219,6 +2230,65 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }
 
+/* Add an explicit mode based on a quirk
+ */
+static int
+do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
+int vdisplay, int vrefresh)
+{
+   struct drm_display_mode *mode;
+   struct drm_device *dev = connector-dev;
+   int num_modes = 0;
+
+   /* sanity check display parameters */
+   if (hdisplay  0)
+   return 0;
+   if (vdisplay  0)
+   return 0;
+   if (vrefresh  0)
+   return 0;
+
+   mode = drm_gtf_mode(dev, hdisplay, vdisplay, vrefresh, 0, 0);
+
+   if (mode) {
+   mode-type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   num_modes++;
+   }
+   return num_modes;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ * @quirks: quirks to apply
+ *
+ * At least one monitor doesn't report its native resolution in its EDID block.
+ * Here we add the native mode according to this quirk
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
+ u32 quirks)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i  ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = edid_quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode-vendor) 
+   (EDID_PRODUCT_ID(edid) == quirk_mode-product_id)) {
+   num_modes = do_force_quirk_modes(connector,
+   quirk_mode-hdisplay,
+   quirk_mode-vdisplay,
+   quirk_mode-vrefresh);
+   }
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2873,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)
 
if (quirks  (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (quirks  EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid, quirks);
 
drm_add_display_info(edid, connector-display_info);
 
-- 
1.7.11.7

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


[PATCH v2 2/2] Adds EDID force mode quirk for MMT Monitor2Go HD+.

2013-03-22 Thread Dylan Semler
Signed-off-by: Dylan Semler dylan.sem...@gmail.com
---
 drivers/gpu/drm/drm_edid.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index b1036b5..b400971 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -109,6 +109,9 @@ static struct edid_quirk {
{ FCM, 13600, EDID_QUIRK_PREFER_LARGE_75 |
  EDID_QUIRK_DETAILED_IN_CM },
 
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { LLP, 0x4c54, EDID_QUIRK_FORCE_MODE},
+
/* LG Philips LCD LP154W01-A5 */
{ LPL, 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
{ LPL, 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
@@ -136,6 +139,8 @@ static struct edid_quirk_force_mode {
int vdisplay;
int vrefresh;
 } edid_quirk_force_mode_list[] = {
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { LLP, 0x4c54, 1600, 900, 60 },
 };
 
 /*
-- 
1.7.11.7

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


Re: Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 9:50 AM, Alex Deucher alexdeuc...@gmail.com wrote:

 On Thu, Mar 21, 2013 at 5:42 PM, Dylan Semler dylan.sem...@gmail.com
wrote:
  Oops.  I neglected to preface this with my motivation:  I have a new
  monitor that doesn't report its native resolution in its EDID block.  It
  seemed to me this calls for an EDID quirk, but the current quirk
  infrastructure doesn't allow explicitly creating new modes.  So I set
out
  to make a simple enhancement to allow specifying a new mode and then
  setting it as preferred.
 

 That's odd.  Maybe it's actually in an extension block or something like
 that?

Yeah, I agree.  According to edid-decode /sys/class/drm/card0-HDMI-A-1/edid
there's one extension block, but none of those modes are the native
resolution
either.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
On Fri, Mar 22, 2013 at 10:41 AM, Daniel Vetter dan...@ffwll.ch wrote:

 On Fri, Mar 22, 2013 at 3:02 PM, Dylan Semler dylan.sem...@gmail.com
wrote:
  On Fri, Mar 22, 2013 at 9:50 AM, Alex Deucher alexdeuc...@gmail.com
  wrote:
 
  That's odd.  Maybe it's actually in an extension block or something
like
  that?
 
  Yeah, I agree.  According to edid-decode
/sys/class/drm/card0-HDMI-A-1/edid
  there's one extension block, but none of those modes are the native
  resolution either.

 Hm, we only recently added support for E-EDID (i.e. more than 1 extension
 block). Have you checked whether latest kernels fare better?

I just tried booting with 3.9rc3 and my distro's latest package of
xorg-utils;
I get the same results.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 0/2] Enhance EDID quirks to allow forcing a mode

2013-03-22 Thread Dylan Semler
Changes in this version
 * Uses drm_cvt_mode() instead of drm_gtf_mode() to build modeline
 * Adds bool to specify reduced blanking to edid_quirk_force_mode
 * Removes preferred bit from all other modes

There is at least one monitor that doesn't report its native resolution
in its EDID block.  This enhancement extends the EDID quirk logic to
make monitors like this just work.

The first patch in this series sets up a new quirk list where monitors'
correct width, height, refresh rate, and reduced blanking parameters are
specified.  When a matching monitor is attached the full mode is
calculated with drm_cvt_mode() and added to the connector.  The
DRM_MODE_TYPE_PREFERRED bit is set on the new mode and unset from all
other modes.

The first patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.
This bit needs to be set for the new quirk list discribed above to be
checked.

The second patch adds the offending monitor to the quirk lists.

Dylan Semler (2):
  drm: Enhance EDID quirks to explicitly set a mode
  drm: Add EDID force quirk for MMT Monitor2Go HD+

 drivers/gpu/drm/drm_edid.c | 83 ++
 1 file changed, 83 insertions(+)

-- 
1.7.11.7

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


[PATCH v3 1/2] drm: Enhance EDID quirks to explicitly set a mode

2013-03-22 Thread Dylan Semler
There is at least one monitor that doesn't report its native resolution
in its EDID block.  This enhancement extends the EDID quirk logic to
make monitors like this just work.

This patch sets up a new quirk list where monitors' correct width,
height, refresh rate, and reduced blanking parameters are specified.
When a matching monitor is attached the full mode is calculated with
drm_cvt_mode() and added to the connector.  The DRM_MODE_TYPE_PREFERRED
bit is set on the new mode and unset from all other modes.

The patch also defines a new quirk bit: EDID_QUIRK_FORCE_MODE.  This
bit needs to be set for the new quirk list discribed above to be
checked.

Signed-off-by: Dylan Semler dylan.sem...@gmail.com
---
 drivers/gpu/drm/drm_edid.c | 78 ++
 1 file changed, 78 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..38b8641 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1  6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1  7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1  8)
 
 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -127,6 +129,16 @@ static struct edid_quirk {
{ VSC, 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
 };
 
+static struct edid_quirk_force_mode {
+   char vendor[4];
+   int product_id;
+   int hdisplay;
+   int vdisplay;
+   int vrefresh;
+   bool reduced;
+} edid_quirk_force_mode_list[] = {
+};
+
 /*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
@@ -2219,6 +2231,70 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }
 
+/* Add an explicit mode based on a quirk
+ */
+static int
+do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
+int vdisplay, int vrefresh, bool reduced)
+{
+   struct drm_display_mode *mode, *t, *cur_mode;
+   struct drm_device *dev = connector-dev;
+   int num_modes = 0;
+
+   /* sanity check display parameters */
+   if (hdisplay  0)
+   return 0;
+   if (vdisplay  0)
+   return 0;
+   if (vrefresh  0)
+   return 0;
+
+   /* loop through the probed modes and clear the preferred bit */
+   list_for_each_entry_safe(cur_mode, t, connector-probed_modes, head)
+   cur_mode-type = ~DRM_MODE_TYPE_PREFERRED;
+
+   mode = drm_cvt_mode(dev, hdisplay, vdisplay, vrefresh, reduced, 0, 0);
+
+   if (mode) {
+   mode-type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   num_modes++;
+   }
+   return num_modes;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ * @quirks: quirks to apply
+ *
+ * At least one monitor doesn't report its native resolution in its EDID block.
+ * Here we add the native mode according to this quirk
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
+ u32 quirks)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i  ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = edid_quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode-vendor) 
+   (EDID_PRODUCT_ID(edid) == quirk_mode-product_id)) {
+   num_modes = do_force_quirk_modes(connector,
+   quirk_mode-hdisplay,
+   quirk_mode-vdisplay,
+   quirk_mode-vrefresh,
+   quirk_mode-reduced);
+   }
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2879,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)
 
if (quirks  (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (quirks  EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid, quirks);
 
drm_add_display_info(edid, connector-display_info);
 
-- 
1.7.11.7

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


[PATCH v3 2/2] drm: Add EDID force quirk for MMT Monitor2Go HD+

2013-03-22 Thread Dylan Semler
Set the new EDID_QUIRK_FORCE_MODE bit for the MMT Monitor2Go HD+ monitor
and add it to the edid_quirk_force_mode_list.

Signed-off-by: Dylan Semler dylan.sem...@gmail.com
---
 drivers/gpu/drm/drm_edid.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 38b8641..2f30be4 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -109,6 +109,9 @@ static struct edid_quirk {
{ FCM, 13600, EDID_QUIRK_PREFER_LARGE_75 |
  EDID_QUIRK_DETAILED_IN_CM },
 
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { LLP, 0x4c54, EDID_QUIRK_FORCE_MODE},
+
/* LG Philips LCD LP154W01-A5 */
{ LPL, 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
{ LPL, 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
@@ -137,6 +140,8 @@ static struct edid_quirk_force_mode {
int vrefresh;
bool reduced;
 } edid_quirk_force_mode_list[] = {
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { LLP, 0x4c54, 1600, 900, 60, 1 },
 };
 
 /*
-- 
1.7.11.7

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


Enhance EDID quirks to allow forcing a mode

2013-03-21 Thread Dylan Semler
Oops.  I neglected to preface this with my motivation:  I have a new
monitor
that doesn't report its native resolution in its EDID block.  It seemed to
me
this calls for an EDID quirk, but the current quirk infrastructure doesn't
allow explicitly creating new modes.  So I set out to make a simple
enhancement
to allow specifying a new mode and then setting it as preferred.



On Thu, Mar 21, 2013 at 5:36 PM, Dylan Semler wrote:

> The idea is setup a new quirk list with width, height, and refresh rates
> for
> each monitor that needs this quirk.  If a monitor is attached that matches
> one
> in this list, the full modeline is calculated with drm_gtf_mode, the
> DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added to the
> connector.
>
> The patch also creates a new quirk bit:  EDID_QUIRK_FORCE_MODE.  This bit
> needs
> to be set for the new quirk list discribed above to be checked.
>
> The first patch enhances the quirk logic as described above.  The second
> one
> adds my new monitor to the quirk lists.
>
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20130321/7be03e5e/attachment.html>


[PATCH 2/2] Adds EDID force mode quirk for MMT Monitor2Go HD+.

2013-03-21 Thread Dylan Semler

Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index b1036b5..b400971 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -109,6 +109,9 @@ static struct edid_quirk {
{ "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 |
  EDID_QUIRK_DETAILED_IN_CM },

+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, EDID_QUIRK_FORCE_MODE},
+
/* LG Philips LCD LP154W01-A5 */
{ "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
{ "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
@@ -136,6 +139,8 @@ static struct edid_quirk_force_mode {
int vdisplay;
int vrefresh;
 } edid_quirk_force_mode_list[] = {
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { "LLP", 0x4c54, 1600, 900, 60 },
 };

 /*
-- 
1.7.11.7



[PATCH 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block.

2013-03-21 Thread Dylan Semler

Signed-off-by: Dylan Semler 
---
 drivers/gpu/drm/drm_edid.c | 72 ++
 1 file changed, 72 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..b1036b5 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1 << 6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1 << 7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1 << 8)

 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -127,6 +129,15 @@ static struct edid_quirk {
{ "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
 };

+static struct edid_quirk_force_mode {
+   char vendor[4];
+   int product_id;
+   int hdisplay;
+   int vdisplay;
+   int vrefresh;
+} edid_quirk_force_mode_list[] = {
+};
+
 /*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
@@ -2219,6 +2230,65 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }

+/* Add an explicit mode based on a quirk
+ */
+static int
+do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
+int vdisplay, int vrefresh)
+{
+   struct drm_display_mode *mode;
+   struct drm_device *dev = connector->dev;
+   int num_modes = 0;
+
+   /* sanity check display parameters */
+   if (hdisplay < 0)
+   return 0;
+   if (vdisplay < 0)
+   return 0;
+   if (vrefresh < 0)
+   return 0;
+
+   mode = drm_gtf_mode(dev, hdisplay, vdisplay, vrefresh, 0, 0);
+
+   if (mode) {
+   mode->type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   num_modes++;
+   }
+   return num_modes;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ * @quirks: quirks to apply
+ *
+ * At least one monitor doesn't report its native resolution in its EDID block.
+ * Here we add the native mode according to this quirk
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
+ u32 quirks)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i < ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = _quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode->vendor) &&
+   (EDID_PRODUCT_ID(edid) == quirk_mode->product_id)) {
+   num_modes = do_force_quirk_modes(connector,
+   quirk_mode->hdisplay,
+   quirk_mode->vdisplay,
+   quirk_mode->vrefresh);
+   }
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2873,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)

if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (quirks & EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid, quirks);

drm_add_display_info(edid, >display_info);

-- 
1.7.11.7



Enhance EDID quirks to allow forcing a mode

2013-03-21 Thread Dylan Semler
The idea is setup a new quirk list with width, height, and refresh rates for
each monitor that needs this quirk.  If a monitor is attached that matches one
in this list, the full modeline is calculated with drm_gtf_mode, the
DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added to the connector.

The patch also creates a new quirk bit:??EDID_QUIRK_FORCE_MODE. ?This bit needs
to be set for the new quirk list discribed above to be checked.

The first patch enhances the quirk logic as described above. ?The second one
adds my new monitor to the quirk lists.


[PATCH 1/2] Enhances EDID quirks to allow for specifying and preferring a mode not reported in the EDID block.

2013-03-21 Thread Dylan Semler

Signed-off-by: Dylan Semler dylan.sem...@gmail.com
---
 drivers/gpu/drm/drm_edid.c | 72 ++
 1 file changed, 72 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c194f4e..b1036b5 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -68,6 +68,8 @@
 #define EDID_QUIRK_DETAILED_SYNC_PP(1  6)
 /* Force reduced-blanking timings for detailed modes */
 #define EDID_QUIRK_FORCE_REDUCED_BLANKING  (1  7)
+/* Force specific mode for monitors that don't report correct EDIDs */
+#define EDID_QUIRK_FORCE_MODE  (1  8)
 
 struct detailed_mode_closure {
struct drm_connector *connector;
@@ -127,6 +129,15 @@ static struct edid_quirk {
{ VSC, 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
 };
 
+static struct edid_quirk_force_mode {
+   char vendor[4];
+   int product_id;
+   int hdisplay;
+   int vdisplay;
+   int vrefresh;
+} edid_quirk_force_mode_list[] = {
+};
+
 /*
  * Autogenerated from the DMT spec.
  * This table is copied from xfree86/modes/xf86EdidModes.c.
@@ -2219,6 +2230,65 @@ add_detailed_modes(struct drm_connector *connector, 
struct edid *edid,
return closure.modes;
 }
 
+/* Add an explicit mode based on a quirk
+ */
+static int
+do_force_quirk_modes(struct drm_connector *connector, int hdisplay,
+int vdisplay, int vrefresh)
+{
+   struct drm_display_mode *mode;
+   struct drm_device *dev = connector-dev;
+   int num_modes = 0;
+
+   /* sanity check display parameters */
+   if (hdisplay  0)
+   return 0;
+   if (vdisplay  0)
+   return 0;
+   if (vrefresh  0)
+   return 0;
+
+   mode = drm_gtf_mode(dev, hdisplay, vdisplay, vrefresh, 0, 0);
+
+   if (mode) {
+   mode-type |= DRM_MODE_TYPE_PREFERRED;
+   drm_mode_probed_add(connector, mode);
+   num_modes++;
+   }
+   return num_modes;
+}
+
+/*
+ * add_force_quirk_modes - Add modes based on monitor's EDID quirks
+ * @connector: attached connector
+ * @edid: EDID block to scan
+ * @quirks: quirks to apply
+ *
+ * At least one monitor doesn't report its native resolution in its EDID block.
+ * Here we add the native mode according to this quirk
+ */
+static int
+add_force_quirk_modes(struct drm_connector *connector, struct edid *edid,
+ u32 quirks)
+{
+   struct edid_quirk_force_mode *quirk_mode;
+   int i, num_modes = 0;
+
+   for (i = 0; i  ARRAY_SIZE(edid_quirk_force_mode_list); i++) {
+   quirk_mode = edid_quirk_force_mode_list[i];
+
+   if (edid_vendor(edid, quirk_mode-vendor) 
+   (EDID_PRODUCT_ID(edid) == quirk_mode-product_id)) {
+   num_modes = do_force_quirk_modes(connector,
+   quirk_mode-hdisplay,
+   quirk_mode-vdisplay,
+   quirk_mode-vrefresh);
+   }
+   }
+   return num_modes;
+
+}
+
 #define HDMI_IDENTIFIER 0x000C03
 #define AUDIO_BLOCK0x01
 #define VIDEO_BLOCK 0x02
@@ -2803,6 +2873,8 @@ int drm_add_edid_modes(struct drm_connector *connector, 
struct edid *edid)
 
if (quirks  (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
edid_fixup_preferred(connector, quirks);
+   if (quirks  EDID_QUIRK_FORCE_MODE)
+   num_modes += add_force_quirk_modes(connector, edid, quirks);
 
drm_add_display_info(edid, connector-display_info);
 
-- 
1.7.11.7

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


[PATCH 2/2] Adds EDID force mode quirk for MMT Monitor2Go HD+.

2013-03-21 Thread Dylan Semler

Signed-off-by: Dylan Semler dylan.sem...@gmail.com
---
 drivers/gpu/drm/drm_edid.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index b1036b5..b400971 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -109,6 +109,9 @@ static struct edid_quirk {
{ FCM, 13600, EDID_QUIRK_PREFER_LARGE_75 |
  EDID_QUIRK_DETAILED_IN_CM },
 
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { LLP, 0x4c54, EDID_QUIRK_FORCE_MODE},
+
/* LG Philips LCD LP154W01-A5 */
{ LPL, 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
{ LPL, 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
@@ -136,6 +139,8 @@ static struct edid_quirk_force_mode {
int vdisplay;
int vrefresh;
 } edid_quirk_force_mode_list[] = {
+   /* Mobile Monitor Technologies LLC, Monitor2Go HD+ */
+   { LLP, 0x4c54, 1600, 900, 60 },
 };
 
 /*
-- 
1.7.11.7

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


Re: Enhance EDID quirks to allow forcing a mode

2013-03-21 Thread Dylan Semler
Oops.  I neglected to preface this with my motivation:  I have a new
monitor
that doesn't report its native resolution in its EDID block.  It seemed to
me
this calls for an EDID quirk, but the current quirk infrastructure doesn't
allow explicitly creating new modes.  So I set out to make a simple
enhancement
to allow specifying a new mode and then setting it as preferred.



On Thu, Mar 21, 2013 at 5:36 PM, Dylan Semler dylan.sem...@gmail.comwrote:

 The idea is setup a new quirk list with width, height, and refresh rates
 for
 each monitor that needs this quirk.  If a monitor is attached that matches
 one
 in this list, the full modeline is calculated with drm_gtf_mode, the
 DRM_MODE_TYPE_PREFERRED bit is set, and the new mode is added to the
 connector.

 The patch also creates a new quirk bit:  EDID_QUIRK_FORCE_MODE.  This bit
 needs
 to be set for the new quirk list discribed above to be checked.

 The first patch enhances the quirk logic as described above.  The second
 one
 adds my new monitor to the quirk lists.

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