aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2015-05-25 14:11:52 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-05-26 09:50:42 -0400
commit955f3c334f0fb2b843efad5cc6d3b7e141e9d666 (patch)
treea5950f3239adb485d3d1129b66d4419f0d324843
parent99cf4a29fa24461bbfe22125967188a18383eb5c (diff)
drm/atomic: Add MODE_ID property
Atomic modesetting: now with modesetting support. v2: Moved drm_atomic_set_mode_prop_for_crtc from previous patch; removed state->active fiddling, documented return code. Changed property type to DRM_MODE_PROP_BLOB. Signed-off-by: Daniel Stone <daniels@collabora.com> Tested-by: Sean Paul <seanpaul@chromium.org> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/drm_atomic.c57
-rw-r--r--drivers/gpu/drm/drm_crtc.c8
-rw-r--r--include/drm/drm_atomic.h3
-rw-r--r--include/drm/drm_crtc.h1
4 files changed, 68 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 327ccc71012f..c7e59b074e62 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -339,6 +339,51 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
339EXPORT_SYMBOL(drm_atomic_set_mode_for_crtc); 339EXPORT_SYMBOL(drm_atomic_set_mode_for_crtc);
340 340
341/** 341/**
342 * drm_atomic_set_mode_prop_for_crtc - set mode for CRTC
343 * @state: the CRTC whose incoming state to update
344 * @blob: pointer to blob property to use for mode
345 *
346 * Set a mode (originating from a blob property) on the desired CRTC state.
347 * This function will take a reference on the blob property for the CRTC state,
348 * and release the reference held on the state's existing mode property, if any
349 * was set.
350 *
351 * RETURNS:
352 * Zero on success, error code on failure. Cannot return -EDEADLK.
353 */
354int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,
355 struct drm_property_blob *blob)
356{
357 if (blob == state->mode_blob)
358 return 0;
359
360 if (state->mode_blob)
361 drm_property_unreference_blob(state->mode_blob);
362 state->mode_blob = NULL;
363
364 if (blob) {
365 if (blob->length != sizeof(struct drm_mode_modeinfo) ||
366 drm_mode_convert_umode(&state->mode,
367 (const struct drm_mode_modeinfo *)
368 blob->data))
369 return -EINVAL;
370
371 state->mode_blob = drm_property_reference_blob(blob);
372 state->enable = true;
373 DRM_DEBUG_ATOMIC("Set [MODE:%s] for CRTC state %p\n",
374 state->mode.name, state);
375 } else {
376 memset(&state->mode, 0, sizeof(state->mode));
377 state->enable = false;
378 DRM_DEBUG_ATOMIC("Set [NOMODE] for CRTC state %p\n",
379 state);
380 }
381
382 return 0;
383}
384EXPORT_SYMBOL(drm_atomic_set_mode_prop_for_crtc);
385
386/**
342 * drm_atomic_crtc_set_property - set property on CRTC 387 * drm_atomic_crtc_set_property - set property on CRTC
343 * @crtc: the drm CRTC to set a property on 388 * @crtc: the drm CRTC to set a property on
344 * @state: the state object to update with the new property value 389 * @state: the state object to update with the new property value
@@ -360,10 +405,18 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
360{ 405{
361 struct drm_device *dev = crtc->dev; 406 struct drm_device *dev = crtc->dev;
362 struct drm_mode_config *config = &dev->mode_config; 407 struct drm_mode_config *config = &dev->mode_config;
408 int ret;
363 409
364 /* FIXME: Mode prop is missing, which also controls ->enable. */
365 if (property == config->prop_active) 410 if (property == config->prop_active)
366 state->active = val; 411 state->active = val;
412 else if (property == config->prop_mode_id) {
413 struct drm_property_blob *mode =
414 drm_property_lookup_blob(dev, val);
415 ret = drm_atomic_set_mode_prop_for_crtc(state, mode);
416 if (mode)
417 drm_property_unreference_blob(mode);
418 return ret;
419 }
367 else if (crtc->funcs->atomic_set_property) 420 else if (crtc->funcs->atomic_set_property)
368 return crtc->funcs->atomic_set_property(crtc, state, property, val); 421 return crtc->funcs->atomic_set_property(crtc, state, property, val);
369 else 422 else
@@ -388,6 +441,8 @@ int drm_atomic_crtc_get_property(struct drm_crtc *crtc,
388 441
389 if (property == config->prop_active) 442 if (property == config->prop_active)
390 *val = state->active; 443 *val = state->active;
444 else if (property == config->prop_mode_id)
445 *val = (state->mode_blob) ? state->mode_blob->base.id : 0;
391 else if (crtc->funcs->atomic_get_property) 446 else if (crtc->funcs->atomic_get_property)
392 return crtc->funcs->atomic_get_property(crtc, state, property, val); 447 return crtc->funcs->atomic_get_property(crtc, state, property, val);
393 else 448 else
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 098c94e53fdf..77f87b23a6e7 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -688,6 +688,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
688 688
689 if (drm_core_check_feature(dev, DRIVER_ATOMIC)) { 689 if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
690 drm_object_attach_property(&crtc->base, config->prop_active, 0); 690 drm_object_attach_property(&crtc->base, config->prop_active, 0);
691 drm_object_attach_property(&crtc->base, config->prop_mode_id, 0);
691 } 692 }
692 693
693 return 0; 694 return 0;
@@ -1454,6 +1455,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
1454 return -ENOMEM; 1455 return -ENOMEM;
1455 dev->mode_config.prop_active = prop; 1456 dev->mode_config.prop_active = prop;
1456 1457
1458 prop = drm_property_create(dev,
1459 DRM_MODE_PROP_ATOMIC | DRM_MODE_PROP_BLOB,
1460 "MODE_ID", 0);
1461 if (!prop)
1462 return -ENOMEM;
1463 dev->mode_config.prop_mode_id = prop;
1464
1457 return 0; 1465 return 0;
1458} 1466}
1459 1467
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 1e8c61f23294..55f46049e4a0 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -113,6 +113,9 @@ int __must_check
113drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, 113drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
114 struct drm_display_mode *mode); 114 struct drm_display_mode *mode);
115int __must_check 115int __must_check
116drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,
117 struct drm_property_blob *blob);
118int __must_check
116drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state, 119drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
117 struct drm_crtc *crtc); 120 struct drm_crtc *crtc);
118void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state, 121void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index c54fa4add792..3b4d8a4a23fb 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1146,6 +1146,7 @@ struct drm_mode_config {
1146 struct drm_property *prop_fb_id; 1146 struct drm_property *prop_fb_id;
1147 struct drm_property *prop_crtc_id; 1147 struct drm_property *prop_crtc_id;
1148 struct drm_property *prop_active; 1148 struct drm_property *prop_active;
1149 struct drm_property *prop_mode_id;
1149 1150
1150 /* DVI-I properties */ 1151 /* DVI-I properties */
1151 struct drm_property *dvi_i_subconnector_property; 1152 struct drm_property *dvi_i_subconnector_property;