Simpler, and less error-prone than a separate set of function pointers.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
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
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
}
static const struct nvkm_ior_func
-ga102_sor_hda = {
+ga102_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
},
};
-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
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
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
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
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
}
static const struct nvkm_ior_func
-gm200_sor_hda = {
+gm200_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
},
};
-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)
{
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
#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,
},
};
-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)
{
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
static int
gt215_sor_new(struct nvkm_disp *disp, int id)
{
- return nvkm_ior_new_(>215_sor, disp, SOR, id);
+ return nvkm_ior_new_(>215_sor, disp, SOR, id, true);
}
static const struct nvkm_disp_func
}
static const struct nvkm_ior_func
-gv100_sor_hda = {
+gv100_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
},
};
-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)
{
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
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)))
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");
PIOR,
} type;
int id;
+ bool hda;
char name[8];
struct list_head head;
};
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);
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
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
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
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
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
/* 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);
* 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);
*
* 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);
}
}
}
static const struct nvkm_ior_func
-tu102_sor_hda = {
+tu102_sor = {
.route = {
.get = gm200_sor_route_get,
.set = gm200_sor_route_set,
},
};
-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