Lines Matching +full:self +full:- +full:advertising

8  * that the name of the copyright holders not be used in advertising or
52 * (or a list of memory handles for multi-planar formats) through the
60 * using drm_framebuffer_init() - after calling that function userspace can use
62 * drm_helper_mode_fill_fb_struct() can be used to pre-fill the required
67 * them again with drm_framebuffer_put(). For driver-private framebuffers for
72 * recommended, and it's better to have a normal free-standing &struct
82 fb_width = fb->width << 16; in drm_framebuffer_check_src_coords()
83 fb_height = fb->height << 16; in drm_framebuffer_check_src_coords()
87 src_x > fb_width - src_w || in drm_framebuffer_check_src_coords()
89 src_y > fb_height - src_h) { in drm_framebuffer_check_src_coords()
90 drm_dbg_kms(fb->dev, "Invalid source coordinates " in drm_framebuffer_check_src_coords()
96 fb->width, fb->height); in drm_framebuffer_check_src_coords()
97 return -ENOSPC; in drm_framebuffer_check_src_coords()
105 * drm_mode_addfb - add an FB to the graphics configuration
113 * Called by the user via ioctl, or by an in-kernel client.
125 return -EOPNOTSUPP; in drm_mode_addfb()
127 r.pixel_format = drm_driver_legacy_fb_format(dev, or->bpp, or->depth); in drm_mode_addfb()
129 drm_dbg_kms(dev, "bad {bpp:%d, depth:%d}\n", or->bpp, or->depth); in drm_mode_addfb()
130 return -EINVAL; in drm_mode_addfb()
134 r.fb_id = or->fb_id; in drm_mode_addfb()
135 r.width = or->width; in drm_mode_addfb()
136 r.height = or->height; in drm_mode_addfb()
137 r.pitches[0] = or->pitch; in drm_mode_addfb()
138 r.handles[0] = or->handle; in drm_mode_addfb()
144 or->fb_id = r.fb_id; in drm_mode_addfb()
162 if (!__drm_format_info(r->pixel_format)) { in framebuffer_check()
164 &r->pixel_format); in framebuffer_check()
165 return -EINVAL; in framebuffer_check()
168 if (r->width == 0) { in framebuffer_check()
169 drm_dbg_kms(dev, "bad framebuffer width %u\n", r->width); in framebuffer_check()
170 return -EINVAL; in framebuffer_check()
173 if (r->height == 0) { in framebuffer_check()
174 drm_dbg_kms(dev, "bad framebuffer height %u\n", r->height); in framebuffer_check()
175 return -EINVAL; in framebuffer_check()
181 for (i = 0; i < info->num_planes; i++) { in framebuffer_check()
182 unsigned int width = drm_format_info_plane_width(info, r->width, i); in framebuffer_check()
183 unsigned int height = drm_format_info_plane_height(info, r->height, i); in framebuffer_check()
184 unsigned int block_size = info->char_per_block[i]; in framebuffer_check()
187 if (!block_size && (r->modifier[i] == DRM_FORMAT_MOD_LINEAR)) { in framebuffer_check()
188 drm_dbg_kms(dev, "Format requires non-linear modifier for plane %d\n", i); in framebuffer_check()
189 return -EINVAL; in framebuffer_check()
192 if (!r->handles[i]) { in framebuffer_check()
194 return -EINVAL; in framebuffer_check()
198 return -ERANGE; in framebuffer_check()
200 if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX) in framebuffer_check()
201 return -ERANGE; in framebuffer_check()
203 if (block_size && r->pitches[i] < min_pitch) { in framebuffer_check()
204 drm_dbg_kms(dev, "bad pitch %u for plane %d\n", r->pitches[i], i); in framebuffer_check()
205 return -EINVAL; in framebuffer_check()
208 if (r->modifier[i] && !(r->flags & DRM_MODE_FB_MODIFIERS)) { in framebuffer_check()
210 r->modifier[i], i); in framebuffer_check()
211 return -EINVAL; in framebuffer_check()
214 if (r->flags & DRM_MODE_FB_MODIFIERS && in framebuffer_check()
215 r->modifier[i] != r->modifier[0]) { in framebuffer_check()
217 r->modifier[i], i); in framebuffer_check()
218 return -EINVAL; in framebuffer_check()
222 switch (r->modifier[i]) { in framebuffer_check()
227 if (r->pixel_format != DRM_FORMAT_NV12 || in framebuffer_check()
229 r->pitches[i] % 128) { in framebuffer_check()
231 return -EINVAL; in framebuffer_check()
240 for (i = info->num_planes; i < 4; i++) { in framebuffer_check()
241 if (r->modifier[i]) { in framebuffer_check()
242 drm_dbg_kms(dev, "non-zero modifier for unused plane %d\n", i); in framebuffer_check()
243 return -EINVAL; in framebuffer_check()
246 /* Pre-FB_MODIFIERS userspace didn't clear the structs properly. */ in framebuffer_check()
247 if (!(r->flags & DRM_MODE_FB_MODIFIERS)) in framebuffer_check()
250 if (r->handles[i]) { in framebuffer_check()
252 return -EINVAL; in framebuffer_check()
255 if (r->pitches[i]) { in framebuffer_check()
256 drm_dbg_kms(dev, "non-zero pitch for unused plane %d\n", i); in framebuffer_check()
257 return -EINVAL; in framebuffer_check()
260 if (r->offsets[i]) { in framebuffer_check()
261 drm_dbg_kms(dev, "non-zero offset for unused plane %d\n", i); in framebuffer_check()
262 return -EINVAL; in framebuffer_check()
274 struct drm_mode_config *config = &dev->mode_config; in drm_internal_framebuffer_create()
278 if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS)) { in drm_internal_framebuffer_create()
279 drm_dbg_kms(dev, "bad framebuffer flags 0x%08x\n", r->flags); in drm_internal_framebuffer_create()
280 return ERR_PTR(-EINVAL); in drm_internal_framebuffer_create()
283 if ((config->min_width > r->width) || (r->width > config->max_width)) { in drm_internal_framebuffer_create()
285 r->width, config->min_width, config->max_width); in drm_internal_framebuffer_create()
286 return ERR_PTR(-EINVAL); in drm_internal_framebuffer_create()
288 if ((config->min_height > r->height) || (r->height > config->max_height)) { in drm_internal_framebuffer_create()
290 r->height, config->min_height, config->max_height); in drm_internal_framebuffer_create()
291 return ERR_PTR(-EINVAL); in drm_internal_framebuffer_create()
294 if (r->flags & DRM_MODE_FB_MODIFIERS && in drm_internal_framebuffer_create()
295 dev->mode_config.fb_modifiers_not_supported) { in drm_internal_framebuffer_create()
297 return ERR_PTR(-EINVAL); in drm_internal_framebuffer_create()
304 fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); in drm_internal_framebuffer_create()
315 * drm_mode_addfb2 - add an FB to the graphics configuration
321 * the 2nd version of the addfb ioctl, which supports multi-planar framebuffers
336 return -EOPNOTSUPP; in drm_mode_addfb2()
342 drm_dbg_kms(dev, "[FB:%d]\n", fb->base.id); in drm_mode_addfb2()
343 r->fb_id = fb->base.id; in drm_mode_addfb2()
346 mutex_lock(&file_priv->fbs_lock); in drm_mode_addfb2()
347 list_add(&fb->filp_head, &file_priv->fbs); in drm_mode_addfb2()
348 mutex_unlock(&file_priv->fbs_lock); in drm_mode_addfb2()
357 if (!dev->mode_config.quirk_addfb_prefer_host_byte_order) { in drm_mode_addfb2_ioctl()
371 return -EOPNOTSUPP; in drm_mode_addfb2_ioctl()
386 while (!list_empty(&arg->fbs)) { in drm_mode_rmfb_work_fn()
388 list_first_entry(&arg->fbs, typeof(*fb), filp_head); in drm_mode_rmfb_work_fn()
390 drm_dbg_kms(fb->dev, in drm_mode_rmfb_work_fn()
392 fb->base.id); in drm_mode_rmfb_work_fn()
393 list_del_init(&fb->filp_head); in drm_mode_rmfb_work_fn()
404 mutex_lock(&file_priv->fbs_lock); in drm_mode_closefb()
405 list_for_each_entry(fbl, &file_priv->fbs, filp_head) in drm_mode_closefb()
410 mutex_unlock(&file_priv->fbs_lock); in drm_mode_closefb()
411 return -ENOENT; in drm_mode_closefb()
414 list_del_init(&fb->filp_head); in drm_mode_closefb()
415 mutex_unlock(&file_priv->fbs_lock); in drm_mode_closefb()
424 * drm_mode_rmfb - remove an FB from the configuration
431 * Called by the user via ioctl, or by an in-kernel client.
443 return -EOPNOTSUPP; in drm_mode_rmfb()
447 return -ENOENT; in drm_mode_rmfb()
456 * drm_framebuffer_remove may fail with -EINTR on pending signals, in drm_mode_rmfb()
465 drm_WARN_ON(dev, !list_empty(&fb->filp_head)); in drm_mode_rmfb()
466 list_add_tail(&fb->filp_head, &arg.fbs); in drm_mode_rmfb()
493 return -EOPNOTSUPP; in drm_mode_closefb_ioctl()
495 if (r->pad) in drm_mode_closefb_ioctl()
496 return -EINVAL; in drm_mode_closefb_ioctl()
498 fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id); in drm_mode_closefb_ioctl()
500 return -ENOENT; in drm_mode_closefb_ioctl()
508 * drm_mode_getfb - get FB info
528 return -EOPNOTSUPP; in drm_mode_getfb()
530 fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id); in drm_mode_getfb()
532 return -ENOENT; in drm_mode_getfb()
534 /* Multi-planar framebuffers need getfb2. */ in drm_mode_getfb()
535 if (fb->format->num_planes > 1) { in drm_mode_getfb()
536 ret = -EINVAL; in drm_mode_getfb()
540 if (!fb->funcs->create_handle) { in drm_mode_getfb()
541 ret = -ENODEV; in drm_mode_getfb()
545 r->height = fb->height; in drm_mode_getfb()
546 r->width = fb->width; in drm_mode_getfb()
547 r->depth = fb->format->depth; in drm_mode_getfb()
548 r->bpp = drm_format_info_bpp(fb->format, 0); in drm_mode_getfb()
549 r->pitch = fb->pitches[0]; in drm_mode_getfb()
552 * buffer-handle to non-master processes! For in drm_mode_getfb()
553 * backwards-compatibility reasons, we cannot make GET_FB() privileged, in drm_mode_getfb()
554 * so just return an invalid handle for non-masters. in drm_mode_getfb()
557 r->handle = 0; in drm_mode_getfb()
562 ret = fb->funcs->create_handle(fb, file_priv, &r->handle); in drm_mode_getfb()
570 * drm_mode_getfb2_ioctl - get extended FB info
591 return -EINVAL; in drm_mode_getfb2_ioctl()
593 fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id); in drm_mode_getfb2_ioctl()
595 return -ENOENT; in drm_mode_getfb2_ioctl()
597 /* For multi-plane framebuffers, we require the driver to place the in drm_mode_getfb2_ioctl()
598 * GEM objects directly in the drm_framebuffer. For single-plane in drm_mode_getfb2_ioctl()
601 if (!fb->obj[0] && in drm_mode_getfb2_ioctl()
602 (fb->format->num_planes > 1 || !fb->funcs->create_handle)) { in drm_mode_getfb2_ioctl()
603 ret = -ENODEV; in drm_mode_getfb2_ioctl()
607 r->height = fb->height; in drm_mode_getfb2_ioctl()
608 r->width = fb->width; in drm_mode_getfb2_ioctl()
609 r->pixel_format = fb->format->format; in drm_mode_getfb2_ioctl()
611 r->flags = 0; in drm_mode_getfb2_ioctl()
612 if (!dev->mode_config.fb_modifiers_not_supported) in drm_mode_getfb2_ioctl()
613 r->flags |= DRM_MODE_FB_MODIFIERS; in drm_mode_getfb2_ioctl()
615 for (i = 0; i < ARRAY_SIZE(r->handles); i++) { in drm_mode_getfb2_ioctl()
616 r->handles[i] = 0; in drm_mode_getfb2_ioctl()
617 r->pitches[i] = 0; in drm_mode_getfb2_ioctl()
618 r->offsets[i] = 0; in drm_mode_getfb2_ioctl()
619 r->modifier[i] = 0; in drm_mode_getfb2_ioctl()
622 for (i = 0; i < fb->format->num_planes; i++) { in drm_mode_getfb2_ioctl()
623 r->pitches[i] = fb->pitches[i]; in drm_mode_getfb2_ioctl()
624 r->offsets[i] = fb->offsets[i]; in drm_mode_getfb2_ioctl()
625 if (!dev->mode_config.fb_modifiers_not_supported) in drm_mode_getfb2_ioctl()
626 r->modifier[i] = fb->modifier; in drm_mode_getfb2_ioctl()
630 * buffer-handle to non master/root processes! To match GET_FB() in drm_mode_getfb2_ioctl()
639 for (i = 0; i < fb->format->num_planes; i++) { in drm_mode_getfb2_ioctl()
646 if (fb->obj[i] == fb->obj[j]) { in drm_mode_getfb2_ioctl()
647 r->handles[i] = r->handles[j]; in drm_mode_getfb2_ioctl()
652 if (r->handles[i]) in drm_mode_getfb2_ioctl()
655 if (fb->obj[i]) { in drm_mode_getfb2_ioctl()
656 ret = drm_gem_handle_create(file_priv, fb->obj[i], in drm_mode_getfb2_ioctl()
657 &r->handles[i]); in drm_mode_getfb2_ioctl()
660 ret = fb->funcs->create_handle(fb, file_priv, in drm_mode_getfb2_ioctl()
661 &r->handles[i]); in drm_mode_getfb2_ioctl()
670 /* Delete any previously-created handles on failure. */ in drm_mode_getfb2_ioctl()
671 for (i = 0; i < ARRAY_SIZE(r->handles); i++) { in drm_mode_getfb2_ioctl()
674 if (r->handles[i]) in drm_mode_getfb2_ioctl()
675 drm_gem_handle_delete(file_priv, r->handles[i]); in drm_mode_getfb2_ioctl()
680 for (j = i + 1; j < ARRAY_SIZE(r->handles); j++) { in drm_mode_getfb2_ioctl()
681 if (r->handles[j] == r->handles[i]) in drm_mode_getfb2_ioctl()
682 r->handles[j] = 0; in drm_mode_getfb2_ioctl()
692 * drm_mode_dirtyfb_ioctl - flush frontbuffer rendering on an FB
699 * this ioctl to flush out the changes on manual-update display outputs, e.g.
700 * usb display-link, mipi manual update panels or edp panel self refresh modes.
722 return -EOPNOTSUPP; in drm_mode_dirtyfb_ioctl()
724 fb = drm_framebuffer_lookup(dev, file_priv, r->fb_id); in drm_mode_dirtyfb_ioctl()
726 return -ENOENT; in drm_mode_dirtyfb_ioctl()
728 num_clips = r->num_clips; in drm_mode_dirtyfb_ioctl()
729 clips_ptr = (struct drm_clip_rect __user *)(unsigned long)r->clips_ptr; in drm_mode_dirtyfb_ioctl()
732 ret = -EINVAL; in drm_mode_dirtyfb_ioctl()
736 flags = DRM_MODE_FB_DIRTY_FLAGS & r->flags; in drm_mode_dirtyfb_ioctl()
740 ret = -EINVAL; in drm_mode_dirtyfb_ioctl()
746 ret = -EINVAL; in drm_mode_dirtyfb_ioctl()
751 ret = -ENOMEM; in drm_mode_dirtyfb_ioctl()
758 ret = -EFAULT; in drm_mode_dirtyfb_ioctl()
763 if (fb->funcs->dirty) { in drm_mode_dirtyfb_ioctl()
764 ret = fb->funcs->dirty(fb, file_priv, flags, r->color, in drm_mode_dirtyfb_ioctl()
767 ret = -ENOSYS; in drm_mode_dirtyfb_ioctl()
779 * drm_fb_release - remove and free the FBs on this file
798 * list any more, so no need to grab fpriv->fbs_lock. And we need to in drm_fb_release()
802 * Note that a real deadlock between fpriv->fbs_lock and the modeset in drm_fb_release()
806 list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) { in drm_fb_release()
808 list_move_tail(&fb->filp_head, &arg.fbs); in drm_fb_release()
810 list_del_init(&fb->filp_head); in drm_fb_release()
812 /* This drops the fpriv->fbs reference. */ in drm_fb_release()
830 struct drm_device *dev = fb->dev; in drm_framebuffer_free()
832 drm_WARN_ON(dev, !list_empty(&fb->filp_head)); in drm_framebuffer_free()
838 drm_mode_object_unregister(dev, &fb->base); in drm_framebuffer_free()
840 fb->funcs->destroy(fb); in drm_framebuffer_free()
845 * drm_framebuffer_init - initialize a framebuffer
855 * by other users. Which means by this point the fb _must_ be fully set up -
867 if (WARN_ON_ONCE(fb->dev != dev || !fb->format)) in drm_framebuffer_init()
868 return -EINVAL; in drm_framebuffer_init()
870 INIT_LIST_HEAD(&fb->filp_head); in drm_framebuffer_init()
872 fb->funcs = funcs; in drm_framebuffer_init()
873 strscpy(fb->comm, current->comm); in drm_framebuffer_init()
875 ret = __drm_mode_object_add(dev, &fb->base, DRM_MODE_OBJECT_FB, in drm_framebuffer_init()
880 mutex_lock(&dev->mode_config.fb_lock); in drm_framebuffer_init()
881 dev->mode_config.num_fb++; in drm_framebuffer_init()
882 list_add(&fb->head, &dev->mode_config.fb_list); in drm_framebuffer_init()
883 mutex_unlock(&dev->mode_config.fb_lock); in drm_framebuffer_init()
885 drm_mode_object_register(dev, &fb->base); in drm_framebuffer_init()
892 * drm_framebuffer_lookup - look up a drm framebuffer and grab a reference
897 * If successful, this grabs an additional reference to the framebuffer -
916 * drm_framebuffer_unregister_private - unregister a private fb from the lookup idr
919 * Drivers need to call this when cleaning up driver-private framebuffers, e.g.
924 * NOTE: This function is deprecated. For driver-private framebuffers it is not
936 dev = fb->dev; in drm_framebuffer_unregister_private()
939 drm_mode_object_unregister(dev, &fb->base); in drm_framebuffer_unregister_private()
944 * drm_framebuffer_cleanup - remove a framebuffer object
951 * Note that this function does not remove the fb from active usage - if it is
953 * the id and get back -EINVAL. Obviously no concern at driver unload time.
955 * Also, the framebuffer will not be removed from the lookup idr - for
956 * user-created framebuffers this will happen in the rmfb ioctl. For
957 * driver-private objects (e.g. for fbdev) drivers need to explicitly call
962 struct drm_device *dev = fb->dev; in drm_framebuffer_cleanup()
964 mutex_lock(&dev->mode_config.fb_lock); in drm_framebuffer_cleanup()
965 list_del(&fb->head); in drm_framebuffer_cleanup()
966 dev->mode_config.num_fb--; in drm_framebuffer_cleanup()
967 mutex_unlock(&dev->mode_config.fb_lock); in drm_framebuffer_cleanup()
974 struct drm_device *dev = fb->dev; in atomic_remove_fb()
988 ret = -ENOMEM; in atomic_remove_fb()
991 state->acquire_ctx = &ctx; in atomic_remove_fb()
1002 if (plane->state->fb != fb) in atomic_remove_fb()
1007 plane->base.id, plane->name, fb->base.id); in atomic_remove_fb()
1015 if (disable_crtcs && plane_state->crtc->primary == plane) { in atomic_remove_fb()
1020 plane_state->crtc->base.id, in atomic_remove_fb()
1021 plane_state->crtc->name, fb->base.id); in atomic_remove_fb()
1023 crtc_state = drm_atomic_get_existing_crtc_state(state, plane_state->crtc); in atomic_remove_fb()
1025 ret = drm_atomic_add_affected_connectors(state, plane_state->crtc); in atomic_remove_fb()
1029 crtc_state->active = false; in atomic_remove_fb()
1055 if (ret == -EDEADLK) { in atomic_remove_fb()
1067 if (ret == -EINVAL && !disable_crtcs) { in atomic_remove_fb()
1077 struct drm_device *dev = fb->dev; in legacy_remove_fb()
1084 if (crtc->primary->fb == fb) { in legacy_remove_fb()
1087 crtc->base.id, crtc->name, fb->base.id); in legacy_remove_fb()
1096 if (plane->fb == fb) { in legacy_remove_fb()
1099 plane->base.id, plane->name, fb->base.id); in legacy_remove_fb()
1107 * drm_framebuffer_remove - remove and unreference a framebuffer object
1112 * passed-in framebuffer. Might take the modeset locks.
1125 dev = fb->dev; in drm_framebuffer_remove()
1127 drm_WARN_ON(dev, !list_empty(&fb->filp_head)); in drm_framebuffer_remove()
1141 * in-use fb with fb-id == 0. Userspace is allowed to shoot its own foot in drm_framebuffer_remove()
1162 drm_printf_indent(p, indent, "allocated by = %s\n", fb->comm); in drm_framebuffer_print_info()
1165 drm_printf_indent(p, indent, "format=%p4cc\n", &fb->format->format); in drm_framebuffer_print_info()
1166 drm_printf_indent(p, indent, "modifier=0x%llx\n", fb->modifier); in drm_framebuffer_print_info()
1167 drm_printf_indent(p, indent, "size=%ux%u\n", fb->width, fb->height); in drm_framebuffer_print_info()
1170 for (i = 0; i < fb->format->num_planes; i++) { in drm_framebuffer_print_info()
1172 drm_format_info_plane_width(fb->format, fb->width, i), in drm_framebuffer_print_info()
1173 drm_format_info_plane_height(fb->format, fb->height, i)); in drm_framebuffer_print_info()
1174 drm_printf_indent(p, indent + 1, "pitch[%u]=%u\n", i, fb->pitches[i]); in drm_framebuffer_print_info()
1175 drm_printf_indent(p, indent + 1, "offset[%u]=%u\n", i, fb->offsets[i]); in drm_framebuffer_print_info()
1177 fb->obj[i] ? "" : "(null)"); in drm_framebuffer_print_info()
1178 if (fb->obj[i]) in drm_framebuffer_print_info()
1179 drm_gem_print_info(p, indent + 2, fb->obj[i]); in drm_framebuffer_print_info()
1186 struct drm_debugfs_entry *entry = m->private; in drm_framebuffer_info()
1187 struct drm_device *dev = entry->dev; in drm_framebuffer_info()
1191 mutex_lock(&dev->mode_config.fb_lock); in drm_framebuffer_info()
1193 drm_printf(&p, "framebuffer[%u]:\n", fb->base.id); in drm_framebuffer_info()
1196 mutex_unlock(&dev->mode_config.fb_lock); in drm_framebuffer_info()