提交 1d7c71a3 编写于 作者: B Ben Skeggs

drm/nouveau/disp: port vblank handling to event interface

This removes the nastiness with the interactions between display and
software engines when handling vblank semaphore release interrupts.

Now, all the semantics are handled in one place (sw) \o/.
Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
上级 21a5ace0
...@@ -143,6 +143,7 @@ nouveau-y += core/engine/copy/nvc0.o ...@@ -143,6 +143,7 @@ nouveau-y += core/engine/copy/nvc0.o
nouveau-y += core/engine/copy/nve0.o nouveau-y += core/engine/copy/nve0.o
nouveau-y += core/engine/crypt/nv84.o nouveau-y += core/engine/crypt/nv84.o
nouveau-y += core/engine/crypt/nv98.o nouveau-y += core/engine/crypt/nv98.o
nouveau-y += core/engine/disp/base.o
nouveau-y += core/engine/disp/nv04.o nouveau-y += core/engine/disp/nv04.o
nouveau-y += core/engine/disp/nv50.o nouveau-y += core/engine/disp/nv50.o
nouveau-y += core/engine/disp/nv84.o nouveau-y += core/engine/disp/nv84.o
......
/*
* Copyright 2013 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
*/
#include <engine/disp.h>
void
_nouveau_disp_dtor(struct nouveau_object *object)
{
struct nouveau_disp *disp = (void *)object;
nouveau_event_destroy(&disp->vblank);
nouveau_engine_destroy(&disp->base);
}
int
nouveau_disp_create_(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, int heads,
const char *intname, const char *extname,
int length, void **pobject)
{
struct nouveau_disp *disp;
int ret;
ret = nouveau_engine_create_(parent, engine, oclass, true,
intname, extname, length, pobject);
disp = *pobject;
if (ret)
return ret;
return nouveau_event_create(heads, &disp->vblank);
}
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
*/ */
#include <engine/disp.h> #include <engine/disp.h>
#include <core/event.h>
#include <core/class.h> #include <core/class.h>
struct nv04_disp_priv { struct nv04_disp_priv {
...@@ -35,12 +37,20 @@ nv04_disp_sclass[] = { ...@@ -35,12 +37,20 @@ nv04_disp_sclass[] = {
{}, {},
}; };
/*******************************************************************************
* Display engine implementation
******************************************************************************/
static void
nv04_disp_vblank_enable(struct nouveau_event *event, int head)
{
nv_wr32(event->priv, 0x600140 + (head * 0x2000) , 0x00000001);
}
static void static void
nv04_disp_intr_vblank(struct nv04_disp_priv *priv, int crtc) nv04_disp_vblank_disable(struct nouveau_event *event, int head)
{ {
struct nouveau_disp *disp = &priv->base; nv_wr32(event->priv, 0x600140 + (head * 0x2000) , 0x00000000);
if (disp->vblank.notify)
disp->vblank.notify(disp->vblank.data, crtc);
} }
static void static void
...@@ -51,12 +61,12 @@ nv04_disp_intr(struct nouveau_subdev *subdev) ...@@ -51,12 +61,12 @@ nv04_disp_intr(struct nouveau_subdev *subdev)
u32 crtc1 = nv_rd32(priv, 0x602100); u32 crtc1 = nv_rd32(priv, 0x602100);
if (crtc0 & 0x00000001) { if (crtc0 & 0x00000001) {
nv04_disp_intr_vblank(priv, 0); nouveau_event_trigger(priv->base.vblank, 0);
nv_wr32(priv, 0x600100, 0x00000001); nv_wr32(priv, 0x600100, 0x00000001);
} }
if (crtc1 & 0x00000001) { if (crtc1 & 0x00000001) {
nv04_disp_intr_vblank(priv, 1); nouveau_event_trigger(priv->base.vblank, 1);
nv_wr32(priv, 0x602100, 0x00000001); nv_wr32(priv, 0x602100, 0x00000001);
} }
} }
...@@ -69,7 +79,7 @@ nv04_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -69,7 +79,7 @@ nv04_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv04_disp_priv *priv; struct nv04_disp_priv *priv;
int ret; int ret;
ret = nouveau_disp_create(parent, engine, oclass, "DISPLAY", ret = nouveau_disp_create(parent, engine, oclass, 2, "DISPLAY",
"display", &priv); "display", &priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
...@@ -77,6 +87,9 @@ nv04_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -77,6 +87,9 @@ nv04_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
nv_engine(priv)->sclass = nv04_disp_sclass; nv_engine(priv)->sclass = nv04_disp_sclass;
nv_subdev(priv)->intr = nv04_disp_intr; nv_subdev(priv)->intr = nv04_disp_intr;
priv->base.vblank->priv = priv;
priv->base.vblank->enable = nv04_disp_vblank_enable;
priv->base.vblank->disable = nv04_disp_vblank_disable;
return 0; return 0;
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <core/handle.h> #include <core/handle.h>
#include <core/class.h> #include <core/class.h>
#include <engine/software.h>
#include <engine/disp.h> #include <engine/disp.h>
#include <subdev/bios.h> #include <subdev/bios.h>
...@@ -37,7 +36,6 @@ ...@@ -37,7 +36,6 @@
#include <subdev/bios/pll.h> #include <subdev/bios/pll.h>
#include <subdev/timer.h> #include <subdev/timer.h>
#include <subdev/fb.h> #include <subdev/fb.h>
#include <subdev/bar.h>
#include <subdev/clock.h> #include <subdev/clock.h>
#include "nv50.h" #include "nv50.h"
...@@ -543,6 +541,18 @@ nv50_disp_curs_ofuncs = { ...@@ -543,6 +541,18 @@ nv50_disp_curs_ofuncs = {
* Base display object * Base display object
******************************************************************************/ ******************************************************************************/
static void
nv50_disp_base_vblank_enable(struct nouveau_event *event, int head)
{
nv_mask(event->priv, 0x61002c, (1 << head), (1 << head));
}
static void
nv50_disp_base_vblank_disable(struct nouveau_event *event, int head)
{
nv_mask(event->priv, 0x61002c, (1 << head), (0 << head));
}
static int static int
nv50_disp_base_ctor(struct nouveau_object *parent, nv50_disp_base_ctor(struct nouveau_object *parent,
struct nouveau_object *engine, struct nouveau_object *engine,
...@@ -559,6 +569,9 @@ nv50_disp_base_ctor(struct nouveau_object *parent, ...@@ -559,6 +569,9 @@ nv50_disp_base_ctor(struct nouveau_object *parent,
if (ret) if (ret)
return ret; return ret;
priv->base.vblank->priv = priv;
priv->base.vblank->enable = nv50_disp_base_vblank_enable;
priv->base.vblank->disable = nv50_disp_base_vblank_disable;
return nouveau_ramht_new(parent, parent, 0x1000, 0, &base->ramht); return nouveau_ramht_new(parent, parent, 0x1000, 0, &base->ramht);
} }
...@@ -756,50 +769,6 @@ nv50_disp_intr_error(struct nv50_disp_priv *priv) ...@@ -756,50 +769,6 @@ nv50_disp_intr_error(struct nv50_disp_priv *priv)
} }
} }
static void
nv50_disp_intr_vblank(struct nv50_disp_priv *priv, int crtc)
{
struct nouveau_bar *bar = nouveau_bar(priv);
struct nouveau_disp *disp = &priv->base;
struct nouveau_software_chan *chan, *temp;
unsigned long flags;
spin_lock_irqsave(&disp->vblank.lock, flags);
list_for_each_entry_safe(chan, temp, &disp->vblank.list, vblank.head) {
if (chan->vblank.crtc != crtc)
continue;
if (nv_device(priv)->chipset >= 0xc0) {
nv_wr32(priv, 0x001718, 0x80000000 | chan->vblank.channel);
bar->flush(bar);
nv_wr32(priv, 0x06000c,
upper_32_bits(chan->vblank.offset));
nv_wr32(priv, 0x060010,
lower_32_bits(chan->vblank.offset));
nv_wr32(priv, 0x060014, chan->vblank.value);
} else {
nv_wr32(priv, 0x001704, chan->vblank.channel);
nv_wr32(priv, 0x001710, 0x80000000 | chan->vblank.ctxdma);
bar->flush(bar);
if (nv_device(priv)->chipset == 0x50) {
nv_wr32(priv, 0x001570, chan->vblank.offset);
nv_wr32(priv, 0x001574, chan->vblank.value);
} else {
nv_wr32(priv, 0x060010, chan->vblank.offset);
nv_wr32(priv, 0x060014, chan->vblank.value);
}
}
list_del(&chan->vblank.head);
if (disp->vblank.put)
disp->vblank.put(disp->vblank.data, crtc);
}
spin_unlock_irqrestore(&disp->vblank.lock, flags);
if (disp->vblank.notify)
disp->vblank.notify(disp->vblank.data, crtc);
}
static u16 static u16
exec_lookup(struct nv50_disp_priv *priv, int head, int outp, u32 ctrl, exec_lookup(struct nv50_disp_priv *priv, int head, int outp, u32 ctrl,
struct dcb_output *dcb, u8 *ver, u8 *hdr, u8 *cnt, u8 *len, struct dcb_output *dcb, u8 *ver, u8 *hdr, u8 *cnt, u8 *len,
...@@ -1201,13 +1170,13 @@ nv50_disp_intr(struct nouveau_subdev *subdev) ...@@ -1201,13 +1170,13 @@ nv50_disp_intr(struct nouveau_subdev *subdev)
} }
if (intr1 & 0x00000004) { if (intr1 & 0x00000004) {
nv50_disp_intr_vblank(priv, 0); nouveau_event_trigger(priv->base.vblank, 0);
nv_wr32(priv, 0x610024, 0x00000004); nv_wr32(priv, 0x610024, 0x00000004);
intr1 &= ~0x00000004; intr1 &= ~0x00000004;
} }
if (intr1 & 0x00000008) { if (intr1 & 0x00000008) {
nv50_disp_intr_vblank(priv, 1); nouveau_event_trigger(priv->base.vblank, 1);
nv_wr32(priv, 0x610024, 0x00000008); nv_wr32(priv, 0x610024, 0x00000008);
intr1 &= ~0x00000008; intr1 &= ~0x00000008;
} }
...@@ -1226,7 +1195,7 @@ nv50_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -1226,7 +1195,7 @@ nv50_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv50_disp_priv *priv; struct nv50_disp_priv *priv;
int ret; int ret;
ret = nouveau_disp_create(parent, engine, oclass, "PDISP", ret = nouveau_disp_create(parent, engine, oclass, 2, "PDISP",
"display", &priv); "display", &priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
...@@ -1242,9 +1211,6 @@ nv50_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -1242,9 +1211,6 @@ nv50_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
priv->dac.power = nv50_dac_power; priv->dac.power = nv50_dac_power;
priv->dac.sense = nv50_dac_sense; priv->dac.sense = nv50_dac_sense;
priv->sor.power = nv50_sor_power; priv->sor.power = nv50_sor_power;
INIT_LIST_HEAD(&priv->base.vblank.list);
spin_lock_init(&priv->base.vblank.lock);
return 0; return 0;
} }
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
#include <core/parent.h> #include <core/parent.h>
#include <core/namedb.h> #include <core/namedb.h>
#include <core/engctx.h>
#include <core/ramht.h> #include <core/ramht.h>
#include <core/event.h>
#include <engine/dmaobj.h> #include <engine/dmaobj.h>
#include <engine/disp.h> #include <engine/disp.h>
......
...@@ -63,7 +63,7 @@ nv84_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -63,7 +63,7 @@ nv84_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv50_disp_priv *priv; struct nv50_disp_priv *priv;
int ret; int ret;
ret = nouveau_disp_create(parent, engine, oclass, "PDISP", ret = nouveau_disp_create(parent, engine, oclass, 2, "PDISP",
"display", &priv); "display", &priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
...@@ -80,9 +80,6 @@ nv84_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -80,9 +80,6 @@ nv84_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
priv->dac.sense = nv50_dac_sense; priv->dac.sense = nv50_dac_sense;
priv->sor.power = nv50_sor_power; priv->sor.power = nv50_sor_power;
priv->sor.hdmi = nv84_hdmi_ctrl; priv->sor.hdmi = nv84_hdmi_ctrl;
INIT_LIST_HEAD(&priv->base.vblank.list);
spin_lock_init(&priv->base.vblank.lock);
return 0; return 0;
} }
......
...@@ -69,7 +69,7 @@ nv94_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -69,7 +69,7 @@ nv94_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv50_disp_priv *priv; struct nv50_disp_priv *priv;
int ret; int ret;
ret = nouveau_disp_create(parent, engine, oclass, "PDISP", ret = nouveau_disp_create(parent, engine, oclass, 2, "PDISP",
"display", &priv); "display", &priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
...@@ -91,9 +91,6 @@ nv94_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -91,9 +91,6 @@ nv94_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
priv->sor.dp_train_fini = nv94_sor_dp_train_fini; priv->sor.dp_train_fini = nv94_sor_dp_train_fini;
priv->sor.dp_lnkctl = nv94_sor_dp_lnkctl; priv->sor.dp_lnkctl = nv94_sor_dp_lnkctl;
priv->sor.dp_drvctl = nv94_sor_dp_drvctl; priv->sor.dp_drvctl = nv94_sor_dp_drvctl;
INIT_LIST_HEAD(&priv->base.vblank.list);
spin_lock_init(&priv->base.vblank.lock);
return 0; return 0;
} }
......
...@@ -53,7 +53,7 @@ nva0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -53,7 +53,7 @@ nva0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv50_disp_priv *priv; struct nv50_disp_priv *priv;
int ret; int ret;
ret = nouveau_disp_create(parent, engine, oclass, "PDISP", ret = nouveau_disp_create(parent, engine, oclass, 2, "PDISP",
"display", &priv); "display", &priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
...@@ -70,9 +70,6 @@ nva0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -70,9 +70,6 @@ nva0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
priv->dac.sense = nv50_dac_sense; priv->dac.sense = nv50_dac_sense;
priv->sor.power = nv50_sor_power; priv->sor.power = nv50_sor_power;
priv->sor.hdmi = nv84_hdmi_ctrl; priv->sor.hdmi = nv84_hdmi_ctrl;
INIT_LIST_HEAD(&priv->base.vblank.list);
spin_lock_init(&priv->base.vblank.lock);
return 0; return 0;
} }
......
...@@ -70,7 +70,7 @@ nva3_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -70,7 +70,7 @@ nva3_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv50_disp_priv *priv; struct nv50_disp_priv *priv;
int ret; int ret;
ret = nouveau_disp_create(parent, engine, oclass, "PDISP", ret = nouveau_disp_create(parent, engine, oclass, 2, "PDISP",
"display", &priv); "display", &priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
...@@ -93,9 +93,6 @@ nva3_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -93,9 +93,6 @@ nva3_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
priv->sor.dp_train_fini = nv94_sor_dp_train_fini; priv->sor.dp_train_fini = nv94_sor_dp_train_fini;
priv->sor.dp_lnkctl = nv94_sor_dp_lnkctl; priv->sor.dp_lnkctl = nv94_sor_dp_lnkctl;
priv->sor.dp_drvctl = nv94_sor_dp_drvctl; priv->sor.dp_drvctl = nv94_sor_dp_drvctl;
INIT_LIST_HEAD(&priv->base.vblank.list);
spin_lock_init(&priv->base.vblank.lock);
return 0; return 0;
} }
......
...@@ -27,12 +27,10 @@ ...@@ -27,12 +27,10 @@
#include <core/handle.h> #include <core/handle.h>
#include <core/class.h> #include <core/class.h>
#include <engine/software.h>
#include <engine/disp.h> #include <engine/disp.h>
#include <subdev/timer.h> #include <subdev/timer.h>
#include <subdev/fb.h> #include <subdev/fb.h>
#include <subdev/bar.h>
#include <subdev/clock.h> #include <subdev/clock.h>
#include <subdev/bios.h> #include <subdev/bios.h>
...@@ -443,6 +441,18 @@ nvd0_disp_curs_ofuncs = { ...@@ -443,6 +441,18 @@ nvd0_disp_curs_ofuncs = {
* Base display object * Base display object
******************************************************************************/ ******************************************************************************/
static void
nvd0_disp_base_vblank_enable(struct nouveau_event *event, int head)
{
nv_mask(event->priv, 0x6100c0 + (head * 0x800), 0x00000001, 0x00000001);
}
static void
nvd0_disp_base_vblank_disable(struct nouveau_event *event, int head)
{
nv_mask(event->priv, 0x6100c0 + (head * 0x800), 0x00000001, 0x00000000);
}
static int static int
nvd0_disp_base_ctor(struct nouveau_object *parent, nvd0_disp_base_ctor(struct nouveau_object *parent,
struct nouveau_object *engine, struct nouveau_object *engine,
...@@ -459,6 +469,10 @@ nvd0_disp_base_ctor(struct nouveau_object *parent, ...@@ -459,6 +469,10 @@ nvd0_disp_base_ctor(struct nouveau_object *parent,
if (ret) if (ret)
return ret; return ret;
priv->base.vblank->priv = priv;
priv->base.vblank->enable = nvd0_disp_base_vblank_enable;
priv->base.vblank->disable = nvd0_disp_base_vblank_disable;
return nouveau_ramht_new(parent, parent, 0x1000, 0, &base->ramht); return nouveau_ramht_new(parent, parent, 0x1000, 0, &base->ramht);
} }
...@@ -822,35 +836,6 @@ nvd0_display_unk4_handler(struct nv50_disp_priv *priv, u32 head, u32 mask) ...@@ -822,35 +836,6 @@ nvd0_display_unk4_handler(struct nv50_disp_priv *priv, u32 head, u32 mask)
nv_wr32(priv, 0x6101d0, 0x80000000); nv_wr32(priv, 0x6101d0, 0x80000000);
} }
static void
nvd0_disp_intr_vblank(struct nv50_disp_priv *priv, int crtc)
{
struct nouveau_bar *bar = nouveau_bar(priv);
struct nouveau_disp *disp = &priv->base;
struct nouveau_software_chan *chan, *temp;
unsigned long flags;
spin_lock_irqsave(&disp->vblank.lock, flags);
list_for_each_entry_safe(chan, temp, &disp->vblank.list, vblank.head) {
if (chan->vblank.crtc != crtc)
continue;
nv_wr32(priv, 0x001718, 0x80000000 | chan->vblank.channel);
bar->flush(bar);
nv_wr32(priv, 0x06000c, upper_32_bits(chan->vblank.offset));
nv_wr32(priv, 0x060010, lower_32_bits(chan->vblank.offset));
nv_wr32(priv, 0x060014, chan->vblank.value);
list_del(&chan->vblank.head);
if (disp->vblank.put)
disp->vblank.put(disp->vblank.data, crtc);
}
spin_unlock_irqrestore(&disp->vblank.lock, flags);
if (disp->vblank.notify)
disp->vblank.notify(disp->vblank.data, crtc);
}
void void
nvd0_disp_intr(struct nouveau_subdev *subdev) nvd0_disp_intr(struct nouveau_subdev *subdev)
{ {
...@@ -920,7 +905,7 @@ nvd0_disp_intr(struct nouveau_subdev *subdev) ...@@ -920,7 +905,7 @@ nvd0_disp_intr(struct nouveau_subdev *subdev)
if (mask & intr) { if (mask & intr) {
u32 stat = nv_rd32(priv, 0x6100bc + (i * 0x800)); u32 stat = nv_rd32(priv, 0x6100bc + (i * 0x800));
if (stat & 0x00000001) if (stat & 0x00000001)
nvd0_disp_intr_vblank(priv, i); nouveau_event_trigger(priv->base.vblank, i);
nv_mask(priv, 0x6100bc + (i * 0x800), 0, 0); nv_mask(priv, 0x6100bc + (i * 0x800), 0, 0);
nv_rd32(priv, 0x6100c0 + (i * 0x800)); nv_rd32(priv, 0x6100c0 + (i * 0x800));
} }
...@@ -933,10 +918,11 @@ nvd0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -933,10 +918,11 @@ nvd0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nouveau_object **pobject) struct nouveau_object **pobject)
{ {
struct nv50_disp_priv *priv; struct nv50_disp_priv *priv;
int heads = nv_rd32(parent, 0x022448);
int ret; int ret;
ret = nouveau_disp_create(parent, engine, oclass, "PDISP", ret = nouveau_disp_create(parent, engine, oclass, heads,
"display", &priv); "PDISP", "display", &priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
return ret; return ret;
...@@ -945,7 +931,7 @@ nvd0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -945,7 +931,7 @@ nvd0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
nv_engine(priv)->cclass = &nv50_disp_cclass; nv_engine(priv)->cclass = &nv50_disp_cclass;
nv_subdev(priv)->intr = nvd0_disp_intr; nv_subdev(priv)->intr = nvd0_disp_intr;
priv->sclass = nvd0_disp_sclass; priv->sclass = nvd0_disp_sclass;
priv->head.nr = nv_rd32(priv, 0x022448); priv->head.nr = heads;
priv->dac.nr = 3; priv->dac.nr = 3;
priv->sor.nr = 4; priv->sor.nr = 4;
priv->dac.power = nv50_dac_power; priv->dac.power = nv50_dac_power;
...@@ -958,9 +944,6 @@ nvd0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -958,9 +944,6 @@ nvd0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
priv->sor.dp_train_fini = nv94_sor_dp_train_fini; priv->sor.dp_train_fini = nv94_sor_dp_train_fini;
priv->sor.dp_lnkctl = nvd0_sor_dp_lnkctl; priv->sor.dp_lnkctl = nvd0_sor_dp_lnkctl;
priv->sor.dp_drvctl = nvd0_sor_dp_drvctl; priv->sor.dp_drvctl = nvd0_sor_dp_drvctl;
INIT_LIST_HEAD(&priv->base.vblank.list);
spin_lock_init(&priv->base.vblank.lock);
return 0; return 0;
} }
......
...@@ -51,10 +51,11 @@ nve0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -51,10 +51,11 @@ nve0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nouveau_object **pobject) struct nouveau_object **pobject)
{ {
struct nv50_disp_priv *priv; struct nv50_disp_priv *priv;
int heads = nv_rd32(parent, 0x022448);
int ret; int ret;
ret = nouveau_disp_create(parent, engine, oclass, "PDISP", ret = nouveau_disp_create(parent, engine, oclass, heads,
"display", &priv); "PDISP", "display", &priv);
*pobject = nv_object(priv); *pobject = nv_object(priv);
if (ret) if (ret)
return ret; return ret;
...@@ -63,7 +64,7 @@ nve0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -63,7 +64,7 @@ nve0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
nv_engine(priv)->cclass = &nv50_disp_cclass; nv_engine(priv)->cclass = &nv50_disp_cclass;
nv_subdev(priv)->intr = nvd0_disp_intr; nv_subdev(priv)->intr = nvd0_disp_intr;
priv->sclass = nve0_disp_sclass; priv->sclass = nve0_disp_sclass;
priv->head.nr = nv_rd32(priv, 0x022448); priv->head.nr = heads;
priv->dac.nr = 3; priv->dac.nr = 3;
priv->sor.nr = 4; priv->sor.nr = 4;
priv->dac.power = nv50_dac_power; priv->dac.power = nv50_dac_power;
...@@ -76,9 +77,6 @@ nve0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ...@@ -76,9 +77,6 @@ nve0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
priv->sor.dp_train_fini = nv94_sor_dp_train_fini; priv->sor.dp_train_fini = nv94_sor_dp_train_fini;
priv->sor.dp_lnkctl = nvd0_sor_dp_lnkctl; priv->sor.dp_lnkctl = nvd0_sor_dp_lnkctl;
priv->sor.dp_drvctl = nvd0_sor_dp_drvctl; priv->sor.dp_drvctl = nvd0_sor_dp_drvctl;
INIT_LIST_HEAD(&priv->base.vblank.list);
spin_lock_init(&priv->base.vblank.lock);
return 0; return 0;
} }
......
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
#include <core/namedb.h> #include <core/namedb.h>
#include <core/handle.h> #include <core/handle.h>
#include <core/gpuobj.h> #include <core/gpuobj.h>
#include <core/event.h>
#include <subdev/bar.h>
#include <engine/software.h> #include <engine/software.h>
#include <engine/disp.h> #include <engine/disp.h>
...@@ -90,18 +93,11 @@ nv50_software_mthd_vblsem_release(struct nouveau_object *object, u32 mthd, ...@@ -90,18 +93,11 @@ nv50_software_mthd_vblsem_release(struct nouveau_object *object, u32 mthd,
{ {
struct nv50_software_chan *chan = (void *)nv_engctx(object->parent); struct nv50_software_chan *chan = (void *)nv_engctx(object->parent);
struct nouveau_disp *disp = nouveau_disp(object); struct nouveau_disp *disp = nouveau_disp(object);
unsigned long flags;
u32 crtc = *(u32 *)args; u32 crtc = *(u32 *)args;
if (crtc > 1) if (crtc > 1)
return -EINVAL; return -EINVAL;
disp->vblank.get(disp->vblank.data, crtc); nouveau_event_get(disp->vblank, crtc, &chan->base.vblank.event);
spin_lock_irqsave(&disp->vblank.lock, flags);
list_add(&chan->base.vblank.head, &disp->vblank.list);
chan->base.vblank.crtc = crtc;
spin_unlock_irqrestore(&disp->vblank.lock, flags);
return 0; return 0;
} }
...@@ -135,6 +131,29 @@ nv50_software_sclass[] = { ...@@ -135,6 +131,29 @@ nv50_software_sclass[] = {
* software context * software context
******************************************************************************/ ******************************************************************************/
static int
nv50_software_vblsem_release(struct nouveau_eventh *event, int head)
{
struct nouveau_software_chan *chan =
container_of(event, struct nouveau_software_chan, vblank.event);
struct nv50_software_priv *priv = (void *)nv_object(chan)->engine;
struct nouveau_bar *bar = nouveau_bar(priv);
nv_wr32(priv, 0x001704, chan->vblank.channel);
nv_wr32(priv, 0x001710, 0x80000000 | chan->vblank.ctxdma);
bar->flush(bar);
if (nv_device(priv)->chipset == 0x50) {
nv_wr32(priv, 0x001570, chan->vblank.offset);
nv_wr32(priv, 0x001574, chan->vblank.value);
} else {
nv_wr32(priv, 0x060010, chan->vblank.offset);
nv_wr32(priv, 0x060014, chan->vblank.value);
}
return NVKM_EVENT_DROP;
}
static int static int
nv50_software_context_ctor(struct nouveau_object *parent, nv50_software_context_ctor(struct nouveau_object *parent,
struct nouveau_object *engine, struct nouveau_object *engine,
...@@ -150,6 +169,7 @@ nv50_software_context_ctor(struct nouveau_object *parent, ...@@ -150,6 +169,7 @@ nv50_software_context_ctor(struct nouveau_object *parent,
return ret; return ret;
chan->base.vblank.channel = nv_gpuobj(parent->parent)->addr >> 12; chan->base.vblank.channel = nv_gpuobj(parent->parent)->addr >> 12;
chan->base.vblank.event.func = nv50_software_vblsem_release;
return 0; return 0;
} }
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
#include <core/os.h> #include <core/os.h>
#include <core/class.h> #include <core/class.h>
#include <core/engctx.h> #include <core/engctx.h>
#include <core/event.h>
#include <subdev/bar.h>
#include <engine/software.h> #include <engine/software.h>
#include <engine/disp.h> #include <engine/disp.h>
...@@ -72,18 +75,12 @@ nvc0_software_mthd_vblsem_release(struct nouveau_object *object, u32 mthd, ...@@ -72,18 +75,12 @@ nvc0_software_mthd_vblsem_release(struct nouveau_object *object, u32 mthd,
{ {
struct nvc0_software_chan *chan = (void *)nv_engctx(object->parent); struct nvc0_software_chan *chan = (void *)nv_engctx(object->parent);
struct nouveau_disp *disp = nouveau_disp(object); struct nouveau_disp *disp = nouveau_disp(object);
unsigned long flags;
u32 crtc = *(u32 *)args; u32 crtc = *(u32 *)args;
if ((nv_device(object)->card_type < NV_E0 && crtc > 1) || crtc > 3) if ((nv_device(object)->card_type < NV_E0 && crtc > 1) || crtc > 3)
return -EINVAL; return -EINVAL;
disp->vblank.get(disp->vblank.data, crtc); nouveau_event_get(disp->vblank, crtc, &chan->base.vblank.event);
spin_lock_irqsave(&disp->vblank.lock, flags);
list_add(&chan->base.vblank.head, &disp->vblank.list);
chan->base.vblank.crtc = crtc;
spin_unlock_irqrestore(&disp->vblank.lock, flags);
return 0; return 0;
} }
...@@ -117,6 +114,23 @@ nvc0_software_sclass[] = { ...@@ -117,6 +114,23 @@ nvc0_software_sclass[] = {
* software context * software context
******************************************************************************/ ******************************************************************************/
static int
nvc0_software_vblsem_release(struct nouveau_eventh *event, int head)
{
struct nouveau_software_chan *chan =
container_of(event, struct nouveau_software_chan, vblank.event);
struct nvc0_software_priv *priv = (void *)nv_object(chan)->engine;
struct nouveau_bar *bar = nouveau_bar(priv);
nv_wr32(priv, 0x001718, 0x80000000 | chan->vblank.channel);
bar->flush(bar);
nv_wr32(priv, 0x06000c, upper_32_bits(chan->vblank.offset));
nv_wr32(priv, 0x060010, lower_32_bits(chan->vblank.offset));
nv_wr32(priv, 0x060014, chan->vblank.value);
return NVKM_EVENT_DROP;
}
static int static int
nvc0_software_context_ctor(struct nouveau_object *parent, nvc0_software_context_ctor(struct nouveau_object *parent,
struct nouveau_object *engine, struct nouveau_object *engine,
...@@ -132,6 +146,7 @@ nvc0_software_context_ctor(struct nouveau_object *parent, ...@@ -132,6 +146,7 @@ nvc0_software_context_ctor(struct nouveau_object *parent,
return ret; return ret;
chan->base.vblank.channel = nv_gpuobj(parent->parent)->addr >> 12; chan->base.vblank.channel = nv_gpuobj(parent->parent)->addr >> 12;
chan->base.vblank.event.func = nvc0_software_vblsem_release;
return 0; return 0;
} }
......
...@@ -4,18 +4,11 @@ ...@@ -4,18 +4,11 @@
#include <core/object.h> #include <core/object.h>
#include <core/engine.h> #include <core/engine.h>
#include <core/device.h> #include <core/device.h>
#include <core/event.h>
struct nouveau_disp { struct nouveau_disp {
struct nouveau_engine base; struct nouveau_engine base;
struct nouveau_event *vblank;
struct {
struct list_head list;
spinlock_t lock;
void (*notify)(void *, int);
void (*get)(void *, int);
void (*put)(void *, int);
void *data;
} vblank;
}; };
static inline struct nouveau_disp * static inline struct nouveau_disp *
...@@ -24,16 +17,22 @@ nouveau_disp(void *obj) ...@@ -24,16 +17,22 @@ nouveau_disp(void *obj)
return (void *)nv_device(obj)->subdev[NVDEV_ENGINE_DISP]; return (void *)nv_device(obj)->subdev[NVDEV_ENGINE_DISP];
} }
#define nouveau_disp_create(p,e,c,i,x,d) \ #define nouveau_disp_create(p,e,c,h,i,x,d) \
nouveau_engine_create((p), (e), (c), true, (i), (x), (d)) nouveau_disp_create_((p), (e), (c), (h), (i), (x), \
#define nouveau_disp_destroy(d) \ sizeof(**d), (void **)d)
nouveau_engine_destroy(&(d)->base) #define nouveau_disp_destroy(d) ({ \
struct nouveau_disp *disp = (d); \
_nouveau_disp_dtor(nv_object(disp)); \
})
#define nouveau_disp_init(d) \ #define nouveau_disp_init(d) \
nouveau_engine_init(&(d)->base) nouveau_engine_init(&(d)->base)
#define nouveau_disp_fini(d,s) \ #define nouveau_disp_fini(d,s) \
nouveau_engine_fini(&(d)->base, (s)) nouveau_engine_fini(&(d)->base, (s))
#define _nouveau_disp_dtor _nouveau_engine_dtor int nouveau_disp_create_(struct nouveau_object *, struct nouveau_object *,
struct nouveau_oclass *, int heads,
const char *, const char *, int, void **);
void _nouveau_disp_dtor(struct nouveau_object *);
#define _nouveau_disp_init _nouveau_engine_init #define _nouveau_disp_init _nouveau_engine_init
#define _nouveau_disp_fini _nouveau_engine_fini #define _nouveau_disp_fini _nouveau_engine_fini
......
...@@ -3,17 +3,17 @@ ...@@ -3,17 +3,17 @@
#include <core/engine.h> #include <core/engine.h>
#include <core/engctx.h> #include <core/engctx.h>
#include <core/event.h>
struct nouveau_software_chan { struct nouveau_software_chan {
struct nouveau_engctx base; struct nouveau_engctx base;
struct { struct {
struct list_head head; struct nouveau_eventh event;
u32 channel; u32 channel;
u32 ctxdma; u32 ctxdma;
u64 offset; u64 offset;
u32 value; u32 value;
u32 crtc;
} vblank; } vblank;
int (*flip)(void *); int (*flip)(void *);
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include <subdev/gpio.h> #include <subdev/gpio.h>
#include <engine/disp.h> #include <engine/disp.h>
#include <core/class.h>
static void static void
nouveau_user_framebuffer_destroy(struct drm_framebuffer *drm_fb) nouveau_user_framebuffer_destroy(struct drm_framebuffer *drm_fb)
{ {
...@@ -257,29 +259,10 @@ nouveau_display_fini(struct drm_device *dev) ...@@ -257,29 +259,10 @@ nouveau_display_fini(struct drm_device *dev)
disp->fini(dev); disp->fini(dev);
} }
static void
nouveau_display_vblank_notify(void *data, int crtc)
{
drm_handle_vblank(data, crtc);
}
static void
nouveau_display_vblank_get(void *data, int crtc)
{
drm_vblank_get(data, crtc);
}
static void
nouveau_display_vblank_put(void *data, int crtc)
{
drm_vblank_put(data, crtc);
}
int int
nouveau_display_create(struct drm_device *dev) nouveau_display_create(struct drm_device *dev)
{ {
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_disp *pdisp = nouveau_disp(drm->device);
struct nouveau_display *disp; struct nouveau_display *disp;
u32 pclass = dev->pdev->class >> 8; u32 pclass = dev->pdev->class >> 8;
int ret, gen; int ret, gen;
...@@ -288,11 +271,6 @@ nouveau_display_create(struct drm_device *dev) ...@@ -288,11 +271,6 @@ nouveau_display_create(struct drm_device *dev)
if (!disp) if (!disp)
return -ENOMEM; return -ENOMEM;
pdisp->vblank.data = dev;
pdisp->vblank.notify = nouveau_display_vblank_notify;
pdisp->vblank.get = nouveau_display_vblank_get;
pdisp->vblank.put = nouveau_display_vblank_put;
drm_mode_config_init(dev); drm_mode_config_init(dev);
drm_mode_create_scaling_mode_property(dev); drm_mode_create_scaling_mode_property(dev);
drm_mode_create_dvi_i_properties(dev); drm_mode_create_dvi_i_properties(dev);
...@@ -474,39 +452,6 @@ nouveau_display_resume(struct drm_device *dev) ...@@ -474,39 +452,6 @@ nouveau_display_resume(struct drm_device *dev)
} }
} }
int
nouveau_vblank_enable(struct drm_device *dev, int crtc)
{
struct nouveau_device *device = nouveau_dev(dev);
if (device->card_type >= NV_D0)
nv_mask(device, 0x6100c0 + (crtc * 0x800), 1, 1);
else
if (device->card_type >= NV_50)
nv_mask(device, NV50_PDISPLAY_INTR_EN_1, 0,
NV50_PDISPLAY_INTR_EN_1_VBLANK_CRTC_(crtc));
else
NVWriteCRTC(dev, crtc, NV_PCRTC_INTR_EN_0,
NV_PCRTC_INTR_0_VBLANK);
return 0;
}
void
nouveau_vblank_disable(struct drm_device *dev, int crtc)
{
struct nouveau_device *device = nouveau_dev(dev);
if (device->card_type >= NV_D0)
nv_mask(device, 0x6100c0 + (crtc * 0x800), 1, 0);
else
if (device->card_type >= NV_50)
nv_mask(device, NV50_PDISPLAY_INTR_EN_1,
NV50_PDISPLAY_INTR_EN_1_VBLANK_CRTC_(crtc), 0);
else
NVWriteCRTC(dev, crtc, NV_PCRTC_INTR_EN_0, 0);
}
static int static int
nouveau_page_flip_reserve(struct nouveau_bo *old_bo, nouveau_page_flip_reserve(struct nouveau_bo *old_bo,
struct nouveau_bo *new_bo) struct nouveau_bo *new_bo)
......
...@@ -59,9 +59,6 @@ void nouveau_display_fini(struct drm_device *dev); ...@@ -59,9 +59,6 @@ void nouveau_display_fini(struct drm_device *dev);
int nouveau_display_suspend(struct drm_device *dev); int nouveau_display_suspend(struct drm_device *dev);
void nouveau_display_resume(struct drm_device *dev); void nouveau_display_resume(struct drm_device *dev);
int nouveau_vblank_enable(struct drm_device *dev, int crtc);
void nouveau_vblank_disable(struct drm_device *dev, int crtc);
int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
struct drm_pending_vblank_event *event); struct drm_pending_vblank_event *event);
int nouveau_finish_page_flip(struct nouveau_channel *, int nouveau_finish_page_flip(struct nouveau_channel *,
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <subdev/device.h> #include <subdev/device.h>
#include <subdev/vm.h> #include <subdev/vm.h>
#include <engine/disp.h>
#include "nouveau_drm.h" #include "nouveau_drm.h"
#include "nouveau_irq.h" #include "nouveau_irq.h"
#include "nouveau_dma.h" #include "nouveau_dma.h"
...@@ -68,6 +70,32 @@ module_param_named(modeset, nouveau_modeset, int, 0400); ...@@ -68,6 +70,32 @@ module_param_named(modeset, nouveau_modeset, int, 0400);
static struct drm_driver driver; static struct drm_driver driver;
static int
nouveau_drm_vblank_enable(struct drm_device *dev, int head)
{
struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_disp *pdisp = nouveau_disp(drm->device);
nouveau_event_get(pdisp->vblank, head, &drm->vblank);
return 0;
}
static void
nouveau_drm_vblank_disable(struct drm_device *dev, int head)
{
struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_disp *pdisp = nouveau_disp(drm->device);
nouveau_event_put(pdisp->vblank, head, &drm->vblank);
}
static int
nouveau_drm_vblank_handler(struct nouveau_eventh *event, int head)
{
struct nouveau_drm *drm =
container_of(event, struct nouveau_drm, vblank);
drm_handle_vblank(drm->dev, head);
return NVKM_EVENT_KEEP;
}
static u64 static u64
nouveau_name(struct pci_dev *pdev) nouveau_name(struct pci_dev *pdev)
{ {
...@@ -259,6 +287,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags) ...@@ -259,6 +287,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
dev->dev_private = drm; dev->dev_private = drm;
drm->dev = dev; drm->dev = dev;
drm->vblank.func = nouveau_drm_vblank_handler;
INIT_LIST_HEAD(&drm->clients); INIT_LIST_HEAD(&drm->clients);
spin_lock_init(&drm->tile.lock); spin_lock_init(&drm->tile.lock);
...@@ -643,8 +672,8 @@ driver = { ...@@ -643,8 +672,8 @@ driver = {
.irq_handler = nouveau_irq_handler, .irq_handler = nouveau_irq_handler,
.get_vblank_counter = drm_vblank_count, .get_vblank_counter = drm_vblank_count,
.enable_vblank = nouveau_vblank_enable, .enable_vblank = nouveau_drm_vblank_enable,
.disable_vblank = nouveau_vblank_disable, .disable_vblank = nouveau_drm_vblank_disable,
.ioctls = nouveau_ioctls, .ioctls = nouveau_ioctls,
.fops = &nouveau_driver_fops, .fops = &nouveau_driver_fops,
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define DRIVER_PATCHLEVEL 0 #define DRIVER_PATCHLEVEL 0
#include <core/client.h> #include <core/client.h>
#include <core/event.h>
#include <subdev/vm.h> #include <subdev/vm.h>
...@@ -112,6 +113,7 @@ struct nouveau_drm { ...@@ -112,6 +113,7 @@ struct nouveau_drm {
struct nvbios vbios; struct nvbios vbios;
struct nouveau_display *display; struct nouveau_display *display;
struct backlight_device *backlight; struct backlight_device *backlight;
struct nouveau_eventh vblank;
/* power management */ /* power management */
struct nouveau_pm *pm; struct nouveau_pm *pm;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册