4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 PathScale Inc. All rights reserved.
24 * Use is subject to license terms.
28 #include "nouveau_drv.h"
29 #include "pscnv_gem.h"
30 #include "pscnv_mem.h"
31 #include "pscnv_drm.h"
33 void pscnv_gem_free_object (struct drm_gem_object
*obj
) {
34 struct pscnv_bo
*vo
= obj
->driver_private
;
35 #ifndef PSCNV_KAPI_DRM_GEM_OBJECT_HANDLE_COUNT
36 atomic_dec(&obj
->handle_count
);
43 drm_gem_free_mmap_offset(obj
);
45 drm_gem_object_release(obj
);
49 struct drm_gem_object
*pscnv_gem_wrap(struct drm_device
*dev
, struct pscnv_bo
*vo
)
51 struct drm_gem_object
*obj
;
53 obj
= drm_gem_object_alloc(dev
, vo
->size
);
57 if (drm_gem_create_mmap_offset(obj
) != 0) {
58 drm_gem_object_handle_unreference_unlocked(obj
);
63 #ifndef PSCNV_KAPI_DRM_GEM_OBJECT_HANDLE_COUNT
64 atomic_inc(&obj
->handle_count
);
66 obj
->driver_private
= vo
;
71 struct drm_gem_object
*pscnv_gem_new(struct drm_device
*dev
, uint64_t size
, uint32_t flags
,
72 uint32_t tile_flags
, uint32_t cookie
, uint32_t *user
)
75 struct pscnv_bo
*vo
= pscnv_mem_alloc(dev
, size
, flags
, tile_flags
, cookie
);
76 struct drm_gem_object
*obj
;
80 if (!(obj
= pscnv_gem_wrap(dev
, vo
)))
83 for (i
= 0; i
< DRM_ARRAY_SIZE(vo
->user
); i
++)
84 vo
->user
[i
] = user
[i
];
86 for (i
= 0; i
< DRM_ARRAY_SIZE(vo
->user
); i
++)