1/* 2* Copyright (c) 2013-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 <display_config.h> 31#include <QServiceUtils.h> 32 33using namespace android; 34using namespace qService; 35 36namespace qdutils { 37 38int 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 56int 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 78int 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 95int 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}; //namespace 117