private.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef _IPECAMERA_PRIVATE_H
  2. #define _IPECAMERA_PRIVATE_H
  3. #include "ipecamera.h"
  4. #define IPECAMERA_BUG_EXTRA_DATA
  5. #define IPECAMERA_BUG_MULTIFRAME_PACKETS
  6. #define IPECAMERA_BUG_INCOMPLETE_PACKETS
  7. #define IPECAMERA_DEFAULT_BUFFER_SIZE 64 //**< should be power of 2 */
  8. #define IPECAMERA_RESERVE_BUFFERS 2 //**< Return Frame is Lost error, if requested frame will be overwritten after specified number of frames
  9. #define IPECAMERA_SLEEP_TIME 250000 //**< Michele thinks 250 should be enough, but reset failing in this case */
  10. #define IPECAMERA_NEXT_FRAME_DELAY 1000 //**< Michele requires 30000 to sync between End Of Readout and next Frame Req */
  11. #define IPECAMERA_WAIT_FRAME_RCVD_TIME 0 //**< by Uros ,wait 6 ms */
  12. #define IPECAMERA_NOFRAME_SLEEP 100
  13. #define IPECAMERA_NOFRAME_PREPROC_SLEEP 100
  14. #define IPECAMERA_MAX_LINES 1088
  15. #define IPECAMERA_EXPECTED_STATUS 0x08409FFFF
  16. #define IPECAMERA_END_OF_SEQUENCE 0x1F001001
  17. #define IPECAMERA_MAX_CHANNELS 16
  18. #define IPECAMERA_PIXELS_PER_CHANNEL 128
  19. #define IPECAMERA_WIDTH (IPECAMERA_MAX_CHANNELS * IPECAMERA_PIXELS_PER_CHANNEL)
  20. #define IPECAMERA_FRAME_REQUEST 0x1E9
  21. #define IPECAMERA_READOUT_FLAG 0x200
  22. #define IPECAMERA_READOUT 0x3E1
  23. #define IPECAMERA_IDLE 0x1E1
  24. #define IPECAMERA_START_INTERNAL_STIMULI 0x1F1
  25. typedef uint32_t ipecamera_payload_t;
  26. typedef struct {
  27. pcilib_event_id_t evid;
  28. struct timeval timestamp;
  29. } ipecamera_autostop_t;
  30. typedef struct {
  31. size_t i;
  32. pthread_t thread;
  33. ipecamera_t *ipecamera;
  34. int started; /**< flag indicating that join & cleanup is required */
  35. } ipecamera_preprocessor_t;
  36. typedef struct {
  37. ipecamera_event_info_t event; /**< this structure is overwritten by the reader thread, we need a copy */
  38. pthread_rwlock_t mutex; /**< this mutex protects reconstructed buffers only, the raw data, event_info, etc. will be overwritten by reader thread anyway */
  39. } ipecamera_frame_t;
  40. struct ipecamera_s {
  41. pcilib_context_t event;
  42. ufo_decoder ipedec;
  43. char *data;
  44. ipecamera_pixel_t *image;
  45. size_t size;
  46. pcilib_event_callback_t cb;
  47. void *cb_user;
  48. pcilib_event_id_t event_id;
  49. pcilib_event_id_t preproc_id;
  50. pcilib_event_id_t reported_id;
  51. pcilib_dma_engine_t rdma, wdma;
  52. pcilib_register_t packet_len_reg;
  53. pcilib_register_t control_reg, status_reg;
  54. pcilib_register_t start_reg, end_reg;
  55. pcilib_register_t n_lines_reg;
  56. uint16_t line_reg;
  57. pcilib_register_t exposure_reg;
  58. pcilib_register_t flip_reg;
  59. int started; /**< Camera is in grabbing mode (start function is called) */
  60. int streaming; /**< Camera is in streaming mode (we are within stream call) */
  61. int parse_data; /**< Indicates if some processing of the data is required, otherwise only rawdata_callback will be called */
  62. int run_reader; /**< Instructs the reader thread to stop processing */
  63. int run_streamer; /**< Indicates request to stop streaming events and can be set by reader_thread upon exit or by user request */
  64. int run_preprocessors; /**< Instructs preprocessors to exit */
  65. ipecamera_autostop_t autostop;
  66. struct timeval autostop_time;
  67. size_t buffer_size; /**< How many images to store */
  68. size_t buffer_pos; /**< Current image offset in the buffer, due to synchronization reasons should not be used outside of reader_thread */
  69. size_t cur_size; /**< Already written part of data in bytes */
  70. size_t raw_size; /**< Size of raw data in bytes */
  71. size_t full_size; /**< Size of raw data including the padding */
  72. size_t padded_size; /**< Size of buffer for raw data, including the padding for performance */
  73. size_t image_size; /**< Size of a single image in bytes */
  74. int width, height;
  75. // void *raw_buffer;
  76. void *buffer;
  77. ipecamera_change_mask_t *cmask;
  78. ipecamera_frame_t *frame;
  79. ipecamera_image_dimensions_t dim;
  80. pthread_t rthread;
  81. size_t n_preproc;
  82. ipecamera_preprocessor_t *preproc;
  83. pthread_mutex_t preproc_mutex;
  84. int preproc_mutex_destroy;
  85. int frame_mutex_destroy;
  86. };
  87. #endif /* _IPECAMERA_PRIVATE_H */