Use Cmake and make libam7xxx a shared library
[libam7xxx.git] / src / am7xxx.h
1 /* am7xxx - communication with AM7XXX based USB Pico Projectors and DPFs
2  *
3  * Copyright (C) 2011  Antonio Ospite <ospite@studenti.unina.it>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program 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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __AM7XXX_H
20 #define __AM7XXX_H
21
22 #include <stdint.h>
23 #include <libusb-1.0/libusb.h>
24
25 typedef libusb_device_handle *am7xxx_device;
26
27 typedef enum {
28         AM7XXX_PACKET_TYPE_INIT    = 0x01,
29         AM7XXX_PACKET_TYPE_IMAGE   = 0x02,
30         AM7XXX_PACKET_TYPE_POWER   = 0x04,
31         AM7XXX_PACKET_TYPE_UNKNOWN = 0x05,
32 } am7xxx_packet_type;
33
34 typedef enum {
35         AM7XXX_IMAGE_FORMAT_JPEG = 1,
36 } am7xxx_image_format;
37
38 typedef enum {
39         AM7XXX_POWER_OFF  = 0,
40         AM7XXX_POWER_LOW  = 1,
41         AM7XXX_POWER_MID  = 2,
42         AM7XXX_POWER_HIGH = 3,
43 } am7xxx_power_mode;
44
45 struct am7xxx_image_header {
46         uint32_t format;
47         uint32_t width;
48         uint32_t height;
49         uint32_t image_size;
50 };
51
52 struct am7xxx_power_header {
53         uint32_t power_low;
54         uint32_t power_mid;
55         uint32_t power_high;
56 };
57
58 /*
59  * Examples of packet headers:
60  *
61  * Image header:
62  * 02 00 00 00 00 10 3e 10 01 00 00 00 20 03 00 00 e0 01 00 00 53 E8 00 00
63  *
64  * Power header:
65  * 04 00 00 00 00 0c ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
66  */
67
68 struct am7xxx_header {
69         uint32_t packet_type;
70         uint8_t unknown0;
71         uint8_t header_len;
72         uint8_t unknown2;
73         uint8_t unknown3;
74         union {
75                 struct am7xxx_image_header image;
76                 struct am7xxx_power_header power;
77         } header_data;
78 };
79
80 am7xxx_device am7xxx_init(void);
81 void am7xxx_shutdown(am7xxx_device dev);
82
83 int am7xxx_send_image(am7xxx_device dev,
84                       am7xxx_image_format format,
85                       unsigned int width,
86                       unsigned int height,
87                       uint8_t *image,
88                       unsigned int size);
89
90 #endif /* __AM7XXX_H */