drm: add encoder ids to the output handling
authorDave Airlie <airlied@redhat.com>
Fri, 30 May 2008 02:19:13 +0000 (12:19 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 30 May 2008 02:19:13 +0000 (12:19 +1000)
linux-core/drm_crtc.c
linux-core/drm_crtc.h

index 5d5448c..fc35c1a 100644 (file)
@@ -1104,6 +1104,7 @@ int drm_mode_getoutput(struct drm_device *dev,
        struct drm_display_mode *mode;
        int mode_count = 0;
        int props_count = 0;
+       int encoders_count = 0;
        int ret = 0;
        int copied = 0;
        int i;
@@ -1111,6 +1112,7 @@ int drm_mode_getoutput(struct drm_device *dev,
        struct drm_mode_modeinfo __user *mode_ptr;
        uint32_t __user *prop_ptr;
        uint64_t __user *prop_values;
+       uint32_t __user *encoder_ptr;
 
        memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo));
 
@@ -1132,6 +1134,12 @@ int drm_mode_getoutput(struct drm_device *dev,
                }
        }
 
+       for (i = 0; i < DRM_OUTPUT_MAX_ENCODER; i++) {
+               if (output->encoder_ids[i] != 0) {
+                       encoders_count++;
+               }
+       }
+
        if (out_resp->count_modes == 0) {
                drm_crtc_probe_single_output_modes(output, dev->mode_config.max_width, dev->mode_config.max_height);
        }
@@ -1187,6 +1195,21 @@ int drm_mode_getoutput(struct drm_device *dev,
        }
        out_resp->count_props = props_count;
 
+       if ((out_resp->count_encoders >= encoders_count) && encoders_count) {
+               copied = 0;
+               encoder_ptr = (uint32_t *)(unsigned long)(out_resp->encoders_ptr);
+               for (i = 0; i < DRM_OUTPUT_MAX_ENCODER; i++) {
+                       if (output->encoder_ids[i] != 0) {
+                               if (put_user(output->encoder_ids[i], encoder_ptr + copied)) {
+                                       ret = -EFAULT;
+                                       goto out;
+                               }
+                               copied++;
+                       }
+               }
+       }
+       out_resp->count_encoders = encoders_count;
+
 out:
        mutex_unlock(&dev->mode_config.mutex);
        return ret;
index adaa49b..ed8467e 100644 (file)
@@ -402,6 +402,7 @@ struct drm_encoder_funcs {
 #define DRM_OUTPUT_MAX_UMODES 16
 #define DRM_OUTPUT_MAX_PROPERTY 16
 #define DRM_OUTPUT_LEN 32
+#define DRM_OUTPUT_MAX_ENCODER 2
 
 /**
  * drm_encoder - central DRM encoder structure 
@@ -468,6 +469,8 @@ struct drm_output {
        uint64_t property_values[DRM_OUTPUT_MAX_PROPERTY];
 
        void *helper_private;
+
+       u32 encoder_ids[DRM_OUTPUT_MAX_ENCODER];
 };
 
 /**