[gnome-color-manager: 43/80] huey: read out the matrix we found in the register map
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager: 43/80] huey: read out the matrix we found in the register map
- Date: Mon, 19 Jul 2010 11:36:04 +0000 (UTC)
commit de84d6f6072ce82e79baf327135da431219e6756
Author: Richard Hughes <richard hughsie com>
Date: Sat Jul 17 23:09:47 2010 +0100
huey: read out the matrix we found in the register map
docs/huey/register-dump.txt | 126 +++++++++++++++++++++---------------------
src/gcm-huey-example.c | 95 +++++++++++++++++++++++++++-----
2 files changed, 144 insertions(+), 77 deletions(-)
---
diff --git a/docs/huey/register-dump.txt b/docs/huey/register-dump.txt
index b82519f..df653c5 100644
--- a/docs/huey/register-dump.txt
+++ b/docs/huey/register-dump.txt
@@ -193,69 +193,69 @@
0xf8 255 255 255 255
0xfc 255 255 255 255
-0x00 -1.9442
-0x04 0.0000 <---- A 3x3 matrix?
-0x08 0.1543 <-|
-0x0c -0.0096 <-|
-0x10 0.0381 <-|
-0x14 -0.0021 <-|
-0x18 0.1220 <-|
-0x1c 0.0033 <-|
-0x20 -0.0009 <-|
-0x24 0.0013 <-|
-0x28 0.2536 <-/
-0x2c -nan
-0x30 -nan
-0x34 -nan
-0x38 0.0000
-0x3c -0.0000
-0x40 -0.0000
-0x44 1635019055663975370442683149451264.0000
-0x48 -48481762635939840.0000
-0x4c -0.3305
-0x50 5203377440267420143976448.0000
-0x54 0.0000
-0x58 -0.0000
-0x5c 0.0000
-0x60 0.0000
-0x64 -nan
-0x68 -nan
-0x6c 66188340873952120274944.0000
-0x70 66188340873952120274944.0000
-0x74 -0.0000
-0x78 0.0000
-0x7c -nan
-0x80 236978400.0000
-0x84 0.0000
-0x88 0.0000
-0x8c 0.0000
-0x90 0.0000
-0x94 -nan
-0x98 0.0012
-0x9c -nan
-0xa0 -nan
-0xa4 -nan
-0xa8 -nan
-0xac -nan
-0xb0 -nan
-0xb4 -nan
-0xb8 -nan
-0xbc -nan
-0xc0 -nan
-0xc4 -nan
-0xc8 -nan
-0xcc -nan
-0xd0 -nan
-0xd4 -nan
-0xd8 -nan
-0xdc -nan
-0xe0 -nan
-0xe4 -nan
-0xe8 -nan
-0xec -nan
-0xf0 -nan
-0xf4 -nan
-0xf8 -nan
+0x00 0.000000
+0x04 0.154293 <---- A 3x3 matrix?
+0x08 -0.009611 <-|
+0x0c 0.038087 <-|
+0x10 -0.002070 <-|
+0x14 0.122019 <-|
+0x18 0.003279 <-|
+0x1c -0.000930 <-|
+0x20 0.001326 <-|
+0x24 0.253616 <-/
+0x28 -nan
+0x2c -nan
+0x30 -nan
+0x34 0.000000
+0x38 -0.000000
+0x3c -0.000000
+0x40 1635019055663975370442683149451264.000000
+0x44 -48481762635939840.000000
+0x48 -0.330530
+0x4c 5203377440267420143976448.000000
+0x50 0.000000
+0x54 -0.000000
+0x58 0.000000
+0x5c 0.000000
+0x60 -nan
+0x64 -nan
+0x68 66188340873952120274944.000000
+0x6c 66188340873952120274944.000000
+0x70 -0.000000
+0x74 0.000000
+0x78 -nan
+0x7c 236978400.000000
+0x80 0.000000
+0x84 0.000000
+0x88 0.000000
+0x8c 0.000000
+0x90 -nan
+0x94 0.001228
+0x98 -nan
+0x9c -nan
+0xa0 -nan
+0xa4 -nan
+0xa8 -nan
+0xac -nan
+0xb0 -nan
+0xb4 -nan
+0xb8 -nan
+0xbc -nan
+0xc0 -nan
+0xc4 -nan
+0xc8 -nan
+0xcc -nan
+0xd0 -nan
+0xd4 -nan
+0xd8 -nan
+0xdc -nan
+0xe0 -nan
+0xe4 -nan
+0xe8 -nan
+0xec -nan
+0xf0 -nan
+0xf4 -nan
+0xf8 -nan
0xfc -nan
0x00 ? ? ? ? > ? ? ?
diff --git a/src/gcm-huey-example.c b/src/gcm-huey-example.c
index 5cf0dad..5eea920 100644
--- a/src/gcm-huey-example.c
+++ b/src/gcm-huey-example.c
@@ -501,7 +501,7 @@ data_to_float (guint8 *value)
static gboolean
-read_register_byte (GcmPriv *priv, guint8 address, guint8 *value, GError **error)
+read_register_byte (GcmPriv *priv, guint8 addr, guint8 *value, GError **error)
{
guchar request[] = { HUEY_COMMAND_REGISTER_READ, 0xff, 0x00, 0x10, 0x3c, 0x06, 0x00, 0x00 };
guchar reply[8];
@@ -509,26 +509,27 @@ read_register_byte (GcmPriv *priv, guint8 address, guint8 *value, GError **error
gsize reply_read;
/* hit hardware -- it would be good to be able to get more than one byte of data at a time... */
- request[1] = address;
+ request[1] = addr;
ret = send_data (priv, request, 8, reply, 8, &reply_read, error);
if (!ret)
goto out;
/* this seems like the only byte of data that's useful */
*value = reply[3];
+// g_debug ("%02x", *value);
out:
return ret;
}
static gboolean
-read_register_string (GcmPriv *priv, guint8 address, gchar *value, gsize len, GError **error)
+read_register_string (GcmPriv *priv, guint8 addr, gchar *value, gsize len, GError **error)
{
guint8 i;
gboolean ret = TRUE;
/* get each byte of the string */
for (i=0; i<len; i++) {
- ret = read_register_byte (priv, address+i, (guint8*) &value[i], error);
+ ret = read_register_byte (priv, addr+i, (guint8*) &value[i], error);
if (!ret)
goto out;
}
@@ -537,13 +538,74 @@ out:
}
static gboolean
+read_register_word (GcmPriv *priv, guint8 addr, guint32 *value, GError **error)
+{
+ guint8 i;
+ guint8 tmp[4];
+ gboolean ret = TRUE;
+
+ /* get each byte of the 32 bit number */
+ for (i=0; i<4; i++) {
+ ret = read_register_byte (priv, addr+i, tmp+i, error);
+ if (!ret)
+ goto out;
+ }
+
+ /* convert to a 32 bit integer */
+ *value = (tmp[0] << 24) + (tmp[1] << 16) + (tmp[2] << 8) + (tmp[3] << 0);
+// g_debug ("%u", *value);
+out:
+ return ret;
+}
+
+static gboolean
+read_register_float (GcmPriv *priv, guint8 addr, gfloat *value, GError **error)
+{
+ gboolean ret;
+ guint32 tmp;
+
+ /* first read in 32 bit integer */
+ ret = read_register_word (priv, addr, &tmp, error);
+ if (!ret)
+ goto out;
+
+ /* convert to float */
+ *((guint32 *)value) = tmp;
+out:
+ return ret;
+}
+
+static gboolean
+read_register_matrix (GcmPriv *priv, guint8 addr, GcmMat3x3 *value, GError **error)
+{
+ gboolean ret = TRUE;
+ guint i;
+ gfloat tmp;
+
+ /* read in 3d matrix */
+ for (i=0; i<9; i++) {
+ ret = read_register_float (priv, addr + (i*4), &tmp, error);
+ if (!ret)
+ goto out;
+
+ /* save in matrix -- FIXME: make this a macro */
+ *(((gdouble *) value)+i) = tmp;
+
+ g_debug ("tmp=%f", tmp);
+ }
+out:
+ return ret;
+}
+
+static gboolean
read_registers (GcmPriv *priv, GError **error)
{
gboolean ret;
- guint i, j;
- guint len = 0x02;//0xff;
+ guint8 i, j;
+ guint len = 0xff;
guint8 data[len];
gchar unlock[5];
+ GcmMat3x3 value;
/* get unlock string */
ret = read_register_string (priv, 0x7a, unlock, 5, error);
@@ -551,6 +613,19 @@ read_registers (GcmPriv *priv, GError **error)
goto out;
g_print ("Unlock string: %s\n", unlock);
+
+//g_error ("moo");
+
+ /* get matrix */
+ gcm_mat33_clear (&value);
+ ret = read_register_matrix (priv, 0x04, &value, error);
+ if (!ret)
+ goto out;
+ g_print ("Big number @0x%02x): %s\n", 0x00, gcm_mat33_to_string (&value));
+
+g_error ("moo");
+
+
/* We read from 0x04 to 0x72 at startup */
for (i=0x00; i<=len; i++) {
ret = read_register_byte (priv, i, &data[i], error);
@@ -570,14 +645,6 @@ read_registers (GcmPriv *priv, GError **error)
for (i=0; i<len; i+=4) {
g_print ("0x%02x\t", i);
for (j=0; j<4; j++)
- g_print ("%02x ", data[i+j]);
- g_print ("\n");
- }
- g_print ("\n");
-
- for (i=0; i<len; i+=4) {
- g_print ("0x%02x\t", i);
- for (j=0; j<4; j++)
g_print ("%02i ", data[i+j]);
g_print ("\n");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]