Skip to content

Commit cbced93

Browse files
Timur Kristófalexdeucher
authored andcommitted
drm/amd/display: Set CRTC source for DAC using registers
Apparently the VBIOS SelectCRTC_Source function overwrites a few registers (such as FMT_*) which DC writes in a different place, which can cause problems. Instead of using the SelectCRTC_Source function from the VBIOS, use the DAC_SOURCE_SELECT register directly, similarly to how it is done for digital link encoders. Fixes: 3be26d8 ("drm/amd/display: Support DAC in dce110_hwseq") Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Tested-by: Mauro Rossi <issor.oruam@gmail.com> Reviewed-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent e2a0243 commit cbced93

6 files changed

Lines changed: 43 additions & 37 deletions

File tree

drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,10 @@ static void dig_connect_to_otg(
14981498
{
14991499
struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
15001500

1501-
REG_UPDATE(DIG_FE_CNTL, DIG_SOURCE_SELECT, tg_inst);
1501+
if (enc->id == ENGINE_ID_DACA || enc->id == ENGINE_ID_DACB)
1502+
REG_UPDATE(DAC_SOURCE_SELECT, DAC_SOURCE_SELECT, tg_inst);
1503+
else
1504+
REG_UPDATE(DIG_FE_CNTL, DIG_SOURCE_SELECT, tg_inst);
15021505
}
15031506

15041507
static unsigned int dig_source_otg(
@@ -1507,7 +1510,10 @@ static unsigned int dig_source_otg(
15071510
uint32_t tg_inst = 0;
15081511
struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
15091512

1510-
REG_GET(DIG_FE_CNTL, DIG_SOURCE_SELECT, &tg_inst);
1513+
if (enc->id == ENGINE_ID_DACA || enc->id == ENGINE_ID_DACB)
1514+
REG_GET(DAC_SOURCE_SELECT, DAC_SOURCE_SELECT, &tg_inst);
1515+
else
1516+
REG_GET(DIG_FE_CNTL, DIG_SOURCE_SELECT, &tg_inst);
15111517

15121518
return tg_inst;
15131519
}
@@ -1568,16 +1574,25 @@ void dce110_stream_encoder_construct(
15681574
enc110->se_mask = se_mask;
15691575
}
15701576

1571-
static const struct stream_encoder_funcs dce110_an_str_enc_funcs = {};
1577+
static const struct stream_encoder_funcs dce110_an_str_enc_funcs = {
1578+
.dig_connect_to_otg = dig_connect_to_otg,
1579+
.dig_source_otg = dig_source_otg,
1580+
};
15721581

15731582
void dce110_analog_stream_encoder_construct(
15741583
struct dce110_stream_encoder *enc110,
15751584
struct dc_context *ctx,
15761585
struct dc_bios *bp,
1577-
enum engine_id eng_id)
1586+
enum engine_id eng_id,
1587+
const struct dce110_stream_enc_registers *regs,
1588+
const struct dce_stream_encoder_shift *se_shift,
1589+
const struct dce_stream_encoder_mask *se_mask)
15781590
{
15791591
enc110->base.funcs = &dce110_an_str_enc_funcs;
15801592
enc110->base.ctx = ctx;
15811593
enc110->base.id = eng_id;
15821594
enc110->base.bp = bp;
1595+
enc110->regs = regs;
1596+
enc110->se_shift = se_shift;
1597+
enc110->se_mask = se_mask;
15831598
}

drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
SRI(AFMT_60958_1, DIG, id), \
6666
SRI(AFMT_60958_2, DIG, id), \
6767
SRI(DIG_FE_CNTL, DIG, id), \
68+
SR(DAC_SOURCE_SELECT), \
6869
SRI(HDMI_CONTROL, DIG, id), \
6970
SRI(HDMI_GC, DIG, id), \
7071
SRI(HDMI_GENERIC_PACKET_CONTROL0, DIG, id), \
@@ -290,7 +291,8 @@
290291
#define SE_COMMON_MASK_SH_LIST_DCE80_100(mask_sh)\
291292
SE_COMMON_MASK_SH_LIST_DCE_COMMON(mask_sh),\
292293
SE_SF(TMDS_CNTL, TMDS_PIXEL_ENCODING, mask_sh),\
293-
SE_SF(TMDS_CNTL, TMDS_COLOR_FORMAT, mask_sh)
294+
SE_SF(TMDS_CNTL, TMDS_COLOR_FORMAT, mask_sh),\
295+
SE_SF(DAC_SOURCE_SELECT, DAC_SOURCE_SELECT, mask_sh)
294296

295297
#define SE_COMMON_MASK_SH_LIST_DCE110(mask_sh)\
296298
SE_COMMON_MASK_SH_LIST_DCE_COMMON(mask_sh),\
@@ -494,6 +496,7 @@ struct dce_stream_encoder_shift {
494496
uint8_t DP_VID_N_MUL;
495497
uint8_t DP_VID_M_DOUBLE_VALUE_EN;
496498
uint8_t DIG_SOURCE_SELECT;
499+
uint8_t DAC_SOURCE_SELECT;
497500
};
498501

499502
struct dce_stream_encoder_mask {
@@ -626,6 +629,7 @@ struct dce_stream_encoder_mask {
626629
uint32_t DP_VID_N_MUL;
627630
uint32_t DP_VID_M_DOUBLE_VALUE_EN;
628631
uint32_t DIG_SOURCE_SELECT;
632+
uint32_t DAC_SOURCE_SELECT;
629633
};
630634

631635
struct dce110_stream_enc_registers {
@@ -653,6 +657,7 @@ struct dce110_stream_enc_registers {
653657
uint32_t AFMT_60958_1;
654658
uint32_t AFMT_60958_2;
655659
uint32_t DIG_FE_CNTL;
660+
uint32_t DAC_SOURCE_SELECT;
656661
uint32_t DP_MSE_RATE_CNTL;
657662
uint32_t DP_MSE_RATE_UPDATE;
658663
uint32_t DP_PIXEL_FORMAT;
@@ -712,7 +717,10 @@ void dce110_analog_stream_encoder_construct(
712717
struct dce110_stream_encoder *enc110,
713718
struct dc_context *ctx,
714719
struct dc_bios *bp,
715-
enum engine_id eng_id);
720+
enum engine_id eng_id,
721+
const struct dce110_stream_enc_registers *regs,
722+
const struct dce_stream_encoder_shift *se_shift,
723+
const struct dce_stream_encoder_mask *se_mask);
716724

717725
void dce110_se_audio_mute_control(
718726
struct stream_encoder *enc, bool mute);

drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,25 +1581,6 @@ static enum dc_status dce110_enable_stream_timing(
15811581
return DC_OK;
15821582
}
15831583

1584-
static void
1585-
dce110_select_crtc_source(struct pipe_ctx *pipe_ctx)
1586-
{
1587-
struct dc_link *link = pipe_ctx->stream->link;
1588-
struct dc_bios *bios = link->ctx->dc_bios;
1589-
struct bp_crtc_source_select crtc_source_select = {0};
1590-
enum engine_id engine_id = link->link_enc->preferred_engine;
1591-
1592-
if (dc_is_rgb_signal(pipe_ctx->stream->signal))
1593-
engine_id = link->link_enc->analog_engine;
1594-
1595-
crtc_source_select.controller_id = CONTROLLER_ID_D0 + pipe_ctx->stream_res.tg->inst;
1596-
crtc_source_select.color_depth = pipe_ctx->stream->timing.display_color_depth;
1597-
crtc_source_select.engine_id = engine_id;
1598-
crtc_source_select.sink_signal = pipe_ctx->stream->signal;
1599-
1600-
bios->funcs->select_crtc_source(bios, &crtc_source_select);
1601-
}
1602-
16031584
enum dc_status dce110_apply_single_controller_ctx_to_hw(
16041585
struct pipe_ctx *pipe_ctx,
16051586
struct dc_state *context,
@@ -1619,10 +1600,6 @@ enum dc_status dce110_apply_single_controller_ctx_to_hw(
16191600
hws->funcs.disable_stream_gating(dc, pipe_ctx);
16201601
}
16211602

1622-
if (pipe_ctx->stream->signal == SIGNAL_TYPE_RGB) {
1623-
dce110_select_crtc_source(pipe_ctx);
1624-
}
1625-
16261603
if (pipe_ctx->stream_res.audio != NULL) {
16271604
struct audio_output audio_output = {0};
16281605

@@ -1702,8 +1679,7 @@ enum dc_status dce110_apply_single_controller_ctx_to_hw(
17021679
pipe_ctx->stream_res.tg->funcs->set_static_screen_control(
17031680
pipe_ctx->stream_res.tg, event_triggers, 2);
17041681

1705-
if (!dc_is_virtual_signal(pipe_ctx->stream->signal) &&
1706-
!dc_is_rgb_signal(pipe_ctx->stream->signal))
1682+
if (!dc_is_virtual_signal(pipe_ctx->stream->signal))
17071683
pipe_ctx->stream_res.stream_enc->funcs->dig_connect_to_otg(
17081684
pipe_ctx->stream_res.stream_enc,
17091685
pipe_ctx->stream_res.tg->inst);

drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ static const struct dce110_stream_enc_registers stream_enc_regs[] = {
242242
stream_enc_regs(3),
243243
stream_enc_regs(4),
244244
stream_enc_regs(5),
245-
stream_enc_regs(6)
245+
stream_enc_regs(6),
246+
{SR(DAC_SOURCE_SELECT),} /* DACA */
246247
};
247248

248249
static const struct dce_stream_encoder_shift se_shift = {
@@ -491,7 +492,8 @@ static struct stream_encoder *dce100_stream_encoder_create(
491492
return NULL;
492493

493494
if (eng_id == ENGINE_ID_DACA || eng_id == ENGINE_ID_DACB) {
494-
dce110_analog_stream_encoder_construct(enc110, ctx, ctx->dc_bios, eng_id);
495+
dce110_analog_stream_encoder_construct(enc110, ctx, ctx->dc_bios, eng_id,
496+
&stream_enc_regs[eng_id], &se_shift, &se_mask);
495497
return &enc110->base;
496498
}
497499

drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ static const struct dce110_stream_enc_registers stream_enc_regs[] = {
258258
stream_enc_regs(2),
259259
stream_enc_regs(3),
260260
stream_enc_regs(4),
261-
stream_enc_regs(5)
261+
stream_enc_regs(5),
262+
{0},
263+
{SR(DAC_SOURCE_SELECT),} /* DACA */
262264
};
263265

264266
static const struct dce_stream_encoder_shift se_shift = {
@@ -607,7 +609,8 @@ static struct stream_encoder *dce60_stream_encoder_create(
607609
return NULL;
608610

609611
if (eng_id == ENGINE_ID_DACA || eng_id == ENGINE_ID_DACB) {
610-
dce110_analog_stream_encoder_construct(enc110, ctx, ctx->dc_bios, eng_id);
612+
dce110_analog_stream_encoder_construct(enc110, ctx, ctx->dc_bios, eng_id,
613+
&stream_enc_regs[eng_id], &se_shift, &se_mask);
611614
return &enc110->base;
612615
}
613616

drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ static const struct dce110_stream_enc_registers stream_enc_regs[] = {
258258
stream_enc_regs(3),
259259
stream_enc_regs(4),
260260
stream_enc_regs(5),
261-
stream_enc_regs(6)
261+
stream_enc_regs(6),
262+
{SR(DAC_SOURCE_SELECT),} /* DACA */
262263
};
263264

264265
static const struct dce_stream_encoder_shift se_shift = {
@@ -614,7 +615,8 @@ static struct stream_encoder *dce80_stream_encoder_create(
614615
return NULL;
615616

616617
if (eng_id == ENGINE_ID_DACA || eng_id == ENGINE_ID_DACB) {
617-
dce110_analog_stream_encoder_construct(enc110, ctx, ctx->dc_bios, eng_id);
618+
dce110_analog_stream_encoder_construct(enc110, ctx, ctx->dc_bios, eng_id,
619+
&stream_enc_regs[eng_id], &se_shift, &se_mask);
618620
return &enc110->base;
619621
}
620622

0 commit comments

Comments
 (0)