107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani/* 207bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * Copyright (c) 2013 The Linux Foundation. All rights reserved. 307bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * 407bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * Redistribution and use in source and binary forms, with or without 507bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * modification, are permitted provided that the following conditions are 607bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * met: 707bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * * Redistributions of source code must retain the above copyright 807bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * notice, this list of conditions and the following disclaimer. 907bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * * Redistributions in binary form must reproduce the above 1007bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * copyright notice, this list of conditions and the following 1107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * disclaimer in the documentation and/or other materials provided 1207bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * with the distribution. 1307bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * * Neither the name of The Linux Foundation. nor the names of its 1407bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * contributors may be used to endorse or promote products derived 1507bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * from this software without specific prior written permission. 1607bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * 1707bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 1807bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1907bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 2007bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 2107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2207bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2307bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 2407bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2507bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 2607bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 2707bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2807bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani */ 2907bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani#include <gralloc_priv.h> 3007bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani#include <qdMetaData.h> 3107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani#include <mdp_version.h> 3207bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani#include <hardware/hwcomposer.h> 3307bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 3407bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// This header is for clients to use to set/get global display configuration 3507bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// The functions in this header run in the client process and wherever necessary 3607bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// do a binder call to HWC to get/set data. 3707bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Only primary and external displays are supported here. 3807bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// WiFi/virtual displays are not supported. 3907bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 4007bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malaninamespace qdutils { 4107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 4207bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Use this enum to specify the dpy parameters where needed 4307bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malanienum { 4407bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani DISPLAY_PRIMARY = HWC_DISPLAY_PRIMARY, 4507bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani DISPLAY_EXTERNAL = HWC_DISPLAY_EXTERNAL, 4607bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani DISPLAY_VIRTUAL = HWC_DISPLAY_VIRTUAL, 4707bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani}; 4807bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 4907bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// External Display states - used in setSecondaryDisplayStatus() 5007bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// To be consistent with the same defined in hwc_utils.h 5107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malanienum { 5207bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani EXTERNAL_OFFLINE = 0, 5307bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani EXTERNAL_ONLINE, 5407bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani EXTERNAL_PAUSE, 5507bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani EXTERNAL_RESUME, 5607bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani}; 5707bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 5807bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malanienum { 5907bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani DISABLE_METADATA_DYN_REFRESH_RATE = 0, 6007bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani ENABLE_METADATA_DYN_REFRESH_RATE, 6107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani SET_BINDER_DYN_REFRESH_RATE, 6207bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani}; 6307bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 6407bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Display Attributes that are available to clients of this library 6507bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Not to be confused with a similar struct in hwc_utils (in the hwc namespace) 6607bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malanistruct DisplayAttributes_t { 6707bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani uint32_t vsync_period; //nanoseconds 6807bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani uint32_t xres; 6907bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani uint32_t yres; 7007bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani float xdpi; 7107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani float ydpi; 7207bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani char panel_type; 7307bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani}; 7407bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 7507bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Check if external display is connected. Useful to check before making 7607bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// calls for external displays 7707bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Returns 1 if connected, 0 if disconnected, negative values on errors 7807bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malaniint isExternalConnected(void); 7907bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 8007bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Get display vsync period which is in nanoseconds 8107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// i.e vsync_period = 1000000000l / fps 8207bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Returns 0 on success, negative values on errors 8307bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malaniint getDisplayAttributes(int dpy, DisplayAttributes_t& dpyattr); 8407bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 8507bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Set HSIC data on a given display ID 8607bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Returns 0 on success, negative values on errors 8707bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malaniint setHSIC(int dpy, const HSICData_t& hsic_data); 8807bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 8907bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// get the active visible region for the display 9007bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Returns 0 on success, negative values on errors 9107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malaniint getDisplayVisibleRegion(int dpy, hwc_rect_t &rect); 9207bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 9307bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// set the view frame information in hwc context from surfaceflinger 9407bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malaniint setViewFrame(int dpy, int l, int t, int r, int b); 9507bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 9607bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Set the secondary display status(pause/resume/offline etc.,) 9707bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malaniint setSecondaryDisplayStatus(int dpy, uint32_t status); 9807bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani 9907bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani// Enable/Disable/Set refresh rate dynamically 10007bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malaniint configureDynRefreshRate(uint32_t op, uint32_t refreshRate); 10107bbf1e89c031a5d41a7561433e832d396c311a5Prashant Malani}; //namespace 102