This is initial change adding support for DRIVER_GEM to vmwgfx. vmwgfx was written before GEM and has always used TTM. Over the years the TTM buffers started inherting from GEM objects but vmwgfx never implemented GEM making it quite awkward. We were directly setting variables in GEM objects to not make DRM crash. This change brings vmwgfx inline with other DRM drivers and allows us to use a lot of DRM helpers which have depended on drivers with GEM support. Due to historical reasons vmwgfx splits the idea of a buffer and surface which makes it a littly tricky since either one can be used in most of our ioctl's which take user space handles. For now our BO's are GEM objects and our surfaces are opaque objects which are backed by GEM objects. In the future I'd like to combine those into a single BO but we don't want to break any of our existing ioctl's so it will take time to do it in a non-destructive way. Signed-off-by: Zack Rusin <zackr@vmware.com> Reviewed-by: Martin Krastev <krastevm@vmware.com> Link: https://patchwork.freedesktop.org/patch/msgid/20211206172620.3139754-5-zack@kde.org
90 lines
2.8 KiB
C
90 lines
2.8 KiB
C
// SPDX-License-Identifier: GPL-2.0 OR MIT
|
|
/**************************************************************************
|
|
*
|
|
* Copyright 2013 VMware, Inc., Palo Alto, CA., USA
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the
|
|
* "Software"), to deal in the Software without restriction, including
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
* distribute, sub license, and/or sell copies of the Software, and to
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
* the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
* of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
**************************************************************************/
|
|
/*
|
|
* Authors:
|
|
* Thomas Hellstrom <thellstrom@vmware.com>
|
|
*
|
|
*/
|
|
|
|
#include "vmwgfx_drv.h"
|
|
#include "ttm_object.h"
|
|
#include <linux/dma-buf.h>
|
|
|
|
/*
|
|
* DMA-BUF attach- and mapping methods. No need to implement
|
|
* these until we have other virtual devices use them.
|
|
*/
|
|
|
|
static int vmw_prime_map_attach(struct dma_buf *dma_buf,
|
|
struct dma_buf_attachment *attach)
|
|
{
|
|
return -ENOSYS;
|
|
}
|
|
|
|
static void vmw_prime_map_detach(struct dma_buf *dma_buf,
|
|
struct dma_buf_attachment *attach)
|
|
{
|
|
}
|
|
|
|
static struct sg_table *vmw_prime_map_dma_buf(struct dma_buf_attachment *attach,
|
|
enum dma_data_direction dir)
|
|
{
|
|
return ERR_PTR(-ENOSYS);
|
|
}
|
|
|
|
static void vmw_prime_unmap_dma_buf(struct dma_buf_attachment *attach,
|
|
struct sg_table *sgb,
|
|
enum dma_data_direction dir)
|
|
{
|
|
}
|
|
|
|
const struct dma_buf_ops vmw_prime_dmabuf_ops = {
|
|
.attach = vmw_prime_map_attach,
|
|
.detach = vmw_prime_map_detach,
|
|
.map_dma_buf = vmw_prime_map_dma_buf,
|
|
.unmap_dma_buf = vmw_prime_unmap_dma_buf,
|
|
.release = NULL,
|
|
};
|
|
|
|
int vmw_prime_fd_to_handle(struct drm_device *dev,
|
|
struct drm_file *file_priv,
|
|
int fd, u32 *handle)
|
|
{
|
|
struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
|
|
|
|
return ttm_prime_fd_to_handle(tfile, fd, handle);
|
|
}
|
|
|
|
int vmw_prime_handle_to_fd(struct drm_device *dev,
|
|
struct drm_file *file_priv,
|
|
uint32_t handle, uint32_t flags,
|
|
int *prime_fd)
|
|
{
|
|
struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
|
|
return ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd);
|
|
}
|