Lines Matching full:fb
78 const struct drm_framebuffer *fb) in drm_framebuffer_check_src_coords() argument
82 fb_width = fb->width << 16; in drm_framebuffer_check_src_coords()
83 fb_height = fb->height << 16; in drm_framebuffer_check_src_coords()
85 /* Make sure source coordinates are inside the fb. */ in drm_framebuffer_check_src_coords()
90 drm_dbg_kms(fb->dev, "Invalid source coordinates " in drm_framebuffer_check_src_coords()
91 "%u.%06ux%u.%06u+%u.%06u+%u.%06u (fb %ux%u)\n", in drm_framebuffer_check_src_coords()
96 fb->width, fb->height); in drm_framebuffer_check_src_coords()
105 * drm_mode_addfb - add an FB to the graphics configuration
110 * Add a new FB to the specified CRTC, given a user request. This is the
199 drm_dbg_kms(dev, "bad fb modifier %llu for plane %d\n", in framebuffer_check()
206 drm_dbg_kms(dev, "bad fb modifier %llu for plane %d\n", in framebuffer_check()
266 struct drm_framebuffer *fb; in drm_internal_framebuffer_create() local
287 drm_dbg_kms(dev, "driver does not support fb modifiers\n"); in drm_internal_framebuffer_create()
305 fb = dev->mode_config.funcs->fb_create(dev, file_priv, info, r); in drm_internal_framebuffer_create()
306 if (IS_ERR(fb)) { in drm_internal_framebuffer_create()
308 return fb; in drm_internal_framebuffer_create()
311 return fb; in drm_internal_framebuffer_create()
316 * drm_mode_addfb2 - add an FB to the graphics configuration
321 * Add a new FB to the specified CRTC, given a user request with format. This is
334 struct drm_framebuffer *fb; in drm_mode_addfb2() local
339 fb = drm_internal_framebuffer_create(dev, r, file_priv); in drm_mode_addfb2()
340 if (IS_ERR(fb)) in drm_mode_addfb2()
341 return PTR_ERR(fb); in drm_mode_addfb2()
343 drm_dbg_kms(dev, "[FB:%d]\n", fb->base.id); in drm_mode_addfb2()
344 r->fb_id = fb->base.id; in drm_mode_addfb2()
348 list_add(&fb->filp_head, &file_priv->fbs); in drm_mode_addfb2()
388 struct drm_framebuffer *fb = in drm_mode_rmfb_work_fn() local
389 list_first_entry(&arg->fbs, typeof(*fb), filp_head); in drm_mode_rmfb_work_fn()
391 drm_dbg_kms(fb->dev, in drm_mode_rmfb_work_fn()
392 "Removing [FB:%d] from all active usage due to RMFB ioctl\n", in drm_mode_rmfb_work_fn()
393 fb->base.id); in drm_mode_rmfb_work_fn()
394 list_del_init(&fb->filp_head); in drm_mode_rmfb_work_fn()
395 drm_framebuffer_remove(fb); in drm_mode_rmfb_work_fn()
399 static int drm_mode_closefb(struct drm_framebuffer *fb, in drm_mode_closefb() argument
407 if (fb == fbl) in drm_mode_closefb()
415 list_del_init(&fb->filp_head); in drm_mode_closefb()
419 drm_framebuffer_put(fb); in drm_mode_closefb()
425 * drm_mode_rmfb - remove an FB from the configuration
430 * Remove the specified FB.
440 struct drm_framebuffer *fb; in drm_mode_rmfb() local
446 fb = drm_framebuffer_lookup(dev, file_priv, fb_id); in drm_mode_rmfb()
447 if (!fb) in drm_mode_rmfb()
450 ret = drm_mode_closefb(fb, file_priv); in drm_mode_rmfb()
452 drm_framebuffer_put(fb); in drm_mode_rmfb()
459 * handle this after the fb is already removed from the lookup table. in drm_mode_rmfb()
461 if (drm_framebuffer_read_refcount(fb) > 1) { in drm_mode_rmfb()
466 drm_WARN_ON(dev, !list_empty(&fb->filp_head)); in drm_mode_rmfb()
467 list_add_tail(&fb->filp_head, &arg.fbs); in drm_mode_rmfb()
473 drm_framebuffer_put(fb); in drm_mode_rmfb()
490 struct drm_framebuffer *fb; in drm_mode_closefb_ioctl() local
499 fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id); in drm_mode_closefb_ioctl()
500 if (!fb) in drm_mode_closefb_ioctl()
503 ret = drm_mode_closefb(fb, file_priv); in drm_mode_closefb_ioctl()
504 drm_framebuffer_put(fb); in drm_mode_closefb_ioctl()
509 * drm_mode_getfb - get FB info
514 * Lookup the FB given its ID and return info about it.
525 struct drm_framebuffer *fb; in drm_mode_getfb() local
531 fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id); in drm_mode_getfb()
532 if (!fb) in drm_mode_getfb()
536 if (fb->format->num_planes > 1) { in drm_mode_getfb()
541 if (!fb->funcs->create_handle) { in drm_mode_getfb()
546 r->height = fb->height; in drm_mode_getfb()
547 r->width = fb->width; in drm_mode_getfb()
548 r->depth = fb->format->depth; in drm_mode_getfb()
549 r->bpp = drm_format_info_bpp(fb->format, 0); in drm_mode_getfb()
550 r->pitch = fb->pitches[0]; in drm_mode_getfb()
563 ret = fb->funcs->create_handle(fb, file_priv, &r->handle); in drm_mode_getfb()
566 drm_framebuffer_put(fb); in drm_mode_getfb()
571 * drm_mode_getfb2_ioctl - get extended FB info
576 * Lookup the FB given its ID and return info about it.
587 struct drm_framebuffer *fb; in drm_mode_getfb2_ioctl() local
594 fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id); in drm_mode_getfb2_ioctl()
595 if (!fb) in drm_mode_getfb2_ioctl()
602 if (!fb->obj[0] && in drm_mode_getfb2_ioctl()
603 (fb->format->num_planes > 1 || !fb->funcs->create_handle)) { in drm_mode_getfb2_ioctl()
608 r->height = fb->height; in drm_mode_getfb2_ioctl()
609 r->width = fb->width; in drm_mode_getfb2_ioctl()
610 r->pixel_format = fb->format->format; in drm_mode_getfb2_ioctl()
623 for (i = 0; i < fb->format->num_planes; i++) { in drm_mode_getfb2_ioctl()
624 r->pitches[i] = fb->pitches[i]; in drm_mode_getfb2_ioctl()
625 r->offsets[i] = fb->offsets[i]; in drm_mode_getfb2_ioctl()
627 r->modifier[i] = fb->modifier; in drm_mode_getfb2_ioctl()
640 for (i = 0; i < fb->format->num_planes; i++) { in drm_mode_getfb2_ioctl()
647 if (fb->obj[i] == fb->obj[j]) { in drm_mode_getfb2_ioctl()
656 if (fb->obj[i]) { in drm_mode_getfb2_ioctl()
657 ret = drm_gem_handle_create(file_priv, fb->obj[i], in drm_mode_getfb2_ioctl()
661 ret = fb->funcs->create_handle(fb, file_priv, in drm_mode_getfb2_ioctl()
688 drm_framebuffer_put(fb); in drm_mode_getfb2_ioctl()
693 * drm_mode_dirtyfb_ioctl - flush frontbuffer rendering on an FB
698 * Lookup the FB and flush out the damaged area supplied by userspace as a clip
717 struct drm_framebuffer *fb; in drm_mode_dirtyfb_ioctl() local
725 fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id); in drm_mode_dirtyfb_ioctl()
726 if (!fb) in drm_mode_dirtyfb_ioctl()
764 if (fb->funcs->dirty) { in drm_mode_dirtyfb_ioctl()
765 ret = fb->funcs->dirty(fb, file_priv, flags, r->color, in drm_mode_dirtyfb_ioctl()
774 drm_framebuffer_put(fb); in drm_mode_dirtyfb_ioctl()
792 struct drm_framebuffer *fb, *tfb; in drm_fb_release() local
798 * When the file gets released that means no one else can access the fb in drm_fb_release()
807 list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) { in drm_fb_release()
808 if (drm_framebuffer_read_refcount(fb) > 1) { in drm_fb_release()
809 list_move_tail(&fb->filp_head, &arg.fbs); in drm_fb_release()
811 list_del_init(&fb->filp_head); in drm_fb_release()
814 drm_framebuffer_put(fb); in drm_fb_release()
829 struct drm_framebuffer *fb = in drm_framebuffer_free() local
831 struct drm_device *dev = fb->dev; in drm_framebuffer_free()
833 drm_WARN_ON(dev, !list_empty(&fb->filp_head)); in drm_framebuffer_free()
839 drm_mode_object_unregister(dev, &fb->base); in drm_framebuffer_free()
841 fb->funcs->destroy(fb); in drm_framebuffer_free()
848 * @fb: framebuffer to be initialized
855 * This functions publishes the fb and makes it available for concurrent access
856 * by other users. Which means by this point the fb _must_ be fully set up -
857 * since all the fb attributes are invariant over its lifetime, no further
863 int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, in drm_framebuffer_init() argument
870 if (WARN_ON_ONCE(fb->dev != dev || !fb->format)) in drm_framebuffer_init()
873 for (i = 0; i < fb->format->num_planes; i++) { in drm_framebuffer_init()
874 if (drm_WARN_ON_ONCE(dev, fb->internal_flags & DRM_FRAMEBUFFER_HAS_HANDLE_REF(i))) in drm_framebuffer_init()
875 fb->internal_flags &= ~DRM_FRAMEBUFFER_HAS_HANDLE_REF(i); in drm_framebuffer_init()
876 if (fb->obj[i]) { in drm_framebuffer_init()
877 exists = drm_gem_object_handle_get_if_exists_unlocked(fb->obj[i]); in drm_framebuffer_init()
879 fb->internal_flags |= DRM_FRAMEBUFFER_HAS_HANDLE_REF(i); in drm_framebuffer_init()
883 INIT_LIST_HEAD(&fb->filp_head); in drm_framebuffer_init()
885 fb->funcs = funcs; in drm_framebuffer_init()
886 strscpy(fb->comm, current->comm); in drm_framebuffer_init()
888 ret = __drm_mode_object_add(dev, &fb->base, DRM_MODE_OBJECT_FB, in drm_framebuffer_init()
895 list_add(&fb->head, &dev->mode_config.fb_list); in drm_framebuffer_init()
898 drm_mode_object_register(dev, &fb->base); in drm_framebuffer_init()
903 for (i = 0; i < fb->format->num_planes; i++) { in drm_framebuffer_init()
904 if (fb->internal_flags & DRM_FRAMEBUFFER_HAS_HANDLE_REF(i)) { in drm_framebuffer_init()
905 drm_gem_object_handle_put_unlocked(fb->obj[i]); in drm_framebuffer_init()
906 fb->internal_flags &= ~DRM_FRAMEBUFFER_HAS_HANDLE_REF(i); in drm_framebuffer_init()
917 * @id: id of the fb object
928 struct drm_framebuffer *fb = NULL; in drm_framebuffer_lookup() local
932 fb = obj_to_fb(obj); in drm_framebuffer_lookup()
933 return fb; in drm_framebuffer_lookup()
938 * drm_framebuffer_unregister_private - unregister a private fb from the lookup idr
939 * @fb: fb to unregister
951 void drm_framebuffer_unregister_private(struct drm_framebuffer *fb) in drm_framebuffer_unregister_private() argument
955 if (!fb) in drm_framebuffer_unregister_private()
958 dev = fb->dev; in drm_framebuffer_unregister_private()
960 /* Mark fb as reaped and drop idr ref. */ in drm_framebuffer_unregister_private()
961 drm_mode_object_unregister(dev, &fb->base); in drm_framebuffer_unregister_private()
967 * @fb: framebuffer to remove
973 * Note that this function does not remove the fb from active usage - if it is
982 void drm_framebuffer_cleanup(struct drm_framebuffer *fb) in drm_framebuffer_cleanup() argument
984 struct drm_device *dev = fb->dev; in drm_framebuffer_cleanup()
987 for (i = 0; i < fb->format->num_planes; i++) { in drm_framebuffer_cleanup()
988 if (fb->internal_flags & DRM_FRAMEBUFFER_HAS_HANDLE_REF(i)) in drm_framebuffer_cleanup()
989 drm_gem_object_handle_put_unlocked(fb->obj[i]); in drm_framebuffer_cleanup()
993 list_del(&fb->head); in drm_framebuffer_cleanup()
999 static int atomic_remove_fb(struct drm_framebuffer *fb) in atomic_remove_fb() argument
1002 struct drm_device *dev = fb->dev; in atomic_remove_fb()
1030 if (plane->state->fb != fb) in atomic_remove_fb()
1034 "Disabling [PLANE:%d:%s] because [FB:%d] is removed\n", in atomic_remove_fb()
1035 plane->base.id, plane->name, fb->base.id); in atomic_remove_fb()
1047 "Disabling [CRTC:%d:%s] because [FB:%d] is removed\n", in atomic_remove_fb()
1049 plane_state->crtc->name, fb->base.id); in atomic_remove_fb()
1103 static void legacy_remove_fb(struct drm_framebuffer *fb) in legacy_remove_fb() argument
1105 struct drm_device *dev = fb->dev; in legacy_remove_fb()
1112 if (crtc->primary->fb == fb) { in legacy_remove_fb()
1114 "Disabling [CRTC:%d:%s] because [FB:%d] is removed\n", in legacy_remove_fb()
1115 crtc->base.id, crtc->name, fb->base.id); in legacy_remove_fb()
1119 DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc); in legacy_remove_fb()
1124 if (plane->fb == fb) { in legacy_remove_fb()
1126 "Disabling [PLANE:%d:%s] because [FB:%d] is removed\n", in legacy_remove_fb()
1127 plane->base.id, plane->name, fb->base.id); in legacy_remove_fb()
1136 * @fb: framebuffer to remove
1139 * using @fb, removes it, setting it to NULL. Then drops the reference to the
1146 void drm_framebuffer_remove(struct drm_framebuffer *fb) in drm_framebuffer_remove() argument
1150 if (!fb) in drm_framebuffer_remove()
1153 dev = fb->dev; in drm_framebuffer_remove()
1155 drm_WARN_ON(dev, !list_empty(&fb->filp_head)); in drm_framebuffer_remove()
1169 * in-use fb with fb-id == 0. Userspace is allowed to shoot its own foot in drm_framebuffer_remove()
1172 if (drm_framebuffer_read_refcount(fb) > 1) { in drm_framebuffer_remove()
1174 int ret = atomic_remove_fb(fb); in drm_framebuffer_remove()
1178 legacy_remove_fb(fb); in drm_framebuffer_remove()
1181 drm_framebuffer_put(fb); in drm_framebuffer_remove()
1186 const struct drm_framebuffer *fb) in drm_framebuffer_print_info() argument
1190 drm_printf_indent(p, indent, "allocated by = %s\n", fb->comm); in drm_framebuffer_print_info()
1192 drm_framebuffer_read_refcount(fb)); in drm_framebuffer_print_info()
1193 drm_printf_indent(p, indent, "format=%p4cc\n", &fb->format->format); in drm_framebuffer_print_info()
1194 drm_printf_indent(p, indent, "modifier=0x%llx\n", fb->modifier); in drm_framebuffer_print_info()
1195 drm_printf_indent(p, indent, "size=%ux%u\n", fb->width, fb->height); in drm_framebuffer_print_info()
1198 for (i = 0; i < fb->format->num_planes; i++) { in drm_framebuffer_print_info()
1200 drm_format_info_plane_width(fb->format, fb->width, i), in drm_framebuffer_print_info()
1201 drm_format_info_plane_height(fb->format, fb->height, i)); in drm_framebuffer_print_info()
1202 drm_printf_indent(p, indent + 1, "pitch[%u]=%u\n", i, fb->pitches[i]); in drm_framebuffer_print_info()
1203 drm_printf_indent(p, indent + 1, "offset[%u]=%u\n", i, fb->offsets[i]); in drm_framebuffer_print_info()
1205 fb->obj[i] ? "" : "(null)"); in drm_framebuffer_print_info()
1206 if (fb->obj[i]) in drm_framebuffer_print_info()
1207 drm_gem_print_info(p, indent + 2, fb->obj[i]); in drm_framebuffer_print_info()
1217 struct drm_framebuffer *fb; in drm_framebuffer_info() local
1220 drm_for_each_fb(fb, dev) { in drm_framebuffer_info()
1221 drm_printf(&p, "framebuffer[%u]:\n", fb->base.id); in drm_framebuffer_info()
1222 drm_framebuffer_print_info(&p, 1, fb); in drm_framebuffer_info()