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

drm/vram-helpers: Merge code into a single file

Most of the documentation was in an otherwise empty file, which was
probably just left from a previous clean-up effort. So move code and
documentation into a single file.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200331081238.24749-1-tzimmermann@suse.de

+91 -110
-9
Documentation/gpu/drm-mm.rst
··· 373 373 .. kernel-doc:: drivers/gpu/drm/drm_gem_cma_helper.c 374 374 :export: 375 375 376 - VRAM Helper Function Reference 377 - ============================== 378 - 379 - .. kernel-doc:: drivers/gpu/drm/drm_vram_helper_common.c 380 - :doc: overview 381 - 382 - .. kernel-doc:: include/drm/drm_gem_vram_helper.h 383 - :internal: 384 - 385 376 GEM VRAM Helper Functions Reference 386 377 ----------------------------------- 387 378
+1 -2
drivers/gpu/drm/Makefile
··· 33 33 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o 34 34 drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o 35 35 36 - drm_vram_helper-y := drm_gem_vram_helper.o \ 37 - drm_vram_helper_common.o 36 + drm_vram_helper-y := drm_gem_vram_helper.o 38 37 obj-$(CONFIG_DRM_VRAM_HELPER) += drm_vram_helper.o 39 38 40 39 drm_ttm_helper-y := drm_gem_ttm_helper.o
+90 -5
drivers/gpu/drm/drm_gem_vram_helper.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 2 3 + #include <linux/module.h> 4 + 3 5 #include <drm/drm_debugfs.h> 4 6 #include <drm/drm_device.h> 5 7 #include <drm/drm_drv.h> ··· 21 19 /** 22 20 * DOC: overview 23 21 * 24 - * This library provides a GEM buffer object that is backed by video RAM 25 - * (VRAM). It can be used for framebuffer devices with dedicated memory. 22 + * This library provides &struct drm_gem_vram_object (GEM VRAM), a GEM 23 + * buffer object that is backed by video RAM (VRAM). It can be used for 24 + * framebuffer devices with dedicated memory. 26 25 * 27 26 * The data structure &struct drm_vram_mm and its helpers implement a memory 28 - * manager for simple framebuffer devices with dedicated video memory. Buffer 29 - * objects are either placed in video RAM or evicted to system memory. The rsp. 30 - * buffer object is provided by &struct drm_gem_vram_object. 27 + * manager for simple framebuffer devices with dedicated video memory. GEM 28 + * VRAM buffer objects are either placed in the video memory or remain evicted 29 + * to system memory. 30 + * 31 + * With the GEM interface userspace applications create, manage and destroy 32 + * graphics buffers, such as an on-screen framebuffer. GEM does not provide 33 + * an implementation of these interfaces. It's up to the DRM driver to 34 + * provide an implementation that suits the hardware. If the hardware device 35 + * contains dedicated video memory, the DRM driver can use the VRAM helper 36 + * library. Each active buffer object is stored in video RAM. Active 37 + * buffer are used for drawing the current frame, typically something like 38 + * the frame's scanout buffer or the cursor image. If there's no more space 39 + * left in VRAM, inactive GEM objects can be moved to system memory. 40 + * 41 + * The easiest way to use the VRAM helper library is to call 42 + * drm_vram_helper_alloc_mm(). The function allocates and initializes an 43 + * instance of &struct drm_vram_mm in &struct drm_device.vram_mm . Use 44 + * &DRM_GEM_VRAM_DRIVER to initialize &struct drm_driver and 45 + * &DRM_VRAM_MM_FILE_OPERATIONS to initialize &struct file_operations; 46 + * as illustrated below. 47 + * 48 + * .. code-block:: c 49 + * 50 + * struct file_operations fops ={ 51 + * .owner = THIS_MODULE, 52 + * DRM_VRAM_MM_FILE_OPERATION 53 + * }; 54 + * struct drm_driver drv = { 55 + * .driver_feature = DRM_ ... , 56 + * .fops = &fops, 57 + * DRM_GEM_VRAM_DRIVER 58 + * }; 59 + * 60 + * int init_drm_driver() 61 + * { 62 + * struct drm_device *dev; 63 + * uint64_t vram_base; 64 + * unsigned long vram_size; 65 + * int ret; 66 + * 67 + * // setup device, vram base and size 68 + * // ... 69 + * 70 + * ret = drm_vram_helper_alloc_mm(dev, vram_base, vram_size); 71 + * if (ret) 72 + * return ret; 73 + * return 0; 74 + * } 75 + * 76 + * This creates an instance of &struct drm_vram_mm, exports DRM userspace 77 + * interfaces for GEM buffer management and initializes file operations to 78 + * allow for accessing created GEM buffers. With this setup, the DRM driver 79 + * manages an area of video RAM with VRAM MM and provides GEM VRAM objects 80 + * to userspace. 81 + * 82 + * To clean up the VRAM memory management, call drm_vram_helper_release_mm() 83 + * in the driver's clean-up code. 84 + * 85 + * .. code-block:: c 86 + * 87 + * void fini_drm_driver() 88 + * { 89 + * struct drm_device *dev = ...; 90 + * 91 + * drm_vram_helper_release_mm(dev); 92 + * } 93 + * 94 + * For drawing or scanout operations, buffer object have to be pinned in video 95 + * RAM. Call drm_gem_vram_pin() with &DRM_GEM_VRAM_PL_FLAG_VRAM or 96 + * &DRM_GEM_VRAM_PL_FLAG_SYSTEM to pin a buffer object in video RAM or system 97 + * memory. Call drm_gem_vram_unpin() to release the pinned object afterwards. 98 + * 99 + * A buffer object that is pinned in video RAM has a fixed address within that 100 + * memory region. Call drm_gem_vram_offset() to retrieve this value. Typically 101 + * it's used to program the hardware's scanout engine for framebuffers, set 102 + * the cursor overlay's image for a mouse cursor, or use it as input to the 103 + * hardware's draing engine. 104 + * 105 + * To access a buffer object's memory from the DRM driver, call 106 + * drm_gem_vram_kmap(). It (optionally) maps the buffer into kernel address 107 + * space and returns the memory address. Use drm_gem_vram_kunmap() to 108 + * release the mapping. 31 109 */ 32 110 33 111 /* ··· 1279 1197 return drm_vram_helper_mode_valid_internal(dev, mode, max_bpp); 1280 1198 } 1281 1199 EXPORT_SYMBOL(drm_vram_helper_mode_valid); 1200 + 1201 + MODULE_DESCRIPTION("DRM VRAM memory-management helpers"); 1202 + MODULE_LICENSE("GPL");
-94
drivers/gpu/drm/drm_vram_helper_common.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - 3 - #include <linux/module.h> 4 - 5 - /** 6 - * DOC: overview 7 - * 8 - * This library provides &struct drm_gem_vram_object (GEM VRAM), a GEM 9 - * buffer object that is backed by video RAM. It can be used for 10 - * framebuffer devices with dedicated memory. The video RAM is managed 11 - * by &struct drm_vram_mm (VRAM MM). 12 - * 13 - * With the GEM interface userspace applications create, manage and destroy 14 - * graphics buffers, such as an on-screen framebuffer. GEM does not provide 15 - * an implementation of these interfaces. It's up to the DRM driver to 16 - * provide an implementation that suits the hardware. If the hardware device 17 - * contains dedicated video memory, the DRM driver can use the VRAM helper 18 - * library. Each active buffer object is stored in video RAM. Active 19 - * buffer are used for drawing the current frame, typically something like 20 - * the frame's scanout buffer or the cursor image. If there's no more space 21 - * left in VRAM, inactive GEM objects can be moved to system memory. 22 - * 23 - * The easiest way to use the VRAM helper library is to call 24 - * drm_vram_helper_alloc_mm(). The function allocates and initializes an 25 - * instance of &struct drm_vram_mm in &struct drm_device.vram_mm . Use 26 - * &DRM_GEM_VRAM_DRIVER to initialize &struct drm_driver and 27 - * &DRM_VRAM_MM_FILE_OPERATIONS to initialize &struct file_operations; 28 - * as illustrated below. 29 - * 30 - * .. code-block:: c 31 - * 32 - * struct file_operations fops ={ 33 - * .owner = THIS_MODULE, 34 - * DRM_VRAM_MM_FILE_OPERATION 35 - * }; 36 - * struct drm_driver drv = { 37 - * .driver_feature = DRM_ ... , 38 - * .fops = &fops, 39 - * DRM_GEM_VRAM_DRIVER 40 - * }; 41 - * 42 - * int init_drm_driver() 43 - * { 44 - * struct drm_device *dev; 45 - * uint64_t vram_base; 46 - * unsigned long vram_size; 47 - * int ret; 48 - * 49 - * // setup device, vram base and size 50 - * // ... 51 - * 52 - * ret = drm_vram_helper_alloc_mm(dev, vram_base, vram_size); 53 - * if (ret) 54 - * return ret; 55 - * return 0; 56 - * } 57 - * 58 - * This creates an instance of &struct drm_vram_mm, exports DRM userspace 59 - * interfaces for GEM buffer management and initializes file operations to 60 - * allow for accessing created GEM buffers. With this setup, the DRM driver 61 - * manages an area of video RAM with VRAM MM and provides GEM VRAM objects 62 - * to userspace. 63 - * 64 - * To clean up the VRAM memory management, call drm_vram_helper_release_mm() 65 - * in the driver's clean-up code. 66 - * 67 - * .. code-block:: c 68 - * 69 - * void fini_drm_driver() 70 - * { 71 - * struct drm_device *dev = ...; 72 - * 73 - * drm_vram_helper_release_mm(dev); 74 - * } 75 - * 76 - * For drawing or scanout operations, buffer object have to be pinned in video 77 - * RAM. Call drm_gem_vram_pin() with &DRM_GEM_VRAM_PL_FLAG_VRAM or 78 - * &DRM_GEM_VRAM_PL_FLAG_SYSTEM to pin a buffer object in video RAM or system 79 - * memory. Call drm_gem_vram_unpin() to release the pinned object afterwards. 80 - * 81 - * A buffer object that is pinned in video RAM has a fixed address within that 82 - * memory region. Call drm_gem_vram_offset() to retrieve this value. Typically 83 - * it's used to program the hardware's scanout engine for framebuffers, set 84 - * the cursor overlay's image for a mouse cursor, or use it as input to the 85 - * hardware's draing engine. 86 - * 87 - * To access a buffer object's memory from the DRM driver, call 88 - * drm_gem_vram_kmap(). It (optionally) maps the buffer into kernel address 89 - * space and returns the memory address. Use drm_gem_vram_kunmap() to 90 - * release the mapping. 91 - */ 92 - 93 - MODULE_DESCRIPTION("DRM VRAM memory-management helpers"); 94 - MODULE_LICENSE("GPL");