Skip to content

Commit

Permalink
drm/fbdev-generic: Convert to fbdev-ttm
Browse files Browse the repository at this point in the history
Only TTM-based drivers use fbdev-generic. Rename it to fbdev-ttm and
change the symbol infix from _generic_ to _ttm_. Link the source file
into TTM helpers, so that it is only build if TTM-based drivers have
been selected. Select DRM_TTM_HELPER for loongson.

Signed-off-by: Thomas Zimmermann <[email protected]>
Reviewed-by: Javier Martinez Canillas <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
Thomas Zimmermann committed May 2, 2024
1 parent c32705b commit aae4682
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Documentation/gpu/drm-kms-helpers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fbdev Helper Functions Reference
.. kernel-doc:: drivers/gpu/drm/drm_fb_helper.c
:export:

.. kernel-doc:: drivers/gpu/drm/drm_fbdev_generic.c
.. kernel-doc:: drivers/gpu/drm/drm_fbdev_ttm.c
:export:

format Helper Functions Reference
Expand Down
5 changes: 2 additions & 3 deletions drivers/gpu/drm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ drm_vram_helper-y := drm_gem_vram_helper.o
obj-$(CONFIG_DRM_VRAM_HELPER) += drm_vram_helper.o

drm_ttm_helper-y := drm_gem_ttm_helper.o
drm_ttm_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fbdev_ttm.o
obj-$(CONFIG_DRM_TTM_HELPER) += drm_ttm_helper.o

#
Expand All @@ -143,9 +144,7 @@ drm_kms_helper-y := \
drm_self_refresh_helper.o \
drm_simple_kms_helper.o
drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += \
drm_fbdev_generic.o \
drm_fb_helper.o
drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o

#
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <drm/amdgpu_drm.h>
#include <drm/drm_drv.h>
#include <drm/drm_fbdev_generic.h>
#include <drm/drm_fbdev_ttm.h>
#include <drm/drm_gem.h>
#include <drm/drm_managed.h>
#include <drm/drm_pciids.h>
Expand Down Expand Up @@ -2318,9 +2318,9 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
!list_empty(&adev_to_drm(adev)->mode_config.connector_list)) {
/* select 8 bpp console on low vram cards */
if (adev->gmc.real_vram_size <= (32*1024*1024))
drm_fbdev_generic_setup(adev_to_drm(adev), 8);
drm_fbdev_ttm_setup(adev_to_drm(adev), 8);
else
drm_fbdev_generic_setup(adev_to_drm(adev), 32);
drm_fbdev_ttm_setup(adev_to_drm(adev), 32);
}

ret = amdgpu_debugfs_init(adev);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include <drm/drm_gem.h>
#include <drm/drm_print.h>

#include <drm/drm_fbdev_generic.h>
#include <drm/drm_fbdev_ttm.h>

/* @user: 1=userspace, 0=fbcon */
static int drm_fbdev_generic_fb_open(struct fb_info *info, int user)
static int drm_fbdev_ttm_fb_open(struct fb_info *info, int user)
{
struct drm_fb_helper *fb_helper = info->par;

Expand All @@ -24,7 +24,7 @@ static int drm_fbdev_generic_fb_open(struct fb_info *info, int user)
return 0;
}

static int drm_fbdev_generic_fb_release(struct fb_info *info, int user)
static int drm_fbdev_ttm_fb_release(struct fb_info *info, int user)
{
struct drm_fb_helper *fb_helper = info->par;

Expand All @@ -34,11 +34,11 @@ static int drm_fbdev_generic_fb_release(struct fb_info *info, int user)
return 0;
}

FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(drm_fbdev_generic,
FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(drm_fbdev_ttm,
drm_fb_helper_damage_range,
drm_fb_helper_damage_area);

static void drm_fbdev_generic_fb_destroy(struct fb_info *info)
static void drm_fbdev_ttm_fb_destroy(struct fb_info *info)
{
struct drm_fb_helper *fb_helper = info->par;
void *shadow = info->screen_buffer;
Expand All @@ -56,19 +56,19 @@ static void drm_fbdev_generic_fb_destroy(struct fb_info *info)
kfree(fb_helper);
}

static const struct fb_ops drm_fbdev_generic_fb_ops = {
static const struct fb_ops drm_fbdev_ttm_fb_ops = {
.owner = THIS_MODULE,
.fb_open = drm_fbdev_generic_fb_open,
.fb_release = drm_fbdev_generic_fb_release,
FB_DEFAULT_DEFERRED_OPS(drm_fbdev_generic),
.fb_open = drm_fbdev_ttm_fb_open,
.fb_release = drm_fbdev_ttm_fb_release,
FB_DEFAULT_DEFERRED_OPS(drm_fbdev_ttm),
DRM_FB_HELPER_DEFAULT_OPS,
.fb_destroy = drm_fbdev_generic_fb_destroy,
.fb_destroy = drm_fbdev_ttm_fb_destroy,
};

/*
* This function uses the client API to create a framebuffer backed by a dumb buffer.
*/
static int drm_fbdev_generic_helper_fb_probe(struct drm_fb_helper *fb_helper,
static int drm_fbdev_ttm_helper_fb_probe(struct drm_fb_helper *fb_helper,
struct drm_fb_helper_surface_size *sizes)
{
struct drm_client_dev *client = &fb_helper->client;
Expand Down Expand Up @@ -108,7 +108,7 @@ static int drm_fbdev_generic_helper_fb_probe(struct drm_fb_helper *fb_helper,

drm_fb_helper_fill_info(info, fb_helper, sizes);

info->fbops = &drm_fbdev_generic_fb_ops;
info->fbops = &drm_fbdev_ttm_fb_ops;

/* screen */
info->flags |= FBINFO_VIRTFB | FBINFO_READS_FAST;
Expand Down Expand Up @@ -137,9 +137,9 @@ static int drm_fbdev_generic_helper_fb_probe(struct drm_fb_helper *fb_helper,
return ret;
}

static void drm_fbdev_generic_damage_blit_real(struct drm_fb_helper *fb_helper,
struct drm_clip_rect *clip,
struct iosys_map *dst)
static void drm_fbdev_ttm_damage_blit_real(struct drm_fb_helper *fb_helper,
struct drm_clip_rect *clip,
struct iosys_map *dst)
{
struct drm_framebuffer *fb = fb_helper->fb;
size_t offset = clip->y1 * fb->pitches[0];
Expand Down Expand Up @@ -176,8 +176,8 @@ static void drm_fbdev_generic_damage_blit_real(struct drm_fb_helper *fb_helper,
}
}

static int drm_fbdev_generic_damage_blit(struct drm_fb_helper *fb_helper,
struct drm_clip_rect *clip)
static int drm_fbdev_ttm_damage_blit(struct drm_fb_helper *fb_helper,
struct drm_clip_rect *clip)
{
struct drm_client_buffer *buffer = fb_helper->buffer;
struct iosys_map map, dst;
Expand All @@ -201,7 +201,7 @@ static int drm_fbdev_generic_damage_blit(struct drm_fb_helper *fb_helper,
goto out;

dst = map;
drm_fbdev_generic_damage_blit_real(fb_helper, clip, &dst);
drm_fbdev_ttm_damage_blit_real(fb_helper, clip, &dst);

drm_client_buffer_vunmap_local(buffer);

Expand All @@ -211,8 +211,8 @@ static int drm_fbdev_generic_damage_blit(struct drm_fb_helper *fb_helper,
return ret;
}

static int drm_fbdev_generic_helper_fb_dirty(struct drm_fb_helper *helper,
struct drm_clip_rect *clip)
static int drm_fbdev_ttm_helper_fb_dirty(struct drm_fb_helper *helper,
struct drm_clip_rect *clip)
{
struct drm_device *dev = helper->dev;
int ret;
Expand All @@ -221,7 +221,7 @@ static int drm_fbdev_generic_helper_fb_dirty(struct drm_fb_helper *helper,
if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
return 0;

ret = drm_fbdev_generic_damage_blit(helper, clip);
ret = drm_fbdev_ttm_damage_blit(helper, clip);
if (drm_WARN_ONCE(dev, ret, "Damage blitter failed: ret=%d\n", ret))
return ret;

Expand All @@ -234,12 +234,12 @@ static int drm_fbdev_generic_helper_fb_dirty(struct drm_fb_helper *helper,
return 0;
}

static const struct drm_fb_helper_funcs drm_fbdev_generic_helper_funcs = {
.fb_probe = drm_fbdev_generic_helper_fb_probe,
.fb_dirty = drm_fbdev_generic_helper_fb_dirty,
static const struct drm_fb_helper_funcs drm_fbdev_ttm_helper_funcs = {
.fb_probe = drm_fbdev_ttm_helper_fb_probe,
.fb_dirty = drm_fbdev_ttm_helper_fb_dirty,
};

static void drm_fbdev_generic_client_unregister(struct drm_client_dev *client)
static void drm_fbdev_ttm_client_unregister(struct drm_client_dev *client)
{
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);

Expand All @@ -252,14 +252,14 @@ static void drm_fbdev_generic_client_unregister(struct drm_client_dev *client)
}
}

static int drm_fbdev_generic_client_restore(struct drm_client_dev *client)
static int drm_fbdev_ttm_client_restore(struct drm_client_dev *client)
{
drm_fb_helper_lastclose(client->dev);

return 0;
}

static int drm_fbdev_generic_client_hotplug(struct drm_client_dev *client)
static int drm_fbdev_ttm_client_hotplug(struct drm_client_dev *client)
{
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
struct drm_device *dev = client->dev;
Expand All @@ -284,32 +284,32 @@ static int drm_fbdev_generic_client_hotplug(struct drm_client_dev *client)
err_drm_fb_helper_fini:
drm_fb_helper_fini(fb_helper);
err_drm_err:
drm_err(dev, "fbdev: Failed to setup generic emulation (ret=%d)\n", ret);
drm_err(dev, "fbdev: Failed to setup emulation (ret=%d)\n", ret);
return ret;
}

static const struct drm_client_funcs drm_fbdev_generic_client_funcs = {
static const struct drm_client_funcs drm_fbdev_ttm_client_funcs = {
.owner = THIS_MODULE,
.unregister = drm_fbdev_generic_client_unregister,
.restore = drm_fbdev_generic_client_restore,
.hotplug = drm_fbdev_generic_client_hotplug,
.unregister = drm_fbdev_ttm_client_unregister,
.restore = drm_fbdev_ttm_client_restore,
.hotplug = drm_fbdev_ttm_client_hotplug,
};

/**
* drm_fbdev_generic_setup() - Setup generic fbdev emulation
* drm_fbdev_ttm_setup() - Setup fbdev emulation for TTM-based drivers
* @dev: DRM device
* @preferred_bpp: Preferred bits per pixel for the device.
*
* This function sets up generic fbdev emulation for drivers that supports
* This function sets up fbdev emulation for TTM-based drivers that support
* dumb buffers with a virtual address and that can be mmap'ed.
* drm_fbdev_generic_setup() shall be called after the DRM driver registered
* drm_fbdev_ttm_setup() shall be called after the DRM driver registered
* the new DRM device with drm_dev_register().
*
* Restore, hotplug events and teardown are all taken care of. Drivers that do
* suspend/resume need to call drm_fb_helper_set_suspend_unlocked() themselves.
* Simple drivers might use drm_mode_config_helper_suspend().
*
* In order to provide fixed mmap-able memory ranges, generic fbdev emulation
* In order to provide fixed mmap-able memory ranges, fbdev emulation
* uses a shadow buffer in system memory. The implementation blits the shadow
* fbdev buffer onto the real buffer in regular intervals.
*
Expand All @@ -318,7 +318,7 @@ static const struct drm_client_funcs drm_fbdev_generic_client_funcs = {
*
* The fbdev is destroyed by drm_dev_unregister().
*/
void drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp)
void drm_fbdev_ttm_setup(struct drm_device *dev, unsigned int preferred_bpp)
{
struct drm_fb_helper *fb_helper;
int ret;
Expand All @@ -329,9 +329,9 @@ void drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp)
fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
if (!fb_helper)
return;
drm_fb_helper_prepare(dev, fb_helper, preferred_bpp, &drm_fbdev_generic_helper_funcs);
drm_fb_helper_prepare(dev, fb_helper, preferred_bpp, &drm_fbdev_ttm_helper_funcs);

ret = drm_client_init(dev, &fb_helper->client, "fbdev", &drm_fbdev_generic_client_funcs);
ret = drm_client_init(dev, &fb_helper->client, "fbdev", &drm_fbdev_ttm_client_funcs);
if (ret) {
drm_err(dev, "Failed to register client: %d\n", ret);
goto err_drm_client_init;
Expand All @@ -346,4 +346,4 @@ void drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp)
kfree(fb_helper);
return;
}
EXPORT_SYMBOL(drm_fbdev_generic_setup);
EXPORT_SYMBOL(drm_fbdev_ttm_setup);
4 changes: 2 additions & 2 deletions drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <drm/drm_aperture.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fbdev_generic.h>
#include <drm/drm_fbdev_ttm.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_gem_vram_helper.h>
#include <drm/drm_managed.h>
Expand Down Expand Up @@ -339,7 +339,7 @@ static int hibmc_pci_probe(struct pci_dev *pdev,
goto err_unload;
}

drm_fbdev_generic_setup(dev, 32);
drm_fbdev_ttm_setup(dev, 32);

return 0;

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/loongson/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ config DRM_LOONGSON
depends on LOONGARCH || MIPS || COMPILE_TEST
select DRM_KMS_HELPER
select DRM_TTM
select DRM_TTM_HELPER
select I2C
select I2C_ALGOBIT
help
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/loongson/lsdc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fbdev_generic.h>
#include <drm/drm_fbdev_ttm.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_modeset_helper.h>
Expand Down Expand Up @@ -314,7 +314,7 @@ static int lsdc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret)
return ret;

drm_fbdev_generic_setup(ddev, 32);
drm_fbdev_ttm_setup(ddev, 32);

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/nouveau/nouveau_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include <drm/drm_aperture.h>
#include <drm/drm_drv.h>
#include <drm/drm_fbdev_generic.h>
#include <drm/drm_fbdev_ttm.h>
#include <drm/drm_gem_ttm_helper.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_vblank.h>
Expand Down Expand Up @@ -846,9 +846,9 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
goto fail_drm_dev_init;

if (nouveau_drm(drm_dev)->client.device.info.ram_size <= 32 * 1024 * 1024)
drm_fbdev_generic_setup(drm_dev, 8);
drm_fbdev_ttm_setup(drm_dev, 8);
else
drm_fbdev_generic_setup(drm_dev, 32);
drm_fbdev_ttm_setup(drm_dev, 32);

quirk_broken_nv_runpm(pdev);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/qxl/qxl_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <drm/drm_aperture.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fbdev_generic.h>
#include <drm/drm_fbdev_ttm.h>
#include <drm/drm_file.h>
#include <drm/drm_gem_ttm_helper.h>
#include <drm/drm_module.h>
Expand Down Expand Up @@ -118,7 +118,7 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret)
goto modeset_cleanup;

drm_fbdev_generic_setup(&qdev->ddev, 32);
drm_fbdev_ttm_setup(&qdev->ddev, 32);
return 0;

modeset_cleanup:
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/tiny/bochs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_edid.h>
#include <drm/drm_fbdev_generic.h>
#include <drm/drm_fbdev_ttm.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_framebuffer_helper.h>
Expand Down Expand Up @@ -670,7 +670,7 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
if (ret)
goto err_hw_fini;

drm_fbdev_generic_setup(dev, 32);
drm_fbdev_ttm_setup(dev, 32);
return ret;

err_hw_fini:
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/vboxvideo/vbox_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <drm/drm_aperture.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fbdev_generic.h>
#include <drm/drm_fbdev_ttm.h>
#include <drm/drm_file.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_managed.h>
Expand Down Expand Up @@ -80,7 +80,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret)
goto err_irq_fini;

drm_fbdev_generic_setup(&vbox->ddev, 32);
drm_fbdev_ttm_setup(&vbox->ddev, 32);

return 0;

Expand Down
Loading

0 comments on commit aae4682

Please sign in to comment.