blob: 2248d30d243b766d2c1a03dbf1ce9f8e47e610c2 [file] [log] [blame]
Iliyan Malchev202a77d2012-06-11 14:41:12 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
Arun Kumar K.R6c85f052014-01-21 21:47:41 -08003 * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
Iliyan Malchev202a77d2012-06-11 14:41:12 -07004 *
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>
Iliyan Malchev202a77d2012-06-11 14:41:12 -070027
28#include "gralloc_priv.h"
Jeykumar Sankaranc1f86822013-02-20 18:32:01 -080029#include "fb_priv.h"
Iliyan Malchev202a77d2012-06-11 14:41:12 -070030
31namespace gralloc {
Naseer Ahmed29a26812012-06-14 00:56:20 -070032class IAllocController;
33class gpu_context_t : public alloc_device_t {
34 public:
35 gpu_context_t(const private_module_t* module,
Naseer Ahmed01d3fd32012-07-14 21:08:13 -070036 IAllocController* alloc_ctrl);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070037
Saurabh Shah8f0ea6f2014-05-19 16:48:53 -070038 int gralloc_alloc_buffer(unsigned int size, int usage,
Naseer Ahmed29a26812012-06-14 00:56:20 -070039 buffer_handle_t* pHandle,
40 int bufferType, int format,
41 int width, int height);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070042
Naseer Ahmed29a26812012-06-14 00:56:20 -070043 int free_impl(private_handle_t const* hnd);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070044
Naseer Ahmed29a26812012-06-14 00:56:20 -070045 int alloc_impl(int w, int h, int format, int usage,
46 buffer_handle_t* pHandle, int* pStride,
Saurabh Shah8f0ea6f2014-05-19 16:48:53 -070047 unsigned int bufferSize = 0);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070048
Naseer Ahmed29a26812012-06-14 00:56:20 -070049 static int gralloc_alloc(alloc_device_t* dev, int w, int h,
50 int format, int usage,
51 buffer_handle_t* pHandle,
52 int* pStride);
Arun Kumar K.R6c85f052014-01-21 21:47:41 -080053 int gralloc_alloc_framebuffer_locked(int usage,
Naseer Ahmed47aa15e2013-04-10 21:27:09 -040054 buffer_handle_t* pHandle);
55
Arun Kumar K.R6c85f052014-01-21 21:47:41 -080056 int gralloc_alloc_framebuffer(int usage,
Naseer Ahmed47aa15e2013-04-10 21:27:09 -040057 buffer_handle_t* pHandle);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070058
Naseer Ahmed29a26812012-06-14 00:56:20 -070059 static int gralloc_free(alloc_device_t* dev, buffer_handle_t handle);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070060
Naseer Ahmed29a26812012-06-14 00:56:20 -070061 static int gralloc_alloc_size(alloc_device_t* dev,
62 int w, int h, int format,
63 int usage, buffer_handle_t* pHandle,
64 int* pStride, int bufferSize);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070065
Naseer Ahmed29a26812012-06-14 00:56:20 -070066 static int gralloc_close(struct hw_device_t *dev);
Iliyan Malchev202a77d2012-06-11 14:41:12 -070067
Naseer Ahmed29a26812012-06-14 00:56:20 -070068 private:
Naseer Ahmed01d3fd32012-07-14 21:08:13 -070069 IAllocController* mAllocCtrl;
Naseer Ahmed29a26812012-06-14 00:56:20 -070070 void getGrallocInformationFromFormat(int inputFormat,
Naseer Ahmed29a26812012-06-14 00:56:20 -070071 int *bufferType);
72};
Iliyan Malchev202a77d2012-06-11 14:41:12 -070073}
74#endif // GRALLOC_GPU_H