[gnome-desktop] Add a size return value to gnome_rr_output_get_edid_data()



commit d9166b77a5cd03d7d846e9856e9fe9a23dc08a3c
Author: Richard Hughes <richard hughsie com>
Date:   Tue Jun 7 12:07:07 2011 +0100

    Add a size return value to gnome_rr_output_get_edid_data()
    
    It's wrong to assume that the EDID size is always 128 bytes if there are
    extension blocks.
    
    This functionality is required if we want to parse the EDID in any safe way.

 libgnome-desktop/gnome-rr-config.c |    2 +-
 libgnome-desktop/gnome-rr.c        |   11 ++++++-----
 libgnome-desktop/gnome-rr.h        |    3 ++-
 3 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr-config.c b/libgnome-desktop/gnome-rr-config.c
index 9511034..68c0aaa 100644
--- a/libgnome-desktop/gnome-rr-config.c
+++ b/libgnome-desktop/gnome-rr-config.c
@@ -511,7 +511,7 @@ gnome_rr_config_load_current (GnomeRRConfig *config, GError **error)
 	GnomeRROutput *rr_output = rr_outputs[i];
 	GnomeRROutputInfo *output = g_object_new (GNOME_TYPE_RR_OUTPUT_INFO, NULL);
 	GnomeRRMode *mode = NULL;
-	const guint8 *edid_data = gnome_rr_output_get_edid_data (rr_output);
+	const guint8 *edid_data = gnome_rr_output_get_edid_data (rr_output, NULL);
 	GnomeRRCrtc *crtc;
 
 	output->priv->name = g_strdup (gnome_rr_output_get_name (rr_output));
diff --git a/libgnome-desktop/gnome-rr.c b/libgnome-desktop/gnome-rr.c
index eb3d735..9a3fe9e 100644
--- a/libgnome-desktop/gnome-rr.c
+++ b/libgnome-desktop/gnome-rr.c
@@ -96,7 +96,7 @@ struct GnomeRROutput
     GnomeRRMode **	modes;
     int			n_preferred;
     guint8 *		edid_data;
-    int         edid_size;
+    gsize		edid_size;
     char *              connector_type;
 };
 
@@ -1159,7 +1159,7 @@ static guint8 *
 get_property (Display *dpy,
 	      RROutput output,
 	      Atom atom,
-	      int *len)
+	      gsize *len)
 {
 #ifdef HAVE_RANDR
     unsigned char *prop;
@@ -1194,7 +1194,7 @@ get_property (Display *dpy,
 }
 
 static guint8 *
-read_edid_data (GnomeRROutput *output, int *len)
+read_edid_data (GnomeRROutput *output, gsize *len)
 {
     Atom edid_atom;
     guint8 *result;
@@ -1408,10 +1408,11 @@ gnome_rr_output_get_id (GnomeRROutput *output)
 }
 
 const guint8 *
-gnome_rr_output_get_edid_data (GnomeRROutput *output)
+gnome_rr_output_get_edid_data (GnomeRROutput *output, gsize *size)
 {
     g_return_val_if_fail (output != NULL, NULL);
-    
+    if (size)
+        *size = output->edid_size;
     return output->edid_data;
 }
 
diff --git a/libgnome-desktop/gnome-rr.h b/libgnome-desktop/gnome-rr.h
index 64dd055..68bdbff 100644
--- a/libgnome-desktop/gnome-rr.h
+++ b/libgnome-desktop/gnome-rr.h
@@ -132,7 +132,8 @@ gboolean        gnome_rr_output_is_connected       (GnomeRROutput         *outpu
 int             gnome_rr_output_get_size_inches    (GnomeRROutput         *output);
 int             gnome_rr_output_get_width_mm       (GnomeRROutput         *outout);
 int             gnome_rr_output_get_height_mm      (GnomeRROutput         *output);
-const guint8 *  gnome_rr_output_get_edid_data      (GnomeRROutput         *output);
+const guint8 *  gnome_rr_output_get_edid_data      (GnomeRROutput         *output,
+                                                    gsize                 *size);
 GnomeRRCrtc **  gnome_rr_output_get_possible_crtcs (GnomeRROutput         *output);
 GnomeRRMode *   gnome_rr_output_get_current_mode   (GnomeRROutput         *output);
 GnomeRRCrtc *   gnome_rr_output_get_crtc           (GnomeRROutput         *output);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]