Lines Matching refs:fb

349  * This functions publishes the fb and makes it available for concurrent access
350 * by other users. Which means by this point the fb _must_ be fully set up -
351 * since all the fb attributes are invariant over its lifetime, no further
357 int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
363 kref_init(&fb->refcount);
364 INIT_LIST_HEAD(&fb->filp_head);
365 fb->dev = dev;
366 fb->funcs = funcs;
368 ret = drm_mode_object_get(dev, &fb->base, DRM_MODE_OBJECT_FB);
373 drm_framebuffer_reference(fb);
376 list_add(&fb->head, &dev->mode_config.fb_list, (caddr_t)fb);
385 struct drm_framebuffer *fb =
387 fb->funcs->destroy(fb);
394 struct drm_framebuffer *fb;
399 fb = NULL;
401 fb = obj_to_fb(obj);
404 return fb;
410 * @id: id of the fb object
419 struct drm_framebuffer *fb;
423 fb = __drm_framebuffer_lookup(dev, id);
424 if (fb)
425 kref_get(&fb->refcount);
429 return fb;
436 void drm_framebuffer_unreference(struct drm_framebuffer *fb)
438 DRM_DEBUG("FB ID: %d\n", fb->base.id);
439 kref_put(&fb->refcount, drm_framebuffer_free);
443 * drm_framebuffer_reference - incr the fb refcnt
445 void drm_framebuffer_reference(struct drm_framebuffer *fb)
447 DRM_DEBUG("FB ID: %d\n", fb->base.id);
448 kref_get(&fb->refcount);
457 static void __drm_framebuffer_unreference(struct drm_framebuffer *fb)
459 DRM_DEBUG("FB ID: %d\n", fb->base.id);
460 kref_put(&fb->refcount, drm_framebuffer_free_bug);
465 struct drm_framebuffer *fb)
468 (void) idr_remove(&dev->mode_config.crtc_idr, fb->base.id);
471 fb->base.id = 0;
473 __drm_framebuffer_unreference(fb);
477 * drm_framebuffer_unregister_private - unregister a private fb from the lookup idr
478 * @fb: fb to unregister
485 void drm_framebuffer_unregister_private(struct drm_framebuffer *fb)
487 struct drm_device *dev = fb->dev;
490 /* Mark fb as reaped and drop idr ref. */
491 __drm_framebuffer_unregister(dev, fb);
497 * @fb: framebuffer to remove
503 * Note that this function does not remove the fb from active usuage - if it is
512 void drm_framebuffer_cleanup(struct drm_framebuffer *fb)
514 struct drm_device *dev = fb->dev;
516 list_del(&fb->head);
523 * @fb: framebuffer to remove
525 * using @fb, removes it, setting it to NULL. Then drops the reference to the
532 void drm_framebuffer_remove(struct drm_framebuffer *fb)
534 struct drm_device *dev = fb->dev;
540 WARN_ON(!list_empty(&fb->filp_head));
554 * in-use fb with fb-id == 0. Userspace is allowed to shoot its own foot
557 if (atomic_read(&fb->refcount.refcount) > 1) {
561 if (crtc->fb == fb) {
565 set.fb = NULL;
568 DRM_ERROR("failed to reset crtc %p when fb was deleted\n", (void *)crtc);
572 if (plane->fb == fb)
578 drm_framebuffer_unreference(fb);
894 if (!plane->fb)
899 DRM_ERROR("failed to disable plane with busy fb\n");
900 /* disconnect the plane from the fb and crtc: */
901 __drm_framebuffer_unreference(plane->fb);
902 plane->fb = NULL;
1290 struct drm_framebuffer *fb;
1323 list_for_each_entry(fb, struct drm_framebuffer, &file->fbs, filp_head) {
1324 if (put_user(fb->base.id, fb_id + copied)) {
1497 if (crtc->fb)
1498 crtc_resp->fb_id = crtc->fb->base.id;
1747 * current fb, etc.
1775 if (plane->fb)
1776 plane_resp->fb_id = plane->fb->base.id;
1812 * Set plane info, including placement, fb, scaling, and other factors.
1813 * Or pass a NULL fb to disable.
1822 struct drm_framebuffer *fb = NULL, *old_fb = NULL;
1831 * First, find the plane, crtc, and fb objects. If not available,
1843 /* No fb means shut it down */
1846 old_fb = plane->fb;
1849 plane->fb = NULL;
1864 fb = drm_framebuffer_lookup(dev, plane_req->fb_id);
1865 if (!fb) {
1872 /* Check whether this plane supports the fb pixel format. */
1874 if (fb->pixel_format == plane->format_types[i])
1877 DRM_DEBUG_KMS("Invalid pixel format 0x%08x\n", fb->pixel_format);
1882 fb_width = fb->width << 16;
1883 fb_height = fb->height << 16;
1885 /* Make sure source coordinates are inside the fb. */
1917 ret = plane->funcs->update_plane(plane, crtc, fb,
1923 old_fb = plane->fb;
1925 plane->fb = fb;
1926 fb = NULL;
1931 if (fb)
1932 drm_framebuffer_unreference(fb);
1948 struct drm_framebuffer *fb;
1958 tmp->old_fb = tmp->fb;
1960 fb = set->fb;
1963 /* crtc->fb must be updated by ->set_config, enforces this. */
1964 if (fb != crtc->fb)
1965 DRM_ERROR("fb 0x%lx != crtc->fb 0x%lx", (uintptr_t)fb, (uintptr_t)crtc->fb);
1969 if (tmp->fb)
1970 drm_framebuffer_reference(tmp->fb);
2001 struct drm_framebuffer *fb = NULL;
2029 /* If we pass -1, set the mode with the currently bound fb */
2032 if (!crtc->fb) {
2037 fb = crtc->fb;
2039 drm_framebuffer_reference(fb);
2041 fb = drm_framebuffer_lookup(dev, crtc_req->fb_id);
2042 if (!fb) {
2070 if (hdisplay > fb->width ||
2071 vdisplay > fb->height ||
2072 crtc_req->x > fb->width - hdisplay ||
2073 crtc_req->y > fb->height - vdisplay) {
2074 DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport %ux%u+%d+%d%s.\n",
2075 fb->width, fb->height,
2089 if (crtc_req->count_connectors > 0 && (!mode || !fb)) {
2090 DRM_DEBUG_KMS("Count connectors is %d but no mode or fb set\n",
2143 set.fb = fb;
2147 if (fb)
2148 drm_framebuffer_unreference(fb);
2280 struct drm_framebuffer *fb;
2302 fb = dev->mode_config.funcs->fb_create(dev, file, &r);
2303 if (fb == NULL) {
2309 or->fb_id = fb->base.id;
2310 list_add(&fb->filp_head, &file->fbs, (caddr_t)fb);
2311 DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
2456 struct drm_framebuffer *fb;
2482 fb = dev->mode_config.funcs->fb_create(dev, file, r);
2483 if (fb == NULL) {
2489 r->fb_id = fb->base.id;
2490 list_add(&fb->filp_head, &file->fbs, (caddr_t)fb);
2491 DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
2513 struct drm_framebuffer *fb = NULL;
2523 fb = __drm_framebuffer_lookup(dev, *id);
2524 if (!fb)
2528 if (fb == fbl)
2534 /* Mark fb as reaped, we still have a ref from fpriv->fbs. */
2535 __drm_framebuffer_unregister(dev, fb);
2537 list_del_init(&fb->filp_head);
2541 drm_framebuffer_remove(fb);
2568 struct drm_framebuffer *fb;
2574 fb = drm_framebuffer_lookup(dev, r->fb_id);
2575 if (!fb)
2578 r->height = fb->height;
2579 r->width = fb->width;
2580 r->depth = fb->depth;
2581 r->bpp = fb->bits_per_pixel;
2582 r->pitch = fb->pitches[0];
2583 if (fb->funcs->create_handle)
2584 ret = fb->funcs->create_handle(fb, file, &r->handle);
2588 drm_framebuffer_unreference(fb);
2599 struct drm_framebuffer *fb;
2607 fb = drm_framebuffer_lookup(dev, r->fb_id);
2608 if (!fb)
2646 if (fb->funcs->dirty) {
2648 ret = fb->funcs->dirty(fb, file, flags, r->color,
2659 drm_framebuffer_unreference(fb);
2679 struct drm_framebuffer *fb, *tfb;
2682 list_for_each_entry_safe(fb, tfb, struct drm_framebuffer, &priv->fbs, filp_head) {
2685 /* Mark fb as reaped, we still have a ref from fpriv->fbs. */
2686 __drm_framebuffer_unregister(dev, fb);
2689 list_del_init(&fb->filp_head);
2692 drm_framebuffer_remove(fb);
3469 struct drm_framebuffer *fb = NULL, *old_fb = NULL;
3485 if (crtc->fb == NULL) {
3497 fb = drm_framebuffer_lookup(dev, page_flip->fb_id);
3498 if (!fb)
3507 if (hdisplay > fb->width ||
3508 vdisplay > fb->height ||
3509 crtc->x > fb->width - hdisplay ||
3510 crtc->y > fb->height - vdisplay) {
3511 DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport %ux%u+%d+%d%s.\n",
3512 fb->width, fb->height, hdisplay, vdisplay, crtc->x, crtc->y,
3518 if (crtc->fb->pixel_format != fb->pixel_format) {
3551 old_fb = crtc->fb;
3552 ret = crtc->funcs->page_flip(crtc, fb, e);
3560 /* Keep the old fb, don't unref it. */
3564 * Warn if the driver hasn't properly updated the crtc->fb
3569 WARN_ON(crtc->fb != fb);
3571 fb = NULL;
3575 if (fb)
3576 drm_framebuffer_unreference(fb);
3896 struct drm_framebuffer *fb, *fbt;
3930 list_for_each_entry_safe(fb, fbt, struct drm_framebuffer, &dev->mode_config.fb_list, head) {
3931 drm_framebuffer_remove(fb);