2 * Copyright (C) 2015 Broadcom
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
12 * This is the general code for implementing KMS mode setting that
13 * doesn't clearly associate with any of the other objects (plane,
14 * crtc, HDMI encoder).
18 #include "drm_atomic_helper.h"
19 #include "drm_crtc_helper.h"
20 #include "drm_plane_helper.h"
21 #include "drm_fb_cma_helper.h"
24 static void vc4_output_poll_changed(struct drm_device
*dev
)
26 struct vc4_dev
*vc4
= to_vc4_dev(dev
);
29 drm_fbdev_cma_hotplug_event(vc4
->fbdev
);
32 static const struct drm_mode_config_funcs vc4_mode_funcs
= {
33 .output_poll_changed
= vc4_output_poll_changed
,
34 .atomic_check
= drm_atomic_helper_check
,
35 .atomic_commit
= drm_atomic_helper_commit
,
36 .fb_create
= drm_fb_cma_create
,
39 int vc4_kms_load(struct drm_device
*dev
)
41 struct vc4_dev
*vc4
= to_vc4_dev(dev
);
44 ret
= drm_vblank_init(dev
, dev
->mode_config
.num_crtc
);
46 dev_err(dev
->dev
, "failed to initialize vblank\n");
50 dev
->mode_config
.max_width
= 2048;
51 dev
->mode_config
.max_height
= 2048;
52 dev
->mode_config
.funcs
= &vc4_mode_funcs
;
53 dev
->mode_config
.preferred_depth
= 24;
54 dev
->vblank_disable_allowed
= true;
56 drm_mode_config_reset(dev
);
58 vc4
->fbdev
= drm_fbdev_cma_init(dev
, 32,
59 dev
->mode_config
.num_crtc
,
60 dev
->mode_config
.num_connector
);
61 if (IS_ERR(vc4
->fbdev
))
64 drm_kms_helper_poll_init(dev
);