drm_legacy_misc.c 2.8 KB

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