aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-08-04 22:31:20 +0200
committerMattias Andrée <maandree@kth.se>2016-08-04 22:31:20 +0200
commitfe683b43918238c6453bf9059fb2e4c04b4dfb44 (patch)
treec32b9d7b7b044481496afe85478b85ca39ca99b9 /src
parentFix bug: length header should be "ignored" silently (diff)
downloadcoopgammad-fe683b43918238c6453bf9059fb2e4c04b4dfb44.tar.gz
coopgammad-fe683b43918238c6453bf9059fb2e4c04b4dfb44.tar.bz2
coopgammad-fe683b43918238c6453bf9059fb2e4c04b4dfb44.tar.xz
m improvement + bug fix
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/servers/gamma.c23
-rw-r--r--src/types/output.h23
2 files changed, 22 insertions, 24 deletions
diff --git a/src/servers/gamma.c b/src/servers/gamma.c
index 9800997..04b8856 100644
--- a/src/servers/gamma.c
+++ b/src/servers/gamma.c
@@ -155,26 +155,23 @@ void set_gamma(const struct output* restrict output, const union gamma_ramps* re
* Parse the EDID of a monitor
*
* @param output The output
+ * @param edid The EDID in binary format
+ * @param n The length of the EDID
*/
-static void parse_edid(struct output* restrict output)
+static void parse_edid(struct output* restrict output, const unsigned char* restrict edid, size_t n)
{
- const unsigned char* restrict edid = (const unsigned char*)(output->name);
size_t i;
- int sum, analogue;
+ int analogue;
+ unsigned sum;
output->red_x = output->green_x = output->blue_x = output->white_x = 0;
output->red_y = output->green_y = output->blue_y = output->white_y = 0;
+ output->colourspace = COLOURSPACE_UNKNOWN;
- if (output->name_is_edid == 0)
- {
- output->colourspace = COLOURSPACE_UNKNOWN;
- return;
- }
-
- if (strlen((const char*)edid) < 128)
+ if ((edid == NULL) || (n < 128))
return;
for (i = 0, sum = 0; i < 128; i++)
- sum += (int)edid[i];
+ sum += (unsigned)edid[i];
if ((sum & 0xFF) != 0)
return;
if ((edid[0] != 0) || (edid[7] != 0))
@@ -198,7 +195,7 @@ static void parse_edid(struct output* restrict output)
if (output->colourspace != COLOURSPACE_RGB)
return;
- if (edid[24] & 2)
+ if (edid[24] & 4)
output->colourspace = COLOURSPACE_SRGB;
output->red_x = (edid[25] >> 6) & 3;
@@ -263,6 +260,7 @@ int initialise_gamma_info(void)
if (outputs[i].depth == 0 || outputs[i].red_size == 0 ||
outputs[i].green_size == 0 || outputs[i].blue_size == 0)
outputs[i].supported = 0;
+ parse_edid(outputs + i, info.edid_error ? NULL : info.edid, info.edid_error ? 0 : info.edid_length);
outputs[i].name = get_crtc_name(&info, crtcs + i);
saved_errno = errno;
outputs[i].name_is_edid = ((info.edid_error == 0) && (info.edid != NULL));
@@ -284,7 +282,6 @@ int initialise_gamma_info(void)
errno = saved_errno;
if (outputs[i].name == NULL)
return -1;
- parse_edid(outputs + i);
}
return 0;
diff --git a/src/types/output.h b/src/types/output.h
index 95270ae..750ec41 100644
--- a/src/types/output.h
+++ b/src/types/output.h
@@ -59,40 +59,41 @@
*/
enum colourspace
{
+
+ /**
+ * Unknown
+ */
+ COLOURSPACE_UNKNOWN = 0,
+
/**
* sRGB with explicit gamut
*/
- COLOURSPACE_SRGB = 0,
+ COLOURSPACE_SRGB = 1,
/**
* sRGB without explicit gamut
*/
- COLOURSPACE_SRGB_SANS_GAMUT = 1,
+ COLOURSPACE_SRGB_SANS_GAMUT = 2,
/**
* RGB (but not sRGB) with known gamut
*/
- COLOURSPACE_RGB = 2,
+ COLOURSPACE_RGB = 3,
/**
* RGB (but not sRGB) without known gamut
*/
- COLOURSPACE_RGB_SANS_GAMUT = 3,
+ COLOURSPACE_RGB_SANS_GAMUT = 4,
/**
* Non-RGB multicolour
*/
- COLOURSPACE_NON_RGB = 4,
+ COLOURSPACE_NON_RGB = 5,
/**
* Greyscale or monochrome
*/
- COLOURSPACE_GREY = 5,
-
- /**
- * Unknown
- */
- COLOURSPACE_UNKNOWN = 6
+ COLOURSPACE_GREY = 6
};