Commit 3324529d authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

Refactor Buffer API, set buffer CPUAffinity to GlobalCPUAffinity::lima

parent 866e8c8c
......@@ -74,15 +74,14 @@ class BufferMgr
DEB_CLASS_NAMESPC(DebModCamera, "BufferMgr", "SlsDetector");
public:
void setLimaBufferCtrlObj(BufferCtrlObj *buffer_ctrl_obj);
void setBufferCtrlObj(BufferCtrlObj *buffer_ctrl_obj);
void setAcqBufferCPUAffinity(CPUAffinity buffer_affinity);
void setBufferCPUAffinity(CPUAffinity buffer_affinity);
bool waitLimaFrame(FrameType frame_nb, AutoMutex& l);
char *getAcqFrameBufferPtr(FrameType frame_nb);
bool waitFrame(FrameType frame_nb, AutoMutex& l);
BufferCtrlObj *getBufferCtrlObj()
{ return m_lima_buffer_ctrl_obj; }
{ return m_buffer_ctrl_obj; }
StdBufferCbMgr *getBufferCbMgr()
{
......@@ -109,8 +108,8 @@ private:
Camera *m_cam;
Cond& m_cond;
CPUAffinity m_buffer_affinity;
BufferCtrlObj *m_lima_buffer_ctrl_obj;
BufferSync *m_lima_buffer_sync;
BufferCtrlObj *m_buffer_ctrl_obj;
BufferSync *m_buffer_sync;
int m_max_memory;
};
......
......@@ -28,50 +28,39 @@ using namespace lima::SlsDetector;
BufferMgr::BufferMgr(Camera *cam)
: m_cam(cam), m_cond(m_cam->m_cond), m_lima_buffer_ctrl_obj(NULL),
: m_cam(cam), m_cond(m_cam->m_cond), m_buffer_ctrl_obj(NULL),
m_max_memory(70)
{
DEB_CONSTRUCTOR();
}
void BufferMgr::setLimaBufferCtrlObj(BufferCtrlObj *buffer_ctrl_obj)
void BufferMgr::setBufferCtrlObj(BufferCtrlObj *buffer_ctrl_obj)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(m_lima_buffer_ctrl_obj, buffer_ctrl_obj);
m_lima_buffer_ctrl_obj = buffer_ctrl_obj;
m_lima_buffer_sync = buffer_ctrl_obj ?
DEB_PARAM() << DEB_VAR2(m_buffer_ctrl_obj, buffer_ctrl_obj);
m_buffer_ctrl_obj = buffer_ctrl_obj;
m_buffer_sync = buffer_ctrl_obj ?
buffer_ctrl_obj->getBufferSync(m_cond) : NULL;
}
bool BufferMgr::waitLimaFrame(FrameType frame_nb, AutoMutex& l)
bool BufferMgr::waitFrame(FrameType frame_nb, AutoMutex& l)
{
DEB_MEMBER_FUNCT();
if (!m_lima_buffer_ctrl_obj)
THROW_HW_ERROR(Error) << "No Lima BufferCbMgr defined";
BufferSync::Status status = m_lima_buffer_sync->wait(frame_nb);
if (!m_buffer_ctrl_obj)
THROW_HW_ERROR(Error) << "No BufferCbMgr defined";
BufferSync::Status status = m_buffer_sync->wait(frame_nb);
switch (status) {
case BufferSync::AVAILABLE:
return true;
case BufferSync::INTERRUPTED:
return false;
default:
THROW_HW_ERROR(Error) << "Lima buffer sync wait error: "
THROW_HW_ERROR(Error) << "Buffer sync wait error: "
<< status;
}
}
char *BufferMgr::getAcqFrameBufferPtr(FrameType frame_nb)
{
DEB_MEMBER_FUNCT();
StdBufferCbMgr *cb_mgr = getBufferCbMgr();
if (!cb_mgr)
THROW_HW_ERROR(InvalidValue) << "No BufferCbMgr defined";
void *ptr = cb_mgr->getFrameBufferPtr(frame_nb);
return static_cast<char *>(ptr);
}
void BufferMgr::setAcqBufferCPUAffinity(CPUAffinity buffer_affinity)
void BufferMgr::setBufferCPUAffinity(CPUAffinity buffer_affinity)
{
DEB_MEMBER_FUNCT();
DEB_ALWAYS() << DEB_VAR1(buffer_affinity);
......@@ -133,8 +122,8 @@ void BufferMgr::releaseBuffers()
bool prev_release_unused;
// BufferCtrlObj::getBufferMgrResizePolicy(prev_release_unused);
// BufferCtrlObj::setBufferMgrResizePolicy(true);
if (m_lima_buffer_ctrl_obj)
m_lima_buffer_ctrl_obj->releaseBuffers();
if (m_buffer_ctrl_obj)
m_buffer_ctrl_obj->releaseBuffers();
// BufferCtrlObj::setBufferMgrResizePolicy(prev_release_unused);
}
......
......@@ -1702,6 +1702,9 @@ void GlobalCPUAffinityMgr::setLimaAffinity(CPUAffinity lima_affinity)
lima_affinity.applyToTask(pid, true);
m_curr.updateRecvAffinity(lima_affinity);
}
m_cam->m_buffer.setBufferCPUAffinity(lima_affinity);
m_curr.lima = lima_affinity;
}
......@@ -1726,9 +1729,6 @@ void GlobalCPUAffinityMgr::setModelAffinity(
if (model_affinity_list == m_curr.model_threads)
return;
CPUAffinity buffer_affinity = CPUAffinityList_all(model_affinity_list);
m_cam->m_buffer.setAcqBufferCPUAffinity(buffer_affinity);
m_curr.model_threads = model_affinity_list;
}
......
......@@ -207,7 +207,7 @@ void Camera::AcqThread::threadFunction()
if ((frame == -1) || (m_state == StopReq))
break;
while (m_state != StopReq)
if (m_cam->m_buffer.waitLimaFrame(frame, l))
if (m_cam->m_buffer.waitFrame(frame, l))
break;
if (m_state == StopReq)
break;
......@@ -800,19 +800,21 @@ void Camera::setPixelDepth(PixelDepth pixel_depth)
THROW_HW_FATAL(Error) << "Camera is not idle";
waitAcqState(Idle);
ImageType image_type;
switch (pixel_depth) {
case PixelDepth4:
case PixelDepth8:
m_image_type = Bpp8; break;
image_type = Bpp8; break;
case PixelDepth16:
m_image_type = Bpp16; break;
image_type = Bpp16; break;
case PixelDepth32:
m_image_type = Bpp32; break;
image_type = Bpp32; break;
default:
THROW_HW_ERROR(InvalidValue) << DEB_VAR1(pixel_depth);
}
EXC_CHECK(m_det->setDynamicRange(pixel_depth));
m_pixel_depth = pixel_depth;
m_image_type = image_type;
if (m_model) {
updateImageSize();
......
......@@ -369,7 +369,7 @@ Interface::Interface(Camera& cam)
{
DEB_CONSTRUCTOR();
m_cam.getBuffer()->setLimaBufferCtrlObj(&m_buffer);
m_cam.getBuffer()->setBufferCtrlObj(&m_buffer);
m_cam.registerEventCallback(m_event_cb);
HwDetInfoCtrlObj *det_info = &m_det_info;
......@@ -395,7 +395,7 @@ Interface::~Interface()
{
DEB_DESTRUCTOR();
stopAcq();
m_cam.getBuffer()->setLimaBufferCtrlObj(NULL);
m_cam.getBuffer()->setBufferCtrlObj(NULL);
}
void Interface::getCapList(HwInterface::CapList &cap_list) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment