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