mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Amlogic: remove ge2d mode
This commit is contained in:
202
libsrc/grabber/amlogic/AmlogicGrabber.cpp
Executable file → Normal file
202
libsrc/grabber/amlogic/AmlogicGrabber.cpp
Executable file → Normal file
@@ -19,25 +19,16 @@
|
||||
|
||||
#define VIDEO_DEVICE "/dev/amvideo"
|
||||
#define CAPTURE_DEVICE "/dev/amvideocap0"
|
||||
#define GE2D_DEVICE "/dev/ge2d"
|
||||
|
||||
AmlogicGrabber::AmlogicGrabber(const unsigned width, const unsigned height, const unsigned ge2d_mode, const QString device)
|
||||
AmlogicGrabber::AmlogicGrabber(const unsigned width, const unsigned height)
|
||||
: Grabber("AMLOGICGRABBER", qMax(160u, width), qMax(160u, height)) // Minimum required width or height is 160
|
||||
, _captureDev(-1)
|
||||
, _videoDev(-1)
|
||||
, _ge2dDev(-1)
|
||||
, _lastError(0)
|
||||
, _fbGrabber("/dev/fb0",width,height)
|
||||
, _grabbingModeNotification(0)
|
||||
, _ge2dVideoBufferPtr(nullptr)
|
||||
, _ge2dIonBuffer(nullptr)
|
||||
, _ge2d_mode(ge2d_mode)
|
||||
, _device(device)
|
||||
{
|
||||
Debug(_log, "constructed(%d x %d), grabber device: %s",_width,_height,QSTRING_CSTR(_device));
|
||||
|
||||
if (_device.contains("ge2d"))
|
||||
Debug(_log, "'ge2d' device use mode %d",ge2d_mode);
|
||||
Debug(_log, "constructed(%d x %d), grabber device: %s",_width,_height, CAPTURE_DEVICE);
|
||||
|
||||
_image_bgr.resize(_width, _height);
|
||||
_bytesToRead = _image_bgr.size();
|
||||
@@ -48,7 +39,6 @@ AmlogicGrabber::~AmlogicGrabber()
|
||||
{
|
||||
closeDev(_captureDev);
|
||||
closeDev(_videoDev);
|
||||
closeDev(_ge2dDev);
|
||||
}
|
||||
|
||||
bool AmlogicGrabber::openDev(int &fd, const char* dev)
|
||||
@@ -107,22 +97,8 @@ int AmlogicGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
_lastError = 0;
|
||||
}
|
||||
|
||||
if (_device == "ge2d")
|
||||
{
|
||||
if (grabFrame_ge2d(image) < 0)
|
||||
{
|
||||
closeDev(_videoDev);
|
||||
closeDev(_ge2dDev);
|
||||
}
|
||||
}
|
||||
else if (_device == "amvideocap0")
|
||||
{
|
||||
if (grabFrame_amvideocap(image) < 0)
|
||||
{
|
||||
closeDev(_videoDev);
|
||||
closeDev(_captureDev);
|
||||
}
|
||||
}
|
||||
if (grabFrame_amvideocap(image) < 0)
|
||||
closeDev(_captureDev);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -188,173 +164,3 @@ int AmlogicGrabber::grabFrame_amvideocap(Image<ColorRgb> & image)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AmlogicGrabber::grabFrame_ge2d(Image<ColorRgb> & image)
|
||||
{
|
||||
int ret;
|
||||
static int videoWidth;
|
||||
static int videoHeight;
|
||||
|
||||
if ( ! openDev(_ge2dDev, GE2D_DEVICE) || ! openDev(_videoDev, VIDEO_DEVICE))
|
||||
{
|
||||
ErrorIf( _lastError != 1 && _ge2dDev < 0, _log,"Failed to open the ge2d device: (%d - %s)", errno, strerror(errno));
|
||||
ErrorIf( _lastError != 1 && _videoDev < 0, _log,"Failed to open the AMLOGIC video device: (%d - %s)", errno, strerror(errno));
|
||||
_lastError = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Ion
|
||||
if (_ge2dIonBuffer == nullptr)
|
||||
{
|
||||
_ge2dIonBuffer = new IonBuffer(_width * _height * 3); // BGR
|
||||
_ge2dVideoBufferPtr = _ge2dIonBuffer->Map();
|
||||
memset(_ge2dVideoBufferPtr, 0, _ge2dIonBuffer->BufferSize());
|
||||
|
||||
memset(&_configex, 0, sizeof(_configex));
|
||||
_configex.src_para.mem_type = CANVAS_TYPE_INVALID;
|
||||
_configex.dst_para.mem_type = CANVAS_ALLOC;
|
||||
_configex.dst_para.format = GE2D_FORMAT_S24_RGB;
|
||||
_configex.dst_planes[0].addr = (long unsigned int)_ge2dIonBuffer->PhysicalAddress();
|
||||
_configex.dst_para.width = _width;
|
||||
_configex.dst_para.height = _height;
|
||||
_configex.dst_planes[0].w = _configex.dst_para.width;
|
||||
_configex.dst_planes[0].h = _configex.dst_para.height;
|
||||
|
||||
memset(&_blitRect, 0, sizeof(_blitRect));
|
||||
_blitRect.dst_rect.w = _configex.dst_para.width;
|
||||
_blitRect.dst_rect.h = _configex.dst_para.height;
|
||||
}
|
||||
|
||||
switch(_ge2d_mode)
|
||||
{
|
||||
case ge2d_single:
|
||||
{
|
||||
int canvas_index;
|
||||
if ((ret = ioctl(_videoDev, AMVIDEO_EXT_GET_CURRENT_VIDEOFRAME, &canvas_index)) < 0)
|
||||
{
|
||||
if (ret != -EAGAIN)
|
||||
{
|
||||
Error(_log, "AMVIDEO_EXT_GET_CURRENT_VIDEOFRAME failed: (%d - %s)", errno, strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning(_log, "AMVIDEO_EXT_GET_CURRENT_VIDEOFRAME failed, please try again!");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t canvas0addr;
|
||||
if (ioctl(_videoDev, AMVIDEO_EXT_CURRENT_VIDEOFRAME_GET_CANVAS0ADDR, &canvas0addr) < 0)
|
||||
{
|
||||
Error(_log, "AMSTREAM_EXT_CURRENT_VIDEOFRAME_GET_CANVAS0ADDR failed: (%d - %s)", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
_configex.src_para.canvas_index = canvas0addr;
|
||||
|
||||
uint32_t ge2dformat;
|
||||
if (ioctl(_videoDev, AMVIDEO_EXT_CURRENT_VIDEOFRAME_GET_GE2D_FORMAT, &ge2dformat) <0)
|
||||
{
|
||||
Error(_log, "AMSTREAM_EXT_CURRENT_VIDEOFRAME_GET_GE2D_FORMAT failed: (%d - %s)", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
_configex.src_para.format = ge2dformat;
|
||||
|
||||
uint64_t size;
|
||||
if (ioctl(_videoDev, AMVIDEO_EXT_CURRENT_VIDEOFRAME_GET_SIZE, &size) < 0)
|
||||
{
|
||||
Error(_log, "AMSTREAM_EXT_CURRENT_VIDEOFRAME_GET_SIZE failed: (%d - %s)", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
videoWidth = (size >> 32) - _cropLeft - _cropRight;
|
||||
videoHeight = (size & 0xffffff) - _cropTop - _cropBottom;
|
||||
}
|
||||
break;
|
||||
|
||||
case ge2d_combined:
|
||||
{
|
||||
static struct amvideo_grabber_data grabber_data;
|
||||
|
||||
if ((ret = ioctl(_videoDev, AMVIDEO_EXT_CURRENT_VIDEOFRAME_GET_DATA, &grabber_data)) < 0)
|
||||
{
|
||||
if (ret == -EAGAIN)
|
||||
{
|
||||
Warning(_log, "AMVIDEO_EXT_CURRENT_VIDEOFRAME_GET_DATA failed, please try again!");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(_log, "AMVIDEO_EXT_CURRENT_VIDEOFRAME_GET_DATA failed.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
videoWidth = (grabber_data.size >> 32) - _cropLeft - _cropRight;
|
||||
videoHeight = (grabber_data.size & 0xffffff) - _cropTop - _cropBottom;
|
||||
|
||||
_configex.src_para.canvas_index = grabber_data.canvas0Addr;
|
||||
_configex.src_para.format = grabber_data.ge2dformat;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned cropLeft = _cropLeft;
|
||||
unsigned cropTop = _cropTop;
|
||||
|
||||
// calculate final image dimensions and adjust top/left cropping in 3D modes
|
||||
switch (_videoMode)
|
||||
{
|
||||
case VIDEO_3DSBS:
|
||||
videoWidth >>= 1;
|
||||
cropLeft = _cropLeft >> 1;
|
||||
break;
|
||||
case VIDEO_3DTAB:
|
||||
videoHeight >>= 1;
|
||||
cropTop = _cropTop >> 1;
|
||||
break;
|
||||
case VIDEO_2D:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_configex.src_para.left = cropLeft;
|
||||
_configex.src_para.top = cropTop;
|
||||
_configex.src_para.width = videoWidth;
|
||||
_configex.src_para.height = videoHeight >> 1;
|
||||
|
||||
if (ioctl(_ge2dDev, GE2D_CONFIG_EX, &_configex) < 0)
|
||||
{
|
||||
Error(_log, "video GE2D_CONFIG_EX failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
_blitRect.src1_rect.w = _configex.src_para.width;
|
||||
_blitRect.src1_rect.h = _configex.src_para.height;
|
||||
|
||||
// Blit to videoBuffer
|
||||
if (ioctl(_ge2dDev, GE2D_STRETCHBLIT_NOALPHA, &_blitRect) < 0)
|
||||
{
|
||||
Error(_log,"GE2D_STRETCHBLIT_NOALPHA failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Return video frame
|
||||
if (ioctl(_videoDev, AMVIDEO_EXT_PUT_CURRENT_VIDEOFRAME) < 0)
|
||||
{
|
||||
Error(_log, "AMSTREAM_EXT_PUT_CURRENT_VIDEOFRAME failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
_ge2dIonBuffer->Sync();
|
||||
|
||||
// Read the snapshot into the memory
|
||||
_useImageResampler = false;
|
||||
_imageResampler.processImage((const uint8_t*)_ge2dVideoBufferPtr, _width, _height, (_width << 1) + _width, PIXELFORMAT_BGR24, image);
|
||||
_lastError = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include <grabber/AmlogicWrapper.h>
|
||||
|
||||
AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const unsigned ge2d_mode, const QString device)
|
||||
AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz)
|
||||
: GrabberWrapper("AmLogic", &_grabber, grabWidth, grabHeight, updateRate_Hz)
|
||||
, _grabber(grabWidth, grabHeight, ge2d_mode, device)
|
||||
, _grabber(grabWidth, grabHeight)
|
||||
{}
|
||||
|
||||
void AmlogicWrapper::action()
|
||||
|
@@ -11,75 +11,9 @@
|
||||
#define CAP_FLAG_AT_TIME_WINDOW 1
|
||||
#define CAP_FLAG_AT_END 2
|
||||
|
||||
/*
|
||||
format see linux/ge2d/ge2d.h
|
||||
like:
|
||||
GE2D_FORMAT_S24_RGB
|
||||
*/
|
||||
#define GE2D_ENDIAN_SHIFT 24
|
||||
#define GE2D_LITTLE_ENDIAN (1 << GE2D_ENDIAN_SHIFT)
|
||||
#define GE2D_COLOR_MAP_SHIFT 20
|
||||
#define GE2D_COLOR_MAP_BGR888 (5 << GE2D_COLOR_MAP_SHIFT)
|
||||
#define GE2D_COLOR_MAP_RGB888 (0 << GE2D_COLOR_MAP_SHIFT)
|
||||
#define GE2D_FMT_S24_RGB (GE2D_LITTLE_ENDIAN|0x00200) /* 10_00_0_00_0_00 */
|
||||
#define GE2D_FORMAT_S24_BGR (GE2D_FMT_S24_RGB | GE2D_COLOR_MAP_BGR888)
|
||||
#define GE2D_FORMAT_S24_RGB (GE2D_FMT_S24_RGB | GE2D_COLOR_MAP_RGB888)
|
||||
|
||||
// #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 _A_M 'S'
|
||||
#define AMSTREAM_IOC_GET_VIDEO_DISABLE _IOR((_A_M), 0x48, int)
|
||||
|
||||
#define AMVIDEO_MAGIC 'X'
|
||||
|
||||
#define AMVIDEO_EXT_GET_CURRENT_VIDEOFRAME _IOR((AMVIDEO_MAGIC), 0x01, int)
|
||||
#define AMVIDEO_EXT_PUT_CURRENT_VIDEOFRAME _IO((AMVIDEO_MAGIC), 0x02)
|
||||
|
||||
#define AMVIDEO_EXT_CURRENT_VIDEOFRAME_GET_GE2D_FORMAT _IOR((AMVIDEO_MAGIC), 0x03, uint32_t)
|
||||
#define AMVIDEO_EXT_CURRENT_VIDEOFRAME_GET_SIZE _IOR((AMVIDEO_MAGIC), 0x04, uint64_t)
|
||||
#define AMVIDEO_EXT_CURRENT_VIDEOFRAME_GET_CANVAS0ADDR _IOR((AMVIDEO_MAGIC), 0x05, uint32_t)
|
||||
#define AMVIDEO_EXT_CURRENT_VIDEOFRAME_GET_DATA _IOR((AMVIDEO_MAGIC), 0x06, struct amvideo_grabber_data)
|
||||
|
||||
// GE2D commands
|
||||
#define GE2D_IOC_MAGIC 'G'
|
||||
#define GE2D_STRETCHBLIT_NOALPHA 0x4702
|
||||
#define GE2D_CONFIG_EX _IOW(GE2D_IOC_MAGIC, 0x01, struct config_para_ex_s)
|
||||
|
||||
|
||||
// data structures
|
||||
enum ge2d_src_dst_e {
|
||||
OSD0_OSD0 = 0,
|
||||
OSD0_OSD1,
|
||||
OSD1_OSD1,
|
||||
OSD1_OSD0,
|
||||
ALLOC_OSD0,
|
||||
ALLOC_OSD1,
|
||||
ALLOC_ALLOC,
|
||||
TYPE_INVALID,
|
||||
};
|
||||
|
||||
enum ge2d_src_canvas_type_e {
|
||||
CANVAS_OSD0 = 0,
|
||||
CANVAS_OSD1,
|
||||
CANVAS_ALLOC,
|
||||
CANVAS_TYPE_INVALID,
|
||||
};
|
||||
|
||||
struct src_dst_para_s {
|
||||
int xres;
|
||||
int yres;
|
||||
int canvas_index;
|
||||
int bpp;
|
||||
int ge2d_color_index;
|
||||
};
|
||||
|
||||
enum ge2d_op_type_e {
|
||||
GE2D_OP_DEFAULT = 0,
|
||||
GE2D_OP_FILLRECT,
|
||||
GE2D_OP_BLIT,
|
||||
GE2D_OP_STRETCHBLIT,
|
||||
GE2D_OP_BLEND,
|
||||
GE2D_OP_MAXNUM
|
||||
};
|
||||
|
Reference in New Issue
Block a user