struct drm_crtc **save_crtcs, *new_crtc;
bool save_enabled = crtc->enabled;
bool changed = false;
+ bool flip_or_move = false;
struct drm_output *output;
int count = 0, ro;
if (!save_crtcs)
return -ENOMEM;
+ /* We should be able to check here if the fb has the same properties
+ * and then just flip_or_move it */
if (crtc->fb != fb)
changed = true;
if (crtc_info->x != crtc->x || crtc_info->y != crtc->y)
- changed = true;
+ flip_or_move = true;
if (new_mode && !drm_mode_equal(new_mode, &crtc->mode))
changed = true;
}
}
+ /* mode_set_base is not a required function */
+ if (flip_or_move && !crtc->funcs->mode_set_base)
+ changed = true;
+
if (changed) {
crtc->fb = fb;
crtc->enabled = (new_mode != NULL);
crtc->desired_mode = new_mode;
}
drm_disable_unused_functions(dev);
+ } else if (flip_or_move) {
+ crtc->funcs->mode_set_base(crtc, crtc_info->x, crtc_info->y);
}
+
kfree(save_crtcs);
return 0;
}
if (crtc_req->count_outputs > 0) {
u32 out_id;
+ /* Maybe we should check that count_outputs is a sensible value. */
output_set = kmalloc(crtc_req->count_outputs *
sizeof(struct drm_output *), GFP_KERNEL);
if (!output_set) {
}
}
+ /* What happens to output_set, leak? */
ret = drm_crtc_set_config(crtc, crtc_req, mode, output_set, fb);
out:
#include "xf86drm.h"
#include "xf86drmMode.h"
-/* setting this to 2024 gets the pitch wrong check it */
#define SIZE_X 2048
#define SIZE_Y 2048
+/* Pitch needs to be power of two */
+#define PITCH 2048
static struct drm_mode_modeinfo mode = {
.name = "Test mode",
prettyColors(fd, framebuffer->handle);
printf("0 0\n");
- drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 0, &out[1]->output_id, 1, &mode);
+ drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 0, &out[0]->output_id, 1, &mode);
sleep(2);
printf("0 100\n");
- drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 100, &out[1]->output_id, 1, &mode);
+ drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 100, &out[0]->output_id, 1, &mode);
sleep(2);
printf("100 0\n");
- drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 0, &out[1]->output_id, 1, &mode);
+ drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 0, &out[0]->output_id, 1, &mode);
sleep(2);
printf("100 100\n");
- drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 100, &out[1]->output_id, 1, &mode);
+ drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 100, &out[0]->output_id, 1, &mode);
sleep(2);
/* turn the crtc off just in case */
if (ret)
goto err;
- ret = drmModeAddFB(fd, SIZE_X, SIZE_Y, 32, 32, SIZE_X*4, &bo, &fb);
+ ret = drmModeAddFB(fd, SIZE_X, SIZE_Y, 32, 32, PITCH * 4, &bo, &fb);
if (ret)
goto err_bo;
drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res)
{
- return drmModeGetCrtc(fd, res->crtcs[1]);
+ return drmModeGetCrtc(fd, res->crtcs[0]);
}
void draw(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int v, unsigned int *ptr)
for (i = x; i < x + w; i++)
for(j = y; j < y + h; j++)
- ptr[(i * SIZE_X) + j] = v;
+ ptr[(i * PITCH) + j] = v;
}
{
drmBO bo;
unsigned int *ptr;
- int i, j;
+ int i;
drmBOReference(fd, handle, &bo);
drmBOMap(fd, &bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, (void**)&ptr);
ptr[i] = 0xFFFFFFFF;
for (i = 0; i < 8; i++)
- draw(i*40, i*40, 40, 40, 0, ptr);
+ draw(i * 40, i * 40, 40, 40, 0, ptr);
draw(200, 100, 40, 40, 0xff00ff, ptr);