12
13
# define IPECAMERA_DEBUG_BROKEN_FRAMES //**< Store broken frames in the specified directory */
13
14
# define IPECAMERA_DEBUG_RAW_PACKETS //**< Store all raw packets read from DMA grouped in frames */
14
15
# define IPECAMERA_DEBUG_HARDWARE //**< Produce various debugging information about ipecamera operation */
16
# define IPECAMERA_DEBUG_FRAME_HEADERS //**< Print frame headers & footers */
15
17
#endif /* IPECAMERA_DEBUG */
17
//#define IPECAMERA_BUG_MISSING_PAYLOAD //**< CMOSIS fails to provide a first payload for each frame, therefore the frame is 32 bit shorter */
19
#define IPECAMERA_BUG_MISSING_PAYLOAD //**< CMOSIS fails to provide a first payload for each frame, therefore the frame is 32 bit shorter */
18
20
#define IPECAMERA_BUG_MULTIFRAME_PACKETS //**< This is by design, start of packet comes directly after the end of last one in streaming mode */
19
21
//#define IPECAMERA_BUG_INCOMPLETE_PACKETS //**< Support incomplete packets, i.e. check for frame magic even if full frame size is not reached yet (slow) */
20
22
//#define IPECAMERA_ANNOUNCE_READY //**< Announce new event only after the reconstruction is done */
35
37
#define IPECAMERA_NOFRAME_SLEEP 100 //**< Sleep while polling for a new frame in reader */
36
38
#define IPECAMERA_NOFRAME_PREPROC_SLEEP 100 //**< Sleep while polling for a new frame in pre-processor */
38
//#define IPECAMERA_MAX_LINES 1088
39
#define IPECAMERA_MAX_LINES 2048
40
40
#define IPECAMERA_EXPECTED_STATUS_4 0x08409FFFF
41
41
#define IPECAMERA_EXPECTED_STATUS 0x08449FFFF
43
43
#define IPECAMERA_END_OF_SEQUENCE 0x1F001001
45
#define IPECAMERA_MAX_CHANNELS 16
46
#define IPECAMERA_PIXELS_PER_CHANNEL 128
47
#define IPECAMERA_WIDTH (IPECAMERA_MAX_CHANNELS * IPECAMERA_PIXELS_PER_CHANNEL)
46
#define CMOSIS_FRAME_HEADER_SIZE 8 * sizeof(ipecamera_payload_t)
47
#define CMOSIS_FRAME_TAIL_SIZE 8 * sizeof(ipecamera_payload_t)
49
#define CMOSIS_MAX_CHANNELS 16
50
#define CMOSIS_PIXELS_PER_CHANNEL 128
51
#define CMOSIS_WIDTH (CMOSIS_MAX_CHANNELS * CMOSIS_PIXELS_PER_CHANNEL)
52
//#define IPECAMERA_MAX_LINES 1088
53
#define CMOSIS_MAX_LINES 2048
54
#define CMOSIS20_MAX_CHANNELS 8
55
#define CMOSIS20_PIXELS_PER_CHANNEL 640
56
#define CMOSIS20_WIDTH (CMOSIS20_MAX_CHANNELS * CMOSIS20_PIXELS_PER_CHANNEL)
57
#define CMOSIS20_MAX_LINES 3840
49
59
#define IPECAMERA_FRAME_REQUEST 0x80000209 // 0x1E9
50
60
#define IPECAMERA_IDLE 0x80000201 // 0x1E1
57
67
#define IPECAMERA_MODE_11_BIT_ADC 1
58
68
#define IPECAMERA_MODE_10_BIT_ADC 0
60
71
#ifdef IPECAMERA_DEBUG_RAW_FRAMES
61
# define IPECAMERA_DEBUG_RAW_FRAMES_MESSAGE(function, ...) pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__)
62
# define IPECAMERA_DEBUG_RAW_FRAMES_BUFFER(function, ...) pcilib_debug_data_buffer (#function, __VA_ARGS__)
72
# define IPECAMERA_DEBUG_RAW_FRAMES_MESSAGE(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); }
73
# define IPECAMERA_DEBUG_RAW_FRAMES_BUFFER(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); }
63
74
#else /* IPECAMERA_DEBUG_RAW_FRAMES */
64
75
# define IPECAMERA_DEBUG_RAW_FRAMES_MESSAGE(function, ...)
65
76
# define IPECAMERA_DEBUG_RAW_FRAMES_BUFFER(function, ...)
66
77
#endif /* IPECAMERA_DEBUG_RAW_FRAMES */
68
79
#ifdef IPECAMERA_DEBUG_BROKEN_FRAMES
69
# define IPECAMERA_DEBUG_BROKEN_FRAMES_MESSAGE(function, ...) pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__)
70
# define IPECAMERA_DEBUG_BROKEN_FRAMES_BUFFER(function, ...) pcilib_debug_data_buffer (#function, __VA_ARGS__)
80
# define IPECAMERA_DEBUG_BROKEN_FRAMES_MESSAGE(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); }
81
# define IPECAMERA_DEBUG_BROKEN_FRAMES_BUFFER(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); }
71
82
#else /* IPECAMERA_DEBUG_BROKEN_FRAMES */
72
83
# define IPECAMERA_DEBUG_BROKEN_FRAMES_MESSAGE(function, ...)
73
84
# define IPECAMERA_DEBUG_BROKEN_FRAMES_BUFFER(function, ...)
74
85
#endif /* IPECAMERA_DEBUG_BROKEN_FRAMES */
76
87
#ifdef IPECAMERA_DEBUG_RAW_PACKETS
77
# define IPECAMERA_DEBUG_RAW_PACKETS_MESSAGE(function, ...) pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__)
78
# define IPECAMERA_DEBUG_RAW_PACKETS_BUFFER(function, ...) pcilib_debug_data_buffer (#function, __VA_ARGS__)
88
# define IPECAMERA_DEBUG_RAW_PACKETS_MESSAGE(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); }
89
# define IPECAMERA_DEBUG_RAW_PACKETS_BUFFER(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); }
79
90
#else /* IPECAMERA_DEBUG_RAW_PACKETS */
80
91
# define IPECAMERA_DEBUG_RAW_PACKETS_MESSAGE(function, ...)
81
92
# define IPECAMERA_DEBUG_RAW_PACKETS_BUFFER(function, ...)
82
93
#endif /* IPECAMERA_DEBUG_RAW_PACKETS */
84
95
#ifdef IPECAMERA_DEBUG_HARDWARE
85
# define IPECAMERA_DEBUG_HARDWARE_MESSAGE(function, ...) pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__)
86
# define IPECAMERA_DEBUG_HARDWARE_BUFFER(function, ...) pcilib_debug_data_buffer (#function, __VA_ARGS__)
96
# define IPECAMERA_DEBUG_HARDWARE_MESSAGE(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); }
97
# define IPECAMERA_DEBUG_HARDWARE_BUFFER(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); }
87
98
#else /* IPECAMERA_DEBUG_HARDWARE */
88
99
# define IPECAMERA_DEBUG_HARDWARE_MESSAGE(function, ...)
89
100
# define IPECAMERA_DEBUG_HARDWARE_BUFFER(function, ...)
90
101
#endif /* IPECAMERA_DEBUG_HARDWARE */
103
#ifdef IPECAMERA_DEBUG_FRAME_HEADERS
104
# define IPECAMERA_DEBUG_FRAME_HEADERS_MESSAGE(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_message (#function, __FILE__, __LINE__, __VA_ARGS__); }
105
# define IPECAMERA_DEBUG_FRAME_HEADERS_BUFFER(function, ...) if (ipecamera_getenv(function##_ENV, #function)) { pcilib_debug_data_buffer (#function, __VA_ARGS__); }
106
#else /* IPECAMERA_DEBUG_RAW_FRAMES */
107
# define IPECAMERA_DEBUG_FRAME_HEADERS_MESSAGE(function, ...)
108
# define IPECAMERA_DEBUG_FRAME_HEADERS_BUFFER(function, ...)
109
#endif /* IPECAMERA_DEBUG_RAW_FRAMES */
93
112
#define ipecamera_debug(function, ...) \
94
113
IPECAMERA_DEBUG_##function##_MESSAGE(IPECAMERA_DEBUG_##function, PCILIB_LOG_DEFAULT, __VA_ARGS__)
159
190
struct timeval autostop_time;
160
191
struct timeval next_trigger; /**< The minimal delay between trigger signals is mandatory, this indicates time when next trigger is possible */
162
size_t buffer_size; /**< How many images to store */
163
size_t buffer_pos; /**< Current image offset in the buffer, due to synchronization reasons should not be used outside of reader_thread */
164
size_t cur_size; /**< Already written part of data in bytes */
165
size_t raw_size; /**< Expected maximum size of raw data in bytes */
166
size_t padded_size; /**< Expected maximum size of buffer for raw data, including additional padding */
167
size_t roi_raw_size; /**< Expected size (for currently configured ROI) of raw data in bytes */
168
size_t roi_padded_size; /**< Expected size (for currently configured ROI) of buffer for raw data, including additional padding */
170
size_t image_size; /**< Size of a single image in bytes */
172
size_t max_frames; /**< Maximal number of frames what may be buffered in camera DDR memory */
173
int firmware; /**< Firmware version */
174
int cmosis_outputs; /**< Number of active cmosis outputs: 4 or 16 */
193
size_t buffer_size; /**< How many images to store */
194
size_t buffer_pos; /**< Current image offset in the buffer, due to synchronization reasons should not be used outside of reader_thread */
195
size_t cur_size; /**< Already written part of data in bytes */
196
size_t raw_size; /**< Expected maximum size of raw data in bytes */
197
size_t padded_size; /**< Expected maximum size of buffer for raw data, including additional padding */
198
size_t roi_raw_size; /**< Expected size (for currently configured ROI) of raw data in bytes */
199
size_t roi_padded_size; /**< Expected size (for currently configured ROI) of buffer for raw data, including additional padding */
201
size_t image_size; /**< Size of a single image in bytes */
203
size_t max_frames; /**< Maximal number of frames what may be buffered in camera DDR memory */
204
ipecamera_firmware_t firmware; /**< Firmware type */
205
int cmosis_outputs; /**< Number of active cmosis outputs: 4 or 16 */
175
206
int width, height;