Source
x
/*
* 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
*/
int
abi16_chan_nv04(struct nouveau_object *obj)
{
struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
struct nv04_fifo *nv04 = obj->data;
struct drm_nouveau_channel_alloc req = {nv04->vram, nv04->gart};
int ret;
ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
nv04->base.channel = req.channel;
nv04->base.pushbuf = req.pushbuf_domains;
nv04->notify = req.notifier_handle;
nv04->base.object->handle = req.channel;
nv04->base.object->length = sizeof(*nv04);
return 0;
}
int
abi16_chan_nvc0(struct nouveau_object *obj)
{
struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
struct drm_nouveau_channel_alloc req = {};
struct nvc0_fifo *nvc0 = obj->data;
int ret;
ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
nvc0->base.channel = req.channel;
nvc0->base.pushbuf = req.pushbuf_domains;
nvc0->notify = req.notifier_handle;
nvc0->base.object->handle = req.channel;
nvc0->base.object->length = sizeof(*nvc0);
return 0;
}
int
abi16_chan_nve0(struct nouveau_object *obj)
{
struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
struct drm_nouveau_channel_alloc req = {};
struct nve0_fifo *nve0 = obj->data;
int ret;
if (obj->length > offsetof(struct nve0_fifo, engine)) {
req.fb_ctxdma_handle = 0xffffffff;
req.tt_ctxdma_handle = nve0->engine;
}
ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
nve0->base.channel = req.channel;