drm/simpledrm: Acquire memory aperture for framebuffer
We register the simplekms device with the DRM platform helpers. A native driver for the graphics hardware will kick-out the simpledrm driver before taking over the device. The original generic platform device from the simple-framebuffer boot code will be unregistered. The native driver will use whatever native hardware device it received. v4: * convert to drm_aperture_acquire_from_firmware() v3: * use platform_device_unregister() and handle detachment like hot-unplug event (Daniel) v2: * adapt to aperture changes * use drm_dev_unplug() and drm_dev_enter/exit() * don't split error string Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Maxime Ripard <maxime@cerno.tech> Tested-by: nerdopolis <bluescreen_avenger@verizon.net> Link: https://patchwork.freedesktop.org/patch/msgid/20210430105840.30515-10-tzimmermann@suse.de
This commit is contained in:
parent
11e8f5fd22
commit
4aae79f77e
1 changed files with 24 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/regulator/consumer.h>
|
#include <linux/regulator/consumer.h>
|
||||||
|
|
||||||
|
#include <drm/drm_aperture.h>
|
||||||
#include <drm/drm_atomic_state_helper.h>
|
#include <drm/drm_atomic_state_helper.h>
|
||||||
#include <drm/drm_connector.h>
|
#include <drm/drm_connector.h>
|
||||||
#include <drm/drm_damage_helper.h>
|
#include <drm/drm_damage_helper.h>
|
||||||
|
@ -517,14 +518,23 @@ static int simpledrm_device_init_fb(struct simpledrm_device *sdev)
|
||||||
|
|
||||||
static int simpledrm_device_init_mm(struct simpledrm_device *sdev)
|
static int simpledrm_device_init_mm(struct simpledrm_device *sdev)
|
||||||
{
|
{
|
||||||
|
struct drm_device *dev = &sdev->dev;
|
||||||
struct platform_device *pdev = sdev->pdev;
|
struct platform_device *pdev = sdev->pdev;
|
||||||
struct resource *mem;
|
struct resource *mem;
|
||||||
void __iomem *screen_base;
|
void __iomem *screen_base;
|
||||||
|
int ret;
|
||||||
|
|
||||||
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
if (!mem)
|
if (!mem)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ret = devm_aperture_acquire_from_firmware(dev, mem->start, resource_size(mem));
|
||||||
|
if (ret) {
|
||||||
|
drm_err(dev, "could not acquire memory range [0x%llx:0x%llx]: error %d\n",
|
||||||
|
mem->start, mem->end, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
screen_base = devm_ioremap_wc(&pdev->dev, mem->start,
|
screen_base = devm_ioremap_wc(&pdev->dev, mem->start,
|
||||||
resource_size(mem));
|
resource_size(mem));
|
||||||
if (!screen_base)
|
if (!screen_base)
|
||||||
|
@ -625,12 +635,18 @@ simpledrm_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
|
||||||
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
|
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
|
||||||
struct drm_framebuffer *fb = plane_state->fb;
|
struct drm_framebuffer *fb = plane_state->fb;
|
||||||
void *vmap = shadow_plane_state->map[0].vaddr; /* TODO: Use mapping abstraction properly */
|
void *vmap = shadow_plane_state->map[0].vaddr; /* TODO: Use mapping abstraction properly */
|
||||||
|
struct drm_device *dev = &sdev->dev;
|
||||||
|
int idx;
|
||||||
|
|
||||||
if (!fb)
|
if (!fb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!drm_dev_enter(dev, &idx))
|
||||||
|
return;
|
||||||
|
|
||||||
drm_fb_blit_dstclip(sdev->screen_base, sdev->pitch,
|
drm_fb_blit_dstclip(sdev->screen_base, sdev->pitch,
|
||||||
sdev->format->format, vmap, fb);
|
sdev->format->format, vmap, fb);
|
||||||
|
drm_dev_exit(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -658,7 +674,9 @@ simpledrm_simple_display_pipe_update(struct drm_simple_display_pipe *pipe,
|
||||||
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
|
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
|
||||||
void *vmap = shadow_plane_state->map[0].vaddr; /* TODO: Use mapping abstraction properly */
|
void *vmap = shadow_plane_state->map[0].vaddr; /* TODO: Use mapping abstraction properly */
|
||||||
struct drm_framebuffer *fb = plane_state->fb;
|
struct drm_framebuffer *fb = plane_state->fb;
|
||||||
|
struct drm_device *dev = &sdev->dev;
|
||||||
struct drm_rect clip;
|
struct drm_rect clip;
|
||||||
|
int idx;
|
||||||
|
|
||||||
if (!fb)
|
if (!fb)
|
||||||
return;
|
return;
|
||||||
|
@ -666,8 +684,13 @@ simpledrm_simple_display_pipe_update(struct drm_simple_display_pipe *pipe,
|
||||||
if (!drm_atomic_helper_damage_merged(old_plane_state, plane_state, &clip))
|
if (!drm_atomic_helper_damage_merged(old_plane_state, plane_state, &clip))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!drm_dev_enter(dev, &idx))
|
||||||
|
return;
|
||||||
|
|
||||||
drm_fb_blit_rect_dstclip(sdev->screen_base, sdev->pitch,
|
drm_fb_blit_rect_dstclip(sdev->screen_base, sdev->pitch,
|
||||||
sdev->format->format, vmap, fb, &clip);
|
sdev->format->format, vmap, fb, &clip);
|
||||||
|
|
||||||
|
drm_dev_exit(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct drm_simple_display_pipe_funcs
|
static const struct drm_simple_display_pipe_funcs
|
||||||
|
@ -847,7 +870,7 @@ static int simpledrm_remove(struct platform_device *pdev)
|
||||||
struct simpledrm_device *sdev = platform_get_drvdata(pdev);
|
struct simpledrm_device *sdev = platform_get_drvdata(pdev);
|
||||||
struct drm_device *dev = &sdev->dev;
|
struct drm_device *dev = &sdev->dev;
|
||||||
|
|
||||||
drm_dev_unregister(dev);
|
drm_dev_unplug(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue