1 /* 2 * Copyright 2015 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 * Authors: Ben Skeggs <bskeggs@redhat.com> 23 */ 24 #include "chan.h" 25 26 #include <core/notify.h> 27 28 #include <nvif/event.h> 29 #include <nvif/unpack.h> 30 31 static int 32 nvkm_sw_chan_event_ctor(struct nvkm_object *object, void *data, u32 size, 33 struct nvkm_notify *notify) 34 { 35 union { 36 struct nvif_notify_uevent_req none; 37 } *req = data; 38 int ret; 39 40 if (nvif_unvers(req->none)) { 41 notify->size = sizeof(struct nvif_notify_uevent_rep); 42 notify->types = 1; 43 notify->index = 0; 44 } 45 46 return ret; 47 } 48 49 static const struct nvkm_event_func 50 nvkm_sw_chan_event = { 51 .ctor = nvkm_sw_chan_event_ctor, 52 }; 53 54 void 55 nvkm_sw_chan_dtor(struct nvkm_object *base) 56 { 57 struct nvkm_sw_chan *chan = (void *)base; 58 nvkm_event_fini(&chan->event); 59 nvkm_engctx_destroy(&chan->base); 60 } 61 62 int 63 nvkm_sw_chan_ctor(struct nvkm_object *parent, struct nvkm_object *engine, 64 struct nvkm_oclass *oclass, int length, void **pobject) 65 { 66 struct nvkm_sw_chan *chan; 67 int ret; 68 69 ret = nvkm_engctx_create_(parent, engine, oclass, parent, 70 0, 0, 0, length, pobject); 71 chan = *pobject; 72 if (ret) 73 return ret; 74 75 return nvkm_event_init(&nvkm_sw_chan_event, 1, 1, &chan->event); 76 } 77