From a240a9dd4a7e0dc06de339917810259319e45d84 Mon Sep 17 00:00:00 2001 From: Jing Wei Date: Tue, 14 Feb 2017 07:58:55 +0000 Subject: PD#138612: get hdmi port id from tvconfig.conf Change-Id: I7fe1b609ff169b00e9dec8bc9bcdacbcfdfca53d --- diff --git a/TvPlay.cpp b/TvPlay.cpp index 266e264..1d081c3 100644 --- a/TvPlay.cpp +++ b/TvPlay.cpp @@ -10,6 +10,7 @@ TvPlay::TvPlay() mpObserver = NULL; tvSession = TvClient::connect(); tvSession->setListener(this); + mHdmiPorts = getHdmiPorts(); } TvPlay::~TvPlay() @@ -120,3 +121,16 @@ int TvPlay::getAllTvDevices(int *devices, int *count) return 0; } +int TvPlay::getHdmiPorts() +{ + Parcel p, r; + p.writeInt32(GET_HDMI_PORTS); + tvSession->processCmd(p, &r); + + return r.readInt32(); +} + +int TvPlay::getHdmiPort(tv_source_input_t source_input) { + return mHdmiPorts == 0 ? 0 : 0x3 & (mHdmiPorts >> (2* (source_input - SOURCE_HDMI1))); +} + diff --git a/TvPlay.h b/TvPlay.h index 1b0dd69..0d6880f 100644 --- a/TvPlay.h +++ b/TvPlay.h @@ -49,12 +49,15 @@ public: int GetHdmiAvHotplugDetectOnoff(); int setTvObserver (TvPlayObserver *ob); int getAllTvDevices(int *devices, int *count); + int getHdmiPorts(); + int getHdmiPort(tv_source_input_t source_input); virtual void notify(int32_t msgType, const Parcel &p); sp tvSession; private: TvPlayObserver *mpObserver; + int mHdmiPorts; }; #ifdef __cplusplus diff --git a/tv_input.cpp b/tv_input.cpp index 6b0582b..dc079f6 100644 --- a/tv_input.cpp +++ b/tv_input.cpp @@ -64,31 +64,6 @@ typedef struct tv_input_private { static int capWidth; static int capHeight; -enum hdmi_port_id { - PORT_HDMI1 = 1, - PORT_HDMI3, - PORT_HDMI2, -}; - -static int getHdmiPort(tv_source_input_t source_input) -{ - int port = PORT_HDMI1; - switch (source_input) { - case SOURCE_HDMI1: - port = PORT_HDMI1; - break; - case SOURCE_HDMI2: - port = PORT_HDMI2; - break; - case SOURCE_HDMI3: - port = PORT_HDMI3; - break; - default: - break; - } - return port; -} - void TvIputHal_ChannelConl(tv_input_private_t *priv, int ops_type, int device_id) { if (priv->mpTv) { @@ -123,7 +98,7 @@ static int notify_tv_device_status(tv_input_private_t *priv, tv_source_input_t s case SOURCE_HDMI2: case SOURCE_HDMI3: event.device_info.type = TV_INPUT_TYPE_HDMI; - event.device_info.hdmi.port_id = getHdmiPort(source_input); + event.device_info.hdmi.port_id = priv->mpTv->getHdmiPort(source_input); break; case SOURCE_SPDIF: event.device_info.type = TV_INPUT_TYPE_OTHER_HARDWARE; -- cgit