Files
BPI-CM9-Linux/aml-comp/vendor/amlogic/meson_videoserver/display/drm/GpscPlane.cpp
T

90 lines
2.3 KiB
C++

/*
* 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 <fcntl.h>
#include <poll.h>
#include <sys/ioctl.h>
#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<std::mutex> 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<DrmFramebufferBase> fb, uint32_t zorder, int blankOp)
{
std::lock_guard<std::mutex> lock(mMutex);
std::shared_ptr<MesonLayer> mesonfb = std::static_pointer_cast<MesonLayer>(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;
}