blob: 867672eb1feebaddd754b8369e74a04dc224cabb [file] [log] [blame]
Rob Clarkdd2da6e2013-11-30 16:12:10 -05001/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __MSM_KMS_H__
19#define __MSM_KMS_H__
20
21#include <linux/clk.h>
22#include <linux/regulator/consumer.h>
23
24#include "msm_drv.h"
25
26/* As there are different display controller blocks depending on the
27 * snapdragon version, the kms support is split out and the appropriate
28 * implementation is loaded at runtime. The kms module is responsible
29 * for constructing the appropriate planes/crtcs/encoders/connectors.
30 */
31struct msm_kms_funcs {
32 /* hw initialization: */
33 int (*hw_init)(struct msm_kms *kms);
34 /* irq handling: */
35 void (*irq_preinstall)(struct msm_kms *kms);
36 int (*irq_postinstall)(struct msm_kms *kms);
37 void (*irq_uninstall)(struct msm_kms *kms);
38 irqreturn_t (*irq)(struct msm_kms *kms);
39 int (*enable_vblank)(struct msm_kms *kms, struct drm_crtc *crtc);
40 void (*disable_vblank)(struct msm_kms *kms, struct drm_crtc *crtc);
Rob Clark0b776d42015-01-30 17:04:45 -050041 /* modeset, bracketing atomic_commit(): */
42 void (*prepare_commit)(struct msm_kms *kms, struct drm_atomic_state *state);
43 void (*complete_commit)(struct msm_kms *kms, struct drm_atomic_state *state);
Rob Clarkdd2da6e2013-11-30 16:12:10 -050044 /* misc: */
45 const struct msm_format *(*get_format)(struct msm_kms *kms, uint32_t format);
46 long (*round_pixclk)(struct msm_kms *kms, unsigned long rate,
47 struct drm_encoder *encoder);
48 /* cleanup: */
49 void (*preclose)(struct msm_kms *kms, struct drm_file *file);
50 void (*destroy)(struct msm_kms *kms);
51};
52
53struct msm_kms {
54 const struct msm_kms_funcs *funcs;
Rob Clark9e0efa62013-11-30 17:24:22 -050055
56 /* irq handling: */
57 bool in_irq;
58 struct list_head irq_list; /* list of mdp4_irq */
59 uint32_t vblank_mask; /* irq bits set for userspace vblank */
Rob Clarkdd2da6e2013-11-30 16:12:10 -050060};
61
Rob Clark9e0efa62013-11-30 17:24:22 -050062static inline void msm_kms_init(struct msm_kms *kms,
63 const struct msm_kms_funcs *funcs)
64{
65 kms->funcs = funcs;
66}
67
Rob Clarkdd2da6e2013-11-30 16:12:10 -050068struct msm_kms *mdp4_kms_init(struct drm_device *dev);
Rob Clark06c0dd92013-11-30 17:51:47 -050069struct msm_kms *mdp5_kms_init(struct drm_device *dev);
Rob Clarkdd2da6e2013-11-30 16:12:10 -050070
71#endif /* __MSM_KMS_H__ */