}
+/**
+ * vmw_du_connector_duplicate_state - duplicate connector state
+ * @connector: DRM connector
+ *
+ * Allocates and returns a copy of the connector state (both common and
+ * vmw-specific) for the specified connector.
+ *
+ * Returns: The newly allocated connector state, or NULL on failure.
+ */
+struct drm_connector_state *
+vmw_du_connector_duplicate_state(struct drm_connector *connector)
+{
+ struct drm_connector_state *state;
+ struct vmw_connector_state *vcs;
+
+ if (WARN_ON(!connector->state))
+ return NULL;
+
+ vcs = kmemdup(connector->state, sizeof(*vcs), GFP_KERNEL);
+
+ if (!vcs)
+ return NULL;
+
+ state = &vcs->base;
+
+ __drm_atomic_helper_connector_duplicate_state(connector, state);
+
+ return state;
+}
+
+
+/**
+ * vmw_du_connector_reset - creates a blank vmw connector state
+ * @connector: DRM connector
+ *
+ * Resets the atomic state for @connector 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_connector_reset(struct drm_connector *connector)
+{
+ struct vmw_connector_state *vcs;
+
+
+ if (connector->state) {
+ __drm_atomic_helper_connector_destroy_state(connector->state);
+
+ kfree(vmw_connector_state_to_vcs(connector->state));
+ }
+
+ vcs = kzalloc(sizeof(*vcs), GFP_KERNEL);
+
+ if (!vcs) {
+ DRM_ERROR("Cannot allocate vmw_connector_state\n");
+ return;
+ }
+
+ __drm_atomic_helper_connector_reset(connector, &vcs->base);
+}
+
+
+/**
+ * vmw_du_connector_destroy_state - destroy connector state
+ * @connector: DRM connector
+ * @state: state object to destroy
+ *
+ * Destroys the connector state (both common and vmw-specific) for the
+ * specified plane.
+ */
+void
+vmw_du_connector_destroy_state(struct drm_connector *connector,
+ struct drm_connector_state *state)
+{
+ drm_atomic_helper_connector_destroy_state(connector, state);
+}
/*
* Generic framebuffer code
*/
+/**
+ * vmw_du_connector_atomic_set_property - Atomic version of get property
+ *
+ * @crtc - crtc the property is associated with
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int
+vmw_du_connector_atomic_set_property(struct drm_connector *connector,
+ struct drm_connector_state *state,
+ struct drm_property *property,
+ uint64_t val)
+{
+ struct vmw_private *dev_priv = vmw_priv(connector->dev);
+ struct vmw_connector_state *vcs = vmw_connector_state_to_vcs(state);
+ struct vmw_display_unit *du = vmw_connector_to_du(connector);
+
+
+ if (property == dev_priv->implicit_placement_property) {
+ vcs->is_implicit = val;
+
+ /*
+ * We should really be doing a drm_atomic_commit() to
+ * commit the new state, but since this doesn't cause
+ * an immedate state change, this is probably ok
+ */
+ du->is_implicit = vcs->is_implicit;
+ } else {
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+
+/**
+ * vmw_du_connector_atomic_get_property - Atomic version of get property
+ *
+ * @connector - connector the property is associated with
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int
+vmw_du_connector_atomic_get_property(struct drm_connector *connector,
+ const struct drm_connector_state *state,
+ struct drm_property *property,
+ uint64_t *val)
+{
+ struct vmw_private *dev_priv = vmw_priv(connector->dev);
+ struct vmw_connector_state *vcs = vmw_connector_state_to_vcs(state);
+
+ if (property == dev_priv->implicit_placement_property)
+ *val = vcs->is_implicit;
+ else {
+ DRM_ERROR("Invalid Property %s\n", property->name);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+
int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
#define vmw_crtc_state_to_vcs(x) container_of(x, struct vmw_crtc_state, base)
#define vmw_plane_state_to_vps(x) container_of(x, struct vmw_plane_state, base)
-
+#define vmw_connector_state_to_vcs(x) \
+ container_of(x, struct vmw_connector_state, base)
/**
* Derived class for crtc state object
int pinned;
};
+
+/**
+ * Derived class for connector state object
+ *
+ * @base DRM connector object
+ * @is_implicit connector property
+ *
+ */
+struct vmw_connector_state {
+ struct drm_connector_state base;
+
+ bool is_implicit;
+};
+
/**
* Base class display unit.
*
int vmw_du_connector_set_property(struct drm_connector *connector,
struct drm_property *property,
uint64_t val);
+int vmw_du_connector_atomic_set_property(struct drm_connector *connector,
+ struct drm_connector_state *state,
+ struct drm_property *property,
+ uint64_t val);
+int
+vmw_du_connector_atomic_get_property(struct drm_connector *connector,
+ const struct drm_connector_state *state,
+ struct drm_property *property,
+ uint64_t *val);
int vmw_du_connector_dpms(struct drm_connector *connector, int mode);
void vmw_du_connector_save(struct drm_connector *connector);
void vmw_du_connector_restore(struct drm_connector *connector);
struct drm_crtc_state *vmw_du_crtc_duplicate_state(struct drm_crtc *crtc);
void vmw_du_crtc_destroy_state(struct drm_crtc *crtc,
struct drm_crtc_state *state);
+void vmw_du_connector_reset(struct drm_connector *connector);
+struct drm_connector_state *
+vmw_du_connector_duplicate_state(struct drm_connector *connector);
+
+void vmw_du_connector_destroy_state(struct drm_connector *connector,
+ struct drm_connector_state *state);
/*
* Legacy display unit functions - vmwgfx_ldu.c
#include "vmwgfx_kms.h"
#include <drm/drm_plane_helper.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
#define vmw_crtc_to_ldu(x) \
.fill_modes = vmw_du_connector_fill_modes,
.set_property = vmw_du_connector_set_property,
.destroy = vmw_ldu_connector_destroy,
+ .reset = vmw_du_connector_reset,
+ .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+ .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+ .atomic_set_property = vmw_du_connector_atomic_set_property,
+ .atomic_get_property = vmw_du_connector_atomic_get_property,
};
/*
goto err_free;
}
connector->status = vmw_du_connector_detect(connector, true);
+ vmw_connector_state_to_vcs(connector->state)->is_implicit = true;
+
ret = drm_encoder_init(dev, encoder, &vmw_legacy_encoder_funcs,
DRM_MODE_ENCODER_VIRTUAL, NULL);
goto err_free_encoder;
}
- /* FIXME: Turn on after plane/connector states are implemented. */
- /* vmw_du_crtc_reset(crtc); */
+
+ vmw_du_crtc_reset(crtc);
ret = drm_crtc_init_with_planes(dev, crtc, &ldu->base.primary,
&ldu->base.cursor,
&vmw_legacy_crtc_funcs, NULL);
#include "vmwgfx_kms.h"
#include <drm/drm_plane_helper.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
#define vmw_crtc_to_sou(x) \
.fill_modes = vmw_du_connector_fill_modes,
.set_property = vmw_du_connector_set_property,
.destroy = vmw_sou_connector_destroy,
+ .reset = vmw_du_connector_reset,
+ .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+ .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+ .atomic_set_property = vmw_du_connector_atomic_set_property,
+ .atomic_get_property = vmw_du_connector_atomic_get_property,
};
/*
}
connector->status = vmw_du_connector_detect(connector, true);
+ vmw_connector_state_to_vcs(connector->state)->is_implicit = false;
+
ret = drm_encoder_init(dev, encoder, &vmw_screen_object_encoder_funcs,
DRM_MODE_ENCODER_VIRTUAL, NULL);
goto err_free_encoder;
}
- /* FIXME: Turn on after plane/connector states are implemented. */
- /* vmw_du_crtc_reset(crtc); */
+
+ vmw_du_crtc_reset(crtc);
ret = drm_crtc_init_with_planes(dev, crtc, &sou->base.primary,
&sou->base.cursor,
&vmw_screen_object_crtc_funcs, NULL);
#include "vmwgfx_kms.h"
#include "device_include/svga3d_surfacedefs.h"
#include <drm/drm_plane_helper.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+
#define vmw_crtc_to_stdu(x) \
container_of(x, struct vmw_screen_target_display_unit, base.crtc)
.fill_modes = vmw_du_connector_fill_modes,
.set_property = vmw_du_connector_set_property,
.destroy = vmw_stdu_connector_destroy,
+ .reset = vmw_du_connector_reset,
+ .atomic_duplicate_state = vmw_du_connector_duplicate_state,
+ .atomic_destroy_state = vmw_du_connector_destroy_state,
+ .atomic_set_property = vmw_du_connector_atomic_set_property,
+ .atomic_get_property = vmw_du_connector_atomic_get_property,
};
goto err_free;
}
+ vmw_du_connector_reset(connector);
+
ret = drm_connector_init(dev, connector, &vmw_stdu_connector_funcs,
DRM_MODE_CONNECTOR_VIRTUAL);
if (ret) {
goto err_free;
}
connector->status = vmw_du_connector_detect(connector, false);
+ vmw_connector_state_to_vcs(connector->state)->is_implicit = false;
ret = drm_encoder_init(dev, encoder, &vmw_stdu_encoder_funcs,
DRM_MODE_ENCODER_VIRTUAL, NULL);
goto err_free_encoder;
}
- /* FIXME: Turn on after plane/connector states are implemented. */
- /* vmw_du_crtc_reset(crtc); */
+ vmw_du_crtc_reset(crtc);
ret = drm_crtc_init_with_planes(dev, crtc, &stdu->base.primary,
&stdu->base.cursor,
&vmw_stdu_crtc_funcs, NULL);