diff options
Diffstat (limited to 'drivers/gpu/drm/qxl/qxl_display.c')
-rw-r--r-- | drivers/gpu/drm/qxl/qxl_display.c | 229 |
1 files changed, 124 insertions, 105 deletions
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c index 686a937675cb..f76f5dd7bfc4 100644 --- a/drivers/gpu/drm/qxl/qxl_display.c +++ b/drivers/gpu/drm/qxl/qxl_display.c | |||
@@ -30,53 +30,9 @@ | |||
30 | #include "qxl_object.h" | 30 | #include "qxl_object.h" |
31 | #include "drm_crtc_helper.h" | 31 | #include "drm_crtc_helper.h" |
32 | 32 | ||
33 | static void qxl_crtc_set_to_mode(struct qxl_device *qdev, | 33 | static bool qxl_head_enabled(struct qxl_head *head) |
34 | struct drm_connector *connector, | ||
35 | struct qxl_head *head) | ||
36 | { | 34 | { |
37 | struct drm_device *dev = connector->dev; | 35 | return head->width && head->height; |
38 | struct drm_display_mode *mode, *t; | ||
39 | int width = head->width; | ||
40 | int height = head->height; | ||
41 | |||
42 | if (width < 320 || height < 240) { | ||
43 | qxl_io_log(qdev, "%s: bad head: %dx%d", width, height); | ||
44 | width = 1024; | ||
45 | height = 768; | ||
46 | } | ||
47 | if (width * height * 4 > 16*1024*1024) { | ||
48 | width = 1024; | ||
49 | height = 768; | ||
50 | } | ||
51 | /* TODO: go over regular modes and removed preferred? */ | ||
52 | list_for_each_entry_safe(mode, t, &connector->probed_modes, head) | ||
53 | drm_mode_remove(connector, mode); | ||
54 | mode = drm_cvt_mode(dev, width, height, 60, false, false, false); | ||
55 | mode->type |= DRM_MODE_TYPE_PREFERRED; | ||
56 | mode->status = MODE_OK; | ||
57 | drm_mode_probed_add(connector, mode); | ||
58 | qxl_io_log(qdev, "%s: %d x %d\n", __func__, width, height); | ||
59 | } | ||
60 | |||
61 | void qxl_crtc_set_from_monitors_config(struct qxl_device *qdev) | ||
62 | { | ||
63 | struct drm_connector *connector; | ||
64 | int i; | ||
65 | struct drm_device *dev = qdev->ddev; | ||
66 | |||
67 | i = 0; | ||
68 | qxl_io_log(qdev, "%s: %d, %d\n", __func__, | ||
69 | dev->mode_config.num_connector, | ||
70 | qdev->monitors_config->count); | ||
71 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | ||
72 | if (i > qdev->monitors_config->count) { | ||
73 | /* crtc will be reported as disabled */ | ||
74 | continue; | ||
75 | } | ||
76 | qxl_crtc_set_to_mode(qdev, connector, | ||
77 | &qdev->monitors_config->heads[i]); | ||
78 | ++i; | ||
79 | } | ||
80 | } | 36 | } |
81 | 37 | ||
82 | void qxl_alloc_client_monitors_config(struct qxl_device *qdev, unsigned count) | 38 | void qxl_alloc_client_monitors_config(struct qxl_device *qdev, unsigned count) |
@@ -106,7 +62,6 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) | |||
106 | int num_monitors; | 62 | int num_monitors; |
107 | uint32_t crc; | 63 | uint32_t crc; |
108 | 64 | ||
109 | BUG_ON(!qdev->monitors_config); | ||
110 | num_monitors = qdev->rom->client_monitors_config.count; | 65 | num_monitors = qdev->rom->client_monitors_config.count; |
111 | crc = crc32(0, (const uint8_t *)&qdev->rom->client_monitors_config, | 66 | crc = crc32(0, (const uint8_t *)&qdev->rom->client_monitors_config, |
112 | sizeof(qdev->rom->client_monitors_config)); | 67 | sizeof(qdev->rom->client_monitors_config)); |
@@ -117,8 +72,8 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) | |||
117 | return 1; | 72 | return 1; |
118 | } | 73 | } |
119 | if (num_monitors > qdev->monitors_config->max_allowed) { | 74 | if (num_monitors > qdev->monitors_config->max_allowed) { |
120 | DRM_INFO("client monitors list will be truncated: %d < %d\n", | 75 | DRM_DEBUG_KMS("client monitors list will be truncated: %d < %d\n", |
121 | qdev->monitors_config->max_allowed, num_monitors); | 76 | qdev->monitors_config->max_allowed, num_monitors); |
122 | num_monitors = qdev->monitors_config->max_allowed; | 77 | num_monitors = qdev->monitors_config->max_allowed; |
123 | } else { | 78 | } else { |
124 | num_monitors = qdev->rom->client_monitors_config.count; | 79 | num_monitors = qdev->rom->client_monitors_config.count; |
@@ -132,18 +87,15 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) | |||
132 | &qdev->rom->client_monitors_config.heads[i]; | 87 | &qdev->rom->client_monitors_config.heads[i]; |
133 | struct qxl_head *client_head = | 88 | struct qxl_head *client_head = |
134 | &qdev->client_monitors_config->heads[i]; | 89 | &qdev->client_monitors_config->heads[i]; |
135 | struct qxl_head *head = &qdev->monitors_config->heads[i]; | 90 | client_head->x = c_rect->left; |
136 | client_head->x = head->x = c_rect->left; | 91 | client_head->y = c_rect->top; |
137 | client_head->y = head->y = c_rect->top; | 92 | client_head->width = c_rect->right - c_rect->left; |
138 | client_head->width = head->width = | 93 | client_head->height = c_rect->bottom - c_rect->top; |
139 | c_rect->right - c_rect->left; | 94 | client_head->surface_id = 0; |
140 | client_head->height = head->height = | 95 | client_head->id = i; |
141 | c_rect->bottom - c_rect->top; | 96 | client_head->flags = 0; |
142 | client_head->surface_id = head->surface_id = 0; | 97 | DRM_DEBUG_KMS("read %dx%d+%d+%d\n", client_head->width, client_head->height, |
143 | client_head->id = head->id = i; | 98 | client_head->x, client_head->y); |
144 | client_head->flags = head->flags = 0; | ||
145 | QXL_DEBUG(qdev, "read %dx%d+%d+%d\n", head->width, head->height, | ||
146 | head->x, head->y); | ||
147 | } | 99 | } |
148 | return 0; | 100 | return 0; |
149 | } | 101 | } |
@@ -155,10 +107,7 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev) | |||
155 | qxl_io_log(qdev, "failed crc check for client_monitors_config," | 107 | qxl_io_log(qdev, "failed crc check for client_monitors_config," |
156 | " retrying\n"); | 108 | " retrying\n"); |
157 | } | 109 | } |
158 | qxl_crtc_set_from_monitors_config(qdev); | 110 | drm_helper_hpd_irq_event(qdev->ddev); |
159 | /* fire off a uevent and let userspace tell us what to do */ | ||
160 | qxl_io_log(qdev, "calling drm_sysfs_hotplug_event\n"); | ||
161 | drm_sysfs_hotplug_event(qdev->ddev); | ||
162 | } | 111 | } |
163 | 112 | ||
164 | static int qxl_add_monitors_config_modes(struct drm_connector *connector) | 113 | static int qxl_add_monitors_config_modes(struct drm_connector *connector) |
@@ -170,9 +119,9 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector) | |||
170 | struct drm_display_mode *mode = NULL; | 119 | struct drm_display_mode *mode = NULL; |
171 | struct qxl_head *head; | 120 | struct qxl_head *head; |
172 | 121 | ||
173 | if (!qdev->monitors_config) | 122 | if (!qdev->client_monitors_config) |
174 | return 0; | 123 | return 0; |
175 | head = &qdev->monitors_config->heads[h]; | 124 | head = &qdev->client_monitors_config->heads[h]; |
176 | 125 | ||
177 | mode = drm_cvt_mode(dev, head->width, head->height, 60, false, false, | 126 | mode = drm_cvt_mode(dev, head->width, head->height, 60, false, false, |
178 | false); | 127 | false); |
@@ -499,7 +448,7 @@ qxl_send_monitors_config(struct qxl_device *qdev) | |||
499 | for (i = 0 ; i < qdev->monitors_config->count ; ++i) { | 448 | for (i = 0 ; i < qdev->monitors_config->count ; ++i) { |
500 | struct qxl_head *head = &qdev->monitors_config->heads[i]; | 449 | struct qxl_head *head = &qdev->monitors_config->heads[i]; |
501 | 450 | ||
502 | if (head->y > 8192 || head->y < head->x || | 451 | if (head->y > 8192 || head->x > 8192 || |
503 | head->width > 8192 || head->height > 8192) { | 452 | head->width > 8192 || head->height > 8192) { |
504 | DRM_ERROR("head %d wrong: %dx%d+%d+%d\n", | 453 | DRM_ERROR("head %d wrong: %dx%d+%d+%d\n", |
505 | i, head->width, head->height, | 454 | i, head->width, head->height, |
@@ -510,16 +459,19 @@ qxl_send_monitors_config(struct qxl_device *qdev) | |||
510 | qxl_io_monitors_config(qdev); | 459 | qxl_io_monitors_config(qdev); |
511 | } | 460 | } |
512 | 461 | ||
513 | static void qxl_monitors_config_set_single(struct qxl_device *qdev, | 462 | static void qxl_monitors_config_set(struct qxl_device *qdev, |
514 | unsigned x, unsigned y, | 463 | int index, |
515 | unsigned width, unsigned height) | 464 | unsigned x, unsigned y, |
465 | unsigned width, unsigned height, | ||
466 | unsigned surf_id) | ||
516 | { | 467 | { |
517 | DRM_DEBUG("%dx%d+%d+%d\n", width, height, x, y); | 468 | DRM_DEBUG_KMS("%d:%dx%d+%d+%d\n", index, width, height, x, y); |
518 | qdev->monitors_config->count = 1; | 469 | qdev->monitors_config->heads[index].x = x; |
519 | qdev->monitors_config->heads[0].x = x; | 470 | qdev->monitors_config->heads[index].y = y; |
520 | qdev->monitors_config->heads[0].y = y; | 471 | qdev->monitors_config->heads[index].width = width; |
521 | qdev->monitors_config->heads[0].width = width; | 472 | qdev->monitors_config->heads[index].height = height; |
522 | qdev->monitors_config->heads[0].height = height; | 473 | qdev->monitors_config->heads[index].surface_id = surf_id; |
474 | |||
523 | } | 475 | } |
524 | 476 | ||
525 | static int qxl_crtc_mode_set(struct drm_crtc *crtc, | 477 | static int qxl_crtc_mode_set(struct drm_crtc *crtc, |
@@ -533,10 +485,11 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc, | |||
533 | struct qxl_mode *m = (void *)mode->private; | 485 | struct qxl_mode *m = (void *)mode->private; |
534 | struct qxl_framebuffer *qfb; | 486 | struct qxl_framebuffer *qfb; |
535 | struct qxl_bo *bo, *old_bo = NULL; | 487 | struct qxl_bo *bo, *old_bo = NULL; |
488 | struct qxl_crtc *qcrtc = to_qxl_crtc(crtc); | ||
536 | uint32_t width, height, base_offset; | 489 | uint32_t width, height, base_offset; |
537 | bool recreate_primary = false; | 490 | bool recreate_primary = false; |
538 | int ret; | 491 | int ret; |
539 | 492 | int surf_id; | |
540 | if (!crtc->fb) { | 493 | if (!crtc->fb) { |
541 | DRM_DEBUG_KMS("No FB bound\n"); | 494 | DRM_DEBUG_KMS("No FB bound\n"); |
542 | return 0; | 495 | return 0; |
@@ -560,7 +513,8 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc, | |||
560 | adjusted_mode->hdisplay, | 513 | adjusted_mode->hdisplay, |
561 | adjusted_mode->vdisplay); | 514 | adjusted_mode->vdisplay); |
562 | 515 | ||
563 | recreate_primary = true; | 516 | if (qcrtc->index == 0) |
517 | recreate_primary = true; | ||
564 | 518 | ||
565 | width = mode->hdisplay; | 519 | width = mode->hdisplay; |
566 | height = mode->vdisplay; | 520 | height = mode->vdisplay; |
@@ -581,8 +535,11 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc, | |||
581 | "recreate primary: %dx%d (was %dx%d,%d,%d)\n", | 535 | "recreate primary: %dx%d (was %dx%d,%d,%d)\n", |
582 | width, height, bo->surf.width, | 536 | width, height, bo->surf.width, |
583 | bo->surf.height, bo->surf.stride, bo->surf.format); | 537 | bo->surf.height, bo->surf.stride, bo->surf.format); |
584 | qxl_io_create_primary(qdev, width, height, base_offset, bo); | 538 | qxl_io_create_primary(qdev, base_offset, bo); |
585 | bo->is_primary = true; | 539 | bo->is_primary = true; |
540 | surf_id = 0; | ||
541 | } else { | ||
542 | surf_id = bo->surface_id; | ||
586 | } | 543 | } |
587 | 544 | ||
588 | if (old_bo && old_bo != bo) { | 545 | if (old_bo && old_bo != bo) { |
@@ -592,11 +549,9 @@ static int qxl_crtc_mode_set(struct drm_crtc *crtc, | |||
592 | qxl_bo_unreserve(old_bo); | 549 | qxl_bo_unreserve(old_bo); |
593 | } | 550 | } |
594 | 551 | ||
595 | if (qdev->monitors_config->count == 0) { | 552 | qxl_monitors_config_set(qdev, qcrtc->index, x, y, |
596 | qxl_monitors_config_set_single(qdev, x, y, | 553 | mode->hdisplay, |
597 | mode->hdisplay, | 554 | mode->vdisplay, surf_id); |
598 | mode->vdisplay); | ||
599 | } | ||
600 | return 0; | 555 | return 0; |
601 | } | 556 | } |
602 | 557 | ||
@@ -612,15 +567,36 @@ static void qxl_crtc_commit(struct drm_crtc *crtc) | |||
612 | DRM_DEBUG("\n"); | 567 | DRM_DEBUG("\n"); |
613 | } | 568 | } |
614 | 569 | ||
570 | static void qxl_crtc_disable(struct drm_crtc *crtc) | ||
571 | { | ||
572 | struct qxl_crtc *qcrtc = to_qxl_crtc(crtc); | ||
573 | struct drm_device *dev = crtc->dev; | ||
574 | struct qxl_device *qdev = dev->dev_private; | ||
575 | if (crtc->fb) { | ||
576 | struct qxl_framebuffer *qfb = to_qxl_framebuffer(crtc->fb); | ||
577 | struct qxl_bo *bo = gem_to_qxl_bo(qfb->obj); | ||
578 | int ret; | ||
579 | ret = qxl_bo_reserve(bo, false); | ||
580 | qxl_bo_unpin(bo); | ||
581 | qxl_bo_unreserve(bo); | ||
582 | crtc->fb = NULL; | ||
583 | } | ||
584 | |||
585 | qxl_monitors_config_set(qdev, qcrtc->index, 0, 0, 0, 0, 0); | ||
586 | |||
587 | qxl_send_monitors_config(qdev); | ||
588 | } | ||
589 | |||
615 | static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = { | 590 | static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = { |
616 | .dpms = qxl_crtc_dpms, | 591 | .dpms = qxl_crtc_dpms, |
592 | .disable = qxl_crtc_disable, | ||
617 | .mode_fixup = qxl_crtc_mode_fixup, | 593 | .mode_fixup = qxl_crtc_mode_fixup, |
618 | .mode_set = qxl_crtc_mode_set, | 594 | .mode_set = qxl_crtc_mode_set, |
619 | .prepare = qxl_crtc_prepare, | 595 | .prepare = qxl_crtc_prepare, |
620 | .commit = qxl_crtc_commit, | 596 | .commit = qxl_crtc_commit, |
621 | }; | 597 | }; |
622 | 598 | ||
623 | static int qdev_crtc_init(struct drm_device *dev, int num_crtc) | 599 | static int qdev_crtc_init(struct drm_device *dev, int crtc_id) |
624 | { | 600 | { |
625 | struct qxl_crtc *qxl_crtc; | 601 | struct qxl_crtc *qxl_crtc; |
626 | 602 | ||
@@ -629,7 +605,7 @@ static int qdev_crtc_init(struct drm_device *dev, int num_crtc) | |||
629 | return -ENOMEM; | 605 | return -ENOMEM; |
630 | 606 | ||
631 | drm_crtc_init(dev, &qxl_crtc->base, &qxl_crtc_funcs); | 607 | drm_crtc_init(dev, &qxl_crtc->base, &qxl_crtc_funcs); |
632 | 608 | qxl_crtc->index = crtc_id; | |
633 | drm_mode_crtc_set_gamma_size(&qxl_crtc->base, 256); | 609 | drm_mode_crtc_set_gamma_size(&qxl_crtc->base, 256); |
634 | drm_crtc_helper_add(&qxl_crtc->base, &qxl_crtc_helper_funcs); | 610 | drm_crtc_helper_add(&qxl_crtc->base, &qxl_crtc_helper_funcs); |
635 | return 0; | 611 | return 0; |
@@ -657,18 +633,13 @@ static void qxl_write_monitors_config_for_encoder(struct qxl_device *qdev, | |||
657 | struct drm_encoder *encoder) | 633 | struct drm_encoder *encoder) |
658 | { | 634 | { |
659 | int i; | 635 | int i; |
636 | struct qxl_output *output = drm_encoder_to_qxl_output(encoder); | ||
660 | struct qxl_head *head; | 637 | struct qxl_head *head; |
661 | struct drm_display_mode *mode; | 638 | struct drm_display_mode *mode; |
662 | 639 | ||
663 | BUG_ON(!encoder); | 640 | BUG_ON(!encoder); |
664 | /* TODO: ugly, do better */ | 641 | /* TODO: ugly, do better */ |
665 | for (i = 0 ; (encoder->possible_crtcs != (1 << i)) && i < 32; ++i) | 642 | i = output->index; |
666 | ; | ||
667 | if (encoder->possible_crtcs != (1 << i)) { | ||
668 | DRM_ERROR("encoder has wrong possible_crtcs: %x\n", | ||
669 | encoder->possible_crtcs); | ||
670 | return; | ||
671 | } | ||
672 | if (!qdev->monitors_config || | 643 | if (!qdev->monitors_config || |
673 | qdev->monitors_config->max_allowed <= i) { | 644 | qdev->monitors_config->max_allowed <= i) { |
674 | DRM_ERROR( | 645 | DRM_ERROR( |
@@ -686,7 +657,6 @@ static void qxl_write_monitors_config_for_encoder(struct qxl_device *qdev, | |||
686 | DRM_DEBUG("missing for multiple monitors: no head holes\n"); | 657 | DRM_DEBUG("missing for multiple monitors: no head holes\n"); |
687 | head = &qdev->monitors_config->heads[i]; | 658 | head = &qdev->monitors_config->heads[i]; |
688 | head->id = i; | 659 | head->id = i; |
689 | head->surface_id = 0; | ||
690 | if (encoder->crtc->enabled) { | 660 | if (encoder->crtc->enabled) { |
691 | mode = &encoder->crtc->mode; | 661 | mode = &encoder->crtc->mode; |
692 | head->width = mode->hdisplay; | 662 | head->width = mode->hdisplay; |
@@ -701,8 +671,8 @@ static void qxl_write_monitors_config_for_encoder(struct qxl_device *qdev, | |||
701 | head->x = 0; | 671 | head->x = 0; |
702 | head->y = 0; | 672 | head->y = 0; |
703 | } | 673 | } |
704 | DRM_DEBUG("setting head %d to +%d+%d %dx%d\n", | 674 | DRM_DEBUG_KMS("setting head %d to +%d+%d %dx%d out of %d\n", |
705 | i, head->x, head->y, head->width, head->height); | 675 | i, head->x, head->y, head->width, head->height, qdev->monitors_config->count); |
706 | head->flags = 0; | 676 | head->flags = 0; |
707 | /* TODO - somewhere else to call this for multiple monitors | 677 | /* TODO - somewhere else to call this for multiple monitors |
708 | * (config_commit?) */ | 678 | * (config_commit?) */ |
@@ -797,8 +767,9 @@ static enum drm_connector_status qxl_conn_detect( | |||
797 | 767 | ||
798 | /* The first monitor is always connected */ | 768 | /* The first monitor is always connected */ |
799 | connected = (output->index == 0) || | 769 | connected = (output->index == 0) || |
800 | (qdev->monitors_config && | 770 | (qdev->client_monitors_config && |
801 | qdev->monitors_config->count > output->index); | 771 | qdev->client_monitors_config->count > output->index && |
772 | qxl_head_enabled(&qdev->client_monitors_config->heads[output->index])); | ||
802 | 773 | ||
803 | DRM_DEBUG("\n"); | 774 | DRM_DEBUG("\n"); |
804 | return connected ? connector_status_connected | 775 | return connected ? connector_status_connected |
@@ -862,6 +833,8 @@ static int qdev_output_init(struct drm_device *dev, int num_output) | |||
862 | drm_encoder_init(dev, &qxl_output->enc, &qxl_enc_funcs, | 833 | drm_encoder_init(dev, &qxl_output->enc, &qxl_enc_funcs, |
863 | DRM_MODE_ENCODER_VIRTUAL); | 834 | DRM_MODE_ENCODER_VIRTUAL); |
864 | 835 | ||
836 | /* we get HPD via client monitors config */ | ||
837 | connector->polled = DRM_CONNECTOR_POLL_HPD; | ||
865 | encoder->possible_crtcs = 1 << num_output; | 838 | encoder->possible_crtcs = 1 << num_output; |
866 | drm_mode_connector_attach_encoder(&qxl_output->base, | 839 | drm_mode_connector_attach_encoder(&qxl_output->base, |
867 | &qxl_output->enc); | 840 | &qxl_output->enc); |
@@ -901,16 +874,14 @@ static const struct drm_mode_config_funcs qxl_mode_funcs = { | |||
901 | .fb_create = qxl_user_framebuffer_create, | 874 | .fb_create = qxl_user_framebuffer_create, |
902 | }; | 875 | }; |
903 | 876 | ||
904 | int qxl_modeset_init(struct qxl_device *qdev) | 877 | int qxl_create_monitors_object(struct qxl_device *qdev) |
905 | { | 878 | { |
906 | int i; | ||
907 | int ret; | 879 | int ret; |
908 | struct drm_gem_object *gobj; | 880 | struct drm_gem_object *gobj; |
909 | int max_allowed = QXL_NUM_OUTPUTS; | 881 | int max_allowed = qxl_num_crtc; |
910 | int monitors_config_size = sizeof(struct qxl_monitors_config) + | 882 | int monitors_config_size = sizeof(struct qxl_monitors_config) + |
911 | max_allowed * sizeof(struct qxl_head); | 883 | max_allowed * sizeof(struct qxl_head); |
912 | 884 | ||
913 | drm_mode_config_init(qdev->ddev); | ||
914 | ret = qxl_gem_object_create(qdev, monitors_config_size, 0, | 885 | ret = qxl_gem_object_create(qdev, monitors_config_size, 0, |
915 | QXL_GEM_DOMAIN_VRAM, | 886 | QXL_GEM_DOMAIN_VRAM, |
916 | false, false, NULL, &gobj); | 887 | false, false, NULL, &gobj); |
@@ -919,13 +890,59 @@ int qxl_modeset_init(struct qxl_device *qdev) | |||
919 | return -ENOMEM; | 890 | return -ENOMEM; |
920 | } | 891 | } |
921 | qdev->monitors_config_bo = gem_to_qxl_bo(gobj); | 892 | qdev->monitors_config_bo = gem_to_qxl_bo(gobj); |
893 | |||
894 | ret = qxl_bo_reserve(qdev->monitors_config_bo, false); | ||
895 | if (ret) | ||
896 | return ret; | ||
897 | |||
898 | ret = qxl_bo_pin(qdev->monitors_config_bo, QXL_GEM_DOMAIN_VRAM, NULL); | ||
899 | if (ret) { | ||
900 | qxl_bo_unreserve(qdev->monitors_config_bo); | ||
901 | return ret; | ||
902 | } | ||
903 | |||
904 | qxl_bo_unreserve(qdev->monitors_config_bo); | ||
905 | |||
922 | qxl_bo_kmap(qdev->monitors_config_bo, NULL); | 906 | qxl_bo_kmap(qdev->monitors_config_bo, NULL); |
907 | |||
923 | qdev->monitors_config = qdev->monitors_config_bo->kptr; | 908 | qdev->monitors_config = qdev->monitors_config_bo->kptr; |
924 | qdev->ram_header->monitors_config = | 909 | qdev->ram_header->monitors_config = |
925 | qxl_bo_physical_address(qdev, qdev->monitors_config_bo, 0); | 910 | qxl_bo_physical_address(qdev, qdev->monitors_config_bo, 0); |
926 | 911 | ||
927 | memset(qdev->monitors_config, 0, monitors_config_size); | 912 | memset(qdev->monitors_config, 0, monitors_config_size); |
928 | qdev->monitors_config->max_allowed = max_allowed; | 913 | qdev->monitors_config->max_allowed = max_allowed; |
914 | return 0; | ||
915 | } | ||
916 | |||
917 | int qxl_destroy_monitors_object(struct qxl_device *qdev) | ||
918 | { | ||
919 | int ret; | ||
920 | |||
921 | qdev->monitors_config = NULL; | ||
922 | qdev->ram_header->monitors_config = 0; | ||
923 | |||
924 | qxl_bo_kunmap(qdev->monitors_config_bo); | ||
925 | ret = qxl_bo_reserve(qdev->monitors_config_bo, false); | ||
926 | if (ret) | ||
927 | return ret; | ||
928 | |||
929 | qxl_bo_unpin(qdev->monitors_config_bo); | ||
930 | qxl_bo_unreserve(qdev->monitors_config_bo); | ||
931 | |||
932 | qxl_bo_unref(&qdev->monitors_config_bo); | ||
933 | return 0; | ||
934 | } | ||
935 | |||
936 | int qxl_modeset_init(struct qxl_device *qdev) | ||
937 | { | ||
938 | int i; | ||
939 | int ret; | ||
940 | |||
941 | drm_mode_config_init(qdev->ddev); | ||
942 | |||
943 | ret = qxl_create_monitors_object(qdev); | ||
944 | if (ret) | ||
945 | return ret; | ||
929 | 946 | ||
930 | qdev->ddev->mode_config.funcs = (void *)&qxl_mode_funcs; | 947 | qdev->ddev->mode_config.funcs = (void *)&qxl_mode_funcs; |
931 | 948 | ||
@@ -936,7 +953,7 @@ int qxl_modeset_init(struct qxl_device *qdev) | |||
936 | qdev->ddev->mode_config.max_height = 8192; | 953 | qdev->ddev->mode_config.max_height = 8192; |
937 | 954 | ||
938 | qdev->ddev->mode_config.fb_base = qdev->vram_base; | 955 | qdev->ddev->mode_config.fb_base = qdev->vram_base; |
939 | for (i = 0 ; i < QXL_NUM_OUTPUTS; ++i) { | 956 | for (i = 0 ; i < qxl_num_crtc; ++i) { |
940 | qdev_crtc_init(qdev->ddev, i); | 957 | qdev_crtc_init(qdev->ddev, i); |
941 | qdev_output_init(qdev->ddev, i); | 958 | qdev_output_init(qdev->ddev, i); |
942 | } | 959 | } |
@@ -953,6 +970,8 @@ int qxl_modeset_init(struct qxl_device *qdev) | |||
953 | void qxl_modeset_fini(struct qxl_device *qdev) | 970 | void qxl_modeset_fini(struct qxl_device *qdev) |
954 | { | 971 | { |
955 | qxl_fbdev_fini(qdev); | 972 | qxl_fbdev_fini(qdev); |
973 | |||
974 | qxl_destroy_monitors_object(qdev); | ||
956 | if (qdev->mode_info.mode_config_initialized) { | 975 | if (qdev->mode_info.mode_config_initialized) { |
957 | drm_mode_config_cleanup(qdev->ddev); | 976 | drm_mode_config_cleanup(qdev->ddev); |
958 | qdev->mode_info.mode_config_initialized = false; | 977 | qdev->mode_info.mode_config_initialized = false; |