1054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin/* 2054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * Copyright (C) 2008 The Android Open Source Project 3054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * Copyright (c) 2010-2014 The Linux Foundation. All rights reserved. 4054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * 5054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * Licensed under the Apache License, Version 2.0 (the "License"); 6054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * you may not use this file except in compliance with the License. 7054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * You may obtain a copy of the License at 8054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * 9054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * http://www.apache.org/licenses/LICENSE-2.0 10054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * 11054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * Unless required by applicable law or agreed to in writing, software 12054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * distributed under the License is distributed on an "AS IS" BASIS, 13054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * See the License for the specific language governing permissions and 15054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * limitations under the License. 16054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin */ 17054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 18054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <sys/mman.h> 19054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 20054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <cutils/log.h> 21054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <cutils/properties.h> 22054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <dlfcn.h> 23054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 24054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <hardware/hardware.h> 25054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 26054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <fcntl.h> 27054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <errno.h> 28054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <sys/ioctl.h> 29054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <string.h> 30054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <stdlib.h> 31054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <pthread.h> 32054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <cutils/atomic.h> 33054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 34054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <linux/fb.h> 35054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <linux/msm_mdp.h> 36054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 37054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <GLES/gl.h> 38054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 39054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include "gralloc_priv.h" 40054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include "fb_priv.h" 41054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include "gr.h" 42054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <cutils/properties.h> 43054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#include <profiler.h> 44054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 45054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#define EVEN_OUT(x) if (x & 0x0001) {x--;} 46054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin/** min of int a, b */ 47054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinstatic inline int min(int a, int b) { 48054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return (a<b) ? a : b; 49054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin} 50054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin/** max of int a, b */ 51054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinstatic inline int max(int a, int b) { 52054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return (a>b) ? a : b; 53054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin} 54054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 55054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinenum { 56054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin PAGE_FLIP = 0x00000001, 57054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin}; 58054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 59054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinstruct fb_context_t { 60054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin framebuffer_device_t device; 61054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //fd - which is returned on open 62054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int fbFd; 63054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin}; 64054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 65054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinstatic int fb_setSwapInterval(struct framebuffer_device_t* dev, 66054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int interval) 67054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin{ 685936d78c2a15671de2a803e3beffdcb5079041b3Alex Naidis#ifdef DEBUG_SWAPINTERVAL 69054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //XXX: Get the value here and implement along with 70054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //single vsync in HWC 71054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin char pval[PROPERTY_VALUE_MAX]; 72054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin property_get("debug.egl.swapinterval", pval, "-1"); 73054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int property_interval = atoi(pval); 74054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (property_interval >= 0) 75054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin interval = property_interval; 765936d78c2a15671de2a803e3beffdcb5079041b3Alex Naidis#endif 77054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 78054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin private_module_t* m = reinterpret_cast<private_module_t*>( 79054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin dev->common.module); 80054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (interval < dev->minSwapInterval || interval > dev->maxSwapInterval) 81054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -EINVAL; 82054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 83054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin m->swapInterval = interval; 84054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return 0; 85054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin} 86054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 87054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinstatic int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer) 88054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin{ 89054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin private_module_t* m = 90054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin reinterpret_cast<private_module_t*>(dev->common.module); 91054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin private_handle_t *hnd = static_cast<private_handle_t*> 92054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin (const_cast<native_handle_t*>(buffer)); 93054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin fb_context_t *ctx = reinterpret_cast<fb_context_t*>(dev); 94054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const unsigned int offset = (unsigned int) (hnd->base - 95054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin m->framebuffer->base); 96054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin m->info.activate = FB_ACTIVATE_VBL; 97054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin m->info.yoffset = (int)(offset / m->finfo.line_length); 98054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (ioctl(ctx->fbFd, FBIOPUT_VSCREENINFO, &m->info) == -1) { 99054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ALOGE("%s: FBIOPUT_VSCREENINFO for primary failed, str: %s", 100054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin __FUNCTION__, strerror(errno)); 101054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 102054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 103054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return 0; 104054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin} 105054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 106054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinstatic int fb_compositionComplete(struct framebuffer_device_t* dev) 107054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin{ 108054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin // TODO: Properly implement composition complete callback 109054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if(!dev) { 110054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -1; 111054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 112054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin glFinish(); 113054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 114054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return 0; 115054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin} 116054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 117054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinint mapFrameBufferLocked(framebuffer_device_t *dev) 118054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin{ 119054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin private_module_t* module = 120054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin reinterpret_cast<private_module_t*>(dev->common.module); 121054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin fb_context_t *ctx = reinterpret_cast<fb_context_t*>(dev); 122054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin // already initialized... 123054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (module->framebuffer) { 124054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return 0; 125054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 126054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin char const * const device_template[] = { 127054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "/dev/graphics/fb%u", 128054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "/dev/fb%u", 129054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 0 }; 130054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 131054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int fd = -1; 132054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int i=0; 133054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin char name[64]; 134054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin char property[PROPERTY_VALUE_MAX]; 135054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 136054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin while ((fd==-1) && device_template[i]) { 137054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin snprintf(name, 64, device_template[i], 0); 138054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin fd = open(name, O_RDWR, 0); 139054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin i++; 140054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 141054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (fd < 0) 142054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 143054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 144054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin struct fb_fix_screeninfo finfo; 145054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) { 146054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin close(fd); 147054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 148054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 149054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 150054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin struct fb_var_screeninfo info; 151054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) { 152054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin close(fd); 153054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 154054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 155054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 156054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.reserved[0] = 0; 157054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.reserved[1] = 0; 158054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.reserved[2] = 0; 159054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.xoffset = 0; 160054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.yoffset = 0; 161054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.activate = FB_ACTIVATE_NOW; 162054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 163054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin /* Interpretation of offset for color fields: All offsets are from the 164054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * right, inside a "pixel" value, which is exactly 'bits_per_pixel' wide 165054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * (means: you can use the offset as right argument to <<). A pixel 166054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * afterwards is a bit stream and is written to video memory as that 167054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * unmodified. This implies big-endian byte order if bits_per_pixel is 168054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * greater than 8. 169054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin */ 170054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 171054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if(info.bits_per_pixel == 32) { 172054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin /* 173054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * Explicitly request RGBA_8888 174054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin */ 175054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.bits_per_pixel = 32; 176054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.red.offset = 24; 177054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.red.length = 8; 178054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.green.offset = 16; 179054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.green.length = 8; 180054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.blue.offset = 8; 181054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.blue.length = 8; 182054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.transp.offset = 0; 183054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.transp.length = 8; 184054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 185054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin /* Note: the GL driver does not have a r=8 g=8 b=8 a=0 config, so if we 186054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * do not use the MDP for composition (i.e. hw composition == 0), ask 187054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * for RGBA instead of RGBX. */ 188054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (property_get("debug.sf.hw", property, NULL) > 0 && 189054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin atoi(property) == 0) 190054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->fbFormat = HAL_PIXEL_FORMAT_RGBX_8888; 191054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin else if(property_get("debug.composition.type", property, NULL) > 0 && 192054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin (strncmp(property, "mdp", 3) == 0)) 193054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->fbFormat = HAL_PIXEL_FORMAT_RGBX_8888; 194054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin else 195054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->fbFormat = HAL_PIXEL_FORMAT_RGBA_8888; 196054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } else { 197054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin /* 198054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * Explicitly request 5/6/5 199054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin */ 200054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.bits_per_pixel = 16; 201054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.red.offset = 11; 202054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.red.length = 5; 203054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.green.offset = 5; 204054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.green.length = 6; 205054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.blue.offset = 0; 206054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.blue.length = 5; 207054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.transp.offset = 0; 208054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.transp.length = 0; 209054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->fbFormat = HAL_PIXEL_FORMAT_RGB_565; 210054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 211054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 212054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //adreno needs 4k aligned offsets. Max hole size is 4096-1 213054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin unsigned int size = roundUpToPageSize(info.yres * info.xres * 214054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin (info.bits_per_pixel/8)); 215054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 216054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin /* 217054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * Request NUM_BUFFERS screens (at least 2 for page flipping) 218054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin */ 219054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int numberOfBuffers = (int)(finfo.smem_len/size); 220054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ALOGV("num supported framebuffers in kernel = %d", numberOfBuffers); 221054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 222054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (property_get("debug.gr.numframebuffers", property, NULL) > 0) { 223054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int num = atoi(property); 224054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if ((num >= NUM_FRAMEBUFFERS_MIN) && (num <= NUM_FRAMEBUFFERS_MAX)) { 225054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin numberOfBuffers = num; 226054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 227054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 228054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (numberOfBuffers > NUM_FRAMEBUFFERS_MAX) 229054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin numberOfBuffers = NUM_FRAMEBUFFERS_MAX; 230054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 231054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ALOGV("We support %d buffers", numberOfBuffers); 232054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 233054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //consider the included hole by 4k alignment 234054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin uint32_t line_length = (info.xres * info.bits_per_pixel / 8); 235054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.yres_virtual = (uint32_t) ((size * numberOfBuffers) / line_length); 236054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 237054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin uint32_t flags = PAGE_FLIP; 238054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 239054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (info.yres_virtual < ((size * 2) / line_length) ) { 240054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin // we need at least 2 for page-flipping 241054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.yres_virtual = (int)(size / line_length); 242054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin flags &= ~PAGE_FLIP; 243054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ALOGW("page flipping not supported (yres_virtual=%d, requested=%d)", 244054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.yres_virtual, info.yres*2); 245054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 246054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 247054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) { 248054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin close(fd); 249054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 250054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 251054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 252054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (int(info.width) <= 0 || int(info.height) <= 0) { 253054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin // the driver doesn't return that information 254054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin // default to 160 dpi 255054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.width = (uint32_t)(((float)(info.xres) * 25.4f)/160.0f + 0.5f); 256054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.height = (uint32_t)(((float)(info.yres) * 25.4f)/160.0f + 0.5f); 257054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 258054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 259054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin float xdpi = ((float)(info.xres) * 25.4f) / (float)info.width; 260054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin float ydpi = ((float)(info.yres) * 25.4f) / (float)info.height; 261054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 262054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#ifdef MSMFB_METADATA_GET 263054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin struct msmfb_metadata metadata; 264054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin memset(&metadata, 0 , sizeof(metadata)); 265054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin metadata.op = metadata_op_frame_rate; 266054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (ioctl(fd, MSMFB_METADATA_GET, &metadata) == -1) { 267054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ALOGE("Error retrieving panel frame rate"); 268054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin close(fd); 269054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 270054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 271054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin float fps = (float)metadata.data.panel_frame_rate; 272054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#else 273054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //XXX: Remove reserved field usage on all baselines 274054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //The reserved[3] field is used to store FPS by the driver. 275054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin float fps = info.reserved[3] & 0xFF; 276054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#endif 277054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ALOGI("using (fd=%d)\n" 278054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "id = %s\n" 279054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "xres = %d px\n" 280054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "yres = %d px\n" 281054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "xres_virtual = %d px\n" 282054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "yres_virtual = %d px\n" 283054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "bpp = %d\n" 284054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "r = %2u:%u\n" 285054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "g = %2u:%u\n" 286054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "b = %2u:%u\n", 287054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin fd, 288054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin finfo.id, 289054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.xres, 290054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.yres, 291054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.xres_virtual, 292054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.yres_virtual, 293054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.bits_per_pixel, 294054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.red.offset, info.red.length, 295054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.green.offset, info.green.length, 296054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.blue.offset, info.blue.length 297054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ); 298054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 299054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ALOGI("width = %d mm (%f dpi)\n" 300054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "height = %d mm (%f dpi)\n" 301054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin "refresh rate = %.2f Hz\n", 302054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.width, xdpi, 303054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin info.height, ydpi, 304054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin fps 305054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ); 306054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 307054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 308054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) { 309054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin close(fd); 310054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 311054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 312054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 313054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (finfo.smem_len <= 0) { 314054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin close(fd); 315054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 316054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 317054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 318054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->flags = flags; 319054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->info = info; 320054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->finfo = finfo; 321054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->xdpi = xdpi; 322054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->ydpi = ydpi; 323054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->fps = fps; 324054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->swapInterval = 1; 325054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 326054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin CALC_INIT(); 327054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 328054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin /* 329054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin * map the framebuffer 330054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin */ 331054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 332054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->numBuffers = info.yres_virtual / info.yres; 333054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->bufferMask = 0; 334054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //adreno needs page aligned offsets. Align the fbsize to pagesize. 335054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin unsigned int fbSize = roundUpToPageSize(finfo.line_length * info.yres)* 336054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->numBuffers; 337054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin void* vaddr = mmap(0, fbSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 338054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (vaddr == MAP_FAILED) { 339054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ALOGE("Error mapping the framebuffer (%s)", strerror(errno)); 340054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin close(fd); 341054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 342054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 343054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //store the framebuffer fd in the ctx 344054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ctx->fbFd = fd; 345054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#ifdef MSMFB_METADATA_GET 346054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin memset(&metadata, 0 , sizeof(metadata)); 347054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin metadata.op = metadata_op_get_ion_fd; 348054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin // get the ION fd for the framebuffer, as GPU needs ION fd 349054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (ioctl(fd, MSMFB_METADATA_GET, &metadata) == -1) { 350054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ALOGE("Error getting ION fd (%s)", strerror(errno)); 351054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin close(fd); 352054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 353054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 354054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if(metadata.data.fbmem_ionfd < 0) { 355054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ALOGE("Error: Ioctl returned invalid ION fd = %d", 356054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin metadata.data.fbmem_ionfd); 357054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin close(fd); 358054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return -errno; 359054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 360054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin fd = metadata.data.fbmem_ionfd; 361054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#endif 362054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin // Create framebuffer handle using the ION fd 363054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->framebuffer = new private_handle_t(fd, fbSize, 364054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin private_handle_t::PRIV_FLAGS_USES_ION, 365054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin BUFFER_TYPE_UI, 366054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->fbFormat, info.xres, info.yres); 367054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin module->framebuffer->base = uint64_t(vaddr); 368054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin memset(vaddr, 0, fbSize); 369054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //Enable vsync 370054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int enable = 1; 371054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin ioctl(ctx->fbFd, MSMFB_OVERLAY_VSYNC_CTRL, &enable); 372054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return 0; 373054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin} 374054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 375054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinstatic int mapFrameBuffer(framebuffer_device_t *dev) 376054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin{ 377054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int err = -1; 378054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin char property[PROPERTY_VALUE_MAX]; 379054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if((property_get("debug.gralloc.map_fb_memory", property, NULL) > 0) && 380054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || 381054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { 382054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin private_module_t* module = 383054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin reinterpret_cast<private_module_t*>(dev->common.module); 384054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin pthread_mutex_lock(&module->lock); 385054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin err = mapFrameBufferLocked(dev); 386054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin pthread_mutex_unlock(&module->lock); 387054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 388054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return err; 389054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin} 390054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 391054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin/*****************************************************************************/ 392054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 393054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinstatic int fb_close(struct hw_device_t *dev) 394054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin{ 395054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin fb_context_t* ctx = (fb_context_t*)dev; 396054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (ctx) { 397054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#ifdef MSMFB_METADATA_GET 398054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if(ctx->fbFd >=0) { 399054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin close(ctx->fbFd); 400054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 401054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin#endif 402054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //Hack until fbdev is removed. Framework could close this causing hwc a 403054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //pain. 404054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin //free(ctx); 405054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 406054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return 0; 407054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin} 408054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 409054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjinint fb_device_open(hw_module_t const* module, const char* name, 410054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin hw_device_t** device) 411054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin{ 412054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int status = -EINVAL; 413054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (!strcmp(name, GRALLOC_HARDWARE_FB0)) { 414054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin alloc_device_t* gralloc_device; 415054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin status = gralloc_open(module, &gralloc_device); 416054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (status < 0) 417054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return status; 418054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 419054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin /* initialize our state here */ 420054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin fb_context_t *dev = (fb_context_t*)malloc(sizeof(*dev)); 421054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if(dev == NULL) { 422054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin gralloc_close(gralloc_device); 423054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return status; 424054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 425054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin memset(dev, 0, sizeof(*dev)); 426054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 427054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin /* initialize the procs */ 428054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin dev->device.common.tag = HARDWARE_DEVICE_TAG; 429054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin dev->device.common.version = 0; 430054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin dev->device.common.module = const_cast<hw_module_t*>(module); 431054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin dev->device.common.close = fb_close; 432054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin dev->device.setSwapInterval = fb_setSwapInterval; 433054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin dev->device.post = fb_post; 434054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin dev->device.setUpdateRect = 0; 435054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin dev->device.compositionComplete = fb_compositionComplete; 436054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 437054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin status = mapFrameBuffer((framebuffer_device_t*)dev); 438054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin private_module_t* m = (private_module_t*)dev->device.common.module; 439054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin if (status >= 0) { 440054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin int stride = m->finfo.line_length / (m->info.bits_per_pixel >> 3); 441054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<uint32_t&>(dev->device.flags) = 0; 442054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<uint32_t&>(dev->device.width) = m->info.xres; 443054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<uint32_t&>(dev->device.height) = m->info.yres; 444054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<int&>(dev->device.stride) = stride; 445054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<int&>(dev->device.format) = m->fbFormat; 446054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<float&>(dev->device.xdpi) = m->xdpi; 447054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<float&>(dev->device.ydpi) = m->ydpi; 448054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<float&>(dev->device.fps) = m->fps; 449054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<int&>(dev->device.minSwapInterval) = 450054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin PRIV_MIN_SWAP_INTERVAL; 451054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<int&>(dev->device.maxSwapInterval) = 452054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin PRIV_MAX_SWAP_INTERVAL; 453054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin const_cast<int&>(dev->device.numFramebuffers) = m->numBuffers; 454054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin dev->device.setUpdateRect = 0; 455054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 456054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin *device = &dev->device.common; 457054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 458054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin 459054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin // Close the gralloc module 460054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin gralloc_close(gralloc_device); 461054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin } 462054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin return status; 463054df959aef7dce630a7f41d4aba6626c130756bPatrick Tjin} 464