Amlogic: implement CAP_FLAG_AT_END mode

The OSD will use 20Hz for frame capture frequency
The video capture frequency is based on the amlvideodri capture module
This commit is contained in:
Portisch
2019-03-27 09:07:20 +01:00
parent 101855fe4f
commit f2eef4ecea
9 changed files with 32 additions and 30 deletions

View File

@@ -109,6 +109,8 @@ int AmlogicGrabber::grabFrame(Image<ColorRgb> & image)
_lastError = 0;
}
_fbGrabber.grabFrame(image);
usleep(50 * 1000);
}
return 0;
@@ -129,11 +131,11 @@ int AmlogicGrabber::grabFrame_amvideocap(Image<ColorRgb> & image)
long r1 = ioctl(_captureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_WIDTH, _width);
long r2 = ioctl(_captureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_HEIGHT, _height);
long r3 = ioctl(_captureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_AT_FLAGS, CAP_FLAG_AT_END);
if (r1<0 || r2<0 || _height==0 || _width==0)
if (r1<0 || r2<0 || r3<0 || _height==0 || _width==0)
{
ErrorIf(_lastError != 2,_log,"Failed to configure capture size (%d - %s)", errno, strerror(errno));
closeDev(_captureDev);
ErrorIf(_lastError != 2,_log,"Failed to configure capture device (%d - %s)", errno, strerror(errno));
_lastError = 2;
return -1;
}
@@ -145,7 +147,6 @@ int AmlogicGrabber::grabFrame_amvideocap(Image<ColorRgb> & image)
if (bytesRead < 0)
{
ErrorIf(_lastError != 3, _log,"Read of device failed: %d - %s", errno, strerror(errno));
closeDev(_captureDev);
_lastError = 3;
return -1;
}
@@ -153,7 +154,6 @@ int AmlogicGrabber::grabFrame_amvideocap(Image<ColorRgb> & image)
{
// Read of snapshot failed
ErrorIf(_lastError != 4, _log,"Capture failed to grab entire image [bytesToRead(%d) != bytesRead(%d)]", _bytesToRead, bytesRead);
closeDev(_captureDev);
_lastError = 4;
return -1;
}

View File

@@ -1,7 +1,7 @@
#include <grabber/AmlogicWrapper.h>
AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz)
: GrabberWrapper("AmLogic", &_grabber, grabWidth, grabHeight, updateRate_Hz)
AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight)
: GrabberWrapper("AmLogic", &_grabber, grabWidth, grabHeight)
, _grabber(grabWidth, grabHeight)
{}

View File

@@ -14,6 +14,7 @@
// #define AMVIDEOCAP_IOW_SET_WANTFRAME_FORMAT _IOW(AMVIDEOCAP_IOC_MAGIC, 0x01, int)
#define AMVIDEOCAP_IOW_SET_WANTFRAME_WIDTH _IOW(AMVIDEOCAP_IOC_MAGIC, 0x02, int)
#define AMVIDEOCAP_IOW_SET_WANTFRAME_HEIGHT _IOW(AMVIDEOCAP_IOC_MAGIC, 0x03, int)
#define AMVIDEOCAP_IOW_SET_WANTFRAME_AT_FLAGS _IOW(AMVIDEOCAP_IOC_MAGIC, 0x06, int)
#define _A_M 'S'
#define AMSTREAM_IOC_GET_VIDEO_DISABLE _IOR((_A_M), 0x48, int)