summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
diff options
context:
space:
mode:
authorSinclair Yeh <syeh@vmware.com>2017-03-23 11:33:39 -0700
committerSinclair Yeh <syeh@vmware.com>2017-03-31 09:13:08 -0700
commit9c2542a41f559452d570b96239a81038c49becfc (patch)
treed3f26c0c4579a8269cb7dbe43e13a7a18c1e19d2 /drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
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>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_kms.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c81
1 files changed, 81 insertions, 0 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 @@
**************************************************************************/
#include "vmwgfx_kms.h"
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
/* Might need a hrtimer here? */
@@ -388,6 +390,84 @@ void vmw_du_primary_plane_destroy(struct drm_plane *plane)
}
+/**
+ * vmw_du_crtc_duplicate_state - duplicate crtc state
+ * @crtc: DRM crtc
+ *
+ * Allocates and returns a copy of the crtc state (both common and
+ * vmw-specific) for the specified crtc.
+ *
+ * Returns: The newly allocated crtc state, or NULL on failure.
+ */
+struct drm_crtc_state *
+vmw_du_crtc_duplicate_state(struct drm_crtc *crtc)
+{
+ struct drm_crtc_state *state;
+ struct vmw_crtc_state *vcs;
+
+ if (WARN_ON(!crtc->state))
+ return NULL;
+
+ vcs = kmemdup(crtc->state, sizeof(*vcs), GFP_KERNEL);
+
+ if (!vcs)
+ return NULL;
+
+ state = &vcs->base;
+
+ __drm_atomic_helper_crtc_duplicate_state(crtc, state);
+
+ return state;
+}
+
+
+/**
+ * vmw_du_crtc_reset - creates a blank vmw crtc state
+ * @crtc: DRM crtc
+ *
+ * Resets the atomic state for @crtc by freeing the state pointer (which
+ * might be NULL, e.g. at driver load time) and allocating a new empty state
+ * object.
+ */
+void vmw_du_crtc_reset(struct drm_crtc *crtc)
+{
+ struct vmw_crtc_state *vcs;
+
+
+ if (crtc->state) {
+ __drm_atomic_helper_crtc_destroy_state(crtc->state);
+
+ kfree(vmw_crtc_state_to_vcs(crtc->state));
+ }
+
+ vcs = kzalloc(sizeof(*vcs), GFP_KERNEL);
+
+ if (!vcs) {
+ DRM_ERROR("Cannot allocate vmw_crtc_state\n");
+ return;
+ }
+
+ crtc->state = &vcs->base;
+ crtc->state->crtc = crtc;
+}
+
+
+/**
+ * vmw_du_crtc_destroy_state - destroy crtc state
+ * @crtc: DRM crtc
+ * @state: state object to destroy
+ *
+ * Destroys the crtc state (both common and vmw-specific) for the
+ * specified plane.
+ */
+void
+vmw_du_crtc_destroy_state(struct drm_crtc *crtc,
+ struct drm_crtc_state *state)
+{
+ drm_atomic_helper_crtc_destroy_state(crtc, state);
+}
+
+
/*
* Generic framebuffer code
*/
@@ -1600,6 +1680,7 @@ int vmw_du_connector_set_property(struct drm_connector *connector,
}
+
int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
b_contract891'>feature/cib_contract891