drm: switch possible crtc/clones over to encoders
authorDave Airlie <airlied@redhat.com>
Fri, 30 May 2008 05:32:58 +0000 (15:32 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 30 May 2008 05:32:58 +0000 (15:32 +1000)
libdrm/xf86drmMode.c
libdrm/xf86drmMode.h
linux-core/drm_crtc.c
linux-core/drm_crtc.h
linux-core/drm_crtc_helper.c
linux-core/intel_display.c
linux-core/intel_tv.c
shared-core/drm.h

index a18c429..8b7f2bc 100644 (file)
@@ -381,10 +381,6 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id)
        conn.connector = connector_id;
        conn.connector_type_id = 0;
        conn.connector_type  = 0;
-       conn.count_crtcs  = 0;
-       conn.crtcs        = 0;
-       conn.count_clones = 0;
-       conn.clones       = 0;
        conn.count_modes  = 0;
        conn.modes_ptr    = 0;
        conn.count_props  = 0;
@@ -420,12 +416,8 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id)
        r->mmWidth      = conn.mm_width;
        r->mmHeight     = conn.mm_height;
        r->subpixel     = conn.subpixel;
-       r->count_crtcs  = conn.count_crtcs;
-       r->count_clones = conn.count_clones;
        r->count_modes  = conn.count_modes;
        /* TODO we should test if these alloc & cpy fails. */
-       r->crtcs        = conn.crtcs;
-       r->clones       = conn.clones;
        r->count_props  = conn.count_props;
        r->props        = drmAllocCpy(U642VOID(conn.props_ptr), conn.count_props, sizeof(uint32_t));
        r->prop_values  = drmAllocCpy(U642VOID(conn.prop_values_ptr), conn.count_props, sizeof(uint64_t));
index 03268b1..ceaa9ab 100644 (file)
@@ -141,12 +141,6 @@ typedef struct _drmModeConnector {
        uint32_t mmWidth, mmHeight; /**< HxW in millimeters */
        drmModeSubPixel subpixel;
 
-       int count_crtcs;
-       uint32_t crtcs; /**< Possible crtc to connect to */
-
-       int count_clones;
-       uint32_t clones; /**< Mask of clones */
-
        int count_modes;
        struct drm_mode_modeinfo *modes;
 
index c60476a..bf6afd6 100644 (file)
@@ -1148,9 +1148,6 @@ int drm_mode_getconnector(struct drm_device *dev,
        else
                out_resp->crtc = 0;
 
-       out_resp->crtcs = connector->possible_crtcs;
-       out_resp->clones = connector->possible_clones;
-
        if ((out_resp->count_modes >= mode_count) && mode_count) {
                copied = 0;
                mode_ptr = (struct drm_mode_modeinfo *)(unsigned long)out_resp->modes_ptr;
@@ -2201,6 +2198,9 @@ int drm_mode_connector_attach_encoder(struct drm_connector *connector,
        for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
                if (connector->encoder_ids[i] == 0) {
                        connector->encoder_ids[i] = encoder->id;
+                       /* pick the first added encoder as the current */
+                       if (i == 0)
+                               connector->current_encoder_id = encoder->id;
                        return 0;
                }
        }
index 568b6b3..09886c1 100644 (file)
@@ -423,8 +423,6 @@ struct drm_encoder {
 /**
  * drm_connector - central DRM connector control structure
  * @crtc: CRTC this connector is currently connected to, NULL if none
- * @possible_crtcs: bitmap of CRTCS this connector could be attached to
- * @possible_clones: bitmap of possible connectors this connector could clone
  * @interlace_allowed: can this connector handle interlaced modes?
  * @doublescan_allowed: can this connector handle doublescan?
  * @available_modes: modes available on this connector (from get_modes() + user)
@@ -448,8 +446,6 @@ struct drm_connector {
 
        int connector_type;
        int connector_type_id;
-       unsigned long possible_crtcs;
-       unsigned long possible_clones;
        bool interlace_allowed;
        bool doublescan_allowed;
        struct list_head modes; /* list of modes on this connector */
@@ -470,7 +466,9 @@ struct drm_connector {
 
        void *helper_private;
 
-       u32 encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
+       uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
+       uint32_t force_encoder_id;
+       uint32_t current_encoder_id;
 };
 
 /**
index 98b112e..e5774cc 100644 (file)
@@ -46,6 +46,7 @@ static void drm_pick_crtcs (struct drm_device *dev)
 {
        int c, o, assigned;
        struct drm_connector *connector, *connector_equal;
+       struct drm_encoder *encoder, *encoder_equal;
        struct drm_crtc   *crtc;
        struct drm_display_mode *des_mode = NULL, *modes, *modes_equal;
        int found;
@@ -89,12 +90,16 @@ static void drm_pick_crtcs (struct drm_device *dev)
                        }
                }
 
+               list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
+                       if (encoder->id == connector->current_encoder_id)
+                               break;
+
                c = -1;
                list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
                        assigned = 0;
 
                        c++;
-                       if ((connector->possible_crtcs & (1 << c)) == 0)
+                       if ((encoder->possible_crtcs & (1 << c)) == 0)
                                continue;
        
                        list_for_each_entry(connector_equal, &dev->mode_config.connector_list, head) {
@@ -117,11 +122,15 @@ static void drm_pick_crtcs (struct drm_device *dev)
                                if (connector->id == connector_equal->id)
                                        continue;
 
+                               list_for_each_entry(encoder_equal, &dev->mode_config.encoder_list, head)
+                                       if (encoder_equal->id == connector_equal->current_encoder_id)
+                                               break;
+
                                list_for_each_entry(modes, &connector->modes, head) {
                                        list_for_each_entry(modes_equal, &connector_equal->modes, head) {
                                                if (drm_mode_equal (modes, modes_equal)) {
-                                                       if ((connector->possible_clones & connector_equal->possible_clones) && (connector_equal->crtc == crtc)) {
-                                                               printk("Cloning %s (0x%lx) to %s (0x%lx)\n",drm_get_connector_name(connector),connector->possible_clones,drm_get_connector_name(connector_equal),connector_equal->possible_clones);
+                                                       if ((encoder->possible_clones & encoder_equal->possible_clones) && (connector_equal->crtc == crtc)) {
+                                                               printk("Cloning %s (0x%lx) to %s (0x%lx)\n",drm_get_connector_name(connector),encoder->possible_clones,drm_get_connector_name(connector_equal),encoder_equal->possible_clones);
                                                                des_mode = modes;
                                                                assigned = 0;
                                                                goto clone;
index 7fb1ea5..f0cbc38 100644 (file)
@@ -1091,6 +1091,7 @@ struct drm_crtc *intel_get_load_detect_pipe(struct drm_connector *connector,
        struct intel_crtc *intel_crtc;
        struct drm_crtc *possible_crtc;
        struct drm_crtc *supported_crtc =NULL;
+       struct drm_encoder *encoder = NULL;
        struct drm_crtc *crtc = NULL;
        struct drm_connector_helper_funcs *connector_funcs;
        int i = -1;
@@ -1118,10 +1119,14 @@ struct drm_crtc *intel_get_load_detect_pipe(struct drm_connector *connector,
                return crtc;
        }
 
+       list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
+               if (encoder->id == connector->current_encoder_id)
+                       break;
+
        /* Find an unused one (if possible) */
        list_for_each_entry(possible_crtc, &dev->mode_config.crtc_list, head) {
                i++;
-               if (!(connector->possible_crtcs & (1 << i)))
+               if (!(encoder->possible_crtcs & (1 << i)))
                        continue;
                if (!possible_crtc->enabled) {
                        crtc = possible_crtc;
@@ -1395,6 +1400,7 @@ static void intel_setup_outputs(struct drm_device *dev)
 
        list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
                struct intel_output *intel_output = to_intel_output(connector);
+               struct drm_encoder *encoder = &intel_output->enc;
                int crtc_mask = 0, clone_mask = 0;
                
                /* valid crtcs */
@@ -1424,8 +1430,8 @@ static void intel_setup_outputs(struct drm_device *dev)
                        clone_mask = (1 << INTEL_OUTPUT_TVOUT);
                        break;
                }
-               connector->possible_crtcs = crtc_mask;
-               connector->possible_clones = intel_connector_clones(dev, clone_mask);
+               encoder->possible_crtcs = crtc_mask;
+               encoder->possible_clones = intel_connector_clones(dev, clone_mask);
        }
 }
 
index 330c204..c2658f1 100644 (file)
@@ -1614,6 +1614,16 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = {
        .set_property = intel_tv_set_property,
 };
 
+void intel_tv_enc_destroy(struct drm_encoder *encoder)
+{
+       drm_encoder_cleanup(encoder);
+}
+
+static const struct drm_encoder_funcs intel_tv_enc_funcs = {
+       .destroy = intel_tv_enc_destroy,
+};
+
+
 void
 intel_tv_init(struct drm_device *dev)
 {
@@ -1665,10 +1675,13 @@ intel_tv_init(struct drm_device *dev)
        drm_connector_init(dev, connector, &intel_tv_connector_funcs,
                           DRM_MODE_CONNECTOR_Unknown);
 
+       drm_encoder_init(dev, &intel_output->enc, &intel_tv_enc_funcs,
+                        DRM_MODE_ENCODER_TVDAC);
+
        tv_priv = (struct intel_tv_priv *)(intel_output + 1);
        intel_output->type = INTEL_OUTPUT_TVOUT;
-       connector->possible_crtcs = ((1 << 0) | (1 << 1));
-       connector->possible_clones = (1 << INTEL_OUTPUT_TVOUT);
+       intel_output->enc.possible_crtcs = ((1 << 0) | (1 << 1));
+       intel_output->enc.possible_clones = (1 << INTEL_OUTPUT_TVOUT);
        intel_output->dev_priv = tv_priv;
        tv_priv->type = DRM_MODE_CONNECTOR_Unknown;
 
index a7f590d..1fcbf14 100644 (file)
@@ -1087,10 +1087,6 @@ struct drm_mode_get_connector {
        unsigned int connection;
        unsigned int mm_width, mm_height; /**< HxW in millimeters */
        unsigned int subpixel;
-       int count_crtcs;
-       int count_clones;
-       unsigned int crtcs; /**< possible crtc to connect to */
-       unsigned int clones; /**< list of clones */
 };
 
 #define DRM_MODE_PROP_PENDING (1<<0)