Commit 78f1ad6f authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/disp: introduce input/output resource abstraction

In order to properly support the SOR -> SOR + pad macro separation
that occurred with GM20x GPUs, we need to separate OR handling out
of the output path code.

This will be used as the base to support ORs (DAC, SOR, PIOR).
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 57b2d73b
......@@ -9,6 +9,7 @@ struct nvkm_disp {
struct nvkm_engine engine;
struct list_head head;
struct list_head ior;
struct list_head outp;
struct list_head conn;
......
......@@ -19,6 +19,7 @@ nvkm-y += nvkm/engine/disp/headnv04.o
nvkm-y += nvkm/engine/disp/headnv50.o
nvkm-y += nvkm/engine/disp/headgf119.o
nvkm-y += nvkm/engine/disp/ior.o
nvkm-y += nvkm/engine/disp/dacnv50.o
nvkm-y += nvkm/engine/disp/piornv50.o
nvkm-y += nvkm/engine/disp/sornv50.o
......
......@@ -24,6 +24,7 @@
#include "priv.h"
#include "conn.h"
#include "head.h"
#include "ior.h"
#include "outp.h"
#include <core/client.h>
......@@ -414,6 +415,12 @@ nvkm_disp_dtor(struct nvkm_engine *engine)
nvkm_outp_del(&outp);
}
while (!list_empty(&disp->ior)) {
struct nvkm_ior *ior =
list_first_entry(&disp->ior, typeof(*ior), head);
nvkm_ior_del(&ior);
}
while (!list_empty(&disp->head)) {
struct nvkm_head *head =
list_first_entry(&disp->head, typeof(*head), head);
......@@ -439,6 +446,7 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
{
disp->func = func;
INIT_LIST_HEAD(&disp->head);
INIT_LIST_HEAD(&disp->ior);
INIT_LIST_HEAD(&disp->outp);
INIT_LIST_HEAD(&disp->conn);
return nvkm_engine_ctor(&nvkm_disp, device, index, true, &disp->engine);
......
......@@ -21,6 +21,7 @@
*
* Authors: Ben Skeggs
*/
#include "ior.h"
#include "nv50.h"
#include "outp.h"
......@@ -124,3 +125,13 @@ nv50_dac_power(NV50_DISP_MTHD_V1)
);
return 0;
}
static const struct nvkm_ior_func
nv50_dac = {
};
int
nv50_dac_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&nv50_dac, disp, DAC, id);
}
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
static const struct nv50_disp_func
......@@ -38,12 +39,15 @@ g84_disp = {
.outp.external.tmds = nv50_pior_output_new,
.outp.external.dp = nv50_pior_dp_new,
.dac.nr = 3,
.dac.new = nv50_dac_new,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 2,
.sor.new = nv50_sor_new,
.sor.power = nv50_sor_power,
.sor.hdmi = g84_hdmi_ctrl,
.pior.nr = 3,
.pior.new = nv50_pior_new,
.pior.power = nv50_pior_power,
};
......
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
static const struct nv50_disp_func
......@@ -39,12 +40,15 @@ g94_disp = {
.outp.external.tmds = nv50_pior_output_new,
.outp.external.dp = nv50_pior_dp_new,
.dac.nr = 3,
.dac.new = nv50_dac_new,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 4,
.sor.new = g94_sor_new,
.sor.power = nv50_sor_power,
.sor.hdmi = g84_hdmi_ctrl,
.pior.nr = 3,
.pior.new = nv50_pior_new,
.pior.power = nv50_pior_power,
};
......
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
#include <subdev/bios.h>
......@@ -506,9 +507,11 @@ gf119_disp = {
.outp.internal.lvds = nv50_sor_output_new,
.outp.internal.dp = gf119_sor_dp_new,
.dac.nr = 3,
.dac.new = nv50_dac_new,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 4,
.sor.new = gf119_sor_new,
.sor.power = nv50_sor_power,
.sor.hda_eld = gf119_hda_eld,
.sor.hdmi = gf119_hdmi_ctrl,
......
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
static const struct nv50_disp_func
......@@ -38,9 +39,11 @@ gk104_disp = {
.outp.internal.lvds = nv50_sor_output_new,
.outp.internal.dp = gf119_sor_dp_new,
.dac.nr = 3,
.dac.new = nv50_dac_new,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 4,
.sor.new = gf119_sor_new,
.sor.power = nv50_sor_power,
.sor.hda_eld = gf119_hda_eld,
.sor.hdmi = gk104_hdmi_ctrl,
......
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
static const struct nv50_disp_func
......@@ -38,9 +39,11 @@ gk110_disp = {
.outp.internal.lvds = nv50_sor_output_new,
.outp.internal.dp = gf119_sor_dp_new,
.dac.nr = 3,
.dac.new = nv50_dac_new,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 4,
.sor.new = gf119_sor_new,
.sor.power = nv50_sor_power,
.sor.hda_eld = gf119_hda_eld,
.sor.hdmi = gk104_hdmi_ctrl,
......
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
static const struct nv50_disp_func
......@@ -38,9 +39,11 @@ gm107_disp = {
.outp.internal.lvds = nv50_sor_output_new,
.outp.internal.dp = gm107_sor_dp_new,
.dac.nr = 3,
.dac.new = nv50_dac_new,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 4,
.sor.new = gm107_sor_new,
.sor.power = nv50_sor_power,
.sor.hda_eld = gf119_hda_eld,
.sor.hdmi = gk104_hdmi_ctrl,
......
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
static const struct nv50_disp_func
......@@ -38,9 +39,11 @@ gm200_disp = {
.outp.internal.lvds = nv50_sor_output_new,
.outp.internal.dp = gm200_sor_dp_new,
.dac.nr = 3,
.dac.new = nv50_dac_new,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 4,
.sor.new = gm200_sor_new,
.sor.power = nv50_sor_power,
.sor.hda_eld = gf119_hda_eld,
.sor.hdmi = gk104_hdmi_ctrl,
......
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
static const struct nv50_disp_func
......@@ -33,14 +34,11 @@ gp100_disp = {
.super = gf119_disp_super,
.root = &gp100_disp_root_oclass,
.head.new = gf119_head_new,
.outp.internal.crt = nv50_dac_output_new,
.outp.internal.tmds = nv50_sor_output_new,
.outp.internal.lvds = nv50_sor_output_new,
.outp.internal.dp = gm200_sor_dp_new,
.dac.nr = 3,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 4,
.sor.new = gm200_sor_new,
.sor.power = nv50_sor_power,
.sor.hda_eld = gf119_hda_eld,
.sor.hdmi = gk104_hdmi_ctrl,
......
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
static void
......@@ -59,14 +60,11 @@ gp102_disp = {
.super = gf119_disp_super,
.root = &gp102_disp_root_oclass,
.head.new = gf119_head_new,
.outp.internal.crt = nv50_dac_output_new,
.outp.internal.tmds = nv50_sor_output_new,
.outp.internal.lvds = nv50_sor_output_new,
.outp.internal.dp = gm200_sor_dp_new,
.dac.nr = 3,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 4,
.sor.new = gm200_sor_new,
.sor.power = nv50_sor_power,
.sor.hda_eld = gf119_hda_eld,
.sor.hdmi = gk104_hdmi_ctrl,
......
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
static const struct nv50_disp_func
......@@ -38,12 +39,15 @@ gt200_disp = {
.outp.external.tmds = nv50_pior_output_new,
.outp.external.dp = nv50_pior_dp_new,
.dac.nr = 3,
.dac.new = nv50_dac_new,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 2,
.sor.new = nv50_sor_new,
.sor.power = nv50_sor_power,
.sor.hdmi = g84_hdmi_ctrl,
.pior.nr = 3,
.pior.new = nv50_pior_new,
.pior.power = nv50_pior_power,
};
......
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
static const struct nv50_disp_func
......@@ -39,13 +40,16 @@ gt215_disp = {
.outp.external.tmds = nv50_pior_output_new,
.outp.external.dp = nv50_pior_dp_new,
.dac.nr = 3,
.dac.new = nv50_dac_new,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 4,
.sor.new = g94_sor_new,
.sor.power = nv50_sor_power,
.sor.hda_eld = gt215_hda_eld,
.sor.hdmi = gt215_hdmi_ctrl,
.pior.nr = 3,
.pior.new = nv50_pior_new,
.pior.power = nv50_pior_power,
};
......
/*
* Copyright 2017 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: Ben Skeggs <bskeggs@redhat.com>
*/
#include "ior.h"
static const char *
nvkm_ior_name[] = {
[DAC] = "DAC",
[SOR] = "SOR",
[PIOR] = "PIOR",
};
struct nvkm_ior *
nvkm_ior_find(struct nvkm_disp *disp, enum nvkm_ior_type type, int id)
{
struct nvkm_ior *ior;
list_for_each_entry(ior, &disp->ior, head) {
if (ior->type == type && (id < 0 || ior->id == id))
return ior;
}
return NULL;
}
void
nvkm_ior_del(struct nvkm_ior **pior)
{
struct nvkm_ior *ior = *pior;
if (ior) {
IOR_DBG(ior, "dtor");
list_del(&ior->head);
kfree(*pior);
*pior = NULL;
}
}
int
nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *disp,
enum nvkm_ior_type type, int id)
{
struct nvkm_ior *ior;
if (!(ior = kzalloc(sizeof(*ior), GFP_KERNEL)))
return -ENOMEM;
ior->func = func;
ior->disp = disp;
ior->type = type;
ior->id = id;
snprintf(ior->name, sizeof(ior->name), "%s-%d",
nvkm_ior_name[ior->type], ior->id);
list_add_tail(&ior->head, &disp->ior);
IOR_DBG(ior, "ctor");
return 0;
}
#ifndef __NVKM_DISP_IOR_H__
#define __NVKM_DISP_IOR_H__
#include "priv.h"
struct nvkm_ior {
const struct nvkm_ior_func *func;
struct nvkm_disp *disp;
enum nvkm_ior_type {
DAC,
SOR,
PIOR,
} type;
int id;
char name[8];
struct list_head head;
};
struct nvkm_ior_func {
};
int nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *,
enum nvkm_ior_type type, int id);
void nvkm_ior_del(struct nvkm_ior **);
struct nvkm_ior *nvkm_ior_find(struct nvkm_disp *, enum nvkm_ior_type, int id);
#define IOR_MSG(i,l,f,a...) do { \
struct nvkm_ior *_ior = (i); \
nvkm_##l(&_ior->disp->engine.subdev, "%s: "f, _ior->name, ##a); \
} while(0)
#define IOR_WARN(i,f,a...) IOR_MSG((i), warn, f, ##a)
#define IOR_DBG(i,f,a...) IOR_MSG((i), debug, f, ##a)
int nv50_dac_new(struct nvkm_disp *, int);
int nv50_pior_new(struct nvkm_disp *, int);
int nv50_sor_new(struct nvkm_disp *, int);
int g94_sor_new(struct nvkm_disp *, int);
int gf119_sor_new(struct nvkm_disp *, int);
int gm107_sor_new(struct nvkm_disp *, int);
int gm200_sor_new(struct nvkm_disp *, int);
#endif
......@@ -23,6 +23,7 @@
*/
#include "nv50.h"
#include "head.h"
#include "ior.h"
#include "rootnv50.h"
#include <core/client.h>
......@@ -149,6 +150,24 @@ nv50_disp_new_(const struct nv50_disp_func *func, struct nvkm_device *device,
return ret;
}
for (i = 0; func->dac.new && i < func->dac.nr; i++) {
ret = func->dac.new(&disp->base, i);
if (ret)
return ret;
}
for (i = 0; func->pior.new && i < func->pior.nr; i++) {
ret = func->pior.new(&disp->base, i);
if (ret)
return ret;
}
for (i = 0; func->sor.new && i < func->sor.nr; i++) {
ret = func->sor.new(&disp->base, i);
if (ret)
return ret;
}
return nvkm_event_init(func->uevent, 1, 1 + (heads * 4), &disp->uevent);
}
......@@ -803,11 +822,14 @@ nv50_disp = {
.outp.external.tmds = nv50_pior_output_new,
.outp.external.dp = nv50_pior_dp_new,
.dac.nr = 3,
.dac.new = nv50_dac_new,
.dac.power = nv50_dac_power,
.dac.sense = nv50_dac_sense,
.sor.nr = 2,
.sor.new = nv50_sor_new,
.sor.power = nv50_sor_power,
.pior.nr = 3,
.pior.new = nv50_pior_new,
.pior.power = nv50_pior_power,
};
......
......@@ -80,12 +80,14 @@ struct nv50_disp_func {
struct {
int nr;
int (*new)(struct nvkm_disp *, int id);
int (*power)(NV50_DISP_MTHD_V1);
int (*sense)(NV50_DISP_MTHD_V1);
} dac;
struct {
int nr;
int (*new)(struct nvkm_disp *, int id);
int (*power)(NV50_DISP_MTHD_V1);
int (*hda_eld)(NV50_DISP_MTHD_V1);
int (*hdmi)(NV50_DISP_MTHD_V1);
......@@ -94,6 +96,7 @@ struct nv50_disp_func {
struct {
int nr;
int (*new)(struct nvkm_disp *, int id);
int (*power)(NV50_DISP_MTHD_V1);
} pior;
};
......
......@@ -21,6 +21,7 @@
*
* Authors: Ben Skeggs
*/
#include "ior.h"
#include "nv50.h"
#include <core/client.h>
......@@ -119,3 +120,13 @@ nv50_pior_power(NV50_DISP_MTHD_V1)
disp->pior.type[outp->or] = type;
return 0;
}
static const struct nvkm_ior_func
nv50_pior = {
};
int
nv50_pior_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&nv50_pior, disp, PIOR, id);
}
......@@ -21,6 +21,7 @@
*
* Authors: Ben Skeggs
*/
#include "ior.h"
#include "nv50.h"
#include <subdev/timer.h>
......@@ -276,3 +277,13 @@ nv50_disp_dptmds_war_2(struct nv50_disp *disp, struct dcb_output *outp)
nvkm_wr32(device, 0x61c040 + soff + pu_pc * 4, 0x1f008000);
}
}
static const struct nvkm_ior_func
g94_sor = {
};
int
g94_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&g94_sor, disp, SOR, id);
}
......@@ -21,6 +21,7 @@
*
* Authors: Ben Skeggs
*/
#include "ior.h"
#include "nv50.h"
void
......@@ -128,3 +129,13 @@ gf119_sor_dp_new(struct nvkm_disp *disp, int index,
{
return nvkm_output_dp_new_(&gf119_sor_dp_func, disp, index, dcbE, poutp);
}
static const struct nvkm_ior_func
gf119_sor = {
};
int
gf119_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&gf119_sor, disp, SOR, id);
}
......@@ -21,6 +21,7 @@
*
* Authors: Ben Skeggs <bskeggs@redhat.com>
*/
#include "ior.h"
#include "nv50.h"
int
......@@ -51,3 +52,13 @@ gm107_sor_dp_new(struct nvkm_disp *disp, int index,
{
return nvkm_output_dp_new_(&gm107_sor_dp_func, disp, index, dcbE, poutp);
}
static const struct nvkm_ior_func
gm107_sor = {
};
int
gm107_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&gm107_sor, disp, SOR, id);
}
......@@ -21,6 +21,7 @@
*
* Authors: Ben Skeggs
*/
#include "ior.h"
#include "nv50.h"
#include <subdev/timer.h>
......@@ -128,3 +129,13 @@ gm200_sor_magic(struct nvkm_output *outp)
if (outp->info.sorconf.link & 2)
nvkm_mask(device, 0x612388 + soff, 0x0000001f, 0x00000010 | data);
}
static const struct nvkm_ior_func
gm200_sor = {
};
int
gm200_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&gm200_sor, disp, SOR, id);
}
......@@ -21,6 +21,7 @@
*
* Authors: Ben Skeggs
*/
#include "ior.h"
#include "nv50.h"
#include "outp.h"
......@@ -77,3 +78,13 @@ nv50_sor_power(NV50_DISP_MTHD_V1)
);
return 0;
}
static const struct nvkm_ior_func
nv50_sor = {
};
int
nv50_sor_new(struct nvkm_disp *disp, int id)
{
return nvkm_ior_new_(&nv50_sor, disp, SOR, id);
}
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