disp: msm: sde: reduce complexity in _sde_plane_install_properties

Lower the cyclomatic complexity for this function by splitting the
work into helper functions.

Change-Id: I07d399e455ca2f73a14875b45c30f123c39fa501
Signed-off-by: Steve Cohen <cohens@codeaurora.org>
This commit is contained in:
Steve Cohen
2020-02-01 23:14:52 -05:00
parent 697315b082
commit ba96d9f114

View File

@@ -3403,164 +3403,11 @@ static void _sde_plane_install_master_only_properties(struct sde_plane *psde)
}
/* helper to install properties which are common to planes and crtcs */
static void _sde_plane_install_properties(struct drm_plane *plane,
struct sde_mdss_cfg *catalog, u32 master_plane_id)
static void _sde_plane_install_colorproc_properties(struct sde_plane *psde,
struct sde_kms_info *info)
{
static const struct drm_prop_enum_list e_blend_op[] = {
{SDE_DRM_BLEND_OP_NOT_DEFINED, "not_defined"},
{SDE_DRM_BLEND_OP_OPAQUE, "opaque"},
{SDE_DRM_BLEND_OP_PREMULTIPLIED, "premultiplied"},
{SDE_DRM_BLEND_OP_COVERAGE, "coverage"},
{SDE_DRM_BLEND_OP_SKIP, "skip_blending"},
};
static const struct drm_prop_enum_list e_src_config[] = {
{SDE_DRM_DEINTERLACE, "deinterlace"}
};
static const struct drm_prop_enum_list e_fb_translation_mode[] = {
{SDE_DRM_FB_NON_SEC, "non_sec"},
{SDE_DRM_FB_SEC, "sec"},
{SDE_DRM_FB_NON_SEC_DIR_TRANS, "non_sec_direct_translation"},
{SDE_DRM_FB_SEC_DIR_TRANS, "sec_direct_translation"},
};
static const struct drm_prop_enum_list e_multirect_mode[] = {
{SDE_SSPP_MULTIRECT_NONE, "none"},
{SDE_SSPP_MULTIRECT_PARALLEL, "parallel"},
{SDE_SSPP_MULTIRECT_TIME_MX, "serial"},
};
const struct sde_format_extended *format_list;
struct sde_kms_info *info;
struct sde_plane *psde = to_sde_plane(plane);
bool is_master;
int zpos_max = 255;
int zpos_def = 0;
char feature_name[256];
uint32_t index;
if (!plane || !psde) {
SDE_ERROR("invalid plane\n");
return;
} else if (!psde->pipe_hw || !psde->pipe_sblk) {
SDE_ERROR("invalid plane, pipe_hw %d pipe_sblk %d\n",
!psde->pipe_hw, !psde->pipe_sblk);
return;
} else if (!catalog) {
SDE_ERROR("invalid catalog\n");
return;
}
psde->catalog = catalog;
is_master = !psde->is_virtual;
if (sde_is_custom_client()) {
if (catalog->mixer_count &&
catalog->mixer[0].sblk->maxblendstages) {
zpos_max = catalog->mixer[0].sblk->maxblendstages - 1;
if (catalog->has_base_layer &&
(zpos_max > SDE_STAGE_MAX - 1))
zpos_max = SDE_STAGE_MAX - 1;
else if (zpos_max > SDE_STAGE_MAX - SDE_STAGE_0 - 1)
zpos_max = SDE_STAGE_MAX - SDE_STAGE_0 - 1;
}
} else if (plane->type != DRM_PLANE_TYPE_PRIMARY) {
/* reserve zpos == 0 for primary planes */
zpos_def = drm_plane_index(plane) + 1;
}
msm_property_install_range(&psde->property_info, "zpos",
0x0, 0, zpos_max, zpos_def, PLANE_PROP_ZPOS);
msm_property_install_range(&psde->property_info, "alpha",
0x0, 0, 255, 255, PLANE_PROP_ALPHA);
/* linux default file descriptor range on each process */
msm_property_install_range(&psde->property_info, "input_fence",
0x0, 0, INR_OPEN_MAX, 0, PLANE_PROP_INPUT_FENCE);
if (is_master)
_sde_plane_install_master_only_properties(psde);
if (psde->features & BIT(SDE_SSPP_EXCL_RECT))
msm_property_install_volatile_range(&psde->property_info,
"excl_rect_v1", 0x0, 0, ~0, 0, PLANE_PROP_EXCL_RECT_V1);
sde_plane_rot_install_properties(plane, catalog);
msm_property_install_enum(&psde->property_info, "blend_op", 0x0, 0,
e_blend_op, ARRAY_SIZE(e_blend_op), PLANE_PROP_BLEND_OP);
msm_property_install_enum(&psde->property_info, "src_config", 0x0, 1,
e_src_config, ARRAY_SIZE(e_src_config), PLANE_PROP_SRC_CONFIG);
if (psde->pipe_hw->ops.setup_solidfill)
msm_property_install_range(&psde->property_info, "color_fill",
0, 0, 0xFFFFFFFF, 0, PLANE_PROP_COLOR_FILL);
msm_property_install_range(&psde->property_info,
"prefill_size", 0x0, 0, ~0, 0,
PLANE_PROP_PREFILL_SIZE);
msm_property_install_range(&psde->property_info,
"prefill_time", 0x0, 0, ~0, 0,
PLANE_PROP_PREFILL_TIME);
info = kzalloc(sizeof(struct sde_kms_info), GFP_KERNEL);
if (!info) {
SDE_ERROR("failed to allocate info memory\n");
return;
}
msm_property_install_blob(&psde->property_info, "capabilities",
DRM_MODE_PROP_IMMUTABLE, PLANE_PROP_INFO);
sde_kms_info_reset(info);
if (is_master) {
format_list = psde->pipe_sblk->format_list;
} else {
format_list = psde->pipe_sblk->virt_format_list;
sde_kms_info_add_keyint(info, "primary_smart_plane_id",
master_plane_id);
msm_property_install_enum(&psde->property_info,
"multirect_mode", 0x0, 0, e_multirect_mode,
ARRAY_SIZE(e_multirect_mode),
PLANE_PROP_MULTIRECT_MODE);
}
if (format_list) {
sde_kms_info_start(info, "pixel_formats");
while (format_list->fourcc_format) {
sde_kms_info_append_format(info,
format_list->fourcc_format,
format_list->modifier);
++format_list;
}
sde_kms_info_stop(info);
}
if (psde->pipe_hw && psde->pipe_hw->ops.get_scaler_ver)
sde_kms_info_add_keyint(info, "scaler_step_ver",
psde->pipe_hw->ops.get_scaler_ver(psde->pipe_hw));
sde_kms_info_add_keyint(info, "max_linewidth",
psde->pipe_sblk->maxlinewidth);
sde_kms_info_add_keyint(info, "max_upscale",
psde->pipe_sblk->maxupscale);
sde_kms_info_add_keyint(info, "max_downscale",
psde->pipe_sblk->maxdwnscale);
sde_kms_info_add_keyint(info, "max_horizontal_deci",
psde->pipe_sblk->maxhdeciexp);
sde_kms_info_add_keyint(info, "max_vertical_deci",
psde->pipe_sblk->maxvdeciexp);
sde_kms_info_add_keyint(info, "max_per_pipe_bw",
psde->pipe_sblk->max_per_pipe_bw * 1000LL);
sde_kms_info_add_keyint(info, "max_per_pipe_bw_high",
psde->pipe_sblk->max_per_pipe_bw_high * 1000LL);
index = (master_plane_id == 0) ? 0 : 1;
if (catalog->has_demura &&
catalog->demura_supported[psde->pipe][index] != ~0x0) {
sde_kms_info_add_keyint(info, "demura_block", index);
sde_kms_info_add_keyint(info, "demura_pipe_id",
psde->pipe - SSPP_DMA0);
}
bool is_master = !psde->is_virtual;
if ((is_master &&
(psde->features & BIT(SDE_SSPP_INVERSE_PMA))) ||
@@ -3577,52 +3424,6 @@ static void _sde_plane_install_properties(struct drm_plane *plane,
sde_kms_info_add_keyint(info, "csc_dma_v1", 1);
}
if (psde->features & BIT(SDE_SSPP_SEC_UI_ALLOWED))
sde_kms_info_add_keyint(info, "sec_ui_allowed", 1);
if (psde->features & BIT(SDE_SSPP_BLOCK_SEC_UI))
sde_kms_info_add_keyint(info, "block_sec_ui", 1);
if (psde->features & BIT(SDE_SSPP_TRUE_INLINE_ROT)) {
const struct sde_format_extended *inline_rot_fmt_list;
sde_kms_info_add_keyint(info, "true_inline_rot_rev",
catalog->true_inline_rot_rev);
sde_kms_info_add_keyint(info,
"true_inline_dwnscale_rt",
(int) (psde->pipe_sblk->in_rot_maxdwnscale_rt_num /
psde->pipe_sblk->in_rot_maxdwnscale_rt_denom));
sde_kms_info_add_keyint(info,
"true_inline_dwnscale_rt_numerator",
psde->pipe_sblk->in_rot_maxdwnscale_rt_num);
sde_kms_info_add_keyint(info,
"true_inline_dwnscale_rt_denominator",
psde->pipe_sblk->in_rot_maxdwnscale_rt_denom);
sde_kms_info_add_keyint(info, "true_inline_dwnscale_nrt",
psde->pipe_sblk->in_rot_maxdwnscale_nrt);
sde_kms_info_add_keyint(info, "true_inline_max_height",
psde->pipe_sblk->in_rot_maxheight);
inline_rot_fmt_list = psde->pipe_sblk->in_rot_format_list;
if (inline_rot_fmt_list) {
sde_kms_info_start(info, "inline_rot_pixel_formats");
while (inline_rot_fmt_list->fourcc_format) {
sde_kms_info_append_format(info,
inline_rot_fmt_list->fourcc_format,
inline_rot_fmt_list->modifier);
++inline_rot_fmt_list;
}
sde_kms_info_stop(info);
}
}
msm_property_set_blob(&psde->property_info, &psde->blob_info,
info->data, SDE_KMS_INFO_DATALEN(info),
PLANE_PROP_INFO);
kfree(info);
if (psde->features & BIT(SDE_SSPP_MEMCOLOR)) {
snprintf(feature_name, sizeof(feature_name), "%s%d",
"SDE_SSPP_SKIN_COLOR_V",
@@ -3672,12 +3473,226 @@ static void _sde_plane_install_properties(struct drm_plane *plane,
msm_property_install_blob(&psde->property_info, feature_name, 0,
PLANE_PROP_DMA_GC);
}
}
static void _sde_plane_setup_capabilities_blob(struct sde_plane *psde,
u32 master_plane_id, struct sde_kms_info *info,
struct sde_mdss_cfg *catalog)
{
bool is_master = !psde->is_virtual;
const struct sde_format_extended *format_list;
u32 index;
if (is_master) {
format_list = psde->pipe_sblk->format_list;
} else {
format_list = psde->pipe_sblk->virt_format_list;
sde_kms_info_add_keyint(info, "primary_smart_plane_id",
master_plane_id);
}
if (format_list) {
sde_kms_info_start(info, "pixel_formats");
while (format_list->fourcc_format) {
sde_kms_info_append_format(info,
format_list->fourcc_format,
format_list->modifier);
++format_list;
}
sde_kms_info_stop(info);
}
if (psde->pipe_hw && psde->pipe_hw->ops.get_scaler_ver)
sde_kms_info_add_keyint(info, "scaler_step_ver",
psde->pipe_hw->ops.get_scaler_ver(psde->pipe_hw));
sde_kms_info_add_keyint(info, "max_linewidth",
psde->pipe_sblk->maxlinewidth);
sde_kms_info_add_keyint(info, "max_upscale",
psde->pipe_sblk->maxupscale);
sde_kms_info_add_keyint(info, "max_downscale",
psde->pipe_sblk->maxdwnscale);
sde_kms_info_add_keyint(info, "max_horizontal_deci",
psde->pipe_sblk->maxhdeciexp);
sde_kms_info_add_keyint(info, "max_vertical_deci",
psde->pipe_sblk->maxvdeciexp);
sde_kms_info_add_keyint(info, "max_per_pipe_bw",
psde->pipe_sblk->max_per_pipe_bw * 1000LL);
sde_kms_info_add_keyint(info, "max_per_pipe_bw_high",
psde->pipe_sblk->max_per_pipe_bw_high * 1000LL);
index = (master_plane_id == 0) ? 0 : 1;
if (catalog->has_demura &&
catalog->demura_supported[psde->pipe][index] != ~0x0) {
sde_kms_info_add_keyint(info, "demura_block", index);
sde_kms_info_add_keyint(info, "demura_pipe_id",
psde->pipe - SSPP_DMA0);
}
if (psde->features & BIT(SDE_SSPP_SEC_UI_ALLOWED))
sde_kms_info_add_keyint(info, "sec_ui_allowed", 1);
if (psde->features & BIT(SDE_SSPP_BLOCK_SEC_UI))
sde_kms_info_add_keyint(info, "block_sec_ui", 1);
if (psde->features & BIT(SDE_SSPP_TRUE_INLINE_ROT)) {
const struct sde_format_extended *inline_rot_fmt_list;
sde_kms_info_add_keyint(info, "true_inline_rot_rev",
catalog->true_inline_rot_rev);
sde_kms_info_add_keyint(info,
"true_inline_dwnscale_rt",
(int) (psde->pipe_sblk->in_rot_maxdwnscale_rt_num /
psde->pipe_sblk->in_rot_maxdwnscale_rt_denom));
sde_kms_info_add_keyint(info,
"true_inline_dwnscale_rt_numerator",
psde->pipe_sblk->in_rot_maxdwnscale_rt_num);
sde_kms_info_add_keyint(info,
"true_inline_dwnscale_rt_denominator",
psde->pipe_sblk->in_rot_maxdwnscale_rt_denom);
sde_kms_info_add_keyint(info, "true_inline_dwnscale_nrt",
psde->pipe_sblk->in_rot_maxdwnscale_nrt);
sde_kms_info_add_keyint(info, "true_inline_max_height",
psde->pipe_sblk->in_rot_maxheight);
inline_rot_fmt_list = psde->pipe_sblk->in_rot_format_list;
if (inline_rot_fmt_list) {
sde_kms_info_start(info, "inline_rot_pixel_formats");
while (inline_rot_fmt_list->fourcc_format) {
sde_kms_info_append_format(info,
inline_rot_fmt_list->fourcc_format,
inline_rot_fmt_list->modifier);
++inline_rot_fmt_list;
}
sde_kms_info_stop(info);
}
}
}
/* helper to install properties which are common to planes and crtcs */
static void _sde_plane_install_properties(struct drm_plane *plane,
struct sde_mdss_cfg *catalog, u32 master_plane_id)
{
static const struct drm_prop_enum_list e_blend_op[] = {
{SDE_DRM_BLEND_OP_NOT_DEFINED, "not_defined"},
{SDE_DRM_BLEND_OP_OPAQUE, "opaque"},
{SDE_DRM_BLEND_OP_PREMULTIPLIED, "premultiplied"},
{SDE_DRM_BLEND_OP_COVERAGE, "coverage"},
{SDE_DRM_BLEND_OP_SKIP, "skip_blending"},
};
static const struct drm_prop_enum_list e_src_config[] = {
{SDE_DRM_DEINTERLACE, "deinterlace"}
};
static const struct drm_prop_enum_list e_fb_translation_mode[] = {
{SDE_DRM_FB_NON_SEC, "non_sec"},
{SDE_DRM_FB_SEC, "sec"},
{SDE_DRM_FB_NON_SEC_DIR_TRANS, "non_sec_direct_translation"},
{SDE_DRM_FB_SEC_DIR_TRANS, "sec_direct_translation"},
};
static const struct drm_prop_enum_list e_multirect_mode[] = {
{SDE_SSPP_MULTIRECT_NONE, "none"},
{SDE_SSPP_MULTIRECT_PARALLEL, "parallel"},
{SDE_SSPP_MULTIRECT_TIME_MX, "serial"},
};
struct sde_kms_info *info;
struct sde_plane *psde = to_sde_plane(plane);
bool is_master;
int zpos_max = 255;
int zpos_def = 0;
if (!plane || !psde) {
SDE_ERROR("invalid plane\n");
return;
} else if (!psde->pipe_hw || !psde->pipe_sblk) {
SDE_ERROR("invalid plane, pipe_hw %d pipe_sblk %d\n",
!psde->pipe_hw, !psde->pipe_sblk);
return;
} else if (!catalog) {
SDE_ERROR("invalid catalog\n");
return;
}
psde->catalog = catalog;
is_master = !psde->is_virtual;
info = kzalloc(sizeof(struct sde_kms_info), GFP_KERNEL);
if (!info) {
SDE_ERROR("failed to allocate info memory\n");
return;
}
if (sde_is_custom_client()) {
if (catalog->mixer_count &&
catalog->mixer[0].sblk->maxblendstages) {
zpos_max = catalog->mixer[0].sblk->maxblendstages - 1;
if (catalog->has_base_layer &&
(zpos_max > SDE_STAGE_MAX - 1))
zpos_max = SDE_STAGE_MAX - 1;
else if (zpos_max > SDE_STAGE_MAX - SDE_STAGE_0 - 1)
zpos_max = SDE_STAGE_MAX - SDE_STAGE_0 - 1;
}
} else if (plane->type != DRM_PLANE_TYPE_PRIMARY) {
/* reserve zpos == 0 for primary planes */
zpos_def = drm_plane_index(plane) + 1;
}
msm_property_install_range(&psde->property_info, "zpos",
0x0, 0, zpos_max, zpos_def, PLANE_PROP_ZPOS);
msm_property_install_range(&psde->property_info, "alpha",
0x0, 0, 255, 255, PLANE_PROP_ALPHA);
/* linux default file descriptor range on each process */
msm_property_install_range(&psde->property_info, "input_fence",
0x0, 0, INR_OPEN_MAX, 0, PLANE_PROP_INPUT_FENCE);
if (is_master)
_sde_plane_install_master_only_properties(psde);
else
msm_property_install_enum(&psde->property_info,
"multirect_mode", 0x0, 0, e_multirect_mode,
ARRAY_SIZE(e_multirect_mode),
PLANE_PROP_MULTIRECT_MODE);
if (psde->features & BIT(SDE_SSPP_EXCL_RECT))
msm_property_install_volatile_range(&psde->property_info,
"excl_rect_v1", 0x0, 0, ~0, 0, PLANE_PROP_EXCL_RECT_V1);
sde_plane_rot_install_properties(plane, catalog);
msm_property_install_enum(&psde->property_info, "blend_op", 0x0, 0,
e_blend_op, ARRAY_SIZE(e_blend_op), PLANE_PROP_BLEND_OP);
msm_property_install_enum(&psde->property_info, "src_config", 0x0, 1,
e_src_config, ARRAY_SIZE(e_src_config), PLANE_PROP_SRC_CONFIG);
if (psde->pipe_hw->ops.setup_solidfill)
msm_property_install_range(&psde->property_info, "color_fill",
0, 0, 0xFFFFFFFF, 0, PLANE_PROP_COLOR_FILL);
msm_property_install_range(&psde->property_info, "prefill_size", 0x0,
0, ~0, 0, PLANE_PROP_PREFILL_SIZE);
msm_property_install_range(&psde->property_info, "prefill_time", 0x0,
0, ~0, 0, PLANE_PROP_PREFILL_TIME);
msm_property_install_blob(&psde->property_info, "capabilities",
DRM_MODE_PROP_IMMUTABLE, PLANE_PROP_INFO);
sde_kms_info_reset(info);
_sde_plane_setup_capabilities_blob(psde, master_plane_id, info,
catalog);
_sde_plane_install_colorproc_properties(psde, info);
msm_property_set_blob(&psde->property_info, &psde->blob_info,
info->data, SDE_KMS_INFO_DATALEN(info),
PLANE_PROP_INFO);
msm_property_install_enum(&psde->property_info, "fb_translation_mode",
0x0,
0, e_fb_translation_mode,
0x0, 0, e_fb_translation_mode,
ARRAY_SIZE(e_fb_translation_mode),
PLANE_PROP_FB_TRANSLATION_MODE);
kfree(info);
}
static inline void _sde_plane_set_csc_v1(struct sde_plane *psde,