aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSinclair Yeh <syeh@vmware.com>2017-03-23 14:33:39 -0400
committerSinclair Yeh <syeh@vmware.com>2017-03-31 12:13:08 -0400
commit9c2542a41f559452d570b96239a81038c49becfc (patch)
treed3f26c0c4579a8269cb7dbe43e13a7a18c1e19d2
parent36cc79bc9077319c04bd3b132edcacaa9a0d9f2b (diff)
drm/vmwgfx: CRTC atomic state
Create and Add CRTC state. We currently do not track any properties or custom states so we can technically use the DRM helpers. Creating this code just to make potential future additions easier. Most of the new code will be compiled but not enabled until plane/connector state handling code is also in place. This is the first of a series to enable atomic mode set for vmwgfx. The atomic enabling effort was done in collaboration with Thomas Hellstrom and the VMware Graphics Team. Signed-off-by: Sinclair Yeh <syeh@vmware.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c81
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.h23
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c10
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c10
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c10
5 files changed, 131 insertions, 3 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index c9f5ddabfb72..18bd8dc46507 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -26,6 +26,8 @@
26 **************************************************************************/ 26 **************************************************************************/
27 27
28#include "vmwgfx_kms.h" 28#include "vmwgfx_kms.h"
29#include <drm/drm_atomic.h>
30#include <drm/drm_atomic_helper.h>
29 31
30 32
31/* Might need a hrtimer here? */ 33/* Might need a hrtimer here? */
@@ -388,6 +390,84 @@ void vmw_du_primary_plane_destroy(struct drm_plane *plane)
388} 390}
389 391
390 392
393/**
394 * vmw_du_crtc_duplicate_state - duplicate crtc state
395 * @crtc: DRM crtc
396 *
397 * Allocates and returns a copy of the crtc state (both common and
398 * vmw-specific) for the specified crtc.
399 *
400 * Returns: The newly allocated crtc state, or NULL on failure.
401 */
402struct drm_crtc_state *
403vmw_du_crtc_duplicate_state(struct drm_crtc *crtc)
404{
405 struct drm_crtc_state *state;
406 struct vmw_crtc_state *vcs;
407
408 if (WARN_ON(!crtc->state))
409 return NULL;
410
411 vcs = kmemdup(crtc->state, sizeof(*vcs), GFP_KERNEL);
412
413 if (!vcs)
414 return NULL;
415
416 state = &vcs->base;
417
418 __drm_atomic_helper_crtc_duplicate_state(crtc, state);
419
420 return state;
421}
422
423
424/**
425 * vmw_du_crtc_reset - creates a blank vmw crtc state
426 * @crtc: DRM crtc
427 *
428 * Resets the atomic state for @crtc by freeing the state pointer (which
429 * might be NULL, e.g. at driver load time) and allocating a new empty state
430 * object.
431 */
432void vmw_du_crtc_reset(struct drm_crtc *crtc)
433{
434 struct vmw_crtc_state *vcs;
435
436
437 if (crtc->state) {
438 __drm_atomic_helper_crtc_destroy_state(crtc->state);
439
440 kfree(vmw_crtc_state_to_vcs(crtc->state));
441 }
442
443 vcs = kzalloc(sizeof(*vcs), GFP_KERNEL);
444
445 if (!vcs) {
446 DRM_ERROR("Cannot allocate vmw_crtc_state\n");
447 return;
448 }
449
450 crtc->state = &vcs->base;
451 crtc->state->crtc = crtc;
452}
453
454
455/**
456 * vmw_du_crtc_destroy_state - destroy crtc state
457 * @crtc: DRM crtc
458 * @state: state object to destroy
459 *
460 * Destroys the crtc state (both common and vmw-specific) for the
461 * specified plane.
462 */
463void
464vmw_du_crtc_destroy_state(struct drm_crtc *crtc,
465 struct drm_crtc_state *state)
466{
467 drm_atomic_helper_crtc_destroy_state(crtc, state);
468}
469
470
391/* 471/*
392 * Generic framebuffer code 472 * Generic framebuffer code
393 */ 473 */
@@ -1600,6 +1680,7 @@ int vmw_du_connector_set_property(struct drm_connector *connector,
1600} 1680}
1601 1681
1602 1682
1683
1603int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data, 1684int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
1604 struct drm_file *file_priv) 1685 struct drm_file *file_priv)
1605{ 1686{
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
index e400bfb26167..370f75c95f56 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
@@ -139,6 +139,19 @@ static const uint32_t vmw_cursor_plane_formats[] = {
139 DRM_FORMAT_ARGB8888, 139 DRM_FORMAT_ARGB8888,
140}; 140};
141 141
142
143#define vmw_crtc_state_to_vcs(x) container_of(x, struct vmw_crtc_state, base)
144
145
146/**
147 * Derived class for crtc state object
148 *
149 * @base DRM crtc object
150 */
151struct vmw_crtc_state {
152 struct drm_crtc_state base;
153};
154
142/** 155/**
143 * Base class display unit. 156 * Base class display unit.
144 * 157 *
@@ -205,6 +218,9 @@ int vmw_du_crtc_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
205 uint32_t handle, uint32_t width, uint32_t height, 218 uint32_t handle, uint32_t width, uint32_t height,
206 int32_t hot_x, int32_t hot_y); 219 int32_t hot_x, int32_t hot_y);
207int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y); 220int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
221int vmw_du_connector_set_property(struct drm_connector *connector,
222 struct drm_property *property,
223 uint64_t val);
208int vmw_du_connector_dpms(struct drm_connector *connector, int mode); 224int vmw_du_connector_dpms(struct drm_connector *connector, int mode);
209void vmw_du_connector_save(struct drm_connector *connector); 225void vmw_du_connector_save(struct drm_connector *connector);
210void vmw_du_connector_restore(struct drm_connector *connector); 226void vmw_du_connector_restore(struct drm_connector *connector);
@@ -212,9 +228,6 @@ enum drm_connector_status
212vmw_du_connector_detect(struct drm_connector *connector, bool force); 228vmw_du_connector_detect(struct drm_connector *connector, bool force);
213int vmw_du_connector_fill_modes(struct drm_connector *connector, 229int vmw_du_connector_fill_modes(struct drm_connector *connector,
214 uint32_t max_width, uint32_t max_height); 230 uint32_t max_width, uint32_t max_height);
215int vmw_du_connector_set_property(struct drm_connector *connector,
216 struct drm_property *property,
217 uint64_t val);
218int vmw_kms_helper_dirty(struct vmw_private *dev_priv, 231int vmw_kms_helper_dirty(struct vmw_private *dev_priv,
219 struct vmw_framebuffer *framebuffer, 232 struct vmw_framebuffer *framebuffer,
220 const struct drm_clip_rect *clips, 233 const struct drm_clip_rect *clips,
@@ -285,6 +298,10 @@ int vmw_du_cursor_plane_update(struct drm_plane *plane,
285 uint32_t src_x, uint32_t src_y, 298 uint32_t src_x, uint32_t src_y,
286 uint32_t src_w, uint32_t src_h); 299 uint32_t src_w, uint32_t src_h);
287 300
301void vmw_du_crtc_reset(struct drm_crtc *crtc);
302struct drm_crtc_state *vmw_du_crtc_duplicate_state(struct drm_crtc *crtc);
303void vmw_du_crtc_destroy_state(struct drm_crtc *crtc,
304 struct drm_crtc_state *state);
288 305
289/* 306/*
290 * Legacy display unit functions - vmwgfx_ldu.c 307 * Legacy display unit functions - vmwgfx_ldu.c
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 3efcbe514472..3ee33f0234e4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -280,6 +280,9 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set)
280static const struct drm_crtc_funcs vmw_legacy_crtc_funcs = { 280static const struct drm_crtc_funcs vmw_legacy_crtc_funcs = {
281 .gamma_set = vmw_du_crtc_gamma_set, 281 .gamma_set = vmw_du_crtc_gamma_set,
282 .destroy = vmw_ldu_crtc_destroy, 282 .destroy = vmw_ldu_crtc_destroy,
283 .reset = vmw_du_crtc_reset,
284 .atomic_duplicate_state = vmw_du_crtc_duplicate_state,
285 .atomic_destroy_state = vmw_du_crtc_destroy_state,
283 .set_config = vmw_ldu_crtc_set_config, 286 .set_config = vmw_ldu_crtc_set_config,
284}; 287};
285 288
@@ -355,6 +358,11 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
355 ldu->base.pref_width = dev_priv->initial_width; 358 ldu->base.pref_width = dev_priv->initial_width;
356 ldu->base.pref_height = dev_priv->initial_height; 359 ldu->base.pref_height = dev_priv->initial_height;
357 ldu->base.pref_mode = NULL; 360 ldu->base.pref_mode = NULL;
361
362 /*
363 * Remove this after enabling atomic because property values can
364 * only exist in a state object
365 */
358 ldu->base.is_implicit = true; 366 ldu->base.is_implicit = true;
359 367
360 /* Initialize primary plane */ 368 /* Initialize primary plane */
@@ -405,6 +413,8 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
405 goto err_free_encoder; 413 goto err_free_encoder;
406 } 414 }
407 415
416 /* FIXME: Turn on after plane/connector states are implemented. */
417 /* vmw_du_crtc_reset(crtc); */
408 ret = drm_crtc_init_with_planes(dev, crtc, &ldu->base.primary, 418 ret = drm_crtc_init_with_planes(dev, crtc, &ldu->base.primary,
409 &ldu->base.cursor, 419 &ldu->base.cursor,
410 &vmw_legacy_crtc_funcs, NULL); 420 &vmw_legacy_crtc_funcs, NULL);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index 8ffccb87cf3a..033e17b966b1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -461,6 +461,9 @@ out_no_fence:
461static const struct drm_crtc_funcs vmw_screen_object_crtc_funcs = { 461static const struct drm_crtc_funcs vmw_screen_object_crtc_funcs = {
462 .gamma_set = vmw_du_crtc_gamma_set, 462 .gamma_set = vmw_du_crtc_gamma_set,
463 .destroy = vmw_sou_crtc_destroy, 463 .destroy = vmw_sou_crtc_destroy,
464 .reset = vmw_du_crtc_reset,
465 .atomic_duplicate_state = vmw_du_crtc_duplicate_state,
466 .atomic_destroy_state = vmw_du_crtc_destroy_state,
464 .set_config = vmw_sou_crtc_set_config, 467 .set_config = vmw_sou_crtc_set_config,
465 .page_flip = vmw_sou_crtc_page_flip, 468 .page_flip = vmw_sou_crtc_page_flip,
466}; 469};
@@ -535,6 +538,11 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)
535 sou->base.pref_width = dev_priv->initial_width; 538 sou->base.pref_width = dev_priv->initial_width;
536 sou->base.pref_height = dev_priv->initial_height; 539 sou->base.pref_height = dev_priv->initial_height;
537 sou->base.pref_mode = NULL; 540 sou->base.pref_mode = NULL;
541
542 /*
543 * Remove this after enabling atomic because property values can
544 * only exist in a state object
545 */
538 sou->base.is_implicit = false; 546 sou->base.is_implicit = false;
539 547
540 /* Initialize primary plane */ 548 /* Initialize primary plane */
@@ -586,6 +594,8 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)
586 goto err_free_encoder; 594 goto err_free_encoder;
587 } 595 }
588 596
597 /* FIXME: Turn on after plane/connector states are implemented. */
598 /* vmw_du_crtc_reset(crtc); */
589 ret = drm_crtc_init_with_planes(dev, crtc, &sou->base.primary, 599 ret = drm_crtc_init_with_planes(dev, crtc, &sou->base.primary,
590 &sou->base.cursor, 600 &sou->base.cursor,
591 &vmw_screen_object_crtc_funcs, NULL); 601 &vmw_screen_object_crtc_funcs, NULL);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index 4d9dd1b67b93..3b8fafe1586e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -1017,6 +1017,9 @@ out_finish:
1017static const struct drm_crtc_funcs vmw_stdu_crtc_funcs = { 1017static const struct drm_crtc_funcs vmw_stdu_crtc_funcs = {
1018 .gamma_set = vmw_du_crtc_gamma_set, 1018 .gamma_set = vmw_du_crtc_gamma_set,
1019 .destroy = vmw_stdu_crtc_destroy, 1019 .destroy = vmw_stdu_crtc_destroy,
1020 .reset = vmw_du_crtc_reset,
1021 .atomic_duplicate_state = vmw_du_crtc_duplicate_state,
1022 .atomic_destroy_state = vmw_du_crtc_destroy_state,
1020 .set_config = vmw_stdu_crtc_set_config, 1023 .set_config = vmw_stdu_crtc_set_config,
1021 .page_flip = vmw_stdu_crtc_page_flip, 1024 .page_flip = vmw_stdu_crtc_page_flip,
1022}; 1025};
@@ -1131,6 +1134,11 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
1131 stdu->base.pref_active = (unit == 0); 1134 stdu->base.pref_active = (unit == 0);
1132 stdu->base.pref_width = dev_priv->initial_width; 1135 stdu->base.pref_width = dev_priv->initial_width;
1133 stdu->base.pref_height = dev_priv->initial_height; 1136 stdu->base.pref_height = dev_priv->initial_height;
1137
1138 /*
1139 * Remove this after enabling atomic because property values can
1140 * only exist in a state object
1141 */
1134 stdu->base.is_implicit = false; 1142 stdu->base.is_implicit = false;
1135 1143
1136 /* Initialize primary plane */ 1144 /* Initialize primary plane */
@@ -1181,6 +1189,8 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
1181 goto err_free_encoder; 1189 goto err_free_encoder;
1182 } 1190 }
1183 1191
1192 /* FIXME: Turn on after plane/connector states are implemented. */
1193 /* vmw_du_crtc_reset(crtc); */
1184 ret = drm_crtc_init_with_planes(dev, crtc, &stdu->base.primary, 1194 ret = drm_crtc_init_with_planes(dev, crtc, &stdu->base.primary,
1185 &stdu->base.cursor, 1195 &stdu->base.cursor,
1186 &vmw_stdu_crtc_funcs, NULL); 1196 &vmw_stdu_crtc_funcs, NULL);