drivers/gpu/drm/openchrome/Makefile | 2 drivers/gpu/drm/openchrome/openchrome_drv.c | 6 drivers/gpu/drm/openchrome/openchrome_drv.h | 10 - drivers/gpu/drm/openchrome/openchrome_ioc32.c | 226 -------------------------- drivers/gpu/drm/openchrome/openchrome_ioctl.c | 111 ++++++++++++ include/uapi/drm/openchrome_drm.h | 69 +++++++ include/uapi/drm/via_drm.h | 116 ++----------- 7 files changed, 209 insertions(+), 331 deletions(-)
New commits: commit 33ce41f27b78bdfa3ffe53f8507aabc95c4262a2 Author: Kevin Brace <kevinbr...@gmx.com> Date: Mon Aug 10 19:14:56 2020 -0700 drm/openchrome: Version bumped to 3.2.0 Starting with OpenChrome DRM Version 3.2.0, OpenChrome graphics stack components will need to use OpenChrome DRM uAPI. Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h index 2e95e9c65e63..d16d392a5dca 100644 --- a/drivers/gpu/drm/openchrome/openchrome_drv.h +++ b/drivers/gpu/drm/openchrome/openchrome_drv.h @@ -60,8 +60,8 @@ #define DRIVER_MAJOR 3 -#define DRIVER_MINOR 1 -#define DRIVER_PATCHLEVEL 30 +#define DRIVER_MINOR 2 +#define DRIVER_PATCHLEVEL 0 #define DRIVER_NAME "openchrome" #define DRIVER_DESC "OpenChrome DRM for VIA Technologies Chrome IGP" #define DRIVER_DATE "20200810" commit 856fcebf7018aa37ae4ff805d3454964a6245962 Author: Kevin Brace <kevinbr...@gmx.com> Date: Mon Aug 10 19:11:34 2020 -0700 drm/openchrome: Restore the original VIA DRM uAPI header file Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/include/uapi/drm/via_drm.h b/include/uapi/drm/via_drm.h index b85b2ffa71d4..a1e125d42208 100644 --- a/include/uapi/drm/via_drm.h +++ b/include/uapi/drm/via_drm.h @@ -16,7 +16,7 @@ * 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 AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * VIA, S3 GRAPHICS, 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. @@ -26,6 +26,10 @@ #include "drm.h" +#if defined(__cplusplus) +extern "C" { +#endif + /* WARNING: These defines must be the same as what the Xserver uses. * if you change them, you must change the defines in the Xserver. */ @@ -33,10 +37,11 @@ #ifndef _VIA_DEFINES_ #define _VIA_DEFINES_ + #define VIA_NR_SAREA_CLIPRECTS 8 -#define VIA_NR_XVMC_PORTS 10 -#define VIA_NR_XVMC_LOCKS 5 -#define VIA_MAX_CACHELINE_SIZE 64 +#define VIA_NR_XVMC_PORTS 10 +#define VIA_NR_XVMC_LOCKS 5 +#define VIA_MAX_CACHELINE_SIZE 64 #define XVMCLOCKPTR(saPriv,lockNo) \ ((volatile struct drm_hw_lock *)(((((unsigned long) (saPriv)->XvMCLockArea) + \ (VIA_MAX_CACHELINE_SIZE - 1)) & \ @@ -60,28 +65,21 @@ /* VIA specific ioctls */ #define DRM_VIA_ALLOCMEM 0x00 -#define DRM_VIA_FREEMEM 0x01 +#define DRM_VIA_FREEMEM 0x01 #define DRM_VIA_AGP_INIT 0x02 -#define DRM_VIA_FB_INIT 0x03 +#define DRM_VIA_FB_INIT 0x03 #define DRM_VIA_MAP_INIT 0x04 -#define DRM_VIA_DEC_FUTEX 0x05 -#define DRM_VIA_OLD_GEM_CREATE 0x06 +#define DRM_VIA_DEC_FUTEX 0x05 +#define NOT_USED #define DRM_VIA_DMA_INIT 0x07 #define DRM_VIA_CMDBUFFER 0x08 -#define DRM_VIA_FLUSH 0x09 -#define DRM_VIA_PCICMD 0x0a +#define DRM_VIA_FLUSH 0x09 +#define DRM_VIA_PCICMD 0x0a #define DRM_VIA_CMDBUF_SIZE 0x0b #define NOT_USED -#define DRM_VIA_WAIT_IRQ 0x0d -#define DRM_VIA_DMA_BLIT 0x0e -#define DRM_VIA_BLIT_SYNC 0x0f - -/* KMS ioctls */ -#define DRM_VIA_GETPARAM 0x10 -#define DRM_VIA_SETPARAM 0x11 -#define DRM_VIA_GEM_CREATE 0x12 -#define DRM_VIA_GEM_WAIT 0x13 -#define DRM_VIA_GEM_STATE 0x14 +#define DRM_VIA_WAIT_IRQ 0x0d +#define DRM_VIA_DMA_BLIT 0x0e +#define DRM_VIA_BLIT_SYNC 0x0f #define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t) #define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t) @@ -89,7 +87,6 @@ #define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t) #define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t) #define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t) -#define DRM_IOCTL_VIA_OLD_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_OLD_GEM_CREATE, struct drm_via_gem_object) #define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t) #define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t) #define DRM_IOCTL_VIA_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_VIA_FLUSH) @@ -100,13 +97,6 @@ #define DRM_IOCTL_VIA_DMA_BLIT DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t) #define DRM_IOCTL_VIA_BLIT_SYNC DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t) -/* KMS ioctls */ -#define DRM_IOCTL_VIA_GETPARAM DRM_IOR(DRM_COMMAND_BASE + DRM_VIA_GETPARAM, struct drm_via_param) -#define DRM_IOCTL_VIA_SETPARAM DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_SETPARAM, struct drm_via_param) -#define DRM_IOCTL_VIA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_GEM_CREATE, struct drm_via_gem_object) -#define DRM_IOCTL_VIA_GEM_WAIT DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_GEM_WAIT, struct drm_via_gem_wait) -#define DRM_IOCTL_VIA_GEM_STATE DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_GEM_STATE, struct drm_via_gem_object) - /* Indices into buf.Setup where various bits of state are mirrored per * context and per buffer. These can be fired at the card as a unit, * or in a piecewise fashion as required. @@ -120,7 +110,6 @@ #define VIA_BACK 0x2 #define VIA_DEPTH 0x4 #define VIA_STENCIL 0x8 - #define VIA_MEM_VIDEO 0 /* matches drm constant */ #define VIA_MEM_AGP 1 /* matches drm constant */ #define VIA_MEM_SYSTEM 2 @@ -286,71 +275,8 @@ typedef struct drm_via_dmablit { drm_via_blitsync_t sync; } drm_via_dmablit_t; -/* Ioctl to query kernel params: - */ -#define VIA_PARAM_CHIPSET_ID 0 -#define VIA_PARAM_REVISION_ID 1 - -struct drm_via_param { - uint64_t param; - uint64_t value; -}; - -struct drm_via_gem_object { - /** - * Requested size for the object. - * - * The (page-aligned) allocated size for the object will be returned. - */ - uint64_t size; - - /* - * Place the memory at the proper byte alignment. - */ - uint32_t alignment; - - /** - * Format of data i.e tile pitch, for linear it is zero - */ - uint32_t pitch; - - /** - * Give hints where to allocate this object. - */ - uint32_t domains; - - /** - * chmod values applied to a buffer. - */ - uint32_t mode_t; - - /** - * Offset to start of memory region. - */ - uint64_t offset; - - /** - * Returned handle need to mmap the buffer. - */ - uint64_t map_handle; - - /** - * Returned handle for the object. - * - * Object handles are nonzero. - */ - uint32_t handle; - - /** - * Version to tell how to handle this data. - */ - uint32_t version; -}; - -struct drm_via_gem_wait { - /* the buffer object handle */ - uint32_t handle; - uint32_t no_wait; -}; +#if defined(__cplusplus) +} +#endif #endif /* _VIA_DRM_H_ */ commit b117384e9df30a52aefdd8ab769891bd1586958c Author: Kevin Brace <kevinbr...@gmx.com> Date: Mon Aug 10 19:07:52 2020 -0700 drm/openchrome: Switch to OpenChrome DRM uAPI Remove the stillborn KMS supporting VIA DRM uAPI, and replace it with OpenChrome DRM uAPI. Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/Makefile b/drivers/gpu/drm/openchrome/Makefile index b7fc2ff9dc8d..e26022adb6fc 100644 --- a/drivers/gpu/drm/openchrome/Makefile +++ b/drivers/gpu/drm/openchrome/Makefile @@ -17,7 +17,7 @@ openchrome-y := openchrome_analog.o \ openchrome_hdmi.o \ openchrome_i2c.o \ openchrome_init.o \ - openchrome_ioc32.o \ + openchrome_ioctl.o \ openchrome_object.o \ openchrome_pm.o \ openchrome_sii164.o \ diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.c b/drivers/gpu/drm/openchrome/openchrome_drv.c index 0485e3d1e229..bec5563ca74a 100644 --- a/drivers/gpu/drm/openchrome/openchrome_drv.c +++ b/drivers/gpu/drm/openchrome/openchrome_drv.c @@ -267,7 +267,7 @@ static struct drm_driver via_driver = { .dumb_create = openchrome_drm_driver_dumb_create, .dumb_map_offset = openchrome_drm_driver_dumb_map_offset, - .ioctls = via_ioctls, + .ioctls = openchrome_ioctls, .fops = &via_driver_fops, .name = DRIVER_NAME, .desc = DRIVER_DESC, @@ -340,7 +340,7 @@ static int __init openchrome_init(void) DRM_DEBUG_KMS("Entered %s.\n", __func__); - via_driver.num_ioctls = via_max_ioctl; + via_driver.num_ioctls = openchrome_max_ioctl; ret = pci_register_driver(&via_pci_driver); diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h index 54645c458d3e..2e95e9c65e63 100644 --- a/drivers/gpu/drm/openchrome/openchrome_drv.h +++ b/drivers/gpu/drm/openchrome/openchrome_drv.h @@ -53,7 +53,7 @@ #include <drm/ttm/ttm_bo_driver.h> #include <drm/ttm/ttm_placement.h> -#include <drm/via_drm.h> +#include <drm/openchrome_drm.h> #include "openchrome_crtc_hw.h" #include "openchrome_regs.h" @@ -375,8 +375,8 @@ disable_second_display_channel(void __iomem *regs) } -extern const struct drm_ioctl_desc via_ioctls[]; -extern int via_max_ioctl; +extern const struct drm_ioctl_desc openchrome_ioctls[]; +extern int openchrome_max_ioctl; extern int via_hdmi_audio; diff --git a/drivers/gpu/drm/openchrome/openchrome_ioc32.c b/drivers/gpu/drm/openchrome/openchrome_ioc32.c deleted file mode 100644 index b10c72d37c21..000000000000 --- a/drivers/gpu/drm/openchrome/openchrome_ioc32.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2006 Tungsten Graphics Inc., Bismarck, ND., USA. - * All rights reserved. - * - * 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 AUTHORS OR COPYRIGHT HOLDERS AND/OR THEIR 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 Hellström <thomas-at-tungstengraphics-dot-com> - */ - -#include <drm/drm_ioctl.h> - -#include "openchrome_drv.h" - - -static int -via_getparam(struct drm_device *dev, void *data, - struct drm_file *filp) -{ - struct openchrome_drm_private *dev_private = dev->dev_private; - struct drm_via_param *args = data; - int ret = 0; - - switch (args->param) { - case VIA_PARAM_CHIPSET_ID: - args->value = dev->pdev->device; - break; - case VIA_PARAM_REVISION_ID: - args->value = dev_private->revision; - break; - default: - ret = -EINVAL; - break; - } - return ret; -} - -/* Not yet supported */ -static int -via_setparam(struct drm_device *dev, void *data, - struct drm_file *filp) -{ - return -EINVAL; -} - -static int -via_gem_alloc(struct drm_device *dev, void *data, - struct drm_file *filp) -{ - struct drm_via_gem_object *args = data; - struct openchrome_drm_private *dev_private = dev->dev_private; - struct openchrome_bo *bo; - uint32_t handle; - int ret; - - DRM_DEBUG_KMS("Entered %s.\n", __func__); - - ret = openchrome_bo_create(dev, - &dev_private->bdev, - args->size, - ttm_bo_type_device, - args->domains, - false, - &bo); - - if (ret) { - goto exit; - } - - ret = drm_gem_handle_create(filp, &bo->gem, - &handle); - - /* Drop reference from allocate; handle holds it now. */ - drm_gem_object_put(&bo->gem); - - if (ret) { - openchrome_bo_destroy(bo, false); - goto exit; - } - - args->size = bo->ttm_bo.mem.size; - args->domains = bo->ttm_bo.mem.placement & - TTM_PL_MASK_MEM; - args->offset = bo->ttm_bo.mem.start << PAGE_SHIFT; - args->map_handle = drm_vma_node_offset_addr( - &bo->ttm_bo.base.vma_node); - args->handle = handle; - args->version = 1; - -exit: - DRM_DEBUG_KMS("Exiting %s.\n", __func__); - return ret; -} - -static int -via_gem_state(struct drm_device *dev, void *data, struct drm_file *file_priv) -{ - struct ttm_operation_ctx ctx = {.interruptible = false, - .no_wait_gpu = false}; - struct drm_gem_object *gem; - struct drm_via_gem_object *args = data; - struct openchrome_bo *bo; - int ret = -EINVAL; - - DRM_DEBUG_KMS("Entered %s.\n", __func__); - - gem = drm_gem_object_lookup(file_priv, args->handle); - if (!gem) { - goto exit; - } - - bo = container_of(gem, struct openchrome_bo, gem); - - /* Don't bother to migrate to same domain */ - args->domains &= ~(bo->ttm_bo.mem.placement & TTM_PL_MASK_MEM); - if (args->domains) { - ret = ttm_bo_reserve(&bo->ttm_bo, true, false, NULL); - if (ret) { - goto exit; - } - - openchrome_ttm_domain_to_placement(bo, args->domains); - ret = ttm_bo_validate(&bo->ttm_bo, &bo->placement, - &ctx); - ttm_bo_unreserve(&bo->ttm_bo); - - if (!ret) { - args->size = bo->ttm_bo.mem.size; - args->domains = bo->ttm_bo.mem.placement & - TTM_PL_MASK_MEM; - args->offset = bo->ttm_bo.mem.start << - PAGE_SHIFT; - args->map_handle = drm_vma_node_offset_addr( - &bo->ttm_bo.base.vma_node); - } - } - - mutex_lock(&dev->struct_mutex); - drm_gem_object_put(gem); - mutex_unlock(&dev->struct_mutex); -exit: - DRM_DEBUG_KMS("Exiting %s.\n", __func__); - return ret; -} - -static int -via_gem_wait(struct drm_device *dev, void *data, struct drm_file *file_priv) -{ - struct drm_gem_object *gem; - struct drm_via_gem_wait *args = data; - struct openchrome_bo *bo; - int ret = -EINVAL; - bool no_wait; - - DRM_DEBUG_KMS("Entered %s.\n", __func__); - - gem = drm_gem_object_lookup(file_priv, args->handle); - if (!gem) { - goto exit; - } - - bo = container_of(gem, struct openchrome_bo, gem); - - no_wait = (args->no_wait != 0); - ret = ttm_bo_reserve(&bo->ttm_bo, true, no_wait, NULL); - if (ret) { - goto exit; - } - - ret = ttm_bo_wait(&bo->ttm_bo, true, no_wait); - ttm_bo_unreserve(&bo->ttm_bo); - - mutex_lock(&dev->struct_mutex); - drm_gem_object_put(gem); - mutex_unlock(&dev->struct_mutex); -exit: - DRM_DEBUG_KMS("Exiting %s.\n", __func__); - return ret; -} - -#define KMS_INVALID_IOCTL(name) \ -int name(struct drm_device *dev, void *data, struct drm_file *file_priv)\ -{ \ - DRM_ERROR("invalid ioctl with kms %s\n", __func__); \ - return -EINVAL; \ -} - -KMS_INVALID_IOCTL(via_mem_alloc) -KMS_INVALID_IOCTL(via_mem_free) -KMS_INVALID_IOCTL(via_agp_init) -KMS_INVALID_IOCTL(via_fb_init) -KMS_INVALID_IOCTL(via_map_init) -KMS_INVALID_IOCTL(via_decoder_futex) - -const struct drm_ioctl_desc via_ioctls[] = { - DRM_IOCTL_DEF_DRV(VIA_ALLOCMEM, via_mem_alloc, DRM_AUTH), - DRM_IOCTL_DEF_DRV(VIA_FREEMEM, via_mem_free, DRM_AUTH), - DRM_IOCTL_DEF_DRV(VIA_FB_INIT, via_fb_init, DRM_AUTH | DRM_MASTER), - DRM_IOCTL_DEF_DRV(VIA_MAP_INIT, via_map_init, DRM_AUTH | DRM_MASTER), - DRM_IOCTL_DEF_DRV(VIA_DEC_FUTEX, via_decoder_futex, DRM_AUTH), - DRM_IOCTL_DEF_DRV(VIA_OLD_GEM_CREATE, via_gem_alloc, DRM_AUTH | DRM_UNLOCKED), - DRM_IOCTL_DEF_DRV(VIA_GETPARAM, via_getparam, DRM_AUTH | DRM_UNLOCKED), - DRM_IOCTL_DEF_DRV(VIA_SETPARAM, via_setparam, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY), - DRM_IOCTL_DEF_DRV(VIA_GEM_CREATE, via_gem_alloc, DRM_AUTH | DRM_UNLOCKED), - DRM_IOCTL_DEF_DRV(VIA_GEM_WAIT, via_gem_wait, DRM_AUTH), - DRM_IOCTL_DEF_DRV(VIA_GEM_STATE, via_gem_state, DRM_AUTH), -}; - -int via_max_ioctl = ARRAY_SIZE(via_ioctls); diff --git a/drivers/gpu/drm/openchrome/openchrome_ioctl.c b/drivers/gpu/drm/openchrome/openchrome_ioctl.c new file mode 100644 index 000000000000..17fb2ae5ee32 --- /dev/null +++ b/drivers/gpu/drm/openchrome/openchrome_ioctl.c @@ -0,0 +1,111 @@ +/* + * Copyright © 2020 Kevin Brace + * + * 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, sublicense, 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 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS 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. + */ +/* + * Author(s): + * + * Kevin Brace <kevinbr...@gmx.com> + */ + +#include <drm/drm_ioctl.h> + +#include "openchrome_drv.h" + + +static int openchrome_gem_create(struct drm_device *dev, + void *data, + struct drm_file *file_priv) +{ + struct drm_openchrome_gem_create *args = data; + struct openchrome_drm_private *dev_private = dev->dev_private; + struct openchrome_bo *bo; + uint32_t handle; + int ret; + + DRM_DEBUG_KMS("Entered %s.\n", __func__); + + ret = openchrome_bo_create(dev, + &dev_private->bdev, + args->size, + ttm_bo_type_device, + args->domain, + false, + &bo); + + if (ret) { + goto exit; + } + + ret = drm_gem_handle_create(file_priv, &bo->gem, + &handle); + drm_gem_object_put(&bo->gem); + if (ret) { + openchrome_bo_destroy(bo, false); + goto exit; + } + + args->size = bo->ttm_bo.mem.size; + args->domain = bo->ttm_bo.mem.placement & + TTM_PL_MASK_MEM; + args->handle = handle; + args->offset = bo->ttm_bo.mem.start << PAGE_SHIFT; +exit: + DRM_DEBUG_KMS("Exiting %s.\n", __func__); + return ret; +} + +static int openchrome_gem_map(struct drm_device *dev, + void *data, + struct drm_file *file_priv) +{ + struct drm_openchrome_gem_map *args = data; + struct drm_gem_object *gem; + struct openchrome_bo *bo; + int ret = 0; + + DRM_DEBUG_KMS("Entered %s.\n", __func__); + + gem = drm_gem_object_lookup(file_priv, args->handle); + if (!gem) { + ret = -EINVAL; + goto exit; + } + + bo = container_of(gem, struct openchrome_bo, gem); + + args->map_offset = drm_vma_node_offset_addr( + &bo->ttm_bo.base.vma_node); +exit: + DRM_DEBUG_KMS("Exiting %s.\n", __func__); + return ret; +} + + +const struct drm_ioctl_desc openchrome_ioctls[] = { + DRM_IOCTL_DEF_DRV(OPENCHROME_GEM_CREATE, openchrome_gem_create, DRM_AUTH | DRM_UNLOCKED), + DRM_IOCTL_DEF_DRV(OPENCHROME_GEM_MAP, openchrome_gem_map, DRM_AUTH | DRM_UNLOCKED), +}; + + +int openchrome_max_ioctl = ARRAY_SIZE(openchrome_ioctls); diff --git a/include/uapi/drm/openchrome_drm.h b/include/uapi/drm/openchrome_drm.h new file mode 100644 index 000000000000..06f7f2ababda --- /dev/null +++ b/include/uapi/drm/openchrome_drm.h @@ -0,0 +1,69 @@ +/* + * Copyright © 2020 Kevin Brace + * + * 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, sublicense, 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 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS 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. + */ +/* + * Author(s): + * + * Kevin Brace <kevinbr...@gmx.com> + */ + +#ifndef __OPENCHROME_DRM_H__ +#define __OPENCHROME_DRM_H__ + + +#include <drm/drm.h> + + +#if defined(__cplusplus) +extern "C" { +#endif + + +#define DRM_OPENCHROME_GEM_CREATE 0x00 +#define DRM_OPENCHROME_GEM_MAP 0x01 + + +#define DRM_IOCTL_OPENCHROME_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_OPENCHROME_GEM_CREATE, struct drm_openchrome_gem_create) +#define DRM_IOCTL_OPENCHROME_GEM_MAP DRM_IOWR(DRM_COMMAND_BASE + DRM_OPENCHROME_GEM_MAP, struct drm_openchrome_gem_map) + + +struct drm_openchrome_gem_create { + uint64_t size; + uint32_t alignment; + uint32_t domain; + uint32_t handle; + uint64_t offset; +}; + +struct drm_openchrome_gem_map { + uint32_t handle; + uint64_t map_offset; +}; + + +#if defined(__cplusplus) +} +#endif + +#endif /* __OPENCHROME_DRM_H__ */ commit e2558360e7cbcd11394bb401928b28e963a180a5 Author: Kevin Brace <kevinbr...@gmx.com> Date: Mon Aug 10 18:30:34 2020 -0700 drm/openchrome: Stop including drm/via_drm.h inside openchrome_drv.c openchrome_drv.h takes care of including drm/via_drm.h. Signed-off-by: Kevin Brace <kevinbr...@gmx.com> diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.c b/drivers/gpu/drm/openchrome/openchrome_drv.c index cbab0f32793e..0485e3d1e229 100644 --- a/drivers/gpu/drm/openchrome/openchrome_drv.c +++ b/drivers/gpu/drm/openchrome/openchrome_drv.c @@ -33,8 +33,6 @@ #include <drm/drm_file.h> #include <drm/drm_pciids.h> -#include <drm/via_drm.h> - #include "openchrome_drv.h" _______________________________________________ openchrome-devel mailing list openchrome-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/openchrome-devel