2019-05-29 14:17:58 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2014-11-18 17:49:49 +00:00
|
|
|
/*
|
2015-03-13 19:49:33 +00:00
|
|
|
* Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
|
2014-11-18 17:49:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mdp5_kms.h"
|
|
|
|
#include "mdp5_ctl.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CTL - MDP Control Pool Manager
|
|
|
|
*
|
2015-06-26 20:03:26 +00:00
|
|
|
* Controls are shared between all display interfaces.
|
2014-11-18 17:49:49 +00:00
|
|
|
*
|
|
|
|
* They are intended to be used for data path configuration.
|
|
|
|
* The top level register programming describes the complete data path for
|
|
|
|
* a specific data path ID - REG_MDP5_CTL_*(<id>, ...)
|
|
|
|
*
|
|
|
|
* Hardware capabilities determine the number of concurrent data paths
|
|
|
|
*
|
|
|
|
* In certain use cases (high-resolution dual pipe), one single CTL can be
|
|
|
|
* shared across multiple CRTCs.
|
|
|
|
*/
|
|
|
|
|
2015-06-26 20:03:26 +00:00
|
|
|
#define CTL_STAT_BUSY 0x1
|
|
|
|
#define CTL_STAT_BOOKED 0x2
|
|
|
|
|
2014-11-18 17:49:49 +00:00
|
|
|
struct mdp5_ctl {
|
2014-11-18 22:22:51 +00:00
|
|
|
struct mdp5_ctl_manager *ctlm;
|
|
|
|
|
2014-11-18 17:49:49 +00:00
|
|
|
u32 id;
|
|
|
|
|
2015-06-26 20:03:26 +00:00
|
|
|
/* CTL status bitmask */
|
|
|
|
u32 status;
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2017-03-23 10:28:00 +00:00
|
|
|
bool encoder_enabled;
|
2018-02-19 13:17:06 +00:00
|
|
|
|
|
|
|
/* pending flush_mask bits */
|
|
|
|
u32 flush_mask;
|
2014-11-18 17:49:49 +00:00
|
|
|
|
|
|
|
/* REG_MDP5_CTL_*(<id>) registers access info + lock: */
|
|
|
|
spinlock_t hw_lock;
|
|
|
|
u32 reg_offset;
|
|
|
|
|
2015-03-13 19:49:33 +00:00
|
|
|
/* when do CTL registers need to be flushed? (mask of trigger bits) */
|
|
|
|
u32 pending_ctl_trigger;
|
2014-11-18 17:49:49 +00:00
|
|
|
|
|
|
|
bool cursor_on;
|
2015-06-26 20:03:26 +00:00
|
|
|
|
|
|
|
/* True if the current CTL has FLUSH bits pending for single FLUSH. */
|
|
|
|
bool flush_pending;
|
|
|
|
|
|
|
|
struct mdp5_ctl *pair; /* Paired CTL to be flushed together */
|
2014-11-18 17:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mdp5_ctl_manager {
|
|
|
|
struct drm_device *dev;
|
|
|
|
|
|
|
|
/* number of CTL / Layer Mixers in this hw config: */
|
|
|
|
u32 nlm;
|
|
|
|
u32 nctl;
|
|
|
|
|
2015-03-13 19:49:33 +00:00
|
|
|
/* to filter out non-present bits in the current hardware config */
|
|
|
|
u32 flush_hw_mask;
|
|
|
|
|
2015-06-26 20:03:26 +00:00
|
|
|
/* status for single FLUSH */
|
|
|
|
bool single_flush_supported;
|
|
|
|
u32 single_flush_pending_mask;
|
|
|
|
|
2014-11-18 17:49:49 +00:00
|
|
|
/* pool of CTLs + lock to protect resource allocation (ctls[i].busy) */
|
|
|
|
spinlock_t pool_lock;
|
|
|
|
struct mdp5_ctl ctls[MAX_CTL];
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline
|
|
|
|
struct mdp5_kms *get_kms(struct mdp5_ctl_manager *ctl_mgr)
|
|
|
|
{
|
|
|
|
struct msm_drm_private *priv = ctl_mgr->dev->dev_private;
|
|
|
|
|
|
|
|
return to_mdp5_kms(to_mdp_kms(priv->kms));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
void ctl_write(struct mdp5_ctl *ctl, u32 reg, u32 data)
|
|
|
|
{
|
2014-11-18 22:22:51 +00:00
|
|
|
struct mdp5_kms *mdp5_kms = get_kms(ctl->ctlm);
|
2014-11-18 17:49:49 +00:00
|
|
|
|
|
|
|
(void)ctl->reg_offset; /* TODO use this instead of mdp5_write */
|
|
|
|
mdp5_write(mdp5_kms, reg, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
u32 ctl_read(struct mdp5_ctl *ctl, u32 reg)
|
|
|
|
{
|
2014-11-18 22:22:51 +00:00
|
|
|
struct mdp5_kms *mdp5_kms = get_kms(ctl->ctlm);
|
2014-11-18 17:49:49 +00:00
|
|
|
|
|
|
|
(void)ctl->reg_offset; /* TODO use this instead of mdp5_write */
|
|
|
|
return mdp5_read(mdp5_kms, reg);
|
|
|
|
}
|
|
|
|
|
2015-03-13 19:49:32 +00:00
|
|
|
static void set_display_intf(struct mdp5_kms *mdp5_kms,
|
|
|
|
struct mdp5_interface *intf)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
u32 intf_sel;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&mdp5_kms->resource_lock, flags);
|
2016-05-10 05:35:58 +00:00
|
|
|
intf_sel = mdp5_read(mdp5_kms, REG_MDP5_DISP_INTF_SEL);
|
2015-03-13 19:49:32 +00:00
|
|
|
|
|
|
|
switch (intf->num) {
|
|
|
|
case 0:
|
2016-05-10 05:35:58 +00:00
|
|
|
intf_sel &= ~MDP5_DISP_INTF_SEL_INTF0__MASK;
|
|
|
|
intf_sel |= MDP5_DISP_INTF_SEL_INTF0(intf->type);
|
2015-03-13 19:49:32 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-05-10 05:35:58 +00:00
|
|
|
intf_sel &= ~MDP5_DISP_INTF_SEL_INTF1__MASK;
|
|
|
|
intf_sel |= MDP5_DISP_INTF_SEL_INTF1(intf->type);
|
2015-03-13 19:49:32 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-05-10 05:35:58 +00:00
|
|
|
intf_sel &= ~MDP5_DISP_INTF_SEL_INTF2__MASK;
|
|
|
|
intf_sel |= MDP5_DISP_INTF_SEL_INTF2(intf->type);
|
2015-03-13 19:49:32 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2016-05-10 05:35:58 +00:00
|
|
|
intf_sel &= ~MDP5_DISP_INTF_SEL_INTF3__MASK;
|
|
|
|
intf_sel |= MDP5_DISP_INTF_SEL_INTF3(intf->type);
|
2015-03-13 19:49:32 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-05-10 05:35:58 +00:00
|
|
|
mdp5_write(mdp5_kms, REG_MDP5_DISP_INTF_SEL, intf_sel);
|
2015-03-13 19:49:32 +00:00
|
|
|
spin_unlock_irqrestore(&mdp5_kms->resource_lock, flags);
|
|
|
|
}
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2017-03-23 10:28:17 +00:00
|
|
|
static void set_ctl_op(struct mdp5_ctl *ctl, struct mdp5_pipeline *pipeline)
|
2014-11-18 17:49:49 +00:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
2017-03-23 10:28:17 +00:00
|
|
|
struct mdp5_interface *intf = pipeline->intf;
|
2015-03-13 19:49:32 +00:00
|
|
|
u32 ctl_op = 0;
|
|
|
|
|
|
|
|
if (!mdp5_cfg_intf_is_virtual(intf->type))
|
|
|
|
ctl_op |= MDP5_CTL_OP_INTF_NUM(INTF0 + intf->num);
|
|
|
|
|
|
|
|
switch (intf->type) {
|
|
|
|
case INTF_DSI:
|
|
|
|
if (intf->mode == MDP5_INTF_DSI_MODE_COMMAND)
|
|
|
|
ctl_op |= MDP5_CTL_OP_CMD_MODE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INTF_WB:
|
|
|
|
if (intf->mode == MDP5_INTF_WB_MODE_LINE)
|
|
|
|
ctl_op |= MDP5_CTL_OP_MODE(MODE_WB_2_LINE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2017-03-23 10:28:17 +00:00
|
|
|
if (pipeline->r_mixer)
|
|
|
|
ctl_op |= MDP5_CTL_OP_PACK_3D_ENABLE |
|
|
|
|
MDP5_CTL_OP_PACK_3D(1);
|
|
|
|
|
2014-11-18 17:49:49 +00:00
|
|
|
spin_lock_irqsave(&ctl->hw_lock, flags);
|
2015-03-13 19:49:32 +00:00
|
|
|
ctl_write(ctl, REG_MDP5_CTL_OP(ctl->id), ctl_op);
|
2014-11-18 17:49:49 +00:00
|
|
|
spin_unlock_irqrestore(&ctl->hw_lock, flags);
|
2015-03-13 19:49:32 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:28:06 +00:00
|
|
|
int mdp5_ctl_set_pipeline(struct mdp5_ctl *ctl, struct mdp5_pipeline *pipeline)
|
2015-03-13 19:49:32 +00:00
|
|
|
{
|
2018-02-19 13:17:06 +00:00
|
|
|
struct mdp5_kms *mdp5_kms = get_kms(ctl->ctlm);
|
2017-03-23 10:28:06 +00:00
|
|
|
struct mdp5_interface *intf = pipeline->intf;
|
2015-03-13 19:49:33 +00:00
|
|
|
|
2015-03-13 19:49:32 +00:00
|
|
|
/* Virtual interfaces need not set a display intf (e.g.: Writeback) */
|
|
|
|
if (!mdp5_cfg_intf_is_virtual(intf->type))
|
|
|
|
set_display_intf(mdp5_kms, intf);
|
|
|
|
|
2017-03-23 10:28:17 +00:00
|
|
|
set_ctl_op(ctl, pipeline);
|
2014-11-18 17:49:49 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:28:06 +00:00
|
|
|
static bool start_signal_needed(struct mdp5_ctl *ctl,
|
|
|
|
struct mdp5_pipeline *pipeline)
|
2015-03-13 19:49:33 +00:00
|
|
|
{
|
2017-03-23 10:28:06 +00:00
|
|
|
struct mdp5_interface *intf = pipeline->intf;
|
|
|
|
|
2018-02-19 13:17:06 +00:00
|
|
|
if (!ctl->encoder_enabled)
|
2015-03-13 19:49:33 +00:00
|
|
|
return false;
|
|
|
|
|
2017-03-23 10:28:06 +00:00
|
|
|
switch (intf->type) {
|
2015-03-13 19:49:33 +00:00
|
|
|
case INTF_WB:
|
|
|
|
return true;
|
|
|
|
case INTF_DSI:
|
2017-03-23 10:28:06 +00:00
|
|
|
return intf->mode == MDP5_INTF_DSI_MODE_COMMAND;
|
2015-03-13 19:49:33 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* send_start_signal() - Overlay Processor Start Signal
|
|
|
|
*
|
|
|
|
* For a given control operation (display pipeline), a START signal needs to be
|
|
|
|
* executed in order to kick off operation and activate all layers.
|
|
|
|
* e.g.: DSI command mode, Writeback
|
|
|
|
*/
|
|
|
|
static void send_start_signal(struct mdp5_ctl *ctl)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ctl->hw_lock, flags);
|
|
|
|
ctl_write(ctl, REG_MDP5_CTL_START(ctl->id), 1);
|
|
|
|
spin_unlock_irqrestore(&ctl->hw_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mdp5_ctl_set_encoder_state() - set the encoder state
|
|
|
|
*
|
|
|
|
* @enable: true, when encoder is ready for data streaming; false, otherwise.
|
|
|
|
*
|
|
|
|
* Note:
|
|
|
|
* This encoder state is needed to trigger START signal (data path kickoff).
|
|
|
|
*/
|
2017-03-23 10:28:06 +00:00
|
|
|
int mdp5_ctl_set_encoder_state(struct mdp5_ctl *ctl,
|
|
|
|
struct mdp5_pipeline *pipeline,
|
|
|
|
bool enabled)
|
2015-03-13 19:49:33 +00:00
|
|
|
{
|
2017-03-23 10:28:06 +00:00
|
|
|
struct mdp5_interface *intf = pipeline->intf;
|
|
|
|
|
2015-03-13 19:49:33 +00:00
|
|
|
if (WARN_ON(!ctl))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2017-03-23 10:28:00 +00:00
|
|
|
ctl->encoder_enabled = enabled;
|
2017-03-23 10:28:06 +00:00
|
|
|
DBG("intf_%d: %s", intf->num, enabled ? "on" : "off");
|
2015-03-13 19:49:33 +00:00
|
|
|
|
2017-03-23 10:28:06 +00:00
|
|
|
if (start_signal_needed(ctl, pipeline)) {
|
2015-03-13 19:49:33 +00:00
|
|
|
send_start_signal(ctl);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note:
|
|
|
|
* CTL registers need to be flushed after calling this function
|
|
|
|
* (call mdp5_ctl_commit() with mdp_ctl_flush_mask_ctl() mask)
|
|
|
|
*/
|
2017-03-23 10:28:06 +00:00
|
|
|
int mdp5_ctl_set_cursor(struct mdp5_ctl *ctl, struct mdp5_pipeline *pipeline,
|
|
|
|
int cursor_id, bool enable)
|
2014-11-18 17:49:49 +00:00
|
|
|
{
|
2014-11-18 22:22:51 +00:00
|
|
|
struct mdp5_ctl_manager *ctl_mgr = ctl->ctlm;
|
2014-11-18 17:49:49 +00:00
|
|
|
unsigned long flags;
|
|
|
|
u32 blend_cfg;
|
2017-03-23 10:28:06 +00:00
|
|
|
struct mdp5_hw_mixer *mixer = pipeline->mixer;
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2019-08-29 16:50:16 +00:00
|
|
|
if (WARN_ON(!mixer)) {
|
2018-10-20 17:49:26 +00:00
|
|
|
DRM_DEV_ERROR(ctl_mgr->dev->dev, "CTL %d cannot find LM",
|
2017-03-23 10:27:57 +00:00
|
|
|
ctl->id);
|
2014-11-18 17:49:49 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
if (pipeline->r_mixer) {
|
2018-10-20 17:49:26 +00:00
|
|
|
DRM_DEV_ERROR(ctl_mgr->dev->dev, "unsupported configuration");
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-11-18 17:49:49 +00:00
|
|
|
spin_lock_irqsave(&ctl->hw_lock, flags);
|
|
|
|
|
2017-03-23 10:27:57 +00:00
|
|
|
blend_cfg = ctl_read(ctl, REG_MDP5_CTL_LAYER_REG(ctl->id, mixer->lm));
|
2014-11-18 17:49:49 +00:00
|
|
|
|
|
|
|
if (enable)
|
|
|
|
blend_cfg |= MDP5_CTL_LAYER_REG_CURSOR_OUT;
|
|
|
|
else
|
|
|
|
blend_cfg &= ~MDP5_CTL_LAYER_REG_CURSOR_OUT;
|
|
|
|
|
2017-03-23 10:27:57 +00:00
|
|
|
ctl_write(ctl, REG_MDP5_CTL_LAYER_REG(ctl->id, mixer->lm), blend_cfg);
|
2015-06-25 21:37:42 +00:00
|
|
|
ctl->cursor_on = enable;
|
2014-11-18 17:49:49 +00:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ctl->hw_lock, flags);
|
|
|
|
|
2015-03-13 19:49:33 +00:00
|
|
|
ctl->pending_ctl_trigger = mdp_ctl_flush_mask_cursor(cursor_id);
|
2014-11-18 17:49:49 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-25 21:37:42 +00:00
|
|
|
static u32 mdp_ctl_blend_mask(enum mdp5_pipe pipe,
|
|
|
|
enum mdp_mixer_stage_id stage)
|
|
|
|
{
|
|
|
|
switch (pipe) {
|
|
|
|
case SSPP_VIG0: return MDP5_CTL_LAYER_REG_VIG0(stage);
|
|
|
|
case SSPP_VIG1: return MDP5_CTL_LAYER_REG_VIG1(stage);
|
|
|
|
case SSPP_VIG2: return MDP5_CTL_LAYER_REG_VIG2(stage);
|
|
|
|
case SSPP_RGB0: return MDP5_CTL_LAYER_REG_RGB0(stage);
|
|
|
|
case SSPP_RGB1: return MDP5_CTL_LAYER_REG_RGB1(stage);
|
|
|
|
case SSPP_RGB2: return MDP5_CTL_LAYER_REG_RGB2(stage);
|
|
|
|
case SSPP_DMA0: return MDP5_CTL_LAYER_REG_DMA0(stage);
|
|
|
|
case SSPP_DMA1: return MDP5_CTL_LAYER_REG_DMA1(stage);
|
|
|
|
case SSPP_VIG3: return MDP5_CTL_LAYER_REG_VIG3(stage);
|
|
|
|
case SSPP_RGB3: return MDP5_CTL_LAYER_REG_RGB3(stage);
|
2017-01-16 06:27:04 +00:00
|
|
|
case SSPP_CURSOR0:
|
|
|
|
case SSPP_CURSOR1:
|
2015-06-25 21:37:42 +00:00
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 mdp_ctl_blend_ext_mask(enum mdp5_pipe pipe,
|
|
|
|
enum mdp_mixer_stage_id stage)
|
|
|
|
{
|
2017-01-16 06:27:04 +00:00
|
|
|
if (stage < STAGE6 && (pipe != SSPP_CURSOR0 && pipe != SSPP_CURSOR1))
|
2015-06-25 21:37:42 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (pipe) {
|
|
|
|
case SSPP_VIG0: return MDP5_CTL_LAYER_EXT_REG_VIG0_BIT3;
|
|
|
|
case SSPP_VIG1: return MDP5_CTL_LAYER_EXT_REG_VIG1_BIT3;
|
|
|
|
case SSPP_VIG2: return MDP5_CTL_LAYER_EXT_REG_VIG2_BIT3;
|
|
|
|
case SSPP_RGB0: return MDP5_CTL_LAYER_EXT_REG_RGB0_BIT3;
|
|
|
|
case SSPP_RGB1: return MDP5_CTL_LAYER_EXT_REG_RGB1_BIT3;
|
|
|
|
case SSPP_RGB2: return MDP5_CTL_LAYER_EXT_REG_RGB2_BIT3;
|
|
|
|
case SSPP_DMA0: return MDP5_CTL_LAYER_EXT_REG_DMA0_BIT3;
|
|
|
|
case SSPP_DMA1: return MDP5_CTL_LAYER_EXT_REG_DMA1_BIT3;
|
|
|
|
case SSPP_VIG3: return MDP5_CTL_LAYER_EXT_REG_VIG3_BIT3;
|
|
|
|
case SSPP_RGB3: return MDP5_CTL_LAYER_EXT_REG_RGB3_BIT3;
|
2017-01-16 06:27:04 +00:00
|
|
|
case SSPP_CURSOR0: return MDP5_CTL_LAYER_EXT_REG_CURSOR0(stage);
|
|
|
|
case SSPP_CURSOR1: return MDP5_CTL_LAYER_EXT_REG_CURSOR1(stage);
|
2015-06-25 21:37:42 +00:00
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:28:16 +00:00
|
|
|
static void mdp5_ctl_reset_blend_regs(struct mdp5_ctl *ctl)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct mdp5_ctl_manager *ctl_mgr = ctl->ctlm;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ctl->hw_lock, flags);
|
|
|
|
|
|
|
|
for (i = 0; i < ctl_mgr->nlm; i++) {
|
|
|
|
ctl_write(ctl, REG_MDP5_CTL_LAYER_REG(ctl->id, i), 0x0);
|
|
|
|
ctl_write(ctl, REG_MDP5_CTL_LAYER_EXT_REG(ctl->id, i), 0x0);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ctl->hw_lock, flags);
|
|
|
|
}
|
|
|
|
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
#define PIPE_LEFT 0
|
|
|
|
#define PIPE_RIGHT 1
|
2017-03-23 10:28:06 +00:00
|
|
|
int mdp5_ctl_blend(struct mdp5_ctl *ctl, struct mdp5_pipeline *pipeline,
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
enum mdp5_pipe stage[][MAX_PIPE_STAGE],
|
|
|
|
enum mdp5_pipe r_stage[][MAX_PIPE_STAGE],
|
|
|
|
u32 stage_cnt, u32 ctl_blend_op_flags)
|
2014-11-18 17:49:49 +00:00
|
|
|
{
|
2017-03-23 10:28:06 +00:00
|
|
|
struct mdp5_hw_mixer *mixer = pipeline->mixer;
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
struct mdp5_hw_mixer *r_mixer = pipeline->r_mixer;
|
2014-11-18 17:49:49 +00:00
|
|
|
unsigned long flags;
|
2015-06-25 21:37:42 +00:00
|
|
|
u32 blend_cfg = 0, blend_ext_cfg = 0;
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
u32 r_blend_cfg = 0, r_blend_ext_cfg = 0;
|
2015-06-25 21:37:42 +00:00
|
|
|
int i, start_stage;
|
|
|
|
|
2017-03-23 10:28:16 +00:00
|
|
|
mdp5_ctl_reset_blend_regs(ctl);
|
|
|
|
|
2015-06-25 21:37:42 +00:00
|
|
|
if (ctl_blend_op_flags & MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT) {
|
|
|
|
start_stage = STAGE0;
|
|
|
|
blend_cfg |= MDP5_CTL_LAYER_REG_BORDER_COLOR;
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
if (r_mixer)
|
|
|
|
r_blend_cfg |= MDP5_CTL_LAYER_REG_BORDER_COLOR;
|
2015-06-25 21:37:42 +00:00
|
|
|
} else {
|
|
|
|
start_stage = STAGE_BASE;
|
|
|
|
}
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2017-01-16 06:27:04 +00:00
|
|
|
for (i = start_stage; stage_cnt && i <= STAGE_MAX; i++) {
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
blend_cfg |=
|
2017-03-23 10:28:13 +00:00
|
|
|
mdp_ctl_blend_mask(stage[i][PIPE_LEFT], i) |
|
|
|
|
mdp_ctl_blend_mask(stage[i][PIPE_RIGHT], i);
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
blend_ext_cfg |=
|
2017-03-23 10:28:13 +00:00
|
|
|
mdp_ctl_blend_ext_mask(stage[i][PIPE_LEFT], i) |
|
|
|
|
mdp_ctl_blend_ext_mask(stage[i][PIPE_RIGHT], i);
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
if (r_mixer) {
|
|
|
|
r_blend_cfg |=
|
2017-03-23 10:28:13 +00:00
|
|
|
mdp_ctl_blend_mask(r_stage[i][PIPE_LEFT], i) |
|
|
|
|
mdp_ctl_blend_mask(r_stage[i][PIPE_RIGHT], i);
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
r_blend_ext_cfg |=
|
2017-03-23 10:28:13 +00:00
|
|
|
mdp_ctl_blend_ext_mask(r_stage[i][PIPE_LEFT], i) |
|
|
|
|
mdp_ctl_blend_ext_mask(r_stage[i][PIPE_RIGHT], i);
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
}
|
2015-06-25 21:37:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ctl->hw_lock, flags);
|
2014-11-18 17:49:49 +00:00
|
|
|
if (ctl->cursor_on)
|
|
|
|
blend_cfg |= MDP5_CTL_LAYER_REG_CURSOR_OUT;
|
|
|
|
|
2017-03-23 10:27:57 +00:00
|
|
|
ctl_write(ctl, REG_MDP5_CTL_LAYER_REG(ctl->id, mixer->lm), blend_cfg);
|
|
|
|
ctl_write(ctl, REG_MDP5_CTL_LAYER_EXT_REG(ctl->id, mixer->lm),
|
|
|
|
blend_ext_cfg);
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
if (r_mixer) {
|
|
|
|
ctl_write(ctl, REG_MDP5_CTL_LAYER_REG(ctl->id, r_mixer->lm),
|
|
|
|
r_blend_cfg);
|
|
|
|
ctl_write(ctl, REG_MDP5_CTL_LAYER_EXT_REG(ctl->id, r_mixer->lm),
|
|
|
|
r_blend_ext_cfg);
|
|
|
|
}
|
2014-11-18 17:49:49 +00:00
|
|
|
spin_unlock_irqrestore(&ctl->hw_lock, flags);
|
|
|
|
|
2017-03-23 10:27:57 +00:00
|
|
|
ctl->pending_ctl_trigger = mdp_ctl_flush_mask_lm(mixer->lm);
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
if (r_mixer)
|
|
|
|
ctl->pending_ctl_trigger |= mdp_ctl_flush_mask_lm(r_mixer->lm);
|
2015-03-13 19:49:33 +00:00
|
|
|
|
2017-03-23 10:27:57 +00:00
|
|
|
DBG("lm%d: blend config = 0x%08x. ext_cfg = 0x%08x", mixer->lm,
|
2015-06-25 21:37:42 +00:00
|
|
|
blend_cfg, blend_ext_cfg);
|
drm/msm/mdp5: Add optional 'right' Layer Mixer in CRTC state
Add another mdp5_hw_mixer pointer (r_mixer) in mdp5_crtc_state.
This mixer will be used to generate the right half of the scanout.
With Source Split, a SSPP can now be connected to 2 Layer Mixers, but
has to be at the same blend level (stage #) on both Layer Mixers.
A drm_plane that has a lesser width than the max width supported, will
comprise of a single SSPP/hwpipe, staged on both the Layer Mixers at
the same blend level. A plane that is greater than max width will comprise
of 2 SSPPs, with the 'left' SSPP staged on the left LM, and the 'right'
SSPP staged on the right LM at the same blend level.
For now, the drm_plane consists of only one SSPP, therefore, it
needs to be staged on both the LMs in blend_setup() and mdp5_ctl_blend().
We'll extend this logic to support 2 hwpipes per plane later.
The crtc cursor ops (using the LM cursors, not SSPP cursors) simply
return an error if they're called when the right mixer is assigned to
the CRTC state. With source split is enabled, we're expected to only
SSPP cursors.
This commit adds code that configures the right mixer, but the r_mixer
itself isn't assigned at the moment.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-03-23 10:28:08 +00:00
|
|
|
if (r_mixer)
|
|
|
|
DBG("lm%d: blend config = 0x%08x. ext_cfg = 0x%08x",
|
|
|
|
r_mixer->lm, r_blend_cfg, r_blend_ext_cfg);
|
2015-06-25 21:37:42 +00:00
|
|
|
|
2014-11-18 17:49:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-13 19:49:33 +00:00
|
|
|
u32 mdp_ctl_flush_mask_encoder(struct mdp5_interface *intf)
|
|
|
|
{
|
|
|
|
if (intf->type == INTF_WB)
|
|
|
|
return MDP5_CTL_FLUSH_WB;
|
|
|
|
|
|
|
|
switch (intf->num) {
|
|
|
|
case 0: return MDP5_CTL_FLUSH_TIMING_0;
|
|
|
|
case 1: return MDP5_CTL_FLUSH_TIMING_1;
|
|
|
|
case 2: return MDP5_CTL_FLUSH_TIMING_2;
|
|
|
|
case 3: return MDP5_CTL_FLUSH_TIMING_3;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 mdp_ctl_flush_mask_cursor(int cursor_id)
|
|
|
|
{
|
|
|
|
switch (cursor_id) {
|
|
|
|
case 0: return MDP5_CTL_FLUSH_CURSOR_0;
|
|
|
|
case 1: return MDP5_CTL_FLUSH_CURSOR_1;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 mdp_ctl_flush_mask_pipe(enum mdp5_pipe pipe)
|
|
|
|
{
|
|
|
|
switch (pipe) {
|
|
|
|
case SSPP_VIG0: return MDP5_CTL_FLUSH_VIG0;
|
|
|
|
case SSPP_VIG1: return MDP5_CTL_FLUSH_VIG1;
|
|
|
|
case SSPP_VIG2: return MDP5_CTL_FLUSH_VIG2;
|
|
|
|
case SSPP_RGB0: return MDP5_CTL_FLUSH_RGB0;
|
|
|
|
case SSPP_RGB1: return MDP5_CTL_FLUSH_RGB1;
|
|
|
|
case SSPP_RGB2: return MDP5_CTL_FLUSH_RGB2;
|
|
|
|
case SSPP_DMA0: return MDP5_CTL_FLUSH_DMA0;
|
|
|
|
case SSPP_DMA1: return MDP5_CTL_FLUSH_DMA1;
|
|
|
|
case SSPP_VIG3: return MDP5_CTL_FLUSH_VIG3;
|
|
|
|
case SSPP_RGB3: return MDP5_CTL_FLUSH_RGB3;
|
2017-01-16 06:27:04 +00:00
|
|
|
case SSPP_CURSOR0: return MDP5_CTL_FLUSH_CURSOR_0;
|
|
|
|
case SSPP_CURSOR1: return MDP5_CTL_FLUSH_CURSOR_1;
|
2015-03-13 19:49:33 +00:00
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 mdp_ctl_flush_mask_lm(int lm)
|
|
|
|
{
|
|
|
|
switch (lm) {
|
|
|
|
case 0: return MDP5_CTL_FLUSH_LM0;
|
|
|
|
case 1: return MDP5_CTL_FLUSH_LM1;
|
|
|
|
case 2: return MDP5_CTL_FLUSH_LM2;
|
2018-02-19 13:29:33 +00:00
|
|
|
case 3: return MDP5_CTL_FLUSH_LM3;
|
|
|
|
case 4: return MDP5_CTL_FLUSH_LM4;
|
2015-03-13 19:49:33 +00:00
|
|
|
case 5: return MDP5_CTL_FLUSH_LM5;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:28:06 +00:00
|
|
|
static u32 fix_sw_flush(struct mdp5_ctl *ctl, struct mdp5_pipeline *pipeline,
|
|
|
|
u32 flush_mask)
|
2015-03-13 19:49:33 +00:00
|
|
|
{
|
|
|
|
struct mdp5_ctl_manager *ctl_mgr = ctl->ctlm;
|
|
|
|
u32 sw_mask = 0;
|
|
|
|
#define BIT_NEEDS_SW_FIX(bit) \
|
|
|
|
(!(ctl_mgr->flush_hw_mask & bit) && (flush_mask & bit))
|
|
|
|
|
|
|
|
/* for some targets, cursor bit is the same as LM bit */
|
|
|
|
if (BIT_NEEDS_SW_FIX(MDP5_CTL_FLUSH_CURSOR_0))
|
2017-03-23 10:28:06 +00:00
|
|
|
sw_mask |= mdp_ctl_flush_mask_lm(pipeline->mixer->lm);
|
2015-03-13 19:49:33 +00:00
|
|
|
|
|
|
|
return sw_mask;
|
|
|
|
}
|
|
|
|
|
2015-06-26 20:03:26 +00:00
|
|
|
static void fix_for_single_flush(struct mdp5_ctl *ctl, u32 *flush_mask,
|
|
|
|
u32 *flush_id)
|
|
|
|
{
|
|
|
|
struct mdp5_ctl_manager *ctl_mgr = ctl->ctlm;
|
|
|
|
|
|
|
|
if (ctl->pair) {
|
|
|
|
DBG("CTL %d FLUSH pending mask %x", ctl->id, *flush_mask);
|
|
|
|
ctl->flush_pending = true;
|
|
|
|
ctl_mgr->single_flush_pending_mask |= (*flush_mask);
|
|
|
|
*flush_mask = 0;
|
|
|
|
|
|
|
|
if (ctl->pair->flush_pending) {
|
|
|
|
*flush_id = min_t(u32, ctl->id, ctl->pair->id);
|
|
|
|
*flush_mask = ctl_mgr->single_flush_pending_mask;
|
|
|
|
|
|
|
|
ctl->flush_pending = false;
|
|
|
|
ctl->pair->flush_pending = false;
|
|
|
|
ctl_mgr->single_flush_pending_mask = 0;
|
|
|
|
|
|
|
|
DBG("Single FLUSH mask %x,ID %d", *flush_mask,
|
|
|
|
*flush_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-13 19:49:33 +00:00
|
|
|
/**
|
|
|
|
* mdp5_ctl_commit() - Register Flush
|
|
|
|
*
|
|
|
|
* The flush register is used to indicate several registers are all
|
|
|
|
* programmed, and are safe to update to the back copy of the double
|
|
|
|
* buffered registers.
|
|
|
|
*
|
|
|
|
* Some registers FLUSH bits are shared when the hardware does not have
|
|
|
|
* dedicated bits for them; handling these is the job of fix_sw_flush().
|
|
|
|
*
|
|
|
|
* CTL registers need to be flushed in some circumstances; if that is the
|
|
|
|
* case, some trigger bits will be present in both flush mask and
|
|
|
|
* ctl->pending_ctl_trigger.
|
2015-04-28 23:35:37 +00:00
|
|
|
*
|
|
|
|
* Return H/W flushed bit mask.
|
2015-03-13 19:49:33 +00:00
|
|
|
*/
|
2017-03-23 10:28:06 +00:00
|
|
|
u32 mdp5_ctl_commit(struct mdp5_ctl *ctl,
|
|
|
|
struct mdp5_pipeline *pipeline,
|
2018-02-19 13:17:06 +00:00
|
|
|
u32 flush_mask, bool start)
|
2014-11-18 17:49:49 +00:00
|
|
|
{
|
2014-11-18 22:22:51 +00:00
|
|
|
struct mdp5_ctl_manager *ctl_mgr = ctl->ctlm;
|
2014-11-18 17:49:49 +00:00
|
|
|
unsigned long flags;
|
2015-06-26 20:03:26 +00:00
|
|
|
u32 flush_id = ctl->id;
|
|
|
|
u32 curr_ctl_flush_mask;
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2018-02-19 13:17:06 +00:00
|
|
|
VERB("flush_mask=%x, trigger=%x", flush_mask, ctl->pending_ctl_trigger);
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2015-03-13 19:49:33 +00:00
|
|
|
if (ctl->pending_ctl_trigger & flush_mask) {
|
|
|
|
flush_mask |= MDP5_CTL_FLUSH_CTL;
|
|
|
|
ctl->pending_ctl_trigger = 0;
|
2014-11-18 17:49:49 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:28:06 +00:00
|
|
|
flush_mask |= fix_sw_flush(ctl, pipeline, flush_mask);
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2015-03-13 19:49:33 +00:00
|
|
|
flush_mask &= ctl_mgr->flush_hw_mask;
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2015-06-26 20:03:26 +00:00
|
|
|
curr_ctl_flush_mask = flush_mask;
|
|
|
|
|
|
|
|
fix_for_single_flush(ctl, &flush_mask, &flush_id);
|
|
|
|
|
2018-02-19 13:17:06 +00:00
|
|
|
if (!start) {
|
|
|
|
ctl->flush_mask |= flush_mask;
|
|
|
|
return curr_ctl_flush_mask;
|
|
|
|
} else {
|
|
|
|
flush_mask |= ctl->flush_mask;
|
|
|
|
ctl->flush_mask = 0;
|
|
|
|
}
|
|
|
|
|
2015-03-13 19:49:33 +00:00
|
|
|
if (flush_mask) {
|
|
|
|
spin_lock_irqsave(&ctl->hw_lock, flags);
|
2015-06-26 20:03:26 +00:00
|
|
|
ctl_write(ctl, REG_MDP5_CTL_FLUSH(flush_id), flush_mask);
|
2015-03-13 19:49:33 +00:00
|
|
|
spin_unlock_irqrestore(&ctl->hw_lock, flags);
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:28:06 +00:00
|
|
|
if (start_signal_needed(ctl, pipeline)) {
|
2015-03-13 19:49:33 +00:00
|
|
|
send_start_signal(ctl);
|
|
|
|
}
|
|
|
|
|
2015-06-26 20:03:26 +00:00
|
|
|
return curr_ctl_flush_mask;
|
2015-04-28 23:35:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 mdp5_ctl_get_commit_status(struct mdp5_ctl *ctl)
|
|
|
|
{
|
|
|
|
return ctl_read(ctl, REG_MDP5_CTL_FLUSH(ctl->id));
|
2014-11-18 17:49:49 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 19:49:33 +00:00
|
|
|
int mdp5_ctl_get_ctl_id(struct mdp5_ctl *ctl)
|
|
|
|
{
|
|
|
|
return WARN_ON(!ctl) ? -EINVAL : ctl->id;
|
|
|
|
}
|
|
|
|
|
2015-06-26 20:03:26 +00:00
|
|
|
/*
|
|
|
|
* mdp5_ctl_pair() - Associate 2 booked CTLs for single FLUSH
|
|
|
|
*/
|
|
|
|
int mdp5_ctl_pair(struct mdp5_ctl *ctlx, struct mdp5_ctl *ctly, bool enable)
|
|
|
|
{
|
|
|
|
struct mdp5_ctl_manager *ctl_mgr = ctlx->ctlm;
|
|
|
|
struct mdp5_kms *mdp5_kms = get_kms(ctl_mgr);
|
|
|
|
|
|
|
|
/* do nothing silently if hw doesn't support */
|
|
|
|
if (!ctl_mgr->single_flush_supported)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!enable) {
|
|
|
|
ctlx->pair = NULL;
|
|
|
|
ctly->pair = NULL;
|
2016-05-10 05:35:58 +00:00
|
|
|
mdp5_write(mdp5_kms, REG_MDP5_SPARE_0, 0);
|
2015-06-26 20:03:26 +00:00
|
|
|
return 0;
|
|
|
|
} else if ((ctlx->pair != NULL) || (ctly->pair != NULL)) {
|
2018-10-20 17:49:26 +00:00
|
|
|
DRM_DEV_ERROR(ctl_mgr->dev->dev, "CTLs already paired\n");
|
2015-06-26 20:03:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
} else if (!(ctlx->status & ctly->status & CTL_STAT_BOOKED)) {
|
2018-10-20 17:49:26 +00:00
|
|
|
DRM_DEV_ERROR(ctl_mgr->dev->dev, "Only pair booked CTLs\n");
|
2015-06-26 20:03:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctlx->pair = ctly;
|
|
|
|
ctly->pair = ctlx;
|
|
|
|
|
2016-05-10 05:35:58 +00:00
|
|
|
mdp5_write(mdp5_kms, REG_MDP5_SPARE_0,
|
|
|
|
MDP5_SPARE_0_SPLIT_DPL_SINGLE_FLUSH_EN);
|
2015-06-26 20:03:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-18 17:49:49 +00:00
|
|
|
/*
|
2015-06-26 20:03:25 +00:00
|
|
|
* mdp5_ctl_request() - CTL allocation
|
2014-11-18 17:49:49 +00:00
|
|
|
*
|
2015-06-26 20:03:26 +00:00
|
|
|
* Try to return booked CTL for @intf_num is 1 or 2, unbooked for other INTFs.
|
|
|
|
* If no CTL is available in preferred category, allocate from the other one.
|
|
|
|
*
|
|
|
|
* @return fail if no CTL is available.
|
2014-11-18 17:49:49 +00:00
|
|
|
*/
|
2014-11-18 19:28:43 +00:00
|
|
|
struct mdp5_ctl *mdp5_ctlm_request(struct mdp5_ctl_manager *ctl_mgr,
|
2015-06-26 20:03:25 +00:00
|
|
|
int intf_num)
|
2014-11-18 17:49:49 +00:00
|
|
|
{
|
|
|
|
struct mdp5_ctl *ctl = NULL;
|
2015-06-26 20:03:26 +00:00
|
|
|
const u32 checkm = CTL_STAT_BUSY | CTL_STAT_BOOKED;
|
|
|
|
u32 match = ((intf_num == 1) || (intf_num == 2)) ? CTL_STAT_BOOKED : 0;
|
2014-11-18 17:49:49 +00:00
|
|
|
unsigned long flags;
|
|
|
|
int c;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ctl_mgr->pool_lock, flags);
|
|
|
|
|
2015-06-26 20:03:26 +00:00
|
|
|
/* search the preferred */
|
2014-11-18 17:49:49 +00:00
|
|
|
for (c = 0; c < ctl_mgr->nctl; c++)
|
2015-06-26 20:03:26 +00:00
|
|
|
if ((ctl_mgr->ctls[c].status & checkm) == match)
|
|
|
|
goto found;
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2015-06-26 20:03:26 +00:00
|
|
|
dev_warn(ctl_mgr->dev->dev,
|
|
|
|
"fall back to the other CTL category for INTF %d!\n", intf_num);
|
|
|
|
|
|
|
|
match ^= CTL_STAT_BOOKED;
|
|
|
|
for (c = 0; c < ctl_mgr->nctl; c++)
|
|
|
|
if ((ctl_mgr->ctls[c].status & checkm) == match)
|
|
|
|
goto found;
|
2014-11-18 17:49:49 +00:00
|
|
|
|
2018-10-20 17:49:26 +00:00
|
|
|
DRM_DEV_ERROR(ctl_mgr->dev->dev, "No more CTL available!");
|
2015-06-26 20:03:26 +00:00
|
|
|
goto unlock;
|
|
|
|
|
|
|
|
found:
|
2014-11-18 17:49:49 +00:00
|
|
|
ctl = &ctl_mgr->ctls[c];
|
2015-06-26 20:03:26 +00:00
|
|
|
ctl->status |= CTL_STAT_BUSY;
|
2015-03-13 19:49:33 +00:00
|
|
|
ctl->pending_ctl_trigger = 0;
|
2014-11-18 17:49:49 +00:00
|
|
|
DBG("CTL %d allocated", ctl->id);
|
|
|
|
|
|
|
|
unlock:
|
|
|
|
spin_unlock_irqrestore(&ctl_mgr->pool_lock, flags);
|
|
|
|
return ctl;
|
|
|
|
}
|
|
|
|
|
2014-11-18 19:28:43 +00:00
|
|
|
void mdp5_ctlm_hw_reset(struct mdp5_ctl_manager *ctl_mgr)
|
2014-11-18 17:49:49 +00:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int c;
|
|
|
|
|
|
|
|
for (c = 0; c < ctl_mgr->nctl; c++) {
|
|
|
|
struct mdp5_ctl *ctl = &ctl_mgr->ctls[c];
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ctl->hw_lock, flags);
|
|
|
|
ctl_write(ctl, REG_MDP5_CTL_OP(ctl->id), 0);
|
|
|
|
spin_unlock_irqrestore(&ctl->hw_lock, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-18 19:28:43 +00:00
|
|
|
void mdp5_ctlm_destroy(struct mdp5_ctl_manager *ctl_mgr)
|
2014-11-18 17:49:49 +00:00
|
|
|
{
|
|
|
|
kfree(ctl_mgr);
|
|
|
|
}
|
|
|
|
|
2014-11-18 19:28:43 +00:00
|
|
|
struct mdp5_ctl_manager *mdp5_ctlm_init(struct drm_device *dev,
|
2015-06-26 20:03:26 +00:00
|
|
|
void __iomem *mmio_base, struct mdp5_cfg_handler *cfg_hnd)
|
2014-11-18 17:49:49 +00:00
|
|
|
{
|
2014-11-18 22:22:51 +00:00
|
|
|
struct mdp5_ctl_manager *ctl_mgr;
|
2015-06-26 20:03:26 +00:00
|
|
|
const struct mdp5_cfg_hw *hw_cfg = mdp5_cfg_get_hw_config(cfg_hnd);
|
|
|
|
int rev = mdp5_cfg_get_hw_rev(cfg_hnd);
|
2018-02-19 13:31:29 +00:00
|
|
|
unsigned dsi_cnt = 0;
|
2015-03-13 19:49:33 +00:00
|
|
|
const struct mdp5_ctl_block *ctl_cfg = &hw_cfg->ctl;
|
2014-11-18 17:49:49 +00:00
|
|
|
unsigned long flags;
|
|
|
|
int c, ret;
|
|
|
|
|
2014-11-18 22:22:51 +00:00
|
|
|
ctl_mgr = kzalloc(sizeof(*ctl_mgr), GFP_KERNEL);
|
|
|
|
if (!ctl_mgr) {
|
2018-10-20 17:49:26 +00:00
|
|
|
DRM_DEV_ERROR(dev->dev, "failed to allocate CTL manager\n");
|
2014-11-18 22:22:51 +00:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-08-29 16:50:16 +00:00
|
|
|
if (WARN_ON(ctl_cfg->count > MAX_CTL)) {
|
2018-10-20 17:49:26 +00:00
|
|
|
DRM_DEV_ERROR(dev->dev, "Increase static pool size to at least %d\n",
|
2014-11-18 17:49:49 +00:00
|
|
|
ctl_cfg->count);
|
|
|
|
ret = -ENOSPC;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize the CTL manager: */
|
|
|
|
ctl_mgr->dev = dev;
|
|
|
|
ctl_mgr->nlm = hw_cfg->lm.count;
|
|
|
|
ctl_mgr->nctl = ctl_cfg->count;
|
2015-03-13 19:49:33 +00:00
|
|
|
ctl_mgr->flush_hw_mask = ctl_cfg->flush_hw_mask;
|
2014-11-18 17:49:49 +00:00
|
|
|
spin_lock_init(&ctl_mgr->pool_lock);
|
|
|
|
|
|
|
|
/* initialize each CTL of the pool: */
|
|
|
|
spin_lock_irqsave(&ctl_mgr->pool_lock, flags);
|
|
|
|
for (c = 0; c < ctl_mgr->nctl; c++) {
|
|
|
|
struct mdp5_ctl *ctl = &ctl_mgr->ctls[c];
|
|
|
|
|
|
|
|
if (WARN_ON(!ctl_cfg->base[c])) {
|
2018-10-20 17:49:26 +00:00
|
|
|
DRM_DEV_ERROR(dev->dev, "CTL_%d: base is null!\n", c);
|
2014-11-18 17:49:49 +00:00
|
|
|
ret = -EINVAL;
|
2015-06-26 20:03:26 +00:00
|
|
|
spin_unlock_irqrestore(&ctl_mgr->pool_lock, flags);
|
2014-11-18 17:49:49 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
2014-11-18 22:22:51 +00:00
|
|
|
ctl->ctlm = ctl_mgr;
|
2014-11-18 17:49:49 +00:00
|
|
|
ctl->id = c;
|
|
|
|
ctl->reg_offset = ctl_cfg->base[c];
|
2015-06-26 20:03:26 +00:00
|
|
|
ctl->status = 0;
|
2014-11-18 17:49:49 +00:00
|
|
|
spin_lock_init(&ctl->hw_lock);
|
|
|
|
}
|
2015-06-26 20:03:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* In Dual DSI case, CTL0 and CTL1 are always assigned to two DSI
|
|
|
|
* interfaces to support single FLUSH feature (Flush CTL0 and CTL1 when
|
|
|
|
* only write into CTL0's FLUSH register) to keep two DSI pipes in sync.
|
|
|
|
* Single FLUSH is supported from hw rev v3.0.
|
|
|
|
*/
|
2018-02-19 13:31:29 +00:00
|
|
|
for (c = 0; c < ARRAY_SIZE(hw_cfg->intf.connect); c++)
|
|
|
|
if (hw_cfg->intf.connect[c] == INTF_DSI)
|
|
|
|
dsi_cnt++;
|
|
|
|
if ((rev >= 3) && (dsi_cnt > 1)) {
|
2015-06-26 20:03:26 +00:00
|
|
|
ctl_mgr->single_flush_supported = true;
|
|
|
|
/* Reserve CTL0/1 for INTF1/2 */
|
|
|
|
ctl_mgr->ctls[0].status |= CTL_STAT_BOOKED;
|
|
|
|
ctl_mgr->ctls[1].status |= CTL_STAT_BOOKED;
|
|
|
|
}
|
2014-11-18 17:49:49 +00:00
|
|
|
spin_unlock_irqrestore(&ctl_mgr->pool_lock, flags);
|
|
|
|
DBG("Pool of %d CTLs created.", ctl_mgr->nctl);
|
|
|
|
|
|
|
|
return ctl_mgr;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (ctl_mgr)
|
|
|
|
mdp5_ctlm_destroy(ctl_mgr);
|
|
|
|
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|