hwc_utils.h revision 29a26818d7294055539167b2fbfdaa168bcf725c
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * Copyright (C) 2012, Code Aurora Forum. All rights reserved. 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 HWC_UTILS_H 19#define HWC_UTILS_H 20#include <cutils/log.h> 21#include <gralloc_priv.h> 22#include <hardware/hwcomposer.h> 23#include <hardware/hardware.h> 24#include <hardware/gralloc.h> 25#include <stdlib.h> 26#include <string.h> 27#include <fb_priv.h> 28#include <overlay.h> 29#include <qcom_ui.h> 30#include <genlock.h> 31#include "hwc_qbuf.h" 32 33#define ALIGN(x, align) (((x) + ((align)-1)) & ~((align)-1)) 34#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true )) 35#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) 36 37struct hwc_context_t; 38namespace qhwc { 39 40// ----------------------------------------------------------------------------- 41// Utility functions - implemented in hwc_utils.cpp 42void dumpLayer(hwc_layer_t const* l); 43void getLayerStats(hwc_context_t *ctx, const hwc_layer_list_t *list); 44void handleYUV(hwc_context_t *ctx, hwc_layer_t *layer); 45void initContext(hwc_context_t *ctx); 46void closeContext(hwc_context_t *ctx); 47void openFramebufferDevice(hwc_context_t *ctx); 48 49// Inline utility functions 50static inline bool isSkipLayer(const hwc_layer_t* l) { 51 return (UNLIKELY(l && (l->flags & HWC_SKIP_LAYER))); 52} 53 54// Returns true if the buffer is yuv 55static inline bool isYuvBuffer(const private_handle_t* hnd) { 56 return (hnd && (hnd->bufferType == BUFFER_TYPE_VIDEO)); 57} 58 59//Return true if buffer is marked locked 60static inline bool isBufferLocked(const private_handle_t* hnd) { 61 return (hnd && (private_handle_t::PRIV_FLAGS_HWC_LOCK & hnd->flags)); 62} 63 64// ----------------------------------------------------------------------------- 65// Overlay specific functions - inline or implemented in hwc_overlay.cpp 66bool prepareOverlay(hwc_context_t *ctx, hwc_layer_t *layer); 67//XXX: Refine draw functions 68bool drawLayerUsingOverlay(hwc_context_t *ctx, hwc_layer_t *layer); 69//XXX: Refine 70void cleanOverlays(hwc_context_t *ctx ); 71void setOverlayState(hwc_context_t* ctx, ovutils::eOverlayState state); 72 73// ----------------------------------------------------------------------------- 74// Copybit specific functions - inline or implemented in hwc_copybit.cpp 75 76 77 78// ----------------------------------------------------------------------------- 79// HDMI specific functions - inline or implemented in hwc_hdmi.cpp 80 81 82 83} //qhwc namespace 84 85 86 87// ----------------------------------------------------------------------------- 88// HWC context 89// This structure contains overall state 90struct hwc_context_t { 91 hwc_composer_device_t device; 92 // Layer variables 93 int yuvBufferCount; 94 int hdmiEnabled; 95 int numHwLayers; 96 bool skipComposition; 97 98 //Framebuffer device 99 framebuffer_device_t *fbDev; 100 101 //Overlay object - NULL for non overlay devices 102 overlay::Overlay *mOverlay; 103 104 //QueuedBufferStore to hold buffers for overlay 105 qhwc::QueuedBufferStore *qbuf; 106}; 107 108 109 110 111#endif //HWC_UTILS_H 112