2 * Copyright (c) 2016 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 #include <linux/export.h>
25 #include <drm/drm_auth.h>
26 #include <drm/drm_framebuffer.h>
28 #include "drm_crtc_internal.h"
33 * Frame buffers are abstract memory objects that provide a source of pixels to
34 * scanout to a CRTC. Applications explicitly request the creation of frame
35 * buffers through the DRM_IOCTL_MODE_ADDFB(2) ioctls and receive an opaque
36 * handle that can be passed to the KMS CRTC control, plane configuration and
37 * page flip functions.
39 * Frame buffers rely on the underlying memory manager for allocating backing
40 * storage. When creating a frame buffer applications pass a memory handle
41 * (or a list of memory handles for multi-planar formats) through the
42 * &struct drm_mode_fb_cmd2 argument. For drivers using GEM as their userspace
43 * buffer management interface this would be a GEM handle. Drivers are however
44 * free to use their own backing storage object handles, e.g. vmwgfx directly
45 * exposes special TTM handles to userspace and so expects TTM handles in the
46 * create ioctl and not GEM handles.
48 * Framebuffers are tracked with &struct drm_framebuffer. They are published
49 * using drm_framebuffer_init() - after calling that function userspace can use
50 * and access the framebuffer object. The helper function
51 * drm_helper_mode_fill_fb_struct() can be used to pre-fill the required
54 * The lifetime of a drm framebuffer is controlled with a reference count,
55 * drivers can grab additional references with drm_framebuffer_get() and drop
56 * them again with drm_framebuffer_put(). For driver-private framebuffers for
57 * which the last reference is never dropped (e.g. for the fbdev framebuffer
58 * when the struct &struct drm_framebuffer is embedded into the fbdev helper
59 * struct) drivers can manually clean up a framebuffer at module unload time
60 * with drm_framebuffer_unregister_private(). But doing this is not
61 * recommended, and it's better to have a normal free-standing &struct
65 int drm_framebuffer_check_src_coords(uint32_t src_x, uint32_t src_y,
66 uint32_t src_w, uint32_t src_h,
67 const struct drm_framebuffer *fb)
69 unsigned int fb_width, fb_height;
71 fb_width = fb->width << 16;
72 fb_height = fb->height << 16;
74 /* Make sure source coordinates are inside the fb. */
75 if (src_w > fb_width ||
76 src_x > fb_width - src_w ||
78 src_y > fb_height - src_h) {
79 DRM_DEBUG_KMS("Invalid source coordinates "
80 "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n",
81 src_w >> 16, ((src_w & 0xffff) * 15625) >> 10,
82 src_h >> 16, ((src_h & 0xffff) * 15625) >> 10,
83 src_x >> 16, ((src_x & 0xffff) * 15625) >> 10,
84 src_y >> 16, ((src_y & 0xffff) * 15625) >> 10);
92 * drm_mode_addfb - add an FB to the graphics configuration
93 * @dev: drm device for the ioctl
94 * @data: data pointer for the ioctl
95 * @file_priv: drm file for the ioctl call
97 * Add a new FB to the specified CRTC, given a user request. This is the
98 * original addfb ioctl which only supported RGB formats.
100 * Called by the user via ioctl.
103 * Zero on success, negative errno on failure.
105 int drm_mode_addfb(struct drm_device *dev,
106 void *data, struct drm_file *file_priv)
108 struct drm_mode_fb_cmd *or = data;
109 struct drm_mode_fb_cmd2 r = {};
112 /* convert to new format and call new ioctl */
115 r.height = or->height;
116 r.pitches[0] = or->pitch;
117 r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth);
118 r.handles[0] = or->handle;
120 ret = drm_mode_addfb2(dev, &r, file_priv);
129 static int fb_plane_width(int width,
130 const struct drm_format_info *format, int plane)
135 return DIV_ROUND_UP(width, format->hsub);
138 static int fb_plane_height(int height,
139 const struct drm_format_info *format, int plane)
144 return DIV_ROUND_UP(height, format->vsub);
147 static int framebuffer_check(struct drm_device *dev,
148 const struct drm_mode_fb_cmd2 *r)
150 const struct drm_format_info *info;
153 /* check if the format is supported at all */
154 info = __drm_format_info(r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN);
156 struct drm_format_name_buf format_name;
157 DRM_DEBUG_KMS("bad framebuffer format %s\n",
158 drm_get_format_name(r->pixel_format,
163 /* now let the driver pick its own format info */
164 info = drm_get_format_info(dev, r);
167 DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
171 if (r->height == 0) {
172 DRM_DEBUG_KMS("bad framebuffer height %u\n", r->height);
176 for (i = 0; i < info->num_planes; i++) {
177 unsigned int width = fb_plane_width(r->width, info, i);
178 unsigned int height = fb_plane_height(r->height, info, i);
179 unsigned int cpp = info->cpp[i];
181 if (!r->handles[i]) {
182 DRM_DEBUG_KMS("no buffer object handle for plane %d\n", i);
186 if ((uint64_t) width * cpp > UINT_MAX)
189 if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX)
192 if (r->pitches[i] < width * cpp) {
193 DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[i], i);
197 if (r->modifier[i] && !(r->flags & DRM_MODE_FB_MODIFIERS)) {
198 DRM_DEBUG_KMS("bad fb modifier %llu for plane %d\n",
203 if (r->flags & DRM_MODE_FB_MODIFIERS &&
204 r->modifier[i] != r->modifier[0]) {
205 DRM_DEBUG_KMS("bad fb modifier %llu for plane %d\n",
210 /* modifier specific checks: */
211 switch (r->modifier[i]) {
212 case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE:
213 /* NOTE: the pitch restriction may be lifted later if it turns
214 * out that no hw has this restriction:
216 if (r->pixel_format != DRM_FORMAT_NV12 ||
217 width % 128 || height % 32 ||
218 r->pitches[i] % 128) {
219 DRM_DEBUG_KMS("bad modifier data for plane %d\n", i);
229 for (i = info->num_planes; i < 4; i++) {
230 if (r->modifier[i]) {
231 DRM_DEBUG_KMS("non-zero modifier for unused plane %d\n", i);
235 /* Pre-FB_MODIFIERS userspace didn't clear the structs properly. */
236 if (!(r->flags & DRM_MODE_FB_MODIFIERS))
240 DRM_DEBUG_KMS("buffer object handle for unused plane %d\n", i);
245 DRM_DEBUG_KMS("non-zero pitch for unused plane %d\n", i);
250 DRM_DEBUG_KMS("non-zero offset for unused plane %d\n", i);
258 struct drm_framebuffer *
259 drm_internal_framebuffer_create(struct drm_device *dev,
260 const struct drm_mode_fb_cmd2 *r,
261 struct drm_file *file_priv)
263 struct drm_mode_config *config = &dev->mode_config;
264 struct drm_framebuffer *fb;
267 if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS)) {
268 DRM_DEBUG_KMS("bad framebuffer flags 0x%08x\n", r->flags);
269 return ERR_PTR(-EINVAL);
272 if ((config->min_width > r->width) || (r->width > config->max_width)) {
273 DRM_DEBUG_KMS("bad framebuffer width %d, should be >= %d && <= %d\n",
274 r->width, config->min_width, config->max_width);
275 return ERR_PTR(-EINVAL);
277 if ((config->min_height > r->height) || (r->height > config->max_height)) {
278 DRM_DEBUG_KMS("bad framebuffer height %d, should be >= %d && <= %d\n",
279 r->height, config->min_height, config->max_height);
280 return ERR_PTR(-EINVAL);
283 if (r->flags & DRM_MODE_FB_MODIFIERS &&
284 !dev->mode_config.allow_fb_modifiers) {
285 DRM_DEBUG_KMS("driver does not support fb modifiers\n");
286 return ERR_PTR(-EINVAL);
289 ret = framebuffer_check(dev, r);
293 fb = dev->mode_config.funcs->fb_create(dev, file_priv, r);
295 DRM_DEBUG_KMS("could not create framebuffer\n");
303 * drm_mode_addfb2 - add an FB to the graphics configuration
304 * @dev: drm device for the ioctl
305 * @data: data pointer for the ioctl
306 * @file_priv: drm file for the ioctl call
308 * Add a new FB to the specified CRTC, given a user request with format. This is
309 * the 2nd version of the addfb ioctl, which supports multi-planar framebuffers
310 * and uses fourcc codes as pixel format specifiers.
312 * Called by the user via ioctl.
315 * Zero on success, negative errno on failure.
317 int drm_mode_addfb2(struct drm_device *dev,
318 void *data, struct drm_file *file_priv)
320 struct drm_mode_fb_cmd2 *r = data;
321 struct drm_framebuffer *fb;
323 if (!drm_core_check_feature(dev, DRIVER_MODESET))
326 fb = drm_internal_framebuffer_create(dev, r, file_priv);
330 DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
331 r->fb_id = fb->base.id;
333 /* Transfer ownership to the filp for reaping on close */
334 mutex_lock(&file_priv->fbs_lock);
335 list_add(&fb->filp_head, &file_priv->fbs);
336 mutex_unlock(&file_priv->fbs_lock);
341 struct drm_mode_rmfb_work {
342 struct work_struct work;
343 struct list_head fbs;
346 static void drm_mode_rmfb_work_fn(struct work_struct *w)
348 struct drm_mode_rmfb_work *arg = container_of(w, typeof(*arg), work);
350 while (!list_empty(&arg->fbs)) {
351 struct drm_framebuffer *fb =
352 list_first_entry(&arg->fbs, typeof(*fb), filp_head);
354 list_del_init(&fb->filp_head);
355 drm_framebuffer_remove(fb);
360 * drm_mode_rmfb - remove an FB from the configuration
361 * @dev: drm device for the ioctl
362 * @data: data pointer for the ioctl
363 * @file_priv: drm file for the ioctl call
365 * Remove the FB specified by the user.
367 * Called by the user via ioctl.
370 * Zero on success, negative errno on failure.
372 int drm_mode_rmfb(struct drm_device *dev,
373 void *data, struct drm_file *file_priv)
375 struct drm_framebuffer *fb = NULL;
376 struct drm_framebuffer *fbl = NULL;
380 if (!drm_core_check_feature(dev, DRIVER_MODESET))
383 fb = drm_framebuffer_lookup(dev, *id);
387 mutex_lock(&file_priv->fbs_lock);
388 list_for_each_entry(fbl, &file_priv->fbs, filp_head)
392 mutex_unlock(&file_priv->fbs_lock);
396 list_del_init(&fb->filp_head);
397 mutex_unlock(&file_priv->fbs_lock);
399 /* drop the reference we picked up in framebuffer lookup */
400 drm_framebuffer_put(fb);
403 * we now own the reference that was stored in the fbs list
405 * drm_framebuffer_remove may fail with -EINTR on pending signals,
406 * so run this in a separate stack as there's no way to correctly
407 * handle this after the fb is already removed from the lookup table.
409 if (drm_framebuffer_read_refcount(fb) > 1) {
410 struct drm_mode_rmfb_work arg;
412 INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn);
413 INIT_LIST_HEAD(&arg.fbs);
414 list_add_tail(&fb->filp_head, &arg.fbs);
416 schedule_work(&arg.work);
417 flush_work(&arg.work);
418 destroy_work_on_stack(&arg.work);
420 drm_framebuffer_put(fb);
425 drm_framebuffer_put(fb);
430 * drm_mode_getfb - get FB info
431 * @dev: drm device for the ioctl
432 * @data: data pointer for the ioctl
433 * @file_priv: drm file for the ioctl call
435 * Lookup the FB given its ID and return info about it.
437 * Called by the user via ioctl.
440 * Zero on success, negative errno on failure.
442 int drm_mode_getfb(struct drm_device *dev,
443 void *data, struct drm_file *file_priv)
445 struct drm_mode_fb_cmd *r = data;
446 struct drm_framebuffer *fb;
449 if (!drm_core_check_feature(dev, DRIVER_MODESET))
452 fb = drm_framebuffer_lookup(dev, r->fb_id);
456 r->height = fb->height;
457 r->width = fb->width;
458 r->depth = fb->format->depth;
459 r->bpp = fb->format->cpp[0] * 8;
460 r->pitch = fb->pitches[0];
461 if (fb->funcs->create_handle) {
462 if (drm_is_current_master(file_priv) || capable(CAP_SYS_ADMIN) ||
463 drm_is_control_client(file_priv)) {
464 ret = fb->funcs->create_handle(fb, file_priv,
467 /* GET_FB() is an unprivileged ioctl so we must not
468 * return a buffer-handle to non-master processes! For
469 * backwards-compatibility reasons, we cannot make
470 * GET_FB() privileged, so just return an invalid handle
471 * for non-masters. */
479 drm_framebuffer_put(fb);
485 * drm_mode_dirtyfb_ioctl - flush frontbuffer rendering on an FB
486 * @dev: drm device for the ioctl
487 * @data: data pointer for the ioctl
488 * @file_priv: drm file for the ioctl call
490 * Lookup the FB and flush out the damaged area supplied by userspace as a clip
491 * rectangle list. Generic userspace which does frontbuffer rendering must call
492 * this ioctl to flush out the changes on manual-update display outputs, e.g.
493 * usb display-link, mipi manual update panels or edp panel self refresh modes.
495 * Modesetting drivers which always update the frontbuffer do not need to
496 * implement the corresponding &drm_framebuffer_funcs.dirty callback.
498 * Called by the user via ioctl.
501 * Zero on success, negative errno on failure.
503 int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
504 void *data, struct drm_file *file_priv)
506 struct drm_clip_rect __user *clips_ptr;
507 struct drm_clip_rect *clips = NULL;
508 struct drm_mode_fb_dirty_cmd *r = data;
509 struct drm_framebuffer *fb;
514 if (!drm_core_check_feature(dev, DRIVER_MODESET))
517 fb = drm_framebuffer_lookup(dev, r->fb_id);
521 num_clips = r->num_clips;
522 clips_ptr = (struct drm_clip_rect __user *)(unsigned long)r->clips_ptr;
524 if (!num_clips != !clips_ptr) {
529 flags = DRM_MODE_FB_DIRTY_FLAGS & r->flags;
531 /* If userspace annotates copy, clips must come in pairs */
532 if (flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY && (num_clips % 2)) {
537 if (num_clips && clips_ptr) {
538 if (num_clips < 0 || num_clips > DRM_MODE_FB_DIRTY_MAX_CLIPS) {
542 clips = kcalloc(num_clips, sizeof(*clips), GFP_KERNEL);
548 ret = copy_from_user(clips, clips_ptr,
549 num_clips * sizeof(*clips));
556 if (fb->funcs->dirty) {
557 ret = fb->funcs->dirty(fb, file_priv, flags, r->color,
566 drm_framebuffer_put(fb);
572 * drm_fb_release - remove and free the FBs on this file
573 * @priv: drm file for the ioctl
575 * Destroy all the FBs associated with @filp.
577 * Called by the user via ioctl.
580 * Zero on success, negative errno on failure.
582 void drm_fb_release(struct drm_file *priv)
584 struct drm_framebuffer *fb, *tfb;
585 struct drm_mode_rmfb_work arg;
587 INIT_LIST_HEAD(&arg.fbs);
590 * When the file gets released that means no one else can access the fb
591 * list any more, so no need to grab fpriv->fbs_lock. And we need to
592 * avoid upsetting lockdep since the universal cursor code adds a
593 * framebuffer while holding mutex locks.
595 * Note that a real deadlock between fpriv->fbs_lock and the modeset
596 * locks is impossible here since no one else but this function can get
599 list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) {
600 if (drm_framebuffer_read_refcount(fb) > 1) {
601 list_move_tail(&fb->filp_head, &arg.fbs);
603 list_del_init(&fb->filp_head);
605 /* This drops the fpriv->fbs reference. */
606 drm_framebuffer_put(fb);
610 if (!list_empty(&arg.fbs)) {
611 INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn);
613 schedule_work(&arg.work);
614 flush_work(&arg.work);
615 destroy_work_on_stack(&arg.work);
619 void drm_framebuffer_free(struct kref *kref)
621 struct drm_framebuffer *fb =
622 container_of(kref, struct drm_framebuffer, base.refcount);
623 struct drm_device *dev = fb->dev;
626 * The lookup idr holds a weak reference, which has not necessarily been
627 * removed at this point. Check for that.
629 drm_mode_object_unregister(dev, &fb->base);
631 fb->funcs->destroy(fb);
635 * drm_framebuffer_init - initialize a framebuffer
637 * @fb: framebuffer to be initialized
638 * @funcs: ... with these functions
640 * Allocates an ID for the framebuffer's parent mode object, sets its mode
641 * functions & device file and adds it to the master fd list.
644 * This functions publishes the fb and makes it available for concurrent access
645 * by other users. Which means by this point the fb _must_ be fully set up -
646 * since all the fb attributes are invariant over its lifetime, no further
647 * locking but only correct reference counting is required.
650 * Zero on success, error code on failure.
652 int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
653 const struct drm_framebuffer_funcs *funcs)
657 if (WARN_ON_ONCE(fb->dev != dev || !fb->format))
660 INIT_LIST_HEAD(&fb->filp_head);
664 ret = __drm_mode_object_add(dev, &fb->base, DRM_MODE_OBJECT_FB,
665 false, drm_framebuffer_free);
669 mutex_lock(&dev->mode_config.fb_lock);
670 dev->mode_config.num_fb++;
671 list_add(&fb->head, &dev->mode_config.fb_list);
672 mutex_unlock(&dev->mode_config.fb_lock);
674 drm_mode_object_register(dev, &fb->base);
678 EXPORT_SYMBOL(drm_framebuffer_init);
681 * drm_framebuffer_lookup - look up a drm framebuffer and grab a reference
683 * @id: id of the fb object
685 * If successful, this grabs an additional reference to the framebuffer -
686 * callers need to make sure to eventually unreference the returned framebuffer
687 * again, using drm_framebuffer_put().
689 struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
692 struct drm_mode_object *obj;
693 struct drm_framebuffer *fb = NULL;
695 obj = __drm_mode_object_find(dev, id, DRM_MODE_OBJECT_FB);
700 EXPORT_SYMBOL(drm_framebuffer_lookup);
703 * drm_framebuffer_unregister_private - unregister a private fb from the lookup idr
704 * @fb: fb to unregister
706 * Drivers need to call this when cleaning up driver-private framebuffers, e.g.
707 * those used for fbdev. Note that the caller must hold a reference of it's own,
708 * i.e. the object may not be destroyed through this call (since it'll lead to a
709 * locking inversion).
711 * NOTE: This function is deprecated. For driver-private framebuffers it is not
712 * recommended to embed a framebuffer struct info fbdev struct, instead, a
713 * framebuffer pointer is preferred and drm_framebuffer_put() should be called
714 * when the framebuffer is to be cleaned up.
716 void drm_framebuffer_unregister_private(struct drm_framebuffer *fb)
718 struct drm_device *dev;
725 /* Mark fb as reaped and drop idr ref. */
726 drm_mode_object_unregister(dev, &fb->base);
728 EXPORT_SYMBOL(drm_framebuffer_unregister_private);
731 * drm_framebuffer_cleanup - remove a framebuffer object
732 * @fb: framebuffer to remove
734 * Cleanup framebuffer. This function is intended to be used from the drivers
735 * &drm_framebuffer_funcs.destroy callback. It can also be used to clean up
736 * driver private framebuffers embedded into a larger structure.
738 * Note that this function does not remove the fb from active usage - if it is
739 * still used anywhere, hilarity can ensue since userspace could call getfb on
740 * the id and get back -EINVAL. Obviously no concern at driver unload time.
742 * Also, the framebuffer will not be removed from the lookup idr - for
743 * user-created framebuffers this will happen in in the rmfb ioctl. For
744 * driver-private objects (e.g. for fbdev) drivers need to explicitly call
745 * drm_framebuffer_unregister_private.
747 void drm_framebuffer_cleanup(struct drm_framebuffer *fb)
749 struct drm_device *dev = fb->dev;
751 mutex_lock(&dev->mode_config.fb_lock);
753 dev->mode_config.num_fb--;
754 mutex_unlock(&dev->mode_config.fb_lock);
756 EXPORT_SYMBOL(drm_framebuffer_cleanup);
759 * drm_framebuffer_remove - remove and unreference a framebuffer object
760 * @fb: framebuffer to remove
762 * Scans all the CRTCs and planes in @dev's mode_config. If they're
763 * using @fb, removes it, setting it to NULL. Then drops the reference to the
764 * passed-in framebuffer. Might take the modeset locks.
766 * Note that this function optimizes the cleanup away if the caller holds the
767 * last reference to the framebuffer. It is also guaranteed to not take the
768 * modeset locks in this case.
770 void drm_framebuffer_remove(struct drm_framebuffer *fb)
772 struct drm_device *dev;
773 struct drm_crtc *crtc;
774 struct drm_plane *plane;
781 WARN_ON(!list_empty(&fb->filp_head));
784 * drm ABI mandates that we remove any deleted framebuffers from active
785 * useage. But since most sane clients only remove framebuffers they no
786 * longer need, try to optimize this away.
788 * Since we're holding a reference ourselves, observing a refcount of 1
789 * means that we're the last holder and can skip it. Also, the refcount
790 * can never increase from 1 again, so we don't need any barriers or
793 * Note that userspace could try to race with use and instate a new
794 * usage _after_ we've cleared all current ones. End result will be an
795 * in-use fb with fb-id == 0. Userspace is allowed to shoot its own foot
798 if (drm_framebuffer_read_refcount(fb) > 1) {
799 if (drm_drv_uses_atomic_modeset(dev)) {
800 int ret = drm_atomic_remove_fb(fb);
801 WARN(ret, "atomic remove_fb failed with %i\n", ret);
805 drm_modeset_lock_all(dev);
806 /* remove from any CRTC */
807 drm_for_each_crtc(crtc, dev) {
808 if (crtc->primary->fb == fb) {
809 /* should turn off the crtc */
810 if (drm_crtc_force_disable(crtc))
811 DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc);
815 drm_for_each_plane(plane, dev) {
817 drm_plane_force_disable(plane);
819 drm_modeset_unlock_all(dev);
823 drm_framebuffer_put(fb);
825 EXPORT_SYMBOL(drm_framebuffer_remove);
828 * drm_framebuffer_plane_width - width of the plane given the first plane
829 * @width: width of the first plane
830 * @fb: the framebuffer
831 * @plane: plane index
834 * The width of @plane, given that the width of the first plane is @width.
836 int drm_framebuffer_plane_width(int width,
837 const struct drm_framebuffer *fb, int plane)
839 if (plane >= fb->format->num_planes)
842 return fb_plane_width(width, fb->format, plane);
844 EXPORT_SYMBOL(drm_framebuffer_plane_width);
847 * drm_framebuffer_plane_height - height of the plane given the first plane
848 * @height: height of the first plane
849 * @fb: the framebuffer
850 * @plane: plane index
853 * The height of @plane, given that the height of the first plane is @height.
855 int drm_framebuffer_plane_height(int height,
856 const struct drm_framebuffer *fb, int plane)
858 if (plane >= fb->format->num_planes)
861 return fb_plane_height(height, fb->format, plane);
863 EXPORT_SYMBOL(drm_framebuffer_plane_height);