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"
|
2015-08-20 04:54:19 +00:00
|
|
|
#include "rootnv50.h"
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2014-08-09 18:10:26 +00:00
|
|
|
#include <core/client.h>
|
2014-02-21 01:06:40 +00:00
|
|
|
#include <core/enum.h>
|
2015-08-20 04:54:19 +00:00
|
|
|
#include <core/gpuobj.h>
|
2012-11-09 02:09:48 +00:00
|
|
|
#include <subdev/bios.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 00:04:04 +00:00
|
|
|
|
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);
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = disp->engine.subdev.device;
|
|
|
|
nvkm_mask(device, 0x61002c, (4 << head), 0);
|
2014-08-09 18:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = disp->engine.subdev.device;
|
|
|
|
nvkm_mask(device, 0x61002c, (4 << head), (4 << head));
|
2014-08-09 18:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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:13 +00:00
|
|
|
struct nvkm_subdev *subdev = &disp->base.engine.subdev;
|
|
|
|
struct nvkm_device *device = subdev->device;
|
2015-08-20 04:54:10 +00:00
|
|
|
u32 data = nvkm_rd32(device, 0x610084 + (chid * 0x08));
|
|
|
|
u32 addr = nvkm_rd32(device, 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
|
|
|
|
2015-01-14 05:24:57 +00:00
|
|
|
et = nvkm_enum_find(nv50_disp_intr_error_type, type);
|
|
|
|
ec = nvkm_enum_find(nv50_disp_intr_error_code, code);
|
2014-02-21 01:06:40 +00:00
|
|
|
|
2015-08-20 04:54:13 +00:00
|
|
|
nvkm_error(subdev,
|
|
|
|
"ERROR %d [%s] %02x [%s] chid %d mthd %04x data %08x\n",
|
|
|
|
type, et ? et->name : "", code, ec ? ec->name : "",
|
|
|
|
chid, mthd, data);
|
2014-02-21 01:06:40 +00:00
|
|
|
|
2015-08-20 04:54:19 +00:00
|
|
|
if (chid < ARRAY_SIZE(disp->chan)) {
|
2014-02-20 13:26:18 +00:00
|
|
|
switch (mthd) {
|
|
|
|
case 0x0080:
|
2015-08-20 04:54:19 +00:00
|
|
|
nv50_disp_chan_mthd(disp->chan[chid], NV_DBG_ERROR);
|
2014-02-20 13:26:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, 0x610020, 0x00010000 << chid);
|
|
|
|
nvkm_wr32(device, 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:13 +00:00
|
|
|
struct nvkm_subdev *subdev = &disp->base.engine.subdev;
|
|
|
|
struct nvkm_bios *bios = subdev->device->bios;
|
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:13 +00:00
|
|
|
nvkm_error(subdev, "unknown SOR mc %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:13 +00:00
|
|
|
nvkm_error(subdev, "unknown PIOR mc %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:10 +00:00
|
|
|
struct nvkm_device *device = disp->base.engine.subdev.device;
|
|
|
|
struct nvkm_bios *bios = device->bios;
|
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++)
|
2015-08-20 04:54:10 +00:00
|
|
|
ctrl = nvkm_rd32(device, 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++)
|
2015-08-20 04:54:10 +00:00
|
|
|
ctrl = nvkm_rd32(device, 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++)
|
2015-08-20 04:54:10 +00:00
|
|
|
ctrl = nvkm_rd32(device, 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:10 +00:00
|
|
|
struct nvkm_device *device = disp->base.engine.subdev.device;
|
|
|
|
struct nvkm_bios *bios = device->bios;
|
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++)
|
2015-08-20 04:54:10 +00:00
|
|
|
ctrl = nvkm_rd32(device, 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++)
|
2015-08-20 04:54:10 +00:00
|
|
|
ctrl = nvkm_rd32(device, 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++)
|
2015-08-20 04:54:10 +00:00
|
|
|
ctrl = nvkm_rd32(device, 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) {
|
2015-08-20 04:54:15 +00:00
|
|
|
struct nvkm_output_dp *outpdp = nvkm_output_dp(outp);
|
2014-06-11 03:06:48 +00:00
|
|
|
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:10 +00:00
|
|
|
struct nvkm_device *device = disp->base.engine.subdev.device;
|
|
|
|
struct nvkm_devinit *devinit = device->devinit;
|
|
|
|
u32 pclk = nvkm_rd32(device, 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
|
|
|
{
|
2015-08-20 04:54:13 +00:00
|
|
|
struct nvkm_subdev *subdev = &disp->base.engine.subdev;
|
|
|
|
struct nvkm_device *device = subdev->device;
|
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:10 +00:00
|
|
|
const u32 ctrl = nvkm_rd32(device, 0x610794 + (or * 8));
|
2012-11-09 02:09:48 +00:00
|
|
|
const u32 symbol = 100000;
|
2015-08-20 04:54:10 +00:00
|
|
|
const s32 vactive = nvkm_rd32(device, 0x610af8 + (head * 0x540)) & 0xffff;
|
|
|
|
const s32 vblanke = nvkm_rd32(device, 0x610ae8 + (head * 0x540)) & 0xffff;
|
|
|
|
const s32 vblanks = nvkm_rd32(device, 0x610af0 + (head * 0x540)) & 0xffff;
|
|
|
|
u32 dpctrl = nvkm_rd32(device, 0x61c10c + loff);
|
|
|
|
u32 clksor = nvkm_rd32(device, 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:10 +00:00
|
|
|
nvkm_mask(device, 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:10 +00:00
|
|
|
nvkm_mask(device, 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:13 +00:00
|
|
|
nvkm_error(subdev, "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:10 +00:00
|
|
|
nvkm_mask(device, 0x61c10c + loff, 0x000001fc, bestTU << 2);
|
|
|
|
nvkm_mask(device, 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
|
|
|
{
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = disp->base.engine.subdev.device;
|
2014-05-21 01:24:43 +00:00
|
|
|
struct nvkm_output *outp;
|
2015-08-20 04:54:10 +00:00
|
|
|
u32 pclk = nvkm_rd32(device, 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:10 +00:00
|
|
|
ctrl = nvkm_rd32(device, 0x610794 + soff);
|
2014-05-27 05:00:36 +00:00
|
|
|
soff = 1;
|
|
|
|
} else {
|
2015-08-20 04:54:10 +00:00
|
|
|
ctrl = nvkm_rd32(device, 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))
|
2015-08-20 04:54:15 +00:00
|
|
|
OUTP_ERR(outp, "link not trained before attach");
|
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:10 +00:00
|
|
|
nvkm_mask(device, hreg, 0x0000000f, hval);
|
|
|
|
nvkm_mask(device, 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:10 +00:00
|
|
|
struct nvkm_device *device = disp->base.engine.subdev.device;
|
|
|
|
struct nvkm_bios *bios = device->bios;
|
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:10 +00:00
|
|
|
nvkm_mask(device, 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
|
|
|
{
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = disp->base.engine.subdev.device;
|
2014-05-21 01:24:43 +00:00
|
|
|
struct nvkm_output *outp;
|
2015-08-20 04:54:10 +00:00
|
|
|
u32 pclk = nvkm_rd32(device, 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);
|
2015-08-20 04:54:13 +00:00
|
|
|
struct nvkm_subdev *subdev = &disp->base.engine.subdev;
|
|
|
|
struct nvkm_device *device = subdev->device;
|
2015-08-20 04:54:10 +00:00
|
|
|
u32 super = nvkm_rd32(device, 0x610030);
|
2013-02-20 08:56:33 +00:00
|
|
|
int head;
|
2012-11-09 02:09:48 +00:00
|
|
|
|
2015-08-20 04:54:13 +00:00
|
|
|
nvkm_debug(subdev, "supervisor %08x %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) {
|
2015-08-20 04:54:19 +00:00
|
|
|
nv50_disp_chan_mthd(disp->chan[0], NV_DBG_DEBUG);
|
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 & (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:10 +00:00
|
|
|
nvkm_wr32(device, 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;
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = disp->base.engine.subdev.device;
|
|
|
|
u32 intr0 = nvkm_rd32(device, 0x610020);
|
|
|
|
u32 intr1 = nvkm_rd32(device, 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);
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, 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);
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, 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);
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, 0x610024, disp->super);
|
2012-11-09 02:09:48 +00:00
|
|
|
}
|
2012-07-19 22:17:34 +00:00
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:19 +00:00
|
|
|
static const struct nvkm_disp_func
|
|
|
|
nv50_disp = {
|
|
|
|
.root = &nv50_disp_root_oclass,
|
|
|
|
};
|
|
|
|
|
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:19 +00:00
|
|
|
disp->base.func = &nv50_disp;
|
|
|
|
|
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_subdev(disp)->intr = nv50_disp_intr;
|
|
|
|
INIT_WORK(&disp->supervisor, nv50_disp_intr_supervisor);
|
|
|
|
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-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
|
|
|
},
|
2015-08-20 04:54:15 +00:00
|
|
|
.base.outp.internal.crt = nv50_dac_output_new,
|
|
|
|
.base.outp.internal.tmds = nv50_sor_output_new,
|
|
|
|
.base.outp.internal.lvds = nv50_sor_output_new,
|
|
|
|
.base.outp.external.tmds = nv50_pior_output_new,
|
|
|
|
.base.outp.external.dp = nv50_pior_dp_new,
|
2014-08-09 18:10:20 +00:00
|
|
|
.base.vblank = &nv50_disp_vblank_func,
|
2015-08-20 04:54:19 +00:00
|
|
|
.head.scanoutpos = nv50_disp_root_scanoutpos,
|
2014-02-20 11:33:34 +00:00
|
|
|
}.base.base;
|