1
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3
* Copyright (C) 2011 Richard Hughes <richard@hughsie.com>
3
* Copyright (C) 2011-2012 Richard Hughes <richard@hughsie.com>
5
5
* Licensed under the GNU General Public License Version 2
35
35
#define CH_USB_HID_EP_OUT (CH_USB_HID_EP | 0x00)
36
36
#define CH_USB_HID_EP_SIZE 64
38
/* the default timeout in client tools */
39
#define CH_DEVICE_USB_TIMEOUT 5000 /* ms */
41
/* constants for ownership tags */
42
#define CH_OWNER_LENGTH_MAX 60
39
45
* CH_CMD_GET_COLOR_SELECT:
104
122
* OUT: [1:retval][1:cmd][2:major][2:minor][2:micro]
124
* This command is available in bootloader and firmware mode.
106
126
#define CH_CMD_GET_FIRMWARE_VERSION 0x07
109
129
* CH_CMD_GET_CALIBRATION:
111
* Gets the calibration matrix. The description does not have to be NULL terminated.
131
* Gets the calibration matrix. The description does not have to be NULL
134
* @types is a bitmask which corresponds to:
137
* 0 Can be used with LCD panels
138
* 1 Can be used with CRT monitors
139
* 2 Can be used with projectors
140
* 3 Can be used with LED panels
141
* 4-7 Reserved for future use
113
143
* IN: [1:cmd][2:index]
114
* OUT: [1:retval][1:cmd][2*9:matrix_value][24:description]
144
* OUT: [1:retval][1:cmd][2*9:matrix_value][1:types][23:description]
146
* This command is only available in firmware mode.
116
148
#define CH_CMD_GET_CALIBRATION 0x09
119
151
* CH_CMD_SET_CALIBRATION:
121
* Sets the calibration matrix. The @matrix_value parameter is a 16 bit
122
* _signed_ value that scales from -1.0 to +1.0.
153
* Sets the calibration matrix.
124
* IN: [1:cmd][2:index][4*9:matrix_value][24:description]
155
* IN: [1:cmd][2:index][4*9:matrix_value][1:types][23:description]
125
156
* OUT: [1:retval][1:cmd]
158
* This command is only available in firmware mode.
127
160
#define CH_CMD_SET_CALIBRATION 0x0a
188
231
* IN: [1:cmd][2:red][2:green][2:blue]
189
232
* OUT: [1:retval][1:cmd]
234
* This command is only available in firmware mode.
191
236
#define CH_CMD_SET_DARK_OFFSETS 0x10
239
* CH_CMD_GET_OWNER_NAME:
244
* OUT: [1:retval][1:cmd][60:owner-name]
246
* This command is only available in firmware mode.
248
#define CH_CMD_GET_OWNER_NAME 0x11
251
* CH_CMD_SET_OWNER_NAME:
255
* IN: [1:cmd][60:owner-name]
256
* OUT: [1:retval][1:cmd]
258
* This command is only available in firmware mode.
260
#define CH_CMD_SET_OWNER_NAME 0x12
263
* CH_CMD_GET_OWNER_EMAIL:
265
* Get User's Email Address
268
* OUT: [1:retval][1:cmd][60:owner-email]
270
* This command is only available in firmware mode.
272
#define CH_CMD_GET_OWNER_EMAIL 0x13
275
* CH_CMD_SET_OWNER_NAME:
277
* Set User's Email Address
279
* IN: [1:cmd][60:owner-email]
280
* OUT: [1:retval][1:cmd]
282
* This command is only available in firmware mode.
284
#define CH_CMD_SET_OWNER_EMAIL 0x14
194
287
* CH_CMD_WRITE_EEPROM:
196
289
* Write values to EEPROM.
198
291
* IN: [1:cmd][8:eeprom_magic]
199
292
* OUT: [1:retval][1:cmd]
294
* This command is only available in firmware mode.
201
296
#define CH_CMD_WRITE_EEPROM 0x20
234
333
* map is used to find the default calibration index to use.
236
335
* IN: [1:cmd][2:calibration-index]
237
* OUT: [1:retval][1:cmd][2:red][2:green][2:blue]
336
* OUT: [1:retval][1:cmd][4:red][4:green][4:blue]
338
* This command is only available in firmware mode.
239
340
#define CH_CMD_TAKE_READING_XYZ 0x23
371
493
* In the future CustomX may be renamed to another display technology,
375
497
* OUT: [1:retval][1:cmd][6*2:types]
499
* This command is only available in firmware mode.
377
501
#define CH_CMD_GET_CALIBRATION_MAP 0x2e
384
508
* IN: [1:cmd][6*2:types]
385
509
* OUT: [1:retval][1:cmd]
511
* This command is only available in firmware mode.
387
513
#define CH_CMD_SET_CALIBRATION_MAP 0x2f
516
* CH_CMD_GET_HARDWARE_VERSION:
518
* Get the hardware version.
520
* The hardware versions are as follows:
521
* 0x00 = Pre-production hardware
522
* 0x01 = First generation hardware
523
* 0x02-0x0f = Reserved for future use
526
* OUT: [1:retval][1:cmd][1:hw_version]
528
* This command is available in bootloader and firmware mode.
530
#define CH_CMD_GET_HARDWARE_VERSION 0x30
533
* CH_CMD_TAKE_READING_ARRAY:
535
* Takes 30 raw samples and returns them in an array.
537
* This command can be used to find the optimum delay between patches
538
* by showing a black sample area, then white, and then using this
539
* command to find out how long the actual hardware delay is.
541
* It can also be used to find out how stable the device or output is
542
* over a small amount of time, typically ~2.5 seconds for the maximum
546
* OUT: [1:retval][1:cmd][30:reading_array]
548
* This command is available in firmware mode.
550
#define CH_CMD_TAKE_READING_ARRAY 0x31
553
* CH_CMD_SET_PCB_ERRATA:
555
* Sets the board errata value. Board errata is used to correct swapped
556
* LEDs and any future problems discovered that only affect some batches
557
* of hardware version 1.
559
* The errata bitmask is as follows:
560
* 0x00 = No errata for this PCB
561
* 0x01 = Leds are swapped
562
* 0x02-0xffff = Reserved for future use
564
* IN: [1:cmd][2:pcb_errata]
565
* OUT: [1:retval][1:cmd]
567
* This command is available in firmware mode.
569
#define CH_CMD_SET_PCB_ERRATA 0x32
572
* CH_CMD_GET_PCB_ERRATA:
574
* Gets the board errata value.
577
* OUT: [1:retval][1:cmd][2:pcb_errata]
579
* This command is available in firmware mode.
581
#define CH_CMD_GET_PCB_ERRATA 0x33
389
583
/* secret code */
390
584
#define CH_WRITE_EEPROM_MAGIC "Un1c0rn2"
402
596
/* although each calibration can be stored in 60 bytes,
403
597
* we use a full 64 byte block */
404
598
#define CH_CALIBRATION_MAX 64 /* so finishes at device params */
599
#define CH_CALIBRATION_DESCRIPTION_LEN 23 /* 60 - (9*4) - 1 */
601
/* the supported calibration types bitfield */
602
#define CH_CALIBRATION_TYPE_LCD 0x01
603
#define CH_CALIBRATION_TYPE_CRT 0x02
604
#define CH_CALIBRATION_TYPE_PROJECTOR 0x04
605
#define CH_CALIBRATION_TYPE_LED 0x08
606
#define CH_CALIBRATION_TYPE_ALL 0xff
406
608
/* approximate sample times */
407
609
#define CH_INTEGRAL_TIME_VALUE_5MS 0x0300
414
616
#define CH_FLASH_ERASE_BLOCK_SIZE 0x400 /* 1024 */
415
617
#define CH_FLASH_WRITE_BLOCK_SIZE 0x040 /* 64 */
416
618
#define CH_FLASH_TRANSFER_BLOCK_SIZE 0x020 /* 32 */
619
#define CH_FLASH_RECONNECT_TIMEOUT 2500 /* ms */
418
621
/* calibration remapping contants */
419
622
#define CH_CALIBRATION_INDEX_LCD (CH_CALIBRATION_MAX + 0)
420
623
#define CH_CALIBRATION_INDEX_CRT (CH_CALIBRATION_MAX + 1)
421
624
#define CH_CALIBRATION_INDEX_PROJECTOR (CH_CALIBRATION_MAX + 2)
625
#define CH_CALIBRATION_INDEX_LED (CH_CALIBRATION_MAX + 3)
423
627
/* which color to select */
428
632
CH_COLOR_SELECT_GREEN
635
/* Led colors: possible bitfield values */
637
CH_STATUS_LED_GREEN = 1 << 0,
638
CH_STATUS_LED_RED = 1 << 1
431
641
/* what frequency divider to use */
455
665
CH_ERROR_OVERFLOW_ADDITION,
456
666
CH_ERROR_OVERFLOW_SENSOR,
457
667
CH_ERROR_OVERFLOW_STACK,
668
CH_ERROR_DEVICE_DEACTIVATED,
669
CH_ERROR_INCOMPLETE_REQUEST,
673
/* any problems with the PCB */
675
CH_PCB_ERRATA_NONE = 0,
676
CH_PCB_ERRATA_SWAPPED_LEDS = 1 << 0,
677
CH_PCB_ERRATA_LAST = 1 << 1
462
681
const gchar *ch_strerror (ChError error_enum);
463
682
const gchar *ch_command_to_string (guint8 cmd);