codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 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 | ** |
| 21 | ** @author Taikyung, Yu(taikyung.yu@samsung.com) |
| 22 | ** @date 2011-07-06 |
| 23 | */ |
| 24 | |
Daniel Hillenbrand | 353fecb | 2012-07-22 16:14:08 +0200 | [diff] [blame^] | 25 | #define LOG_TAG "libhdmiclient" |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 26 | |
| 27 | #include "SecHdmiClient.h" |
| 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | static sp<ISecTVOut> g_SecTVOutService = 0; |
| 32 | |
| 33 | SecHdmiClient::SecHdmiClient() |
| 34 | { |
| 35 | g_SecTVOutService = m_getSecTVOutService(); |
| 36 | mEnable = 0; |
| 37 | } |
| 38 | |
| 39 | SecHdmiClient::~SecHdmiClient() |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | SecHdmiClient * SecHdmiClient::getInstance(void) |
| 44 | { |
| 45 | static SecHdmiClient singleton; |
| 46 | return &singleton; |
| 47 | } |
| 48 | |
| 49 | void SecHdmiClient::setHdmiCableStatus(int status) |
| 50 | { |
Daniel Hillenbrand | 0fdadca | 2012-07-22 15:45:33 +0200 | [diff] [blame] | 51 | //ALOGD("%s HDMI status: %d\n", __func__, status); |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 52 | |
| 53 | if (g_SecTVOutService != 0) |
| 54 | g_SecTVOutService->setHdmiCableStatus(status); |
| 55 | } |
| 56 | |
| 57 | void SecHdmiClient::setHdmiMode(int mode) |
| 58 | { |
Daniel Hillenbrand | 0fdadca | 2012-07-22 15:45:33 +0200 | [diff] [blame] | 59 | //ALOGD("%s HDMI Mode: %d\n", __func__, mode); |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 60 | |
| 61 | if (g_SecTVOutService != 0) |
| 62 | g_SecTVOutService->setHdmiMode(mode); |
| 63 | } |
| 64 | |
| 65 | void SecHdmiClient::setHdmiResolution(int resolution) |
| 66 | { |
Daniel Hillenbrand | 0fdadca | 2012-07-22 15:45:33 +0200 | [diff] [blame] | 67 | //ALOGD("%s HDMI Resolution: %d\n", __func__, resolution); |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 68 | |
| 69 | if (g_SecTVOutService != 0) |
| 70 | g_SecTVOutService->setHdmiResolution(resolution); |
| 71 | } |
| 72 | |
| 73 | void SecHdmiClient::setHdmiHdcp(int enHdcp) |
| 74 | { |
Daniel Hillenbrand | 0fdadca | 2012-07-22 15:45:33 +0200 | [diff] [blame] | 75 | //ALOGD("%s HDMI HDCP: %d\n", __func__, enHdcp); |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 76 | |
| 77 | if (g_SecTVOutService != 0) |
| 78 | g_SecTVOutService->setHdmiHdcp(enHdcp); |
| 79 | } |
| 80 | |
| 81 | void SecHdmiClient::setHdmiRotate(int rotVal, uint32_t hwcLayer) |
| 82 | { |
Daniel Hillenbrand | 0fdadca | 2012-07-22 15:45:33 +0200 | [diff] [blame] | 83 | //ALOGD("%s HDMI ROTATE: %d\n", __func__, rotVal); |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 84 | |
| 85 | if (g_SecTVOutService != 0) |
| 86 | g_SecTVOutService->setHdmiRotate(rotVal, hwcLayer); |
| 87 | } |
| 88 | |
| 89 | void SecHdmiClient::setHdmiHwcLayer(uint32_t hwcLayer) |
| 90 | { |
Daniel Hillenbrand | 0fdadca | 2012-07-22 15:45:33 +0200 | [diff] [blame] | 91 | //ALOGD("%s HDMI HWCLAYER: %d\n", __func__, hwcLayer); |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 92 | |
| 93 | if (g_SecTVOutService != 0) |
| 94 | g_SecTVOutService->setHdmiHwcLayer(hwcLayer); |
| 95 | } |
| 96 | |
| 97 | void SecHdmiClient::setHdmiEnable(uint32_t enable) |
| 98 | { |
Daniel Hillenbrand | 0fdadca | 2012-07-22 15:45:33 +0200 | [diff] [blame] | 99 | //ALOGD("%s HDMI ENABLE: %d\n", __func__, enable); |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 100 | |
| 101 | if (g_SecTVOutService != 0) |
| 102 | mEnable = enable; |
| 103 | } |
| 104 | |
| 105 | void SecHdmiClient::blit2Hdmi(uint32_t w, uint32_t h, |
| 106 | uint32_t colorFormat, |
| 107 | uint32_t physYAddr, |
| 108 | uint32_t physCbAddr, |
| 109 | uint32_t physCrAddr, |
| 110 | uint32_t dstX, |
| 111 | uint32_t dstY, |
| 112 | uint32_t hdmiLayer, |
| 113 | uint32_t num_of_hwc_layer) |
| 114 | { |
| 115 | if (g_SecTVOutService != 0 && mEnable == 1) |
| 116 | g_SecTVOutService->blit2Hdmi(w, h, colorFormat, physYAddr, physCbAddr, physCrAddr, dstX, dstY, hdmiLayer, num_of_hwc_layer); |
| 117 | } |
| 118 | |
| 119 | sp<ISecTVOut> SecHdmiClient::m_getSecTVOutService(void) |
| 120 | { |
| 121 | int ret = 0; |
| 122 | |
| 123 | if (g_SecTVOutService == 0) { |
| 124 | sp<IBinder> binder; |
| 125 | sp<ISecTVOut> sc; |
| 126 | sp<IServiceManager> sm = defaultServiceManager(); |
| 127 | int getSvcTimes = 0; |
| 128 | for(getSvcTimes = 0; getSvcTimes < GETSERVICETIMEOUT; getSvcTimes++) { |
| 129 | binder = sm->getService(String16("SecTVOutService")); |
| 130 | if (binder == 0) { |
Daniel Hillenbrand | 0fdadca | 2012-07-22 15:45:33 +0200 | [diff] [blame] | 131 | ALOGW("SecTVOutService not published, waiting..."); |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 132 | usleep(500000); // 0.5 s |
| 133 | } else { |
| 134 | break; |
| 135 | } |
| 136 | } |
| 137 | // grab the lock again for updating g_surfaceFlinger |
| 138 | if (getSvcTimes < GETSERVICETIMEOUT) { |
| 139 | sc = interface_cast<ISecTVOut>(binder); |
| 140 | g_SecTVOutService = sc; |
| 141 | } else { |
Daniel Hillenbrand | 0fdadca | 2012-07-22 15:45:33 +0200 | [diff] [blame] | 142 | ALOGW("Failed to get SecTVOutService... SecHdmiClient will get it later.."); |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | return g_SecTVOutService; |
| 146 | } |
| 147 | |
| 148 | } |