mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
cec volume switch audiosystem/tv
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2018-2020 TangoCash
|
Copyright (C) 2018-2021 TangoCash
|
||||||
|
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
|
|
||||||
@@ -85,6 +85,7 @@ hdmi_cec::hdmi_cec()
|
|||||||
fallback = false;
|
fallback = false;
|
||||||
tv_off = true;
|
tv_off = true;
|
||||||
deviceType = CEC_LOG_ADDR_TYPE_UNREGISTERED;
|
deviceType = CEC_LOG_ADDR_TYPE_UNREGISTERED;
|
||||||
|
audio_destination = CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
hdmi_cec::~hdmi_cec()
|
hdmi_cec::~hdmi_cec()
|
||||||
@@ -812,7 +813,7 @@ void hdmi_cec::send_key(unsigned char key, unsigned char destination)
|
|||||||
void hdmi_cec::request_audio_status()
|
void hdmi_cec::request_audio_status()
|
||||||
{
|
{
|
||||||
struct cec_message txmessage;
|
struct cec_message txmessage;
|
||||||
txmessage.destination = CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM;
|
txmessage.destination = audio_destination;
|
||||||
txmessage.initiator = logicalAddress;
|
txmessage.initiator = logicalAddress;
|
||||||
txmessage.data[0] = CEC_OPCODE_GIVE_AUDIO_STATUS;
|
txmessage.data[0] = CEC_OPCODE_GIVE_AUDIO_STATUS;
|
||||||
txmessage.length = 1;
|
txmessage.length = 1;
|
||||||
@@ -821,16 +822,31 @@ void hdmi_cec::request_audio_status()
|
|||||||
|
|
||||||
void hdmi_cec::vol_up()
|
void hdmi_cec::vol_up()
|
||||||
{
|
{
|
||||||
send_key(CEC_USER_CONTROL_CODE_VOLUME_UP, CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM);
|
send_key(CEC_USER_CONTROL_CODE_VOLUME_UP, audio_destination);
|
||||||
request_audio_status();
|
request_audio_status();
|
||||||
}
|
}
|
||||||
void hdmi_cec::vol_down()
|
void hdmi_cec::vol_down()
|
||||||
{
|
{
|
||||||
send_key(CEC_USER_CONTROL_CODE_VOLUME_DOWN, CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM);
|
send_key(CEC_USER_CONTROL_CODE_VOLUME_DOWN, audio_destination);
|
||||||
request_audio_status();
|
request_audio_status();
|
||||||
}
|
}
|
||||||
void hdmi_cec::toggle_mute()
|
void hdmi_cec::toggle_mute()
|
||||||
{
|
{
|
||||||
send_key(CEC_USER_CONTROL_CODE_MUTE, CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM);
|
send_key(CEC_USER_CONTROL_CODE_MUTE, audio_destination);
|
||||||
request_audio_status();
|
request_audio_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hdmi_cec::SetAudioDestination(int audio_dest)
|
||||||
|
{
|
||||||
|
switch(audio_dest)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
audio_destination = CEC_OP_PRIM_DEVTYPE_TV;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
default:
|
||||||
|
audio_destination = CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#define __HDMI_CEC_H__
|
#define __HDMI_CEC_H__
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2018-2020 TangoCash
|
Copyright (C) 2018-2021 TangoCash
|
||||||
|
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
|
|
||||||
@@ -79,6 +79,7 @@ private:
|
|||||||
int volume;
|
int volume;
|
||||||
bool fallback;
|
bool fallback;
|
||||||
bool tv_off;
|
bool tv_off;
|
||||||
|
unsigned char audio_destination;
|
||||||
protected:
|
protected:
|
||||||
bool running;
|
bool running;
|
||||||
public:
|
public:
|
||||||
@@ -103,6 +104,11 @@ public:
|
|||||||
{
|
{
|
||||||
return muted;
|
return muted;
|
||||||
};
|
};
|
||||||
|
int GetAudioDestination()
|
||||||
|
{
|
||||||
|
return (int)audio_destination;
|
||||||
|
}
|
||||||
|
void SetAudioDestination(int audio_dest);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __HDMI_CEC_H__
|
#endif // __HDMI_CEC_H__
|
||||||
|
@@ -1303,3 +1303,13 @@ void cVideo::SetCECAutoView(bool state)
|
|||||||
{
|
{
|
||||||
hdmi_cec::getInstance()->SetCECAutoView(state);
|
hdmi_cec::getInstance()->SetCECAutoView(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cVideo::GetAudioDestination()
|
||||||
|
{
|
||||||
|
return (int)hdmi_cec::getInstance()->GetAudioDestination();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cVideo::SetAudioDestination(int audio_dest)
|
||||||
|
{
|
||||||
|
hdmi_cec::getInstance()->SetAudioDestination(audio_dest);
|
||||||
|
}
|
@@ -130,6 +130,12 @@ typedef enum {
|
|||||||
VIDEO_HDMI_CEC_MODE_RECORDER = 1
|
VIDEO_HDMI_CEC_MODE_RECORDER = 1
|
||||||
} VIDEO_HDMI_CEC_MODE;
|
} VIDEO_HDMI_CEC_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIDEO_HDMI_CEC_VOL_OFF = 0,
|
||||||
|
VIDEO_HDMI_CEC_VOL_AUDIOSYSTEM = 1,
|
||||||
|
VIDEO_HDMI_CEC_VOL_TV = 2
|
||||||
|
} VIDEO_HDMI_CEC_VOL;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
VIDEO_CONTROL_BRIGHTNESS = 0,
|
VIDEO_CONTROL_BRIGHTNESS = 0,
|
||||||
@@ -238,6 +244,8 @@ class cVideo
|
|||||||
bool SetCECMode(VIDEO_HDMI_CEC_MODE);
|
bool SetCECMode(VIDEO_HDMI_CEC_MODE);
|
||||||
void SetCECAutoView(bool);
|
void SetCECAutoView(bool);
|
||||||
void SetCECAutoStandby(bool);
|
void SetCECAutoStandby(bool);
|
||||||
|
int GetAudioDestination();
|
||||||
|
void SetAudioDestination(int audio_dest);
|
||||||
bool ShowPicture(const char * fname);
|
bool ShowPicture(const char * fname);
|
||||||
void StopPicture();
|
void StopPicture();
|
||||||
void Standby(unsigned int bOn);
|
void Standby(unsigned int bOn);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2018-2020 TangoCash
|
Copyright (C) 2018-2021 TangoCash
|
||||||
|
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
|
|
||||||
@@ -85,6 +85,7 @@ hdmi_cec::hdmi_cec()
|
|||||||
fallback = false;
|
fallback = false;
|
||||||
tv_off = true;
|
tv_off = true;
|
||||||
deviceType = CEC_LOG_ADDR_TYPE_UNREGISTERED;
|
deviceType = CEC_LOG_ADDR_TYPE_UNREGISTERED;
|
||||||
|
audio_destination = CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
hdmi_cec::~hdmi_cec()
|
hdmi_cec::~hdmi_cec()
|
||||||
@@ -101,7 +102,7 @@ hdmi_cec* hdmi_cec::getInstance()
|
|||||||
if (hdmi_cec_instance == NULL)
|
if (hdmi_cec_instance == NULL)
|
||||||
{
|
{
|
||||||
hdmi_cec_instance = new hdmi_cec();
|
hdmi_cec_instance = new hdmi_cec();
|
||||||
hal_info_c(GREEN "[CEC] new instance created \n" NORMAL);
|
hal_info_c(GREEN"[CEC] new instance created \n"NORMAL);
|
||||||
}
|
}
|
||||||
return hdmi_cec_instance;
|
return hdmi_cec_instance;
|
||||||
}
|
}
|
||||||
@@ -115,13 +116,13 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType)
|
|||||||
if (_deviceType == VIDEO_HDMI_CEC_MODE_OFF)
|
if (_deviceType == VIDEO_HDMI_CEC_MODE_OFF)
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
hal_info(GREEN "[CEC] switch off %s\n" NORMAL, __func__);
|
hal_info(GREEN"[CEC] switch off %s\n"NORMAL, __func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
deviceType = _deviceType;
|
deviceType = _deviceType;
|
||||||
|
|
||||||
hal_info(GREEN "[CEC] switch on %s\n" NORMAL, __func__);
|
hal_info(GREEN"[CEC] switch on %s\n"NORMAL, __func__);
|
||||||
|
|
||||||
#if BOXMODEL_VUPLUS_ALL
|
#if BOXMODEL_VUPLUS_ALL
|
||||||
if (hdmiFd == -1)
|
if (hdmiFd == -1)
|
||||||
@@ -142,21 +143,21 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType)
|
|||||||
{
|
{
|
||||||
fallback = true;
|
fallback = true;
|
||||||
#if BOXMODEL_VUPLUS_ALL
|
#if BOXMODEL_VUPLUS_ALL
|
||||||
hal_info(RED "[CEC] fallback on %s\n" NORMAL, __func__);
|
hal_info(RED"[CEC] fallback on %s\n"NORMAL, __func__);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__u32 monitor = CEC_MODE_INITIATOR | CEC_MODE_FOLLOWER;
|
__u32 monitor = CEC_MODE_INITIATOR | CEC_MODE_FOLLOWER;
|
||||||
struct cec_caps caps = {};
|
struct cec_caps caps = {};
|
||||||
|
|
||||||
if (ioctl(hdmiFd, CEC_ADAP_G_CAPS, &caps) < 0)
|
if (ioctl(hdmiFd, CEC_ADAP_G_CAPS, &caps) < 0)
|
||||||
hal_info(RED "[CEC] %s: get caps failed (%m)\n" NORMAL, __func__);
|
hal_info(RED"[CEC] %s: get caps failed (%m)\n"NORMAL, __func__);
|
||||||
|
|
||||||
if (caps.capabilities & CEC_CAP_LOG_ADDRS)
|
if (caps.capabilities & CEC_CAP_LOG_ADDRS)
|
||||||
{
|
{
|
||||||
struct cec_log_addrs laddrs = {};
|
struct cec_log_addrs laddrs = {};
|
||||||
|
|
||||||
if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0)
|
if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0)
|
||||||
hal_info(RED "[CEC] %s: reset log addr failed (%m)\n" NORMAL, __func__);
|
hal_info(RED"[CEC] %s: reset log addr failed (%m)\n"NORMAL, __func__);
|
||||||
|
|
||||||
memset(&laddrs, 0, sizeof(laddrs));
|
memset(&laddrs, 0, sizeof(laddrs));
|
||||||
|
|
||||||
@@ -206,11 +207,11 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType)
|
|||||||
laddrs.num_log_addrs++;
|
laddrs.num_log_addrs++;
|
||||||
|
|
||||||
if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0)
|
if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0)
|
||||||
hal_info(RED "[CEC] %s: et log addr failed (%m)\n" NORMAL, __func__);
|
hal_info(RED"[CEC] %s: et log addr failed (%m)\n"NORMAL, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(hdmiFd, CEC_S_MODE, &monitor) < 0)
|
if (ioctl(hdmiFd, CEC_S_MODE, &monitor) < 0)
|
||||||
hal_info(RED "[CEC] %s: monitor failed (%m)\n" NORMAL, __func__);
|
hal_info(RED"[CEC] %s: monitor failed (%m)\n"NORMAL, __func__);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,7 +286,7 @@ void hdmi_cec::GetCECAddressInfo()
|
|||||||
logicalAddress = addressinfo.logical;
|
logicalAddress = addressinfo.logical;
|
||||||
if (memcmp(physicalAddress, addressinfo.physical, sizeof(physicalAddress)))
|
if (memcmp(physicalAddress, addressinfo.physical, sizeof(physicalAddress)))
|
||||||
{
|
{
|
||||||
hal_info(GREEN "[CEC] %s: detected physical address change: %02X%02X --> %02X%02X\n" NORMAL, __func__, physicalAddress[0], physicalAddress[1], addressinfo.physical[0], addressinfo.physical[1]);
|
hal_info(GREEN"[CEC] %s: detected physical address change: %02X%02X --> %02X%02X\n"NORMAL, __func__, physicalAddress[0], physicalAddress[1], addressinfo.physical[0], addressinfo.physical[1]);
|
||||||
memcpy(physicalAddress, addressinfo.physical, sizeof(physicalAddress));
|
memcpy(physicalAddress, addressinfo.physical, sizeof(physicalAddress));
|
||||||
ReportPhysicalAddress();
|
ReportPhysicalAddress();
|
||||||
}
|
}
|
||||||
@@ -316,7 +317,7 @@ void hdmi_cec::SendCECMessage(struct cec_message &txmessage, int sleeptime)
|
|||||||
{
|
{
|
||||||
sprintf(str+(i*6),"[0x%02X]", txmessage.data[i]);
|
sprintf(str+(i*6),"[0x%02X]", txmessage.data[i]);
|
||||||
}
|
}
|
||||||
hal_info(GREEN "[CEC] send message %s to %s (0x%02X>>0x%02X) '%s' (%s)\n" NORMAL,ToString((cec_logical_address)txmessage.initiator), txmessage.destination == 0xf ? "all" : ToString((cec_logical_address)txmessage.destination), txmessage.initiator, txmessage.destination, ToString((cec_opcode)txmessage.data[0]), str);
|
hal_info(GREEN"[CEC] send message %s to %s (0x%02X>>0x%02X) '%s' (%s)\n"NORMAL,ToString((cec_logical_address)txmessage.initiator), txmessage.destination == 0xf ? "all" : ToString((cec_logical_address)txmessage.destination), txmessage.initiator, txmessage.destination, ToString((cec_opcode)txmessage.data[0]), str);
|
||||||
|
|
||||||
if (fallback)
|
if (fallback)
|
||||||
{
|
{
|
||||||
@@ -593,9 +594,15 @@ void hdmi_cec::run()
|
|||||||
struct epoll_event event;
|
struct epoll_event event;
|
||||||
event.data.fd = hdmiFd;
|
event.data.fd = hdmiFd;
|
||||||
event.events = EPOLLIN;
|
event.events = EPOLLIN;
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
epoll_ctl(epollfd, EPOLL_CTL_ADD, hdmiFd, &event);
|
epoll_ctl(epollfd, EPOLL_CTL_ADD, hdmiFd, &event);
|
||||||
|
|
||||||
|
=======
|
||||||
|
|
||||||
|
epoll_ctl(epollfd, EPOLL_CTL_ADD, hdmiFd, &event);
|
||||||
|
|
||||||
|
>>>>>>> e24aae1... cec volume switch audiosystem/tv
|
||||||
std::array<struct epoll_event, EPOLL_MAX_EVENTS> events;
|
std::array<struct epoll_event, EPOLL_MAX_EVENTS> events;
|
||||||
|
|
||||||
while (running)
|
while (running)
|
||||||
@@ -658,7 +665,7 @@ void hdmi_cec::Receive(int what)
|
|||||||
{
|
{
|
||||||
sprintf(str+(i*6),"[0x%02X]", rxmessage.data[i]);
|
sprintf(str+(i*6),"[0x%02X]", rxmessage.data[i]);
|
||||||
}
|
}
|
||||||
hal_info(GREEN "[CEC] received message %s to %s (0x%02X>>0x%02X) '%s' (%s)\n" NORMAL,ToString((cec_logical_address)rxmessage.initiator), rxmessage.destination == 0xf ? "all" : ToString((cec_logical_address)rxmessage.destination), rxmessage.initiator, rxmessage.destination, ToString((cec_opcode)rxmessage.opcode), str);
|
hal_info(GREEN"[CEC] received message %s to %s (0x%02X>>0x%02X) '%s' (%s)\n"NORMAL,ToString((cec_logical_address)rxmessage.initiator), rxmessage.destination == 0xf ? "all" : ToString((cec_logical_address)rxmessage.destination), rxmessage.initiator, rxmessage.destination, ToString((cec_opcode)rxmessage.opcode), str);
|
||||||
|
|
||||||
switch (rxmessage.opcode)
|
switch (rxmessage.opcode)
|
||||||
{
|
{
|
||||||
@@ -679,9 +686,9 @@ void hdmi_cec::Receive(int what)
|
|||||||
muted = ((rxmessage.data[1] & 0x80) == 0x80);
|
muted = ((rxmessage.data[1] & 0x80) == 0x80);
|
||||||
volume = ((rxmessage.data[1] & 0x7F) / 127.0) * 100.0;
|
volume = ((rxmessage.data[1] & 0x7F) / 127.0) * 100.0;
|
||||||
if (muted)
|
if (muted)
|
||||||
hal_info(GREEN "[CEC] %s volume muted\n" NORMAL, ToString((cec_logical_address)rxmessage.initiator));
|
hal_info(GREEN"[CEC] %s volume muted\n"NORMAL, ToString((cec_logical_address)rxmessage.initiator));
|
||||||
else
|
else
|
||||||
hal_info(GREEN "[CEC] %s volume %d \n" NORMAL, ToString((cec_logical_address)rxmessage.initiator), volume);
|
hal_info(GREEN"[CEC] %s volume %d \n"NORMAL, ToString((cec_logical_address)rxmessage.initiator), volume);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CEC_OPCODE_DEVICE_VENDOR_ID:
|
case CEC_OPCODE_DEVICE_VENDOR_ID:
|
||||||
@@ -690,7 +697,7 @@ void hdmi_cec::Receive(int what)
|
|||||||
uint64_t iVendorId = ((uint64_t)rxmessage.data[1] << 16) +
|
uint64_t iVendorId = ((uint64_t)rxmessage.data[1] << 16) +
|
||||||
((uint64_t)rxmessage.data[2] << 8) +
|
((uint64_t)rxmessage.data[2] << 8) +
|
||||||
(uint64_t)rxmessage.data[3];
|
(uint64_t)rxmessage.data[3];
|
||||||
hal_info(GREEN "[CEC] decoded message '%s' (%s)\n" NORMAL, ToString((cec_opcode)rxmessage.opcode), ToString((cec_vendor_id)iVendorId));
|
hal_info(GREEN"[CEC] decoded message '%s' (%s)\n"NORMAL, ToString((cec_opcode)rxmessage.opcode), ToString((cec_vendor_id)iVendorId));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS:
|
case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS:
|
||||||
@@ -707,11 +714,11 @@ void hdmi_cec::Receive(int what)
|
|||||||
{
|
{
|
||||||
if ((rxmessage.data[1] == CEC_POWER_STATUS_ON) || (rxmessage.data[1] == CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON))
|
if ((rxmessage.data[1] == CEC_POWER_STATUS_ON) || (rxmessage.data[1] == CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON))
|
||||||
{
|
{
|
||||||
hal_info(GREEN "[CEC] %s reporting state on (%d)\n" NORMAL, ToString((cec_logical_address)rxmessage.initiator), rxmessage.data[1]);
|
hal_info(GREEN"[CEC] %s reporting state on (%d)\n"NORMAL, ToString((cec_logical_address)rxmessage.initiator), rxmessage.data[1]);
|
||||||
if (rxmessage.initiator == CEC_OP_PRIM_DEVTYPE_TV)
|
if (rxmessage.initiator == CEC_OP_PRIM_DEVTYPE_TV)
|
||||||
tv_off = false;
|
tv_off = false;
|
||||||
} else {
|
} else {
|
||||||
hal_info(GREEN "[CEC] %s reporting state off (%d)\n" NORMAL, ToString((cec_logical_address)rxmessage.initiator), rxmessage.data[1]);
|
hal_info(GREEN"[CEC] %s reporting state off (%d)\n"NORMAL, ToString((cec_logical_address)rxmessage.initiator), rxmessage.data[1]);
|
||||||
if (rxmessage.initiator == CEC_OP_PRIM_DEVTYPE_TV)
|
if (rxmessage.initiator == CEC_OP_PRIM_DEVTYPE_TV)
|
||||||
tv_off = true;
|
tv_off = true;
|
||||||
}
|
}
|
||||||
@@ -731,7 +738,7 @@ void hdmi_cec::Receive(int what)
|
|||||||
case CEC_OPCODE_USER_CONTROL_RELEASE: /* key released */
|
case CEC_OPCODE_USER_CONTROL_RELEASE: /* key released */
|
||||||
{
|
{
|
||||||
long code = translateKey(pressedkey);
|
long code = translateKey(pressedkey);
|
||||||
hal_info(GREEN "[CEC] decoded key %s (%ld)\n" NORMAL,ToString((cec_user_control_code)pressedkey), code);
|
hal_info(GREEN"[CEC] decoded key %s (%ld)\n"NORMAL,ToString((cec_user_control_code)pressedkey), code);
|
||||||
handleCode(code,keypressed);
|
handleCode(code,keypressed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -745,14 +752,14 @@ void hdmi_cec::handleCode(long code, bool keypressed)
|
|||||||
int evd = open(RC_DEVICE, O_RDWR);
|
int evd = open(RC_DEVICE, O_RDWR);
|
||||||
if (evd < 0)
|
if (evd < 0)
|
||||||
{
|
{
|
||||||
hal_info(RED "[CEC] opening " RC_DEVICE " failed" NORMAL);
|
hal_info(RED"[CEC] opening " RC_DEVICE " failed"NORMAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (keypressed)
|
if (keypressed)
|
||||||
{
|
{
|
||||||
if (rc_send(evd, code, CEC_KEY_PRESSED) < 0)
|
if (rc_send(evd, code, CEC_KEY_PRESSED) < 0)
|
||||||
{
|
{
|
||||||
hal_info(RED "[CEC] writing 'KEY_PRESSED' event failed" NORMAL);
|
hal_info(RED"[CEC] writing 'KEY_PRESSED' event failed"NORMAL);
|
||||||
close(evd);
|
close(evd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -762,7 +769,7 @@ void hdmi_cec::handleCode(long code, bool keypressed)
|
|||||||
{
|
{
|
||||||
if (rc_send(evd, code, CEC_KEY_RELEASED) < 0)
|
if (rc_send(evd, code, CEC_KEY_RELEASED) < 0)
|
||||||
{
|
{
|
||||||
hal_info(RED "[CEC] writing 'KEY_RELEASED' event failed" NORMAL);
|
hal_info(RED"[CEC] writing 'KEY_RELEASED' event failed"NORMAL);
|
||||||
close(evd);
|
close(evd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -812,7 +819,7 @@ void hdmi_cec::send_key(unsigned char key, unsigned char destination)
|
|||||||
void hdmi_cec::request_audio_status()
|
void hdmi_cec::request_audio_status()
|
||||||
{
|
{
|
||||||
struct cec_message txmessage;
|
struct cec_message txmessage;
|
||||||
txmessage.destination = CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM;
|
txmessage.destination = audio_destination;
|
||||||
txmessage.initiator = logicalAddress;
|
txmessage.initiator = logicalAddress;
|
||||||
txmessage.data[0] = CEC_OPCODE_GIVE_AUDIO_STATUS;
|
txmessage.data[0] = CEC_OPCODE_GIVE_AUDIO_STATUS;
|
||||||
txmessage.length = 1;
|
txmessage.length = 1;
|
||||||
@@ -821,16 +828,31 @@ void hdmi_cec::request_audio_status()
|
|||||||
|
|
||||||
void hdmi_cec::vol_up()
|
void hdmi_cec::vol_up()
|
||||||
{
|
{
|
||||||
send_key(CEC_USER_CONTROL_CODE_VOLUME_UP, CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM);
|
send_key(CEC_USER_CONTROL_CODE_VOLUME_UP, audio_destination);
|
||||||
request_audio_status();
|
request_audio_status();
|
||||||
}
|
}
|
||||||
void hdmi_cec::vol_down()
|
void hdmi_cec::vol_down()
|
||||||
{
|
{
|
||||||
send_key(CEC_USER_CONTROL_CODE_VOLUME_DOWN, CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM);
|
send_key(CEC_USER_CONTROL_CODE_VOLUME_DOWN, audio_destination);
|
||||||
request_audio_status();
|
request_audio_status();
|
||||||
}
|
}
|
||||||
void hdmi_cec::toggle_mute()
|
void hdmi_cec::toggle_mute()
|
||||||
{
|
{
|
||||||
send_key(CEC_USER_CONTROL_CODE_MUTE, CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM);
|
send_key(CEC_USER_CONTROL_CODE_MUTE, audio_destination);
|
||||||
request_audio_status();
|
request_audio_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hdmi_cec::SetAudioDestination(int audio_dest)
|
||||||
|
{
|
||||||
|
switch(audio_dest)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
audio_destination = CEC_OP_PRIM_DEVTYPE_TV;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
default:
|
||||||
|
audio_destination = CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#define __HDMI_CEC_H__
|
#define __HDMI_CEC_H__
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2018-2020 TangoCash
|
Copyright (C) 2018-2021 TangoCash
|
||||||
|
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
|
|
||||||
@@ -79,6 +79,7 @@ private:
|
|||||||
int volume;
|
int volume;
|
||||||
bool fallback;
|
bool fallback;
|
||||||
bool tv_off;
|
bool tv_off;
|
||||||
|
unsigned char audio_destination;
|
||||||
protected:
|
protected:
|
||||||
bool running;
|
bool running;
|
||||||
public:
|
public:
|
||||||
@@ -103,6 +104,11 @@ public:
|
|||||||
{
|
{
|
||||||
return muted;
|
return muted;
|
||||||
};
|
};
|
||||||
|
int GetAudioDestination()
|
||||||
|
{
|
||||||
|
return (int)audio_destination;
|
||||||
|
}
|
||||||
|
void SetAudioDestination(int audio_dest);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __HDMI_CEC_H__
|
#endif // __HDMI_CEC_H__
|
||||||
|
@@ -1278,3 +1278,13 @@ void cVideo::SetCECAutoView(bool state)
|
|||||||
{
|
{
|
||||||
hdmi_cec::getInstance()->SetCECAutoView(state);
|
hdmi_cec::getInstance()->SetCECAutoView(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cVideo::GetAudioDestination()
|
||||||
|
{
|
||||||
|
return (int)hdmi_cec::getInstance()->GetAudioDestination();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cVideo::SetAudioDestination(int audio_dest)
|
||||||
|
{
|
||||||
|
hdmi_cec::getInstance()->SetAudioDestination(audio_dest);
|
||||||
|
}
|
@@ -126,6 +126,12 @@ typedef enum {
|
|||||||
VIDEO_HDMI_CEC_MODE_RECORDER = 1
|
VIDEO_HDMI_CEC_MODE_RECORDER = 1
|
||||||
} VIDEO_HDMI_CEC_MODE;
|
} VIDEO_HDMI_CEC_MODE;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIDEO_HDMI_CEC_VOL_OFF = 0,
|
||||||
|
VIDEO_HDMI_CEC_VOL_AUDIOSYSTEM = 1,
|
||||||
|
VIDEO_HDMI_CEC_VOL_TV = 2
|
||||||
|
} VIDEO_HDMI_CEC_VOL;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
VIDEO_CONTROL_BRIGHTNESS = 0,
|
VIDEO_CONTROL_BRIGHTNESS = 0,
|
||||||
@@ -234,7 +240,8 @@ class cVideo
|
|||||||
bool SetCECMode(VIDEO_HDMI_CEC_MODE);
|
bool SetCECMode(VIDEO_HDMI_CEC_MODE);
|
||||||
void SetCECAutoView(bool);
|
void SetCECAutoView(bool);
|
||||||
void SetCECAutoStandby(bool);
|
void SetCECAutoStandby(bool);
|
||||||
void ShowPicture(const char * fname);
|
int GetAudioDestination();
|
||||||
|
void SetAudioDestination(int audio_dest);
|
||||||
void StopPicture();
|
void StopPicture();
|
||||||
void Standby(unsigned int bOn);
|
void Standby(unsigned int bOn);
|
||||||
void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600, int startx = 0, int starty = 0, int endx = 1279, int endy = 719);
|
void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600, int startx = 0, int starty = 0, int endx = 1279, int endy = 719);
|
||||||
|
Reference in New Issue
Block a user