Commit 79c453af authored by Ben Skeggs's avatar Ben Skeggs Committed by Dave Airlie

drm/nouveau/disp: replace hda func pointer check with flag

Simpler, and less error-prone than a separate set of function pointers.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 1c6aab75
......@@ -109,7 +109,7 @@ g84_sor = {
int
g84_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&g84_sor, disp, SOR, id);
return nvkm_ior_new_(&g84_sor, disp, SOR, id, false);
}
static const struct nvkm_disp_mthd_list
......
......@@ -298,7 +298,7 @@ g94_sor = {
static int
g94_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&g94_sor, disp, SOR, id);
return nvkm_ior_new_(&g94_sor, disp, SOR, id, false);
}
int
......
......@@ -84,7 +84,7 @@ ga102_sor_clock(struct nvkm_ior *sor)
}
static const struct nvkm_ior_func
ga102_sor_hda = {
ga102_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
......@@ -114,40 +114,13 @@ ga102_sor_hda = {
},
};
static const struct nvkm_ior_func
ga102_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
},
.state = gv100_sor_state,
.power = nv50_sor_power,
.clock = ga102_sor_clock,
.hdmi = {
.ctrl = gv100_sor_hdmi_ctrl,
.scdc = gm200_sor_hdmi_scdc,
},
.dp = {
.lanes = { 0, 1, 2, 3 },
.links = ga102_sor_dp_links,
.power = g94_sor_dp_power,
.pattern = gm107_sor_dp_pattern,
.drive = gm200_sor_dp_drive,
.vcpi = tu102_sor_dp_vcpi,
.audio = gv100_sor_dp_audio,
.audio_sym = gv100_sor_dp_audio_sym,
.watermark = gv100_sor_dp_watermark,
},
};
static int
ga102_sor_new(struct nvkm_disp *disp, int id)
{
struct nvkm_device *device = disp->engine.subdev.device;
u32 hda = nvkm_rd32(device, 0x08a15c);
if (hda & BIT(id))
return nvkm_ior_new_(&ga102_sor_hda, disp, SOR, id);
return nvkm_ior_new_(&ga102_sor, disp, SOR, id);
return nvkm_ior_new_(&ga102_sor, disp, SOR, id, hda & BIT(id));
}
static const struct nvkm_disp_func
......
......@@ -309,7 +309,7 @@ gf119_sor = {
static int
gf119_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&gf119_sor, disp, SOR, id);
return nvkm_ior_new_(&gf119_sor, disp, SOR, id, true);
}
int
......@@ -357,7 +357,7 @@ gf119_dac = {
int
gf119_dac_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&gf119_dac, disp, DAC, id);
return nvkm_ior_new_(&gf119_dac, disp, DAC, id, false);
}
int
......
......@@ -116,7 +116,7 @@ gk104_sor = {
int
gk104_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&gk104_sor, disp, SOR, id);
return nvkm_ior_new_(&gk104_sor, disp, SOR, id, true);
}
static const struct nvkm_disp_mthd_list
......
......@@ -81,7 +81,7 @@ gm107_sor = {
static int
gm107_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&gm107_sor, disp, SOR, id);
return nvkm_ior_new_(&gm107_sor, disp, SOR, id, true);
}
static const struct nvkm_disp_func
......
......@@ -110,7 +110,7 @@ gm200_sor_route_get(struct nvkm_outp *outp, int *link)
}
static const struct nvkm_ior_func
gm200_sor_hda = {
gm200_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
......@@ -140,32 +140,6 @@ gm200_sor_hda = {
},
};
static const struct nvkm_ior_func
gm200_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
},
.state = gf119_sor_state,
.power = nv50_sor_power,
.clock = gf119_sor_clock,
.hdmi = {
.ctrl = gk104_sor_hdmi_ctrl,
.scdc = gm200_sor_hdmi_scdc,
},
.dp = {
.lanes = { 0, 1, 2, 3 },
.links = gf119_sor_dp_links,
.power = g94_sor_dp_power,
.pattern = gm107_sor_dp_pattern,
.drive = gm200_sor_dp_drive,
.vcpi = gf119_sor_dp_vcpi,
.audio = gf119_sor_dp_audio,
.audio_sym = gf119_sor_dp_audio_sym,
.watermark = gf119_sor_dp_watermark,
},
};
static int
gm200_sor_new(struct nvkm_disp *disp, int id)
{
......@@ -175,10 +149,7 @@ gm200_sor_new(struct nvkm_disp *disp, int id)
if (!((hda = nvkm_rd32(device, 0x08a15c)) & 0x40000000))
hda = nvkm_rd32(device, 0x101034);
if (hda & BIT(id))
return nvkm_ior_new_(&gm200_sor_hda, disp, SOR, id);
return nvkm_ior_new_(&gm200_sor, disp, SOR, id);
return nvkm_ior_new_(&gm200_sor, disp, SOR, id, hda & BIT(id));
}
static const struct nvkm_disp_func
......
......@@ -29,7 +29,7 @@
#include <nvif/class.h>
static const struct nvkm_ior_func
gp100_sor_hda = {
gp100_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
......@@ -59,32 +59,6 @@ gp100_sor_hda = {
},
};
static const struct nvkm_ior_func
gp100_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
},
.state = gf119_sor_state,
.power = nv50_sor_power,
.clock = gf119_sor_clock,
.hdmi = {
.ctrl = gk104_sor_hdmi_ctrl,
.scdc = gm200_sor_hdmi_scdc,
},
.dp = {
.lanes = { 0, 1, 2, 3 },
.links = gf119_sor_dp_links,
.power = g94_sor_dp_power,
.pattern = gm107_sor_dp_pattern,
.drive = gm200_sor_dp_drive,
.vcpi = gf119_sor_dp_vcpi,
.audio = gf119_sor_dp_audio,
.audio_sym = gf119_sor_dp_audio_sym,
.watermark = gf119_sor_dp_watermark,
},
};
int
gp100_sor_new(struct nvkm_disp *disp, int id)
{
......@@ -94,9 +68,7 @@ gp100_sor_new(struct nvkm_disp *disp, int id)
if (!((hda = nvkm_rd32(device, 0x08a15c)) & 0x40000000))
hda = nvkm_rd32(device, 0x10ebb0) >> 8;
if (hda & BIT(id))
return nvkm_ior_new_(&gp100_sor_hda, disp, SOR, id);
return nvkm_ior_new_(&gp100_sor, disp, SOR, id);
return nvkm_ior_new_(&gp100_sor, disp, SOR, id, hda & BIT(id));
}
static const struct nvkm_disp_func
......
......@@ -168,7 +168,7 @@ gt215_sor = {
static int
gt215_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&gt215_sor, disp, SOR, id);
return nvkm_ior_new_(&gt215_sor, disp, SOR, id, true);
}
static const struct nvkm_disp_func
......
......@@ -165,7 +165,7 @@ gv100_sor_state(struct nvkm_ior *sor, struct nvkm_ior_state *state)
}
static const struct nvkm_ior_func
gv100_sor_hda = {
gv100_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
......@@ -194,31 +194,6 @@ gv100_sor_hda = {
},
};
static const struct nvkm_ior_func
gv100_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
},
.state = gv100_sor_state,
.power = nv50_sor_power,
.clock = gf119_sor_clock,
.hdmi = {
.ctrl = gv100_sor_hdmi_ctrl,
.scdc = gm200_sor_hdmi_scdc,
},
.dp = {
.lanes = { 0, 1, 2, 3 },
.links = gf119_sor_dp_links,
.power = g94_sor_dp_power,
.pattern = gm107_sor_dp_pattern,
.drive = gm200_sor_dp_drive,
.audio = gv100_sor_dp_audio,
.audio_sym = gv100_sor_dp_audio_sym,
.watermark = gv100_sor_dp_watermark,
},
};
static int
gv100_sor_new(struct nvkm_disp *disp, int id)
{
......@@ -228,10 +203,7 @@ gv100_sor_new(struct nvkm_disp *disp, int id)
if (!((hda = nvkm_rd32(device, 0x08a15c)) & 0x40000000))
hda = nvkm_rd32(device, 0x118fb0) >> 8;
if (hda & BIT(id))
return nvkm_ior_new_(&gv100_sor_hda, disp, SOR, id);
return nvkm_ior_new_(&gv100_sor, disp, SOR, id);
return nvkm_ior_new_(&gv100_sor, disp, SOR, id, hda & BIT(id));
}
int
......
......@@ -55,7 +55,7 @@ nvkm_ior_del(struct nvkm_ior **pior)
int
nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *disp,
enum nvkm_ior_type type, int id)
enum nvkm_ior_type type, int id, bool hda)
{
struct nvkm_ior *ior;
if (!(ior = kzalloc(sizeof(*ior), GFP_KERNEL)))
......@@ -64,6 +64,7 @@ nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *disp,
ior->disp = disp;
ior->type = type;
ior->id = id;
ior->hda = hda;
snprintf(ior->name, sizeof(ior->name), "%s-%d", nvkm_ior_name[ior->type], ior->id);
list_add_tail(&ior->head, &disp->iors);
IOR_DBG(ior, "ctor");
......
......@@ -13,6 +13,7 @@ struct nvkm_ior {
PIOR,
} type;
int id;
bool hda;
char name[8];
struct list_head head;
......@@ -93,7 +94,7 @@ struct nvkm_ior_func {
};
int nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *,
enum nvkm_ior_type type, int id);
enum nvkm_ior_type type, int id, bool hda);
void nvkm_ior_del(struct nvkm_ior **);
struct nvkm_ior *nvkm_ior_find(struct nvkm_disp *, enum nvkm_ior_type, int id);
......
......@@ -49,7 +49,7 @@ mcp77_sor = {
static int
mcp77_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&mcp77_sor, disp, SOR, id);
return nvkm_ior_new_(&mcp77_sor, disp, SOR, id, false);
}
static const struct nvkm_disp_func
......
......@@ -54,7 +54,7 @@ mcp89_sor = {
static int
mcp89_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&mcp89_sor, disp, SOR, id);
return nvkm_ior_new_(&mcp89_sor, disp, SOR, id, true);
}
static const struct nvkm_disp_func
......
......@@ -147,7 +147,7 @@ nv50_pior = {
int
nv50_pior_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&nv50_pior, disp, PIOR, id);
return nvkm_ior_new_(&nv50_pior, disp, PIOR, id, false);
}
int
......@@ -228,7 +228,7 @@ nv50_sor = {
static int
nv50_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&nv50_sor, disp, SOR, id);
return nvkm_ior_new_(&nv50_sor, disp, SOR, id, false);
}
int
......@@ -324,7 +324,7 @@ nv50_dac = {
int
nv50_dac_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&nv50_dac, disp, DAC, id);
return nvkm_ior_new_(&nv50_dac, disp, DAC, id, false);
}
int
......
......@@ -120,7 +120,7 @@ nvkm_outp_acquire_hda(struct nvkm_outp *outp, enum nvkm_ior_type type,
/* Failing that, a completely unused OR is the next best thing. */
list_for_each_entry(ior, &outp->disp->iors, head) {
if (!ior->identity && !!ior->func->hda.hpd == hda &&
if (!ior->identity && ior->hda == hda &&
!ior->asy.outp && ior->type == type && !ior->arm.outp &&
(ior->func->route.set || ior->id == __ffs(outp->info.or)))
return nvkm_outp_acquire_ior(outp, user, ior);
......@@ -130,7 +130,7 @@ nvkm_outp_acquire_hda(struct nvkm_outp *outp, enum nvkm_ior_type type,
* but will be released during the next modeset.
*/
list_for_each_entry(ior, &outp->disp->iors, head) {
if (!ior->identity && !!ior->func->hda.hpd == hda &&
if (!ior->identity && ior->hda == hda &&
!ior->asy.outp && ior->type == type &&
(ior->func->route.set || ior->id == __ffs(outp->info.or)))
return nvkm_outp_acquire_ior(outp, user, ior);
......@@ -181,7 +181,7 @@ nvkm_outp_acquire(struct nvkm_outp *outp, u8 user, bool hda)
*
* This warning is to make it obvious if that proves wrong.
*/
WARN_ON(hda && !ior->func->hda.hpd);
WARN_ON(hda && !ior->hda);
return nvkm_outp_acquire_ior(outp, user, ior);
}
}
......
......@@ -67,7 +67,7 @@ tu102_sor_dp_links(struct nvkm_ior *sor, struct nvkm_i2c_aux *aux)
}
static const struct nvkm_ior_func
tu102_sor_hda = {
tu102_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
......@@ -97,40 +97,13 @@ tu102_sor_hda = {
},
};
static const struct nvkm_ior_func
tu102_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
},
.state = gv100_sor_state,
.power = nv50_sor_power,
.clock = gf119_sor_clock,
.hdmi = {
.ctrl = gv100_sor_hdmi_ctrl,
.scdc = gm200_sor_hdmi_scdc,
},
.dp = {
.lanes = { 0, 1, 2, 3 },
.links = tu102_sor_dp_links,
.power = g94_sor_dp_power,
.pattern = gm107_sor_dp_pattern,
.drive = gm200_sor_dp_drive,
.vcpi = tu102_sor_dp_vcpi,
.audio = gv100_sor_dp_audio,
.audio_sym = gv100_sor_dp_audio_sym,
.watermark = gv100_sor_dp_watermark,
},
};
static int
tu102_sor_new(struct nvkm_disp *disp, int id)
{
struct nvkm_device *device = disp->engine.subdev.device;
u32 hda = nvkm_rd32(device, 0x08a15c);
if (hda & BIT(id))
return nvkm_ior_new_(&tu102_sor_hda, disp, SOR, id);
return nvkm_ior_new_(&tu102_sor, disp, SOR, id);
return nvkm_ior_new_(&tu102_sor, disp, SOR, id, hda & BIT(id));
}
int
......
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