1 /* 2 * Copyright (c) 2013-2015 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 <display_config.h> 31 #include <QServiceUtils.h> 32 33 using namespace android; 34 using namespace qService; 35 36 namespace qdutils { 37 38 int isExternalConnected(void) { 39 int ret; 40 status_t err = (status_t) FAILED_TRANSACTION; 41 sp<IQService> binder = getBinder(); 42 Parcel inParcel, outParcel; 43 if(binder != NULL) { 44 err = binder->dispatch(IQService::CHECK_EXTERNAL_STATUS, 45 &inParcel , &outParcel); 46 } 47 if(err) { 48 ALOGE("%s: Failed to get external status err=%d", __FUNCTION__, err); 49 ret = err; 50 } else { 51 ret = outParcel.readInt32(); 52 } 53 return ret; 54 } 55 56 int getDisplayAttributes(int dpy, DisplayAttributes_t& dpyattr) { 57 status_t err = (status_t) FAILED_TRANSACTION; 58 sp<IQService> binder = getBinder(); 59 Parcel inParcel, outParcel; 60 inParcel.writeInt32(dpy); 61 if(binder != NULL) { 62 err = binder->dispatch(IQService::GET_DISPLAY_ATTRIBUTES, 63 &inParcel, &outParcel); 64 } 65 if(!err) { 66 dpyattr.vsync_period = outParcel.readInt32(); 67 dpyattr.xres = outParcel.readInt32(); 68 dpyattr.yres = outParcel.readInt32(); 69 dpyattr.xdpi = outParcel.readFloat(); 70 dpyattr.ydpi = outParcel.readFloat(); 71 dpyattr.panel_type = (char) outParcel.readInt32(); 72 } else { 73 ALOGE("%s: Failed to get display attributes err=%d", __FUNCTION__, err); 74 } 75 return err; 76 } 77 78 int setHSIC(int dpy, const HSICData_t& hsic_data) { 79 status_t err = (status_t) FAILED_TRANSACTION; 80 sp<IQService> binder = getBinder(); 81 Parcel inParcel, outParcel; 82 inParcel.writeInt32(dpy); 83 inParcel.writeInt32(hsic_data.hue); 84 inParcel.writeFloat(hsic_data.saturation); 85 inParcel.writeInt32(hsic_data.intensity); 86 inParcel.writeFloat(hsic_data.contrast); 87 if(binder != NULL) { 88 err = binder->dispatch(IQService::SET_HSIC_DATA, &inParcel, &outParcel); 89 } 90 if(err) 91 ALOGE("%s: Failed to get external status err=%d", __FUNCTION__, err); 92 return err; 93 } 94 95 int getDisplayVisibleRegion(int dpy, hwc_rect_t &rect) { 96 status_t err = (status_t) FAILED_TRANSACTION; 97 sp<IQService> binder = getBinder(); 98 Parcel inParcel, outParcel; 99 inParcel.writeInt32(dpy); 100 if(binder != NULL) { 101 err = binder->dispatch(IQService::GET_DISPLAY_VISIBLE_REGION, 102 &inParcel, &outParcel); 103 } 104 if(!err) { 105 rect.left = outParcel.readInt32(); 106 rect.top = outParcel.readInt32(); 107 rect.right = outParcel.readInt32(); 108 rect.bottom = outParcel.readInt32(); 109 } else { 110 ALOGE("%s: Failed to getVisibleRegion for dpy =%d: err = %d", 111 __FUNCTION__, dpy, err); 112 } 113 return err; 114 } 115 116 int setViewFrame(int dpy, int l, int t, int r, int b) { 117 status_t err = (status_t) FAILED_TRANSACTION; 118 sp<IQService> binder = getBinder(); 119 Parcel inParcel, outParcel; 120 inParcel.writeInt32(dpy); 121 inParcel.writeInt32(l); 122 inParcel.writeInt32(t); 123 inParcel.writeInt32(r); 124 inParcel.writeInt32(b); 125 126 if(binder != NULL) { 127 err = binder->dispatch(IQService::SET_VIEW_FRAME, 128 &inParcel, &outParcel); 129 } 130 if(err) 131 ALOGE("%s: Failed to set view frame for dpy %d err=%d", 132 __FUNCTION__, dpy, err); 133 134 return err; 135 } 136 137 int setSecondaryDisplayStatus(int dpy, uint32_t status) { 138 status_t err = (status_t) FAILED_TRANSACTION; 139 sp<IQService> binder = getBinder(); 140 Parcel inParcel, outParcel; 141 inParcel.writeInt32(dpy); 142 inParcel.writeInt32(status); 143 144 if(binder != NULL) { 145 err = binder->dispatch(IQService::SET_SECONDARY_DISPLAY_STATUS, 146 &inParcel, &outParcel); 147 } 148 if(err) 149 ALOGE("%s: Failed for dpy %d status = %d err=%d", __FUNCTION__, dpy, 150 status, err); 151 152 return err; 153 } 154 155 int configureDynRefreshRate(uint32_t op, uint32_t refreshRate) { 156 status_t err = (status_t) FAILED_TRANSACTION; 157 sp<IQService> binder = getBinder(); 158 Parcel inParcel, outParcel; 159 inParcel.writeInt32(op); 160 inParcel.writeInt32(refreshRate); 161 162 if(binder != NULL) { 163 err = binder->dispatch(IQService::CONFIGURE_DYN_REFRESH_RATE, 164 &inParcel, &outParcel); 165 } 166 167 if(err) 168 ALOGE("%s: Failed setting op %d err=%d", __FUNCTION__, op, err); 169 170 return err; 171 } 172 173 }; //namespace 174 175 // ---------------------------------------------------------------------------- 176 // Screen refresh for native daemons linking dynamically to libqdutils 177 // ---------------------------------------------------------------------------- 178 extern "C" int refreshScreen() { 179 int ret = 0; 180 ret = screenRefresh(); 181 return ret; 182 } 183 184 // ---------------------------------------------------------------------------- 185 // Native daemons needs to send enable partial update ack for PU to enable 186 // ---------------------------------------------------------------------------- 187 extern "C" int setPartialUpdateState() { 188 int ret = 0; 189 ret = setPartialUpdate(IQService::ENABLE_PARTIAL_UPDATE); 190 return ret; 191 } 192