Lines Matching refs:fb

405 int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,  in drm_framebuffer_init()  argument
411 kref_init(&fb->refcount); in drm_framebuffer_init()
412 INIT_LIST_HEAD(&fb->filp_head); in drm_framebuffer_init()
413 fb->dev = dev; in drm_framebuffer_init()
414 fb->funcs = funcs; in drm_framebuffer_init()
416 ret = drm_mode_object_get(dev, &fb->base, DRM_MODE_OBJECT_FB); in drm_framebuffer_init()
421 list_add(&fb->head, &dev->mode_config.fb_list); in drm_framebuffer_init()
431 struct drm_framebuffer *fb) in __drm_framebuffer_unregister() argument
434 idr_remove(&dev->mode_config.crtc_idr, fb->base.id); in __drm_framebuffer_unregister()
437 fb->base.id = 0; in __drm_framebuffer_unregister()
442 struct drm_framebuffer *fb = in drm_framebuffer_free() local
444 struct drm_device *dev = fb->dev; in drm_framebuffer_free()
451 if (fb->base.id) { in drm_framebuffer_free()
453 __drm_framebuffer_unregister(dev, fb); in drm_framebuffer_free()
457 fb->funcs->destroy(fb); in drm_framebuffer_free()
464 struct drm_framebuffer *fb; in __drm_framebuffer_lookup() local
469 fb = NULL; in __drm_framebuffer_lookup()
471 fb = obj_to_fb(obj); in __drm_framebuffer_lookup()
474 return fb; in __drm_framebuffer_lookup()
489 struct drm_framebuffer *fb; in drm_framebuffer_lookup() local
492 fb = __drm_framebuffer_lookup(dev, id); in drm_framebuffer_lookup()
493 if (fb) { in drm_framebuffer_lookup()
494 if (!kref_get_unless_zero(&fb->refcount)) in drm_framebuffer_lookup()
495 fb = NULL; in drm_framebuffer_lookup()
499 return fb; in drm_framebuffer_lookup()
509 void drm_framebuffer_unreference(struct drm_framebuffer *fb) in drm_framebuffer_unreference() argument
511 DRM_DEBUG("%p: FB ID: %d (%d)\n", fb, fb->base.id, atomic_read(&fb->refcount.refcount)); in drm_framebuffer_unreference()
512 kref_put(&fb->refcount, drm_framebuffer_free); in drm_framebuffer_unreference()
522 void drm_framebuffer_reference(struct drm_framebuffer *fb) in drm_framebuffer_reference() argument
524 DRM_DEBUG("%p: FB ID: %d (%d)\n", fb, fb->base.id, atomic_read(&fb->refcount.refcount)); in drm_framebuffer_reference()
525 kref_get(&fb->refcount); in drm_framebuffer_reference()
538 void drm_framebuffer_unregister_private(struct drm_framebuffer *fb) in drm_framebuffer_unregister_private() argument
542 if (!fb) in drm_framebuffer_unregister_private()
545 dev = fb->dev; in drm_framebuffer_unregister_private()
549 __drm_framebuffer_unregister(dev, fb); in drm_framebuffer_unregister_private()
571 void drm_framebuffer_cleanup(struct drm_framebuffer *fb) in drm_framebuffer_cleanup() argument
573 struct drm_device *dev = fb->dev; in drm_framebuffer_cleanup()
576 list_del(&fb->head); in drm_framebuffer_cleanup()
594 void drm_framebuffer_remove(struct drm_framebuffer *fb) in drm_framebuffer_remove() argument
602 if (!fb) in drm_framebuffer_remove()
605 dev = fb->dev; in drm_framebuffer_remove()
607 WARN_ON(!list_empty(&fb->filp_head)); in drm_framebuffer_remove()
624 if (atomic_read(&fb->refcount.refcount) > 1) { in drm_framebuffer_remove()
628 if (crtc->primary->fb == fb) { in drm_framebuffer_remove()
632 set.fb = NULL; in drm_framebuffer_remove()
640 if (plane->fb == fb) in drm_framebuffer_remove()
646 drm_framebuffer_unreference(fb); in drm_framebuffer_remove()
1338 if (!plane->fb) in drm_plane_force_disable()
1341 plane->old_fb = plane->fb; in drm_plane_force_disable()
1351 plane->fb = NULL; in drm_plane_force_disable()
1739 struct drm_framebuffer *fb; in drm_mode_getresources() local
1771 list_for_each_entry(fb, &file_priv->fbs, filp_head) { in drm_mode_getresources()
1772 if (put_user(fb->base.id, fb_id + copied)) { in drm_mode_getresources()
1885 if (crtc->primary->fb) in drm_mode_getcrtc()
1886 crtc_resp->fb_id = crtc->primary->fb->base.id; in drm_mode_getcrtc()
2268 if (plane->fb) in drm_mode_getplane()
2269 plane_resp->fb_id = plane->fb->base.id; in drm_mode_getplane()
2319 const struct drm_framebuffer *fb) in check_src_coords() argument
2323 fb_width = fb->width << 16; in check_src_coords()
2324 fb_height = fb->height << 16; in check_src_coords()
2354 struct drm_framebuffer *fb, in __setplane_internal() argument
2364 if (!fb) { in __setplane_internal()
2365 plane->old_fb = plane->fb; in __setplane_internal()
2369 plane->fb = NULL; in __setplane_internal()
2384 ret = drm_plane_check_pixel_format(plane, fb->pixel_format); in __setplane_internal()
2387 drm_get_format_name(fb->pixel_format)); in __setplane_internal()
2402 ret = check_src_coords(src_x, src_y, src_w, src_h, fb); in __setplane_internal()
2406 plane->old_fb = plane->fb; in __setplane_internal()
2407 ret = plane->funcs->update_plane(plane, crtc, fb, in __setplane_internal()
2412 plane->fb = fb; in __setplane_internal()
2413 fb = NULL; in __setplane_internal()
2419 if (fb) in __setplane_internal()
2420 drm_framebuffer_unreference(fb); in __setplane_internal()
2430 struct drm_framebuffer *fb, in setplane_internal() argument
2440 ret = __setplane_internal(plane, crtc, fb, in setplane_internal()
2467 struct drm_framebuffer *fb = NULL; in drm_mode_setplane() local
2484 fb = drm_framebuffer_lookup(dev, plane_req->fb_id); in drm_mode_setplane()
2485 if (!fb) { in drm_mode_setplane()
2503 return setplane_internal(plane, crtc, fb, in drm_mode_setplane()
2523 struct drm_framebuffer *fb; in drm_mode_set_config_internal() local
2533 tmp->primary->old_fb = tmp->primary->fb; in drm_mode_set_config_internal()
2535 fb = set->fb; in drm_mode_set_config_internal()
2540 crtc->primary->fb = fb; in drm_mode_set_config_internal()
2544 if (tmp->primary->fb) in drm_mode_set_config_internal()
2545 drm_framebuffer_reference(tmp->primary->fb); in drm_mode_set_config_internal()
2588 const struct drm_framebuffer *fb) in drm_crtc_check_viewport() argument
2601 hdisplay << 16, vdisplay << 16, fb); in drm_crtc_check_viewport()
2625 struct drm_framebuffer *fb = NULL; in drm_mode_setcrtc() local
2655 if (!crtc->primary->fb) { in drm_mode_setcrtc()
2660 fb = crtc->primary->fb; in drm_mode_setcrtc()
2662 drm_framebuffer_reference(fb); in drm_mode_setcrtc()
2664 fb = drm_framebuffer_lookup(dev, crtc_req->fb_id); in drm_mode_setcrtc()
2665 if (!fb) { in drm_mode_setcrtc()
2696 fb->pixel_format); in drm_mode_setcrtc()
2699 drm_get_format_name(fb->pixel_format)); in drm_mode_setcrtc()
2705 mode, fb); in drm_mode_setcrtc()
2717 if (crtc_req->count_connectors > 0 && (!mode || !fb)) { in drm_mode_setcrtc()
2769 set.fb = fb; in drm_mode_setcrtc()
2773 if (fb) in drm_mode_setcrtc()
2774 drm_framebuffer_unreference(fb); in drm_mode_setcrtc()
2806 struct drm_framebuffer *fb = NULL; in drm_mode_cursor_universal() local
2829 fb = internal_framebuffer_create(dev, &fbreq, file_priv); in drm_mode_cursor_universal()
2830 if (IS_ERR(fb)) { in drm_mode_cursor_universal()
2832 return PTR_ERR(fb); in drm_mode_cursor_universal()
2835 fb = NULL; in drm_mode_cursor_universal()
2838 fb = crtc->cursor->fb; in drm_mode_cursor_universal()
2839 if (fb) in drm_mode_cursor_universal()
2840 drm_framebuffer_reference(fb); in drm_mode_cursor_universal()
2851 if (fb) { in drm_mode_cursor_universal()
2852 crtc_w = fb->width; in drm_mode_cursor_universal()
2853 crtc_h = fb->height; in drm_mode_cursor_universal()
2854 src_w = fb->width << 16; in drm_mode_cursor_universal()
2855 src_h = fb->height << 16; in drm_mode_cursor_universal()
2862 ret = __setplane_internal(crtc->cursor, crtc, fb, in drm_mode_cursor_universal()
3242 struct drm_framebuffer *fb; in internal_framebuffer_create() local
3271 fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); in internal_framebuffer_create()
3272 if (IS_ERR(fb)) { in internal_framebuffer_create()
3274 return fb; in internal_framebuffer_create()
3277 return fb; in internal_framebuffer_create()
3299 struct drm_framebuffer *fb; in drm_mode_addfb2() local
3304 fb = internal_framebuffer_create(dev, r, file_priv); in drm_mode_addfb2()
3305 if (IS_ERR(fb)) in drm_mode_addfb2()
3306 return PTR_ERR(fb); in drm_mode_addfb2()
3310 DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id); in drm_mode_addfb2()
3312 r->fb_id = fb->base.id; in drm_mode_addfb2()
3313 list_add(&fb->filp_head, &file_priv->fbs); in drm_mode_addfb2()
3329 struct drm_framebuffer *fb = in drm_mode_rmfb_work_fn() local
3330 list_first_entry(&arg->fbs, typeof(*fb), filp_head); in drm_mode_rmfb_work_fn()
3332 list_del_init(&fb->filp_head); in drm_mode_rmfb_work_fn()
3333 drm_framebuffer_remove(fb); in drm_mode_rmfb_work_fn()
3353 struct drm_framebuffer *fb = NULL; in drm_mode_rmfb() local
3363 fb = __drm_framebuffer_lookup(dev, *id); in drm_mode_rmfb()
3364 if (!fb) in drm_mode_rmfb()
3368 if (fb == fbl) in drm_mode_rmfb()
3373 list_del_init(&fb->filp_head); in drm_mode_rmfb()
3384 if (atomic_read(&fb->refcount.refcount) > 1) { in drm_mode_rmfb()
3389 list_add_tail(&fb->filp_head, &arg.fbs); in drm_mode_rmfb()
3395 drm_framebuffer_unreference(fb); in drm_mode_rmfb()
3423 struct drm_framebuffer *fb; in drm_mode_getfb() local
3429 fb = drm_framebuffer_lookup(dev, r->fb_id); in drm_mode_getfb()
3430 if (!fb) in drm_mode_getfb()
3433 r->height = fb->height; in drm_mode_getfb()
3434 r->width = fb->width; in drm_mode_getfb()
3435 r->depth = fb->depth; in drm_mode_getfb()
3436 r->bpp = fb->bits_per_pixel; in drm_mode_getfb()
3437 r->pitch = fb->pitches[0]; in drm_mode_getfb()
3438 if (fb->funcs->create_handle) { in drm_mode_getfb()
3441 ret = fb->funcs->create_handle(fb, file_priv, in drm_mode_getfb()
3456 drm_framebuffer_unreference(fb); in drm_mode_getfb()
3486 struct drm_framebuffer *fb; in drm_mode_dirtyfb_ioctl() local
3494 fb = drm_framebuffer_lookup(dev, r->fb_id); in drm_mode_dirtyfb_ioctl()
3495 if (!fb) in drm_mode_dirtyfb_ioctl()
3533 if (fb->funcs->dirty) { in drm_mode_dirtyfb_ioctl()
3534 ret = fb->funcs->dirty(fb, file_priv, flags, r->color, in drm_mode_dirtyfb_ioctl()
3543 drm_framebuffer_unreference(fb); in drm_mode_dirtyfb_ioctl()
3561 struct drm_framebuffer *fb, *tfb; in drm_fb_release() local
3576 list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) { in drm_fb_release()
3577 if (atomic_read(&fb->refcount.refcount) > 1) { in drm_fb_release()
3578 list_move_tail(&fb->filp_head, &arg.fbs); in drm_fb_release()
3580 list_del_init(&fb->filp_head); in drm_fb_release()
3583 drm_framebuffer_unreference(fb); in drm_fb_release()
4768 struct drm_framebuffer *fb; in drm_property_change_valid_get() local
4769 fb = drm_framebuffer_lookup(property->dev, value); in drm_property_change_valid_get()
4770 if (fb) { in drm_property_change_valid_get()
4771 *ref = &fb->base; in drm_property_change_valid_get()
5231 struct drm_framebuffer *fb = NULL; in drm_mode_page_flip_ioctl() local
5248 if (crtc->primary->fb == NULL) { in drm_mode_page_flip_ioctl()
5260 fb = drm_framebuffer_lookup(dev, page_flip->fb_id); in drm_mode_page_flip_ioctl()
5261 if (!fb) { in drm_mode_page_flip_ioctl()
5270 state->src_w, state->src_h, fb); in drm_mode_page_flip_ioctl()
5272 ret = drm_crtc_check_viewport(crtc, crtc->x, crtc->y, &crtc->mode, fb); in drm_mode_page_flip_ioctl()
5277 if (crtc->primary->fb->pixel_format != fb->pixel_format) { in drm_mode_page_flip_ioctl()
5310 crtc->primary->old_fb = crtc->primary->fb; in drm_mode_page_flip_ioctl()
5311 ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags); in drm_mode_page_flip_ioctl()
5322 crtc->primary->fb = fb; in drm_mode_page_flip_ioctl()
5324 fb = NULL; in drm_mode_page_flip_ioctl()
5328 if (fb) in drm_mode_page_flip_ioctl()
5329 drm_framebuffer_unreference(fb); in drm_mode_page_flip_ioctl()
5790 struct drm_framebuffer *fb, *fbt; in drm_mode_config_cleanup() local
5824 list_for_each_entry_safe(fb, fbt, &dev->mode_config.fb_list, head) { in drm_mode_config_cleanup()
5825 drm_framebuffer_free(&fb->refcount); in drm_mode_config_cleanup()