Lines Matching refs:fb
404 int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, in drm_framebuffer_init() argument
410 kref_init(&fb->refcount); in drm_framebuffer_init()
411 INIT_LIST_HEAD(&fb->filp_head); in drm_framebuffer_init()
412 fb->dev = dev; in drm_framebuffer_init()
413 fb->funcs = funcs; in drm_framebuffer_init()
415 ret = drm_mode_object_get(dev, &fb->base, DRM_MODE_OBJECT_FB); in drm_framebuffer_init()
420 list_add(&fb->head, &dev->mode_config.fb_list); in drm_framebuffer_init()
430 struct drm_framebuffer *fb) in __drm_framebuffer_unregister() argument
433 idr_remove(&dev->mode_config.crtc_idr, fb->base.id); in __drm_framebuffer_unregister()
436 fb->base.id = 0; in __drm_framebuffer_unregister()
441 struct drm_framebuffer *fb = in drm_framebuffer_free() local
443 struct drm_device *dev = fb->dev; in drm_framebuffer_free()
450 if (fb->base.id) { in drm_framebuffer_free()
452 __drm_framebuffer_unregister(dev, fb); in drm_framebuffer_free()
456 fb->funcs->destroy(fb); in drm_framebuffer_free()
463 struct drm_framebuffer *fb; in __drm_framebuffer_lookup() local
468 fb = NULL; in __drm_framebuffer_lookup()
470 fb = obj_to_fb(obj); in __drm_framebuffer_lookup()
473 return fb; in __drm_framebuffer_lookup()
488 struct drm_framebuffer *fb; in drm_framebuffer_lookup() local
491 fb = __drm_framebuffer_lookup(dev, id); in drm_framebuffer_lookup()
492 if (fb) { in drm_framebuffer_lookup()
493 if (!kref_get_unless_zero(&fb->refcount)) in drm_framebuffer_lookup()
494 fb = NULL; in drm_framebuffer_lookup()
498 return fb; in drm_framebuffer_lookup()
508 void drm_framebuffer_unreference(struct drm_framebuffer *fb) in drm_framebuffer_unreference() argument
510 DRM_DEBUG("%p: FB ID: %d (%d)\n", fb, fb->base.id, atomic_read(&fb->refcount.refcount)); in drm_framebuffer_unreference()
511 kref_put(&fb->refcount, drm_framebuffer_free); in drm_framebuffer_unreference()
521 void drm_framebuffer_reference(struct drm_framebuffer *fb) in drm_framebuffer_reference() argument
523 DRM_DEBUG("%p: FB ID: %d (%d)\n", fb, fb->base.id, atomic_read(&fb->refcount.refcount)); in drm_framebuffer_reference()
524 kref_get(&fb->refcount); in drm_framebuffer_reference()
537 void drm_framebuffer_unregister_private(struct drm_framebuffer *fb) in drm_framebuffer_unregister_private() argument
539 struct drm_device *dev = fb->dev; in drm_framebuffer_unregister_private()
543 __drm_framebuffer_unregister(dev, fb); in drm_framebuffer_unregister_private()
565 void drm_framebuffer_cleanup(struct drm_framebuffer *fb) in drm_framebuffer_cleanup() argument
567 struct drm_device *dev = fb->dev; in drm_framebuffer_cleanup()
570 list_del(&fb->head); in drm_framebuffer_cleanup()
588 void drm_framebuffer_remove(struct drm_framebuffer *fb) in drm_framebuffer_remove() argument
590 struct drm_device *dev = fb->dev; in drm_framebuffer_remove()
596 WARN_ON(!list_empty(&fb->filp_head)); in drm_framebuffer_remove()
613 if (atomic_read(&fb->refcount.refcount) > 1) { in drm_framebuffer_remove()
617 if (crtc->primary->fb == fb) { in drm_framebuffer_remove()
621 set.fb = NULL; in drm_framebuffer_remove()
629 if (plane->fb == fb) in drm_framebuffer_remove()
635 drm_framebuffer_unreference(fb); in drm_framebuffer_remove()
1304 if (!plane->fb) in drm_plane_force_disable()
1307 plane->old_fb = plane->fb; in drm_plane_force_disable()
1317 plane->fb = NULL; in drm_plane_force_disable()
1808 struct drm_framebuffer *fb; in drm_mode_getresources() local
1841 list_for_each_entry(fb, &file_priv->fbs, filp_head) { in drm_mode_getresources()
1842 if (put_user(fb->base.id, fb_id + copied)) { in drm_mode_getresources()
2006 if (crtc->primary->fb) in drm_mode_getcrtc()
2007 crtc_resp->fb_id = crtc->primary->fb->base.id; in drm_mode_getcrtc()
2389 if (plane->fb) in drm_mode_getplane()
2390 plane_resp->fb_id = plane->fb->base.id; in drm_mode_getplane()
2449 struct drm_framebuffer *fb, in __setplane_internal() argument
2460 if (!fb) { in __setplane_internal()
2461 plane->old_fb = plane->fb; in __setplane_internal()
2465 plane->fb = NULL; in __setplane_internal()
2480 ret = drm_plane_check_pixel_format(plane, fb->pixel_format); in __setplane_internal()
2483 drm_get_format_name(fb->pixel_format)); in __setplane_internal()
2498 fb_width = fb->width << 16; in __setplane_internal()
2499 fb_height = fb->height << 16; in __setplane_internal()
2516 plane->old_fb = plane->fb; in __setplane_internal()
2517 ret = plane->funcs->update_plane(plane, crtc, fb, in __setplane_internal()
2522 plane->fb = fb; in __setplane_internal()
2523 fb = NULL; in __setplane_internal()
2529 if (fb) in __setplane_internal()
2530 drm_framebuffer_unreference(fb); in __setplane_internal()
2540 struct drm_framebuffer *fb, in setplane_internal() argument
2550 ret = __setplane_internal(plane, crtc, fb, in setplane_internal()
2577 struct drm_framebuffer *fb = NULL; in drm_mode_setplane() local
2594 fb = drm_framebuffer_lookup(dev, plane_req->fb_id); in drm_mode_setplane()
2595 if (!fb) { in drm_mode_setplane()
2613 return setplane_internal(plane, crtc, fb, in drm_mode_setplane()
2633 struct drm_framebuffer *fb; in drm_mode_set_config_internal() local
2643 tmp->primary->old_fb = tmp->primary->fb; in drm_mode_set_config_internal()
2645 fb = set->fb; in drm_mode_set_config_internal()
2650 crtc->primary->fb = fb; in drm_mode_set_config_internal()
2654 if (tmp->primary->fb) in drm_mode_set_config_internal()
2655 drm_framebuffer_reference(tmp->primary->fb); in drm_mode_set_config_internal()
2698 const struct drm_framebuffer *fb) in drm_crtc_check_viewport() argument
2708 if (hdisplay > fb->width || in drm_crtc_check_viewport()
2709 vdisplay > fb->height || in drm_crtc_check_viewport()
2710 x > fb->width - hdisplay || in drm_crtc_check_viewport()
2711 y > fb->height - vdisplay) { in drm_crtc_check_viewport()
2713 fb->width, fb->height, hdisplay, vdisplay, x, y, in drm_crtc_check_viewport()
2742 struct drm_framebuffer *fb = NULL; in drm_mode_setcrtc() local
2772 if (!crtc->primary->fb) { in drm_mode_setcrtc()
2777 fb = crtc->primary->fb; in drm_mode_setcrtc()
2779 drm_framebuffer_reference(fb); in drm_mode_setcrtc()
2781 fb = drm_framebuffer_lookup(dev, crtc_req->fb_id); in drm_mode_setcrtc()
2782 if (!fb) { in drm_mode_setcrtc()
2819 fb->pixel_format); in drm_mode_setcrtc()
2822 drm_get_format_name(fb->pixel_format)); in drm_mode_setcrtc()
2828 mode, fb); in drm_mode_setcrtc()
2840 if (crtc_req->count_connectors > 0 && (!mode || !fb)) { in drm_mode_setcrtc()
2892 set.fb = fb; in drm_mode_setcrtc()
2896 if (fb) in drm_mode_setcrtc()
2897 drm_framebuffer_unreference(fb); in drm_mode_setcrtc()
2929 struct drm_framebuffer *fb = NULL; in drm_mode_cursor_universal() local
2952 fb = internal_framebuffer_create(dev, &fbreq, file_priv); in drm_mode_cursor_universal()
2953 if (IS_ERR(fb)) { in drm_mode_cursor_universal()
2955 return PTR_ERR(fb); in drm_mode_cursor_universal()
2958 fb = NULL; in drm_mode_cursor_universal()
2961 fb = crtc->cursor->fb; in drm_mode_cursor_universal()
2962 if (fb) in drm_mode_cursor_universal()
2963 drm_framebuffer_reference(fb); in drm_mode_cursor_universal()
2974 if (fb) { in drm_mode_cursor_universal()
2975 crtc_w = fb->width; in drm_mode_cursor_universal()
2976 crtc_h = fb->height; in drm_mode_cursor_universal()
2977 src_w = fb->width << 16; in drm_mode_cursor_universal()
2978 src_h = fb->height << 16; in drm_mode_cursor_universal()
2985 ret = __setplane_internal(crtc->cursor, crtc, fb, in drm_mode_cursor_universal()
3321 struct drm_framebuffer *fb; in internal_framebuffer_create() local
3350 fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); in internal_framebuffer_create()
3351 if (IS_ERR(fb)) { in internal_framebuffer_create()
3353 return fb; in internal_framebuffer_create()
3356 return fb; in internal_framebuffer_create()
3378 struct drm_framebuffer *fb; in drm_mode_addfb2() local
3383 fb = internal_framebuffer_create(dev, r, file_priv); in drm_mode_addfb2()
3384 if (IS_ERR(fb)) in drm_mode_addfb2()
3385 return PTR_ERR(fb); in drm_mode_addfb2()
3389 DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id); in drm_mode_addfb2()
3391 r->fb_id = fb->base.id; in drm_mode_addfb2()
3392 list_add(&fb->filp_head, &file_priv->fbs); in drm_mode_addfb2()
3414 struct drm_framebuffer *fb = NULL; in drm_mode_rmfb() local
3424 fb = __drm_framebuffer_lookup(dev, *id); in drm_mode_rmfb()
3425 if (!fb) in drm_mode_rmfb()
3429 if (fb == fbl) in drm_mode_rmfb()
3435 __drm_framebuffer_unregister(dev, fb); in drm_mode_rmfb()
3437 list_del_init(&fb->filp_head); in drm_mode_rmfb()
3441 drm_framebuffer_remove(fb); in drm_mode_rmfb()
3469 struct drm_framebuffer *fb; in drm_mode_getfb() local
3475 fb = drm_framebuffer_lookup(dev, r->fb_id); in drm_mode_getfb()
3476 if (!fb) in drm_mode_getfb()
3479 r->height = fb->height; in drm_mode_getfb()
3480 r->width = fb->width; in drm_mode_getfb()
3481 r->depth = fb->depth; in drm_mode_getfb()
3482 r->bpp = fb->bits_per_pixel; in drm_mode_getfb()
3483 r->pitch = fb->pitches[0]; in drm_mode_getfb()
3484 if (fb->funcs->create_handle) { in drm_mode_getfb()
3487 ret = fb->funcs->create_handle(fb, file_priv, in drm_mode_getfb()
3502 drm_framebuffer_unreference(fb); in drm_mode_getfb()
3532 struct drm_framebuffer *fb; in drm_mode_dirtyfb_ioctl() local
3540 fb = drm_framebuffer_lookup(dev, r->fb_id); in drm_mode_dirtyfb_ioctl()
3541 if (!fb) in drm_mode_dirtyfb_ioctl()
3579 if (fb->funcs->dirty) { in drm_mode_dirtyfb_ioctl()
3580 ret = fb->funcs->dirty(fb, file_priv, flags, r->color, in drm_mode_dirtyfb_ioctl()
3589 drm_framebuffer_unreference(fb); in drm_mode_dirtyfb_ioctl()
3609 struct drm_framebuffer *fb, *tfb; in drm_fb_release() local
3621 list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) { in drm_fb_release()
3625 __drm_framebuffer_unregister(dev, fb); in drm_fb_release()
3628 list_del_init(&fb->filp_head); in drm_fb_release()
3631 drm_framebuffer_remove(fb); in drm_fb_release()
4459 struct drm_framebuffer *fb; in drm_property_change_valid_get() local
4460 fb = drm_framebuffer_lookup(property->dev, value); in drm_property_change_valid_get()
4461 if (fb) { in drm_property_change_valid_get()
4462 *ref = &fb->base; in drm_property_change_valid_get()
4921 struct drm_framebuffer *fb = NULL; in drm_mode_page_flip_ioctl() local
4938 if (crtc->primary->fb == NULL) { in drm_mode_page_flip_ioctl()
4950 fb = drm_framebuffer_lookup(dev, page_flip->fb_id); in drm_mode_page_flip_ioctl()
4951 if (!fb) { in drm_mode_page_flip_ioctl()
4956 ret = drm_crtc_check_viewport(crtc, crtc->x, crtc->y, &crtc->mode, fb); in drm_mode_page_flip_ioctl()
4960 if (crtc->primary->fb->pixel_format != fb->pixel_format) { in drm_mode_page_flip_ioctl()
4993 crtc->primary->old_fb = crtc->primary->fb; in drm_mode_page_flip_ioctl()
4994 ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags); in drm_mode_page_flip_ioctl()
5011 WARN_ON(crtc->primary->fb != fb); in drm_mode_page_flip_ioctl()
5013 fb = NULL; in drm_mode_page_flip_ioctl()
5017 if (fb) in drm_mode_page_flip_ioctl()
5018 drm_framebuffer_unreference(fb); in drm_mode_page_flip_ioctl()
5475 struct drm_framebuffer *fb, *fbt; in drm_mode_config_cleanup() local
5509 list_for_each_entry_safe(fb, fbt, &dev->mode_config.fb_list, head) { in drm_mode_config_cleanup()
5510 drm_framebuffer_remove(fb); in drm_mode_config_cleanup()