-rw-r--r-- | TvPlay.cpp | 14 | ||||
-rw-r--r-- | TvPlay.h | 3 | ||||
-rw-r--r-- | tv_input.cpp | 27 |
3 files changed, 18 insertions, 26 deletions
@@ -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))); +} + @@ -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<TvClient> 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; |