|
36 | 36 | * and registers the DRM device using devm_tinydrm_register(). |
37 | 37 | */ |
38 | 38 |
|
39 | | -/** |
40 | | - * tinydrm_gem_cma_prime_import_sg_table - Produce a CMA GEM object from |
41 | | - * another driver's scatter/gather table of pinned pages |
42 | | - * @drm: DRM device to import into |
43 | | - * @attach: DMA-BUF attachment |
44 | | - * @sgt: Scatter/gather table of pinned pages |
45 | | - * |
46 | | - * This function imports a scatter/gather table exported via DMA-BUF by |
47 | | - * another driver using drm_gem_cma_prime_import_sg_table(). It sets the |
48 | | - * kernel virtual address on the CMA object. Drivers should use this as their |
49 | | - * &drm_driver->gem_prime_import_sg_table callback if they need the virtual |
50 | | - * address. tinydrm_gem_cma_free_object() should be used in combination with |
51 | | - * this function. |
52 | | - * |
53 | | - * Returns: |
54 | | - * A pointer to a newly created GEM object or an ERR_PTR-encoded negative |
55 | | - * error code on failure. |
56 | | - */ |
57 | | -struct drm_gem_object * |
58 | | -tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm, |
59 | | - struct dma_buf_attachment *attach, |
60 | | - struct sg_table *sgt) |
61 | | -{ |
62 | | - struct drm_gem_cma_object *cma_obj; |
63 | | - struct drm_gem_object *obj; |
64 | | - void *vaddr; |
65 | | - |
66 | | - vaddr = dma_buf_vmap(attach->dmabuf); |
67 | | - if (!vaddr) { |
68 | | - DRM_ERROR("Failed to vmap PRIME buffer\n"); |
69 | | - return ERR_PTR(-ENOMEM); |
70 | | - } |
71 | | - |
72 | | - obj = drm_gem_cma_prime_import_sg_table(drm, attach, sgt); |
73 | | - if (IS_ERR(obj)) { |
74 | | - dma_buf_vunmap(attach->dmabuf, vaddr); |
75 | | - return obj; |
76 | | - } |
77 | | - |
78 | | - cma_obj = to_drm_gem_cma_obj(obj); |
79 | | - cma_obj->vaddr = vaddr; |
80 | | - |
81 | | - return obj; |
82 | | -} |
83 | | -EXPORT_SYMBOL(tinydrm_gem_cma_prime_import_sg_table); |
84 | | - |
85 | | -/** |
86 | | - * tinydrm_gem_cma_free_object - Free resources associated with a CMA GEM |
87 | | - * object |
88 | | - * @gem_obj: GEM object to free |
89 | | - * |
90 | | - * This function frees the backing memory of the CMA GEM object, cleans up the |
91 | | - * GEM object state and frees the memory used to store the object itself using |
92 | | - * drm_gem_cma_free_object(). It also handles PRIME buffers which has the kernel |
93 | | - * virtual address set by tinydrm_gem_cma_prime_import_sg_table(). Drivers |
94 | | - * can use this as their &drm_driver->gem_free_object_unlocked callback. |
95 | | - */ |
96 | | -void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj) |
97 | | -{ |
98 | | - if (gem_obj->import_attach) { |
99 | | - struct drm_gem_cma_object *cma_obj; |
100 | | - |
101 | | - cma_obj = to_drm_gem_cma_obj(gem_obj); |
102 | | - dma_buf_vunmap(gem_obj->import_attach->dmabuf, cma_obj->vaddr); |
103 | | - cma_obj->vaddr = NULL; |
104 | | - } |
105 | | - |
106 | | - drm_gem_cma_free_object(gem_obj); |
107 | | -} |
108 | | -EXPORT_SYMBOL_GPL(tinydrm_gem_cma_free_object); |
109 | | - |
110 | 39 | static struct drm_framebuffer * |
111 | 40 | tinydrm_fb_create(struct drm_device *drm, struct drm_file *file_priv, |
112 | 41 | const struct drm_mode_fb_cmd2 *mode_cmd) |
|
0 commit comments