/exynos4/hal/libhdmi/libhdmiservice/SecHdmiClient.cpp

https://bitbucket.org/cyanogenmod/android_hardware_samsung · C++ · 148 lines · 92 code · 26 blank · 30 comment · 26 complexity · 9842f1cd3b2339545ed7adbc2f754ba9 MD5 · raw file

  1. /*
  2. **
  3. ** Copyright 2008, The Android Open Source Project
  4. ** Copyright 2010, Samsung Electronics Co. LTD
  5. **
  6. ** Licensed under the Apache License, Version 2.0 (the "License");
  7. ** you may not use this file except in compliance with the License.
  8. ** You may obtain a copy of the License at
  9. **
  10. ** http://www.apache.org/licenses/LICENSE-2.0
  11. **
  12. ** Unless required by applicable law or agreed to in writing, software
  13. ** distributed under the License is distributed on an "AS IS" BASIS,
  14. ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. ** See the License for the specific language governing permissions and
  16. ** limitations under the License.
  17. */
  18. /*
  19. **
  20. ** @author Taikyung, Yu(taikyung.yu@samsung.com)
  21. ** @date 2011-07-06
  22. */
  23. #define LOG_TAG "libhdmiclient"
  24. #include "SecHdmiClient.h"
  25. namespace android {
  26. static sp<ISecTVOut> g_SecTVOutService = 0;
  27. SecHdmiClient::SecHdmiClient()
  28. {
  29. g_SecTVOutService = m_getSecTVOutService();
  30. mEnable = 0;
  31. }
  32. SecHdmiClient::~SecHdmiClient()
  33. {
  34. }
  35. SecHdmiClient * SecHdmiClient::getInstance(void)
  36. {
  37. static SecHdmiClient singleton;
  38. return &singleton;
  39. }
  40. void SecHdmiClient::setHdmiCableStatus(int status)
  41. {
  42. //ALOGD("%s HDMI status: %d\n", __func__, status);
  43. if (g_SecTVOutService != 0)
  44. g_SecTVOutService->setHdmiCableStatus(status);
  45. }
  46. void SecHdmiClient::setHdmiMode(int mode)
  47. {
  48. //ALOGD("%s HDMI Mode: %d\n", __func__, mode);
  49. if (g_SecTVOutService != 0)
  50. g_SecTVOutService->setHdmiMode(mode);
  51. }
  52. void SecHdmiClient::setHdmiResolution(int resolution)
  53. {
  54. //ALOGD("%s HDMI Resolution: %d\n", __func__, resolution);
  55. if (g_SecTVOutService != 0)
  56. g_SecTVOutService->setHdmiResolution(resolution);
  57. }
  58. void SecHdmiClient::setHdmiHdcp(int enHdcp)
  59. {
  60. //ALOGD("%s HDMI HDCP: %d\n", __func__, enHdcp);
  61. if (g_SecTVOutService != 0)
  62. g_SecTVOutService->setHdmiHdcp(enHdcp);
  63. }
  64. void SecHdmiClient::setHdmiRotate(int rotVal, uint32_t hwcLayer)
  65. {
  66. //ALOGD("%s HDMI ROTATE: %d\n", __func__, rotVal);
  67. if (g_SecTVOutService != 0)
  68. g_SecTVOutService->setHdmiRotate(rotVal, hwcLayer);
  69. }
  70. void SecHdmiClient::setHdmiHwcLayer(uint32_t hwcLayer)
  71. {
  72. //ALOGD("%s HDMI HWCLAYER: %d\n", __func__, hwcLayer);
  73. if (g_SecTVOutService != 0)
  74. g_SecTVOutService->setHdmiHwcLayer(hwcLayer);
  75. }
  76. void SecHdmiClient::setHdmiEnable(uint32_t enable)
  77. {
  78. //ALOGD("%s HDMI ENABLE: %d\n", __func__, enable);
  79. if (g_SecTVOutService != 0)
  80. mEnable = enable;
  81. }
  82. void SecHdmiClient::blit2Hdmi(uint32_t w, uint32_t h,
  83. uint32_t colorFormat,
  84. uint32_t physYAddr,
  85. uint32_t physCbAddr,
  86. uint32_t physCrAddr,
  87. uint32_t dstX,
  88. uint32_t dstY,
  89. uint32_t hdmiLayer,
  90. uint32_t num_of_hwc_layer)
  91. {
  92. if (g_SecTVOutService != 0 && mEnable == 1)
  93. g_SecTVOutService->blit2Hdmi(w, h, colorFormat, physYAddr, physCbAddr, physCrAddr, dstX, dstY, hdmiLayer, num_of_hwc_layer);
  94. }
  95. sp<ISecTVOut> SecHdmiClient::m_getSecTVOutService(void)
  96. {
  97. int ret = 0;
  98. if (g_SecTVOutService == 0) {
  99. sp<IBinder> binder;
  100. sp<ISecTVOut> sc;
  101. sp<IServiceManager> sm = defaultServiceManager();
  102. int getSvcTimes = 0;
  103. for(getSvcTimes = 0; getSvcTimes < GETSERVICETIMEOUT; getSvcTimes++) {
  104. binder = sm->getService(String16("SecTVOutService"));
  105. if (binder == 0) {
  106. ALOGW("SecTVOutService not published, waiting...");
  107. usleep(500000); // 0.5 s
  108. } else {
  109. break;
  110. }
  111. }
  112. // grab the lock again for updating g_surfaceFlinger
  113. if (getSvcTimes < GETSERVICETIMEOUT) {
  114. sc = interface_cast<ISecTVOut>(binder);
  115. g_SecTVOutService = sc;
  116. } else {
  117. ALOGW("Failed to get SecTVOutService... SecHdmiClient will get it later..");
  118. }
  119. }
  120. return g_SecTVOutService;
  121. }
  122. }