blob: ace05e86470e6ac597823f586ce4a615b14c8091 [file] [log] [blame]
Jeykumar Sankaran2e655032017-02-04 14:05:45 -08001/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Narendra Muppalla1b0b3352015-09-29 10:16:51 -07002 *
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
Clarence Ipc475b082016-06-26 09:27:23 -040013#ifndef _SDE_HW_CTL_H
14#define _SDE_HW_CTL_H
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070015
16#include "sde_hw_mdss.h"
Clarence Ipc475b082016-06-26 09:27:23 -040017#include "sde_hw_util.h"
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070018#include "sde_hw_catalog.h"
Jeykumar Sankaran2e655032017-02-04 14:05:45 -080019#include "sde_hw_sspp.h"
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070020
Lloyd Atkinson5d722782016-05-30 14:09:41 -040021/**
22 * sde_ctl_mode_sel: Interface mode selection
23 * SDE_CTL_MODE_SEL_VID: Video mode interface
24 * SDE_CTL_MODE_SEL_CMD: Command mode interface
25 */
26enum sde_ctl_mode_sel {
27 SDE_CTL_MODE_SEL_VID = 0,
28 SDE_CTL_MODE_SEL_CMD
29};
30
Alan Kwong4dd64c82017-02-04 18:41:51 -080031/**
32 * sde_ctl_rot_op_mode - inline rotation mode
33 * SDE_CTL_ROT_OP_MODE_OFFLINE: offline rotation
34 * SDE_CTL_ROT_OP_MODE_RESERVED: reserved
35 * SDE_CTL_ROT_OP_MODE_INLINE_SYNC: inline rotation synchronous mode
36 * SDE_CTL_ROT_OP_MODE_INLINE_ASYNC: inline rotation asynchronous mode
37 */
38enum sde_ctl_rot_op_mode {
39 SDE_CTL_ROT_OP_MODE_OFFLINE,
40 SDE_CTL_ROT_OP_MODE_RESERVED,
41 SDE_CTL_ROT_OP_MODE_INLINE_SYNC,
42 SDE_CTL_ROT_OP_MODE_INLINE_ASYNC,
43};
44
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070045struct sde_hw_ctl;
46/**
47 * struct sde_hw_stage_cfg - blending stage cfg
Jeykumar Sankaran2e655032017-02-04 14:05:45 -080048 * @stage : SSPP_ID at each stage
49 * @multirect_index: index of the rectangle of SSPP.
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070050 */
51struct sde_hw_stage_cfg {
Dhaval Patel48c76022016-09-01 17:51:23 -070052 enum sde_sspp stage[CRTC_DUAL_MIXERS][SDE_STAGE_MAX][PIPES_PER_STAGE];
Jeykumar Sankaran2e655032017-02-04 14:05:45 -080053 enum sde_sspp_multirect_index multirect_index[CRTC_DUAL_MIXERS]
54 [SDE_STAGE_MAX][PIPES_PER_STAGE];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070055};
56
57/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -040058 * struct sde_hw_intf_cfg :Describes how the SDE writes data to output interface
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040059 * @intf : Interface id
Lloyd Atkinson5d722782016-05-30 14:09:41 -040060 * @wb: Writeback id
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040061 * @mode_3d: 3d mux configuration
Lloyd Atkinson5d722782016-05-30 14:09:41 -040062 * @intf_mode_sel: Interface mode, cmd / vid
63 * @stream_sel: Stream selection for multi-stream interfaces
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040064 */
65struct sde_hw_intf_cfg {
66 enum sde_intf intf;
67 enum sde_wb wb;
68 enum sde_3d_blend_mode mode_3d;
Lloyd Atkinson5d722782016-05-30 14:09:41 -040069 enum sde_ctl_mode_sel intf_mode_sel;
70 int stream_sel;
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040071};
72
73/**
Alan Kwong4dd64c82017-02-04 18:41:51 -080074 * struct sde_ctl_sbuf_cfg - control for stream buffer configuration
75 * @rot_op_mode: rotator operation mode
76 */
77struct sde_ctl_sbuf_cfg {
78 enum sde_ctl_rot_op_mode rot_op_mode;
79};
80
81/**
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070082 * struct sde_hw_ctl_ops - Interface to the wb Hw driver functions
83 * Assumption is these functions will be called after clocks are enabled
84 */
85struct sde_hw_ctl_ops {
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040086 /**
87 * kickoff hw operation for Sw controlled interfaces
88 * DSI cmd mode and WB interface are SW controlled
89 * @ctx : ctl path ctx pointer
90 */
Lloyd Atkinson5d722782016-05-30 14:09:41 -040091 void (*trigger_start)(struct sde_hw_ctl *ctx);
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040092
93 /**
Dhaval Patel0e558f42017-04-30 00:51:40 -070094 * kickoff prepare is in progress hw operation for sw
95 * controlled interfaces: DSI cmd mode and WB interface
96 * are SW controlled
97 * @ctx : ctl path ctx pointer
98 */
99 void (*trigger_pending)(struct sde_hw_ctl *ctx);
100
101 /**
Alan Kwong4dd64c82017-02-04 18:41:51 -0800102 * kickoff rotator operation for Sw controlled interfaces
103 * DSI cmd mode and WB interface are SW controlled
104 * @ctx : ctl path ctx pointer
105 */
106 void (*trigger_rot_start)(struct sde_hw_ctl *ctx);
107
108 /**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400109 * Clear the value of the cached pending_flush_mask
110 * No effect on hardware
111 * @ctx : ctl path ctx pointer
112 */
113 void (*clear_pending_flush)(struct sde_hw_ctl *ctx);
114
115 /**
Clarence Ip110d15c2016-08-16 14:44:41 -0400116 * Query the value of the cached pending_flush_mask
117 * No effect on hardware
118 * @ctx : ctl path ctx pointer
119 */
120 u32 (*get_pending_flush)(struct sde_hw_ctl *ctx);
121
122 /**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400123 * OR in the given flushbits to the cached pending_flush_mask
124 * No effect on hardware
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400125 * @ctx : ctl path ctx pointer
126 * @flushbits : module flushmask
127 */
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400128 void (*update_pending_flush)(struct sde_hw_ctl *ctx,
129 u32 flushbits);
130
131 /**
132 * Write the value of the pending_flush_mask to hardware
133 * @ctx : ctl path ctx pointer
134 */
135 void (*trigger_flush)(struct sde_hw_ctl *ctx);
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400136
137 /**
Lloyd Atkinson6340a372017-04-05 13:04:22 -0700138 * Read the value of the flush register
139 * @ctx : ctl path ctx pointer
140 * @Return: value of the ctl flush register.
141 */
142 u32 (*get_flush_register)(struct sde_hw_ctl *ctx);
143
144 /**
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400145 * Setup ctl_path interface config
146 * @ctx
147 * @cfg : interface config structure pointer
148 */
149 void (*setup_intf_cfg)(struct sde_hw_ctl *ctx,
150 struct sde_hw_intf_cfg *cfg);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700151
152 int (*reset)(struct sde_hw_ctl *c);
153
Lloyd Atkinson6cc9de32016-11-17 17:56:13 -0500154 /*
155 * wait_reset_status - checks ctl reset status
156 * @ctx : ctl path ctx pointer
157 *
158 * This function checks the ctl reset status bit.
159 * If the reset bit is set, it keeps polling the status till the hw
160 * reset is complete.
161 * Returns: 0 on success or -error if reset incomplete within interval
162 */
163 int (*wait_reset_status)(struct sde_hw_ctl *ctx);
164
Dhaval Patel48c76022016-09-01 17:51:23 -0700165 uint32_t (*get_bitmask_sspp)(struct sde_hw_ctl *ctx,
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700166 enum sde_sspp blk);
167
Dhaval Patel48c76022016-09-01 17:51:23 -0700168 uint32_t (*get_bitmask_mixer)(struct sde_hw_ctl *ctx,
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700169 enum sde_lm blk);
170
171 int (*get_bitmask_dspp)(struct sde_hw_ctl *ctx,
172 u32 *flushbits,
173 enum sde_dspp blk);
174
175 int (*get_bitmask_intf)(struct sde_hw_ctl *ctx,
176 u32 *flushbits,
177 enum sde_intf blk);
178
179 int (*get_bitmask_cdm)(struct sde_hw_ctl *ctx,
180 u32 *flushbits,
181 enum sde_cdm blk);
182
Alan Kwong3232ca52016-07-29 02:27:47 -0400183 int (*get_bitmask_wb)(struct sde_hw_ctl *ctx,
184 u32 *flushbits,
185 enum sde_wb blk);
186
Alan Kwong4dd64c82017-02-04 18:41:51 -0800187 int (*get_bitmask_rot)(struct sde_hw_ctl *ctx,
188 u32 *flushbits,
189 enum sde_rot blk);
190
Lloyd Atkinsone5ec30d2016-08-23 14:32:32 -0400191 /**
192 * Set all blend stages to disabled
193 * @ctx : ctl path ctx pointer
194 */
195 void (*clear_all_blendstages)(struct sde_hw_ctl *ctx);
196
197 /**
198 * Configure layer mixer to pipe configuration
199 * @ctx : ctl path ctx pointer
200 * @lm : layer mixer enumeration
201 * @cfg : blend stage configuration
202 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700203 void (*setup_blendstage)(struct sde_hw_ctl *ctx,
Dhaval Patel44f12472016-08-29 12:19:47 -0700204 enum sde_lm lm, struct sde_hw_stage_cfg *cfg, u32 index);
Alan Kwong4dd64c82017-02-04 18:41:51 -0800205
206 void (*setup_sbuf_cfg)(struct sde_hw_ctl *ctx,
207 struct sde_ctl_sbuf_cfg *cfg);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700208};
209
210/**
211 * struct sde_hw_ctl : CTL PATH driver object
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400212 * @hw: block register map object
213 * @idx: control path index
214 * @ctl_hw_caps: control path capabilities
215 * @mixer_count: number of mixers
216 * @mixer_hw_caps: mixer hardware capabilities
217 * @pending_flush_mask: storage for pending ctl_flush managed via ops
218 * @ops: operation list
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700219 */
220struct sde_hw_ctl {
221 /* base */
222 struct sde_hw_blk_reg_map hw;
223
224 /* ctl path */
225 int idx;
226 const struct sde_ctl_cfg *caps;
227 int mixer_count;
228 const struct sde_lm_cfg *mixer_hw_caps;
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400229 u32 pending_flush_mask;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700230
231 /* ops */
232 struct sde_hw_ctl_ops ops;
233};
234
235/**
236 * sde_hw_ctl_init(): Initializes the ctl_path hw driver object.
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400237 * should be called before accessing every ctl path registers.
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700238 * @idx: ctl_path index for which driver object is required
239 * @addr: mapped register io address of MDP
240 * @m : pointer to mdss catalog data
241 */
242struct sde_hw_ctl *sde_hw_ctl_init(enum sde_ctl idx,
243 void __iomem *addr,
244 struct sde_mdss_cfg *m);
245
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400246/**
247 * sde_hw_ctl_destroy(): Destroys ctl driver context
248 * should be called to free the context
249 */
250void sde_hw_ctl_destroy(struct sde_hw_ctl *ctx);
251
Clarence Ipc475b082016-06-26 09:27:23 -0400252#endif /*_SDE_HW_CTL_H */