drm: introduce generation counter to interface.
authorDave Airlie <airlied@redhat.com>
Wed, 4 Jun 2008 03:49:43 +0000 (13:49 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 4 Jun 2008 03:50:51 +0000 (13:50 +1000)
Idea being if you want to add new crtc/output/encoder dynamically later,
you just increase the generation counter and userspace should re-read
all the resources

libdrm/xf86drmMode.h
linux-core/drm_crtc.c
linux-core/drm_crtc.h
shared-core/drm.h

index 56908d8..3bd30a9 100644 (file)
  * buffer object interface. This object needs to be pinned.
  */
 
+/*
+ * generation - these are to be read by userspace, and if it notices
+ * while calling a get output or get crtc that the generation has changed
+ * it should re-call the mode resource functions resync its view of the
+ * outputs with current view.
+ */
 
 typedef struct _drmModeRes {
 
+       uint32_t generation;
        int count_fbs;
        uint32_t *fbs;
 
@@ -93,6 +100,7 @@ typedef struct _drmModeProperty {
 typedef struct _drmModeCrtc {
        unsigned int crtc_id;
        unsigned int buffer_id; /**< FB id to connect to 0 = disconnect*/
+       uint32_t generation;
 
        uint32_t x, y; /**< Position on the frameuffer */
        uint32_t width, height;
@@ -110,6 +118,7 @@ typedef struct _drmModeCrtc {
 } drmModeCrtc, *drmModeCrtcPtr;
 
 typedef struct _drmModeEncoder {
+       uint32_t generation;
        unsigned int encoder_id;
        unsigned int encoder_type;
        uint32_t crtc;
@@ -133,8 +142,8 @@ typedef enum {
 } drmModeSubPixel;
 
 typedef struct _drmModeConnector {
+       uint32_t generation;
        unsigned int connector_id;
-
        unsigned int encoder; /**< Crtc currently connected to */
        unsigned int connector_type;
        unsigned int connector_type_id;
index d2060fd..4c6afd1 100644 (file)
@@ -571,6 +571,7 @@ void drm_mode_config_init(struct drm_device *dev)
        drm_mode_create_standard_connector_properties(dev);
 
        /* Just to be sure */
+       dev->mode_config.current_generation = 0;
        dev->mode_config.num_fb = 0;
        dev->mode_config.num_connector = 0;
        dev->mode_config.num_crtc = 0;
@@ -801,6 +802,7 @@ int drm_mode_getresources(struct drm_device *dev,
        card_res->min_height = dev->mode_config.min_height;
        card_res->max_width = dev->mode_config.max_width;
        card_res->min_width = dev->mode_config.min_width;
+       card_res->generation = dev->mode_config.current_generation;
 
        /* handle this in 4 parts */
        /* FBs */
@@ -943,7 +945,7 @@ int drm_mode_getcrtc(struct drm_device *dev,
        crtc_resp->x = crtc->x;
        crtc_resp->y = crtc->y;
        crtc_resp->gamma_size = crtc->gamma_size;
-
+       crtc_resp->generation = dev->mode_config.current_generation;
        if (crtc->fb)
                crtc_resp->fb_id = crtc->fb->base.id;
        else
@@ -1032,6 +1034,7 @@ int drm_mode_getconnector(struct drm_device *dev,
                connector->funcs->fill_modes(connector, dev->mode_config.max_width, dev->mode_config.max_height);
        }
 
+       out_resp->generation = dev->mode_config.current_generation;
        out_resp->connector_type = connector->connector_type;
        out_resp->connector_type_id = connector->connector_type_id;
        out_resp->mm_width = connector->display_info.width_mm;
@@ -1120,6 +1123,7 @@ int drm_mode_getencoder(struct drm_device *dev,
                enc_resp->crtc = encoder->crtc->base.id;
        else
                enc_resp->crtc = 0;
+       enc_resp->generation = dev->mode_config.current_generation;
        enc_resp->encoder_type = encoder->encoder_type;
        enc_resp->encoder_id = encoder->base.id;
        enc_resp->crtcs = encoder->possible_crtcs;
index c92c59b..f395369 100644 (file)
@@ -554,6 +554,9 @@ struct drm_mode_config {
 
        struct list_head property_list;
 
+       /* currently in use generation id */
+       int current_generation;
+
        int min_width, min_height;
        int max_width, max_height;
        struct drm_mode_config_funcs *funcs;
index 132c774..40653b4 100644 (file)
@@ -1033,6 +1033,7 @@ struct drm_mode_card_res {
        int count_encoders;
        int min_width, max_width;
        int min_height, max_height;
+       uint32_t generation;
 };
 
 struct drm_mode_crtc {
@@ -1043,6 +1044,8 @@ struct drm_mode_crtc {
 
        int x, y; /**< Position on the frameuffer */
 
+       uint32_t generation;
+
        int count_connectors;
        unsigned int connectors; /**< Connectors that are connected */
 
@@ -1055,6 +1058,8 @@ struct drm_mode_crtc {
 
 struct drm_mode_get_encoder {
 
+       uint32_t generation;
+
        uint32_t encoder_type;
        uint32_t encoder_id;
 
@@ -1085,6 +1090,8 @@ struct drm_mode_get_connector {
        unsigned int connector_type;
        unsigned int connector_type_id;
 
+       uint32_t generation;
+
        unsigned int connection;
        unsigned int mm_width, mm_height; /**< HxW in millimeters */
        unsigned int subpixel;