Bug Summary

File:dev/pci/drm/radeon/radeon_fb.c
Warning:line 278, column 2
Value stored to 'tmp' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.4 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name radeon_fb.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -ffp-contract=on -fno-rounding-math -mconstructor-aliases -ffreestanding -mcmodel=kernel -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -target-feature -sse2 -target-feature -sse -target-feature -3dnow -target-feature -mmx -target-feature +save-args -target-feature +retpoline-external-thunk -disable-red-zone -no-implicit-float -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -nostdsysteminc -nobuiltininc -resource-dir /usr/local/llvm16/lib/clang/16 -I /usr/src/sys -I /usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -I /usr/src/sys/arch -I /usr/src/sys/dev/pci/drm/include -I /usr/src/sys/dev/pci/drm/include/uapi -I /usr/src/sys/dev/pci/drm/amd/include/asic_reg -I /usr/src/sys/dev/pci/drm/amd/include -I /usr/src/sys/dev/pci/drm/amd/amdgpu -I /usr/src/sys/dev/pci/drm/amd/display -I /usr/src/sys/dev/pci/drm/amd/display/include -I /usr/src/sys/dev/pci/drm/amd/display/dc -I /usr/src/sys/dev/pci/drm/amd/display/amdgpu_dm -I /usr/src/sys/dev/pci/drm/amd/pm/inc -I /usr/src/sys/dev/pci/drm/amd/pm/legacy-dpm -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu11 -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu12 -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu13 -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/inc -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/hwmgr -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/smumgr -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/inc/pmfw_if -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc/hw -I /usr/src/sys/dev/pci/drm/amd/display/dc/clk_mgr -I /usr/src/sys/dev/pci/drm/amd/display/modules/inc -I /usr/src/sys/dev/pci/drm/amd/display/modules/hdcp -I /usr/src/sys/dev/pci/drm/amd/display/dmub/inc -I /usr/src/sys/dev/pci/drm/i915 -D DDB -D DIAGNOSTIC -D KTRACE -D ACCOUNTING -D KMEMSTATS -D PTRACE -D POOL_DEBUG -D CRYPTO -D SYSVMSG -D SYSVSEM -D SYSVSHM -D UVM_SWAP_ENCRYPT -D FFS -D FFS2 -D FFS_SOFTUPDATES -D UFS_DIRHASH -D QUOTA -D EXT2FS -D MFS -D NFSCLIENT -D NFSSERVER -D CD9660 -D UDF -D MSDOSFS -D FIFO -D FUSE -D SOCKET_SPLICE -D TCP_ECN -D TCP_SIGNATURE -D INET6 -D IPSEC -D PPP_BSDCOMP -D PPP_DEFLATE -D PIPEX -D MROUTING -D MPLS -D BOOT_CONFIG -D USER_PCICONF -D APERTURE -D MTRR -D NTFS -D SUSPEND -D HIBERNATE -D PCIVERBOSE -D USBVERBOSE -D WSDISPLAY_COMPAT_USL -D WSDISPLAY_COMPAT_RAWKBD -D WSDISPLAY_DEFAULTSCREENS=6 -D X86EMU -D ONEWIREVERBOSE -D MULTIPROCESSOR -D MAXUSERS=80 -D _KERNEL -O2 -Wno-pointer-sign -Wno-address-of-packed-member -Wno-constant-conversion -Wno-unused-but-set-variable -Wno-gnu-folding-constant -fdebug-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fcf-protection=branch -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -o /home/ben/Projects/scan/2024-01-11-110808-61670-1 -x c /usr/src/sys/dev/pci/drm/radeon/radeon_fb.c
1/*
2 * Copyright © 2007 David Airlie
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * David Airlie
25 */
26
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
33#include <drm/drm_crtc.h>
34#include <drm/drm_crtc_helper.h>
35#include <drm/drm_fb_helper.h>
36#include <drm/drm_fourcc.h>
37#include <drm/drm_framebuffer.h>
38#include <drm/radeon_drm.h>
39
40#include "radeon.h"
41
42/* object hierarchy -
43 * this contains a helper + a radeon fb
44 * the helper contains a pointer to radeon framebuffer baseclass.
45 */
46struct radeon_fbdev {
47 struct drm_fb_helper helper; /* must be first */
48 struct drm_framebuffer fb;
49 struct radeon_device *rdev;
50};
51
52#ifdef __linux__
53static int
54radeonfb_open(struct fb_info *info, int user)
55{
56 struct radeon_fbdev *rfbdev = info->par;
57 struct radeon_device *rdev = rfbdev->rdev;
58 int ret = pm_runtime_get_sync(rdev->ddev->dev);
59
60 if (ret < 0 && ret != -EACCES13) {
61 pm_runtime_mark_last_busy(rdev->ddev->dev);
62 pm_runtime_put_autosuspend(rdev->ddev->dev);
63 return ret;
64 }
65 return 0;
66}
67
68static int
69radeonfb_release(struct fb_info *info, int user)
70{
71 struct radeon_fbdev *rfbdev = info->par;
72 struct radeon_device *rdev = rfbdev->rdev;
73
74 pm_runtime_mark_last_busy(rdev->ddev->dev);
75 pm_runtime_put_autosuspend(rdev->ddev->dev);
76 return 0;
77}
78#endif
79
80static const struct fb_ops radeonfb_ops = {
81#ifdef notyet
82 .owner = THIS_MODULE((void *)0),
83 DRM_FB_HELPER_DEFAULT_OPS.fb_set_par = drm_fb_helper_set_par,
84 .fb_open = radeonfb_open,
85 .fb_release = radeonfb_release,
86 .fb_fillrect = drm_fb_helper_cfb_fillrect,
87 .fb_copyarea = drm_fb_helper_cfb_copyarea,
88 .fb_imageblit = drm_fb_helper_cfb_imageblit,
89#else
90 DRM_FB_HELPER_DEFAULT_OPS.fb_set_par = drm_fb_helper_set_par,
91#endif
92};
93
94void radeondrm_burner_cb(void *);
95
96int radeon_align_pitch(struct radeon_device *rdev, int width, int cpp, bool_Bool tiled)
97{
98 int aligned = width;
99 int align_large = (ASIC_IS_AVIVO(rdev)((rdev->family >= CHIP_RS600))) || tiled;
100 int pitch_mask = 0;
101
102 switch (cpp) {
103 case 1:
104 pitch_mask = align_large ? 255 : 127;
105 break;
106 case 2:
107 pitch_mask = align_large ? 127 : 31;
108 break;
109 case 3:
110 case 4:
111 pitch_mask = align_large ? 63 : 15;
112 break;
113 }
114
115 aligned += pitch_mask;
116 aligned &= ~pitch_mask;
117 return aligned * cpp;
118}
119
120static void radeonfb_destroy_pinned_object(struct drm_gem_object *gobj)
121{
122 struct radeon_bo *rbo = gem_to_radeon_bo(gobj)({ const __typeof( ((struct radeon_bo *)0)->tbo.base ) *__mptr
= ((gobj)); (struct radeon_bo *)( (char *)__mptr - __builtin_offsetof
(struct radeon_bo, tbo.base) );})
;
123 int ret;
124
125 ret = radeon_bo_reserve(rbo, false0);
126 if (likely(ret == 0)__builtin_expect(!!(ret == 0), 1)) {
127 radeon_bo_kunmap(rbo);
128 radeon_bo_unpin(rbo);
129 radeon_bo_unreserve(rbo);
130 }
131 drm_gem_object_put(gobj);
132}
133
134static int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev,
135 struct drm_mode_fb_cmd2 *mode_cmd,
136 struct drm_gem_object **gobj_p)
137{
138 const struct drm_format_info *info;
139 struct radeon_device *rdev = rfbdev->rdev;
140 struct drm_gem_object *gobj = NULL((void *)0);
141 struct radeon_bo *rbo = NULL((void *)0);
142 bool_Bool fb_tiled = false0; /* useful for testing */
143 u32 tiling_flags = 0;
144 int ret;
145 int aligned_size, size;
146 int height = mode_cmd->height;
147 u32 cpp;
148
149 info = drm_get_format_info(rdev->ddev, mode_cmd);
150 cpp = info->cpp[0];
151
152 /* need to align pitch with crtc limits */
153 mode_cmd->pitches[0] = radeon_align_pitch(rdev, mode_cmd->width, cpp,
154 fb_tiled);
155
156 if (rdev->family >= CHIP_R600)
157 height = roundup2(mode_cmd->height, 8)(((mode_cmd->height) + ((8) - 1)) & (~((__typeof(mode_cmd
->height))(8) - 1)))
;
158 size = mode_cmd->pitches[0] * height;
159 aligned_size = roundup2(size, PAGE_SIZE)(((size) + (((1 << 12)) - 1)) & (~((__typeof(size))
((1 << 12)) - 1)))
;
160 ret = radeon_gem_object_create(rdev, aligned_size, 0,
161 RADEON_GEM_DOMAIN_VRAM0x4,
162 0, true1, &gobj);
163 if (ret) {
164 pr_err("failed to allocate framebuffer (%d)\n", aligned_size)printk("\0013" "failed to allocate framebuffer (%d)\n", aligned_size
)
;
165 return -ENOMEM12;
166 }
167 rbo = gem_to_radeon_bo(gobj)({ const __typeof( ((struct radeon_bo *)0)->tbo.base ) *__mptr
= ((gobj)); (struct radeon_bo *)( (char *)__mptr - __builtin_offsetof
(struct radeon_bo, tbo.base) );})
;
168
169 if (fb_tiled)
170 tiling_flags = RADEON_TILING_MACRO0x1;
171
172#ifdef __BIG_ENDIAN
173 switch (cpp) {
174 case 4:
175 tiling_flags |= RADEON_TILING_SWAP_32BIT0x8;
176 break;
177 case 2:
178 tiling_flags |= RADEON_TILING_SWAP_16BIT0x4;
179 break;
180 default:
181 break;
182 }
183#endif
184
185 if (tiling_flags) {
186 ret = radeon_bo_set_tiling_flags(rbo,
187 tiling_flags | RADEON_TILING_SURFACE0x10,
188 mode_cmd->pitches[0]);
189 if (ret)
190 dev_err(rdev->dev, "FB failed to set tiling flags\n")printf("drm:pid%d:%s *ERROR* " "FB failed to set tiling flags\n"
, ({struct cpu_info *__ci; asm volatile("movq %%gs:%P1,%0" : "=r"
(__ci) :"n" (__builtin_offsetof(struct cpu_info, ci_self)));
__ci;})->ci_curproc->p_p->ps_pid, __func__)
;
191 }
192
193
194 ret = radeon_bo_reserve(rbo, false0);
195 if (unlikely(ret != 0)__builtin_expect(!!(ret != 0), 0))
196 goto out_unref;
197 /* Only 27 bit offset for legacy CRTC */
198 ret = radeon_bo_pin_restricted(rbo, RADEON_GEM_DOMAIN_VRAM0x4,
199 ASIC_IS_AVIVO(rdev)((rdev->family >= CHIP_RS600)) ? 0 : 1 << 27,
200 NULL((void *)0));
201 if (ret) {
202 radeon_bo_unreserve(rbo);
203 goto out_unref;
204 }
205 if (fb_tiled)
206 radeon_bo_check_tiling(rbo, 0, 0);
207 ret = radeon_bo_kmap(rbo, NULL((void *)0));
208 radeon_bo_unreserve(rbo);
209 if (ret)
210 goto out_unref;
211
212 *gobj_p = gobj;
213 return 0;
214out_unref:
215 radeonfb_destroy_pinned_object(gobj);
216 *gobj_p = NULL((void *)0);
217 return ret;
218}
219
220static int radeonfb_create(struct drm_fb_helper *helper,
221 struct drm_fb_helper_surface_size *sizes)
222{
223 struct radeon_fbdev *rfbdev =
224 container_of(helper, struct radeon_fbdev, helper)({ const __typeof( ((struct radeon_fbdev *)0)->helper ) *__mptr
= (helper); (struct radeon_fbdev *)( (char *)__mptr - __builtin_offsetof
(struct radeon_fbdev, helper) );})
;
225 struct radeon_device *rdev = rfbdev->rdev;
226 struct fb_info *info;
227 struct rasops_info *ri = &rdev->ro;
228 struct drm_framebuffer *fb = NULL((void *)0);
229 struct drm_mode_fb_cmd2 mode_cmd;
230 struct drm_gem_object *gobj = NULL((void *)0);
231 struct radeon_bo *rbo = NULL((void *)0);
232 int ret;
233 unsigned long tmp;
234
235 mode_cmd.width = sizes->surface_width;
236 mode_cmd.height = sizes->surface_height;
237
238 /* avivo can't scanout real 24bpp */
239 if ((sizes->surface_bpp == 24) && ASIC_IS_AVIVO(rdev)((rdev->family >= CHIP_RS600)))
240 sizes->surface_bpp = 32;
241
242 mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
243 sizes->surface_depth);
244
245 ret = radeonfb_create_pinned_object(rfbdev, &mode_cmd, &gobj);
246 if (ret) {
247 DRM_ERROR("failed to create fbcon object %d\n", ret)__drm_err("failed to create fbcon object %d\n", ret);
248 return ret;
249 }
250
251 rbo = gem_to_radeon_bo(gobj)({ const __typeof( ((struct radeon_bo *)0)->tbo.base ) *__mptr
= ((gobj)); (struct radeon_bo *)( (char *)__mptr - __builtin_offsetof
(struct radeon_bo, tbo.base) );})
;
252
253 /* okay we have an object now allocate the framebuffer */
254 info = drm_fb_helper_alloc_fbi(helper);
255 if (IS_ERR(info)) {
256 ret = PTR_ERR(info);
257 goto out;
258 }
259
260 /* radeon resume is fragile and needs a vt switch to help it along */
261 info->skip_vt_switch = false0;
262
263 ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->fb, &mode_cmd, gobj);
264 if (ret) {
265 DRM_ERROR("failed to initialize framebuffer %d\n", ret)__drm_err("failed to initialize framebuffer %d\n", ret);
266 goto out;
267 }
268
269 fb = &rfbdev->fb;
270
271 /* setup helper */
272 rfbdev->helper.fb = fb;
273
274 memset_io(rbo->kptr, 0x0, radeon_bo_size(rbo))__builtin_memset((rbo->kptr), (0x0), (radeon_bo_size(rbo))
)
;
275
276 info->fbops = &radeonfb_ops;
277
278 tmp = radeon_bo_gpu_offset(rbo) - rdev->mc.vram_start;
Value stored to 'tmp' is never read
279#ifdef __linux__
280 info->fix.smem_start = rdev->mc.aper_base + tmp;
281 info->fix.smem_len = radeon_bo_size(rbo);
282 info->screen_base = rbo->kptr;
283 info->screen_size = radeon_bo_size(rbo);
284#endif
285
286 drm_fb_helper_fill_info(info, &rfbdev->helper, sizes);
287
288#ifdef __linux__
289 /* setup aperture base/size for vesafb takeover */
290 info->apertures->ranges[0].base = rdev->ddev->mode_config.fb_base;
291 info->apertures->ranges[0].size = rdev->mc.aper_size;
292#endif
293
294 /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
295
296#ifdef __linux__
297 if (info->screen_base == NULL((void *)0)) {
298 ret = -ENOSPC28;
299 goto out;
300 }
301
302 DRM_INFO("fb mappable at 0x%lX\n", info->fix.smem_start)printk("\0016" "[" "drm" "] " "fb mappable at 0x%lX\n", info->
fix.smem_start)
;
303#endif
304 DRM_INFO("vram apper at 0x%lX\n", (unsigned long)rdev->mc.aper_base)printk("\0016" "[" "drm" "] " "vram apper at 0x%lX\n", (unsigned
long)rdev->mc.aper_base)
;
305 DRM_INFO("size %lu\n", (unsigned long)radeon_bo_size(rbo))printk("\0016" "[" "drm" "] " "size %lu\n", (unsigned long)radeon_bo_size
(rbo))
;
306 DRM_INFO("fb depth is %d\n", fb->format->depth)printk("\0016" "[" "drm" "] " "fb depth is %d\n", fb->format
->depth)
;
307 DRM_INFO(" pitch is %d\n", fb->pitches[0])printk("\0016" "[" "drm" "] " " pitch is %d\n", fb->pitches
[0])
;
308
309 ri->ri_bits = rbo->kptr;
310 ri->ri_depth = fb->format->cpp[0] * 8;
311 ri->ri_stride = fb->pitches[0];
312 ri->ri_width = sizes->fb_width;
313 ri->ri_height = sizes->fb_height;
314
315 switch (fb->format->format) {
316 case DRM_FORMAT_XRGB8888((__u32)('X') | ((__u32)('R') << 8) | ((__u32)('2') <<
16) | ((__u32)('4') << 24))
:
317 ri->ri_rnum = 8;
318 ri->ri_rpos = 16;
319 ri->ri_gnum = 8;
320 ri->ri_gpos = 8;
321 ri->ri_bnum = 8;
322 ri->ri_bpos = 0;
323 break;
324 case DRM_FORMAT_RGB565((__u32)('R') | ((__u32)('G') << 8) | ((__u32)('1') <<
16) | ((__u32)('6') << 24))
:
325 ri->ri_rnum = 5;
326 ri->ri_rpos = 11;
327 ri->ri_gnum = 6;
328 ri->ri_gpos = 5;
329 ri->ri_bnum = 5;
330 ri->ri_bpos = 0;
331 break;
332 }
333
334 vga_switcheroo_client_fb_set(rdev->pdev, info);
335 return 0;
336
337out:
338 if (fb && ret) {
339 drm_gem_object_put(gobj);
340 drm_framebuffer_unregister_private(fb);
341 drm_framebuffer_cleanup(fb);
342 kfree(fb);
343 }
344 return ret;
345}
346
347#ifdef notyet
348static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfbdev)
349{
350 struct drm_framebuffer *fb = &rfbdev->fb;
351
352 drm_fb_helper_unregister_fbi(&rfbdev->helper);
353
354 if (fb->obj[0]) {
355 radeonfb_destroy_pinned_object(fb->obj[0]);
356 fb->obj[0] = NULL((void *)0);
357 drm_framebuffer_unregister_private(fb);
358 drm_framebuffer_cleanup(fb);
359 }
360 drm_fb_helper_fini(&rfbdev->helper);
361
362 return 0;
363}
364#endif
365
366static const struct drm_fb_helper_funcs radeon_fb_helper_funcs = {
367 .fb_probe = radeonfb_create,
368};
369
370int radeon_fbdev_init(struct radeon_device *rdev)
371{
372 struct radeon_fbdev *rfbdev;
373 int bpp_sel = 32;
374 int ret;
375
376 /* don't enable fbdev if no connectors */
377 if (list_empty(&rdev->ddev->mode_config.connector_list))
378 return 0;
379
380 /* select 8 bpp console on 8MB cards, or 16 bpp on RN50 or 32MB */
381 if (rdev->mc.real_vram_size <= (8*1024*1024))
382 bpp_sel = 8;
383 else if (ASIC_IS_RN50(rdev)((rdev->pdev->device == 0x515e) || (rdev->pdev->device
== 0x5969))
||
384 rdev->mc.real_vram_size <= (32*1024*1024))
385 bpp_sel = 16;
386
387 rfbdev = kzalloc(sizeof(struct radeon_fbdev), GFP_KERNEL(0x0001 | 0x0004));
388 if (!rfbdev)
389 return -ENOMEM12;
390
391 rfbdev->rdev = rdev;
392 rdev->mode_info.rfbdev = rfbdev;
393
394 drm_fb_helper_prepare(rdev->ddev, &rfbdev->helper,
395 &radeon_fb_helper_funcs);
396
397 ret = drm_fb_helper_init(rdev->ddev, &rfbdev->helper);
398 if (ret)
399 goto free;
400
401 task_set(&rdev->burner_task, radeondrm_burner_cb, rdev);
402
403#ifdef __sparc64__
404{
405 struct drm_fb_helper *fb_helper = &rfbdev->helper;
406 struct drm_connector_list_iter conn_iter;
407 struct drm_connector *connector;
408 struct drm_cmdline_mode *mode;
409
410 drm_connector_list_iter_begin(fb_helper->dev, &conn_iter);
411 drm_client_for_each_connector_iter(connector, &conn_iter)while ((connector = drm_connector_list_iter_next(&conn_iter
))) if (connector->connector_type != 18)
{
412 mode = &connector->cmdline_mode;
413
414 mode->specified = true1;
415 mode->xres = rdev->sf.sf_width;
416 mode->yres = rdev->sf.sf_height;
417 mode->bpp_specified = true1;
418 mode->bpp = rdev->sf.sf_depth;
419 }
420 drm_connector_list_iter_end(&conn_iter);
421}
422#endif
423
424 /* disable all the possible outputs/crtcs before entering KMS mode */
425 drm_helper_disable_unused_functions(rdev->ddev);
426
427 ret = drm_fb_helper_initial_config(&rfbdev->helper, bpp_sel);
428 if (ret)
429 goto fini;
430
431 return 0;
432
433fini:
434 drm_fb_helper_fini(&rfbdev->helper);
435free:
436 kfree(rfbdev);
437 return ret;
438}
439
440void radeon_fbdev_fini(struct radeon_device *rdev)
441{
442 if (!rdev->mode_info.rfbdev)
443 return;
444
445 task_del(systq, &rdev->burner_task);
446
447#ifdef notyet
448 radeon_fbdev_destroy(rdev->ddev, rdev->mode_info.rfbdev);
449#endif
450 kfree(rdev->mode_info.rfbdev);
451 rdev->mode_info.rfbdev = NULL((void *)0);
452}
453
454void radeon_fbdev_set_suspend(struct radeon_device *rdev, int state)
455{
456 if (rdev->mode_info.rfbdev)
457 drm_fb_helper_set_suspend(&rdev->mode_info.rfbdev->helper, state);
458}
459
460bool_Bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj)
461{
462 if (!rdev->mode_info.rfbdev)
463 return false0;
464
465 if (robj == gem_to_radeon_bo(rdev->mode_info.rfbdev->fb.obj[0])({ const __typeof( ((struct radeon_bo *)0)->tbo.base ) *__mptr
= ((rdev->mode_info.rfbdev->fb.obj[0])); (struct radeon_bo
*)( (char *)__mptr - __builtin_offsetof(struct radeon_bo, tbo
.base) );})
)
466 return true1;
467 return false0;
468}
469
470void
471radeondrm_burner(void *v, u_int on, u_int flags)
472{
473 struct rasops_info *ri = v;
474 struct radeon_device *rdev = ri->ri_hw;
475
476 task_del(systq, &rdev->burner_task);
477
478 if (on)
479 rdev->burner_fblank = FB_BLANK_UNBLANK0;
480 else {
481 if (flags & WSDISPLAY_BURN_VBLANK0x0001)
482 rdev->burner_fblank = FB_BLANK_VSYNC_SUSPEND3;
483 else
484 rdev->burner_fblank = FB_BLANK_NORMAL1;
485 }
486
487 /*
488 * Setting the DPMS mode may sleep while waiting for vblank so
489 * hand things off to a taskq.
490 */
491 task_add(systq, &rdev->burner_task);
492}
493
494void
495radeondrm_burner_cb(void *arg1)
496{
497 struct radeon_device *rdev = arg1;
498 struct drm_fb_helper *helper = &rdev->mode_info.rfbdev->helper;
499
500 drm_fb_helper_blank(rdev->burner_fblank, helper->fbdev);
501}