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