122 lines
3.1 KiB
C++
122 lines
3.1 KiB
C++
/*
|
|
* Copyright (C) 2024 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.
|
|
*/
|
|
|
|
#ifndef V2D_COMPOSER_H
|
|
#define V2D_COMPOSER_H
|
|
|
|
#include <IComposer.h>
|
|
#include <DrmFramebufferBase.h>
|
|
#include "MesonLayer.h"
|
|
|
|
#define V2D_COMPOSER_NAME "V2DComposer"
|
|
|
|
#define V2D_IOC_MAGIC 'R'
|
|
#define V2D_IOCTL_SET_FRAMES _IOW(V2D_IOC_MAGIC, 0x00, frames_info_t)
|
|
#define V2D_IOCTL_SET_ENABLE _IOW(V2D_IOC_MAGIC, 0x01, int)
|
|
#define V2D_IOCTL_SET_FENCE _IOW(V2D_IOC_MAGIC, 0x02, release_info_t)
|
|
|
|
#define V2D_POOL_SIZE 8
|
|
#define BUFFER_LEN 4
|
|
#define MIN_ALPHA_VALUE 0
|
|
#define MAX_ALPHA_VALUE 255
|
|
|
|
|
|
typedef struct frame_info {
|
|
int32_t fd;
|
|
int32_t fence_fd;
|
|
int32_t buffer_w;
|
|
int32_t buffer_h;
|
|
int32_t align_w;
|
|
int32_t align_h;
|
|
int32_t dst_x;
|
|
int32_t dst_y;
|
|
int32_t dst_w;
|
|
int32_t dst_h;
|
|
int32_t crop_x;
|
|
int32_t crop_y;
|
|
int32_t crop_w;
|
|
int32_t crop_h;
|
|
int32_t zorder;
|
|
int32_t buffer_format;
|
|
int32_t transform;
|
|
int32_t alpha;
|
|
int32_t reserved[10];
|
|
}frame_info_t;
|
|
|
|
typedef struct frames_info {
|
|
int32_t frame_count;
|
|
frame_info_t input_buffer[MAX_LAYER_COUNT];
|
|
frame_info_t out_buffer;
|
|
int32_t reserved[4];
|
|
} frames_info_t;
|
|
|
|
typedef struct release_info {
|
|
int32_t fd;
|
|
int32_t fence_fd;
|
|
} release_info_t;
|
|
|
|
class V2DComposer : public IComposer {
|
|
public:
|
|
V2DComposer(int displayId, int fd);
|
|
~V2DComposer();
|
|
|
|
const char* getName() { return V2D_COMPOSER_NAME; }
|
|
meson_composition_t getType() { return MESON_COMPOSITION_V2D; }
|
|
|
|
bool isFbsSupport(
|
|
std::vector<std::shared_ptr<DrmFramebufferBase>> & fbs,
|
|
std::vector<std::shared_ptr<DrmFramebufferBase>> & overlayfbs,
|
|
int composeIdx = 0);
|
|
|
|
int32_t prepare();
|
|
|
|
int32_t addInputs(
|
|
std::vector<std::shared_ptr<DrmFramebufferBase>> & fbs,
|
|
std::vector<std::shared_ptr<DrmFramebufferBase>> & overlayfbs,
|
|
int composeIdx = 0);
|
|
|
|
int32_t getOverlyFbs(std::vector<std::shared_ptr<DrmFramebufferBase>> & overlays);
|
|
|
|
int32_t setOutput(
|
|
std::shared_ptr<DrmFramebufferBase> & fb,
|
|
int composeIdx = 0);
|
|
|
|
int32_t start(int composeIdx = 0);
|
|
|
|
std::shared_ptr<DrmFramebufferBase> getOutput(int composeIdx = 0);
|
|
|
|
int32_t setReleaseFence();
|
|
int32_t enable(bool enable);
|
|
|
|
protected:
|
|
int32_t fillOutputFrameBuffer(frame_info_t & buffer);
|
|
bool needSkipRotationInComposer();
|
|
|
|
protected:
|
|
bool mEnable;
|
|
int mDevFd;
|
|
int mDisplayID;
|
|
|
|
std::vector<std::shared_ptr<DrmFramebufferBase>> mInputFbs;
|
|
std::vector<std::shared_ptr<DrmFramebufferBase>> mOverlayFbs;
|
|
std::shared_ptr<MesonLayer> mOutputFb;
|
|
|
|
frames_info_t mVideoFramesInfo;
|
|
};
|
|
|
|
#endif/*V2D_COMPOSER_H*/
|