blob: 9fd330c3301b58a61686296ffcfe140900049e67 [file] [log] [blame]
codeworkx62f02ba2012-05-20 12:00:36 +02001/*
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 Hillenbrand0fdadca2012-07-22 15:45:33 +020025#define ALOG_TAG "libhdmiclient"
codeworkx62f02ba2012-05-20 12:00:36 +020026
27#include "SecHdmiClient.h"
28
29namespace android {
30
31static sp<ISecTVOut> g_SecTVOutService = 0;
32
33SecHdmiClient::SecHdmiClient()
34{
35 g_SecTVOutService = m_getSecTVOutService();
36 mEnable = 0;
37}
38
39SecHdmiClient::~SecHdmiClient()
40{
41}
42
43SecHdmiClient * SecHdmiClient::getInstance(void)
44{
45 static SecHdmiClient singleton;
46 return &singleton;
47}
48
49void SecHdmiClient::setHdmiCableStatus(int status)
50{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020051 //ALOGD("%s HDMI status: %d\n", __func__, status);
codeworkx62f02ba2012-05-20 12:00:36 +020052
53 if (g_SecTVOutService != 0)
54 g_SecTVOutService->setHdmiCableStatus(status);
55}
56
57void SecHdmiClient::setHdmiMode(int mode)
58{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020059 //ALOGD("%s HDMI Mode: %d\n", __func__, mode);
codeworkx62f02ba2012-05-20 12:00:36 +020060
61 if (g_SecTVOutService != 0)
62 g_SecTVOutService->setHdmiMode(mode);
63}
64
65void SecHdmiClient::setHdmiResolution(int resolution)
66{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020067 //ALOGD("%s HDMI Resolution: %d\n", __func__, resolution);
codeworkx62f02ba2012-05-20 12:00:36 +020068
69 if (g_SecTVOutService != 0)
70 g_SecTVOutService->setHdmiResolution(resolution);
71}
72
73void SecHdmiClient::setHdmiHdcp(int enHdcp)
74{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020075 //ALOGD("%s HDMI HDCP: %d\n", __func__, enHdcp);
codeworkx62f02ba2012-05-20 12:00:36 +020076
77 if (g_SecTVOutService != 0)
78 g_SecTVOutService->setHdmiHdcp(enHdcp);
79}
80
81void SecHdmiClient::setHdmiRotate(int rotVal, uint32_t hwcLayer)
82{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020083 //ALOGD("%s HDMI ROTATE: %d\n", __func__, rotVal);
codeworkx62f02ba2012-05-20 12:00:36 +020084
85 if (g_SecTVOutService != 0)
86 g_SecTVOutService->setHdmiRotate(rotVal, hwcLayer);
87}
88
89void SecHdmiClient::setHdmiHwcLayer(uint32_t hwcLayer)
90{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020091 //ALOGD("%s HDMI HWCLAYER: %d\n", __func__, hwcLayer);
codeworkx62f02ba2012-05-20 12:00:36 +020092
93 if (g_SecTVOutService != 0)
94 g_SecTVOutService->setHdmiHwcLayer(hwcLayer);
95}
96
97void SecHdmiClient::setHdmiEnable(uint32_t enable)
98{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020099 //ALOGD("%s HDMI ENABLE: %d\n", __func__, enable);
codeworkx62f02ba2012-05-20 12:00:36 +0200100
101 if (g_SecTVOutService != 0)
102 mEnable = enable;
103}
104
105void 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
119sp<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 Hillenbrand0fdadca2012-07-22 15:45:33 +0200131 ALOGW("SecTVOutService not published, waiting...");
codeworkx62f02ba2012-05-20 12:00:36 +0200132 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 Hillenbrand0fdadca2012-07-22 15:45:33 +0200142 ALOGW("Failed to get SecTVOutService... SecHdmiClient will get it later..");
codeworkx62f02ba2012-05-20 12:00:36 +0200143 }
144 }
145 return g_SecTVOutService;
146}
147
148}