mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
core:
- extract i915 eDP backlight into core
- DP aux bus support
- drm_device.irq_enabled removed
- port drivers to native irq interfaces
- export gem shadow plane handling for vgem
- print proper driver name in framebuffer registration
- driver fixes for implicit fencing rules
- ARM fixed rate compression modifier added
- updated fb damage handling
- rmfb ioctl logging/docs
- drop drm_gem_object_put_locked
- define DRM_FORMAT_MAX_PLANES
- add gem fb vmap/vunmap helpers
- add lockdep_assert(once) helpers
- mark drm irq midlayer as legacy
- use offset adjusted bo mapping conversion
vgaarb:
- cleanups
fbdev:
- extend efifb handling to all arches
- div by 0 fixes for multiple drivers
udmabuf:
- add hugepage mapping support
dma-buf:
- non-dynamic exporter fixups
- document implicit fencing rules
amdgpu:
- Initial Cyan Skillfish support
- switch virtual DCE over to vkms based atomic
- VCN/JPEG power down fixes
- NAVI PCIE link handling fixes
- AMD HDMI freesync fixes
- Yellow Carp + Beige Goby fixes
- Clockgating/S0ix/SMU/EEPROM fixes
- embed hw fence in job
- rework dma-resv handling
- ensure eviction to system ram
amdkfd:
- uapi: SVM address range query added
- sysfs leak fix
- GPUVM TLB optimizations
- vmfault/migration counters
i915:
- Enable JSL and EHL by default
- preliminary XeHP/DG2 support
- remove all CNL support (never shipped)
- move to TTM for discrete memory support
- allow mixed object mmap handling
- GEM uAPI spring cleaning
- add I915_MMAP_OBJECT_FIXED
- reinstate ADL-P mmap ioctls
- drop a bunch of unused by userspace features
- disable and remove GPU relocations
- revert some i915 misfeatures
- major refactoring of GuC for Gen11+
- execbuffer object locking separate step
- reject caching/set-domain on discrete
- Enable pipe DMC loading on XE-LPD and ADL-P
- add PSF GV point support
- Refactor and fix DDI buffer translations
- Clean up FBC CFB allocation code
- Finish INTEL_GEN() and friends macro conversions
nouveau:
- add eDP backlight support
- implicit fence fix
msm:
- a680/7c3 support
- drm/scheduler conversion
panfrost:
- rework GPU reset
virtio:
- fix fencing for planes
ast:
- add detect support
bochs:
- move to tiny GPU driver
vc4:
- use hotplug irqs
- HDMI codec support
vmwgfx:
- use internal vmware device headers
ingenic:
- demidlayering irq
rcar-du:
- shutdown fixes
- convert to bridge connector helpers
zynqmp-dsub:
- misc fixes
mgag200:
- convert PLL handling to atomic
mediatek:
- MT8133 AAL support
- gem mmap object support
- MT8167 support
etnaviv:
- NXP Layerscape LS1028A SoC support
- GEM mmap cleanups
tegra:
- new user API
exynos:
- missing unlock fix
- build warning fix
- use refcount_t
-----BEGIN PGP SIGNATURE-----
iQIzBAABCAAdFiEEEKbZHaGwW9KfbeusDHTzWXnEhr4FAmEtvn8ACgkQDHTzWXnE
hr7aqw//WfcIyGdPLjAz59cW8jm+FgihD5colHtOUYRHRO4GeX/bNNufquR8+N3y
HESsyZdpihFHms/wURMq41ibmHg0EuHA01HZzjZuGBesG4F9I8sP/HnDOxDuYuAx
N7Lg4PlUNlfFHmw7Y84owQ6s/XWmNp5iZ8e/mTK5hcraJFQKS4QO74n9RbG/F1vC
Hc3P6AnpqGac2AEGXt0NjIRxVVCTUIBGx+XOhj+1AMyAGzt9VcO1DS9PVCS0zsEy
zKMj9tZAPNg0wYsXAi4kA1lK7uVY8KoXSVDYLpsI5Or2/e7mfq2b4EWrezbtp6UA
H+w86axuwJq7NaYHYH6HqyrLTOmvcHgIl2LoZN91KaNt61xfJT3XZkyQoYViGIrJ
oZy6X/+s+WPoW98bHZrr6vbcxtWKfEeQyUFEAaDMmraKNJwROjtwgFC9DP8MDctq
PUSM+XkwbGRRxQfv9dNKufeWfV5blVfzEJO8EfTU1YET3WTDaUHe/FoIcLZt2DZG
JAJgZkIlU8egthPdakUjQz/KoyLMyovcN5zcjgzgjA9PyNEq74uElN9l446kSSxu
jEVErOdd+aG3Zzk7/ZZL/RmpNQpPfpQ2RaPUkgeUsW01myNzUNuU3KUDaSlVa+Oi
1n7eKoaQ2to/+LjhYApVriri4hIZckNNn5FnnhkgwGi8mpHQIVQ=
=vZkA
-----END PGP SIGNATURE-----
Merge tag 'drm-next-2021-08-31-1' of git://anongit.freedesktop.org/drm/drm
Pull drm updates from Dave Airlie:
"Highlights:
- i915 has seen a lot of refactoring and uAPI cleanups due to a
change in the upstream direction going forward
This has all been audited with known userspace, but there may be
some pitfalls that were missed.
- i915 now uses common TTM to enable discrete memory on DG1/2 GPUs
- i915 enables Jasper and Elkhart Lake by default and has preliminary
XeHP/DG2 support
- amdgpu adds support for Cyan Skillfish
- lots of implicit fencing rules documented and fixed up in drivers
- msm now uses the core scheduler
- the irq midlayer has been removed for non-legacy drivers
- the sysfb code now works on more than x86.
Otherwise the usual smattering of stuff everywhere, panels, bridges,
refactorings.
Detailed summary:
core:
- extract i915 eDP backlight into core
- DP aux bus support
- drm_device.irq_enabled removed
- port drivers to native irq interfaces
- export gem shadow plane handling for vgem
- print proper driver name in framebuffer registration
- driver fixes for implicit fencing rules
- ARM fixed rate compression modifier added
- updated fb damage handling
- rmfb ioctl logging/docs
- drop drm_gem_object_put_locked
- define DRM_FORMAT_MAX_PLANES
- add gem fb vmap/vunmap helpers
- add lockdep_assert(once) helpers
- mark drm irq midlayer as legacy
- use offset adjusted bo mapping conversion
vgaarb:
- cleanups
fbdev:
- extend efifb handling to all arches
- div by 0 fixes for multiple drivers
udmabuf:
- add hugepage mapping support
dma-buf:
- non-dynamic exporter fixups
- document implicit fencing rules
amdgpu:
- Initial Cyan Skillfish support
- switch virtual DCE over to vkms based atomic
- VCN/JPEG power down fixes
- NAVI PCIE link handling fixes
- AMD HDMI freesync fixes
- Yellow Carp + Beige Goby fixes
- Clockgating/S0ix/SMU/EEPROM fixes
- embed hw fence in job
- rework dma-resv handling
- ensure eviction to system ram
amdkfd:
- uapi: SVM address range query added
- sysfs leak fix
- GPUVM TLB optimizations
- vmfault/migration counters
i915:
- Enable JSL and EHL by default
- preliminary XeHP/DG2 support
- remove all CNL support (never shipped)
- move to TTM for discrete memory support
- allow mixed object mmap handling
- GEM uAPI spring cleaning
- add I915_MMAP_OBJECT_FIXED
- reinstate ADL-P mmap ioctls
- drop a bunch of unused by userspace features
- disable and remove GPU relocations
- revert some i915 misfeatures
- major refactoring of GuC for Gen11+
- execbuffer object locking separate step
- reject caching/set-domain on discrete
- Enable pipe DMC loading on XE-LPD and ADL-P
- add PSF GV point support
- Refactor and fix DDI buffer translations
- Clean up FBC CFB allocation code
- Finish INTEL_GEN() and friends macro conversions
nouveau:
- add eDP backlight support
- implicit fence fix
msm:
- a680/7c3 support
- drm/scheduler conversion
panfrost:
- rework GPU reset
virtio:
- fix fencing for planes
ast:
- add detect support
bochs:
- move to tiny GPU driver
vc4:
- use hotplug irqs
- HDMI codec support
vmwgfx:
- use internal vmware device headers
ingenic:
- demidlayering irq
rcar-du:
- shutdown fixes
- convert to bridge connector helpers
zynqmp-dsub:
- misc fixes
mgag200:
- convert PLL handling to atomic
mediatek:
- MT8133 AAL support
- gem mmap object support
- MT8167 support
etnaviv:
- NXP Layerscape LS1028A SoC support
- GEM mmap cleanups
tegra:
- new user API
exynos:
- missing unlock fix
- build warning fix
- use refcount_t"
* tag 'drm-next-2021-08-31-1' of git://anongit.freedesktop.org/drm/drm: (1318 commits)
drm/amd/display: Move AllowDRAMSelfRefreshOrDRAMClockChangeInVblank to bounding box
drm/amd/display: Remove duplicate dml init
drm/amd/display: Update bounding box states (v2)
drm/amd/display: Update number of DCN3 clock states
drm/amdgpu: disable GFX CGCG in aldebaran
drm/amdgpu: Clear RAS interrupt status on aldebaran
drm/amdgpu: Add support for RAS XGMI err query
drm/amdkfd: Account for SH/SE count when setting up cu masks.
drm/amdgpu: rename amdgpu_bo_get_preferred_pin_domain
drm/amdgpu: drop redundant cancel_delayed_work_sync call
drm/amdgpu: add missing cleanups for more ASICs on UVD/VCE suspend
drm/amdgpu: add missing cleanups for Polaris12 UVD/VCE on suspend
drm/amdkfd: map SVM range with correct access permission
drm/amdkfd: check access permisson to restore retry fault
drm/amdgpu: Update RAS XGMI Error Query
drm/amdgpu: Add driver infrastructure for MCA RAS
drm/amd/display: Add Logging for HDMI color depth information
drm/amd/amdgpu: consolidate PSP TA init shared buf functions
drm/amd/amdgpu: add name field back to ras_common_if
drm/amdgpu: Fix build with missing pm_suspend_target_state module export
...
271 lines
7.5 KiB
C
271 lines
7.5 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (c) 2015 MediaTek Inc.
|
|
* Author: CK Hu <ck.hu@mediatek.com>
|
|
*/
|
|
|
|
#include <drm/drm_atomic.h>
|
|
#include <drm/drm_atomic_helper.h>
|
|
#include <drm/drm_atomic_uapi.h>
|
|
#include <drm/drm_fourcc.h>
|
|
#include <drm/drm_gem_atomic_helper.h>
|
|
#include <drm/drm_plane_helper.h>
|
|
|
|
#include "mtk_drm_crtc.h"
|
|
#include "mtk_drm_ddp_comp.h"
|
|
#include "mtk_drm_drv.h"
|
|
#include "mtk_drm_gem.h"
|
|
#include "mtk_drm_plane.h"
|
|
|
|
static const u32 formats[] = {
|
|
DRM_FORMAT_XRGB8888,
|
|
DRM_FORMAT_ARGB8888,
|
|
DRM_FORMAT_BGRX8888,
|
|
DRM_FORMAT_BGRA8888,
|
|
DRM_FORMAT_ABGR8888,
|
|
DRM_FORMAT_XBGR8888,
|
|
DRM_FORMAT_RGB888,
|
|
DRM_FORMAT_BGR888,
|
|
DRM_FORMAT_RGB565,
|
|
DRM_FORMAT_UYVY,
|
|
DRM_FORMAT_YUYV,
|
|
};
|
|
|
|
static void mtk_plane_reset(struct drm_plane *plane)
|
|
{
|
|
struct mtk_plane_state *state;
|
|
|
|
if (plane->state) {
|
|
__drm_atomic_helper_plane_destroy_state(plane->state);
|
|
|
|
state = to_mtk_plane_state(plane->state);
|
|
memset(state, 0, sizeof(*state));
|
|
} else {
|
|
state = kzalloc(sizeof(*state), GFP_KERNEL);
|
|
if (!state)
|
|
return;
|
|
plane->state = &state->base;
|
|
}
|
|
|
|
state->base.plane = plane;
|
|
state->pending.format = DRM_FORMAT_RGB565;
|
|
}
|
|
|
|
static struct drm_plane_state *mtk_plane_duplicate_state(struct drm_plane *plane)
|
|
{
|
|
struct mtk_plane_state *old_state = to_mtk_plane_state(plane->state);
|
|
struct mtk_plane_state *state;
|
|
|
|
state = kzalloc(sizeof(*state), GFP_KERNEL);
|
|
if (!state)
|
|
return NULL;
|
|
|
|
__drm_atomic_helper_plane_duplicate_state(plane, &state->base);
|
|
|
|
WARN_ON(state->base.plane != plane);
|
|
|
|
state->pending = old_state->pending;
|
|
|
|
return &state->base;
|
|
}
|
|
|
|
static void mtk_drm_plane_destroy_state(struct drm_plane *plane,
|
|
struct drm_plane_state *state)
|
|
{
|
|
__drm_atomic_helper_plane_destroy_state(state);
|
|
kfree(to_mtk_plane_state(state));
|
|
}
|
|
|
|
static int mtk_plane_atomic_async_check(struct drm_plane *plane,
|
|
struct drm_atomic_state *state)
|
|
{
|
|
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
|
|
plane);
|
|
struct drm_crtc_state *crtc_state;
|
|
int ret;
|
|
|
|
if (plane != new_plane_state->crtc->cursor)
|
|
return -EINVAL;
|
|
|
|
if (!plane->state)
|
|
return -EINVAL;
|
|
|
|
if (!plane->state->fb)
|
|
return -EINVAL;
|
|
|
|
ret = mtk_drm_crtc_plane_check(new_plane_state->crtc, plane,
|
|
to_mtk_plane_state(new_plane_state));
|
|
if (ret)
|
|
return ret;
|
|
|
|
if (state)
|
|
crtc_state = drm_atomic_get_existing_crtc_state(state,
|
|
new_plane_state->crtc);
|
|
else /* Special case for asynchronous cursor updates. */
|
|
crtc_state = new_plane_state->crtc->state;
|
|
|
|
return drm_atomic_helper_check_plane_state(plane->state, crtc_state,
|
|
DRM_PLANE_HELPER_NO_SCALING,
|
|
DRM_PLANE_HELPER_NO_SCALING,
|
|
true, true);
|
|
}
|
|
|
|
static void mtk_plane_update_new_state(struct drm_plane_state *new_state,
|
|
struct mtk_plane_state *mtk_plane_state)
|
|
{
|
|
struct drm_framebuffer *fb = new_state->fb;
|
|
struct drm_gem_object *gem;
|
|
struct mtk_drm_gem_obj *mtk_gem;
|
|
unsigned int pitch, format;
|
|
dma_addr_t addr;
|
|
|
|
gem = fb->obj[0];
|
|
mtk_gem = to_mtk_gem_obj(gem);
|
|
addr = mtk_gem->dma_addr;
|
|
pitch = fb->pitches[0];
|
|
format = fb->format->format;
|
|
|
|
addr += (new_state->src.x1 >> 16) * fb->format->cpp[0];
|
|
addr += (new_state->src.y1 >> 16) * pitch;
|
|
|
|
mtk_plane_state->pending.enable = true;
|
|
mtk_plane_state->pending.pitch = pitch;
|
|
mtk_plane_state->pending.format = format;
|
|
mtk_plane_state->pending.addr = addr;
|
|
mtk_plane_state->pending.x = new_state->dst.x1;
|
|
mtk_plane_state->pending.y = new_state->dst.y1;
|
|
mtk_plane_state->pending.width = drm_rect_width(&new_state->dst);
|
|
mtk_plane_state->pending.height = drm_rect_height(&new_state->dst);
|
|
mtk_plane_state->pending.rotation = new_state->rotation;
|
|
}
|
|
|
|
static void mtk_plane_atomic_async_update(struct drm_plane *plane,
|
|
struct drm_atomic_state *state)
|
|
{
|
|
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
|
|
plane);
|
|
struct mtk_plane_state *new_plane_state = to_mtk_plane_state(plane->state);
|
|
|
|
plane->state->crtc_x = new_state->crtc_x;
|
|
plane->state->crtc_y = new_state->crtc_y;
|
|
plane->state->crtc_h = new_state->crtc_h;
|
|
plane->state->crtc_w = new_state->crtc_w;
|
|
plane->state->src_x = new_state->src_x;
|
|
plane->state->src_y = new_state->src_y;
|
|
plane->state->src_h = new_state->src_h;
|
|
plane->state->src_w = new_state->src_w;
|
|
swap(plane->state->fb, new_state->fb);
|
|
|
|
mtk_plane_update_new_state(new_state, new_plane_state);
|
|
wmb(); /* Make sure the above parameters are set before update */
|
|
new_plane_state->pending.async_dirty = true;
|
|
mtk_drm_crtc_async_update(new_state->crtc, plane, state);
|
|
}
|
|
|
|
static const struct drm_plane_funcs mtk_plane_funcs = {
|
|
.update_plane = drm_atomic_helper_update_plane,
|
|
.disable_plane = drm_atomic_helper_disable_plane,
|
|
.destroy = drm_plane_cleanup,
|
|
.reset = mtk_plane_reset,
|
|
.atomic_duplicate_state = mtk_plane_duplicate_state,
|
|
.atomic_destroy_state = mtk_drm_plane_destroy_state,
|
|
};
|
|
|
|
static int mtk_plane_atomic_check(struct drm_plane *plane,
|
|
struct drm_atomic_state *state)
|
|
{
|
|
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
|
|
plane);
|
|
struct drm_framebuffer *fb = new_plane_state->fb;
|
|
struct drm_crtc_state *crtc_state;
|
|
int ret;
|
|
|
|
if (!fb)
|
|
return 0;
|
|
|
|
if (WARN_ON(!new_plane_state->crtc))
|
|
return 0;
|
|
|
|
ret = mtk_drm_crtc_plane_check(new_plane_state->crtc, plane,
|
|
to_mtk_plane_state(new_plane_state));
|
|
if (ret)
|
|
return ret;
|
|
|
|
crtc_state = drm_atomic_get_crtc_state(state,
|
|
new_plane_state->crtc);
|
|
if (IS_ERR(crtc_state))
|
|
return PTR_ERR(crtc_state);
|
|
|
|
return drm_atomic_helper_check_plane_state(new_plane_state,
|
|
crtc_state,
|
|
DRM_PLANE_HELPER_NO_SCALING,
|
|
DRM_PLANE_HELPER_NO_SCALING,
|
|
true, true);
|
|
}
|
|
|
|
static void mtk_plane_atomic_disable(struct drm_plane *plane,
|
|
struct drm_atomic_state *state)
|
|
{
|
|
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
|
|
plane);
|
|
struct mtk_plane_state *mtk_plane_state = to_mtk_plane_state(new_state);
|
|
mtk_plane_state->pending.enable = false;
|
|
wmb(); /* Make sure the above parameter is set before update */
|
|
mtk_plane_state->pending.dirty = true;
|
|
}
|
|
|
|
static void mtk_plane_atomic_update(struct drm_plane *plane,
|
|
struct drm_atomic_state *state)
|
|
{
|
|
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
|
|
plane);
|
|
struct mtk_plane_state *mtk_plane_state = to_mtk_plane_state(new_state);
|
|
|
|
if (!new_state->crtc || WARN_ON(!new_state->fb))
|
|
return;
|
|
|
|
if (!new_state->visible) {
|
|
mtk_plane_atomic_disable(plane, state);
|
|
return;
|
|
}
|
|
|
|
mtk_plane_update_new_state(new_state, mtk_plane_state);
|
|
wmb(); /* Make sure the above parameters are set before update */
|
|
mtk_plane_state->pending.dirty = true;
|
|
}
|
|
|
|
static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = {
|
|
.atomic_check = mtk_plane_atomic_check,
|
|
.atomic_update = mtk_plane_atomic_update,
|
|
.atomic_disable = mtk_plane_atomic_disable,
|
|
.atomic_async_update = mtk_plane_atomic_async_update,
|
|
.atomic_async_check = mtk_plane_atomic_async_check,
|
|
};
|
|
|
|
int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
|
|
unsigned long possible_crtcs, enum drm_plane_type type,
|
|
unsigned int supported_rotations)
|
|
{
|
|
int err;
|
|
|
|
err = drm_universal_plane_init(dev, plane, possible_crtcs,
|
|
&mtk_plane_funcs, formats,
|
|
ARRAY_SIZE(formats), NULL, type, NULL);
|
|
if (err) {
|
|
DRM_ERROR("failed to initialize plane\n");
|
|
return err;
|
|
}
|
|
|
|
if (supported_rotations & ~DRM_MODE_ROTATE_0) {
|
|
err = drm_plane_create_rotation_property(plane,
|
|
DRM_MODE_ROTATE_0,
|
|
supported_rotations);
|
|
if (err)
|
|
DRM_INFO("Create rotation property failed\n");
|
|
}
|
|
|
|
drm_plane_helper_add(plane, &mtk_plane_helper_funcs);
|
|
|
|
return 0;
|
|
}
|