/* * Copyright (C) 2026 Amlogic Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include "GpscPlane.h" #include "MesonLayer.h" #include "DispAdptLog.h" GpscPlane::GpscPlane(int drvFd) : HwDisplayPlaneBase (drvFd), mConnectTunnel(0) { } void GpscPlane::setConnectTunnel(int id) { std::lock_guard lock(mMutex); mConnectTunnel = id; } int GpscPlane::getGpscIndex(int id) { switch (id) { case MESON_USE_VDEC_TUNNEL: return 0; case MESON_USE_VDEC_EXT_TUNNEL: return 1; case MESON_USE_VO_TUNNEL: return 2; case MESON_USE_TVIN_TUNNEL: return 3; default: break; } return 0; } int32_t GpscPlane::setPlane(std::shared_ptr fb, uint32_t zorder, int blankOp) { std::lock_guard lock(mMutex); std::shared_ptr mesonfb = std::static_pointer_cast(fb); struct gpscaler_frames_t frame = { 0 }; if (!fb.get()) return 1; int tunnelid = mesonfb->getTunnelId(); int index = getGpscIndex(tunnelid); if (!(mConnectTunnel & (1 << index))) { DISPLAY_LOGD("fb %p no need gpsc\n", fb.get()); return 1; } if (blankOp == BLANK_FOR_NO_CONTENT) return 0; int bufferFd = fb->getBufferFd(); if (bufferFd < 0) { DISPLAY_LOGD("setPlane but fb: %" PRIu64 " %p has no buffer", fb->getUniqueId(), fb.get()); return 0; } frame.fd = bufferFd; frame.index = index; frame.out_fen_fd = -1; if (ioctl(mDrvFd, GPSCALER_POST_FRAMES, &frame) < 0) DISPLAY_LOGE("set frame fail: %d\n", errno); fb->setCurReleaseFence(frame.out_fen_fd); return 0; }