nouveau_fbcon.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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. #include <linux/module.h>
  27. #include <linux/kernel.h>
  28. #include <linux/errno.h>
  29. #include <linux/string.h>
  30. #include <linux/mm.h>
  31. #include <linux/tty.h>
  32. #include <linux/sysrq.h>
  33. #include <linux/delay.h>
  34. #include <linux/fb.h>
  35. #include <linux/init.h>
  36. #include <linux/screen_info.h>
  37. #include <linux/vga_switcheroo.h>
  38. #include <linux/console.h>
  39. #include <drm/drmP.h>
  40. #include <drm/drm_crtc.h>
  41. #include <drm/drm_crtc_helper.h>
  42. #include <drm/drm_fb_helper.h>
  43. #include "nouveau_drm.h"
  44. #include "nouveau_gem.h"
  45. #include "nouveau_bo.h"
  46. #include "nouveau_fbcon.h"
  47. #include "nouveau_chan.h"
  48. #include "nouveau_crtc.h"
  49. MODULE_PARM_DESC(nofbaccel, "Disable fbcon acceleration");
  50. int nouveau_nofbaccel = 0;
  51. module_param_named(nofbaccel, nouveau_nofbaccel, int, 0400);
  52. static void
  53. nouveau_fbcon_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
  54. {
  55. struct nouveau_fbdev *fbcon = info->par;
  56. struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
  57. struct nvif_device *device = &drm->device;
  58. int ret;
  59. if (info->state != FBINFO_STATE_RUNNING)
  60. return;
  61. ret = -ENODEV;
  62. if (!in_interrupt() && !(info->flags & FBINFO_HWACCEL_DISABLED) &&
  63. mutex_trylock(&drm->client.mutex)) {
  64. if (device->info.family < NV_DEVICE_INFO_V0_TESLA)
  65. ret = nv04_fbcon_fillrect(info, rect);
  66. else
  67. if (device->info.family < NV_DEVICE_INFO_V0_FERMI)
  68. ret = nv50_fbcon_fillrect(info, rect);
  69. else
  70. ret = nvc0_fbcon_fillrect(info, rect);
  71. mutex_unlock(&drm->client.mutex);
  72. }
  73. if (ret == 0)
  74. return;
  75. if (ret != -ENODEV)
  76. nouveau_fbcon_gpu_lockup(info);
  77. drm_fb_helper_cfb_fillrect(info, rect);
  78. }
  79. static void
  80. nouveau_fbcon_copyarea(struct fb_info *info, const struct fb_copyarea *image)
  81. {
  82. struct nouveau_fbdev *fbcon = info->par;
  83. struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
  84. struct nvif_device *device = &drm->device;
  85. int ret;
  86. if (info->state != FBINFO_STATE_RUNNING)
  87. return;
  88. ret = -ENODEV;
  89. if (!in_interrupt() && !(info->flags & FBINFO_HWACCEL_DISABLED) &&
  90. mutex_trylock(&drm->client.mutex)) {
  91. if (device->info.family < NV_DEVICE_INFO_V0_TESLA)
  92. ret = nv04_fbcon_copyarea(info, image);
  93. else
  94. if (device->info.family < NV_DEVICE_INFO_V0_FERMI)
  95. ret = nv50_fbcon_copyarea(info, image);
  96. else
  97. ret = nvc0_fbcon_copyarea(info, image);
  98. mutex_unlock(&drm->client.mutex);
  99. }
  100. if (ret == 0)
  101. return;
  102. if (ret != -ENODEV)
  103. nouveau_fbcon_gpu_lockup(info);
  104. drm_fb_helper_cfb_copyarea(info, image);
  105. }
  106. static void
  107. nouveau_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
  108. {
  109. struct nouveau_fbdev *fbcon = info->par;
  110. struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
  111. struct nvif_device *device = &drm->device;
  112. int ret;
  113. if (info->state != FBINFO_STATE_RUNNING)
  114. return;
  115. ret = -ENODEV;
  116. if (!in_interrupt() && !(info->flags & FBINFO_HWACCEL_DISABLED) &&
  117. mutex_trylock(&drm->client.mutex)) {
  118. if (device->info.family < NV_DEVICE_INFO_V0_TESLA)
  119. ret = nv04_fbcon_imageblit(info, image);
  120. else
  121. if (device->info.family < NV_DEVICE_INFO_V0_FERMI)
  122. ret = nv50_fbcon_imageblit(info, image);
  123. else
  124. ret = nvc0_fbcon_imageblit(info, image);
  125. mutex_unlock(&drm->client.mutex);
  126. }
  127. if (ret == 0)
  128. return;
  129. if (ret != -ENODEV)
  130. nouveau_fbcon_gpu_lockup(info);
  131. drm_fb_helper_cfb_imageblit(info, image);
  132. }
  133. static int
  134. nouveau_fbcon_sync(struct fb_info *info)
  135. {
  136. struct nouveau_fbdev *fbcon = info->par;
  137. struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
  138. struct nouveau_channel *chan = drm->channel;
  139. int ret;
  140. if (!chan || !chan->accel_done || in_interrupt() ||
  141. info->state != FBINFO_STATE_RUNNING ||
  142. info->flags & FBINFO_HWACCEL_DISABLED)
  143. return 0;
  144. if (!mutex_trylock(&drm->client.mutex))
  145. return 0;
  146. ret = nouveau_channel_idle(chan);
  147. mutex_unlock(&drm->client.mutex);
  148. if (ret) {
  149. nouveau_fbcon_gpu_lockup(info);
  150. return 0;
  151. }
  152. chan->accel_done = false;
  153. return 0;
  154. }
  155. static int
  156. nouveau_fbcon_open(struct fb_info *info, int user)
  157. {
  158. struct nouveau_fbdev *fbcon = info->par;
  159. struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
  160. int ret = pm_runtime_get_sync(drm->dev->dev);
  161. if (ret < 0 && ret != -EACCES)
  162. return ret;
  163. return 0;
  164. }
  165. static int
  166. nouveau_fbcon_release(struct fb_info *info, int user)
  167. {
  168. struct nouveau_fbdev *fbcon = info->par;
  169. struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
  170. pm_runtime_put(drm->dev->dev);
  171. return 0;
  172. }
  173. static struct fb_ops nouveau_fbcon_ops = {
  174. .owner = THIS_MODULE,
  175. .fb_open = nouveau_fbcon_open,
  176. .fb_release = nouveau_fbcon_release,
  177. .fb_check_var = drm_fb_helper_check_var,
  178. .fb_set_par = drm_fb_helper_set_par,
  179. .fb_fillrect = nouveau_fbcon_fillrect,
  180. .fb_copyarea = nouveau_fbcon_copyarea,
  181. .fb_imageblit = nouveau_fbcon_imageblit,
  182. .fb_sync = nouveau_fbcon_sync,
  183. .fb_pan_display = drm_fb_helper_pan_display,
  184. .fb_blank = drm_fb_helper_blank,
  185. .fb_setcmap = drm_fb_helper_setcmap,
  186. .fb_debug_enter = drm_fb_helper_debug_enter,
  187. .fb_debug_leave = drm_fb_helper_debug_leave,
  188. };
  189. static struct fb_ops nouveau_fbcon_sw_ops = {
  190. .owner = THIS_MODULE,
  191. .fb_open = nouveau_fbcon_open,
  192. .fb_release = nouveau_fbcon_release,
  193. .fb_check_var = drm_fb_helper_check_var,
  194. .fb_set_par = drm_fb_helper_set_par,
  195. .fb_fillrect = drm_fb_helper_cfb_fillrect,
  196. .fb_copyarea = drm_fb_helper_cfb_copyarea,
  197. .fb_imageblit = drm_fb_helper_cfb_imageblit,
  198. .fb_pan_display = drm_fb_helper_pan_display,
  199. .fb_blank = drm_fb_helper_blank,
  200. .fb_setcmap = drm_fb_helper_setcmap,
  201. .fb_debug_enter = drm_fb_helper_debug_enter,
  202. .fb_debug_leave = drm_fb_helper_debug_leave,
  203. };
  204. void
  205. nouveau_fbcon_accel_save_disable(struct drm_device *dev)
  206. {
  207. struct nouveau_drm *drm = nouveau_drm(dev);
  208. if (drm->fbcon && drm->fbcon->helper.fbdev) {
  209. drm->fbcon->saved_flags = drm->fbcon->helper.fbdev->flags;
  210. drm->fbcon->helper.fbdev->flags |= FBINFO_HWACCEL_DISABLED;
  211. }
  212. }
  213. void
  214. nouveau_fbcon_accel_restore(struct drm_device *dev)
  215. {
  216. struct nouveau_drm *drm = nouveau_drm(dev);
  217. if (drm->fbcon && drm->fbcon->helper.fbdev) {
  218. drm->fbcon->helper.fbdev->flags = drm->fbcon->saved_flags;
  219. }
  220. }
  221. static void
  222. nouveau_fbcon_accel_fini(struct drm_device *dev)
  223. {
  224. struct nouveau_drm *drm = nouveau_drm(dev);
  225. struct nouveau_fbdev *fbcon = drm->fbcon;
  226. if (fbcon && drm->channel) {
  227. console_lock();
  228. if (fbcon->helper.fbdev)
  229. fbcon->helper.fbdev->flags |= FBINFO_HWACCEL_DISABLED;
  230. console_unlock();
  231. nouveau_channel_idle(drm->channel);
  232. nvif_object_fini(&fbcon->twod);
  233. nvif_object_fini(&fbcon->blit);
  234. nvif_object_fini(&fbcon->gdi);
  235. nvif_object_fini(&fbcon->patt);
  236. nvif_object_fini(&fbcon->rop);
  237. nvif_object_fini(&fbcon->clip);
  238. nvif_object_fini(&fbcon->surf2d);
  239. }
  240. }
  241. static void
  242. nouveau_fbcon_accel_init(struct drm_device *dev)
  243. {
  244. struct nouveau_drm *drm = nouveau_drm(dev);
  245. struct nouveau_fbdev *fbcon = drm->fbcon;
  246. struct fb_info *info = fbcon->helper.fbdev;
  247. int ret;
  248. if (drm->device.info.family < NV_DEVICE_INFO_V0_TESLA)
  249. ret = nv04_fbcon_accel_init(info);
  250. else
  251. if (drm->device.info.family < NV_DEVICE_INFO_V0_FERMI)
  252. ret = nv50_fbcon_accel_init(info);
  253. else
  254. ret = nvc0_fbcon_accel_init(info);
  255. if (ret == 0)
  256. info->fbops = &nouveau_fbcon_ops;
  257. }
  258. static void nouveau_fbcon_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
  259. u16 blue, int regno)
  260. {
  261. struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
  262. nv_crtc->lut.r[regno] = red;
  263. nv_crtc->lut.g[regno] = green;
  264. nv_crtc->lut.b[regno] = blue;
  265. }
  266. static void nouveau_fbcon_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
  267. u16 *blue, int regno)
  268. {
  269. struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
  270. *red = nv_crtc->lut.r[regno];
  271. *green = nv_crtc->lut.g[regno];
  272. *blue = nv_crtc->lut.b[regno];
  273. }
  274. static void
  275. nouveau_fbcon_zfill(struct drm_device *dev, struct nouveau_fbdev *fbcon)
  276. {
  277. struct fb_info *info = fbcon->helper.fbdev;
  278. struct fb_fillrect rect;
  279. /* Clear the entire fbcon. The drm will program every connector
  280. * with it's preferred mode. If the sizes differ, one display will
  281. * quite likely have garbage around the console.
  282. */
  283. rect.dx = rect.dy = 0;
  284. rect.width = info->var.xres_virtual;
  285. rect.height = info->var.yres_virtual;
  286. rect.color = 0;
  287. rect.rop = ROP_COPY;
  288. info->fbops->fb_fillrect(info, &rect);
  289. }
  290. static int
  291. nouveau_fbcon_create(struct drm_fb_helper *helper,
  292. struct drm_fb_helper_surface_size *sizes)
  293. {
  294. struct nouveau_fbdev *fbcon =
  295. container_of(helper, struct nouveau_fbdev, helper);
  296. struct drm_device *dev = fbcon->dev;
  297. struct nouveau_drm *drm = nouveau_drm(dev);
  298. struct nvif_device *device = &drm->device;
  299. struct fb_info *info;
  300. struct drm_framebuffer *fb;
  301. struct nouveau_framebuffer *nouveau_fb;
  302. struct nouveau_channel *chan;
  303. struct nouveau_bo *nvbo;
  304. struct drm_mode_fb_cmd2 mode_cmd;
  305. int size, ret;
  306. mode_cmd.width = sizes->surface_width;
  307. mode_cmd.height = sizes->surface_height;
  308. mode_cmd.pitches[0] = mode_cmd.width * (sizes->surface_bpp >> 3);
  309. mode_cmd.pitches[0] = roundup(mode_cmd.pitches[0], 256);
  310. mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
  311. sizes->surface_depth);
  312. size = mode_cmd.pitches[0] * mode_cmd.height;
  313. size = roundup(size, PAGE_SIZE);
  314. ret = nouveau_gem_new(dev, size, 0, NOUVEAU_GEM_DOMAIN_VRAM,
  315. 0, 0x0000, &nvbo);
  316. if (ret) {
  317. NV_ERROR(drm, "failed to allocate framebuffer\n");
  318. goto out;
  319. }
  320. ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM, false);
  321. if (ret) {
  322. NV_ERROR(drm, "failed to pin fb: %d\n", ret);
  323. goto out_unref;
  324. }
  325. ret = nouveau_bo_map(nvbo);
  326. if (ret) {
  327. NV_ERROR(drm, "failed to map fb: %d\n", ret);
  328. goto out_unpin;
  329. }
  330. chan = nouveau_nofbaccel ? NULL : drm->channel;
  331. if (chan && device->info.family >= NV_DEVICE_INFO_V0_TESLA) {
  332. ret = nouveau_bo_vma_add(nvbo, drm->client.vm,
  333. &fbcon->nouveau_fb.vma);
  334. if (ret) {
  335. NV_ERROR(drm, "failed to map fb into chan: %d\n", ret);
  336. chan = NULL;
  337. }
  338. }
  339. mutex_lock(&dev->struct_mutex);
  340. info = drm_fb_helper_alloc_fbi(helper);
  341. if (IS_ERR(info)) {
  342. ret = PTR_ERR(info);
  343. goto out_unlock;
  344. }
  345. info->skip_vt_switch = 1;
  346. info->par = fbcon;
  347. nouveau_framebuffer_init(dev, &fbcon->nouveau_fb, &mode_cmd, nvbo);
  348. nouveau_fb = &fbcon->nouveau_fb;
  349. fb = &nouveau_fb->base;
  350. /* setup helper */
  351. fbcon->helper.fb = fb;
  352. strcpy(info->fix.id, "nouveaufb");
  353. if (!chan)
  354. info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_DISABLED;
  355. else
  356. info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
  357. FBINFO_HWACCEL_FILLRECT |
  358. FBINFO_HWACCEL_IMAGEBLIT;
  359. info->flags |= FBINFO_CAN_FORCE_OUTPUT;
  360. info->fbops = &nouveau_fbcon_sw_ops;
  361. info->fix.smem_start = nvbo->bo.mem.bus.base +
  362. nvbo->bo.mem.bus.offset;
  363. info->fix.smem_len = size;
  364. info->screen_base = nvbo_kmap_obj_iovirtual(nouveau_fb->nvbo);
  365. info->screen_size = size;
  366. drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
  367. drm_fb_helper_fill_var(info, &fbcon->helper, sizes->fb_width, sizes->fb_height);
  368. /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
  369. mutex_unlock(&dev->struct_mutex);
  370. if (chan)
  371. nouveau_fbcon_accel_init(dev);
  372. nouveau_fbcon_zfill(dev, fbcon);
  373. /* To allow resizeing without swapping buffers */
  374. NV_INFO(drm, "allocated %dx%d fb: 0x%llx, bo %p\n",
  375. nouveau_fb->base.width, nouveau_fb->base.height,
  376. nvbo->bo.offset, nvbo);
  377. vga_switcheroo_client_fb_set(dev->pdev, info);
  378. return 0;
  379. out_unlock:
  380. mutex_unlock(&dev->struct_mutex);
  381. if (chan)
  382. nouveau_bo_vma_del(nvbo, &fbcon->nouveau_fb.vma);
  383. nouveau_bo_unmap(nvbo);
  384. out_unpin:
  385. nouveau_bo_unpin(nvbo);
  386. out_unref:
  387. nouveau_bo_ref(NULL, &nvbo);
  388. out:
  389. return ret;
  390. }
  391. void
  392. nouveau_fbcon_output_poll_changed(struct drm_device *dev)
  393. {
  394. struct nouveau_drm *drm = nouveau_drm(dev);
  395. if (drm->fbcon)
  396. drm_fb_helper_hotplug_event(&drm->fbcon->helper);
  397. }
  398. static int
  399. nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon)
  400. {
  401. struct nouveau_framebuffer *nouveau_fb = &fbcon->nouveau_fb;
  402. drm_fb_helper_unregister_fbi(&fbcon->helper);
  403. drm_fb_helper_release_fbi(&fbcon->helper);
  404. if (nouveau_fb->nvbo) {
  405. nouveau_bo_unmap(nouveau_fb->nvbo);
  406. nouveau_bo_vma_del(nouveau_fb->nvbo, &nouveau_fb->vma);
  407. nouveau_bo_unpin(nouveau_fb->nvbo);
  408. drm_gem_object_unreference_unlocked(&nouveau_fb->nvbo->gem);
  409. nouveau_fb->nvbo = NULL;
  410. }
  411. drm_fb_helper_fini(&fbcon->helper);
  412. drm_framebuffer_unregister_private(&nouveau_fb->base);
  413. drm_framebuffer_cleanup(&nouveau_fb->base);
  414. return 0;
  415. }
  416. void nouveau_fbcon_gpu_lockup(struct fb_info *info)
  417. {
  418. struct nouveau_fbdev *fbcon = info->par;
  419. struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
  420. NV_ERROR(drm, "GPU lockup - switching to software fbcon\n");
  421. info->flags |= FBINFO_HWACCEL_DISABLED;
  422. }
  423. static const struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = {
  424. .gamma_set = nouveau_fbcon_gamma_set,
  425. .gamma_get = nouveau_fbcon_gamma_get,
  426. .fb_probe = nouveau_fbcon_create,
  427. };
  428. void
  429. nouveau_fbcon_set_suspend(struct drm_device *dev, int state)
  430. {
  431. struct nouveau_drm *drm = nouveau_drm(dev);
  432. if (drm->fbcon) {
  433. console_lock();
  434. if (state == FBINFO_STATE_RUNNING)
  435. nouveau_fbcon_accel_restore(dev);
  436. drm_fb_helper_set_suspend(&drm->fbcon->helper, state);
  437. if (state != FBINFO_STATE_RUNNING)
  438. nouveau_fbcon_accel_save_disable(dev);
  439. console_unlock();
  440. }
  441. }
  442. int
  443. nouveau_fbcon_init(struct drm_device *dev)
  444. {
  445. struct nouveau_drm *drm = nouveau_drm(dev);
  446. struct nouveau_fbdev *fbcon;
  447. int preferred_bpp;
  448. int ret;
  449. if (!dev->mode_config.num_crtc ||
  450. (dev->pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
  451. return 0;
  452. fbcon = kzalloc(sizeof(struct nouveau_fbdev), GFP_KERNEL);
  453. if (!fbcon)
  454. return -ENOMEM;
  455. fbcon->dev = dev;
  456. drm->fbcon = fbcon;
  457. drm_fb_helper_prepare(dev, &fbcon->helper, &nouveau_fbcon_helper_funcs);
  458. ret = drm_fb_helper_init(dev, &fbcon->helper,
  459. dev->mode_config.num_crtc, 4);
  460. if (ret)
  461. goto free;
  462. ret = drm_fb_helper_single_add_all_connectors(&fbcon->helper);
  463. if (ret)
  464. goto fini;
  465. if (drm->device.info.ram_size <= 32 * 1024 * 1024)
  466. preferred_bpp = 8;
  467. else
  468. if (drm->device.info.ram_size <= 64 * 1024 * 1024)
  469. preferred_bpp = 16;
  470. else
  471. preferred_bpp = 32;
  472. /* disable all the possible outputs/crtcs before entering KMS mode */
  473. drm_helper_disable_unused_functions(dev);
  474. ret = drm_fb_helper_initial_config(&fbcon->helper, preferred_bpp);
  475. if (ret)
  476. goto fini;
  477. if (fbcon->helper.fbdev)
  478. fbcon->helper.fbdev->pixmap.buf_align = 4;
  479. return 0;
  480. fini:
  481. drm_fb_helper_fini(&fbcon->helper);
  482. free:
  483. kfree(fbcon);
  484. return ret;
  485. }
  486. void
  487. nouveau_fbcon_fini(struct drm_device *dev)
  488. {
  489. struct nouveau_drm *drm = nouveau_drm(dev);
  490. if (!drm->fbcon)
  491. return;
  492. nouveau_fbcon_accel_fini(dev);
  493. nouveau_fbcon_destroy(dev, drm->fbcon);
  494. kfree(drm->fbcon);
  495. drm->fbcon = NULL;
  496. }