Lines Matching +full:has +full:- +full:legacy +full:- +full:mode
2 * Copyright (c) 2006-2008 Intel Corporation
36 #include <linux/dma-fence.h>
68 * The CRTC is also the entry point for legacy modeset operations (see
69 * &drm_crtc_funcs.set_config), legacy plane operations (see
70 * &drm_crtc_funcs.page_flip and &drm_crtc_funcs.cursor_set2), and other legacy
77 * drm_crtc_from_index - find the registered CRTC at an index
92 if (idx == crtc->index) in drm_crtc_from_index()
105 WARN_ON(drm_drv_uses_atomic_modeset(crtc->dev)); in drm_crtc_force_disable()
118 if (crtc->funcs->late_register) in drm_crtc_register_all()
119 ret = crtc->funcs->late_register(crtc); in drm_crtc_register_all()
132 if (crtc->funcs->early_unregister) in drm_crtc_unregister_all()
133 crtc->funcs->early_unregister(crtc); in drm_crtc_unregister_all()
141 spin_lock_init(&crtc->crc.lock); in drm_crtc_crc_init()
142 init_waitqueue_head(&crtc->crc.wq); in drm_crtc_crc_init()
143 crtc->crc.source = kstrdup("auto", GFP_KERNEL); in drm_crtc_crc_init()
144 if (!crtc->crc.source) in drm_crtc_crc_init()
145 return -ENOMEM; in drm_crtc_crc_init()
153 kfree(crtc->crc.source); in drm_crtc_crc_fini()
161 BUG_ON(fence->ops != &drm_crtc_fence_ops); in fence_to_crtc()
162 return container_of(fence->lock, struct drm_crtc, fence_lock); in fence_to_crtc()
169 return crtc->dev->driver->name; in drm_crtc_fence_get_driver_name()
176 return crtc->timeline_name; in drm_crtc_fence_get_timeline_name()
192 dma_fence_init(fence, &drm_crtc_fence_ops, &crtc->fence_lock, in drm_crtc_create_fence()
193 crtc->fence_context, ++crtc->fence_seqno); in drm_crtc_create_fence()
206 * powered off. There is no expectation that user-space will reset CRTC
207 * resources like the mode and planes when setting ACTIVE to 0.
209 * User-space can rely on an ACTIVE change to 1 to never fail an atomic
210 * test as long as no other property has changed. If a change to ACTIVE
215 * Note that the legacy DPMS property on connectors is internally routed
219 * ID of a blob containing the DRM mode info. To disable the CRTC,
220 * user-space must set this property to 0.
241 struct drm_mode_config *config = &dev->mode_config; in __drm_crtc_init_with_planes()
244 WARN_ON(primary && primary->type != DRM_PLANE_TYPE_PRIMARY); in __drm_crtc_init_with_planes()
245 WARN_ON(cursor && cursor->type != DRM_PLANE_TYPE_CURSOR); in __drm_crtc_init_with_planes()
248 if (WARN_ON(config->num_crtc >= 32)) in __drm_crtc_init_with_planes()
249 return -EINVAL; in __drm_crtc_init_with_planes()
252 (!funcs->atomic_destroy_state || in __drm_crtc_init_with_planes()
253 !funcs->atomic_duplicate_state)); in __drm_crtc_init_with_planes()
255 crtc->dev = dev; in __drm_crtc_init_with_planes()
256 crtc->funcs = funcs; in __drm_crtc_init_with_planes()
258 INIT_LIST_HEAD(&crtc->commit_list); in __drm_crtc_init_with_planes()
259 spin_lock_init(&crtc->commit_lock); in __drm_crtc_init_with_planes()
261 drm_modeset_lock_init(&crtc->mutex); in __drm_crtc_init_with_planes()
262 ret = drm_mode_object_add(dev, &crtc->base, DRM_MODE_OBJECT_CRTC); in __drm_crtc_init_with_planes()
267 crtc->name = kvasprintf(GFP_KERNEL, name, ap); in __drm_crtc_init_with_planes()
269 crtc->name = kasprintf(GFP_KERNEL, "crtc-%d", config->num_crtc); in __drm_crtc_init_with_planes()
271 if (!crtc->name) { in __drm_crtc_init_with_planes()
272 drm_mode_object_unregister(dev, &crtc->base); in __drm_crtc_init_with_planes()
273 return -ENOMEM; in __drm_crtc_init_with_planes()
276 crtc->fence_context = dma_fence_context_alloc(1); in __drm_crtc_init_with_planes()
277 spin_lock_init(&crtc->fence_lock); in __drm_crtc_init_with_planes()
278 snprintf(crtc->timeline_name, sizeof(crtc->timeline_name), in __drm_crtc_init_with_planes()
279 "CRTC:%d-%s", crtc->base.id, crtc->name); in __drm_crtc_init_with_planes()
281 crtc->base.properties = &crtc->properties; in __drm_crtc_init_with_planes()
283 list_add_tail(&crtc->head, &config->crtc_list); in __drm_crtc_init_with_planes()
284 crtc->index = config->num_crtc++; in __drm_crtc_init_with_planes()
286 crtc->primary = primary; in __drm_crtc_init_with_planes()
287 crtc->cursor = cursor; in __drm_crtc_init_with_planes()
288 if (primary && !primary->possible_crtcs) in __drm_crtc_init_with_planes()
289 primary->possible_crtcs = drm_crtc_mask(crtc); in __drm_crtc_init_with_planes()
290 if (cursor && !cursor->possible_crtcs) in __drm_crtc_init_with_planes()
291 cursor->possible_crtcs = drm_crtc_mask(crtc); in __drm_crtc_init_with_planes()
295 drm_mode_object_unregister(dev, &crtc->base); in __drm_crtc_init_with_planes()
300 drm_object_attach_property(&crtc->base, config->prop_active, 0); in __drm_crtc_init_with_planes()
301 drm_object_attach_property(&crtc->base, config->prop_mode_id, 0); in __drm_crtc_init_with_planes()
302 drm_object_attach_property(&crtc->base, in __drm_crtc_init_with_planes()
303 config->prop_out_fence_ptr, 0); in __drm_crtc_init_with_planes()
304 drm_object_attach_property(&crtc->base, in __drm_crtc_init_with_planes()
305 config->prop_vrr_enabled, 0); in __drm_crtc_init_with_planes()
312 * drm_crtc_init_with_planes - Initialise a new CRTC object with
324 * planes). For really simple hardware which has only 1 plane look at
330 * The @primary and @cursor planes are only relevant for legacy uAPI, see
350 WARN_ON(!funcs->destroy); in drm_crtc_init_with_planes()
380 drm_WARN_ON(dev, funcs && funcs->destroy); in __drmm_crtc_init_with_planes()
396 * drmm_crtc_init_with_planes - Initialise a new CRTC object with
408 * planes). For really simple hardware which has only 1 plane look at
417 * The @primary and @cursor planes are only relevant for legacy uAPI, see
455 if (WARN_ON(!funcs || funcs->destroy)) in __drmm_crtc_alloc_with_planes()
456 return ERR_PTR(-EINVAL); in __drmm_crtc_alloc_with_planes()
460 return ERR_PTR(-ENOMEM); in __drmm_crtc_alloc_with_planes()
476 * drm_crtc_cleanup - Clean up the core crtc usage
479 * This function cleans up @crtc and removes it from the DRM mode setting
485 struct drm_device *dev = crtc->dev; in drm_crtc_cleanup()
494 kfree(crtc->gamma_store); in drm_crtc_cleanup()
495 crtc->gamma_store = NULL; in drm_crtc_cleanup()
497 drm_modeset_lock_fini(&crtc->mutex); in drm_crtc_cleanup()
499 drm_mode_object_unregister(dev, &crtc->base); in drm_crtc_cleanup()
500 list_del(&crtc->head); in drm_crtc_cleanup()
501 dev->mode_config.num_crtc--; in drm_crtc_cleanup()
503 WARN_ON(crtc->state && !crtc->funcs->atomic_destroy_state); in drm_crtc_cleanup()
504 if (crtc->state && crtc->funcs->atomic_destroy_state) in drm_crtc_cleanup()
505 crtc->funcs->atomic_destroy_state(crtc, crtc->state); in drm_crtc_cleanup()
507 kfree(crtc->name); in drm_crtc_cleanup()
514 * drm_mode_getcrtc - get CRTC configuration
534 return -EOPNOTSUPP; in drm_mode_getcrtc()
536 crtc = drm_crtc_find(dev, file_priv, crtc_resp->crtc_id); in drm_mode_getcrtc()
538 return -ENOENT; in drm_mode_getcrtc()
540 plane = crtc->primary; in drm_mode_getcrtc()
542 crtc_resp->gamma_size = crtc->gamma_size; in drm_mode_getcrtc()
544 drm_modeset_lock(&plane->mutex, NULL); in drm_mode_getcrtc()
545 if (plane->state && plane->state->fb) in drm_mode_getcrtc()
546 crtc_resp->fb_id = plane->state->fb->base.id; in drm_mode_getcrtc()
547 else if (!plane->state && plane->fb) in drm_mode_getcrtc()
548 crtc_resp->fb_id = plane->fb->base.id; in drm_mode_getcrtc()
550 crtc_resp->fb_id = 0; in drm_mode_getcrtc()
552 if (plane->state) { in drm_mode_getcrtc()
553 crtc_resp->x = plane->state->src_x >> 16; in drm_mode_getcrtc()
554 crtc_resp->y = plane->state->src_y >> 16; in drm_mode_getcrtc()
556 drm_modeset_unlock(&plane->mutex); in drm_mode_getcrtc()
558 drm_modeset_lock(&crtc->mutex, NULL); in drm_mode_getcrtc()
559 if (crtc->state) { in drm_mode_getcrtc()
560 if (crtc->state->enable) { in drm_mode_getcrtc()
561 drm_mode_convert_to_umode(&crtc_resp->mode, &crtc->state->mode); in drm_mode_getcrtc()
562 crtc_resp->mode_valid = 1; in drm_mode_getcrtc()
564 crtc_resp->mode_valid = 0; in drm_mode_getcrtc()
567 crtc_resp->x = crtc->x; in drm_mode_getcrtc()
568 crtc_resp->y = crtc->y; in drm_mode_getcrtc()
570 if (crtc->enabled) { in drm_mode_getcrtc()
571 drm_mode_convert_to_umode(&crtc_resp->mode, &crtc->mode); in drm_mode_getcrtc()
572 crtc_resp->mode_valid = 1; in drm_mode_getcrtc()
575 crtc_resp->mode_valid = 0; in drm_mode_getcrtc()
578 if (!file_priv->aspect_ratio_allowed) in drm_mode_getcrtc()
579 crtc_resp->mode.flags &= ~DRM_MODE_FLAG_PIC_AR_MASK; in drm_mode_getcrtc()
580 drm_modeset_unlock(&crtc->mutex); in drm_mode_getcrtc()
588 struct drm_crtc *crtc = set->crtc; in __drm_mode_set_config_internal()
593 WARN_ON(drm_drv_uses_atomic_modeset(crtc->dev)); in __drm_mode_set_config_internal()
596 * NOTE: ->set_config can also disable other crtcs (if we steal all in __drm_mode_set_config_internal()
600 drm_for_each_crtc(tmp, crtc->dev) { in __drm_mode_set_config_internal()
601 struct drm_plane *plane = tmp->primary; in __drm_mode_set_config_internal()
603 plane->old_fb = plane->fb; in __drm_mode_set_config_internal()
606 fb = set->fb; in __drm_mode_set_config_internal()
608 ret = crtc->funcs->set_config(set, ctx); in __drm_mode_set_config_internal()
610 struct drm_plane *plane = crtc->primary; in __drm_mode_set_config_internal()
612 plane->crtc = fb ? crtc : NULL; in __drm_mode_set_config_internal()
613 plane->fb = fb; in __drm_mode_set_config_internal()
616 drm_for_each_crtc(tmp, crtc->dev) { in __drm_mode_set_config_internal()
617 struct drm_plane *plane = tmp->primary; in __drm_mode_set_config_internal()
619 if (plane->fb) in __drm_mode_set_config_internal()
620 drm_framebuffer_get(plane->fb); in __drm_mode_set_config_internal()
621 if (plane->old_fb) in __drm_mode_set_config_internal()
622 drm_framebuffer_put(plane->old_fb); in __drm_mode_set_config_internal()
623 plane->old_fb = NULL; in __drm_mode_set_config_internal()
630 * drm_mode_set_config_internal - helper to call &drm_mode_config_funcs.set_config
637 * This should only be used by non-atomic legacy drivers.
644 WARN_ON(drm_drv_uses_atomic_modeset(set->crtc->dev)); in drm_mode_set_config_internal()
651 * drm_crtc_check_viewport - Checks that a framebuffer is big enough for the
656 * @mode: mode that framebuffer will be displayed under
661 const struct drm_display_mode *mode, in drm_crtc_check_viewport() argument
667 drm_mode_get_hv_timing(mode, &hdisplay, &vdisplay); in drm_crtc_check_viewport()
669 if (crtc->state && in drm_crtc_check_viewport()
670 drm_rotation_90_or_270(crtc->primary->state->rotation)) in drm_crtc_check_viewport()
680 * drm_mode_setcrtc - set CRTC configuration
695 struct drm_mode_config *config = &dev->mode_config; in drm_mode_setcrtc()
701 struct drm_display_mode *mode = NULL; in drm_mode_setcrtc() local
708 return -EOPNOTSUPP; in drm_mode_setcrtc()
714 if (crtc_req->x & 0xffff0000 || crtc_req->y & 0xffff0000) in drm_mode_setcrtc()
715 return -ERANGE; in drm_mode_setcrtc()
717 crtc = drm_crtc_find(dev, file_priv, crtc_req->crtc_id); in drm_mode_setcrtc()
719 drm_dbg_kms(dev, "Unknown CRTC ID %d\n", crtc_req->crtc_id); in drm_mode_setcrtc()
720 return -ENOENT; in drm_mode_setcrtc()
722 drm_dbg_kms(dev, "[CRTC:%d:%s]\n", crtc->base.id, crtc->name); in drm_mode_setcrtc()
724 plane = crtc->primary; in drm_mode_setcrtc()
727 if (crtc_req->mode_valid && !drm_lease_held(file_priv, plane->base.id)) in drm_mode_setcrtc()
728 return -EACCES; in drm_mode_setcrtc()
733 if (crtc_req->mode_valid) { in drm_mode_setcrtc()
734 /* If we have a mode we need a framebuffer. */ in drm_mode_setcrtc()
735 /* If we pass -1, set the mode with the currently bound fb */ in drm_mode_setcrtc()
736 if (crtc_req->fb_id == -1) { in drm_mode_setcrtc()
739 if (plane->state) in drm_mode_setcrtc()
740 old_fb = plane->state->fb; in drm_mode_setcrtc()
742 old_fb = plane->fb; in drm_mode_setcrtc()
746 ret = -EINVAL; in drm_mode_setcrtc()
754 fb = drm_framebuffer_lookup(dev, file_priv, crtc_req->fb_id); in drm_mode_setcrtc()
757 crtc_req->fb_id); in drm_mode_setcrtc()
758 ret = -ENOENT; in drm_mode_setcrtc()
763 mode = drm_mode_create(dev); in drm_mode_setcrtc()
764 if (!mode) { in drm_mode_setcrtc()
765 ret = -ENOMEM; in drm_mode_setcrtc()
768 if (!file_priv->aspect_ratio_allowed && in drm_mode_setcrtc()
769 (crtc_req->mode.flags & DRM_MODE_FLAG_PIC_AR_MASK) != DRM_MODE_FLAG_PIC_AR_NONE) { in drm_mode_setcrtc()
770 drm_dbg_kms(dev, "Unexpected aspect-ratio flag bits\n"); in drm_mode_setcrtc()
771 ret = -EINVAL; in drm_mode_setcrtc()
776 ret = drm_mode_convert_umode(dev, mode, &crtc_req->mode); in drm_mode_setcrtc()
778 drm_dbg_kms(dev, "Invalid mode (%s, %pe): " DRM_MODE_FMT "\n", in drm_mode_setcrtc()
779 drm_get_mode_status_name(mode->status), in drm_mode_setcrtc()
780 ERR_PTR(ret), DRM_MODE_ARG(mode)); in drm_mode_setcrtc()
791 if (!plane->format_default) { in drm_mode_setcrtc()
792 if (!drm_plane_has_format(plane, fb->format->format, fb->modifier)) { in drm_mode_setcrtc()
794 &fb->format->format, fb->modifier); in drm_mode_setcrtc()
795 ret = -EINVAL; in drm_mode_setcrtc()
800 ret = drm_crtc_check_viewport(crtc, crtc_req->x, crtc_req->y, in drm_mode_setcrtc()
801 mode, fb); in drm_mode_setcrtc()
807 if (crtc_req->count_connectors == 0 && mode) { in drm_mode_setcrtc()
808 drm_dbg_kms(dev, "Count connectors is 0 but mode set\n"); in drm_mode_setcrtc()
809 ret = -EINVAL; in drm_mode_setcrtc()
813 if (crtc_req->count_connectors > 0 && (!mode || !fb)) { in drm_mode_setcrtc()
814 drm_dbg_kms(dev, "Count connectors is %d but no mode or fb set\n", in drm_mode_setcrtc()
815 crtc_req->count_connectors); in drm_mode_setcrtc()
816 ret = -EINVAL; in drm_mode_setcrtc()
820 if (crtc_req->count_connectors > 0) { in drm_mode_setcrtc()
824 if (crtc_req->count_connectors > config->num_connector) { in drm_mode_setcrtc()
825 ret = -EINVAL; in drm_mode_setcrtc()
829 connector_set = kmalloc_array(crtc_req->count_connectors, in drm_mode_setcrtc()
833 ret = -ENOMEM; in drm_mode_setcrtc()
837 for (i = 0; i < crtc_req->count_connectors; i++) { in drm_mode_setcrtc()
839 set_connectors_ptr = (uint32_t __user *)(unsigned long)crtc_req->set_connectors_ptr; in drm_mode_setcrtc()
841 ret = -EFAULT; in drm_mode_setcrtc()
849 ret = -ENOENT; in drm_mode_setcrtc()
853 connector->base.id, connector->name); in drm_mode_setcrtc()
861 set.x = crtc_req->x; in drm_mode_setcrtc()
862 set.y = crtc_req->y; in drm_mode_setcrtc()
863 set.mode = mode; in drm_mode_setcrtc()
869 ret = crtc->funcs->set_config(&set, &ctx); in drm_mode_setcrtc()
884 drm_mode_destroy(dev, mode); in drm_mode_setcrtc()
889 mode = NULL; in drm_mode_setcrtc()
901 int ret = -EINVAL; in drm_mode_crtc_set_obj_prop()
904 if (crtc->funcs->set_property) in drm_mode_crtc_set_obj_prop()
905 ret = crtc->funcs->set_property(crtc, property, value); in drm_mode_crtc_set_obj_prop()
913 * drm_crtc_create_scaling_filter_property - create a new scaling filter
924 * Zero for success or -errno
930 drm_create_scaling_filter_prop(crtc->dev, supported_filters); in drm_crtc_create_scaling_filter_property()
935 drm_object_attach_property(&crtc->base, prop, in drm_crtc_create_scaling_filter_property()
937 crtc->scaling_filter_property = prop; in drm_crtc_create_scaling_filter_property()