sharp: check whether the 'auto power on' option is disabled and tell the user how...
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 5 Sep 2013 17:14:24 +0000 (19:14 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 5 Sep 2013 17:18:13 +0000 (19:18 +0200)
src/lib/CECProcessor.cpp
src/lib/Makefile.am
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h
src/lib/implementations/AQCommandHandler.cpp [new file with mode: 0644]
src/lib/implementations/AQCommandHandler.h [new file with mode: 0644]
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/CECCommandHandler.h
src/lib/implementations/VLCommandHandler.cpp

index 6749170cda71cd8310c859d54ae037e628f5a2d6..b1761a3d763ae922ee03fb6f2daa0b002a90ed6f 100644 (file)
@@ -859,7 +859,7 @@ bool CCECProcessor::RegisterClient(CCECClient *client)
   client->GetPrimaryDevice()->TransmitOSDName(CECDEVICE_TV, false);
 
   // request the power status of the TV
-  tv->RequestPowerStatus(sourceAddress, true);
+  tv->RequestPowerStatus(sourceAddress, true, true);
 
   return bReturn;
 }
index cdc1cbd9279aa860181de522094e716a184fd782..9117d8ebf3ce8fb7e9880b8b3497b4b8e3b946aa 100644 (file)
@@ -27,7 +27,8 @@ libcec_la_SOURCES = CECProcessor.cpp \
                     implementations/VLCommandHandler.cpp \
                     implementations/RLCommandHandler.cpp \
                     implementations/PHCommandHandler.cpp \
-                    implementations/RHCommandHandler.cpp
+                    implementations/RHCommandHandler.cpp \
+                    implementations/AQCommandHandler.cpp
 
 ## server sockets, currently unused
 ##libcec_la_SOURCES += platform/posix/serversocket.cpp
index 25332b33dad1478bc2ec67358ba5ff881fefc76e..f2bd59f7b495345b7cad0fd6fbd25c03ae43a046 100644 (file)
@@ -42,6 +42,7 @@
 #include "lib/implementations/PHCommandHandler.h"
 #include "lib/implementations/RLCommandHandler.h"
 #include "lib/implementations/RHCommandHandler.h"
+#include "lib/implementations/AQCommandHandler.h"
 #include "lib/LibCEC.h"
 #include "lib/CECTypeUtils.h"
 #include "lib/platform/util/timeutils.h"
@@ -145,6 +146,9 @@ bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */)
         case CEC_VENDOR_ONKYO:
           m_handler = new CRHCommandHandler(this, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending);
           break;
+        case CEC_VENDOR_SHARP:
+          m_handler = new CAQCommandHandler(this, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending);
+          break;
         default:
           m_handler = new CCECCommandHandler(this, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending);
           break;
@@ -609,7 +613,7 @@ cec_power_status CCECBusDevice::GetPowerStatus(const cec_logical_address initiat
   if (bRequestUpdate)
   {
     CheckVendorIdRequested(initiator);
-    RequestPowerStatus(initiator);
+    RequestPowerStatus(initiator, bUpdate);
   }
 
   CLockObject lock(m_mutex);
@@ -646,7 +650,7 @@ bool CCECBusDevice::ImageViewOnSent(void)
   return m_bImageViewOnSent;
 }
 
-bool CCECBusDevice::RequestPowerStatus(const cec_logical_address initiator, bool bWaitForResponse /* = true */)
+bool CCECBusDevice::RequestPowerStatus(const cec_logical_address initiator, bool bUpdate, bool bWaitForResponse /* = true */)
 {
   bool bReturn(false);
 
@@ -654,7 +658,7 @@ bool CCECBusDevice::RequestPowerStatus(const cec_logical_address initiator, bool
       !IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS))
   {
     MarkBusy();
-    bReturn = m_handler->TransmitRequestPowerStatus(initiator, m_iLogicalAddress, bWaitForResponse);
+    bReturn = m_handler->TransmitRequestPowerStatus(initiator, m_iLogicalAddress, bUpdate, bWaitForResponse);
     if (!bReturn)
       SetPowerStatus(CEC_POWER_STATUS_UNKNOWN);
     MarkReady();
index e159aea2289d243b65d2b6bd83fd7d3b8d267d80..8a80f48673a7b179223f89c472f442a7045b82af 100644 (file)
@@ -194,7 +194,7 @@ namespace CEC
     virtual void                  SetPowerStatus(const cec_power_status powerStatus);
     virtual void                  OnImageViewOnSent(bool bSentByLibCEC);
     virtual bool                  ImageViewOnSent(void);
-    virtual bool                  RequestPowerStatus(const cec_logical_address initiator, bool bWaitForResponse = true);
+    virtual bool                  RequestPowerStatus(const cec_logical_address initiator, bool bUpdate, bool bWaitForResponse = true);
     virtual bool                  TransmitPowerState(const cec_logical_address destination, bool bIsReply);
 
     virtual cec_vendor_id         GetCurrentVendorId(void);
diff --git a/src/lib/implementations/AQCommandHandler.cpp b/src/lib/implementations/AQCommandHandler.cpp
new file mode 100644 (file)
index 0000000..93bba24
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * This file is part of the libCEC(R) library.
+ *
+ * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited.  All rights reserved.
+ * libCEC(R) is an original work, containing original code.
+ *
+ * libCEC(R) is a trademark of Pulse-Eight Limited.
+ *
+ * This program is dual-licensed; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * Alternatively, you can license this library under a commercial license,
+ * please contact Pulse-Eight Licensing for more information.
+ *
+ * For more information contact:
+ * Pulse-Eight Licensing       <license@pulse-eight.com>
+ *     http://www.pulse-eight.com/
+ *     http://www.pulse-eight.net/
+ */
+
+#include "env.h"
+#include "AQCommandHandler.h"
+
+#include "lib/devices/CECBusDevice.h"
+#include "lib/CECProcessor.h"
+#include "lib/LibCEC.h"
+#include "lib/CECClient.h"
+
+using namespace CEC;
+using namespace PLATFORM;
+
+#define LIB_CEC     m_busDevice->GetProcessor()->GetLib()
+#define ToString(p) LIB_CEC->ToString(p)
+
+CAQCommandHandler::CAQCommandHandler(CCECBusDevice *busDevice,
+                                     int32_t iTransmitTimeout /* = CEC_DEFAULT_TRANSMIT_TIMEOUT */,
+                                     int32_t iTransmitWait /* = CEC_DEFAULT_TRANSMIT_WAIT */,
+                                     int8_t iTransmitRetries /* = CEC_DEFAULT_TRANSMIT_RETRIES */,
+                                     int64_t iActiveSourcePending /* = 0 */) :
+    CCECCommandHandler(busDevice, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending),
+    m_powerOnCheck(NULL)
+{
+  m_vendorId = CEC_VENDOR_SHARP;
+}
+
+CAQCommandHandler::~CAQCommandHandler(void)
+{
+  delete m_powerOnCheck;
+}
+
+bool CAQCommandHandler::PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination)
+{
+  bool bCheck(false);
+  bool bRetval(false);
+  if (m_busDevice->GetCurrentPowerStatus() != CEC_POWER_STATUS_ON && (!m_powerOnCheck || !m_powerOnCheck->IsRunning()))
+    bCheck = true;
+  bRetval = CCECCommandHandler::PowerOn(iInitiator, iDestination);
+
+  if (bRetval && bCheck)
+  {
+    if (!m_powerOnCheck)
+      m_powerOnCheck = new CAQPowerStatusCheck(this, iInitiator, iDestination);
+    if (m_powerOnCheck)
+      m_powerOnCheck->CreateThread();
+  }
+
+  return bRetval;
+}
+
+void* CAQPowerStatusCheck::Process(void)
+{
+  // sleep for 2 seconds and query the power status
+  Sleep(2000);
+  if (m_handler->m_busDevice->GetProcessor()->GetDevice(m_iDestination)->GetPowerStatus(m_iInitiator, true) == CEC_POWER_STATUS_STANDBY)
+    m_handler->m_busDevice->GetProcessor()->GetLib()->AddLog(CEC_LOG_WARNING, "AQUOS LINK 'auto power on' is disabled, which prevents the TV from being powered on. To correct this, press the menu button on your remote, go to 'link operation' -> 'AQUOS LINK setup' -> 'Auto power on' and set it to 'On'");
+  return NULL;
+}
diff --git a/src/lib/implementations/AQCommandHandler.h b/src/lib/implementations/AQCommandHandler.h
new file mode 100644 (file)
index 0000000..9193b3a
--- /dev/null
@@ -0,0 +1,74 @@
+#pragma once
+/*
+ * This file is part of the libCEC(R) library.
+ *
+ * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited.  All rights reserved.
+ * libCEC(R) is an original work, containing original code.
+ *
+ * libCEC(R) is a trademark of Pulse-Eight Limited.
+ *
+ * This program is dual-licensed; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * Alternatively, you can license this library under a commercial license,
+ * please contact Pulse-Eight Licensing for more information.
+ *
+ * For more information contact:
+ * Pulse-Eight Licensing       <license@pulse-eight.com>
+ *     http://www.pulse-eight.com/
+ *     http://www.pulse-eight.net/
+ */
+
+#include "CECCommandHandler.h"
+#include "platform/threads/threads.h"
+
+namespace CEC
+{
+  class CAQPowerStatusCheck;
+
+  class CAQCommandHandler : public CCECCommandHandler
+  {
+    friend class CAQPowerStatusCheck;
+  public:
+    CAQCommandHandler(CCECBusDevice *busDevice,
+                      int32_t iTransmitTimeout = CEC_DEFAULT_TRANSMIT_TIMEOUT,
+                      int32_t iTransmitWait = CEC_DEFAULT_TRANSMIT_WAIT,
+                      int8_t iTransmitRetries = CEC_DEFAULT_TRANSMIT_RETRIES,
+                      int64_t iActiveSourcePending = 0);
+    virtual ~CAQCommandHandler(void);
+
+  protected:
+    virtual bool PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination);
+
+  private:
+    CAQPowerStatusCheck* m_powerOnCheck;
+  };
+
+  class CAQPowerStatusCheck : public PLATFORM::CThread
+  {
+  public:
+    CAQPowerStatusCheck(CAQCommandHandler* handler, cec_logical_address iInitiator, cec_logical_address iDestination) :
+      m_handler(handler),
+      m_iInitiator(iInitiator),
+      m_iDestination(iDestination) {}
+    virtual ~CAQPowerStatusCheck(void) {}
+
+  private:
+    void* Process(void);
+    CAQCommandHandler* m_handler;
+    cec_logical_address m_iInitiator;
+    cec_logical_address m_iDestination;
+  };
+};
index b742f49898001f437d64478d0e8b6f7593c7e4dc..12e74e3e31bfded1ffe5406d46c806b43a607739 100644 (file)
@@ -910,12 +910,12 @@ bool CCECCommandHandler::TransmitRequestPhysicalAddress(const cec_logical_addres
   return Transmit(command, !bWaitForResponse, false);
 }
 
-bool CCECCommandHandler::TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse /* = true */)
+bool CCECCommandHandler::TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bUpdate, bool bWaitForResponse /* = true */)
 {
   if (iDestination == CECDEVICE_TV)
   {
     int64_t now(GetTimeMs());
-    if (now - m_iPowerStatusRequested < REQUEST_POWER_STATUS_TIMEOUT)
+    if (!bUpdate && now - m_iPowerStatusRequested < REQUEST_POWER_STATUS_TIMEOUT)
       return true;
     m_iPowerStatusRequested = now;
   }
@@ -1207,7 +1207,7 @@ bool CCECCommandHandler::ActivateSource(bool bTransmitDelayedCommandsOnly /* = f
     bool bTvPresent = (tv && tv->GetStatus() == CEC_DEVICE_STATUS_PRESENT);
     bool bActiveSourceFailed(false);
     if (bTvPresent)
-      bActiveSourceFailed = !m_busDevice->TransmitImageViewOn();
+      bActiveSourceFailed = !tv->PowerOn(m_busDevice->GetLogicalAddress());
     else
       LIB_CEC->AddLog(CEC_LOG_DEBUG, "TV not present, not sending 'image view on'");
 
index 5ad5ab01d98c78e57fd41e63c020cf50c4c4ee46..aeace0233a3ae673ed1a71977b858c29689b915e 100644 (file)
@@ -58,7 +58,7 @@ namespace CEC
     virtual bool HandleCommand(const cec_command &command);
     virtual cec_vendor_id GetVendorId(void) { return m_vendorId; };
     virtual void SetVendorId(cec_vendor_id vendorId) { m_vendorId = vendorId; }
-    static bool HasSpecificHandler(cec_vendor_id vendorId) { return vendorId == CEC_VENDOR_LG || vendorId == CEC_VENDOR_SAMSUNG || vendorId == CEC_VENDOR_PANASONIC || vendorId == CEC_VENDOR_PHILIPS;}
+    static bool HasSpecificHandler(cec_vendor_id vendorId) { return vendorId == CEC_VENDOR_LG || vendorId == CEC_VENDOR_SAMSUNG || vendorId == CEC_VENDOR_PANASONIC || vendorId == CEC_VENDOR_PHILIPS || vendorId == CEC_VENDOR_SHARP;}
 
     virtual bool InitHandler(void) { return true; }
     virtual bool ActivateSource(bool bTransmitDelayedCommandsOnly = false);
@@ -73,7 +73,7 @@ namespace CEC
     virtual bool TransmitRequestOSDName(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse = true);
     virtual bool TransmitRequestAudioStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse = true);
     virtual bool TransmitRequestPhysicalAddress(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse = true);
-    virtual bool TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse = true);
+    virtual bool TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bUpdate, bool bWaitForResponse = true);
     virtual bool TransmitRequestVendorId(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse = true);
     virtual bool TransmitActiveSource(const cec_logical_address iInitiator, uint16_t iPhysicalAddress, bool bIsReply);
     virtual bool TransmitCECVersion(const cec_logical_address iInitiator, const cec_logical_address iDestination, cec_version cecVersion, bool bIsReply);
index 907de02dda786e69892d4419613bb619cbc00e6e..5f014f0d6e709bc6cc49a78b77fe156bb7effff4 100644 (file)
@@ -262,7 +262,7 @@ int CVLCommandHandler::HandleVendorCommand(const cec_command &command)
 bool CVLCommandHandler::SourceSwitchAllowed(void)
 {
   if (!PowerUpEventReceived())
-    TransmitRequestPowerStatus(m_processor->GetPrimaryDevice()->GetLogicalAddress(), CECDEVICE_TV, false);
+    TransmitRequestPowerStatus(m_processor->GetPrimaryDevice()->GetLogicalAddress(), CECDEVICE_TV, false, false);
 
   return PowerUpEventReceived();
 }