Home | History | Annotate | Download | only in gralloc960
      1 /*
      2  * Copyright (C) 2016 ARM Limited. All rights reserved.
      3  *
      4  * Copyright (C) 2008 The Android Open Source Project
      5  *
      6  * Licensed under the Apache License, Version 2.0 (the "License");
      7  * you may not use this file except in compliance with the License.
      8  * You may obtain a copy of the License at
      9  *
     10  *      http://www.apache.org/licenses/LICENSE-2.0
     11  *
     12  * Unless required by applicable law or agreed to in writing, software
     13  * distributed under the License is distributed on an "AS IS" BASIS,
     14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15  * See the License for the specific language governing permissions and
     16  * limitations under the License.
     17  */
     18 #ifndef MALI_GRALLOC_MODULE_H_
     19 #define MALI_GRALLOC_MODULE_H_
     20 
     21 #include <linux/fb.h>
     22 #include <pthread.h>
     23 
     24 typedef enum
     25 {
     26 	MALI_DPY_TYPE_UNKNOWN = 0,
     27 	MALI_DPY_TYPE_CLCD,
     28 	MALI_DPY_TYPE_HDLCD
     29 } mali_dpy_type;
     30 
     31 #if GRALLOC_USE_GRALLOC1_API == 1
     32 typedef struct
     33 {
     34 	struct hw_module_t common;
     35 } gralloc_module_t;
     36 
     37 /*
     38  * Most gralloc code is fairly version agnostic, but certain
     39  * places still use old usage defines. Make sure it works
     40  * ok for usages that are backwards compatible.
     41  */
     42 #define GRALLOC_USAGE_PRIVATE_0 GRALLOC1_CONSUMER_USAGE_PRIVATE_0
     43 #define GRALLOC_USAGE_PRIVATE_1 GRALLOC1_CONSUMER_USAGE_PRIVATE_1
     44 #define GRALLOC_USAGE_PRIVATE_2 GRALLOC1_CONSUMER_USAGE_PRIVATE_2
     45 #define GRALLOC_USAGE_PRIVATE_3 GRALLOC1_CONSUMER_USAGE_PRIVATE_3
     46 
     47 #define GRALLOC_USAGE_SW_WRITE_RARELY GRALLOC1_PRODUCER_USAGE_CPU_WRITE
     48 #define GRALLOC_USAGE_SW_WRITE_OFTEN GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN
     49 #define GRALLOC_USAGE_SW_READ_RARELY GRALLOC1_CONSUMER_USAGE_CPU_READ
     50 #define GRALLOC_USAGE_SW_READ_OFTEN GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN
     51 #define GRALLOC_USAGE_HW_FB GRALLOC1_CONSUMER_USAGE_CLIENT_TARGET
     52 #define GRALLOC_USAGE_HW_2D 0x00000400
     53 
     54 #define GRALLOC_USAGE_SW_WRITE_MASK 0x000000F0
     55 #define GRALLOC_USAGE_SW_READ_MASK 0x0000000F
     56 #define GRALLOC_USAGE_PROTECTED GRALLOC1_PRODUCER_USAGE_PROTECTED
     57 #define GRALLOC_USAGE_HW_RENDER GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET
     58 #define GRALLOC_USAGE_HW_CAMERA_MASK (GRALLOC1_CONSUMER_USAGE_CAMERA | GRALLOC1_PRODUCER_USAGE_CAMERA)
     59 #define GRALLOC_USAGE_HW_TEXTURE GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE
     60 #define GRALLOC_USAGE_HW_VIDEO_ENCODER GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER
     61 #define GRALLOC_USAGE_HW_COMPOSER GRALLOC1_CONSUMER_USAGE_HWCOMPOSER
     62 #define GRALLOC_USAGE_EXTERNAL_DISP 0x00002000
     63 
     64 #endif
     65 
     66 struct private_module_t
     67 {
     68 	gralloc_module_t base;
     69 
     70 	struct private_handle_t *framebuffer;
     71 	uint32_t flags;
     72 	uint32_t numBuffers;
     73 	uint32_t bufferMask;
     74 	pthread_mutex_t lock;
     75 	buffer_handle_t currentBuffer;
     76 	int ion_client;
     77 	mali_dpy_type dpy_type;
     78 
     79 	struct fb_var_screeninfo info;
     80 	struct fb_fix_screeninfo finfo;
     81 	float xdpi;
     82 	float ydpi;
     83 	float fps;
     84 	int swapInterval;
     85 
     86 #ifdef __cplusplus
     87 	/* Never intended to be used from C code */
     88 	enum
     89 	{
     90 		// flag to indicate we'll post this buffer
     91 		PRIV_USAGE_LOCKED_FOR_POST = 0x80000000
     92 	};
     93 #endif
     94 
     95 #ifdef __cplusplus
     96 	/* default constructor */
     97 	private_module_t();
     98 #endif
     99 };
    100 typedef struct private_module_t mali_gralloc_module;
    101 
    102 #endif /* MALI_GRALLOC_MODULE_H_ */
    103