#include <drm/drm_encoder.h>
#include <linux/hrtimer.h>
-#define XRES_MIN 32
-#define YRES_MIN 32
+#define XRES_MIN 20
+#define YRES_MIN 20
#define XRES_DEF 1024
#define YRES_DEF 768
DRM_FORMAT_XRGB8888,
};
+static const u32 vkms_cursor_formats[] = {
+ DRM_FORMAT_ARGB8888,
+};
+
struct vkms_crc_data {
struct drm_rect src;
struct drm_framebuffer fb;
int vkms_output_init(struct vkms_device *vkmsdev);
-struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev);
+struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev,
+ enum drm_plane_type type);
/* Gem stuff */
struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
struct drm_connector *connector = &output->connector;
struct drm_encoder *encoder = &output->encoder;
struct drm_crtc *crtc = &output->crtc;
- struct drm_plane *primary;
+ struct drm_plane *primary, *cursor = NULL;
int ret;
- primary = vkms_plane_init(vkmsdev);
+ primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY);
if (IS_ERR(primary))
return PTR_ERR(primary);
- ret = vkms_crtc_init(dev, crtc, primary, NULL);
+ cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR);
+ if (IS_ERR(cursor)) {
+ ret = PTR_ERR(cursor);
+ goto err_cursor;
+ }
+
+ ret = vkms_crtc_init(dev, crtc, primary, cursor);
if (ret)
goto err_crtc;
drm_crtc_cleanup(crtc);
err_crtc:
+ drm_plane_cleanup(cursor);
+
+err_cursor:
drm_plane_cleanup(primary);
+
return ret;
}
.atomic_destroy_state = vkms_plane_destroy_state,
};
-static void vkms_primary_plane_update(struct drm_plane *plane,
- struct drm_plane_state *old_state)
+static void vkms_plane_atomic_update(struct drm_plane *plane,
+ struct drm_plane_state *old_state)
{
struct vkms_plane_state *vkms_plane_state;
struct vkms_crc_data *crc_data;
struct drm_plane_state *state)
{
struct drm_crtc_state *crtc_state;
+ bool can_position = false;
int ret;
if (!state->fb | !state->crtc)
if (IS_ERR(crtc_state))
return PTR_ERR(crtc_state);
+ if (plane->type == DRM_PLANE_TYPE_CURSOR)
+ can_position = true;
+
ret = drm_atomic_helper_check_plane_state(state, crtc_state,
DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING,
- false, true);
+ can_position, true);
if (ret != 0)
return ret;
/* for now primary plane must be visible and full screen */
- if (!state->visible)
+ if (!state->visible && !can_position)
return -EINVAL;
return 0;
}
static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = {
- .atomic_update = vkms_primary_plane_update,
+ .atomic_update = vkms_plane_atomic_update,
.atomic_check = vkms_plane_atomic_check,
.prepare_fb = vkms_prepare_fb,
.cleanup_fb = vkms_cleanup_fb,
};
-struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev)
+struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev,
+ enum drm_plane_type type)
{
struct drm_device *dev = &vkmsdev->drm;
+ const struct drm_plane_helper_funcs *funcs;
struct drm_plane *plane;
const u32 *formats;
int ret, nformats;
if (!plane)
return ERR_PTR(-ENOMEM);
- formats = vkms_formats;
- nformats = ARRAY_SIZE(vkms_formats);
+ if (type == DRM_PLANE_TYPE_CURSOR) {
+ formats = vkms_cursor_formats;
+ nformats = ARRAY_SIZE(vkms_cursor_formats);
+ funcs = &vkms_primary_helper_funcs;
+ } else {
+ formats = vkms_formats;
+ nformats = ARRAY_SIZE(vkms_formats);
+ funcs = &vkms_primary_helper_funcs;
+ }
ret = drm_universal_plane_init(dev, plane, 0,
&vkms_plane_funcs,
formats, nformats,
- NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
+ NULL, type, NULL);
if (ret) {
kfree(plane);
return ERR_PTR(ret);
}
- drm_plane_helper_add(plane, &vkms_primary_helper_funcs);
+ drm_plane_helper_add(plane, funcs);
return plane;
}