disp: msm: sde: refactor topology group check helpers

Refactor topology group check helpers into a single
function to remove duplicate code. This change also
uses atomic state to extract topology information
since those functions can be called during atomic
check phase.

Change-Id: Ia262009e0b8fe9fcdeff05e544d2e59be35c9c54
Signed-off-by: Amine Najahi <anajahi@codeaurora.org>
This commit is contained in:
Amine Najahi
2020-07-07 16:46:39 -04:00
szülő 9ec78e3339
commit 2d624f6ab8
3 fájl változott, egészen pontosan 105 új sor hozzáadva és 100 régi sor törölve

Fájl megtekintése

@@ -852,7 +852,8 @@ static int _sde_crtc_set_lm_roi(struct drm_crtc *crtc,
* hence, crtc roi must match the mixer dimensions. * hence, crtc roi must match the mixer dimensions.
*/ */
if (crtc_state->num_ds_enabled || if (crtc_state->num_ds_enabled ||
sde_rm_topology_is_3dmux_dsc(&sde_kms->rm, state)) { sde_rm_topology_is_group(&sde_kms->rm, state,
SDE_RM_TOPOLOGY_GROUP_3DMERGE_DSC)) {
if (memcmp(lm_roi, lm_bounds, sizeof(struct sde_rect))) { if (memcmp(lm_roi, lm_bounds, sizeof(struct sde_rect))) {
SDE_ERROR("Unsupported: Dest scaler/3d mux DSC + PU\n"); SDE_ERROR("Unsupported: Dest scaler/3d mux DSC + PU\n");
return -EINVAL; return -EINVAL;
@@ -4815,7 +4816,8 @@ static int _sde_crtc_check_plane_layout(struct drm_crtc *crtc,
return -EINVAL; return -EINVAL;
} }
if (!sde_rm_topology_is_quad_pipe(&kms->rm, crtc_state)) if (!sde_rm_topology_is_group(&kms->rm, crtc_state,
SDE_RM_TOPOLOGY_GROUP_QUADPIPE))
return 0; return 0;
drm_atomic_crtc_state_for_each_plane(plane, crtc_state) { drm_atomic_crtc_state_for_each_plane(plane, crtc_state) {

Fájl megtekintése

@@ -2121,84 +2121,77 @@ int sde_rm_update_topology(struct sde_rm *rm,
return ret; return ret;
} }
bool sde_rm_topology_is_quad_pipe(struct sde_rm *rm, bool sde_rm_topology_is_group(struct sde_rm *rm,
struct drm_crtc_state *state) struct drm_crtc_state *state,
enum sde_rm_topology_group group)
{ {
int i; int i, ret = 0;
struct sde_crtc_state *cstate; struct sde_crtc_state *cstate;
uint64_t topology = SDE_RM_TOPOLOGY_NONE; struct drm_connector *conn;
struct drm_connector_state *conn_state;
struct msm_display_topology topology;
enum sde_rm_topology_name name;
if ((!rm) || (!state)) { if ((!rm) || (!state) || (!state->state)) {
pr_err("invalid arguments: rm:%d state:%d\n", pr_err("invalid arguments: rm:%d state:%d atomic state:%d\n",
rm == NULL, state == NULL); !rm, !state, state ? (!state->state) : 0);
return false; return false;
} }
cstate = to_sde_crtc_state(state); cstate = to_sde_crtc_state(state);
for (i = 0; i < cstate->num_connectors; i++) { for (i = 0; i < cstate->num_connectors; i++) {
struct drm_connector *conn = cstate->connectors[i]; conn = cstate->connectors[i];
if (!conn) {
SDE_DEBUG("invalid connector\n");
continue;
}
topology = sde_connector_get_topology_name(conn); conn_state = drm_atomic_get_connector_state(state->state, conn);
if (TOPOLOGY_QUADPIPE_MERGE_MODE(topology)) if (!conn_state) {
return true; SDE_DEBUG("%s invalid connector state\n", conn->name);
} continue;
}
return false; ret = sde_connector_state_get_topology(conn_state, &topology);
} if (ret) {
SDE_DEBUG("%s invalid topology\n", conn->name);
continue;
}
bool sde_rm_topology_is_dual_pipe(struct sde_rm *rm, name = sde_rm_get_topology_name(rm, topology);
struct drm_crtc_state *state) switch (group) {
{ case SDE_RM_TOPOLOGY_GROUP_SINGLEPIPE:
int i; if (TOPOLOGY_SINGLEPIPE_MODE(name))
struct sde_crtc_state *cstate; return true;
uint64_t topology = SDE_RM_TOPOLOGY_NONE; break;
case SDE_RM_TOPOLOGY_GROUP_DUALPIPE:
if ((!rm) || (!state)) { if (TOPOLOGY_DUALPIPE_MODE(name))
pr_err("invalid arguments: rm:%d state:%d\n", return true;
rm == NULL, state == NULL); break;
return false; case SDE_RM_TOPOLOGY_GROUP_QUADPIPE:
} if (TOPOLOGY_QUADPIPE_MODE(name))
return true;
cstate = to_sde_crtc_state(state); break;
case SDE_RM_TOPOLOGY_GROUP_3DMERGE:
for (i = 0; i < cstate->num_connectors; i++) { if (topology.num_lm > topology.num_intf &&
struct drm_connector *conn = cstate->connectors[i]; !topology.num_enc)
return true;
topology = sde_connector_get_topology_name(conn); break;
if (TOPOLOGY_DUALPIPE_MERGE_MODE(topology)) case SDE_RM_TOPOLOGY_GROUP_3DMERGE_DSC:
return true; if (topology.num_lm > topology.num_enc &&
} topology.num_enc)
return true;
return false; break;
} case SDE_RM_TOPOLOGY_GROUP_DSCMERGE:
if (topology.num_lm == topology.num_enc &&
bool sde_rm_topology_is_3dmux_dsc(struct sde_rm *rm, topology.num_enc)
struct drm_crtc_state *state) return true;
{ break;
int i; default:
struct sde_crtc_state *cstate; SDE_ERROR("invalid topology group\n");
uint64_t topology = SDE_RM_TOPOLOGY_NONE; return false;
const struct sde_rm_topology_def *def; }
int num_lm, num_enc;
if ((!rm) || (!state)) {
pr_err("invalid arguments: rm:%d state:%d\n",
rm == NULL, state == NULL);
return false;
}
cstate = to_sde_crtc_state(state);
for (i = 0; i < cstate->num_connectors; i++) {
struct drm_connector *conn = cstate->connectors[i];
topology = sde_connector_get_topology_name(conn);
def = sde_rm_topology_get_topology_def(rm, topology);
num_lm = def->num_lm;
num_enc = def->num_comp_enc;
if (num_lm > num_enc && num_enc)
return true;
} }
return false; return false;

Fájl megtekintése

@@ -14,18 +14,25 @@
#define SINGLE_CTL 1 #define SINGLE_CTL 1
#define DUAL_CTL 2 #define DUAL_CTL 2
#define TOPOLOGY_QUADPIPE_MERGE_MODE(x) \ #define TOPOLOGY_SINGLEPIPE_MODE(x) \
(x == SDE_RM_TOPOLOGY_SINGLEPIPE ||\
x == SDE_RM_TOPOLOGY_SINGLEPIPE_DSC ||\
x == SDE_RM_TOPOLOGY_SINGLEPIPE_VDC)
#define TOPOLOGY_DUALPIPE_MODE(x) \
(x == SDE_RM_TOPOLOGY_DUALPIPE ||\
x == SDE_RM_TOPOLOGY_DUALPIPE_DSC ||\
x == SDE_RM_TOPOLOGY_DUALPIPE_DSCMERGE ||\
x == SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE ||\
x == SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE_VDC ||\
x == SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE_DSC)
#define TOPOLOGY_QUADPIPE_MODE(x) \
(x == SDE_RM_TOPOLOGY_QUADPIPE_3DMERGE ||\ (x == SDE_RM_TOPOLOGY_QUADPIPE_3DMERGE ||\
x == SDE_RM_TOPOLOGY_QUADPIPE_3DMERGE_DSC ||\ x == SDE_RM_TOPOLOGY_QUADPIPE_3DMERGE_DSC ||\
x == SDE_RM_TOPOLOGY_QUADPIPE_DSCMERGE ||\ x == SDE_RM_TOPOLOGY_QUADPIPE_DSCMERGE ||\
x == SDE_RM_TOPOLOGY_QUADPIPE_DSC4HSMERGE) x == SDE_RM_TOPOLOGY_QUADPIPE_DSC4HSMERGE)
#define TOPOLOGY_DUALPIPE_MERGE_MODE(x) \
(x == SDE_RM_TOPOLOGY_DUALPIPE_DSCMERGE || \
x == SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE || \
x == SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE_VDC || \
x == SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE_DSC)
/** /**
* enum sde_rm_topology_name - HW resource use case in use by connector * enum sde_rm_topology_name - HW resource use case in use by connector
* @SDE_RM_TOPOLOGY_NONE: No topology in use currently * @SDE_RM_TOPOLOGY_NONE: No topology in use currently
@@ -63,6 +70,27 @@ enum sde_rm_topology_name {
SDE_RM_TOPOLOGY_MAX, SDE_RM_TOPOLOGY_MAX,
}; };
/**
* enum sde_rm_topology_group - Topology group selection
* @SDE_RM_TOPOLOGY_GROUP_NONE: No topology group in use currently
* @SDE_RM_TOPOLOGY_GROUP_SINGLEPIPE: Any topology that uses 1 LM
* @SDE_RM_TOPOLOGY_GROUP_DUALPIPE: Any topology that uses 2 LM
* @SDE_RM_TOPOLOGY_GROUP_QUADPIPE: Any topology that uses 4 LM
* @SDE_RM_TOPOLOGY_GROUP_3DMERGE: Any topology that uses 3D merge only
* @SDE_RM_TOPOLOGY_GROUP_3DMERGE_DSC: Any topology that uses 3D merge + DSC
* @SDE_RM_TOPOLOGY_GROUP_DSCMERGE: Any topology that uses DSC merge
*/
enum sde_rm_topology_group {
SDE_RM_TOPOLOGY_GROUP_NONE = 0,
SDE_RM_TOPOLOGY_GROUP_SINGLEPIPE,
SDE_RM_TOPOLOGY_GROUP_DUALPIPE,
SDE_RM_TOPOLOGY_GROUP_QUADPIPE,
SDE_RM_TOPOLOGY_GROUP_3DMERGE,
SDE_RM_TOPOLOGY_GROUP_3DMERGE_DSC,
SDE_RM_TOPOLOGY_GROUP_DSCMERGE,
SDE_RM_TOPOLOGY_GROUP_MAX,
};
/** /**
* enum sde_rm_topology_control - HW resource use case in use by connector * enum sde_rm_topology_control - HW resource use case in use by connector
* @SDE_RM_TOPCTL_RESERVE_LOCK: If set, in AtomicTest phase, after a successful * @SDE_RM_TOPCTL_RESERVE_LOCK: If set, in AtomicTest phase, after a successful
@@ -350,34 +378,16 @@ static inline int sde_rm_topology_get_num_lm(struct sde_rm *rm,
} }
/** /**
* sde_rm_topology_is_dual_pipe - check if the topology used * sde_rm_topology_is_group - check if the topology in use
* is a dual-pipe mode one * is part of the requested group
* @rm: SDE Resource Manager handle * @rm: SDE Resource Manager handle
* @state: drm state of the crtc * @state: drm state of the crtc
* @return: true if attached connector is in dual-pipe mode * @group: topology group to check
* @return: true if attached connector is in the topology group
*/ */
bool sde_rm_topology_is_dual_pipe(struct sde_rm *rm, bool sde_rm_topology_is_group(struct sde_rm *rm,
struct drm_crtc_state *state); struct drm_crtc_state *state,
enum sde_rm_topology_group group);
/**
* sde_rm_topology_is_3dmux_dsc - check if the topology used
* is a 3dmerge dsc mode one
* @rm: SDE Resource Manager handle
* @state: drm state of the crtc
* @return: true if attached connector is in 3DMERGE DSC mode
*/
bool sde_rm_topology_is_3dmux_dsc(struct sde_rm *rm,
struct drm_crtc_state *state);
/**
* sde_rm_topology_is_quad_pipe - check if the topology used
* is a quad-pipe mode one
* @rm: SDE Resource Manager handle
* @state: drm state of the crtc
* @return: true if attached connector is in quad-pipe mode
*/
bool sde_rm_topology_is_quad_pipe(struct sde_rm *rm,
struct drm_crtc_state *state);
/** /**
* sde_rm_ext_blk_create_reserve - Create external HW blocks * sde_rm_ext_blk_create_reserve - Create external HW blocks