Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0 OR MIT
0002 /**************************************************************************
0003  *
0004  * Copyright 2013 VMware, Inc., Palo Alto, CA., USA
0005  *
0006  * Permission is hereby granted, free of charge, to any person obtaining a
0007  * copy of this software and associated documentation files (the
0008  * "Software"), to deal in the Software without restriction, including
0009  * without limitation the rights to use, copy, modify, merge, publish,
0010  * distribute, sub license, and/or sell copies of the Software, and to
0011  * permit persons to whom the Software is furnished to do so, subject to
0012  * the following conditions:
0013  *
0014  * The above copyright notice and this permission notice (including the
0015  * next paragraph) shall be included in all copies or substantial portions
0016  * of the Software.
0017  *
0018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0019  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0020  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
0021  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
0022  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
0023  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
0024  * USE OR OTHER DEALINGS IN THE SOFTWARE.
0025  *
0026  **************************************************************************/
0027 /*
0028  * Authors:
0029  *     Thomas Hellstrom <thellstrom@vmware.com>
0030  *
0031  */
0032 
0033 #include "vmwgfx_drv.h"
0034 #include "ttm_object.h"
0035 #include <linux/dma-buf.h>
0036 
0037 /*
0038  * DMA-BUF attach- and mapping methods. No need to implement
0039  * these until we have other virtual devices use them.
0040  */
0041 
0042 static int vmw_prime_map_attach(struct dma_buf *dma_buf,
0043                 struct dma_buf_attachment *attach)
0044 {
0045     return -ENOSYS;
0046 }
0047 
0048 static void vmw_prime_map_detach(struct dma_buf *dma_buf,
0049                  struct dma_buf_attachment *attach)
0050 {
0051 }
0052 
0053 static struct sg_table *vmw_prime_map_dma_buf(struct dma_buf_attachment *attach,
0054                           enum dma_data_direction dir)
0055 {
0056     return ERR_PTR(-ENOSYS);
0057 }
0058 
0059 static void vmw_prime_unmap_dma_buf(struct dma_buf_attachment *attach,
0060                     struct sg_table *sgb,
0061                     enum dma_data_direction dir)
0062 {
0063 }
0064 
0065 const struct dma_buf_ops vmw_prime_dmabuf_ops =  {
0066     .attach = vmw_prime_map_attach,
0067     .detach = vmw_prime_map_detach,
0068     .map_dma_buf = vmw_prime_map_dma_buf,
0069     .unmap_dma_buf = vmw_prime_unmap_dma_buf,
0070     .release = NULL,
0071 };
0072 
0073 int vmw_prime_fd_to_handle(struct drm_device *dev,
0074                struct drm_file *file_priv,
0075                int fd, u32 *handle)
0076 {
0077     struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
0078 
0079     return ttm_prime_fd_to_handle(tfile, fd, handle);
0080 }
0081 
0082 int vmw_prime_handle_to_fd(struct drm_device *dev,
0083                struct drm_file *file_priv,
0084                uint32_t handle, uint32_t flags,
0085                int *prime_fd)
0086 {
0087     struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
0088     return ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd);
0089 }