EspiaAcq.h 2.49 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef ESPIAACQ_H
#define ESPIAACQ_H

#include "EspiaDev.h"
#include "SizeUtils.h"

namespace lima
{

class EspiaAcq : public Espia
{
 public:
	EspiaAcq(EspiaDev& dev);
	~EspiaAcq();

	typedef struct AcqStatus {
		bool	acq_started;
		bool	acq_running;
		int	acq_run_nb;
		int	last_acq_frame_nb;
	} AcqStatusType;

	void bufferAlloc(const FrameDim& frame_dim, int& nb_buffers,
			 int buffer_frames);
	void bufferFree();

	void getFrameDim(FrameDim& frame_dim);
	void getNbBuffers(int& nb_buffers);
	void getBufferFrames(int& buffer_frames);

	void *getBufferFramePtr(int buffer_nb, int frame_nb = 0);
	void *getAcqFramePtr(int acq_frame_nb);
	void getFrameInfo(int acq_frame_nb, HwFrameInfoType& info);

	void setNbFrames(int  nb_frames);
	void getNbFrames(int& nb_frames);

	void startAcq();
	void stopAcq();
	void getAcqStatus(AcqStatusType& acq_status);

	void getStartTimestamp(Timestamp& start_ts);

 private:
	bool hasVirtualBuffers();
	int realBufferNb(int virt_buffer, int virt_frame);
	int realFrameNb (int virt_buffer, int virt_frame);
	int virtBufferNb(int real_buffer, int real_frame);
	int virtFrameNb (int real_buffer, int real_frame);

	void real2virtFrameInfo(const struct img_frame_info& real_info, 
				HwFrameInfoType& virt_info);
	void resetFrameInfo(struct img_frame_info& frame_info);

	static int dispatchFrameCb(struct espia_cb_data *cb_data);

	void registerLastFrameCb();
	void unregisterLastFrameCb();
	void lastFrameCb(struct espia_cb_data *cb_data);

	AutoMutex acqLock();

	EspiaDev& m_dev;

	FrameDim m_frame_dim;
	int m_nb_buffers;
	int m_buffer_frames;
	int m_real_frame_factor;
	int m_real_frame_size;

	int m_nb_frames;
	bool m_started;
	Timestamp m_start_ts;
	struct img_frame_info m_last_frame_info;
	int m_last_frame_cb_nr;
};

inline bool EspiaAcq::hasVirtualBuffers()
{
	return m_real_frame_factor != 1;
}

inline int EspiaAcq::realBufferNb(int virt_buffer, int virt_frame)
{
	return virt_buffer / m_real_frame_factor;
}

inline int EspiaAcq::realFrameNb (int virt_buffer, int virt_frame)
{
	return virt_buffer % m_real_frame_factor + virt_frame;
}

inline int EspiaAcq::virtBufferNb(int real_buffer, int real_frame)
{
	return (real_buffer * m_real_frame_factor + 
		real_frame / m_buffer_frames);
}

inline int EspiaAcq::virtFrameNb (int real_buffer, int real_frame)
{
	return real_frame % m_buffer_frames;
}

inline void EspiaAcq::getStartTimestamp(Timestamp& start_ts)
{
	start_ts = m_start_ts;
}

109
110
111
112
113
inline AutoMutex EspiaAcq::acqLock()
{
	return m_dev.acqLock();
}

114
115
116
117
118
119


} // namespace lima


#endif // ESPIAACQ_H