Skip to content

Commit dfc4005

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/disp: move DAC load detection method
Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Reviewed-by: Lyude Paul <lyude@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 1b255f1 commit dfc4005

7 files changed

Lines changed: 57 additions & 44 deletions

File tree

drivers/gpu/drm/nouveau/dispnv50/disp.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -529,24 +529,15 @@ static enum drm_connector_status
529529
nv50_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector)
530530
{
531531
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
532-
struct nv50_disp *disp = nv50_disp(encoder->dev);
533-
struct {
534-
struct nv50_disp_mthd_v1 base;
535-
struct nv50_disp_dac_load_v0 load;
536-
} args = {
537-
.base.version = 1,
538-
.base.method = NV50_DISP_MTHD_V1_DAC_LOAD,
539-
.base.hasht = nv_encoder->dcb->hasht,
540-
.base.hashm = nv_encoder->dcb->hashm,
541-
};
532+
u32 loadval;
542533
int ret;
543534

544-
args.load.data = nouveau_drm(encoder->dev)->vbios.dactestval;
545-
if (args.load.data == 0)
546-
args.load.data = 340;
535+
loadval = nouveau_drm(encoder->dev)->vbios.dactestval;
536+
if (loadval == 0)
537+
loadval = 340;
547538

548-
ret = nvif_mthd(&disp->disp->object, 0, &args, sizeof(args));
549-
if (ret || !args.load.load)
539+
ret = nvif_outp_load_detect(&nv_encoder->outp, loadval);
540+
if (ret <= 0)
550541
return connector_status_disconnected;
551542

552543
return connector_status_connected;

drivers/gpu/drm/nouveau/include/nvif/cl5070.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ struct nv50_disp_mthd_v1 {
3030
__u8 version;
3131
#define NV50_DISP_MTHD_V1_ACQUIRE 0x01
3232
#define NV50_DISP_MTHD_V1_RELEASE 0x02
33-
#define NV50_DISP_MTHD_V1_DAC_LOAD 0x11
3433
#define NV50_DISP_MTHD_V1_SOR_HDA_ELD 0x21
3534
#define NV50_DISP_MTHD_V1_SOR_HDMI_PWR 0x22
3635
#define NV50_DISP_MTHD_V1_SOR_LVDS_SCRIPT 0x23
@@ -50,13 +49,6 @@ struct nv50_disp_acquire_v0 {
5049
__u8 pad04[4];
5150
};
5251

53-
struct nv50_disp_dac_load_v0 {
54-
__u8 version;
55-
__u8 load;
56-
__u8 pad02[2];
57-
__u32 data;
58-
};
59-
6052
struct nv50_disp_sor_hda_eld_v0 {
6153
__u8 version;
6254
__u8 pad01[7];

drivers/gpu/drm/nouveau/include/nvif/if0012.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,15 @@ union nvif_outp_args {
99
__u8 pad02[6];
1010
} v0;
1111
};
12+
13+
#define NVIF_OUTP_V0_LOAD_DETECT 0x00
14+
15+
union nvif_outp_load_detect_args {
16+
struct nvif_outp_load_detect_v0 {
17+
__u8 version;
18+
__u8 load;
19+
__u8 pad02[2];
20+
__u32 data; /*TODO: move vbios loadval parsing into nvkm */
21+
} v0;
22+
};
1223
#endif

drivers/gpu/drm/nouveau/include/nvif/outp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ struct nvif_outp {
1010

1111
int nvif_outp_ctor(struct nvif_disp *, const char *name, int id, struct nvif_outp *);
1212
void nvif_outp_dtor(struct nvif_outp *);
13+
int nvif_outp_load_detect(struct nvif_outp *, u32 loadval);
1314
#endif

drivers/gpu/drm/nouveau/nvif/outp.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@
2626
#include <nvif/class.h>
2727
#include <nvif/if0012.h>
2828

29+
int
30+
nvif_outp_load_detect(struct nvif_outp *outp, u32 loadval)
31+
{
32+
struct nvif_outp_load_detect_v0 args;
33+
int ret;
34+
35+
args.version = 0;
36+
args.data = loadval;
37+
38+
ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_LOAD_DETECT, &args, sizeof(args));
39+
NVIF_ERRON(ret, &outp->object, "[LOAD_DETECT data:%08x] load:%02x", args.data, args.load);
40+
return ret < 0 ? ret : args.load;
41+
}
42+
2943
void
3044
nvif_outp_dtor(struct nvif_outp *outp)
3145
{

drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,27 +109,6 @@ nv50_disp_root_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
109109
case NV50_DISP_MTHD_V1_RELEASE:
110110
nvkm_outp_release(outp, NVKM_OUTP_USER);
111111
return 0;
112-
case NV50_DISP_MTHD_V1_DAC_LOAD: {
113-
union {
114-
struct nv50_disp_dac_load_v0 v0;
115-
} *args = data;
116-
int ret = -ENOSYS;
117-
if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
118-
if (args->v0.data & 0xfff00000)
119-
return -EINVAL;
120-
ret = nvkm_outp_acquire(outp, NVKM_OUTP_PRIV, false);
121-
if (ret)
122-
return ret;
123-
ret = outp->ior->func->sense(outp->ior, args->v0.data);
124-
nvkm_outp_release(outp, NVKM_OUTP_PRIV);
125-
if (ret < 0)
126-
return ret;
127-
args->v0.load = ret;
128-
return 0;
129-
} else
130-
return ret;
131-
}
132-
break;
133112
case NV50_DISP_MTHD_V1_SOR_HDA_ELD: {
134113
union {
135114
struct nv50_disp_sor_hda_eld_v0 v0;

drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,38 @@
2121
*/
2222
#define nvkm_uoutp(p) container_of((p), struct nvkm_outp, object)
2323
#include "outp.h"
24+
#include "ior.h"
2425

2526
#include <nvif/if0012.h>
2627

28+
static int
29+
nvkm_uoutp_mthd_load_detect(struct nvkm_outp *outp, void *argv, u32 argc)
30+
{
31+
union nvif_outp_load_detect_args *args = argv;
32+
int ret;
33+
34+
if (argc != sizeof(args->v0) || args->v0.version != 0)
35+
return -ENOSYS;
36+
37+
ret = nvkm_outp_acquire(outp, NVKM_OUTP_PRIV, false);
38+
if (ret == 0) {
39+
if (outp->ior->func->sense) {
40+
ret = outp->ior->func->sense(outp->ior, args->v0.data);
41+
args->v0.load = ret < 0 ? 0 : ret;
42+
} else {
43+
ret = -EINVAL;
44+
}
45+
nvkm_outp_release(outp, NVKM_OUTP_PRIV);
46+
}
47+
48+
return ret;
49+
}
50+
2751
static int
2852
nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
2953
{
3054
switch (mthd) {
55+
case NVIF_OUTP_V0_LOAD_DETECT: return nvkm_uoutp_mthd_load_detect(outp, argv, argc);
3156
default:
3257
break;
3358
}

0 commit comments

Comments
 (0)