mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
@@ -92,7 +92,15 @@ int map_volume(const int volume)
|
|||||||
if (vol > 100)
|
if (vol > 100)
|
||||||
vol = 100;
|
vol = 100;
|
||||||
|
|
||||||
|
// convert to -1dB steps
|
||||||
vol = 63 - vol * 63 / 100;
|
vol = 63 - vol * 63 / 100;
|
||||||
|
// now range is 63..0, where 0 is loudest
|
||||||
|
|
||||||
|
#if BOXMODEL_VUPLUS4K
|
||||||
|
if (vol == 63)
|
||||||
|
vol = 255;
|
||||||
|
#endif
|
||||||
|
|
||||||
return vol;
|
return vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,10 +111,8 @@ int cAudio::setVolume(unsigned int left, unsigned int right)
|
|||||||
volume = (left + right) / 2;
|
volume = (left + right) / 2;
|
||||||
int v = map_volume(volume);
|
int v = map_volume(volume);
|
||||||
|
|
||||||
// convert to -1dB steps
|
|
||||||
left = map_volume(volume);
|
left = map_volume(volume);
|
||||||
right = map_volume(volume);
|
right = map_volume(volume);
|
||||||
//now range is 63..0, where 0 is loudest
|
|
||||||
|
|
||||||
audio_mixer_t mixer;
|
audio_mixer_t mixer;
|
||||||
|
|
||||||
|
@@ -60,6 +60,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
#define CEC_DEVICE "/dev/cec0"
|
#define CEC_DEVICE "/dev/cec0"
|
||||||
|
#define CEC_HDMIDEVICE "/dev/hdmi_cec"
|
||||||
#define RC_DEVICE "/dev/input/event1"
|
#define RC_DEVICE "/dev/input/event1"
|
||||||
|
|
||||||
hdmi_cec * hdmi_cec::hdmi_cec_instance = NULL;
|
hdmi_cec * hdmi_cec::hdmi_cec_instance = NULL;
|
||||||
@@ -72,6 +73,7 @@ hdmi_cec::hdmi_cec()
|
|||||||
standby_cec_activ = autoview_cec_activ = standby = muted = false;
|
standby_cec_activ = autoview_cec_activ = standby = muted = false;
|
||||||
hdmiFd = -1;
|
hdmiFd = -1;
|
||||||
volume = 0;
|
volume = 0;
|
||||||
|
hdmi_mode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hdmi_cec::~hdmi_cec()
|
hdmi_cec::~hdmi_cec()
|
||||||
@@ -193,15 +195,39 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hdmiFd == -1)
|
||||||
|
{
|
||||||
|
hdmiFd = open(CEC_HDMIDEVICE, O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||||
|
if (hdmiFd >= 0)
|
||||||
|
{
|
||||||
|
hdmi_mode = true;
|
||||||
|
|
||||||
|
::ioctl(hdmiFd, 0);
|
||||||
|
|
||||||
|
GetCECAddressInfo();
|
||||||
|
|
||||||
|
if(autoview_cec_activ)
|
||||||
|
SetCECState(false);
|
||||||
|
|
||||||
|
Start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hdmi_cec::GetCECAddressInfo()
|
void hdmi_cec::GetCECAddressInfo()
|
||||||
{
|
{
|
||||||
if (hdmiFd >= 0)
|
struct addressinfo addressinfo;
|
||||||
{
|
|
||||||
struct addressinfo addressinfo;
|
|
||||||
|
|
||||||
|
if (hdmi_mode)
|
||||||
|
{
|
||||||
|
::ioctl(hdmiFd, 1, &addressinfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
__u16 phys_addr;
|
__u16 phys_addr;
|
||||||
struct cec_log_addrs laddrs = {};
|
struct cec_log_addrs laddrs = {};
|
||||||
|
|
||||||
@@ -234,15 +260,15 @@ void hdmi_cec::GetCECAddressInfo()
|
|||||||
addressinfo.type = CEC_LOG_ADDR_UNREGISTERED;
|
addressinfo.type = CEC_LOG_ADDR_UNREGISTERED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
deviceType = addressinfo.type;
|
deviceType = addressinfo.type;
|
||||||
logicalAddress = addressinfo.logical;
|
logicalAddress = addressinfo.logical;
|
||||||
if (memcmp(physicalAddress, addressinfo.physical, sizeof(physicalAddress)))
|
if (memcmp(physicalAddress, addressinfo.physical, sizeof(physicalAddress)))
|
||||||
{
|
{
|
||||||
hal_info("[CEC] %s: detected physical address change: %02X%02X --> %02X%02X\n", __func__, physicalAddress[0], physicalAddress[1], addressinfo.physical[0], addressinfo.physical[1]);
|
hal_info("[CEC] %s: detected physical address change: %02X%02X --> %02X%02X\n", __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();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,11 +295,18 @@ void hdmi_cec::SendCECMessage(struct cec_message &txmessage)
|
|||||||
sprintf(str+(i*6),"[0x%02X]", txmessage.data[i]);
|
sprintf(str+(i*6),"[0x%02X]", txmessage.data[i]);
|
||||||
}
|
}
|
||||||
hal_info("[CEC] send message %s to %s (0x%02X>>0x%02X) '%s' (%s)\n",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("[CEC] send message %s to %s (0x%02X>>0x%02X) '%s' (%s)\n",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);
|
||||||
struct cec_msg msg;
|
if (hdmi_mode)
|
||||||
cec_msg_init(&msg, txmessage.initiator, txmessage.destination);
|
{
|
||||||
memcpy(&msg.msg[1], txmessage.data, txmessage.length);
|
::write(hdmiFd, &txmessage, 2 + txmessage.length);
|
||||||
msg.len = txmessage.length + 1;
|
}
|
||||||
ioctl(hdmiFd, CEC_TRANSMIT, &msg);
|
else
|
||||||
|
{
|
||||||
|
struct cec_msg msg;
|
||||||
|
cec_msg_init(&msg, txmessage.initiator, txmessage.destination);
|
||||||
|
memcpy(&msg.msg[1], txmessage.data, txmessage.length);
|
||||||
|
msg.len = txmessage.length + 1;
|
||||||
|
ioctl(hdmiFd, CEC_TRANSMIT, &msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,15 +533,28 @@ void hdmi_cec::Receive()
|
|||||||
struct cec_message rxmessage;
|
struct cec_message rxmessage;
|
||||||
struct cec_message txmessage;
|
struct cec_message txmessage;
|
||||||
|
|
||||||
struct cec_msg msg;
|
if (hdmi_mode)
|
||||||
if (::ioctl(hdmiFd, CEC_RECEIVE, &msg) >= 0)
|
|
||||||
{
|
{
|
||||||
rxmessage.length = msg.len - 1;
|
if (::read(hdmiFd, &rxmessage, 2) == 2)
|
||||||
rxmessage.initiator = cec_msg_initiator(&msg);
|
{
|
||||||
rxmessage.destination = cec_msg_destination(&msg);
|
if (::read(hdmiFd, &rxmessage.data, rxmessage.length) == rxmessage.length)
|
||||||
rxmessage.opcode = cec_msg_opcode(&msg);
|
{
|
||||||
memcpy(&rxmessage.data, &msg.msg[1], rxmessage.length);
|
hasdata = true;
|
||||||
hasdata = true;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct cec_msg msg;
|
||||||
|
if (::ioctl(hdmiFd, CEC_RECEIVE, &msg) >= 0)
|
||||||
|
{
|
||||||
|
rxmessage.length = msg.len - 1;
|
||||||
|
rxmessage.initiator = cec_msg_initiator(&msg);
|
||||||
|
rxmessage.destination = cec_msg_destination(&msg);
|
||||||
|
rxmessage.opcode = cec_msg_opcode(&msg);
|
||||||
|
memcpy(&rxmessage.data, &msg.msg[1], rxmessage.length);
|
||||||
|
hasdata = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasdata)
|
if (hasdata)
|
||||||
|
@@ -70,6 +70,7 @@ private:
|
|||||||
void request_audio_status();
|
void request_audio_status();
|
||||||
bool muted;
|
bool muted;
|
||||||
int volume;
|
int volume;
|
||||||
|
bool hdmi_mode;
|
||||||
protected:
|
protected:
|
||||||
bool running;
|
bool running;
|
||||||
public:
|
public:
|
||||||
|
Reference in New Issue
Block a user