1 1.2 riastrad /* $NetBSD: vmwgfx_prime.c,v 1.3 2021/12/18 23:45:45 riastradh Exp $ */ 2 1.2 riastrad 3 1.3 riastrad // SPDX-License-Identifier: GPL-2.0 OR MIT 4 1.1 riastrad /************************************************************************** 5 1.1 riastrad * 6 1.3 riastrad * Copyright 2013 VMware, Inc., Palo Alto, CA., USA 7 1.1 riastrad * 8 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 9 1.1 riastrad * copy of this software and associated documentation files (the 10 1.1 riastrad * "Software"), to deal in the Software without restriction, including 11 1.1 riastrad * without limitation the rights to use, copy, modify, merge, publish, 12 1.1 riastrad * distribute, sub license, and/or sell copies of the Software, and to 13 1.1 riastrad * permit persons to whom the Software is furnished to do so, subject to 14 1.1 riastrad * the following conditions: 15 1.1 riastrad * 16 1.1 riastrad * The above copyright notice and this permission notice (including the 17 1.1 riastrad * next paragraph) shall be included in all copies or substantial portions 18 1.1 riastrad * of the Software. 19 1.1 riastrad * 20 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 23 1.1 riastrad * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 24 1.1 riastrad * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 25 1.1 riastrad * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 26 1.1 riastrad * USE OR OTHER DEALINGS IN THE SOFTWARE. 27 1.1 riastrad * 28 1.1 riastrad **************************************************************************/ 29 1.1 riastrad /* 30 1.1 riastrad * Authors: 31 1.1 riastrad * Thomas Hellstrom <thellstrom (at) vmware.com> 32 1.1 riastrad * 33 1.1 riastrad */ 34 1.1 riastrad 35 1.2 riastrad #include <sys/cdefs.h> 36 1.2 riastrad __KERNEL_RCSID(0, "$NetBSD: vmwgfx_prime.c,v 1.3 2021/12/18 23:45:45 riastradh Exp $"); 37 1.2 riastrad 38 1.1 riastrad #include "vmwgfx_drv.h" 39 1.3 riastrad #include "ttm_object.h" 40 1.1 riastrad #include <linux/dma-buf.h> 41 1.1 riastrad 42 1.1 riastrad /* 43 1.1 riastrad * DMA-BUF attach- and mapping methods. No need to implement 44 1.1 riastrad * these until we have other virtual devices use them. 45 1.1 riastrad */ 46 1.1 riastrad 47 1.1 riastrad static int vmw_prime_map_attach(struct dma_buf *dma_buf, 48 1.1 riastrad struct dma_buf_attachment *attach) 49 1.1 riastrad { 50 1.1 riastrad return -ENOSYS; 51 1.1 riastrad } 52 1.1 riastrad 53 1.1 riastrad static void vmw_prime_map_detach(struct dma_buf *dma_buf, 54 1.1 riastrad struct dma_buf_attachment *attach) 55 1.1 riastrad { 56 1.1 riastrad } 57 1.1 riastrad 58 1.1 riastrad static struct sg_table *vmw_prime_map_dma_buf(struct dma_buf_attachment *attach, 59 1.1 riastrad enum dma_data_direction dir) 60 1.1 riastrad { 61 1.1 riastrad return ERR_PTR(-ENOSYS); 62 1.1 riastrad } 63 1.1 riastrad 64 1.1 riastrad static void vmw_prime_unmap_dma_buf(struct dma_buf_attachment *attach, 65 1.1 riastrad struct sg_table *sgb, 66 1.1 riastrad enum dma_data_direction dir) 67 1.1 riastrad { 68 1.1 riastrad } 69 1.1 riastrad 70 1.1 riastrad const struct dma_buf_ops vmw_prime_dmabuf_ops = { 71 1.1 riastrad .attach = vmw_prime_map_attach, 72 1.1 riastrad .detach = vmw_prime_map_detach, 73 1.1 riastrad .map_dma_buf = vmw_prime_map_dma_buf, 74 1.1 riastrad .unmap_dma_buf = vmw_prime_unmap_dma_buf, 75 1.1 riastrad .release = NULL, 76 1.1 riastrad }; 77 1.1 riastrad 78 1.1 riastrad int vmw_prime_fd_to_handle(struct drm_device *dev, 79 1.1 riastrad struct drm_file *file_priv, 80 1.1 riastrad int fd, u32 *handle) 81 1.1 riastrad { 82 1.1 riastrad struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 83 1.1 riastrad 84 1.1 riastrad return ttm_prime_fd_to_handle(tfile, fd, handle); 85 1.1 riastrad } 86 1.1 riastrad 87 1.1 riastrad int vmw_prime_handle_to_fd(struct drm_device *dev, 88 1.1 riastrad struct drm_file *file_priv, 89 1.1 riastrad uint32_t handle, uint32_t flags, 90 1.1 riastrad int *prime_fd) 91 1.1 riastrad { 92 1.1 riastrad struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 93 1.1 riastrad 94 1.1 riastrad return ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd); 95 1.1 riastrad } 96