]> Pileus Git - ~andy/linux/blob - drivers/staging/imx-drm/imx-fbdev.c
Linux 3.14
[~andy/linux] / drivers / staging / imx-drm / imx-fbdev.c
1 /*
2  * i.MX drm driver
3  *
4  * Copyright (C) 2012 Sascha Hauer, Pengutronix
5  *
6  * Based on Samsung Exynos code
7  *
8  * Copyright (c) 2011 Samsung Electronics Co., Ltd.
9  *
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.
18  *
19  */
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>
25
26 #include "imx-drm.h"
27
28 #define MAX_CONNECTOR           4
29 #define PREFERRED_BPP           16
30
31 static struct drm_fbdev_cma *fbdev_cma;
32
33 static int legacyfb_depth = 16;
34
35 module_param(legacyfb_depth, int, 0444);
36
37 static int __init imx_fb_helper_init(void)
38 {
39         struct drm_device *drm = imx_drm_device_get();
40
41         if (!drm)
42                 return -EINVAL;
43
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;
47         }
48
49         fbdev_cma = drm_fbdev_cma_init(drm, legacyfb_depth,
50                         drm->mode_config.num_crtc, MAX_CONNECTOR);
51
52         if (IS_ERR(fbdev_cma)) {
53                 imx_drm_device_put();
54                 return PTR_ERR(fbdev_cma);
55         }
56
57         imx_drm_fb_helper_set(fbdev_cma);
58
59         return 0;
60 }
61
62 static void __exit imx_fb_helper_exit(void)
63 {
64         imx_drm_fb_helper_set(NULL);
65         drm_fbdev_cma_fini(fbdev_cma);
66         imx_drm_device_put();
67 }
68
69 late_initcall(imx_fb_helper_init);
70 module_exit(imx_fb_helper_exit);
71
72 MODULE_DESCRIPTION("Freescale i.MX legacy fb driver");
73 MODULE_AUTHOR("Sascha Hauer, Pengutronix");
74 MODULE_LICENSE("GPL");