[gnome-color-manager] Manually reset the VCGT tables before we attempt calibration



commit cc0463d76a8f1f04acba7d9c81319191fce21509
Author: Richard Hughes <richard hughsie com>
Date:   Thu Oct 14 13:07:04 2010 +0100

    Manually reset the VCGT tables before we attempt calibration

 src/cc-color-panel.c    |    8 ++++++
 src/gcm-device-xrandr.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++-
 src/gcm-device-xrandr.h |    2 +
 3 files changed, 65 insertions(+), 1 deletions(-)
---
diff --git a/src/cc-color-panel.c b/src/cc-color-panel.c
index 71638ee..27830b2 100644
--- a/src/cc-color-panel.c
+++ b/src/cc-color-panel.c
@@ -289,6 +289,14 @@ cc_color_panel_calibrate_display (CcColorPanel *panel, GcmCalibrate *calibrate)
 		goto out;
 	}
 
+	/* clear any VCGT */
+	ret = gcm_device_xrandr_reset (GCM_DEVICE_XRANDR (panel->priv->current_device), &error);
+	if (!ret) {
+		egg_warning ("failed to reset so we can calibrate: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
 	/* run each task in order */
 	window = GTK_WINDOW(panel->priv->main_window);
 	ret = gcm_calibrate_display (calibrate, window, &error);
diff --git a/src/gcm-device-xrandr.c b/src/gcm-device-xrandr.c
index 498baea..d347632 100644
--- a/src/gcm-device-xrandr.c
+++ b/src/gcm-device-xrandr.c
@@ -299,7 +299,7 @@ out:
 }
 
 /**
- * gcm_device_xrandr_apply_for_output:
+ * gcm_device_xrandr_get_xrandr13:
  * @device_xrandr: a valid #GcmDeviceXrandr instance
  *
  * Return value: %TRUE if the display supports XRandr 1.3;
@@ -468,6 +468,60 @@ out:
 }
 
 /**
+ * gcm_device_xrandr_reset:
+ *
+ * Clears any VCGT table, so we're ready for profiling
+ *
+ * Return value: %TRUE for success;
+ **/
+gboolean
+gcm_device_xrandr_reset (GcmDeviceXrandr *device_xrandr, GError **error)
+{
+	const gchar *id;
+	const gchar *output_name;
+	gboolean ret = FALSE;
+	GcmClut *clut = NULL;
+	GcmDeviceKind kind;
+	GcmX11Output *output;
+	guint size;
+	GcmDeviceXrandrPrivate *priv = device_xrandr->priv;
+
+	/* do no set the gamma for non-display types */
+	id = gcm_device_get_id (GCM_DEVICE (device_xrandr));
+	kind = gcm_device_get_kind (GCM_DEVICE (device_xrandr));
+	if (kind != GCM_DEVICE_KIND_DISPLAY) {
+		g_set_error (error, 1, 0, "not a display: %s", id);
+		goto out;
+	}
+
+	/* should be set for display types */
+	output_name = gcm_device_xrandr_get_native_device (device_xrandr);
+	if (output_name == NULL || output_name[0] == '\0') {
+		g_set_error (error, 1, 0, "no output name for display: %s", id);
+		goto out;
+	}
+
+	/* get GcmX11Output for this device */
+	output = gcm_x11_screen_get_output_by_name (priv->screen, output_name, error);
+	if (output == NULL)
+		goto out;
+	size = gcm_x11_output_get_gamma_size (output);
+
+	/* create a linear ramp */
+	clut = gcm_clut_new ();
+	g_object_set (clut,
+		      "size", size,
+		      NULL);
+
+	/* actually set the gamma */
+	ret = gcm_device_xrandr_apply_for_output (device_xrandr, output, clut, error);
+	if (!ret)
+		goto out;
+out:
+	return ret;
+}
+
+/**
  * gcm_device_xrandr_apply:
  *
  * Return value: %TRUE for success;
diff --git a/src/gcm-device-xrandr.h b/src/gcm-device-xrandr.h
index d47fa04..91bd7aa 100644
--- a/src/gcm-device-xrandr.h
+++ b/src/gcm-device-xrandr.h
@@ -60,6 +60,8 @@ const gchar	*gcm_device_xrandr_get_eisa_id		(GcmDeviceXrandr	*device_xrandr);
 const gchar	*gcm_device_xrandr_get_edid_md5		(GcmDeviceXrandr	*device_xrandr);
 gboolean	 gcm_device_xrandr_get_xrandr13		(GcmDeviceXrandr	*device_xrandr);
 gboolean	 gcm_device_xrandr_is_primary		(GcmDeviceXrandr	*device_xrandr);
+gboolean	 gcm_device_xrandr_reset		(GcmDeviceXrandr	*device_xrandr,
+							 GError			**error);
 
 G_END_DECLS
 



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