18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * \file drm_legacy_misc.c 38c2ecf20Sopenharmony_ci * Misc legacy support functions. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * \author Rickard E. (Rik) Faith <faith@valinux.com> 68c2ecf20Sopenharmony_ci * \author Gareth Hughes <gareth@valinux.com> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci/* 108c2ecf20Sopenharmony_ci * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 138c2ecf20Sopenharmony_ci * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 148c2ecf20Sopenharmony_ci * All Rights Reserved. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 178c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 188c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 198c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 208c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 218c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next 248c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 258c2ecf20Sopenharmony_ci * Software. 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 288c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 298c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 308c2ecf20Sopenharmony_ci * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 318c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 328c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 338c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#include <drm/drm_agpsupport.h> 378c2ecf20Sopenharmony_ci#include <drm/drm_device.h> 388c2ecf20Sopenharmony_ci#include <drm/drm_drv.h> 398c2ecf20Sopenharmony_ci#include <drm/drm_irq.h> 408c2ecf20Sopenharmony_ci#include <drm/drm_print.h> 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#include "drm_internal.h" 438c2ecf20Sopenharmony_ci#include "drm_legacy.h" 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_civoid drm_legacy_init_members(struct drm_device *dev) 468c2ecf20Sopenharmony_ci{ 478c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&dev->ctxlist); 488c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&dev->vmalist); 498c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&dev->maplist); 508c2ecf20Sopenharmony_ci spin_lock_init(&dev->buf_lock); 518c2ecf20Sopenharmony_ci mutex_init(&dev->ctxlist_mutex); 528c2ecf20Sopenharmony_ci} 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_civoid drm_legacy_destroy_members(struct drm_device *dev) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci mutex_destroy(&dev->ctxlist_mutex); 578c2ecf20Sopenharmony_ci} 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciint drm_legacy_setup(struct drm_device * dev) 608c2ecf20Sopenharmony_ci{ 618c2ecf20Sopenharmony_ci int ret; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci if (dev->driver->firstopen && 648c2ecf20Sopenharmony_ci drm_core_check_feature(dev, DRIVER_LEGACY)) { 658c2ecf20Sopenharmony_ci ret = dev->driver->firstopen(dev); 668c2ecf20Sopenharmony_ci if (ret != 0) 678c2ecf20Sopenharmony_ci return ret; 688c2ecf20Sopenharmony_ci } 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci ret = drm_legacy_dma_setup(dev); 718c2ecf20Sopenharmony_ci if (ret < 0) 728c2ecf20Sopenharmony_ci return ret; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci DRM_DEBUG("\n"); 768c2ecf20Sopenharmony_ci return 0; 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_civoid drm_legacy_dev_reinit(struct drm_device *dev) 808c2ecf20Sopenharmony_ci{ 818c2ecf20Sopenharmony_ci if (dev->irq_enabled) 828c2ecf20Sopenharmony_ci drm_irq_uninstall(dev); 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci mutex_lock(&dev->struct_mutex); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci drm_legacy_agp_clear(dev); 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci drm_legacy_sg_cleanup(dev); 898c2ecf20Sopenharmony_ci drm_legacy_vma_flush(dev); 908c2ecf20Sopenharmony_ci drm_legacy_dma_takedown(dev); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci mutex_unlock(&dev->struct_mutex); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci dev->sigdata.lock = NULL; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci dev->context_flag = 0; 978c2ecf20Sopenharmony_ci dev->last_context = 0; 988c2ecf20Sopenharmony_ci dev->if_version = 0; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci DRM_DEBUG("lastclose completed\n"); 1018c2ecf20Sopenharmony_ci} 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_civoid drm_master_legacy_init(struct drm_master *master) 1048c2ecf20Sopenharmony_ci{ 1058c2ecf20Sopenharmony_ci spin_lock_init(&master->lock.spinlock); 1068c2ecf20Sopenharmony_ci init_waitqueue_head(&master->lock.lock_queue); 1078c2ecf20Sopenharmony_ci} 108