blob: 2992f0a6b349dbbe62e97fb2accdd686a08899b8 [file] [log] [blame]
Maxime Ripard9026e0d2015-10-29 09:36:23 +01001/*
2 * Copyright (C) 2015 Free Electrons
3 * Copyright (C) 2015 NextThing Co
4 *
5 * Maxime Ripard <maxime.ripard@free-electrons.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 */
12
13#include <drm/drm_atomic_helper.h>
14#include <drm/drm_fb_cma_helper.h>
Noralf Trønnes1287c942017-09-24 14:26:23 +020015#include <drm/drm_gem_framebuffer_helper.h>
Maxime Ripard9026e0d2015-10-29 09:36:23 +010016#include <drm/drmP.h>
17
18#include "sun4i_drv.h"
Baoyou Xie0c3ff442016-09-08 18:59:22 +080019#include "sun4i_framebuffer.h"
Maxime Ripard9026e0d2015-10-29 09:36:23 +010020
21static void sun4i_de_output_poll_changed(struct drm_device *drm)
22{
23 struct sun4i_drv *drv = drm->dev_private;
24
Markus Elfring29d79ed2016-07-20 18:32:34 +020025 drm_fbdev_cma_hotplug_event(drv->fbdev);
Maxime Ripard9026e0d2015-10-29 09:36:23 +010026}
27
28static const struct drm_mode_config_funcs sun4i_de_mode_config_funcs = {
29 .output_poll_changed = sun4i_de_output_poll_changed,
30 .atomic_check = drm_atomic_helper_check,
31 .atomic_commit = drm_atomic_helper_commit,
Noralf Trønnes1287c942017-09-24 14:26:23 +020032 .fb_create = drm_gem_fb_create,
Maxime Ripard9026e0d2015-10-29 09:36:23 +010033};
34
35struct drm_fbdev_cma *sun4i_framebuffer_init(struct drm_device *drm)
36{
37 drm_mode_config_reset(drm);
38
39 drm->mode_config.max_width = 8192;
40 drm->mode_config.max_height = 8192;
41
42 drm->mode_config.funcs = &sun4i_de_mode_config_funcs;
43
Gabriel Krisman Bertazie4563f62017-02-02 14:26:40 -020044 return drm_fbdev_cma_init(drm, 32, drm->mode_config.num_connector);
Maxime Ripard9026e0d2015-10-29 09:36:23 +010045}
46
47void sun4i_framebuffer_free(struct drm_device *drm)
48{
49 struct sun4i_drv *drv = drm->dev_private;
50
51 drm_fbdev_cma_fini(drv->fbdev);
Maxime Ripard9026e0d2015-10-29 09:36:23 +010052}