0254438ad1a6512182926860204cd3aa7cec278a
2 * Copyright © 2012 Intel Corporation
3 * Copyright © 2014 The Chromium OS Authors
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * Ben Widawsky <ben@bwidawsk.net>
29 #include <linux/dma-buf.h>
32 struct sg_table
*vgem_gem_prime_get_sg_table(struct drm_gem_object
*gobj
)
34 struct drm_vgem_gem_object
*obj
= to_vgem_bo(gobj
);
35 BUG_ON(obj
->pages
== NULL
);
37 return drm_prime_pages_to_sg(obj
->pages
, obj
->base
.size
/ PAGE_SIZE
);
40 int vgem_gem_prime_pin(struct drm_gem_object
*gobj
)
42 struct drm_vgem_gem_object
*obj
= to_vgem_bo(gobj
);
43 return vgem_gem_get_pages(obj
);
46 void vgem_gem_prime_unpin(struct drm_gem_object
*gobj
)
48 struct drm_vgem_gem_object
*obj
= to_vgem_bo(gobj
);
49 vgem_gem_put_pages(obj
);
52 void *vgem_gem_prime_vmap(struct drm_gem_object
*gobj
)
54 struct drm_vgem_gem_object
*obj
= to_vgem_bo(gobj
);
55 BUG_ON(obj
->pages
== NULL
);
57 return vmap(obj
->pages
, obj
->base
.size
/ PAGE_SIZE
, 0, PAGE_KERNEL
);
60 void vgem_gem_prime_vunmap(struct drm_gem_object
*obj
, void *vaddr
)
65 struct drm_gem_object
*vgem_gem_prime_import(struct drm_device
*dev
,
66 struct dma_buf
*dma_buf
)
68 struct drm_vgem_gem_object
*obj
= NULL
;
71 obj
= kzalloc(sizeof(*obj
), GFP_KERNEL
);
77 ret
= drm_gem_object_init(dev
, &obj
->base
, dma_buf
->size
);
85 obj
->base
.dma_buf
= dma_buf
;
86 obj
->use_dma_buf
= true;
This page took 0.034331 seconds and 4 git commands to generate.