Home | History | Annotate | Line # | Download | only in drm
      1  1.3  riastrad /*	$NetBSD: drm_legacy_misc.c,v 1.3 2021/12/19 12:30:04 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * \file drm_legacy_misc.c
      5  1.1  riastrad  * Misc legacy support functions.
      6  1.1  riastrad  *
      7  1.1  riastrad  * \author Rickard E. (Rik) Faith <faith (at) valinux.com>
      8  1.1  riastrad  * \author Gareth Hughes <gareth (at) valinux.com>
      9  1.1  riastrad  */
     10  1.1  riastrad 
     11  1.1  riastrad /*
     12  1.1  riastrad  * Created: Tue Feb  2 08:37:54 1999 by faith (at) valinux.com
     13  1.1  riastrad  *
     14  1.1  riastrad  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
     15  1.1  riastrad  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
     16  1.1  riastrad  * All Rights Reserved.
     17  1.1  riastrad  *
     18  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
     19  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
     20  1.1  riastrad  * to deal in the Software without restriction, including without limitation
     21  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     22  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     23  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     24  1.1  riastrad  *
     25  1.1  riastrad  * The above copyright notice and this permission notice (including the next
     26  1.1  riastrad  * paragraph) shall be included in all copies or substantial portions of the
     27  1.1  riastrad  * Software.
     28  1.1  riastrad  *
     29  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     30  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     31  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     32  1.1  riastrad  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
     33  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     34  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     35  1.1  riastrad  * OTHER DEALINGS IN THE SOFTWARE.
     36  1.1  riastrad  */
     37  1.1  riastrad 
     38  1.1  riastrad #include <sys/cdefs.h>
     39  1.3  riastrad __KERNEL_RCSID(0, "$NetBSD: drm_legacy_misc.c,v 1.3 2021/12/19 12:30:04 riastradh Exp $");
     40  1.1  riastrad 
     41  1.1  riastrad #include <drm/drm_agpsupport.h>
     42  1.1  riastrad #include <drm/drm_device.h>
     43  1.1  riastrad #include <drm/drm_drv.h>
     44  1.1  riastrad #include <drm/drm_irq.h>
     45  1.1  riastrad #include <drm/drm_print.h>
     46  1.1  riastrad 
     47  1.1  riastrad #include "drm_internal.h"
     48  1.1  riastrad #include "drm_legacy.h"
     49  1.1  riastrad 
     50  1.3  riastrad #include <linux/nbsd-namespace.h>
     51  1.3  riastrad 
     52  1.1  riastrad void drm_legacy_init_members(struct drm_device *dev)
     53  1.1  riastrad {
     54  1.1  riastrad 	INIT_LIST_HEAD(&dev->ctxlist);
     55  1.1  riastrad 	INIT_LIST_HEAD(&dev->vmalist);
     56  1.1  riastrad 	INIT_LIST_HEAD(&dev->maplist);
     57  1.1  riastrad 	spin_lock_init(&dev->buf_lock);
     58  1.1  riastrad 	mutex_init(&dev->ctxlist_mutex);
     59  1.1  riastrad }
     60  1.1  riastrad 
     61  1.1  riastrad void drm_legacy_destroy_members(struct drm_device *dev)
     62  1.1  riastrad {
     63  1.1  riastrad 	mutex_destroy(&dev->ctxlist_mutex);
     64  1.3  riastrad 	spin_lock_destroy(&dev->buf_lock);
     65  1.1  riastrad }
     66  1.1  riastrad 
     67  1.1  riastrad int drm_legacy_setup(struct drm_device * dev)
     68  1.1  riastrad {
     69  1.1  riastrad 	int ret;
     70  1.1  riastrad 
     71  1.1  riastrad 	if (dev->driver->firstopen &&
     72  1.1  riastrad 	    drm_core_check_feature(dev, DRIVER_LEGACY)) {
     73  1.1  riastrad 		ret = dev->driver->firstopen(dev);
     74  1.1  riastrad 		if (ret != 0)
     75  1.1  riastrad 			return ret;
     76  1.1  riastrad 	}
     77  1.1  riastrad 
     78  1.1  riastrad 	ret = drm_legacy_dma_setup(dev);
     79  1.1  riastrad 	if (ret < 0)
     80  1.1  riastrad 		return ret;
     81  1.1  riastrad 
     82  1.1  riastrad 
     83  1.1  riastrad 	DRM_DEBUG("\n");
     84  1.1  riastrad 	return 0;
     85  1.1  riastrad }
     86  1.1  riastrad 
     87  1.1  riastrad void drm_legacy_dev_reinit(struct drm_device *dev)
     88  1.1  riastrad {
     89  1.1  riastrad 	if (dev->irq_enabled)
     90  1.1  riastrad 		drm_irq_uninstall(dev);
     91  1.1  riastrad 
     92  1.1  riastrad 	mutex_lock(&dev->struct_mutex);
     93  1.1  riastrad 
     94  1.1  riastrad 	drm_legacy_agp_clear(dev);
     95  1.1  riastrad 
     96  1.1  riastrad 	drm_legacy_sg_cleanup(dev);
     97  1.1  riastrad 	drm_legacy_vma_flush(dev);
     98  1.1  riastrad 	drm_legacy_dma_takedown(dev);
     99  1.1  riastrad 
    100  1.1  riastrad 	mutex_unlock(&dev->struct_mutex);
    101  1.1  riastrad 
    102  1.1  riastrad 	dev->sigdata.lock = NULL;
    103  1.1  riastrad 
    104  1.1  riastrad 	dev->context_flag = 0;
    105  1.1  riastrad 	dev->last_context = 0;
    106  1.1  riastrad 	dev->if_version = 0;
    107  1.1  riastrad 
    108  1.1  riastrad 	DRM_DEBUG("lastclose completed\n");
    109  1.1  riastrad }
    110  1.1  riastrad 
    111  1.1  riastrad void drm_master_legacy_init(struct drm_master *master)
    112  1.1  riastrad {
    113  1.1  riastrad 	spin_lock_init(&master->lock.spinlock);
    114  1.3  riastrad 	DRM_INIT_WAITQUEUE(&master->lock.lock_queue, "drmlock");
    115  1.1  riastrad }
    116