blob: 3b98788567defc6d31a5f3eb7069e8ab9a9e0ab3 [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
Naseer Ahmed4957c522013-11-12 18:07:15 -050054static void securing(hwc_context_t *ctx, uint32_t startEnd) {
55 Locker::Autolock _sl(ctx->mDrawLock);
Saurabh Shahc2125772013-03-15 16:49:50 -070056 //The only way to make this class in this process subscribe to media
57 //player's death.
58 IMediaDeathNotifier::getMediaPlayerService();
59
Naseer Ahmed4957c522013-11-12 18:07:15 -050060 ctx->mSecuring = startEnd;
Saurabh Shah86c17292013-02-08 15:24:13 -080061 //We're done securing
62 if(startEnd == IQService::END)
Naseer Ahmed4957c522013-11-12 18:07:15 -050063 ctx->mSecureMode = true;
64 if(ctx->proc)
65 ctx->proc->invalidate(ctx->proc);
Saurabh Shah86c17292013-02-08 15:24:13 -080066}
67
Naseer Ahmed4957c522013-11-12 18:07:15 -050068static void unsecuring(hwc_context_t *ctx, uint32_t startEnd) {
69 Locker::Autolock _sl(ctx->mDrawLock);
70 ctx->mSecuring = startEnd;
Saurabh Shah86c17292013-02-08 15:24:13 -080071 //We're done unsecuring
72 if(startEnd == IQService::END)
Naseer Ahmed4957c522013-11-12 18:07:15 -050073 ctx->mSecureMode = false;
74 if(ctx->proc)
75 ctx->proc->invalidate(ctx->proc);
Saurabh Shah86c17292013-02-08 15:24:13 -080076}
77
Saurabh Shah7128e502013-02-20 13:24:48 -080078void QClient::MPDeathNotifier::died() {
Saurabh Shahb39f8152013-08-22 10:21:44 -070079 Locker::Autolock _sl(mHwcContext->mDrawLock);
Saurabh Shah7128e502013-02-20 13:24:48 -080080 ALOGD_IF(QCLIENT_DEBUG, "Media Player died");
81 mHwcContext->mSecuring = false;
82 mHwcContext->mSecureMode = false;
83 if(mHwcContext->proc)
84 mHwcContext->proc->invalidate(mHwcContext->proc);
85}
86
Naseer Ahmed4957c522013-11-12 18:07:15 -050087static android::status_t screenRefresh(hwc_context_t *ctx) {
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -080088 status_t result = NO_INIT;
89#ifdef QCOM_BSP
Naseer Ahmed4957c522013-11-12 18:07:15 -050090 if(ctx->proc) {
91 ctx->proc->invalidate(ctx->proc);
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -080092 result = NO_ERROR;
93 }
94#endif
95 return result;
96}
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070097
Naseer Ahmed4957c522013-11-12 18:07:15 -050098static android::status_t vpuCommand(hwc_context_t *ctx,
99 uint32_t command,
100 const Parcel* inParcel,
101 Parcel* outParcel) {
Naseer Ahmed58780b92013-07-29 17:41:40 -0400102 status_t result = NO_INIT;
103#ifdef QCOM_BSP
104#ifdef VPU_TARGET
Naseer Ahmed4957c522013-11-12 18:07:15 -0500105 result = ctx->mVPUClient->processCommand(command, inParcel, outParcel);
Naseer Ahmed58780b92013-07-29 17:41:40 -0400106#endif
107#endif
108 return result;
109}
110
Naseer Ahmed4957c522013-11-12 18:07:15 -0500111static void setExtOrientation(hwc_context_t *ctx, uint32_t orientation) {
112 ctx->mExtOrientation = orientation;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700113}
114
Naseer Ahmed4957c522013-11-12 18:07:15 -0500115static void setBufferMirrorMode(hwc_context_t *ctx, uint32_t enable) {
116 ctx->mBufferMirrorMode = enable;
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700117}
118
Naseer Ahmed4957c522013-11-12 18:07:15 -0500119status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel,
120 Parcel* outParcel) {
121
122 if (command > IQService::VPU_COMMAND_LIST_START &&
123 command < IQService::VPU_COMMAND_LIST_END) {
124 return vpuCommand(mHwcContext, command, inParcel, outParcel);
125 }
126
127 switch(command) {
128 case IQService::SECURING:
129 securing(mHwcContext, inParcel->readInt32());
130 break;
131 case IQService::UNSECURING:
132 unsecuring(mHwcContext, inParcel->readInt32());
133 break;
134 case IQService::SCREEN_REFRESH:
135 return screenRefresh(mHwcContext);
136 break;
137 case IQService::EXTERNAL_ORIENTATION:
138 setExtOrientation(mHwcContext, inParcel->readInt32());
139 break;
140 case IQService::BUFFER_MIRRORMODE:
141 setBufferMirrorMode(mHwcContext, inParcel->readInt32());
142 break;
143 default:
144 return NO_ERROR;
145 }
146 return NO_ERROR;
147}
148
149
150
Saurabh Shah86c17292013-02-08 15:24:13 -0800151}