blob: a17565b5d088bc5444caa74fd18d3c4457c66748 [file] [log] [blame]
Saurabh Shah86c17292013-02-08 15:24:13 -08001/*
2 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR CLIENTS; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <hwc_qclient.h>
31#include <IQService.h>
32#include <hwc_utils.h>
Naseer Ahmed58780b92013-07-29 17:41:40 -040033#include <hwc_vpuclient.h>
Saurabh Shah86c17292013-02-08 15:24:13 -080034
35#define QCLIENT_DEBUG 0
36
37using namespace android;
38using namespace qService;
39
40namespace qClient {
41
42// ----------------------------------------------------------------------------
Saurabh Shah7128e502013-02-20 13:24:48 -080043QClient::QClient(hwc_context_t *ctx) : mHwcContext(ctx),
44 mMPDeathNotifier(new MPDeathNotifier(ctx))
Saurabh Shah86c17292013-02-08 15:24:13 -080045{
46 ALOGD_IF(QCLIENT_DEBUG, "QClient Constructor invoked");
47}
48
49QClient::~QClient()
50{
51 ALOGD_IF(QCLIENT_DEBUG,"QClient Destructor invoked");
52}
53
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -080054status_t QClient::notifyCallback(uint32_t msg, uint32_t value) {
Naseer Ahmed58780b92013-07-29 17:41:40 -040055
56 if (msg > IQService::VPU_COMMAND_LIST_START &&
57 msg < IQService::VPU_COMMAND_LIST_END) {
58 return vpuCommand(msg, value);
59 }
60
Saurabh Shah86c17292013-02-08 15:24:13 -080061 switch(msg) {
62 case IQService::SECURING:
63 securing(value);
64 break;
65 case IQService::UNSECURING:
66 unsecuring(value);
67 break;
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -080068 case IQService::SCREEN_REFRESH:
69 return screenRefresh();
70 break;
Arun Kumar K.R4b79e272013-05-21 10:41:02 -070071 case IQService::EXTERNAL_ORIENTATION:
72 setExtOrientation(value);
73 break;
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -070074 case IQService::BUFFER_MIRRORMODE:
75 setBufferMirrorMode(value);
76 break;
Saurabh Shah86c17292013-02-08 15:24:13 -080077 default:
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -080078 return NO_ERROR;
Saurabh Shah86c17292013-02-08 15:24:13 -080079 }
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -080080 return NO_ERROR;
Saurabh Shah86c17292013-02-08 15:24:13 -080081}
82
83void QClient::securing(uint32_t startEnd) {
Saurabh Shahb39f8152013-08-22 10:21:44 -070084 Locker::Autolock _sl(mHwcContext->mDrawLock);
Saurabh Shahc2125772013-03-15 16:49:50 -070085 //The only way to make this class in this process subscribe to media
86 //player's death.
87 IMediaDeathNotifier::getMediaPlayerService();
88
Saurabh Shah86c17292013-02-08 15:24:13 -080089 mHwcContext->mSecuring = startEnd;
90 //We're done securing
91 if(startEnd == IQService::END)
92 mHwcContext->mSecureMode = true;
93 if(mHwcContext->proc)
94 mHwcContext->proc->invalidate(mHwcContext->proc);
95}
96
97void QClient::unsecuring(uint32_t startEnd) {
Saurabh Shahb39f8152013-08-22 10:21:44 -070098 Locker::Autolock _sl(mHwcContext->mDrawLock);
Saurabh Shah86c17292013-02-08 15:24:13 -080099 mHwcContext->mSecuring = startEnd;
100 //We're done unsecuring
101 if(startEnd == IQService::END)
102 mHwcContext->mSecureMode = false;
103 if(mHwcContext->proc)
104 mHwcContext->proc->invalidate(mHwcContext->proc);
105}
106
Saurabh Shah7128e502013-02-20 13:24:48 -0800107void QClient::MPDeathNotifier::died() {
Saurabh Shahb39f8152013-08-22 10:21:44 -0700108 Locker::Autolock _sl(mHwcContext->mDrawLock);
Saurabh Shah7128e502013-02-20 13:24:48 -0800109 ALOGD_IF(QCLIENT_DEBUG, "Media Player died");
110 mHwcContext->mSecuring = false;
111 mHwcContext->mSecureMode = false;
112 if(mHwcContext->proc)
113 mHwcContext->proc->invalidate(mHwcContext->proc);
114}
115
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -0800116android::status_t QClient::screenRefresh() {
117 status_t result = NO_INIT;
118#ifdef QCOM_BSP
119 if(mHwcContext->proc) {
120 mHwcContext->proc->invalidate(mHwcContext->proc);
121 result = NO_ERROR;
122 }
123#endif
124 return result;
125}
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700126
Naseer Ahmed58780b92013-07-29 17:41:40 -0400127android::status_t QClient::vpuCommand(uint32_t command, uint32_t setting) {
128 status_t result = NO_INIT;
129#ifdef QCOM_BSP
130#ifdef VPU_TARGET
131 result = mHwcContext->mVPUClient->processCommand(command, setting);
132#endif
133#endif
134 return result;
135}
136
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700137void QClient::setExtOrientation(uint32_t orientation) {
138 mHwcContext->mExtOrientation = orientation;
139}
140
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700141void QClient::setBufferMirrorMode(uint32_t enable) {
142 mHwcContext->mBufferMirrorMode = enable;
143}
144
Saurabh Shah86c17292013-02-08 15:24:13 -0800145}