hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/gpu/drm/radeon/radeon_fb.c
....@@ -23,26 +23,27 @@
2323 * Authors:
2424 * David Airlie
2525 */
26
-#include <linux/module.h>
27
-#include <linux/slab.h>
28
-#include <linux/pm_runtime.h>
2926
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
+
3133 #include <drm/drm_crtc.h>
3234 #include <drm/drm_crtc_helper.h>
33
-#include <drm/radeon_drm.h>
34
-#include "radeon.h"
35
-
3635 #include <drm/drm_fb_helper.h>
36
+#include <drm/drm_fourcc.h>
37
+#include <drm/radeon_drm.h>
3738
38
-#include <linux/vga_switcheroo.h>
39
+#include "radeon.h"
3940
4041 /* object hierarchy -
4142 * this contains a helper + a radeon fb
4243 * the helper contains a pointer to radeon framebuffer baseclass.
4344 */
4445 struct radeon_fbdev {
45
- struct drm_fb_helper helper;
46
+ struct drm_fb_helper helper; /* must be first */
4647 struct drm_framebuffer fb;
4748 struct radeon_device *rdev;
4849 };
....@@ -72,7 +73,7 @@
7273 return 0;
7374 }
7475
75
-static struct fb_ops radeonfb_ops = {
76
+static const struct fb_ops radeonfb_ops = {
7677 .owner = THIS_MODULE,
7778 DRM_FB_HELPER_DEFAULT_OPS,
7879 .fb_open = radeonfb_open,
....@@ -118,13 +119,14 @@
118119 radeon_bo_unpin(rbo);
119120 radeon_bo_unreserve(rbo);
120121 }
121
- drm_gem_object_put_unlocked(gobj);
122
+ drm_gem_object_put(gobj);
122123 }
123124
124125 static int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev,
125126 struct drm_mode_fb_cmd2 *mode_cmd,
126127 struct drm_gem_object **gobj_p)
127128 {
129
+ const struct drm_format_info *info;
128130 struct radeon_device *rdev = rfbdev->rdev;
129131 struct drm_gem_object *gobj = NULL;
130132 struct radeon_bo *rbo = NULL;
....@@ -135,7 +137,8 @@
135137 int height = mode_cmd->height;
136138 u32 cpp;
137139
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];
139142
140143 /* need to align pitch with crtc limits */
141144 mode_cmd->pitches[0] = radeon_align_pitch(rdev, mode_cmd->width, cpp,
....@@ -244,7 +247,8 @@
244247 goto out;
245248 }
246249
247
- info->par = rfbdev;
250
+ /* radeon resume is fragile and needs a vt switch to help it along */
251
+ info->skip_vt_switch = false;
248252
249253 ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->fb, &mode_cmd, gobj);
250254 if (ret) {
....@@ -259,10 +263,6 @@
259263
260264 memset_io(rbo->kptr, 0x0, radeon_bo_size(rbo));
261265
262
- strcpy(info->fix.id, "radeondrmfb");
263
-
264
- drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
265
-
266266 info->fbops = &radeonfb_ops;
267267
268268 tmp = radeon_bo_gpu_offset(rbo) - rdev->mc.vram_start;
....@@ -271,7 +271,7 @@
271271 info->screen_base = rbo->kptr;
272272 info->screen_size = radeon_bo_size(rbo);
273273
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);
275275
276276 /* setup aperture base/size for vesafb takeover */
277277 info->apertures->ranges[0].base = rdev->ddev->mode_config.fb_base;
....@@ -298,7 +298,7 @@
298298
299299 }
300300 if (fb && ret) {
301
- drm_gem_object_put_unlocked(gobj);
301
+ drm_gem_object_put(gobj);
302302 drm_framebuffer_unregister_private(fb);
303303 drm_framebuffer_cleanup(fb);
304304 kfree(fb);
....@@ -354,14 +354,9 @@
354354 drm_fb_helper_prepare(rdev->ddev, &rfbdev->helper,
355355 &radeon_fb_helper_funcs);
356356
357
- ret = drm_fb_helper_init(rdev->ddev, &rfbdev->helper,
358
- RADEONFB_CONN_LIMIT);
357
+ ret = drm_fb_helper_init(rdev->ddev, &rfbdev->helper);
359358 if (ret)
360359 goto free;
361
-
362
- ret = drm_fb_helper_single_add_all_connectors(&rfbdev->helper);
363
- if (ret)
364
- goto fini;
365360
366361 /* disable all the possible outputs/crtcs before entering KMS mode */
367362 drm_helper_disable_unused_functions(rdev->ddev);
....@@ -403,16 +398,4 @@
403398 if (robj == gem_to_radeon_bo(rdev->mode_info.rfbdev->fb.obj[0]))
404399 return true;
405400 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);
418401 }