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