From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> Standard connector properties are kept in the mode_config structure. Move the CRTC and plane properties there as well. Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> --- drivers/gpu/drm/i915/intel_atomic.c | 293 +++++++++++++++++++---------------- include/drm/drm_crtc.h | 19 +++ 2 files changed, 175 insertions(+), 137 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c index 0e37cf5..0def947 100644 --- a/drivers/gpu/drm/i915/intel_atomic.c +++ b/drivers/gpu/drm/i915/intel_atomic.c @@ -30,24 +30,6 @@ #include "intel_drv.h" -static struct drm_property *prop_src_x; -static struct drm_property *prop_src_y; -static struct drm_property *prop_src_w; -static struct drm_property *prop_src_h; -static struct drm_property *prop_crtc_x; -static struct drm_property *prop_crtc_y; -static struct drm_property *prop_crtc_w; -static struct drm_property *prop_crtc_h; -static struct drm_property *prop_fb_id; -static struct drm_property *prop_crtc_id; -static struct drm_property *prop_mode; -static struct drm_property *prop_connector_ids; -static struct drm_property *prop_cursor_id; -static struct drm_property *prop_cursor_x; -static struct drm_property *prop_cursor_y; -static struct drm_property *prop_cursor_w; -static struct drm_property *prop_cursor_h; - struct intel_flip { struct drm_flip base; u32 vbl_count; @@ -368,27 +350,28 @@ static int plane_set(struct intel_atomic_state *s, uint64_t value) { struct drm_plane *plane = state->plane; + struct drm_mode_config *config = &plane->dev->mode_config; struct drm_mode_object *obj; state->changed = true; - if (prop == prop_src_x) { + if (prop == config->src_x_prop) { plane->src_x = value; - } else if (prop == prop_src_y) { + } else if (prop == config->src_y_prop) { plane->src_y = value; - } else if (prop == prop_src_w) { + } else if (prop == config->src_w_prop) { plane->src_w = value; - } else if (prop == prop_src_h) { + } else if (prop == config->src_h_prop) { plane->src_h = value; - } else if (prop == prop_crtc_x) { + } else if (prop == config->crtc_x_prop) { plane->crtc_x = value; - } else if (prop == prop_crtc_y) { + } else if (prop == config->crtc_y_prop) { plane->crtc_y = value; - } else if (prop == prop_crtc_w) { + } else if (prop == config->crtc_w_prop) { plane->crtc_w = value; - } else if (prop == prop_crtc_h) { + } else if (prop == config->crtc_h_prop) { plane->crtc_h = value; - } else if (prop == prop_crtc_id) { + } else if (prop == config->crtc_id_prop) { if (value) { obj = drm_mode_object_find(plane->dev, value, DRM_MODE_OBJECT_CRTC); if (!obj) { @@ -398,7 +381,7 @@ static int plane_set(struct intel_atomic_state *s, plane->crtc = obj_to_crtc(obj); } else plane->crtc = NULL; - } else if (prop == prop_fb_id) { + } else if (prop == config->fb_id_prop) { if (value) { obj = drm_mode_object_find(plane->dev, value, DRM_MODE_OBJECT_FB); if (!obj) { @@ -422,16 +405,17 @@ static int crtc_set(struct intel_atomic_state *s, uint64_t value, const void *blob_data) { struct drm_crtc *crtc = state->crtc; + struct drm_mode_config *config = &crtc->dev->mode_config; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct drm_mode_object *obj; state->changed = true; - if (prop == prop_src_x) { + if (prop == config->src_x_prop) { crtc->x = value; - } else if (prop == prop_src_y) { + } else if (prop == config->src_y_prop) { crtc->y = value; - } else if (prop == prop_mode) { + } else if (prop == config->mode_prop) { const struct drm_mode_modeinfo *umode = blob_data; if (value != 0 && value != sizeof *umode) { @@ -462,7 +446,7 @@ static int crtc_set(struct intel_atomic_state *s, drm_mode_destroy(crtc->dev, mode); } else crtc->enabled = false; - } else if (prop == prop_fb_id) { + } else if (prop == config->fb_id_prop) { if (value) { obj = drm_mode_object_find(crtc->dev, value, DRM_MODE_OBJECT_FB); if (!obj) { @@ -472,7 +456,7 @@ static int crtc_set(struct intel_atomic_state *s, crtc->fb = obj_to_fb(obj); } else crtc->fb = NULL; - } else if (prop == prop_connector_ids) { + } else if (prop == config->connector_ids_prop) { const uint32_t *ids = blob_data; uint64_t count_ids = value / sizeof(uint32_t); int ret; @@ -482,7 +466,7 @@ static int crtc_set(struct intel_atomic_state *s, return -EINVAL; } - if (count_ids > crtc->dev->mode_config.num_connector) { + if (count_ids > config->num_connector) { DRM_DEBUG_KMS("Too many connectors specified\n"); return -ERANGE; } @@ -490,19 +474,19 @@ static int crtc_set(struct intel_atomic_state *s, ret = process_connectors(state, ids, count_ids); if (ret) return ret; - } else if (prop == prop_cursor_id) { + } else if (prop == config->cursor_id_prop) { intel_crtc->cursor_handle = value; - } else if (prop == prop_cursor_x) { + } else if (prop == config->cursor_x_prop) { intel_crtc->cursor_x = value; - } else if (prop == prop_cursor_y) { + } else if (prop == config->cursor_y_prop) { intel_crtc->cursor_y = value; - } else if (prop == prop_cursor_w) { + } else if (prop == config->cursor_w_prop) { if (value != 0 && value != 64) { DRM_DEBUG_KMS("only 64x64 cursor sprites are supported\n"); return -EINVAL; } intel_crtc->cursor_width = value; - } else if (prop == prop_cursor_h) { + } else if (prop == config->cursor_h_prop) { if (value != 0 && value != 64) { DRM_DEBUG_KMS("only 64x64 cursor sprites are supported\n"); return -EINVAL; @@ -2297,13 +2281,13 @@ void intel_atomic_clear_flips(struct drm_crtc *crtc) static void drm_crtc_update_connector_ids_property(struct drm_crtc *crtc) { - struct drm_device *dev = crtc->dev; + struct drm_mode_config *config = &crtc->dev->mode_config; struct drm_connector *connector; uint64_t value = 0; int i = 0; - uint32_t connector_ids[dev->mode_config.num_connector]; + uint32_t connector_ids[config->num_connector]; - list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + list_for_each_entry(connector, &config->connector_list, head) { if (connector->encoder && connector->encoder->crtc == crtc) connector_ids[i++] = connector->base.id; } @@ -2315,11 +2299,12 @@ static void drm_crtc_update_connector_ids_property(struct drm_crtc *crtc) } else drm_property_blob_replace_data(crtc->connector_ids_blob, 0, NULL); - drm_object_property_set_value(&crtc->base, prop_connector_ids, value); + drm_object_property_set_value(&crtc->base, config->connector_ids_prop, value); } static void drm_crtc_update_mode_property(struct drm_crtc *crtc) { + struct drm_mode_config *config = &crtc->dev->mode_config; uint64_t value = 0; if (crtc->enabled) { @@ -2331,16 +2316,17 @@ static void drm_crtc_update_mode_property(struct drm_crtc *crtc) } else drm_property_blob_replace_data(crtc->mode_blob, 0, NULL); - drm_object_property_set_value(&crtc->base, prop_mode, value); + drm_object_property_set_value(&crtc->base, config->mode_prop, value); } void drm_crtc_update_properties(struct drm_crtc *crtc) { struct drm_mode_object *obj = &crtc->base; + struct drm_mode_config *config = &crtc->dev->mode_config; - drm_object_property_set_value(obj, prop_src_x, crtc->x); - drm_object_property_set_value(obj, prop_src_y, crtc->y); - drm_object_property_set_value(obj, prop_fb_id, crtc->fb ? crtc->fb->base.id : 0); + drm_object_property_set_value(obj, config->src_x_prop, crtc->x); + drm_object_property_set_value(obj, config->src_y_prop, crtc->y); + drm_object_property_set_value(obj, config->fb_id_prop, crtc->fb ? crtc->fb->base.id : 0); drm_crtc_update_mode_property(crtc); drm_crtc_update_connector_ids_property(crtc); @@ -2349,33 +2335,35 @@ void drm_crtc_update_properties(struct drm_crtc *crtc) void intel_crtc_update_properties(struct drm_crtc *crtc) { struct drm_mode_object *obj = &crtc->base; + struct drm_mode_config *config = &crtc->dev->mode_config; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); drm_crtc_update_properties(crtc); - drm_object_property_set_value(obj, prop_cursor_id, intel_crtc->cursor_handle); - drm_object_property_set_value(obj, prop_cursor_x, intel_crtc->cursor_x); - drm_object_property_set_value(obj, prop_cursor_y, intel_crtc->cursor_y); - drm_object_property_set_value(obj, prop_cursor_w, intel_crtc->cursor_width); - drm_object_property_set_value(obj, prop_cursor_h, intel_crtc->cursor_height); + drm_object_property_set_value(obj, config->cursor_id_prop, intel_crtc->cursor_handle); + drm_object_property_set_value(obj, config->cursor_x_prop, intel_crtc->cursor_x); + drm_object_property_set_value(obj, config->cursor_y_prop, intel_crtc->cursor_y); + drm_object_property_set_value(obj, config->cursor_w_prop, intel_crtc->cursor_width); + drm_object_property_set_value(obj, config->cursor_h_prop, intel_crtc->cursor_height); } void drm_plane_update_properties(struct drm_plane *plane) { struct drm_mode_object *obj = &plane->base; + struct drm_mode_config *config = &plane->dev->mode_config; - drm_object_property_set_value(obj, prop_src_x, plane->src_x); - drm_object_property_set_value(obj, prop_src_y, plane->src_y); - drm_object_property_set_value(obj, prop_src_w, plane->src_w); - drm_object_property_set_value(obj, prop_src_h, plane->src_h); + drm_object_property_set_value(obj, config->src_x_prop, plane->src_x); + drm_object_property_set_value(obj, config->src_y_prop, plane->src_y); + drm_object_property_set_value(obj, config->src_w_prop, plane->src_w); + drm_object_property_set_value(obj, config->src_h_prop, plane->src_h); - drm_object_property_set_value(obj, prop_crtc_x, plane->crtc_x); - drm_object_property_set_value(obj, prop_crtc_y, plane->crtc_y); - drm_object_property_set_value(obj, prop_crtc_w, plane->crtc_w); - drm_object_property_set_value(obj, prop_crtc_h, plane->crtc_h); + drm_object_property_set_value(obj, config->crtc_x_prop, plane->crtc_x); + drm_object_property_set_value(obj, config->crtc_y_prop, plane->crtc_y); + drm_object_property_set_value(obj, config->crtc_w_prop, plane->crtc_w); + drm_object_property_set_value(obj, config->crtc_h_prop, plane->crtc_h); - drm_object_property_set_value(obj, prop_fb_id, plane->fb ? plane->fb->base.id : 0); - drm_object_property_set_value(obj, prop_crtc_id, plane->crtc ? plane->crtc->base.id : 0); + drm_object_property_set_value(obj, config->fb_id_prop, plane->fb ? plane->fb->base.id : 0); + drm_object_property_set_value(obj, config->crtc_id_prop, plane->crtc ? plane->crtc->base.id : 0); } int drm_crtc_create_blobs(struct drm_crtc *crtc) @@ -2401,77 +2389,105 @@ void drm_crtc_destroy_blobs(struct drm_crtc *crtc) drm_property_destroy_blob(dev, crtc->connector_ids_blob); } +void drm_property_destroy_null(struct drm_device *dev, struct drm_property **prop) +{ + drm_property_destroy(dev, *prop); + *prop = NULL; +} + void drm_mode_destroy_properties(struct drm_device *dev) { - drm_property_destroy(dev, prop_connector_ids); - drm_property_destroy(dev, prop_mode); - drm_property_destroy(dev, prop_crtc_id); - drm_property_destroy(dev, prop_fb_id); - - drm_property_destroy(dev, prop_crtc_h); - drm_property_destroy(dev, prop_crtc_w); - drm_property_destroy(dev, prop_crtc_y); - drm_property_destroy(dev, prop_crtc_x); - - drm_property_destroy(dev, prop_src_h); - drm_property_destroy(dev, prop_src_w); - drm_property_destroy(dev, prop_src_y); - drm_property_destroy(dev, prop_src_x); + struct drm_mode_config *config = &dev->mode_config; + + drm_property_destroy_null(dev, &config->cursor_h_prop); + drm_property_destroy_null(dev, &config->cursor_w_prop); + drm_property_destroy_null(dev, &config->cursor_y_prop); + drm_property_destroy_null(dev, &config->cursor_x_prop); + drm_property_destroy_null(dev, &config->cursor_id_prop); + + drm_property_destroy_null(dev, &config->connector_ids_prop); + drm_property_destroy_null(dev, &config->mode_prop); + + drm_property_destroy_null(dev, &config->crtc_id_prop); + drm_property_destroy_null(dev, &config->fb_id_prop); + + drm_property_destroy_null(dev, &config->crtc_h_prop); + drm_property_destroy_null(dev, &config->crtc_w_prop); + drm_property_destroy_null(dev, &config->crtc_y_prop); + drm_property_destroy_null(dev, &config->crtc_x_prop); + + drm_property_destroy_null(dev, &config->src_h_prop); + drm_property_destroy_null(dev, &config->src_w_prop); + drm_property_destroy_null(dev, &config->src_y_prop); + drm_property_destroy_null(dev, &config->src_x_prop); } -static struct { - struct drm_property **prop; - const char *name; - uint64_t min; - uint64_t max; -} props[] = { - { &prop_src_x, "SRC_X", 0, UINT_MAX }, - { &prop_src_y, "SRC_Y", 0, UINT_MAX }, - { &prop_src_w, "SRC_W", 0, UINT_MAX }, - { &prop_src_h, "SRC_H", 0, UINT_MAX }, - - { &prop_crtc_x, "CRTC_X", INT_MIN, INT_MAX }, - { &prop_crtc_y, "CRTC_Y", INT_MIN, INT_MAX }, - { &prop_crtc_w, "CRTC_W", 0, INT_MAX }, - { &prop_crtc_h, "CRTC_H", 0, INT_MAX }, - - { &prop_fb_id, "FB_ID", 0, UINT_MAX }, - { &prop_crtc_id, "CRTC_ID", 0, UINT_MAX }, - - { &prop_cursor_id, "CURSOR_ID", 0, UINT_MAX }, - { &prop_cursor_w, "CURSOR_W", 0, UINT_MAX }, - { &prop_cursor_h, "CURSOR_H", 0, UINT_MAX }, - { &prop_cursor_x, "CURSOR_X", INT_MIN, INT_MAX }, - { &prop_cursor_y, "CURSOR_Y", INT_MIN, INT_MAX }, -}; - int drm_mode_create_properties(struct drm_device *dev) { - int i; + struct drm_mode_config *config = &dev->mode_config; - for (i = 0; i < ARRAY_SIZE(props); i++) { - *props[i].prop = drm_property_create_range(dev, 0, props[i].name, props[i].min, props[i].max); - if (!*props[i].prop) - goto out; - } + config->src_x_prop = drm_property_create_range(dev, 0, "SRC_X", 0, UINT_MAX); + if (!config->src_x_prop) + goto out; + config->src_y_prop = drm_property_create_range(dev, 0, "SRC_Y", 0, UINT_MAX); + if (!config->src_y_prop) + goto out; + config->src_w_prop = drm_property_create_range(dev, 0, "SRC_W", 0, UINT_MAX); + if (!config->src_w_prop) + goto out; + config->src_h_prop = drm_property_create_range(dev, 0, "SRC_H", 0, UINT_MAX); + if (!config->src_h_prop) + goto out; + + config->crtc_x_prop = drm_property_create_range(dev, 0, "CRTC_X", INT_MIN, INT_MAX); + if (!config->crtc_x_prop) + goto out; + config->crtc_y_prop = drm_property_create_range(dev, 0, "CRTC_Y", INT_MIN, INT_MAX); + if (!config->crtc_y_prop) + goto out; + config->crtc_w_prop = drm_property_create_range(dev, 0, "CRTC_W", 0, UINT_MAX); + if (!config->crtc_w_prop) + goto out; + config->crtc_h_prop = drm_property_create_range(dev, 0, "CRTC_H", 0, UINT_MAX); + if (!config->crtc_h_prop) + goto out; + + config->fb_id_prop = drm_property_create_range(dev, 0, "FB_ID", 0, UINT_MAX); + if (!config->fb_id_prop) + goto out; + config->crtc_id_prop = drm_property_create_range(dev, 0, "CRTC_ID", 0, UINT_MAX); + if (!config->crtc_id_prop) + goto out; + + config->cursor_id_prop = drm_property_create_range(dev, 0, "CURSOR_ID", 0, UINT_MAX); + if (!config->cursor_id_prop) + goto out; + config->cursor_x_prop = drm_property_create_range(dev, 0, "CURSOR_X", INT_MIN, INT_MAX); + if (!config->cursor_x_prop) + goto out; + config->cursor_y_prop = drm_property_create_range(dev, 0, "CURSOR_Y", INT_MIN, INT_MAX); + if (!config->cursor_y_prop) + goto out; + config->cursor_w_prop = drm_property_create_range(dev, 0, "CURSOR_W", 0, UINT_MAX); + if (!config->cursor_w_prop) + goto out; + config->cursor_h_prop = drm_property_create_range(dev, 0, "CURSOR_H", 0, UINT_MAX); + if (!config->cursor_h_prop) + goto out; /* FIXME create special object ID list property type? */ - prop_connector_ids = drm_property_create(dev, DRM_MODE_PROP_BLOB, "CONNECTOR_IDS", 0); - if (!prop_connector_ids) + config->connector_ids_prop = drm_property_create(dev, DRM_MODE_PROP_BLOB, "CONNECTOR_IDS", 0); + if (!config->connector_ids_prop) goto out; - prop_mode = drm_property_create(dev, DRM_MODE_PROP_BLOB, "MODE", 0); - if (!prop_mode) + config->mode_prop = drm_property_create(dev, DRM_MODE_PROP_BLOB, "MODE", 0); + if (!config->mode_prop) goto out; return 0; out: - drm_property_destroy(dev, prop_mode); - drm_property_destroy(dev, prop_connector_ids); - - while (i--) - drm_property_destroy(dev, *props[i].prop); + drm_mode_destroy_properties(dev); return -ENOMEM; /* FIXME? */ } @@ -2479,39 +2495,42 @@ int drm_mode_create_properties(struct drm_device *dev) void drm_plane_attach_properties(struct drm_plane *plane) { struct drm_mode_object *obj = &plane->base; + struct drm_mode_config *config = &plane->dev->mode_config; - drm_object_attach_property(obj, prop_src_x, 0); - drm_object_attach_property(obj, prop_src_y, 0); - drm_object_attach_property(obj, prop_src_w, 0); - drm_object_attach_property(obj, prop_src_h, 0); - drm_object_attach_property(obj, prop_crtc_x, 0); - drm_object_attach_property(obj, prop_crtc_y, 0); - drm_object_attach_property(obj, prop_crtc_w, 0); - drm_object_attach_property(obj, prop_crtc_h, 0); - drm_object_attach_property(obj, prop_fb_id, 0); - drm_object_attach_property(obj, prop_crtc_id, 0); + drm_object_attach_property(obj, config->src_x_prop, 0); + drm_object_attach_property(obj, config->src_y_prop, 0); + drm_object_attach_property(obj, config->src_w_prop, 0); + drm_object_attach_property(obj, config->src_h_prop, 0); + drm_object_attach_property(obj, config->crtc_x_prop, 0); + drm_object_attach_property(obj, config->crtc_y_prop, 0); + drm_object_attach_property(obj, config->crtc_w_prop, 0); + drm_object_attach_property(obj, config->crtc_h_prop, 0); + drm_object_attach_property(obj, config->fb_id_prop, 0); + drm_object_attach_property(obj, config->crtc_id_prop, 0); } void drm_crtc_attach_properties(struct drm_crtc *crtc) { struct drm_mode_object *obj = &crtc->base; + struct drm_mode_config *config = &crtc->dev->mode_config; - drm_object_attach_property(obj, prop_src_x, 0); - drm_object_attach_property(obj, prop_src_y, 0); - drm_object_attach_property(obj, prop_fb_id, 0); - drm_object_attach_property(obj, prop_mode, 0); - drm_object_attach_property(obj, prop_connector_ids, 0); + drm_object_attach_property(obj, config->src_x_prop, 0); + drm_object_attach_property(obj, config->src_y_prop, 0); + drm_object_attach_property(obj, config->fb_id_prop, 0); + drm_object_attach_property(obj, config->mode_prop, 0); + drm_object_attach_property(obj, config->connector_ids_prop, 0); } void intel_crtc_attach_properties(struct drm_crtc *crtc) { struct drm_mode_object *obj = &crtc->base; + struct drm_mode_config *config = &crtc->dev->mode_config; drm_crtc_attach_properties(crtc); - drm_object_attach_property(obj, prop_cursor_id, 0); - drm_object_attach_property(obj, prop_cursor_x, 0); - drm_object_attach_property(obj, prop_cursor_y, 0); - drm_object_attach_property(obj, prop_cursor_w, 0); - drm_object_attach_property(obj, prop_cursor_h, 0); + drm_object_attach_property(obj, config->cursor_id_prop, 0); + drm_object_attach_property(obj, config->cursor_x_prop, 0); + drm_object_attach_property(obj, config->cursor_y_prop, 0); + drm_object_attach_property(obj, config->cursor_w_prop, 0); + drm_object_attach_property(obj, config->cursor_h_prop, 0); } diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 74fb5a8..c8cea87 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -835,6 +835,25 @@ struct drm_mode_config { struct drm_property *dithering_mode_property; struct drm_property *dirty_info_property; + /* CRTC/plane properties */ + struct drm_property *src_x_prop; + struct drm_property *src_y_prop; + struct drm_property *src_w_prop; + struct drm_property *src_h_prop; + struct drm_property *crtc_x_prop; + struct drm_property *crtc_y_prop; + struct drm_property *crtc_w_prop; + struct drm_property *crtc_h_prop; + struct drm_property *fb_id_prop; + struct drm_property *crtc_id_prop; + struct drm_property *mode_prop; + struct drm_property *connector_ids_prop; + struct drm_property *cursor_id_prop; + struct drm_property *cursor_x_prop; + struct drm_property *cursor_y_prop; + struct drm_property *cursor_w_prop; + struct drm_property *cursor_h_prop; + /* dumb ioctl parameters */ uint32_t preferred_depth, prefer_shadow; }; -- 1.7.8.6 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel