blob: 3e94c79c215a7979b4bf32919c461c1ca74ebd62 [file] [log] [blame]
Rob Clarkc8afe682013-06-26 12:44:06 -04001/*
Dhaval Patel14d46ce2017-01-17 16:28:12 -08002 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
Rob Clarkc8afe682013-06-26 12:44:06 -04003 * Copyright (C) 2013 Red Hat
4 * Author: Rob Clark <robdclark@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __MSM_DRV_H__
20#define __MSM_DRV_H__
21
22#include <linux/kernel.h>
23#include <linux/clk.h>
24#include <linux/cpufreq.h>
25#include <linux/module.h>
Rob Clark060530f2014-03-03 14:19:12 -050026#include <linux/component.h>
Rob Clarkc8afe682013-06-26 12:44:06 -040027#include <linux/platform_device.h>
28#include <linux/pm.h>
29#include <linux/pm_runtime.h>
30#include <linux/slab.h>
31#include <linux/list.h>
32#include <linux/iommu.h>
33#include <linux/types.h>
Archit Taneja3d6df062015-06-09 14:17:22 +053034#include <linux/of_graph.h>
Archit Tanejae9fbdaf2015-11-18 12:15:14 +053035#include <linux/of_device.h>
Dhaval Patel1ac91032016-09-26 19:25:39 -070036#include <linux/sde_io_util.h>
Rob Clarkc8afe682013-06-26 12:44:06 -040037#include <asm/sizes.h>
Sandeep Pandaf48c46a2016-10-24 09:48:50 +053038#include <linux/kthread.h>
Rob Clarkc8afe682013-06-26 12:44:06 -040039
Rob Clarkc8afe682013-06-26 12:44:06 -040040#include <drm/drmP.h>
Rob Clarkcf3a7e42014-11-08 13:21:06 -050041#include <drm/drm_atomic.h>
42#include <drm/drm_atomic_helper.h>
Rob Clarkc8afe682013-06-26 12:44:06 -040043#include <drm/drm_crtc_helper.h>
Rob Clarkcf3a7e42014-11-08 13:21:06 -050044#include <drm/drm_plane_helper.h>
Rob Clarkc8afe682013-06-26 12:44:06 -040045#include <drm/drm_fb_helper.h>
Rob Clark7198e6b2013-07-19 12:59:32 -040046#include <drm/msm_drm.h>
Daniel Vetterd9fc9412014-09-23 15:46:53 +020047#include <drm/drm_gem.h>
Rob Clarkc8afe682013-06-26 12:44:06 -040048
Dhaval Patel3949f032016-06-20 16:24:33 -070049#include "sde_power_handle.h"
50
51#define GET_MAJOR_REV(rev) ((rev) >> 28)
52#define GET_MINOR_REV(rev) (((rev) >> 16) & 0xFFF)
53#define GET_STEP_REV(rev) ((rev) & 0xFFFF)
Lloyd Atkinson154b6aa2016-05-24 17:11:37 -040054
Rob Clarkc8afe682013-06-26 12:44:06 -040055struct msm_kms;
Rob Clark7198e6b2013-07-19 12:59:32 -040056struct msm_gpu;
Rob Clark871d8122013-11-16 12:56:06 -050057struct msm_mmu;
Archit Taneja990a4002016-05-07 23:11:25 +053058struct msm_mdss;
Rob Clarka7d3c952014-05-30 14:47:38 -040059struct msm_rd_state;
Rob Clark70c70f02014-05-30 14:49:43 -040060struct msm_perf_state;
Rob Clarka7d3c952014-05-30 14:47:38 -040061struct msm_gem_submit;
Rob Clarkca762a82016-03-15 17:22:13 -040062struct msm_fence_context;
Rob Clarkfde5de62016-03-15 15:35:08 -040063struct msm_fence_cb;
Rob Clarke22a2fb2017-02-13 10:14:11 -070064struct msm_gem_address_space;
65struct msm_gem_vma;
Rob Clarkc8afe682013-06-26 12:44:06 -040066
Alan Kwong112a84f2016-05-24 20:49:21 -040067#define NUM_DOMAINS 4 /* one for KMS, then one per gpu core (?) */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070068#define MAX_CRTCS 8
Jeykumar Sankaran2e655032017-02-04 14:05:45 -080069#define MAX_PLANES 20
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070070#define MAX_ENCODERS 8
71#define MAX_BRIDGES 8
72#define MAX_CONNECTORS 8
Rob Clark7198e6b2013-07-19 12:59:32 -040073
Veera Sundaram Sankarane2bf6862017-08-01 13:55:12 -070074#define TEARDOWN_DEADLOCK_RETRY_MAX 5
75
Rob Clark7198e6b2013-07-19 12:59:32 -040076struct msm_file_private {
77 /* currently we don't do anything useful with this.. but when
78 * per-context address spaces are supported we'd keep track of
79 * the context's page-tables here.
80 */
81 int dummy;
82};
Rob Clarkc8afe682013-06-26 12:44:06 -040083
jilai wang12987782015-06-25 17:37:42 -040084enum msm_mdp_plane_property {
Clarence Ip5e2a9222016-06-26 22:38:24 -040085 /* blob properties, always put these first */
Clarence Ipb43d4592016-09-08 14:21:35 -040086 PLANE_PROP_SCALER_V1,
abeykun48f407a2016-08-25 12:06:44 -040087 PLANE_PROP_SCALER_V2,
Clarence Ip5fc00c52016-09-23 15:03:34 -040088 PLANE_PROP_CSC_V1,
Dhaval Patel4e574842016-08-23 15:11:37 -070089 PLANE_PROP_INFO,
abeykun48f407a2016-08-25 12:06:44 -040090 PLANE_PROP_SCALER_LUT_ED,
91 PLANE_PROP_SCALER_LUT_CIR,
92 PLANE_PROP_SCALER_LUT_SEP,
Benet Clarkd009b1d2016-06-27 14:45:59 -070093 PLANE_PROP_SKIN_COLOR,
94 PLANE_PROP_SKY_COLOR,
95 PLANE_PROP_FOLIAGE_COLOR,
Alan Kwong4dd64c82017-02-04 18:41:51 -080096 PLANE_PROP_ROT_CAPS_V1,
Clarence Ip5e2a9222016-06-26 22:38:24 -040097
98 /* # of blob properties */
99 PLANE_PROP_BLOBCOUNT,
100
Clarence Ipe78efb72016-06-24 18:35:21 -0400101 /* range properties */
Clarence Ip5e2a9222016-06-26 22:38:24 -0400102 PLANE_PROP_ZPOS = PLANE_PROP_BLOBCOUNT,
jilai wang12987782015-06-25 17:37:42 -0400103 PLANE_PROP_ALPHA,
Clarence Ipcb410d42016-06-26 22:52:33 -0400104 PLANE_PROP_COLOR_FILL,
Clarence Ipdedbba92016-09-27 17:43:10 -0400105 PLANE_PROP_H_DECIMATE,
106 PLANE_PROP_V_DECIMATE,
Clarence Ipcae1bb62016-07-07 12:07:13 -0400107 PLANE_PROP_INPUT_FENCE,
Benet Clarkeb1b4462016-06-27 14:43:06 -0700108 PLANE_PROP_HUE_ADJUST,
109 PLANE_PROP_SATURATION_ADJUST,
110 PLANE_PROP_VALUE_ADJUST,
111 PLANE_PROP_CONTRAST_ADJUST,
Veera Sundaram Sankaran02dd6ac2016-12-22 15:08:29 -0800112 PLANE_PROP_EXCL_RECT_V1,
Alan Kwong4dd64c82017-02-04 18:41:51 -0800113 PLANE_PROP_ROT_DST_X,
114 PLANE_PROP_ROT_DST_Y,
115 PLANE_PROP_ROT_DST_W,
116 PLANE_PROP_ROT_DST_H,
Alan Kwong2349d742017-04-20 08:27:30 -0700117 PLANE_PROP_PREFILL_SIZE,
118 PLANE_PROP_PREFILL_TIME,
Clarence Ipe78efb72016-06-24 18:35:21 -0400119
Clarence Ip5e2a9222016-06-26 22:38:24 -0400120 /* enum/bitmask properties */
121 PLANE_PROP_ROTATION,
122 PLANE_PROP_BLEND_OP,
123 PLANE_PROP_SRC_CONFIG,
Abhijit Kulkarni50d69442017-04-11 19:50:47 -0700124 PLANE_PROP_FB_TRANSLATION_MODE,
Clarence Ipe78efb72016-06-24 18:35:21 -0400125
Clarence Ip5e2a9222016-06-26 22:38:24 -0400126 /* total # of properties */
127 PLANE_PROP_COUNT
jilai wang12987782015-06-25 17:37:42 -0400128};
129
Clarence Ip7a753bb2016-07-07 11:47:44 -0400130enum msm_mdp_crtc_property {
Dhaval Patele4a5dda2016-10-13 19:29:30 -0700131 CRTC_PROP_INFO,
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530132 CRTC_PROP_DEST_SCALER_LUT_ED,
133 CRTC_PROP_DEST_SCALER_LUT_CIR,
134 CRTC_PROP_DEST_SCALER_LUT_SEP,
Dhaval Patele4a5dda2016-10-13 19:29:30 -0700135
Clarence Ip7a753bb2016-07-07 11:47:44 -0400136 /* # of blob properties */
137 CRTC_PROP_BLOBCOUNT,
138
139 /* range properties */
Clarence Ipcae1bb62016-07-07 12:07:13 -0400140 CRTC_PROP_INPUT_FENCE_TIMEOUT = CRTC_PROP_BLOBCOUNT,
Clarence Ip24f80662016-06-13 19:05:32 -0400141 CRTC_PROP_OUTPUT_FENCE,
Clarence Ip1d9728b2016-09-01 11:10:54 -0400142 CRTC_PROP_OUTPUT_FENCE_OFFSET,
Veera Sundaram Sankaran3171ff82017-01-04 14:34:47 -0800143 CRTC_PROP_DIM_LAYER_V1,
Alan Kwong9aa061c2016-11-06 21:17:12 -0500144 CRTC_PROP_CORE_CLK,
145 CRTC_PROP_CORE_AB,
146 CRTC_PROP_CORE_IB,
Alan Kwong0230a102017-05-16 11:36:44 -0700147 CRTC_PROP_LLCC_AB,
148 CRTC_PROP_LLCC_IB,
149 CRTC_PROP_DRAM_AB,
150 CRTC_PROP_DRAM_IB,
Alan Kwong4aacd532017-02-04 18:51:33 -0800151 CRTC_PROP_ROT_PREFILL_BW,
Alan Kwong8c176bf2017-02-09 19:34:32 -0800152 CRTC_PROP_ROT_CLK,
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400153 CRTC_PROP_ROI_V1,
Abhijit Kulkarni50d69442017-04-11 19:50:47 -0700154 CRTC_PROP_SECURITY_LEVEL,
Dhaval Patele17e0ee2017-08-23 18:01:42 -0700155 CRTC_PROP_IDLE_TIMEOUT,
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +0530156 CRTC_PROP_DEST_SCALER,
Clarence Ip7a753bb2016-07-07 11:47:44 -0400157
158 /* total # of properties */
159 CRTC_PROP_COUNT
160};
161
Clarence Ipdd8021c2016-07-20 16:39:47 -0400162enum msm_mdp_conn_property {
163 /* blob properties, always put these first */
164 CONNECTOR_PROP_SDE_INFO,
Ping Li898b1bf2017-02-09 18:03:28 -0800165 CONNECTOR_PROP_HDR_INFO,
Ping Li8430ee12017-02-24 14:14:44 -0800166 CONNECTOR_PROP_PP_DITHER,
Clarence Ipdd8021c2016-07-20 16:39:47 -0400167
168 /* # of blob properties */
169 CONNECTOR_PROP_BLOBCOUNT,
170
171 /* range properties */
172 CONNECTOR_PROP_OUT_FB = CONNECTOR_PROP_BLOBCOUNT,
173 CONNECTOR_PROP_RETIRE_FENCE,
Alan Kwongbb27c092016-07-20 16:41:25 -0400174 CONNECTOR_PROP_DST_X,
175 CONNECTOR_PROP_DST_Y,
176 CONNECTOR_PROP_DST_W,
177 CONNECTOR_PROP_DST_H,
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400178 CONNECTOR_PROP_ROI_V1,
Xu Yangd566d222017-05-19 17:18:12 +0800179 CONNECTOR_PROP_BL_SCALE,
180 CONNECTOR_PROP_AD_BL_SCALE,
Clarence Ipdd8021c2016-07-20 16:39:47 -0400181
182 /* enum/bitmask properties */
Lloyd Atkinsonb6191972016-08-10 18:31:46 -0400183 CONNECTOR_PROP_TOPOLOGY_NAME,
184 CONNECTOR_PROP_TOPOLOGY_CONTROL,
Lloyd Atkinson77382202017-02-01 14:59:43 -0500185 CONNECTOR_PROP_AUTOREFRESH,
Clarence Ip90b282d2017-05-04 10:00:32 -0700186 CONNECTOR_PROP_LP,
Alan Kwong03b89842017-08-17 16:32:45 -0400187 CONNECTOR_PROP_FB_TRANSLATION_MODE,
Clarence Ipdd8021c2016-07-20 16:39:47 -0400188
189 /* total # of properties */
190 CONNECTOR_PROP_COUNT
191};
192
Hai Li78b1d472015-07-27 13:49:45 -0400193struct msm_vblank_ctrl {
Sandeep Pandaf48c46a2016-10-24 09:48:50 +0530194 struct kthread_work work;
Hai Li78b1d472015-07-27 13:49:45 -0400195 struct list_head event_list;
196 spinlock_t lock;
197};
198
Clarence Ipa4039322016-07-15 16:23:59 -0400199#define MAX_H_TILES_PER_DISPLAY 2
200
201/**
Alexander Beykunac182352017-02-27 17:46:51 -0500202 * enum msm_display_compression_type - compression method used for pixel stream
203 * @MSM_DISPLAY_COMPRESSION_NONE: Pixel data is not compressed
204 * @MSM_DISPLAY_COMPRESSION_DSC: DSC compresison is used
Clarence Ipa4039322016-07-15 16:23:59 -0400205 */
Alexander Beykunac182352017-02-27 17:46:51 -0500206enum msm_display_compression_type {
207 MSM_DISPLAY_COMPRESSION_NONE,
208 MSM_DISPLAY_COMPRESSION_DSC,
Clarence Ipa4039322016-07-15 16:23:59 -0400209};
210
211/**
212 * enum msm_display_caps - features/capabilities supported by displays
213 * @MSM_DISPLAY_CAP_VID_MODE: Video or "active" mode supported
214 * @MSM_DISPLAY_CAP_CMD_MODE: Command mode supported
215 * @MSM_DISPLAY_CAP_HOT_PLUG: Hot plug detection supported
216 * @MSM_DISPLAY_CAP_EDID: EDID supported
Sandeep Panda98d6ab22017-09-05 08:03:16 +0530217 * @MSM_DISPLAY_ESD_ENABLED: ESD feature enabled
Clarence Ipa4039322016-07-15 16:23:59 -0400218 */
219enum msm_display_caps {
220 MSM_DISPLAY_CAP_VID_MODE = BIT(0),
221 MSM_DISPLAY_CAP_CMD_MODE = BIT(1),
222 MSM_DISPLAY_CAP_HOT_PLUG = BIT(2),
223 MSM_DISPLAY_CAP_EDID = BIT(3),
Sandeep Panda98d6ab22017-09-05 08:03:16 +0530224 MSM_DISPLAY_ESD_ENABLED = BIT(4),
Clarence Ipa4039322016-07-15 16:23:59 -0400225};
226
227/**
Jeykumar Sankarandfaeec92017-06-06 15:21:51 -0700228 * enum msm_event_wait - type of HW events to wait for
229 * @MSM_ENC_COMMIT_DONE - wait for the driver to flush the registers to HW
230 * @MSM_ENC_TX_COMPLETE - wait for the HW to transfer the frame to panel
Lloyd Atkinsonf68a2132017-07-17 10:16:30 -0400231 * @MSM_ENC_VBLANK - wait for the HW VBLANK event (for driver-internal waiters)
Jeykumar Sankarandfaeec92017-06-06 15:21:51 -0700232 */
233enum msm_event_wait {
234 MSM_ENC_COMMIT_DONE = 0,
235 MSM_ENC_TX_COMPLETE,
Lloyd Atkinsonf68a2132017-07-17 10:16:30 -0400236 MSM_ENC_VBLANK,
Jeykumar Sankarandfaeec92017-06-06 15:21:51 -0700237};
238
239/**
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400240 * struct msm_roi_alignment - region of interest alignment restrictions
241 * @xstart_pix_align: left x offset alignment restriction
242 * @width_pix_align: width alignment restriction
243 * @ystart_pix_align: top y offset alignment restriction
244 * @height_pix_align: height alignment restriction
245 * @min_width: minimum width restriction
246 * @min_height: minimum height restriction
247 */
248struct msm_roi_alignment {
249 uint32_t xstart_pix_align;
250 uint32_t width_pix_align;
251 uint32_t ystart_pix_align;
252 uint32_t height_pix_align;
253 uint32_t min_width;
254 uint32_t min_height;
255};
256
257/**
258 * struct msm_roi_caps - display's region of interest capabilities
259 * @enabled: true if some region of interest is supported
260 * @merge_rois: merge rois before sending to display
261 * @num_roi: maximum number of rois supported
262 * @align: roi alignment restrictions
263 */
264struct msm_roi_caps {
265 bool enabled;
266 bool merge_rois;
267 uint32_t num_roi;
268 struct msm_roi_alignment align;
269};
270
271/**
Alexander Beykunac182352017-02-27 17:46:51 -0500272 * struct msm_display_dsc_info - defines dsc configuration
273 * @version: DSC version.
274 * @scr_rev: DSC revision.
275 * @pic_height: Picture height in pixels.
276 * @pic_width: Picture width in pixels.
277 * @initial_lines: Number of initial lines stored in encoder.
278 * @pkt_per_line: Number of packets per line.
279 * @bytes_in_slice: Number of bytes in slice.
280 * @eol_byte_num: Valid bytes at the end of line.
281 * @pclk_per_line: Compressed width.
282 * @full_frame_slices: Number of slice per interface.
283 * @slice_height: Slice height in pixels.
284 * @slice_width: Slice width in pixels.
285 * @chunk_size: Chunk size in bytes for slice multiplexing.
286 * @slice_last_group_size: Size of last group in pixels.
287 * @bpp: Target bits per pixel.
288 * @bpc: Number of bits per component.
289 * @line_buf_depth: Line buffer bit depth.
290 * @block_pred_enable: Block prediction enabled/disabled.
291 * @vbr_enable: VBR mode.
292 * @enable_422: Indicates if input uses 4:2:2 sampling.
293 * @convert_rgb: DSC color space conversion.
294 * @input_10_bits: 10 bit per component input.
295 * @slice_per_pkt: Number of slices per packet.
296 * @initial_dec_delay: Initial decoding delay.
297 * @initial_xmit_delay: Initial transmission delay.
298 * @initial_scale_value: Scale factor value at the beginning of a slice.
299 * @scale_decrement_interval: Scale set up at the beginning of a slice.
300 * @scale_increment_interval: Scale set up at the end of a slice.
301 * @first_line_bpg_offset: Extra bits allocated on the first line of a slice.
302 * @nfl_bpg_offset: Slice specific settings.
303 * @slice_bpg_offset: Slice specific settings.
304 * @initial_offset: Initial offset at the start of a slice.
305 * @final_offset: Maximum end-of-slice value.
306 * @rc_model_size: Number of bits in RC model.
307 * @det_thresh_flatness: Flatness threshold.
308 * @max_qp_flatness: Maximum QP for flatness adjustment.
309 * @min_qp_flatness: Minimum QP for flatness adjustment.
310 * @edge_factor: Ratio to detect presence of edge.
311 * @quant_incr_limit0: QP threshold.
312 * @quant_incr_limit1: QP threshold.
313 * @tgt_offset_hi: Upper end of variability range.
314 * @tgt_offset_lo: Lower end of variability range.
315 * @buf_thresh: Thresholds in RC model
316 * @range_min_qp: Min QP allowed.
317 * @range_max_qp: Max QP allowed.
318 * @range_bpg_offset: Bits per group adjustment.
319 */
320struct msm_display_dsc_info {
321 u8 version;
322 u8 scr_rev;
323
324 int pic_height;
325 int pic_width;
326 int slice_height;
327 int slice_width;
328
329 int initial_lines;
330 int pkt_per_line;
331 int bytes_in_slice;
332 int bytes_per_pkt;
333 int eol_byte_num;
334 int pclk_per_line;
335 int full_frame_slices;
336 int slice_last_group_size;
337 int bpp;
338 int bpc;
339 int line_buf_depth;
340
341 int slice_per_pkt;
342 int chunk_size;
343 bool block_pred_enable;
344 int vbr_enable;
345 int enable_422;
346 int convert_rgb;
347 int input_10_bits;
348
349 int initial_dec_delay;
350 int initial_xmit_delay;
351 int initial_scale_value;
352 int scale_decrement_interval;
353 int scale_increment_interval;
354 int first_line_bpg_offset;
355 int nfl_bpg_offset;
356 int slice_bpg_offset;
357 int initial_offset;
358 int final_offset;
359
360 int rc_model_size;
361 int det_thresh_flatness;
362 int max_qp_flatness;
363 int min_qp_flatness;
364 int edge_factor;
365 int quant_incr_limit0;
366 int quant_incr_limit1;
367 int tgt_offset_hi;
368 int tgt_offset_lo;
369
370 u32 *buf_thresh;
371 char *range_min_qp;
372 char *range_max_qp;
373 char *range_bpg_offset;
374};
375
376/**
377 * struct msm_compression_info - defined panel compression
378 * @comp_type: type of compression supported
379 * @dsc_info: dsc configuration if the compression
380 * supported is DSC
381 */
382struct msm_compression_info {
383 enum msm_display_compression_type comp_type;
384
385 union{
386 struct msm_display_dsc_info dsc_info;
387 };
388};
389
390/**
Jeykumar Sankaran6b345ac2017-03-15 19:17:19 -0700391 * struct msm_display_topology - defines a display topology pipeline
392 * @num_lm: number of layer mixers used
393 * @num_enc: number of compression encoder blocks used
394 * @num_intf: number of interfaces the panel is mounted on
395 */
396struct msm_display_topology {
397 u32 num_lm;
398 u32 num_enc;
399 u32 num_intf;
400};
401
402/**
403 * struct msm_mode_info - defines all msm custom mode info
Jeykumar Sankaran446a5f12017-05-09 20:30:39 -0700404 * @frame_rate: frame_rate of the mode
405 * @vtotal: vtotal calculated for the mode
406 * @prefill_lines: prefill lines based on porches.
407 * @jitter_numer: display panel jitter numerator configuration
408 * @jitter_denom: display panel jitter denominator configuration
Vara Reddy812bd722017-09-20 07:19:19 -0700409 * @clk_rate: DSI bit clock per lane in HZ.
Jeykumar Sankaran446a5f12017-05-09 20:30:39 -0700410 * @topology: supported topology for the mode
411 * @comp_info: compression info supported
Jeykumar Sankaran6b345ac2017-03-15 19:17:19 -0700412 */
413struct msm_mode_info {
Jeykumar Sankaran446a5f12017-05-09 20:30:39 -0700414 uint32_t frame_rate;
415 uint32_t vtotal;
416 uint32_t prefill_lines;
417 uint32_t jitter_numer;
418 uint32_t jitter_denom;
Vara Reddy812bd722017-09-20 07:19:19 -0700419 uint64_t clk_rate;
Jeykumar Sankaran6b345ac2017-03-15 19:17:19 -0700420 struct msm_display_topology topology;
Jeykumar Sankaran446a5f12017-05-09 20:30:39 -0700421 struct msm_compression_info comp_info;
Jeykumar Sankaran6b345ac2017-03-15 19:17:19 -0700422};
423
424/**
Clarence Ipa4039322016-07-15 16:23:59 -0400425 * struct msm_display_info - defines display properties
426 * @intf_type: DRM_MODE_CONNECTOR_ display type
427 * @capabilities: Bitmask of display flags
428 * @num_of_h_tiles: Number of horizontal tiles in case of split interface
429 * @h_tile_instance: Controller instance used per tile. Number of elements is
430 * based on num_of_h_tiles
431 * @is_connected: Set to true if display is connected
432 * @width_mm: Physical width
433 * @height_mm: Physical height
434 * @max_width: Max width of display. In case of hot pluggable display
435 * this is max width supported by controller
436 * @max_height: Max height of display. In case of hot pluggable display
437 * this is max height supported by controller
Vara Reddy812bd722017-09-20 07:19:19 -0700438 * @clk_rate: DSI bit clock per lane in HZ.
Dhaval Patel60e1ff52017-02-18 21:03:40 -0800439 * @is_primary: Set to true if display is primary display
Narendra Muppallad4081e12017-04-20 19:24:08 -0700440 * @is_te_using_watchdog_timer: Boolean to indicate watchdog TE is
441 * used instead of panel TE in cmd mode panels
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400442 * @roi_caps: Region of interest capability info
Clarence Ipa4039322016-07-15 16:23:59 -0400443 */
444struct msm_display_info {
445 int intf_type;
446 uint32_t capabilities;
447
448 uint32_t num_of_h_tiles;
449 uint32_t h_tile_instance[MAX_H_TILES_PER_DISPLAY];
450
451 bool is_connected;
452
453 unsigned int width_mm;
454 unsigned int height_mm;
455
456 uint32_t max_width;
457 uint32_t max_height;
Vara Reddy812bd722017-09-20 07:19:19 -0700458 uint64_t clk_rate;
Clarence Ipa4039322016-07-15 16:23:59 -0400459
Dhaval Patel60e1ff52017-02-18 21:03:40 -0800460 bool is_primary;
Narendra Muppallad4081e12017-04-20 19:24:08 -0700461 bool is_te_using_watchdog_timer;
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400462 struct msm_roi_caps roi_caps;
Clarence Ipa4039322016-07-15 16:23:59 -0400463};
464
Lloyd Atkinson05d75512017-01-17 14:45:51 -0500465#define MSM_MAX_ROI 4
466
467/**
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400468 * struct msm_roi_list - list of regions of interest for a drm object
469 * @num_rects: number of valid rectangles in the roi array
470 * @roi: list of roi rectangles
Lloyd Atkinson05d75512017-01-17 14:45:51 -0500471 */
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400472struct msm_roi_list {
Lloyd Atkinson05d75512017-01-17 14:45:51 -0500473 uint32_t num_rects;
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400474 struct drm_clip_rect roi[MSM_MAX_ROI];
Lloyd Atkinson05d75512017-01-17 14:45:51 -0500475};
476
477/**
478 * struct - msm_display_kickoff_params - info for display features at kickoff
479 * @rois: Regions of interest structure for mapping CRTC to Connector output
480 */
481struct msm_display_kickoff_params {
Lloyd Atkinson8ba47032017-03-22 17:13:32 -0400482 struct msm_roi_list *rois;
Lloyd Atkinson05d75512017-01-17 14:45:51 -0500483};
484
Clarence Ip3649f8b2016-10-31 09:59:44 -0400485/**
486 * struct msm_drm_event - defines custom event notification struct
487 * @base: base object required for event notification by DRM framework.
488 * @event: event object required for event notification by DRM framework.
489 * @info: contains information of DRM object for which events has been
490 * requested.
491 * @data: memory location which contains response payload for event.
492 */
493struct msm_drm_event {
494 struct drm_pending_event base;
495 struct drm_event event;
Gopikrishnaiah Anandande2c81b2017-03-15 12:41:29 -0700496 struct drm_msm_event_req info;
Clarence Ip3649f8b2016-10-31 09:59:44 -0400497 u8 data[];
498};
Ajay Singh Parmar64c19192016-06-10 16:44:56 -0700499
Veera Sundaram Sankaran10ea2bd2017-06-14 14:10:57 -0700500/* Commit/Event thread specific structure */
501struct msm_drm_thread {
Sandeep Pandaf48c46a2016-10-24 09:48:50 +0530502 struct drm_device *dev;
503 struct task_struct *thread;
504 unsigned int crtc_id;
505 struct kthread_worker worker;
506};
507
Rob Clarkc8afe682013-06-26 12:44:06 -0400508struct msm_drm_private {
509
Rob Clark68209392016-05-17 16:19:32 -0400510 struct drm_device *dev;
511
Rob Clarkc8afe682013-06-26 12:44:06 -0400512 struct msm_kms *kms;
513
Dhaval Patel3949f032016-06-20 16:24:33 -0700514 struct sde_power_handle phandle;
515 struct sde_power_client *pclient;
516
Rob Clark060530f2014-03-03 14:19:12 -0500517 /* subordinate devices, if present: */
Rob Clark067fef32014-11-04 13:33:14 -0500518 struct platform_device *gpu_pdev;
519
Archit Taneja990a4002016-05-07 23:11:25 +0530520 /* top level MDSS wrapper device (for MDP5 only) */
521 struct msm_mdss *mdss;
522
Rob Clark067fef32014-11-04 13:33:14 -0500523 /* possibly this should be in the kms component, but it is
524 * shared by both mdp4 and mdp5..
525 */
526 struct hdmi *hdmi;
Rob Clark060530f2014-03-03 14:19:12 -0500527
Hai Liab5b0102015-01-07 18:47:44 -0500528 /* eDP is for mdp5 only, but kms has not been created
529 * when edp_bind() and edp_init() are called. Here is the only
530 * place to keep the edp instance.
531 */
532 struct msm_edp *edp;
533
Hai Lia6895542015-03-31 14:36:33 -0400534 /* DSI is shared by mdp4 and mdp5 */
535 struct msm_dsi *dsi[2];
536
Rob Clark7198e6b2013-07-19 12:59:32 -0400537 /* when we have more than one 'msm_gpu' these need to be an array: */
538 struct msm_gpu *gpu;
539 struct msm_file_private *lastctx;
540
Rob Clarkc8afe682013-06-26 12:44:06 -0400541 struct drm_fb_helper *fbdev;
542
Rob Clarka7d3c952014-05-30 14:47:38 -0400543 struct msm_rd_state *rd;
Rob Clark70c70f02014-05-30 14:49:43 -0400544 struct msm_perf_state *perf;
Rob Clarka7d3c952014-05-30 14:47:38 -0400545
Rob Clarkc8afe682013-06-26 12:44:06 -0400546 /* list of GEM objects: */
547 struct list_head inactive_list;
548
549 struct workqueue_struct *wq;
550
Rob Clarkf86afec2014-11-25 12:41:18 -0500551 /* crtcs pending async atomic updates: */
552 uint32_t pending_crtcs;
553 wait_queue_head_t pending_crtcs_event;
554
Rob Clarke22a2fb2017-02-13 10:14:11 -0700555 /* Registered address spaces.. currently this is fixed per # of
556 * iommu's. Ie. one for display block and one for gpu block.
557 * Eventually, to do per-process gpu pagetables, we'll want one
558 * of these per-process.
559 */
560 unsigned int num_aspaces;
561 struct msm_gem_address_space *aspace[NUM_DOMAINS];
Rob Clarkc8afe682013-06-26 12:44:06 -0400562
Rob Clarka8623912013-10-08 12:57:48 -0400563 unsigned int num_planes;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700564 struct drm_plane *planes[MAX_PLANES];
Rob Clarka8623912013-10-08 12:57:48 -0400565
Rob Clarkc8afe682013-06-26 12:44:06 -0400566 unsigned int num_crtcs;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700567 struct drm_crtc *crtcs[MAX_CRTCS];
Rob Clarkc8afe682013-06-26 12:44:06 -0400568
Veera Sundaram Sankaran10ea2bd2017-06-14 14:10:57 -0700569 struct msm_drm_thread disp_thread[MAX_CRTCS];
570 struct msm_drm_thread event_thread[MAX_CRTCS];
Sandeep Pandaf48c46a2016-10-24 09:48:50 +0530571
Rob Clarkc8afe682013-06-26 12:44:06 -0400572 unsigned int num_encoders;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700573 struct drm_encoder *encoders[MAX_ENCODERS];
Rob Clarkc8afe682013-06-26 12:44:06 -0400574
Rob Clarka3376e32013-08-30 13:02:15 -0400575 unsigned int num_bridges;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700576 struct drm_bridge *bridges[MAX_BRIDGES];
Rob Clarka3376e32013-08-30 13:02:15 -0400577
Rob Clarkc8afe682013-06-26 12:44:06 -0400578 unsigned int num_connectors;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700579 struct drm_connector *connectors[MAX_CONNECTORS];
Rob Clark871d8122013-11-16 12:56:06 -0500580
jilai wang12987782015-06-25 17:37:42 -0400581 /* Properties */
Clarence Ipe78efb72016-06-24 18:35:21 -0400582 struct drm_property *plane_property[PLANE_PROP_COUNT];
Clarence Ip7a753bb2016-07-07 11:47:44 -0400583 struct drm_property *crtc_property[CRTC_PROP_COUNT];
Clarence Ipdd8021c2016-07-20 16:39:47 -0400584 struct drm_property *conn_property[CONNECTOR_PROP_COUNT];
jilai wang12987782015-06-25 17:37:42 -0400585
Gopikrishnaiah Anandane0e5e0c2016-05-25 11:05:33 -0700586 /* Color processing properties for the crtc */
587 struct drm_property **cp_property;
588
Rob Clark871d8122013-11-16 12:56:06 -0500589 /* VRAM carveout, used when no IOMMU: */
590 struct {
591 unsigned long size;
592 dma_addr_t paddr;
593 /* NOTE: mm managed at the page level, size is in # of pages
594 * and position mm_node->start is in # of pages:
595 */
596 struct drm_mm mm;
597 } vram;
Hai Li78b1d472015-07-27 13:49:45 -0400598
Rob Clarke1e9db22016-05-27 11:16:28 -0400599 struct notifier_block vmap_notifier;
Rob Clark68209392016-05-17 16:19:32 -0400600 struct shrinker shrinker;
601
Hai Li78b1d472015-07-27 13:49:45 -0400602 struct msm_vblank_ctrl vblank_ctrl;
Rob Clarkd78d3832016-08-22 15:28:38 -0400603
Dhaval Patel5200c602017-01-17 15:53:37 -0800604 /* task holding struct_mutex.. currently only used in submit path
605 * to detect and reject faults from copy_from_user() for submit
606 * ioctl.
607 */
608 struct task_struct *struct_mutex_task;
609
Lloyd Atkinson5d40d312016-09-06 08:34:13 -0400610 /* list of clients waiting for events */
611 struct list_head client_event_list;
Lloyd Atkinsonab3dd302017-02-13 10:44:55 -0800612
613 /* whether registered and drm_dev_unregister should be called */
614 bool registered;
Dhaval Patel6c666622017-03-21 23:02:59 -0700615
616 /* msm drv debug root node */
617 struct dentry *debug_root;
Rob Clarkc8afe682013-06-26 12:44:06 -0400618};
619
Clarence Ipd86f6e42017-08-08 18:31:00 -0400620/* get struct msm_kms * from drm_device * */
621#define ddev_to_msm_kms(D) ((D) && (D)->dev_private ? \
622 ((struct msm_drm_private *)((D)->dev_private))->kms : NULL)
623
Rob Clarkc8afe682013-06-26 12:44:06 -0400624struct msm_format {
625 uint32_t pixel_format;
626};
627
Dhaval Patel7a7d85d2016-08-26 16:35:34 -0700628/* callback from wq once fence has passed: */
629struct msm_fence_cb {
630 struct work_struct work;
631 uint32_t fence;
632 void (*func)(struct msm_fence_cb *cb);
633};
634
635void __msm_fence_worker(struct work_struct *work);
636
637#define INIT_FENCE_CB(_cb, _func) do { \
638 INIT_WORK(&(_cb)->work, __msm_fence_worker); \
639 (_cb)->func = _func; \
640 } while (0)
641
Rob Clarkcf3a7e42014-11-08 13:21:06 -0500642int msm_atomic_commit(struct drm_device *dev,
Maarten Lankhorsta3ccfb92016-04-26 16:11:38 +0200643 struct drm_atomic_state *state, bool nonblock);
Rob Clarkcf3a7e42014-11-08 13:21:06 -0500644
Rob Clark40e68152016-05-03 09:50:26 -0400645void msm_gem_submit_free(struct msm_gem_submit *submit);
Rob Clarke22a2fb2017-02-13 10:14:11 -0700646void msm_gem_unmap_vma(struct msm_gem_address_space *aspace,
Jordan Crouse12bf3622017-02-13 10:14:11 -0700647 struct msm_gem_vma *vma, struct sg_table *sgt,
648 void *priv);
Rob Clarke22a2fb2017-02-13 10:14:11 -0700649int msm_gem_map_vma(struct msm_gem_address_space *aspace,
Jordan Crouse12bf3622017-02-13 10:14:11 -0700650 struct msm_gem_vma *vma, struct sg_table *sgt,
651 void *priv, unsigned int flags);
Rob Clarke22a2fb2017-02-13 10:14:11 -0700652void msm_gem_address_space_destroy(struct msm_gem_address_space *aspace);
Jordan Crouse12bf3622017-02-13 10:14:11 -0700653
654/* For GPU and legacy display */
Rob Clarke22a2fb2017-02-13 10:14:11 -0700655struct msm_gem_address_space *
656msm_gem_address_space_create(struct device *dev, struct iommu_domain *domain,
657 const char *name);
658
Jordan Crouse12bf3622017-02-13 10:14:11 -0700659/* For SDE display */
660struct msm_gem_address_space *
Abhijit Kulkarnif4657b12017-06-28 18:40:19 -0700661msm_gem_smmu_address_space_create(struct drm_device *dev, struct msm_mmu *mmu,
Jordan Crouse12bf3622017-02-13 10:14:11 -0700662 const char *name);
663
Abhijit Kulkarnif4657b12017-06-28 18:40:19 -0700664/**
665 * msm_gem_add_obj_to_aspace_active_list: adds obj to active obj list in aspace
666 */
667void msm_gem_add_obj_to_aspace_active_list(
668 struct msm_gem_address_space *aspace,
669 struct drm_gem_object *obj);
670
671/**
672 * msm_gem_remove_obj_from_aspace_active_list: removes obj from active obj
673 * list in aspace
674 */
675void msm_gem_remove_obj_from_aspace_active_list(
676 struct msm_gem_address_space *aspace,
677 struct drm_gem_object *obj);
678
679/**
680 * msm_gem_smmu_address_space_get: returns the aspace pointer for the requested
681 * domain
682 */
Jordan Croused8e96522017-02-13 10:14:16 -0700683struct msm_gem_address_space *
684msm_gem_smmu_address_space_get(struct drm_device *dev,
685 unsigned int domain);
686
Abhijit Kulkarnif4657b12017-06-28 18:40:19 -0700687/**
688 * msm_gem_aspace_domain_attach_detach: function to inform the attach/detach
689 * of the domain for this aspace
690 */
691void msm_gem_aspace_domain_attach_detach_update(
692 struct msm_gem_address_space *aspace,
693 bool is_detach);
694
695/**
696 * msm_gem_address_space_register_cb: function to register callback for attach
697 * and detach of the domain
698 */
699int msm_gem_address_space_register_cb(
700 struct msm_gem_address_space *aspace,
701 void (*cb)(void *, bool),
702 void *cb_data);
703
704/**
705 * msm_gem_address_space_register_cb: function to unregister callback
706 */
707int msm_gem_address_space_unregister_cb(
708 struct msm_gem_address_space *aspace,
709 void (*cb)(void *, bool),
710 void *cb_data);
711
Rob Clark7198e6b2013-07-19 12:59:32 -0400712int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
713 struct drm_file *file);
714
Rob Clark68209392016-05-17 16:19:32 -0400715void msm_gem_shrinker_init(struct drm_device *dev);
716void msm_gem_shrinker_cleanup(struct drm_device *dev);
717
Daniel Thompson77a147e2014-11-12 11:38:14 +0000718int msm_gem_mmap_obj(struct drm_gem_object *obj,
719 struct vm_area_struct *vma);
Rob Clarkc8afe682013-06-26 12:44:06 -0400720int msm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
721int msm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
722uint64_t msm_gem_mmap_offset(struct drm_gem_object *obj);
Jordan Croused8e96522017-02-13 10:14:16 -0700723int msm_gem_get_iova_locked(struct drm_gem_object *obj,
724 struct msm_gem_address_space *aspace, uint32_t *iova);
725int msm_gem_get_iova(struct drm_gem_object *obj,
726 struct msm_gem_address_space *aspace, uint32_t *iova);
727uint32_t msm_gem_iova(struct drm_gem_object *obj,
728 struct msm_gem_address_space *aspace);
Rob Clark05b84912013-09-28 11:28:35 -0400729struct page **msm_gem_get_pages(struct drm_gem_object *obj);
730void msm_gem_put_pages(struct drm_gem_object *obj);
Jordan Croused8e96522017-02-13 10:14:16 -0700731void msm_gem_put_iova(struct drm_gem_object *obj,
732 struct msm_gem_address_space *aspace);
Abhijit Kulkarni1b3340c2017-06-22 12:39:37 -0700733dma_addr_t msm_gem_get_dma_addr(struct drm_gem_object *obj);
Rob Clarkc8afe682013-06-26 12:44:06 -0400734int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
735 struct drm_mode_create_dumb *args);
Rob Clarkc8afe682013-06-26 12:44:06 -0400736int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
737 uint32_t handle, uint64_t *offset);
Rob Clark05b84912013-09-28 11:28:35 -0400738struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj);
739void *msm_gem_prime_vmap(struct drm_gem_object *obj);
740void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
Daniel Thompson77a147e2014-11-12 11:38:14 +0000741int msm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
Eric Anholtb3a42bb2017-04-12 12:11:58 -0700742struct reservation_object *msm_gem_prime_res_obj(struct drm_gem_object *obj);
Rob Clark05b84912013-09-28 11:28:35 -0400743struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,
Maarten Lankhorstb5e9c1a2014-01-09 11:03:14 +0100744 struct dma_buf_attachment *attach, struct sg_table *sg);
Rob Clark05b84912013-09-28 11:28:35 -0400745int msm_gem_prime_pin(struct drm_gem_object *obj);
746void msm_gem_prime_unpin(struct drm_gem_object *obj);
Rob Clark18f23042016-05-26 16:24:35 -0400747void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj);
748void *msm_gem_get_vaddr(struct drm_gem_object *obj);
749void msm_gem_put_vaddr_locked(struct drm_gem_object *obj);
750void msm_gem_put_vaddr(struct drm_gem_object *obj);
Rob Clark4cd33c42016-05-17 15:44:49 -0400751int msm_gem_madvise(struct drm_gem_object *obj, unsigned madv);
Rob Clark68209392016-05-17 16:19:32 -0400752void msm_gem_purge(struct drm_gem_object *obj);
Rob Clarke1e9db22016-05-27 11:16:28 -0400753void msm_gem_vunmap(struct drm_gem_object *obj);
Rob Clarkb6295f92016-03-15 18:26:28 -0400754int msm_gem_sync_object(struct drm_gem_object *obj,
755 struct msm_fence_context *fctx, bool exclusive);
Rob Clark7198e6b2013-07-19 12:59:32 -0400756void msm_gem_move_to_active(struct drm_gem_object *obj,
Rob Clarkb6295f92016-03-15 18:26:28 -0400757 struct msm_gpu *gpu, bool exclusive, struct fence *fence);
Rob Clark7198e6b2013-07-19 12:59:32 -0400758void msm_gem_move_to_inactive(struct drm_gem_object *obj);
Rob Clarkba00c3f2016-03-16 18:18:17 -0400759int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout);
Rob Clark7198e6b2013-07-19 12:59:32 -0400760int msm_gem_cpu_fini(struct drm_gem_object *obj);
Rob Clarkc8afe682013-06-26 12:44:06 -0400761void msm_gem_free_object(struct drm_gem_object *obj);
762int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
763 uint32_t size, uint32_t flags, uint32_t *handle);
764struct drm_gem_object *msm_gem_new(struct drm_device *dev,
765 uint32_t size, uint32_t flags);
Rob Clark05b84912013-09-28 11:28:35 -0400766struct drm_gem_object *msm_gem_import(struct drm_device *dev,
Rob Clark79f0e202016-03-16 12:40:35 -0400767 struct dma_buf *dmabuf, struct sg_table *sgt);
Rob Clarkc8afe682013-06-26 12:44:06 -0400768
Alan Kwong578cdaf2017-01-28 17:25:43 -0800769void msm_framebuffer_set_kmap(struct drm_framebuffer *fb, bool enable);
Jordan Croused8e96522017-02-13 10:14:16 -0700770int msm_framebuffer_prepare(struct drm_framebuffer *fb,
771 struct msm_gem_address_space *aspace);
772void msm_framebuffer_cleanup(struct drm_framebuffer *fb,
773 struct msm_gem_address_space *aspace);
774uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb,
775 struct msm_gem_address_space *aspace, int plane);
Abhijit Kulkarni1b3340c2017-06-22 12:39:37 -0700776uint32_t msm_framebuffer_phys(struct drm_framebuffer *fb, int plane);
Rob Clarkc8afe682013-06-26 12:44:06 -0400777struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane);
778const struct msm_format *msm_framebuffer_format(struct drm_framebuffer *fb);
779struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
Ville Syrjälä1eb83452015-11-11 19:11:29 +0200780 const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
Rob Clarkc8afe682013-06-26 12:44:06 -0400781struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev,
Ville Syrjälä1eb83452015-11-11 19:11:29 +0200782 struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd);
Rob Clarkc8afe682013-06-26 12:44:06 -0400783
784struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev);
Archit Taneja1aaa57f2016-02-25 11:19:45 +0530785void msm_fbdev_free(struct drm_device *dev);
Rob Clarkc8afe682013-06-26 12:44:06 -0400786
Rob Clarkdada25b2013-12-01 12:12:54 -0500787struct hdmi;
Dhaval Patel1ba4ab92017-06-30 14:51:08 -0700788#ifdef CONFIG_DRM_MSM_HDMI
Arnd Bergmannfcda50c2016-02-22 22:08:35 +0100789int msm_hdmi_modeset_init(struct hdmi *hdmi, struct drm_device *dev,
Rob Clark067fef32014-11-04 13:33:14 -0500790 struct drm_encoder *encoder);
Arnd Bergmannfcda50c2016-02-22 22:08:35 +0100791void __init msm_hdmi_register(void);
792void __exit msm_hdmi_unregister(void);
Dhaval Patel1ba4ab92017-06-30 14:51:08 -0700793#else
794static inline void __init msm_hdmi_register(void)
795{
796}
797static inline void __exit msm_hdmi_unregister(void)
798{
799}
800#endif
Rob Clarkc8afe682013-06-26 12:44:06 -0400801
Hai Li00453982014-12-12 14:41:17 -0500802struct msm_edp;
Dhaval Patel1ba4ab92017-06-30 14:51:08 -0700803#ifdef CONFIG_DRM_MSM_EDP
Hai Li00453982014-12-12 14:41:17 -0500804void __init msm_edp_register(void);
805void __exit msm_edp_unregister(void);
806int msm_edp_modeset_init(struct msm_edp *edp, struct drm_device *dev,
807 struct drm_encoder *encoder);
Dhaval Patel1ba4ab92017-06-30 14:51:08 -0700808#else
809static inline void __init msm_edp_register(void)
810{
811}
812static inline void __exit msm_edp_unregister(void)
813{
814}
815#endif
Hai Li00453982014-12-12 14:41:17 -0500816
Hai Lia6895542015-03-31 14:36:33 -0400817struct msm_dsi;
818enum msm_dsi_encoder_id {
819 MSM_DSI_VIDEO_ENCODER_ID = 0,
820 MSM_DSI_CMD_ENCODER_ID = 1,
821 MSM_DSI_ENCODER_NUM = 2
822};
Gopikrishnaiah Anandande2c81b2017-03-15 12:41:29 -0700823
824/* *
Gopikrishnaiah Anandan84b4f672017-04-26 10:28:51 -0700825 * msm_mode_object_event_notify - notify user-space clients of drm object
826 * events.
827 * @obj: mode object (crtc/connector) that is generating the event.
Gopikrishnaiah Anandande2c81b2017-03-15 12:41:29 -0700828 * @event: event that needs to be notified.
829 * @payload: payload for the event.
830 */
Benjamin Chan34a92c72017-06-28 11:01:18 -0400831void msm_mode_object_event_notify(struct drm_mode_object *obj,
Gopikrishnaiah Anandan84b4f672017-04-26 10:28:51 -0700832 struct drm_device *dev, struct drm_event *event, u8 *payload);
Hai Lia6895542015-03-31 14:36:33 -0400833#ifdef CONFIG_DRM_MSM_DSI
834void __init msm_dsi_register(void);
835void __exit msm_dsi_unregister(void);
836int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
837 struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM]);
838#else
839static inline void __init msm_dsi_register(void)
840{
841}
842static inline void __exit msm_dsi_unregister(void)
843{
844}
845static inline int msm_dsi_modeset_init(struct msm_dsi *msm_dsi,
846 struct drm_device *dev,
847 struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM])
848{
849 return -EINVAL;
850}
851#endif
852
Archit Taneja1dd0a0b2016-05-30 16:36:50 +0530853void __init msm_mdp_register(void);
854void __exit msm_mdp_unregister(void);
855
Rob Clarkc8afe682013-06-26 12:44:06 -0400856#ifdef CONFIG_DEBUG_FS
857void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
858void msm_gem_describe_objects(struct list_head *list, struct seq_file *m);
859void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
Rob Clarka7d3c952014-05-30 14:47:38 -0400860int msm_debugfs_late_init(struct drm_device *dev);
861int msm_rd_debugfs_init(struct drm_minor *minor);
862void msm_rd_debugfs_cleanup(struct drm_minor *minor);
863void msm_rd_dump_submit(struct msm_gem_submit *submit);
Rob Clark70c70f02014-05-30 14:49:43 -0400864int msm_perf_debugfs_init(struct drm_minor *minor);
865void msm_perf_debugfs_cleanup(struct drm_minor *minor);
Rob Clarka7d3c952014-05-30 14:47:38 -0400866#else
867static inline int msm_debugfs_late_init(struct drm_device *dev) { return 0; }
868static inline void msm_rd_dump_submit(struct msm_gem_submit *submit) {}
Rob Clarkc8afe682013-06-26 12:44:06 -0400869#endif
870
871void __iomem *msm_ioremap(struct platform_device *pdev, const char *name,
872 const char *dbgname);
Dhaval Patela2430842017-06-15 14:32:36 -0700873unsigned long msm_iomap_size(struct platform_device *pdev, const char *name);
Lloyd Atkinson1a0c9172016-10-04 10:01:24 -0400874void msm_iounmap(struct platform_device *dev, void __iomem *addr);
Rob Clarkc8afe682013-06-26 12:44:06 -0400875void msm_writel(u32 data, void __iomem *addr);
876u32 msm_readl(const void __iomem *addr);
877
878#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
879#define VERB(fmt, ...) if (0) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
880
881static inline int align_pitch(int width, int bpp)
882{
883 int bytespp = (bpp + 7) / 8;
884 /* adreno needs pitch aligned to 32 pixels: */
885 return bytespp * ALIGN(width, 32);
886}
887
888/* for the generated headers: */
889#define INVALID_IDX(idx) ({BUG(); 0;})
Rob Clark7198e6b2013-07-19 12:59:32 -0400890#define fui(x) ({BUG(); 0;})
891#define util_float_to_half(x) ({BUG(); 0;})
892
Rob Clarkc8afe682013-06-26 12:44:06 -0400893
894#define FIELD(val, name) (((val) & name ## __MASK) >> name ## __SHIFT)
895
896/* for conditionally setting boolean flag(s): */
897#define COND(bool, val) ((bool) ? (val) : 0)
898
Rob Clark340ff412016-03-16 14:57:22 -0400899static inline unsigned long timeout_to_jiffies(const ktime_t *timeout)
900{
901 ktime_t now = ktime_get();
902 unsigned long remaining_jiffies;
903
904 if (ktime_compare(*timeout, now) < 0) {
905 remaining_jiffies = 0;
906 } else {
907 ktime_t rem = ktime_sub(*timeout, now);
908 struct timespec ts = ktime_to_timespec(rem);
909 remaining_jiffies = timespec_to_jiffies(&ts);
910 }
911
912 return remaining_jiffies;
913}
Rob Clarkc8afe682013-06-26 12:44:06 -0400914
915#endif /* __MSM_DRV_H__ */