Merge tag 'topic/drm-misc-2016-08-12' of git://anongit.freedesktop.org/drm-intel into drm-next

- more fence destaging and cleanup (Gustavo&Sumit)
- DRIVER_LEGACY to untangle from DRIVER_MODESET
- drm_mm refactor (Chris)
- fbdev-less compile fies
- clipped plane src/dst rects (Ville)
- + a few mediatek patches that build on top of that (Bibby+Daniel)
- small stuff all over really

* tag 'topic/drm-misc-2016-08-12' of git://anongit.freedesktop.org/drm-intel: (43 commits)
  dma-buf/fence: kerneldoc: remove spurious section header
  dma-buf/fence: kerneldoc: remove unused struct members
  Revert "gpu: drm: omapdrm: dss-of: add missing of_node_put after calling of_parse_phandle"
  drm: Protect fb_defio in drivers with CONFIG_KMS_FBDEV_EMULATION
  drm/radeon|amgpu: Make fbdev emulation optional
  drm/vmwgfx: select CONFIG_FB
  drm: Remove superflous linux/fb.h includes
  drm/fb-helper: Add a dummy remove_conflicting_framebuffers
  dma-buf/sync_file: only enable fence signalling on poll()
  Documentation: add doc for sync_file_get_fence()
  dma-buf/sync_file: add sync_file_get_fence()
  dma-buf/sync_file: refactor fence storage in struct sync_file
  dma-buf/fence-array: add fence_is_array()
  drm/dp_helper: Rate limit timeout errors from drm_dp_i2c_do_msg()
  drm/dp_helper: Print first error received on failure in drm_dp_dpcd_access()
  drm: Add ratelimited versions of the DRM_DEBUG* macros
  drm: Make sure drm_vblank_no_hw_counter isn't abused
  drm/mediatek: Fix mtk_atomic_complete for runtime_pm
  drm/mediatek: plane: Use FB's format's cpp to compute x offset
  drm/mediatek: plane: Merge mtk_plane_enable into mtk_plane_atomic_update
  ...
This commit is contained in:
Dave Airlie 2016-08-15 16:46:36 +10:00
commit f8725ad1da
103 changed files with 981 additions and 769 deletions

View File

@ -53,9 +53,12 @@ u32 driver_features;
DRIVER_USE_AGP DRIVER_USE_AGP
Driver uses AGP interface, the DRM core will manage AGP resources. Driver uses AGP interface, the DRM core will manage AGP resources.
DRIVER_REQUIRE_AGP DRIVER_LEGACY
Driver needs AGP interface to function. AGP initialization failure Denote a legacy driver using shadow attach. Don't use.
will become a fatal error.
DRIVER_KMS_LEGACY_CONTEXT
Used only by nouveau for backwards compatibility with existing userspace.
Don't use.
DRIVER_PCI_DMA DRIVER_PCI_DMA
Driver is capable of PCI DMA, mapping of PCI DMA buffers to Driver is capable of PCI DMA, mapping of PCI DMA buffers to

View File

@ -64,6 +64,20 @@ The sync_file fd now can be sent to userspace.
If the creation process fail, or the sync_file needs to be released by any If the creation process fail, or the sync_file needs to be released by any
other reason fput(sync_file->file) should be used. other reason fput(sync_file->file) should be used.
Receiving Sync Files from Userspace
-----------------------------------
When userspace needs to send an in-fence to the driver it passes file descriptor
of the Sync File to the kernel. The kernel can then retrieve the fences
from it.
Interface:
struct fence *sync_file_get_fence(int fd);
The returned reference is owned by the caller and must be disposed of
afterwards using fence_put(). In case of error, a NULL is returned instead.
References: References:
[1] struct sync_file in include/linux/sync_file.h [1] struct sync_file in include/linux/sync_file.h
[2] All interfaces mentioned above defined in include/linux/sync_file.h [2] All interfaces mentioned above defined in include/linux/sync_file.h

View File

@ -99,6 +99,7 @@ const struct fence_ops fence_array_ops = {
.wait = fence_default_wait, .wait = fence_default_wait,
.release = fence_array_release, .release = fence_array_release,
}; };
EXPORT_SYMBOL(fence_array_ops);
/** /**
* fence_array_create - Create a custom fence array * fence_array_create - Create a custom fence array

View File

@ -28,11 +28,11 @@
static const struct file_operations sync_file_fops; static const struct file_operations sync_file_fops;
static struct sync_file *sync_file_alloc(int size) static struct sync_file *sync_file_alloc(void)
{ {
struct sync_file *sync_file; struct sync_file *sync_file;
sync_file = kzalloc(size, GFP_KERNEL); sync_file = kzalloc(sizeof(*sync_file), GFP_KERNEL);
if (!sync_file) if (!sync_file)
return NULL; return NULL;
@ -45,6 +45,8 @@ static struct sync_file *sync_file_alloc(int size)
init_waitqueue_head(&sync_file->wq); init_waitqueue_head(&sync_file->wq);
INIT_LIST_HEAD(&sync_file->cb.node);
return sync_file; return sync_file;
err: err:
@ -54,14 +56,11 @@ static struct sync_file *sync_file_alloc(int size)
static void fence_check_cb_func(struct fence *f, struct fence_cb *cb) static void fence_check_cb_func(struct fence *f, struct fence_cb *cb)
{ {
struct sync_file_cb *check;
struct sync_file *sync_file; struct sync_file *sync_file;
check = container_of(cb, struct sync_file_cb, cb); sync_file = container_of(cb, struct sync_file, cb);
sync_file = check->sync_file;
if (atomic_dec_and_test(&sync_file->status)) wake_up_all(&sync_file->wq);
wake_up_all(&sync_file->wq);
} }
/** /**
@ -76,23 +75,17 @@ struct sync_file *sync_file_create(struct fence *fence)
{ {
struct sync_file *sync_file; struct sync_file *sync_file;
sync_file = sync_file_alloc(offsetof(struct sync_file, cbs[1])); sync_file = sync_file_alloc();
if (!sync_file) if (!sync_file)
return NULL; return NULL;
sync_file->num_fences = 1; sync_file->fence = fence;
atomic_set(&sync_file->status, 1);
snprintf(sync_file->name, sizeof(sync_file->name), "%s-%s%llu-%d", snprintf(sync_file->name, sizeof(sync_file->name), "%s-%s%llu-%d",
fence->ops->get_driver_name(fence), fence->ops->get_driver_name(fence),
fence->ops->get_timeline_name(fence), fence->context, fence->ops->get_timeline_name(fence), fence->context,
fence->seqno); fence->seqno);
sync_file->cbs[0].fence = fence;
sync_file->cbs[0].sync_file = sync_file;
if (fence_add_callback(fence, &sync_file->cbs[0].cb,
fence_check_cb_func))
atomic_dec(&sync_file->status);
return sync_file; return sync_file;
} }
EXPORT_SYMBOL(sync_file_create); EXPORT_SYMBOL(sync_file_create);
@ -121,14 +114,72 @@ static struct sync_file *sync_file_fdget(int fd)
return NULL; return NULL;
} }
static void sync_file_add_pt(struct sync_file *sync_file, int *i, /**
struct fence *fence) * sync_file_get_fence - get the fence related to the sync_file fd
* @fd: sync_file fd to get the fence from
*
* Ensures @fd references a valid sync_file and returns a fence that
* represents all fence in the sync_file. On error NULL is returned.
*/
struct fence *sync_file_get_fence(int fd)
{ {
sync_file->cbs[*i].fence = fence; struct sync_file *sync_file;
sync_file->cbs[*i].sync_file = sync_file; struct fence *fence;
if (!fence_add_callback(fence, &sync_file->cbs[*i].cb, sync_file = sync_file_fdget(fd);
fence_check_cb_func)) { if (!sync_file)
return NULL;
fence = fence_get(sync_file->fence);
fput(sync_file->file);
return fence;
}
EXPORT_SYMBOL(sync_file_get_fence);
static int sync_file_set_fence(struct sync_file *sync_file,
struct fence **fences, int num_fences)
{
struct fence_array *array;
/*
* The reference for the fences in the new sync_file and held
* in add_fence() during the merge procedure, so for num_fences == 1
* we already own a new reference to the fence. For num_fence > 1
* we own the reference of the fence_array creation.
*/
if (num_fences == 1) {
sync_file->fence = fences[0];
} else {
array = fence_array_create(num_fences, fences,
fence_context_alloc(1), 1, false);
if (!array)
return -ENOMEM;
sync_file->fence = &array->base;
}
return 0;
}
static struct fence **get_fences(struct sync_file *sync_file, int *num_fences)
{
if (fence_is_array(sync_file->fence)) {
struct fence_array *array = to_fence_array(sync_file->fence);
*num_fences = array->num_fences;
return array->fences;
}
*num_fences = 1;
return &sync_file->fence;
}
static void add_fence(struct fence **fences, int *i, struct fence *fence)
{
fences[*i] = fence;
if (!fence_is_signaled(fence)) {
fence_get(fence); fence_get(fence);
(*i)++; (*i)++;
} }
@ -147,16 +198,24 @@ static void sync_file_add_pt(struct sync_file *sync_file, int *i,
static struct sync_file *sync_file_merge(const char *name, struct sync_file *a, static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
struct sync_file *b) struct sync_file *b)
{ {
int num_fences = a->num_fences + b->num_fences;
struct sync_file *sync_file; struct sync_file *sync_file;
int i, i_a, i_b; struct fence **fences, **nfences, **a_fences, **b_fences;
unsigned long size = offsetof(struct sync_file, cbs[num_fences]); int i, i_a, i_b, num_fences, a_num_fences, b_num_fences;
sync_file = sync_file_alloc(size); sync_file = sync_file_alloc();
if (!sync_file) if (!sync_file)
return NULL; return NULL;
atomic_set(&sync_file->status, num_fences); a_fences = get_fences(a, &a_num_fences);
b_fences = get_fences(b, &b_num_fences);
if (a_num_fences > INT_MAX - b_num_fences)
return NULL;
num_fences = a_num_fences + b_num_fences;
fences = kcalloc(num_fences, sizeof(*fences), GFP_KERNEL);
if (!fences)
goto err;
/* /*
* Assume sync_file a and b are both ordered and have no * Assume sync_file a and b are both ordered and have no
@ -165,55 +224,71 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
* If a sync_file can only be created with sync_file_merge * If a sync_file can only be created with sync_file_merge
* and sync_file_create, this is a reasonable assumption. * and sync_file_create, this is a reasonable assumption.
*/ */
for (i = i_a = i_b = 0; i_a < a->num_fences && i_b < b->num_fences; ) { for (i = i_a = i_b = 0; i_a < a_num_fences && i_b < b_num_fences; ) {
struct fence *pt_a = a->cbs[i_a].fence; struct fence *pt_a = a_fences[i_a];
struct fence *pt_b = b->cbs[i_b].fence; struct fence *pt_b = b_fences[i_b];
if (pt_a->context < pt_b->context) { if (pt_a->context < pt_b->context) {
sync_file_add_pt(sync_file, &i, pt_a); add_fence(fences, &i, pt_a);
i_a++; i_a++;
} else if (pt_a->context > pt_b->context) { } else if (pt_a->context > pt_b->context) {
sync_file_add_pt(sync_file, &i, pt_b); add_fence(fences, &i, pt_b);
i_b++; i_b++;
} else { } else {
if (pt_a->seqno - pt_b->seqno <= INT_MAX) if (pt_a->seqno - pt_b->seqno <= INT_MAX)
sync_file_add_pt(sync_file, &i, pt_a); add_fence(fences, &i, pt_a);
else else
sync_file_add_pt(sync_file, &i, pt_b); add_fence(fences, &i, pt_b);
i_a++; i_a++;
i_b++; i_b++;
} }
} }
for (; i_a < a->num_fences; i_a++) for (; i_a < a_num_fences; i_a++)
sync_file_add_pt(sync_file, &i, a->cbs[i_a].fence); add_fence(fences, &i, a_fences[i_a]);
for (; i_b < b->num_fences; i_b++) for (; i_b < b_num_fences; i_b++)
sync_file_add_pt(sync_file, &i, b->cbs[i_b].fence); add_fence(fences, &i, b_fences[i_b]);
if (num_fences > i) if (i == 0) {
atomic_sub(num_fences - i, &sync_file->status); add_fence(fences, &i, a_fences[0]);
sync_file->num_fences = i; i++;
}
if (num_fences > i) {
nfences = krealloc(fences, i * sizeof(*fences),
GFP_KERNEL);
if (!nfences)
goto err;
fences = nfences;
}
if (sync_file_set_fence(sync_file, fences, i) < 0) {
kfree(fences);
goto err;
}
strlcpy(sync_file->name, name, sizeof(sync_file->name)); strlcpy(sync_file->name, name, sizeof(sync_file->name));
return sync_file; return sync_file;
err:
fput(sync_file->file);
return NULL;
} }
static void sync_file_free(struct kref *kref) static void sync_file_free(struct kref *kref)
{ {
struct sync_file *sync_file = container_of(kref, struct sync_file, struct sync_file *sync_file = container_of(kref, struct sync_file,
kref); kref);
int i;
for (i = 0; i < sync_file->num_fences; ++i) {
fence_remove_callback(sync_file->cbs[i].fence,
&sync_file->cbs[i].cb);
fence_put(sync_file->cbs[i].fence);
}
if (test_bit(POLL_ENABLED, &sync_file->fence->flags))
fence_remove_callback(sync_file->fence, &sync_file->cb);
fence_put(sync_file->fence);
kfree(sync_file); kfree(sync_file);
} }
@ -228,17 +303,16 @@ static int sync_file_release(struct inode *inode, struct file *file)
static unsigned int sync_file_poll(struct file *file, poll_table *wait) static unsigned int sync_file_poll(struct file *file, poll_table *wait)
{ {
struct sync_file *sync_file = file->private_data; struct sync_file *sync_file = file->private_data;
int status;
poll_wait(file, &sync_file->wq, wait); poll_wait(file, &sync_file->wq, wait);
status = atomic_read(&sync_file->status); if (!test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) {
if (fence_add_callback(sync_file->fence, &sync_file->cb,
fence_check_cb_func) < 0)
wake_up_all(&sync_file->wq);
}
if (!status) return fence_is_signaled(sync_file->fence) ? POLLIN : 0;
return POLLIN;
if (status < 0)
return POLLERR;
return 0;
} }
static long sync_file_ioctl_merge(struct sync_file *sync_file, static long sync_file_ioctl_merge(struct sync_file *sync_file,
@ -315,8 +389,9 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
{ {
struct sync_file_info info; struct sync_file_info info;
struct sync_fence_info *fence_info = NULL; struct sync_fence_info *fence_info = NULL;
struct fence **fences;
__u32 size; __u32 size;
int ret, i; int num_fences, ret, i;
if (copy_from_user(&info, (void __user *)arg, sizeof(info))) if (copy_from_user(&info, (void __user *)arg, sizeof(info)))
return -EFAULT; return -EFAULT;
@ -324,6 +399,8 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
if (info.flags || info.pad) if (info.flags || info.pad)
return -EINVAL; return -EINVAL;
fences = get_fences(sync_file, &num_fences);
/* /*
* Passing num_fences = 0 means that userspace doesn't want to * Passing num_fences = 0 means that userspace doesn't want to
* retrieve any sync_fence_info. If num_fences = 0 we skip filling * retrieve any sync_fence_info. If num_fences = 0 we skip filling
@ -333,16 +410,16 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
if (!info.num_fences) if (!info.num_fences)
goto no_fences; goto no_fences;
if (info.num_fences < sync_file->num_fences) if (info.num_fences < num_fences)
return -EINVAL; return -EINVAL;
size = sync_file->num_fences * sizeof(*fence_info); size = num_fences * sizeof(*fence_info);
fence_info = kzalloc(size, GFP_KERNEL); fence_info = kzalloc(size, GFP_KERNEL);
if (!fence_info) if (!fence_info)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < sync_file->num_fences; ++i) for (i = 0; i < num_fences; i++)
sync_fill_fence_info(sync_file->cbs[i].fence, &fence_info[i]); sync_fill_fence_info(fences[i], &fence_info[i]);
if (copy_to_user(u64_to_user_ptr(info.sync_fence_info), fence_info, if (copy_to_user(u64_to_user_ptr(info.sync_fence_info), fence_info,
size)) { size)) {
@ -352,11 +429,8 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
no_fences: no_fences:
strlcpy(info.name, sync_file->name, sizeof(info.name)); strlcpy(info.name, sync_file->name, sizeof(info.name));
info.status = atomic_read(&sync_file->status); info.status = fence_is_signaled(sync_file->fence);
if (info.status >= 0) info.num_fences = num_fences;
info.status = !info.status;
info.num_fences = sync_file->num_fences;
if (copy_to_user((void __user *)arg, &info, sizeof(info))) if (copy_to_user((void __user *)arg, &info, sizeof(info)))
ret = -EFAULT; ret = -EFAULT;

View File

@ -129,12 +129,8 @@ config DRM_R128
config DRM_RADEON config DRM_RADEON
tristate "ATI Radeon" tristate "ATI Radeon"
depends on DRM && PCI depends on DRM && PCI
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
select FW_LOADER select FW_LOADER
select DRM_KMS_HELPER select DRM_KMS_HELPER
select DRM_KMS_FB_HELPER
select DRM_TTM select DRM_TTM
select POWER_SUPPLY select POWER_SUPPLY
select HWMON select HWMON
@ -153,12 +149,8 @@ source "drivers/gpu/drm/radeon/Kconfig"
config DRM_AMDGPU config DRM_AMDGPU
tristate "AMD GPU" tristate "AMD GPU"
depends on DRM && PCI depends on DRM && PCI
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
select FW_LOADER select FW_LOADER
select DRM_KMS_HELPER select DRM_KMS_HELPER
select DRM_KMS_FB_HELPER
select DRM_TTM select DRM_TTM
select POWER_SUPPLY select POWER_SUPPLY
select HWMON select HWMON

View File

@ -341,7 +341,7 @@ static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev)
#ifdef CONFIG_X86 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
#endif #endif
remove_conflicting_framebuffers(ap, "amdgpudrmfb", primary); drm_fb_helper_remove_conflicting_framebuffers(ap, "amdgpudrmfb", primary);
kfree(ap); kfree(ap);
return 0; return 0;

View File

@ -25,7 +25,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/fb.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include <drm/drm_crtc.h> #include <drm/drm_crtc.h>

View File

@ -22,7 +22,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/fb.h>
#include "linux/delay.h" #include "linux/delay.h"
#include "hwmgr.h" #include "hwmgr.h"

View File

@ -22,7 +22,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/fb.h>
#include <asm/div64.h> #include <asm/div64.h>
#include "linux/delay.h" #include "linux/delay.h"
#include "pp_acpi.h" #include "pp_acpi.h"

View File

@ -22,7 +22,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/fb.h>
#include "ppatomctrl.h" #include "ppatomctrl.h"
#include "atombios.h" #include "atombios.h"

View File

@ -22,7 +22,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/fb.h>
#include "linux/delay.h" #include "linux/delay.h"
#include "pp_acpi.h" #include "pp_acpi.h"
#include "hwmgr.h" #include "hwmgr.h"

View File

@ -22,7 +22,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/fb.h>
#include "tonga_processpptables.h" #include "tonga_processpptables.h"
#include "ppatomctrl.h" #include "ppatomctrl.h"

View File

@ -49,6 +49,6 @@ void malidp_de_planes_destroy(struct drm_device *drm);
int malidp_crtc_init(struct drm_device *drm); int malidp_crtc_init(struct drm_device *drm);
/* often used combination of rotational bits */ /* often used combination of rotational bits */
#define MALIDP_ROTATED_MASK (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270)) #define MALIDP_ROTATED_MASK (DRM_ROTATE_90 | DRM_ROTATE_270)
#endif /* __MALIDP_DRV_H__ */ #endif /* __MALIDP_DRV_H__ */

View File

@ -108,7 +108,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
return -EINVAL; return -EINVAL;
/* packed RGB888 / BGR888 can't be rotated or flipped */ /* packed RGB888 / BGR888 can't be rotated or flipped */
if (state->rotation != BIT(DRM_ROTATE_0) && if (state->rotation != DRM_ROTATE_0 &&
(state->fb->pixel_format == DRM_FORMAT_RGB888 || (state->fb->pixel_format == DRM_FORMAT_RGB888 ||
state->fb->pixel_format == DRM_FORMAT_BGR888)) state->fb->pixel_format == DRM_FORMAT_BGR888))
return -EINVAL; return -EINVAL;
@ -188,9 +188,9 @@ static void malidp_de_plane_update(struct drm_plane *plane,
/* setup the rotation and axis flip bits */ /* setup the rotation and axis flip bits */
if (plane->state->rotation & DRM_ROTATE_MASK) if (plane->state->rotation & DRM_ROTATE_MASK)
val = ilog2(plane->state->rotation & DRM_ROTATE_MASK) << LAYER_ROT_OFFSET; val = ilog2(plane->state->rotation & DRM_ROTATE_MASK) << LAYER_ROT_OFFSET;
if (plane->state->rotation & BIT(DRM_REFLECT_X)) if (plane->state->rotation & DRM_REFLECT_X)
val |= LAYER_V_FLIP; val |= LAYER_V_FLIP;
if (plane->state->rotation & BIT(DRM_REFLECT_Y)) if (plane->state->rotation & DRM_REFLECT_Y)
val |= LAYER_H_FLIP; val |= LAYER_H_FLIP;
/* set the 'enable layer' bit */ /* set the 'enable layer' bit */
@ -255,12 +255,12 @@ int malidp_de_planes_init(struct drm_device *drm)
goto cleanup; goto cleanup;
if (!drm->mode_config.rotation_property) { if (!drm->mode_config.rotation_property) {
unsigned long flags = BIT(DRM_ROTATE_0) | unsigned long flags = DRM_ROTATE_0 |
BIT(DRM_ROTATE_90) | DRM_ROTATE_90 |
BIT(DRM_ROTATE_180) | DRM_ROTATE_180 |
BIT(DRM_ROTATE_270) | DRM_ROTATE_270 |
BIT(DRM_REFLECT_X) | DRM_REFLECT_X |
BIT(DRM_REFLECT_Y); DRM_REFLECT_Y;
drm->mode_config.rotation_property = drm->mode_config.rotation_property =
drm_mode_create_rotation_property(drm, flags); drm_mode_create_rotation_property(drm, flags);
} }
@ -268,7 +268,7 @@ int malidp_de_planes_init(struct drm_device *drm)
if (drm->mode_config.rotation_property && (id != DE_SMART)) if (drm->mode_config.rotation_property && (id != DE_SMART))
drm_object_attach_property(&plane->base.base, drm_object_attach_property(&plane->base.base,
drm->mode_config.rotation_property, drm->mode_config.rotation_property,
BIT(DRM_ROTATE_0)); DRM_ROTATE_0);
drm_plane_helper_add(&plane->base, drm_plane_helper_add(&plane->base,
&malidp_de_plane_helper_funcs); &malidp_de_plane_helper_funcs);

View File

@ -7,7 +7,6 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fb.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>

View File

@ -121,7 +121,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
int ret; int ret;
ret = drm_plane_helper_check_update(plane, crtc, fb, &src, &dest, &clip, ret = drm_plane_helper_check_update(plane, crtc, fb, &src, &dest, &clip,
BIT(DRM_ROTATE_0), DRM_ROTATE_0,
0, INT_MAX, true, false, &visible); 0, INT_MAX, true, false, &visible);
if (ret) if (ret)
return ret; return ret;

View File

@ -33,7 +33,6 @@
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/sysrq.h> #include <linux/sysrq.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/fb.h>
#include <linux/init.h> #include <linux/init.h>

View File

@ -393,7 +393,7 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane,
if ((state->base.fb->pixel_format == DRM_FORMAT_YUV422 || if ((state->base.fb->pixel_format == DRM_FORMAT_YUV422 ||
state->base.fb->pixel_format == DRM_FORMAT_NV61) && state->base.fb->pixel_format == DRM_FORMAT_NV61) &&
(state->base.rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270)))) (state->base.rotation & (DRM_ROTATE_90 | DRM_ROTATE_270)))
cfg |= ATMEL_HLCDC_YUV422ROT; cfg |= ATMEL_HLCDC_YUV422ROT;
atmel_hlcdc_layer_update_cfg(&plane->layer, atmel_hlcdc_layer_update_cfg(&plane->layer,
@ -628,7 +628,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
/* /*
* Swap width and size in case of 90 or 270 degrees rotation * Swap width and size in case of 90 or 270 degrees rotation
*/ */
if (state->base.rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270))) { if (state->base.rotation & (DRM_ROTATE_90 | DRM_ROTATE_270)) {
tmp = state->crtc_w; tmp = state->crtc_w;
state->crtc_w = state->crtc_h; state->crtc_w = state->crtc_h;
state->crtc_h = tmp; state->crtc_h = tmp;
@ -677,7 +677,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
return -EINVAL; return -EINVAL;
switch (state->base.rotation & DRM_ROTATE_MASK) { switch (state->base.rotation & DRM_ROTATE_MASK) {
case BIT(DRM_ROTATE_90): case DRM_ROTATE_90:
offset = ((y_offset + state->src_y + patched_src_w - 1) / offset = ((y_offset + state->src_y + patched_src_w - 1) /
ydiv) * fb->pitches[i]; ydiv) * fb->pitches[i];
offset += ((x_offset + state->src_x) / xdiv) * offset += ((x_offset + state->src_x) / xdiv) *
@ -686,7 +686,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
fb->pitches[i]; fb->pitches[i];
state->pstride[i] = -fb->pitches[i] - state->bpp[i]; state->pstride[i] = -fb->pitches[i] - state->bpp[i];
break; break;
case BIT(DRM_ROTATE_180): case DRM_ROTATE_180:
offset = ((y_offset + state->src_y + patched_src_h - 1) / offset = ((y_offset + state->src_y + patched_src_h - 1) /
ydiv) * fb->pitches[i]; ydiv) * fb->pitches[i];
offset += ((x_offset + state->src_x + patched_src_w - 1) / offset += ((x_offset + state->src_x + patched_src_w - 1) /
@ -695,7 +695,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
state->bpp[i]) - fb->pitches[i]; state->bpp[i]) - fb->pitches[i];
state->pstride[i] = -2 * state->bpp[i]; state->pstride[i] = -2 * state->bpp[i];
break; break;
case BIT(DRM_ROTATE_270): case DRM_ROTATE_270:
offset = ((y_offset + state->src_y) / ydiv) * offset = ((y_offset + state->src_y) / ydiv) *
fb->pitches[i]; fb->pitches[i];
offset += ((x_offset + state->src_x + patched_src_h - 1) / offset += ((x_offset + state->src_x + patched_src_h - 1) /
@ -705,7 +705,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
(2 * state->bpp[i]); (2 * state->bpp[i]);
state->pstride[i] = fb->pitches[i] - state->bpp[i]; state->pstride[i] = fb->pitches[i] - state->bpp[i];
break; break;
case BIT(DRM_ROTATE_0): case DRM_ROTATE_0:
default: default:
offset = ((y_offset + state->src_y) / ydiv) * offset = ((y_offset + state->src_y) / ydiv) *
fb->pitches[i]; fb->pitches[i];
@ -905,7 +905,7 @@ static void atmel_hlcdc_plane_init_properties(struct atmel_hlcdc_plane *plane,
if (desc->layout.xstride && desc->layout.pstride) if (desc->layout.xstride && desc->layout.pstride)
drm_object_attach_property(&plane->base.base, drm_object_attach_property(&plane->base.base,
plane->base.dev->mode_config.rotation_property, plane->base.dev->mode_config.rotation_property,
BIT(DRM_ROTATE_0)); DRM_ROTATE_0);
if (desc->layout.csc) { if (desc->layout.csc) {
/* /*
@ -1056,10 +1056,10 @@ atmel_hlcdc_plane_create_properties(struct drm_device *dev)
dev->mode_config.rotation_property = dev->mode_config.rotation_property =
drm_mode_create_rotation_property(dev, drm_mode_create_rotation_property(dev,
BIT(DRM_ROTATE_0) | DRM_ROTATE_0 |
BIT(DRM_ROTATE_90) | DRM_ROTATE_90 |
BIT(DRM_ROTATE_180) | DRM_ROTATE_180 |
BIT(DRM_ROTATE_270)); DRM_ROTATE_270);
if (!dev->mode_config.rotation_property) if (!dev->mode_config.rotation_property)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);

View File

@ -1,5 +1,4 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/fb.h>
#include <linux/console.h> #include <linux/console.h>
#include <drm/drmP.h> #include <drm/drmP.h>

View File

@ -8,6 +8,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <drm/drm_fb_helper.h>
#include "bochs.h" #include "bochs.h"
@ -153,7 +154,7 @@ static int bochs_kick_out_firmware_fb(struct pci_dev *pdev)
ap->ranges[0].base = pci_resource_start(pdev, 0); ap->ranges[0].base = pci_resource_start(pdev, 0);
ap->ranges[0].size = pci_resource_len(pdev, 0); ap->ranges[0].size = pci_resource_len(pdev, 0);
remove_conflicting_framebuffers(ap, "bochsdrmfb", false); drm_fb_helper_remove_conflicting_framebuffers(ap, "bochsdrmfb", false);
kfree(ap); kfree(ap);
return 0; return 0;

View File

@ -16,7 +16,6 @@
#include <linux/backlight.h> #include <linux/backlight.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/fb.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/i2c.h> #include <linux/i2c.h>

View File

@ -57,7 +57,7 @@ static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
#ifdef CONFIG_X86 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
#endif #endif
remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary); drm_fb_helper_remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary);
kfree(ap); kfree(ap);
return 0; return 0;

View File

@ -13,8 +13,6 @@
#include <drm/drm_fb_helper.h> #include <drm/drm_fb_helper.h>
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <linux/fb.h>
#include "cirrus_drv.h" #include "cirrus_drv.h"
static void cirrus_dirty_update(struct cirrus_fbdev *afbdev, static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,

View File

@ -430,9 +430,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
* intact so it can still be used. It is safe to call this if AGP is disabled or * intact so it can still be used. It is safe to call this if AGP is disabled or
* was already removed. * was already removed.
* *
* If DRIVER_MODESET is active, nothing is done to protect the modesetting * Cleanup is only done for drivers who have DRIVER_LEGACY set.
* resources from getting destroyed. Drivers are responsible of cleaning them up
* during device shutdown.
*/ */
void drm_legacy_agp_clear(struct drm_device *dev) void drm_legacy_agp_clear(struct drm_device *dev)
{ {
@ -440,7 +438,7 @@ void drm_legacy_agp_clear(struct drm_device *dev)
if (!dev->agp) if (!dev->agp)
return; return;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return; return;
list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) { list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {

View File

@ -1635,6 +1635,9 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,
funcs = plane->helper_private; funcs = plane->helper_private;
if (!drm_atomic_helper_framebuffer_changed(dev, state, plane_state->crtc))
continue;
if (funcs->prepare_fb) { if (funcs->prepare_fb) {
ret = funcs->prepare_fb(plane, plane_state); ret = funcs->prepare_fb(plane, plane_state);
if (ret) if (ret)
@ -1651,11 +1654,13 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,
if (j >= i) if (j >= i)
continue; continue;
if (!drm_atomic_helper_framebuffer_changed(dev, state, plane_state->crtc))
continue;
funcs = plane->helper_private; funcs = plane->helper_private;
if (funcs->cleanup_fb) if (funcs->cleanup_fb)
funcs->cleanup_fb(plane, plane_state); funcs->cleanup_fb(plane, plane_state);
} }
return ret; return ret;
@ -1898,6 +1903,9 @@ void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
for_each_plane_in_state(old_state, plane, plane_state, i) { for_each_plane_in_state(old_state, plane, plane_state, i) {
const struct drm_plane_helper_funcs *funcs; const struct drm_plane_helper_funcs *funcs;
if (!drm_atomic_helper_framebuffer_changed(dev, old_state, plane_state->crtc))
continue;
funcs = plane->helper_private; funcs = plane->helper_private;
if (funcs->cleanup_fb) if (funcs->cleanup_fb)
@ -2358,7 +2366,7 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,
primary_state->crtc_h = vdisplay; primary_state->crtc_h = vdisplay;
primary_state->src_x = set->x << 16; primary_state->src_x = set->x << 16;
primary_state->src_y = set->y << 16; primary_state->src_y = set->y << 16;
if (primary_state->rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270))) { if (primary_state->rotation & (DRM_ROTATE_90 | DRM_ROTATE_270)) {
primary_state->src_w = vdisplay << 16; primary_state->src_w = vdisplay << 16;
primary_state->src_h = hdisplay << 16; primary_state->src_h = hdisplay << 16;
} else { } else {
@ -3043,7 +3051,7 @@ void drm_atomic_helper_plane_reset(struct drm_plane *plane)
if (plane->state) { if (plane->state) {
plane->state->plane = plane; plane->state->plane = plane;
plane->state->rotation = BIT(DRM_ROTATE_0); plane->state->rotation = DRM_ROTATE_0;
} }
} }
EXPORT_SYMBOL(drm_atomic_helper_plane_reset); EXPORT_SYMBOL(drm_atomic_helper_plane_reset);

View File

@ -251,7 +251,7 @@ void drm_master_release(struct drm_file *file_priv)
if (!drm_is_current_master(file_priv)) if (!drm_is_current_master(file_priv))
goto out; goto out;
if (!drm_core_check_feature(dev, DRIVER_MODESET)) { if (drm_core_check_feature(dev, DRIVER_LEGACY)) {
/* /*
* Since the master is disappearing, so is the * Since the master is disappearing, so is the
* possibility to lock. * possibility to lock.

View File

@ -397,7 +397,7 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
return -EPERM; return -EPERM;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
err = drm_addmap_core(dev, map->offset, map->size, map->type, err = drm_addmap_core(dev, map->offset, map->size, map->type,
@ -443,7 +443,7 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
int i; int i;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
idx = map->offset; idx = map->offset;
@ -545,7 +545,7 @@ EXPORT_SYMBOL(drm_legacy_rmmap_locked);
void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map) void drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
{ {
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return; return;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
@ -558,7 +558,7 @@ void drm_legacy_master_rmmaps(struct drm_device *dev, struct drm_master *master)
{ {
struct drm_map_list *r_list, *list_temp; struct drm_map_list *r_list, *list_temp;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return; return;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
@ -595,7 +595,7 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
int ret; int ret;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
@ -1220,7 +1220,7 @@ int drm_legacy_addbufs(struct drm_device *dev, void *data,
struct drm_buf_desc *request = data; struct drm_buf_desc *request = data;
int ret; int ret;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@ -1266,7 +1266,7 @@ int drm_legacy_infobufs(struct drm_device *dev, void *data,
int i; int i;
int count; int count;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@ -1347,7 +1347,7 @@ int drm_legacy_markbufs(struct drm_device *dev, void *data,
int order; int order;
struct drm_buf_entry *entry; struct drm_buf_entry *entry;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@ -1395,7 +1395,7 @@ int drm_legacy_freebufs(struct drm_device *dev, void *data,
int idx; int idx;
struct drm_buf *buf; struct drm_buf *buf;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@ -1450,7 +1450,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
struct drm_buf_map *request = data; struct drm_buf_map *request = data;
int i; int i;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
@ -1530,7 +1530,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
int drm_legacy_dma_ioctl(struct drm_device *dev, void *data, int drm_legacy_dma_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv) struct drm_file *file_priv)
{ {
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
if (dev->driver->dma_ioctl) if (dev->driver->dma_ioctl)

View File

@ -54,7 +54,7 @@ struct drm_ctx_list {
void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle) void drm_legacy_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
{ {
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return; return;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
@ -92,7 +92,7 @@ static int drm_legacy_ctxbitmap_next(struct drm_device * dev)
void drm_legacy_ctxbitmap_init(struct drm_device * dev) void drm_legacy_ctxbitmap_init(struct drm_device * dev)
{ {
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return; return;
idr_init(&dev->ctx_idr); idr_init(&dev->ctx_idr);
@ -109,7 +109,7 @@ void drm_legacy_ctxbitmap_init(struct drm_device * dev)
void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev) void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
{ {
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return; return;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
@ -131,7 +131,7 @@ void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file)
struct drm_ctx_list *pos, *tmp; struct drm_ctx_list *pos, *tmp;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return; return;
mutex_lock(&dev->ctxlist_mutex); mutex_lock(&dev->ctxlist_mutex);
@ -177,7 +177,7 @@ int drm_legacy_getsareactx(struct drm_device *dev, void *data,
struct drm_map_list *_entry; struct drm_map_list *_entry;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
@ -225,7 +225,7 @@ int drm_legacy_setsareactx(struct drm_device *dev, void *data,
struct drm_map_list *r_list = NULL; struct drm_map_list *r_list = NULL;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
@ -329,7 +329,7 @@ int drm_legacy_resctx(struct drm_device *dev, void *data,
int i; int i;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
if (res->count >= DRM_RESERVED_CONTEXTS) { if (res->count >= DRM_RESERVED_CONTEXTS) {
@ -363,7 +363,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
struct drm_ctx *ctx = data; struct drm_ctx *ctx = data;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
ctx->handle = drm_legacy_ctxbitmap_next(dev); ctx->handle = drm_legacy_ctxbitmap_next(dev);
@ -410,7 +410,7 @@ int drm_legacy_getctx(struct drm_device *dev, void *data,
struct drm_ctx *ctx = data; struct drm_ctx *ctx = data;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
/* This is 0, because we don't handle any context flags */ /* This is 0, because we don't handle any context flags */
@ -436,7 +436,7 @@ int drm_legacy_switchctx(struct drm_device *dev, void *data,
struct drm_ctx *ctx = data; struct drm_ctx *ctx = data;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
DRM_DEBUG("%d\n", ctx->handle); DRM_DEBUG("%d\n", ctx->handle);
@ -460,7 +460,7 @@ int drm_legacy_newctx(struct drm_device *dev, void *data,
struct drm_ctx *ctx = data; struct drm_ctx *ctx = data;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
DRM_DEBUG("%d\n", ctx->handle); DRM_DEBUG("%d\n", ctx->handle);
@ -486,7 +486,7 @@ int drm_legacy_rmctx(struct drm_device *dev, void *data,
struct drm_ctx *ctx = data; struct drm_ctx *ctx = data;
if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) && if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
drm_core_check_feature(dev, DRIVER_MODESET)) !drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
DRM_DEBUG("%d\n", ctx->handle); DRM_DEBUG("%d\n", ctx->handle);

View File

@ -2802,8 +2802,8 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
drm_crtc_get_hv_timing(mode, &hdisplay, &vdisplay); drm_crtc_get_hv_timing(mode, &hdisplay, &vdisplay);
if (crtc->state && if (crtc->state &&
crtc->primary->state->rotation & (BIT(DRM_ROTATE_90) | crtc->primary->state->rotation & (DRM_ROTATE_90 |
BIT(DRM_ROTATE_270))) DRM_ROTATE_270))
swap(hdisplay, vdisplay); swap(hdisplay, vdisplay);
return check_src_coords(x << 16, y << 16, return check_src_coords(x << 16, y << 16,
@ -5644,9 +5644,9 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
* Eg. if the hardware supports everything except DRM_REFLECT_X * Eg. if the hardware supports everything except DRM_REFLECT_X
* one could call this function like this: * one could call this function like this:
* *
* drm_rotation_simplify(rotation, BIT(DRM_ROTATE_0) | * drm_rotation_simplify(rotation, DRM_ROTATE_0 |
* BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_180) | * DRM_ROTATE_90 | DRM_ROTATE_180 |
* BIT(DRM_ROTATE_270) | BIT(DRM_REFLECT_Y)); * DRM_ROTATE_270 | DRM_REFLECT_Y);
* *
* to eliminate the DRM_ROTATE_X flag. Depending on what kind of * to eliminate the DRM_ROTATE_X flag. Depending on what kind of
* transforms the hardware supports, this function may not * transforms the hardware supports, this function may not
@ -5657,7 +5657,7 @@ unsigned int drm_rotation_simplify(unsigned int rotation,
unsigned int supported_rotations) unsigned int supported_rotations)
{ {
if (rotation & ~supported_rotations) { if (rotation & ~supported_rotations) {
rotation ^= BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y); rotation ^= DRM_REFLECT_X | DRM_REFLECT_Y;
rotation = (rotation & DRM_REFLECT_MASK) | rotation = (rotation & DRM_REFLECT_MASK) |
BIT((ffs(rotation & DRM_ROTATE_MASK) + 1) % 4); BIT((ffs(rotation & DRM_ROTATE_MASK) + 1) % 4);
} }
@ -5786,12 +5786,12 @@ struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
unsigned int supported_rotations) unsigned int supported_rotations)
{ {
static const struct drm_prop_enum_list props[] = { static const struct drm_prop_enum_list props[] = {
{ DRM_ROTATE_0, "rotate-0" }, { __builtin_ffs(DRM_ROTATE_0) - 1, "rotate-0" },
{ DRM_ROTATE_90, "rotate-90" }, { __builtin_ffs(DRM_ROTATE_90) - 1, "rotate-90" },
{ DRM_ROTATE_180, "rotate-180" }, { __builtin_ffs(DRM_ROTATE_180) - 1, "rotate-180" },
{ DRM_ROTATE_270, "rotate-270" }, { __builtin_ffs(DRM_ROTATE_270) - 1, "rotate-270" },
{ DRM_REFLECT_X, "reflect-x" }, { __builtin_ffs(DRM_REFLECT_X) - 1, "reflect-x" },
{ DRM_REFLECT_Y, "reflect-y" }, { __builtin_ffs(DRM_REFLECT_Y) - 1, "reflect-y" },
}; };
return drm_property_create_bitmask(dev, 0, "rotation", return drm_property_create_bitmask(dev, 0, "rotation",

View File

@ -50,9 +50,8 @@ int drm_legacy_dma_setup(struct drm_device *dev)
int i; int i;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) || if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
drm_core_check_feature(dev, DRIVER_MODESET)) { !drm_core_check_feature(dev, DRIVER_LEGACY))
return 0; return 0;
}
dev->buf_use = 0; dev->buf_use = 0;
atomic_set(&dev->buf_alloc, 0); atomic_set(&dev->buf_alloc, 0);
@ -81,9 +80,8 @@ void drm_legacy_dma_takedown(struct drm_device *dev)
int i, j; int i, j;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) || if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
drm_core_check_feature(dev, DRIVER_MODESET)) { !drm_core_check_feature(dev, DRIVER_LEGACY))
return; return;
}
if (!dma) if (!dma)
return; return;

View File

@ -223,7 +223,7 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
err = ret; err = ret;
} }
DRM_DEBUG_KMS("too many retries, giving up\n"); DRM_DEBUG_KMS("Too many retries, giving up. First error: %d\n", err);
ret = err; ret = err;
unlock: unlock:
@ -574,7 +574,17 @@ static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
if (ret == -EBUSY) if (ret == -EBUSY)
continue; continue;
DRM_DEBUG_KMS("transaction failed: %d\n", ret); /*
* While timeouts can be errors, they're usually normal
* behavior (for instance, when a driver tries to
* communicate with a non-existant DisplayPort device).
* Avoid spamming the kernel log with timeout errors.
*/
if (ret == -ETIMEDOUT)
DRM_DEBUG_KMS_RATELIMITED("transaction timed out\n");
else
DRM_DEBUG_KMS("transaction failed: %d\n", ret);
return ret; return ret;
} }

View File

@ -112,7 +112,7 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
unsigned int type) unsigned int type)
{ {
switch (type) { switch (type) {
case DRM_MINOR_LEGACY: case DRM_MINOR_PRIMARY:
return &dev->primary; return &dev->primary;
case DRM_MINOR_RENDER: case DRM_MINOR_RENDER:
return &dev->render; return &dev->render;
@ -512,7 +512,7 @@ int drm_dev_init(struct drm_device *dev,
goto err_minors; goto err_minors;
} }
ret = drm_minor_alloc(dev, DRM_MINOR_LEGACY); ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
if (ret) if (ret)
goto err_minors; goto err_minors;
@ -545,7 +545,7 @@ int drm_dev_init(struct drm_device *dev,
drm_legacy_ctxbitmap_cleanup(dev); drm_legacy_ctxbitmap_cleanup(dev);
drm_ht_remove(&dev->map_hash); drm_ht_remove(&dev->map_hash);
err_minors: err_minors:
drm_minor_free(dev, DRM_MINOR_LEGACY); drm_minor_free(dev, DRM_MINOR_PRIMARY);
drm_minor_free(dev, DRM_MINOR_RENDER); drm_minor_free(dev, DRM_MINOR_RENDER);
drm_minor_free(dev, DRM_MINOR_CONTROL); drm_minor_free(dev, DRM_MINOR_CONTROL);
drm_fs_inode_free(dev->anon_inode); drm_fs_inode_free(dev->anon_inode);
@ -608,7 +608,7 @@ static void drm_dev_release(struct kref *ref)
drm_ht_remove(&dev->map_hash); drm_ht_remove(&dev->map_hash);
drm_fs_inode_free(dev->anon_inode); drm_fs_inode_free(dev->anon_inode);
drm_minor_free(dev, DRM_MINOR_LEGACY); drm_minor_free(dev, DRM_MINOR_PRIMARY);
drm_minor_free(dev, DRM_MINOR_RENDER); drm_minor_free(dev, DRM_MINOR_RENDER);
drm_minor_free(dev, DRM_MINOR_CONTROL); drm_minor_free(dev, DRM_MINOR_CONTROL);
@ -684,7 +684,7 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
if (ret) if (ret)
goto err_minors; goto err_minors;
ret = drm_minor_register(dev, DRM_MINOR_LEGACY); ret = drm_minor_register(dev, DRM_MINOR_PRIMARY);
if (ret) if (ret)
goto err_minors; goto err_minors;
@ -701,7 +701,7 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
goto out_unlock; goto out_unlock;
err_minors: err_minors:
drm_minor_unregister(dev, DRM_MINOR_LEGACY); drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
drm_minor_unregister(dev, DRM_MINOR_RENDER); drm_minor_unregister(dev, DRM_MINOR_RENDER);
drm_minor_unregister(dev, DRM_MINOR_CONTROL); drm_minor_unregister(dev, DRM_MINOR_CONTROL);
out_unlock: out_unlock:
@ -741,7 +741,7 @@ void drm_dev_unregister(struct drm_device *dev)
list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
drm_legacy_rmmap(dev, r_list->map); drm_legacy_rmmap(dev, r_list->map);
drm_minor_unregister(dev, DRM_MINOR_LEGACY); drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
drm_minor_unregister(dev, DRM_MINOR_RENDER); drm_minor_unregister(dev, DRM_MINOR_RENDER);
drm_minor_unregister(dev, DRM_MINOR_CONTROL); drm_minor_unregister(dev, DRM_MINOR_CONTROL);
} }

View File

@ -32,7 +32,6 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sysrq.h> #include <linux/sysrq.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/fb.h>
#include <linux/module.h> #include <linux/module.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include <drm/drm_crtc.h> #include <drm/drm_crtc.h>
@ -335,7 +334,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper)
goto fail; goto fail;
} }
plane_state->rotation = BIT(DRM_ROTATE_0); plane_state->rotation = DRM_ROTATE_0;
plane->old_fb = plane->fb; plane->old_fb = plane->fb;
plane_mask |= 1 << drm_plane_index(plane); plane_mask |= 1 << drm_plane_index(plane);
@ -395,7 +394,7 @@ static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
if (dev->mode_config.rotation_property) { if (dev->mode_config.rotation_property) {
drm_mode_plane_set_obj_prop(plane, drm_mode_plane_set_obj_prop(plane,
dev->mode_config.rotation_property, dev->mode_config.rotation_property,
BIT(DRM_ROTATE_0)); DRM_ROTATE_0);
} }
} }

View File

@ -92,7 +92,7 @@ static int drm_setup(struct drm_device * dev)
int ret; int ret;
if (dev->driver->firstopen && if (dev->driver->firstopen &&
!drm_core_check_feature(dev, DRIVER_MODESET)) { drm_core_check_feature(dev, DRIVER_LEGACY)) {
ret = dev->driver->firstopen(dev); ret = dev->driver->firstopen(dev);
if (ret != 0) if (ret != 0)
return ret; return ret;
@ -346,7 +346,7 @@ void drm_lastclose(struct drm_device * dev)
dev->driver->lastclose(dev); dev->driver->lastclose(dev);
DRM_DEBUG("driver lastclose completed\n"); DRM_DEBUG("driver lastclose completed\n");
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (drm_core_check_feature(dev, DRIVER_LEGACY))
drm_legacy_dev_reinit(dev); drm_legacy_dev_reinit(dev);
} }
@ -389,7 +389,7 @@ int drm_release(struct inode *inode, struct file *filp)
(long)old_encode_dev(file_priv->minor->kdev->devt), (long)old_encode_dev(file_priv->minor->kdev->devt),
dev->open_count); dev->open_count);
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (drm_core_check_feature(dev, DRIVER_LEGACY))
drm_legacy_lock_release(dev, filp); drm_legacy_lock_release(dev, filp);
if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))

View File

@ -714,9 +714,9 @@ long drm_ioctl(struct file *filp,
if (ksize > in_size) if (ksize > in_size)
memset(kdata + in_size, 0, ksize - in_size); memset(kdata + in_size, 0, ksize - in_size);
/* Enforce sane locking for kms driver ioctls. Core ioctls are /* Enforce sane locking for modern driver ioctls. Core ioctls are
* too messy still. */ * too messy still. */
if ((drm_core_check_feature(dev, DRIVER_MODESET) && is_driver_ioctl) || if ((!drm_core_check_feature(dev, DRIVER_LEGACY) && is_driver_ioctl) ||
(ioctl->flags & DRM_UNLOCKED)) (ioctl->flags & DRM_UNLOCKED))
retcode = func(dev, kdata, file_priv); retcode = func(dev, kdata, file_priv);
else { else {

View File

@ -482,7 +482,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
return ret; return ret;
} }
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (drm_core_check_feature(dev, DRIVER_LEGACY))
vga_client_register(dev->pdev, (void *)dev, drm_irq_vgaarb_nokms, NULL); vga_client_register(dev->pdev, (void *)dev, drm_irq_vgaarb_nokms, NULL);
/* After installing handler */ /* After installing handler */
@ -491,7 +491,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
if (ret < 0) { if (ret < 0) {
dev->irq_enabled = false; dev->irq_enabled = false;
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (drm_core_check_feature(dev, DRIVER_LEGACY))
vga_client_register(dev->pdev, NULL, NULL, NULL); vga_client_register(dev->pdev, NULL, NULL, NULL);
free_irq(irq, dev); free_irq(irq, dev);
} else { } else {
@ -557,7 +557,7 @@ int drm_irq_uninstall(struct drm_device *dev)
DRM_DEBUG("irq=%d\n", dev->irq); DRM_DEBUG("irq=%d\n", dev->irq);
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (drm_core_check_feature(dev, DRIVER_LEGACY))
vga_client_register(dev->pdev, NULL, NULL, NULL); vga_client_register(dev->pdev, NULL, NULL, NULL);
if (dev->driver->irq_uninstall) if (dev->driver->irq_uninstall)
@ -592,7 +592,7 @@ int drm_control(struct drm_device *dev, void *data,
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return 0; return 0;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return 0; return 0;
/* UMS was only ever supported on pci devices. */ /* UMS was only ever supported on pci devices. */
if (WARN_ON(!dev->pdev)) if (WARN_ON(!dev->pdev))
@ -1295,7 +1295,7 @@ void drm_vblank_off(struct drm_device *dev, unsigned int pipe)
if (e->pipe != pipe) if (e->pipe != pipe)
continue; continue;
DRM_DEBUG("Sending premature vblank event on disable: " DRM_DEBUG("Sending premature vblank event on disable: "
"wanted %d, current %d\n", "wanted %u, current %u\n",
e->event.sequence, seq); e->event.sequence, seq);
list_del(&e->base.link); list_del(&e->base.link);
drm_vblank_put(dev, pipe); drm_vblank_put(dev, pipe);
@ -1519,7 +1519,7 @@ int drm_modeset_ctl(struct drm_device *dev, void *data,
return 0; return 0;
/* KMS drivers handle this internally */ /* KMS drivers handle this internally */
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return 0; return 0;
pipe = modeset->crtc; pipe = modeset->crtc;
@ -1585,7 +1585,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
seq = drm_vblank_count_and_time(dev, pipe, &now); seq = drm_vblank_count_and_time(dev, pipe, &now);
DRM_DEBUG("event on vblank count %d, current %d, crtc %u\n", DRM_DEBUG("event on vblank count %u, current %u, crtc %u\n",
vblwait->request.sequence, seq, pipe); vblwait->request.sequence, seq, pipe);
trace_drm_vblank_event_queued(current->pid, pipe, trace_drm_vblank_event_queued(current->pid, pipe,
@ -1693,7 +1693,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
return drm_queue_vblank_event(dev, pipe, vblwait, file_priv); return drm_queue_vblank_event(dev, pipe, vblwait, file_priv);
} }
DRM_DEBUG("waiting on vblank count %d, crtc %u\n", DRM_DEBUG("waiting on vblank count %u, crtc %u\n",
vblwait->request.sequence, pipe); vblwait->request.sequence, pipe);
DRM_WAIT_ON(ret, vblank->queue, 3 * HZ, DRM_WAIT_ON(ret, vblank->queue, 3 * HZ,
(((drm_vblank_count(dev, pipe) - (((drm_vblank_count(dev, pipe) -
@ -1708,7 +1708,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
vblwait->reply.tval_sec = now.tv_sec; vblwait->reply.tval_sec = now.tv_sec;
vblwait->reply.tval_usec = now.tv_usec; vblwait->reply.tval_usec = now.tv_usec;
DRM_DEBUG("returning %d to client\n", DRM_DEBUG("returning %u to client\n",
vblwait->reply.sequence); vblwait->reply.sequence);
} else { } else {
DRM_DEBUG("vblank wait interrupted by signal\n"); DRM_DEBUG("vblank wait interrupted by signal\n");
@ -1735,7 +1735,7 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
if ((seq - e->event.sequence) > (1<<23)) if ((seq - e->event.sequence) > (1<<23))
continue; continue;
DRM_DEBUG("vblank event on %d, current %d\n", DRM_DEBUG("vblank event on %u, current %u\n",
e->event.sequence, seq); e->event.sequence, seq);
list_del(&e->base.link); list_del(&e->base.link);
@ -1826,6 +1826,7 @@ EXPORT_SYMBOL(drm_crtc_handle_vblank);
*/ */
u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe) u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe)
{ {
WARN_ON_ONCE(dev->max_vblank_count != 0);
return 0; return 0;
} }
EXPORT_SYMBOL(drm_vblank_no_hw_counter); EXPORT_SYMBOL(drm_vblank_no_hw_counter);

View File

@ -163,7 +163,7 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
struct drm_master *master = file_priv->master; struct drm_master *master = file_priv->master;
int ret = 0; int ret = 0;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
++file_priv->lock_count; ++file_priv->lock_count;
@ -252,7 +252,7 @@ int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_
struct drm_lock *lock = data; struct drm_lock *lock = data;
struct drm_master *master = file_priv->master; struct drm_master *master = file_priv->master;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
if (lock->context == DRM_KERNEL_CONTEXT) { if (lock->context == DRM_KERNEL_CONTEXT) {

View File

@ -46,6 +46,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/interval_tree_generic.h>
/** /**
* DOC: Overview * DOC: Overview
@ -103,6 +104,72 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
u64 end, u64 end,
enum drm_mm_search_flags flags); enum drm_mm_search_flags flags);
#define START(node) ((node)->start)
#define LAST(node) ((node)->start + (node)->size - 1)
INTERVAL_TREE_DEFINE(struct drm_mm_node, rb,
u64, __subtree_last,
START, LAST, static inline, drm_mm_interval_tree)
struct drm_mm_node *
drm_mm_interval_first(struct drm_mm *mm, u64 start, u64 last)
{
return drm_mm_interval_tree_iter_first(&mm->interval_tree,
start, last);
}
EXPORT_SYMBOL(drm_mm_interval_first);
struct drm_mm_node *
drm_mm_interval_next(struct drm_mm_node *node, u64 start, u64 last)
{
return drm_mm_interval_tree_iter_next(node, start, last);
}
EXPORT_SYMBOL(drm_mm_interval_next);
static void drm_mm_interval_tree_add_node(struct drm_mm_node *hole_node,
struct drm_mm_node *node)
{
struct drm_mm *mm = hole_node->mm;
struct rb_node **link, *rb;
struct drm_mm_node *parent;
node->__subtree_last = LAST(node);
if (hole_node->allocated) {
rb = &hole_node->rb;
while (rb) {
parent = rb_entry(rb, struct drm_mm_node, rb);
if (parent->__subtree_last >= node->__subtree_last)
break;
parent->__subtree_last = node->__subtree_last;
rb = rb_parent(rb);
}
rb = &hole_node->rb;
link = &hole_node->rb.rb_right;
} else {
rb = NULL;
link = &mm->interval_tree.rb_node;
}
while (*link) {
rb = *link;
parent = rb_entry(rb, struct drm_mm_node, rb);
if (parent->__subtree_last < node->__subtree_last)
parent->__subtree_last = node->__subtree_last;
if (node->start < parent->start)
link = &parent->rb.rb_left;
else
link = &parent->rb.rb_right;
}
rb_link_node(&node->rb, rb, link);
rb_insert_augmented(&node->rb,
&mm->interval_tree,
&drm_mm_interval_tree_augment);
}
static void drm_mm_insert_helper(struct drm_mm_node *hole_node, static void drm_mm_insert_helper(struct drm_mm_node *hole_node,
struct drm_mm_node *node, struct drm_mm_node *node,
u64 size, unsigned alignment, u64 size, unsigned alignment,
@ -150,9 +217,10 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,
node->color = color; node->color = color;
node->allocated = 1; node->allocated = 1;
INIT_LIST_HEAD(&node->hole_stack);
list_add(&node->node_list, &hole_node->node_list); list_add(&node->node_list, &hole_node->node_list);
drm_mm_interval_tree_add_node(hole_node, node);
BUG_ON(node->start + node->size > adj_end); BUG_ON(node->start + node->size > adj_end);
node->hole_follows = 0; node->hole_follows = 0;
@ -178,41 +246,54 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node,
*/ */
int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node) int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node)
{ {
u64 end = node->start + node->size;
struct drm_mm_node *hole; struct drm_mm_node *hole;
u64 end; u64 hole_start, hole_end;
u64 hole_start;
u64 hole_end;
BUG_ON(node == NULL); if (WARN_ON(node->size == 0))
return -EINVAL;
end = node->start + node->size; end = node->start + node->size;
/* Find the relevant hole to add our node to */ /* Find the relevant hole to add our node to */
drm_mm_for_each_hole(hole, mm, hole_start, hole_end) { hole = drm_mm_interval_tree_iter_first(&mm->interval_tree,
if (hole_start > node->start || hole_end < end) node->start, ~(u64)0);
continue; if (hole) {
if (hole->start < end)
node->mm = mm; return -ENOSPC;
node->allocated = 1; } else {
hole = list_entry(&mm->head_node.node_list,
INIT_LIST_HEAD(&node->hole_stack); typeof(*hole), node_list);
list_add(&node->node_list, &hole->node_list);
if (node->start == hole_start) {
hole->hole_follows = 0;
list_del_init(&hole->hole_stack);
}
node->hole_follows = 0;
if (end != hole_end) {
list_add(&node->hole_stack, &mm->hole_stack);
node->hole_follows = 1;
}
return 0;
} }
return -ENOSPC; hole = list_last_entry(&hole->node_list, typeof(*hole), node_list);
if (!hole->hole_follows)
return -ENOSPC;
hole_start = __drm_mm_hole_node_start(hole);
hole_end = __drm_mm_hole_node_end(hole);
if (hole_start > node->start || hole_end < end)
return -ENOSPC;
node->mm = mm;
node->allocated = 1;
list_add(&node->node_list, &hole->node_list);
drm_mm_interval_tree_add_node(hole, node);
if (node->start == hole_start) {
hole->hole_follows = 0;
list_del(&hole->hole_stack);
}
node->hole_follows = 0;
if (end != hole_end) {
list_add(&node->hole_stack, &mm->hole_stack);
node->hole_follows = 1;
}
return 0;
} }
EXPORT_SYMBOL(drm_mm_reserve_node); EXPORT_SYMBOL(drm_mm_reserve_node);
@ -239,6 +320,9 @@ int drm_mm_insert_node_generic(struct drm_mm *mm, struct drm_mm_node *node,
{ {
struct drm_mm_node *hole_node; struct drm_mm_node *hole_node;
if (WARN_ON(size == 0))
return -EINVAL;
hole_node = drm_mm_search_free_generic(mm, size, alignment, hole_node = drm_mm_search_free_generic(mm, size, alignment,
color, sflags); color, sflags);
if (!hole_node) if (!hole_node)
@ -299,9 +383,10 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,
node->color = color; node->color = color;
node->allocated = 1; node->allocated = 1;
INIT_LIST_HEAD(&node->hole_stack);
list_add(&node->node_list, &hole_node->node_list); list_add(&node->node_list, &hole_node->node_list);
drm_mm_interval_tree_add_node(hole_node, node);
BUG_ON(node->start < start); BUG_ON(node->start < start);
BUG_ON(node->start < adj_start); BUG_ON(node->start < adj_start);
BUG_ON(node->start + node->size > adj_end); BUG_ON(node->start + node->size > adj_end);
@ -340,6 +425,9 @@ int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, struct drm_mm_node *n
{ {
struct drm_mm_node *hole_node; struct drm_mm_node *hole_node;
if (WARN_ON(size == 0))
return -EINVAL;
hole_node = drm_mm_search_free_in_range_generic(mm, hole_node = drm_mm_search_free_in_range_generic(mm,
size, alignment, color, size, alignment, color,
start, end, sflags); start, end, sflags);
@ -390,6 +478,7 @@ void drm_mm_remove_node(struct drm_mm_node *node)
} else } else
list_move(&prev_node->hole_stack, &mm->hole_stack); list_move(&prev_node->hole_stack, &mm->hole_stack);
drm_mm_interval_tree_remove(node, &mm->interval_tree);
list_del(&node->node_list); list_del(&node->node_list);
node->allocated = 0; node->allocated = 0;
} }
@ -516,11 +605,13 @@ void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new)
{ {
list_replace(&old->node_list, &new->node_list); list_replace(&old->node_list, &new->node_list);
list_replace(&old->hole_stack, &new->hole_stack); list_replace(&old->hole_stack, &new->hole_stack);
rb_replace_node(&old->rb, &new->rb, &old->mm->interval_tree);
new->hole_follows = old->hole_follows; new->hole_follows = old->hole_follows;
new->mm = old->mm; new->mm = old->mm;
new->start = old->start; new->start = old->start;
new->size = old->size; new->size = old->size;
new->color = old->color; new->color = old->color;
new->__subtree_last = old->__subtree_last;
old->allocated = 0; old->allocated = 0;
new->allocated = 1; new->allocated = 1;
@ -748,7 +839,6 @@ void drm_mm_init(struct drm_mm * mm, u64 start, u64 size)
/* Clever trick to avoid a special case in the free hole tracking. */ /* Clever trick to avoid a special case in the free hole tracking. */
INIT_LIST_HEAD(&mm->head_node.node_list); INIT_LIST_HEAD(&mm->head_node.node_list);
INIT_LIST_HEAD(&mm->head_node.hole_stack);
mm->head_node.hole_follows = 1; mm->head_node.hole_follows = 1;
mm->head_node.scanned_block = 0; mm->head_node.scanned_block = 0;
mm->head_node.scanned_prev_free = 0; mm->head_node.scanned_prev_free = 0;
@ -758,6 +848,8 @@ void drm_mm_init(struct drm_mm * mm, u64 start, u64 size)
mm->head_node.size = start - mm->head_node.start; mm->head_node.size = start - mm->head_node.start;
list_add_tail(&mm->head_node.hole_stack, &mm->hole_stack); list_add_tail(&mm->head_node.hole_stack, &mm->hole_stack);
mm->interval_tree = RB_ROOT;
mm->color_adjust = NULL; mm->color_adjust = NULL;
} }
EXPORT_SYMBOL(drm_mm_init); EXPORT_SYMBOL(drm_mm_init);

View File

@ -175,7 +175,7 @@ int drm_irq_by_busid(struct drm_device *dev, void *data,
{ {
struct drm_irq_busid *p = data; struct drm_irq_busid *p = data;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
/* UMS was only ever support on PCI devices. */ /* UMS was only ever support on PCI devices. */
@ -263,7 +263,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
/* No locking needed since shadow-attach is single-threaded since it may /* No locking needed since shadow-attach is single-threaded since it may
* only be called from the per-driver module init hook. */ * only be called from the per-driver module init hook. */
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (drm_core_check_feature(dev, DRIVER_LEGACY))
list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list); list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
return 0; return 0;
@ -299,7 +299,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
DRM_DEBUG("\n"); DRM_DEBUG("\n");
if (driver->driver_features & DRIVER_MODESET) if (!(driver->driver_features & DRIVER_LEGACY))
return pci_register_driver(pdriver); return pci_register_driver(pdriver);
/* If not using KMS, fall back to stealth mode manual scanning. */ /* If not using KMS, fall back to stealth mode manual scanning. */
@ -421,7 +421,7 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
struct drm_device *dev, *tmp; struct drm_device *dev, *tmp;
DRM_DEBUG("\n"); DRM_DEBUG("\n");
if (driver->driver_features & DRIVER_MODESET) { if (!(driver->driver_features & DRIVER_LEGACY)) {
pci_unregister_driver(pdriver); pci_unregister_driver(pdriver);
} else { } else {
list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list, list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,

View File

@ -107,6 +107,104 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,
return count; return count;
} }
/**
* drm_plane_helper_check_state() - Check plane state for validity
* @state: plane state to check
* @clip: integer clipping coordinates
* @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point
* @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point
* @can_position: is it legal to position the plane such that it
* doesn't cover the entire crtc? This will generally
* only be false for primary planes.
* @can_update_disabled: can the plane be updated while the crtc
* is disabled?
*
* Checks that a desired plane update is valid, and updates various
* bits of derived state (clipped coordinates etc.). Drivers that provide
* their own plane handling rather than helper-provided implementations may
* still wish to call this function to avoid duplication of error checking
* code.
*
* RETURNS:
* Zero if update appears valid, error code on failure
*/
int drm_plane_helper_check_state(struct drm_plane_state *state,
const struct drm_rect *clip,
int min_scale,
int max_scale,
bool can_position,
bool can_update_disabled)
{
struct drm_crtc *crtc = state->crtc;
struct drm_framebuffer *fb = state->fb;
struct drm_rect *src = &state->src;
struct drm_rect *dst = &state->dst;
unsigned int rotation = state->rotation;
int hscale, vscale;
src->x1 = state->src_x;
src->y1 = state->src_y;
src->x2 = state->src_x + state->src_w;
src->y2 = state->src_y + state->src_h;
dst->x1 = state->crtc_x;
dst->y1 = state->crtc_y;
dst->x2 = state->crtc_x + state->crtc_w;
dst->y2 = state->crtc_y + state->crtc_h;
if (!fb) {
state->visible = false;
return 0;
}
/* crtc should only be NULL when disabling (i.e., !fb) */
if (WARN_ON(!crtc)) {
state->visible = false;
return 0;
}
if (!crtc->enabled && !can_update_disabled) {
DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n");
return -EINVAL;
}
drm_rect_rotate(src, fb->width << 16, fb->height << 16, rotation);
/* Check scaling */
hscale = drm_rect_calc_hscale(src, dst, min_scale, max_scale);
vscale = drm_rect_calc_vscale(src, dst, min_scale, max_scale);
if (hscale < 0 || vscale < 0) {
DRM_DEBUG_KMS("Invalid scaling of plane\n");
drm_rect_debug_print("src: ", &state->src, true);
drm_rect_debug_print("dst: ", &state->dst, false);
return -ERANGE;
}
state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation);
if (!state->visible)
/*
* Plane isn't visible; some drivers can handle this
* so we just return success here. Drivers that can't
* (including those that use the primary plane helper's
* update function) will return an error from their
* update_plane handler.
*/
return 0;
if (!can_position && !drm_rect_equals(dst, clip)) {
DRM_DEBUG_KMS("Plane must cover entire CRTC\n");
drm_rect_debug_print("dst: ", dst, false);
drm_rect_debug_print("clip: ", clip, false);
return -EINVAL;
}
return 0;
}
EXPORT_SYMBOL(drm_plane_helper_check_state);
/** /**
* drm_plane_helper_check_update() - Check plane update for validity * drm_plane_helper_check_update() - Check plane update for validity
* @plane: plane object to update * @plane: plane object to update
@ -138,7 +236,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
struct drm_crtc *crtc, struct drm_crtc *crtc,
struct drm_framebuffer *fb, struct drm_framebuffer *fb,
struct drm_rect *src, struct drm_rect *src,
struct drm_rect *dest, struct drm_rect *dst,
const struct drm_rect *clip, const struct drm_rect *clip,
unsigned int rotation, unsigned int rotation,
int min_scale, int min_scale,
@ -147,56 +245,33 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
bool can_update_disabled, bool can_update_disabled,
bool *visible) bool *visible)
{ {
int hscale, vscale; struct drm_plane_state state = {
.plane = plane,
.crtc = crtc,
.fb = fb,
.src_x = src->x1,
.src_y = src->y1,
.src_w = drm_rect_width(src),
.src_h = drm_rect_height(src),
.crtc_x = dst->x1,
.crtc_y = dst->y1,
.crtc_w = drm_rect_width(dst),
.crtc_h = drm_rect_height(dst),
.rotation = rotation,
.visible = *visible,
};
int ret;
if (!fb) { ret = drm_plane_helper_check_state(&state, clip,
*visible = false; min_scale, max_scale,
return 0; can_position,
} can_update_disabled);
if (ret)
return ret;
/* crtc should only be NULL when disabling (i.e., !fb) */ *src = state.src;
if (WARN_ON(!crtc)) { *dst = state.dst;
*visible = false; *visible = state.visible;
return 0;
}
if (!crtc->enabled && !can_update_disabled) {
DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n");
return -EINVAL;
}
drm_rect_rotate(src, fb->width << 16, fb->height << 16, rotation);
/* Check scaling */
hscale = drm_rect_calc_hscale(src, dest, min_scale, max_scale);
vscale = drm_rect_calc_vscale(src, dest, min_scale, max_scale);
if (hscale < 0 || vscale < 0) {
DRM_DEBUG_KMS("Invalid scaling of plane\n");
drm_rect_debug_print("src: ", src, true);
drm_rect_debug_print("dst: ", dest, false);
return -ERANGE;
}
*visible = drm_rect_clip_scaled(src, dest, clip, hscale, vscale);
drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation);
if (!*visible)
/*
* Plane isn't visible; some drivers can handle this
* so we just return success here. Drivers that can't
* (including those that use the primary plane helper's
* update function) will return an error from their
* update_plane handler.
*/
return 0;
if (!can_position && !drm_rect_equals(dest, clip)) {
DRM_DEBUG_KMS("Plane must cover entire CRTC\n");
drm_rect_debug_print("dst: ", dest, false);
drm_rect_debug_print("clip: ", clip, false);
return -EINVAL;
}
return 0; return 0;
} }
@ -274,7 +349,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
ret = drm_plane_helper_check_update(plane, crtc, fb, ret = drm_plane_helper_check_update(plane, crtc, fb,
&src, &dest, &clip, &src, &dest, &clip,
BIT(DRM_ROTATE_0), DRM_ROTATE_0,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
false, false, &visible); false, false, &visible);

View File

@ -100,7 +100,7 @@ static int drm_calc_scale(int src, int dst)
{ {
int scale = 0; int scale = 0;
if (src < 0 || dst < 0) if (WARN_ON(src < 0 || dst < 0))
return -EINVAL; return -EINVAL;
if (dst == 0) if (dst == 0)
@ -317,38 +317,38 @@ void drm_rect_rotate(struct drm_rect *r,
{ {
struct drm_rect tmp; struct drm_rect tmp;
if (rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))) { if (rotation & (DRM_REFLECT_X | DRM_REFLECT_Y)) {
tmp = *r; tmp = *r;
if (rotation & BIT(DRM_REFLECT_X)) { if (rotation & DRM_REFLECT_X) {
r->x1 = width - tmp.x2; r->x1 = width - tmp.x2;
r->x2 = width - tmp.x1; r->x2 = width - tmp.x1;
} }
if (rotation & BIT(DRM_REFLECT_Y)) { if (rotation & DRM_REFLECT_Y) {
r->y1 = height - tmp.y2; r->y1 = height - tmp.y2;
r->y2 = height - tmp.y1; r->y2 = height - tmp.y1;
} }
} }
switch (rotation & DRM_ROTATE_MASK) { switch (rotation & DRM_ROTATE_MASK) {
case BIT(DRM_ROTATE_0): case DRM_ROTATE_0:
break; break;
case BIT(DRM_ROTATE_90): case DRM_ROTATE_90:
tmp = *r; tmp = *r;
r->x1 = tmp.y1; r->x1 = tmp.y1;
r->x2 = tmp.y2; r->x2 = tmp.y2;
r->y1 = width - tmp.x2; r->y1 = width - tmp.x2;
r->y2 = width - tmp.x1; r->y2 = width - tmp.x1;
break; break;
case BIT(DRM_ROTATE_180): case DRM_ROTATE_180:
tmp = *r; tmp = *r;
r->x1 = width - tmp.x2; r->x1 = width - tmp.x2;
r->x2 = width - tmp.x1; r->x2 = width - tmp.x1;
r->y1 = height - tmp.y2; r->y1 = height - tmp.y2;
r->y2 = height - tmp.y1; r->y2 = height - tmp.y1;
break; break;
case BIT(DRM_ROTATE_270): case DRM_ROTATE_270:
tmp = *r; tmp = *r;
r->x1 = height - tmp.y2; r->x1 = height - tmp.y2;
r->x2 = height - tmp.y1; r->x2 = height - tmp.y1;
@ -392,23 +392,23 @@ void drm_rect_rotate_inv(struct drm_rect *r,
struct drm_rect tmp; struct drm_rect tmp;
switch (rotation & DRM_ROTATE_MASK) { switch (rotation & DRM_ROTATE_MASK) {
case BIT(DRM_ROTATE_0): case DRM_ROTATE_0:
break; break;
case BIT(DRM_ROTATE_90): case DRM_ROTATE_90:
tmp = *r; tmp = *r;
r->x1 = width - tmp.y2; r->x1 = width - tmp.y2;
r->x2 = width - tmp.y1; r->x2 = width - tmp.y1;
r->y1 = tmp.x1; r->y1 = tmp.x1;
r->y2 = tmp.x2; r->y2 = tmp.x2;
break; break;
case BIT(DRM_ROTATE_180): case DRM_ROTATE_180:
tmp = *r; tmp = *r;
r->x1 = width - tmp.x2; r->x1 = width - tmp.x2;
r->x2 = width - tmp.x1; r->x2 = width - tmp.x1;
r->y1 = height - tmp.y2; r->y1 = height - tmp.y2;
r->y2 = height - tmp.y1; r->y2 = height - tmp.y1;
break; break;
case BIT(DRM_ROTATE_270): case DRM_ROTATE_270:
tmp = *r; tmp = *r;
r->x1 = tmp.y1; r->x1 = tmp.y1;
r->x2 = tmp.y2; r->x2 = tmp.y2;
@ -419,15 +419,15 @@ void drm_rect_rotate_inv(struct drm_rect *r,
break; break;
} }
if (rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))) { if (rotation & (DRM_REFLECT_X | DRM_REFLECT_Y)) {
tmp = *r; tmp = *r;
if (rotation & BIT(DRM_REFLECT_X)) { if (rotation & DRM_REFLECT_X) {
r->x1 = width - tmp.x2; r->x1 = width - tmp.x2;
r->x2 = width - tmp.x1; r->x2 = width - tmp.x1;
} }
if (rotation & BIT(DRM_REFLECT_Y)) { if (rotation & DRM_REFLECT_Y) {
r->y1 = height - tmp.y2; r->y1 = height - tmp.y2;
r->y2 = height - tmp.y1; r->y2 = height - tmp.y1;
} }

View File

@ -68,7 +68,7 @@ static void drm_sg_cleanup(struct drm_sg_mem * entry)
void drm_legacy_sg_cleanup(struct drm_device *dev) void drm_legacy_sg_cleanup(struct drm_device *dev)
{ {
if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg && if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
!drm_core_check_feature(dev, DRIVER_MODESET)) { drm_core_check_feature(dev, DRIVER_LEGACY)) {
drm_sg_cleanup(dev->sg); drm_sg_cleanup(dev->sg);
dev->sg = NULL; dev->sg = NULL;
} }
@ -88,7 +88,7 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
DRM_DEBUG("\n"); DRM_DEBUG("\n");
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
if (!drm_core_check_feature(dev, DRIVER_SG)) if (!drm_core_check_feature(dev, DRIVER_SG))
@ -201,7 +201,7 @@ int drm_legacy_sg_free(struct drm_device *dev, void *data,
struct drm_scatter_gather *request = data; struct drm_scatter_gather *request = data;
struct drm_sg_mem *entry; struct drm_sg_mem *entry;
if (drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_LEGACY))
return -EINVAL; return -EINVAL;
if (!drm_core_check_feature(dev, DRIVER_SG)) if (!drm_core_check_feature(dev, DRIVER_SG))

View File

@ -73,22 +73,9 @@ static const struct drm_crtc_funcs drm_simple_kms_crtc_funcs = {
static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane, static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,
struct drm_plane_state *plane_state) struct drm_plane_state *plane_state)
{ {
struct drm_rect src = {
.x1 = plane_state->src_x,
.y1 = plane_state->src_y,
.x2 = plane_state->src_x + plane_state->src_w,
.y2 = plane_state->src_y + plane_state->src_h,
};
struct drm_rect dest = {
.x1 = plane_state->crtc_x,
.y1 = plane_state->crtc_y,
.x2 = plane_state->crtc_x + plane_state->crtc_w,
.y2 = plane_state->crtc_y + plane_state->crtc_h,
};
struct drm_rect clip = { 0 }; struct drm_rect clip = { 0 };
struct drm_simple_display_pipe *pipe; struct drm_simple_display_pipe *pipe;
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
bool visible;
int ret; int ret;
pipe = container_of(plane, struct drm_simple_display_pipe, plane); pipe = container_of(plane, struct drm_simple_display_pipe, plane);
@ -102,17 +89,15 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,
clip.x2 = crtc_state->adjusted_mode.hdisplay; clip.x2 = crtc_state->adjusted_mode.hdisplay;
clip.y2 = crtc_state->adjusted_mode.vdisplay; clip.y2 = crtc_state->adjusted_mode.vdisplay;
ret = drm_plane_helper_check_update(plane, &pipe->crtc,
plane_state->fb, ret = drm_plane_helper_check_state(plane_state, &clip,
&src, &dest, &clip, DRM_PLANE_HELPER_NO_SCALING,
plane_state->rotation, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, false, true);
DRM_PLANE_HELPER_NO_SCALING,
false, true, &visible);
if (ret) if (ret)
return ret; return ret;
if (!visible) if (!plane_state->visible)
return -EINVAL; return -EINVAL;
if (!pipe->funcs || !pipe->funcs->check) if (!pipe->funcs || !pipe->funcs->check)

View File

@ -86,7 +86,6 @@ void drm_vma_offset_manager_init(struct drm_vma_offset_manager *mgr,
unsigned long page_offset, unsigned long size) unsigned long page_offset, unsigned long size)
{ {
rwlock_init(&mgr->vm_lock); rwlock_init(&mgr->vm_lock);
mgr->vm_addr_space_rb = RB_ROOT;
drm_mm_init(&mgr->vm_addr_space_mm, page_offset, size); drm_mm_init(&mgr->vm_addr_space_mm, page_offset, size);
} }
EXPORT_SYMBOL(drm_vma_offset_manager_init); EXPORT_SYMBOL(drm_vma_offset_manager_init);
@ -145,16 +144,16 @@ struct drm_vma_offset_node *drm_vma_offset_lookup_locked(struct drm_vma_offset_m
unsigned long start, unsigned long start,
unsigned long pages) unsigned long pages)
{ {
struct drm_vma_offset_node *node, *best; struct drm_mm_node *node, *best;
struct rb_node *iter; struct rb_node *iter;
unsigned long offset; unsigned long offset;
iter = mgr->vm_addr_space_rb.rb_node; iter = mgr->vm_addr_space_mm.interval_tree.rb_node;
best = NULL; best = NULL;
while (likely(iter)) { while (likely(iter)) {
node = rb_entry(iter, struct drm_vma_offset_node, vm_rb); node = rb_entry(iter, struct drm_mm_node, rb);
offset = node->vm_node.start; offset = node->start;
if (start >= offset) { if (start >= offset) {
iter = iter->rb_right; iter = iter->rb_right;
best = node; best = node;
@ -167,39 +166,18 @@ struct drm_vma_offset_node *drm_vma_offset_lookup_locked(struct drm_vma_offset_m
/* verify that the node spans the requested area */ /* verify that the node spans the requested area */
if (best) { if (best) {
offset = best->vm_node.start + best->vm_node.size; offset = best->start + best->size;
if (offset < start + pages) if (offset < start + pages)
best = NULL; best = NULL;
} }
return best; if (!best)
return NULL;
return container_of(best, struct drm_vma_offset_node, vm_node);
} }
EXPORT_SYMBOL(drm_vma_offset_lookup_locked); EXPORT_SYMBOL(drm_vma_offset_lookup_locked);
/* internal helper to link @node into the rb-tree */
static void _drm_vma_offset_add_rb(struct drm_vma_offset_manager *mgr,
struct drm_vma_offset_node *node)
{
struct rb_node **iter = &mgr->vm_addr_space_rb.rb_node;
struct rb_node *parent = NULL;
struct drm_vma_offset_node *iter_node;
while (likely(*iter)) {
parent = *iter;
iter_node = rb_entry(*iter, struct drm_vma_offset_node, vm_rb);
if (node->vm_node.start < iter_node->vm_node.start)
iter = &(*iter)->rb_left;
else if (node->vm_node.start > iter_node->vm_node.start)
iter = &(*iter)->rb_right;
else
BUG();
}
rb_link_node(&node->vm_rb, parent, iter);
rb_insert_color(&node->vm_rb, &mgr->vm_addr_space_rb);
}
/** /**
* drm_vma_offset_add() - Add offset node to manager * drm_vma_offset_add() - Add offset node to manager
* @mgr: Manager object * @mgr: Manager object
@ -240,8 +218,6 @@ int drm_vma_offset_add(struct drm_vma_offset_manager *mgr,
if (ret) if (ret)
goto out_unlock; goto out_unlock;
_drm_vma_offset_add_rb(mgr, node);
out_unlock: out_unlock:
write_unlock(&mgr->vm_lock); write_unlock(&mgr->vm_lock);
return ret; return ret;
@ -265,7 +241,6 @@ void drm_vma_offset_remove(struct drm_vma_offset_manager *mgr,
write_lock(&mgr->vm_lock); write_lock(&mgr->vm_lock);
if (drm_mm_node_allocated(&node->vm_node)) { if (drm_mm_node_allocated(&node->vm_node)) {
rb_erase(&node->vm_rb, &mgr->vm_addr_space_rb);
drm_mm_remove_node(&node->vm_node); drm_mm_remove_node(&node->vm_node);
memset(&node->vm_node, 0, sizeof(node->vm_node)); memset(&node->vm_node, 0, sizeof(node->vm_node));
} }

View File

@ -28,7 +28,6 @@
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/fb.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/console.h> #include <linux/console.h>

View File

@ -26,7 +26,6 @@
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/fb.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/console.h> #include <linux/console.h>

View File

@ -18,7 +18,6 @@
*/ */
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/fb.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include "psb_intel_drv.h" #include "psb_intel_drv.h"

View File

@ -56,9 +56,7 @@ static const struct file_operations i810_driver_fops = {
}; };
static struct drm_driver driver = { static struct drm_driver driver = {
.driver_features = .driver_features = DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_LEGACY,
DRIVER_USE_AGP |
DRIVER_HAVE_DMA,
.dev_priv_size = sizeof(drm_i810_buf_priv_t), .dev_priv_size = sizeof(drm_i810_buf_priv_t),
.load = i810_driver_load, .load = i810_driver_load,
.lastclose = i810_driver_lastclose, .lastclose = i810_driver_lastclose,

View File

@ -3089,12 +3089,12 @@ static const char *plane_rotation(unsigned int rotation)
*/ */
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"%s%s%s%s%s%s(0x%08x)", "%s%s%s%s%s%s(0x%08x)",
(rotation & BIT(DRM_ROTATE_0)) ? "0 " : "", (rotation & DRM_ROTATE_0) ? "0 " : "",
(rotation & BIT(DRM_ROTATE_90)) ? "90 " : "", (rotation & DRM_ROTATE_90) ? "90 " : "",
(rotation & BIT(DRM_ROTATE_180)) ? "180 " : "", (rotation & DRM_ROTATE_180) ? "180 " : "",
(rotation & BIT(DRM_ROTATE_270)) ? "270 " : "", (rotation & DRM_ROTATE_270) ? "270 " : "",
(rotation & BIT(DRM_REFLECT_X)) ? "FLIPX " : "", (rotation & DRM_REFLECT_X) ? "FLIPX " : "",
(rotation & BIT(DRM_REFLECT_Y)) ? "FLIPY " : "", (rotation & DRM_REFLECT_Y) ? "FLIPY " : "",
rotation); rotation);
return buf; return buf;

View File

@ -706,7 +706,7 @@ static int i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
primary = primary =
pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
ret = remove_conflicting_framebuffers(ap, "inteldrmfb", primary); ret = drm_fb_helper_remove_conflicting_framebuffers(ap, "inteldrmfb", primary);
kfree(ap); kfree(ap);

View File

@ -55,7 +55,7 @@ intel_create_plane_state(struct drm_plane *plane)
return NULL; return NULL;
state->base.plane = plane; state->base.plane = plane;
state->base.rotation = BIT(DRM_ROTATE_0); state->base.rotation = DRM_ROTATE_0;
state->ckey.flags = I915_SET_COLORKEY_NONE; state->ckey.flags = I915_SET_COLORKEY_NONE;
return state; return state;
@ -134,20 +134,6 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
crtc_state = to_intel_crtc_state(drm_crtc_state); crtc_state = to_intel_crtc_state(drm_crtc_state);
/*
* The original src/dest coordinates are stored in state->base, but
* we want to keep another copy internal to our driver that we can
* clip/modify ourselves.
*/
intel_state->src.x1 = state->src_x;
intel_state->src.y1 = state->src_y;
intel_state->src.x2 = state->src_x + state->src_w;
intel_state->src.y2 = state->src_y + state->src_h;
intel_state->dst.x1 = state->crtc_x;
intel_state->dst.y1 = state->crtc_y;
intel_state->dst.x2 = state->crtc_x + state->crtc_w;
intel_state->dst.y2 = state->crtc_y + state->crtc_h;
/* Clip all planes to CRTC size, or 0x0 if CRTC is disabled */ /* Clip all planes to CRTC size, or 0x0 if CRTC is disabled */
intel_state->clip.x1 = 0; intel_state->clip.x1 = 0;
intel_state->clip.y1 = 0; intel_state->clip.y1 = 0;
@ -180,7 +166,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
} }
} }
intel_state->visible = false; intel_state->base.visible = false;
ret = intel_plane->check_plane(plane, crtc_state, intel_state); ret = intel_plane->check_plane(plane, crtc_state, intel_state);
if (ret) if (ret)
return ret; return ret;
@ -196,7 +182,7 @@ static void intel_plane_atomic_update(struct drm_plane *plane,
to_intel_plane_state(plane->state); to_intel_plane_state(plane->state);
struct drm_crtc *crtc = plane->state->crtc ?: old_state->crtc; struct drm_crtc *crtc = plane->state->crtc ?: old_state->crtc;
if (intel_state->visible) if (intel_state->base.visible)
intel_plane->update_plane(plane, intel_plane->update_plane(plane,
to_intel_crtc_state(crtc->state), to_intel_crtc_state(crtc->state),
intel_state); intel_state);

View File

@ -2565,7 +2565,7 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
* simplest solution is to just disable the primary plane now and * simplest solution is to just disable the primary plane now and
* pretend the BIOS never had it enabled. * pretend the BIOS never had it enabled.
*/ */
to_intel_plane_state(plane_state)->visible = false; to_intel_plane_state(plane_state)->base.visible = false;
crtc_state->plane_mask &= ~(1 << drm_plane_index(primary)); crtc_state->plane_mask &= ~(1 << drm_plane_index(primary));
intel_pre_disable_primary_noatomic(&intel_crtc->base); intel_pre_disable_primary_noatomic(&intel_crtc->base);
intel_plane->disable_plane(primary, &intel_crtc->base); intel_plane->disable_plane(primary, &intel_crtc->base);
@ -2583,14 +2583,14 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
plane_state->crtc_w = fb->width; plane_state->crtc_w = fb->width;
plane_state->crtc_h = fb->height; plane_state->crtc_h = fb->height;
intel_state->src.x1 = plane_state->src_x; intel_state->base.src.x1 = plane_state->src_x;
intel_state->src.y1 = plane_state->src_y; intel_state->base.src.y1 = plane_state->src_y;
intel_state->src.x2 = plane_state->src_x + plane_state->src_w; intel_state->base.src.x2 = plane_state->src_x + plane_state->src_w;
intel_state->src.y2 = plane_state->src_y + plane_state->src_h; intel_state->base.src.y2 = plane_state->src_y + plane_state->src_h;
intel_state->dst.x1 = plane_state->crtc_x; intel_state->base.dst.x1 = plane_state->crtc_x;
intel_state->dst.y1 = plane_state->crtc_y; intel_state->base.dst.y1 = plane_state->crtc_y;
intel_state->dst.x2 = plane_state->crtc_x + plane_state->crtc_w; intel_state->base.dst.x2 = plane_state->crtc_x + plane_state->crtc_w;
intel_state->dst.y2 = plane_state->crtc_y + plane_state->crtc_h; intel_state->base.dst.y2 = plane_state->crtc_y + plane_state->crtc_h;
obj = intel_fb_obj(fb); obj = intel_fb_obj(fb);
if (obj->tiling_mode != I915_TILING_NONE) if (obj->tiling_mode != I915_TILING_NONE)
@ -2618,8 +2618,8 @@ static void i9xx_update_primary_plane(struct drm_plane *primary,
i915_reg_t reg = DSPCNTR(plane); i915_reg_t reg = DSPCNTR(plane);
unsigned int rotation = plane_state->base.rotation; unsigned int rotation = plane_state->base.rotation;
int cpp = drm_format_plane_cpp(fb->pixel_format, 0); int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
int x = plane_state->src.x1 >> 16; int x = plane_state->base.src.x1 >> 16;
int y = plane_state->src.y1 >> 16; int y = plane_state->base.src.y1 >> 16;
dspcntr = DISPPLANE_GAMMA_ENABLE; dspcntr = DISPPLANE_GAMMA_ENABLE;
@ -2688,7 +2688,7 @@ static void i9xx_update_primary_plane(struct drm_plane *primary,
intel_crtc->dspaddr_offset = linear_offset; intel_crtc->dspaddr_offset = linear_offset;
} }
if (rotation == BIT(DRM_ROTATE_180)) { if (rotation == DRM_ROTATE_180) {
dspcntr |= DISPPLANE_ROTATE_180; dspcntr |= DISPPLANE_ROTATE_180;
x += (crtc_state->pipe_src_w - 1); x += (crtc_state->pipe_src_w - 1);
@ -2748,8 +2748,8 @@ static void ironlake_update_primary_plane(struct drm_plane *primary,
i915_reg_t reg = DSPCNTR(plane); i915_reg_t reg = DSPCNTR(plane);
unsigned int rotation = plane_state->base.rotation; unsigned int rotation = plane_state->base.rotation;
int cpp = drm_format_plane_cpp(fb->pixel_format, 0); int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
int x = plane_state->src.x1 >> 16; int x = plane_state->base.src.x1 >> 16;
int y = plane_state->src.y1 >> 16; int y = plane_state->base.src.y1 >> 16;
dspcntr = DISPPLANE_GAMMA_ENABLE; dspcntr = DISPPLANE_GAMMA_ENABLE;
dspcntr |= DISPLAY_PLANE_ENABLE; dspcntr |= DISPLAY_PLANE_ENABLE;
@ -2791,7 +2791,7 @@ static void ironlake_update_primary_plane(struct drm_plane *primary,
intel_compute_tile_offset(&x, &y, fb, 0, intel_compute_tile_offset(&x, &y, fb, 0,
fb->pitches[0], rotation); fb->pitches[0], rotation);
linear_offset -= intel_crtc->dspaddr_offset; linear_offset -= intel_crtc->dspaddr_offset;
if (rotation == BIT(DRM_ROTATE_180)) { if (rotation == DRM_ROTATE_180) {
dspcntr |= DISPPLANE_ROTATE_180; dspcntr |= DISPPLANE_ROTATE_180;
if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) { if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) {
@ -2952,17 +2952,17 @@ u32 skl_plane_ctl_tiling(uint64_t fb_modifier)
u32 skl_plane_ctl_rotation(unsigned int rotation) u32 skl_plane_ctl_rotation(unsigned int rotation)
{ {
switch (rotation) { switch (rotation) {
case BIT(DRM_ROTATE_0): case DRM_ROTATE_0:
break; break;
/* /*
* DRM_ROTATE_ is counter clockwise to stay compatible with Xrandr * DRM_ROTATE_ is counter clockwise to stay compatible with Xrandr
* while i915 HW rotation is clockwise, thats why this swapping. * while i915 HW rotation is clockwise, thats why this swapping.
*/ */
case BIT(DRM_ROTATE_90): case DRM_ROTATE_90:
return PLANE_CTL_ROTATE_270; return PLANE_CTL_ROTATE_270;
case BIT(DRM_ROTATE_180): case DRM_ROTATE_180:
return PLANE_CTL_ROTATE_180; return PLANE_CTL_ROTATE_180;
case BIT(DRM_ROTATE_270): case DRM_ROTATE_270:
return PLANE_CTL_ROTATE_90; return PLANE_CTL_ROTATE_90;
default: default:
MISSING_CASE(rotation); MISSING_CASE(rotation);
@ -2987,14 +2987,14 @@ static void skylake_update_primary_plane(struct drm_plane *plane,
int x_offset, y_offset; int x_offset, y_offset;
u32 surf_addr; u32 surf_addr;
int scaler_id = plane_state->scaler_id; int scaler_id = plane_state->scaler_id;
int src_x = plane_state->src.x1 >> 16; int src_x = plane_state->base.src.x1 >> 16;
int src_y = plane_state->src.y1 >> 16; int src_y = plane_state->base.src.y1 >> 16;
int src_w = drm_rect_width(&plane_state->src) >> 16; int src_w = drm_rect_width(&plane_state->base.src) >> 16;
int src_h = drm_rect_height(&plane_state->src) >> 16; int src_h = drm_rect_height(&plane_state->base.src) >> 16;
int dst_x = plane_state->dst.x1; int dst_x = plane_state->base.dst.x1;
int dst_y = plane_state->dst.y1; int dst_y = plane_state->base.dst.y1;
int dst_w = drm_rect_width(&plane_state->dst); int dst_w = drm_rect_width(&plane_state->base.dst);
int dst_h = drm_rect_height(&plane_state->dst); int dst_h = drm_rect_height(&plane_state->base.dst);
plane_ctl = PLANE_CTL_ENABLE | plane_ctl = PLANE_CTL_ENABLE |
PLANE_CTL_PIPE_GAMMA_ENABLE | PLANE_CTL_PIPE_GAMMA_ENABLE |
@ -3009,7 +3009,7 @@ static void skylake_update_primary_plane(struct drm_plane *plane,
fb->pixel_format); fb->pixel_format);
surf_addr = intel_plane_obj_offset(to_intel_plane(plane), obj, 0); surf_addr = intel_plane_obj_offset(to_intel_plane(plane), obj, 0);
WARN_ON(drm_rect_width(&plane_state->src) == 0); WARN_ON(drm_rect_width(&plane_state->base.src) == 0);
if (intel_rotation_90_or_270(rotation)) { if (intel_rotation_90_or_270(rotation)) {
int cpp = drm_format_plane_cpp(fb->pixel_format, 0); int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
@ -3098,7 +3098,7 @@ static void intel_update_primary_planes(struct drm_device *dev)
drm_modeset_lock_crtc(crtc, &plane->base); drm_modeset_lock_crtc(crtc, &plane->base);
plane_state = to_intel_plane_state(plane->base.state); plane_state = to_intel_plane_state(plane->base.state);
if (plane_state->visible) if (plane_state->base.visible)
plane->update_plane(&plane->base, plane->update_plane(&plane->base,
to_intel_crtc_state(crtc->state), to_intel_crtc_state(crtc->state),
plane_state); plane_state);
@ -4248,7 +4248,7 @@ int skl_update_scaler_crtc(struct intel_crtc_state *state)
intel_crtc->pipe, SKL_CRTC_INDEX); intel_crtc->pipe, SKL_CRTC_INDEX);
return skl_update_scaler(state, !state->base.active, SKL_CRTC_INDEX, return skl_update_scaler(state, !state->base.active, SKL_CRTC_INDEX,
&state->scaler_state.scaler_id, BIT(DRM_ROTATE_0), &state->scaler_state.scaler_id, DRM_ROTATE_0,
state->pipe_src_w, state->pipe_src_h, state->pipe_src_w, state->pipe_src_h,
adjusted_mode->crtc_hdisplay, adjusted_mode->crtc_vdisplay); adjusted_mode->crtc_hdisplay, adjusted_mode->crtc_vdisplay);
} }
@ -4273,7 +4273,7 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
struct drm_framebuffer *fb = plane_state->base.fb; struct drm_framebuffer *fb = plane_state->base.fb;
int ret; int ret;
bool force_detach = !fb || !plane_state->visible; bool force_detach = !fb || !plane_state->base.visible;
DRM_DEBUG_KMS("Updating scaler for [PLANE:%d:%s] scaler_user index %u.%u\n", DRM_DEBUG_KMS("Updating scaler for [PLANE:%d:%s] scaler_user index %u.%u\n",
intel_plane->base.base.id, intel_plane->base.name, intel_plane->base.base.id, intel_plane->base.name,
@ -4283,10 +4283,10 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
drm_plane_index(&intel_plane->base), drm_plane_index(&intel_plane->base),
&plane_state->scaler_id, &plane_state->scaler_id,
plane_state->base.rotation, plane_state->base.rotation,
drm_rect_width(&plane_state->src) >> 16, drm_rect_width(&plane_state->base.src) >> 16,
drm_rect_height(&plane_state->src) >> 16, drm_rect_height(&plane_state->base.src) >> 16,
drm_rect_width(&plane_state->dst), drm_rect_width(&plane_state->base.dst),
drm_rect_height(&plane_state->dst)); drm_rect_height(&plane_state->base.dst));
if (ret || plane_state->scaler_id < 0) if (ret || plane_state->scaler_id < 0)
return ret; return ret;
@ -4584,9 +4584,9 @@ static void intel_post_plane_update(struct intel_crtc_state *old_crtc_state)
intel_fbc_post_update(crtc); intel_fbc_post_update(crtc);
if (primary_state->visible && if (primary_state->base.visible &&
(needs_modeset(&pipe_config->base) || (needs_modeset(&pipe_config->base) ||
!old_primary_state->visible)) !old_primary_state->base.visible))
intel_post_enable_primary(&crtc->base); intel_post_enable_primary(&crtc->base);
} }
} }
@ -4612,8 +4612,8 @@ static void intel_pre_plane_update(struct intel_crtc_state *old_crtc_state)
intel_fbc_pre_update(crtc, pipe_config, primary_state); intel_fbc_pre_update(crtc, pipe_config, primary_state);
if (old_primary_state->visible && if (old_primary_state->base.visible &&
(modeset || !primary_state->visible)) (modeset || !primary_state->base.visible))
intel_pre_disable_primary(&crtc->base); intel_pre_disable_primary(&crtc->base);
} }
@ -6290,13 +6290,13 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
if (!intel_crtc->active) if (!intel_crtc->active)
return; return;
if (to_intel_plane_state(crtc->primary->state)->visible) { if (to_intel_plane_state(crtc->primary->state)->base.visible) {
WARN_ON(intel_crtc->flip_work); WARN_ON(intel_crtc->flip_work);
intel_pre_disable_primary_noatomic(crtc); intel_pre_disable_primary_noatomic(crtc);
intel_crtc_disable_planes(crtc, 1 << drm_plane_index(crtc->primary)); intel_crtc_disable_planes(crtc, 1 << drm_plane_index(crtc->primary));
to_intel_plane_state(crtc->primary->state)->visible = false; to_intel_plane_state(crtc->primary->state)->base.visible = false;
} }
dev_priv->display.crtc_disable(crtc); dev_priv->display.crtc_disable(crtc);
@ -10170,7 +10170,7 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base,
struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
uint32_t cntl = 0, size = 0; uint32_t cntl = 0, size = 0;
if (plane_state && plane_state->visible) { if (plane_state && plane_state->base.visible) {
unsigned int width = plane_state->base.crtc_w; unsigned int width = plane_state->base.crtc_w;
unsigned int height = plane_state->base.crtc_h; unsigned int height = plane_state->base.crtc_h;
unsigned int stride = roundup_pow_of_two(width) * 4; unsigned int stride = roundup_pow_of_two(width) * 4;
@ -10234,7 +10234,7 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base,
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
uint32_t cntl = 0; uint32_t cntl = 0;
if (plane_state && plane_state->visible) { if (plane_state && plane_state->base.visible) {
cntl = MCURSOR_GAMMA_ENABLE; cntl = MCURSOR_GAMMA_ENABLE;
switch (plane_state->base.crtc_w) { switch (plane_state->base.crtc_w) {
case 64: case 64:
@ -10255,7 +10255,7 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base,
if (HAS_DDI(dev)) if (HAS_DDI(dev))
cntl |= CURSOR_PIPE_CSC_ENABLE; cntl |= CURSOR_PIPE_CSC_ENABLE;
if (plane_state->base.rotation == BIT(DRM_ROTATE_180)) if (plane_state->base.rotation == DRM_ROTATE_180)
cntl |= CURSOR_ROTATE_180; cntl |= CURSOR_ROTATE_180;
} }
@ -10301,7 +10301,7 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
/* ILK+ do this automagically */ /* ILK+ do this automagically */
if (HAS_GMCH_DISPLAY(dev) && if (HAS_GMCH_DISPLAY(dev) &&
plane_state->base.rotation == BIT(DRM_ROTATE_180)) { plane_state->base.rotation == DRM_ROTATE_180) {
base += (plane_state->base.crtc_h * base += (plane_state->base.crtc_h *
plane_state->base.crtc_w - 1) * 4; plane_state->base.crtc_w - 1) * 4;
} }
@ -11818,7 +11818,7 @@ static bool intel_wm_need_update(struct drm_plane *plane,
struct intel_plane_state *cur = to_intel_plane_state(plane->state); struct intel_plane_state *cur = to_intel_plane_state(plane->state);
/* Update watermarks on tiling or size changes. */ /* Update watermarks on tiling or size changes. */
if (new->visible != cur->visible) if (new->base.visible != cur->base.visible)
return true; return true;
if (!cur->base.fb || !new->base.fb) if (!cur->base.fb || !new->base.fb)
@ -11826,10 +11826,10 @@ static bool intel_wm_need_update(struct drm_plane *plane,
if (cur->base.fb->modifier[0] != new->base.fb->modifier[0] || if (cur->base.fb->modifier[0] != new->base.fb->modifier[0] ||
cur->base.rotation != new->base.rotation || cur->base.rotation != new->base.rotation ||
drm_rect_width(&new->src) != drm_rect_width(&cur->src) || drm_rect_width(&new->base.src) != drm_rect_width(&cur->base.src) ||
drm_rect_height(&new->src) != drm_rect_height(&cur->src) || drm_rect_height(&new->base.src) != drm_rect_height(&cur->base.src) ||
drm_rect_width(&new->dst) != drm_rect_width(&cur->dst) || drm_rect_width(&new->base.dst) != drm_rect_width(&cur->base.dst) ||
drm_rect_height(&new->dst) != drm_rect_height(&cur->dst)) drm_rect_height(&new->base.dst) != drm_rect_height(&cur->base.dst))
return true; return true;
return false; return false;
@ -11837,10 +11837,10 @@ static bool intel_wm_need_update(struct drm_plane *plane,
static bool needs_scaling(struct intel_plane_state *state) static bool needs_scaling(struct intel_plane_state *state)
{ {
int src_w = drm_rect_width(&state->src) >> 16; int src_w = drm_rect_width(&state->base.src) >> 16;
int src_h = drm_rect_height(&state->src) >> 16; int src_h = drm_rect_height(&state->base.src) >> 16;
int dst_w = drm_rect_width(&state->dst); int dst_w = drm_rect_width(&state->base.dst);
int dst_h = drm_rect_height(&state->dst); int dst_h = drm_rect_height(&state->base.dst);
return (src_w != dst_w || src_h != dst_h); return (src_w != dst_w || src_h != dst_h);
} }
@ -11871,8 +11871,8 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
return ret; return ret;
} }
was_visible = old_plane_state->visible; was_visible = old_plane_state->base.visible;
visible = to_intel_plane_state(plane_state)->visible; visible = to_intel_plane_state(plane_state)->base.visible;
if (!was_crtc_enabled && WARN_ON(was_visible)) if (!was_crtc_enabled && WARN_ON(was_visible))
was_visible = false; was_visible = false;
@ -11888,7 +11888,7 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
* only combine the results from all planes in the current place? * only combine the results from all planes in the current place?
*/ */
if (!is_crtc_enabled) if (!is_crtc_enabled)
to_intel_plane_state(plane_state)->visible = visible = false; to_intel_plane_state(plane_state)->base.visible = visible = false;
if (!was_visible && !visible) if (!was_visible && !visible)
return 0; return 0;
@ -12283,12 +12283,13 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,
drm_get_format_name(fb->pixel_format)); drm_get_format_name(fb->pixel_format));
DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n", DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n",
state->scaler_id, state->scaler_id,
state->src.x1 >> 16, state->src.y1 >> 16, state->base.src.x1 >> 16,
drm_rect_width(&state->src) >> 16, state->base.src.y1 >> 16,
drm_rect_height(&state->src) >> 16, drm_rect_width(&state->base.src) >> 16,
state->dst.x1, state->dst.y1, drm_rect_height(&state->base.src) >> 16,
drm_rect_width(&state->dst), state->base.dst.x1, state->base.dst.y1,
drm_rect_height(&state->dst)); drm_rect_width(&state->base.dst),
drm_rect_height(&state->base.dst));
} }
} }
@ -14109,7 +14110,6 @@ intel_check_primary_plane(struct drm_plane *plane,
struct intel_plane_state *state) struct intel_plane_state *state)
{ {
struct drm_crtc *crtc = state->base.crtc; struct drm_crtc *crtc = state->base.crtc;
struct drm_framebuffer *fb = state->base.fb;
int min_scale = DRM_PLANE_HELPER_NO_SCALING; int min_scale = DRM_PLANE_HELPER_NO_SCALING;
int max_scale = DRM_PLANE_HELPER_NO_SCALING; int max_scale = DRM_PLANE_HELPER_NO_SCALING;
bool can_position = false; bool can_position = false;
@ -14123,12 +14123,10 @@ intel_check_primary_plane(struct drm_plane *plane,
can_position = true; can_position = true;
} }
return drm_plane_helper_check_update(plane, crtc, fb, &state->src, return drm_plane_helper_check_state(&state->base,
&state->dst, &state->clip, &state->clip,
state->base.rotation, min_scale, max_scale,
min_scale, max_scale, can_position, true);
can_position, true,
&state->visible);
} }
static void intel_begin_crtc_commit(struct drm_crtc *crtc, static void intel_begin_crtc_commit(struct drm_crtc *crtc,
@ -14288,11 +14286,11 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
void intel_create_rotation_property(struct drm_device *dev, struct intel_plane *plane) void intel_create_rotation_property(struct drm_device *dev, struct intel_plane *plane)
{ {
if (!dev->mode_config.rotation_property) { if (!dev->mode_config.rotation_property) {
unsigned long flags = BIT(DRM_ROTATE_0) | unsigned long flags = DRM_ROTATE_0 |
BIT(DRM_ROTATE_180); DRM_ROTATE_180;
if (INTEL_INFO(dev)->gen >= 9) if (INTEL_INFO(dev)->gen >= 9)
flags |= BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270); flags |= DRM_ROTATE_90 | DRM_ROTATE_270;
dev->mode_config.rotation_property = dev->mode_config.rotation_property =
drm_mode_create_rotation_property(dev, flags); drm_mode_create_rotation_property(dev, flags);
@ -14308,19 +14306,17 @@ intel_check_cursor_plane(struct drm_plane *plane,
struct intel_crtc_state *crtc_state, struct intel_crtc_state *crtc_state,
struct intel_plane_state *state) struct intel_plane_state *state)
{ {
struct drm_crtc *crtc = crtc_state->base.crtc;
struct drm_framebuffer *fb = state->base.fb; struct drm_framebuffer *fb = state->base.fb;
struct drm_i915_gem_object *obj = intel_fb_obj(fb); struct drm_i915_gem_object *obj = intel_fb_obj(fb);
enum pipe pipe = to_intel_plane(plane)->pipe; enum pipe pipe = to_intel_plane(plane)->pipe;
unsigned stride; unsigned stride;
int ret; int ret;
ret = drm_plane_helper_check_update(plane, crtc, fb, &state->src, ret = drm_plane_helper_check_state(&state->base,
&state->dst, &state->clip, &state->clip,
state->base.rotation, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, true, true);
true, true, &state->visible);
if (ret) if (ret)
return ret; return ret;
@ -14357,7 +14353,7 @@ intel_check_cursor_plane(struct drm_plane *plane,
* Refuse the put the cursor into that compromised position. * Refuse the put the cursor into that compromised position.
*/ */
if (IS_CHERRYVIEW(plane->dev) && pipe == PIPE_C && if (IS_CHERRYVIEW(plane->dev) && pipe == PIPE_C &&
state->visible && state->base.crtc_x < 0) { state->base.visible && state->base.crtc_x < 0) {
DRM_DEBUG_KMS("CHV cursor C not allowed to straddle the left screen edge\n"); DRM_DEBUG_KMS("CHV cursor C not allowed to straddle the left screen edge\n");
return -EINVAL; return -EINVAL;
} }
@ -14435,8 +14431,8 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
if (!dev->mode_config.rotation_property) if (!dev->mode_config.rotation_property)
dev->mode_config.rotation_property = dev->mode_config.rotation_property =
drm_mode_create_rotation_property(dev, drm_mode_create_rotation_property(dev,
BIT(DRM_ROTATE_0) | DRM_ROTATE_0 |
BIT(DRM_ROTATE_180)); DRM_ROTATE_180);
if (dev->mode_config.rotation_property) if (dev->mode_config.rotation_property)
drm_object_attach_property(&cursor->base.base, drm_object_attach_property(&cursor->base.base,
dev->mode_config.rotation_property, dev->mode_config.rotation_property,
@ -15807,7 +15803,7 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)
* Temporarily change the plane mapping and disable everything * Temporarily change the plane mapping and disable everything
* ... */ * ... */
plane = crtc->plane; plane = crtc->plane;
to_intel_plane_state(crtc->base.primary->state)->visible = true; to_intel_plane_state(crtc->base.primary->state)->base.visible = true;
crtc->plane = !plane; crtc->plane = !plane;
intel_crtc_disable_noatomic(&crtc->base); intel_crtc_disable_noatomic(&crtc->base);
crtc->plane = plane; crtc->plane = plane;
@ -15934,10 +15930,10 @@ static void readout_plane_state(struct intel_crtc *crtc)
struct intel_plane_state *plane_state = struct intel_plane_state *plane_state =
to_intel_plane_state(primary->state); to_intel_plane_state(primary->state);
plane_state->visible = crtc->active && plane_state->base.visible = crtc->active &&
primary_get_hw_state(to_intel_plane(primary)); primary_get_hw_state(to_intel_plane(primary));
if (plane_state->visible) if (plane_state->base.visible)
crtc->base.state->plane_mask |= 1 << drm_plane_index(primary); crtc->base.state->plane_mask |= 1 << drm_plane_index(primary);
} }

View File

@ -338,10 +338,7 @@ struct intel_atomic_state {
struct intel_plane_state { struct intel_plane_state {
struct drm_plane_state base; struct drm_plane_state base;
struct drm_rect src;
struct drm_rect dst;
struct drm_rect clip; struct drm_rect clip;
bool visible;
/* /*
* scaler_id * scaler_id
@ -1258,7 +1255,7 @@ unsigned int intel_tile_height(const struct drm_i915_private *dev_priv,
static inline bool static inline bool
intel_rotation_90_or_270(unsigned int rotation) intel_rotation_90_or_270(unsigned int rotation)
{ {
return rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270)); return rotation & (DRM_ROTATE_90 | DRM_ROTATE_270);
} }
void intel_create_rotation_property(struct drm_device *dev, void intel_create_rotation_property(struct drm_device *dev,

View File

@ -494,7 +494,7 @@ static bool multiple_pipes_ok(struct intel_crtc *crtc,
if (!no_fbc_on_multiple_pipes(dev_priv)) if (!no_fbc_on_multiple_pipes(dev_priv))
return true; return true;
if (plane_state->visible) if (plane_state->base.visible)
fbc->visible_pipes_mask |= (1 << pipe); fbc->visible_pipes_mask |= (1 << pipe);
else else
fbc->visible_pipes_mask &= ~(1 << pipe); fbc->visible_pipes_mask &= ~(1 << pipe);
@ -725,9 +725,9 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc,
ilk_pipe_pixel_rate(crtc_state); ilk_pipe_pixel_rate(crtc_state);
cache->plane.rotation = plane_state->base.rotation; cache->plane.rotation = plane_state->base.rotation;
cache->plane.src_w = drm_rect_width(&plane_state->src) >> 16; cache->plane.src_w = drm_rect_width(&plane_state->base.src) >> 16;
cache->plane.src_h = drm_rect_height(&plane_state->src) >> 16; cache->plane.src_h = drm_rect_height(&plane_state->base.src) >> 16;
cache->plane.visible = plane_state->visible; cache->plane.visible = plane_state->base.visible;
if (!cache->plane.visible) if (!cache->plane.visible)
return; return;
@ -775,7 +775,7 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc)
return false; return false;
} }
if (INTEL_INFO(dev_priv)->gen <= 4 && !IS_G4X(dev_priv) && if (INTEL_INFO(dev_priv)->gen <= 4 && !IS_G4X(dev_priv) &&
cache->plane.rotation != BIT(DRM_ROTATE_0)) { cache->plane.rotation != DRM_ROTATE_0) {
fbc->no_fbc_reason = "rotation unsupported"; fbc->no_fbc_reason = "rotation unsupported";
return false; return false;
} }
@ -1050,7 +1050,7 @@ void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
struct intel_plane_state *intel_plane_state = struct intel_plane_state *intel_plane_state =
to_intel_plane_state(plane_state); to_intel_plane_state(plane_state);
if (!intel_plane_state->visible) if (!intel_plane_state->base.visible)
continue; continue;
for_each_crtc_in_state(state, crtc, crtc_state, j) { for_each_crtc_in_state(state, crtc, crtc_state, j) {
@ -1212,7 +1212,7 @@ void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv)
for_each_intel_crtc(&dev_priv->drm, crtc) for_each_intel_crtc(&dev_priv->drm, crtc)
if (intel_crtc_active(&crtc->base) && if (intel_crtc_active(&crtc->base) &&
to_intel_plane_state(crtc->base.primary->state)->visible) to_intel_plane_state(crtc->base.primary->state)->base.visible)
dev_priv->fbc.visible_pipes_mask |= (1 << crtc->pipe); dev_priv->fbc.visible_pipes_mask |= (1 << crtc->pipe);
} }

View File

@ -34,7 +34,6 @@
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/sysrq.h> #include <linux/sysrq.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/fb.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/vga_switcheroo.h> #include <linux/vga_switcheroo.h>
@ -223,7 +222,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
* This also validates that any existing fb inherited from the * This also validates that any existing fb inherited from the
* BIOS is suitable for own access. * BIOS is suitable for own access.
*/ */
ret = intel_pin_and_fence_fb_obj(&ifbdev->fb->base, BIT(DRM_ROTATE_0)); ret = intel_pin_and_fence_fb_obj(&ifbdev->fb->base, DRM_ROTATE_0);
if (ret) if (ret)
goto out_unlock; goto out_unlock;
@ -289,7 +288,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
out_destroy_fbi: out_destroy_fbi:
drm_fb_helper_release_fbi(helper); drm_fb_helper_release_fbi(helper);
out_unpin: out_unpin:
intel_unpin_fb_obj(&ifbdev->fb->base, BIT(DRM_ROTATE_0)); intel_unpin_fb_obj(&ifbdev->fb->base, DRM_ROTATE_0);
out_unlock: out_unlock:
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
return ret; return ret;
@ -554,7 +553,7 @@ static void intel_fbdev_destroy(struct intel_fbdev *ifbdev)
if (ifbdev->fb) { if (ifbdev->fb) {
mutex_lock(&ifbdev->helper.dev->struct_mutex); mutex_lock(&ifbdev->helper.dev->struct_mutex);
intel_unpin_fb_obj(&ifbdev->fb->base, BIT(DRM_ROTATE_0)); intel_unpin_fb_obj(&ifbdev->fb->base, DRM_ROTATE_0);
mutex_unlock(&ifbdev->helper.dev->struct_mutex); mutex_unlock(&ifbdev->helper.dev->struct_mutex);
drm_framebuffer_remove(&ifbdev->fb->base); drm_framebuffer_remove(&ifbdev->fb->base);

View File

@ -25,7 +25,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/fb.h>
#include <drm/drm_edid.h> #include <drm/drm_edid.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include "intel_drv.h" #include "intel_drv.h"

View File

@ -960,7 +960,7 @@ static uint16_t vlv_compute_wm_level(struct intel_plane *plane,
if (dev_priv->wm.pri_latency[level] == 0) if (dev_priv->wm.pri_latency[level] == 0)
return USHRT_MAX; return USHRT_MAX;
if (!state->visible) if (!state->base.visible)
return 0; return 0;
cpp = drm_format_plane_cpp(state->base.fb->pixel_format, 0); cpp = drm_format_plane_cpp(state->base.fb->pixel_format, 0);
@ -1002,7 +1002,7 @@ static void vlv_compute_fifo(struct intel_crtc *crtc)
if (plane->base.type == DRM_PLANE_TYPE_CURSOR) if (plane->base.type == DRM_PLANE_TYPE_CURSOR)
continue; continue;
if (state->visible) { if (state->base.visible) {
wm_state->num_active_planes++; wm_state->num_active_planes++;
total_rate += drm_format_plane_cpp(state->base.fb->pixel_format, 0); total_rate += drm_format_plane_cpp(state->base.fb->pixel_format, 0);
} }
@ -1018,7 +1018,7 @@ static void vlv_compute_fifo(struct intel_crtc *crtc)
continue; continue;
} }
if (!state->visible) { if (!state->base.visible) {
plane->wm.fifo_size = 0; plane->wm.fifo_size = 0;
continue; continue;
} }
@ -1118,7 +1118,7 @@ static void vlv_compute_wm(struct intel_crtc *crtc)
struct intel_plane_state *state = struct intel_plane_state *state =
to_intel_plane_state(plane->base.state); to_intel_plane_state(plane->base.state);
if (!state->visible) if (!state->base.visible)
continue; continue;
/* normal watermarks */ /* normal watermarks */
@ -1767,7 +1767,7 @@ static uint32_t ilk_compute_pri_wm(const struct intel_crtc_state *cstate,
drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0; drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
uint32_t method1, method2; uint32_t method1, method2;
if (!cstate->base.active || !pstate->visible) if (!cstate->base.active || !pstate->base.visible)
return 0; return 0;
method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value); method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
@ -1777,7 +1777,7 @@ static uint32_t ilk_compute_pri_wm(const struct intel_crtc_state *cstate,
method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate), method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate),
cstate->base.adjusted_mode.crtc_htotal, cstate->base.adjusted_mode.crtc_htotal,
drm_rect_width(&pstate->dst), drm_rect_width(&pstate->base.dst),
cpp, mem_value); cpp, mem_value);
return min(method1, method2); return min(method1, method2);
@ -1795,13 +1795,13 @@ static uint32_t ilk_compute_spr_wm(const struct intel_crtc_state *cstate,
drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0; drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
uint32_t method1, method2; uint32_t method1, method2;
if (!cstate->base.active || !pstate->visible) if (!cstate->base.active || !pstate->base.visible)
return 0; return 0;
method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value); method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate), method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate),
cstate->base.adjusted_mode.crtc_htotal, cstate->base.adjusted_mode.crtc_htotal,
drm_rect_width(&pstate->dst), drm_rect_width(&pstate->base.dst),
cpp, mem_value); cpp, mem_value);
return min(method1, method2); return min(method1, method2);
} }
@ -1820,7 +1820,7 @@ static uint32_t ilk_compute_cur_wm(const struct intel_crtc_state *cstate,
* this is necessary to avoid flickering. * this is necessary to avoid flickering.
*/ */
int cpp = 4; int cpp = 4;
int width = pstate->visible ? pstate->base.crtc_w : 64; int width = pstate->base.visible ? pstate->base.crtc_w : 64;
if (!cstate->base.active) if (!cstate->base.active)
return 0; return 0;
@ -1838,10 +1838,10 @@ static uint32_t ilk_compute_fbc_wm(const struct intel_crtc_state *cstate,
int cpp = pstate->base.fb ? int cpp = pstate->base.fb ?
drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0; drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
if (!cstate->base.active || !pstate->visible) if (!cstate->base.active || !pstate->base.visible)
return 0; return 0;
return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->dst), cpp); return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->base.dst), cpp);
} }
static unsigned int ilk_display_fifo_size(const struct drm_device *dev) static unsigned int ilk_display_fifo_size(const struct drm_device *dev)
@ -2358,10 +2358,10 @@ static int ilk_compute_pipe_wm(struct intel_crtc_state *cstate)
pipe_wm->pipe_enabled = cstate->base.active; pipe_wm->pipe_enabled = cstate->base.active;
if (sprstate) { if (sprstate) {
pipe_wm->sprites_enabled = sprstate->visible; pipe_wm->sprites_enabled = sprstate->base.visible;
pipe_wm->sprites_scaled = sprstate->visible && pipe_wm->sprites_scaled = sprstate->base.visible &&
(drm_rect_width(&sprstate->dst) != drm_rect_width(&sprstate->src) >> 16 || (drm_rect_width(&sprstate->base.dst) != drm_rect_width(&sprstate->base.src) >> 16 ||
drm_rect_height(&sprstate->dst) != drm_rect_height(&sprstate->src) >> 16); drm_rect_height(&sprstate->base.dst) != drm_rect_height(&sprstate->base.src) >> 16);
} }
usable_level = max_level; usable_level = max_level;
@ -2996,14 +2996,14 @@ skl_plane_downscale_amount(const struct intel_plane_state *pstate)
uint32_t downscale_h, downscale_w; uint32_t downscale_h, downscale_w;
uint32_t src_w, src_h, dst_w, dst_h; uint32_t src_w, src_h, dst_w, dst_h;
if (WARN_ON(!pstate->visible)) if (WARN_ON(!pstate->base.visible))
return DRM_PLANE_HELPER_NO_SCALING; return DRM_PLANE_HELPER_NO_SCALING;
/* n.b., src is 16.16 fixed point, dst is whole integer */ /* n.b., src is 16.16 fixed point, dst is whole integer */
src_w = drm_rect_width(&pstate->src); src_w = drm_rect_width(&pstate->base.src);
src_h = drm_rect_height(&pstate->src); src_h = drm_rect_height(&pstate->base.src);
dst_w = drm_rect_width(&pstate->dst); dst_w = drm_rect_width(&pstate->base.dst);
dst_h = drm_rect_height(&pstate->dst); dst_h = drm_rect_height(&pstate->base.dst);
if (intel_rotation_90_or_270(pstate->base.rotation)) if (intel_rotation_90_or_270(pstate->base.rotation))
swap(dst_w, dst_h); swap(dst_w, dst_h);
@ -3025,15 +3025,15 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
uint32_t width = 0, height = 0; uint32_t width = 0, height = 0;
unsigned format = fb ? fb->pixel_format : DRM_FORMAT_XRGB8888; unsigned format = fb ? fb->pixel_format : DRM_FORMAT_XRGB8888;
if (!intel_pstate->visible) if (!intel_pstate->base.visible)
return 0; return 0;
if (pstate->plane->type == DRM_PLANE_TYPE_CURSOR) if (pstate->plane->type == DRM_PLANE_TYPE_CURSOR)
return 0; return 0;
if (y && format != DRM_FORMAT_NV12) if (y && format != DRM_FORMAT_NV12)
return 0; return 0;
width = drm_rect_width(&intel_pstate->src) >> 16; width = drm_rect_width(&intel_pstate->base.src) >> 16;
height = drm_rect_height(&intel_pstate->src) >> 16; height = drm_rect_height(&intel_pstate->base.src) >> 16;
if (intel_rotation_90_or_270(pstate->rotation)) if (intel_rotation_90_or_270(pstate->rotation))
swap(width, height); swap(width, height);
@ -3134,8 +3134,8 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate,
fb->modifier[0] != I915_FORMAT_MOD_Yf_TILED) fb->modifier[0] != I915_FORMAT_MOD_Yf_TILED)
return 8; return 8;
src_w = drm_rect_width(&intel_pstate->src) >> 16; src_w = drm_rect_width(&intel_pstate->base.src) >> 16;
src_h = drm_rect_height(&intel_pstate->src) >> 16; src_h = drm_rect_height(&intel_pstate->base.src) >> 16;
if (intel_rotation_90_or_270(pstate->rotation)) if (intel_rotation_90_or_270(pstate->rotation))
swap(src_w, src_h); swap(src_w, src_h);
@ -3226,7 +3226,7 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
if (intel_plane->pipe != pipe) if (intel_plane->pipe != pipe)
continue; continue;
if (!to_intel_plane_state(pstate)->visible) { if (!to_intel_plane_state(pstate)->base.visible) {
minimum[id] = 0; minimum[id] = 0;
y_minimum[id] = 0; y_minimum[id] = 0;
continue; continue;
@ -3363,7 +3363,7 @@ static uint32_t skl_adjusted_plane_pixel_rate(const struct intel_crtc_state *cst
uint64_t pixel_rate; uint64_t pixel_rate;
/* Shouldn't reach here on disabled planes... */ /* Shouldn't reach here on disabled planes... */
if (WARN_ON(!pstate->visible)) if (WARN_ON(!pstate->base.visible))
return 0; return 0;
/* /*
@ -3399,13 +3399,13 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
uint32_t width = 0, height = 0; uint32_t width = 0, height = 0;
uint32_t plane_pixel_rate; uint32_t plane_pixel_rate;
if (latency == 0 || !cstate->base.active || !intel_pstate->visible) { if (latency == 0 || !cstate->base.active || !intel_pstate->base.visible) {
*enabled = false; *enabled = false;
return 0; return 0;
} }
width = drm_rect_width(&intel_pstate->src) >> 16; width = drm_rect_width(&intel_pstate->base.src) >> 16;
height = drm_rect_height(&intel_pstate->src) >> 16; height = drm_rect_height(&intel_pstate->base.src) >> 16;
if (intel_rotation_90_or_270(pstate->rotation)) if (intel_rotation_90_or_270(pstate->rotation))
swap(width, height); swap(width, height);

View File

@ -211,14 +211,14 @@ skl_update_plane(struct drm_plane *drm_plane,
u32 tile_height, plane_offset, plane_size; u32 tile_height, plane_offset, plane_size;
unsigned int rotation = plane_state->base.rotation; unsigned int rotation = plane_state->base.rotation;
int x_offset, y_offset; int x_offset, y_offset;
int crtc_x = plane_state->dst.x1; int crtc_x = plane_state->base.dst.x1;
int crtc_y = plane_state->dst.y1; int crtc_y = plane_state->base.dst.y1;
uint32_t crtc_w = drm_rect_width(&plane_state->dst); uint32_t crtc_w = drm_rect_width(&plane_state->base.dst);
uint32_t crtc_h = drm_rect_height(&plane_state->dst); uint32_t crtc_h = drm_rect_height(&plane_state->base.dst);
uint32_t x = plane_state->src.x1 >> 16; uint32_t x = plane_state->base.src.x1 >> 16;
uint32_t y = plane_state->src.y1 >> 16; uint32_t y = plane_state->base.src.y1 >> 16;
uint32_t src_w = drm_rect_width(&plane_state->src) >> 16; uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16;
uint32_t src_h = drm_rect_height(&plane_state->src) >> 16; uint32_t src_h = drm_rect_height(&plane_state->base.src) >> 16;
plane_ctl = PLANE_CTL_ENABLE | plane_ctl = PLANE_CTL_ENABLE |
PLANE_CTL_PIPE_GAMMA_ENABLE | PLANE_CTL_PIPE_GAMMA_ENABLE |
@ -370,14 +370,14 @@ vlv_update_plane(struct drm_plane *dplane,
unsigned int rotation = dplane->state->rotation; unsigned int rotation = dplane->state->rotation;
int cpp = drm_format_plane_cpp(fb->pixel_format, 0); int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
int crtc_x = plane_state->dst.x1; int crtc_x = plane_state->base.dst.x1;
int crtc_y = plane_state->dst.y1; int crtc_y = plane_state->base.dst.y1;
uint32_t crtc_w = drm_rect_width(&plane_state->dst); uint32_t crtc_w = drm_rect_width(&plane_state->base.dst);
uint32_t crtc_h = drm_rect_height(&plane_state->dst); uint32_t crtc_h = drm_rect_height(&plane_state->base.dst);
uint32_t x = plane_state->src.x1 >> 16; uint32_t x = plane_state->base.src.x1 >> 16;
uint32_t y = plane_state->src.y1 >> 16; uint32_t y = plane_state->base.src.y1 >> 16;
uint32_t src_w = drm_rect_width(&plane_state->src) >> 16; uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16;
uint32_t src_h = drm_rect_height(&plane_state->src) >> 16; uint32_t src_h = drm_rect_height(&plane_state->base.src) >> 16;
sprctl = SP_ENABLE; sprctl = SP_ENABLE;
@ -444,7 +444,7 @@ vlv_update_plane(struct drm_plane *dplane,
fb->pitches[0], rotation); fb->pitches[0], rotation);
linear_offset -= sprsurf_offset; linear_offset -= sprsurf_offset;
if (rotation == BIT(DRM_ROTATE_180)) { if (rotation == DRM_ROTATE_180) {
sprctl |= SP_ROTATE_180; sprctl |= SP_ROTATE_180;
x += src_w; x += src_w;
@ -512,14 +512,14 @@ ivb_update_plane(struct drm_plane *plane,
unsigned int rotation = plane_state->base.rotation; unsigned int rotation = plane_state->base.rotation;
int cpp = drm_format_plane_cpp(fb->pixel_format, 0); int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
int crtc_x = plane_state->dst.x1; int crtc_x = plane_state->base.dst.x1;
int crtc_y = plane_state->dst.y1; int crtc_y = plane_state->base.dst.y1;
uint32_t crtc_w = drm_rect_width(&plane_state->dst); uint32_t crtc_w = drm_rect_width(&plane_state->base.dst);
uint32_t crtc_h = drm_rect_height(&plane_state->dst); uint32_t crtc_h = drm_rect_height(&plane_state->base.dst);
uint32_t x = plane_state->src.x1 >> 16; uint32_t x = plane_state->base.src.x1 >> 16;
uint32_t y = plane_state->src.y1 >> 16; uint32_t y = plane_state->base.src.y1 >> 16;
uint32_t src_w = drm_rect_width(&plane_state->src) >> 16; uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16;
uint32_t src_h = drm_rect_height(&plane_state->src) >> 16; uint32_t src_h = drm_rect_height(&plane_state->base.src) >> 16;
sprctl = SPRITE_ENABLE; sprctl = SPRITE_ENABLE;
@ -577,7 +577,7 @@ ivb_update_plane(struct drm_plane *plane,
fb->pitches[0], rotation); fb->pitches[0], rotation);
linear_offset -= sprsurf_offset; linear_offset -= sprsurf_offset;
if (rotation == BIT(DRM_ROTATE_180)) { if (rotation == DRM_ROTATE_180) {
sprctl |= SPRITE_ROTATE_180; sprctl |= SPRITE_ROTATE_180;
/* HSW and BDW does this automagically in hardware */ /* HSW and BDW does this automagically in hardware */
@ -653,14 +653,14 @@ ilk_update_plane(struct drm_plane *plane,
unsigned int rotation = plane_state->base.rotation; unsigned int rotation = plane_state->base.rotation;
int cpp = drm_format_plane_cpp(fb->pixel_format, 0); int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
int crtc_x = plane_state->dst.x1; int crtc_x = plane_state->base.dst.x1;
int crtc_y = plane_state->dst.y1; int crtc_y = plane_state->base.dst.y1;
uint32_t crtc_w = drm_rect_width(&plane_state->dst); uint32_t crtc_w = drm_rect_width(&plane_state->base.dst);
uint32_t crtc_h = drm_rect_height(&plane_state->dst); uint32_t crtc_h = drm_rect_height(&plane_state->base.dst);
uint32_t x = plane_state->src.x1 >> 16; uint32_t x = plane_state->base.src.x1 >> 16;
uint32_t y = plane_state->src.y1 >> 16; uint32_t y = plane_state->base.src.y1 >> 16;
uint32_t src_w = drm_rect_width(&plane_state->src) >> 16; uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16;
uint32_t src_h = drm_rect_height(&plane_state->src) >> 16; uint32_t src_h = drm_rect_height(&plane_state->base.src) >> 16;
dvscntr = DVS_ENABLE; dvscntr = DVS_ENABLE;
@ -714,7 +714,7 @@ ilk_update_plane(struct drm_plane *plane,
fb->pitches[0], rotation); fb->pitches[0], rotation);
linear_offset -= dvssurf_offset; linear_offset -= dvssurf_offset;
if (rotation == BIT(DRM_ROTATE_180)) { if (rotation == DRM_ROTATE_180) {
dvscntr |= DVS_ROTATE_180; dvscntr |= DVS_ROTATE_180;
x += src_w; x += src_w;
@ -778,15 +778,25 @@ intel_check_sprite_plane(struct drm_plane *plane,
int crtc_x, crtc_y; int crtc_x, crtc_y;
unsigned int crtc_w, crtc_h; unsigned int crtc_w, crtc_h;
uint32_t src_x, src_y, src_w, src_h; uint32_t src_x, src_y, src_w, src_h;
struct drm_rect *src = &state->src; struct drm_rect *src = &state->base.src;
struct drm_rect *dst = &state->dst; struct drm_rect *dst = &state->base.dst;
const struct drm_rect *clip = &state->clip; const struct drm_rect *clip = &state->clip;
int hscale, vscale; int hscale, vscale;
int max_scale, min_scale; int max_scale, min_scale;
bool can_scale; bool can_scale;
src->x1 = state->base.src_x;
src->y1 = state->base.src_y;
src->x2 = state->base.src_x + state->base.src_w;
src->y2 = state->base.src_y + state->base.src_h;
dst->x1 = state->base.crtc_x;
dst->y1 = state->base.crtc_y;
dst->x2 = state->base.crtc_x + state->base.crtc_w;
dst->y2 = state->base.crtc_y + state->base.crtc_h;
if (!fb) { if (!fb) {
state->visible = false; state->base.visible = false;
return 0; return 0;
} }
@ -834,14 +844,14 @@ intel_check_sprite_plane(struct drm_plane *plane,
vscale = drm_rect_calc_vscale_relaxed(src, dst, min_scale, max_scale); vscale = drm_rect_calc_vscale_relaxed(src, dst, min_scale, max_scale);
BUG_ON(vscale < 0); BUG_ON(vscale < 0);
state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale); state->base.visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
crtc_x = dst->x1; crtc_x = dst->x1;
crtc_y = dst->y1; crtc_y = dst->y1;
crtc_w = drm_rect_width(dst); crtc_w = drm_rect_width(dst);
crtc_h = drm_rect_height(dst); crtc_h = drm_rect_height(dst);
if (state->visible) { if (state->base.visible) {
/* check again in case clipping clamped the results */ /* check again in case clipping clamped the results */
hscale = drm_rect_calc_hscale(src, dst, min_scale, max_scale); hscale = drm_rect_calc_hscale(src, dst, min_scale, max_scale);
if (hscale < 0) { if (hscale < 0) {
@ -898,12 +908,12 @@ intel_check_sprite_plane(struct drm_plane *plane,
crtc_w &= ~1; crtc_w &= ~1;
if (crtc_w == 0) if (crtc_w == 0)
state->visible = false; state->base.visible = false;
} }
} }
/* Check size restrictions when scaling */ /* Check size restrictions when scaling */
if (state->visible && (src_w != crtc_w || src_h != crtc_h)) { if (state->base.visible && (src_w != crtc_w || src_h != crtc_h)) {
unsigned int width_bytes; unsigned int width_bytes;
int cpp = drm_format_plane_cpp(fb->pixel_format, 0); int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
@ -912,10 +922,10 @@ intel_check_sprite_plane(struct drm_plane *plane,
/* FIXME interlacing min height is 6 */ /* FIXME interlacing min height is 6 */
if (crtc_w < 3 || crtc_h < 3) if (crtc_w < 3 || crtc_h < 3)
state->visible = false; state->base.visible = false;
if (src_w < 3 || src_h < 3) if (src_w < 3 || src_h < 3)
state->visible = false; state->base.visible = false;
width_bytes = ((src_x * cpp) & 63) + src_w * cpp; width_bytes = ((src_x * cpp) & 63) + src_w * cpp;
@ -926,7 +936,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
} }
} }
if (state->visible) { if (state->base.visible) {
src->x1 = src_x << 16; src->x1 = src_x << 16;
src->x2 = (src_x + src_w) << 16; src->x2 = (src_x + src_w) << 16;
src->y1 = src_y << 16; src->y1 = src_y << 16;

View File

@ -16,7 +16,6 @@
#include <linux/component.h> #include <linux/component.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/dma-buf.h> #include <linux/dma-buf.h>
#include <linux/fb.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/reservation.h> #include <linux/reservation.h>

View File

@ -21,7 +21,6 @@
#include <drm/drm_atomic.h> #include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <linux/fb.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_cma_helper.h>

View File

@ -31,7 +31,7 @@
* struct mtk_drm_crtc - MediaTek specific crtc structure. * struct mtk_drm_crtc - MediaTek specific crtc structure.
* @base: crtc object. * @base: crtc object.
* @enabled: records whether crtc_enable succeeded * @enabled: records whether crtc_enable succeeded
* @planes: array of 4 mtk_drm_plane structures, one for each overlay plane * @planes: array of 4 drm_plane structures, one for each overlay plane
* @pending_planes: whether any plane has pending changes to be applied * @pending_planes: whether any plane has pending changes to be applied
* @config_regs: memory mapped mmsys configuration register space * @config_regs: memory mapped mmsys configuration register space
* @mutex: handle to one of the ten disp_mutex streams * @mutex: handle to one of the ten disp_mutex streams
@ -45,7 +45,7 @@ struct mtk_drm_crtc {
bool pending_needs_vblank; bool pending_needs_vblank;
struct drm_pending_vblank_event *event; struct drm_pending_vblank_event *event;
struct mtk_drm_plane planes[OVL_LAYER_NR]; struct drm_plane planes[OVL_LAYER_NR];
bool pending_planes; bool pending_planes;
void __iomem *config_regs; void __iomem *config_regs;
@ -112,8 +112,7 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
struct mtk_crtc_state *state; struct mtk_crtc_state *state;
if (crtc->state) { if (crtc->state) {
if (crtc->state->mode_blob) __drm_atomic_helper_crtc_destroy_state(crtc->state);
drm_property_unreference_blob(crtc->state->mode_blob);
state = to_mtk_crtc_state(crtc->state); state = to_mtk_crtc_state(crtc->state);
memset(state, 0, sizeof(*state)); memset(state, 0, sizeof(*state));
@ -287,7 +286,7 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc)
/* Initially configure all planes */ /* Initially configure all planes */
for (i = 0; i < OVL_LAYER_NR; i++) { for (i = 0; i < OVL_LAYER_NR; i++) {
struct drm_plane *plane = &mtk_crtc->planes[i].base; struct drm_plane *plane = &mtk_crtc->planes[i];
struct mtk_plane_state *plane_state; struct mtk_plane_state *plane_state;
plane_state = to_mtk_plane_state(plane->state); plane_state = to_mtk_plane_state(plane->state);
@ -366,7 +365,7 @@ static void mtk_drm_crtc_disable(struct drm_crtc *crtc)
/* Set all pending plane state to disabled */ /* Set all pending plane state to disabled */
for (i = 0; i < OVL_LAYER_NR; i++) { for (i = 0; i < OVL_LAYER_NR; i++) {
struct drm_plane *plane = &mtk_crtc->planes[i].base; struct drm_plane *plane = &mtk_crtc->planes[i];
struct mtk_plane_state *plane_state; struct mtk_plane_state *plane_state;
plane_state = to_mtk_plane_state(plane->state); plane_state = to_mtk_plane_state(plane->state);
@ -412,7 +411,7 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
if (mtk_crtc->event) if (mtk_crtc->event)
mtk_crtc->pending_needs_vblank = true; mtk_crtc->pending_needs_vblank = true;
for (i = 0; i < OVL_LAYER_NR; i++) { for (i = 0; i < OVL_LAYER_NR; i++) {
struct drm_plane *plane = &mtk_crtc->planes[i].base; struct drm_plane *plane = &mtk_crtc->planes[i];
struct mtk_plane_state *plane_state; struct mtk_plane_state *plane_state;
plane_state = to_mtk_plane_state(plane->state); plane_state = to_mtk_plane_state(plane->state);
@ -490,7 +489,7 @@ void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *ovl)
if (mtk_crtc->pending_planes) { if (mtk_crtc->pending_planes) {
for (i = 0; i < OVL_LAYER_NR; i++) { for (i = 0; i < OVL_LAYER_NR; i++) {
struct drm_plane *plane = &mtk_crtc->planes[i].base; struct drm_plane *plane = &mtk_crtc->planes[i];
struct mtk_plane_state *plane_state; struct mtk_plane_state *plane_state;
plane_state = to_mtk_plane_state(plane->state); plane_state = to_mtk_plane_state(plane->state);
@ -578,13 +577,13 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
(zpos == 1) ? DRM_PLANE_TYPE_CURSOR : (zpos == 1) ? DRM_PLANE_TYPE_CURSOR :
DRM_PLANE_TYPE_OVERLAY; DRM_PLANE_TYPE_OVERLAY;
ret = mtk_plane_init(drm_dev, &mtk_crtc->planes[zpos], ret = mtk_plane_init(drm_dev, &mtk_crtc->planes[zpos],
BIT(pipe), type, zpos); BIT(pipe), type);
if (ret) if (ret)
goto unprepare; goto unprepare;
} }
ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0].base, ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
&mtk_crtc->planes[1].base, pipe); &mtk_crtc->planes[1], pipe);
if (ret < 0) if (ret < 0)
goto unprepare; goto unprepare;
drm_mode_crtc_set_gamma_size(&mtk_crtc->base, MTK_LUT_SIZE); drm_mode_crtc_set_gamma_size(&mtk_crtc->base, MTK_LUT_SIZE);

View File

@ -25,7 +25,6 @@
int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe); int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe);
void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe); void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe);
void mtk_drm_crtc_check_flush(struct drm_crtc *crtc);
void mtk_drm_crtc_commit(struct drm_crtc *crtc); void mtk_drm_crtc_commit(struct drm_crtc *crtc);
void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *ovl); void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *ovl);
int mtk_drm_crtc_create(struct drm_device *drm_dev, int mtk_drm_crtc_create(struct drm_device *drm_dev,

View File

@ -61,10 +61,25 @@ static void mtk_atomic_complete(struct mtk_drm_private *private,
mtk_atomic_wait_for_fences(state); mtk_atomic_wait_for_fences(state);
/*
* Mediatek drm supports runtime PM, so plane registers cannot be
* written when their crtc is disabled.
*
* The comment for drm_atomic_helper_commit states:
* For drivers supporting runtime PM the recommended sequence is
*
* drm_atomic_helper_commit_modeset_disables(dev, state);
* drm_atomic_helper_commit_modeset_enables(dev, state);
* drm_atomic_helper_commit_planes(dev, state, true);
*
* See the kerneldoc entries for these three functions for more details.
*/
drm_atomic_helper_commit_modeset_disables(drm, state); drm_atomic_helper_commit_modeset_disables(drm, state);
drm_atomic_helper_commit_planes(drm, state, false);
drm_atomic_helper_commit_modeset_enables(drm, state); drm_atomic_helper_commit_modeset_enables(drm, state);
drm_atomic_helper_commit_planes(drm, state, true);
drm_atomic_helper_wait_for_vblanks(drm, state); drm_atomic_helper_wait_for_vblanks(drm, state);
drm_atomic_helper_cleanup_planes(drm, state); drm_atomic_helper_cleanup_planes(drm, state);
drm_atomic_state_free(state); drm_atomic_state_free(state);
} }

View File

@ -30,57 +30,12 @@ static const u32 formats[] = {
DRM_FORMAT_RGB565, DRM_FORMAT_RGB565,
}; };
static void mtk_plane_enable(struct mtk_drm_plane *mtk_plane, bool enable,
dma_addr_t addr, struct drm_rect *dest)
{
struct drm_plane *plane = &mtk_plane->base;
struct mtk_plane_state *state = to_mtk_plane_state(plane->state);
unsigned int pitch, format;
int x, y;
if (WARN_ON(!plane->state || (enable && !plane->state->fb)))
return;
if (plane->state->fb) {
pitch = plane->state->fb->pitches[0];
format = plane->state->fb->pixel_format;
} else {
pitch = 0;
format = DRM_FORMAT_RGBA8888;
}
x = plane->state->crtc_x;
y = plane->state->crtc_y;
if (x < 0) {
addr -= x * 4;
x = 0;
}
if (y < 0) {
addr -= y * pitch;
y = 0;
}
state->pending.enable = enable;
state->pending.pitch = pitch;
state->pending.format = format;
state->pending.addr = addr;
state->pending.x = x;
state->pending.y = y;
state->pending.width = dest->x2 - dest->x1;
state->pending.height = dest->y2 - dest->y1;
wmb(); /* Make sure the above parameters are set before update */
state->pending.dirty = true;
}
static void mtk_plane_reset(struct drm_plane *plane) static void mtk_plane_reset(struct drm_plane *plane)
{ {
struct mtk_plane_state *state; struct mtk_plane_state *state;
if (plane->state) { if (plane->state) {
if (plane->state->fb) __drm_atomic_helper_plane_destroy_state(plane->state);
drm_framebuffer_unreference(plane->state->fb);
state = to_mtk_plane_state(plane->state); state = to_mtk_plane_state(plane->state);
memset(state, 0, sizeof(*state)); memset(state, 0, sizeof(*state));
@ -134,20 +89,6 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
{ {
struct drm_framebuffer *fb = state->fb; struct drm_framebuffer *fb = state->fb;
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
bool visible;
struct drm_rect dest = {
.x1 = state->crtc_x,
.y1 = state->crtc_y,
.x2 = state->crtc_x + state->crtc_w,
.y2 = state->crtc_y + state->crtc_h,
};
struct drm_rect src = {
/* 16.16 fixed point */
.x1 = state->src_x,
.y1 = state->src_y,
.x2 = state->src_x + state->src_w,
.y2 = state->src_y + state->src_h,
};
struct drm_rect clip = { 0, }; struct drm_rect clip = { 0, };
if (!fb) if (!fb)
@ -168,40 +109,45 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
clip.x2 = crtc_state->mode.hdisplay; clip.x2 = crtc_state->mode.hdisplay;
clip.y2 = crtc_state->mode.vdisplay; clip.y2 = crtc_state->mode.vdisplay;
return drm_plane_helper_check_update(plane, state->crtc, fb, return drm_plane_helper_check_state(state, &clip,
&src, &dest, &clip, DRM_PLANE_HELPER_NO_SCALING,
state->rotation, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, true, true);
DRM_PLANE_HELPER_NO_SCALING,
true, true, &visible);
} }
static void mtk_plane_atomic_update(struct drm_plane *plane, static void mtk_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state) struct drm_plane_state *old_state)
{ {
struct mtk_plane_state *state = to_mtk_plane_state(plane->state); struct mtk_plane_state *state = to_mtk_plane_state(plane->state);
struct drm_crtc *crtc = state->base.crtc; struct drm_crtc *crtc = plane->state->crtc;
struct drm_framebuffer *fb = plane->state->fb;
struct drm_gem_object *gem; struct drm_gem_object *gem;
struct mtk_drm_gem_obj *mtk_gem; struct mtk_drm_gem_obj *mtk_gem;
struct mtk_drm_plane *mtk_plane = to_mtk_plane(plane); unsigned int pitch, format;
struct drm_rect dest = { dma_addr_t addr;
.x1 = state->base.crtc_x,
.y1 = state->base.crtc_y,
.x2 = state->base.crtc_x + state->base.crtc_w,
.y2 = state->base.crtc_y + state->base.crtc_h,
};
struct drm_rect clip = { 0, };
if (!crtc) if (!crtc || WARN_ON(!fb))
return; return;
clip.x2 = state->base.crtc->state->mode.hdisplay; gem = mtk_fb_get_gem_obj(fb);
clip.y2 = state->base.crtc->state->mode.vdisplay;
drm_rect_intersect(&dest, &clip);
gem = mtk_fb_get_gem_obj(state->base.fb);
mtk_gem = to_mtk_gem_obj(gem); mtk_gem = to_mtk_gem_obj(gem);
mtk_plane_enable(mtk_plane, true, mtk_gem->dma_addr, &dest); addr = mtk_gem->dma_addr;
pitch = fb->pitches[0];
format = fb->pixel_format;
addr += (plane->state->src.x1 >> 16) * drm_format_plane_cpp(format, 0);
addr += (plane->state->src.y1 >> 16) * pitch;
state->pending.enable = true;
state->pending.pitch = pitch;
state->pending.format = format;
state->pending.addr = addr;
state->pending.x = plane->state->dst.x1;
state->pending.y = plane->state->dst.y1;
state->pending.width = drm_rect_width(&plane->state->dst);
state->pending.height = drm_rect_height(&plane->state->dst);
wmb(); /* Make sure the above parameters are set before update */
state->pending.dirty = true;
} }
static void mtk_plane_atomic_disable(struct drm_plane *plane, static void mtk_plane_atomic_disable(struct drm_plane *plane,
@ -220,13 +166,12 @@ static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = {
.atomic_disable = mtk_plane_atomic_disable, .atomic_disable = mtk_plane_atomic_disable,
}; };
int mtk_plane_init(struct drm_device *dev, struct mtk_drm_plane *mtk_plane, int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
unsigned long possible_crtcs, enum drm_plane_type type, unsigned long possible_crtcs, enum drm_plane_type type)
unsigned int zpos)
{ {
int err; int err;
err = drm_universal_plane_init(dev, &mtk_plane->base, possible_crtcs, err = drm_universal_plane_init(dev, plane, possible_crtcs,
&mtk_plane_funcs, formats, &mtk_plane_funcs, formats,
ARRAY_SIZE(formats), type, NULL); ARRAY_SIZE(formats), type, NULL);
if (err) { if (err) {
@ -234,8 +179,7 @@ int mtk_plane_init(struct drm_device *dev, struct mtk_drm_plane *mtk_plane,
return err; return err;
} }
drm_plane_helper_add(&mtk_plane->base, &mtk_plane_helper_funcs); drm_plane_helper_add(plane, &mtk_plane_helper_funcs);
mtk_plane->idx = zpos;
return 0; return 0;
} }

View File

@ -18,11 +18,6 @@
#include <drm/drm_crtc.h> #include <drm/drm_crtc.h>
#include <linux/types.h> #include <linux/types.h>
struct mtk_drm_plane {
struct drm_plane base;
unsigned int idx;
};
struct mtk_plane_pending_state { struct mtk_plane_pending_state {
bool config; bool config;
bool enable; bool enable;
@ -41,19 +36,13 @@ struct mtk_plane_state {
struct mtk_plane_pending_state pending; struct mtk_plane_pending_state pending;
}; };
static inline struct mtk_drm_plane *to_mtk_plane(struct drm_plane *plane)
{
return container_of(plane, struct mtk_drm_plane, base);
}
static inline struct mtk_plane_state * static inline struct mtk_plane_state *
to_mtk_plane_state(struct drm_plane_state *state) to_mtk_plane_state(struct drm_plane_state *state)
{ {
return container_of(state, struct mtk_plane_state, base); return container_of(state, struct mtk_plane_state, base);
} }
int mtk_plane_init(struct drm_device *dev, struct mtk_drm_plane *mtk_plane, int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
unsigned long possible_crtcs, enum drm_plane_type type, unsigned long possible_crtcs, enum drm_plane_type type);
unsigned int zpos);
#endif #endif

View File

@ -58,7 +58,7 @@ static const struct file_operations mga_driver_fops = {
static struct drm_driver driver = { static struct drm_driver driver = {
.driver_features = .driver_features =
DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_LEGACY |
DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
.dev_priv_size = sizeof(drm_mga_buf_priv_t), .dev_priv_size = sizeof(drm_mga_buf_priv_t),
.load = mga_driver_load, .load = mga_driver_load,

View File

@ -56,7 +56,7 @@ static void mgag200_kick_out_firmware_fb(struct pci_dev *pdev)
#ifdef CONFIG_X86 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
#endif #endif
remove_conflicting_framebuffers(ap, "mgag200drmfb", primary); drm_fb_helper_remove_conflicting_framebuffers(ap, "mgag200drmfb", primary);
kfree(ap); kfree(ap);
} }

View File

@ -15,8 +15,6 @@
#include <drm/drm_fb_helper.h> #include <drm/drm_fb_helper.h>
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <linux/fb.h>
#include "mgag200_drv.h" #include "mgag200_drv.h"
static void mga_dirty_update(struct mga_fbdev *mfbdev, static void mga_dirty_update(struct mga_fbdev *mfbdev,

View File

@ -135,7 +135,7 @@ static int mga_vram_init(struct mga_device *mdev)
aper->ranges[0].base = mdev->mc.vram_base; aper->ranges[0].base = mdev->mc.vram_base;
aper->ranges[0].size = mdev->mc.vram_window; aper->ranges[0].size = mdev->mc.vram_window;
remove_conflicting_framebuffers(aper, "mgafb", true); drm_fb_helper_remove_conflicting_framebuffers(aper, "mgafb", true);
kfree(aper); kfree(aper);
if (!devm_request_mem_region(mdev->dev->dev, mdev->mc.vram_base, mdev->mc.vram_window, if (!devm_request_mem_region(mdev->dev->dev, mdev->mc.vram_base, mdev->mc.vram_window,

View File

@ -78,7 +78,7 @@ static void mdp5_plane_install_rotation_property(struct drm_device *dev,
if (!dev->mode_config.rotation_property) if (!dev->mode_config.rotation_property)
dev->mode_config.rotation_property = dev->mode_config.rotation_property =
drm_mode_create_rotation_property(dev, drm_mode_create_rotation_property(dev,
BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y)); DRM_REFLECT_X | DRM_REFLECT_Y);
if (dev->mode_config.rotation_property) if (dev->mode_config.rotation_property)
drm_object_attach_property(&plane->base, drm_object_attach_property(&plane->base,
@ -309,8 +309,8 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
return -EINVAL; return -EINVAL;
} }
hflip = !!(state->rotation & BIT(DRM_REFLECT_X)); hflip = !!(state->rotation & DRM_REFLECT_X);
vflip = !!(state->rotation & BIT(DRM_REFLECT_Y)); vflip = !!(state->rotation & DRM_REFLECT_Y);
if ((vflip && !(mdp5_plane->caps & MDP_PIPE_CAP_VFLIP)) || if ((vflip && !(mdp5_plane->caps & MDP_PIPE_CAP_VFLIP)) ||
(hflip && !(mdp5_plane->caps & MDP_PIPE_CAP_HFLIP))) { (hflip && !(mdp5_plane->caps & MDP_PIPE_CAP_HFLIP))) {
dev_err(plane->dev->dev, dev_err(plane->dev->dev,
@ -743,8 +743,8 @@ static int mdp5_plane_mode_set(struct drm_plane *plane,
config |= get_scale_config(format, src_h, crtc_h, false); config |= get_scale_config(format, src_h, crtc_h, false);
DBG("scale config = %x", config); DBG("scale config = %x", config);
hflip = !!(pstate->rotation & BIT(DRM_REFLECT_X)); hflip = !!(pstate->rotation & DRM_REFLECT_X);
vflip = !!(pstate->rotation & BIT(DRM_REFLECT_Y)); vflip = !!(pstate->rotation & DRM_REFLECT_Y);
spin_lock_irqsave(&mdp5_plane->pipe_lock, flags); spin_lock_irqsave(&mdp5_plane->pipe_lock, flags);

View File

@ -351,7 +351,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
boot = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; boot = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
#endif #endif
if (nouveau_modeset != 2) if (nouveau_modeset != 2)
remove_conflicting_framebuffers(aper, "nouveaufb", boot); drm_fb_helper_remove_conflicting_framebuffers(aper, "nouveaufb", boot);
kfree(aper); kfree(aper);
ret = nvkm_device_pci_new(pdev, nouveau_config, nouveau_debug, ret = nvkm_device_pci_new(pdev, nouveau_config, nouveau_debug,

View File

@ -32,7 +32,6 @@
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/sysrq.h> #include <linux/sysrq.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/fb.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/screen_info.h> #include <linux/screen_info.h>
#include <linux/vga_switcheroo.h> #include <linux/vga_switcheroo.h>

View File

@ -13,7 +13,6 @@
#include <linux/backlight.h> #include <linux/backlight.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/fb.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>

View File

@ -14,7 +14,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/fb.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>

View File

@ -28,7 +28,6 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/backlight.h> #include <linux/backlight.h>
#include <linux/fb.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>

View File

@ -125,16 +125,15 @@ u32 dss_of_port_get_port_number(struct device_node *port)
static struct device_node *omapdss_of_get_remote_port(const struct device_node *node) static struct device_node *omapdss_of_get_remote_port(const struct device_node *node)
{ {
struct device_node *np, *np_parent; struct device_node *np;
np = of_parse_phandle(node, "remote-endpoint", 0); np = of_parse_phandle(node, "remote-endpoint", 0);
if (!np) if (!np)
return NULL; return NULL;
np_parent = of_get_next_parent(np); np = of_get_next_parent(np);
of_node_put(np);
return np_parent; return np;
} }
struct device_node * struct device_node *

View File

@ -295,9 +295,9 @@ static int omap_modeset_init_properties(struct drm_device *dev)
if (priv->has_dmm) { if (priv->has_dmm) {
dev->mode_config.rotation_property = dev->mode_config.rotation_property =
drm_mode_create_rotation_property(dev, drm_mode_create_rotation_property(dev,
BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_90) | DRM_ROTATE_0 | DRM_ROTATE_90 |
BIT(DRM_ROTATE_180) | BIT(DRM_ROTATE_270) | DRM_ROTATE_180 | DRM_ROTATE_270 |
BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y)); DRM_REFLECT_X | DRM_REFLECT_Y);
if (!dev->mode_config.rotation_property) if (!dev->mode_config.rotation_property)
return -ENOMEM; return -ENOMEM;
} }

View File

@ -179,24 +179,24 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
(uint32_t)win->rotation); (uint32_t)win->rotation);
/* fallthru to default to no rotation */ /* fallthru to default to no rotation */
case 0: case 0:
case BIT(DRM_ROTATE_0): case DRM_ROTATE_0:
orient = 0; orient = 0;
break; break;
case BIT(DRM_ROTATE_90): case DRM_ROTATE_90:
orient = MASK_XY_FLIP | MASK_X_INVERT; orient = MASK_XY_FLIP | MASK_X_INVERT;
break; break;
case BIT(DRM_ROTATE_180): case DRM_ROTATE_180:
orient = MASK_X_INVERT | MASK_Y_INVERT; orient = MASK_X_INVERT | MASK_Y_INVERT;
break; break;
case BIT(DRM_ROTATE_270): case DRM_ROTATE_270:
orient = MASK_XY_FLIP | MASK_Y_INVERT; orient = MASK_XY_FLIP | MASK_Y_INVERT;
break; break;
} }
if (win->rotation & BIT(DRM_REFLECT_X)) if (win->rotation & DRM_REFLECT_X)
orient ^= MASK_X_INVERT; orient ^= MASK_X_INVERT;
if (win->rotation & BIT(DRM_REFLECT_Y)) if (win->rotation & DRM_REFLECT_Y)
orient ^= MASK_Y_INVERT; orient ^= MASK_Y_INVERT;
/* adjust x,y offset for flip/invert: */ /* adjust x,y offset for flip/invert: */
@ -213,7 +213,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
} else { } else {
switch (win->rotation & DRM_ROTATE_MASK) { switch (win->rotation & DRM_ROTATE_MASK) {
case 0: case 0:
case BIT(DRM_ROTATE_0): case DRM_ROTATE_0:
/* OK */ /* OK */
break; break;

View File

@ -109,8 +109,8 @@ static void omap_plane_atomic_update(struct drm_plane *plane,
win.src_y = state->src_y >> 16; win.src_y = state->src_y >> 16;
switch (state->rotation & DRM_ROTATE_MASK) { switch (state->rotation & DRM_ROTATE_MASK) {
case BIT(DRM_ROTATE_90): case DRM_ROTATE_90:
case BIT(DRM_ROTATE_270): case DRM_ROTATE_270:
win.src_w = state->src_h >> 16; win.src_w = state->src_h >> 16;
win.src_h = state->src_w >> 16; win.src_h = state->src_w >> 16;
break; break;
@ -149,7 +149,7 @@ static void omap_plane_atomic_disable(struct drm_plane *plane,
struct omap_plane_state *omap_state = to_omap_plane_state(plane->state); struct omap_plane_state *omap_state = to_omap_plane_state(plane->state);
struct omap_plane *omap_plane = to_omap_plane(plane); struct omap_plane *omap_plane = to_omap_plane(plane);
plane->state->rotation = BIT(DRM_ROTATE_0); plane->state->rotation = DRM_ROTATE_0;
omap_state->zorder = plane->type == DRM_PLANE_TYPE_PRIMARY omap_state->zorder = plane->type == DRM_PLANE_TYPE_PRIMARY
? 0 : omap_plane->id; ? 0 : omap_plane->id;
@ -178,7 +178,7 @@ static int omap_plane_atomic_check(struct drm_plane *plane,
return -EINVAL; return -EINVAL;
if (state->fb) { if (state->fb) {
if (state->rotation != BIT(DRM_ROTATE_0) && if (state->rotation != DRM_ROTATE_0 &&
!omap_framebuffer_supports_rotation(state->fb)) !omap_framebuffer_supports_rotation(state->fb))
return -EINVAL; return -EINVAL;
} }
@ -269,7 +269,7 @@ static void omap_plane_reset(struct drm_plane *plane)
*/ */
omap_state->zorder = plane->type == DRM_PLANE_TYPE_PRIMARY omap_state->zorder = plane->type == DRM_PLANE_TYPE_PRIMARY
? 0 : omap_plane->id; ? 0 : omap_plane->id;
omap_state->base.rotation = BIT(DRM_ROTATE_0); omap_state->base.rotation = DRM_ROTATE_0;
plane->state = &omap_state->base; plane->state = &omap_state->base;
plane->state->plane = plane; plane->state->plane = plane;

View File

@ -24,7 +24,6 @@
* David Airlie * David Airlie
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/fb.h>
#include "drmP.h" #include "drmP.h"
#include "drm/drm.h" #include "drm/drm.h"
@ -73,10 +72,12 @@ static void qxl_fb_image_init(struct qxl_fb_image *qxl_fb_image,
} }
} }
#ifdef CONFIG_DRM_FBDEV_EMULATION
static struct fb_deferred_io qxl_defio = { static struct fb_deferred_io qxl_defio = {
.delay = QXL_DIRTY_DELAY, .delay = QXL_DIRTY_DELAY,
.deferred_io = drm_fb_helper_deferred_io, .deferred_io = drm_fb_helper_deferred_io,
}; };
#endif
static struct fb_ops qxlfb_ops = { static struct fb_ops qxlfb_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
@ -313,8 +314,10 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
goto out_destroy_fbi; goto out_destroy_fbi;
} }
#ifdef CONFIG_DRM_FBDEV_EMULATION
info->fbdefio = &qxl_defio; info->fbdefio = &qxl_defio;
fb_deferred_io_init(info); fb_deferred_io_init(info);
#endif
qdev->fbdev_info = info; qdev->fbdev_info = info;
qdev->fbdev_qfb = &qfbdev->qfb; qdev->fbdev_qfb = &qfbdev->qfb;

View File

@ -56,7 +56,7 @@ static const struct file_operations r128_driver_fops = {
static struct drm_driver driver = { static struct drm_driver driver = {
.driver_features = .driver_features =
DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_LEGACY |
DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
.dev_priv_size = sizeof(drm_r128_buf_priv_t), .dev_priv_size = sizeof(drm_r128_buf_priv_t),
.load = r128_driver_load, .load = r128_driver_load,

View File

@ -39,6 +39,7 @@
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/vga_switcheroo.h> #include <linux/vga_switcheroo.h>
#include <drm/drm_gem.h> #include <drm/drm_gem.h>
#include <drm/drm_fb_helper.h>
#include "drm_crtc_helper.h" #include "drm_crtc_helper.h"
#include "radeon_kfd.h" #include "radeon_kfd.h"
@ -324,7 +325,7 @@ static int radeon_kick_out_firmware_fb(struct pci_dev *pdev)
#ifdef CONFIG_X86 #ifdef CONFIG_X86
primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
#endif #endif
remove_conflicting_framebuffers(ap, "radeondrmfb", primary); drm_fb_helper_remove_conflicting_framebuffers(ap, "radeondrmfb", primary);
kfree(ap); kfree(ap);
return 0; return 0;

View File

@ -25,7 +25,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/fb.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include <drm/drm_crtc.h> #include <drm/drm_crtc.h>
@ -383,7 +382,7 @@ void radeon_fbdev_fini(struct radeon_device *rdev)
void radeon_fbdev_set_suspend(struct radeon_device *rdev, int state) void radeon_fbdev_set_suspend(struct radeon_device *rdev, int state)
{ {
if (rdev->mode_info.rfbdev) if (rdev->mode_info.rfbdev)
fb_set_suspend(rdev->mode_info.rfbdev->helper.fbdev, state); drm_fb_helper_set_suspend(&rdev->mode_info.rfbdev->helper, state);
} }
bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj) bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj)

View File

@ -87,8 +87,6 @@
struct vop_plane_state { struct vop_plane_state {
struct drm_plane_state base; struct drm_plane_state base;
int format; int format;
struct drm_rect src;
struct drm_rect dest;
dma_addr_t yrgb_mst; dma_addr_t yrgb_mst;
bool enable; bool enable;
}; };
@ -593,10 +591,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
struct vop_win *vop_win = to_vop_win(plane); struct vop_win *vop_win = to_vop_win(plane);
struct vop_plane_state *vop_plane_state = to_vop_plane_state(state); struct vop_plane_state *vop_plane_state = to_vop_plane_state(state);
const struct vop_win_data *win = vop_win->data; const struct vop_win_data *win = vop_win->data;
bool visible;
int ret; int ret;
struct drm_rect *dest = &vop_plane_state->dest;
struct drm_rect *src = &vop_plane_state->src;
struct drm_rect clip; struct drm_rect clip;
int min_scale = win->phy->scl ? FRAC_16_16(1, 8) : int min_scale = win->phy->scl ? FRAC_16_16(1, 8) :
DRM_PLANE_HELPER_NO_SCALING; DRM_PLANE_HELPER_NO_SCALING;
@ -610,30 +605,18 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
if (WARN_ON(!crtc_state)) if (WARN_ON(!crtc_state))
return -EINVAL; return -EINVAL;
src->x1 = state->src_x;
src->y1 = state->src_y;
src->x2 = state->src_x + state->src_w;
src->y2 = state->src_y + state->src_h;
dest->x1 = state->crtc_x;
dest->y1 = state->crtc_y;
dest->x2 = state->crtc_x + state->crtc_w;
dest->y2 = state->crtc_y + state->crtc_h;
clip.x1 = 0; clip.x1 = 0;
clip.y1 = 0; clip.y1 = 0;
clip.x2 = crtc_state->adjusted_mode.hdisplay; clip.x2 = crtc_state->adjusted_mode.hdisplay;
clip.y2 = crtc_state->adjusted_mode.vdisplay; clip.y2 = crtc_state->adjusted_mode.vdisplay;
ret = drm_plane_helper_check_update(plane, crtc, state->fb, ret = drm_plane_helper_check_state(state, &clip,
src, dest, &clip, min_scale, max_scale,
state->rotation, true, true);
min_scale,
max_scale,
true, true, &visible);
if (ret) if (ret)
return ret; return ret;
if (!visible) if (!state->visible)
goto out_disable; goto out_disable;
vop_plane_state->format = vop_convert_format(fb->pixel_format); vop_plane_state->format = vop_convert_format(fb->pixel_format);
@ -644,7 +627,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
* Src.x1 can be odd when do clip, but yuv plane start point * Src.x1 can be odd when do clip, but yuv plane start point
* need align with 2 pixel. * need align with 2 pixel.
*/ */
if (is_yuv_support(fb->pixel_format) && ((src->x1 >> 16) % 2)) if (is_yuv_support(fb->pixel_format) && ((state->src.x1 >> 16) % 2))
return -EINVAL; return -EINVAL;
vop_plane_state->enable = true; vop_plane_state->enable = true;
@ -694,8 +677,8 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
unsigned int actual_w, actual_h; unsigned int actual_w, actual_h;
unsigned int dsp_stx, dsp_sty; unsigned int dsp_stx, dsp_sty;
uint32_t act_info, dsp_info, dsp_st; uint32_t act_info, dsp_info, dsp_st;
struct drm_rect *src = &vop_plane_state->src; struct drm_rect *src = &state->src;
struct drm_rect *dest = &vop_plane_state->dest; struct drm_rect *dest = &state->dst;
struct drm_gem_object *obj, *uv_obj; struct drm_gem_object *obj, *uv_obj;
struct rockchip_gem_object *rk_obj, *rk_uv_obj; struct rockchip_gem_object *rk_obj, *rk_uv_obj;
unsigned long offset; unsigned long offset;

View File

@ -50,7 +50,7 @@ static const struct file_operations savage_driver_fops = {
static struct drm_driver driver = { static struct drm_driver driver = {
.driver_features = .driver_features =
DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA, DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA | DRIVER_LEGACY,
.dev_priv_size = sizeof(drm_savage_buf_priv_t), .dev_priv_size = sizeof(drm_savage_buf_priv_t),
.load = savage_driver_load, .load = savage_driver_load,
.firstopen = savage_driver_firstopen, .firstopen = savage_driver_firstopen,

View File

@ -102,7 +102,7 @@ static void sis_driver_postclose(struct drm_device *dev, struct drm_file *file)
} }
static struct drm_driver driver = { static struct drm_driver driver = {
.driver_features = DRIVER_USE_AGP, .driver_features = DRIVER_USE_AGP | DRIVER_LEGACY,
.load = sis_driver_load, .load = sis_driver_load,
.unload = sis_driver_unload, .unload = sis_driver_unload,
.open = sis_driver_open, .open = sis_driver_open,

View File

@ -17,6 +17,7 @@
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_fb_cma_helper.h> #include <drm/drm_fb_cma_helper.h>
#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
#include <drm/drm_fb_helper.h>
#include "sun4i_crtc.h" #include "sun4i_crtc.h"
#include "sun4i_drv.h" #include "sun4i_drv.h"
@ -109,7 +110,7 @@ static void sun4i_remove_framebuffers(void)
ap->ranges[0].base = 0; ap->ranges[0].base = 0;
ap->ranges[0].size = ~0; ap->ranges[0].size = ~0;
remove_conflicting_framebuffers(ap, "sun4i-drm-fb", false); drm_fb_helper_remove_conflicting_framebuffers(ap, "sun4i-drm-fb", false);
kfree(ap); kfree(ap);
} }

View File

@ -56,6 +56,7 @@ static const struct file_operations tdfx_driver_fops = {
}; };
static struct drm_driver driver = { static struct drm_driver driver = {
.driver_features = DRIVER_LEGACY,
.set_busid = drm_pci_set_busid, .set_busid = drm_pci_set_busid,
.fops = &tdfx_driver_fops, .fops = &tdfx_driver_fops,
.name = DRIVER_NAME, .name = DRIVER_NAME,

View File

@ -203,6 +203,7 @@ static int udl_fb_open(struct fb_info *info, int user)
ufbdev->fb_count++; ufbdev->fb_count++;
#ifdef CONFIG_DRM_FBDEV_EMULATION
if (fb_defio && (info->fbdefio == NULL)) { if (fb_defio && (info->fbdefio == NULL)) {
/* enable defio at last moment if not disabled by client */ /* enable defio at last moment if not disabled by client */
@ -218,6 +219,7 @@ static int udl_fb_open(struct fb_info *info, int user)
info->fbdefio = fbdefio; info->fbdefio = fbdefio;
fb_deferred_io_init(info); fb_deferred_io_init(info);
} }
#endif
pr_notice("open /dev/fb%d user=%d fb_info=%p count=%d\n", pr_notice("open /dev/fb%d user=%d fb_info=%p count=%d\n",
info->node, user, info, ufbdev->fb_count); info->node, user, info, ufbdev->fb_count);
@ -235,12 +237,14 @@ static int udl_fb_release(struct fb_info *info, int user)
ufbdev->fb_count--; ufbdev->fb_count--;
#ifdef CONFIG_DRM_FBDEV_EMULATION
if ((ufbdev->fb_count == 0) && (info->fbdefio)) { if ((ufbdev->fb_count == 0) && (info->fbdefio)) {
fb_deferred_io_cleanup(info); fb_deferred_io_cleanup(info);
kfree(info->fbdefio); kfree(info->fbdefio);
info->fbdefio = NULL; info->fbdefio = NULL;
info->fbops->fb_mmap = udl_fb_mmap; info->fbops->fb_mmap = udl_fb_mmap;
} }
#endif
pr_warn("released /dev/fb%d user=%d count=%d\n", pr_warn("released /dev/fb%d user=%d count=%d\n",
info->node, user, ufbdev->fb_count); info->node, user, ufbdev->fb_count);

View File

@ -16,6 +16,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include "drm_fb_cma_helper.h" #include "drm_fb_cma_helper.h"
#include <drm/drm_fb_helper.h>
#include "uapi/drm/vc4_drm.h" #include "uapi/drm/vc4_drm.h"
#include "vc4_drv.h" #include "vc4_drv.h"
@ -214,7 +215,7 @@ static void vc4_kick_out_firmware_fb(void)
ap->ranges[0].base = 0; ap->ranges[0].base = 0;
ap->ranges[0].size = ~0; ap->ranges[0].size = ~0;
remove_conflicting_framebuffers(ap, "vc4drmfb", false); drm_fb_helper_remove_conflicting_framebuffers(ap, "vc4drmfb", false);
kfree(ap); kfree(ap);
} }

View File

@ -72,7 +72,7 @@ static const struct file_operations via_driver_fops = {
static struct drm_driver driver = { static struct drm_driver driver = {
.driver_features = .driver_features =
DRIVER_USE_AGP | DRIVER_HAVE_IRQ | DRIVER_USE_AGP | DRIVER_HAVE_IRQ | DRIVER_LEGACY |
DRIVER_IRQ_SHARED, DRIVER_IRQ_SHARED,
.load = via_driver_load, .load = via_driver_load,
.unload = via_driver_unload, .unload = via_driver_unload,

View File

@ -24,6 +24,7 @@
*/ */
#include <linux/pci.h> #include <linux/pci.h>
#include <drm/drm_fb_helper.h>
#include "virtgpu_drv.h" #include "virtgpu_drv.h"
@ -42,7 +43,7 @@ static void virtio_pci_kick_out_firmware_fb(struct pci_dev *pci_dev)
primary = pci_dev->resource[PCI_ROM_RESOURCE].flags primary = pci_dev->resource[PCI_ROM_RESOURCE].flags
& IORESOURCE_ROM_SHADOW; & IORESOURCE_ROM_SHADOW;
remove_conflicting_framebuffers(ap, "virtiodrmfb", primary); drm_fb_helper_remove_conflicting_framebuffers(ap, "virtiodrmfb", primary);
kfree(ap); kfree(ap);
} }

View File

@ -6,6 +6,7 @@ config DRM_VMWGFX
select FB_CFB_COPYAREA select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT select FB_CFB_IMAGEBLIT
select DRM_TTM select DRM_TTM
select FB
# Only needed for the transitional use of drm_crtc_init - can be removed # Only needed for the transitional use of drm_crtc_init - can be removed
# again once vmwgfx sets up the primary plane itself. # again once vmwgfx sets up the primary plane itself.
select DRM_KMS_HELPER select DRM_KMS_HELPER

View File

@ -135,10 +135,16 @@ static void sync_print_sync_file(struct seq_file *s,
int i; int i;
seq_printf(s, "[%p] %s: %s\n", sync_file, sync_file->name, seq_printf(s, "[%p] %s: %s\n", sync_file, sync_file->name,
sync_status_str(atomic_read(&sync_file->status))); sync_status_str(!fence_is_signaled(sync_file->fence)));
for (i = 0; i < sync_file->num_fences; ++i) if (fence_is_array(sync_file->fence)) {
sync_print_fence(s, sync_file->cbs[i].fence, true); struct fence_array *array = to_fence_array(sync_file->fence);
for (i = 0; i < array->num_fences; ++i)
sync_print_fence(s, array->fences[i], true);
} else {
sync_print_fence(s, sync_file->fence, true);
}
} }
static int sync_debugfs_show(struct seq_file *s, void *unused) static int sync_debugfs_show(struct seq_file *s, void *unused)

View File

@ -146,6 +146,7 @@ void drm_err(const char *format, ...);
/* driver capabilities and requirements mask */ /* driver capabilities and requirements mask */
#define DRIVER_USE_AGP 0x1 #define DRIVER_USE_AGP 0x1
#define DRIVER_LEGACY 0x2
#define DRIVER_PCI_DMA 0x8 #define DRIVER_PCI_DMA 0x8
#define DRIVER_SG 0x10 #define DRIVER_SG 0x10
#define DRIVER_HAVE_DMA 0x20 #define DRIVER_HAVE_DMA 0x20
@ -231,6 +232,36 @@ void drm_err(const char *format, ...);
drm_ut_debug_printk(__func__, fmt, ##args); \ drm_ut_debug_printk(__func__, fmt, ##args); \
} while (0) } while (0)
#define _DRM_DEFINE_DEBUG_RATELIMITED(level, fmt, args...) \
do { \
if (unlikely(drm_debug & DRM_UT_ ## level)) { \
static DEFINE_RATELIMIT_STATE( \
_rs, \
DEFAULT_RATELIMIT_INTERVAL, \
DEFAULT_RATELIMIT_BURST); \
\
if (__ratelimit(&_rs)) { \
drm_ut_debug_printk(__func__, fmt, \
##args); \
} \
} \
} while (0)
/**
* Rate limited debug output. Like DRM_DEBUG() but won't flood the log.
*
* \param fmt printf() like format string.
* \param arg arguments
*/
#define DRM_DEBUG_RATELIMITED(fmt, args...) \
_DRM_DEFINE_DEBUG_RATELIMITED(CORE, fmt, ##args)
#define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \
_DRM_DEFINE_DEBUG_RATELIMITED(DRIVER, fmt, ##args)
#define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \
_DRM_DEFINE_DEBUG_RATELIMITED(KMS, fmt, ##args)
#define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \
_DRM_DEFINE_DEBUG_RATELIMITED(PRIME, fmt, ##args)
/*@}*/ /*@}*/
/***********************************************************************/ /***********************************************************************/
@ -642,7 +673,7 @@ struct drm_driver {
}; };
enum drm_minor_type { enum drm_minor_type {
DRM_MINOR_LEGACY, DRM_MINOR_PRIMARY,
DRM_MINOR_CONTROL, DRM_MINOR_CONTROL,
DRM_MINOR_RENDER, DRM_MINOR_RENDER,
DRM_MINOR_CNT, DRM_MINOR_CNT,
@ -856,7 +887,7 @@ static inline bool drm_is_control_client(const struct drm_file *file_priv)
static inline bool drm_is_primary_client(const struct drm_file *file_priv) static inline bool drm_is_primary_client(const struct drm_file *file_priv)
{ {
return file_priv->minor->type == DRM_MINOR_LEGACY; return file_priv->minor->type == DRM_MINOR_PRIMARY;
} }
/******************************************************************/ /******************************************************************/

View File

@ -35,6 +35,7 @@
#include <uapi/drm/drm_mode.h> #include <uapi/drm/drm_mode.h>
#include <uapi/drm/drm_fourcc.h> #include <uapi/drm/drm_fourcc.h>
#include <drm/drm_modeset_lock.h> #include <drm/drm_modeset_lock.h>
#include <drm/drm_rect.h>
struct drm_device; struct drm_device;
struct drm_mode_set; struct drm_mode_set;
@ -83,14 +84,15 @@ static inline uint64_t I642U64(int64_t val)
* specified amount in degrees in counter clockwise direction. DRM_REFLECT_X and * specified amount in degrees in counter clockwise direction. DRM_REFLECT_X and
* DRM_REFLECT_Y reflects the image along the specified axis prior to rotation * DRM_REFLECT_Y reflects the image along the specified axis prior to rotation
*/ */
#define DRM_ROTATE_MASK 0x0f #define DRM_ROTATE_0 BIT(0)
#define DRM_ROTATE_0 0 #define DRM_ROTATE_90 BIT(1)
#define DRM_ROTATE_90 1 #define DRM_ROTATE_180 BIT(2)
#define DRM_ROTATE_180 2 #define DRM_ROTATE_270 BIT(3)
#define DRM_ROTATE_270 3 #define DRM_ROTATE_MASK (DRM_ROTATE_0 | DRM_ROTATE_90 | \
#define DRM_REFLECT_MASK (~DRM_ROTATE_MASK) DRM_ROTATE_180 | DRM_ROTATE_270)
#define DRM_REFLECT_X 4 #define DRM_REFLECT_X BIT(4)
#define DRM_REFLECT_Y 5 #define DRM_REFLECT_Y BIT(5)
#define DRM_REFLECT_MASK (DRM_REFLECT_X | DRM_REFLECT_Y)
enum drm_connector_force { enum drm_connector_force {
DRM_FORCE_UNSPECIFIED, DRM_FORCE_UNSPECIFIED,
@ -1414,6 +1416,9 @@ struct drm_connector {
* @zpos: priority of the given plane on crtc (optional) * @zpos: priority of the given plane on crtc (optional)
* @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1 * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1
* where N is the number of active planes for given crtc * where N is the number of active planes for given crtc
* @src: clipped source coordinates of the plane (in 16.16)
* @dst: clipped destination coordinates of the plane
* @visible: visibility of the plane
* @state: backpointer to global drm_atomic_state * @state: backpointer to global drm_atomic_state
*/ */
struct drm_plane_state { struct drm_plane_state {
@ -1438,6 +1443,15 @@ struct drm_plane_state {
unsigned int zpos; unsigned int zpos;
unsigned int normalized_zpos; unsigned int normalized_zpos;
/* Clipped coordinates */
struct drm_rect src, dst;
/*
* Is the plane actually visible? Can be false even
* if fb!=NULL and crtc!=NULL, due to clipping.
*/
bool visible;
struct drm_atomic_state *state; struct drm_atomic_state *state;
}; };

View File

@ -32,6 +32,7 @@
struct drm_fb_helper; struct drm_fb_helper;
#include <drm/drm_crtc.h>
#include <linux/kgdb.h> #include <linux/kgdb.h>
enum mode_set_atomic { enum mode_set_atomic {
@ -282,6 +283,12 @@ drm_pick_cmdline_mode(struct drm_fb_helper_connector *fb_helper_conn,
int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector); int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector);
int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
struct drm_connector *connector); struct drm_connector *connector);
static inline int
drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
const char *name, bool primary)
{
return remove_conflicting_framebuffers(a, name, primary);
}
#else #else
static inline int drm_fb_helper_modinit(void) static inline int drm_fb_helper_modinit(void)
{ {
@ -475,5 +482,12 @@ drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
{ {
return 0; return 0;
} }
static inline int
drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a,
const char *name, bool primary)
{
return 0;
}
#endif #endif
#endif #endif

View File

@ -37,6 +37,7 @@
* Generic range manager structs * Generic range manager structs
*/ */
#include <linux/bug.h> #include <linux/bug.h>
#include <linux/rbtree.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
@ -61,6 +62,7 @@ enum drm_mm_allocator_flags {
struct drm_mm_node { struct drm_mm_node {
struct list_head node_list; struct list_head node_list;
struct list_head hole_stack; struct list_head hole_stack;
struct rb_node rb;
unsigned hole_follows : 1; unsigned hole_follows : 1;
unsigned scanned_block : 1; unsigned scanned_block : 1;
unsigned scanned_prev_free : 1; unsigned scanned_prev_free : 1;
@ -70,6 +72,7 @@ struct drm_mm_node {
unsigned long color; unsigned long color;
u64 start; u64 start;
u64 size; u64 size;
u64 __subtree_last;
struct drm_mm *mm; struct drm_mm *mm;
}; };
@ -79,6 +82,9 @@ struct drm_mm {
/* head_node.node_list is the list of all memory nodes, ordered /* head_node.node_list is the list of all memory nodes, ordered
* according to the (increasing) start address of the memory node. */ * according to the (increasing) start address of the memory node. */
struct drm_mm_node head_node; struct drm_mm_node head_node;
/* Keep an interval_tree for fast lookup of drm_mm_nodes by address. */
struct rb_root interval_tree;
unsigned int scan_check_range : 1; unsigned int scan_check_range : 1;
unsigned scan_alignment; unsigned scan_alignment;
unsigned long scan_color; unsigned long scan_color;
@ -295,6 +301,12 @@ void drm_mm_init(struct drm_mm *mm,
void drm_mm_takedown(struct drm_mm *mm); void drm_mm_takedown(struct drm_mm *mm);
bool drm_mm_clean(struct drm_mm *mm); bool drm_mm_clean(struct drm_mm *mm);
struct drm_mm_node *
drm_mm_interval_first(struct drm_mm *mm, u64 start, u64 last);
struct drm_mm_node *
drm_mm_interval_next(struct drm_mm_node *node, u64 start, u64 last);
void drm_mm_init_scan(struct drm_mm *mm, void drm_mm_init_scan(struct drm_mm *mm,
u64 size, u64 size,
unsigned alignment, unsigned alignment,

View File

@ -40,6 +40,11 @@
int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
const struct drm_crtc_funcs *funcs); const struct drm_crtc_funcs *funcs);
int drm_plane_helper_check_state(struct drm_plane_state *state,
const struct drm_rect *clip,
int min_scale, int max_scale,
bool can_position,
bool can_update_disabled);
int drm_plane_helper_check_update(struct drm_plane *plane, int drm_plane_helper_check_update(struct drm_plane *plane,
struct drm_crtc *crtc, struct drm_crtc *crtc,
struct drm_framebuffer *fb, struct drm_framebuffer *fb,

View File

@ -40,13 +40,11 @@ struct drm_vma_offset_file {
struct drm_vma_offset_node { struct drm_vma_offset_node {
rwlock_t vm_lock; rwlock_t vm_lock;
struct drm_mm_node vm_node; struct drm_mm_node vm_node;
struct rb_node vm_rb;
struct rb_root vm_files; struct rb_root vm_files;
}; };
struct drm_vma_offset_manager { struct drm_vma_offset_manager {
rwlock_t vm_lock; rwlock_t vm_lock;
struct rb_root vm_addr_space_rb;
struct drm_mm vm_addr_space_mm; struct drm_mm vm_addr_space_mm;
}; };

Some files were not shown because too many files have changed in this diff Show More