gpu.h revision 15c7eb9ba46119290695b650d23180884f1156fa
1ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* 2ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Copyright (C) 2008 The Android Open Source Project 315c7eb9ba46119290695b650d23180884f1156faArun Kumar K.R * Copyright (c) 2011-2012,2014, The Linux Foundation. All rights reserved. 4ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * 5ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Licensed under the Apache License, Version 2.0 (the "License"); 6ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * you may not use this file except in compliance with the License. 7ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * You may obtain a copy of the License at 8ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * 9ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * http://www.apache.org/licenses/LICENSE-2.0 10ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * 11ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Unless required by applicable law or agreed to in writing, software 12ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * distributed under the License is distributed on an "AS IS" BASIS, 13ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * See the License for the specific language governing permissions and 15ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * limitations under the License. 16ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson */ 17ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 18ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#ifndef GRALLOC_GPU_H_ 19ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define GRALLOC_GPU_H_ 20ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 21ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <errno.h> 22ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <pthread.h> 23ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <stdlib.h> 24ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <string.h> 25ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 26ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <cutils/log.h> 27ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 28ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include "gralloc_priv.h" 29ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include "fb_priv.h" 30ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 31ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonnamespace gralloc { 32ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonclass IAllocController; 33ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonclass gpu_context_t : public alloc_device_t { 34ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson public: 35ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson gpu_context_t(const private_module_t* module, 36ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson IAllocController* alloc_ctrl); 37ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 38ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int gralloc_alloc_buffer(size_t size, int usage, 39ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson buffer_handle_t* pHandle, 40ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int bufferType, int format, 41ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int width, int height); 42ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 43ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int free_impl(private_handle_t const* hnd); 44ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 45ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int alloc_impl(int w, int h, int format, int usage, 46ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson buffer_handle_t* pHandle, int* pStride, 47ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson size_t bufferSize = 0); 48ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 49ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson static int gralloc_alloc(alloc_device_t* dev, int w, int h, 50ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int format, int usage, 51ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson buffer_handle_t* pHandle, 52ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int* pStride); 5315c7eb9ba46119290695b650d23180884f1156faArun Kumar K.R int gralloc_alloc_framebuffer_locked(int usage, 54ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson buffer_handle_t* pHandle); 55ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 5615c7eb9ba46119290695b650d23180884f1156faArun Kumar K.R int gralloc_alloc_framebuffer(int usage, 57ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson buffer_handle_t* pHandle); 58ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 59ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson static int gralloc_free(alloc_device_t* dev, buffer_handle_t handle); 60ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 61ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson static int gralloc_alloc_size(alloc_device_t* dev, 62ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int w, int h, int format, 63ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int usage, buffer_handle_t* pHandle, 64ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int* pStride, int bufferSize); 65ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 66ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson static int gralloc_close(struct hw_device_t *dev); 67ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 68ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson private: 69ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson IAllocController* mAllocCtrl; 70ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson void getGrallocInformationFromFormat(int inputFormat, 71ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int *bufferType); 72ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson}; 73ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 74ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#endif // GRALLOC_GPU_H 75