summaryrefslogtreecommitdiff
path: root/omap/omap_drmif.h
blob: e62d127820de5a83e8382e9972e58e67da49eb92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Copyright (C) 2011 Texas Instruments, 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 (including the next
 * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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:
 *    Rob Clark <rob@ti.com>
 */

#ifndef OMAP_DRMIF_H_
#define OMAP_DRMIF_H_

#include <xf86drm.h>
#include <stdint.h>
#include <omap_drm.h>

struct omap_bo;
struct omap_device;

/* device related functions:
 */

struct omap_device * omap_device_new(int fd);
struct omap_device * omap_device_ref(struct omap_device *dev);
void omap_device_del(struct omap_device *dev);
int omap_get_param(struct omap_device *dev, uint64_t param, uint64_t *value);
int omap_set_param(struct omap_device *dev, uint64_t param, uint64_t value);

/* buffer-object related functions:
 */

struct omap_bo * omap_bo_new(struct omap_device *dev,
		uint32_t size, uint32_t flags);
struct omap_bo * omap_bo_new_tiled(struct omap_device *dev,
		uint32_t width, uint32_t height, uint32_t flags);
struct omap_bo * omap_bo_ref(struct omap_bo *bo);
struct omap_bo * omap_bo_from_name(struct omap_device *dev, uint32_t name);
struct omap_bo * omap_bo_from_dmabuf(struct omap_device *dev, int fd);
void omap_bo_del(struct omap_bo *bo);
int omap_bo_get_name(struct omap_bo *bo, uint32_t *name);
uint32_t omap_bo_handle(struct omap_bo *bo);
int omap_bo_dmabuf(struct omap_bo *bo);
uint32_t omap_bo_size(struct omap_bo *bo);
void * omap_bo_map(struct omap_bo *bo);
int omap_bo_cpu_prep(struct omap_bo *bo, enum omap_gem_op op);
int omap_bo_cpu_fini(struct omap_bo *bo, enum omap_gem_op op);

#endif /* OMAP_DRMIF_H_ */
pt">, sizeof(g)); if (ret) { nouveau_grobj_free((void *)&nvgrobj); return ret; } *grobj = &nvgrobj->base; return 0; } int nouveau_grobj_ref(struct nouveau_channel *chan, uint32_t handle, struct nouveau_grobj **grobj) { struct nouveau_grobj_priv *nvgrobj; if (!chan || !grobj || *grobj) return -EINVAL; nvgrobj = calloc(1, sizeof(struct nouveau_grobj_priv)); if (!nvgrobj) return -ENOMEM; nvgrobj->base.channel = chan; nvgrobj->base.handle = handle; nvgrobj->base.grclass = 0; *grobj = &nvgrobj->base; return 0; } void nouveau_grobj_free(struct nouveau_grobj **grobj) { struct nouveau_device_priv *nvdev; struct nouveau_channel_priv *chan; struct nouveau_grobj_priv *nvgrobj; if (!grobj || !*grobj) return; nvgrobj = nouveau_grobj(*grobj); *grobj = NULL; chan = nouveau_channel(nvgrobj->base.channel); nvdev = nouveau_device(chan->base.device); if (nvgrobj->base.grclass) { struct drm_nouveau_gpuobj_free f; FIRE_RING(&chan->base); f.channel = chan->drm.channel; f.handle = nvgrobj->base.handle; drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GPUOBJ_FREE, &f, sizeof(f)); } if (nvgrobj->base.bound != NOUVEAU_GROBJ_UNBOUND) chan->base.subc[nvgrobj->base.subc].gr = NULL; free(nvgrobj); } void nouveau_grobj_autobind(struct nouveau_grobj *grobj) { struct nouveau_channel *chan = grobj->channel; struct nouveau_subchannel *subc = NULL; int i; for (i = 0; i < 8; i++) { struct nouveau_subchannel *scc = &grobj->channel->subc[i]; if (scc->gr && scc->gr->bound == NOUVEAU_GROBJ_BOUND_EXPLICIT) continue; if (!subc || scc->sequence < subc->sequence) subc = scc; } if (subc->gr) { subc->gr->bound = NOUVEAU_GROBJ_UNBOUND; subc->gr->subc = -1; } subc->gr = grobj; subc->gr->bound = NOUVEAU_GROBJ_BOUND; subc->gr->subc = subc - &grobj->channel->subc[0]; WAIT_RING(chan, 2); if (chan->device->chipset < 0xc0) { OUT_RING (chan, (1 << 18) | (grobj->subc << 13)); OUT_RING (chan, grobj->handle); } else { OUT_RING (chan, (2 << 28) | (1 << 16) | (grobj->subc << 13)); OUT_RING (chan, grobj->grclass); } }