162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 OR MIT 262306a36Sopenharmony_ci/************************************************************************** 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Copyright 2013 VMware, Inc., Palo Alto, CA., USA 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 762306a36Sopenharmony_ci * copy of this software and associated documentation files (the 862306a36Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 962306a36Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 1062306a36Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 1162306a36Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 1262306a36Sopenharmony_ci * the following conditions: 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * The above copyright notice and this permission notice (including the 1562306a36Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 1662306a36Sopenharmony_ci * of the Software. 1762306a36Sopenharmony_ci * 1862306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1962306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2062306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 2162306a36Sopenharmony_ci * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 2262306a36Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 2362306a36Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 2462306a36Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 2562306a36Sopenharmony_ci * 2662306a36Sopenharmony_ci **************************************************************************/ 2762306a36Sopenharmony_ci/* 2862306a36Sopenharmony_ci * Authors: 2962306a36Sopenharmony_ci * Thomas Hellstrom <thellstrom@vmware.com> 3062306a36Sopenharmony_ci * 3162306a36Sopenharmony_ci */ 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#include "vmwgfx_drv.h" 3462306a36Sopenharmony_ci#include "ttm_object.h" 3562306a36Sopenharmony_ci#include <linux/dma-buf.h> 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci/* 3862306a36Sopenharmony_ci * DMA-BUF attach- and mapping methods. No need to implement 3962306a36Sopenharmony_ci * these until we have other virtual devices use them. 4062306a36Sopenharmony_ci */ 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_cistatic int vmw_prime_map_attach(struct dma_buf *dma_buf, 4362306a36Sopenharmony_ci struct dma_buf_attachment *attach) 4462306a36Sopenharmony_ci{ 4562306a36Sopenharmony_ci return -ENOSYS; 4662306a36Sopenharmony_ci} 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_cistatic void vmw_prime_map_detach(struct dma_buf *dma_buf, 4962306a36Sopenharmony_ci struct dma_buf_attachment *attach) 5062306a36Sopenharmony_ci{ 5162306a36Sopenharmony_ci} 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_cistatic struct sg_table *vmw_prime_map_dma_buf(struct dma_buf_attachment *attach, 5462306a36Sopenharmony_ci enum dma_data_direction dir) 5562306a36Sopenharmony_ci{ 5662306a36Sopenharmony_ci return ERR_PTR(-ENOSYS); 5762306a36Sopenharmony_ci} 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_cistatic void vmw_prime_unmap_dma_buf(struct dma_buf_attachment *attach, 6062306a36Sopenharmony_ci struct sg_table *sgb, 6162306a36Sopenharmony_ci enum dma_data_direction dir) 6262306a36Sopenharmony_ci{ 6362306a36Sopenharmony_ci} 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ciconst struct dma_buf_ops vmw_prime_dmabuf_ops = { 6662306a36Sopenharmony_ci .attach = vmw_prime_map_attach, 6762306a36Sopenharmony_ci .detach = vmw_prime_map_detach, 6862306a36Sopenharmony_ci .map_dma_buf = vmw_prime_map_dma_buf, 6962306a36Sopenharmony_ci .unmap_dma_buf = vmw_prime_unmap_dma_buf, 7062306a36Sopenharmony_ci .release = NULL, 7162306a36Sopenharmony_ci}; 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ciint vmw_prime_fd_to_handle(struct drm_device *dev, 7462306a36Sopenharmony_ci struct drm_file *file_priv, 7562306a36Sopenharmony_ci int fd, u32 *handle) 7662306a36Sopenharmony_ci{ 7762306a36Sopenharmony_ci struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci return ttm_prime_fd_to_handle(tfile, fd, handle); 8062306a36Sopenharmony_ci} 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ciint vmw_prime_handle_to_fd(struct drm_device *dev, 8362306a36Sopenharmony_ci struct drm_file *file_priv, 8462306a36Sopenharmony_ci uint32_t handle, uint32_t flags, 8562306a36Sopenharmony_ci int *prime_fd) 8662306a36Sopenharmony_ci{ 8762306a36Sopenharmony_ci struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 8862306a36Sopenharmony_ci return ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd); 8962306a36Sopenharmony_ci} 90