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