1 /*
2  * AuthenTec AES1660/AES2660 common definitions
3  * Copyright (c) 2012 Vasily Khoruzhick <anarsoul@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef __AESX660_H
21 #define __AESX660_H
22 
23 #define AESX660_HEADER_SIZE 3
24 #define AESX660_RESPONSE_TYPE_OFFSET 0x00
25 #define AESX660_RESPONSE_SIZE_LSB_OFFSET 0x01
26 #define AESX660_RESPONSE_SIZE_MSB_OFFSET 0x02
27 
28 #define AESX660_CALIBRATE_RESPONSE 0x06
29 #define AESX660_FINGER_DET_RESPONSE 0x40
30 #define AESX660_FINGER_PRESENT_OFFSET 0x03
31 #define AESX660_FINGER_PRESENT 0x01
32 
33 #define AESX660_IMAGE_OK_OFFSET 0x03
34 #define AESX660_IMAGE_OK 0x0d
35 #define AESX660_LAST_FRAME_OFFSET 0x04
36 #define AESX660_LAST_FRAME_BIT 0x01
37 
38 #define AESX660_FRAME_DELTA_X_OFFSET 16
39 #define AESX660_FRAME_DELTA_Y_OFFSET 17
40 
41 #define AESX660_IMAGE_OFFSET 43
42 #define AESX660_BULK_TRANSFER_SIZE 4096
43 
44 #define AESX660_FRAME_HEIGHT 8
45 
46 struct aesX660_dev {
47 	GSList *strips;
48 	size_t strips_len;
49 	gboolean deactivating;
50 	struct aesX660_cmd *init_seq;
51 	size_t init_seq_len;
52 	unsigned int init_cmd_idx;
53 	unsigned int init_seq_idx;
54 	struct libusb_transfer *fd_data_transfer;
55 	unsigned char *buffer;
56 	size_t buffer_size;
57 	size_t buffer_max;
58 
59 	/* Device-specific stuff */
60 	struct aesX660_cmd *init_seqs[2];
61 	size_t init_seqs_len[2];
62 	unsigned char *start_imaging_cmd;
63 	size_t start_imaging_cmd_len;
64 	struct fpi_frame_asmbl_ctx *assembling_ctx;
65 	uint16_t extra_img_flags;
66 };
67 
68 struct aesX660_cmd {
69 	const unsigned char *cmd;
70 	size_t len;
71 };
72 
73 /* 0x77 cmd seems to control LED, this sequence
74  * makes LED blink
75  */
76 static const unsigned char led_blink_cmd[] = {
77 0x77, 0x18, 0x00,
78 0x00, 0x3f, 0x00, 0xff, 0x00,
79 0x01, 0x01, 0x00, 0x00, 0x00, 0xf3, 0x01, 0x00,
80 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0xf3,
81 0x01, 0x00, 0x7f
82 };
83 
84 /* This sequence makes LED light solid
85  */
86 static const unsigned char led_solid_cmd[] = {
87 0x77, 0x18, 0x00, 0x00, 0x3f, 0x00, 0xff, 0x00,
88 0x01, 0x01, 0x00, 0x00, 0x00, 0xe7, 0x03, 0x00,
89 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
90 0x00, 0x00, 0x7f
91 };
92 
93 static const unsigned char wait_for_finger_cmd[] = {
94 0x20,
95 0x40, 0x04, 0x00, 0x02, 0x1e, 0x00, 0x32
96 };
97 
98 /* 0x40 cmd response
99  *
100 static const unsigned char pkt1371[] = {
101 0x40, 0x01, 0x00, 0x01
102 };
103 */
104 
105 static const unsigned char set_idle_cmd[] = {
106 	0x0d, /* Reset or "set idle"? */
107 };
108 
109 static const unsigned char read_id_cmd[] = {
110 	0x44, 0x02, 0x00, 0x08, 0x00, /* Max transfer size is 8 */
111 	0x07, /* Read ID? */
112 };
113 
114 static const unsigned char calibrate_cmd[] = {
115 	0x44, 0x02, 0x00, 0x04, 0x00,
116 	0x06,
117 };
118 
119 int aesX660_dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state);
120 void aesX660_dev_deactivate(struct fp_img_dev *dev);
121 
122 #endif
123