aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-06-03 07:33:31 +0200
committerMattias Andrée <maandree@operamail.com>2014-06-03 07:33:31 +0200
commit9362c381072627b08ca42d6d9f909f9597902dfa (patch)
tree0ce35b3bdef1d078a6d3714b7a3ce6a69d54105b
parentinfo: m (diff)
downloadlibgamma-9362c381072627b08ca42d6d9f909f9597902dfa.tar.gz
libgamma-9362c381072627b08ca42d6d9f909f9597902dfa.tar.bz2
libgamma-9362c381072627b08ca42d6d9f909f9597902dfa.tar.xz
m fixes + print all crtc info , except connector type and subpixel order, in the test
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--Makefile2
-rwxr-xr-xsrc/extract/libgamma-method-extract10
-rw-r--r--src/lib/fake-quartz-cg.c4
-rw-r--r--src/lib/fake-w32-gdi.c4
-rw-r--r--src/lib/gamma-x-randr.c19
-rw-r--r--src/lib/libgamma-facade.c.gpp10
-rw-r--r--src/lib/libgamma-method.h9
-rw-r--r--src/test/test.c99
8 files changed, 143 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index f088418..0989c41 100644
--- a/Makefile
+++ b/Makefile
@@ -139,7 +139,7 @@ bin/test: $(foreach O,$(TESTOBJ),obj/test/$(O).o) bin/libgamma.so.$(LIB_VERSION)
mkdir -p $(shell dirname $@)
$(CC) $(TEST_FLAGS) $(LIBS_LD) -Lbin -lgamma -o $@ $(foreach O,$(TESTOBJ),obj/test/$(O).o)
-obj/test/%.o: src/test/%.c
+obj/test/%.o: src/test/%.c src/lib/libgamma*.h
mkdir -p $(shell dirname $@)
$(CC) $(TEST_FLAGS) -Isrc/lib -c -o $@ $<
diff --git a/src/extract/libgamma-method-extract b/src/extract/libgamma-method-extract
index 88c41f0..fd4266c 100755
--- a/src/extract/libgamma-method-extract
+++ b/src/extract/libgamma-method-extract
@@ -42,7 +42,7 @@ def list_enum(prefix, *blacklist):
def list_struct(name):
global data
- data = data[data.find('\ntypedef struct ' + name):]
+ data = data[data.find('\ntypedef struct ' + name + '\n'):]
data = data[:data.find('\n}')]
test1 = lambda line : line.startswith(' ') and line.endswith(';')
test2 = lambda line : ' * ' not in line
@@ -52,7 +52,7 @@ def list_struct(name):
def type_struct(name):
global data
- data = data[data.find('\ntypedef struct ' + name):]
+ data = data[data.find('\ntypedef struct ' + name + '\n'):]
data = data[:data.find('\n}')]
test1 = lambda line : line.startswith(' ')
test2 = lambda line : ' * ' not in line
@@ -69,7 +69,7 @@ def type_struct(name):
def doc_typedef(name):
global data
- data = data[:data.find('\ntypedef ' + name):]
+ data = data[:data.find('\ntypedef ' + name + '\n'):]
data = data[:data.rfind('\n */')]
data = data[data.rfind('/**\n') + len('/**\n'):]
data = [line[3:] for line in data.split('\n')]
@@ -78,7 +78,7 @@ def doc_typedef(name):
def doc_define():
global data
- data = data[:data.find('\n#define ' + sys.argv[2])]
+ data = data[:data.find('\n#define ' + sys.argv[2] + ' ')]
data = data[:data.rfind('\n */')]
data = data[data.rfind('/**\n') + len('/**\n'):]
data = [line[3:] for line in data.split('\n')]
@@ -96,7 +96,7 @@ def doc_enum():
def doc_struct(name):
global data
- data = data[data.find('\ntypedef struct ' + name):]
+ data = data[data.find('\ntypedef struct ' + name + '\n'):]
data = data[:data.find('\n}')]
test1 = lambda line : line.startswith(' ')
test2 = lambda line : ' * ' not in line
diff --git a/src/lib/fake-quartz-cg.c b/src/lib/fake-quartz-cg.c
index 1fcfaf3..3ce7449 100644
--- a/src/lib/fake-quartz-cg.c
+++ b/src/lib/fake-quartz-cg.c
@@ -147,8 +147,10 @@ static uint16_t* restrict original_ramps = NULL;
/* xcb violates the rule to never return struct:s. */
+#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Waggregate-return"
+#endif
CGError CGGetOnlineDisplayList(uint32_t max_size,
@@ -362,7 +364,9 @@ uint32_t CGDisplayGammaTableCapacity(CGDirectDisplayID display)
}
+#ifdef __GNUC__
# pragma GCC diagnostic pop
+#endif
void close_fake_quartz_cg(void)
diff --git a/src/lib/fake-w32-gdi.c b/src/lib/fake-w32-gdi.c
index c5bf8a3..c4d7c11 100644
--- a/src/lib/fake-w32-gdi.c
+++ b/src/lib/fake-w32-gdi.c
@@ -205,8 +205,10 @@ int GetDeviceCaps(HDC hDC, int nIndex)
/* xcb violates the rule to never return struct:s. */
+#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Waggregate-return"
+#endif
/* http://msdn.microsoft.com/en-us/library/windows/desktop/dd372194(v=vs.85).aspx */
@@ -318,7 +320,9 @@ HDC CreateDC(LPCTSTR restrict lpszDriver, LPCTSTR restrict lpszDevice,
}
+#ifdef __GNUC__
# pragma GCC diagnostic pop
+#endif
/* http://msdn.microsoft.com/en-us/library/windows/desktop/dd162609(v=vs.85).aspx */
diff --git a/src/lib/gamma-x-randr.c b/src/lib/gamma-x-randr.c
index 7ca8674..86e5450 100644
--- a/src/lib/gamma-x-randr.c
+++ b/src/lib/gamma-x-randr.c
@@ -162,8 +162,10 @@ void libgamma_x_randr_method_capabilities(libgamma_method_capabilities_t* restri
/* xcb violates the rule to never return struct:s. */
+#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Waggregate-return"
+#endif
/**
@@ -604,6 +606,7 @@ static int get_connector_type(libgamma_crtc_information_t* restrict this)
__select ("DVI-I", DVII);
__select ("DVI-D", DVID);
__select ("DVI-A", DVIA);
+ __select ("DVI", DVI);
__select ("Composite", Composite);
__select ("S-Video", SVIDEO);
__select ("Component", Component);
@@ -641,7 +644,7 @@ static int get_output_name(libgamma_crtc_information_t* restrict out, xcb_randr_
return out->connector_name_error = LIBGAMMA_REPLY_VALUE_EXTRACTION_FAILED;
/* Allocate a memory area for a NUL-terminated copy of the name. */
- store = malloc(((size_t)length + 1) * sizeof(char));
+ store = out->connector_name = malloc(((size_t)length + 1) * sizeof(char));
if (store == NULL)
return out->connector_name_error = errno, -1;
@@ -750,6 +753,7 @@ static int get_edid(libgamma_crtc_information_t* restrict out,
}
/* Store the EDID. */
+ out->edid_length = (size_t)length;
out->edid = malloc((size_t)length * sizeof(unsigned char));
if (out->edid == NULL)
out->edid_error = errno;
@@ -783,7 +787,7 @@ int libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t* restrict
int e = 0;
xcb_randr_get_output_info_reply_t* restrict output_info = NULL;
xcb_randr_output_t output;
- int free_edid;
+ int free_edid, free_name;
/* Wipe all error indicators. */
memset(this, 0, sizeof(libgamma_crtc_information_t));
@@ -791,6 +795,9 @@ int libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t* restrict
/* We need to free the EDID after us if it is not explicitly requested. */
free_edid = (fields & LIBGAMMA_CRTC_INFO_EDID) == 0;
+ /* We need to free the output's name after us if it is not explicitly requested. */
+ free_name = (fields & LIBGAMMA_CRTC_INFO_CONNECTOR_NAME) == 0;
+
/* Jump if the output information is not required. */
if ((fields & (LIBGAMMA_CRTC_INFO_MACRO_ACTIVE | LIBGAMMA_CRTC_INFO_MACRO_CONNECTOR)) == 0)
goto cont;
@@ -875,6 +882,12 @@ int libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t* restrict
free(this->edid);
this->edid = NULL;
}
+ /* Free the output name after us. */
+ if (free_name)
+ {
+ free(this->connector_name);
+ this->connector_name = NULL;
+ }
free(output_info);
return e ? -1 : 0;
@@ -961,5 +974,7 @@ int libgamma_x_randr_crtc_set_gamma_ramps(libgamma_crtc_state_t* restrict this,
}
+#ifdef __GNUC__
# pragma GCC diagnostic pop
+#endif
diff --git a/src/lib/libgamma-facade.c.gpp b/src/lib/libgamma-facade.c.gpp
index 038fad4..d380d97 100644
--- a/src/lib/libgamma-facade.c.gpp
+++ b/src/lib/libgamma-facade.c.gpp
@@ -60,8 +60,10 @@ lowercase ()
not have any adjustment methods enabled. */
#ifndef HAVE_LIBGAMMA_METHODS
# define HAVE_NO_LIBGAMMA_METHODS
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
+# ifdef __GNUC__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
+# endif
#endif
@@ -1050,6 +1052,8 @@ int libgamma_crtc_set_gamma_£{2}_f(libgamma_crtc_state_t* restrict this,
#ifdef HAVE_NO_LIBGAMMA_METHODS
-# pragma GCC diagnostic pop
+# ifdef __GNUC__
+# pragma GCC diagnostic pop
+# endif
#endif
diff --git a/src/lib/libgamma-method.h b/src/lib/libgamma-method.h
index 143f17c..d57d3cb 100644
--- a/src/lib/libgamma-method.h
+++ b/src/lib/libgamma-method.h
@@ -320,6 +320,11 @@ typedef enum libgamma_connector_type
LIBGAMMA_CONNECTOR_TYPE_VGA,
/**
+ * Digital Visual Interface, unknown type.
+ */
+ LIBGAMMA_CONNECTOR_TYPE_DVI,
+
+ /**
* Digital Visual Interface, integrated (DVI-I).
*/
LIBGAMMA_CONNECTOR_TYPE_DVII,
@@ -410,7 +415,7 @@ typedef enum libgamma_connector_type
/**
* The number of values defined in `libgamma_connector_type_t`.
*/
-#define LIBGAMMA_CONNECTOR_TYPE_COUNT 19
+#define LIBGAMMA_CONNECTOR_TYPE_COUNT 20
/**
* Orders for subpixels. Currently the possible values are
@@ -533,7 +538,7 @@ typedef enum libgamma_subpixel_order
/**
* For a `libgamma_crtc_information_t` fill in the
* values for `gamma_red`, `gamma_green` and `gamma_blue`
- * and report errors to `connector_type_error`.
+ * and report errors to `gamma_error`.
*/
#define LIBGAMMA_CRTC_INFO_GAMMA (1 << 12)
diff --git a/src/test/test.c b/src/test/test.c
index 6c00d3d..f18819c 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -30,7 +30,7 @@
# if LIBGAMMA_METHOD_COUNT > 6
# warning New adjust methods has been added to libgamma
# endif
-# if LIBGAMMA_CONNECTOR_TYPE_COUNT > 19
+# if LIBGAMMA_CONNECTOR_TYPE_COUNT > 20
# warning New connector types have been added to libgamma.
# endif
# if LIBGAMMA_SUBPIXEL_ORDER_COUNT > 6
@@ -249,10 +249,105 @@ static int select_monitor(libgamma_site_state_t* restrict site_state,
return libgamma_perror("error", r), 1;
}
+ printf("\n");
return 0;
}
+#define print_crtc_information_(type, notation) \
+ static void print_crtc_information_##type(int do_print, const char* description, int error, type value) \
+ { \
+ char buf[256]; \
+ if (do_print) \
+ { \
+ if (error) \
+ { \
+ snprintf(buf, sizeof(buf) / sizeof(char), " (error) %s", description); \
+ libgamma_perror(buf, error); \
+ } \
+ else \
+ printf(" %s: %" notation "\n", description, value); \
+ } \
+ }
+
+typedef const char* str;
+print_crtc_information_(size_t, "lu")
+print_crtc_information_(signed, "i")
+print_crtc_information_(int, "i")
+#ifdef __GNUC__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wdouble-promotion"
+#endif
+print_crtc_information_(float, "f")
+#ifdef __GNUC__
+# pragma GCC diagnostic pop
+#endif
+print_crtc_information_(str, "s")
+
+
+static void crtc_information(libgamma_crtc_state_t* restrict crtc)
+{
+ libgamma_method_capabilities_t caps;
+ libgamma_crtc_information_t info;
+ int fields;
+ int field;
+
+ libgamma_method_capabilities(&caps, crtc->partition->site->method);
+
+ for (fields = caps.crtc_information; field = fields & -fields, fields; fields ^= field)
+ {
+ if (libgamma_get_crtc_information(&info, crtc, field))
+ printf("Could not read CRTC information field %i\n", field);
+ free(info.edid);
+ free(info.connector_name);
+ }
+
+ fields = caps.crtc_information;
+ if (libgamma_get_crtc_information(&info, crtc, fields))
+ printf("An error occurred while reading CRTC information\n");
+
+#define print2(TYPE, FIELD_ID, DESCRIPTION, FIELD_VAR, ERROR_VAR) \
+ print_crtc_information_##TYPE(fields & FIELD_ID, DESCRIPTION, info.ERROR_VAR, info.FIELD_VAR);
+#define print(TYPE, FIELD_ID, DESCRIPTION, FIELD_VAR) \
+ print2(TYPE, FIELD_ID, DESCRIPTION, FIELD_VAR, FIELD_VAR##_error);
+
+ printf("CRTC information:\n");
+ if ((fields & LIBGAMMA_CRTC_INFO_EDID))
+ {
+ if (info.edid_error)
+ libgamma_perror(" (error) EDID", info.edid_error);
+ else
+ {
+ char* edid = libgamma_behex_edid(info.edid, info.edid_length);
+ printf(" EDID: %s\n", edid);
+ printf(" EDID (length): %lu\n", info.edid_length);
+ free(edid);
+ }
+ }
+ print(size_t, LIBGAMMA_CRTC_INFO_WIDTH_MM, "width", width_mm);
+ print(size_t, LIBGAMMA_CRTC_INFO_HEIGHT_MM, "height", height_mm);
+ print(size_t, LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID, "width per EDID", width_mm_edid);
+ print(size_t, LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID, "height per EDID", height_mm_edid);
+ print2(size_t, LIBGAMMA_CRTC_INFO_GAMMA_SIZE, "red gamma ramp size", red_gamma_size, gamma_size_error);
+ print2(size_t, LIBGAMMA_CRTC_INFO_GAMMA_SIZE, "green gamma ramp size", green_gamma_size, gamma_size_error);
+ print2(size_t, LIBGAMMA_CRTC_INFO_GAMMA_SIZE, "blue gamma ramp size", blue_gamma_size, gamma_size_error);
+ print(signed, LIBGAMMA_CRTC_INFO_GAMMA_DEPTH, "gamma ramp depth", gamma_depth);
+ print(int, LIBGAMMA_CRTC_INFO_GAMMA_SUPPORT, "gamma support", gamma_support);
+ /* print(size_t, LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER, "subpixel order", subpixel_order); */
+ print(int, LIBGAMMA_CRTC_INFO_ACTIVE, "active", active);
+ print(str, LIBGAMMA_CRTC_INFO_CONNECTOR_NAME, "connector name", connector_name);
+ /* LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE connector_type */
+ print2(float, LIBGAMMA_CRTC_INFO_GAMMA, "red gamma characteristics", gamma_red, gamma_error);
+ print2(float, LIBGAMMA_CRTC_INFO_GAMMA, "green gamma characteristics", gamma_green, gamma_error);
+ print2(float, LIBGAMMA_CRTC_INFO_GAMMA, "blue gamma characteristics", gamma_blue, gamma_error);
+
+#undef print
+
+ free(info.edid);
+ free(info.connector_name);
+}
+
+
int main(void)
{
libgamma_site_state_t* restrict site_state = malloc(sizeof(libgamma_site_state_t));
@@ -268,6 +363,8 @@ int main(void)
if (select_monitor(site_state, part_state, crtc_state))
return 1;
+ crtc_information(crtc_state);
+
libgamma_crtc_free(crtc_state);
libgamma_partition_free(part_state);
libgamma_site_free(site_state);