Re: [PATCH 1/2] Concatenate EDID descriptor strings.



file report here > http://bugzilla.gnome.org/browse.cgi?product=libgnome

[]s
--
Regards,
+--------------------------------------------+
Jorge Pereira,
Blog: http://blog.jorgepereira.com.br/
GPG-Key-ID: 1024D/EC6FB924
+--------------------------------------------+


On Wed, Jul 8, 2009 at 12:50 PM, Adam Jackson <ajax redhat com> wrote:
Some monitors have names longer than 13 bytes, and thus need multiple
name records.
---
 libgnome-desktop/edid-parse.c      |   50 ++++++++++++++++++++++++++++++------
 libgnome-desktop/edid.h            |    7 +++--
 libgnome-desktop/gnome-rr-config.c |    2 +-
 3 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/libgnome-desktop/edid-parse.c b/libgnome-desktop/edid-parse.c
index 225778a..f7daa7f 100644
--- a/libgnome-desktop/edid-parse.c
+++ b/libgnome-desktop/edid-parse.c
@@ -349,27 +349,47 @@ decode_standard_timings (const uchar *edid, MonitorInfo *info)
    return TRUE;
 }

-static void
-decode_lf_string (const uchar *s, int n_chars, char *result)
+static char *
+decode_lf_string (const uchar *s, int n_chars, char *prev)
 {
    int i;
+    char *ret, *tmp;
+
+    tmp = g_malloc0(n_chars);
+
+    if (!tmp)
+       return prev;
+
    for (i = 0; i < n_chars; ++i)
    {
       if (s[i] == 0x0a)
       {
-           *result++ = '\0';
+           tmp[i] = '\0';
           break;
       }
       else if (s[i] == 0x00)
       {
           /* Convert embedded 0's to spaces */
-           *result++ = ' ';
+           tmp[i] = ' ';
       }
       else
       {
-           *result++ = s[i];
+           tmp[i] = s[i];
       }
    }
+
+    if (prev)
+    {
+       ret = g_strjoin(NULL, prev, tmp, NULL);
+       g_free(prev);
+       g_free(tmp);
+    }
+    else
+    {
+       ret = tmp;
+    }
+
+    return ret;
 }

 static void
@@ -379,13 +399,15 @@ decode_display_descriptor (const uchar *desc,
    switch (desc[0x03])
    {
    case 0xFC:
-       decode_lf_string (desc + 5, 13, info->dsc_product_name);
+       info->dsc_product_name = decode_lf_string (desc + 5, 13,
+                                                  info->dsc_product_name);
       break;
    case 0xFF:
-       decode_lf_string (desc + 5, 13, info->dsc_serial_number);
+       info->dsc_serial_number = decode_lf_string (desc + 5, 13,
+                                                   info->dsc_serial_number);
       break;
    case 0xFE:
-       decode_lf_string (desc + 5, 13, info->dsc_string);
+       info->dsc_string = decode_lf_string (desc + 5, 13, info->dsc_string);
       break;
    case 0xFD:
       /* Range Limits */
@@ -514,6 +536,18 @@ decode_check_sum (const uchar *edid,
    info->checksum = check;
 }

+void
+free_edid (MonitorInfo *info)
+{
+    if (info)
+    {
+       g_free (info->dsc_product_name);
+       g_free (info->dsc_serial_number);
+       g_free (info->dsc_string);
+    }
+    g_free (info);
+}
+
 MonitorInfo *
 decode_edid (const uchar *edid)
 {
diff --git a/libgnome-desktop/edid.h b/libgnome-desktop/edid.h
index 3b4e338..ffa9064 100644
--- a/libgnome-desktop/edid.h
+++ b/libgnome-desktop/edid.h
@@ -183,12 +183,13 @@ struct MonitorInfo
                                                */

    /* Optional product description */
-    char               dsc_serial_number[14];
-    char               dsc_product_name[14];
-    char               dsc_string[14];         /* Unspecified ASCII data */
+    char               *dsc_serial_number;
+    char               *dsc_product_name;
+    char               *dsc_string;            /* Unspecified ASCII data */
 };

 MonitorInfo *decode_edid (const uchar *data);
+void free_edid (MonitorInfo *info);
 char *       make_display_name (const char        *output_name,
                               const MonitorInfo *info);

diff --git a/libgnome-desktop/gnome-rr-config.c b/libgnome-desktop/gnome-rr-config.c
index 900f144..8c3b233 100644
--- a/libgnome-desktop/gnome-rr-config.c
+++ b/libgnome-desktop/gnome-rr-config.c
@@ -491,7 +491,7 @@ gnome_rr_config_new_current (GnomeRRScreen *screen)
           output->display_name = make_display_name (
               gnome_rr_output_get_name (rr_output), info);

-           g_free (info);
+           free_edid (info);

           crtc = gnome_rr_output_get_crtc (rr_output);
           mode = crtc? gnome_rr_crtc_get_current_mode (crtc) : NULL;
--
1.6.2.2

_______________________________________________
desktop-devel-list mailing list
desktop-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/desktop-devel-list



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