Skip to content

Commit 1b255f1

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/disp: add output class
Will be used to more cleanly implement existing method interfaces that take some confusing (IEDTkey, inherited from VBIOS, which RM no longer uses on Ampere) match values to determine which display path to operate on. Methods will be protected from racing with supervisor, and from being called where they shouldn't be (ie. without an OR assigned). v2: - use ?: (lyude) v3: - fix return code if noacquire() method fails Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent a6fd8f9 commit 1b255f1

17 files changed

Lines changed: 221 additions & 6 deletions

File tree

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,10 @@ nv50_dac_help = {
563563
static void
564564
nv50_dac_destroy(struct drm_encoder *encoder)
565565
{
566+
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
567+
568+
nvif_outp_dtor(&nv_encoder->outp);
569+
566570
drm_encoder_cleanup(encoder);
567571
kfree(encoder);
568572
}
@@ -576,6 +580,7 @@ static int
576580
nv50_dac_create(struct drm_connector *connector, struct dcb_output *dcbe)
577581
{
578582
struct nouveau_drm *drm = nouveau_drm(connector->dev);
583+
struct nv50_disp *disp = nv50_disp(connector->dev);
579584
struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
580585
struct nvkm_i2c_bus *bus;
581586
struct nouveau_encoder *nv_encoder;
@@ -599,7 +604,7 @@ nv50_dac_create(struct drm_connector *connector, struct dcb_output *dcbe)
599604
drm_encoder_helper_add(encoder, &nv50_dac_help);
600605

601606
drm_connector_attach_encoder(connector, encoder);
602-
return 0;
607+
return nvif_outp_ctor(disp->disp, nv_encoder->base.base.name, dcbe->id, &nv_encoder->outp);
603608
}
604609

605610
/*
@@ -1822,6 +1827,9 @@ static void
18221827
nv50_sor_destroy(struct drm_encoder *encoder)
18231828
{
18241829
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1830+
1831+
nvif_outp_dtor(&nv_encoder->outp);
1832+
18251833
nv50_mstm_del(&nv_encoder->dp.mstm);
18261834
drm_encoder_cleanup(encoder);
18271835

@@ -1918,7 +1926,7 @@ nv50_sor_create(struct drm_connector *connector, struct dcb_output *dcbe)
19181926
nv_encoder->i2c = &bus->i2c;
19191927
}
19201928

1921-
return 0;
1929+
return nvif_outp_ctor(disp->disp, nv_encoder->base.base.name, dcbe->id, &nv_encoder->outp);
19221930
}
19231931

19241932
/******************************************************************************
@@ -1999,6 +2007,10 @@ nv50_pior_help = {
19992007
static void
20002008
nv50_pior_destroy(struct drm_encoder *encoder)
20012009
{
2010+
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
2011+
2012+
nvif_outp_dtor(&nv_encoder->outp);
2013+
20022014
drm_encoder_cleanup(encoder);
20032015
kfree(encoder);
20042016
}
@@ -2056,7 +2068,7 @@ nv50_pior_create(struct drm_connector *connector, struct dcb_output *dcbe)
20562068
disp->core->func->pior->get_caps(disp, nv_encoder, ffs(dcbe->or) - 1);
20572069
nv50_outp_dump_caps(drm, nv_encoder);
20582070

2059-
return 0;
2071+
return nvif_outp_ctor(disp->disp, nv_encoder->base.base.name, dcbe->id, &nv_encoder->outp);
20602072
}
20612073

20622074
/******************************************************************************

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#define NVIF_CLASS_DISP /* if0010.h */ 0x80000010
3636
#define NVIF_CLASS_CONN /* if0011.h */ 0x80000011
37+
#define NVIF_CLASS_OUTP /* if0012.h */ 0x80000012
3738
#define NVIF_CLASS_DISP_CHAN /* if0014.h */ 0x80000014
3839

3940
/* the below match nvidia-assigned (either in hw, or sw) class numbers */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ struct nvif_device;
66
struct nvif_disp {
77
struct nvif_object object;
88
unsigned long conn_mask;
9+
unsigned long outp_mask;
910
};
1011

1112
int nvif_disp_ctor(struct nvif_device *, const char *name, s32 oclass,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ union nvif_disp_args {
77
__u8 version;
88
__u8 pad01[3];
99
__u32 conn_mask;
10+
__u32 outp_mask;
1011
} v0;
1112
};
1213
#endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* SPDX-License-Identifier: MIT */
2+
#ifndef __NVIF_IF0012_H__
3+
#define __NVIF_IF0012_H__
4+
5+
union nvif_outp_args {
6+
struct nvif_outp_v0 {
7+
__u8 version;
8+
__u8 id; /* DCB device index. */
9+
__u8 pad02[6];
10+
} v0;
11+
};
12+
#endif
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: MIT */
2+
#ifndef __NVIF_OUTP_H__
3+
#define __NVIF_OUTP_H__
4+
#include <nvif/object.h>
5+
struct nvif_disp;
6+
7+
struct nvif_outp {
8+
struct nvif_object object;
9+
};
10+
11+
int nvif_outp_ctor(struct nvif_disp *, const char *name, int id, struct nvif_outp *);
12+
void nvif_outp_dtor(struct nvif_outp *);
13+
#endif

drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/dcb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct dcb_output {
5454
} tmdsconf;
5555
};
5656
bool i2c_upper_default;
57+
int id;
5758
};
5859

5960
u16 dcb_table(struct nvkm_bios *, u8 *ver, u8 *hdr, u8 *ent, u8 *len);

drivers/gpu/drm/nouveau/nouveau_bios.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,8 @@ parse_dcb_entry(struct drm_device *dev, void *data, int idx, u8 *outp)
18011801
ret = parse_dcb20_entry(dev, dcb, conn, conf, entry);
18021802
else
18031803
ret = parse_dcb15_entry(dev, dcb, conn, conf, entry);
1804+
entry->id = idx;
1805+
18041806
if (!ret)
18051807
return 1; /* stop parsing */
18061808

drivers/gpu/drm/nouveau/nouveau_encoder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#ifndef __NOUVEAU_ENCODER_H__
2828
#define __NOUVEAU_ENCODER_H__
29-
29+
#include <nvif/outp.h>
3030
#include <subdev/bios/dcb.h>
3131

3232
#include <drm/display/drm_dp_helper.h>
@@ -46,6 +46,7 @@ struct nouveau_encoder {
4646
struct drm_encoder_slave base;
4747

4848
struct dcb_output *dcb;
49+
struct nvif_outp outp;
4950
int or;
5051
int link;
5152

drivers/gpu/drm/nouveau/nvif/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ nvif-y += nvif/fifo.o
99
nvif-y += nvif/mem.o
1010
nvif-y += nvif/mmu.o
1111
nvif-y += nvif/notify.o
12+
nvif-y += nvif/outp.o
1213
nvif-y += nvif/timer.o
1314
nvif-y += nvif/vmm.o
1415

0 commit comments

Comments
 (0)