Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions drivers/gpu/drm/vc4/vc4_hvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
struct vc4_hvs *hvs = NULL;
int ret;
u32 dispctrl;
u32 reg;

hvs = devm_kzalloc(&pdev->dev, sizeof(*hvs), GFP_KERNEL);
if (!hvs)
Expand Down Expand Up @@ -1090,17 +1091,33 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)

vc4->hvs = hvs;

reg = HVS_READ(SCALER_DISPECTRL);
reg &= ~SCALER_DISPECTRL_DSP2_MUX_MASK;
HVS_WRITE(SCALER_DISPECTRL,
reg | VC4_SET_FIELD(0, SCALER_DISPECTRL_DSP2_MUX));

reg = HVS_READ(SCALER_DISPCTRL);
reg &= ~SCALER_DISPCTRL_DSP3_MUX_MASK;
HVS_WRITE(SCALER_DISPCTRL,
reg | VC4_SET_FIELD(3, SCALER_DISPCTRL_DSP3_MUX));

reg = HVS_READ(SCALER_DISPEOLN);
reg &= ~SCALER_DISPEOLN_DSP4_MUX_MASK;
HVS_WRITE(SCALER_DISPEOLN,
reg | VC4_SET_FIELD(3, SCALER_DISPEOLN_DSP4_MUX));

reg = HVS_READ(SCALER_DISPDITHER);
reg &= ~SCALER_DISPDITHER_DSP5_MUX_MASK;
HVS_WRITE(SCALER_DISPDITHER,
reg | VC4_SET_FIELD(3, SCALER_DISPDITHER_DSP5_MUX));

dispctrl = HVS_READ(SCALER_DISPCTRL);

dispctrl |= SCALER_DISPCTRL_ENABLE;
dispctrl |= SCALER_DISPCTRL_DISPEIRQ(0) |
SCALER_DISPCTRL_DISPEIRQ(1) |
SCALER_DISPCTRL_DISPEIRQ(2);

/* Set DSP3 (PV1) to use HVS channel 2, which would otherwise
* be unused.
*/
dispctrl &= ~SCALER_DISPCTRL_DSP3_MUX_MASK;
dispctrl &= ~(SCALER_DISPCTRL_DMAEIRQ |
SCALER_DISPCTRL_SLVWREIRQ |
SCALER_DISPCTRL_SLVRDEIRQ |
Expand All @@ -1114,7 +1131,6 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
SCALER_DISPCTRL_DSPEISLUR(1) |
SCALER_DISPCTRL_DSPEISLUR(2) |
SCALER_DISPCTRL_SCLEIRQ);
dispctrl |= VC4_SET_FIELD(2, SCALER_DISPCTRL_DSP3_MUX);

HVS_WRITE(SCALER_DISPCTRL, dispctrl);

Expand Down
38 changes: 30 additions & 8 deletions drivers/gpu/drm/vc4/vc4_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,24 +286,28 @@ static void vc5_hvs_pv_muxing_commit(struct vc4_dev *vc4,
for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
unsigned int channel = vc4_state->assigned_channel;

if (!vc4_state->update_muxing)
continue;

switch (vc4_crtc->data->hvs_output) {
case 2:
mux = (vc4_state->assigned_channel == 2) ? 0 : 1;
WARN_ON(VC4_GET_FIELD(HVS_READ(SCALER_DISPCTRL),
SCALER_DISPCTRL_DSP3_MUX) == channel);

mux = (channel == 2) ? 0 : 1;
reg = HVS_READ(SCALER_DISPECTRL);
HVS_WRITE(SCALER_DISPECTRL,
(reg & ~SCALER_DISPECTRL_DSP2_MUX_MASK) |
VC4_SET_FIELD(mux, SCALER_DISPECTRL_DSP2_MUX));
break;

case 3:
if (vc4_state->assigned_channel == VC4_HVS_CHANNEL_DISABLED)
if (channel == VC4_HVS_CHANNEL_DISABLED)
mux = 3;
else
mux = vc4_state->assigned_channel;
mux = channel;

reg = HVS_READ(SCALER_DISPCTRL);
HVS_WRITE(SCALER_DISPCTRL,
Expand All @@ -312,10 +316,10 @@ static void vc5_hvs_pv_muxing_commit(struct vc4_dev *vc4,
break;

case 4:
if (vc4_state->assigned_channel == VC4_HVS_CHANNEL_DISABLED)
if (channel == VC4_HVS_CHANNEL_DISABLED)
mux = 3;
else
mux = vc4_state->assigned_channel;
mux = channel;

reg = HVS_READ(SCALER_DISPEOLN);
HVS_WRITE(SCALER_DISPEOLN,
Expand All @@ -325,10 +329,10 @@ static void vc5_hvs_pv_muxing_commit(struct vc4_dev *vc4,
break;

case 5:
if (vc4_state->assigned_channel == VC4_HVS_CHANNEL_DISABLED)
if (channel == VC4_HVS_CHANNEL_DISABLED)
mux = 3;
else
mux = vc4_state->assigned_channel;
mux = channel;

reg = HVS_READ(SCALER_DISPDITHER);
HVS_WRITE(SCALER_DISPDITHER,
Expand Down Expand Up @@ -443,6 +447,9 @@ static void vc4_atomic_commit_tail(struct drm_atomic_state *state)

/* And drop the temporary request */
clk_request_done(core_req);

drm_dbg(dev, "Core clock actual rate: %lu Hz\n",
clk_get_rate(hvs->core_clk));
}
}

Expand Down Expand Up @@ -823,16 +830,29 @@ static int vc4_pv_muxing_atomic_check(struct drm_device *dev,
if (vc4->firmware_kms)
continue;

drm_dbg(dev, "%s: Trying to find a channel.\n", crtc->name);

/* Nothing to do here, let's skip it */
if (old_crtc_state->enable == new_crtc_state->enable)
if (old_crtc_state->enable == new_crtc_state->enable) {
if (new_crtc_state->enable)
drm_dbg(dev, "%s: Already enabled, reusing channel %d.\n",
crtc->name, new_vc4_crtc_state->assigned_channel);
else
drm_dbg(dev, "%s: Disabled, ignoring.\n", crtc->name);

continue;
}

/* Muxing will need to be modified, mark it as such */
new_vc4_crtc_state->update_muxing = true;

/* If we're disabling our CRTC, we put back our channel */
if (!new_crtc_state->enable) {
channel = old_vc4_crtc_state->assigned_channel;

drm_dbg(dev, "%s: Disabling, Freeing channel %d\n",
crtc->name, channel);

hvs_new_state->fifo_state[channel].in_use = false;
new_vc4_crtc_state->assigned_channel = VC4_HVS_CHANNEL_DISABLED;
continue;
Expand Down Expand Up @@ -867,6 +887,8 @@ static int vc4_pv_muxing_atomic_check(struct drm_device *dev,
return -EINVAL;

channel = ffs(matching_channels) - 1;

drm_dbg(dev, "Assigned HVS channel %d to CRTC %s\n", channel, crtc->name);
new_vc4_crtc_state->assigned_channel = channel;
unassigned_channels &= ~BIT(channel);
hvs_new_state->fifo_state[channel].in_use = true;
Expand Down
4 changes: 3 additions & 1 deletion drivers/gpu/drm/vc4/vc4_txp.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,14 @@ static void vc4_txp_connector_atomic_commit(struct drm_connector *conn,
if (WARN_ON(i == ARRAY_SIZE(drm_fmts)))
return;

ctrl = TXP_GO | TXP_VSTART_AT_EOF | TXP_EI |
ctrl = TXP_GO | TXP_EI |
VC4_SET_FIELD(0xf, TXP_BYTE_ENABLE) |
VC4_SET_FIELD(txp_fmts[i], TXP_FORMAT);

if (fb->format->has_alpha)
ctrl |= TXP_ALPHA_ENABLE;
else
ctrl |= TXP_ALPHA_INVERT;

gem = drm_fb_cma_get_gem_obj(fb, 0);
TXP_WRITE(TXP_DST_PTR, gem->paddr + fb->offsets[0]);
Expand Down