2012-07-19 22:17:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 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
|
|
|
|
*/
|
2015-01-14 05:24:57 +00:00
|
|
|
#include "nv50.h"
|
|
|
|
#include "outp.h"
|
|
|
|
#include "outpdp.h"
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2014-08-09 18:10:26 +00:00
|
|
|
#include <core/client.h>
|
2015-01-14 05:24:57 +00:00
|
|
|
#include <core/engctx.h>
|
2014-02-21 01:06:40 +00:00
|
|
|
#include <core/enum.h>
|
2015-01-14 05:24:57 +00:00
|
|
|
#include <core/handle.h>
|
|
|
|
#include <core/ramht.h>
|
|
|
|
#include <engine/dmaobj.h>
|
2012-11-09 02:09:48 +00:00
|
|
|
#include <subdev/bios.h>
|
|
|
|
#include <subdev/bios/dcb.h>
|
|
|
|
#include <subdev/bios/disp.h>
|
|
|
|
#include <subdev/bios/init.h>
|
|
|
|
#include <subdev/bios/pll.h>
|
2013-03-05 00:53:54 +00:00
|
|
|
#include <subdev/devinit.h>
|
2012-08-14 04:11:49 +00:00
|
|
|
#include <subdev/fb.h>
|
2015-01-14 05:24:57 +00:00
|
|
|
#include <subdev/timer.h>
|
2012-08-14 02:50:14 +00:00
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
#include <nvif/class.h>
|
|
|
|
#include <nvif/event.h>
|
|
|
|
#include <nvif/unpack.h>
|
2012-08-14 00:04:04 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
2012-08-14 04:11:49 +00:00
|
|
|
* EVO channel base class
|
2012-08-14 00:04:04 +00:00
|
|
|
******************************************************************************/
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_chan_create_(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, int head,
|
2012-08-14 04:11:49 +00:00
|
|
|
int length, void **pobject)
|
|
|
|
{
|
2014-08-09 18:10:25 +00:00
|
|
|
const struct nv50_disp_chan_impl *impl = (void *)oclass->ofuncs;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_base *base = (void *)parent;
|
|
|
|
struct nv50_disp_chan *chan;
|
2014-08-09 18:10:25 +00:00
|
|
|
int chid = impl->chid + head;
|
2012-08-14 04:11:49 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (base->chan & (1 << chid))
|
|
|
|
return -EBUSY;
|
|
|
|
base->chan |= (1 << chid);
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
ret = nvkm_namedb_create_(parent, engine, oclass, 0, NULL,
|
|
|
|
(1ULL << NVDEV_ENGINE_DMAOBJ),
|
|
|
|
length, pobject);
|
2012-08-14 04:11:49 +00:00
|
|
|
chan = *pobject;
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
chan->chid = chid;
|
2014-08-09 18:10:25 +00:00
|
|
|
|
|
|
|
nv_parent(chan)->object_attach = impl->attach;
|
|
|
|
nv_parent(chan)->object_detach = impl->detach;
|
2012-08-14 04:11:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
static void
|
2012-08-14 04:11:49 +00:00
|
|
|
nv50_disp_chan_destroy(struct nv50_disp_chan *chan)
|
|
|
|
{
|
|
|
|
struct nv50_disp_base *base = (void *)nv_object(chan)->parent;
|
|
|
|
base->chan &= ~(1 << chan->chid);
|
2015-01-14 05:24:57 +00:00
|
|
|
nvkm_namedb_destroy(&chan->base);
|
2012-08-14 04:11:49 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 04:38:10 +00:00
|
|
|
static void
|
|
|
|
nv50_disp_chan_uevent_fini(struct nvkm_event *event, int type, int index)
|
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = container_of(event, typeof(*disp), uevent);
|
|
|
|
nv_mask(disp, 0x610028, 0x00000001 << index, 0x00000000 << index);
|
|
|
|
nv_wr32(disp, 0x610020, 0x00000001 << index);
|
2014-08-11 04:38:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nv50_disp_chan_uevent_init(struct nvkm_event *event, int types, int index)
|
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = container_of(event, typeof(*disp), uevent);
|
|
|
|
nv_wr32(disp, 0x610020, 0x00000001 << index);
|
|
|
|
nv_mask(disp, 0x610028, 0x00000001 << index, 0x00000001 << index);
|
2014-08-11 04:38:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_chan_uevent_send(struct nv50_disp *disp, int chid)
|
2014-08-11 04:38:10 +00:00
|
|
|
{
|
|
|
|
struct nvif_notify_uevent_rep {
|
|
|
|
} rep;
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nvkm_event_send(&disp->uevent, 1, chid, &rep, sizeof(rep));
|
2014-08-11 04:38:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_chan_uevent_ctor(struct nvkm_object *object, void *data, u32 size,
|
2014-08-11 04:38:10 +00:00
|
|
|
struct nvkm_notify *notify)
|
|
|
|
{
|
|
|
|
struct nv50_disp_dmac *dmac = (void *)object;
|
|
|
|
union {
|
|
|
|
struct nvif_notify_uevent_req none;
|
|
|
|
} *args = data;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (nvif_unvers(args->none)) {
|
|
|
|
notify->size = sizeof(struct nvif_notify_uevent_rep);
|
|
|
|
notify->types = 1;
|
|
|
|
notify->index = dmac->base.chid;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct nvkm_event_func
|
|
|
|
nv50_disp_chan_uevent = {
|
|
|
|
.ctor = nv50_disp_chan_uevent_ctor,
|
|
|
|
.init = nv50_disp_chan_uevent_init,
|
|
|
|
.fini = nv50_disp_chan_uevent_fini,
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_chan_ntfy(struct nvkm_object *object, u32 type,
|
2014-08-11 04:38:10 +00:00
|
|
|
struct nvkm_event **pevent)
|
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2014-08-11 04:38:10 +00:00
|
|
|
switch (type) {
|
|
|
|
case NV50_DISP_CORE_CHANNEL_DMA_V0_NTFY_UEVENT:
|
2015-08-20 04:54:07 +00:00
|
|
|
*pevent = &disp->uevent;
|
2014-08-11 04:38:10 +00:00
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:28 +00:00
|
|
|
int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_chan_map(struct nvkm_object *object, u64 *addr, u32 *size)
|
2014-08-09 18:10:28 +00:00
|
|
|
{
|
|
|
|
struct nv50_disp_chan *chan = (void *)object;
|
|
|
|
*addr = nv_device_resource_start(nv_device(object), 0) +
|
|
|
|
0x640000 + (chan->chid * 0x1000);
|
|
|
|
*size = 0x001000;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-14 04:11:49 +00:00
|
|
|
u32
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_chan_rd32(struct nvkm_object *object, u64 addr)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_chan *chan = (void *)object;
|
2015-08-20 04:54:07 +00:00
|
|
|
return nv_rd32(disp, 0x640000 + (chan->chid * 0x1000) + addr);
|
2012-08-14 00:04:04 +00:00
|
|
|
}
|
|
|
|
|
2012-08-14 04:11:49 +00:00
|
|
|
void
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_chan_wr32(struct nvkm_object *object, u64 addr, u32 data)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_chan *chan = (void *)object;
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_wr32(disp, 0x640000 + (chan->chid * 0x1000) + addr, data);
|
2012-08-14 04:11:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* EVO DMA channel base class
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_dmac_object_attach(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *object, u32 name)
|
2012-08-14 04:11:49 +00:00
|
|
|
{
|
|
|
|
struct nv50_disp_base *base = (void *)parent->parent;
|
|
|
|
struct nv50_disp_chan *chan = (void *)parent;
|
|
|
|
u32 addr = nv_gpuobj(object)->node->offset;
|
|
|
|
u32 chid = chan->chid;
|
|
|
|
u32 data = (chid << 28) | (addr << 10) | chid;
|
2015-01-14 05:24:57 +00:00
|
|
|
return nvkm_ramht_insert(base->ramht, chid, name, data);
|
2012-08-14 04:11:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_dmac_object_detach(struct nvkm_object *parent, int cookie)
|
2012-08-14 04:11:49 +00:00
|
|
|
{
|
|
|
|
struct nv50_disp_base *base = (void *)parent->parent;
|
2015-01-14 05:24:57 +00:00
|
|
|
nvkm_ramht_remove(base->ramht, cookie);
|
2012-08-14 04:11:49 +00:00
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_dmac_create_(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, u32 pushbuf, int head,
|
2012-08-14 04:11:49 +00:00
|
|
|
int length, void **pobject)
|
|
|
|
{
|
|
|
|
struct nv50_disp_dmac *dmac;
|
|
|
|
int ret;
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
ret = nv50_disp_chan_create_(parent, engine, oclass, head,
|
2012-08-14 04:11:49 +00:00
|
|
|
length, pobject);
|
|
|
|
dmac = *pobject;
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
dmac->pushdma = (void *)nvkm_handle_ref(parent, pushbuf);
|
2012-08-14 04:11:49 +00:00
|
|
|
if (!dmac->pushdma)
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
switch (nv_mclass(dmac->pushdma)) {
|
|
|
|
case 0x0002:
|
|
|
|
case 0x003d:
|
|
|
|
if (dmac->pushdma->limit - dmac->pushdma->start != 0xfff)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (dmac->pushdma->target) {
|
|
|
|
case NV_MEM_TARGET_VRAM:
|
2015-03-09 23:13:08 +00:00
|
|
|
dmac->push = 0x00000001 | dmac->pushdma->start >> 8;
|
2012-08-14 04:11:49 +00:00
|
|
|
break;
|
2012-10-30 00:03:38 +00:00
|
|
|
case NV_MEM_TARGET_PCI_NOSNOOP:
|
|
|
|
dmac->push = 0x00000003 | dmac->pushdma->start >> 8;
|
|
|
|
break;
|
2012-08-14 04:11:49 +00:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_dmac_dtor(struct nvkm_object *object)
|
2012-08-14 04:11:49 +00:00
|
|
|
{
|
|
|
|
struct nv50_disp_dmac *dmac = (void *)object;
|
2015-01-14 05:24:57 +00:00
|
|
|
nvkm_object_ref(NULL, (struct nvkm_object **)&dmac->pushdma);
|
2012-08-14 04:11:49 +00:00
|
|
|
nv50_disp_chan_destroy(&dmac->base);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_dmac_init(struct nvkm_object *object)
|
2012-08-14 04:11:49 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_dmac *dmac = (void *)object;
|
|
|
|
int chid = dmac->base.chid;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = nv50_disp_chan_init(&dmac->base);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* enable error reporting */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x610028, 0x00010000 << chid, 0x00010000 << chid);
|
2012-08-14 04:11:49 +00:00
|
|
|
|
|
|
|
/* initialise channel for dma command submission */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_wr32(disp, 0x610204 + (chid * 0x0010), dmac->push);
|
|
|
|
nv_wr32(disp, 0x610208 + (chid * 0x0010), 0x00010000);
|
|
|
|
nv_wr32(disp, 0x61020c + (chid * 0x0010), chid);
|
|
|
|
nv_mask(disp, 0x610200 + (chid * 0x0010), 0x00000010, 0x00000010);
|
|
|
|
nv_wr32(disp, 0x640000 + (chid * 0x1000), 0x00000000);
|
|
|
|
nv_wr32(disp, 0x610200 + (chid * 0x0010), 0x00000013);
|
2012-08-14 04:11:49 +00:00
|
|
|
|
|
|
|
/* wait for it to go inactive */
|
2015-08-20 04:54:07 +00:00
|
|
|
if (!nv_wait(disp, 0x610200 + (chid * 0x10), 0x80000000, 0x00000000)) {
|
2012-08-14 04:11:49 +00:00
|
|
|
nv_error(dmac, "init timeout, 0x%08x\n",
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_rd32(disp, 0x610200 + (chid * 0x10)));
|
2012-08-14 04:11:49 +00:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_dmac_fini(struct nvkm_object *object, bool suspend)
|
2012-08-14 04:11:49 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_dmac *dmac = (void *)object;
|
|
|
|
int chid = dmac->base.chid;
|
|
|
|
|
|
|
|
/* deactivate channel */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x610200 + (chid * 0x0010), 0x00001010, 0x00001000);
|
|
|
|
nv_mask(disp, 0x610200 + (chid * 0x0010), 0x00000003, 0x00000000);
|
|
|
|
if (!nv_wait(disp, 0x610200 + (chid * 0x10), 0x001e0000, 0x00000000)) {
|
2012-08-14 04:11:49 +00:00
|
|
|
nv_error(dmac, "fini timeout, 0x%08x\n",
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_rd32(disp, 0x610200 + (chid * 0x10)));
|
2012-08-14 04:11:49 +00:00
|
|
|
if (suspend)
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2014-08-11 04:38:10 +00:00
|
|
|
/* disable error reporting and completion notifications */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x610028, 0x00010001 << chid, 0x00000000 << chid);
|
2012-08-14 04:11:49 +00:00
|
|
|
|
|
|
|
return nv50_disp_chan_fini(&dmac->base, suspend);
|
2012-08-14 00:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* EVO master channel object
|
|
|
|
******************************************************************************/
|
|
|
|
|
2014-02-20 05:14:10 +00:00
|
|
|
static void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_mthd_list(struct nv50_disp *disp, int debug, u32 base, int c,
|
2014-02-20 05:14:10 +00:00
|
|
|
const struct nv50_disp_mthd_list *list, int inst)
|
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nvkm_object *object = nv_object(disp);
|
2014-02-20 05:14:10 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; list->data[i].mthd; i++) {
|
|
|
|
if (list->data[i].addr) {
|
2015-08-20 04:54:07 +00:00
|
|
|
u32 next = nv_rd32(disp, list->data[i].addr + base + 0);
|
|
|
|
u32 prev = nv_rd32(disp, list->data[i].addr + base + c);
|
2014-02-20 05:14:10 +00:00
|
|
|
u32 mthd = list->data[i].mthd + (list->mthd * inst);
|
|
|
|
const char *name = list->data[i].name;
|
|
|
|
char mods[16];
|
|
|
|
|
|
|
|
if (prev != next)
|
|
|
|
snprintf(mods, sizeof(mods), "-> 0x%08x", next);
|
|
|
|
else
|
|
|
|
snprintf(mods, sizeof(mods), "%13c", ' ');
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_printk_(object, debug, "\t0x%04x: 0x%08x %s%s%s\n",
|
2014-02-20 05:14:10 +00:00
|
|
|
mthd, prev, mods, name ? " // " : "",
|
|
|
|
name ? name : "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_mthd_chan(struct nv50_disp *disp, int debug, int head,
|
2014-02-20 05:14:10 +00:00
|
|
|
const struct nv50_disp_mthd_chan *chan)
|
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nvkm_object *object = nv_object(disp);
|
|
|
|
const struct nv50_disp_impl *impl = (void *)object->oclass;
|
2014-02-20 05:14:10 +00:00
|
|
|
const struct nv50_disp_mthd_list *list;
|
|
|
|
int i, j;
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
if (debug > nv_subdev(disp)->debug)
|
2014-02-20 05:14:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; (list = chan->data[i].mthd) != NULL; i++) {
|
|
|
|
u32 base = head * chan->addr;
|
|
|
|
for (j = 0; j < chan->data[i].nr; j++, base += list->addr) {
|
|
|
|
const char *cname = chan->name;
|
|
|
|
const char *sname = "";
|
|
|
|
char cname_[16], sname_[16];
|
|
|
|
|
|
|
|
if (chan->addr) {
|
|
|
|
snprintf(cname_, sizeof(cname_), "%s %d",
|
|
|
|
chan->name, head);
|
|
|
|
cname = cname_;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chan->data[i].nr > 1) {
|
|
|
|
snprintf(sname_, sizeof(sname_), " - %s %d",
|
|
|
|
chan->data[i].name, j);
|
|
|
|
sname = sname_;
|
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_printk_(object, debug, "%s%s:\n", cname, sname);
|
|
|
|
nv50_disp_mthd_list(disp, debug, base, impl->mthd.prev,
|
2014-02-20 05:14:10 +00:00
|
|
|
list, j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct nv50_disp_mthd_list
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_core_mthd_base = {
|
2014-02-20 05:14:10 +00:00
|
|
|
.mthd = 0x0000,
|
|
|
|
.addr = 0x000000,
|
|
|
|
.data = {
|
|
|
|
{ 0x0080, 0x000000 },
|
|
|
|
{ 0x0084, 0x610bb8 },
|
|
|
|
{ 0x0088, 0x610b9c },
|
|
|
|
{ 0x008c, 0x000000 },
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct nv50_disp_mthd_list
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_core_mthd_dac = {
|
2014-02-20 05:14:10 +00:00
|
|
|
.mthd = 0x0080,
|
|
|
|
.addr = 0x000008,
|
|
|
|
.data = {
|
|
|
|
{ 0x0400, 0x610b58 },
|
|
|
|
{ 0x0404, 0x610bdc },
|
|
|
|
{ 0x0420, 0x610828 },
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct nv50_disp_mthd_list
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_core_mthd_sor = {
|
2014-02-20 05:14:10 +00:00
|
|
|
.mthd = 0x0040,
|
|
|
|
.addr = 0x000008,
|
|
|
|
.data = {
|
|
|
|
{ 0x0600, 0x610b70 },
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct nv50_disp_mthd_list
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_core_mthd_pior = {
|
2014-02-20 05:14:10 +00:00
|
|
|
.mthd = 0x0040,
|
|
|
|
.addr = 0x000008,
|
|
|
|
.data = {
|
|
|
|
{ 0x0700, 0x610b80 },
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct nv50_disp_mthd_list
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_core_mthd_head = {
|
2014-02-20 05:14:10 +00:00
|
|
|
.mthd = 0x0400,
|
|
|
|
.addr = 0x000540,
|
|
|
|
.data = {
|
|
|
|
{ 0x0800, 0x610ad8 },
|
|
|
|
{ 0x0804, 0x610ad0 },
|
|
|
|
{ 0x0808, 0x610a48 },
|
|
|
|
{ 0x080c, 0x610a78 },
|
|
|
|
{ 0x0810, 0x610ac0 },
|
|
|
|
{ 0x0814, 0x610af8 },
|
|
|
|
{ 0x0818, 0x610b00 },
|
|
|
|
{ 0x081c, 0x610ae8 },
|
|
|
|
{ 0x0820, 0x610af0 },
|
|
|
|
{ 0x0824, 0x610b08 },
|
|
|
|
{ 0x0828, 0x610b10 },
|
|
|
|
{ 0x082c, 0x610a68 },
|
|
|
|
{ 0x0830, 0x610a60 },
|
|
|
|
{ 0x0834, 0x000000 },
|
|
|
|
{ 0x0838, 0x610a40 },
|
|
|
|
{ 0x0840, 0x610a24 },
|
|
|
|
{ 0x0844, 0x610a2c },
|
|
|
|
{ 0x0848, 0x610aa8 },
|
|
|
|
{ 0x084c, 0x610ab0 },
|
|
|
|
{ 0x0860, 0x610a84 },
|
|
|
|
{ 0x0864, 0x610a90 },
|
|
|
|
{ 0x0868, 0x610b18 },
|
|
|
|
{ 0x086c, 0x610b20 },
|
|
|
|
{ 0x0870, 0x610ac8 },
|
|
|
|
{ 0x0874, 0x610a38 },
|
|
|
|
{ 0x0880, 0x610a58 },
|
|
|
|
{ 0x0884, 0x610a9c },
|
|
|
|
{ 0x08a0, 0x610a70 },
|
|
|
|
{ 0x08a4, 0x610a50 },
|
|
|
|
{ 0x08a8, 0x610ae0 },
|
|
|
|
{ 0x08c0, 0x610b28 },
|
|
|
|
{ 0x08c4, 0x610b30 },
|
|
|
|
{ 0x08c8, 0x610b40 },
|
|
|
|
{ 0x08d4, 0x610b38 },
|
|
|
|
{ 0x08d8, 0x610b48 },
|
|
|
|
{ 0x08dc, 0x610b50 },
|
|
|
|
{ 0x0900, 0x610a18 },
|
|
|
|
{ 0x0904, 0x610ab8 },
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct nv50_disp_mthd_chan
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_core_mthd_chan = {
|
2014-02-20 05:14:10 +00:00
|
|
|
.name = "Core",
|
|
|
|
.addr = 0x000000,
|
|
|
|
.data = {
|
2014-10-02 05:25:25 +00:00
|
|
|
{ "Global", 1, &nv50_disp_core_mthd_base },
|
|
|
|
{ "DAC", 3, &nv50_disp_core_mthd_dac },
|
|
|
|
{ "SOR", 2, &nv50_disp_core_mthd_sor },
|
|
|
|
{ "PIOR", 3, &nv50_disp_core_mthd_pior },
|
|
|
|
{ "HEAD", 2, &nv50_disp_core_mthd_head },
|
2014-02-20 05:14:10 +00:00
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_core_ctor(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2014-08-09 18:10:27 +00:00
|
|
|
union {
|
|
|
|
struct nv50_disp_core_channel_dma_v0 v0;
|
|
|
|
} *args = data;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_dmac *mast;
|
2012-08-14 00:04:04 +00:00
|
|
|
int ret;
|
|
|
|
|
2014-08-09 18:10:27 +00:00
|
|
|
nv_ioctl(parent, "create disp core channel dma size %d\n", size);
|
|
|
|
if (nvif_unpack(args->v0, 0, 0, false)) {
|
|
|
|
nv_ioctl(parent, "create disp core channel dma vers %d "
|
|
|
|
"pushbuf %08x\n",
|
|
|
|
args->v0.version, args->v0.pushbuf);
|
|
|
|
} else
|
|
|
|
return ret;
|
2012-08-14 04:11:49 +00:00
|
|
|
|
2014-08-09 18:10:27 +00:00
|
|
|
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->v0.pushbuf,
|
2012-08-14 04:11:49 +00:00
|
|
|
0, sizeof(*mast), (void **)&mast);
|
|
|
|
*pobject = nv_object(mast);
|
2012-08-14 00:04:04 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_core_init(struct nvkm_object *object)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_dmac *mast = (void *)object;
|
2012-08-14 00:04:04 +00:00
|
|
|
int ret;
|
|
|
|
|
2012-08-14 04:11:49 +00:00
|
|
|
ret = nv50_disp_chan_init(&mast->base);
|
2012-08-14 00:04:04 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2012-08-14 04:11:49 +00:00
|
|
|
/* enable error reporting */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x610028, 0x00010000, 0x00010000);
|
2012-08-14 04:11:49 +00:00
|
|
|
|
|
|
|
/* attempt to unstick channel from some unknown state */
|
2015-08-20 04:54:07 +00:00
|
|
|
if ((nv_rd32(disp, 0x610200) & 0x009f0000) == 0x00020000)
|
|
|
|
nv_mask(disp, 0x610200, 0x00800000, 0x00800000);
|
|
|
|
if ((nv_rd32(disp, 0x610200) & 0x003f0000) == 0x00030000)
|
|
|
|
nv_mask(disp, 0x610200, 0x00600000, 0x00600000);
|
2012-08-14 04:11:49 +00:00
|
|
|
|
|
|
|
/* initialise channel for dma command submission */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_wr32(disp, 0x610204, mast->push);
|
|
|
|
nv_wr32(disp, 0x610208, 0x00010000);
|
|
|
|
nv_wr32(disp, 0x61020c, 0x00000000);
|
|
|
|
nv_mask(disp, 0x610200, 0x00000010, 0x00000010);
|
|
|
|
nv_wr32(disp, 0x640000, 0x00000000);
|
|
|
|
nv_wr32(disp, 0x610200, 0x01000013);
|
2012-08-14 04:11:49 +00:00
|
|
|
|
|
|
|
/* wait for it to go inactive */
|
2015-08-20 04:54:07 +00:00
|
|
|
if (!nv_wait(disp, 0x610200, 0x80000000, 0x00000000)) {
|
|
|
|
nv_error(mast, "init: 0x%08x\n", nv_rd32(disp, 0x610200));
|
2012-08-14 04:11:49 +00:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2012-08-14 00:04:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_core_fini(struct nvkm_object *object, bool suspend)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_dmac *mast = (void *)object;
|
|
|
|
|
|
|
|
/* deactivate channel */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x610200, 0x00000010, 0x00000000);
|
|
|
|
nv_mask(disp, 0x610200, 0x00000003, 0x00000000);
|
|
|
|
if (!nv_wait(disp, 0x610200, 0x001e0000, 0x00000000)) {
|
|
|
|
nv_error(mast, "fini: 0x%08x\n", nv_rd32(disp, 0x610200));
|
2012-08-14 04:11:49 +00:00
|
|
|
if (suspend)
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2014-08-11 04:38:10 +00:00
|
|
|
/* disable error reporting and completion notifications */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x610028, 0x00010001, 0x00000000);
|
2012-08-14 04:11:49 +00:00
|
|
|
|
|
|
|
return nv50_disp_chan_fini(&mast->base, suspend);
|
2012-08-14 00:04:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
struct nv50_disp_chan_impl
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_core_ofuncs = {
|
|
|
|
.base.ctor = nv50_disp_core_ctor,
|
2014-08-09 18:10:25 +00:00
|
|
|
.base.dtor = nv50_disp_dmac_dtor,
|
2014-10-02 05:25:25 +00:00
|
|
|
.base.init = nv50_disp_core_init,
|
|
|
|
.base.fini = nv50_disp_core_fini,
|
2014-08-09 18:10:28 +00:00
|
|
|
.base.map = nv50_disp_chan_map,
|
2014-08-11 04:38:10 +00:00
|
|
|
.base.ntfy = nv50_disp_chan_ntfy,
|
2014-08-09 18:10:25 +00:00
|
|
|
.base.rd32 = nv50_disp_chan_rd32,
|
|
|
|
.base.wr32 = nv50_disp_chan_wr32,
|
|
|
|
.chid = 0,
|
|
|
|
.attach = nv50_disp_dmac_object_attach,
|
|
|
|
.detach = nv50_disp_dmac_object_detach,
|
2012-08-14 00:04:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
2012-08-14 04:11:49 +00:00
|
|
|
* EVO sync channel objects
|
2012-08-14 00:04:04 +00:00
|
|
|
******************************************************************************/
|
|
|
|
|
2014-02-20 05:14:10 +00:00
|
|
|
static const struct nv50_disp_mthd_list
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_base_mthd_base = {
|
2014-02-20 05:14:10 +00:00
|
|
|
.mthd = 0x0000,
|
|
|
|
.addr = 0x000000,
|
|
|
|
.data = {
|
|
|
|
{ 0x0080, 0x000000 },
|
|
|
|
{ 0x0084, 0x0008c4 },
|
|
|
|
{ 0x0088, 0x0008d0 },
|
|
|
|
{ 0x008c, 0x0008dc },
|
|
|
|
{ 0x0090, 0x0008e4 },
|
|
|
|
{ 0x0094, 0x610884 },
|
|
|
|
{ 0x00a0, 0x6108a0 },
|
|
|
|
{ 0x00a4, 0x610878 },
|
|
|
|
{ 0x00c0, 0x61086c },
|
|
|
|
{ 0x00e0, 0x610858 },
|
|
|
|
{ 0x00e4, 0x610860 },
|
|
|
|
{ 0x00e8, 0x6108ac },
|
|
|
|
{ 0x00ec, 0x6108b4 },
|
|
|
|
{ 0x0100, 0x610894 },
|
|
|
|
{ 0x0110, 0x6108bc },
|
|
|
|
{ 0x0114, 0x61088c },
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct nv50_disp_mthd_list
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_base_mthd_image = {
|
2014-02-20 05:14:10 +00:00
|
|
|
.mthd = 0x0400,
|
|
|
|
.addr = 0x000000,
|
|
|
|
.data = {
|
|
|
|
{ 0x0800, 0x6108f0 },
|
|
|
|
{ 0x0804, 0x6108fc },
|
|
|
|
{ 0x0808, 0x61090c },
|
|
|
|
{ 0x080c, 0x610914 },
|
|
|
|
{ 0x0810, 0x610904 },
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct nv50_disp_mthd_chan
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_base_mthd_chan = {
|
2014-02-20 05:14:10 +00:00
|
|
|
.name = "Base",
|
|
|
|
.addr = 0x000540,
|
|
|
|
.data = {
|
2014-10-02 05:25:25 +00:00
|
|
|
{ "Global", 1, &nv50_disp_base_mthd_base },
|
|
|
|
{ "Image", 2, &nv50_disp_base_mthd_image },
|
2014-02-20 05:14:10 +00:00
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_base_ctor(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2014-08-09 18:10:27 +00:00
|
|
|
union {
|
|
|
|
struct nv50_disp_base_channel_dma_v0 v0;
|
|
|
|
} *args = data;
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_dmac *dmac;
|
2012-08-14 00:04:04 +00:00
|
|
|
int ret;
|
|
|
|
|
2014-08-09 18:10:27 +00:00
|
|
|
nv_ioctl(parent, "create disp base channel dma size %d\n", size);
|
|
|
|
if (nvif_unpack(args->v0, 0, 0, false)) {
|
|
|
|
nv_ioctl(parent, "create disp base channel dma vers %d "
|
|
|
|
"pushbuf %08x head %d\n",
|
|
|
|
args->v0.version, args->v0.pushbuf, args->v0.head);
|
2015-08-20 04:54:07 +00:00
|
|
|
if (args->v0.head > disp->head.nr)
|
2014-08-09 18:10:27 +00:00
|
|
|
return -EINVAL;
|
|
|
|
} else
|
|
|
|
return ret;
|
2012-08-14 04:11:49 +00:00
|
|
|
|
2014-08-09 18:10:27 +00:00
|
|
|
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->v0.pushbuf,
|
|
|
|
args->v0.head, sizeof(*dmac),
|
|
|
|
(void **)&dmac);
|
2012-08-14 04:11:49 +00:00
|
|
|
*pobject = nv_object(dmac);
|
2012-08-14 00:04:04 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
struct nv50_disp_chan_impl
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_base_ofuncs = {
|
|
|
|
.base.ctor = nv50_disp_base_ctor,
|
2014-08-09 18:10:25 +00:00
|
|
|
.base.dtor = nv50_disp_dmac_dtor,
|
|
|
|
.base.init = nv50_disp_dmac_init,
|
|
|
|
.base.fini = nv50_disp_dmac_fini,
|
2014-08-11 04:38:10 +00:00
|
|
|
.base.ntfy = nv50_disp_chan_ntfy,
|
2014-08-09 18:10:28 +00:00
|
|
|
.base.map = nv50_disp_chan_map,
|
2014-08-09 18:10:25 +00:00
|
|
|
.base.rd32 = nv50_disp_chan_rd32,
|
|
|
|
.base.wr32 = nv50_disp_chan_wr32,
|
|
|
|
.chid = 1,
|
|
|
|
.attach = nv50_disp_dmac_object_attach,
|
|
|
|
.detach = nv50_disp_dmac_object_detach,
|
2012-08-14 04:11:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* EVO overlay channel objects
|
|
|
|
******************************************************************************/
|
2012-08-14 00:04:04 +00:00
|
|
|
|
2014-02-20 05:14:10 +00:00
|
|
|
const struct nv50_disp_mthd_list
|
|
|
|
nv50_disp_ovly_mthd_base = {
|
|
|
|
.mthd = 0x0000,
|
|
|
|
.addr = 0x000000,
|
|
|
|
.data = {
|
|
|
|
{ 0x0080, 0x000000 },
|
|
|
|
{ 0x0084, 0x0009a0 },
|
|
|
|
{ 0x0088, 0x0009c0 },
|
|
|
|
{ 0x008c, 0x0009c8 },
|
|
|
|
{ 0x0090, 0x6109b4 },
|
|
|
|
{ 0x0094, 0x610970 },
|
|
|
|
{ 0x00a0, 0x610998 },
|
|
|
|
{ 0x00a4, 0x610964 },
|
|
|
|
{ 0x00c0, 0x610958 },
|
|
|
|
{ 0x00e0, 0x6109a8 },
|
|
|
|
{ 0x00e4, 0x6109d0 },
|
|
|
|
{ 0x00e8, 0x6109d8 },
|
|
|
|
{ 0x0100, 0x61094c },
|
|
|
|
{ 0x0104, 0x610984 },
|
|
|
|
{ 0x0108, 0x61098c },
|
|
|
|
{ 0x0800, 0x6109f8 },
|
|
|
|
{ 0x0808, 0x610a08 },
|
|
|
|
{ 0x080c, 0x610a10 },
|
|
|
|
{ 0x0810, 0x610a00 },
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct nv50_disp_mthd_chan
|
|
|
|
nv50_disp_ovly_mthd_chan = {
|
|
|
|
.name = "Overlay",
|
|
|
|
.addr = 0x000540,
|
|
|
|
.data = {
|
|
|
|
{ "Global", 1, &nv50_disp_ovly_mthd_base },
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_ovly_ctor(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2014-08-09 18:10:27 +00:00
|
|
|
union {
|
|
|
|
struct nv50_disp_overlay_channel_dma_v0 v0;
|
|
|
|
} *args = data;
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_dmac *dmac;
|
2012-08-14 00:04:04 +00:00
|
|
|
int ret;
|
|
|
|
|
2014-08-09 18:10:27 +00:00
|
|
|
nv_ioctl(parent, "create disp overlay channel dma size %d\n", size);
|
|
|
|
if (nvif_unpack(args->v0, 0, 0, false)) {
|
|
|
|
nv_ioctl(parent, "create disp overlay channel dma vers %d "
|
|
|
|
"pushbuf %08x head %d\n",
|
|
|
|
args->v0.version, args->v0.pushbuf, args->v0.head);
|
2015-08-20 04:54:07 +00:00
|
|
|
if (args->v0.head > disp->head.nr)
|
2014-08-09 18:10:27 +00:00
|
|
|
return -EINVAL;
|
|
|
|
} else
|
|
|
|
return ret;
|
2012-08-14 04:11:49 +00:00
|
|
|
|
2014-08-09 18:10:27 +00:00
|
|
|
ret = nv50_disp_dmac_create_(parent, engine, oclass, args->v0.pushbuf,
|
|
|
|
args->v0.head, sizeof(*dmac),
|
|
|
|
(void **)&dmac);
|
2012-08-14 04:11:49 +00:00
|
|
|
*pobject = nv_object(dmac);
|
2012-08-14 00:04:04 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
struct nv50_disp_chan_impl
|
2012-08-14 04:11:49 +00:00
|
|
|
nv50_disp_ovly_ofuncs = {
|
2014-08-09 18:10:25 +00:00
|
|
|
.base.ctor = nv50_disp_ovly_ctor,
|
|
|
|
.base.dtor = nv50_disp_dmac_dtor,
|
|
|
|
.base.init = nv50_disp_dmac_init,
|
|
|
|
.base.fini = nv50_disp_dmac_fini,
|
2014-08-11 04:38:10 +00:00
|
|
|
.base.ntfy = nv50_disp_chan_ntfy,
|
2014-08-09 18:10:28 +00:00
|
|
|
.base.map = nv50_disp_chan_map,
|
2014-08-09 18:10:25 +00:00
|
|
|
.base.rd32 = nv50_disp_chan_rd32,
|
|
|
|
.base.wr32 = nv50_disp_chan_wr32,
|
|
|
|
.chid = 3,
|
|
|
|
.attach = nv50_disp_dmac_object_attach,
|
|
|
|
.detach = nv50_disp_dmac_object_detach,
|
2012-08-14 00:04:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
2012-08-14 04:11:49 +00:00
|
|
|
* EVO PIO channel base class
|
2012-08-14 00:04:04 +00:00
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_pioc_create_(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, int head,
|
2012-08-14 04:11:49 +00:00
|
|
|
int length, void **pobject)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2014-08-09 18:10:25 +00:00
|
|
|
return nv50_disp_chan_create_(parent, engine, oclass, head,
|
2012-08-14 04:11:49 +00:00
|
|
|
length, pobject);
|
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
void
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_pioc_dtor(struct nvkm_object *object)
|
2012-08-14 04:11:49 +00:00
|
|
|
{
|
|
|
|
struct nv50_disp_pioc *pioc = (void *)object;
|
|
|
|
nv50_disp_chan_destroy(&pioc->base);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_pioc_init(struct nvkm_object *object)
|
2012-08-14 04:11:49 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_pioc *pioc = (void *)object;
|
|
|
|
int chid = pioc->base.chid;
|
2012-08-14 00:04:04 +00:00
|
|
|
int ret;
|
|
|
|
|
2012-08-14 04:11:49 +00:00
|
|
|
ret = nv50_disp_chan_init(&pioc->base);
|
2012-08-14 00:04:04 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_wr32(disp, 0x610200 + (chid * 0x10), 0x00002000);
|
|
|
|
if (!nv_wait(disp, 0x610200 + (chid * 0x10), 0x00000000, 0x00000000)) {
|
2012-08-14 04:11:49 +00:00
|
|
|
nv_error(pioc, "timeout0: 0x%08x\n",
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_rd32(disp, 0x610200 + (chid * 0x10)));
|
2012-08-14 04:11:49 +00:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_wr32(disp, 0x610200 + (chid * 0x10), 0x00000001);
|
|
|
|
if (!nv_wait(disp, 0x610200 + (chid * 0x10), 0x00030000, 0x00010000)) {
|
2012-08-14 04:11:49 +00:00
|
|
|
nv_error(pioc, "timeout1: 0x%08x\n",
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_rd32(disp, 0x610200 + (chid * 0x10)));
|
2012-08-14 04:11:49 +00:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2012-08-14 00:04:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-14 04:11:49 +00:00
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_pioc_fini(struct nvkm_object *object, bool suspend)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_pioc *pioc = (void *)object;
|
|
|
|
int chid = pioc->base.chid;
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x610200 + (chid * 0x10), 0x00000001, 0x00000000);
|
|
|
|
if (!nv_wait(disp, 0x610200 + (chid * 0x10), 0x00030000, 0x00000000)) {
|
2012-08-14 04:11:49 +00:00
|
|
|
nv_error(pioc, "timeout: 0x%08x\n",
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_rd32(disp, 0x610200 + (chid * 0x10)));
|
2012-08-14 04:11:49 +00:00
|
|
|
if (suspend)
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nv50_disp_chan_fini(&pioc->base, suspend);
|
2012-08-14 00:04:04 +00:00
|
|
|
}
|
|
|
|
|
2012-08-14 04:11:49 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* EVO immediate overlay channel objects
|
|
|
|
******************************************************************************/
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_oimm_ctor(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2014-08-09 18:10:27 +00:00
|
|
|
union {
|
|
|
|
struct nv50_disp_overlay_v0 v0;
|
|
|
|
} *args = data;
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_pioc *pioc;
|
2012-08-14 00:04:04 +00:00
|
|
|
int ret;
|
|
|
|
|
2014-08-09 18:10:27 +00:00
|
|
|
nv_ioctl(parent, "create disp overlay size %d\n", size);
|
|
|
|
if (nvif_unpack(args->v0, 0, 0, false)) {
|
|
|
|
nv_ioctl(parent, "create disp overlay vers %d head %d\n",
|
|
|
|
args->v0.version, args->v0.head);
|
2015-08-20 04:54:07 +00:00
|
|
|
if (args->v0.head > disp->head.nr)
|
2014-08-09 18:10:27 +00:00
|
|
|
return -EINVAL;
|
|
|
|
} else
|
|
|
|
return ret;
|
2012-08-14 04:11:49 +00:00
|
|
|
|
2014-08-09 18:10:27 +00:00
|
|
|
ret = nv50_disp_pioc_create_(parent, engine, oclass, args->v0.head,
|
2012-08-14 04:11:49 +00:00
|
|
|
sizeof(*pioc), (void **)&pioc);
|
|
|
|
*pobject = nv_object(pioc);
|
2012-08-14 00:04:04 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
struct nv50_disp_chan_impl
|
2012-08-14 04:11:49 +00:00
|
|
|
nv50_disp_oimm_ofuncs = {
|
2014-08-09 18:10:25 +00:00
|
|
|
.base.ctor = nv50_disp_oimm_ctor,
|
|
|
|
.base.dtor = nv50_disp_pioc_dtor,
|
|
|
|
.base.init = nv50_disp_pioc_init,
|
|
|
|
.base.fini = nv50_disp_pioc_fini,
|
2014-08-11 04:38:10 +00:00
|
|
|
.base.ntfy = nv50_disp_chan_ntfy,
|
2014-08-09 18:10:28 +00:00
|
|
|
.base.map = nv50_disp_chan_map,
|
2014-08-09 18:10:25 +00:00
|
|
|
.base.rd32 = nv50_disp_chan_rd32,
|
|
|
|
.base.wr32 = nv50_disp_chan_wr32,
|
|
|
|
.chid = 5,
|
2012-08-14 04:11:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* EVO cursor channel objects
|
|
|
|
******************************************************************************/
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_curs_ctor(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2014-08-09 18:10:27 +00:00
|
|
|
union {
|
|
|
|
struct nv50_disp_cursor_v0 v0;
|
|
|
|
} *args = data;
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)engine;
|
2012-08-14 04:11:49 +00:00
|
|
|
struct nv50_disp_pioc *pioc;
|
|
|
|
int ret;
|
|
|
|
|
2014-08-09 18:10:27 +00:00
|
|
|
nv_ioctl(parent, "create disp cursor size %d\n", size);
|
|
|
|
if (nvif_unpack(args->v0, 0, 0, false)) {
|
|
|
|
nv_ioctl(parent, "create disp cursor vers %d head %d\n",
|
|
|
|
args->v0.version, args->v0.head);
|
2015-08-20 04:54:07 +00:00
|
|
|
if (args->v0.head > disp->head.nr)
|
2014-08-09 18:10:27 +00:00
|
|
|
return -EINVAL;
|
|
|
|
} else
|
|
|
|
return ret;
|
2012-08-14 04:11:49 +00:00
|
|
|
|
2014-08-09 18:10:27 +00:00
|
|
|
ret = nv50_disp_pioc_create_(parent, engine, oclass, args->v0.head,
|
2012-08-14 04:11:49 +00:00
|
|
|
sizeof(*pioc), (void **)&pioc);
|
|
|
|
*pobject = nv_object(pioc);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
2012-08-14 00:04:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:25 +00:00
|
|
|
struct nv50_disp_chan_impl
|
2012-08-14 04:11:49 +00:00
|
|
|
nv50_disp_curs_ofuncs = {
|
2014-08-09 18:10:25 +00:00
|
|
|
.base.ctor = nv50_disp_curs_ctor,
|
|
|
|
.base.dtor = nv50_disp_pioc_dtor,
|
|
|
|
.base.init = nv50_disp_pioc_init,
|
|
|
|
.base.fini = nv50_disp_pioc_fini,
|
2014-08-11 04:38:10 +00:00
|
|
|
.base.ntfy = nv50_disp_chan_ntfy,
|
2014-08-09 18:10:28 +00:00
|
|
|
.base.map = nv50_disp_chan_map,
|
2014-08-09 18:10:25 +00:00
|
|
|
.base.rd32 = nv50_disp_chan_rd32,
|
|
|
|
.base.wr32 = nv50_disp_chan_wr32,
|
|
|
|
.chid = 7,
|
2012-08-14 00:04:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Base display object
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-11-14 03:37:48 +00:00
|
|
|
int
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_main_scanoutpos(NV50_DISP_MTHD_V0)
|
2013-11-14 03:37:48 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
const u32 blanke = nv_rd32(disp, 0x610aec + (head * 0x540));
|
|
|
|
const u32 blanks = nv_rd32(disp, 0x610af4 + (head * 0x540));
|
|
|
|
const u32 total = nv_rd32(disp, 0x610afc + (head * 0x540));
|
2014-08-09 18:10:27 +00:00
|
|
|
union {
|
|
|
|
struct nv04_disp_scanoutpos_v0 v0;
|
|
|
|
} *args = data;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
nv_ioctl(object, "disp scanoutpos size %d\n", size);
|
|
|
|
if (nvif_unpack(args->v0, 0, 0, false)) {
|
|
|
|
nv_ioctl(object, "disp scanoutpos vers %d\n", args->v0.version);
|
|
|
|
args->v0.vblanke = (blanke & 0xffff0000) >> 16;
|
|
|
|
args->v0.hblanke = (blanke & 0x0000ffff);
|
|
|
|
args->v0.vblanks = (blanks & 0xffff0000) >> 16;
|
|
|
|
args->v0.hblanks = (blanks & 0x0000ffff);
|
|
|
|
args->v0.vtotal = ( total & 0xffff0000) >> 16;
|
|
|
|
args->v0.htotal = ( total & 0x0000ffff);
|
|
|
|
args->v0.time[0] = ktime_to_ns(ktime_get());
|
|
|
|
args->v0.vline = /* vline read locks hline */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_rd32(disp, 0x616340 + (head * 0x800)) & 0xffff;
|
2014-08-09 18:10:27 +00:00
|
|
|
args->v0.time[1] = ktime_to_ns(ktime_get());
|
|
|
|
args->v0.hline =
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_rd32(disp, 0x616344 + (head * 0x800)) & 0xffff;
|
2014-08-09 18:10:27 +00:00
|
|
|
} else
|
|
|
|
return ret;
|
2013-11-14 03:37:48 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:26 +00:00
|
|
|
int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_main_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
|
2014-08-09 18:10:26 +00:00
|
|
|
{
|
2014-08-09 18:10:27 +00:00
|
|
|
const struct nv50_disp_impl *impl = (void *)nv_oclass(object->engine);
|
2014-08-09 18:10:26 +00:00
|
|
|
union {
|
|
|
|
struct nv50_disp_mthd_v0 v0;
|
|
|
|
struct nv50_disp_mthd_v1 v1;
|
|
|
|
} *args = data;
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2014-08-09 18:10:26 +00:00
|
|
|
struct nvkm_output *outp = NULL;
|
|
|
|
struct nvkm_output *temp;
|
|
|
|
u16 type, mask = 0;
|
|
|
|
int head, ret;
|
|
|
|
|
|
|
|
if (mthd != NV50_DISP_MTHD)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
nv_ioctl(object, "disp mthd size %d\n", size);
|
|
|
|
if (nvif_unpack(args->v0, 0, 0, true)) {
|
|
|
|
nv_ioctl(object, "disp mthd vers %d mthd %02x head %d\n",
|
|
|
|
args->v0.version, args->v0.method, args->v0.head);
|
|
|
|
mthd = args->v0.method;
|
|
|
|
head = args->v0.head;
|
|
|
|
} else
|
|
|
|
if (nvif_unpack(args->v1, 1, 1, true)) {
|
|
|
|
nv_ioctl(object, "disp mthd vers %d mthd %02x "
|
|
|
|
"type %04x mask %04x\n",
|
|
|
|
args->v1.version, args->v1.method,
|
|
|
|
args->v1.hasht, args->v1.hashm);
|
|
|
|
mthd = args->v1.method;
|
|
|
|
type = args->v1.hasht;
|
|
|
|
mask = args->v1.hashm;
|
|
|
|
head = ffs((mask >> 8) & 0x0f) - 1;
|
|
|
|
} else
|
|
|
|
return ret;
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
if (head < 0 || head >= disp->head.nr)
|
2014-08-09 18:10:26 +00:00
|
|
|
return -ENXIO;
|
|
|
|
|
|
|
|
if (mask) {
|
2015-08-20 04:54:07 +00:00
|
|
|
list_for_each_entry(temp, &disp->base.outp, head) {
|
2014-08-09 18:10:26 +00:00
|
|
|
if ((temp->info.hasht == type) &&
|
|
|
|
(temp->info.hashm & mask) == mask) {
|
|
|
|
outp = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (outp == NULL)
|
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mthd) {
|
2014-08-09 18:10:27 +00:00
|
|
|
case NV50_DISP_SCANOUTPOS:
|
2015-08-20 04:54:07 +00:00
|
|
|
return impl->head.scanoutpos(object, disp, data, size, head);
|
2014-08-09 18:10:26 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mthd * !!outp) {
|
|
|
|
case NV50_DISP_MTHD_V1_DAC_PWR:
|
2015-08-20 04:54:07 +00:00
|
|
|
return disp->dac.power(object, disp, data, size, head, outp);
|
2014-08-09 18:10:26 +00:00
|
|
|
case NV50_DISP_MTHD_V1_DAC_LOAD:
|
2015-08-20 04:54:07 +00:00
|
|
|
return disp->dac.sense(object, disp, data, size, head, outp);
|
2014-08-09 18:10:26 +00:00
|
|
|
case NV50_DISP_MTHD_V1_SOR_PWR:
|
2015-08-20 04:54:07 +00:00
|
|
|
return disp->sor.power(object, disp, data, size, head, outp);
|
2014-08-09 18:10:26 +00:00
|
|
|
case NV50_DISP_MTHD_V1_SOR_HDA_ELD:
|
2015-08-20 04:54:07 +00:00
|
|
|
if (!disp->sor.hda_eld)
|
2014-08-09 18:10:26 +00:00
|
|
|
return -ENODEV;
|
2015-08-20 04:54:07 +00:00
|
|
|
return disp->sor.hda_eld(object, disp, data, size, head, outp);
|
2014-08-09 18:10:26 +00:00
|
|
|
case NV50_DISP_MTHD_V1_SOR_HDMI_PWR:
|
2015-08-20 04:54:07 +00:00
|
|
|
if (!disp->sor.hdmi)
|
2014-08-09 18:10:26 +00:00
|
|
|
return -ENODEV;
|
2015-08-20 04:54:07 +00:00
|
|
|
return disp->sor.hdmi(object, disp, data, size, head, outp);
|
2014-08-09 18:10:27 +00:00
|
|
|
case NV50_DISP_MTHD_V1_SOR_LVDS_SCRIPT: {
|
|
|
|
union {
|
|
|
|
struct nv50_disp_sor_lvds_script_v0 v0;
|
|
|
|
} *args = data;
|
|
|
|
nv_ioctl(object, "disp sor lvds script size %d\n", size);
|
|
|
|
if (nvif_unpack(args->v0, 0, 0, false)) {
|
|
|
|
nv_ioctl(object, "disp sor lvds script "
|
|
|
|
"vers %d name %04x\n",
|
|
|
|
args->v0.version, args->v0.script);
|
2015-08-20 04:54:07 +00:00
|
|
|
disp->sor.lvdsconf = args->v0.script;
|
2014-08-09 18:10:27 +00:00
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
break;
|
2014-08-09 18:10:27 +00:00
|
|
|
case NV50_DISP_MTHD_V1_SOR_DP_PWR: {
|
|
|
|
struct nvkm_output_dp *outpdp = (void *)outp;
|
|
|
|
union {
|
|
|
|
struct nv50_disp_sor_dp_pwr_v0 v0;
|
|
|
|
} *args = data;
|
|
|
|
nv_ioctl(object, "disp sor dp pwr size %d\n", size);
|
|
|
|
if (nvif_unpack(args->v0, 0, 0, false)) {
|
|
|
|
nv_ioctl(object, "disp sor dp pwr vers %d state %d\n",
|
|
|
|
args->v0.version, args->v0.state);
|
|
|
|
if (args->v0.state == 0) {
|
|
|
|
nvkm_notify_put(&outpdp->irq);
|
|
|
|
((struct nvkm_output_dp_impl *)nv_oclass(outp))
|
|
|
|
->lnk_pwr(outpdp, 0);
|
|
|
|
atomic_set(&outpdp->lt.done, 0);
|
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
if (args->v0.state != 0) {
|
|
|
|
nvkm_output_dp_train(&outpdp->base, 0, true);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
break;
|
2014-08-09 18:10:27 +00:00
|
|
|
case NV50_DISP_MTHD_V1_PIOR_PWR:
|
2015-08-20 04:54:07 +00:00
|
|
|
if (!disp->pior.power)
|
2014-08-09 18:10:27 +00:00
|
|
|
return -ENODEV;
|
2015-08-20 04:54:07 +00:00
|
|
|
return disp->pior.power(object, disp, data, size, head, outp);
|
2014-08-09 18:10:26 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:20 +00:00
|
|
|
int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_main_ctor(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)engine;
|
2012-08-14 00:04:04 +00:00
|
|
|
struct nv50_disp_base *base;
|
|
|
|
int ret;
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
ret = nvkm_parent_create(parent, engine, oclass, 0,
|
2015-08-20 04:54:07 +00:00
|
|
|
disp->sclass, 0, &base);
|
2012-08-14 00:04:04 +00:00
|
|
|
*pobject = nv_object(base);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
return nvkm_ramht_new(nv_object(base), nv_object(base), 0x1000, 0,
|
|
|
|
&base->ramht);
|
2012-08-14 00:04:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-09 18:10:20 +00:00
|
|
|
void
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_main_dtor(struct nvkm_object *object)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
|
|
|
struct nv50_disp_base *base = (void *)object;
|
2015-01-14 05:24:57 +00:00
|
|
|
nvkm_ramht_ref(NULL, &base->ramht);
|
|
|
|
nvkm_parent_destroy(&base->base);
|
2012-08-14 00:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_main_init(struct nvkm_object *object)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2012-08-14 00:04:04 +00:00
|
|
|
struct nv50_disp_base *base = (void *)object;
|
2012-08-14 01:29:57 +00:00
|
|
|
int ret, i;
|
|
|
|
u32 tmp;
|
2012-08-14 00:04:04 +00:00
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
ret = nvkm_parent_init(&base->base);
|
2012-08-14 00:04:04 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2012-08-14 01:29:57 +00:00
|
|
|
/* The below segments of code copying values from one register to
|
|
|
|
* another appear to inform EVO of the display capabilities or
|
|
|
|
* something similar. NFI what the 0x614004 caps are for..
|
|
|
|
*/
|
2015-08-20 04:54:07 +00:00
|
|
|
tmp = nv_rd32(disp, 0x614004);
|
|
|
|
nv_wr32(disp, 0x610184, tmp);
|
2012-08-14 01:29:57 +00:00
|
|
|
|
|
|
|
/* ... CRTC caps */
|
2015-08-20 04:54:07 +00:00
|
|
|
for (i = 0; i < disp->head.nr; i++) {
|
|
|
|
tmp = nv_rd32(disp, 0x616100 + (i * 0x800));
|
|
|
|
nv_wr32(disp, 0x610190 + (i * 0x10), tmp);
|
|
|
|
tmp = nv_rd32(disp, 0x616104 + (i * 0x800));
|
|
|
|
nv_wr32(disp, 0x610194 + (i * 0x10), tmp);
|
|
|
|
tmp = nv_rd32(disp, 0x616108 + (i * 0x800));
|
|
|
|
nv_wr32(disp, 0x610198 + (i * 0x10), tmp);
|
|
|
|
tmp = nv_rd32(disp, 0x61610c + (i * 0x800));
|
|
|
|
nv_wr32(disp, 0x61019c + (i * 0x10), tmp);
|
2012-08-14 01:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ... DAC caps */
|
2015-08-20 04:54:07 +00:00
|
|
|
for (i = 0; i < disp->dac.nr; i++) {
|
|
|
|
tmp = nv_rd32(disp, 0x61a000 + (i * 0x800));
|
|
|
|
nv_wr32(disp, 0x6101d0 + (i * 0x04), tmp);
|
2012-08-14 01:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ... SOR caps */
|
2015-08-20 04:54:07 +00:00
|
|
|
for (i = 0; i < disp->sor.nr; i++) {
|
|
|
|
tmp = nv_rd32(disp, 0x61c000 + (i * 0x800));
|
|
|
|
nv_wr32(disp, 0x6101e0 + (i * 0x04), tmp);
|
2012-08-14 01:29:57 +00:00
|
|
|
}
|
|
|
|
|
2013-02-10 23:24:23 +00:00
|
|
|
/* ... PIOR caps */
|
2015-08-20 04:54:07 +00:00
|
|
|
for (i = 0; i < disp->pior.nr; i++) {
|
|
|
|
tmp = nv_rd32(disp, 0x61e000 + (i * 0x800));
|
|
|
|
nv_wr32(disp, 0x6101f0 + (i * 0x04), tmp);
|
2012-08-14 01:29:57 +00:00
|
|
|
}
|
|
|
|
|
2012-08-14 02:50:14 +00:00
|
|
|
/* steal display away from vbios, or something like that */
|
2015-08-20 04:54:07 +00:00
|
|
|
if (nv_rd32(disp, 0x610024) & 0x00000100) {
|
|
|
|
nv_wr32(disp, 0x610024, 0x00000100);
|
|
|
|
nv_mask(disp, 0x6194e8, 0x00000001, 0x00000000);
|
|
|
|
if (!nv_wait(disp, 0x6194e8, 0x00000002, 0x00000000)) {
|
|
|
|
nv_error(disp, "timeout acquiring display\n");
|
2012-08-14 02:50:14 +00:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* point at display engine memory area (hash table, objects) */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_wr32(disp, 0x610010, (nv_gpuobj(base->ramht)->addr >> 8) | 9);
|
2012-08-14 02:50:14 +00:00
|
|
|
|
|
|
|
/* enable supervisor interrupts, disable everything else */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_wr32(disp, 0x61002c, 0x00000370);
|
|
|
|
nv_wr32(disp, 0x610028, 0x00000000);
|
2012-08-14 00:04:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_main_fini(struct nvkm_object *object, bool suspend)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)object->engine;
|
2012-08-14 00:04:04 +00:00
|
|
|
struct nv50_disp_base *base = (void *)object;
|
2012-08-14 02:50:14 +00:00
|
|
|
|
|
|
|
/* disable all interrupts */
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_wr32(disp, 0x610024, 0x00000000);
|
|
|
|
nv_wr32(disp, 0x610020, 0x00000000);
|
2012-08-14 02:50:14 +00:00
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
return nvkm_parent_fini(&base->base, suspend);
|
2012-08-14 00:04:04 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
struct nvkm_ofuncs
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_main_ofuncs = {
|
|
|
|
.ctor = nv50_disp_main_ctor,
|
|
|
|
.dtor = nv50_disp_main_dtor,
|
|
|
|
.init = nv50_disp_main_init,
|
|
|
|
.fini = nv50_disp_main_fini,
|
|
|
|
.mthd = nv50_disp_main_mthd,
|
2015-01-14 05:24:57 +00:00
|
|
|
.ntfy = nvkm_disp_ntfy,
|
2012-08-14 00:04:04 +00:00
|
|
|
};
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
static struct nvkm_oclass
|
2014-10-02 05:25:25 +00:00
|
|
|
nv50_disp_main_oclass[] = {
|
|
|
|
{ NV50_DISP, &nv50_disp_main_ofuncs },
|
2012-08-14 04:11:49 +00:00
|
|
|
{}
|
2012-07-19 22:17:34 +00:00
|
|
|
};
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
static struct nvkm_oclass
|
2012-07-19 22:17:34 +00:00
|
|
|
nv50_disp_sclass[] = {
|
2014-10-02 05:25:25 +00:00
|
|
|
{ NV50_DISP_CORE_CHANNEL_DMA, &nv50_disp_core_ofuncs.base },
|
|
|
|
{ NV50_DISP_BASE_CHANNEL_DMA, &nv50_disp_base_ofuncs.base },
|
2014-08-09 18:10:27 +00:00
|
|
|
{ NV50_DISP_OVERLAY_CHANNEL_DMA, &nv50_disp_ovly_ofuncs.base },
|
|
|
|
{ NV50_DISP_OVERLAY, &nv50_disp_oimm_ofuncs.base },
|
|
|
|
{ NV50_DISP_CURSOR, &nv50_disp_curs_ofuncs.base },
|
2012-08-14 00:04:04 +00:00
|
|
|
{}
|
2012-07-19 22:17:34 +00:00
|
|
|
};
|
|
|
|
|
2012-08-14 00:04:04 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* Display context, tracks instmem allocation and prevents more than one
|
|
|
|
* client using the display hardware at any time.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_data_ctor(struct nvkm_object *parent,
|
|
|
|
struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2012-08-14 00:04:04 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)engine;
|
2015-01-14 05:24:57 +00:00
|
|
|
struct nvkm_engctx *ectx;
|
2012-08-14 04:11:49 +00:00
|
|
|
int ret = -EBUSY;
|
2012-08-14 00:04:04 +00:00
|
|
|
|
2012-08-14 04:11:49 +00:00
|
|
|
/* no context needed for channel objects... */
|
2014-08-09 18:10:24 +00:00
|
|
|
if (nv_mclass(parent) != NV_DEVICE) {
|
2012-08-14 04:11:49 +00:00
|
|
|
atomic_inc(&parent->refcount);
|
|
|
|
*pobject = parent;
|
2013-04-25 14:12:59 +00:00
|
|
|
return 1;
|
2012-08-14 04:11:49 +00:00
|
|
|
}
|
2012-08-14 00:04:04 +00:00
|
|
|
|
2012-08-14 04:11:49 +00:00
|
|
|
/* allocate display hardware to client */
|
2015-08-20 04:54:07 +00:00
|
|
|
mutex_lock(&nv_subdev(disp)->mutex);
|
|
|
|
if (list_empty(&nv_engine(disp)->contexts)) {
|
2015-01-14 05:24:57 +00:00
|
|
|
ret = nvkm_engctx_create(parent, engine, oclass, NULL, 0x10000,
|
|
|
|
0x10000, NVOBJ_FLAG_HEAP, &ectx);
|
2012-08-14 04:11:49 +00:00
|
|
|
*pobject = nv_object(ectx);
|
|
|
|
}
|
2015-08-20 04:54:07 +00:00
|
|
|
mutex_unlock(&nv_subdev(disp)->mutex);
|
2012-08-14 04:11:49 +00:00
|
|
|
return ret;
|
2012-08-14 00:04:04 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
struct nvkm_oclass
|
2012-08-14 00:04:04 +00:00
|
|
|
nv50_disp_cclass = {
|
|
|
|
.handle = NV_ENGCTX(DISP, 0x50),
|
2015-01-14 05:24:57 +00:00
|
|
|
.ofuncs = &(struct nvkm_ofuncs) {
|
2012-08-14 00:04:04 +00:00
|
|
|
.ctor = nv50_disp_data_ctor,
|
2015-01-14 05:24:57 +00:00
|
|
|
.dtor = _nvkm_engctx_dtor,
|
|
|
|
.init = _nvkm_engctx_init,
|
|
|
|
.fini = _nvkm_engctx_fini,
|
|
|
|
.rd32 = _nvkm_engctx_rd32,
|
|
|
|
.wr32 = _nvkm_engctx_wr32,
|
2012-08-14 00:04:04 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Display engine implementation
|
|
|
|
******************************************************************************/
|
|
|
|
|
2014-08-09 18:10:20 +00:00
|
|
|
static void
|
|
|
|
nv50_disp_vblank_fini(struct nvkm_event *event, int type, int head)
|
|
|
|
{
|
2015-01-14 05:24:57 +00:00
|
|
|
struct nvkm_disp *disp = container_of(event, typeof(*disp), vblank);
|
2014-08-09 18:10:20 +00:00
|
|
|
nv_mask(disp, 0x61002c, (4 << head), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nv50_disp_vblank_init(struct nvkm_event *event, int type, int head)
|
|
|
|
{
|
2015-01-14 05:24:57 +00:00
|
|
|
struct nvkm_disp *disp = container_of(event, typeof(*disp), vblank);
|
2014-08-09 18:10:20 +00:00
|
|
|
nv_mask(disp, 0x61002c, (4 << head), (4 << head));
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct nvkm_event_func
|
|
|
|
nv50_disp_vblank_func = {
|
2015-01-14 05:24:57 +00:00
|
|
|
.ctor = nvkm_disp_vblank_ctor,
|
2014-08-09 18:10:20 +00:00
|
|
|
.init = nv50_disp_vblank_init,
|
|
|
|
.fini = nv50_disp_vblank_fini,
|
|
|
|
};
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
static const struct nvkm_enum
|
2014-02-21 01:06:40 +00:00
|
|
|
nv50_disp_intr_error_type[] = {
|
|
|
|
{ 3, "ILLEGAL_MTHD" },
|
|
|
|
{ 4, "INVALID_VALUE" },
|
|
|
|
{ 5, "INVALID_STATE" },
|
|
|
|
{ 7, "INVALID_HANDLE" },
|
|
|
|
{}
|
|
|
|
};
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
static const struct nvkm_enum
|
2014-02-21 01:06:40 +00:00
|
|
|
nv50_disp_intr_error_code[] = {
|
|
|
|
{ 0x00, "" },
|
|
|
|
{}
|
|
|
|
};
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2014-02-21 01:06:40 +00:00
|
|
|
static void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_error(struct nv50_disp *disp, int chid)
|
2014-02-21 01:06:40 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp_impl *impl = (void *)nv_object(disp)->oclass;
|
|
|
|
u32 data = nv_rd32(disp, 0x610084 + (chid * 0x08));
|
|
|
|
u32 addr = nv_rd32(disp, 0x610080 + (chid * 0x08));
|
2014-02-21 01:06:40 +00:00
|
|
|
u32 code = (addr & 0x00ff0000) >> 16;
|
|
|
|
u32 type = (addr & 0x00007000) >> 12;
|
|
|
|
u32 mthd = (addr & 0x00000ffc);
|
2015-01-14 05:24:57 +00:00
|
|
|
const struct nvkm_enum *ec, *et;
|
2014-02-21 01:06:40 +00:00
|
|
|
char ecunk[6], etunk[6];
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
et = nvkm_enum_find(nv50_disp_intr_error_type, type);
|
2014-02-21 01:06:40 +00:00
|
|
|
if (!et)
|
|
|
|
snprintf(etunk, sizeof(etunk), "UNK%02X", type);
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
ec = nvkm_enum_find(nv50_disp_intr_error_code, code);
|
2014-02-21 01:06:40 +00:00
|
|
|
if (!ec)
|
|
|
|
snprintf(ecunk, sizeof(ecunk), "UNK%02X", code);
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_error(disp, "%s [%s] chid %d mthd 0x%04x data 0x%08x\n",
|
2014-02-21 01:06:40 +00:00
|
|
|
et ? et->name : etunk, ec ? ec->name : ecunk,
|
|
|
|
chid, mthd, data);
|
|
|
|
|
2014-02-20 13:26:18 +00:00
|
|
|
if (chid == 0) {
|
|
|
|
switch (mthd) {
|
|
|
|
case 0x0080:
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_mthd_chan(disp, NV_DBG_ERROR, chid - 0,
|
2014-02-20 13:26:18 +00:00
|
|
|
impl->mthd.core);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (chid <= 2) {
|
|
|
|
switch (mthd) {
|
|
|
|
case 0x0080:
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_mthd_chan(disp, NV_DBG_ERROR, chid - 1,
|
2014-02-20 13:26:18 +00:00
|
|
|
impl->mthd.base);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (chid <= 4) {
|
|
|
|
switch (mthd) {
|
|
|
|
case 0x0080:
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_mthd_chan(disp, NV_DBG_ERROR, chid - 3,
|
2014-02-20 13:26:18 +00:00
|
|
|
impl->mthd.ovly);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_wr32(disp, 0x610020, 0x00010000 << chid);
|
|
|
|
nv_wr32(disp, 0x610080 + (chid * 0x08), 0x90000000);
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2014-05-21 01:24:43 +00:00
|
|
|
static struct nvkm_output *
|
2015-08-20 04:54:07 +00:00
|
|
|
exec_lookup(struct nv50_disp *disp, int head, int or, u32 ctrl,
|
2014-05-21 01:24:43 +00:00
|
|
|
u32 *data, u8 *ver, u8 *hdr, u8 *cnt, u8 *len,
|
2012-11-09 02:09:48 +00:00
|
|
|
struct nvbios_outp *info)
|
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nvkm_bios *bios = nvkm_bios(disp);
|
2014-05-21 01:24:43 +00:00
|
|
|
struct nvkm_output *outp;
|
|
|
|
u16 mask, type;
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2014-05-21 01:24:43 +00:00
|
|
|
if (or < 4) {
|
2012-11-09 02:09:48 +00:00
|
|
|
type = DCB_OUTPUT_ANALOG;
|
|
|
|
mask = 0;
|
2013-02-10 23:24:23 +00:00
|
|
|
} else
|
2014-05-21 01:24:43 +00:00
|
|
|
if (or < 8) {
|
2012-11-09 02:09:48 +00:00
|
|
|
switch (ctrl & 0x00000f00) {
|
|
|
|
case 0x00000000: type = DCB_OUTPUT_LVDS; mask = 1; break;
|
|
|
|
case 0x00000100: type = DCB_OUTPUT_TMDS; mask = 1; break;
|
|
|
|
case 0x00000200: type = DCB_OUTPUT_TMDS; mask = 2; break;
|
|
|
|
case 0x00000500: type = DCB_OUTPUT_TMDS; mask = 3; break;
|
|
|
|
case 0x00000800: type = DCB_OUTPUT_DP; mask = 1; break;
|
|
|
|
case 0x00000900: type = DCB_OUTPUT_DP; mask = 2; break;
|
|
|
|
default:
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_error(disp, "unknown SOR mc 0x%08x\n", ctrl);
|
2014-05-21 01:24:43 +00:00
|
|
|
return NULL;
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
2014-05-21 01:24:43 +00:00
|
|
|
or -= 4;
|
2013-02-10 23:24:23 +00:00
|
|
|
} else {
|
2014-05-21 01:24:43 +00:00
|
|
|
or = or - 8;
|
2013-02-10 23:24:23 +00:00
|
|
|
type = 0x0010;
|
|
|
|
mask = 0;
|
|
|
|
switch (ctrl & 0x00000f00) {
|
2015-08-20 04:54:07 +00:00
|
|
|
case 0x00000000: type |= disp->pior.type[or]; break;
|
2013-02-10 23:24:23 +00:00
|
|
|
default:
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_error(disp, "unknown PIOR mc 0x%08x\n", ctrl);
|
2014-05-21 01:24:43 +00:00
|
|
|
return NULL;
|
2013-02-10 23:24:23 +00:00
|
|
|
}
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mask = 0x00c0 & (mask << 6);
|
2014-05-21 01:24:43 +00:00
|
|
|
mask |= 0x0001 << or;
|
2012-11-09 02:09:48 +00:00
|
|
|
mask |= 0x0100 << head;
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
list_for_each_entry(outp, &disp->base.outp, head) {
|
2014-05-21 01:24:43 +00:00
|
|
|
if ((outp->info.hasht & 0xff) == type &&
|
|
|
|
(outp->info.hashm & mask) == mask) {
|
|
|
|
*data = nvbios_outp_match(bios, outp->info.hasht,
|
|
|
|
outp->info.hashm,
|
|
|
|
ver, hdr, cnt, len, info);
|
|
|
|
if (!*data)
|
|
|
|
return NULL;
|
|
|
|
return outp;
|
|
|
|
}
|
|
|
|
}
|
2013-02-10 23:24:23 +00:00
|
|
|
|
2014-05-21 01:24:43 +00:00
|
|
|
return NULL;
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2014-06-11 03:06:48 +00:00
|
|
|
static struct nvkm_output *
|
2015-08-20 04:54:07 +00:00
|
|
|
exec_script(struct nv50_disp *disp, int head, int id)
|
2012-11-09 02:09:48 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nvkm_bios *bios = nvkm_bios(disp);
|
2014-05-21 01:24:43 +00:00
|
|
|
struct nvkm_output *outp;
|
2012-11-09 02:09:48 +00:00
|
|
|
struct nvbios_outp info;
|
|
|
|
u8 ver, hdr, cnt, len;
|
2014-05-21 01:24:43 +00:00
|
|
|
u32 data, ctrl = 0;
|
2013-07-30 00:01:10 +00:00
|
|
|
u32 reg;
|
2012-11-09 02:09:48 +00:00
|
|
|
int i;
|
|
|
|
|
2013-02-10 23:24:23 +00:00
|
|
|
/* DAC */
|
2015-08-20 04:54:07 +00:00
|
|
|
for (i = 0; !(ctrl & (1 << head)) && i < disp->dac.nr; i++)
|
|
|
|
ctrl = nv_rd32(disp, 0x610b5c + (i * 8));
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2013-02-10 23:24:23 +00:00
|
|
|
/* SOR */
|
2013-01-03 18:38:45 +00:00
|
|
|
if (!(ctrl & (1 << head))) {
|
2015-08-20 04:54:07 +00:00
|
|
|
if (nv_device(disp)->chipset < 0x90 ||
|
|
|
|
nv_device(disp)->chipset == 0x92 ||
|
|
|
|
nv_device(disp)->chipset == 0xa0) {
|
2013-07-30 00:01:10 +00:00
|
|
|
reg = 0x610b74;
|
2013-01-03 18:38:45 +00:00
|
|
|
} else {
|
2013-07-30 00:01:10 +00:00
|
|
|
reg = 0x610798;
|
2013-01-03 18:38:45 +00:00
|
|
|
}
|
2015-08-20 04:54:07 +00:00
|
|
|
for (i = 0; !(ctrl & (1 << head)) && i < disp->sor.nr; i++)
|
|
|
|
ctrl = nv_rd32(disp, reg + (i * 8));
|
2013-07-30 00:01:10 +00:00
|
|
|
i += 4;
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2013-02-10 23:24:23 +00:00
|
|
|
/* PIOR */
|
|
|
|
if (!(ctrl & (1 << head))) {
|
2015-08-20 04:54:07 +00:00
|
|
|
for (i = 0; !(ctrl & (1 << head)) && i < disp->pior.nr; i++)
|
|
|
|
ctrl = nv_rd32(disp, 0x610b84 + (i * 8));
|
2013-02-10 23:24:23 +00:00
|
|
|
i += 8;
|
|
|
|
}
|
|
|
|
|
2012-11-09 02:09:48 +00:00
|
|
|
if (!(ctrl & (1 << head)))
|
2014-06-11 03:06:48 +00:00
|
|
|
return NULL;
|
2013-01-03 18:38:45 +00:00
|
|
|
i--;
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
outp = exec_lookup(disp, head, i, ctrl, &data, &ver, &hdr, &cnt, &len, &info);
|
2014-05-21 01:24:43 +00:00
|
|
|
if (outp) {
|
2012-11-09 02:09:48 +00:00
|
|
|
struct nvbios_init init = {
|
2015-08-20 04:54:07 +00:00
|
|
|
.subdev = nv_subdev(disp),
|
2012-11-09 02:09:48 +00:00
|
|
|
.bios = bios,
|
|
|
|
.offset = info.script[id],
|
2014-05-21 01:24:43 +00:00
|
|
|
.outp = &outp->info,
|
2012-11-09 02:09:48 +00:00
|
|
|
.crtc = head,
|
|
|
|
.execute = 1,
|
|
|
|
};
|
|
|
|
|
2014-06-11 03:06:48 +00:00
|
|
|
nvbios_exec(&init);
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2014-06-11 03:06:48 +00:00
|
|
|
return outp;
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2014-05-21 01:24:43 +00:00
|
|
|
static struct nvkm_output *
|
2015-08-20 04:54:07 +00:00
|
|
|
exec_clkcmp(struct nv50_disp *disp, int head, int id, u32 pclk, u32 *conf)
|
2012-11-09 02:09:48 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nvkm_bios *bios = nvkm_bios(disp);
|
2014-05-21 01:24:43 +00:00
|
|
|
struct nvkm_output *outp;
|
2012-11-09 02:09:48 +00:00
|
|
|
struct nvbios_outp info1;
|
|
|
|
struct nvbios_ocfg info2;
|
|
|
|
u8 ver, hdr, cnt, len;
|
2014-05-21 01:24:43 +00:00
|
|
|
u32 data, ctrl = 0;
|
2013-07-30 00:01:10 +00:00
|
|
|
u32 reg;
|
2012-11-09 02:09:48 +00:00
|
|
|
int i;
|
|
|
|
|
2013-02-10 23:24:23 +00:00
|
|
|
/* DAC */
|
2015-08-20 04:54:07 +00:00
|
|
|
for (i = 0; !(ctrl & (1 << head)) && i < disp->dac.nr; i++)
|
|
|
|
ctrl = nv_rd32(disp, 0x610b58 + (i * 8));
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2013-02-10 23:24:23 +00:00
|
|
|
/* SOR */
|
2013-01-03 18:38:45 +00:00
|
|
|
if (!(ctrl & (1 << head))) {
|
2015-08-20 04:54:07 +00:00
|
|
|
if (nv_device(disp)->chipset < 0x90 ||
|
|
|
|
nv_device(disp)->chipset == 0x92 ||
|
|
|
|
nv_device(disp)->chipset == 0xa0) {
|
2013-07-30 00:01:10 +00:00
|
|
|
reg = 0x610b70;
|
2013-01-03 18:38:45 +00:00
|
|
|
} else {
|
2013-07-30 00:01:10 +00:00
|
|
|
reg = 0x610794;
|
2013-01-03 18:38:45 +00:00
|
|
|
}
|
2015-08-20 04:54:07 +00:00
|
|
|
for (i = 0; !(ctrl & (1 << head)) && i < disp->sor.nr; i++)
|
|
|
|
ctrl = nv_rd32(disp, reg + (i * 8));
|
2013-07-30 00:01:10 +00:00
|
|
|
i += 4;
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2013-02-10 23:24:23 +00:00
|
|
|
/* PIOR */
|
|
|
|
if (!(ctrl & (1 << head))) {
|
2015-08-20 04:54:07 +00:00
|
|
|
for (i = 0; !(ctrl & (1 << head)) && i < disp->pior.nr; i++)
|
|
|
|
ctrl = nv_rd32(disp, 0x610b80 + (i * 8));
|
2013-02-10 23:24:23 +00:00
|
|
|
i += 8;
|
|
|
|
}
|
|
|
|
|
2012-11-09 02:09:48 +00:00
|
|
|
if (!(ctrl & (1 << head)))
|
2014-05-21 01:24:43 +00:00
|
|
|
return NULL;
|
2013-01-03 18:38:45 +00:00
|
|
|
i--;
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
outp = exec_lookup(disp, head, i, ctrl, &data, &ver, &hdr, &cnt, &len, &info1);
|
2014-06-16 23:39:18 +00:00
|
|
|
if (!outp)
|
2014-05-21 01:24:43 +00:00
|
|
|
return NULL;
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2014-05-21 01:24:43 +00:00
|
|
|
if (outp->info.location == 0) {
|
|
|
|
switch (outp->info.type) {
|
2013-02-10 23:24:23 +00:00
|
|
|
case DCB_OUTPUT_TMDS:
|
2014-05-21 01:24:43 +00:00
|
|
|
*conf = (ctrl & 0x00000f00) >> 8;
|
2013-02-10 23:24:23 +00:00
|
|
|
if (pclk >= 165000)
|
2014-05-21 01:24:43 +00:00
|
|
|
*conf |= 0x0100;
|
2013-02-10 23:24:23 +00:00
|
|
|
break;
|
|
|
|
case DCB_OUTPUT_LVDS:
|
2015-08-20 04:54:07 +00:00
|
|
|
*conf = disp->sor.lvdsconf;
|
2013-02-10 23:24:23 +00:00
|
|
|
break;
|
|
|
|
case DCB_OUTPUT_DP:
|
2014-05-21 01:24:43 +00:00
|
|
|
*conf = (ctrl & 0x00000f00) >> 8;
|
2013-02-10 23:24:23 +00:00
|
|
|
break;
|
|
|
|
case DCB_OUTPUT_ANALOG:
|
|
|
|
default:
|
2014-05-21 01:24:43 +00:00
|
|
|
*conf = 0x00ff;
|
2013-02-10 23:24:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2014-05-21 01:24:43 +00:00
|
|
|
*conf = (ctrl & 0x00000f00) >> 8;
|
2013-02-10 23:24:23 +00:00
|
|
|
pclk = pclk / 2;
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2014-05-21 01:24:43 +00:00
|
|
|
data = nvbios_ocfg_match(bios, data, *conf, &ver, &hdr, &cnt, &len, &info2);
|
2013-02-19 04:17:53 +00:00
|
|
|
if (data && id < 0xff) {
|
2012-11-09 02:09:48 +00:00
|
|
|
data = nvbios_oclk_match(bios, info2.clkcmp[id], pclk);
|
|
|
|
if (data) {
|
|
|
|
struct nvbios_init init = {
|
2015-08-20 04:54:07 +00:00
|
|
|
.subdev = nv_subdev(disp),
|
2012-11-09 02:09:48 +00:00
|
|
|
.bios = bios,
|
|
|
|
.offset = data,
|
2014-05-21 01:24:43 +00:00
|
|
|
.outp = &outp->info,
|
2012-11-09 02:09:48 +00:00
|
|
|
.crtc = head,
|
|
|
|
.execute = 1,
|
|
|
|
};
|
|
|
|
|
2013-02-16 03:49:21 +00:00
|
|
|
nvbios_exec(&init);
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-21 01:24:43 +00:00
|
|
|
return outp;
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk10_0(struct nv50_disp *disp, int head)
|
2012-11-09 02:09:48 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
exec_script(disp, head, 1);
|
2013-02-20 08:56:33 +00:00
|
|
|
}
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2013-02-20 08:56:33 +00:00
|
|
|
static void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk20_0(struct nv50_disp *disp, int head)
|
2013-02-20 08:56:33 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nvkm_output *outp = exec_script(disp, head, 2);
|
2014-06-11 03:06:48 +00:00
|
|
|
|
|
|
|
/* the binary driver does this outside of the supervisor handling
|
|
|
|
* (after the third supervisor from a detach). we (currently?)
|
|
|
|
* allow both detach/attach to happen in the same set of
|
|
|
|
* supervisor interrupts, so it would make sense to execute this
|
|
|
|
* (full power down?) script after all the detach phases of the
|
|
|
|
* supervisor handling. like with training if needed from the
|
|
|
|
* second supervisor, nvidia doesn't do this, so who knows if it's
|
|
|
|
* entirely safe, but it does appear to work..
|
|
|
|
*
|
|
|
|
* without this script being run, on some configurations i've
|
|
|
|
* seen, switching from DP to TMDS on a DP connector may result
|
|
|
|
* in a blank screen (SOR_PWR off/on can restore it)
|
|
|
|
*/
|
|
|
|
if (outp && outp->info.type == DCB_OUTPUT_DP) {
|
|
|
|
struct nvkm_output_dp *outpdp = (void *)outp;
|
|
|
|
struct nvbios_init init = {
|
2015-08-20 04:54:07 +00:00
|
|
|
.subdev = nv_subdev(disp),
|
|
|
|
.bios = nvkm_bios(disp),
|
2014-06-11 03:06:48 +00:00
|
|
|
.outp = &outp->info,
|
|
|
|
.crtc = head,
|
|
|
|
.offset = outpdp->info.script[4],
|
|
|
|
.execute = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
nvbios_exec(&init);
|
|
|
|
atomic_set(&outpdp->lt.done, 0);
|
|
|
|
}
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk20_1(struct nv50_disp *disp, int head)
|
2013-02-20 08:56:33 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nvkm_devinit *devinit = nvkm_devinit(disp);
|
|
|
|
u32 pclk = nv_rd32(disp, 0x610ad0 + (head * 0x540)) & 0x3fffff;
|
2013-02-20 08:56:33 +00:00
|
|
|
if (pclk)
|
2013-03-05 00:53:54 +00:00
|
|
|
devinit->pll_set(devinit, PLL_VPLL0 + head, pclk);
|
2013-02-20 08:56:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk20_2_dp(struct nv50_disp *disp, int head,
|
2013-02-20 08:56:33 +00:00
|
|
|
struct dcb_output *outp, u32 pclk)
|
2012-11-09 02:09:48 +00:00
|
|
|
{
|
|
|
|
const int link = !(outp->sorconf.link & 1);
|
|
|
|
const int or = ffs(outp->or) - 1;
|
|
|
|
const u32 soff = ( or * 0x800);
|
|
|
|
const u32 loff = (link * 0x080) + soff;
|
2015-08-20 04:54:07 +00:00
|
|
|
const u32 ctrl = nv_rd32(disp, 0x610794 + (or * 8));
|
2012-11-09 02:09:48 +00:00
|
|
|
const u32 symbol = 100000;
|
2015-08-20 04:54:07 +00:00
|
|
|
const s32 vactive = nv_rd32(disp, 0x610af8 + (head * 0x540)) & 0xffff;
|
|
|
|
const s32 vblanke = nv_rd32(disp, 0x610ae8 + (head * 0x540)) & 0xffff;
|
|
|
|
const s32 vblanks = nv_rd32(disp, 0x610af0 + (head * 0x540)) & 0xffff;
|
|
|
|
u32 dpctrl = nv_rd32(disp, 0x61c10c + loff);
|
|
|
|
u32 clksor = nv_rd32(disp, 0x614300 + soff);
|
2012-11-09 02:09:48 +00:00
|
|
|
int bestTU = 0, bestVTUi = 0, bestVTUf = 0, bestVTUa = 0;
|
|
|
|
int TU, VTUi, VTUf, VTUa;
|
|
|
|
u64 link_data_rate, link_ratio, unk;
|
|
|
|
u32 best_diff = 64 * symbol;
|
2014-08-09 18:10:30 +00:00
|
|
|
u32 link_nr, link_bw, bits;
|
2014-09-15 05:55:56 +00:00
|
|
|
u64 value;
|
|
|
|
|
|
|
|
link_bw = (clksor & 0x000c0000) ? 270000 : 162000;
|
|
|
|
link_nr = hweight32(dpctrl & 0x000f0000);
|
|
|
|
|
|
|
|
/* symbols/hblank - algorithm taken from comments in tegra driver */
|
|
|
|
value = vblanke + vactive - vblanks - 7;
|
|
|
|
value = value * link_bw;
|
|
|
|
do_div(value, pclk);
|
|
|
|
value = value - (3 * !!(dpctrl & 0x00004000)) - (12 / link_nr);
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x61c1e8 + soff, 0x0000ffff, value);
|
2014-09-15 05:55:56 +00:00
|
|
|
|
|
|
|
/* symbols/vblank - algorithm taken from comments in tegra driver */
|
|
|
|
value = vblanks - vblanke - 25;
|
|
|
|
value = value * link_bw;
|
|
|
|
do_div(value, pclk);
|
|
|
|
value = value - ((36 / link_nr) + 3) - 1;
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x61c1ec + soff, 0x00ffffff, value);
|
2014-09-15 05:55:56 +00:00
|
|
|
|
|
|
|
/* watermark / activesym */
|
2012-11-21 04:49:54 +00:00
|
|
|
if ((ctrl & 0xf0000) == 0x60000) bits = 30;
|
|
|
|
else if ((ctrl & 0xf0000) == 0x50000) bits = 24;
|
|
|
|
else bits = 18;
|
|
|
|
|
2012-11-09 02:09:48 +00:00
|
|
|
link_data_rate = (pclk * bits / 8) / link_nr;
|
|
|
|
|
|
|
|
/* calculate ratio of packed data rate to link symbol rate */
|
|
|
|
link_ratio = link_data_rate * symbol;
|
2014-08-09 18:10:30 +00:00
|
|
|
do_div(link_ratio, link_bw);
|
2012-11-09 02:09:48 +00:00
|
|
|
|
|
|
|
for (TU = 64; TU >= 32; TU--) {
|
|
|
|
/* calculate average number of valid symbols in each TU */
|
|
|
|
u32 tu_valid = link_ratio * TU;
|
|
|
|
u32 calc, diff;
|
|
|
|
|
|
|
|
/* find a hw representation for the fraction.. */
|
|
|
|
VTUi = tu_valid / symbol;
|
|
|
|
calc = VTUi * symbol;
|
|
|
|
diff = tu_valid - calc;
|
|
|
|
if (diff) {
|
|
|
|
if (diff >= (symbol / 2)) {
|
|
|
|
VTUf = symbol / (symbol - diff);
|
|
|
|
if (symbol - (VTUf * diff))
|
|
|
|
VTUf++;
|
|
|
|
|
|
|
|
if (VTUf <= 15) {
|
|
|
|
VTUa = 1;
|
|
|
|
calc += symbol - (symbol / VTUf);
|
|
|
|
} else {
|
|
|
|
VTUa = 0;
|
|
|
|
VTUf = 1;
|
|
|
|
calc += symbol;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
VTUa = 0;
|
|
|
|
VTUf = min((int)(symbol / diff), 15);
|
|
|
|
calc += symbol / VTUf;
|
|
|
|
}
|
|
|
|
|
|
|
|
diff = calc - tu_valid;
|
|
|
|
} else {
|
|
|
|
/* no remainder, but the hw doesn't like the fractional
|
|
|
|
* part to be zero. decrement the integer part and
|
|
|
|
* have the fraction add a whole symbol back
|
|
|
|
*/
|
|
|
|
VTUa = 0;
|
|
|
|
VTUf = 1;
|
|
|
|
VTUi--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (diff < best_diff) {
|
|
|
|
best_diff = diff;
|
|
|
|
bestTU = TU;
|
|
|
|
bestVTUa = VTUa;
|
|
|
|
bestVTUf = VTUf;
|
|
|
|
bestVTUi = VTUi;
|
|
|
|
if (diff == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bestTU) {
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_error(disp, "unable to find suitable dp config\n");
|
2012-11-09 02:09:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX close to vbios numbers, but not right */
|
|
|
|
unk = (symbol - link_ratio) * bestTU;
|
|
|
|
unk *= link_ratio;
|
2014-08-09 18:10:30 +00:00
|
|
|
do_div(unk, symbol);
|
|
|
|
do_div(unk, symbol);
|
2012-11-09 02:09:48 +00:00
|
|
|
unk += 6;
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x61c10c + loff, 0x000001fc, bestTU << 2);
|
|
|
|
nv_mask(disp, 0x61c128 + loff, 0x010f7f3f, bestVTUa << 24 |
|
2012-11-09 02:09:48 +00:00
|
|
|
bestVTUf << 16 |
|
|
|
|
bestVTUi << 8 | unk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk20_2(struct nv50_disp *disp, int head)
|
2012-11-09 02:09:48 +00:00
|
|
|
{
|
2014-05-21 01:24:43 +00:00
|
|
|
struct nvkm_output *outp;
|
2015-08-20 04:54:07 +00:00
|
|
|
u32 pclk = nv_rd32(disp, 0x610ad0 + (head * 0x540)) & 0x3fffff;
|
2013-02-20 08:56:33 +00:00
|
|
|
u32 hval, hreg = 0x614200 + (head * 0x800);
|
|
|
|
u32 oval, oreg;
|
2014-05-21 01:24:43 +00:00
|
|
|
u32 mask, conf;
|
2013-02-19 04:17:53 +00:00
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
outp = exec_clkcmp(disp, head, 0xff, pclk, &conf);
|
2014-05-21 01:24:43 +00:00
|
|
|
if (!outp)
|
|
|
|
return;
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2014-05-20 00:18:03 +00:00
|
|
|
/* we allow both encoder attach and detach operations to occur
|
|
|
|
* within a single supervisor (ie. modeset) sequence. the
|
|
|
|
* encoder detach scripts quite often switch off power to the
|
|
|
|
* lanes, which requires the link to be re-trained.
|
|
|
|
*
|
|
|
|
* this is not generally an issue as the sink "must" (heh)
|
|
|
|
* signal an irq when it's lost sync so the driver can
|
|
|
|
* re-train.
|
|
|
|
*
|
|
|
|
* however, on some boards, if one does not configure at least
|
|
|
|
* the gpu side of the link *before* attaching, then various
|
|
|
|
* things can go horribly wrong (PDISP disappearing from mmio,
|
|
|
|
* third supervisor never happens, etc).
|
|
|
|
*
|
|
|
|
* the solution is simply to retrain here, if necessary. last
|
|
|
|
* i checked, the binary driver userspace does not appear to
|
|
|
|
* trigger this situation (it forces an UPDATE between steps).
|
|
|
|
*/
|
2014-05-27 05:00:36 +00:00
|
|
|
if (outp->info.type == DCB_OUTPUT_DP) {
|
2014-05-21 01:24:43 +00:00
|
|
|
u32 soff = (ffs(outp->info.or) - 1) * 0x08;
|
2014-05-27 05:00:36 +00:00
|
|
|
u32 ctrl, datarate;
|
|
|
|
|
|
|
|
if (outp->info.location == 0) {
|
2015-08-20 04:54:07 +00:00
|
|
|
ctrl = nv_rd32(disp, 0x610794 + soff);
|
2014-05-27 05:00:36 +00:00
|
|
|
soff = 1;
|
|
|
|
} else {
|
2015-08-20 04:54:07 +00:00
|
|
|
ctrl = nv_rd32(disp, 0x610b80 + soff);
|
2014-05-27 05:00:36 +00:00
|
|
|
soff = 2;
|
|
|
|
}
|
2014-05-21 01:24:43 +00:00
|
|
|
|
|
|
|
switch ((ctrl & 0x000f0000) >> 16) {
|
2014-07-01 00:54:52 +00:00
|
|
|
case 6: datarate = pclk * 30; break;
|
|
|
|
case 5: datarate = pclk * 24; break;
|
2014-05-21 01:24:43 +00:00
|
|
|
case 2:
|
|
|
|
default:
|
2014-07-01 00:54:52 +00:00
|
|
|
datarate = pclk * 18;
|
2014-05-21 01:24:43 +00:00
|
|
|
break;
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2014-05-20 00:18:03 +00:00
|
|
|
if (nvkm_output_dp_train(outp, datarate / soff, true))
|
|
|
|
ERR("link not trained before attach\n");
|
2014-05-21 01:24:43 +00:00
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
exec_clkcmp(disp, head, 0, pclk, &conf);
|
2014-05-21 01:24:43 +00:00
|
|
|
|
|
|
|
if (!outp->info.location && outp->info.type == DCB_OUTPUT_ANALOG) {
|
|
|
|
oreg = 0x614280 + (ffs(outp->info.or) - 1) * 0x800;
|
|
|
|
oval = 0x00000000;
|
|
|
|
hval = 0x00000000;
|
|
|
|
mask = 0xffffffff;
|
|
|
|
} else
|
|
|
|
if (!outp->info.location) {
|
|
|
|
if (outp->info.type == DCB_OUTPUT_DP)
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk20_2_dp(disp, head, &outp->info, pclk);
|
2014-05-21 01:24:43 +00:00
|
|
|
oreg = 0x614300 + (ffs(outp->info.or) - 1) * 0x800;
|
|
|
|
oval = (conf & 0x0100) ? 0x00000101 : 0x00000000;
|
|
|
|
hval = 0x00000000;
|
|
|
|
mask = 0x00000707;
|
|
|
|
} else {
|
|
|
|
oreg = 0x614380 + (ffs(outp->info.or) - 1) * 0x800;
|
|
|
|
oval = 0x00000001;
|
|
|
|
hval = 0x00000001;
|
|
|
|
mask = 0x00000707;
|
2013-02-20 08:56:33 +00:00
|
|
|
}
|
2014-05-21 01:24:43 +00:00
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, hreg, 0x0000000f, hval);
|
|
|
|
nv_mask(disp, oreg, mask, oval);
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If programming a TMDS output on a SOR that can also be configured for
|
|
|
|
* DisplayPort, make sure NV50_SOR_DP_CTRL_ENABLE is forced off.
|
|
|
|
*
|
|
|
|
* It looks like the VBIOS TMDS scripts make an attempt at this, however,
|
|
|
|
* the VBIOS scripts on at least one board I have only switch it off on
|
|
|
|
* link 0, causing a blank display if the output has previously been
|
|
|
|
* programmed for DisplayPort.
|
|
|
|
*/
|
|
|
|
static void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk40_0_tmds(struct nv50_disp *disp,
|
2015-01-14 05:24:57 +00:00
|
|
|
struct dcb_output *outp)
|
2012-11-09 02:09:48 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nvkm_bios *bios = nvkm_bios(disp);
|
2012-11-09 02:09:48 +00:00
|
|
|
const int link = !(outp->sorconf.link & 1);
|
|
|
|
const int or = ffs(outp->or) - 1;
|
|
|
|
const u32 loff = (or * 0x800) + (link * 0x80);
|
|
|
|
const u16 mask = (outp->sorconf.link << 6) | outp->or;
|
2014-09-30 00:27:08 +00:00
|
|
|
struct dcb_output match;
|
2012-11-09 02:09:48 +00:00
|
|
|
u8 ver, hdr;
|
|
|
|
|
2014-09-30 00:27:08 +00:00
|
|
|
if (dcb_outp_match(bios, DCB_OUTPUT_DP, mask, &ver, &hdr, &match))
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_mask(disp, 0x61c10c + loff, 0x00000001, 0x00000000);
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk40_0(struct nv50_disp *disp, int head)
|
2012-11-09 02:09:48 +00:00
|
|
|
{
|
2014-05-21 01:24:43 +00:00
|
|
|
struct nvkm_output *outp;
|
2015-08-20 04:54:07 +00:00
|
|
|
u32 pclk = nv_rd32(disp, 0x610ad0 + (head * 0x540)) & 0x3fffff;
|
2014-05-21 01:24:43 +00:00
|
|
|
u32 conf;
|
2013-02-20 08:56:33 +00:00
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
outp = exec_clkcmp(disp, head, 1, pclk, &conf);
|
2014-05-21 01:24:43 +00:00
|
|
|
if (!outp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (outp->info.location == 0 && outp->info.type == DCB_OUTPUT_TMDS)
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk40_0_tmds(disp, &outp->info);
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2013-02-18 22:50:51 +00:00
|
|
|
void
|
|
|
|
nv50_disp_intr_supervisor(struct work_struct *work)
|
2012-11-09 02:09:48 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp =
|
|
|
|
container_of(work, struct nv50_disp, supervisor);
|
|
|
|
struct nv50_disp_impl *impl = (void *)nv_object(disp)->oclass;
|
|
|
|
u32 super = nv_rd32(disp, 0x610030);
|
2013-02-20 08:56:33 +00:00
|
|
|
int head;
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_debug(disp, "supervisor 0x%08x 0x%08x\n", disp->super, super);
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
if (disp->super & 0x00000010) {
|
|
|
|
nv50_disp_mthd_chan(disp, NV_DBG_DEBUG, 0, impl->mthd.core);
|
|
|
|
for (head = 0; head < disp->head.nr; head++) {
|
2013-02-20 08:56:33 +00:00
|
|
|
if (!(super & (0x00000020 << head)))
|
|
|
|
continue;
|
|
|
|
if (!(super & (0x00000080 << head)))
|
|
|
|
continue;
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk10_0(disp, head);
|
2013-02-20 08:56:33 +00:00
|
|
|
}
|
|
|
|
} else
|
2015-08-20 04:54:07 +00:00
|
|
|
if (disp->super & 0x00000020) {
|
|
|
|
for (head = 0; head < disp->head.nr; head++) {
|
2013-02-20 08:56:33 +00:00
|
|
|
if (!(super & (0x00000080 << head)))
|
|
|
|
continue;
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk20_0(disp, head);
|
2013-02-20 08:56:33 +00:00
|
|
|
}
|
2015-08-20 04:54:07 +00:00
|
|
|
for (head = 0; head < disp->head.nr; head++) {
|
2013-02-20 08:56:33 +00:00
|
|
|
if (!(super & (0x00000200 << head)))
|
|
|
|
continue;
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk20_1(disp, head);
|
2013-02-20 08:56:33 +00:00
|
|
|
}
|
2015-08-20 04:54:07 +00:00
|
|
|
for (head = 0; head < disp->head.nr; head++) {
|
2013-02-20 08:56:33 +00:00
|
|
|
if (!(super & (0x00000080 << head)))
|
|
|
|
continue;
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk20_2(disp, head);
|
2013-02-20 08:56:33 +00:00
|
|
|
}
|
|
|
|
} else
|
2015-08-20 04:54:07 +00:00
|
|
|
if (disp->super & 0x00000040) {
|
|
|
|
for (head = 0; head < disp->head.nr; head++) {
|
2013-02-20 08:56:33 +00:00
|
|
|
if (!(super & (0x00000080 << head)))
|
|
|
|
continue;
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_unk40_0(disp, head);
|
2013-02-20 08:56:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_wr32(disp, 0x610030, 0x80000000);
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2012-08-14 00:04:04 +00:00
|
|
|
void
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_intr(struct nvkm_subdev *subdev)
|
2012-07-19 22:17:34 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp = (void *)subdev;
|
|
|
|
u32 intr0 = nv_rd32(disp, 0x610020);
|
|
|
|
u32 intr1 = nv_rd32(disp, 0x610024);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2014-02-21 01:06:40 +00:00
|
|
|
while (intr0 & 0x001f0000) {
|
|
|
|
u32 chid = __ffs(intr0 & 0x001f0000) - 16;
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_intr_error(disp, chid);
|
2014-02-21 01:06:40 +00:00
|
|
|
intr0 &= ~(0x00010000 << chid);
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 04:38:10 +00:00
|
|
|
while (intr0 & 0x0000001f) {
|
|
|
|
u32 chid = __ffs(intr0 & 0x0000001f);
|
2015-08-20 04:54:07 +00:00
|
|
|
nv50_disp_chan_uevent_send(disp, chid);
|
2014-08-11 04:38:10 +00:00
|
|
|
intr0 &= ~(0x00000001 << chid);
|
|
|
|
}
|
|
|
|
|
2012-11-09 02:09:48 +00:00
|
|
|
if (intr1 & 0x00000004) {
|
2015-08-20 04:54:07 +00:00
|
|
|
nvkm_disp_vblank(&disp->base, 0);
|
|
|
|
nv_wr32(disp, 0x610024, 0x00000004);
|
2012-07-19 22:17:34 +00:00
|
|
|
}
|
|
|
|
|
2012-11-09 02:09:48 +00:00
|
|
|
if (intr1 & 0x00000008) {
|
2015-08-20 04:54:07 +00:00
|
|
|
nvkm_disp_vblank(&disp->base, 1);
|
|
|
|
nv_wr32(disp, 0x610024, 0x00000008);
|
2012-07-19 22:17:34 +00:00
|
|
|
}
|
|
|
|
|
2012-11-09 02:09:48 +00:00
|
|
|
if (intr1 & 0x00000070) {
|
2015-08-20 04:54:07 +00:00
|
|
|
disp->super = (intr1 & 0x00000070);
|
|
|
|
schedule_work(&disp->supervisor);
|
|
|
|
nv_wr32(disp, 0x610024, disp->super);
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
2012-07-19 22:17:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-01-14 05:24:57 +00:00
|
|
|
nv50_disp_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2012-07-19 22:17:34 +00:00
|
|
|
{
|
2015-08-20 04:54:07 +00:00
|
|
|
struct nv50_disp *disp;
|
2012-07-19 22:17:34 +00:00
|
|
|
int ret;
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
ret = nvkm_disp_create(parent, engine, oclass, 2, "PDISP",
|
2015-08-20 04:54:07 +00:00
|
|
|
"display", &disp);
|
|
|
|
*pobject = nv_object(disp);
|
2012-07-19 22:17:34 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
ret = nvkm_event_init(&nv50_disp_chan_uevent, 1, 9, &disp->uevent);
|
2014-08-11 04:38:10 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2015-08-20 04:54:07 +00:00
|
|
|
nv_engine(disp)->sclass = nv50_disp_main_oclass;
|
|
|
|
nv_engine(disp)->cclass = &nv50_disp_cclass;
|
|
|
|
nv_subdev(disp)->intr = nv50_disp_intr;
|
|
|
|
INIT_WORK(&disp->supervisor, nv50_disp_intr_supervisor);
|
|
|
|
disp->sclass = nv50_disp_sclass;
|
|
|
|
disp->head.nr = 2;
|
|
|
|
disp->dac.nr = 3;
|
|
|
|
disp->sor.nr = 2;
|
|
|
|
disp->pior.nr = 3;
|
|
|
|
disp->dac.power = nv50_dac_power;
|
|
|
|
disp->dac.sense = nv50_dac_sense;
|
|
|
|
disp->sor.power = nv50_sor_power;
|
|
|
|
disp->pior.power = nv50_pior_power;
|
2012-07-19 22:17:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
struct nvkm_oclass *
|
2014-05-17 01:19:54 +00:00
|
|
|
nv50_disp_outp_sclass[] = {
|
|
|
|
&nv50_pior_dp_impl.base.base,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
struct nvkm_oclass *
|
2014-02-20 11:33:34 +00:00
|
|
|
nv50_disp_oclass = &(struct nv50_disp_impl) {
|
|
|
|
.base.base.handle = NV_ENGINE(DISP, 0x50),
|
2015-01-14 05:24:57 +00:00
|
|
|
.base.base.ofuncs = &(struct nvkm_ofuncs) {
|
2012-07-19 22:17:34 +00:00
|
|
|
.ctor = nv50_disp_ctor,
|
2015-01-14 05:24:57 +00:00
|
|
|
.dtor = _nvkm_disp_dtor,
|
|
|
|
.init = _nvkm_disp_init,
|
|
|
|
.fini = _nvkm_disp_fini,
|
2012-07-19 22:17:34 +00:00
|
|
|
},
|
2014-08-09 18:10:20 +00:00
|
|
|
.base.vblank = &nv50_disp_vblank_func,
|
2014-05-17 01:19:54 +00:00
|
|
|
.base.outp = nv50_disp_outp_sclass,
|
2014-10-02 05:25:25 +00:00
|
|
|
.mthd.core = &nv50_disp_core_mthd_chan,
|
|
|
|
.mthd.base = &nv50_disp_base_mthd_chan,
|
2014-02-20 05:14:10 +00:00
|
|
|
.mthd.ovly = &nv50_disp_ovly_mthd_chan,
|
|
|
|
.mthd.prev = 0x000004,
|
2014-10-02 05:25:25 +00:00
|
|
|
.head.scanoutpos = nv50_disp_main_scanoutpos,
|
2014-02-20 11:33:34 +00:00
|
|
|
}.base.base;
|