| .. | .. |
|---|
| 23 | 23 | * Authors: |
|---|
| 24 | 24 | * David Airlie |
|---|
| 25 | 25 | */ |
|---|
| 26 | | -#include <linux/module.h> |
|---|
| 27 | | -#include <linux/slab.h> |
|---|
| 28 | | -#include <linux/pm_runtime.h> |
|---|
| 29 | 26 | |
|---|
| 30 | | -#include <drm/drmP.h> |
|---|
| 27 | +#include <linux/module.h> |
|---|
| 28 | +#include <linux/pci.h> |
|---|
| 29 | +#include <linux/pm_runtime.h> |
|---|
| 30 | +#include <linux/slab.h> |
|---|
| 31 | +#include <linux/vga_switcheroo.h> |
|---|
| 32 | + |
|---|
| 31 | 33 | #include <drm/drm_crtc.h> |
|---|
| 32 | 34 | #include <drm/drm_crtc_helper.h> |
|---|
| 33 | | -#include <drm/radeon_drm.h> |
|---|
| 34 | | -#include "radeon.h" |
|---|
| 35 | | - |
|---|
| 36 | 35 | #include <drm/drm_fb_helper.h> |
|---|
| 36 | +#include <drm/drm_fourcc.h> |
|---|
| 37 | +#include <drm/radeon_drm.h> |
|---|
| 37 | 38 | |
|---|
| 38 | | -#include <linux/vga_switcheroo.h> |
|---|
| 39 | +#include "radeon.h" |
|---|
| 39 | 40 | |
|---|
| 40 | 41 | /* object hierarchy - |
|---|
| 41 | 42 | * this contains a helper + a radeon fb |
|---|
| 42 | 43 | * the helper contains a pointer to radeon framebuffer baseclass. |
|---|
| 43 | 44 | */ |
|---|
| 44 | 45 | struct radeon_fbdev { |
|---|
| 45 | | - struct drm_fb_helper helper; |
|---|
| 46 | + struct drm_fb_helper helper; /* must be first */ |
|---|
| 46 | 47 | struct drm_framebuffer fb; |
|---|
| 47 | 48 | struct radeon_device *rdev; |
|---|
| 48 | 49 | }; |
|---|
| .. | .. |
|---|
| 72 | 73 | return 0; |
|---|
| 73 | 74 | } |
|---|
| 74 | 75 | |
|---|
| 75 | | -static struct fb_ops radeonfb_ops = { |
|---|
| 76 | +static const struct fb_ops radeonfb_ops = { |
|---|
| 76 | 77 | .owner = THIS_MODULE, |
|---|
| 77 | 78 | DRM_FB_HELPER_DEFAULT_OPS, |
|---|
| 78 | 79 | .fb_open = radeonfb_open, |
|---|
| .. | .. |
|---|
| 118 | 119 | radeon_bo_unpin(rbo); |
|---|
| 119 | 120 | radeon_bo_unreserve(rbo); |
|---|
| 120 | 121 | } |
|---|
| 121 | | - drm_gem_object_put_unlocked(gobj); |
|---|
| 122 | + drm_gem_object_put(gobj); |
|---|
| 122 | 123 | } |
|---|
| 123 | 124 | |
|---|
| 124 | 125 | static int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev, |
|---|
| 125 | 126 | struct drm_mode_fb_cmd2 *mode_cmd, |
|---|
| 126 | 127 | struct drm_gem_object **gobj_p) |
|---|
| 127 | 128 | { |
|---|
| 129 | + const struct drm_format_info *info; |
|---|
| 128 | 130 | struct radeon_device *rdev = rfbdev->rdev; |
|---|
| 129 | 131 | struct drm_gem_object *gobj = NULL; |
|---|
| 130 | 132 | struct radeon_bo *rbo = NULL; |
|---|
| .. | .. |
|---|
| 135 | 137 | int height = mode_cmd->height; |
|---|
| 136 | 138 | u32 cpp; |
|---|
| 137 | 139 | |
|---|
| 138 | | - cpp = drm_format_plane_cpp(mode_cmd->pixel_format, 0); |
|---|
| 140 | + info = drm_get_format_info(rdev->ddev, mode_cmd); |
|---|
| 141 | + cpp = info->cpp[0]; |
|---|
| 139 | 142 | |
|---|
| 140 | 143 | /* need to align pitch with crtc limits */ |
|---|
| 141 | 144 | mode_cmd->pitches[0] = radeon_align_pitch(rdev, mode_cmd->width, cpp, |
|---|
| .. | .. |
|---|
| 244 | 247 | goto out; |
|---|
| 245 | 248 | } |
|---|
| 246 | 249 | |
|---|
| 247 | | - info->par = rfbdev; |
|---|
| 250 | + /* radeon resume is fragile and needs a vt switch to help it along */ |
|---|
| 251 | + info->skip_vt_switch = false; |
|---|
| 248 | 252 | |
|---|
| 249 | 253 | ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->fb, &mode_cmd, gobj); |
|---|
| 250 | 254 | if (ret) { |
|---|
| .. | .. |
|---|
| 259 | 263 | |
|---|
| 260 | 264 | memset_io(rbo->kptr, 0x0, radeon_bo_size(rbo)); |
|---|
| 261 | 265 | |
|---|
| 262 | | - strcpy(info->fix.id, "radeondrmfb"); |
|---|
| 263 | | - |
|---|
| 264 | | - drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); |
|---|
| 265 | | - |
|---|
| 266 | 266 | info->fbops = &radeonfb_ops; |
|---|
| 267 | 267 | |
|---|
| 268 | 268 | tmp = radeon_bo_gpu_offset(rbo) - rdev->mc.vram_start; |
|---|
| .. | .. |
|---|
| 271 | 271 | info->screen_base = rbo->kptr; |
|---|
| 272 | 272 | info->screen_size = radeon_bo_size(rbo); |
|---|
| 273 | 273 | |
|---|
| 274 | | - drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height); |
|---|
| 274 | + drm_fb_helper_fill_info(info, &rfbdev->helper, sizes); |
|---|
| 275 | 275 | |
|---|
| 276 | 276 | /* setup aperture base/size for vesafb takeover */ |
|---|
| 277 | 277 | info->apertures->ranges[0].base = rdev->ddev->mode_config.fb_base; |
|---|
| .. | .. |
|---|
| 298 | 298 | |
|---|
| 299 | 299 | } |
|---|
| 300 | 300 | if (fb && ret) { |
|---|
| 301 | | - drm_gem_object_put_unlocked(gobj); |
|---|
| 301 | + drm_gem_object_put(gobj); |
|---|
| 302 | 302 | drm_framebuffer_unregister_private(fb); |
|---|
| 303 | 303 | drm_framebuffer_cleanup(fb); |
|---|
| 304 | 304 | kfree(fb); |
|---|
| .. | .. |
|---|
| 354 | 354 | drm_fb_helper_prepare(rdev->ddev, &rfbdev->helper, |
|---|
| 355 | 355 | &radeon_fb_helper_funcs); |
|---|
| 356 | 356 | |
|---|
| 357 | | - ret = drm_fb_helper_init(rdev->ddev, &rfbdev->helper, |
|---|
| 358 | | - RADEONFB_CONN_LIMIT); |
|---|
| 357 | + ret = drm_fb_helper_init(rdev->ddev, &rfbdev->helper); |
|---|
| 359 | 358 | if (ret) |
|---|
| 360 | 359 | goto free; |
|---|
| 361 | | - |
|---|
| 362 | | - ret = drm_fb_helper_single_add_all_connectors(&rfbdev->helper); |
|---|
| 363 | | - if (ret) |
|---|
| 364 | | - goto fini; |
|---|
| 365 | 360 | |
|---|
| 366 | 361 | /* disable all the possible outputs/crtcs before entering KMS mode */ |
|---|
| 367 | 362 | drm_helper_disable_unused_functions(rdev->ddev); |
|---|
| .. | .. |
|---|
| 403 | 398 | if (robj == gem_to_radeon_bo(rdev->mode_info.rfbdev->fb.obj[0])) |
|---|
| 404 | 399 | return true; |
|---|
| 405 | 400 | return false; |
|---|
| 406 | | -} |
|---|
| 407 | | - |
|---|
| 408 | | -void radeon_fb_add_connector(struct radeon_device *rdev, struct drm_connector *connector) |
|---|
| 409 | | -{ |
|---|
| 410 | | - if (rdev->mode_info.rfbdev) |
|---|
| 411 | | - drm_fb_helper_add_one_connector(&rdev->mode_info.rfbdev->helper, connector); |
|---|
| 412 | | -} |
|---|
| 413 | | - |
|---|
| 414 | | -void radeon_fb_remove_connector(struct radeon_device *rdev, struct drm_connector *connector) |
|---|
| 415 | | -{ |
|---|
| 416 | | - if (rdev->mode_info.rfbdev) |
|---|
| 417 | | - drm_fb_helper_remove_one_connector(&rdev->mode_info.rfbdev->helper, connector); |
|---|
| 418 | 401 | } |
|---|