mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 23:12:44 +02:00
hdmi cec reduce cpu load
Origin commit data
------------------
Branch: master
Commit: 91641b364f
Author: TangoCash <eric@loxat.de>
Date: 2020-06-20 (Sat, 20 Jun 2020)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/epoll.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -43,6 +44,9 @@
|
|||||||
#define GREEN "\x1B[32m"
|
#define GREEN "\x1B[32m"
|
||||||
#define NORMAL "\x1B[0m"
|
#define NORMAL "\x1B[0m"
|
||||||
|
|
||||||
|
#define EPOLL_WAIT_TIMEOUT (1000)
|
||||||
|
#define EPOLL_MAX_EVENTS (1)
|
||||||
|
|
||||||
#define hal_debug(args...) _hal_debug(HAL_DEBUG_INIT, this, args)
|
#define hal_debug(args...) _hal_debug(HAL_DEBUG_INIT, this, args)
|
||||||
#define hal_info(args...) _hal_info(HAL_DEBUG_INIT, this, args)
|
#define hal_info(args...) _hal_info(HAL_DEBUG_INIT, this, args)
|
||||||
#define hal_debug_c(args...) _hal_debug(HAL_DEBUG_INIT, NULL, args)
|
#define hal_debug_c(args...) _hal_debug(HAL_DEBUG_INIT, NULL, args)
|
||||||
@@ -557,6 +561,7 @@ bool hdmi_cec::Start()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
|
OpenThreads::Thread::setSchedulePriority(THREAD_PRIORITY_MIN);
|
||||||
return (OpenThreads::Thread::start() == 0);
|
return (OpenThreads::Thread::start() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -581,27 +586,30 @@ bool hdmi_cec::Stop()
|
|||||||
void hdmi_cec::run()
|
void hdmi_cec::run()
|
||||||
{
|
{
|
||||||
OpenThreads::Thread::setCancelModeAsynchronous();
|
OpenThreads::Thread::setCancelModeAsynchronous();
|
||||||
struct pollfd pfd;
|
int n;
|
||||||
|
int epollfd = epoll_create1(0);
|
||||||
|
struct epoll_event event;
|
||||||
|
event.data.fd = hdmiFd;
|
||||||
|
event.events = EPOLLIN;
|
||||||
|
|
||||||
pfd.fd = hdmiFd;
|
epoll_ctl(epollfd, EPOLL_CTL_ADD, hdmiFd, &event);
|
||||||
pfd.events = (POLLIN | POLLPRI);
|
|
||||||
|
std::array<struct epoll_event, EPOLL_MAX_EVENTS> events;
|
||||||
|
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
if (poll(&pfd, 1, 0) > 0)
|
n = epoll_wait(epollfd, events.data(), EPOLL_MAX_EVENTS, EPOLL_WAIT_TIMEOUT);
|
||||||
Receive(pfd.revents);
|
for (int i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
if (events[i].events & EPOLLIN)
|
||||||
|
Receive(events[i].events);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hdmi_cec::Receive(int what)
|
void hdmi_cec::Receive(int what)
|
||||||
{
|
{
|
||||||
if (what & POLLPRI)
|
if (what & EPOLLIN)
|
||||||
{
|
|
||||||
GetCECAddressInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (what & POLLIN)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
bool hasdata = false;
|
bool hasdata = false;
|
||||||
|
Reference in New Issue
Block a user