fix a kmap leak in virtio_console
[linux/fpc-iii.git] / drivers / staging / imx-drm / imx-fbdev.c
blob8331739c3d085ca00a6639da41891fb614b23429
1 /*
2 * i.MX drm driver
4 * Copyright (C) 2012 Sascha Hauer, Pengutronix
6 * Based on Samsung Exynos code
8 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 #include <linux/module.h>
21 #include <drm/drmP.h>
22 #include <drm/drm_crtc.h>
23 #include <drm/drm_crtc_helper.h>
24 #include <drm/drm_fb_cma_helper.h>
26 #include "imx-drm.h"
28 #define MAX_CONNECTOR 4
29 #define PREFERRED_BPP 16
31 static struct drm_fbdev_cma *fbdev_cma;
33 static int legacyfb_depth = 16;
35 module_param(legacyfb_depth, int, 0444);
37 static int __init imx_fb_helper_init(void)
39 struct drm_device *drm = imx_drm_device_get();
41 if (!drm)
42 return -EINVAL;
44 if (legacyfb_depth != 16 && legacyfb_depth != 32) {
45 pr_warn("i.MX legacyfb: invalid legacyfb_depth setting. defaulting to 16bpp\n");
46 legacyfb_depth = 16;
49 fbdev_cma = drm_fbdev_cma_init(drm, legacyfb_depth,
50 drm->mode_config.num_crtc, MAX_CONNECTOR);
52 if (IS_ERR(fbdev_cma)) {
53 imx_drm_device_put();
54 return PTR_ERR(fbdev_cma);
57 imx_drm_fb_helper_set(fbdev_cma);
59 return 0;
62 static void __exit imx_fb_helper_exit(void)
64 imx_drm_fb_helper_set(NULL);
65 drm_fbdev_cma_fini(fbdev_cma);
66 imx_drm_device_put();
69 late_initcall(imx_fb_helper_init);
70 module_exit(imx_fb_helper_exit);
72 MODULE_DESCRIPTION("Freescale i.MX legacy fb driver");
73 MODULE_AUTHOR("Sascha Hauer, Pengutronix");
74 MODULE_LICENSE("GPL");