Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reworked Amlogic "ge2d" mode and add single ioctl call #530

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions assets/webconfig/i18n/de.json
Expand Up @@ -534,6 +534,8 @@
"edt_conf_fg_pixelDecimation_expl" : "Bildverkleinerung (Faktor) ausgehend von der original Größe. 1 für unveränderte/originale Größe.",
"edt_conf_fg_device_title" : "Device",
"edt_conf_fg_display_title" : "Display",
"edt_conf_fg_amlogic_grabber_title" : "Amlogic Grabber Device",
"edt_conf_fg_ge2d_mode_title" : "Amlogic ge2d Grabber Modus",
"edt_conf_fg_display_expl" : "Gebe an von welchem Desktop aufgenommen werden soll. (Multi Monitor Setup)",
"edt_conf_bb_heading_title" : "Schwarze Balken Erkennung",
"edt_conf_bb_threshold_title" : "Schwelle",
Expand Down
2 changes: 2 additions & 0 deletions assets/webconfig/i18n/en.json
Expand Up @@ -535,6 +535,8 @@
"edt_conf_fg_pixelDecimation_expl" : "Reduce picture size (factor) based on original size. A factor of 1 means no change",
"edt_conf_fg_device_title" : "Device",
"edt_conf_fg_display_title" : "Display",
"edt_conf_fg_amlogic_grabber_title" : "Amlogic Grabber Device",
"edt_conf_fg_ge2d_mode_title" : "Amlogic ge2d Grabber Modus",
"edt_conf_fg_display_expl" : "Select which desktop should be captured (multi monitor setup)",
"edt_conf_bb_heading_title" : "Blackbar detector",
"edt_conf_bb_threshold_title" : "Threshold",
Expand Down
6 changes: 5 additions & 1 deletion config/hyperion.config.json.commented
Expand Up @@ -162,7 +162,11 @@
"display" 0,

// valid for framebuffer
"device" : "/dev/fb0"
"device" : "/dev/fb0",

// valid for amlogic
"amlogic_grabber" : "amvideocap0",
"ge2d_mode" : 1
},

/// The black border configuration, contains the following items:
Expand Down
4 changes: 3 additions & 1 deletion config/hyperion.config.json.default
Expand Up @@ -88,7 +88,9 @@
"cropRight" : 0,
"cropTop" : 0,
"cropBottom" : 0,
"device" : "/dev/fb0"
"device" : "/dev/fb0",
"amlogic_grabber" : "amvideocap0",
"ge2d_mode" : 1
},

"blackborderdetector" :
Expand Down
5 changes: 2 additions & 3 deletions dependencies/CMakeLists.txt
Expand Up @@ -12,7 +12,7 @@ endif()
set(USE_SYSTEM_FLATBUFFERS_LIBS ${DEFAULT_USE_SYSTEM_FLATBUFFERS_LIBS} CACHE BOOL "use flatbuffers library from system")

if (USE_SYSTEM_FLATBUFFERS_LIBS)
find_package(flatbuffers REQUIRED)
find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc REQUIRED)
include_directories(${FLATBUFFERS_INCLUDE_DIRS})
else ()
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared flatbuffers library")
Expand Down Expand Up @@ -47,6 +47,5 @@ function(compile_flattbuffer_schema SRC_FBS OUTPUT_DIR)
COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --no-includes --gen-mutable
--gen-object-api
-o "${OUTPUT_DIR}"
"${SRC_FBS}"
DEPENDS flatc)
"${SRC_FBS}")
endfunction()
117 changes: 114 additions & 3 deletions include/grabber/AmlogicGrabber.h
Expand Up @@ -8,6 +8,111 @@

class IonBuffer;

struct rectangle_s {
int x; /* X coordinate of its top-left point */
int y; /* Y coordinate of its top-left point */
int w; /* width of it */
int h; /* height of it */
};

struct ge2d_para_s {
unsigned int color;
struct rectangle_s src1_rect;
struct rectangle_s src2_rect;
struct rectangle_s dst_rect;
int op;
};

struct config_planes_s {
unsigned long addr;
unsigned int w;
unsigned int h;
};

struct src_key_ctrl_s {
int key_enable;
int key_color;
int key_mask;
int key_mode;
};

struct config_para_s {
int src_dst_type;
int alu_const_color;
unsigned int src_format;
unsigned int dst_format; /* add for src&dst all in user space. */

struct config_planes_s src_planes[4];
struct config_planes_s dst_planes[4];
struct src_key_ctrl_s src_key;
};

struct src_dst_para_ex_s {
int canvas_index;
int top;
int left;
int width;
int height;
int format;
int mem_type;
int color;
unsigned char x_rev;
unsigned char y_rev;
unsigned char fill_color_en;
unsigned char fill_mode;
};

struct config_para_ex_s {
struct src_dst_para_ex_s src_para;
struct src_dst_para_ex_s src2_para;
struct src_dst_para_ex_s dst_para;

/* key mask */
struct src_key_ctrl_s src_key;
struct src_key_ctrl_s src2_key;

int alu_const_color;
unsigned src1_gb_alpha;
unsigned op_mode;
unsigned char bitmask_en;
unsigned char bytemask_only;
unsigned int bitmask;
unsigned char dst_xy_swap;

/* scaler and phase releated */
unsigned hf_init_phase;
int hf_rpt_num;
unsigned hsc_start_phase_step;
int hsc_phase_slope;
unsigned vf_init_phase;
int vf_rpt_num;
unsigned vsc_start_phase_step;
int vsc_phase_slope;
unsigned char src1_vsc_phase0_always_en;
unsigned char src1_hsc_phase0_always_en;
/* 1bit, 0: using minus, 1: using repeat data */
unsigned char src1_hsc_rpt_ctrl;
/* 1bit, 0: using minus 1: using repeat data */
unsigned char src1_vsc_rpt_ctrl;

/* canvas info */
struct config_planes_s src_planes[4];
struct config_planes_s src2_planes[4];
struct config_planes_s dst_planes[4];
};

struct amvideo_grabber_data {
int canvas_index;
uint32_t canvas0Addr;
uint32_t ge2dformat;
uint64_t size;
};

enum ge2d_mode {
ge2d_single = 0,
ge2d_combined = 1
};

///
///
class AmlogicGrabber : public Grabber
Expand All @@ -18,8 +123,9 @@ class AmlogicGrabber : public Grabber
///
/// @param[in] width The width of the captured screenshot
/// @param[in] height The heigth of the captured screenshot
/// @param[in] ge2d_mode The ge2d mode, 0: single icotl calls, 1: combined data ioctl call
///
AmlogicGrabber(const unsigned width, const unsigned height);
AmlogicGrabber(const unsigned width, const unsigned height, const unsigned ge2d_mode, const QString device);
~AmlogicGrabber();

///
Expand Down Expand Up @@ -51,12 +157,17 @@ class AmlogicGrabber : public Grabber
int _ge2dDev;

Image<ColorBgr> _image_bgr;

void* _image_ptr;
ssize_t _bytesToRead;

int _lastError;
bool _videoPlaying;
FramebufferFrameGrabber _fbGrabber;
int _grabbingModeNotification;
bool _ge2dAvailable;
void* _ge2dVideoBufferPtr;
IonBuffer* _ge2dIonBuffer;
struct config_para_ex_s _configex;
ge2d_para_s _blitRect;
int _ge2d_mode;
QString _device;
};
4 changes: 3 additions & 1 deletion include/grabber/AmlogicWrapper.h
Expand Up @@ -18,8 +18,10 @@ class AmlogicWrapper : public GrabberWrapper
/// @param[in] grabWidth The width of the grabbed image [pixels]
/// @param[in] grabHeight The height of the grabbed images [pixels]
/// @param[in] updateRate_Hz The image grab rate [Hz]
/// @param[in] ge2d_mode use single or combine ge2d ioctl call
/// @param[in] device amlogic grabber device
///
AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz);
AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const unsigned ge2d_mode, const QString device);

///
/// Destructor of this dispmanx frame grabber. Releases any claimed resources.
Expand Down