1861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs/* 2861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * Copyright (C) 2010 Francisco Jerez. 3861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * All Rights Reserved. 4861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * 5861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * Permission is hereby granted, free of charge, to any person obtaining 6861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * a copy of this software and associated documentation files (the 7861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * "Software"), to deal in the Software without restriction, including 8861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * without limitation the rights to use, copy, modify, merge, publish, 9861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * distribute, sublicense, and/or sell copies of the Software, and to 10861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * permit persons to whom the Software is furnished to do so, subject to 11861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * the following conditions: 12861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * 13861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * The above copyright notice and this permission notice (including the 14861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * next paragraph) shall be included in all copies or substantial 15861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * portions of the Software. 16861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * 17861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 21861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs * 25861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs */ 26861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs 2720cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs#include "nv04.h" 28861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs 29dac1558d49d0a9f932babd66144459ef3dd5dfa9Ben Skeggsvoid 30861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggsnv10_fb_tile_init(struct nouveau_fb *pfb, int i, u32 addr, u32 size, u32 pitch, 31861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs u32 flags, struct nouveau_fb_tile *tile) 32d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs{ 33d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs tile->addr = 0x80000000 | addr; 34d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs tile->limit = max(1u, addr + size) - 1; 35d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs tile->pitch = pitch; 36d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs} 37d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs 38dac1558d49d0a9f932babd66144459ef3dd5dfa9Ben Skeggsvoid 39861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggsnv10_fb_tile_fini(struct nouveau_fb *pfb, int i, struct nouveau_fb_tile *tile) 40d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs{ 41861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs tile->addr = 0; 42861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs tile->limit = 0; 43861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs tile->pitch = 0; 44861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs tile->zcomp = 0; 45d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs} 46d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs 47dac1558d49d0a9f932babd66144459ef3dd5dfa9Ben Skeggsvoid 48861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggsnv10_fb_tile_prog(struct nouveau_fb *pfb, int i, struct nouveau_fb_tile *tile) 49d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs{ 50861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs nv_wr32(pfb, 0x100244 + (i * 0x10), tile->limit); 51861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs nv_wr32(pfb, 0x100248 + (i * 0x10), tile->pitch); 52861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs nv_wr32(pfb, 0x100240 + (i * 0x10), tile->addr); 536d338081a6008b3638ca45e0020c5a0cebe362fdBen Skeggs nv_rd32(pfb, 0x100240 + (i * 0x10)); 54d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs} 55d81c19e312a22bdcebef1370f3af30a146670787Ben Skeggs 561e9fc30e38bbedf5cbba9238393084c35e1df551Ben Skeggsstruct nouveau_oclass * 5720cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggsnv10_fb_oclass = &(struct nv04_fb_impl) { 5820cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs .base.base.handle = NV_SUBDEV(FB, 0x10), 5920cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs .base.base.ofuncs = &(struct nouveau_ofuncs) { 6020cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs .ctor = nv04_fb_ctor, 61861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs .dtor = _nouveau_fb_dtor, 62861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs .init = _nouveau_fb_init, 63861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs .fini = _nouveau_fb_fini, 64861d21074bbb141b0cc165a61c11f571571cda12Ben Skeggs }, 6520cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs .base.memtype = nv04_fb_memtype_valid, 6620cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs .base.ram = &nv10_ram_oclass, 6720cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs .tile.regions = 8, 6820cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs .tile.init = nv10_fb_tile_init, 6920cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs .tile.fini = nv10_fb_tile_fini, 7020cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs .tile.prog = nv10_fb_tile_prog, 7120cdeaf938705b79e0fc7aef2f0e05d1eda15e5dBen Skeggs}.base.base; 72