2024-09-09 08:57:42 +00:00
|
|
|
/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
|
2024-09-09 08:52:07 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 and
|
|
|
|
* only version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define pr_fmt(fmt) "%s: " fmt, __func__
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
#include "mdss.h"
|
2024-09-09 08:52:07 +00:00
|
|
|
#include "mdss_mdp.h"
|
2024-09-09 08:57:42 +00:00
|
|
|
#include "mdss_rotator_internal.h"
|
|
|
|
#include "mdss_panel.h"
|
|
|
|
#include "mdss_mdp_trace.h"
|
|
|
|
#include "mdss_debug.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if BWC enabled and format is H1V2 or 420, do not use site C or I.
|
|
|
|
* Hence, set the bits 29:26 in format register, as zero.
|
|
|
|
*/
|
|
|
|
#define BWC_FMT_MASK 0xC3FFFFFF
|
|
|
|
#define MDSS_DEFAULT_OT_SETTING 0x10
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
enum mdss_mdp_writeback_type {
|
|
|
|
MDSS_MDP_WRITEBACK_TYPE_ROTATOR,
|
|
|
|
MDSS_MDP_WRITEBACK_TYPE_LINE,
|
|
|
|
MDSS_MDP_WRITEBACK_TYPE_WFD,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mdss_mdp_writeback_ctx {
|
|
|
|
u32 wb_num;
|
|
|
|
char __iomem *base;
|
|
|
|
u8 ref_cnt;
|
|
|
|
u8 type;
|
|
|
|
struct completion wb_comp;
|
|
|
|
int comp_cnt;
|
|
|
|
|
|
|
|
u32 intr_type;
|
|
|
|
u32 intf_num;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
u32 xin_id;
|
|
|
|
u32 wr_lim;
|
|
|
|
struct mdss_mdp_shared_reg_ctrl clk_ctrl;
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
u32 opmode;
|
|
|
|
struct mdss_mdp_format_params *dst_fmt;
|
2024-09-09 08:57:42 +00:00
|
|
|
u16 img_width;
|
|
|
|
u16 img_height;
|
2024-09-09 08:52:07 +00:00
|
|
|
u16 width;
|
|
|
|
u16 height;
|
2024-09-09 08:57:42 +00:00
|
|
|
u16 frame_rate;
|
|
|
|
struct mdss_rect dst_rect;
|
|
|
|
|
|
|
|
u32 dnsc_factor_w;
|
|
|
|
u32 dnsc_factor_h;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
u8 rot90;
|
|
|
|
u32 bwc_mode;
|
|
|
|
int initialized;
|
|
|
|
|
|
|
|
struct mdss_mdp_plane_sizes dst_planes;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
spinlock_t wb_lock;
|
|
|
|
struct list_head vsync_handlers;
|
|
|
|
|
|
|
|
ktime_t start_time;
|
|
|
|
ktime_t end_time;
|
2024-09-09 08:52:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct mdss_mdp_writeback_ctx wb_ctx_list[MDSS_MDP_MAX_WRITEBACK] = {
|
|
|
|
{
|
|
|
|
.type = MDSS_MDP_WRITEBACK_TYPE_ROTATOR,
|
|
|
|
.intr_type = MDSS_MDP_IRQ_WB_ROT_COMP,
|
|
|
|
.intf_num = 0,
|
2024-09-09 08:57:42 +00:00
|
|
|
.xin_id = 3,
|
|
|
|
.clk_ctrl.reg_off = 0x2BC,
|
|
|
|
.clk_ctrl.bit_off = 0x8,
|
2024-09-09 08:52:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = MDSS_MDP_WRITEBACK_TYPE_ROTATOR,
|
|
|
|
.intr_type = MDSS_MDP_IRQ_WB_ROT_COMP,
|
|
|
|
.intf_num = 1,
|
2024-09-09 08:57:42 +00:00
|
|
|
.xin_id = 11,
|
|
|
|
.clk_ctrl.reg_off = 0x2BC,
|
|
|
|
.clk_ctrl.bit_off = 0xC,
|
2024-09-09 08:52:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = MDSS_MDP_WRITEBACK_TYPE_LINE,
|
|
|
|
.intr_type = MDSS_MDP_IRQ_WB_ROT_COMP,
|
|
|
|
.intf_num = 0,
|
2024-09-09 08:57:42 +00:00
|
|
|
.xin_id = 3,
|
|
|
|
.clk_ctrl.reg_off = 0x2BC,
|
|
|
|
.clk_ctrl.bit_off = 0x8,
|
2024-09-09 08:52:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = MDSS_MDP_WRITEBACK_TYPE_LINE,
|
|
|
|
.intr_type = MDSS_MDP_IRQ_WB_ROT_COMP,
|
|
|
|
.intf_num = 1,
|
2024-09-09 08:57:42 +00:00
|
|
|
.xin_id = 11,
|
|
|
|
.clk_ctrl.reg_off = 0x2BC,
|
|
|
|
.clk_ctrl.bit_off = 0xC,
|
2024-09-09 08:52:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = MDSS_MDP_WRITEBACK_TYPE_WFD,
|
|
|
|
.intr_type = MDSS_MDP_IRQ_WB_WFD,
|
|
|
|
.intf_num = 0,
|
2024-09-09 08:57:42 +00:00
|
|
|
.xin_id = 6,
|
|
|
|
.clk_ctrl.reg_off = 0x2BC,
|
|
|
|
.clk_ctrl.bit_off = 0x10,
|
2024-09-09 08:52:07 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void mdp_wb_write(struct mdss_mdp_writeback_ctx *ctx,
|
|
|
|
u32 reg, u32 val)
|
|
|
|
{
|
|
|
|
writel_relaxed(val, ctx->base + reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mdss_mdp_writeback_addr_setup(struct mdss_mdp_writeback_ctx *ctx,
|
|
|
|
const struct mdss_mdp_data *in_data)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct mdss_mdp_data data;
|
|
|
|
|
|
|
|
if (!in_data)
|
|
|
|
return -EINVAL;
|
|
|
|
data = *in_data;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
pr_debug("wb_num=%d addr=0x%pa\n", ctx->wb_num, &data.p[0].addr);
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
ret = mdss_mdp_data_check(&data, &ctx->dst_planes, ctx->dst_fmt);
|
2024-09-09 08:52:07 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
mdss_mdp_data_calc_offset(&data, ctx->dst_rect.x, ctx->dst_rect.y,
|
|
|
|
&ctx->dst_planes, ctx->dst_fmt);
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if ((ctx->dst_fmt->fetch_planes == MDSS_MDP_PLANE_PLANAR) &&
|
|
|
|
(ctx->dst_fmt->element[0] == C1_B_Cb))
|
|
|
|
swap(data.p[1].addr, data.p[2].addr);
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST0_ADDR, data.p[0].addr);
|
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST1_ADDR, data.p[1].addr);
|
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST2_ADDR, data.p[2].addr);
|
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST3_ADDR, data.p[3].addr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
static int mdss_mdp_writeback_cdm_setup(struct mdss_mdp_writeback_ctx *ctx,
|
|
|
|
struct mdss_mdp_cdm *cdm, u32 format)
|
|
|
|
{
|
|
|
|
struct mdss_mdp_format_params *fmt;
|
|
|
|
struct mdp_cdm_cfg setup;
|
|
|
|
|
|
|
|
fmt = mdss_mdp_get_format_params(format);
|
|
|
|
if (!fmt) {
|
|
|
|
pr_err("%s: format %d not supported\n", __func__, format);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fmt->is_yuv)
|
|
|
|
setup.csc_type = MDSS_MDP_CSC_RGB2YUV_601L;
|
|
|
|
else
|
|
|
|
setup.csc_type = MDSS_MDP_CSC_RGB2RGB;
|
|
|
|
|
|
|
|
switch (fmt->chroma_sample) {
|
|
|
|
case MDSS_MDP_CHROMA_RGB:
|
|
|
|
setup.horz_downsampling_type = MDP_CDM_CDWN_DISABLE;
|
|
|
|
setup.vert_downsampling_type = MDP_CDM_CDWN_DISABLE;
|
|
|
|
break;
|
|
|
|
case MDSS_MDP_CHROMA_H2V1:
|
|
|
|
setup.horz_downsampling_type = MDP_CDM_CDWN_COSITE;
|
|
|
|
setup.vert_downsampling_type = MDP_CDM_CDWN_DISABLE;
|
|
|
|
break;
|
|
|
|
case MDSS_MDP_CHROMA_420:
|
|
|
|
setup.horz_downsampling_type = MDP_CDM_CDWN_COSITE;
|
|
|
|
setup.vert_downsampling_type = MDP_CDM_CDWN_OFFSITE;
|
|
|
|
break;
|
|
|
|
case MDSS_MDP_CHROMA_H1V2:
|
|
|
|
default:
|
|
|
|
pr_err("%s: unsupported chroma sampling type\n", __func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
setup.out_format = format;
|
|
|
|
setup.mdp_csc_bit_depth = MDP_CDM_CSC_8BIT;
|
|
|
|
setup.output_width = ctx->width;
|
|
|
|
setup.output_height = ctx->height;
|
|
|
|
return mdss_mdp_cdm_setup(cdm, &setup);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mdss_mdp_set_wb_cdp(struct mdss_mdp_writeback_ctx *ctx,
|
|
|
|
struct mdss_mdp_format_params *fmt)
|
|
|
|
{
|
|
|
|
struct mdss_data_type *mdata = mdss_mdp_get_mdata();
|
|
|
|
u32 cdp_settings = 0x0;
|
|
|
|
|
|
|
|
/* Disable CDP for rotator in v1 */
|
|
|
|
if (ctx->type == MDSS_MDP_WRITEBACK_TYPE_ROTATOR &&
|
|
|
|
mdss_has_quirk(mdata, MDSS_QUIRK_ROTCDP))
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
cdp_settings = MDSS_MDP_CDP_ENABLE;
|
|
|
|
|
|
|
|
if (!mdss_mdp_is_linear_format(fmt))
|
|
|
|
cdp_settings |= MDSS_MDP_CDP_ENABLE_UBWCMETA;
|
|
|
|
|
|
|
|
/* 64-transactions for line mode otherwise we keep 32 */
|
|
|
|
if (ctx->type != MDSS_MDP_WRITEBACK_TYPE_ROTATOR)
|
|
|
|
cdp_settings |= MDSS_MDP_CDP_AHEAD_64;
|
|
|
|
|
|
|
|
exit:
|
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_CDP_CTRL, cdp_settings);
|
|
|
|
}
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
static int mdss_mdp_writeback_format_setup(struct mdss_mdp_writeback_ctx *ctx,
|
2024-09-09 08:57:42 +00:00
|
|
|
u32 format, struct mdss_mdp_ctl *ctl)
|
2024-09-09 08:52:07 +00:00
|
|
|
{
|
|
|
|
struct mdss_mdp_format_params *fmt;
|
|
|
|
u32 dst_format, pattern, ystride0, ystride1, outsize, chroma_samp;
|
2024-09-09 08:57:42 +00:00
|
|
|
u32 dnsc_factor, write_config = 0;
|
2024-09-09 08:52:07 +00:00
|
|
|
u32 opmode = ctx->opmode;
|
2024-09-09 08:57:42 +00:00
|
|
|
bool rotation = false;
|
|
|
|
struct mdss_data_type *mdata = mdss_mdp_get_mdata();
|
|
|
|
int rc;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
pr_debug("wb_num=%d format=%d\n", ctx->wb_num, format);
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (ctx->rot90)
|
|
|
|
rotation = true;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
fmt = mdss_mdp_get_format_params(format);
|
|
|
|
if (!fmt) {
|
|
|
|
pr_err("wb format=%d not supported\n", format);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2024-09-09 08:57:42 +00:00
|
|
|
|
|
|
|
mdss_mdp_get_plane_sizes(fmt, ctx->img_width, ctx->img_height,
|
|
|
|
&ctx->dst_planes,
|
|
|
|
ctx->opmode & MDSS_MDP_OP_BWC_EN, rotation);
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
ctx->dst_fmt = fmt;
|
|
|
|
|
|
|
|
chroma_samp = fmt->chroma_sample;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (ctl->cdm) {
|
|
|
|
|
|
|
|
rc = mdss_mdp_writeback_cdm_setup(ctx, ctl->cdm, format);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: CDM configuration failed with error %d\n",
|
|
|
|
__func__, rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
ctl->flush_bits |= BIT(26);
|
|
|
|
}
|
|
|
|
if (ctx->type != MDSS_MDP_WRITEBACK_TYPE_ROTATOR &&
|
|
|
|
fmt->is_yuv && !ctl->cdm) {
|
|
|
|
mdss_mdp_csc_setup(MDSS_MDP_BLOCK_WB, ctx->wb_num,
|
|
|
|
MDSS_MDP_CSC_RGB2YUV_601L);
|
2024-09-09 08:52:07 +00:00
|
|
|
opmode |= (1 << 8) | /* CSC_EN */
|
|
|
|
(0 << 9) | /* SRC_DATA=RGB */
|
|
|
|
(1 << 10); /* DST_DATA=YCBCR */
|
|
|
|
|
|
|
|
switch (chroma_samp) {
|
|
|
|
case MDSS_MDP_CHROMA_RGB:
|
|
|
|
case MDSS_MDP_CHROMA_420:
|
|
|
|
case MDSS_MDP_CHROMA_H2V1:
|
|
|
|
opmode |= (chroma_samp << 11);
|
|
|
|
break;
|
|
|
|
case MDSS_MDP_CHROMA_H1V2:
|
|
|
|
default:
|
|
|
|
pr_err("unsupported wb chroma samp=%d\n", chroma_samp);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dst_format = (chroma_samp << 23) |
|
|
|
|
(fmt->fetch_planes << 19) |
|
|
|
|
(fmt->bits[C3_ALPHA] << 6) |
|
|
|
|
(fmt->bits[C2_R_Cr] << 4) |
|
|
|
|
(fmt->bits[C1_B_Cb] << 2) |
|
|
|
|
(fmt->bits[C0_G_Y] << 0);
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
dst_format &= BWC_FMT_MASK;
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
if (fmt->bits[C3_ALPHA] || fmt->alpha_enable) {
|
|
|
|
dst_format |= BIT(8); /* DSTC3_EN */
|
|
|
|
if (!fmt->alpha_enable)
|
|
|
|
dst_format |= BIT(14); /* DST_ALPHA_X */
|
|
|
|
}
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (fmt->is_yuv && test_bit(MDSS_CAPS_YUV_CONFIG, mdata->mdss_caps_map))
|
|
|
|
dst_format |= BIT(15);
|
|
|
|
|
|
|
|
if (mdata->mdp_rev >= MDSS_MDP_HW_REV_102 &&
|
|
|
|
mdata->mdp_rev < MDSS_MDP_HW_REV_200) {
|
2024-09-09 08:52:07 +00:00
|
|
|
pattern = (fmt->element[3] << 24) |
|
|
|
|
(fmt->element[2] << 16) |
|
|
|
|
(fmt->element[1] << 8) |
|
|
|
|
(fmt->element[0] << 0);
|
|
|
|
} else {
|
|
|
|
pattern = (fmt->element[3] << 24) |
|
|
|
|
(fmt->element[2] << 15) |
|
|
|
|
(fmt->element[1] << 8) |
|
|
|
|
(fmt->element[0] << 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
dst_format |= (fmt->unpack_align_msb << 18) |
|
|
|
|
(fmt->unpack_tight << 17) |
|
|
|
|
((fmt->unpack_count - 1) << 12) |
|
|
|
|
((fmt->bpp - 1) << 9);
|
|
|
|
|
|
|
|
ystride0 = (ctx->dst_planes.ystride[0]) |
|
|
|
|
(ctx->dst_planes.ystride[1] << 16);
|
|
|
|
ystride1 = (ctx->dst_planes.ystride[2]) |
|
|
|
|
(ctx->dst_planes.ystride[3] << 16);
|
|
|
|
outsize = (ctx->dst_rect.h << 16) | ctx->dst_rect.w;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (mdss_mdp_is_ubwc_format(fmt)) {
|
|
|
|
if (!ctl->cdm)
|
|
|
|
opmode |= BIT(0);
|
|
|
|
dst_format |= BIT(31);
|
|
|
|
if (mdata->highest_bank_bit)
|
|
|
|
write_config |= (mdata->highest_bank_bit << 8);
|
|
|
|
if (fmt->format == MDP_RGB_565_UBWC)
|
|
|
|
write_config |= 0x8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->type == MDSS_MDP_WRITEBACK_TYPE_ROTATOR
|
|
|
|
&& mdata->has_rot_dwnscale) {
|
|
|
|
dnsc_factor = (ctx->dnsc_factor_h) | (ctx->dnsc_factor_w << 16);
|
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_ROTATOR_PIPE_DOWNSCALER,
|
|
|
|
dnsc_factor);
|
|
|
|
}
|
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_ALPHA_X_VALUE, 0xFF);
|
2024-09-09 08:52:07 +00:00
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST_FORMAT, dst_format);
|
2024-09-09 08:57:42 +00:00
|
|
|
if (!ctl->cdm)
|
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST_OP_MODE, opmode);
|
2024-09-09 08:52:07 +00:00
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST_PACK_PATTERN, pattern);
|
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST_YSTRIDE0, ystride0);
|
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST_YSTRIDE1, ystride1);
|
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_OUT_SIZE, outsize);
|
2024-09-09 08:57:42 +00:00
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST_WRITE_CONFIG, write_config);
|
|
|
|
|
|
|
|
/* configure CDP */
|
|
|
|
if (test_bit(MDSS_QOS_CDP, mdata->mdss_qos_map))
|
|
|
|
mdss_mdp_set_wb_cdp(ctx, fmt);
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mdss_mdp_writeback_prepare_wfd(struct mdss_mdp_ctl *ctl, void *arg)
|
|
|
|
{
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ctx = (struct mdss_mdp_writeback_ctx *) ctl->priv_data;
|
|
|
|
if (!ctx)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (ctx->initialized && !ctl->shared_lock) /* already set */
|
2024-09-09 08:52:07 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
pr_debug("wfd setup ctl=%d\n", ctl->num);
|
|
|
|
|
|
|
|
ctx->opmode = 0;
|
2024-09-09 08:57:42 +00:00
|
|
|
ctx->img_width = ctl->width;
|
|
|
|
ctx->img_height = ctl->height;
|
2024-09-09 08:52:07 +00:00
|
|
|
ctx->width = ctl->width;
|
|
|
|
ctx->height = ctl->height;
|
2024-09-09 08:57:42 +00:00
|
|
|
ctx->frame_rate = ctl->frame_rate;
|
2024-09-09 08:52:07 +00:00
|
|
|
ctx->dst_rect.x = 0;
|
|
|
|
ctx->dst_rect.y = 0;
|
|
|
|
ctx->dst_rect.w = ctx->width;
|
|
|
|
ctx->dst_rect.h = ctx->height;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
ret = mdss_mdp_writeback_format_setup(ctx, ctl->dst_format, ctl);
|
2024-09-09 08:52:07 +00:00
|
|
|
if (ret) {
|
|
|
|
pr_err("format setup failed\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->initialized = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mdss_mdp_writeback_prepare_rot(struct mdss_mdp_ctl *ctl, void *arg)
|
|
|
|
{
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx;
|
|
|
|
struct mdss_mdp_writeback_arg *wb_args;
|
2024-09-09 08:57:42 +00:00
|
|
|
struct mdss_rot_entry *entry;
|
|
|
|
struct mdp_rotation_item *item;
|
|
|
|
struct mdss_data_type *mdata;
|
2024-09-09 08:52:07 +00:00
|
|
|
u32 format;
|
|
|
|
|
|
|
|
ctx = (struct mdss_mdp_writeback_ctx *) ctl->priv_data;
|
|
|
|
if (!ctx)
|
|
|
|
return -ENODEV;
|
|
|
|
wb_args = (struct mdss_mdp_writeback_arg *) arg;
|
|
|
|
if (!wb_args)
|
|
|
|
return -ENOENT;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
entry = (struct mdss_rot_entry *) wb_args->priv_data;
|
|
|
|
if (!entry) {
|
2024-09-09 08:52:07 +00:00
|
|
|
pr_err("unable to retrieve rot session ctl=%d\n", ctl->num);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2024-09-09 08:57:42 +00:00
|
|
|
item = &entry->item;
|
|
|
|
mdata = ctl->mdata;
|
|
|
|
if (!mdata) {
|
|
|
|
pr_err("no mdata attached to ctl=%d", ctl->num);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2024-09-09 08:52:07 +00:00
|
|
|
pr_debug("rot setup wb_num=%d\n", ctx->wb_num);
|
|
|
|
|
|
|
|
ctx->opmode = BIT(6); /* ROT EN */
|
|
|
|
if (ctl->mdata->rot_block_size == 128)
|
|
|
|
ctx->opmode |= BIT(4); /* block size 128 */
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
ctx->bwc_mode = 0;
|
2024-09-09 08:52:07 +00:00
|
|
|
ctx->opmode |= ctx->bwc_mode;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
ctx->img_width = item->output.width;
|
|
|
|
ctx->img_height = item->output.height;
|
|
|
|
ctx->width = ctx->dst_rect.w = item->dst_rect.w;
|
|
|
|
ctx->height = ctx->dst_rect.h = item->dst_rect.h;
|
|
|
|
ctx->dst_rect.x = item->dst_rect.x;
|
|
|
|
ctx->dst_rect.y = item->dst_rect.y;
|
|
|
|
ctx->dnsc_factor_w = entry->dnsc_factor_w;
|
|
|
|
ctx->dnsc_factor_h = entry->dnsc_factor_h;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
ctx->rot90 = !!(item->flags & MDP_ROTATION_90);
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
format = item->output.format;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (ctx->rot90)
|
2024-09-09 08:52:07 +00:00
|
|
|
ctx->opmode |= BIT(5); /* ROT 90 */
|
2024-09-09 08:57:42 +00:00
|
|
|
|
|
|
|
return mdss_mdp_writeback_format_setup(ctx, format, ctl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mdss_mdp_wb_add_vsync_handler(struct mdss_mdp_ctl *ctl,
|
|
|
|
struct mdss_mdp_vsync_handler *handle)
|
|
|
|
{
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx;
|
|
|
|
unsigned long flags;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (!handle || !(handle->vsync_handler)) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx = (struct mdss_mdp_writeback_ctx *) ctl->priv_data;
|
|
|
|
if (!ctx) {
|
|
|
|
pr_err("invalid ctx for ctl=%d\n", ctl->num);
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ctx->wb_lock, flags);
|
|
|
|
if (!handle->enabled) {
|
|
|
|
handle->enabled = true;
|
|
|
|
list_add(&handle->list, &ctx->vsync_handlers);
|
2024-09-09 08:52:07 +00:00
|
|
|
}
|
2024-09-09 08:57:42 +00:00
|
|
|
spin_unlock_irqrestore(&ctx->wb_lock, flags);
|
|
|
|
exit:
|
|
|
|
return ret;
|
|
|
|
}
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
static int mdss_mdp_wb_remove_vsync_handler(struct mdss_mdp_ctl *ctl,
|
|
|
|
struct mdss_mdp_vsync_handler *handle)
|
|
|
|
{
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx;
|
|
|
|
unsigned long flags;
|
|
|
|
int ret = 0;
|
|
|
|
if (!handle || !(handle->vsync_handler)) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
ctx = (struct mdss_mdp_writeback_ctx *) ctl->priv_data;
|
|
|
|
if (!ctx) {
|
|
|
|
pr_err("invalid ctx for ctl=%d\n", ctl->num);
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
spin_lock_irqsave(&ctx->wb_lock, flags);
|
|
|
|
if (handle->enabled) {
|
|
|
|
handle->enabled = false;
|
|
|
|
list_del_init(&handle->list);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ctx->wb_lock, flags);
|
|
|
|
exit:
|
|
|
|
return ret;
|
2024-09-09 08:52:07 +00:00
|
|
|
}
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
static int mdss_mdp_writeback_stop(struct mdss_mdp_ctl *ctl,
|
|
|
|
int panel_power_state)
|
2024-09-09 08:52:07 +00:00
|
|
|
{
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx;
|
2024-09-09 08:57:42 +00:00
|
|
|
struct mdss_mdp_vsync_handler *t, *handle;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
pr_debug("stop ctl=%d\n", ctl->num);
|
|
|
|
|
|
|
|
ctx = (struct mdss_mdp_writeback_ctx *) ctl->priv_data;
|
|
|
|
if (ctx) {
|
2024-09-09 08:57:42 +00:00
|
|
|
list_for_each_entry_safe(handle, t, &ctx->vsync_handlers, list)
|
|
|
|
mdss_mdp_wb_remove_vsync_handler(ctl, handle);
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
mdss_mdp_set_intr_callback(ctx->intr_type, ctx->intf_num,
|
2024-09-09 08:57:42 +00:00
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
complete_all(&ctx->wb_comp);
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
ctl->priv_data = NULL;
|
|
|
|
ctx->ref_cnt--;
|
|
|
|
}
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (ctl->cdm) {
|
|
|
|
mdss_mdp_cdm_destroy(ctl->cdm);
|
|
|
|
ctl->cdm = NULL;
|
|
|
|
}
|
2024-09-09 08:52:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mdss_mdp_writeback_intr_done(void *arg)
|
|
|
|
{
|
2024-09-09 08:57:42 +00:00
|
|
|
struct mdss_mdp_ctl *ctl = arg;
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx = ctl->priv_data;
|
|
|
|
struct mdss_mdp_vsync_handler *tmp;
|
|
|
|
ktime_t vsync_time;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
if (!ctx) {
|
|
|
|
pr_err("invalid ctx\n");
|
|
|
|
return;
|
|
|
|
}
|
2024-09-09 08:57:42 +00:00
|
|
|
vsync_time = ktime_get();
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
pr_debug("intr wb_num=%d\n", ctx->wb_num);
|
|
|
|
|
|
|
|
mdss_mdp_irq_disable_nosync(ctx->intr_type, ctx->intf_num);
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
spin_lock(&ctx->wb_lock);
|
|
|
|
list_for_each_entry(tmp, &ctx->vsync_handlers, list) {
|
|
|
|
tmp->vsync_handler(ctl, vsync_time);
|
|
|
|
}
|
|
|
|
spin_unlock(&ctx->wb_lock);
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
complete_all(&ctx->wb_comp);
|
2024-09-09 08:57:42 +00:00
|
|
|
MDSS_XLOG(ctx->wb_num, ctx->type, ctx->xin_id, ctx->intf_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool mdss_mdp_traffic_shaper_helper(struct mdss_mdp_ctl *ctl,
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
struct mdss_data_type *mdata = mdss_mdp_get_mdata();
|
|
|
|
bool traffic_shaper_enabled = false;
|
|
|
|
struct mdss_mdp_mixer *mixer = ctl->mixer_left;
|
|
|
|
int i;
|
|
|
|
u32 clk_rate;
|
|
|
|
u64 bw_rate;
|
|
|
|
|
|
|
|
if (!mixer)
|
|
|
|
return traffic_shaper_enabled;
|
|
|
|
|
|
|
|
/* currently only for rotator pipes */
|
|
|
|
if (!mixer->rotator_mode)
|
|
|
|
return traffic_shaper_enabled;
|
|
|
|
|
|
|
|
for (i = 0; i < MDSS_MDP_MAX_STAGE; i++) {
|
|
|
|
struct mdss_mdp_pipe *pipe;
|
|
|
|
struct mdss_mdp_perf_params perf;
|
|
|
|
u32 traffic_shaper;
|
|
|
|
pipe = mixer->stage_pipe[i];
|
|
|
|
|
|
|
|
memset(&perf, 0, sizeof(perf));
|
|
|
|
|
|
|
|
if (pipe == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (enable) {
|
|
|
|
if (mdss_mdp_perf_calc_pipe(pipe, &perf, &mixer->roi,
|
|
|
|
PERF_CALC_PIPE_SINGLE_LAYER))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
clk_rate = max(mdss_mdp_get_mdp_clk_rate(ctl->mdata),
|
|
|
|
perf.mdp_clk_rate);
|
|
|
|
ctl->traffic_shaper_mdp_clk = clk_rate;
|
|
|
|
bw_rate = perf.bw_overlap;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bandwidth vote accounts for both read and write
|
|
|
|
* rotator, divide by 2 to get only the write bandwidth.
|
|
|
|
*/
|
|
|
|
do_div(bw_rate, 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculating bytes per clock in 4.4 form
|
|
|
|
* allowing up to 1/16 granularity.
|
|
|
|
*/
|
|
|
|
do_div(bw_rate,
|
|
|
|
(clk_rate >>
|
|
|
|
MDSS_MDP_REG_TRAFFIC_SHAPER_FIXPOINT_FACTOR));
|
|
|
|
|
|
|
|
traffic_shaper = lower_32_bits(bw_rate) + 1;
|
|
|
|
traffic_shaper |= MDSS_MDP_REG_TRAFFIC_SHAPER_EN;
|
|
|
|
traffic_shaper_enabled = true;
|
|
|
|
|
|
|
|
pr_debug("pnum=%d inum:%d bw=%lld clk_rate=%u shaper=0x%x ena:%d\n",
|
|
|
|
pipe->num, ctx->intf_num, perf.bw_overlap,
|
|
|
|
clk_rate, traffic_shaper, enable);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
traffic_shaper = 0;
|
|
|
|
|
|
|
|
pr_debug("inum:%d shaper=0x%x, ena:%d\n",
|
|
|
|
ctx->intf_num, traffic_shaper, enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
writel_relaxed(traffic_shaper, mdata->mdp_base +
|
|
|
|
MDSS_MDP_REG_TRAFFIC_SHAPER_WR_CLIENT(ctx->intf_num));
|
|
|
|
}
|
|
|
|
|
|
|
|
return traffic_shaper_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mdss_mdp_traffic_shaper(struct mdss_mdp_ctl *ctl,
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx, bool enable)
|
|
|
|
{
|
|
|
|
bool traffic_shaper_enabled = 0;
|
|
|
|
|
|
|
|
if (mdss_mdp_ctl_is_power_on(ctl)) {
|
|
|
|
traffic_shaper_enabled = mdss_mdp_traffic_shaper_helper
|
|
|
|
(ctl, ctx, enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
ctl->traffic_shaper_enabled = traffic_shaper_enabled;
|
|
|
|
|
|
|
|
pr_debug("traffic shapper ctl:%d ena:%d\n", ctl->num,
|
|
|
|
ctl->traffic_shaper_enabled);
|
2024-09-09 08:52:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mdss_mdp_wb_wait4comp(struct mdss_mdp_ctl *ctl, void *arg)
|
|
|
|
{
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx;
|
|
|
|
int rc = 0;
|
2024-09-09 08:57:42 +00:00
|
|
|
u64 rot_time;
|
|
|
|
u32 status, mask, isr;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
ctx = (struct mdss_mdp_writeback_ctx *) ctl->priv_data;
|
|
|
|
if (!ctx) {
|
|
|
|
pr_err("invalid ctx\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->comp_cnt == 0)
|
|
|
|
return rc;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
rc = wait_for_completion_timeout(&ctx->wb_comp,
|
2024-09-09 08:52:07 +00:00
|
|
|
KOFF_TIMEOUT);
|
2024-09-09 08:57:42 +00:00
|
|
|
mdss_mdp_set_intr_callback(ctx->intr_type, ctx->intf_num,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
if (rc == 0) {
|
|
|
|
mask = BIT(ctx->intr_type + ctx->intf_num);
|
|
|
|
|
|
|
|
isr = readl_relaxed(ctl->mdata->mdp_base +
|
|
|
|
MDSS_MDP_REG_INTR_STATUS);
|
|
|
|
status = mask & isr;
|
|
|
|
|
|
|
|
pr_info_once("mask: 0x%x, isr: 0x%x, status: 0x%x\n",
|
|
|
|
mask, isr, status);
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
pr_warn_once("wb done but irq not triggered\n");
|
|
|
|
mdss_mdp_irq_clear(ctl->mdata,
|
|
|
|
ctx->intr_type,
|
|
|
|
ctx->intf_num);
|
|
|
|
|
|
|
|
mdss_mdp_writeback_intr_done(ctl);
|
|
|
|
rc = 0;
|
|
|
|
} else {
|
|
|
|
mdss_mdp_ctl_notify(ctl, MDP_NOTIFY_FRAME_TIMEOUT);
|
|
|
|
rc = -ENODEV;
|
|
|
|
WARN(1, "writeback kickoff timed out (%d) ctl=%d\n",
|
|
|
|
rc, ctl->num);
|
|
|
|
}
|
2024-09-09 08:52:07 +00:00
|
|
|
} else {
|
|
|
|
rc = 0;
|
|
|
|
}
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (rc == 0) {
|
|
|
|
ctx->end_time = ktime_get();
|
|
|
|
mdss_mdp_ctl_notify(ctl, MDP_NOTIFY_FRAME_DONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* once operation is done, disable traffic shaper */
|
|
|
|
if (ctl->traffic_shaper_enabled)
|
|
|
|
mdss_mdp_traffic_shaper(ctl, ctx, false);
|
|
|
|
|
|
|
|
mdss_iommu_ctrl(0);
|
|
|
|
mdss_bus_bandwidth_ctrl(false);
|
|
|
|
mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF);
|
|
|
|
|
|
|
|
/* Set flag to release Controller Bandwidth */
|
|
|
|
ctl->perf_release_ctl_bw = true;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
ctx->comp_cnt--;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (!rc) {
|
|
|
|
rot_time = (u64)ktime_to_us(ctx->end_time) -
|
|
|
|
(u64)ktime_to_us(ctx->start_time);
|
|
|
|
pr_debug("ctx%d type:%d xin_id:%d intf_num:%d took %llu microsecs\n",
|
|
|
|
ctx->wb_num, ctx->type, ctx->xin_id,
|
|
|
|
ctx->intf_num, rot_time);
|
|
|
|
}
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
static void mdss_mdp_set_ot_limit_wb(struct mdss_mdp_writeback_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct mdss_mdp_set_ot_params ot_params;
|
|
|
|
struct mdss_data_type *mdata = mdss_mdp_get_mdata();
|
|
|
|
|
|
|
|
ot_params.xin_id = ctx->xin_id;
|
|
|
|
ot_params.num = ctx->wb_num;
|
|
|
|
ot_params.width = ctx->width;
|
|
|
|
ot_params.height = ctx->height;
|
|
|
|
ot_params.frame_rate = ctx->frame_rate;
|
|
|
|
ot_params.reg_off_vbif_lim_conf = MMSS_VBIF_WR_LIM_CONF;
|
|
|
|
ot_params.reg_off_mdp_clk_ctrl = ctx->clk_ctrl.reg_off;
|
|
|
|
ot_params.bit_off_mdp_clk_ctrl = ctx->clk_ctrl.bit_off;
|
|
|
|
ot_params.is_rot = (ctx->type == MDSS_MDP_WRITEBACK_TYPE_ROTATOR);
|
|
|
|
ot_params.is_wb = true;
|
|
|
|
ot_params.is_yuv = ctx->dst_fmt->is_yuv;
|
|
|
|
ot_params.is_vbif_nrt = mdss_mdp_is_nrt_vbif_base_defined(mdata);
|
|
|
|
|
|
|
|
mdss_mdp_set_ot_limit(&ot_params);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
static int mdss_mdp_writeback_display(struct mdss_mdp_ctl *ctl, void *arg)
|
|
|
|
{
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx;
|
|
|
|
struct mdss_mdp_writeback_arg *wb_args;
|
2024-09-09 08:57:42 +00:00
|
|
|
u32 flush_bits = 0;
|
2024-09-09 08:52:07 +00:00
|
|
|
int ret;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (!ctl || !ctl->mdata)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
ctx = (struct mdss_mdp_writeback_ctx *) ctl->priv_data;
|
|
|
|
if (!ctx)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (ctx->comp_cnt) {
|
|
|
|
pr_err("previous kickoff not completed yet, ctl=%d\n",
|
|
|
|
ctl->num);
|
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (ctl->mdata->default_ot_wr_limit ||
|
|
|
|
ctl->mdata->default_ot_rd_limit)
|
|
|
|
mdss_mdp_set_ot_limit_wb(ctx);
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
wb_args = (struct mdss_mdp_writeback_arg *) arg;
|
|
|
|
if (!wb_args)
|
|
|
|
return -ENOENT;
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (ctx->type == MDSS_MDP_WRITEBACK_TYPE_ROTATOR
|
|
|
|
&& ctl->mdata->traffic_shaper_en)
|
|
|
|
mdss_mdp_traffic_shaper(ctl, ctx, true);
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
ret = mdss_mdp_writeback_addr_setup(ctx, wb_args->data);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("writeback data setup error ctl=%d\n", ctl->num);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
mdss_mdp_set_intr_callback(ctx->intr_type, ctx->intf_num,
|
|
|
|
mdss_mdp_writeback_intr_done, ctl);
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
flush_bits |= ctl->flush_reg_data;
|
|
|
|
flush_bits |= BIT(16); /* WB */
|
2024-09-09 08:52:07 +00:00
|
|
|
mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST_ADDR_SW_STATUS, ctl->is_secure);
|
|
|
|
mdss_mdp_ctl_write(ctl, MDSS_MDP_REG_CTL_FLUSH, flush_bits);
|
2024-09-09 08:57:42 +00:00
|
|
|
MDSS_XLOG(ctl->intf_num, flush_bits);
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
reinit_completion(&ctx->wb_comp);
|
2024-09-09 08:52:07 +00:00
|
|
|
mdss_mdp_irq_enable(ctx->intr_type, ctx->intf_num);
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
ret = mdss_iommu_ctrl(1);
|
|
|
|
if (IS_ERR_VALUE(ret)) {
|
|
|
|
pr_err("IOMMU attach failed\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON);
|
|
|
|
mdss_bus_bandwidth_ctrl(true);
|
|
|
|
ctx->start_time = ktime_get();
|
2024-09-09 08:52:07 +00:00
|
|
|
mdss_mdp_ctl_write(ctl, MDSS_MDP_REG_CTL_START, 1);
|
|
|
|
wmb();
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
MDSS_XLOG(ctx->wb_num, ctx->type, ctx->xin_id, ctx->intf_num,
|
|
|
|
ctx->dst_rect.w, ctx->dst_rect.h);
|
|
|
|
pr_debug("ctx%d type:%d xin_id:%d intf_num:%d start\n",
|
|
|
|
ctx->wb_num, ctx->type, ctx->xin_id, ctx->intf_num);
|
|
|
|
|
2024-09-09 08:52:07 +00:00
|
|
|
ctx->comp_cnt++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mdss_mdp_writeback_start(struct mdss_mdp_ctl *ctl)
|
|
|
|
{
|
|
|
|
struct mdss_mdp_writeback_ctx *ctx;
|
2024-09-09 08:57:42 +00:00
|
|
|
struct mdss_mdp_writeback *wb;
|
2024-09-09 08:52:07 +00:00
|
|
|
u32 mem_sel;
|
2024-09-09 08:57:42 +00:00
|
|
|
u32 mixer_type = MDSS_MDP_MIXER_TYPE_UNUSED;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
pr_debug("start ctl=%d\n", ctl->num);
|
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
if (!ctl->wb) {
|
|
|
|
pr_debug("wb not setup in the ctl\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
wb = ctl->wb;
|
2024-09-09 08:52:07 +00:00
|
|
|
mem_sel = (ctl->opmode & 0xF) - 1;
|
|
|
|
if (mem_sel < MDSS_MDP_MAX_WRITEBACK) {
|
|
|
|
ctx = &wb_ctx_list[mem_sel];
|
|
|
|
if (ctx->ref_cnt) {
|
|
|
|
pr_err("writeback in use %d\n", mem_sel);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
ctx->ref_cnt++;
|
|
|
|
} else {
|
|
|
|
pr_err("invalid writeback mode %d\n", mem_sel);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2024-09-09 08:57:42 +00:00
|
|
|
|
|
|
|
if (ctl->mixer_left)
|
|
|
|
mixer_type = ctl->mixer_left->type;
|
|
|
|
|
|
|
|
if (mdss_mdp_is_cdm_supported(ctl->mdata, ctl->intf_type,
|
|
|
|
mixer_type)) {
|
|
|
|
ctl->cdm = mdss_mdp_cdm_init(ctl, MDP_CDM_CDWN_OUTPUT_WB);
|
|
|
|
if (IS_ERR_OR_NULL(ctl->cdm)) {
|
|
|
|
pr_err("%s failed to init cdm\n", __func__);
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ctl->cdm = NULL;
|
|
|
|
pr_debug("%s: cdm not supported\n", __func__);
|
|
|
|
}
|
2024-09-09 08:52:07 +00:00
|
|
|
ctl->priv_data = ctx;
|
2024-09-09 08:57:42 +00:00
|
|
|
ctx->wb_num = wb->num;
|
|
|
|
ctx->base = wb->base;
|
2024-09-09 08:52:07 +00:00
|
|
|
ctx->initialized = false;
|
|
|
|
init_completion(&ctx->wb_comp);
|
2024-09-09 08:57:42 +00:00
|
|
|
spin_lock_init(&ctx->wb_lock);
|
|
|
|
INIT_LIST_HEAD(&ctx->vsync_handlers);
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
if (ctx->type == MDSS_MDP_WRITEBACK_TYPE_ROTATOR)
|
2024-09-09 08:57:42 +00:00
|
|
|
ctl->ops.prepare_fnc = mdss_mdp_writeback_prepare_rot;
|
|
|
|
else { /* wfd or line mode */
|
|
|
|
ctl->ops.prepare_fnc = mdss_mdp_writeback_prepare_wfd;
|
|
|
|
|
|
|
|
/* WB2 Intr Enable is BIT(2) in MDSS 1.8.0 */
|
|
|
|
if (ctl->mdata->mdp_rev == MDSS_MDP_HW_REV_108) {
|
|
|
|
ctx->intr_type = MDSS_MDP_IRQ_WB_ROT_COMP;
|
|
|
|
ctx->intf_num = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctl->ops.stop_fnc = mdss_mdp_writeback_stop;
|
|
|
|
ctl->ops.display_fnc = mdss_mdp_writeback_display;
|
|
|
|
ctl->ops.wait_fnc = mdss_mdp_wb_wait4comp;
|
|
|
|
ctl->ops.add_vsync_handler = mdss_mdp_wb_add_vsync_handler;
|
|
|
|
ctl->ops.remove_vsync_handler = mdss_mdp_wb_remove_vsync_handler;
|
2024-09-09 08:52:07 +00:00
|
|
|
|
2024-09-09 08:57:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mdss_mdp_writeback_display_commit(struct mdss_mdp_ctl *ctl, void *arg)
|
|
|
|
{
|
|
|
|
if (ctl->shared_lock && !mutex_is_locked(ctl->shared_lock)) {
|
|
|
|
pr_err("shared mutex is not locked before commit on ctl=%d\n",
|
|
|
|
ctl->num);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctl->mdata->mixer_switched) {
|
|
|
|
if (ctl->mixer_left)
|
|
|
|
ctl->mixer_left->params_changed++;
|
|
|
|
if (ctl->mixer_right)
|
|
|
|
ctl->mixer_right->params_changed++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mdss_mdp_display_commit(ctl, arg, NULL);
|
2024-09-09 08:52:07 +00:00
|
|
|
}
|