/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to ipecamera/private.h

  • Committer: Suren A. Chilingaryan
  • Date: 2015-04-20 20:01:04 UTC
  • Revision ID: csa@suren.me-20150420200104-b5xny65io8lvoz3w
Big redign of model structures

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _IPECAMERA_PRIVATE_H
2
 
#define _IPECAMERA_PRIVATE_H
3
 
 
4
 
#include "ipecamera.h"
5
 
 
6
 
#define IPECAMERA_BUG_EXTRA_DATA
7
 
#define IPECAMERA_BUG_MULTIFRAME_PACKETS
8
 
//#define IPECAMERA_BUG_INCOMPLETE_PACKETS
9
 
//#define IPECAMERA_BUG_POSTPONED_READ
10
 
//#define IPECAMERA_DEBUG_RAW_PACKETS           "/mnt/fast/frames"
11
 
 
12
 
//#define IPECAMERA_ANNOUNCE_READY              //**< announce new event only after the reconstruction is done */
13
 
 
14
 
#define IPECAMERA_DEFAULT_BUFFER_SIZE 64        //**< should be power of 2 */
15
 
#define IPECAMERA_RESERVE_BUFFERS 2             //**< Return Frame is Lost error, if requested frame will be overwritten after specified number of frames
16
 
#define IPECAMERA_SLEEP_TIME 250000             //**< Michele thinks 250 should be enough, but reset failing in this case */
17
 
#define IPECAMERA_NEXT_FRAME_DELAY 1000         //**< Michele requires 30000 to sync between End Of Readout and next Frame Req */
18
 
#define IPECAMERA_WAIT_FRAME_RCVD_TIME 0        //**< by Uros ,wait 6 ms */
19
 
#define IPECAMERA_NOFRAME_SLEEP 100
20
 
#define IPECAMERA_NOFRAME_PREPROC_SLEEP 100
21
 
 
22
 
//#define IPECAMERA_MAX_LINES 1088
23
 
#define IPECAMERA_MAX_LINES 2048
24
 
#define IPECAMERA_EXPECTED_STATUS_4 0x08409FFFF
25
 
#define IPECAMERA_EXPECTED_STATUS 0x08449FFFF
26
 
 
27
 
#define IPECAMERA_END_OF_SEQUENCE 0x1F001001
28
 
 
29
 
#define IPECAMERA_MAX_CHANNELS 16
30
 
#define IPECAMERA_PIXELS_PER_CHANNEL 128
31
 
#define IPECAMERA_WIDTH (IPECAMERA_MAX_CHANNELS * IPECAMERA_PIXELS_PER_CHANNEL)
32
 
 
33
 
#define IPECAMERA_FRAME_REQUEST                 0x1E9
34
 
#define IPECAMERA_READOUT_FLAG                  0x200
35
 
#define IPECAMERA_READOUT                       0x3E1
36
 
#define IPECAMERA_IDLE                          0x1E1
37
 
#define IPECAMERA_START_INTERNAL_STIMULI        0x1F1
38
 
 
39
 
#define IPECAMERA_MODE_16_CHAN_IO               0
40
 
#define IPECAMERA_MODE_4_CHAN_IO                2
41
 
 
42
 
#define IPECAMERA_MODE_12_BIT_ADC               2
43
 
#define IPECAMERA_MODE_11_BIT_ADC               1
44
 
#define IPECAMERA_MODE_10_BIT_ADC               0
45
 
 
46
 
typedef uint32_t ipecamera_payload_t;
47
 
 
48
 
typedef struct {
49
 
    pcilib_event_id_t evid;
50
 
    struct timeval timestamp;
51
 
} ipecamera_autostop_t;
52
 
 
53
 
typedef struct {
54
 
    size_t i;
55
 
    pthread_t thread;
56
 
    ipecamera_t *ipecamera;
57
 
    
58
 
    int started;                        /**< flag indicating that join & cleanup is required */
59
 
} ipecamera_preprocessor_t;
60
 
 
61
 
 
62
 
typedef struct {
63
 
    ipecamera_event_info_t event;       /**< this structure is overwritten by the reader thread, we need a copy */
64
 
    pthread_rwlock_t mutex;             /**< this mutex protects reconstructed buffers only, the raw data, event_info, etc. will be overwritten by reader thread anyway */
65
 
} ipecamera_frame_t;
66
 
 
67
 
struct ipecamera_s {
68
 
    pcilib_context_t event;
69
 
    UfoDecoder *ipedec;
70
 
 
71
 
    char *data;
72
 
    ipecamera_pixel_t *image;
73
 
    size_t size;
74
 
 
75
 
    pcilib_event_callback_t cb;
76
 
    void *cb_user;
77
 
 
78
 
    volatile pcilib_event_id_t event_id;
79
 
    volatile pcilib_event_id_t preproc_id;
80
 
    pcilib_event_id_t reported_id;
81
 
    
82
 
    pcilib_dma_engine_t rdma, wdma;
83
 
 
84
 
    pcilib_register_t packet_len_reg;
85
 
    pcilib_register_t control_reg, status_reg;
86
 
    pcilib_register_t status3_reg;
87
 
    pcilib_register_t n_lines_reg;
88
 
    uint16_t line_reg;
89
 
    pcilib_register_t exposure_reg;
90
 
    pcilib_register_t flip_reg;
91
 
 
92
 
    pcilib_register_t firmware_version_reg;
93
 
    pcilib_register_t adc_resolution_reg;
94
 
    pcilib_register_t output_mode_reg;
95
 
    
96
 
    pcilib_register_t max_frames_reg;
97
 
    pcilib_register_t num_frames_reg;
98
 
 
99
 
    int started;                /**< Camera is in grabbing mode (start function is called) */
100
 
    int streaming;              /**< Camera is in streaming mode (we are within stream call) */
101
 
    int parse_data;             /**< Indicates if some processing of the data is required, otherwise only rawdata_callback will be called */
102
 
 
103
 
    volatile int run_reader;            /**< Instructs the reader thread to stop processing */
104
 
    volatile int run_streamer;          /**< Indicates request to stop streaming events and can be set by reader_thread upon exit or by user request */
105
 
    volatile int run_preprocessors;     /**< Instructs preprocessors to exit */
106
 
    
107
 
    ipecamera_autostop_t autostop;
108
 
 
109
 
    struct timeval autostop_time;
110
 
    struct timeval next_trigger;        /**< The minimal delay between trigger signals is mandatory, this indicates time when next trigger is possible */
111
 
 
112
 
    size_t buffer_size;         /**< How many images to store */
113
 
    size_t buffer_pos;          /**< Current image offset in the buffer, due to synchronization reasons should not be used outside of reader_thread */
114
 
    size_t cur_size;            /**< Already written part of data in bytes */
115
 
    size_t raw_size;            /**< Size of raw data in bytes */
116
 
    size_t full_size;           /**< Size of raw data including the padding */
117
 
    size_t padded_size;         /**< Size of buffer for raw data, including the padding for performance */
118
 
    size_t cur_raw_size;        /**< Size of raw data in bytes */
119
 
    size_t cur_full_size;       /**< Size of raw data including the padding */
120
 
    size_t cur_padded_size;     /**< Size of buffer for raw data, including the padding for performance */
121
 
    
122
 
    size_t image_size;          /**< Size of a single image in bytes */
123
 
    
124
 
    size_t max_frames;          /**< Maximal number of frames what may be buffered in camera DDR memory */
125
 
    int firmware;               /**< Firmware version */
126
 
    int fr_mode;                /**< Fast Reject mode */
127
 
    int cmosis_outputs;         /**< Number of active cmosis outputs: 4 or 16 */
128
 
    int width, height;
129
 
 
130
 
    
131
 
//    void *raw_buffer;
132
 
    void *buffer;
133
 
    ipecamera_change_mask_t *cmask;
134
 
    ipecamera_frame_t *frame;
135
 
    
136
 
 
137
 
    ipecamera_image_dimensions_t dim;
138
 
 
139
 
    pthread_t rthread;
140
 
    
141
 
    size_t n_preproc;
142
 
    ipecamera_preprocessor_t *preproc;
143
 
    pthread_mutex_t preproc_mutex;
144
 
    
145
 
    int preproc_mutex_destroy;
146
 
    int frame_mutex_destroy;
147
 
};
148
 
 
149
 
#endif /* _IPECAMERA_PRIVATE_H */