Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 1 | /* 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_ROTATOR_R1_INTERNAL_H__ |
| 14 | #define __SDE_ROTATOR_R1_INTERNAL_H__ |
| 15 | |
| 16 | #include <linux/types.h> |
| 17 | #include <linux/file.h> |
| 18 | #include <linux/kref.h> |
| 19 | #include <linux/kernel.h> |
| 20 | |
| 21 | #include "sde_rotator_util.h" |
| 22 | |
| 23 | /** |
| 24 | * enum sde_commit_stage_type - Indicate different commit stages |
| 25 | */ |
| 26 | enum sde_commit_stage_type { |
| 27 | SDE_COMMIT_STAGE_SETUP_DONE, |
| 28 | SDE_COMMIT_STAGE_READY_FOR_KICKOFF, |
| 29 | }; |
| 30 | |
| 31 | enum sde_mdp_wb_ctl_type { |
| 32 | SDE_MDP_WB_CTL_TYPE_BLOCK = 1, |
| 33 | SDE_MDP_WB_CTL_TYPE_LINE |
| 34 | }; |
| 35 | |
| 36 | enum sde_mdp_mixer_mux { |
| 37 | SDE_MDP_MIXER_MUX_DEFAULT, |
| 38 | SDE_MDP_MIXER_MUX_LEFT, |
| 39 | SDE_MDP_MIXER_MUX_RIGHT, |
| 40 | }; |
| 41 | |
| 42 | enum sde_mdp_pipe_type { |
| 43 | SDE_MDP_PIPE_TYPE_UNUSED, |
| 44 | SDE_MDP_PIPE_TYPE_VIG, |
| 45 | SDE_MDP_PIPE_TYPE_RGB, |
| 46 | SDE_MDP_PIPE_TYPE_DMA, |
| 47 | SDE_MDP_PIPE_TYPE_CURSOR, |
| 48 | }; |
| 49 | |
| 50 | struct sde_mdp_data; |
| 51 | struct sde_mdp_ctl; |
| 52 | struct sde_mdp_pipe; |
| 53 | struct sde_mdp_mixer; |
| 54 | struct sde_mdp_wb; |
| 55 | |
| 56 | struct sde_mdp_writeback { |
| 57 | u32 num; |
| 58 | char __iomem *base; |
| 59 | u32 offset; |
| 60 | }; |
| 61 | |
| 62 | struct sde_mdp_ctl_intfs_ops { |
| 63 | int (*start_fnc)(struct sde_mdp_ctl *ctl); |
| 64 | int (*stop_fnc)(struct sde_mdp_ctl *ctl, int panel_power_state); |
| 65 | int (*prepare_fnc)(struct sde_mdp_ctl *ctl, void *arg); |
| 66 | int (*display_fnc)(struct sde_mdp_ctl *ctl, void *arg); |
| 67 | int (*wait_fnc)(struct sde_mdp_ctl *ctl, void *arg); |
| 68 | }; |
| 69 | |
| 70 | struct sde_mdp_ctl { |
| 71 | u32 num; |
| 72 | char __iomem *base; |
| 73 | u32 opmode; |
| 74 | u32 flush_bits; |
| 75 | u32 flush_reg_data; |
| 76 | bool is_secure; |
| 77 | struct sde_rot_data_type *mdata; |
| 78 | struct sde_mdp_mixer *mixer_left; |
| 79 | struct sde_mdp_mixer *mixer_right; |
| 80 | void *priv_data; |
| 81 | u32 wb_type; |
| 82 | struct sde_mdp_writeback *wb; |
| 83 | struct sde_mdp_ctl_intfs_ops ops; |
| 84 | u32 offset; |
| 85 | int irq_num; |
| 86 | }; |
| 87 | |
| 88 | struct sde_mdp_mixer { |
| 89 | u32 num; |
| 90 | char __iomem *base; |
| 91 | u8 rotator_mode; |
| 92 | struct sde_mdp_ctl *ctl; |
| 93 | u32 offset; |
| 94 | }; |
| 95 | |
| 96 | struct sde_mdp_shared_reg_ctrl { |
| 97 | u32 reg_off; |
| 98 | u32 bit_off; |
| 99 | }; |
| 100 | |
| 101 | struct sde_mdp_pipe { |
| 102 | u32 num; |
| 103 | u32 type; |
| 104 | u32 ndx; |
| 105 | char __iomem *base; |
| 106 | u32 xin_id; |
| 107 | u32 flags; |
| 108 | u32 bwc_mode; |
| 109 | u16 img_width; |
| 110 | u16 img_height; |
| 111 | u8 horz_deci; |
| 112 | u8 vert_deci; |
| 113 | struct sde_rect src; |
| 114 | struct sde_rect dst; |
| 115 | struct sde_mdp_format_params *src_fmt; |
| 116 | struct sde_mdp_plane_sizes src_planes; |
| 117 | struct sde_mdp_mixer *mixer_left; |
| 118 | struct sde_mdp_mixer *mixer_right; |
Alan Kwong | effb5ee | 2016-03-12 19:47:45 -0500 | [diff] [blame] | 119 | struct sde_mdp_shared_reg_ctrl clk_ctrl; |
Adrian Salido-Moreno | 5c15038 | 2016-04-06 09:29:37 -0700 | [diff] [blame] | 120 | u32 params_changed; |
| 121 | u32 offset; |
| 122 | }; |
| 123 | |
| 124 | struct sde_mdp_writeback_arg { |
| 125 | struct sde_mdp_data *data; |
| 126 | void *priv_data; |
| 127 | }; |
| 128 | |
| 129 | struct sde_mdp_commit_cb { |
| 130 | void *data; |
| 131 | int (*commit_cb_fnc)(enum sde_commit_stage_type commit_state, |
| 132 | void *data); |
| 133 | }; |
| 134 | |
| 135 | static inline void sde_mdp_ctl_write(struct sde_mdp_ctl *ctl, |
| 136 | u32 reg, u32 val) |
| 137 | { |
| 138 | SDEROT_DBG("ctl%d:%6.6x:%8.8x\n", ctl->num, ctl->offset + reg, val); |
| 139 | writel_relaxed(val, ctl->base + reg); |
| 140 | } |
| 141 | |
| 142 | static inline bool sde_mdp_is_nrt_vbif_client(struct sde_rot_data_type *mdata, |
| 143 | struct sde_mdp_pipe *pipe) |
| 144 | { |
| 145 | return mdata->vbif_nrt_io.base && pipe->mixer_left && |
| 146 | pipe->mixer_left->rotator_mode; |
| 147 | } |
| 148 | int sde_mdp_set_intr_callback(u32 intr_type, u32 intf_num, |
| 149 | void (*fnc_ptr)(void *), void *arg); |
| 150 | int sde_mdp_display_wait4comp(struct sde_mdp_ctl *ctl); |
| 151 | int sde_mdp_writeback_display_commit(struct sde_mdp_ctl *ctl, void *arg); |
| 152 | int sde_mdp_pipe_queue_data(struct sde_mdp_pipe *pipe, |
| 153 | struct sde_mdp_data *src_data); |
| 154 | struct sde_mdp_ctl *sde_mdp_ctl_alloc(struct sde_rot_data_type *mdata, |
| 155 | u32 off); |
| 156 | struct sde_mdp_writeback *sde_mdp_wb_assign(u32 num, u32 reg_index); |
| 157 | void sde_mdp_wb_free(struct sde_mdp_writeback *wb); |
| 158 | struct sde_mdp_mixer *sde_mdp_mixer_assign(u32 id, bool wb); |
| 159 | int sde_mdp_writeback_start(struct sde_mdp_ctl *ctl); |
| 160 | struct sde_mdp_pipe *sde_mdp_pipe_assign(struct sde_rot_data_type *mdata, |
| 161 | struct sde_mdp_mixer *mixer, u32 ndx); |
| 162 | int sde_mdp_pipe_destroy(struct sde_mdp_pipe *pipe); |
| 163 | int sde_mdp_ctl_free(struct sde_mdp_ctl *ctl); |
| 164 | int sde_mdp_display_commit(struct sde_mdp_ctl *ctl, void *arg, |
| 165 | struct sde_mdp_commit_cb *commit_cb); |
| 166 | int sde_mdp_mixer_pipe_update(struct sde_mdp_pipe *pipe, |
| 167 | struct sde_mdp_mixer *mixer, int params_changed); |
| 168 | int sde_mdp_get_pipe_flush_bits(struct sde_mdp_pipe *pipe); |
| 169 | struct sde_mdp_ctl *sde_mdp_ctl_mixer_switch(struct sde_mdp_ctl *ctl, |
| 170 | u32 return_type); |
| 171 | struct sde_mdp_mixer *sde_mdp_mixer_get(struct sde_mdp_ctl *ctl, int mux); |
| 172 | #endif /* __SDE_ROTATOR_R1_INTERNAL_H__ */ |