GNU Linux-libre 4.14.265-gnu1
[releases.git] / drivers / gpu / drm / omapdrm / dss / core.c
1 /*
2  * linux/drivers/video/omap2/dss/core.c
3  *
4  * Copyright (C) 2009 Nokia Corporation
5  * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
6  *
7  * Some code and ideas taken from drivers/video/omap/ driver
8  * by Imre Deak.
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License version 2 as published by
12  * the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
17  * more details.
18  *
19  * You should have received a copy of the GNU General Public License along with
20  * this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #define DSS_SUBSYS_NAME "CORE"
24
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/platform_device.h>
28
29 #include "omapdss.h"
30 #include "dss.h"
31
32 /* INIT */
33 static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
34         dss_init_platform_driver,
35         dispc_init_platform_driver,
36 #ifdef CONFIG_OMAP2_DSS_DSI
37         dsi_init_platform_driver,
38 #endif
39 #ifdef CONFIG_OMAP2_DSS_VENC
40         venc_init_platform_driver,
41 #endif
42 #ifdef CONFIG_OMAP4_DSS_HDMI
43         hdmi4_init_platform_driver,
44 #endif
45 #ifdef CONFIG_OMAP5_DSS_HDMI
46         hdmi5_init_platform_driver,
47 #endif
48 };
49
50 static void (*dss_output_drv_unreg_funcs[])(void) = {
51 #ifdef CONFIG_OMAP5_DSS_HDMI
52         hdmi5_uninit_platform_driver,
53 #endif
54 #ifdef CONFIG_OMAP4_DSS_HDMI
55         hdmi4_uninit_platform_driver,
56 #endif
57 #ifdef CONFIG_OMAP2_DSS_VENC
58         venc_uninit_platform_driver,
59 #endif
60 #ifdef CONFIG_OMAP2_DSS_DSI
61         dsi_uninit_platform_driver,
62 #endif
63         dispc_uninit_platform_driver,
64         dss_uninit_platform_driver,
65 };
66
67 static struct platform_device *omap_drm_device;
68
69 static int __init omap_dss_init(void)
70 {
71         int r;
72         int i;
73
74         for (i = 0; i < ARRAY_SIZE(dss_output_drv_reg_funcs); ++i) {
75                 r = dss_output_drv_reg_funcs[i]();
76                 if (r)
77                         goto err_reg;
78         }
79
80         omap_drm_device = platform_device_register_simple("omapdrm", 0, NULL, 0);
81         if (IS_ERR(omap_drm_device)) {
82                 r = PTR_ERR(omap_drm_device);
83                 goto err_reg;
84         }
85
86         return 0;
87
88 err_reg:
89         for (i = ARRAY_SIZE(dss_output_drv_reg_funcs) - i;
90                         i < ARRAY_SIZE(dss_output_drv_reg_funcs);
91                         ++i)
92                 dss_output_drv_unreg_funcs[i]();
93
94         return r;
95 }
96
97 static void __exit omap_dss_exit(void)
98 {
99         int i;
100
101         platform_device_unregister(omap_drm_device);
102
103         for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i)
104                 dss_output_drv_unreg_funcs[i]();
105 }
106
107 module_init(omap_dss_init);
108 module_exit(omap_dss_exit);
109
110 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>");
111 MODULE_DESCRIPTION("OMAP2/3 Display Subsystem");
112 MODULE_LICENSE("GPL v2");
113