Commit cefc3c14 authored by Ben Skeggs's avatar Ben Skeggs Committed by Lyude Paul

drm/nouveau/disp: add acquire_sor/pior()

- preparing to move protocol-specific args out of acquire() again
- avoid re-acquiring acquired output, will matter when enforced later
- sor/pior done at same time due to shared tmds/dp handling
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Acked-by: default avatarDanilo Krummrich <me@dakr.org>
Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230919220442.202488-14-lyude@redhat.com
parent 724e0f3b
...@@ -1034,7 +1034,7 @@ nv50_msto_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *st ...@@ -1034,7 +1034,7 @@ nv50_msto_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *st
return; return;
if (!mstm->links++) { if (!mstm->links++) {
/*XXX: MST audio. */ nvif_outp_acquire_sor(&mstm->outp->outp, false /*TODO: MST audio... */);
nvif_outp_acquire_dp(&mstm->outp->outp, mstm->outp->dp.dpcd, 0, 0, false, true); nvif_outp_acquire_dp(&mstm->outp->outp, mstm->outp->dp.dpcd, 0, 0, false, true);
} }
...@@ -1602,15 +1602,17 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *sta ...@@ -1602,15 +1602,17 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *sta
if ((disp->disp->object.oclass == GT214_DISP || if ((disp->disp->object.oclass == GT214_DISP ||
disp->disp->object.oclass >= GF110_DISP) && disp->disp->object.oclass >= GF110_DISP) &&
nv_encoder->dcb->type != DCB_OUTPUT_LVDS &&
drm_detect_monitor_audio(nv_connector->edid)) drm_detect_monitor_audio(nv_connector->edid))
hda = true; hda = true;
if (!nvif_outp_acquired(outp))
nvif_outp_acquire_sor(outp, hda);
switch (nv_encoder->dcb->type) { switch (nv_encoder->dcb->type) {
case DCB_OUTPUT_TMDS: case DCB_OUTPUT_TMDS:
if (disp->disp->object.oclass == NV50_DISP || if (disp->disp->object.oclass != NV50_DISP &&
!drm_detect_hdmi_monitor(nv_connector->edid)) drm_detect_hdmi_monitor(nv_connector->edid))
nvif_outp_acquire_tmds(outp, nv_crtc->index, false, 0, 0, 0, false);
else
nv50_hdmi_enable(encoder, nv_crtc, nv_connector, state, mode, hda); nv50_hdmi_enable(encoder, nv_crtc, nv_connector, state, mode, hda);
if (nv_encoder->outp.or.link & 1) { if (nv_encoder->outp.or.link & 1) {
...@@ -1850,6 +1852,9 @@ nv50_pior_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *st ...@@ -1850,6 +1852,9 @@ nv50_pior_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *st
default: asyh->or.depth = NV837D_PIOR_SET_CONTROL_PIXEL_DEPTH_DEFAULT; break; default: asyh->or.depth = NV837D_PIOR_SET_CONTROL_PIXEL_DEPTH_DEFAULT; break;
} }
if (!nvif_outp_acquired(&nv_encoder->outp))
nvif_outp_acquire_pior(&nv_encoder->outp);
switch (nv_encoder->dcb->type) { switch (nv_encoder->dcb->type) {
case DCB_OUTPUT_TMDS: case DCB_OUTPUT_TMDS:
ctrl |= NVDEF(NV507D, PIOR_SET_CONTROL, PROTOCOL, EXT_TMDS_ENC); ctrl |= NVDEF(NV507D, PIOR_SET_CONTROL, PROTOCOL, EXT_TMDS_ENC);
......
...@@ -60,7 +60,9 @@ union nvif_outp_acquire_args { ...@@ -60,7 +60,9 @@ union nvif_outp_acquire_args {
struct nvif_outp_acquire_v0 { struct nvif_outp_acquire_v0 {
__u8 version; __u8 version;
#define NVIF_OUTP_ACQUIRE_V0_DAC 0x00 #define NVIF_OUTP_ACQUIRE_V0_DAC 0x00
#define NVIF_OUTP_ACQUIRE_V0_TMDS 0x02 #define NVIF_OUTP_ACQUIRE_V0_SOR 0x01
#define NVIF_OUTP_ACQUIRE_V0_PIOR 0x02
#define NVIF_OUTP_ACQUIRE_V0_TMDS 0x05
#define NVIF_OUTP_ACQUIRE_V0_LVDS 0x03 #define NVIF_OUTP_ACQUIRE_V0_LVDS 0x03
#define NVIF_OUTP_ACQUIRE_V0_DP 0x04 #define NVIF_OUTP_ACQUIRE_V0_DP 0x04
__u8 type; __u8 type;
...@@ -68,6 +70,9 @@ union nvif_outp_acquire_args { ...@@ -68,6 +70,9 @@ union nvif_outp_acquire_args {
__u8 link; __u8 link;
__u8 pad04[4]; __u8 pad04[4];
union { union {
struct {
__u8 hda;
} sor;
struct { struct {
__u8 head; __u8 head;
__u8 hdmi; __u8 hdmi;
......
...@@ -29,6 +29,8 @@ int nvif_outp_edid_get(struct nvif_outp *, u8 **pedid); ...@@ -29,6 +29,8 @@ int nvif_outp_edid_get(struct nvif_outp *, u8 **pedid);
int nvif_outp_load_detect(struct nvif_outp *, u32 loadval); int nvif_outp_load_detect(struct nvif_outp *, u32 loadval);
int nvif_outp_acquire_dac(struct nvif_outp *); int nvif_outp_acquire_dac(struct nvif_outp *);
int nvif_outp_acquire_sor(struct nvif_outp *, bool hda);
int nvif_outp_acquire_pior(struct nvif_outp *);
int nvif_outp_acquire_tmds(struct nvif_outp *, int head, int nvif_outp_acquire_tmds(struct nvif_outp *, int head,
bool hdmi, u8 max_ac_packet, u8 rekey, u8 scdc, bool hda); bool hdmi, u8 max_ac_packet, u8 rekey, u8 scdc, bool hda);
int nvif_outp_acquire_lvds(struct nvif_outp *, bool dual, bool bpc8); int nvif_outp_acquire_lvds(struct nvif_outp *, bool dual, bool bpc8);
......
...@@ -187,6 +187,30 @@ nvif_outp_acquire(struct nvif_outp *outp, u8 type, struct nvif_outp_acquire_v0 * ...@@ -187,6 +187,30 @@ nvif_outp_acquire(struct nvif_outp *outp, u8 type, struct nvif_outp_acquire_v0 *
return 0; return 0;
} }
int
nvif_outp_acquire_pior(struct nvif_outp *outp)
{
struct nvif_outp_acquire_v0 args;
int ret;
ret = nvif_outp_acquire(outp, NVIF_OUTP_ACQUIRE_V0_PIOR, &args);
NVIF_ERRON(ret, &outp->object, "[ACQUIRE PIOR] or:%d", args.or);
return ret;
}
int
nvif_outp_acquire_sor(struct nvif_outp *outp, bool hda)
{
struct nvif_outp_acquire_v0 args;
int ret;
args.sor.hda = hda;
ret = nvif_outp_acquire(outp, NVIF_OUTP_ACQUIRE_V0_SOR, &args);
NVIF_ERRON(ret, &outp->object, "[ACQUIRE SOR] or:%d link:%d", args.or, args.link);
return ret;
}
int int
nvif_outp_acquire_dac(struct nvif_outp *outp) nvif_outp_acquire_dac(struct nvif_outp *outp)
{ {
......
...@@ -61,12 +61,6 @@ static int ...@@ -61,12 +61,6 @@ static int
nvkm_uoutp_mthd_acquire_dp(struct nvkm_outp *outp, u8 dpcd[DP_RECEIVER_CAP_SIZE], nvkm_uoutp_mthd_acquire_dp(struct nvkm_outp *outp, u8 dpcd[DP_RECEIVER_CAP_SIZE],
u8 link_nr, u8 link_bw, bool hda, bool mst) u8 link_nr, u8 link_bw, bool hda, bool mst)
{ {
int ret;
ret = nvkm_outp_acquire_or(outp, NVKM_OUTP_USER, hda);
if (ret)
return ret;
memcpy(outp->dp.dpcd, dpcd, sizeof(outp->dp.dpcd)); memcpy(outp->dp.dpcd, dpcd, sizeof(outp->dp.dpcd));
outp->dp.lt.nr = link_nr; outp->dp.lt.nr = link_nr;
outp->dp.lt.bw = link_bw; outp->dp.lt.bw = link_bw;
...@@ -146,25 +140,16 @@ static int ...@@ -146,25 +140,16 @@ static int
nvkm_uoutp_mthd_acquire_tmds(struct nvkm_outp *outp, u8 head, u8 hdmi, u8 hdmi_max_ac_packet, nvkm_uoutp_mthd_acquire_tmds(struct nvkm_outp *outp, u8 head, u8 hdmi, u8 hdmi_max_ac_packet,
u8 hdmi_rekey, u8 hdmi_scdc, u8 hdmi_hda) u8 hdmi_rekey, u8 hdmi_scdc, u8 hdmi_hda)
{ {
struct nvkm_ior *ior; struct nvkm_ior *ior = outp->ior;
int ret;
if (!(outp->asy.head = nvkm_head_find(outp->disp, head))) if (!(outp->asy.head = nvkm_head_find(outp->disp, head)))
return -EINVAL; return -EINVAL;
ret = nvkm_outp_acquire_or(outp, NVKM_OUTP_USER, hdmi && hdmi_hda);
if (ret)
return ret;
ior = outp->ior;
if (hdmi) { if (hdmi) {
if (!ior->func->hdmi || if (!ior->func->hdmi ||
hdmi_max_ac_packet > 0x1f || hdmi_rekey > 0x7f || hdmi_max_ac_packet > 0x1f || hdmi_rekey > 0x7f ||
(hdmi_scdc && !ior->func->hdmi->scdc)) { (hdmi_scdc && !ior->func->hdmi->scdc))
nvkm_outp_release_or(outp, NVKM_OUTP_USER);
return -EINVAL; return -EINVAL;
}
ior->func->hdmi->ctrl(ior, head, hdmi, hdmi_max_ac_packet, hdmi_rekey); ior->func->hdmi->ctrl(ior, head, hdmi, hdmi_max_ac_packet, hdmi_rekey);
if (ior->func->hdmi->scdc) if (ior->func->hdmi->scdc)
...@@ -182,8 +167,7 @@ nvkm_uoutp_mthd_acquire_lvds(struct nvkm_outp *outp, bool dual, bool bpc8) ...@@ -182,8 +167,7 @@ nvkm_uoutp_mthd_acquire_lvds(struct nvkm_outp *outp, bool dual, bool bpc8)
outp->lvds.dual = dual; outp->lvds.dual = dual;
outp->lvds.bpc8 = bpc8; outp->lvds.bpc8 = bpc8;
return 0;
return nvkm_outp_acquire_or(outp, NVKM_OUTP_USER, false);
} }
static int static int
...@@ -214,13 +198,17 @@ nvkm_uoutp_mthd_acquire(struct nvkm_outp *outp, void *argv, u32 argc) ...@@ -214,13 +198,17 @@ nvkm_uoutp_mthd_acquire(struct nvkm_outp *outp, void *argv, u32 argc)
if (argc != sizeof(args->v0) || args->v0.version != 0) if (argc != sizeof(args->v0) || args->v0.version != 0)
return -ENOSYS; return -ENOSYS;
if (outp->ior) if (outp->ior && args->v0.type <= NVIF_OUTP_ACQUIRE_V0_PIOR)
return -EBUSY; return -EBUSY;
switch (args->v0.type) { switch (args->v0.type) {
case NVIF_OUTP_ACQUIRE_V0_DAC: case NVIF_OUTP_ACQUIRE_V0_DAC:
case NVIF_OUTP_ACQUIRE_V0_PIOR:
ret = nvkm_outp_acquire_or(outp, NVKM_OUTP_USER, false); ret = nvkm_outp_acquire_or(outp, NVKM_OUTP_USER, false);
break; break;
case NVIF_OUTP_ACQUIRE_V0_SOR:
ret = nvkm_outp_acquire_or(outp, NVKM_OUTP_USER, args->v0.sor.hda);
break;
case NVIF_OUTP_ACQUIRE_V0_TMDS: case NVIF_OUTP_ACQUIRE_V0_TMDS:
ret = nvkm_uoutp_mthd_acquire_tmds(outp, args->v0.tmds.head, ret = nvkm_uoutp_mthd_acquire_tmds(outp, args->v0.tmds.head,
args->v0.tmds.hdmi, args->v0.tmds.hdmi,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment