Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 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> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 29 | #include <genlock.h> |
| 30 | #include "hwc_qbuf.h" |
| 31 | |
| 32 | #define ALIGN(x, align) (((x) + ((align)-1)) & ~((align)-1)) |
| 33 | #define LIKELY( exp ) (__builtin_expect( (exp) != 0, true )) |
| 34 | #define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) |
| 35 | |
| 36 | struct hwc_context_t; |
| 37 | namespace qhwc { |
| 38 | |
Naseer Ahmed | a87da60 | 2012-07-01 23:54:19 -0700 | [diff] [blame] | 39 | enum external_display_type { |
| 40 | EXT_TYPE_NONE, |
| 41 | EXT_TYPE_HDMI, |
| 42 | EXT_TYPE_WIFI |
| 43 | }; |
| 44 | |
| 45 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 46 | // ----------------------------------------------------------------------------- |
| 47 | // Utility functions - implemented in hwc_utils.cpp |
| 48 | void dumpLayer(hwc_layer_t const* l); |
| 49 | void getLayerStats(hwc_context_t *ctx, const hwc_layer_list_t *list); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 50 | void initContext(hwc_context_t *ctx); |
| 51 | void closeContext(hwc_context_t *ctx); |
| 52 | void openFramebufferDevice(hwc_context_t *ctx); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 53 | //Crops source buffer against destination and FB boundaries |
| 54 | void calculate_crop_rects(hwc_rect_t& crop, hwc_rect_t& dst, |
| 55 | const int fbWidth, const int fbHeight); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 56 | |
| 57 | // Inline utility functions |
| 58 | static inline bool isSkipLayer(const hwc_layer_t* l) { |
| 59 | return (UNLIKELY(l && (l->flags & HWC_SKIP_LAYER))); |
| 60 | } |
| 61 | |
| 62 | // Returns true if the buffer is yuv |
| 63 | static inline bool isYuvBuffer(const private_handle_t* hnd) { |
| 64 | return (hnd && (hnd->bufferType == BUFFER_TYPE_VIDEO)); |
| 65 | } |
| 66 | |
| 67 | //Return true if buffer is marked locked |
| 68 | static inline bool isBufferLocked(const private_handle_t* hnd) { |
| 69 | return (hnd && (private_handle_t::PRIV_FLAGS_HWC_LOCK & hnd->flags)); |
| 70 | } |
| 71 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 72 | }; //qhwc namespace |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 73 | |
| 74 | |
| 75 | // ----------------------------------------------------------------------------- |
| 76 | // HWC context |
| 77 | // This structure contains overall state |
| 78 | struct hwc_context_t { |
| 79 | hwc_composer_device_t device; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 80 | int hdmiEnabled; |
| 81 | int numHwLayers; |
Naseer Ahmed | a87da60 | 2012-07-01 23:54:19 -0700 | [diff] [blame] | 82 | int mdpVersion; |
| 83 | bool hasOverlay; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 84 | int overlayInUse; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 85 | |
| 86 | //Framebuffer device |
| 87 | framebuffer_device_t *fbDev; |
| 88 | |
| 89 | //Overlay object - NULL for non overlay devices |
| 90 | overlay::Overlay *mOverlay; |
| 91 | |
| 92 | //QueuedBufferStore to hold buffers for overlay |
| 93 | qhwc::QueuedBufferStore *qbuf; |
| 94 | }; |
| 95 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 96 | #endif //HWC_UTILS_H |