drm/radeon/kms: add query for crtc hw id from crtc id to get info V2
authorJerome Glisse <jglisse@redhat.com>
Wed, 12 May 2010 16:01:13 +0000 (18:01 +0200)
committerDave Airlie <airlied@redhat.com>
Tue, 18 May 2010 05:59:08 +0000 (15:59 +1000)
Userspace need to know the hw crtc id (0, 1, 2, ...) from the drm
crtc id. Bump the minor version so userspace can enable conditionaly
features depend on this.

V2 use num_crtc and avoid DRM_ERROR

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/radeon/radeon_kms.c
include/drm/radeon_drm.h

index 4b05563d99e16335f729cd3b5fe5bcbff683669f..6e22815f7f07e718c91815baaddd2a3cc72ee55c 100644 (file)
  * - 2.1.0 - add square tiling interface
  * - 2.2.0 - add r6xx/r7xx const buffer support
  * - 2.3.0 - add MSPOS + 3D texture + r500 VAP regs
+ * - 2.4.0 - add crtc id query
  */
 #define KMS_DRIVER_MAJOR       2
-#define KMS_DRIVER_MINOR       3
+#define KMS_DRIVER_MINOR       4
 #define KMS_DRIVER_PATCHLEVEL  0
 int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
 int radeon_driver_unload_kms(struct drm_device *dev);
index d3657dcfdd26335ea9b1ed26e5df4a8d57b52094..021572a3dd9cfd61b8afe98012c498aa7d2ad5e5 100644 (file)
@@ -98,11 +98,15 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 {
        struct radeon_device *rdev = dev->dev_private;
        struct drm_radeon_info *info;
+       struct radeon_mode_info *minfo = &rdev->mode_info;
        uint32_t *value_ptr;
        uint32_t value;
+       struct drm_crtc *crtc;
+       int i, found;
 
        info = data;
        value_ptr = (uint32_t *)((unsigned long)info->value);
+       value = *value_ptr;
        switch (info->request) {
        case RADEON_INFO_DEVICE_ID:
                value = dev->pci_device;
@@ -116,6 +120,20 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
        case RADEON_INFO_ACCEL_WORKING:
                value = rdev->accel_working;
                break;
+       case RADEON_INFO_CRTC_FROM_ID:
+               for (i = 0, found = 0; i < rdev->num_crtc; i++) {
+                       crtc = (struct drm_crtc *)minfo->crtcs[i];
+                       if (crtc && crtc->base.id == value) {
+                               value = i;
+                               found = 1;
+                               break;
+                       }
+               }
+               if (!found) {
+                       DRM_DEBUG("unknown crtc id %d\n", value);
+                       return -EINVAL;
+               }
+               break;
        default:
                DRM_DEBUG("Invalid request %d\n", info->request);
                return -EINVAL;
index 81e614bf2dc3ac68accc19b825bf59bff066c913..3ff9fc071dfee1eff45bda07e5ba208af3666c46 100644 (file)
@@ -902,6 +902,7 @@ struct drm_radeon_cs {
 #define RADEON_INFO_NUM_GB_PIPES       0x01
 #define RADEON_INFO_NUM_Z_PIPES        0x02
 #define RADEON_INFO_ACCEL_WORKING      0x03
+#define RADEON_INFO_CRTC_FROM_ID       0x04
 
 struct drm_radeon_info {
        uint32_t                request;