150 lines
4.7 KiB
C++
150 lines
4.7 KiB
C++
/*
|
|
* Copyright (c) 2023 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 ICOMPOSITION_STRATEGY_BASE_H
|
|
#define ICOMPOSITION_STRATEGY_BASE_H
|
|
|
|
#include <stdlib.h>
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <list>
|
|
#include <cstring>
|
|
|
|
#include <BasicTypes.h>
|
|
#include "DrmFramebufferBase.h"
|
|
#include "IComposer.h"
|
|
#include "HwDisplayPlaneBase.h"
|
|
#include "HwDisplayCrtcBase.h"
|
|
|
|
|
|
/*composition request for special cases:
|
|
* FORCE_CLIENT: don't use device composition, for debug.
|
|
* SECURE_FB: hide secure fb for special usecases.
|
|
* HDR_VIDEO: information for vpu composition, may be need conside it.
|
|
*/
|
|
typedef enum {
|
|
COMPOSE_FORCE_CLIENT = 1 << 0,
|
|
COMPOSE_HIDE_SECURE_FB = 1 << 1,
|
|
COMPOSE_WITH_HDR_VIDEO = 1 << 2,
|
|
COMPOSE_DISABLE_SIDEBAND = 1 << 3,
|
|
COMPOSE_ENABLE_MOSAIC_MODE = 1 << 4,
|
|
COMPOSE_FORCE_VIDEO = 1 << 5,
|
|
COMPOSE_HIDE_VIDEO_FOR_HDCP_DEV = 1 << 6,
|
|
} COMPOSITION_REQUEST;
|
|
|
|
struct DisplayPair {
|
|
uint32_t din; // 0: din0, 1: din1, 2:din2, 3:video1, 4:video2
|
|
uint32_t presentZorder;
|
|
std::shared_ptr<IComposer> composer;
|
|
std::vector<std::shared_ptr<DrmFramebufferBase>> fbs; // UI or Video from SF
|
|
std::shared_ptr<HwDisplayPlaneBase> plane; // osdPlane <= 3, videoPlane <= 2
|
|
|
|
bool operator< (const DisplayPair item) const {
|
|
if (din < item.din)
|
|
return true;
|
|
else
|
|
return false;
|
|
};
|
|
|
|
bool operator==(const DisplayPair& other) const {
|
|
if (fbs != other.fbs) return false;
|
|
if (din != other.din) return false;
|
|
if (presentZorder != other.presentZorder) return false;
|
|
if (composer != other.composer) return false;
|
|
if (plane != other.plane) return false;
|
|
return true;
|
|
}
|
|
};
|
|
|
|
|
|
/*Macros for composition info dump.*/
|
|
#define STR_LENGTH 48
|
|
|
|
#define DUMP_ADD_LINE_DIVIDE() \
|
|
mDumpStr.append("+------+-------------+---------------+--------+--------------+\n");
|
|
|
|
#define DUMP_APPEND_FB_INFO(fbZ, compType) \
|
|
snprintf(str, STR_LENGTH - 1, "|%6d|%13s|", fbZ, compositionTypeToString(compType)); \
|
|
mDumpStr.append(str); \
|
|
|
|
#define DUMP_APPEND_EMPTY_FB_INFO() \
|
|
snprintf(str, STR_LENGTH - 1, "|%6s|%13s|", " ", " "); \
|
|
mDumpStr.append(str);
|
|
|
|
#define DUMP_APPEND_PLANE_INFO(planeName, planeZ, blankType) \
|
|
snprintf(str, STR_LENGTH - 1, "%15s|%8d|%14s|\n", planeName, planeZ, \
|
|
drmPlaneBlankToString((drm_plane_blank_t)blankType)); \
|
|
mDumpStr.append(str); \
|
|
|
|
#define DUMP_APPEND_EMPTY_PLANE_INFO() \
|
|
snprintf(str, STR_LENGTH - 1, "%15s|%8s|%14s|\n", " ", " ", " "); \
|
|
mDumpStr.append(str); \
|
|
|
|
#define HWC_PLANE_FAKE_ZORDER (1)
|
|
/*Base composition strategy class.*/
|
|
class ICompositionStrategyBase {
|
|
public:
|
|
ICompositionStrategyBase() = default;
|
|
virtual ~ICompositionStrategyBase() = default;
|
|
|
|
virtual const char* getName() = 0;
|
|
|
|
/*before call decideComb, setup will clean last data.*/
|
|
virtual void setup(std::vector<std::shared_ptr<DrmFramebufferBase>> & layers,
|
|
std::vector<std::shared_ptr<IComposer>> & composers,
|
|
std::vector<std::shared_ptr<HwDisplayPlaneBase>> & planes,
|
|
std::shared_ptr<HwDisplayCrtcBase> & crtc,
|
|
uint32_t reqFlag,
|
|
float scaleValue,
|
|
drm_mode_info_t mode) = 0;
|
|
|
|
virtual void updateComposition() = 0;
|
|
|
|
/*if have no valid combs, result will < 0.*/
|
|
virtual int decideComposition() = 0;
|
|
|
|
virtual int getDisplayPair(std::list<DisplayPair> & displayPairs) = 0;
|
|
|
|
virtual void dump(std::string & dumpstr) = 0;
|
|
|
|
protected:
|
|
/*common functions for dump.*/
|
|
inline void dumpComposedFb(
|
|
std::shared_ptr<DrmFramebufferBase> & fb) {
|
|
char str[STR_LENGTH] = {0};
|
|
DUMP_APPEND_FB_INFO(fb->getZorder(), fb->getCompositionType());
|
|
memset(str, 0, STR_LENGTH);
|
|
DUMP_APPEND_EMPTY_PLANE_INFO();
|
|
}
|
|
inline void dumpFbAndPlane(
|
|
std::shared_ptr<DrmFramebufferBase> & fb,
|
|
std::shared_ptr<HwDisplayPlaneBase> & plane,
|
|
int planeZ,
|
|
int planeBlank) {
|
|
char str[STR_LENGTH] = {0};
|
|
DUMP_ADD_LINE_DIVIDE();
|
|
DUMP_APPEND_FB_INFO(fb->getZorder(), fb->getCompositionType());
|
|
memset(str, 0, STR_LENGTH);
|
|
DUMP_APPEND_PLANE_INFO(plane->getName(), planeZ, planeBlank);
|
|
}
|
|
inline void dumpUnusedPlane(
|
|
std::shared_ptr<HwDisplayPlaneBase> & plane,
|
|
int planeBlank) {
|
|
char str[STR_LENGTH] = {0};
|
|
DUMP_ADD_LINE_DIVIDE();
|
|
DUMP_APPEND_EMPTY_FB_INFO();
|
|
memset(str, 0, STR_LENGTH);
|
|
DUMP_APPEND_PLANE_INFO(plane->getName(), -1, planeBlank);
|
|
}
|
|
|
|
protected:
|
|
std::string mDumpStr;
|
|
};
|
|
|
|
#endif/*ICOMPOSITION_STRATEGY_BASE_H*/
|