blob: 21cac993ac3393b635c2011891cc9ee36be417aa [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 Hillenbrand353fecb2012-07-22 16:14:08 +020025#define LOG_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}
37
38SecHdmiClient::~SecHdmiClient()
39{
40}
41
42SecHdmiClient * SecHdmiClient::getInstance(void)
43{
44 static SecHdmiClient singleton;
45 return &singleton;
46}
47
48void SecHdmiClient::setHdmiCableStatus(int status)
49{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020050 ALOGD("%s HDMI status: %d\n", __func__, status);
codeworkx62f02ba2012-05-20 12:00:36 +020051
52 if (g_SecTVOutService != 0)
53 g_SecTVOutService->setHdmiCableStatus(status);
54}
55
56void SecHdmiClient::setHdmiMode(int mode)
57{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020058 //ALOGD("%s HDMI Mode: %d\n", __func__, mode);
codeworkx62f02ba2012-05-20 12:00:36 +020059
60 if (g_SecTVOutService != 0)
61 g_SecTVOutService->setHdmiMode(mode);
62}
63
64void SecHdmiClient::setHdmiResolution(int resolution)
65{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020066 //ALOGD("%s HDMI Resolution: %d\n", __func__, resolution);
codeworkx62f02ba2012-05-20 12:00:36 +020067
68 if (g_SecTVOutService != 0)
69 g_SecTVOutService->setHdmiResolution(resolution);
70}
71
72void SecHdmiClient::setHdmiHdcp(int enHdcp)
73{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020074 //ALOGD("%s HDMI HDCP: %d\n", __func__, enHdcp);
codeworkx62f02ba2012-05-20 12:00:36 +020075
76 if (g_SecTVOutService != 0)
77 g_SecTVOutService->setHdmiHdcp(enHdcp);
78}
79
80void SecHdmiClient::setHdmiRotate(int rotVal, uint32_t hwcLayer)
81{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020082 //ALOGD("%s HDMI ROTATE: %d\n", __func__, rotVal);
codeworkx62f02ba2012-05-20 12:00:36 +020083
84 if (g_SecTVOutService != 0)
85 g_SecTVOutService->setHdmiRotate(rotVal, hwcLayer);
86}
87
88void SecHdmiClient::setHdmiHwcLayer(uint32_t hwcLayer)
89{
Daniel Hillenbrand0fdadca2012-07-22 15:45:33 +020090 //ALOGD("%s HDMI HWCLAYER: %d\n", __func__, hwcLayer);
codeworkx62f02ba2012-05-20 12:00:36 +020091
92 if (g_SecTVOutService != 0)
93 g_SecTVOutService->setHdmiHwcLayer(hwcLayer);
94}
95
96void 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
110sp<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 Hillenbrand0fdadca2012-07-22 15:45:33 +0200122 ALOGW("SecTVOutService not published, waiting...");
codeworkx62f02ba2012-05-20 12:00:36 +0200123 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 Hillenbrand0fdadca2012-07-22 15:45:33 +0200133 ALOGW("Failed to get SecTVOutService... SecHdmiClient will get it later..");
codeworkx62f02ba2012-05-20 12:00:36 +0200134 }
135 }
136 return g_SecTVOutService;
137}
138
139}