Files
2026-08-24 10:03:24 +08:00

114 lines
2.8 KiB
C++

/*
* Copyright (c) 2024 Amlogic, Inc. All rights reserved.
*
* This source code is subject to the terms and conditions defined in the
* file 'LICENSE' which is part of this source code package.
*
* Description:
*/
#ifndef V2D_COMPOSER_H
#define V2D_COMPOSER_H
#include <IComposer.h>
#include <DrmFramebufferBase.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<DrmFramebufferBase> mOutputFb;
frames_info_t mVideoFramesInfo;
};
#endif/*V2D_COMPOSER_H*/