Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Extract drm_prime.h

Plus a little bit more documentation.

v2: Untangle the missing forward decls to make drm_prime|gem.h
free-standing.

Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170308141257.12119-3-daniel.vetter@ffwll.ch

+91 -31
+3
Documentation/gpu/drm-mm.rst
··· 449 449 PRIME Function References 450 450 ------------------------- 451 451 452 + .. kernel-doc:: include/drm/drm_prime.h 453 + :internal: 454 + 452 455 .. kernel-doc:: drivers/gpu/drm/drm_prime.c 453 456 :export: 454 457
+2 -1
drivers/gpu/drm/drm_prime.c
··· 29 29 #include <linux/export.h> 30 30 #include <linux/dma-buf.h> 31 31 #include <linux/rbtree.h> 32 - #include <drm/drmP.h> 32 + #include <drm/drm_prime.h> 33 33 #include <drm/drm_gem.h> 34 + #include <drm/drmP.h> 34 35 35 36 #include "drm_internal.h" 36 37
+3 -29
include/drm/drmP.h
··· 51 51 #include <linux/platform_device.h> 52 52 #include <linux/poll.h> 53 53 #include <linux/ratelimit.h> 54 - #include <linux/rbtree.h> 55 54 #include <linux/sched.h> 56 55 #include <linux/slab.h> 57 56 #include <linux/types.h> 58 57 #include <linux/vmalloc.h> 59 58 #include <linux/workqueue.h> 60 59 #include <linux/dma-fence.h> 60 + #include <linux/module.h> 61 61 62 62 #include <asm/mman.h> 63 63 #include <asm/pgalloc.h> ··· 75 75 #include <drm/drm_mm.h> 76 76 #include <drm/drm_os_linux.h> 77 77 #include <drm/drm_sarea.h> 78 - #include <drm/drm_vma_manager.h> 79 78 #include <drm/drm_drv.h> 79 + #include <drm/drm_prime.h> 80 80 81 81 struct module; 82 82 ··· 89 89 struct drm_gem_object; 90 90 struct drm_master; 91 91 struct drm_vblank_crtc; 92 + struct drm_vma_offset_manager; 92 93 93 94 struct device_node; 94 95 struct videomode; ··· 369 368 struct drm_file *file_priv; 370 369 pid_t pid; /* pid of requester, no guarantee it's valid by the time 371 370 we deliver the event, for tracing only */ 372 - }; 373 - 374 - struct drm_prime_file_private { 375 - struct mutex lock; 376 - struct rb_root dmabufs; 377 - struct rb_root handles; 378 371 }; 379 372 380 373 /** File private data */ ··· 753 758 return 0; 754 759 } 755 760 #endif 756 - 757 - struct dma_buf_export_info; 758 - 759 - extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, 760 - struct drm_gem_object *obj, 761 - int flags); 762 - extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, 763 - struct drm_file *file_priv, uint32_t handle, uint32_t flags, 764 - int *prime_fd); 765 - extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, 766 - struct dma_buf *dma_buf); 767 - extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, 768 - struct drm_file *file_priv, int prime_fd, uint32_t *handle); 769 - struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev, 770 - struct dma_buf_export_info *exp_info); 771 - extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf); 772 - 773 - extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, 774 - dma_addr_t *addrs, int max_pages); 775 - extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages); 776 - extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); 777 761 778 762 779 763 extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
+4
include/drm/drm_gem.h
··· 34 34 * OTHER DEALINGS IN THE SOFTWARE. 35 35 */ 36 36 37 + #include <linux/kref.h> 38 + 39 + #include <drm/drm_vma_manager.h> 40 + 37 41 /** 38 42 * struct drm_gem_object - GEM buffer object 39 43 *
+79
include/drm/drm_prime.h
··· 1 + /* 2 + * Copyright © 2012 Red Hat 3 + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 4 + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 5 + * Copyright (c) 2009-2010, Code Aurora Forum. 6 + * 7 + * Permission is hereby granted, free of charge, to any person obtaining a 8 + * copy of this software and associated documentation files (the "Software"), 9 + * to deal in the Software without restriction, including without limitation 10 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 + * and/or sell copies of the Software, and to permit persons to whom the 12 + * Software is furnished to do so, subject to the following conditions: 13 + * 14 + * The above copyright notice and this permission notice (including the next 15 + * paragraph) shall be included in all copies or substantial portions of the 16 + * Software. 17 + * 18 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 24 + * IN THE SOFTWARE. 25 + * 26 + * Authors: 27 + * Dave Airlie <airlied@redhat.com> 28 + * Rob Clark <rob.clark@linaro.org> 29 + * 30 + */ 31 + 32 + #ifndef __DRM_PRIME_H__ 33 + #define __DRM_PRIME_H__ 34 + 35 + #include <linux/mutex.h> 36 + #include <linux/rbtree.h> 37 + 38 + /** 39 + * struct drm_prime_file_private - per-file tracking for PRIME 40 + * 41 + * This just contains the internal &struct dma_buf and handle caches for each 42 + * &struct drm_file used by the PRIME core code. 43 + */ 44 + 45 + struct drm_prime_file_private { 46 + /* private: */ 47 + struct mutex lock; 48 + struct rb_root dmabufs; 49 + struct rb_root handles; 50 + }; 51 + 52 + struct dma_buf_export_info; 53 + struct dma_buf; 54 + 55 + struct drm_device; 56 + struct drm_gem_object; 57 + struct drm_file; 58 + 59 + extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, 60 + struct drm_gem_object *obj, 61 + int flags); 62 + extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, 63 + struct drm_file *file_priv, uint32_t handle, uint32_t flags, 64 + int *prime_fd); 65 + extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, 66 + struct dma_buf *dma_buf); 67 + extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, 68 + struct drm_file *file_priv, int prime_fd, uint32_t *handle); 69 + struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev, 70 + struct dma_buf_export_info *exp_info); 71 + extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf); 72 + 73 + extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, 74 + dma_addr_t *addrs, int max_pages); 75 + extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages); 76 + extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); 77 + 78 + 79 + #endif /* __DRM_PRIME_H__ */
-1
include/drm/drm_vma_manager.h
··· 25 25 26 26 #include <drm/drm_mm.h> 27 27 #include <linux/mm.h> 28 - #include <linux/module.h> 29 28 #include <linux/rbtree.h> 30 29 #include <linux/spinlock.h> 31 30 #include <linux/types.h>