2009-12-11 09:24:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2007 Matthieu CASTET <castet.matthieu@free.fr>
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* 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 (including the next
|
2015-01-14 02:02:28 +00:00
|
|
|
* paragr) shall be included in all copies or substantial portions of the
|
2009-12-11 09:24:15 +00:00
|
|
|
* 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
|
|
|
|
* PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
|
|
|
|
*/
|
2015-08-20 04:54:22 +00:00
|
|
|
#include "nv10.h"
|
2015-01-14 05:29:43 +00:00
|
|
|
#include "regs.h"
|
2009-12-11 09:24:15 +00:00
|
|
|
|
2012-12-09 22:00:34 +00:00
|
|
|
#include <core/client.h>
|
2015-08-20 04:54:22 +00:00
|
|
|
#include <core/gpuobj.h>
|
2012-07-19 22:17:34 +00:00
|
|
|
#include <engine/fifo.h>
|
2015-08-20 04:54:19 +00:00
|
|
|
#include <engine/fifo/chan.h>
|
2015-01-14 05:29:43 +00:00
|
|
|
#include <subdev/fb.h>
|
2009-12-11 09:24:15 +00:00
|
|
|
|
|
|
|
struct pipe_state {
|
2012-07-19 22:17:34 +00:00
|
|
|
u32 pipe_0x0000[0x040/4];
|
|
|
|
u32 pipe_0x0040[0x010/4];
|
|
|
|
u32 pipe_0x0200[0x0c0/4];
|
|
|
|
u32 pipe_0x4400[0x080/4];
|
|
|
|
u32 pipe_0x6400[0x3b0/4];
|
|
|
|
u32 pipe_0x6800[0x2f0/4];
|
|
|
|
u32 pipe_0x6c00[0x030/4];
|
|
|
|
u32 pipe_0x7000[0x130/4];
|
|
|
|
u32 pipe_0x7400[0x0c0/4];
|
|
|
|
u32 pipe_0x7800[0x0c0/4];
|
2009-12-11 09:24:15 +00:00
|
|
|
};
|
|
|
|
|
2015-01-14 02:02:28 +00:00
|
|
|
static int nv10_gr_ctx_regs[] = {
|
2010-08-04 02:54:08 +00:00
|
|
|
NV10_PGRAPH_CTX_SWITCH(0),
|
|
|
|
NV10_PGRAPH_CTX_SWITCH(1),
|
|
|
|
NV10_PGRAPH_CTX_SWITCH(2),
|
|
|
|
NV10_PGRAPH_CTX_SWITCH(3),
|
|
|
|
NV10_PGRAPH_CTX_SWITCH(4),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(0, 0),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(0, 1),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(0, 2),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(0, 3),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(0, 4),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(1, 0),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(1, 1),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(1, 2),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(1, 3),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(1, 4),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(2, 0),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(2, 1),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(2, 2),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(2, 3),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(2, 4),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(3, 0),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(3, 1),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(3, 2),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(3, 3),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(3, 4),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(4, 0),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(4, 1),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(4, 2),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(4, 3),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(4, 4),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(5, 0),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(5, 1),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(5, 2),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(5, 3),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(5, 4),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(6, 0),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(6, 1),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(6, 2),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(6, 3),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(6, 4),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(7, 0),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(7, 1),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(7, 2),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(7, 3),
|
|
|
|
NV10_PGRAPH_CTX_CACHE(7, 4),
|
2009-12-11 09:24:15 +00:00
|
|
|
NV10_PGRAPH_CTX_USER,
|
|
|
|
NV04_PGRAPH_DMA_START_0,
|
|
|
|
NV04_PGRAPH_DMA_START_1,
|
|
|
|
NV04_PGRAPH_DMA_LENGTH,
|
|
|
|
NV04_PGRAPH_DMA_MISC,
|
|
|
|
NV10_PGRAPH_DMA_PITCH,
|
|
|
|
NV04_PGRAPH_BOFFSET0,
|
|
|
|
NV04_PGRAPH_BBASE0,
|
|
|
|
NV04_PGRAPH_BLIMIT0,
|
|
|
|
NV04_PGRAPH_BOFFSET1,
|
|
|
|
NV04_PGRAPH_BBASE1,
|
|
|
|
NV04_PGRAPH_BLIMIT1,
|
|
|
|
NV04_PGRAPH_BOFFSET2,
|
|
|
|
NV04_PGRAPH_BBASE2,
|
|
|
|
NV04_PGRAPH_BLIMIT2,
|
|
|
|
NV04_PGRAPH_BOFFSET3,
|
|
|
|
NV04_PGRAPH_BBASE3,
|
|
|
|
NV04_PGRAPH_BLIMIT3,
|
|
|
|
NV04_PGRAPH_BOFFSET4,
|
|
|
|
NV04_PGRAPH_BBASE4,
|
|
|
|
NV04_PGRAPH_BLIMIT4,
|
|
|
|
NV04_PGRAPH_BOFFSET5,
|
|
|
|
NV04_PGRAPH_BBASE5,
|
|
|
|
NV04_PGRAPH_BLIMIT5,
|
|
|
|
NV04_PGRAPH_BPITCH0,
|
|
|
|
NV04_PGRAPH_BPITCH1,
|
|
|
|
NV04_PGRAPH_BPITCH2,
|
|
|
|
NV04_PGRAPH_BPITCH3,
|
|
|
|
NV04_PGRAPH_BPITCH4,
|
|
|
|
NV10_PGRAPH_SURFACE,
|
|
|
|
NV10_PGRAPH_STATE,
|
|
|
|
NV04_PGRAPH_BSWIZZLE2,
|
|
|
|
NV04_PGRAPH_BSWIZZLE5,
|
|
|
|
NV04_PGRAPH_BPIXEL,
|
|
|
|
NV10_PGRAPH_NOTIFY,
|
|
|
|
NV04_PGRAPH_PATT_COLOR0,
|
|
|
|
NV04_PGRAPH_PATT_COLOR1,
|
|
|
|
NV04_PGRAPH_PATT_COLORRAM, /* 64 values from 0x400900 to 0x4009fc */
|
|
|
|
0x00400904,
|
|
|
|
0x00400908,
|
|
|
|
0x0040090c,
|
|
|
|
0x00400910,
|
|
|
|
0x00400914,
|
|
|
|
0x00400918,
|
|
|
|
0x0040091c,
|
|
|
|
0x00400920,
|
|
|
|
0x00400924,
|
|
|
|
0x00400928,
|
|
|
|
0x0040092c,
|
|
|
|
0x00400930,
|
|
|
|
0x00400934,
|
|
|
|
0x00400938,
|
|
|
|
0x0040093c,
|
|
|
|
0x00400940,
|
|
|
|
0x00400944,
|
|
|
|
0x00400948,
|
|
|
|
0x0040094c,
|
|
|
|
0x00400950,
|
|
|
|
0x00400954,
|
|
|
|
0x00400958,
|
|
|
|
0x0040095c,
|
|
|
|
0x00400960,
|
|
|
|
0x00400964,
|
|
|
|
0x00400968,
|
|
|
|
0x0040096c,
|
|
|
|
0x00400970,
|
|
|
|
0x00400974,
|
|
|
|
0x00400978,
|
|
|
|
0x0040097c,
|
|
|
|
0x00400980,
|
|
|
|
0x00400984,
|
|
|
|
0x00400988,
|
|
|
|
0x0040098c,
|
|
|
|
0x00400990,
|
|
|
|
0x00400994,
|
|
|
|
0x00400998,
|
|
|
|
0x0040099c,
|
|
|
|
0x004009a0,
|
|
|
|
0x004009a4,
|
|
|
|
0x004009a8,
|
|
|
|
0x004009ac,
|
|
|
|
0x004009b0,
|
|
|
|
0x004009b4,
|
|
|
|
0x004009b8,
|
|
|
|
0x004009bc,
|
|
|
|
0x004009c0,
|
|
|
|
0x004009c4,
|
|
|
|
0x004009c8,
|
|
|
|
0x004009cc,
|
|
|
|
0x004009d0,
|
|
|
|
0x004009d4,
|
|
|
|
0x004009d8,
|
|
|
|
0x004009dc,
|
|
|
|
0x004009e0,
|
|
|
|
0x004009e4,
|
|
|
|
0x004009e8,
|
|
|
|
0x004009ec,
|
|
|
|
0x004009f0,
|
|
|
|
0x004009f4,
|
|
|
|
0x004009f8,
|
|
|
|
0x004009fc,
|
|
|
|
NV04_PGRAPH_PATTERN, /* 2 values from 0x400808 to 0x40080c */
|
|
|
|
0x0040080c,
|
|
|
|
NV04_PGRAPH_PATTERN_SHAPE,
|
|
|
|
NV03_PGRAPH_MONO_COLOR0,
|
|
|
|
NV04_PGRAPH_ROP3,
|
|
|
|
NV04_PGRAPH_CHROMA,
|
|
|
|
NV04_PGRAPH_BETA_AND,
|
|
|
|
NV04_PGRAPH_BETA_PREMULT,
|
|
|
|
0x00400e70,
|
|
|
|
0x00400e74,
|
|
|
|
0x00400e78,
|
|
|
|
0x00400e7c,
|
|
|
|
0x00400e80,
|
|
|
|
0x00400e84,
|
|
|
|
0x00400e88,
|
|
|
|
0x00400e8c,
|
|
|
|
0x00400ea0,
|
|
|
|
0x00400ea4,
|
|
|
|
0x00400ea8,
|
|
|
|
0x00400e90,
|
|
|
|
0x00400e94,
|
|
|
|
0x00400e98,
|
|
|
|
0x00400e9c,
|
|
|
|
NV10_PGRAPH_WINDOWCLIP_HORIZONTAL, /* 8 values from 0x400f00-0x400f1c */
|
|
|
|
NV10_PGRAPH_WINDOWCLIP_VERTICAL, /* 8 values from 0x400f20-0x400f3c */
|
|
|
|
0x00400f04,
|
|
|
|
0x00400f24,
|
|
|
|
0x00400f08,
|
|
|
|
0x00400f28,
|
|
|
|
0x00400f0c,
|
|
|
|
0x00400f2c,
|
|
|
|
0x00400f10,
|
|
|
|
0x00400f30,
|
|
|
|
0x00400f14,
|
|
|
|
0x00400f34,
|
|
|
|
0x00400f18,
|
|
|
|
0x00400f38,
|
|
|
|
0x00400f1c,
|
|
|
|
0x00400f3c,
|
|
|
|
NV10_PGRAPH_XFMODE0,
|
|
|
|
NV10_PGRAPH_XFMODE1,
|
|
|
|
NV10_PGRAPH_GLOBALSTATE0,
|
|
|
|
NV10_PGRAPH_GLOBALSTATE1,
|
|
|
|
NV04_PGRAPH_STORED_FMT,
|
|
|
|
NV04_PGRAPH_SOURCE_COLOR,
|
|
|
|
NV03_PGRAPH_ABS_X_RAM, /* 32 values from 0x400400 to 0x40047c */
|
|
|
|
NV03_PGRAPH_ABS_Y_RAM, /* 32 values from 0x400480 to 0x4004fc */
|
|
|
|
0x00400404,
|
|
|
|
0x00400484,
|
|
|
|
0x00400408,
|
|
|
|
0x00400488,
|
|
|
|
0x0040040c,
|
|
|
|
0x0040048c,
|
|
|
|
0x00400410,
|
|
|
|
0x00400490,
|
|
|
|
0x00400414,
|
|
|
|
0x00400494,
|
|
|
|
0x00400418,
|
|
|
|
0x00400498,
|
|
|
|
0x0040041c,
|
|
|
|
0x0040049c,
|
|
|
|
0x00400420,
|
|
|
|
0x004004a0,
|
|
|
|
0x00400424,
|
|
|
|
0x004004a4,
|
|
|
|
0x00400428,
|
|
|
|
0x004004a8,
|
|
|
|
0x0040042c,
|
|
|
|
0x004004ac,
|
|
|
|
0x00400430,
|
|
|
|
0x004004b0,
|
|
|
|
0x00400434,
|
|
|
|
0x004004b4,
|
|
|
|
0x00400438,
|
|
|
|
0x004004b8,
|
|
|
|
0x0040043c,
|
|
|
|
0x004004bc,
|
|
|
|
0x00400440,
|
|
|
|
0x004004c0,
|
|
|
|
0x00400444,
|
|
|
|
0x004004c4,
|
|
|
|
0x00400448,
|
|
|
|
0x004004c8,
|
|
|
|
0x0040044c,
|
|
|
|
0x004004cc,
|
|
|
|
0x00400450,
|
|
|
|
0x004004d0,
|
|
|
|
0x00400454,
|
|
|
|
0x004004d4,
|
|
|
|
0x00400458,
|
|
|
|
0x004004d8,
|
|
|
|
0x0040045c,
|
|
|
|
0x004004dc,
|
|
|
|
0x00400460,
|
|
|
|
0x004004e0,
|
|
|
|
0x00400464,
|
|
|
|
0x004004e4,
|
|
|
|
0x00400468,
|
|
|
|
0x004004e8,
|
|
|
|
0x0040046c,
|
|
|
|
0x004004ec,
|
|
|
|
0x00400470,
|
|
|
|
0x004004f0,
|
|
|
|
0x00400474,
|
|
|
|
0x004004f4,
|
|
|
|
0x00400478,
|
|
|
|
0x004004f8,
|
|
|
|
0x0040047c,
|
|
|
|
0x004004fc,
|
|
|
|
NV03_PGRAPH_ABS_UCLIP_XMIN,
|
|
|
|
NV03_PGRAPH_ABS_UCLIP_XMAX,
|
|
|
|
NV03_PGRAPH_ABS_UCLIP_YMIN,
|
|
|
|
NV03_PGRAPH_ABS_UCLIP_YMAX,
|
|
|
|
0x00400550,
|
|
|
|
0x00400558,
|
|
|
|
0x00400554,
|
|
|
|
0x0040055c,
|
|
|
|
NV03_PGRAPH_ABS_UCLIPA_XMIN,
|
|
|
|
NV03_PGRAPH_ABS_UCLIPA_XMAX,
|
|
|
|
NV03_PGRAPH_ABS_UCLIPA_YMIN,
|
|
|
|
NV03_PGRAPH_ABS_UCLIPA_YMAX,
|
|
|
|
NV03_PGRAPH_ABS_ICLIP_XMAX,
|
|
|
|
NV03_PGRAPH_ABS_ICLIP_YMAX,
|
|
|
|
NV03_PGRAPH_XY_LOGIC_MISC0,
|
|
|
|
NV03_PGRAPH_XY_LOGIC_MISC1,
|
|
|
|
NV03_PGRAPH_XY_LOGIC_MISC2,
|
|
|
|
NV03_PGRAPH_XY_LOGIC_MISC3,
|
|
|
|
NV03_PGRAPH_CLIPX_0,
|
|
|
|
NV03_PGRAPH_CLIPX_1,
|
|
|
|
NV03_PGRAPH_CLIPY_0,
|
|
|
|
NV03_PGRAPH_CLIPY_1,
|
|
|
|
NV10_PGRAPH_COMBINER0_IN_ALPHA,
|
|
|
|
NV10_PGRAPH_COMBINER1_IN_ALPHA,
|
|
|
|
NV10_PGRAPH_COMBINER0_IN_RGB,
|
|
|
|
NV10_PGRAPH_COMBINER1_IN_RGB,
|
|
|
|
NV10_PGRAPH_COMBINER_COLOR0,
|
|
|
|
NV10_PGRAPH_COMBINER_COLOR1,
|
|
|
|
NV10_PGRAPH_COMBINER0_OUT_ALPHA,
|
|
|
|
NV10_PGRAPH_COMBINER1_OUT_ALPHA,
|
|
|
|
NV10_PGRAPH_COMBINER0_OUT_RGB,
|
|
|
|
NV10_PGRAPH_COMBINER1_OUT_RGB,
|
|
|
|
NV10_PGRAPH_COMBINER_FINAL0,
|
|
|
|
NV10_PGRAPH_COMBINER_FINAL1,
|
|
|
|
0x00400e00,
|
|
|
|
0x00400e04,
|
|
|
|
0x00400e08,
|
|
|
|
0x00400e0c,
|
|
|
|
0x00400e10,
|
|
|
|
0x00400e14,
|
|
|
|
0x00400e18,
|
|
|
|
0x00400e1c,
|
|
|
|
0x00400e20,
|
|
|
|
0x00400e24,
|
|
|
|
0x00400e28,
|
|
|
|
0x00400e2c,
|
|
|
|
0x00400e30,
|
|
|
|
0x00400e34,
|
|
|
|
0x00400e38,
|
|
|
|
0x00400e3c,
|
|
|
|
NV04_PGRAPH_PASSTHRU_0,
|
|
|
|
NV04_PGRAPH_PASSTHRU_1,
|
|
|
|
NV04_PGRAPH_PASSTHRU_2,
|
|
|
|
NV10_PGRAPH_DIMX_TEXTURE,
|
|
|
|
NV10_PGRAPH_WDIMX_TEXTURE,
|
|
|
|
NV10_PGRAPH_DVD_COLORFMT,
|
|
|
|
NV10_PGRAPH_SCALED_FORMAT,
|
|
|
|
NV04_PGRAPH_MISC24_0,
|
|
|
|
NV04_PGRAPH_MISC24_1,
|
|
|
|
NV04_PGRAPH_MISC24_2,
|
|
|
|
NV03_PGRAPH_X_MISC,
|
|
|
|
NV03_PGRAPH_Y_MISC,
|
|
|
|
NV04_PGRAPH_VALID1,
|
|
|
|
NV04_PGRAPH_VALID2,
|
|
|
|
};
|
|
|
|
|
2015-01-14 02:02:28 +00:00
|
|
|
static int nv17_gr_ctx_regs[] = {
|
2009-12-11 09:24:15 +00:00
|
|
|
NV10_PGRAPH_DEBUG_4,
|
|
|
|
0x004006b0,
|
|
|
|
0x00400eac,
|
|
|
|
0x00400eb0,
|
|
|
|
0x00400eb4,
|
|
|
|
0x00400eb8,
|
|
|
|
0x00400ebc,
|
|
|
|
0x00400ec0,
|
|
|
|
0x00400ec4,
|
|
|
|
0x00400ec8,
|
|
|
|
0x00400ecc,
|
|
|
|
0x00400ed0,
|
|
|
|
0x00400ed4,
|
|
|
|
0x00400ed8,
|
|
|
|
0x00400edc,
|
|
|
|
0x00400ee0,
|
|
|
|
0x00400a00,
|
|
|
|
0x00400a04,
|
|
|
|
};
|
|
|
|
|
2015-08-20 04:54:19 +00:00
|
|
|
#define nv10_gr(p) container_of((p), struct nv10_gr, base)
|
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
struct nv10_gr {
|
2015-01-14 05:29:43 +00:00
|
|
|
struct nvkm_gr base;
|
2015-01-14 02:02:28 +00:00
|
|
|
struct nv10_gr_chan *chan[32];
|
2012-07-19 22:17:34 +00:00
|
|
|
spinlock_t lock;
|
|
|
|
};
|
|
|
|
|
2015-08-20 04:54:19 +00:00
|
|
|
#define nv10_gr_chan(p) container_of((p), struct nv10_gr_chan, object)
|
|
|
|
|
2015-01-14 02:02:28 +00:00
|
|
|
struct nv10_gr_chan {
|
2015-08-20 04:54:19 +00:00
|
|
|
struct nvkm_object object;
|
|
|
|
struct nv10_gr *gr;
|
2012-07-19 22:17:34 +00:00
|
|
|
int chid;
|
2015-01-14 02:02:28 +00:00
|
|
|
int nv10[ARRAY_SIZE(nv10_gr_ctx_regs)];
|
|
|
|
int nv17[ARRAY_SIZE(nv17_gr_ctx_regs)];
|
2009-12-11 09:24:15 +00:00
|
|
|
struct pipe_state pipe_state;
|
2012-07-19 22:17:34 +00:00
|
|
|
u32 lma_window[4];
|
2009-12-11 09:24:15 +00:00
|
|
|
};
|
|
|
|
|
2012-07-19 22:17:34 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Graphics object classes
|
|
|
|
******************************************************************************/
|
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
#define PIPE_SAVE(gr, state, addr) \
|
2009-12-14 14:00:30 +00:00
|
|
|
do { \
|
|
|
|
int __i; \
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, addr); \
|
2009-12-14 14:00:30 +00:00
|
|
|
for (__i = 0; __i < ARRAY_SIZE(state); __i++) \
|
2015-08-20 04:54:10 +00:00
|
|
|
state[__i] = nvkm_rd32(device, NV10_PGRAPH_PIPE_DATA); \
|
2009-12-14 14:00:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
#define PIPE_RESTORE(gr, state, addr) \
|
2009-12-14 14:00:30 +00:00
|
|
|
do { \
|
|
|
|
int __i; \
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, addr); \
|
2009-12-14 14:00:30 +00:00
|
|
|
for (__i = 0; __i < ARRAY_SIZE(state); __i++) \
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, state[__i]); \
|
2009-12-14 14:00:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
static void
|
|
|
|
nv17_gr_mthd_lma_window(struct nv10_gr_chan *chan, u32 mthd, u32 data)
|
2012-07-19 22:17:34 +00:00
|
|
|
{
|
2015-08-20 04:54:19 +00:00
|
|
|
struct nvkm_device *device = chan->object.engine->subdev.device;
|
|
|
|
struct nvkm_gr *gr = &chan->gr->base;
|
2012-07-19 22:17:34 +00:00
|
|
|
struct pipe_state *pipe = &chan->pipe_state;
|
|
|
|
u32 pipe_0x0040[1], pipe_0x64c0[8], pipe_0x6a80[3], pipe_0x6ab0[3];
|
|
|
|
u32 xfmode0, xfmode1;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
chan->lma_window[(mthd - 0x1638) / 4] = data;
|
|
|
|
|
|
|
|
if (mthd != 0x1644)
|
2015-08-20 04:54:18 +00:00
|
|
|
return;
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
nv04_gr_idle(gr);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
PIPE_SAVE(device, pipe_0x0040, 0x0040);
|
|
|
|
PIPE_SAVE(device, pipe->pipe_0x0200, 0x0200);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
PIPE_RESTORE(device, chan->lma_window, 0x6790);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
nv04_gr_idle(gr);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
xfmode0 = nvkm_rd32(device, NV10_PGRAPH_XFMODE0);
|
|
|
|
xfmode1 = nvkm_rd32(device, NV10_PGRAPH_XFMODE1);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
PIPE_SAVE(device, pipe->pipe_0x4400, 0x4400);
|
|
|
|
PIPE_SAVE(device, pipe_0x64c0, 0x64c0);
|
|
|
|
PIPE_SAVE(device, pipe_0x6ab0, 0x6ab0);
|
|
|
|
PIPE_SAVE(device, pipe_0x6a80, 0x6a80);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
nv04_gr_idle(gr);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_XFMODE0, 0x10000000);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_XFMODE1, 0x00000000);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, 0x000064c0);
|
2012-07-19 22:17:34 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x3f800000);
|
2012-07-19 22:17:34 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x00000000);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, 0x00006ab0);
|
2012-07-19 22:17:34 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x3f800000);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, 0x00006a80);
|
2012-07-19 22:17:34 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x00000000);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, 0x00000040);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x00000008);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
PIPE_RESTORE(device, pipe->pipe_0x0200, 0x0200);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
nv04_gr_idle(gr);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
PIPE_RESTORE(device, pipe_0x0040, 0x0040);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_XFMODE0, xfmode0);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_XFMODE1, xfmode1);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
PIPE_RESTORE(device, pipe_0x64c0, 0x64c0);
|
|
|
|
PIPE_RESTORE(device, pipe_0x6ab0, 0x6ab0);
|
|
|
|
PIPE_RESTORE(device, pipe_0x6a80, 0x6a80);
|
|
|
|
PIPE_RESTORE(device, pipe->pipe_0x4400, 0x4400);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, 0x000000c0);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x00000000);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
nv04_gr_idle(gr);
|
2012-07-19 22:17:34 +00:00
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
static void
|
|
|
|
nv17_gr_mthd_lma_enable(struct nv10_gr_chan *chan, u32 mthd, u32 data)
|
2009-12-11 09:24:15 +00:00
|
|
|
{
|
2015-08-20 04:54:19 +00:00
|
|
|
struct nvkm_device *device = chan->object.engine->subdev.device;
|
|
|
|
struct nvkm_gr *gr = &chan->gr->base;
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
nv04_gr_idle(gr);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_mask(device, NV10_PGRAPH_DEBUG_4, 0x00000100, 0x00000100);
|
|
|
|
nvkm_mask(device, 0x4006b0, 0x08000000, 0x08000000);
|
2009-12-11 09:24:15 +00:00
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
static bool
|
|
|
|
nv17_gr_mthd_celcius(struct nv10_gr_chan *chan, u32 mthd, u32 data)
|
|
|
|
{
|
|
|
|
void (*func)(struct nv10_gr_chan *, u32, u32);
|
|
|
|
switch (mthd) {
|
|
|
|
case 0x1638 ... 0x1644:
|
|
|
|
func = nv17_gr_mthd_lma_window; break;
|
|
|
|
case 0x1658: func = nv17_gr_mthd_lma_enable; break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
func(chan, mthd, data);
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
static bool
|
|
|
|
nv10_gr_mthd(struct nv10_gr_chan *chan, u8 class, u32 mthd, u32 data)
|
|
|
|
{
|
|
|
|
bool (*func)(struct nv10_gr_chan *, u32, u32);
|
|
|
|
switch (class) {
|
|
|
|
case 0x99: func = nv17_gr_mthd_celcius; break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return func(chan, mthd, data);
|
|
|
|
}
|
2012-07-19 22:17:34 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* PGRAPH context
|
|
|
|
******************************************************************************/
|
|
|
|
|
2015-01-14 02:02:28 +00:00
|
|
|
static struct nv10_gr_chan *
|
2015-08-20 04:54:08 +00:00
|
|
|
nv10_gr_channel(struct nv10_gr *gr)
|
2009-12-11 09:24:15 +00:00
|
|
|
{
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
2015-01-14 02:02:28 +00:00
|
|
|
struct nv10_gr_chan *chan = NULL;
|
2015-08-20 04:54:10 +00:00
|
|
|
if (nvkm_rd32(device, 0x400144) & 0x00010000) {
|
|
|
|
int chid = nvkm_rd32(device, 0x400148) >> 24;
|
2015-08-20 04:54:08 +00:00
|
|
|
if (chid < ARRAY_SIZE(gr->chan))
|
|
|
|
chan = gr->chan[chid];
|
2012-07-19 22:17:34 +00:00
|
|
|
}
|
|
|
|
return chan;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_save_pipe(struct nv10_gr_chan *chan)
|
2012-07-19 22:17:34 +00:00
|
|
|
{
|
2015-08-20 04:54:19 +00:00
|
|
|
struct nv10_gr *gr = chan->gr;
|
2012-07-19 22:17:34 +00:00
|
|
|
struct pipe_state *pipe = &chan->pipe_state;
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
PIPE_SAVE(gr, pipe->pipe_0x4400, 0x4400);
|
|
|
|
PIPE_SAVE(gr, pipe->pipe_0x0200, 0x0200);
|
|
|
|
PIPE_SAVE(gr, pipe->pipe_0x6400, 0x6400);
|
|
|
|
PIPE_SAVE(gr, pipe->pipe_0x6800, 0x6800);
|
|
|
|
PIPE_SAVE(gr, pipe->pipe_0x6c00, 0x6c00);
|
|
|
|
PIPE_SAVE(gr, pipe->pipe_0x7000, 0x7000);
|
|
|
|
PIPE_SAVE(gr, pipe->pipe_0x7400, 0x7400);
|
|
|
|
PIPE_SAVE(gr, pipe->pipe_0x7800, 0x7800);
|
|
|
|
PIPE_SAVE(gr, pipe->pipe_0x0040, 0x0040);
|
|
|
|
PIPE_SAVE(gr, pipe->pipe_0x0000, 0x0000);
|
2012-07-19 22:17:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_load_pipe(struct nv10_gr_chan *chan)
|
2012-07-19 22:17:34 +00:00
|
|
|
{
|
2015-08-20 04:54:19 +00:00
|
|
|
struct nv10_gr *gr = chan->gr;
|
2012-07-19 22:17:34 +00:00
|
|
|
struct pipe_state *pipe = &chan->pipe_state;
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
2012-07-19 22:17:34 +00:00
|
|
|
u32 xfmode0, xfmode1;
|
2009-12-14 14:00:30 +00:00
|
|
|
int i;
|
2009-12-11 09:24:15 +00:00
|
|
|
|
2015-08-20 04:54:19 +00:00
|
|
|
nv04_gr_idle(&gr->base);
|
2009-12-11 09:24:15 +00:00
|
|
|
/* XXX check haiku comments */
|
2015-08-20 04:54:10 +00:00
|
|
|
xfmode0 = nvkm_rd32(device, NV10_PGRAPH_XFMODE0);
|
|
|
|
xfmode1 = nvkm_rd32(device, NV10_PGRAPH_XFMODE1);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_XFMODE0, 0x10000000);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_XFMODE1, 0x00000000);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, 0x000064c0);
|
2009-12-11 09:24:15 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x3f800000);
|
2009-12-11 09:24:15 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x00000000);
|
2009-12-11 09:24:15 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, 0x00006ab0);
|
2009-12-11 09:24:15 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x3f800000);
|
2009-12-11 09:24:15 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, 0x00006a80);
|
2009-12-11 09:24:15 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x00000000);
|
2009-12-11 09:24:15 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_ADDRESS, 0x00000040);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_PIPE_DATA, 0x00000008);
|
2009-12-11 09:24:15 +00:00
|
|
|
|
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
PIPE_RESTORE(gr, pipe->pipe_0x0200, 0x0200);
|
2015-08-20 04:54:19 +00:00
|
|
|
nv04_gr_idle(&gr->base);
|
2009-12-11 09:24:15 +00:00
|
|
|
|
|
|
|
/* restore XFMODE */
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_XFMODE0, xfmode0);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_XFMODE1, xfmode1);
|
2015-08-20 04:54:08 +00:00
|
|
|
PIPE_RESTORE(gr, pipe->pipe_0x6400, 0x6400);
|
|
|
|
PIPE_RESTORE(gr, pipe->pipe_0x6800, 0x6800);
|
|
|
|
PIPE_RESTORE(gr, pipe->pipe_0x6c00, 0x6c00);
|
|
|
|
PIPE_RESTORE(gr, pipe->pipe_0x7000, 0x7000);
|
|
|
|
PIPE_RESTORE(gr, pipe->pipe_0x7400, 0x7400);
|
|
|
|
PIPE_RESTORE(gr, pipe->pipe_0x7800, 0x7800);
|
|
|
|
PIPE_RESTORE(gr, pipe->pipe_0x4400, 0x4400);
|
|
|
|
PIPE_RESTORE(gr, pipe->pipe_0x0000, 0x0000);
|
|
|
|
PIPE_RESTORE(gr, pipe->pipe_0x0040, 0x0040);
|
2015-08-20 04:54:19 +00:00
|
|
|
nv04_gr_idle(&gr->base);
|
2009-12-11 09:24:15 +00:00
|
|
|
}
|
|
|
|
|
2012-07-19 22:17:34 +00:00
|
|
|
static void
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_create_pipe(struct nv10_gr_chan *chan)
|
2009-12-11 09:24:15 +00:00
|
|
|
{
|
2015-08-20 04:54:19 +00:00
|
|
|
struct nv10_gr *gr = chan->gr;
|
2015-08-20 04:54:13 +00:00
|
|
|
struct nvkm_subdev *subdev = &gr->base.engine.subdev;
|
2012-07-19 22:17:34 +00:00
|
|
|
struct pipe_state *pipe_state = &chan->pipe_state;
|
|
|
|
u32 *pipe_state_addr;
|
2009-12-11 09:24:15 +00:00
|
|
|
int i;
|
|
|
|
#define PIPE_INIT(addr) \
|
|
|
|
do { \
|
2012-07-19 22:17:34 +00:00
|
|
|
pipe_state_addr = pipe_state->pipe_##addr; \
|
2009-12-11 09:24:15 +00:00
|
|
|
} while (0)
|
|
|
|
#define PIPE_INIT_END(addr) \
|
|
|
|
do { \
|
2012-07-19 22:17:34 +00:00
|
|
|
u32 *__end_addr = pipe_state->pipe_##addr + \
|
|
|
|
ARRAY_SIZE(pipe_state->pipe_##addr); \
|
|
|
|
if (pipe_state_addr != __end_addr) \
|
2015-08-20 04:54:13 +00:00
|
|
|
nvkm_error(subdev, "incomplete pipe init for 0x%x : %p/%p\n", \
|
2012-07-19 22:17:34 +00:00
|
|
|
addr, pipe_state_addr, __end_addr); \
|
2009-12-11 09:24:15 +00:00
|
|
|
} while (0)
|
2012-07-19 22:17:34 +00:00
|
|
|
#define NV_WRITE_PIPE_INIT(value) *(pipe_state_addr++) = value
|
2009-12-11 09:24:15 +00:00
|
|
|
|
|
|
|
PIPE_INIT(0x0200);
|
|
|
|
for (i = 0; i < 48; i++)
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
PIPE_INIT_END(0x0200);
|
|
|
|
|
|
|
|
PIPE_INIT(0x6400);
|
|
|
|
for (i = 0; i < 211; i++)
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x3f800000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x40000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x40000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x40000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x40000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x3f800000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x3f000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x3f000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x3f800000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x3f800000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x3f800000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x3f800000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x3f800000);
|
|
|
|
PIPE_INIT_END(0x6400);
|
|
|
|
|
|
|
|
PIPE_INIT(0x6800);
|
|
|
|
for (i = 0; i < 162; i++)
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x3f800000);
|
|
|
|
for (i = 0; i < 25; i++)
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
PIPE_INIT_END(0x6800);
|
|
|
|
|
|
|
|
PIPE_INIT(0x6c00);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0xbf800000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
PIPE_INIT_END(0x6c00);
|
|
|
|
|
|
|
|
PIPE_INIT(0x7000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x7149f2ca);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x7149f2ca);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x7149f2ca);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x7149f2ca);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x7149f2ca);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x7149f2ca);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x7149f2ca);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
NV_WRITE_PIPE_INIT(0x7149f2ca);
|
|
|
|
for (i = 0; i < 35; i++)
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
PIPE_INIT_END(0x7000);
|
|
|
|
|
|
|
|
PIPE_INIT(0x7400);
|
|
|
|
for (i = 0; i < 48; i++)
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
PIPE_INIT_END(0x7400);
|
|
|
|
|
|
|
|
PIPE_INIT(0x7800);
|
|
|
|
for (i = 0; i < 48; i++)
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
PIPE_INIT_END(0x7800);
|
|
|
|
|
|
|
|
PIPE_INIT(0x4400);
|
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
PIPE_INIT_END(0x4400);
|
|
|
|
|
|
|
|
PIPE_INIT(0x0000);
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
PIPE_INIT_END(0x0000);
|
|
|
|
|
|
|
|
PIPE_INIT(0x0040);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
NV_WRITE_PIPE_INIT(0x00000000);
|
|
|
|
PIPE_INIT_END(0x0040);
|
|
|
|
|
|
|
|
#undef PIPE_INIT
|
|
|
|
#undef PIPE_INIT_END
|
|
|
|
#undef NV_WRITE_PIPE_INIT
|
|
|
|
}
|
|
|
|
|
2012-07-19 22:17:34 +00:00
|
|
|
static int
|
2015-08-20 04:54:08 +00:00
|
|
|
nv10_gr_ctx_regs_find_offset(struct nv10_gr *gr, int reg)
|
2009-12-11 09:24:15 +00:00
|
|
|
{
|
2015-08-20 04:54:13 +00:00
|
|
|
struct nvkm_subdev *subdev = &gr->base.engine.subdev;
|
2009-12-11 09:24:15 +00:00
|
|
|
int i;
|
2015-01-14 02:02:28 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(nv10_gr_ctx_regs); i++) {
|
|
|
|
if (nv10_gr_ctx_regs[i] == reg)
|
2009-12-11 09:24:15 +00:00
|
|
|
return i;
|
|
|
|
}
|
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
Pull drm updates from Dave Airlie:
"This is the main pull request for the drm for 4.3. Nouveau is
probably the biggest amount of changes in here, since it missed 4.2.
Highlights below, along with the usual bunch of fixes.
All stuff outside drm should have applicable acks.
Highlights:
- new drivers:
freescale dcu kms driver
- core:
more atomic fixes
disable some dri1 interfaces on kms drivers
drop fb panic handling, this was just getting more broken, as more locking was required.
new core fbdev Kconfig support - instead of each driver enable/disabling it
struct_mutex cleanups
- panel:
more new panels
cleanup Kconfig
- i915:
Skylake support enabled by default
legacy modesetting using atomic infrastructure
Skylake fixes
GEN9 workarounds
- amdgpu:
Fiji support
CGS support for amdgpu
Initial GPU scheduler - off by default
Lots of bug fixes and optimisations.
- radeon:
DP fixes
misc fixes
- amdkfd:
Add Carrizo support for amdkfd using amdgpu.
- nouveau:
long pending cleanup to complete driver,
fully bisectable which makes it larger,
perfmon work
more reclocking improvements
maxwell displayport fixes
- vmwgfx:
new DX device support, supports OpenGL 3.3
screen targets support
- mgag200:
G200eW support
G200e new revision support
- msm:
dragonboard 410c support, msm8x94 support, msm8x74v1 support
yuv format support
dma plane support
mdp5 rotation
initial hdcp
- sti:
atomic support
- exynos:
lots of cleanups
atomic modesetting/pageflipping support
render node support
- tegra:
tegra210 support (dc, dsi, dp/hdmi)
dpms with atomic modesetting support
- atmel:
support for 3 more atmel SoCs
new input formats, PRIME support.
- dwhdmi:
preparing to add audio support
- rockchip:
yuv plane support"
* 'drm-next' of git://people.freedesktop.org/~airlied/linux: (1369 commits)
drm/amdgpu: rename gmc_v8_0_init_compute_vmid
drm/amdgpu: fix vce3 instance handling
drm/amdgpu: remove ib test for the second VCE Ring
drm/amdgpu: properly enable VM fault interrupts
drm/amdgpu: fix warning in scheduler
drm/amdgpu: fix buffer placement under memory pressure
drm/amdgpu/cz: fix cz_dpm_update_low_memory_pstate logic
drm/amdgpu: fix typo in dce11 watermark setup
drm/amdgpu: fix typo in dce10 watermark setup
drm/amdgpu: use top down allocation for non-CPU accessible vram
drm/amdgpu: be explicit about cpu vram access for driver BOs (v2)
drm/amdgpu: set MEC doorbell range for Fiji
drm/amdgpu: implement burst NOP for SDMA
drm/amdgpu: add insert_nop ring func and default implementation
drm/amdgpu: add amdgpu_get_sdma_instance helper function
drm/amdgpu: add AMDGPU_MAX_SDMA_INSTANCES
drm/amdgpu: add burst_nop flag for sdma
drm/amdgpu: add count field for the SDMA NOP packet v2
drm/amdgpu: use PT for VM sync on unmap
drm/amdgpu: make wait_event uninterruptible in push_job
...
2015-09-04 22:49:32 +00:00
|
|
|
nvkm_error(subdev, "unknown offset nv10_ctx_regs %d\n", reg);
|
2009-12-11 09:24:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-07-19 22:17:34 +00:00
|
|
|
static int
|
2015-08-20 04:54:08 +00:00
|
|
|
nv17_gr_ctx_regs_find_offset(struct nv10_gr *gr, int reg)
|
2009-12-11 09:24:15 +00:00
|
|
|
{
|
2015-08-20 04:54:13 +00:00
|
|
|
struct nvkm_subdev *subdev = &gr->base.engine.subdev;
|
2009-12-11 09:24:15 +00:00
|
|
|
int i;
|
2015-01-14 02:02:28 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(nv17_gr_ctx_regs); i++) {
|
|
|
|
if (nv17_gr_ctx_regs[i] == reg)
|
2009-12-11 09:24:15 +00:00
|
|
|
return i;
|
|
|
|
}
|
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
Pull drm updates from Dave Airlie:
"This is the main pull request for the drm for 4.3. Nouveau is
probably the biggest amount of changes in here, since it missed 4.2.
Highlights below, along with the usual bunch of fixes.
All stuff outside drm should have applicable acks.
Highlights:
- new drivers:
freescale dcu kms driver
- core:
more atomic fixes
disable some dri1 interfaces on kms drivers
drop fb panic handling, this was just getting more broken, as more locking was required.
new core fbdev Kconfig support - instead of each driver enable/disabling it
struct_mutex cleanups
- panel:
more new panels
cleanup Kconfig
- i915:
Skylake support enabled by default
legacy modesetting using atomic infrastructure
Skylake fixes
GEN9 workarounds
- amdgpu:
Fiji support
CGS support for amdgpu
Initial GPU scheduler - off by default
Lots of bug fixes and optimisations.
- radeon:
DP fixes
misc fixes
- amdkfd:
Add Carrizo support for amdkfd using amdgpu.
- nouveau:
long pending cleanup to complete driver,
fully bisectable which makes it larger,
perfmon work
more reclocking improvements
maxwell displayport fixes
- vmwgfx:
new DX device support, supports OpenGL 3.3
screen targets support
- mgag200:
G200eW support
G200e new revision support
- msm:
dragonboard 410c support, msm8x94 support, msm8x74v1 support
yuv format support
dma plane support
mdp5 rotation
initial hdcp
- sti:
atomic support
- exynos:
lots of cleanups
atomic modesetting/pageflipping support
render node support
- tegra:
tegra210 support (dc, dsi, dp/hdmi)
dpms with atomic modesetting support
- atmel:
support for 3 more atmel SoCs
new input formats, PRIME support.
- dwhdmi:
preparing to add audio support
- rockchip:
yuv plane support"
* 'drm-next' of git://people.freedesktop.org/~airlied/linux: (1369 commits)
drm/amdgpu: rename gmc_v8_0_init_compute_vmid
drm/amdgpu: fix vce3 instance handling
drm/amdgpu: remove ib test for the second VCE Ring
drm/amdgpu: properly enable VM fault interrupts
drm/amdgpu: fix warning in scheduler
drm/amdgpu: fix buffer placement under memory pressure
drm/amdgpu/cz: fix cz_dpm_update_low_memory_pstate logic
drm/amdgpu: fix typo in dce11 watermark setup
drm/amdgpu: fix typo in dce10 watermark setup
drm/amdgpu: use top down allocation for non-CPU accessible vram
drm/amdgpu: be explicit about cpu vram access for driver BOs (v2)
drm/amdgpu: set MEC doorbell range for Fiji
drm/amdgpu: implement burst NOP for SDMA
drm/amdgpu: add insert_nop ring func and default implementation
drm/amdgpu: add amdgpu_get_sdma_instance helper function
drm/amdgpu: add AMDGPU_MAX_SDMA_INSTANCES
drm/amdgpu: add burst_nop flag for sdma
drm/amdgpu: add count field for the SDMA NOP packet v2
drm/amdgpu: use PT for VM sync on unmap
drm/amdgpu: make wait_event uninterruptible in push_job
...
2015-09-04 22:49:32 +00:00
|
|
|
nvkm_error(subdev, "unknown offset nv17_ctx_regs %d\n", reg);
|
2009-12-11 09:24:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-07-19 22:17:34 +00:00
|
|
|
static void
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_load_dma_vtxbuf(struct nv10_gr_chan *chan, int chid, u32 inst)
|
2010-08-04 02:54:08 +00:00
|
|
|
{
|
2015-08-20 04:54:19 +00:00
|
|
|
struct nv10_gr *gr = chan->gr;
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
2012-07-19 22:17:34 +00:00
|
|
|
u32 st2, st2_dl, st2_dh, fifo_ptr, fifo[0x60/4];
|
|
|
|
u32 ctx_user, ctx_switch[5];
|
2010-08-04 02:54:08 +00:00
|
|
|
int i, subchan = -1;
|
|
|
|
|
|
|
|
/* NV10TCL_DMA_VTXBUF (method 0x18c) modifies hidden state
|
|
|
|
* that cannot be restored via MMIO. Do it through the FIFO
|
|
|
|
* instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Look for a celsius object */
|
|
|
|
for (i = 0; i < 8; i++) {
|
2015-08-20 04:54:10 +00:00
|
|
|
int class = nvkm_rd32(device, NV10_PGRAPH_CTX_CACHE(i, 0)) & 0xfff;
|
2010-08-04 02:54:08 +00:00
|
|
|
|
|
|
|
if (class == 0x56 || class == 0x96 || class == 0x99) {
|
|
|
|
subchan = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (subchan < 0 || !inst)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Save the current ctx object */
|
2015-08-20 04:54:10 +00:00
|
|
|
ctx_user = nvkm_rd32(device, NV10_PGRAPH_CTX_USER);
|
2010-08-04 02:54:08 +00:00
|
|
|
for (i = 0; i < 5; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
ctx_switch[i] = nvkm_rd32(device, NV10_PGRAPH_CTX_SWITCH(i));
|
2010-08-04 02:54:08 +00:00
|
|
|
|
|
|
|
/* Save the FIFO state */
|
2015-08-20 04:54:10 +00:00
|
|
|
st2 = nvkm_rd32(device, NV10_PGRAPH_FFINTFC_ST2);
|
|
|
|
st2_dl = nvkm_rd32(device, NV10_PGRAPH_FFINTFC_ST2_DL);
|
|
|
|
st2_dh = nvkm_rd32(device, NV10_PGRAPH_FFINTFC_ST2_DH);
|
|
|
|
fifo_ptr = nvkm_rd32(device, NV10_PGRAPH_FFINTFC_FIFO_PTR);
|
2010-08-04 02:54:08 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(fifo); i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
fifo[i] = nvkm_rd32(device, 0x4007a0 + 4 * i);
|
2010-08-04 02:54:08 +00:00
|
|
|
|
|
|
|
/* Switch to the celsius subchannel */
|
|
|
|
for (i = 0; i < 5; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_SWITCH(i),
|
|
|
|
nvkm_rd32(device, NV10_PGRAPH_CTX_CACHE(subchan, i)));
|
|
|
|
nvkm_mask(device, NV10_PGRAPH_CTX_USER, 0xe000, subchan << 13);
|
2010-08-04 02:54:08 +00:00
|
|
|
|
|
|
|
/* Inject NV10TCL_DMA_VTXBUF */
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_FFINTFC_FIFO_PTR, 0);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_FFINTFC_ST2,
|
2012-07-19 22:17:34 +00:00
|
|
|
0x2c000000 | chid << 20 | subchan << 16 | 0x18c);
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_FFINTFC_ST2_DL, inst);
|
|
|
|
nvkm_mask(device, NV10_PGRAPH_CTX_CONTROL, 0, 0x10000);
|
|
|
|
nvkm_mask(device, NV04_PGRAPH_FIFO, 0x00000001, 0x00000001);
|
|
|
|
nvkm_mask(device, NV04_PGRAPH_FIFO, 0x00000001, 0x00000000);
|
2010-08-04 02:54:08 +00:00
|
|
|
|
|
|
|
/* Restore the FIFO state */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(fifo); i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, 0x4007a0 + 4 * i, fifo[i]);
|
2010-08-04 02:54:08 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_FFINTFC_FIFO_PTR, fifo_ptr);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_FFINTFC_ST2, st2);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_FFINTFC_ST2_DL, st2_dl);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_FFINTFC_ST2_DH, st2_dh);
|
2010-08-04 02:54:08 +00:00
|
|
|
|
|
|
|
/* Restore the current ctx object */
|
|
|
|
for (i = 0; i < 5; i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_SWITCH(i), ctx_switch[i]);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_USER, ctx_user);
|
2010-08-04 02:54:08 +00:00
|
|
|
}
|
|
|
|
|
2011-04-01 02:50:55 +00:00
|
|
|
static int
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_load_context(struct nv10_gr_chan *chan, int chid)
|
2009-12-11 09:24:15 +00:00
|
|
|
{
|
2015-08-20 04:54:19 +00:00
|
|
|
struct nv10_gr *gr = chan->gr;
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
2012-07-19 22:17:34 +00:00
|
|
|
u32 inst;
|
2009-12-11 09:24:15 +00:00
|
|
|
int i;
|
|
|
|
|
2015-01-14 02:02:28 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(nv10_gr_ctx_regs); i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, nv10_gr_ctx_regs[i], chan->nv10[i]);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
if (device->card_type >= NV_11 && device->chipset >= 0x17) {
|
2015-01-14 02:02:28 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(nv17_gr_ctx_regs); i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, nv17_gr_ctx_regs[i], chan->nv17[i]);
|
2009-12-11 09:24:15 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_load_pipe(chan);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
inst = nvkm_rd32(device, NV10_PGRAPH_GLOBALSTATE1) & 0xffff;
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_load_dma_vtxbuf(chan, chid, inst);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_CONTROL, 0x10010100);
|
|
|
|
nvkm_mask(device, NV10_PGRAPH_CTX_USER, 0xff000000, chid << 24);
|
|
|
|
nvkm_mask(device, NV10_PGRAPH_FFINTFC_ST2, 0x30000000, 0x00000000);
|
2009-12-11 09:24:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-01 02:50:55 +00:00
|
|
|
static int
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_unload_context(struct nv10_gr_chan *chan)
|
2009-12-11 09:24:15 +00:00
|
|
|
{
|
2015-08-20 04:54:19 +00:00
|
|
|
struct nv10_gr *gr = chan->gr;
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
2009-12-11 09:24:15 +00:00
|
|
|
int i;
|
|
|
|
|
2015-01-14 02:02:28 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(nv10_gr_ctx_regs); i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
chan->nv10[i] = nvkm_rd32(device, nv10_gr_ctx_regs[i]);
|
2009-12-11 09:24:15 +00:00
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
if (device->card_type >= NV_11 && device->chipset >= 0x17) {
|
2015-01-14 02:02:28 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(nv17_gr_ctx_regs); i++)
|
2015-08-20 04:54:10 +00:00
|
|
|
chan->nv17[i] = nvkm_rd32(device, nv17_gr_ctx_regs[i]);
|
2009-12-11 09:24:15 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_save_pipe(chan);
|
2009-12-11 09:24:15 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_CONTROL, 0x10000000);
|
|
|
|
nvkm_mask(device, NV10_PGRAPH_CTX_USER, 0xff000000, 0x1f000000);
|
2009-12-11 09:24:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-03 03:16:18 +00:00
|
|
|
static void
|
2015-08-20 04:54:08 +00:00
|
|
|
nv10_gr_context_switch(struct nv10_gr *gr)
|
2009-12-11 09:24:15 +00:00
|
|
|
{
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
2015-01-14 02:02:28 +00:00
|
|
|
struct nv10_gr_chan *prev = NULL;
|
|
|
|
struct nv10_gr_chan *next = NULL;
|
2009-12-11 09:24:15 +00:00
|
|
|
int chid;
|
|
|
|
|
2015-08-20 04:54:19 +00:00
|
|
|
nv04_gr_idle(&gr->base);
|
2009-12-11 09:24:15 +00:00
|
|
|
|
|
|
|
/* If previous context is valid, we need to save it */
|
2015-08-20 04:54:08 +00:00
|
|
|
prev = nv10_gr_channel(gr);
|
2012-07-19 22:17:34 +00:00
|
|
|
if (prev)
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_unload_context(prev);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
|
|
|
/* load context for next channel */
|
2015-08-20 04:54:10 +00:00
|
|
|
chid = (nvkm_rd32(device, NV04_PGRAPH_TRAPPED_ADDR) >> 20) & 0x1f;
|
2015-08-20 04:54:08 +00:00
|
|
|
next = gr->chan[chid];
|
2012-07-19 22:17:34 +00:00
|
|
|
if (next)
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_load_context(next, chid);
|
2009-12-11 09:24:15 +00:00
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:19 +00:00
|
|
|
static int
|
|
|
|
nv10_gr_chan_fini(struct nvkm_object *object, bool suspend)
|
|
|
|
{
|
|
|
|
struct nv10_gr_chan *chan = nv10_gr_chan(object);
|
|
|
|
struct nv10_gr *gr = chan->gr;
|
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
|
|
|
unsigned long flags;
|
2009-12-11 09:24:15 +00:00
|
|
|
|
2015-08-20 04:54:19 +00:00
|
|
|
spin_lock_irqsave(&gr->lock, flags);
|
|
|
|
nvkm_mask(device, NV04_PGRAPH_FIFO, 0x00000001, 0x00000000);
|
|
|
|
if (nv10_gr_channel(gr) == chan)
|
|
|
|
nv10_gr_unload_context(chan);
|
|
|
|
nvkm_mask(device, NV04_PGRAPH_FIFO, 0x00000001, 0x00000001);
|
|
|
|
spin_unlock_irqrestore(&gr->lock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
nv10_gr_chan_dtor(struct nvkm_object *object)
|
|
|
|
{
|
|
|
|
struct nv10_gr_chan *chan = nv10_gr_chan(object);
|
|
|
|
struct nv10_gr *gr = chan->gr;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&gr->lock, flags);
|
|
|
|
gr->chan[chan->chid] = NULL;
|
|
|
|
spin_unlock_irqrestore(&gr->lock, flags);
|
|
|
|
return chan;
|
2009-12-11 09:24:15 +00:00
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:19 +00:00
|
|
|
static const struct nvkm_object_func
|
|
|
|
nv10_gr_chan = {
|
|
|
|
.dtor = nv10_gr_chan_dtor,
|
|
|
|
.fini = nv10_gr_chan_fini,
|
|
|
|
};
|
|
|
|
|
2009-12-11 09:24:15 +00:00
|
|
|
#define NV_WRITE_CTX(reg, val) do { \
|
2015-08-20 04:54:08 +00:00
|
|
|
int offset = nv10_gr_ctx_regs_find_offset(gr, reg); \
|
2009-12-11 09:24:15 +00:00
|
|
|
if (offset > 0) \
|
2012-07-19 22:17:34 +00:00
|
|
|
chan->nv10[offset] = val; \
|
2009-12-11 09:24:15 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define NV17_WRITE_CTX(reg, val) do { \
|
2015-08-20 04:54:08 +00:00
|
|
|
int offset = nv17_gr_ctx_regs_find_offset(gr, reg); \
|
2009-12-11 09:24:15 +00:00
|
|
|
if (offset > 0) \
|
2012-07-19 22:17:34 +00:00
|
|
|
chan->nv17[offset] = val; \
|
2009-12-11 09:24:15 +00:00
|
|
|
} while (0)
|
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
int
|
2015-08-20 04:54:19 +00:00
|
|
|
nv10_gr_chan_new(struct nvkm_gr *base, struct nvkm_fifo_chan *fifoch,
|
|
|
|
const struct nvkm_oclass *oclass, struct nvkm_object **pobject)
|
2009-12-11 09:24:15 +00:00
|
|
|
{
|
2015-08-20 04:54:19 +00:00
|
|
|
struct nv10_gr *gr = nv10_gr(base);
|
2015-01-14 02:02:28 +00:00
|
|
|
struct nv10_gr_chan *chan;
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
2012-07-19 22:17:34 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
2015-08-20 04:54:19 +00:00
|
|
|
if (!(chan = kzalloc(sizeof(*chan), GFP_KERNEL)))
|
|
|
|
return -ENOMEM;
|
|
|
|
nvkm_object_ctor(&nv10_gr_chan, oclass, &chan->object);
|
|
|
|
chan->gr = gr;
|
|
|
|
chan->chid = fifoch->chid;
|
|
|
|
*pobject = &chan->object;
|
2009-12-11 09:24:15 +00:00
|
|
|
|
|
|
|
NV_WRITE_CTX(0x00400e88, 0x08000000);
|
|
|
|
NV_WRITE_CTX(0x00400e9c, 0x4b7fffff);
|
|
|
|
NV_WRITE_CTX(NV03_PGRAPH_XY_LOGIC_MISC0, 0x0001ffff);
|
|
|
|
NV_WRITE_CTX(0x00400e10, 0x00001000);
|
|
|
|
NV_WRITE_CTX(0x00400e14, 0x00001000);
|
|
|
|
NV_WRITE_CTX(0x00400e30, 0x00080008);
|
|
|
|
NV_WRITE_CTX(0x00400e34, 0x00080008);
|
2015-08-20 04:54:19 +00:00
|
|
|
if (device->card_type >= NV_11 && device->chipset >= 0x17) {
|
2009-12-11 09:24:15 +00:00
|
|
|
/* is it really needed ??? */
|
|
|
|
NV17_WRITE_CTX(NV10_PGRAPH_DEBUG_4,
|
2015-08-20 04:54:19 +00:00
|
|
|
nvkm_rd32(device, NV10_PGRAPH_DEBUG_4));
|
2015-08-20 04:54:10 +00:00
|
|
|
NV17_WRITE_CTX(0x004006b0, nvkm_rd32(device, 0x004006b0));
|
2009-12-11 09:24:15 +00:00
|
|
|
NV17_WRITE_CTX(0x00400eac, 0x0fff0000);
|
|
|
|
NV17_WRITE_CTX(0x00400eb0, 0x0fff0000);
|
|
|
|
NV17_WRITE_CTX(0x00400ec0, 0x00000080);
|
|
|
|
NV17_WRITE_CTX(0x00400ed0, 0x00000080);
|
|
|
|
}
|
2012-07-19 22:17:34 +00:00
|
|
|
NV_WRITE_CTX(NV10_PGRAPH_CTX_USER, chan->chid << 24);
|
2009-12-11 09:24:15 +00:00
|
|
|
|
2015-01-14 02:02:28 +00:00
|
|
|
nv10_gr_create_pipe(chan);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
spin_lock_irqsave(&gr->lock, flags);
|
2015-08-20 04:54:19 +00:00
|
|
|
gr->chan[chan->chid] = chan;
|
2015-08-20 04:54:08 +00:00
|
|
|
spin_unlock_irqrestore(&gr->lock, flags);
|
2009-12-11 09:24:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-19 22:17:34 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* PGRAPH engine/subdev functions
|
|
|
|
******************************************************************************/
|
2009-12-14 14:00:30 +00:00
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
void
|
|
|
|
nv10_gr_tile(struct nvkm_gr *base, int i, struct nvkm_fb_tile *tile)
|
2009-12-14 14:00:30 +00:00
|
|
|
{
|
2015-08-20 04:54:22 +00:00
|
|
|
struct nv10_gr *gr = nv10_gr(base);
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
|
|
|
struct nvkm_fifo *fifo = device->fifo;
|
2012-07-19 22:17:34 +00:00
|
|
|
unsigned long flags;
|
2009-12-14 14:00:30 +00:00
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
nvkm_fifo_pause(fifo, &flags);
|
2015-08-20 04:54:19 +00:00
|
|
|
nv04_gr_idle(&gr->base);
|
2009-12-14 14:00:30 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_TLIMIT(i), tile->limit);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_TSIZE(i), tile->pitch);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_TILE(i), tile->addr);
|
2009-12-14 14:00:30 +00:00
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
nvkm_fifo_start(fifo, &flags);
|
2009-12-14 14:00:30 +00:00
|
|
|
}
|
|
|
|
|
2015-01-14 05:29:43 +00:00
|
|
|
const struct nvkm_bitfield nv10_gr_intr_name[] = {
|
2010-11-03 03:16:18 +00:00
|
|
|
{ NV_PGRAPH_INTR_NOTIFY, "NOTIFY" },
|
|
|
|
{ NV_PGRAPH_INTR_ERROR, "ERROR" },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2015-01-14 05:29:43 +00:00
|
|
|
const struct nvkm_bitfield nv10_gr_nstatus[] = {
|
2010-11-03 03:16:18 +00:00
|
|
|
{ NV10_PGRAPH_NSTATUS_STATE_IN_USE, "STATE_IN_USE" },
|
|
|
|
{ NV10_PGRAPH_NSTATUS_INVALID_STATE, "INVALID_STATE" },
|
|
|
|
{ NV10_PGRAPH_NSTATUS_BAD_ARGUMENT, "BAD_ARGUMENT" },
|
|
|
|
{ NV10_PGRAPH_NSTATUS_PROTECTION_FAULT, "PROTECTION_FAULT" },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
void
|
|
|
|
nv10_gr_intr(struct nvkm_gr *base)
|
2010-11-03 03:16:18 +00:00
|
|
|
{
|
2015-08-20 04:54:22 +00:00
|
|
|
struct nv10_gr *gr = nv10_gr(base);
|
|
|
|
struct nvkm_subdev *subdev = &gr->base.engine.subdev;
|
|
|
|
struct nvkm_device *device = subdev->device;
|
2015-08-20 04:54:10 +00:00
|
|
|
u32 stat = nvkm_rd32(device, NV03_PGRAPH_INTR);
|
|
|
|
u32 nsource = nvkm_rd32(device, NV03_PGRAPH_NSOURCE);
|
|
|
|
u32 nstatus = nvkm_rd32(device, NV03_PGRAPH_NSTATUS);
|
|
|
|
u32 addr = nvkm_rd32(device, NV04_PGRAPH_TRAPPED_ADDR);
|
2012-07-19 22:17:34 +00:00
|
|
|
u32 chid = (addr & 0x01f00000) >> 20;
|
|
|
|
u32 subc = (addr & 0x00070000) >> 16;
|
|
|
|
u32 mthd = (addr & 0x00001ffc);
|
2015-08-20 04:54:10 +00:00
|
|
|
u32 data = nvkm_rd32(device, NV04_PGRAPH_TRAPPED_DATA);
|
|
|
|
u32 class = nvkm_rd32(device, 0x400160 + subc * 4) & 0xfff;
|
2012-07-19 22:17:34 +00:00
|
|
|
u32 show = stat;
|
2015-08-20 04:54:13 +00:00
|
|
|
char msg[128], src[128], sta[128];
|
2015-08-20 04:54:22 +00:00
|
|
|
struct nv10_gr_chan *chan;
|
2012-07-19 22:17:34 +00:00
|
|
|
unsigned long flags;
|
2010-11-03 03:16:18 +00:00
|
|
|
|
2015-08-20 04:54:08 +00:00
|
|
|
spin_lock_irqsave(&gr->lock, flags);
|
|
|
|
chan = gr->chan[chid];
|
2012-07-19 22:17:34 +00:00
|
|
|
|
|
|
|
if (stat & NV_PGRAPH_INTR_ERROR) {
|
|
|
|
if (chan && (nsource & NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD)) {
|
2015-08-20 04:54:18 +00:00
|
|
|
if (!nv10_gr_mthd(chan, class, mthd, data))
|
2012-07-19 22:17:34 +00:00
|
|
|
show &= ~NV_PGRAPH_INTR_ERROR;
|
2010-11-03 03:16:18 +00:00
|
|
|
}
|
2012-07-19 22:17:34 +00:00
|
|
|
}
|
2010-11-03 03:16:18 +00:00
|
|
|
|
2012-07-19 22:17:34 +00:00
|
|
|
if (stat & NV_PGRAPH_INTR_CONTEXT_SWITCH) {
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV03_PGRAPH_INTR, NV_PGRAPH_INTR_CONTEXT_SWITCH);
|
2012-07-19 22:17:34 +00:00
|
|
|
stat &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH;
|
|
|
|
show &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH;
|
2015-08-20 04:54:08 +00:00
|
|
|
nv10_gr_context_switch(gr);
|
2012-07-19 22:17:34 +00:00
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV03_PGRAPH_INTR, stat);
|
|
|
|
nvkm_wr32(device, NV04_PGRAPH_FIFO, 0x00000001);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
|
|
|
if (show) {
|
2015-08-20 04:54:13 +00:00
|
|
|
nvkm_snprintbf(msg, sizeof(msg), nv10_gr_intr_name, show);
|
|
|
|
nvkm_snprintbf(src, sizeof(src), nv04_gr_nsource, nsource);
|
|
|
|
nvkm_snprintbf(sta, sizeof(sta), nv10_gr_nstatus, nstatus);
|
|
|
|
nvkm_error(subdev, "intr %08x [%s] nsource %08x [%s] "
|
|
|
|
"nstatus %08x [%s] ch %d [%s] subc %d "
|
|
|
|
"class %04x mthd %04x data %08x\n",
|
|
|
|
show, msg, nsource, src, nstatus, sta, chid,
|
2015-08-20 04:54:19 +00:00
|
|
|
chan ? chan->object.client->name : "unknown",
|
|
|
|
subc, class, mthd, data);
|
2010-11-03 03:16:18 +00:00
|
|
|
}
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:18 +00:00
|
|
|
spin_unlock_irqrestore(&gr->lock, flags);
|
2010-11-03 03:16:18 +00:00
|
|
|
}
|
2011-04-01 02:50:55 +00:00
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
int
|
|
|
|
nv10_gr_init(struct nvkm_gr *base)
|
2011-04-01 02:50:55 +00:00
|
|
|
{
|
2015-08-20 04:54:22 +00:00
|
|
|
struct nv10_gr *gr = nv10_gr(base);
|
2015-08-20 04:54:10 +00:00
|
|
|
struct nvkm_device *device = gr->base.engine.subdev.device;
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV03_PGRAPH_INTR , 0xFFFFFFFF);
|
|
|
|
nvkm_wr32(device, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
|
2015-08-20 04:54:08 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0xFFFFFFFF);
|
|
|
|
nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0x00000000);
|
|
|
|
nvkm_wr32(device, NV04_PGRAPH_DEBUG_1, 0x00118700);
|
|
|
|
/* nvkm_wr32(device, NV04_PGRAPH_DEBUG_2, 0x24E00810); */ /* 0x25f92ad9 */
|
|
|
|
nvkm_wr32(device, NV04_PGRAPH_DEBUG_2, 0x25f92ad9);
|
|
|
|
nvkm_wr32(device, NV04_PGRAPH_DEBUG_3, 0x55DE0830 | (1 << 29) | (1 << 31));
|
2015-08-20 04:54:08 +00:00
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
if (device->card_type >= NV_11 && device->chipset >= 0x17) {
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_DEBUG_4, 0x1f000000);
|
|
|
|
nvkm_wr32(device, 0x400a10, 0x03ff3fb6);
|
|
|
|
nvkm_wr32(device, 0x400838, 0x002f8684);
|
|
|
|
nvkm_wr32(device, 0x40083c, 0x00115f3f);
|
|
|
|
nvkm_wr32(device, 0x4006b0, 0x40000020);
|
2011-04-01 02:50:55 +00:00
|
|
|
} else {
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_DEBUG_4, 0x00000000);
|
2011-04-01 02:50:55 +00:00
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_SWITCH(0), 0x00000000);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_SWITCH(1), 0x00000000);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_SWITCH(2), 0x00000000);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_SWITCH(3), 0x00000000);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_SWITCH(4), 0x00000000);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_STATE, 0xFFFFFFFF);
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:10 +00:00
|
|
|
nvkm_mask(device, NV10_PGRAPH_CTX_USER, 0xff000000, 0x1f000000);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_CTX_CONTROL, 0x10000100);
|
|
|
|
nvkm_wr32(device, NV10_PGRAPH_FFINTFC_ST2, 0x08000000);
|
2011-04-01 02:50:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-07-19 22:17:34 +00:00
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
int
|
|
|
|
nv10_gr_new_(const struct nvkm_gr_func *func, struct nvkm_device *device,
|
|
|
|
int index, struct nvkm_gr **pgr)
|
2012-07-19 22:17:34 +00:00
|
|
|
{
|
2015-08-20 04:54:22 +00:00
|
|
|
struct nv10_gr *gr;
|
|
|
|
|
|
|
|
if (!(gr = kzalloc(sizeof(*gr), GFP_KERNEL)))
|
|
|
|
return -ENOMEM;
|
|
|
|
spin_lock_init(&gr->lock);
|
|
|
|
*pgr = &gr->base;
|
|
|
|
|
2016-04-08 07:24:40 +00:00
|
|
|
return nvkm_gr_ctor(func, device, index, true, &gr->base);
|
2012-07-19 22:17:34 +00:00
|
|
|
}
|
|
|
|
|
2015-08-20 04:54:22 +00:00
|
|
|
static const struct nvkm_gr_func
|
|
|
|
nv10_gr = {
|
|
|
|
.init = nv10_gr_init,
|
|
|
|
.intr = nv10_gr_intr,
|
|
|
|
.tile = nv10_gr_tile,
|
|
|
|
.chan_new = nv10_gr_chan_new,
|
|
|
|
.sclass = {
|
|
|
|
{ -1, -1, 0x0012, &nv04_gr_object }, /* beta1 */
|
|
|
|
{ -1, -1, 0x0019, &nv04_gr_object }, /* clip */
|
|
|
|
{ -1, -1, 0x0030, &nv04_gr_object }, /* null */
|
|
|
|
{ -1, -1, 0x0039, &nv04_gr_object }, /* m2mf */
|
|
|
|
{ -1, -1, 0x0043, &nv04_gr_object }, /* rop */
|
|
|
|
{ -1, -1, 0x0044, &nv04_gr_object }, /* pattern */
|
|
|
|
{ -1, -1, 0x004a, &nv04_gr_object }, /* gdi */
|
|
|
|
{ -1, -1, 0x0052, &nv04_gr_object }, /* swzsurf */
|
|
|
|
{ -1, -1, 0x005f, &nv04_gr_object }, /* blit */
|
|
|
|
{ -1, -1, 0x0062, &nv04_gr_object }, /* surf2d */
|
|
|
|
{ -1, -1, 0x0072, &nv04_gr_object }, /* beta4 */
|
|
|
|
{ -1, -1, 0x0089, &nv04_gr_object }, /* sifm */
|
|
|
|
{ -1, -1, 0x008a, &nv04_gr_object }, /* ifc */
|
|
|
|
{ -1, -1, 0x009f, &nv04_gr_object }, /* blit */
|
|
|
|
{ -1, -1, 0x0093, &nv04_gr_object }, /* surf3d */
|
|
|
|
{ -1, -1, 0x0094, &nv04_gr_object }, /* ttri */
|
|
|
|
{ -1, -1, 0x0095, &nv04_gr_object }, /* mtri */
|
|
|
|
{ -1, -1, 0x0056, &nv04_gr_object }, /* celcius */
|
|
|
|
{}
|
|
|
|
}
|
2012-07-19 22:17:34 +00:00
|
|
|
};
|
2015-08-20 04:54:22 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
nv10_gr_new(struct nvkm_device *device, int index, struct nvkm_gr **pgr)
|
|
|
|
{
|
|
|
|
return nv10_gr_new_(&nv10_gr, device, index, pgr);
|
|
|
|
}
|