Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * \file drm_legacy_misc.c
0003  * Misc legacy support functions.
0004  *
0005  * \author Rickard E. (Rik) Faith <faith@valinux.com>
0006  * \author Gareth Hughes <gareth@valinux.com>
0007  */
0008 
0009 /*
0010  * Created: Tue Feb  2 08:37:54 1999 by faith@valinux.com
0011  *
0012  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
0013  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
0014  * All Rights Reserved.
0015  *
0016  * Permission is hereby granted, free of charge, to any person obtaining a
0017  * copy of this software and associated documentation files (the "Software"),
0018  * to deal in the Software without restriction, including without limitation
0019  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0020  * and/or sell copies of the Software, and to permit persons to whom the
0021  * Software is furnished to do so, subject to the following conditions:
0022  *
0023  * The above copyright notice and this permission notice (including the next
0024  * paragraph) shall be included in all copies or substantial portions of the
0025  * Software.
0026  *
0027  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0028  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0029  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0030  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
0031  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0032  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0033  * OTHER DEALINGS IN THE SOFTWARE.
0034  */
0035 
0036 #include <drm/drm_device.h>
0037 #include <drm/drm_drv.h>
0038 #include <drm/drm_print.h>
0039 
0040 #include "drm_internal.h"
0041 #include "drm_legacy.h"
0042 
0043 void drm_legacy_init_members(struct drm_device *dev)
0044 {
0045     INIT_LIST_HEAD(&dev->ctxlist);
0046     INIT_LIST_HEAD(&dev->vmalist);
0047     INIT_LIST_HEAD(&dev->maplist);
0048     spin_lock_init(&dev->buf_lock);
0049     mutex_init(&dev->ctxlist_mutex);
0050 }
0051 
0052 void drm_legacy_destroy_members(struct drm_device *dev)
0053 {
0054     mutex_destroy(&dev->ctxlist_mutex);
0055 }
0056 
0057 int drm_legacy_setup(struct drm_device * dev)
0058 {
0059     int ret;
0060 
0061     if (dev->driver->firstopen &&
0062         drm_core_check_feature(dev, DRIVER_LEGACY)) {
0063         ret = dev->driver->firstopen(dev);
0064         if (ret != 0)
0065             return ret;
0066     }
0067 
0068     ret = drm_legacy_dma_setup(dev);
0069     if (ret < 0)
0070         return ret;
0071 
0072 
0073     DRM_DEBUG("\n");
0074     return 0;
0075 }
0076 
0077 void drm_legacy_dev_reinit(struct drm_device *dev)
0078 {
0079     if (dev->irq_enabled)
0080         drm_legacy_irq_uninstall(dev);
0081 
0082     mutex_lock(&dev->struct_mutex);
0083 
0084     drm_legacy_agp_clear(dev);
0085 
0086     drm_legacy_sg_cleanup(dev);
0087     drm_legacy_vma_flush(dev);
0088     drm_legacy_dma_takedown(dev);
0089 
0090     mutex_unlock(&dev->struct_mutex);
0091 
0092     dev->sigdata.lock = NULL;
0093 
0094     dev->context_flag = 0;
0095     dev->last_context = 0;
0096     dev->if_version = 0;
0097 
0098     DRM_DEBUG("lastclose completed\n");
0099 }
0100 
0101 void drm_master_legacy_init(struct drm_master *master)
0102 {
0103     spin_lock_init(&master->lock.spinlock);
0104     init_waitqueue_head(&master->lock.lock_queue);
0105 }