[PATCH 11/11] drm/tegra: Use fbdev client helpers

Felix Kuehling felix.kuehling at amd.com
Tue May 7 21:03:41 UTC 2024


On 2024-05-07 07:58, Thomas Zimmermann wrote:
> Implement struct drm_client_funcs with the respective helpers and
> remove the custom code from the emulation. The generic helpers are
> equivalent in functionality.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> ---
>   drivers/gpu/drm/radeon/radeon_fbdev.c | 66 ++-------------------------

Was radeon meant to be a separate patch?

Regards,
   Felix


>   drivers/gpu/drm/tegra/fbdev.c         | 58 ++---------------------
>   2 files changed, 6 insertions(+), 118 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_fbdev.c b/drivers/gpu/drm/radeon/radeon_fbdev.c
> index 02bf25759059a..cf790922174ea 100644
> --- a/drivers/gpu/drm/radeon/radeon_fbdev.c
> +++ b/drivers/gpu/drm/radeon/radeon_fbdev.c
> @@ -29,7 +29,6 @@
>   #include <linux/pm_runtime.h>
>   #include <linux/vga_switcheroo.h>
>   
> -#include <drm/drm_crtc_helper.h>
>   #include <drm/drm_drv.h>
>   #include <drm/drm_fb_helper.h>
>   #include <drm/drm_fourcc.h>
> @@ -293,71 +292,12 @@ static const struct drm_fb_helper_funcs radeon_fbdev_fb_helper_funcs = {
>   };
>   
>   /*
> - * Fbdev client and struct drm_client_funcs
> + * struct drm_client_funcs
>    */
>   
> -static void radeon_fbdev_client_unregister(struct drm_client_dev *client)
> -{
> -	struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
> -	struct drm_device *dev = fb_helper->dev;
> -	struct radeon_device *rdev = dev->dev_private;
> -
> -	if (fb_helper->info) {
> -		vga_switcheroo_client_fb_set(rdev->pdev, NULL);
> -		drm_helper_force_disable_all(dev);
> -		drm_fb_helper_unregister_info(fb_helper);
> -	} else {
> -		drm_client_release(&fb_helper->client);
> -		drm_fb_helper_unprepare(fb_helper);
> -		kfree(fb_helper);
> -	}
> -}
> -
> -static int radeon_fbdev_client_restore(struct drm_client_dev *client)
> -{
> -	drm_fb_helper_lastclose(client->dev);
> -	vga_switcheroo_process_delayed_switch();
> -
> -	return 0;
> -}
> -
> -static int radeon_fbdev_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;
> -	struct radeon_device *rdev = dev->dev_private;
> -	int ret;
> -
> -	if (dev->fb_helper)
> -		return drm_fb_helper_hotplug_event(dev->fb_helper);
> -
> -	ret = drm_fb_helper_init(dev, fb_helper);
> -	if (ret)
> -		goto err_drm_err;
> -
> -	if (!drm_drv_uses_atomic_modeset(dev))
> -		drm_helper_disable_unused_functions(dev);
> -
> -	ret = drm_fb_helper_initial_config(fb_helper);
> -	if (ret)
> -		goto err_drm_fb_helper_fini;
> -
> -	vga_switcheroo_client_fb_set(rdev->pdev, fb_helper->info);
> -
> -	return 0;
> -
> -err_drm_fb_helper_fini:
> -	drm_fb_helper_fini(fb_helper);
> -err_drm_err:
> -	drm_err(dev, "Failed to setup radeon fbdev emulation (ret=%d)\n", ret);
> -	return ret;
> -}
> -
>   static const struct drm_client_funcs radeon_fbdev_client_funcs = {
> -	.owner		= THIS_MODULE,
> -	.unregister	= radeon_fbdev_client_unregister,
> -	.restore	= radeon_fbdev_client_restore,
> -	.hotplug	= radeon_fbdev_client_hotplug,
> +	.owner = THIS_MODULE,
> +	DRM_FBDEV_HELPER_CLIENT_FUNCS,
>   };
>   
>   void radeon_fbdev_setup(struct radeon_device *rdev)
> diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c
> index db6eaac3d30e6..f9cc365cfed94 100644
> --- a/drivers/gpu/drm/tegra/fbdev.c
> +++ b/drivers/gpu/drm/tegra/fbdev.c
> @@ -12,7 +12,6 @@
>   #include <linux/vmalloc.h>
>   
>   #include <drm/drm_drv.h>
> -#include <drm/drm_crtc_helper.h>
>   #include <drm/drm_fb_helper.h>
>   #include <drm/drm_fourcc.h>
>   #include <drm/drm_framebuffer.h>
> @@ -150,63 +149,12 @@ static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = {
>   };
>   
>   /*
> - * struct drm_client
> + * struct drm_client_funcs
>    */
>   
> -static void tegra_fbdev_client_unregister(struct drm_client_dev *client)
> -{
> -	struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
> -
> -	if (fb_helper->info) {
> -		drm_fb_helper_unregister_info(fb_helper);
> -	} else {
> -		drm_client_release(&fb_helper->client);
> -		drm_fb_helper_unprepare(fb_helper);
> -		kfree(fb_helper);
> -	}
> -}
> -
> -static int tegra_fbdev_client_restore(struct drm_client_dev *client)
> -{
> -	drm_fb_helper_lastclose(client->dev);
> -
> -	return 0;
> -}
> -
> -static int tegra_fbdev_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;
> -	int ret;
> -
> -	if (dev->fb_helper)
> -		return drm_fb_helper_hotplug_event(dev->fb_helper);
> -
> -	ret = drm_fb_helper_init(dev, fb_helper);
> -	if (ret)
> -		goto err_drm_err;
> -
> -	if (!drm_drv_uses_atomic_modeset(dev))
> -		drm_helper_disable_unused_functions(dev);
> -
> -	ret = drm_fb_helper_initial_config(fb_helper);
> -	if (ret)
> -		goto err_drm_fb_helper_fini;
> -
> -	return 0;
> -
> -err_drm_fb_helper_fini:
> -	drm_fb_helper_fini(fb_helper);
> -err_drm_err:
> -	drm_err(dev, "Failed to setup fbdev emulation (ret=%d)\n", ret);
> -	return ret;
> -}
> -
>   static const struct drm_client_funcs tegra_fbdev_client_funcs = {
> -	.owner		= THIS_MODULE,
> -	.unregister	= tegra_fbdev_client_unregister,
> -	.restore	= tegra_fbdev_client_restore,
> -	.hotplug	= tegra_fbdev_client_hotplug,
> +	.owner = THIS_MODULE,
> +	DRM_FBDEV_HELPER_CLIENT_FUNCS,
>   };
>   
>   void tegra_fbdev_setup(struct drm_device *dev)


More information about the amd-gfx mailing list