blob: 65707e22b942735cc0a60009c714ed2af07992ad [file] [log] [blame]
Zohaib Alam83ea46d2015-03-23 15:44:19 -04001/*
2 * Copyright (c) 2014, 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 SERVICES; 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_qdcm.h>
31#include <hwc_utils.h>
32#include <utils/String16.h>
33#include <mdp_version.h>
34#include "mode_manager.h"
35#include "libmm-disp-apis.h"
36#include "IQService.h"
37
38using namespace android;
39using namespace qService;
40using namespace qhwc;
41using namespace qmode;
42
43namespace qQdcm {
44//----------------------------------------------------------------------------
45void qdcmInitContext(hwc_context_t *ctx)
46{
47 loadQdcmLibrary(ctx);
48}
49
50void qdcmCloseContext(hwc_context_t *ctx)
51{
52 if (ctx->mQdcmInfo.mQdcmMode) {
53 unloadQdcmLibrary(ctx);
54 }
55}
56
57void qdcmApplyDefaultAfterBootAnimationDone(hwc_context_t *ctx)
58{
59 if (ctx->mQdcmInfo.mQdcmMode)
60 ctx->mQdcmInfo.mQdcmMode->applyDefaultMode(0);
61}
62
63static void qdcmSetActiveMode(hwc_context_t *ctx, const Parcel *in, Parcel *out)
64{
65 int ret = 0;
66
67 if (ctx->mQdcmInfo.mQdcmMode && in && out) {
68
69 struct PARAMS {
70 int dispid;
71 int mode_id;
72 } params = { in->readInt32(), in->readInt32()};
73
74 ret = ctx->mQdcmInfo.mQdcmMode->requestRoute((int)CMD_SET_ACTIVE_MODE,
75 (void *)&params, (void *)NULL);
76
77 out->writeInt32(ret); //return operation status via binder.
78 }
79}
80
81static void qdcmSetDefaultMode(hwc_context_t *ctx, const Parcel *in, Parcel *out)
82{
83 int ret = 0;
84
85 if (ctx->mQdcmInfo.mQdcmMode && in && out) {
86
87 struct PARAMS {
88 int dispid;
89 int mode_id;
90 } params = { in->readInt32(), in->readInt32()};
91
92 ret = ctx->mQdcmInfo.mQdcmMode->requestRoute((int)CMD_SET_DEFAULT_MODE,
93 (void *)&params, (void *)NULL);
94
95 out->writeInt32(ret); //return operation status via binder.
96 }
97}
98
99static void qdcmGetDefaultMode(hwc_context_t *ctx,
100 const Parcel *in, Parcel *out)
101{
102 int ret = 0;
103
104 if (ctx->mQdcmInfo.mQdcmMode && in && out) {
105
106 struct PARAMS {
107 int dispid;
108 } params = { in->readInt32() };
109 int modeid = 0;
110
111 ret = ctx->mQdcmInfo.mQdcmMode->requestRoute((int)CMD_GET_DEFAULT_MODE,
112 (const void *)&params, (void *)&modeid);
113
114 out->writeInt32(modeid);
115 out->writeInt32(ret); //return operation status via binder.
116 }
117}
118
119static void qdcmGetColorBalanceRange(hwc_context_t *ctx,
120 const Parcel *in, Parcel *out)
121{
122}
123
124static void qdcmGetColorBalance(hwc_context_t *ctx,
125 const Parcel *in, Parcel *out)
126{
127 int ret = 0;
128
129 if (ctx->mQdcmInfo.mQdcmMode && in && out) {
130
131 struct PARAMS {
132 int dispid;
133 } params = { in->readInt32() };
134 int warmness = 0;
135
136 ret = ctx->mQdcmInfo.mQdcmMode->requestRoute((int)CMD_GET_CB,
137 (const void *)&params, (void *)&warmness);
138
139 out->writeInt32(warmness);
140 out->writeInt32(ret); //return operation status via binder.
141 }
142}
143
144static void qdcmSetColorBalance(hwc_context_t *ctx,
145 const Parcel *in, Parcel *out)
146{
147 int ret = 0;
148
149 if (ctx->mQdcmInfo.mQdcmMode && in && out) {
150
151 struct PARAMS {
152 int dispid;
153 int warmness;
154 } params = { in->readInt32(), in->readInt32() };
155
156 ALOGD_IF(QDCM_DEBUG, "%s dispID = %d, warmness = %d\n",
157 __FUNCTION__, params.dispid, params.warmness);
158
159 ret = ctx->mQdcmInfo.mQdcmMode->requestRoute((int)CMD_SET_CB,
160 (const void *)&params, NULL);
161
162 out->writeInt32(ret); //return operation status via binder.
163 }
164}
165
166static void qdcmSaveModeV2(hwc_context_t *ctx, const Parcel *in, Parcel *out)
167{
168 int ret = 0;
169
170 if (ctx->mQdcmInfo.mQdcmMode && in && out) {
171
172 struct PARAMS {
173 int dispid;
174 const char *name;
175 int mode_id;
176 } params = { in->readInt32(), in->readCString(), in->readInt32() };
177 int value = 0;
178
179 ret = ctx->mQdcmInfo.mQdcmMode->requestRoute((int)CMD_SAVE_MODE_V2,
180 (const void *)&params, (void *)&value);
181
182 out->writeInt32(value);
183 out->writeInt32(ret); //return operation status via binder.
184 }
185}
186
187static void qdcmSetPaConfig(hwc_context_t *ctx, const Parcel *in, Parcel *out)
188{
189 int ret = 0;
190
191 if (ctx->mQdcmInfo.mQdcmMode && in && out) {
192
193 struct PARAMS {
194 int id;
195 struct disp_pa_config pa;
196 } params;
197 int value = 0;
198
199 params.id = in->readInt32();
200 params.pa.ops = in->readInt32();
201 params.pa.data.hue = in->readInt32();
202 params.pa.data.saturation = in->readInt32();
203 params.pa.data.value = in->readInt32();
204 params.pa.data.contrast = in->readInt32();
205 params.pa.data.sat_thresh = in->readInt32();
206
207 ret = ctx->mQdcmInfo.mQdcmMode->requestRoute((int)CMD_SET_PA_CONFIG,
208 (const void *)&params, NULL);
209
210 out->writeInt32(ret); //return operation status via binder.
211 }
212}
213
214static void qdcmGetPaConfig(hwc_context_t *ctx, const Parcel *in, Parcel *out)
215{
216 int ret = 0;
217
218 if (ctx->mQdcmInfo.mQdcmMode && in && out) {
219
220 struct PARAMS {
221 int dispid;
222 } params = { in->readInt32() };
223 struct disp_pa_config value;
224
225 ret = ctx->mQdcmInfo.mQdcmMode->requestRoute((int)CMD_GET_PA_CONFIG,
226 (const void *)&params, (void *)&value);
227
228 out->writeInt32(value.ops);
229 out->writeInt32(value.data.hue);
230 out->writeInt32(value.data.saturation);
231 out->writeInt32(value.data.value);
232 out->writeInt32(value.data.contrast);
233 out->writeInt32(value.data.sat_thresh);
234
235 out->writeInt32(ret); //return operation status via binder.
236 }
237}
238
239static void qdcmGetPaRange(hwc_context_t *ctx, const Parcel *in, Parcel *out)
240{
241 int ret = 0;
242
243 if (ctx->mQdcmInfo.mQdcmMode && in && out) {
244
245 struct PARAMS {
246 int dispid;
247 } params = { in->readInt32() };
248
249 struct disp_pa_range value;
250
251 ret = ctx->mQdcmInfo.mQdcmMode->requestRoute((int)CMD_GET_PA_RANGE,
252 (const void *)&params, (void *)&value);
253
254 out->writeInt32(value.max.hue);
255 out->writeInt32(value.max.saturation);
256 out->writeInt32(value.max.value);
257 out->writeInt32(value.max.contrast);
258 out->writeInt32(value.max.sat_thresh);
259 out->writeInt32(value.min.hue);
260 out->writeInt32(value.min.saturation);
261 out->writeInt32(value.min.value);
262 out->writeInt32(value.min.contrast);
263 out->writeInt32(value.min.sat_thresh);
264
265 out->writeInt32(ret); //return operation status via binder.
266 }
267}
268
269void qdcmCmdsHandler(hwc_context_t *ctx, const Parcel *in, Parcel *out)
270{
271 int subcmd = in->readInt32();
272
273 ALOGD_IF(QDCM_DEBUG, "%s enter subcmd = %d\n", __FUNCTION__, subcmd);
274 switch (subcmd) {
275 case CMD_SET_ACTIVE_MODE:
276 qdcmSetActiveMode(ctx, in, out);
277 break;
278 case CMD_SET_DEFAULT_MODE:
279 qdcmSetDefaultMode(ctx, in, out);
280 break;
281 case CMD_GET_DEFAULT_MODE:
282 qdcmGetDefaultMode(ctx, in, out);
283 break;
284 case CMD_GET_CB_RANGE:
285 qdcmGetColorBalanceRange(ctx, in, out);
286 break;
287 case CMD_GET_CB:
288 qdcmGetColorBalance(ctx, in, out);
289 break;
290 case CMD_SET_CB:
291 qdcmSetColorBalance(ctx, in, out);
292 break;
293 case CMD_SAVE_MODE_V2:
294 qdcmSaveModeV2(ctx, in, out);
295 break;
296 case CMD_SET_PA_CONFIG:
297 qdcmSetPaConfig(ctx, in, out);
298 break;
299 case CMD_GET_PA_CONFIG:
300 qdcmGetPaConfig(ctx, in, out);
301 break;
302 case CMD_GET_PA_RANGE:
303 qdcmGetPaRange(ctx, in, out);
304 break;
305 }
306}
307
308
309} //namespace qQdcm
310