blob: 5f1a52c526417e4477caddb6239e56f42c22e3a7 [file] [log] [blame]
Narendra Muppalla1b0b3352015-09-29 10:16:51 -07001/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __SDE_KMS_H__
14#define __SDE_KMS_H__
15
16#include "msm_drv.h"
17#include "msm_kms.h"
18#include "mdp/mdp_kms.h"
19#include "sde_hw_catalog.h"
20#include "sde_hw_mdss.h"
Ben Chan78647cd2016-06-26 22:02:47 -040021#include "sde_hw_interrupts.h"
22
23/*
24 * struct sde_irq_callback - IRQ callback handlers
25 * @func: intr handler
26 * @arg: argument for the handler
27 */
28struct sde_irq_callback {
29 void (*func)(void *arg, int irq_idx);
30 void *arg;
31};
32
33/**
34 * struct sde_irq: IRQ structure contains callback registration info
35 * @total_irq: total number of irq_idx obtained from HW interrupts mapping
36 * @irq_cb_tbl: array of IRQ callbacks setting
37 * @cb_lock: callback lock
38 */
39struct sde_irq {
40 u32 total_irqs;
41 struct sde_irq_callback *irq_cb_tbl;
42 spinlock_t cb_lock;
43};
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070044
45struct sde_kms {
Ben Chan78647cd2016-06-26 22:02:47 -040046 struct msm_kms base;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070047 struct drm_device *dev;
48 int rev;
49 struct sde_mdss_cfg *catalog;
50
51 struct msm_mmu *mmu;
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040052 int mmu_id;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070053
54 /* io/register spaces: */
55 void __iomem *mmio, *vbif;
56
57 struct regulator *vdd;
58 struct regulator *mmagic;
59 struct regulator *venus;
60
61 struct clk *axi_clk;
62 struct clk *ahb_clk;
63 struct clk *src_clk;
64 struct clk *core_clk;
65 struct clk *lut_clk;
66 struct clk *mmagic_clk;
67 struct clk *iommu_clk;
68 struct clk *vsync_clk;
69
70 struct {
71 unsigned long enabled_mask;
72 struct irq_domain *domain;
73 } irqcontroller;
Ben Chan78647cd2016-06-26 22:02:47 -040074
75 struct sde_hw_intr *hw_intr;
76 struct sde_irq irq_obj;
77};
78
79struct vsync_info {
80 u32 frame_count;
81 u32 line_count;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070082};
83
84#define to_sde_kms(x) container_of(x, struct sde_kms, base)
85
86struct sde_plane_state {
87 struct drm_plane_state base;
88
89 /* aligned with property */
90 uint8_t premultiplied;
91 uint8_t zpos;
92 uint8_t alpha;
93
94 /* assigned by crtc blender */
95 enum sde_stage stage;
96
97 /* some additional transactional status to help us know in the
98 * apply path whether we need to update SMP allocation, and
99 * whether current update is still pending:
100 */
101 bool mode_changed : 1;
102 bool pending : 1;
103};
104
105#define to_sde_plane_state(x) \
106 container_of(x, struct sde_plane_state, base)
107
108int sde_disable(struct sde_kms *sde_kms);
109int sde_enable(struct sde_kms *sde_kms);
110
Ben Chan78647cd2016-06-26 22:02:47 -0400111/**
112 * IRQ functions
113 */
114int sde_irq_domain_init(struct sde_kms *sde_kms);
115int sde_irq_domain_fini(struct sde_kms *sde_kms);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700116void sde_irq_preinstall(struct msm_kms *kms);
117int sde_irq_postinstall(struct msm_kms *kms);
118void sde_irq_uninstall(struct msm_kms *kms);
119irqreturn_t sde_irq(struct msm_kms *kms);
Ben Chan78647cd2016-06-26 22:02:47 -0400120
121/**
122 * sde_set_irqmask - IRQ helper function for writing IRQ mask
123 * to SDE HW interrupt register.
124 * @sde_kms: SDE handle
125 * @reg_off: SDE HW interrupt register offset
126 * @irqmask: IRQ mask
127 */
128void sde_set_irqmask(
129 struct sde_kms *sde_kms,
130 uint32_t reg_off,
131 uint32_t irqmask);
132
133/**
134 * sde_irq_idx_lookup - IRQ helper function for lookup irq_idx from HW
135 * interrupt mapping table.
136 * @sde_kms: SDE handle
137 * @intr_type: SDE HW interrupt type for lookup
138 * @instance_idx: SDE HW block instance defined in sde_hw_mdss.h
139 * @return: irq_idx or -EINVAL when fail to lookup
140 */
141int sde_irq_idx_lookup(
142 struct sde_kms *sde_kms,
143 enum sde_intr_type intr_type,
144 uint32_t instance_idx);
145
146/**
147 * sde_enable_irq - IRQ helper function for enabling one or more IRQs
148 * @sde_kms: SDE handle
149 * @irq_idxs: Array of irq index
150 * @irq_count: Number of irq_idx provided in the array
151 * @return: 0 for success enabling IRQ, otherwise failure
152 */
153int sde_enable_irq(
154 struct sde_kms *sde_kms,
155 int *irq_idxs,
156 uint32_t irq_count);
157
158/**
159 * sde_disable_irq - IRQ helper function for diabling one of more IRQs
160 * @sde_kms: SDE handle
161 * @irq_idxs: Array of irq index
162 * @irq_count: Number of irq_idx provided in the array
163 * @return: 0 for success disabling IRQ, otherwise failure
164 */
165int sde_disable_irq(
166 struct sde_kms *sde_kms,
167 int *irq_idxs,
168 uint32_t irq_count);
169
170/**
171 * sde_register_irq_callback - For registering callback function on IRQ
172 * interrupt
173 * @sde_kms: SDE handle
174 * @irq_idx: irq index
175 * @irq_cb: IRQ callback structure, containing callback function
176 * and argument. Passing NULL for irq_cb will unregister
177 * the callback for the given irq_idx
178 * @return: 0 for success registering callback, otherwise failure
179 */
180int sde_register_irq_callback(
181 struct sde_kms *sde_kms,
182 int irq_idx,
183 struct sde_irq_callback *irq_cb);
184
185/**
186 * sde_clear_all_irqs - Clearing all SDE IRQ interrupt status
187 * @sde_kms: SDE handle
188 */
189void sde_clear_all_irqs(struct sde_kms *sde_kms);
190
191/**
192 * sde_disable_all_irqs - Diabling all SDE IRQ interrupt
193 * @sde_kms: SDE handle
194 */
195void sde_disable_all_irqs(struct sde_kms *sde_kms);
196
197/**
198 * Vblank enable/disable functions
199 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700200int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
201void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
202
203enum sde_sspp sde_plane_pipe(struct drm_plane *plane);
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400204struct drm_plane *sde_plane_init(struct drm_device *dev, uint32_t pipe,
205 bool private_plane);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700206
207uint32_t sde_crtc_vblank(struct drm_crtc *crtc);
208
209void sde_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
210void sde_crtc_attach(struct drm_crtc *crtc, struct drm_plane *plane);
211void sde_crtc_detach(struct drm_crtc *crtc, struct drm_plane *plane);
212struct drm_crtc *sde_crtc_init(struct drm_device *dev,
213 struct drm_encoder *encoder,
214 struct drm_plane *plane, int id);
215
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400216struct sde_encoder_hw_resources {
217 bool intfs[INTF_MAX];
218 bool pingpongs[PINGPONG_MAX];
219};
220void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
221 struct sde_encoder_hw_resources *hw_res);
222void sde_encoder_register_vblank_callback(struct drm_encoder *drm_enc,
223 void (*cb)(void *), void *data);
224void sde_encoders_init(struct drm_device *dev);
225
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700226
227int sde_irq_domain_init(struct sde_kms *sde_kms);
228int sde_irq_domain_fini(struct sde_kms *sde_kms);
229
230#endif /* __sde_kms_H__ */