7d821d6c592d57f473ab3eceebd5a5047aea28e2
[libam7xxx.git] / src / am7xxx.h
1 /* am7xxx - communication with AM7XXX based USB Pico Projectors and DPFs
2  *
3  * Copyright (C) 2012  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 2 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 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26
27 struct _am7xxx_context;
28 typedef struct _am7xxx_context am7xxx_context;
29
30 struct _am7xxx_device;
31 typedef struct _am7xxx_device am7xxx_device;
32
33 typedef struct {
34         unsigned int native_width;
35         unsigned int native_height;
36 } am7xxx_device_info;
37
38 typedef enum {
39         AM7XXX_LOG_FATAL   = 0,
40         AM7XXX_LOG_ERROR   = 1,
41         AM7XXX_LOG_WARNING = 2,
42         AM7XXX_LOG_INFO    = 3,
43         AM7XXX_LOG_DEBUG   = 4,
44         AM7XXX_LOG_TRACE   = 5,
45 } am7xxx_log_level;
46
47 typedef enum {
48         AM7XXX_IMAGE_FORMAT_JPEG = 1,
49         AM7XXX_IMAGE_FORMAT_NV12 = 2,
50 } am7xxx_image_format;
51
52 typedef enum {
53         AM7XXX_POWER_OFF    = 0,
54         AM7XXX_POWER_LOW    = 1,
55         AM7XXX_POWER_MIDDLE = 2,
56         AM7XXX_POWER_HIGH   = 3,
57         AM7XXX_POWER_TURBO  = 4,
58 } am7xxx_power_mode;
59
60 int am7xxx_init(am7xxx_context **ctx);
61
62 void am7xxx_shutdown(am7xxx_context *ctx);
63
64 void am7xxx_set_log_level(am7xxx_context *ctx, am7xxx_log_level log_level);
65
66 int am7xxx_open_device(am7xxx_context *ctx,
67                        am7xxx_device **dev,
68                        unsigned int device_index);
69
70 int am7xxx_close_device(am7xxx_device *dev);
71
72 int am7xxx_get_device_info(am7xxx_device *dev,
73                            am7xxx_device_info *device_info);
74
75 int am7xxx_send_image(am7xxx_device *dev,
76                       am7xxx_image_format format,
77                       unsigned int width,
78                       unsigned int height,
79                       unsigned char *image,
80                       unsigned int size);
81
82 /*
83  * NOTE: if we set the mode to AM7XXX_POWER_OFF we can't turn the
84  * display on again by using only am7xxx_set_power_mode().
85  *
86  * Remember to mention that when writing the API doc.
87  */
88 int am7xxx_set_power_mode(am7xxx_device *dev, am7xxx_power_mode mode);
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* __AM7XXX_H */