• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <stdint.h>
18 #include <sys/types.h>
19 
20 #include <utils/Errors.h>
21 #include <utils/RefBase.h>
22 #include <utils/Timers.h>
23 
24 #include <binder/Parcel.h>
25 #include <binder/IInterface.h>
26 
27 #include "IExynosHWC.h"
28 
29 #include <vector>
30 
31 #define RET_IF_ERR(expr)      \
32     do {                      \
33         auto err = (expr);    \
34         if (err) [[unlikely]] \
35             return err;       \
36     } while (0)
37 
38 namespace android {
39 
40 enum {
41     ADD_VIRTUAL_DISPLAY_DEVICE = 0,
42     DESTROY_VIRTUAL_DISPLAY_DEVICE,
43     SET_WFD_MODE,
44     GET_WFD_MODE,
45     SEND_WFD_COMMAND,
46     SET_SECURE_VDS_MODE,
47     SET_WFD_OUTPUT_RESOLUTION,
48     GET_WFD_OUTPUT_RESOLUTION,
49     SET_PRESENTATION_MODE,
50     GET_PRESENTATION_MODE,
51     SET_VDS_GLES_FORMAT,
52     HWC_CONTROL,
53     SET_BOOT_FINISHED,
54     SET_VIRTUAL_HPD,
55     GET_EXTERNAL_DISPLAY_CONFIG,
56     SET_EXTERNAL_DISPLAY_CONFIG,
57     ENABLE_MPP,
58     SET_EXTERNAL_VSYNC,
59     SET_DDISCALER,
60     GET_EXTERNAL_HDR_CAPA,
61     SET_SCALE_DOWN_RATIO,
62     SET_HWC_DEBUG = 105,
63     GET_HWC_DEBUG = 106,
64     SET_HWC_FENCE_DEBUG = 107,
65     GET_HWC_FENCE_DEBUG = 108,
66     SET_DISPLAY_DEVICE_MODE = 1000,
67     SET_PANEL_GAMMA_TABLE_SOURCE = 1001,
68     SET_DISPLAY_BRIGHTNESS = 1002,
69     SET_DISPLAY_LHBM = 1003,
70     SET_LBE_CTRL = 1004,
71     SET_MIN_IDLE_REFRESH_RATE = 1005,
72     SET_REFRESH_RATE_THROTTLE = 1006,
73     SET_DISPLAY_RCDLAYER_ENABLED = 1007,
74     TRIGGER_DISPLAY_IDLE_ENTER = 1008,
75     SET_DISPLAY_DBM = 1009,
76     SET_DISPLAY_MULTI_THREADED_PRESENT = 1010,
77     TRIGGER_REFRESH_RATE_INDICATOR_UPDATE = 1011,
78     IGNORE_DISPLAY_BRIGHTNESS_UPDATE_REQUESTS = 1012,
79     SET_DISPLAY_BRIGHTNESS_NITS = 1013,
80     SET_DISPLAY_BRIGHTNESS_DBV = 1014,
81     DUMP_BUFFERS = 1015,
82     SET_PRESENT_TIMEOUT_PARAMETERS = 1016,
83     SET_PRESENT_TIMEOUT_CONTROLLER = 1017,
84     SET_FIXED_TE2_RATE = 1018,
85 };
86 
87 class BpExynosHWCService : public BpInterface<IExynosHWCService> {
88 public:
BpExynosHWCService(const sp<IBinder> & impl)89     BpExynosHWCService(const sp<IBinder>& impl)
90         : BpInterface<IExynosHWCService>(impl)
91     {
92     }
93 
addVirtualDisplayDevice()94     virtual int addVirtualDisplayDevice()
95     {
96         Parcel data, reply;
97         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
98         int result = remote()->transact(ADD_VIRTUAL_DISPLAY_DEVICE, data, &reply);
99         if (result == NO_ERROR)
100             result = reply.readInt32();
101         else
102             ALOGE("ADD_VIRTUAL_DISPLAY_DEVICE transact error(%d)", result);
103         return result;
104     }
105 
destroyVirtualDisplayDevice()106     virtual int destroyVirtualDisplayDevice()
107     {
108         Parcel data, reply;
109         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
110         int result = remote()->transact(DESTROY_VIRTUAL_DISPLAY_DEVICE, data, &reply);
111         if (result == NO_ERROR)
112             result = reply.readInt32();
113         else
114             ALOGE("DESTROY_VIRTUAL_DISPLAY_DEVICE transact error(%d)", result);
115         return result;
116     }
117 
setWFDMode(unsigned int mode)118     virtual int setWFDMode(unsigned int mode)
119     {
120         Parcel data, reply;
121         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
122         data.writeInt32(mode);
123         int result = remote()->transact(SET_WFD_MODE, data, &reply);
124         if (result == NO_ERROR)
125             result = reply.readInt32();
126         else
127             ALOGE("SET_WFD_MODE transact error(%d)", result);
128         return result;
129     }
130 
getWFDMode()131     virtual int getWFDMode()
132     {
133         Parcel data, reply;
134         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
135         int result = remote()->transact(GET_WFD_MODE, data, &reply);
136         if (result == NO_ERROR)
137             result = reply.readInt32();
138         else
139             ALOGE("GET_WFD_MODE transact error(%d)", result);
140         return result;
141     }
142 
sendWFDCommand(int32_t cmd,int32_t ext1,int32_t ext2)143     virtual int sendWFDCommand(int32_t cmd, int32_t ext1, int32_t ext2)
144     {
145         Parcel data, reply;
146         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
147         data.writeInt32(cmd);
148         data.writeInt32(ext1);
149         data.writeInt32(ext2);
150         int result = remote()->transact(SEND_WFD_COMMAND, data, &reply);
151         if (result == NO_ERROR)
152             result = reply.readInt32();
153         else
154             ALOGE("SEND_WFD_COMMAND transact error(%d)", result);
155         return result;
156     }
157 
setSecureVDSMode(unsigned int mode)158     virtual int setSecureVDSMode(unsigned int mode)
159     {
160         Parcel data, reply;
161         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
162         data.writeInt32(mode);
163         int result = remote()->transact(SET_SECURE_VDS_MODE, data, &reply);
164         if (result == NO_ERROR)
165             result = reply.readInt32();
166         else
167             ALOGE("SET_SECURE_VDS_MODE transact error(%d)", result);
168         return result;
169     }
170 
setWFDOutputResolution(unsigned int width,unsigned int height)171     virtual int setWFDOutputResolution(unsigned int width, unsigned int height)
172     {
173         Parcel data, reply;
174         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
175         data.writeInt32(width);
176         data.writeInt32(height);
177         int result = remote()->transact(SET_WFD_OUTPUT_RESOLUTION, data, &reply);
178         if (result == NO_ERROR)
179             result = reply.readInt32();
180         else
181             ALOGE("SET_WFD_OUTPUT_RESOLUTION transact error(%d)", result);
182         return result;
183     }
184 
getWFDOutputResolution(unsigned int * width,unsigned int * height)185     virtual int getWFDOutputResolution(unsigned int* width, unsigned int* height) {
186         Parcel data, reply;
187         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
188         int result = remote()->transact(GET_WFD_OUTPUT_RESOLUTION, data, &reply);
189         if (result == NO_ERROR) {
190             *width  = reply.readInt32();
191             *height = reply.readInt32();
192             result = reply.readInt32();
193         } else
194             ALOGE("GET_WFD_OUTPUT_RESOLUTION transact error(%d)", result);
195         return result;
196     }
197 
setPresentationMode(bool use)198     virtual void setPresentationMode(bool use)
199     {
200         Parcel data, reply;
201         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
202         data.writeInt32(use);
203         int result = remote()->transact(SET_PRESENTATION_MODE, data, &reply);
204         if (result != NO_ERROR)
205             ALOGE("SET_PRESENTATION_MODE transact error(%d)", result);
206     }
207 
getPresentationMode(void)208     virtual int getPresentationMode(void)
209     {
210         Parcel data, reply;
211         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
212         int result = remote()->transact(GET_PRESENTATION_MODE, data, &reply);
213         if (result == NO_ERROR)
214             result = reply.readInt32();
215         else
216             ALOGE("GET_PRESENTATION_MODE transact error(%d)", result);
217         return result;
218     }
219 
setVDSGlesFormat(int format)220     virtual int setVDSGlesFormat(int format)
221     {
222         Parcel data, reply;
223         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
224         data.writeInt32(format);
225         int result = remote()->transact(SET_VDS_GLES_FORMAT, data, &reply);
226         if (result == NO_ERROR)
227             result = reply.readInt32();
228         else
229             ALOGE("SET_VDS_GLES_FORMAT transact error(%d)", result);
230         return result;
231     }
232 
getExternalDisplayConfigs()233     virtual int getExternalDisplayConfigs()
234     {
235         Parcel data, reply;
236         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
237         int result = remote()->transact(GET_EXTERNAL_DISPLAY_CONFIG, data, &reply);
238         if (result == NO_ERROR)
239             result = reply.readInt32();
240         else
241             ALOGE("GET_EXTERNAL_DISPLAY_CONFIG transact error(%d)", result);
242         return result;
243     }
244 
setExternalDisplayConfig(unsigned int index)245     virtual int setExternalDisplayConfig(unsigned int index)
246     {
247         Parcel data, reply;
248         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
249         data.writeInt32(index);
250         int result = remote()->transact(SET_EXTERNAL_DISPLAY_CONFIG, data, &reply);
251         if (result == NO_ERROR)
252             result = reply.readInt32();
253         else
254             ALOGE("SET_EXTERNAL_DISPLAY_CONFIG transact error(%d)", result);
255         return result;
256     }
257 
setExternalVsyncEnabled(unsigned int index)258     virtual int setExternalVsyncEnabled(unsigned int index)
259     {
260         Parcel data, reply;
261         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
262         data.writeInt32(index);
263         int result = remote()->transact(SET_EXTERNAL_VSYNC, data, &reply);
264         if (result == NO_ERROR)
265             result = reply.readInt32();
266         else
267             ALOGE("SET_EXTERNAL_VSYNC transact error(%d)", result);
268         return result;
269     }
270 
getExternalHdrCapabilities()271     virtual int getExternalHdrCapabilities()
272     {
273         Parcel data, reply;
274         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
275         int result = remote()->transact(GET_EXTERNAL_HDR_CAPA, data, &reply);
276         if (result == NO_ERROR)
277             result = reply.readInt32();
278         else
279             ALOGE("GET_EXTERNAL_HDR_CAPA transact error(%d)", result);
280 
281         return result;
282     }
283 
setBootFinished()284     virtual void setBootFinished()
285     {
286         Parcel data, reply;
287         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
288         int result = remote()->transact(SET_BOOT_FINISHED, data, &reply);
289         if (result != NO_ERROR)
290             ALOGE("SET_BOOT_FINISHED transact error(%d)", result);
291     }
292 
enableMPP(uint32_t physicalType,uint32_t physicalIndex,uint32_t logicalIndex,uint32_t enable)293     virtual void enableMPP(uint32_t physicalType, uint32_t physicalIndex, uint32_t logicalIndex, uint32_t enable)
294     {
295         Parcel data, reply;
296         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
297         data.writeInt32(physicalType);
298         data.writeInt32(physicalIndex);
299         data.writeInt32(logicalIndex);
300         data.writeInt32(enable);
301         int result = remote()->transact(ENABLE_MPP, data, &reply);
302         if (result != NO_ERROR)
303             ALOGE("ENABLE_MPP transact error(%d)", result);
304     }
305 
setScaleDownRatio(uint32_t physicalType,uint32_t physicalIndex,uint32_t logicalIndex,uint32_t scaleDownRatio)306     virtual void setScaleDownRatio(uint32_t physicalType, uint32_t physicalIndex,
307             uint32_t logicalIndex, uint32_t scaleDownRatio)
308     {
309         Parcel data, reply;
310         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
311         data.writeInt32(physicalType);
312         data.writeInt32(physicalIndex);
313         data.writeInt32(logicalIndex);
314         data.writeInt32(scaleDownRatio);
315         int result = remote()->transact(SET_SCALE_DOWN_RATIO, data, &reply);
316         if (result != NO_ERROR)
317             ALOGE("SET_SCALE_DOWN_RATIO transact error(%d)", result);
318     }
319 
setLbeCtrl(uint32_t display_id,uint32_t state,uint32_t lux)320     virtual void setLbeCtrl(uint32_t display_id, uint32_t state, uint32_t lux) {
321         Parcel data, reply;
322         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
323         data.writeInt32(display_id);
324         data.writeInt32(state);
325         data.writeInt32(lux);
326         int result = remote()->transact(SET_LBE_CTRL, data, &reply);
327         if (result != NO_ERROR) ALOGE("SET_LBE_CTRL transact error(%d)", result);
328     }
329 
setHWCDebug(int debug)330     virtual void setHWCDebug(int debug)
331     {
332         Parcel data, reply;
333         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
334         data.writeInt32(debug);
335         int result = remote()->transact(SET_HWC_DEBUG, data, &reply);
336         if (result != NO_ERROR)
337             ALOGE("SET_HWC_DEBUG transact error(%d)", result);
338     }
339 
getHWCDebug()340     virtual uint32_t getHWCDebug()
341     {
342         Parcel data, reply;
343         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
344         int result = remote()->transact(GET_HWC_DEBUG, data, &reply);
345         if (result == NO_ERROR)
346             result = reply.readInt32();
347         else {
348             ALOGE("GET_HWC_DEBUG transact error(%d)", result);
349         }
350         return result;
351     }
352 
setHWCFenceDebug(uint32_t fenceNum,uint32_t ipNum,uint32_t mode)353     virtual void setHWCFenceDebug(uint32_t fenceNum, uint32_t ipNum, uint32_t mode)
354     {
355         Parcel data, reply;
356         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
357         data.writeInt32(fenceNum);
358         data.writeInt32(ipNum);
359         data.writeInt32(mode);
360         remote()->transact(SET_HWC_FENCE_DEBUG, data, &reply);
361     }
362 
getHWCFenceDebug()363     virtual void getHWCFenceDebug()
364     {
365         Parcel data, reply;
366         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
367         remote()->transact(GET_HWC_FENCE_DEBUG, data, &reply);
368     }
369 
setHWCCtl(uint32_t display,uint32_t ctrl,int32_t val)370     virtual int setHWCCtl(uint32_t display, uint32_t ctrl, int32_t val) {
371         Parcel data, reply;
372         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
373         data.writeInt32(display);
374         data.writeInt32(ctrl);
375         data.writeInt32(val);
376         int result = remote()->transact(HWC_CONTROL, data, &reply);
377         if (result == NO_ERROR)
378             result = reply.readInt32();
379         else
380             ALOGE("HWC_CONTROL transact error(%d)", result);
381         return result;
382     };
383 
setDDIScaler(uint32_t displayId,uint32_t width,uint32_t height)384     virtual int setDDIScaler(uint32_t displayId, uint32_t width, uint32_t height) {
385         Parcel data, reply;
386         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
387         data.writeUint32(displayId);
388         data.writeUint32(width);
389         data.writeUint32(height);
390         int result = remote()->transact(SET_DDISCALER, data, &reply);
391         if (result == NO_ERROR)
392             result = reply.readInt32();
393         else
394             ALOGE("SET_DDISCALER transact error(%d)", result);
395         return result;
396     }
397 
setDisplayDeviceMode(int32_t display_id,int32_t mode)398     int32_t setDisplayDeviceMode(int32_t display_id, int32_t mode)
399     {
400         ALOGD("null func: %s(%d %d)", __func__, display_id, mode);
401         return NO_ERROR;
402     }
403 
setPanelGammaTableSource(int32_t display_id,int32_t type,int32_t source)404     virtual int32_t setPanelGammaTableSource(int32_t display_id, int32_t type, int32_t source) {
405         ALOGD("null func: %s(%d %d %d)", __func__, display_id, type, source);
406         return NO_ERROR;
407     }
408 
setDisplayBrightness(int32_t display_id,float brightness)409     virtual int32_t setDisplayBrightness(int32_t display_id, float brightness) {
410         Parcel data, reply;
411         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
412         data.writeInt32(display_id);
413         data.writeFloat(brightness);
414         int result = remote()->transact(SET_DISPLAY_BRIGHTNESS, data, &reply);
415         if (result)
416             ALOGE("SET_DISPLAY_BRIGHTNESS transact error(%d)", result);
417         return result;
418     }
419 
ignoreDisplayBrightnessUpdateRequests(int32_t displayId,bool ignore)420     virtual int32_t ignoreDisplayBrightnessUpdateRequests(int32_t displayId, bool ignore) {
421         Parcel data, reply;
422         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
423         data.writeInt32(displayId);
424         data.writeBool(ignore);
425         int result = remote()->transact(IGNORE_DISPLAY_BRIGHTNESS_UPDATE_REQUESTS, data, &reply);
426         if (result) ALOGE("IGNORE_DISPLAY_BRIGHTNESS_UPDATE_REQUESTS transact error(%d)", result);
427         return result;
428     }
429 
setDisplayBrightnessNits(int32_t displayId,float nits)430     virtual int32_t setDisplayBrightnessNits(int32_t displayId, float nits) {
431         Parcel data, reply;
432         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
433         data.writeInt32(displayId);
434         data.writeFloat(nits);
435         int result = remote()->transact(SET_DISPLAY_BRIGHTNESS_NITS, data, &reply);
436         if (result) ALOGE("SET_DISPLAY_BRIGHTNESS_NITS transact error(%d)", result);
437         return result;
438     }
439 
setDisplayBrightnessDbv(int32_t displayId,uint32_t dbv)440     virtual int32_t setDisplayBrightnessDbv(int32_t displayId, uint32_t dbv) {
441         Parcel data, reply;
442         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
443         data.writeInt32(displayId);
444         data.writeUint32(dbv);
445         int result = remote()->transact(SET_DISPLAY_BRIGHTNESS_DBV, data, &reply);
446         if (result) {
447             ALOGE("SET_DISPLAY_BRIGHTNESS_DBV transact error(%d)", result);
448         }
449         return result;
450     }
451 
setDisplayLhbm(int32_t display_id,uint32_t on)452     virtual int32_t setDisplayLhbm(int32_t display_id, uint32_t on) {
453         Parcel data, reply;
454         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
455         data.writeInt32(display_id);
456         data.writeInt32(on);
457         int result = remote()->transact(SET_DISPLAY_LHBM, data, &reply);
458         if (result) ALOGE("SET_DISPLAY_LHBM transact error(%d)", result);
459         return result;
460     }
461 
setMinIdleRefreshRate(uint32_t display_id,int32_t fps)462     virtual int32_t setMinIdleRefreshRate(uint32_t display_id, int32_t fps) {
463         Parcel data, reply;
464         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
465         data.writeUint32(display_id);
466         data.writeInt32(fps);
467         int result = remote()->transact(SET_MIN_IDLE_REFRESH_RATE, data, &reply);
468         if (result) ALOGE("SET_MIN_IDLE_REFRESH_RATE transact error(%d)", result);
469         return result;
470     }
471 
setRefreshRateThrottle(uint32_t display_id,int32_t delay_ms)472     virtual int32_t setRefreshRateThrottle(uint32_t display_id, int32_t delay_ms) {
473         Parcel data, reply;
474         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
475         data.writeUint32(display_id);
476         data.writeInt32(delay_ms);
477         int result = remote()->transact(SET_REFRESH_RATE_THROTTLE, data, &reply);
478         if (result) ALOGE("SET_REFRESH_RATE_THROTTLE transact error(%d)", result);
479         return result;
480     }
481 
setDisplayRCDLayerEnabled(uint32_t displayIndex,bool enable)482     int32_t setDisplayRCDLayerEnabled(uint32_t displayIndex, bool enable) override {
483         Parcel data, reply;
484         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
485         data.writeUint32(displayIndex);
486         data.writeInt32(enable);
487 
488         auto result = remote()->transact(SET_DISPLAY_RCDLAYER_ENABLED, data, &reply);
489         ALOGE_IF(result != NO_ERROR, "SET_DISPLAY_RCDLAYER_ENABLED transact error(%d)", result);
490         return result;
491     }
492 
triggerDisplayIdleEnter(uint32_t displayIndex,uint32_t idleTeRefreshRate)493     int32_t triggerDisplayIdleEnter(uint32_t displayIndex, uint32_t idleTeRefreshRate) override {
494         Parcel data, reply;
495         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
496         data.writeUint32(displayIndex);
497         data.writeUint32(idleTeRefreshRate);
498 
499         auto result = remote()->transact(TRIGGER_DISPLAY_IDLE_ENTER, data, &reply);
500         ALOGE_IF(result != NO_ERROR, "TRIGGER_DISPLAY_IDLE_ENTER transact error(%d)", result);
501         return result;
502     }
503 
setDisplayDbm(int32_t display_id,uint32_t on)504     virtual int32_t setDisplayDbm(int32_t display_id, uint32_t on) {
505         Parcel data, reply;
506         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
507         data.writeInt32(display_id);
508         data.writeInt32(on);
509         int result = remote()->transact(SET_DISPLAY_DBM, data, &reply);
510         if (result) ALOGE("SET_DISPLAY_DBM transact error(%d)", result);
511         return result;
512     }
513 
setDisplayMultiThreadedPresent(const int32_t & displayId,const bool & enable)514     virtual int32_t setDisplayMultiThreadedPresent(const int32_t& displayId,
515                                                    const bool& enable) {
516         Parcel data, reply;
517         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
518         data.writeInt32(displayId);
519         data.writeBool(enable);
520         int result = remote()->transact(SET_DISPLAY_MULTI_THREADED_PRESENT, data, &reply);
521         if (result) ALOGE("SET_DISPLAY_MULTI_THREADED_PRESENT transact error(%d)", result);
522         return result;
523     }
524 
triggerRefreshRateIndicatorUpdate(uint32_t displayId,uint32_t refreshRate)525     virtual int32_t triggerRefreshRateIndicatorUpdate(uint32_t displayId,
526                                                       uint32_t refreshRate) override {
527         Parcel data, reply;
528         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
529         data.writeUint32(displayId);
530         data.writeUint32(refreshRate);
531 
532         auto result = remote()->transact(TRIGGER_REFRESH_RATE_INDICATOR_UPDATE, data, &reply);
533         ALOGE_IF(result != NO_ERROR, "TRIGGER_REFRESH_RATE_INDICATOR_UPDATE transact error(%d)",
534                  result);
535         return result;
536     }
537 
dumpBuffers(uint32_t displayId,int32_t count)538     virtual int32_t dumpBuffers(uint32_t displayId, int32_t count) override {
539         Parcel data, reply;
540         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
541         data.writeUint32(displayId);
542         data.writeInt32(count);
543 
544         auto result = remote()->transact(DUMP_BUFFERS, data, &reply);
545         ALOGE_IF(result != NO_ERROR, "DUMP_BUFFERS transact error(%d)", result);
546         return result;
547     }
548 
setPresentTimeoutController(uint32_t displayId,uint32_t controllerType)549     int32_t setPresentTimeoutController(uint32_t displayId, uint32_t controllerType) override {
550         Parcel data, reply;
551         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
552         data.writeInt32(displayId);
553         data.writeUint32(controllerType);
554         int result = remote()->transact(SET_PRESENT_TIMEOUT_CONTROLLER, data, &reply);
555         ALOGE_IF(result != NO_ERROR, "SET_PRESENT_TIMEOUT_CONTROLLER transact error(%d)", result);
556         return result;
557     }
558 
setPresentTimeoutParameters(uint32_t displayId,int timeoutNs,const std::vector<std::pair<uint32_t,uint32_t>> & settings)559     int32_t setPresentTimeoutParameters(
560             uint32_t displayId, int timeoutNs,
561             const std::vector<std::pair<uint32_t, uint32_t>>& settings) override {
562         Parcel data, reply;
563         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
564         data.writeInt32(displayId);
565         // The format is timeout, [ i32 <frames> i32 <intervalNs> ]+.
566         // E.g. if [2, 8333333], [1, 16666667] ..., the pattern is:
567         // last present <timeout> 1st task <8.3 ms> 2nd task <8.3 ms> 3rd task <16.67ms> ...
568         data.writeInt32(timeoutNs);
569         for (const auto& it : settings) {
570             data.writeUint32(it.first);  // frames
571             data.writeUint32(it.second); // intervalNs
572         }
573         int result = remote()->transact(SET_PRESENT_TIMEOUT_PARAMETERS, data, &reply);
574         ALOGE_IF(result != NO_ERROR, "SET_PRESENT_TIMEOUT_PARAMETERS transact error(%d)", result);
575         return result;
576     }
577 
setFixedTe2Rate(uint32_t displayId,int32_t rateHz)578     virtual int32_t setFixedTe2Rate(uint32_t displayId, int32_t rateHz) {
579         Parcel data, reply;
580         data.writeInterfaceToken(IExynosHWCService::getInterfaceDescriptor());
581         data.writeUint32(displayId);
582         data.writeInt32(rateHz);
583         int result = remote()->transact(SET_FIXED_TE2_RATE, data, &reply);
584         if (result) ALOGE("SET_FIXED_TE2_RATE transact error(%d)", result);
585         return result;
586     }
587 };
588 
589 IMPLEMENT_META_INTERFACE(ExynosHWCService, "android.hal.ExynosHWCService");
590 
onTransact(uint32_t code,const Parcel & data,Parcel * reply,uint32_t flags)591 status_t BnExynosHWCService::onTransact(
592     uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
593 {
594     switch(code) {
595         case ADD_VIRTUAL_DISPLAY_DEVICE: {
596             CHECK_INTERFACE(IExynosHWCService, data, reply);
597             int res = addVirtualDisplayDevice();
598             reply->writeInt32(res);
599             return NO_ERROR;
600         } break;
601         case DESTROY_VIRTUAL_DISPLAY_DEVICE: {
602             CHECK_INTERFACE(IExynosHWCService, data, reply);
603             int res = destroyVirtualDisplayDevice();
604             reply->writeInt32(res);
605             return NO_ERROR;
606         } break;
607         case SET_WFD_MODE: {
608             CHECK_INTERFACE(IExynosHWCService, data, reply);
609             int mode = data.readInt32();
610             int res = setWFDMode(mode);
611             reply->writeInt32(res);
612             return NO_ERROR;
613         } break;
614         case GET_WFD_MODE: {
615             CHECK_INTERFACE(IExynosHWCService, data, reply);
616             int res = getWFDMode();
617             reply->writeInt32(res);
618             return NO_ERROR;
619         } break;
620         case SEND_WFD_COMMAND: {
621             CHECK_INTERFACE(IExynosHWCService, data, reply);
622             int cmd = data.readInt32();
623             int ext1 = data.readInt32();
624             int ext2 = data.readInt32();
625             int res = sendWFDCommand(cmd, ext1, ext2);
626             reply->writeInt32(res);
627             return NO_ERROR;
628         } break;
629         case SET_SECURE_VDS_MODE: {
630             CHECK_INTERFACE(IExynosHWCService, data, reply);
631             int mode = data.readInt32();
632             int res = setSecureVDSMode(mode);
633             reply->writeInt32(res);
634             return NO_ERROR;
635         } break;
636         case SET_WFD_OUTPUT_RESOLUTION: {
637             CHECK_INTERFACE(IExynosHWCService, data, reply);
638             int width  = data.readInt32();
639             int height = data.readInt32();
640             int res = setWFDOutputResolution(width, height);
641             reply->writeInt32(res);
642             return NO_ERROR;
643         } break;
644         case GET_WFD_OUTPUT_RESOLUTION: {
645             CHECK_INTERFACE(IExynosHWCService, data, reply);
646             uint32_t width = 0, height = 0;
647             int res = getWFDOutputResolution(&width, &height);
648             reply->writeInt32(width);
649             reply->writeInt32(height);
650             reply->writeInt32(res);
651             return NO_ERROR;
652         } break;
653         case SET_PRESENTATION_MODE: {
654             CHECK_INTERFACE(IExynosHWCService, data, reply);
655             int use = data.readInt32();
656             setPresentationMode(use);
657             return NO_ERROR;
658         } break;
659         case GET_PRESENTATION_MODE: {
660             CHECK_INTERFACE(IExynosHWCService, data, reply);
661             int res = getPresentationMode();
662             reply->writeInt32(res);
663             return NO_ERROR;
664         } break;
665         case SET_VDS_GLES_FORMAT: {
666             CHECK_INTERFACE(IExynosHWCService, data, reply);
667             int format  = data.readInt32();
668             int res = setVDSGlesFormat(format);
669             reply->writeInt32(res);
670             return NO_ERROR;
671         } break;
672        case HWC_CONTROL: {
673             CHECK_INTERFACE(IExynosHWCService, data, reply);
674             int display = data.readInt32();
675             int ctrl = data.readInt32();
676             int value = data.readInt32();
677             int res = setHWCCtl(display, ctrl, value);
678             reply->writeInt32(res);
679             return NO_ERROR;
680         } break;
681         case GET_EXTERNAL_DISPLAY_CONFIG: {
682             CHECK_INTERFACE(IExynosHWCService, data, reply);
683             int res = getExternalDisplayConfigs();
684             reply->writeInt32(res);
685             return NO_ERROR;
686         } break;
687         case SET_EXTERNAL_DISPLAY_CONFIG: {
688             CHECK_INTERFACE(IExynosHWCService, data, reply);
689             int index = data.readInt32();
690             int res = setExternalDisplayConfig(index);
691             reply->writeInt32(res);
692             return NO_ERROR;
693         } break;
694         case SET_EXTERNAL_VSYNC: {
695             CHECK_INTERFACE(IExynosHWCService, data, reply);
696             int index = data.readInt32();
697             int res = setExternalVsyncEnabled(index);
698             reply->writeInt32(res);
699             return NO_ERROR;
700         } break;
701         case GET_EXTERNAL_HDR_CAPA: {
702             CHECK_INTERFACE(IExynosHWCService, data, reply);
703             int res = getExternalHdrCapabilities();
704             reply->writeInt32(res);
705             return NO_ERROR;
706         } break;
707         case SET_BOOT_FINISHED: {
708             CHECK_INTERFACE(IExynosHWCService, data, reply);
709             setBootFinished();
710             return NO_ERROR;
711         } break;
712         case ENABLE_MPP: {
713             CHECK_INTERFACE(IExynosHWCService, data, reply);
714             uint32_t type = data.readInt32();
715             uint32_t physicalIdx = data.readInt32();
716             uint32_t logicalIdx = data.readInt32();
717             uint32_t enable = data.readInt32();
718             enableMPP(type, physicalIdx, logicalIdx, enable);
719             return NO_ERROR;
720         } break;
721         case SET_SCALE_DOWN_RATIO: {
722             CHECK_INTERFACE(IExynosHWCService, data, reply);
723             uint32_t type = data.readInt32();
724             uint32_t physicalIdx = data.readInt32();
725             uint32_t logicalIdx = data.readInt32();
726             uint32_t scaleDownRatio = data.readInt32();
727             setScaleDownRatio(type, physicalIdx, logicalIdx, scaleDownRatio);
728             return NO_ERROR;
729         } break;
730         case SET_HWC_DEBUG: {
731             CHECK_INTERFACE(IExynosHWCService, data, reply);
732             int debug = data.readInt32();
733             setHWCDebug(debug);
734             reply->writeInt32(debug);
735             return NO_ERROR;
736         } break;
737         case GET_HWC_DEBUG: {
738             CHECK_INTERFACE(IExynosHWCService, data, reply);
739             int debugFlag = getHWCDebug();
740             reply->writeInt32(debugFlag);
741             return NO_ERROR;
742         } break;
743         case SET_HWC_FENCE_DEBUG: {
744             CHECK_INTERFACE(IExynosHWCService, data, reply);
745             uint32_t fenceNum = data.readInt32();
746             uint32_t ipNum = data.readInt32();
747             uint32_t mode = data.readInt32();
748             setHWCFenceDebug(fenceNum, ipNum, mode);
749             return NO_ERROR;
750         } break;
751         case SET_DDISCALER: {
752             CHECK_INTERFACE(IExynosHWCService, data, reply);
753             uint32_t display_id = data.readUint32();
754             uint32_t width = data.readUint32();
755             uint32_t height = data.readUint32();
756             int error = setDDIScaler(display_id, width, height);
757             reply->writeInt32(error);
758             return NO_ERROR;
759         } break;
760         case SET_DISPLAY_DEVICE_MODE: {
761             CHECK_INTERFACE(IExynosHWCService, data, reply);
762             int32_t display_id = data.readInt32();
763             int32_t mode = data.readInt32();
764             int32_t error = setDisplayDeviceMode(display_id, mode);
765             reply->writeInt32(error);
766             return NO_ERROR;
767         } break;
768         case SET_PANEL_GAMMA_TABLE_SOURCE: {
769             CHECK_INTERFACE(IExynosHWCService, data, reply);
770             int32_t display_id = data.readInt32();
771             int32_t type = data.readInt32();
772             int32_t source = data.readInt32();
773             int32_t error = setPanelGammaTableSource(display_id, type, source);
774             reply->writeInt32(error);
775             return NO_ERROR;
776         } break;
777 
778         case SET_DISPLAY_BRIGHTNESS: {
779             CHECK_INTERFACE(IExynosHWCService, data, reply);
780             int32_t display_id = data.readInt32();
781             float brightness = data.readFloat();
782             int32_t error = setDisplayBrightness(display_id, brightness);
783             reply->writeInt32(error);
784             return NO_ERROR;
785         } break;
786 
787         case SET_DISPLAY_LHBM: {
788             CHECK_INTERFACE(IExynosHWCService, data, reply);
789             int32_t display_id = data.readInt32();
790             uint32_t on = data.readInt32();
791             int32_t error = setDisplayLhbm(display_id, on);
792             reply->writeInt32(error);
793             return NO_ERROR;
794         } break;
795 
796         case SET_LBE_CTRL: {
797             CHECK_INTERFACE(IExynosHWCService, data, reply);
798             uint32_t display_id = data.readInt32();
799             uint32_t state = data.readInt32();
800             uint32_t lux = data.readInt32();
801             setLbeCtrl(display_id, state, lux);
802             return NO_ERROR;
803         } break;
804 
805         case SET_MIN_IDLE_REFRESH_RATE: {
806             CHECK_INTERFACE(IExynosHWCService, data, reply);
807             uint32_t display_id = data.readUint32();
808             int32_t fps = data.readInt32();
809             return setMinIdleRefreshRate(display_id, fps);
810         } break;
811 
812         case SET_REFRESH_RATE_THROTTLE: {
813             CHECK_INTERFACE(IExynosHWCService, data, reply);
814             uint32_t display_id = data.readUint32();
815             int32_t delay_ms = data.readInt32();
816             return setRefreshRateThrottle(display_id, delay_ms);
817         } break;
818 
819         case SET_DISPLAY_RCDLAYER_ENABLED: {
820             CHECK_INTERFACE(IExynosHWCService, data, reply);
821             uint32_t displayIndex = data.readUint32();
822             bool enable = data.readInt32();
823             return setDisplayRCDLayerEnabled(displayIndex, enable);
824         } break;
825 
826         case TRIGGER_DISPLAY_IDLE_ENTER: {
827             CHECK_INTERFACE(IExynosHWCService, data, reply);
828             uint32_t displayIndex = data.readUint32();
829             uint32_t idleTeRefreshRate = data.readUint32();
830             return triggerDisplayIdleEnter(displayIndex, idleTeRefreshRate);
831         } break;
832 
833         case SET_DISPLAY_DBM: {
834             CHECK_INTERFACE(IExynosHWCService, data, reply);
835             int32_t display_id = data.readInt32();
836             uint32_t on = data.readInt32();
837             int32_t error = setDisplayDbm(display_id, on);
838             reply->writeInt32(error);
839             return NO_ERROR;
840         } break;
841 
842         case SET_DISPLAY_MULTI_THREADED_PRESENT: {
843             CHECK_INTERFACE(IExynosHWCService, data, reply);
844             int32_t displayId = data.readInt32();
845             bool enable = data.readBool();
846             int32_t error = setDisplayMultiThreadedPresent(displayId, enable);
847             reply->writeInt32(error);
848             return NO_ERROR;
849         } break;
850 
851         case TRIGGER_REFRESH_RATE_INDICATOR_UPDATE: {
852             CHECK_INTERFACE(IExynosHWCService, data, reply);
853             uint32_t displayId = data.readUint32();
854             uint32_t refreshRate = data.readUint32();
855             return triggerRefreshRateIndicatorUpdate(displayId, refreshRate);
856         } break;
857 
858         case IGNORE_DISPLAY_BRIGHTNESS_UPDATE_REQUESTS: {
859             CHECK_INTERFACE(IExynosHWCService, data, reply);
860             int32_t displayId = data.readInt32();
861             bool ignore = data.readBool();
862             int32_t error = ignoreDisplayBrightnessUpdateRequests(displayId, ignore);
863             reply->writeInt32(error);
864             return NO_ERROR;
865         } break;
866 
867         case SET_DISPLAY_BRIGHTNESS_NITS: {
868             CHECK_INTERFACE(IExynosHWCService, data, reply);
869             int32_t displayId = data.readInt32();
870             float nits = data.readFloat();
871             int32_t error = setDisplayBrightnessNits(displayId, nits);
872             reply->writeInt32(error);
873             return NO_ERROR;
874         } break;
875 
876         case SET_DISPLAY_BRIGHTNESS_DBV: {
877             CHECK_INTERFACE(IExynosHWCService, data, reply);
878             int32_t displayId = data.readInt32();
879             uint32_t dbv = data.readUint32();
880             int32_t error = setDisplayBrightnessDbv(displayId, dbv);
881             reply->writeInt32(error);
882             return NO_ERROR;
883         } break;
884 
885         case DUMP_BUFFERS: {
886             CHECK_INTERFACE(IExynosHWCService, data, reply);
887             uint32_t displayId = data.readUint32();
888             int32_t count = data.readInt32();
889             return dumpBuffers(displayId, count);
890         } break;
891 
892         case SET_PRESENT_TIMEOUT_CONTROLLER: {
893             CHECK_INTERFACE(IExynosHWCService, data, reply);
894             int32_t displayId = data.readInt32();
895             uint32_t controllerType = data.readUint32();
896             int32_t error = setPresentTimeoutController(displayId, controllerType);
897             reply->writeInt32(error);
898             return NO_ERROR;
899         } break;
900 
901         case SET_PRESENT_TIMEOUT_PARAMETERS: {
902             CHECK_INTERFACE(IExynosHWCService, data, reply);
903             int32_t displayId;
904             uint32_t timeoutNs;
905             RET_IF_ERR(data.readInt32(&displayId));
906             RET_IF_ERR(data.readUint32(&timeoutNs));
907             std::vector<std::pair<uint32_t, uint32_t>> settings;
908             while (true) {
909                 uint32_t numOfWorks, intervalNs;
910                 if (data.readUint32(&numOfWorks)) {
911                     break;
912                 }
913                 RET_IF_ERR(data.readUint32(&intervalNs));
914                 settings.emplace_back(std::make_pair(numOfWorks, intervalNs));
915             }
916             int32_t error = setPresentTimeoutParameters(displayId, timeoutNs, settings);
917             reply->writeInt32(error);
918             return NO_ERROR;
919         } break;
920 
921         case SET_FIXED_TE2_RATE: {
922             CHECK_INTERFACE(IExynosHWCService, data, reply);
923             uint32_t displayId = data.readUint32();
924             int32_t rateHz = data.readInt32();
925             return setFixedTe2Rate(displayId, rateHz);
926         } break;
927 
928         default:
929             return BBinder::onTransact(code, data, reply, flags);
930     }
931 }
932 } // namespace android
933