summaryrefslogtreecommitdiff
path: root/lib/colorhug/ch-device.h
blob: 2acabbba710329c25267b73e2d9fe3e490f6b823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2011-2016 Richard Hughes <richard@hughsie.com>
 *
 * Licensed under the GNU General Public License Version 2
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#if !defined (__COLORHUG_H_INSIDE__) && !defined (CH_COMPILATION)
#error "Only <colorhug.h> can be included directly."
#endif

#ifndef CH_DEVICE_H
#define CH_DEVICE_H

#include <glib.h>
#include <gusb.h>
#include <colord-private.h>

#include "ch-common.h"

G_BEGIN_DECLS

#define CH_DEVICE_ERROR		(ch_device_error_quark ())

GQuark		 ch_device_error_quark		(void);
gboolean	 ch_device_open			(GUsbDevice	*device,
						 GError		**error)
						 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 ch_device_close		(GUsbDevice	*device,
						 GError		**error)
						 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 ch_device_is_colorhug		(GUsbDevice	*device);
ChDeviceMode	 ch_device_get_mode		(GUsbDevice	*device);
void		 ch_device_write_command_async	(GUsbDevice	*device,
						 guint8		 cmd,
						 const guint8	*buffer_in,
						 gsize		 buffer_in_len,
						 guint8		*buffer_out,
						 gsize		 buffer_out_len,
						 GCancellable	*cancellable,
						 GAsyncReadyCallback callback,
						 gpointer	 user_data);
gboolean	 ch_device_write_command_finish	(GUsbDevice	*device,
						 GAsyncResult	*res,
						 GError		**error)
						 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 ch_device_write_command	(GUsbDevice	*device,
						 guint8		 cmd,
						 const guint8	*buffer_in,
						 gsize		 buffer_in_len,
						 guint8		*buffer_out,
						 gsize		 buffer_out_len,
						 GCancellable	*cancellable,
						 GError		**error)
						 G_GNUC_WARN_UNUSED_RESULT;
gboolean	 ch_device_check_firmware	(GUsbDevice	*device,
						 const guint8	*data,
						 gsize		 data_len,
						 GError		**error)
						 G_GNUC_WARN_UNUSED_RESULT;
guint16		 ch_device_get_runcode_address	(GUsbDevice	*device);
const gchar	*ch_device_get_guid		(GUsbDevice	*device);


// FIXME: add to spec
typedef enum {
	CH_SPECTRUM_KIND_RAW		= 0x00,
	CH_SPECTRUM_KIND_DARK_CAL	= 0x01,
	CH_SPECTRUM_KIND_TEMP_CAL	= 0x02,
	CH_SPECTRUM_KIND_LAST
} ChSpectrumKind;

gboolean	 ch_device_open_full		(GUsbDevice	*device,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_self_test		(GUsbDevice	*device,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_set_serial_number	(GUsbDevice	*device,
						 guint32	 value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_get_serial_number	(GUsbDevice	*device,
						 guint32	*value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_set_leds		(GUsbDevice	*device,
						 ChStatusLed	 value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_get_leds		(GUsbDevice	*device,
						 ChStatusLed	*value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_set_illuminants	(GUsbDevice	*device,
						 ChIlluminant	 value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_get_illuminants	(GUsbDevice	*device,
						 ChIlluminant	*value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_set_pcb_errata	(GUsbDevice	*device,
						 ChPcbErrata	 value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_get_pcb_errata	(GUsbDevice	*device,
						 ChPcbErrata	*value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_set_ccd_calibration	(GUsbDevice	*device,
						 gdouble	 nm_start,
						 gdouble	 c0,
						 gdouble	 c1,
						 gdouble	 c2,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_set_crypto_key	(GUsbDevice	*device,
						 guint32	 keys[4],
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_get_ccd_calibration	(GUsbDevice	*device,
						 gdouble	*nm_start,
						 gdouble	*c0,
						 gdouble	*c1,
						 gdouble	*c2,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_set_integral_time	(GUsbDevice	*device,
						 guint16	 value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_get_integral_time	(GUsbDevice	*device,
						 guint16	*value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_get_temperature	(GUsbDevice	*device,
						 gdouble	*value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_get_adc_calibration_pos (GUsbDevice	*device,
						 gdouble	*value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_get_adc_calibration_neg (GUsbDevice	*device,
						 gdouble	*value,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_get_error		(GUsbDevice	*device,
						 ChError	*status,
						 ChCmd		*cmd,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_take_reading_spectral(GUsbDevice	*device,
						 ChSpectrumKind value,
						 GCancellable	*cancellable,
						 GError		**error);
CdColorXYZ	*ch_device_take_reading_xyz	(GUsbDevice	*device,
						 guint16	 calibration_idx,
						 GCancellable	*cancellable,
						 GError		**error);
CdSpectrum	*ch_device_get_spectrum		(GUsbDevice	*device,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_load_sram		(GUsbDevice	*device,
						 GCancellable	*cancellable,
						 GError		**error);
gboolean	 ch_device_save_sram		(GUsbDevice	*device,
						 GCancellable	*cancellable,
						 GError		**error);

G_END_DECLS

#endif