Debian Codegraph @

src/sensors/huey/huey-enum.h

raw
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2013 Richard Hughes <[email protected]>
4 *
5 * Licensed under the GNU General Public License Version 2
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 #ifndef __HUEY_ENUM_H
23 #define __HUEY_ENUM_H
24
25 #include <glib-object.h>
26
27 G_BEGIN_DECLS
28
29 /* external hueys */
30 #define CD_SENSOR_HUEY_VENDOR_ID 0x0971
31 #define CD_SENSOR_HUEY_PRODUCT_ID 0x2005
32
33 /* integrated and newer devices */
34 #define CD_SENSOR_HUEY_VENDOR_ID2 0x0765
35 #define CD_SENSOR_HUEY_PRODUCT_ID2 0x5001
36
37 /* Return values from the commands */
38 #define HUEY_RC_SUCCESS 0x00
39 #define HUEY_RC_LOCKED 0xc0
40 #define HUEY_RC_UNKNOWN_5A 0x5a /* seen in profiling */
41 #define HUEY_RC_ERROR 0x80
42 #define HUEY_RC_UNKNOWN_81 0x81 /* seen once in init */
43 #define HUEY_RC_RETRY 0x90
44
45 /*
46 * Get the currect status of the device
47 *
48 * input: 00 00 00 00 3f 00 00 00
49 * returns: 00 00 43 69 72 30 30 31 (or)
50 * "Cir001" --^^^^^^^^^^^^^^^^^ (Pantone Huey)
51 * c0 00 xx xx xx xx xx xx
52 * "huL002" --^^^^^^^^^^^^^^^^^ (Lenovo Huey)
53 * c0 00 4c 6f 63 6b 65 64
54 * "locked" --^^^^^^^^^^^^^^^^^
55 */
56 #define HUEY_CMD_GET_STATUS 0x00
57
58 /*
59 * Read the green sample data
60 *
61 * input: 02 xx xx xx xx xx xx xx
62 * returns: 00 02 00 00 0a 00 00 00 (or)
63 * 00 02 00 0e c6 80 00 00
64 * data --^^^^^ ^-- only ever 00 or 80
65 * |
66 * \-- for RGB(00,00,00) is 09 f2
67 * RGB(ff,ff,ff) is 00 00
68 * RGB(ff,00,00) is 02 a5
69 * RGB(00,ff,00) is 00 f1
70 * RGB(00,00,ff) is 08 56
71 *
72 * This doesn't do a sensor read, it seems to be a simple accessor.
73 * HUEY_CMD_SENSOR_MEASURE_RGB has to be used before this one.
74 */
75 #define HUEY_CMD_READ_GREEN 0x02
76
77 /*
78 * Read the blue sample data
79 *
80 * input: 03 xx xx xx xx xx xx xx
81 * returns: 00 03 00 0f 18 00 00 00
82 * data --^^^^^ ^-- only ever 00 or 80
83 * |
84 * \-- for RGB(00,00,00) is 09 64
85 * RGB(ff,ff,ff) is 08 80
86 * RGB(ff,00,00) is 03 22
87 * RGB(00,ff,00) is 00 58
88 * RGB(00,00,ff) is 00 59
89 *
90 * This doesn't do a sensor read, it seems to be a simple accessor.
91 * HUEY_CMD_SENSOR_MEASURE_RGB has to be used before this one.
92 */
93 #define HUEY_CMD_READ_BLUE 0x03
94
95 /*
96 * Sets a 32 bit integration time register.
97 *
98 * input: 05 ?? 11 12 13 14 xx xx
99 * returns: 00 05 00 00 00 00 00 00
100 * ^--- always the same no matter the input
101 *
102 * This is not normally used during profiling
103 */
104 #define HUEY_CMD_SET_INTEGRATION_TIME 0x05
105
106 /*
107 * Get the value of the 32 bit integration time register.
108 *
109 * input: 06 xx xx xx xx xx xx xx
110 * returns: 00 06 11 12 13 14 00 00
111 * 4 bytes ----^^^^^^^^^^^ (from HUEY_CMD_SET_INTEGRATION_TIME)
112 *
113 * The default value at plug-in is 00 0f 42 40, although during
114 * profiling it is set to 00 00 6f 00 and then 00 00 61 00.
115 */
116 #define HUEY_CMD_GET_INTEGRATION_TIME 0x06
117
118 /*
119 * Writes a register value.
120 *
121 * (sent at startup after the unlock)
122 * input: 07 0b ff xx xx xx xx xx
123 * ^^-- data value
124 * ^^-- register address
125 * returns: 00 xx xx xx xx xx xx xx
126 *
127 * You can only write one byte at a time.
128 */
129 #define HUEY_CMD_REGISTER_WRITE 0x07
130
131 /*
132 * Reads a register value.
133 *
134 * (sent at startup after the unlock)
135 * input: 08 0b xx xx xx xx xx xx
136 * ^^-- register address
137 * returns: 00 08 0b b8 00 00 00 00
138 * address --^^ ^^-- value
139 *
140 * You can only read one byte at a time.
141 */
142 #define HUEY_CMD_REGISTER_READ 0x08
143
144 /*
145 * Unlock a locked sensor.
146 *
147 * input: 0e 47 72 4d 62 6b 65 64 (Pantone Huey)
148 * "GrMb"--^^^^^^^^^^^
149 * 0e 47 72 4d 62 6b 65 64 (Lenovo Huey)
150 * "huyL"--^^^^^^^^^^^
151 * returns: 00 0e 00 00 00 00 00 00
152 *
153 * Only GrMbk or huyL is needed to unlock, the rest is just junk data.
154 * We still don't know how to 'lock' a device, it just kinda happens.
155 */
156 #define HUEY_CMD_UNLOCK 0x0e
157
158 /*
159 * Unknown command
160 *
161 * returns: all NULL all of the time */
162 #define HUEY_CMD_UNKNOWN_0F 0x0f
163
164 /*
165 * Unknown command
166 *
167 * Something to do with sampling */
168 #define HUEY_CMD_UNKNOWN_10 0x10
169
170 /*
171 * Unknown command
172 *
173 * Something to do with sampling (that needs a retry with code 5a)
174 */
175 #define HUEY_CMD_UNKNOWN_11 0x11
176
177 /*
178 * Unknown command
179 *
180 * something to do with sampling
181 */
182 #define HUEY_CMD_UNKNOWN_12 0x12
183
184 /*
185 * Measures RGB value, and return the red value (only used in CRT mode).
186 *
187 * Seems to have to retry, every single time.
188 *
189 * Gain?
190 * _______|_______
191 * /---\ /---\ /---\
192 * input: 13 02 41 00 54 00 49 00
193 * returns: 00 13 00 00 01 99 02 00
194 * ^^^^^ - would match HUEY_CMD_SENSOR_MEASURE_RGB
195 *
196 * The gain seems not to change for different measurements with different
197 * colors. This seems to be a less precise profile too.
198 */
199 #define HUEY_CMD_SENSOR_MEASURE_RGB_CRT 0x13
200
201 /*
202 * Unknown command
203 *
204 * returns: seems to be sent, but not requested
205 */
206 #define HUEY_CMD_UNKNOWN_15 0x15
207
208 /*
209 * Sample a color and return the red component
210 *
211 * input: 16 00 01 00 01 00 01 00
212 * returns: 00 16 00 00 00 00 00 00
213 *
214 * or:
215 * ,,-,,-,,-,,-,,-,,-- 'gain control'
216 * || || || || || ||
217 * input: 16 00 35 00 48 00 1d 03
218 * returns: 00 16 00 0b d0 00 00 00
219 * data --^^^^^ ^^-- only ever 00 or 80
220 *
221 * This is used when profiling, and all commands are followed by
222 * HUEY_CMD_READ_GREEN and HUEY_COMMAND_READ_BLUE.
223 *
224 * The returned values are some kind of 16 bit register count that
225 * indicate how much light fell on a sensor. If the sensors are
226 * converting light to pulses, then the 'gain' control tells the sensor
227 * how long to read. It's therefore quicker to read white than black.
228 *
229 * Given there exists only GREEN and BLUE accessors, and that RED comes
230 * first in a RGB sequence, I think it's safe to assume that this command
231 * does the measurement, and the others just return cached data.
232 *
233 * argyll does (for #ff0000)
234 *
235 * -> 16 00 01 00 01 00 01 00
236 * <- 00 00 0b 00 00 00
237 * -> 02 xx xx xx xx xx xx xx
238 * <- 00 00 12 00 00 00
239 * -> 03 xx xx xx xx xx xx xx
240 * <- 00 03 41 00 00 00
241 *
242 * then does:
243 *
244 * -> 16 01 63 00 d9 00 04 00
245 * <- 00 0f ce 80 00 00
246 * -> 02 xx xx xx xx xx xx xx
247 * <- 00 0e d0 80 00 00
248 * -> 03 xx xx xx xx xx xx xx
249 * <- 00 0d 3c 00 00 00
250 *
251 * then returns XYZ=87.239169 45.548708 1.952249
252 */
253 #define HUEY_CMD_SENSOR_MEASURE_RGB 0x16
254
255 /*
256 * Unknown command (some sort of poll?)
257 *
258 * input: 21 09 00 02 00 00 08 00 (or)
259 * returns: [never seems to return a value]
260 *
261 * Only when profiling, and over and over.
262 */
263 #define HUEY_CMD_UNKNOWN_21 0x21
264
265 /*
266 * Get the level of ambient light from the sensor
267 *
268 * ,,--- The output-type, where 00 is LCD and 02 is CRT
269 * input: 17 03 00 xx xx xx xx xx
270 * returns: 90 17 03 00 00 00 00 00 then on second read:
271 * 00 17 03 00 00 62 57 00 in light (or)
272 * 00 17 03 00 00 00 08 00 in dark
273 * no idea --^^ ^---^ = 16bits data
274 */
275 #define HUEY_CMD_GET_AMBIENT 0x17
276
277 /*
278 * Set the LEDs on the sensor
279 *
280 * input: 18 00 f0 xx xx xx xx xx
281 * returns: 00 18 f0 00 00 00 00 00
282 * led mask ----^^
283 */
284 #define HUEY_CMD_SET_LEDS 0x18
285
286 /*
287 * Unknown command
288 *
289 * returns: all NULL for NULL input: times out for f1 f2 f3 f4 f5 f6 f7 f8 */
290 #define HUEY_CMD_SENSOR_MEASURE_RGB_ALT 0x19
291
292 /*
293 * Register map:
294 * x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF
295 * 0x [serial-number.][matrix-lcd....................................|
296 * 1x ...............................................................|
297 * 2x .......] |
298 * 3x [calib-lcd-time][matrix-crt............................|
299 * 4x ...............................................................|
300 * 5x .......................................][calib-crt-time] |
301 * 6x [calib_vector......................|
302 * 7x ...........] [unlock-string.....] |
303 * 8x |
304 * 9x [calib_value...] |
305 */
306 #define HUEY_EEPROM_ADDR_SERIAL 0x00 /* 4 bytes */
307 #define HUEY_EEPROM_ADDR_CALIBRATION_DATA_LCD 0x04 /* 36 bytes */
308 #define HUEY_EEPROM_ADDR_CALIBRATION_TIME_LCD 0x32 /* 4 bytes */
309 #define HUEY_EEPROM_ADDR_CALIBRATION_DATA_CRT 0x36 /* 36 bytes */
310 #define HUEY_EEPROM_ADDR_CALIBRATION_TIME_CRT 0x5a /* 4 bytes */
311 #define HUEY_EEPROM_ADDR_DARK_OFFSET 0x67 /* 12 bytes */
312 #define HUEY_EEPROM_ADDR_UNLOCK 0x7a /* 5 bytes */
313 #define HUEY_EEPROM_ADDR_AMBIENT_CALIB_VALUE 0x94 /* 4 bytes */
314
315 const gchar *huey_rc_to_string (guchar value);
316 const gchar *huey_cmd_code_to_string (guchar value);
317
318 G_END_DECLS
319
320 #endif /* __HUEY_ENUM_H */
321