Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / tegra / fb.c
1 /*
2  * Copyright (C) 2012 Avionic Design GmbH
3  * Copyright (C) 2012 NVIDIA CORPORATION.  All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  */
9
10 #include "drm.h"
11
12 static void tegra_drm_fb_output_poll_changed(struct drm_device *drm)
13 {
14         struct host1x *host1x = drm->dev_private;
15
16         drm_fbdev_cma_hotplug_event(host1x->fbdev);
17 }
18
19 static const struct drm_mode_config_funcs tegra_drm_mode_funcs = {
20         .fb_create = drm_fb_cma_create,
21         .output_poll_changed = tegra_drm_fb_output_poll_changed,
22 };
23
24 int tegra_drm_fb_init(struct drm_device *drm)
25 {
26         struct host1x *host1x = drm->dev_private;
27         struct drm_fbdev_cma *fbdev;
28
29         drm->mode_config.min_width = 0;
30         drm->mode_config.min_height = 0;
31
32         drm->mode_config.max_width = 4096;
33         drm->mode_config.max_height = 4096;
34
35         drm->mode_config.funcs = &tegra_drm_mode_funcs;
36
37         fbdev = drm_fbdev_cma_init(drm, 32, drm->mode_config.num_crtc,
38                                    drm->mode_config.num_connector);
39         if (IS_ERR(fbdev))
40                 return PTR_ERR(fbdev);
41
42 #ifndef CONFIG_FRAMEBUFFER_CONSOLE
43         drm_fbdev_cma_restore_mode(fbdev);
44 #endif
45
46         host1x->fbdev = fbdev;
47
48         return 0;
49 }
50
51 void tegra_drm_fb_exit(struct drm_device *drm)
52 {
53         struct host1x *host1x = drm->dev_private;
54
55         drm_fbdev_cma_fini(host1x->fbdev);
56 }