summaryrefslogtreecommitdiffstats
path: root/exynos4/hal/libhdmi/libhdmiservice/SecHdmiClient.cpp
blob: 9fd330c3301b58a61686296ffcfe140900049e67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
**
** Copyright 2008, The Android Open Source Project
** Copyright 2010, Samsung Electronics Co. LTD
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

/*
**
** @author  Taikyung, Yu(taikyung.yu@samsung.com)
** @date    2011-07-06
*/

#define ALOG_TAG "libhdmiclient"

#include "SecHdmiClient.h"

namespace android {

static sp<ISecTVOut> g_SecTVOutService = 0;

SecHdmiClient::SecHdmiClient()
{
    g_SecTVOutService = m_getSecTVOutService();
    mEnable = 0;
}

SecHdmiClient::~SecHdmiClient()
{
}

SecHdmiClient * SecHdmiClient::getInstance(void)
{
    static SecHdmiClient singleton;
    return &singleton;
}

void SecHdmiClient::setHdmiCableStatus(int status)
{
    //ALOGD("%s HDMI status: %d\n", __func__, status);

    if (g_SecTVOutService != 0)
        g_SecTVOutService->setHdmiCableStatus(status);
}

void SecHdmiClient::setHdmiMode(int mode)
{
    //ALOGD("%s HDMI Mode: %d\n", __func__, mode);

    if (g_SecTVOutService != 0)
        g_SecTVOutService->setHdmiMode(mode);
}

void SecHdmiClient::setHdmiResolution(int resolution)
{
    //ALOGD("%s HDMI Resolution: %d\n", __func__, resolution);

    if (g_SecTVOutService != 0)
        g_SecTVOutService->setHdmiResolution(resolution);
}

void SecHdmiClient::setHdmiHdcp(int enHdcp)
{
    //ALOGD("%s HDMI HDCP: %d\n", __func__, enHdcp);

    if (g_SecTVOutService != 0)
        g_SecTVOutService->setHdmiHdcp(enHdcp);
}

void SecHdmiClient::setHdmiRotate(int rotVal, uint32_t hwcLayer)
{
    //ALOGD("%s HDMI ROTATE: %d\n", __func__, rotVal);

    if (g_SecTVOutService != 0)
        g_SecTVOutService->setHdmiRotate(rotVal, hwcLayer);
}

void SecHdmiClient::setHdmiHwcLayer(uint32_t hwcLayer)
{
    //ALOGD("%s HDMI HWCLAYER: %d\n", __func__, hwcLayer);

    if (g_SecTVOutService != 0)
        g_SecTVOutService->setHdmiHwcLayer(hwcLayer);
}

void SecHdmiClient::setHdmiEnable(uint32_t enable)
{
    //ALOGD("%s HDMI ENABLE: %d\n", __func__, enable);

    if (g_SecTVOutService != 0)
        mEnable = enable;
}

void SecHdmiClient::blit2Hdmi(uint32_t w, uint32_t h,
                                uint32_t colorFormat,
                                uint32_t physYAddr,
                                uint32_t physCbAddr,
                                uint32_t physCrAddr,
                                uint32_t dstX,
                                uint32_t dstY,
                                uint32_t hdmiLayer,
                                uint32_t num_of_hwc_layer)
{
    if (g_SecTVOutService != 0 && mEnable == 1)
        g_SecTVOutService->blit2Hdmi(w, h, colorFormat, physYAddr, physCbAddr, physCrAddr, dstX, dstY, hdmiLayer, num_of_hwc_layer);
}

sp<ISecTVOut> SecHdmiClient::m_getSecTVOutService(void)
{
    int ret = 0;

    if (g_SecTVOutService == 0) {
        sp<IBinder> binder;
        sp<ISecTVOut> sc;
        sp<IServiceManager> sm = defaultServiceManager();
        int getSvcTimes = 0;
        for(getSvcTimes = 0; getSvcTimes < GETSERVICETIMEOUT; getSvcTimes++) {
            binder = sm->getService(String16("SecTVOutService"));
            if (binder == 0) {
                ALOGW("SecTVOutService not published, waiting...");
                usleep(500000); // 0.5 s
            } else {
                break;
            }
        }
        // grab the lock again for updating g_surfaceFlinger
        if (getSvcTimes < GETSERVICETIMEOUT) {
            sc = interface_cast<ISecTVOut>(binder);
            g_SecTVOutService = sc;
        } else {
            ALOGW("Failed to get SecTVOutService... SecHdmiClient will get it later..");
        }
    }
    return g_SecTVOutService;
}

}