summaryrefslogtreecommitdiff
path: root/src/sensors/munki/munki-enum.h
blob: d43c15cd16d8c668e79952a7ca93674407bee939 (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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2013 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.
 */

#ifndef __MUNKI_ENUM_H
#define __MUNKI_ENUM_H

#include <glib-object.h>

G_BEGIN_DECLS

#define MUNKI_COMMAND_DIAL_ROTATE		0x00
#define MUNKI_COMMAND_BUTTON_PRESSED		0x01
#define MUNKI_COMMAND_BUTTON_RELEASED		0x02

#define	MUNKI_BUTTON_STATE_RELEASED		0x00
#define	MUNKI_BUTTON_STATE_PRESSED		0x01

#define	MUNKI_DIAL_POSITION_PROJECTOR		0x00
#define	MUNKI_DIAL_POSITION_SURFACE		0x01
#define	MUNKI_DIAL_POSITION_CALIBRATION	0x02
#define	MUNKI_DIAL_POSITION_AMBIENT		0x03
#define	MUNKI_DIAL_POSITION_UNKNOWN		0xff


/*
 * Triggers a request for a bulk transfer of EEPROM
 * Length: 8 bytes
 *
 *   address     length (LE)
 *  ____|____   ____|____
 * /         \ /         \
 * 04 00 00 00 04 00 00 00
 */
#define	MUNKI_REQUEST_EEPROM_DATA			0x81

/*
 * Gets the next hardware event
 * Length: 8 bytes
 *
 * This blocks until the hardware sends an event, and must either be
 * run in a mainloop or thread to avoid blocking.
 *
 *   subcmd ----\       /------------ 32 bit event time
 *  cmd ----|\ ||       || || || ||
 * Returns: 02 00 00 00 ac 62 07 00
 * always zero ---||-||
 *
 * cmd is:
 * 00	dial rotate
 * 01	button pressed
 * 02	button released
 *
 * subcmd is:
 * 00	button event
 * 01	dial rotate
 */
#define	MUNKI_REQUEST_INTERRUPT				0x83

/*
 * Returns the major and minor version numbers
 * Length: 24 bytes
 */
#define	MUNKI_REQUEST_VERSION_STRING			0x85

/*
 * Returns the chip id
 * Length: 8 bytes
 */
#define	MUNKI_REQUEST_FIRMWARE_PARAMS			0x86

/*
 * Gets the device status
 * Length: 2 bytes
 *
 * Returns:  00 00
 *           |/ ||
 * dial pos -/  \--- button value
 * - 00 = projector
 * - 01 = surface
 * - 02 = calibration
 * - 03 = ambient
 */
#define	MUNKI_REQUEST_GET_STATUS			0x87

/*
 * Returns the version string
 * Length: 36 bytes
 */
#define	MUNKI_REQUEST_CHIP_ID				0x8A

/* USB endpoints in use */
#define MUNKI_EP_CONTROL				0x00
#define MUNKI_EP_DATA					0x01
#define MUNKI_EP_EVENT					0x03

/* EEPROM is massive */
#define	COLORMUNKI_EEPROM_OFFSET_SERIAL_NUMBER		0x0018 /* 10 bytes */

const gchar	*munki_button_state_to_string		(guint8	 value);
const gchar	*munki_dial_position_to_string		(guint8	 value);
const gchar	*munki_command_value_to_string		(guint8	 value);
const gchar	*munki_endpoint_to_string		(guint	 value);

G_END_DECLS

#endif /* __MUNKI_ENUM_H */