Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 3 | * Copyright (C) 2012, The Linux Foundation. All rights reserved. |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -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 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 18 | #define VIDEO_DEBUG 0 |
| 19 | #include <overlay.h> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 20 | #include "hwc_video.h" |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 21 | #include "hwc_utils.h" |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 22 | |
| 23 | namespace qhwc { |
| 24 | |
| 25 | #define FINAL_TRANSFORM_MASK 0x000F |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 26 | |
| 27 | //Static Members |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 28 | ovutils::eOverlayState VideoOverlay::sState[] = {ovutils::OV_CLOSED}; |
| 29 | bool VideoOverlay::sIsModeOn[] = {false}; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 30 | |
| 31 | //Cache stats, figure out the state, config overlay |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 32 | bool VideoOverlay::prepare(hwc_context_t *ctx, hwc_display_contents_1_t *list, |
| 33 | int dpy) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 34 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 35 | int yuvIndex = ctx->listStats[dpy].yuvIndex; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 36 | sIsModeOn[dpy] = false; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 37 | |
Naseer Ahmed | 96c4c95 | 2012-07-25 18:27:14 -0700 | [diff] [blame] | 38 | if(!ctx->mMDP.hasOverlay) { |
Naseer Ahmed | 31da0b1 | 2012-07-31 18:55:33 -0700 | [diff] [blame] | 39 | ALOGD_IF(VIDEO_DEBUG,"%s, this hw doesnt support overlay", __FUNCTION__); |
| 40 | return false; |
| 41 | } |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 42 | |
| 43 | if(yuvIndex == -1 || ctx->listStats[dpy].yuvCount != 1) { |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 44 | return false; |
| 45 | } |
Naseer Ahmed | 4c588a2 | 2012-07-31 19:12:17 -0700 | [diff] [blame] | 46 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 47 | //index guaranteed to be not -1 at this point |
| 48 | hwc_layer_1_t *yuvLayer = &list->hwLayers[yuvIndex]; |
Naseer Ahmed | 68b88cf | 2012-10-02 14:15:12 -0400 | [diff] [blame] | 49 | |
| 50 | if(ctx->mSecureMode) { |
| 51 | private_handle_t *hnd = (private_handle_t *)yuvLayer->handle; |
| 52 | if (! isSecureBuffer(hnd)) { |
| 53 | ALOGD_IF(VIDEO_DEBUG, "%s: Handle non-secure video layer" |
| 54 | "during secure playback gracefully", __FUNCTION__); |
| 55 | return false; |
| 56 | } |
| 57 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 58 | chooseState(ctx, dpy, yuvLayer); |
| 59 | if(configure(ctx, dpy, yuvLayer)) { |
| 60 | markFlags(yuvLayer); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 61 | sIsModeOn[dpy] = true; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 64 | return sIsModeOn[dpy]; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 67 | void VideoOverlay::chooseState(hwc_context_t *ctx, int dpy, |
| 68 | hwc_layer_1_t *yuvLayer) { |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 69 | ALOGD_IF(VIDEO_DEBUG, "%s: old state = %s", __FUNCTION__, |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 70 | ovutils::getStateString(sState[dpy])); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 71 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 72 | private_handle_t *hnd = NULL; |
| 73 | if(yuvLayer) { |
| 74 | hnd = (private_handle_t *)yuvLayer->handle; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 75 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 76 | ovutils::eOverlayState newState = ovutils::OV_CLOSED; |
| 77 | switch(dpy) { |
| 78 | case HWC_DISPLAY_PRIMARY: |
| 79 | if(ctx->listStats[dpy].yuvCount == 1) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 80 | newState = ovutils::OV_2D_VIDEO_ON_PANEL; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 81 | if(isSkipLayer(yuvLayer) && !isSecureBuffer(hnd)) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 82 | newState = ovutils::OV_CLOSED; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | break; |
| 86 | case HWC_DISPLAY_EXTERNAL: |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 87 | newState = ctx->mOverlay[HWC_DISPLAY_EXTERNAL]->getState(); //If we are here, external is active |
| 88 | if(ctx->listStats[dpy].yuvCount == 1) { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 89 | if(!isSkipLayer(yuvLayer) || isSecureBuffer(hnd)) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 90 | newState = ovutils::OV_UI_VIDEO_TV; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 91 | } |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 92 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 93 | break; |
| 94 | default: |
| 95 | break; |
| 96 | } |
| 97 | |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 98 | sState[dpy] = newState; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 99 | ALOGD_IF(VIDEO_DEBUG, "%s: new chosen state = %s", __FUNCTION__, |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 100 | ovutils::getStateString(sState[dpy])); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 103 | void VideoOverlay::markFlags(hwc_layer_1_t *yuvLayer) { |
| 104 | if(yuvLayer) { |
| 105 | yuvLayer->compositionType = HWC_OVERLAY; |
| 106 | yuvLayer->hints |= HWC_HINT_CLEAR_FB; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 107 | } |
| 108 | } |
| 109 | |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 110 | /* Helpers */ |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 111 | bool configPrimVid(hwc_context_t *ctx, hwc_layer_1_t *layer) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 112 | overlay::Overlay& ov = *(ctx->mOverlay[HWC_DISPLAY_PRIMARY]); |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 113 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 114 | ovutils::Whf info(hnd->width, hnd->height, hnd->format, hnd->size); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 115 | |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 116 | ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_FLAGS_NONE; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 117 | if (isSecureBuffer(hnd)) { |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 118 | ovutils::setMdpFlags(mdpFlags, |
| 119 | ovutils::OV_MDP_SECURE_OVERLAY_SESSION); |
| 120 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 121 | |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 122 | ovutils::eIsFg isFgFlag = ovutils::IS_FG_OFF; |
| 123 | if (ctx->numHwLayers == 1) { |
| 124 | isFgFlag = ovutils::IS_FG_SET; |
| 125 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 126 | |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 127 | ovutils::PipeArgs parg(mdpFlags, |
| 128 | info, |
| 129 | ovutils::ZORDER_0, |
| 130 | isFgFlag, |
| 131 | ovutils::ROT_FLAG_DISABLED); |
| 132 | ovutils::PipeArgs pargs[ovutils::MAX_PIPES] = { parg, parg, parg }; |
| 133 | ov.setSource(pargs, ovutils::OV_PIPE0); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 134 | |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 135 | hwc_rect_t sourceCrop = layer->sourceCrop; |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 136 | hwc_rect_t displayFrame = layer->displayFrame; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 137 | |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 138 | //Calculate the rect for primary based on whether the supplied position |
| 139 | //is within or outside bounds. |
| 140 | const int fbWidth = |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 141 | ovutils::FrameBufferInfo::getInstance()->getWidth(); |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 142 | const int fbHeight = |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 143 | ovutils::FrameBufferInfo::getInstance()->getHeight(); |
| 144 | |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 145 | if( displayFrame.left < 0 || |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 146 | displayFrame.top < 0 || |
| 147 | displayFrame.right > fbWidth || |
| 148 | displayFrame.bottom > fbHeight) { |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 149 | calculate_crop_rects(sourceCrop, displayFrame, fbWidth, fbHeight); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 150 | } |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 151 | |
Saurabh Shah | 1023ce2 | 2012-09-05 18:45:59 -0700 | [diff] [blame] | 152 | // source crop x,y,w,h |
| 153 | ovutils::Dim dcrop(sourceCrop.left, sourceCrop.top, |
| 154 | sourceCrop.right - sourceCrop.left, |
| 155 | sourceCrop.bottom - sourceCrop.top); |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 156 | //Only for Primary |
| 157 | ov.setCrop(dcrop, ovutils::OV_PIPE0); |
| 158 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 159 | int transform = layer->transform; |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 160 | ovutils::eTransform orient = |
| 161 | static_cast<ovutils::eTransform>(transform); |
| 162 | ov.setTransform(orient, ovutils::OV_PIPE0); |
| 163 | |
Saurabh Shah | 1023ce2 | 2012-09-05 18:45:59 -0700 | [diff] [blame] | 164 | // position x,y,w,h |
| 165 | ovutils::Dim dpos(displayFrame.left, |
| 166 | displayFrame.top, |
| 167 | displayFrame.right - displayFrame.left, |
| 168 | displayFrame.bottom - displayFrame.top); |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 169 | ov.setPosition(dpos, ovutils::OV_PIPE0); |
| 170 | |
| 171 | if (!ov.commit(ovutils::OV_PIPE0)) { |
| 172 | ALOGE("%s: commit fails", __FUNCTION__); |
| 173 | return false; |
| 174 | } |
| 175 | return true; |
| 176 | } |
| 177 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 178 | bool configExtVid(hwc_context_t *ctx, hwc_layer_1_t *layer) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 179 | overlay::Overlay& ov = *(ctx->mOverlay[HWC_DISPLAY_EXTERNAL]); |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 180 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 181 | ovutils::Whf info(hnd->width, hnd->height, hnd->format, hnd->size); |
| 182 | |
| 183 | ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_FLAGS_NONE; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 184 | if (isSecureBuffer(hnd)) { |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 185 | ovutils::setMdpFlags(mdpFlags, |
| 186 | ovutils::OV_MDP_SECURE_OVERLAY_SESSION); |
| 187 | } |
| 188 | |
| 189 | ovutils::eIsFg isFgFlag = ovutils::IS_FG_OFF; |
| 190 | if (ctx->numHwLayers == 1) { |
| 191 | isFgFlag = ovutils::IS_FG_SET; |
| 192 | } |
| 193 | |
| 194 | ovutils::PipeArgs parg(mdpFlags, |
| 195 | info, |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 196 | ovutils::ZORDER_1, |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 197 | isFgFlag, |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 198 | ovutils::ROT_FLAG_DISABLED); |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 199 | ovutils::PipeArgs pargs[ovutils::MAX_PIPES] = { parg, parg, parg }; |
| 200 | ov.setSource(pargs, ovutils::OV_PIPE1); |
| 201 | |
| 202 | hwc_rect_t sourceCrop = layer->sourceCrop; |
| 203 | // x,y,w,h |
| 204 | ovutils::Dim dcrop(sourceCrop.left, sourceCrop.top, |
| 205 | sourceCrop.right - sourceCrop.left, |
| 206 | sourceCrop.bottom - sourceCrop.top); |
| 207 | //Only for External |
| 208 | ov.setCrop(dcrop, ovutils::OV_PIPE1); |
| 209 | |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 210 | int transform = layer->transform; |
| 211 | ovutils::eTransform orient = |
| 212 | static_cast<ovutils::eTransform>(transform); |
| 213 | ov.setTransform(orient, ovutils::OV_PIPE1); |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 214 | |
| 215 | ovutils::Dim dpos; |
| 216 | hwc_rect_t displayFrame = layer->displayFrame; |
| 217 | dpos.x = displayFrame.left; |
| 218 | dpos.y = displayFrame.top; |
| 219 | dpos.w = (displayFrame.right - displayFrame.left); |
| 220 | dpos.h = (displayFrame.bottom - displayFrame.top); |
| 221 | |
| 222 | //Only for External |
| 223 | ov.setPosition(dpos, ovutils::OV_PIPE1); |
| 224 | |
| 225 | if (!ov.commit(ovutils::OV_PIPE1)) { |
| 226 | ALOGE("%s: commit fails", __FUNCTION__); |
| 227 | return false; |
| 228 | } |
| 229 | return true; |
| 230 | } |
| 231 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 232 | bool VideoOverlay::configure(hwc_context_t *ctx, int dpy, |
| 233 | hwc_layer_1_t *yuvLayer) { |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 234 | bool ret = true; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 235 | overlay::Overlay& ov = *(ctx->mOverlay[dpy]); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 236 | switch(dpy) { |
| 237 | case HWC_DISPLAY_PRIMARY: |
| 238 | // Set overlay state |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 239 | ov.setState(sState[dpy]); |
| 240 | switch(sState[dpy]) { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 241 | case ovutils::OV_2D_VIDEO_ON_PANEL: |
| 242 | ret &= configPrimVid(ctx, yuvLayer); |
| 243 | break; |
| 244 | default: |
| 245 | return false; |
| 246 | } |
| 247 | break; |
| 248 | case HWC_DISPLAY_EXTERNAL: |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 249 | ov.setState(sState[dpy]); |
| 250 | switch(sState[dpy]) { |
| 251 | case ovutils::OV_UI_VIDEO_TV: |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 252 | ret = configExtVid(ctx, yuvLayer); |
| 253 | break; |
| 254 | default: |
| 255 | return false; |
| 256 | } |
| 257 | break; |
Naseer Ahmed | 2cc53dd | 2012-07-31 19:11:48 -0700 | [diff] [blame] | 258 | } |
| 259 | return ret; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 262 | bool VideoOverlay::draw(hwc_context_t *ctx, hwc_display_contents_1_t *list, |
| 263 | int dpy) |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 264 | { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 265 | if(!sIsModeOn[dpy]) { |
| 266 | return true; |
| 267 | } |
| 268 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 269 | int yuvIndex = ctx->listStats[dpy].yuvIndex; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 270 | if(yuvIndex == -1) { |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 271 | return true; |
| 272 | } |
| 273 | |
Naseer Ahmed | 4c588a2 | 2012-07-31 19:12:17 -0700 | [diff] [blame] | 274 | private_handle_t *hnd = (private_handle_t *) |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 275 | list->hwLayers[yuvIndex].handle; |
Naseer Ahmed | 4c588a2 | 2012-07-31 19:12:17 -0700 | [diff] [blame] | 276 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 277 | bool ret = true; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 278 | overlay::Overlay& ov = *(ctx->mOverlay[dpy]); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 279 | ovutils::eOverlayState state = ov.getState(); |
| 280 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 281 | switch(dpy) { |
| 282 | case HWC_DISPLAY_PRIMARY: |
| 283 | switch (state) { |
| 284 | case ovutils::OV_2D_VIDEO_ON_PANEL: |
| 285 | // Play primary |
| 286 | if (!ov.queueBuffer(hnd->fd, hnd->offset, ovutils::OV_PIPE0)) { |
| 287 | ALOGE("%s: queueBuffer failed for primary", __FUNCTION__); |
| 288 | ret = false; |
| 289 | } |
| 290 | break; |
| 291 | default: |
| 292 | ret = false; |
| 293 | break; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 294 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 295 | break; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 296 | case HWC_DISPLAY_EXTERNAL: |
| 297 | switch(state) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 298 | case ovutils::OV_UI_VIDEO_TV: |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 299 | // Play external |
| 300 | if (!ov.queueBuffer(hnd->fd, hnd->offset, ovutils::OV_PIPE1)) { |
| 301 | ALOGE("%s: queueBuffer failed for external", __FUNCTION__); |
| 302 | ret = false; |
| 303 | } |
| 304 | break; |
| 305 | default: |
| 306 | ret = false; |
| 307 | break; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 308 | } |
| 309 | break; |
| 310 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 311 | return ret; |
| 312 | } |
| 313 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 314 | }; //namespace qhwc |