capsgv100.c (2139B)
1/* 2 * Copyright 2020 Red Hat Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22#define gv100_disp_caps(p) container_of((p), struct gv100_disp_caps, object) 23#include "rootnv50.h" 24 25struct gv100_disp_caps { 26 struct nvkm_object object; 27 struct nv50_disp *disp; 28}; 29 30static int 31gv100_disp_caps_map(struct nvkm_object *object, void *argv, u32 argc, 32 enum nvkm_object_map *type, u64 *addr, u64 *size) 33{ 34 struct gv100_disp_caps *caps = gv100_disp_caps(object); 35 struct nvkm_device *device = caps->disp->base.engine.subdev.device; 36 *type = NVKM_OBJECT_MAP_IO; 37 *addr = 0x640000 + device->func->resource_addr(device, 0); 38 *size = 0x1000; 39 return 0; 40} 41 42static const struct nvkm_object_func 43gv100_disp_caps = { 44 .map = gv100_disp_caps_map, 45}; 46 47int 48gv100_disp_caps_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, 49 struct nv50_disp *disp, struct nvkm_object **pobject) 50{ 51 struct gv100_disp_caps *caps; 52 53 if (!(caps = kzalloc(sizeof(*caps), GFP_KERNEL))) 54 return -ENOMEM; 55 *pobject = &caps->object; 56 57 nvkm_object_ctor(&gv100_disp_caps, oclass, &caps->object); 58 caps->disp = disp; 59 return 0; 60}