From ca25b72ba61036d5b3cd0528a963c3a62918f27d Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sun, 7 Oct 2018 22:21:38 +0200 Subject: [PATCH 1/4] libarmbox: hdmi_cec add some more output Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/73a8a5078657531c135de4657fc3134a758acc28 Author: TangoCash Date: 2018-10-07 (Sun, 07 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 26 +- libarmbox/hdmi_cec_types.h | 600 +++++++++++++++++++++++++++++++++++++ 2 files changed, 619 insertions(+), 7 deletions(-) create mode 100644 libarmbox/hdmi_cec_types.h diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index ddea9b6..a45597d 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -33,8 +33,12 @@ #include "linux-uapi-cec.h" #include "hdmi_cec.h" +#include "hdmi_cec_types.h" #include "lt_debug.h" +#define RED "\x1B[31m" +#define NORMAL "\x1B[0m" + #define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args) #define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args) #define lt_debug_c(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, NULL, args) @@ -250,9 +254,9 @@ void hdmi_cec::SendCECMessage(struct cec_message &txmessage) char str[txmessage.length*6]; for (int i = 0; i < txmessage.length; i++) { - sprintf(str+(i*6),"(0x%02X)", txmessage.data[i]); + sprintf(str+(i*6),"[0x%02X]", txmessage.data[i]); } - lt_info("[CEC] send message %s\n",str); + lt_info("[CEC] send message '%s' (%s)\n", ToString((cec_opcode)txmessage.data[0]), str); struct cec_msg msg; cec_msg_init(&msg, logicalAddress, txmessage.address); memcpy(&msg.msg[1], txmessage.data, txmessage.length); @@ -474,21 +478,29 @@ void hdmi_cec::Receive() char str[rxmessage.length*6]; for (int i = 0; i < rxmessage.length; i++) { - sprintf(str+(i*6),"(0x%02X)", rxmessage.data[i]); + sprintf(str+(i*6),"[0x%02X]", rxmessage.data[i]); } - lt_info("[CEC] received message %s\n", str); + lt_info("[CEC] received message '%s' (%s)\n", ToString((cec_opcode)rxmessage.data[0]), str); switch (rxmessage.data[0]) { - case 0x44: /* key pressed */ + case CEC_MSG_DEVICE_VENDOR_ID: + { + uint64_t iVendorId = ((uint64_t)rxmessage.data[1] << 16) + + ((uint64_t)rxmessage.data[2] << 8) + + (uint64_t)rxmessage.data[3]; + lt_info("[CEC] decoded message '%s' (%s)\n", ToString((cec_opcode)rxmessage.data[0]), ToString((cec_vendor_id)iVendorId)); + break; + } + case CEC_MSG_USER_CONTROL_PRESSED: /* key pressed */ keypressed = true; pressedkey = rxmessage.data[1]; - case 0x45: /* key released */ + case CEC_MSG_USER_CONTROL_RELEASED: /* key released */ { long code = translateKey(pressedkey); if (keypressed) code |= 0x80000000; - lt_info("[CEC] received key %ld\n",code); + lt_info("[CEC] decoded key %s (%ld)\n",ToString((cec_user_control_code)pressedkey), code); break; } } diff --git a/libarmbox/hdmi_cec_types.h b/libarmbox/hdmi_cec_types.h new file mode 100644 index 0000000..f5808af --- /dev/null +++ b/libarmbox/hdmi_cec_types.h @@ -0,0 +1,600 @@ +typedef enum cec_vendor_id +{ + CEC_VENDOR_TOSHIBA = 0x000039, + CEC_VENDOR_SAMSUNG = 0x0000F0, + CEC_VENDOR_DENON = 0x0005CD, + CEC_VENDOR_MARANTZ = 0x000678, + CEC_VENDOR_LOEWE = 0x000982, + CEC_VENDOR_ONKYO = 0x0009B0, + CEC_VENDOR_MEDION = 0x000CB8, + CEC_VENDOR_TOSHIBA2 = 0x000CE7, + CEC_VENDOR_PULSE_EIGHT = 0x001582, + CEC_VENDOR_HARMAN_KARDON2 = 0x001950, + CEC_VENDOR_GOOGLE = 0x001A11, + CEC_VENDOR_AKAI = 0x0020C7, + CEC_VENDOR_AOC = 0x002467, + CEC_VENDOR_PANASONIC = 0x008045, + CEC_VENDOR_PHILIPS = 0x00903E, + CEC_VENDOR_DAEWOO = 0x009053, + CEC_VENDOR_YAMAHA = 0x00A0DE, + CEC_VENDOR_GRUNDIG = 0x00D0D5, + CEC_VENDOR_PIONEER = 0x00E036, + CEC_VENDOR_LG = 0x00E091, + CEC_VENDOR_SHARP = 0x08001F, + CEC_VENDOR_SONY = 0x080046, + CEC_VENDOR_BROADCOM = 0x18C086, + CEC_VENDOR_SHARP2 = 0x534850, + CEC_VENDOR_VIZIO = 0x6B746D, + CEC_VENDOR_BENQ = 0x8065E9, + CEC_VENDOR_HARMAN_KARDON = 0x9C645E, + CEC_VENDOR_UNKNOWN = 0 +} cec_vendor_id; + +typedef enum cec_user_control_code +{ + CEC_USER_CONTROL_CODE_SELECT = 0x00, + CEC_USER_CONTROL_CODE_UP = 0x01, + CEC_USER_CONTROL_CODE_DOWN = 0x02, + CEC_USER_CONTROL_CODE_LEFT = 0x03, + CEC_USER_CONTROL_CODE_RIGHT = 0x04, + CEC_USER_CONTROL_CODE_RIGHT_UP = 0x05, + CEC_USER_CONTROL_CODE_RIGHT_DOWN = 0x06, + CEC_USER_CONTROL_CODE_LEFT_UP = 0x07, + CEC_USER_CONTROL_CODE_LEFT_DOWN = 0x08, + CEC_USER_CONTROL_CODE_ROOT_MENU = 0x09, + CEC_USER_CONTROL_CODE_SETUP_MENU = 0x0A, + CEC_USER_CONTROL_CODE_CONTENTS_MENU = 0x0B, + CEC_USER_CONTROL_CODE_FAVORITE_MENU = 0x0C, + CEC_USER_CONTROL_CODE_EXIT = 0x0D, + // reserved: 0x0E, 0x0F + CEC_USER_CONTROL_CODE_TOP_MENU = 0x10, + CEC_USER_CONTROL_CODE_DVD_MENU = 0x11, + // reserved: 0x12 ... 0x1C + CEC_USER_CONTROL_CODE_NUMBER_ENTRY_MODE = 0x1D, + CEC_USER_CONTROL_CODE_NUMBER11 = 0x1E, + CEC_USER_CONTROL_CODE_NUMBER12 = 0x1F, + CEC_USER_CONTROL_CODE_NUMBER0 = 0x20, + CEC_USER_CONTROL_CODE_NUMBER1 = 0x21, + CEC_USER_CONTROL_CODE_NUMBER2 = 0x22, + CEC_USER_CONTROL_CODE_NUMBER3 = 0x23, + CEC_USER_CONTROL_CODE_NUMBER4 = 0x24, + CEC_USER_CONTROL_CODE_NUMBER5 = 0x25, + CEC_USER_CONTROL_CODE_NUMBER6 = 0x26, + CEC_USER_CONTROL_CODE_NUMBER7 = 0x27, + CEC_USER_CONTROL_CODE_NUMBER8 = 0x28, + CEC_USER_CONTROL_CODE_NUMBER9 = 0x29, + CEC_USER_CONTROL_CODE_DOT = 0x2A, + CEC_USER_CONTROL_CODE_ENTER = 0x2B, + CEC_USER_CONTROL_CODE_CLEAR = 0x2C, + CEC_USER_CONTROL_CODE_NEXT_FAVORITE = 0x2F, + CEC_USER_CONTROL_CODE_CHANNEL_UP = 0x30, + CEC_USER_CONTROL_CODE_CHANNEL_DOWN = 0x31, + CEC_USER_CONTROL_CODE_PREVIOUS_CHANNEL = 0x32, + CEC_USER_CONTROL_CODE_SOUND_SELECT = 0x33, + CEC_USER_CONTROL_CODE_INPUT_SELECT = 0x34, + CEC_USER_CONTROL_CODE_DISPLAY_INFORMATION = 0x35, + CEC_USER_CONTROL_CODE_HELP = 0x36, + CEC_USER_CONTROL_CODE_PAGE_UP = 0x37, + CEC_USER_CONTROL_CODE_PAGE_DOWN = 0x38, + // reserved: 0x39 ... 0x3F + CEC_USER_CONTROL_CODE_POWER = 0x40, + CEC_USER_CONTROL_CODE_VOLUME_UP = 0x41, + CEC_USER_CONTROL_CODE_VOLUME_DOWN = 0x42, + CEC_USER_CONTROL_CODE_MUTE = 0x43, + CEC_USER_CONTROL_CODE_PLAY = 0x44, + CEC_USER_CONTROL_CODE_STOP = 0x45, + CEC_USER_CONTROL_CODE_PAUSE = 0x46, + CEC_USER_CONTROL_CODE_RECORD = 0x47, + CEC_USER_CONTROL_CODE_REWIND = 0x48, + CEC_USER_CONTROL_CODE_FAST_FORWARD = 0x49, + CEC_USER_CONTROL_CODE_EJECT = 0x4A, + CEC_USER_CONTROL_CODE_FORWARD = 0x4B, + CEC_USER_CONTROL_CODE_BACKWARD = 0x4C, + CEC_USER_CONTROL_CODE_STOP_RECORD = 0x4D, + CEC_USER_CONTROL_CODE_PAUSE_RECORD = 0x4E, + // reserved: 0x4F + CEC_USER_CONTROL_CODE_ANGLE = 0x50, + CEC_USER_CONTROL_CODE_SUB_PICTURE = 0x51, + CEC_USER_CONTROL_CODE_VIDEO_ON_DEMAND = 0x52, + CEC_USER_CONTROL_CODE_ELECTRONIC_PROGRAM_GUIDE = 0x53, + CEC_USER_CONTROL_CODE_TIMER_PROGRAMMING = 0x54, + CEC_USER_CONTROL_CODE_INITIAL_CONFIGURATION = 0x55, + CEC_USER_CONTROL_CODE_SELECT_BROADCAST_TYPE = 0x56, + CEC_USER_CONTROL_CODE_SELECT_SOUND_PRESENTATION = 0x57, + // reserved: 0x58 ... 0x5F + CEC_USER_CONTROL_CODE_PLAY_FUNCTION = 0x60, + CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION = 0x61, + CEC_USER_CONTROL_CODE_RECORD_FUNCTION = 0x62, + CEC_USER_CONTROL_CODE_PAUSE_RECORD_FUNCTION = 0x63, + CEC_USER_CONTROL_CODE_STOP_FUNCTION = 0x64, + CEC_USER_CONTROL_CODE_MUTE_FUNCTION = 0x65, + CEC_USER_CONTROL_CODE_RESTORE_VOLUME_FUNCTION = 0x66, + CEC_USER_CONTROL_CODE_TUNE_FUNCTION = 0x67, + CEC_USER_CONTROL_CODE_SELECT_MEDIA_FUNCTION = 0x68, + CEC_USER_CONTROL_CODE_SELECT_AV_INPUT_FUNCTION = 0x69, + CEC_USER_CONTROL_CODE_SELECT_AUDIO_INPUT_FUNCTION = 0x6A, + CEC_USER_CONTROL_CODE_POWER_TOGGLE_FUNCTION = 0x6B, + CEC_USER_CONTROL_CODE_POWER_OFF_FUNCTION = 0x6C, + CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION = 0x6D, + // reserved: 0x6E ... 0x70 + CEC_USER_CONTROL_CODE_F1_BLUE = 0x71, + CEC_USER_CONTROL_CODE_F2_RED = 0X72, + CEC_USER_CONTROL_CODE_F3_GREEN = 0x73, + CEC_USER_CONTROL_CODE_F4_YELLOW = 0x74, + CEC_USER_CONTROL_CODE_F5 = 0x75, + CEC_USER_CONTROL_CODE_DATA = 0x76, + // reserved: 0x77 ... 0xFF + CEC_USER_CONTROL_CODE_AN_RETURN = 0x91, // return (Samsung) + CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST = 0x96, // channels list (Samsung) + CEC_USER_CONTROL_CODE_MAX = 0x96, + CEC_USER_CONTROL_CODE_UNKNOWN = 0xFF +} cec_user_control_code; + +typedef enum cec_opcode +{ + CEC_OPCODE_ACTIVE_SOURCE = 0x82, + CEC_OPCODE_IMAGE_VIEW_ON = 0x04, + CEC_OPCODE_TEXT_VIEW_ON = 0x0D, + CEC_OPCODE_INACTIVE_SOURCE = 0x9D, + CEC_OPCODE_REQUEST_ACTIVE_SOURCE = 0x85, + CEC_OPCODE_ROUTING_CHANGE = 0x80, + CEC_OPCODE_ROUTING_INFORMATION = 0x81, + CEC_OPCODE_SET_STREAM_PATH = 0x86, + CEC_OPCODE_STANDBY = 0x36, + CEC_OPCODE_RECORD_OFF = 0x0B, + CEC_OPCODE_RECORD_ON = 0x09, + CEC_OPCODE_RECORD_STATUS = 0x0A, + CEC_OPCODE_RECORD_TV_SCREEN = 0x0F, + CEC_OPCODE_CLEAR_ANALOGUE_TIMER = 0x33, + CEC_OPCODE_CLEAR_DIGITAL_TIMER = 0x99, + CEC_OPCODE_CLEAR_EXTERNAL_TIMER = 0xA1, + CEC_OPCODE_SET_ANALOGUE_TIMER = 0x34, + CEC_OPCODE_SET_DIGITAL_TIMER = 0x97, + CEC_OPCODE_SET_EXTERNAL_TIMER = 0xA2, + CEC_OPCODE_SET_TIMER_PROGRAM_TITLE = 0x67, + CEC_OPCODE_TIMER_CLEARED_STATUS = 0x43, + CEC_OPCODE_TIMER_STATUS = 0x35, + CEC_OPCODE_CEC_VERSION = 0x9E, + CEC_OPCODE_GET_CEC_VERSION = 0x9F, + CEC_OPCODE_GIVE_PHYSICAL_ADDRESS = 0x83, + CEC_OPCODE_GET_MENU_LANGUAGE = 0x91, + CEC_OPCODE_REPORT_PHYSICAL_ADDRESS = 0x84, + CEC_OPCODE_SET_MENU_LANGUAGE = 0x32, + CEC_OPCODE_DECK_CONTROL = 0x42, + CEC_OPCODE_DECK_STATUS = 0x1B, + CEC_OPCODE_GIVE_DECK_STATUS = 0x1A, + CEC_OPCODE_PLAY = 0x41, + CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS = 0x08, + CEC_OPCODE_SELECT_ANALOGUE_SERVICE = 0x92, + CEC_OPCODE_SELECT_DIGITAL_SERVICE = 0x93, + CEC_OPCODE_TUNER_DEVICE_STATUS = 0x07, + CEC_OPCODE_TUNER_STEP_DECREMENT = 0x06, + CEC_OPCODE_TUNER_STEP_INCREMENT = 0x05, + CEC_OPCODE_DEVICE_VENDOR_ID = 0x87, + CEC_OPCODE_GIVE_DEVICE_VENDOR_ID = 0x8C, + CEC_OPCODE_VENDOR_COMMAND = 0x89, + CEC_OPCODE_VENDOR_COMMAND_WITH_ID = 0xA0, + CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A, + CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP = 0x8B, + CEC_OPCODE_SET_OSD_STRING = 0x64, + CEC_OPCODE_GIVE_OSD_NAME = 0x46, + CEC_OPCODE_SET_OSD_NAME = 0x47, + CEC_OPCODE_MENU_REQUEST = 0x8D, + CEC_OPCODE_MENU_STATUS = 0x8E, + CEC_OPCODE_USER_CONTROL_PRESSED = 0x44, + CEC_OPCODE_USER_CONTROL_RELEASE = 0x45, + CEC_OPCODE_GIVE_DEVICE_POWER_STATUS = 0x8F, + CEC_OPCODE_REPORT_POWER_STATUS = 0x90, + CEC_OPCODE_FEATURE_ABORT = 0x00, + CEC_OPCODE_ABORT = 0xFF, + CEC_OPCODE_GIVE_AUDIO_STATUS = 0x71, + CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D, + CEC_OPCODE_REPORT_AUDIO_STATUS = 0x7A, + CEC_OPCODE_SET_SYSTEM_AUDIO_MODE = 0x72, + CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST = 0x70, + CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS = 0x7E, + CEC_OPCODE_SET_AUDIO_RATE = 0x9A, + + /* CEC 1.4 */ + CEC_OPCODE_START_ARC = 0xC0, + CEC_OPCODE_REPORT_ARC_STARTED = 0xC1, + CEC_OPCODE_REPORT_ARC_ENDED = 0xC2, + CEC_OPCODE_REQUEST_ARC_START = 0xC3, + CEC_OPCODE_REQUEST_ARC_END = 0xC4, + CEC_OPCODE_END_ARC = 0xC5, + CEC_OPCODE_CDC = 0xF8, + /* when this opcode is set, no opcode will be sent to the device. this is one of the reserved numbers */ + CEC_OPCODE_NONE = 0xFD +} cec_opcode; + +static const char *ToString(const cec_opcode opcode) +{ + switch (opcode) + { + case CEC_OPCODE_ACTIVE_SOURCE: + return "active source"; + case CEC_OPCODE_IMAGE_VIEW_ON: + return "image view on"; + case CEC_OPCODE_TEXT_VIEW_ON: + return "text view on"; + case CEC_OPCODE_INACTIVE_SOURCE: + return "inactive source"; + case CEC_OPCODE_REQUEST_ACTIVE_SOURCE: + return "request active source"; + case CEC_OPCODE_ROUTING_CHANGE: + return "routing change"; + case CEC_OPCODE_ROUTING_INFORMATION: + return "routing information"; + case CEC_OPCODE_SET_STREAM_PATH: + return "set stream path"; + case CEC_OPCODE_STANDBY: + return "standby"; + case CEC_OPCODE_RECORD_OFF: + return "record off"; + case CEC_OPCODE_RECORD_ON: + return "record on"; + case CEC_OPCODE_RECORD_STATUS: + return "record status"; + case CEC_OPCODE_RECORD_TV_SCREEN: + return "record tv screen"; + case CEC_OPCODE_CLEAR_ANALOGUE_TIMER: + return "clear analogue timer"; + case CEC_OPCODE_CLEAR_DIGITAL_TIMER: + return "clear digital timer"; + case CEC_OPCODE_CLEAR_EXTERNAL_TIMER: + return "clear external timer"; + case CEC_OPCODE_SET_ANALOGUE_TIMER: + return "set analogue timer"; + case CEC_OPCODE_SET_DIGITAL_TIMER: + return "set digital timer"; + case CEC_OPCODE_SET_EXTERNAL_TIMER: + return "set external timer"; + case CEC_OPCODE_SET_TIMER_PROGRAM_TITLE: + return "set timer program title"; + case CEC_OPCODE_TIMER_CLEARED_STATUS: + return "timer cleared status"; + case CEC_OPCODE_TIMER_STATUS: + return "timer status"; + case CEC_OPCODE_CEC_VERSION: + return "cec version"; + case CEC_OPCODE_GET_CEC_VERSION: + return "get cec version"; + case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS: + return "give physical address"; + case CEC_OPCODE_GET_MENU_LANGUAGE: + return "get menu language"; + case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS: + return "report physical address"; + case CEC_OPCODE_SET_MENU_LANGUAGE: + return "set menu language"; + case CEC_OPCODE_DECK_CONTROL: + return "deck control"; + case CEC_OPCODE_DECK_STATUS: + return "deck status"; + case CEC_OPCODE_GIVE_DECK_STATUS: + return "give deck status"; + case CEC_OPCODE_PLAY: + return "play"; + case CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS: + return "give tuner status"; + case CEC_OPCODE_SELECT_ANALOGUE_SERVICE: + return "select analogue service"; + case CEC_OPCODE_SELECT_DIGITAL_SERVICE: + return "set digital service"; + case CEC_OPCODE_TUNER_DEVICE_STATUS: + return "tuner device status"; + case CEC_OPCODE_TUNER_STEP_DECREMENT: + return "tuner step decrement"; + case CEC_OPCODE_TUNER_STEP_INCREMENT: + return "tuner step increment"; + case CEC_OPCODE_DEVICE_VENDOR_ID: + return "device vendor id"; + case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID: + return "give device vendor id"; + case CEC_OPCODE_VENDOR_COMMAND: + return "vendor command"; + case CEC_OPCODE_VENDOR_COMMAND_WITH_ID: + return "vendor command with id"; + case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN: + return "vendor remote button down"; + case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP: + return "vendor remote button up"; + case CEC_OPCODE_SET_OSD_STRING: + return "set osd string"; + case CEC_OPCODE_GIVE_OSD_NAME: + return "give osd name"; + case CEC_OPCODE_SET_OSD_NAME: + return "set osd name"; + case CEC_OPCODE_MENU_REQUEST: + return "menu request"; + case CEC_OPCODE_MENU_STATUS: + return "menu status"; + case CEC_OPCODE_USER_CONTROL_PRESSED: + return "user control pressed"; + case CEC_OPCODE_USER_CONTROL_RELEASE: + return "user control release"; + case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS: + return "give device power status"; + case CEC_OPCODE_REPORT_POWER_STATUS: + return "report power status"; + case CEC_OPCODE_FEATURE_ABORT: + return "feature abort"; + case CEC_OPCODE_ABORT: + return "abort"; + case CEC_OPCODE_GIVE_AUDIO_STATUS: + return "give audio status"; + case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS: + return "give audio mode status"; + case CEC_OPCODE_REPORT_AUDIO_STATUS: + return "report audio status"; + case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE: + return "set system audio mode"; + case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST: + return "system audio mode request"; + case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS: + return "system audio mode status"; + case CEC_OPCODE_SET_AUDIO_RATE: + return "set audio rate"; + case CEC_OPCODE_START_ARC: + return "start ARC"; + case CEC_OPCODE_REPORT_ARC_STARTED: + return "report ARC started"; + case CEC_OPCODE_REPORT_ARC_ENDED: + return "report ARC ended"; + case CEC_OPCODE_REQUEST_ARC_START: + return "request ARC start"; + case CEC_OPCODE_REQUEST_ARC_END: + return "request ARC end"; + case CEC_OPCODE_END_ARC: + return "end ARC"; + case CEC_OPCODE_CDC: + return "CDC"; + case CEC_OPCODE_NONE: + return "poll"; + default: + return "UNKNOWN"; + } +} + +static const char *ToString(const cec_vendor_id vendor) +{ + switch (vendor) + { + case CEC_VENDOR_SAMSUNG: + return "Samsung"; + case CEC_VENDOR_LG: + return "LG"; + case CEC_VENDOR_PANASONIC: + return "Panasonic"; + case CEC_VENDOR_PIONEER: + return "Pioneer"; + case CEC_VENDOR_ONKYO: + return "Onkyo"; + case CEC_VENDOR_YAMAHA: + return "Yamaha"; + case CEC_VENDOR_PHILIPS: + return "Philips"; + case CEC_VENDOR_SONY: + return "Sony"; + case CEC_VENDOR_TOSHIBA: + case CEC_VENDOR_TOSHIBA2: + return "Toshiba"; + case CEC_VENDOR_AKAI: + return "Akai"; + case CEC_VENDOR_AOC: + return "AOC"; + case CEC_VENDOR_BENQ: + return "Benq"; + case CEC_VENDOR_DAEWOO: + return "Daewoo"; + case CEC_VENDOR_GRUNDIG: + return "Grundig"; + case CEC_VENDOR_MEDION: + return "Medion"; + case CEC_VENDOR_SHARP: + case CEC_VENDOR_SHARP2: + return "Sharp"; + case CEC_VENDOR_VIZIO: + return "Vizio"; + case CEC_VENDOR_BROADCOM: + return "Broadcom"; + case CEC_VENDOR_LOEWE: + return "Loewe"; + case CEC_VENDOR_DENON: + return "Denon"; + case CEC_VENDOR_MARANTZ: + return "Marantz"; + case CEC_VENDOR_HARMAN_KARDON: + case CEC_VENDOR_HARMAN_KARDON2: + return "Harman/Kardon"; + case CEC_VENDOR_PULSE_EIGHT: + return "Pulse Eight"; + case CEC_VENDOR_GOOGLE: + return "Google"; + default: + return "Unknown"; + } +} + +static const char *ToString(const cec_user_control_code key) +{ + switch (key) + { + case CEC_USER_CONTROL_CODE_SELECT: + return "select"; + case CEC_USER_CONTROL_CODE_UP: + return "up"; + case CEC_USER_CONTROL_CODE_DOWN: + return "down"; + case CEC_USER_CONTROL_CODE_LEFT: + return "left"; + case CEC_USER_CONTROL_CODE_RIGHT: + return "right"; + case CEC_USER_CONTROL_CODE_RIGHT_UP: + return "right+up"; + case CEC_USER_CONTROL_CODE_RIGHT_DOWN: + return "right+down"; + case CEC_USER_CONTROL_CODE_LEFT_UP: + return "left+up"; + case CEC_USER_CONTROL_CODE_LEFT_DOWN: + return "left+down"; + case CEC_USER_CONTROL_CODE_ROOT_MENU: + return "root menu"; + case CEC_USER_CONTROL_CODE_SETUP_MENU: + return "setup menu"; + case CEC_USER_CONTROL_CODE_CONTENTS_MENU: + return "contents menu"; + case CEC_USER_CONTROL_CODE_FAVORITE_MENU: + return "favourite menu"; + case CEC_USER_CONTROL_CODE_EXIT: + return "exit"; + case CEC_USER_CONTROL_CODE_TOP_MENU: + return "top menu"; + case CEC_USER_CONTROL_CODE_DVD_MENU: + return "dvd menu"; + case CEC_USER_CONTROL_CODE_NUMBER_ENTRY_MODE: + return "number entry mode"; + case CEC_USER_CONTROL_CODE_NUMBER11: + return "11"; + case CEC_USER_CONTROL_CODE_NUMBER12: + return "12"; + case CEC_USER_CONTROL_CODE_NUMBER0: + return "0"; + case CEC_USER_CONTROL_CODE_NUMBER1: + return "1"; + case CEC_USER_CONTROL_CODE_NUMBER2: + return "2"; + case CEC_USER_CONTROL_CODE_NUMBER3: + return "3"; + case CEC_USER_CONTROL_CODE_NUMBER4: + return "4"; + case CEC_USER_CONTROL_CODE_NUMBER5: + return "5"; + case CEC_USER_CONTROL_CODE_NUMBER6: + return "6"; + case CEC_USER_CONTROL_CODE_NUMBER7: + return "7"; + case CEC_USER_CONTROL_CODE_NUMBER8: + return "8"; + case CEC_USER_CONTROL_CODE_NUMBER9: + return "9"; + case CEC_USER_CONTROL_CODE_DOT: + return "."; + case CEC_USER_CONTROL_CODE_ENTER: + return "enter"; + case CEC_USER_CONTROL_CODE_CLEAR: + return "clear"; + case CEC_USER_CONTROL_CODE_NEXT_FAVORITE: + return "next favourite"; + case CEC_USER_CONTROL_CODE_CHANNEL_UP: + return "channel up"; + case CEC_USER_CONTROL_CODE_CHANNEL_DOWN: + return "channel down"; + case CEC_USER_CONTROL_CODE_PREVIOUS_CHANNEL: + return "previous channel"; + case CEC_USER_CONTROL_CODE_SOUND_SELECT: + return "sound select"; + case CEC_USER_CONTROL_CODE_INPUT_SELECT: + return "input select"; + case CEC_USER_CONTROL_CODE_DISPLAY_INFORMATION: + return "display information"; + case CEC_USER_CONTROL_CODE_HELP: + return "help"; + case CEC_USER_CONTROL_CODE_PAGE_UP: + return "page up"; + case CEC_USER_CONTROL_CODE_PAGE_DOWN: + return "page down"; + case CEC_USER_CONTROL_CODE_POWER: + return "power"; + case CEC_USER_CONTROL_CODE_VOLUME_UP: + return "volume up"; + case CEC_USER_CONTROL_CODE_VOLUME_DOWN: + return "volume down"; + case CEC_USER_CONTROL_CODE_MUTE: + return "mute"; + case CEC_USER_CONTROL_CODE_PLAY: + return "play"; + case CEC_USER_CONTROL_CODE_STOP: + return "stop"; + case CEC_USER_CONTROL_CODE_PAUSE: + return "pause"; + case CEC_USER_CONTROL_CODE_RECORD: + return "record"; + case CEC_USER_CONTROL_CODE_REWIND: + return "rewind"; + case CEC_USER_CONTROL_CODE_FAST_FORWARD: + return "Fast forward"; + case CEC_USER_CONTROL_CODE_EJECT: + return "eject"; + case CEC_USER_CONTROL_CODE_FORWARD: + return "forward"; + case CEC_USER_CONTROL_CODE_BACKWARD: + return "backward"; + case CEC_USER_CONTROL_CODE_STOP_RECORD: + return "stop record"; + case CEC_USER_CONTROL_CODE_PAUSE_RECORD: + return "pause record"; + case CEC_USER_CONTROL_CODE_ANGLE: + return "angle"; + case CEC_USER_CONTROL_CODE_SUB_PICTURE: + return "sub picture"; + case CEC_USER_CONTROL_CODE_VIDEO_ON_DEMAND: + return "video on demand"; + case CEC_USER_CONTROL_CODE_ELECTRONIC_PROGRAM_GUIDE: + return "electronic program guide"; + case CEC_USER_CONTROL_CODE_TIMER_PROGRAMMING: + return "timer programming"; + case CEC_USER_CONTROL_CODE_INITIAL_CONFIGURATION: + return "initial configuration"; + case CEC_USER_CONTROL_CODE_SELECT_BROADCAST_TYPE: + return "select broadcast type"; + case CEC_USER_CONTROL_CODE_SELECT_SOUND_PRESENTATION: + return "select sound presentation"; + case CEC_USER_CONTROL_CODE_PLAY_FUNCTION: + return "play (function)"; + case CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION: + return "pause play (function)"; + case CEC_USER_CONTROL_CODE_RECORD_FUNCTION: + return "record (function)"; + case CEC_USER_CONTROL_CODE_PAUSE_RECORD_FUNCTION: + return "pause record (function)"; + case CEC_USER_CONTROL_CODE_STOP_FUNCTION: + return "stop (function)"; + case CEC_USER_CONTROL_CODE_MUTE_FUNCTION: + return "mute (function)"; + case CEC_USER_CONTROL_CODE_RESTORE_VOLUME_FUNCTION: + return "restore volume"; + case CEC_USER_CONTROL_CODE_TUNE_FUNCTION: + return "tune"; + case CEC_USER_CONTROL_CODE_SELECT_MEDIA_FUNCTION: + return "select media"; + case CEC_USER_CONTROL_CODE_SELECT_AV_INPUT_FUNCTION: + return "select AV input"; + case CEC_USER_CONTROL_CODE_SELECT_AUDIO_INPUT_FUNCTION: + return "select audio input"; + case CEC_USER_CONTROL_CODE_POWER_TOGGLE_FUNCTION: + return "power toggle"; + case CEC_USER_CONTROL_CODE_POWER_OFF_FUNCTION: + return "power off"; + case CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION: + return "power on"; + case CEC_USER_CONTROL_CODE_F1_BLUE: + return "F1 (blue)"; + case CEC_USER_CONTROL_CODE_F2_RED: + return "F2 (red)"; + case CEC_USER_CONTROL_CODE_F3_GREEN: + return "F3 (green)"; + case CEC_USER_CONTROL_CODE_F4_YELLOW: + return "F4 (yellow)"; + case CEC_USER_CONTROL_CODE_F5: + return "F5"; + case CEC_USER_CONTROL_CODE_DATA: + return "data"; + case CEC_USER_CONTROL_CODE_AN_RETURN: + return "return (Samsung)"; + case CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST: + return "channels list (Samsung)"; + default: + return "unknown"; + } +} From e0811c89bd1e9aa566e3c218af23e34517170272 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sun, 7 Oct 2018 23:00:29 +0200 Subject: [PATCH 2/4] libarmbox: hdmi_cec better readability Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/2658572c2ad11b75e6e39d9ba6386c352a78c9ee Author: TangoCash Date: 2018-10-07 (Sun, 07 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 144 +++++++++++++++++++++-------------------- libarmbox/hdmi_cec.h | 20 ++++++ 2 files changed, 93 insertions(+), 71 deletions(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index a45597d..195887e 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include "linux-uapi-cec.h" #include "hdmi_cec.h" #include "hdmi_cec_types.h" @@ -309,113 +311,113 @@ long hdmi_cec::translateKey(unsigned char code) long key = 0; switch (code) { - case 0x32: - key = 0x8b; + case CEC_USER_CONTROL_CODE_PREVIOUS_CHANNEL: + key = KEY_MENU; break; - case 0x20: - key = 0x0b; + case CEC_USER_CONTROL_CODE_NUMBER0: + key = KEY_0; break; - case 0x21: - key = 0x02; + case CEC_USER_CONTROL_CODE_NUMBER1: + key = KEY_1; break; - case 0x22: - key = 0x03; + case CEC_USER_CONTROL_CODE_NUMBER2: + key = KEY_2; break; - case 0x23: - key = 0x04; + case CEC_USER_CONTROL_CODE_NUMBER3: + key = KEY_3; break; - case 0x24: - key = 0x05; + case CEC_USER_CONTROL_CODE_NUMBER4: + key = KEY_4; break; - case 0x25: - key = 0x06; + case CEC_USER_CONTROL_CODE_NUMBER5: + key = KEY_5; break; - case 0x26: - key = 0x07; + case CEC_USER_CONTROL_CODE_NUMBER6: + key = KEY_6; break; - case 0x27: - key = 0x08; + case CEC_USER_CONTROL_CODE_NUMBER7: + key = KEY_7; break; - case 0x28: - key = 0x09; + case CEC_USER_CONTROL_CODE_NUMBER8: + key = KEY_8; break; - case 0x29: - key = 0x0a; + case CEC_USER_CONTROL_CODE_NUMBER9: + key = KEY_9; break; - case 0x30: - key = 0x192; + case CEC_USER_CONTROL_CODE_CHANNEL_UP: + key = KEY_CHANNELUP; break; - case 0x31: - key = 0x193; + case CEC_USER_CONTROL_CODE_CHANNEL_DOWN: + key = KEY_CHANNELDOWN; break; - case 0x44: - key = 0xcf; + case CEC_USER_CONTROL_CODE_PLAY: + key = KEY_PLAY; break; - case 0x45: - key = 0x80; + case CEC_USER_CONTROL_CODE_STOP: + key = KEY_STOP; break; - case 0x46: - key = 0x77; + case CEC_USER_CONTROL_CODE_PAUSE: + key = KEY_PAUSE; break; - case 0x47: - key = 0xa7; + case CEC_USER_CONTROL_CODE_RECORD: + key = KEY_RECORD; break; - case 0x48: - key = 0xa8; + case CEC_USER_CONTROL_CODE_REWIND: + key = KEY_REWIND; break; - case 0x49: - key = 0xd0; + case CEC_USER_CONTROL_CODE_FAST_FORWARD: + key = KEY_FASTFORWARD; break; - case 0x53: - key = 0x166; + case CEC_USER_CONTROL_CODE_ELECTRONIC_PROGRAM_GUIDE: + key = KEY_INFO; break; - case 0x54: - key = 0x16a; + case CEC_USER_CONTROL_CODE_TIMER_PROGRAMMING: + key = KEY_PROGRAM; break; - case 0x60: - key = 0xcf; + case CEC_USER_CONTROL_CODE_PLAY_FUNCTION: + key = KEY_PLAY; break; - case 0x61: - key = 0xa4; + case CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION: + key = KEY_PLAYPAUSE; break; - case 0x62: - key = 0xa7; + case CEC_USER_CONTROL_CODE_RECORD_FUNCTION: + key = KEY_RECORD; break; - case 0x64: - key = 0x80; + case CEC_USER_CONTROL_CODE_STOP_FUNCTION: + key = KEY_STOP; break; - case 0x00: - key = 0x160; + case CEC_USER_CONTROL_CODE_SELECT: + key = KEY_OK; break; - case 0x03: - key = 0x69; + case CEC_USER_CONTROL_CODE_LEFT: + key = KEY_LEFT; break; - case 0x04: - key = 0x6a; + case CEC_USER_CONTROL_CODE_RIGHT: + key = KEY_RIGHT; break; - case 0x01: - key = 0x67; + case CEC_USER_CONTROL_CODE_UP: + key = KEY_UP; break; - case 0x02: - key = 0x6c; + case CEC_USER_CONTROL_CODE_DOWN: + key = KEY_DOWN; break; - case 0x0d: - key = 0xae; + case CEC_USER_CONTROL_CODE_EXIT: + key = KEY_EXIT; break; - case 0x72: - key = 0x18e; + case CEC_USER_CONTROL_CODE_F2_RED: + key = KEY_RED; break; - case 0x71: - key = 0x191; + case CEC_USER_CONTROL_CODE_F3_GREEN: + key = KEY_GREEN; break; - case 0x73: - key = 0x18f; + case CEC_USER_CONTROL_CODE_F4_YELLOW: + key = KEY_YELLOW; break; - case 0x74: - key = 0x190; + case CEC_USER_CONTROL_CODE_F1_BLUE: + key = KEY_BLUE; break; default: - key = 0x8b; + key = KEY_MENU; break; } return key; diff --git a/libarmbox/hdmi_cec.h b/libarmbox/hdmi_cec.h index 0dc97cb..9654e73 100644 --- a/libarmbox/hdmi_cec.h +++ b/libarmbox/hdmi_cec.h @@ -22,6 +22,26 @@ #include "video_lib.h" +#ifndef KEY_OK +#define KEY_OK 0x160 +#endif + +#ifndef KEY_RED +#define KEY_RED 0x18e +#endif + +#ifndef KEY_GREEN +#define KEY_GREEN 0x18f +#endif + +#ifndef KEY_YELLOW +#define KEY_YELLOW 0x190 +#endif + +#ifndef KEY_BLUE +#define KEY_BLUE 0x191 +#endif + struct cec_message { unsigned char address; From 043eb80d33efae292a804bb00f161790bf4d3392 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Mon, 8 Oct 2018 16:23:15 +0200 Subject: [PATCH 3/4] libarmbox: hdmi_cec fixx segfault on DDT, align log Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/58089348e6435134a1bcbac2b5d2bf3a347f84bb Author: TangoCash Date: 2018-10-08 (Mon, 08 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index 195887e..ef279f3 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -62,6 +62,9 @@ hdmi_cec * hdmi_cec::hdmi_cec_instance = NULL; +//hack to get an instance before first call +hdmi_cec * CEC = hdmi_cec::getInstance(); + hdmi_cec::hdmi_cec() { standby_cec_activ = autoview_cec_activ = false; @@ -80,7 +83,10 @@ hdmi_cec::~hdmi_cec() hdmi_cec* hdmi_cec::getInstance() { if (hdmi_cec_instance == NULL) + { hdmi_cec_instance = new hdmi_cec(); + lt_debug("[CEC] new instance created \n"); + } return hdmi_cec_instance; } @@ -93,13 +99,13 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) if (_deviceType == VIDEO_HDMI_CEC_MODE_OFF) { Stop(); - lt_debug("CEC OFF %s\n", __func__); + lt_debug("[CEC] switch off %s\n", __func__); return false; } else deviceType = _deviceType; - lt_debug("CEC ON %s\n", __func__); + lt_debug("[CEC] switch on %s\n", __func__); if (hdmiFd == -1) { @@ -112,14 +118,14 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) struct cec_caps caps = {}; if (ioctl(hdmiFd, CEC_ADAP_G_CAPS, &caps) < 0) - lt_info("%s: CEC get caps failed (%m)\n", __func__); + lt_info("[CEC] %s: get caps failed (%m)\n", __func__); if (caps.capabilities & CEC_CAP_LOG_ADDRS) { struct cec_log_addrs laddrs = {}; if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0) - lt_info("%s: CEC reset log addr failed (%m)\n", __func__); + lt_info("[CEC] %s: reset log addr failed (%m)\n", __func__); memset(&laddrs, 0, sizeof(laddrs)); @@ -169,11 +175,11 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) laddrs.num_log_addrs++; if (ioctl(hdmiFd, CEC_ADAP_S_LOG_ADDRS, &laddrs) < 0) - lt_info("%s: CEC set log addr failed (%m)\n", __func__); + lt_info("[CEC] %s: et log addr failed (%m)\n", __func__); } if (ioctl(hdmiFd, CEC_S_MODE, &monitor) < 0) - lt_info("%s: CEC monitor failed (%m)\n", __func__); + lt_info("[CEC] %s: monitor failed (%m)\n", __func__); GetCECAddressInfo(); @@ -230,7 +236,7 @@ void hdmi_cec::GetCECAddressInfo() logicalAddress = addressinfo.logical; if (memcmp(physicalAddress, addressinfo.physical, sizeof(physicalAddress))) { - lt_info("%s: detected physical address change: %02X%02X --> %02X%02X\n", __func__, physicalAddress[0], physicalAddress[1], addressinfo.physical[0], addressinfo.physical[1]); + lt_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)); ReportPhysicalAddress(); } From f2314e1dddcb5112cc9e4d2ce815e8511fc4a437 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Mon, 8 Oct 2018 16:27:52 +0200 Subject: [PATCH 4/4] libarmbox: hdmi_cec typo Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/9bf2bce32e9e772047d7e6fc5df6080ffb7dbfe3 Author: TangoCash Date: 2018-10-08 (Mon, 08 Oct 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/hdmi_cec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index ef279f3..cc4db35 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -85,7 +85,7 @@ hdmi_cec* hdmi_cec::getInstance() if (hdmi_cec_instance == NULL) { hdmi_cec_instance = new hdmi_cec(); - lt_debug("[CEC] new instance created \n"); + lt_debug_c("[CEC] new instance created \n"); } return hdmi_cec_instance; }