Skip to content

Commit 49fa564

Browse files
committed
Add ENABLE_AMLOGIC build option
1 parent 1c06c67 commit 49fa564

File tree

14 files changed

+147
-52
lines changed

14 files changed

+147
-52
lines changed

BUILDING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Use -D prefix when configuring the build.
1717
* ENABLE_PIPEWIRE = ON | OFF, enables the Pipewire software grabber (Linux)
1818
* ENABLE_PIPEWIRE_EGL = ON | OFF, enables EGL for the Pipewire grabber (Linux)
1919
* ENABLE_X11 = ON | OFF, enables the X11 software grabber (Linux)
20+
* ENABLE_AMLOGIC = ON | OFF, forces the Amlogic software grabber (Linux)
2021

2122
* HARDWARE GRABBERS
2223
* ENABLE_AVF = ON | OFF, enables the AVF USB grabber support (macOS)

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ SET ( DEFAULT_X11 OFF )
4343
SET ( DEFAULT_PIPEWIRE OFF )
4444
SET ( DEFAULT_PIPEWIRE_EGL OFF )
4545
SET ( DEFAULT_FRAMEBUFFER OFF )
46+
SET ( DEFAULT_AMLOGIC OFF )
4647
SET ( DEFAULT_SOUNDCAPWINDOWS OFF )
4748
SET ( DEFAULT_SOUNDCAPMACOS OFF )
4849
SET ( DEFAULT_CEC OFF )
@@ -431,6 +432,9 @@ colorMe("ENABLE_DX = " ${ENABLE_DX})
431432
option(ENABLE_FRAMEBUFFER "Enable the framebuffer Linux system grabber" ${DEFAULT_FRAMEBUFFER})
432433
colorMe("ENABLE_FRAMEBUFFER = " ${ENABLE_FRAMEBUFFER})
433434

435+
option(ENABLE_AMLOGIC "Enable the Amlogic grabber" ${DEFAULT_AMLOGIC})
436+
colorMe("ENABLE_AMLOGIC = " ${ENABLE_AMLOGIC})
437+
434438
option(ENABLE_MAC_SYSTEM "Enable macOS system grabber" ${DEFAULT_MAC_SYSTEM})
435439
colorMe("ENABLE_MAC_SYSTEM = " ${ENABLE_MAC_SYSTEM})
436440

HyperhdrConfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
// framebuffer linux system grabber
1919
#cmakedefine ENABLE_FRAMEBUFFER
2020

21+
// amlogic system grabber
22+
#cmakedefine ENABLE_AMLOGIC
23+
2124
// macOs system grabber
2225
#cmakedefine ENABLE_MAC_SYSTEM
2326

include/grabber/linux/amlogic/AmlogicGrabber.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
#include <grabber/linux/amlogic/Amvideocap.h>
2525

2626

27-
class FrameBufGrabber : public Grabber
27+
class AmlogicGrabber : public Grabber
2828
{
2929
Q_OBJECT
3030

3131
public:
3232

33-
FrameBufGrabber(const QString& device, const QString& configurationPath);
33+
AmlogicGrabber(const QString& device, const QString& configurationPath);
3434

35-
~FrameBufGrabber();
35+
~AmlogicGrabber();
3636

3737
void setHdrToneMappingEnabled(int mode) override;
3838

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
#include <base/SystemWrapper.h>
4+
#include <grabber/linux/amlogic/AmlogicGrabber.h>
5+
6+
class AmlogicWrapper : public SystemWrapper
7+
{
8+
Q_OBJECT
9+
10+
public:
11+
AmlogicWrapper(const QString& device, const QString& configurationPath);
12+
bool isActivated(bool forced) override;
13+
14+
protected:
15+
QString getGrabberInfo() override;
16+
17+
18+
private:
19+
AmlogicGrabber _grabber;
20+
};

include/grabber/linux/framebuffer/FrameBufGrabber.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
#include <utils/Components.h>
2121

2222

23-
//AML
24-
#include <grabber/linux/amlogic/Amvideocap.h>
25-
2623

2724
class FrameBufGrabber : public Grabber
2825
{
@@ -68,16 +65,6 @@ public slots:
6865
bool init() override;
6966

7067
void uninit() override;
71-
72-
73-
//AMLOGIC
74-
bool isVideoPlayingAML();
75-
void closeDeviceAML(int& fd);
76-
bool openDeviceAML(int& fd, const char* dev);
77-
bool initAmlogic();
78-
bool stopAmlogic();
79-
bool grabFrameAmlogic();
80-
bool grabFrameFramebuffer();
8168

8269
private:
8370
QString _configurationPath;

sources/grabber/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ if (ENABLE_FRAMEBUFFER)
1010
add_subdirectory(linux/framebuffer)
1111
endif(ENABLE_FRAMEBUFFER)
1212

13+
if (ENABLE_AMLOGIC)
14+
add_subdirectory(linux/amlogic)
15+
endif(ENABLE_AMLOGIC)
16+
1317
if (ENABLE_V4L2)
1418
add_subdirectory(linux/v4l2)
1519
endif (ENABLE_V4L2)

sources/grabber/linux/amlogic/AmlogicGrabber.cpp

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -50,53 +50,54 @@
5050

5151
#include <grabber/linux/amlogic/AmlogicGrabber.h>
5252

53-
const int AMVIDEOCAP_WAIT_MAX_MS = 40;
54-
const char DEFAULT_VIDEO_DEVICE[] = "/dev/amvideo";
55-
const char DEFAULT_CAPTURE_DEVICE[] = "/dev/amvideocap0";
56-
uint8_t* lastValidFrame = nullptr;
57-
size_t lastFrameSize = 0;
53+
namespace {
54+
const int AMVIDEOCAP_WAIT_MAX_MS = 40;
55+
const char DEFAULT_VIDEO_DEVICE[] = "/dev/amvideo";
56+
const char DEFAULT_CAPTURE_DEVICE[] = "/dev/amvideocap0";
57+
uint8_t* lastValidFrame = nullptr;
58+
size_t lastFrameSize = 0;
5859

59-
int _captureDev = -1;
60-
int _videoDev = -1;
60+
int _captureDev = -1;
61+
int _videoDev = -1;
6162

62-
void* base;
63-
ssize_t _bytesToRead;
63+
void* base;
6464

65-
bool messageShow = false;
66-
bool _usingAmlogic = false;
65+
bool messageShow = false;
66+
bool _usingAmlogic = false;
67+
}
6768

6869

69-
FrameBufGrabber::FrameBufGrabber(const QString& device, const QString& configurationPath)
70-
: Grabber(configurationPath, "FRAMEBUFFER_SYSTEM:" + device.left(14))
70+
AmlogicGrabber::AmlogicGrabber(const QString& device, const QString& configurationPath)
71+
: Grabber(configurationPath, "AMLOGIC_SYSTEM:" + device.left(14))
7172
, _configurationPath(configurationPath)
7273
, _semaphore(1)
7374
, _handle(-1)
7475
{
7576
_timer.setTimerType(Qt::PreciseTimer);
76-
connect(&_timer, &QTimer::timeout, this, &FrameBufGrabber::grabFrame);
77+
connect(&_timer, &QTimer::timeout, this, &AmlogicGrabber::grabFrame);
7778

7879
getDevices();
7980
}
8081

81-
QString FrameBufGrabber::GetSharedLut()
82+
QString AmlogicGrabber::GetSharedLut()
8283
{
8384
return "";
8485
}
8586

86-
void FrameBufGrabber::loadLutFile(PixelFormat color)
87+
void AmlogicGrabber::loadLutFile(PixelFormat color)
8788
{
8889
}
8990

90-
void FrameBufGrabber::setHdrToneMappingEnabled(int mode)
91+
void AmlogicGrabber::setHdrToneMappingEnabled(int mode)
9192
{
9293
}
9394

94-
FrameBufGrabber::~FrameBufGrabber()
95+
AmlogicGrabber::~AmlogicGrabber()
9596
{
9697
uninit();
9798
}
9899

99-
void FrameBufGrabber::uninit()
100+
void AmlogicGrabber::uninit()
100101
{
101102
if (_initialized)
102103
{
@@ -107,7 +108,7 @@ void FrameBufGrabber::uninit()
107108
_initialized = false;
108109
}
109110

110-
bool FrameBufGrabber::init()
111+
bool AmlogicGrabber::init()
111112
{
112113
Debug(_log, "init");
113114

@@ -187,17 +188,17 @@ bool FrameBufGrabber::init()
187188
}
188189

189190

190-
void FrameBufGrabber::getDevices()
191+
void AmlogicGrabber::getDevices()
191192
{
192193
enumerateDevices(false);
193194
}
194195

195-
bool FrameBufGrabber::isActivated()
196+
bool AmlogicGrabber::isActivated()
196197
{
197198
return !_deviceProperties.isEmpty();
198199
}
199200

200-
void FrameBufGrabber::enumerateDevices(bool silent)
201+
void AmlogicGrabber::enumerateDevices(bool silent)
201202
{
202203
_deviceProperties.clear();
203204

@@ -220,7 +221,7 @@ void FrameBufGrabber::enumerateDevices(bool silent)
220221
}
221222
}
222223

223-
bool FrameBufGrabber::start()
224+
bool AmlogicGrabber::start()
224225
{
225226
try
226227
{
@@ -240,7 +241,7 @@ bool FrameBufGrabber::start()
240241
return false;
241242
}
242243

243-
void FrameBufGrabber::stop()
244+
void AmlogicGrabber::stop()
244245
{
245246
if (_initialized)
246247
{
@@ -259,7 +260,7 @@ void FrameBufGrabber::stop()
259260
}
260261
}
261262

262-
void FrameBufGrabber::grabFrame()
263+
void AmlogicGrabber::grabFrame()
263264
{
264265
bool stopNow = false;
265266

@@ -316,7 +317,7 @@ void FrameBufGrabber::grabFrame()
316317
}
317318
}
318319

319-
bool FrameBufGrabber::grabFrameFramebuffer()
320+
bool AmlogicGrabber::grabFrameFramebuffer()
320321
{
321322
struct fb_var_screeninfo scr;
322323
bool isStillActive = false;
@@ -385,7 +386,7 @@ bool FrameBufGrabber::grabFrameFramebuffer()
385386
}
386387

387388

388-
void FrameBufGrabber::setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom)
389+
void AmlogicGrabber::setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom)
389390
{
390391
_cropLeft = cropLeft;
391392
_cropRight = cropRight;
@@ -394,7 +395,7 @@ void FrameBufGrabber::setCropping(unsigned cropLeft, unsigned cropRight, unsigne
394395
}
395396

396397

397-
bool FrameBufGrabber::grabFrameAmlogic()
398+
bool AmlogicGrabber::grabFrameAmlogic()
398399
{
399400
long r1 = ioctl(_captureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_WIDTH, _width);
400401
long r2 = ioctl(_captureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_HEIGHT, _height);
@@ -471,7 +472,7 @@ bool FrameBufGrabber::grabFrameAmlogic()
471472
return true;
472473
}
473474

474-
bool FrameBufGrabber::initAmlogic()
475+
bool AmlogicGrabber::initAmlogic()
475476
{
476477
Info(_log, "Starting Amlogic capture device...");
477478
try {
@@ -490,7 +491,7 @@ bool FrameBufGrabber::initAmlogic()
490491
}
491492
}
492493

493-
bool FrameBufGrabber::stopAmlogic()
494+
bool AmlogicGrabber::stopAmlogic()
494495
{
495496
Info(_log, "Stopping Amlogic capture device...");
496497
try {
@@ -509,7 +510,7 @@ bool FrameBufGrabber::stopAmlogic()
509510
}
510511
}
511512

512-
void FrameBufGrabber::closeDeviceAML(int& fd)
513+
void AmlogicGrabber::closeDeviceAML(int& fd)
513514
{
514515
if (fd >= 0)
515516
{
@@ -518,7 +519,7 @@ void FrameBufGrabber::closeDeviceAML(int& fd)
518519
}
519520
}
520521

521-
bool FrameBufGrabber::openDeviceAML(int& fd, const char* dev)
522+
bool AmlogicGrabber::openDeviceAML(int& fd, const char* dev)
522523
{
523524
if (fd < 0)
524525
{
@@ -531,7 +532,7 @@ bool FrameBufGrabber::openDeviceAML(int& fd, const char* dev)
531532
return true;
532533
}
533534

534-
bool FrameBufGrabber::isVideoPlayingAML()
535+
bool AmlogicGrabber::isVideoPlayingAML()
535536
{
536537
if (QFile::exists(DEFAULT_VIDEO_DEVICE))
537538
{
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* AmlogicWrapper.cpp
2+
*
3+
* MIT License
4+
*
5+
* Copyright (c) 2020-2025 awawa-dev
6+
*
7+
* Project homesite: https://github.com/awawa-dev/HyperHDR
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documentation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furnished to do so, subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in all
17+
* copies or substantial portions of the Software.
18+
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
* SOFTWARE.
26+
*/
27+
28+
#include <QMetaType>
29+
#include <grabber/linux/amlogic/AmlogicWrapper.h>
30+
31+
32+
AmlogicWrapper::AmlogicWrapper(const QString &device,
33+
const QString & configurationPath )
34+
: SystemWrapper("AMLOGIC_SYSTEM:"+device.left(14), &_grabber)
35+
, _grabber(device, configurationPath)
36+
{
37+
qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>");
38+
connect(&_grabber, &Grabber::SignalNewCapturedFrame, this, &SystemWrapper::newCapturedFrameHandler, Qt::DirectConnection);
39+
connect(&_grabber, &Grabber::SignalCapturingException, this, &SystemWrapper::capturingExceptionHandler, Qt::DirectConnection);
40+
}
41+
42+
QString AmlogicWrapper::getGrabberInfo()
43+
{
44+
return "amlogic";
45+
}
46+
47+
bool AmlogicWrapper::isActivated(bool forced)
48+
{
49+
return _grabber.isActivated();
50+
}
51+
52+

sources/grabber/linux/amlogic/IonBuffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* more details.
1414
*
1515
*/
16-
#include "IonBuffer.h"
16+
#include <grabber/linux/amlogic/IonBuffer.h>
1717

1818
int IonBuffer::ion_fd = -1;
1919

0 commit comments

Comments
 (0)