Subversion Repositories Kolibri OS

Rev

Rev 2007 | Rev 3120 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright 2008 Advanced Micro Devices, Inc.
  3.  * Copyright 2008 Red Hat Inc.
  4.  * Copyright 2009 Jerome Glisse.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the "Software"),
  8.  * to deal in the Software without restriction, including without limitation
  9.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10.  * and/or sell copies of the Software, and to permit persons to whom the
  11.  * Software is furnished to do so, subject to the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice shall be included in
  14.  * all copies or substantial portions of the Software.
  15.  *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  19.  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22.  * OTHER DEALINGS IN THE SOFTWARE.
  23.  *
  24.  * Authors: Dave Airlie
  25.  *          Alex Deucher
  26.  *          Jerome Glisse
  27.  */
  28. #include "drmP.h"
  29. #include "drm_crtc_helper.h"
  30. #include "radeon_drm.h"
  31. #include "radeon_reg.h"
  32. #include "radeon.h"
  33. #include "atom.h"
  34.  
  35. struct radeon_device *main_device;
  36.  
  37. extern int irq_override;
  38.  
  39. void irq_handler_kms()
  40. {
  41. //    dbgprintf("%s\n",__FUNCTION__);
  42.     radeon_irq_process(main_device);
  43. }
  44.  
  45.  
  46. static void radeon_irq_preinstall(struct radeon_device *rdev)
  47. {
  48.     unsigned i;
  49.  
  50.     /* Disable *all* interrupts */
  51.     rdev->irq.sw_int = false;
  52.     rdev->irq.gui_idle = false;
  53.     for (i = 0; i < rdev->num_crtc; i++)
  54.         rdev->irq.crtc_vblank_int[i] = false;
  55.     for (i = 0; i < 6; i++) {
  56.         rdev->irq.hpd[i] = false;
  57.         rdev->irq.pflip[i] = false;
  58.     }
  59.     radeon_irq_set(rdev);
  60.     /* Clear bits */
  61.     radeon_irq_process(rdev);
  62. }
  63.  
  64. int radeon_driver_irq_postinstall(struct radeon_device *rdev)
  65. {
  66. //    struct radeon_device *rdev = dev->dev_private;
  67.  
  68. //    dev->max_vblank_count = 0x001fffff;
  69.     rdev->irq.sw_int = true;
  70.     radeon_irq_set(rdev);
  71.     return 0;
  72. }
  73.  
  74. int radeon_irq_kms_init(struct radeon_device *rdev)
  75. {
  76.         int i;
  77.     int irq_line;
  78.         int r = 0;
  79.  
  80.     ENTER();
  81.  
  82. //   INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
  83.  
  84.         spin_lock_init(&rdev->irq.sw_lock);
  85.         for (i = 0; i < rdev->num_crtc; i++)
  86.                 spin_lock_init(&rdev->irq.pflip_lock[i]);
  87. //   r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
  88. //   if (r) {
  89. //       return r;
  90. //   }
  91.  
  92.         rdev->msi_enabled = 0;
  93.     rdev->irq.installed = true;
  94.     main_device = rdev;
  95.  
  96.     radeon_irq_preinstall(rdev);
  97.  
  98.     if (irq_override)
  99.         irq_line = irq_override;
  100.     else
  101.         irq_line = rdev->pdev->irq;
  102.  
  103.     dbgprintf("%s install irq %d\n", __FUNCTION__, irq_line);
  104.  
  105.     AttachIntHandler(irq_line, irq_handler_kms, 2);
  106.  
  107. //   r = drm_irq_install(rdev->ddev);
  108.  
  109.     r = radeon_driver_irq_postinstall(rdev);
  110.     if (r) {
  111.        rdev->irq.installed = false;
  112.         LEAVE();
  113.        return r;
  114.    }
  115.  
  116.         DRM_INFO("radeon: irq initialized.\n");
  117.         return 0;
  118. }
  119.  
  120.  
  121. void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev)
  122. {
  123.         unsigned long irqflags;
  124.  
  125.         spin_lock_irqsave(&rdev->irq.sw_lock, irqflags);
  126.         if (rdev->ddev->irq_enabled && (++rdev->irq.sw_refcount == 1)) {
  127.                 rdev->irq.sw_int = true;
  128.                 radeon_irq_set(rdev);
  129.         }
  130.         spin_unlock_irqrestore(&rdev->irq.sw_lock, irqflags);
  131. }
  132.  
  133. void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev)
  134. {
  135.         unsigned long irqflags;
  136.  
  137.         spin_lock_irqsave(&rdev->irq.sw_lock, irqflags);
  138.         BUG_ON(rdev->ddev->irq_enabled && rdev->irq.sw_refcount <= 0);
  139.         if (rdev->ddev->irq_enabled && (--rdev->irq.sw_refcount == 0)) {
  140.                 rdev->irq.sw_int = false;
  141.                 radeon_irq_set(rdev);
  142.         }
  143.         spin_unlock_irqrestore(&rdev->irq.sw_lock, irqflags);
  144. }
  145.  
  146.  
  147.