Lines Matching refs:qdev
49 static int qxl_alloc_client_monitors_config(struct qxl_device *qdev,
52 if (qdev->client_monitors_config &&
53 count > qdev->client_monitors_config->count) {
54 kfree(qdev->client_monitors_config);
55 qdev->client_monitors_config = NULL;
57 if (!qdev->client_monitors_config) {
58 qdev->client_monitors_config = kzalloc(
59 struct_size(qdev->client_monitors_config,
61 if (!qdev->client_monitors_config)
64 qdev->client_monitors_config->count = count;
75 static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)
82 num_monitors = qdev->rom->client_monitors_config.count;
83 crc = crc32(0, (const uint8_t *)&qdev->rom->client_monitors_config,
84 sizeof(qdev->rom->client_monitors_config));
85 if (crc != qdev->rom->client_monitors_config_crc)
96 num_monitors = qdev->rom->client_monitors_config.count;
98 if (qdev->client_monitors_config
99 && (num_monitors != qdev->client_monitors_config->count)) {
102 if (qxl_alloc_client_monitors_config(qdev, num_monitors)) {
107 qdev->client_monitors_config->max_allowed = qxl_num_crtc;
108 for (i = 0 ; i < qdev->client_monitors_config->count ; ++i) {
110 &qdev->rom->client_monitors_config.heads[i];
112 &qdev->client_monitors_config->heads[i];
148 static void qxl_update_offset_props(struct qxl_device *qdev)
150 struct drm_device *dev = &qdev->ddev;
158 head = &qdev->client_monitors_config->heads[output->index];
167 void qxl_display_read_client_monitors_config(struct qxl_device *qdev)
169 struct drm_device *dev = &qdev->ddev;
174 status = qxl_display_copy_rom_client_monitors_config(qdev);
193 qxl_update_offset_props(qdev);
202 static int qxl_check_mode(struct qxl_device *qdev,
213 if (size > qdev->vram_size)
218 static int qxl_check_framebuffer(struct qxl_device *qdev,
221 return qxl_check_mode(qdev, bo->surf.width, bo->surf.height);
230 struct qxl_device *qdev = to_qxl(dev);
234 rc = qxl_check_mode(qdev, width, height);
251 struct qxl_device *qdev = to_qxl(dev);
256 if (!qdev->monitors_config)
260 if (!qdev->client_monitors_config)
262 if (h >= qdev->client_monitors_config->count)
265 head = &qdev->client_monitors_config->heads[h];
292 static void qxl_send_monitors_config(struct qxl_device *qdev)
296 BUG_ON(!qdev->ram_header->monitors_config);
298 if (qdev->monitors_config->count == 0)
301 for (i = 0 ; i < qdev->monitors_config->count ; ++i) {
302 struct qxl_head *head = &qdev->monitors_config->heads[i];
312 qxl_io_monitors_config(qdev);
319 struct qxl_device *qdev = to_qxl(dev);
324 if (!qdev->primary_bo) {
329 if (!qdev->monitors_config || qxl_num_crtc <= i)
335 oldcount = qdev->monitors_config->count;
343 if (qdev->monitors_config->count < i + 1)
344 qdev->monitors_config->count = i + 1;
345 if (qdev->primary_bo == qdev->dumb_shadow_bo)
346 head.x += qdev->dumb_heads[i].x;
352 if (qdev->monitors_config->count == i + 1)
353 qdev->monitors_config->count = i;
359 if (head.width == qdev->monitors_config->heads[i].width &&
360 head.height == qdev->monitors_config->heads[i].height &&
361 head.x == qdev->monitors_config->heads[i].x &&
362 head.y == qdev->monitors_config->heads[i].y &&
363 oldcount == qdev->monitors_config->count)
369 if (oldcount != qdev->monitors_config->count)
371 oldcount, qdev->monitors_config->count,
374 qdev->monitors_config->heads[i] = head;
375 qdev->monitors_config->max_allowed = qxl_num_crtc;
376 qxl_send_monitors_config(qdev);
410 struct qxl_device *qdev = to_qxl(fb->dev);
436 qxl_draw_dirty_fb(qdev, fb, qobj, flags, color,
474 struct qxl_device *qdev = to_qxl(plane->dev);
482 return qxl_check_framebuffer(qdev, bo);
485 static int qxl_primary_apply_cursor(struct qxl_device *qdev,
497 ret = qxl_alloc_release_reserved(qdev, sizeof(*cmd),
511 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
516 cmd->u.set.shape = qxl_bo_physical_address(qdev, qcrtc->cursor_bo, 0);
519 qxl_release_unmap(qdev, release, &cmd->release_info);
522 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
527 qxl_release_free(qdev, release);
531 static int qxl_primary_move_cursor(struct qxl_device *qdev,
543 ret = qxl_alloc_release_reserved(qdev, sizeof(*cmd),
551 qxl_release_free(qdev, release);
555 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
559 qxl_release_unmap(qdev, release, &cmd->release_info);
562 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
566 static struct qxl_bo *qxl_create_cursor(struct qxl_device *qdev,
580 ret = qxl_bo_create(qdev, sizeof(struct qxl_cursor) + size,
643 struct qxl_device *qdev = to_qxl(plane->dev);
657 if (qdev->primary_bo)
658 qxl_io_destroy_primary(qdev);
659 qxl_io_create_primary(qdev, primary);
660 qxl_primary_apply_cursor(qdev, plane->state);
665 qdev->dumb_heads[new_state->crtc->index].x;
667 qxl_draw_dirty_fb(qdev, new_state->fb, bo, 0, 0, &norect, 1, 1,
676 struct qxl_device *qdev = to_qxl(plane->dev);
684 qxl_io_destroy_primary(qdev);
695 struct qxl_device *qdev = to_qxl(plane->dev);
699 qxl_primary_apply_cursor(qdev, new_state);
701 qxl_primary_move_cursor(qdev, new_state);
710 struct qxl_device *qdev = to_qxl(plane->dev);
716 ret = qxl_alloc_release_reserved(qdev, sizeof(*cmd),
724 qxl_release_free(qdev, release);
728 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
730 qxl_release_unmap(qdev, release, &cmd->release_info);
733 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
740 static void qxl_update_dumb_head(struct qxl_device *qdev,
745 if (index >= qdev->monitors_config->max_allowed)
756 if (qdev->dumb_heads[index].width == width &&
757 qdev->dumb_heads[index].height == height)
761 qdev->dumb_heads[index].width,
762 qdev->dumb_heads[index].height,
764 qdev->dumb_heads[index].width = width;
765 qdev->dumb_heads[index].height = height;
768 static void qxl_calc_dumb_shadow(struct qxl_device *qdev,
775 for (i = 0; i < qdev->monitors_config->max_allowed; i++) {
776 head = qdev->dumb_heads + i;
789 if (!qdev->dumb_shadow_bo ||
790 qdev->dumb_shadow_bo->surf.width != surf->width ||
791 qdev->dumb_shadow_bo->surf.height != surf->height)
795 static void qxl_prepare_shadow(struct qxl_device *qdev, struct qxl_bo *user_bo,
800 qxl_update_dumb_head(qdev, crtc_index,
802 qxl_calc_dumb_shadow(qdev, &surf);
803 if (!qdev->dumb_shadow_bo ||
804 qdev->dumb_shadow_bo->surf.width != surf.width ||
805 qdev->dumb_shadow_bo->surf.height != surf.height) {
806 if (qdev->dumb_shadow_bo) {
807 qxl_bo_unpin(qdev->dumb_shadow_bo);
809 (&qdev->dumb_shadow_bo->tbo.base);
810 qdev->dumb_shadow_bo = NULL;
812 qxl_bo_create(qdev, surf.height * surf.stride,
814 &surf, &qdev->dumb_shadow_bo);
816 if (user_bo->shadow != qdev->dumb_shadow_bo) {
823 drm_gem_object_get(&qdev->dumb_shadow_bo->tbo.base);
824 user_bo->shadow = qdev->dumb_shadow_bo;
832 struct qxl_device *qdev = to_qxl(plane->dev);
845 qxl_prepare_shadow(qdev, user_bo, new_state->crtc->index);
853 qcrtc->cursor_bo = qxl_create_cursor(qdev, user_bo,
933 static struct drm_plane *qxl_create_plane(struct qxl_device *qdev,
962 err = drm_universal_plane_init(&qdev->ddev, plane, possible_crtcs,
981 struct qxl_device *qdev = to_qxl(dev);
988 primary = qxl_create_plane(qdev, 1 << crtc_id, DRM_PLANE_TYPE_PRIMARY);
994 cursor = qxl_create_plane(qdev, 1 << crtc_id, DRM_PLANE_TYPE_CURSOR);
1023 struct qxl_device *qdev = to_qxl(dev);
1029 if (qdev->client_monitors_config) {
1031 head = &qdev->client_monitors_config->heads[output->index];
1049 struct qxl_device *qdev = to_qxl(ddev);
1051 if (qxl_check_mode(qdev, mode->hdisplay, mode->vdisplay) != 0)
1079 struct qxl_device *qdev = to_qxl(ddev);
1083 if (!qdev->client_monitors_config) {
1087 connected = qdev->client_monitors_config->count > output->index &&
1088 qxl_head_enabled(&qdev->client_monitors_config->heads[output->index]);
1115 static int qxl_mode_create_hotplug_mode_update_property(struct qxl_device *qdev)
1117 if (qdev->hotplug_mode_update_property)
1120 qdev->hotplug_mode_update_property =
1121 drm_property_create_range(&qdev->ddev, DRM_MODE_PROP_IMMUTABLE,
1129 struct qxl_device *qdev = to_qxl(dev);
1162 qdev->hotplug_mode_update_property, 0);
1190 int qxl_create_monitors_object(struct qxl_device *qdev)
1198 ret = qxl_gem_object_create(qdev, monitors_config_size, 0,
1205 qdev->monitors_config_bo = gem_to_qxl_bo(gobj);
1207 ret = qxl_bo_vmap(qdev->monitors_config_bo, &map);
1211 qdev->monitors_config = qdev->monitors_config_bo->kptr;
1212 qdev->ram_header->monitors_config =
1213 qxl_bo_physical_address(qdev, qdev->monitors_config_bo, 0);
1215 memset(qdev->monitors_config, 0, monitors_config_size);
1216 qdev->dumb_heads = kcalloc(qxl_num_crtc, sizeof(qdev->dumb_heads[0]),
1218 if (!qdev->dumb_heads) {
1219 qxl_destroy_monitors_object(qdev);
1225 int qxl_destroy_monitors_object(struct qxl_device *qdev)
1229 if (!qdev->monitors_config_bo)
1232 kfree(qdev->dumb_heads);
1233 qdev->dumb_heads = NULL;
1235 qdev->monitors_config = NULL;
1236 qdev->ram_header->monitors_config = 0;
1238 ret = qxl_bo_vunmap(qdev->monitors_config_bo);
1242 qxl_bo_unref(&qdev->monitors_config_bo);
1246 int qxl_modeset_init(struct qxl_device *qdev)
1251 ret = drmm_mode_config_init(&qdev->ddev);
1255 ret = qxl_create_monitors_object(qdev);
1259 qdev->ddev.mode_config.funcs = (void *)&qxl_mode_funcs;
1262 qdev->ddev.mode_config.min_width = 0;
1263 qdev->ddev.mode_config.min_height = 0;
1264 qdev->ddev.mode_config.max_width = 8192;
1265 qdev->ddev.mode_config.max_height = 8192;
1267 drm_mode_create_suggested_offset_properties(&qdev->ddev);
1268 qxl_mode_create_hotplug_mode_update_property(qdev);
1271 qdev_crtc_init(&qdev->ddev, i);
1272 qdev_output_init(&qdev->ddev, i);
1275 qxl_display_read_client_monitors_config(qdev);
1277 drm_mode_config_reset(&qdev->ddev);
1281 void qxl_modeset_fini(struct qxl_device *qdev)
1283 if (qdev->dumb_shadow_bo) {
1284 qxl_bo_unpin(qdev->dumb_shadow_bo);
1285 drm_gem_object_put(&qdev->dumb_shadow_bo->tbo.base);
1286 qdev->dumb_shadow_bo = NULL;
1288 qxl_destroy_monitors_object(qdev);