Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 1 | /* |
Dhaval Patel | 81e8788 | 2016-10-19 21:41:56 -0700 | [diff] [blame] | 2 | * Copyright (c) 2015-2017 The Linux Foundation. All rights reserved. |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef __SDE_ENCODER_PHYS_H__ |
| 16 | #define __SDE_ENCODER_PHYS_H__ |
| 17 | |
| 18 | #include "sde_kms.h" |
| 19 | #include "sde_hw_intf.h" |
Lloyd Atkinson | a59eead | 2016-05-30 14:37:06 -0400 | [diff] [blame] | 20 | #include "sde_hw_pingpong.h" |
Clarence Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 21 | #include "sde_hw_ctl.h" |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 22 | #include "sde_hw_top.h" |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 23 | #include "sde_hw_wb.h" |
| 24 | #include "sde_hw_cdm.h" |
Alan Kwong | 83285fb | 2016-10-21 20:51:17 -0400 | [diff] [blame] | 25 | #include "sde_encoder.h" |
| 26 | #include "sde_connector.h" |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 27 | |
| 28 | #define SDE_ENCODER_NAME_MAX 16 |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 29 | |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 30 | /** |
| 31 | * enum sde_enc_split_role - Role this physical encoder will play in a |
| 32 | * split-panel configuration, where one panel is master, and others slaves. |
| 33 | * Masters have extra responsibilities, like managing the VBLANK IRQ. |
| 34 | * @ENC_ROLE_SOLO: This is the one and only panel. This encoder is master. |
| 35 | * @ENC_ROLE_MASTER: This encoder is the master of a split panel config. |
| 36 | * @ENC_ROLE_SLAVE: This encoder is not the master of a split panel config. |
| 37 | */ |
| 38 | enum sde_enc_split_role { |
| 39 | ENC_ROLE_SOLO, |
| 40 | ENC_ROLE_MASTER, |
| 41 | ENC_ROLE_SLAVE |
| 42 | }; |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 43 | |
| 44 | struct sde_encoder_phys; |
| 45 | |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 46 | /** |
| 47 | * struct sde_encoder_virt_ops - Interface the containing virtual encoder |
| 48 | * provides for the physical encoders to use to callback. |
| 49 | * @handle_vblank_virt: Notify virtual encoder of vblank IRQ reception |
| 50 | * Note: This is called from IRQ handler context. |
Dhaval Patel | 81e8788 | 2016-10-19 21:41:56 -0700 | [diff] [blame] | 51 | * @handle_underrun_virt: Notify virtual encoder of underrun IRQ reception |
| 52 | * Note: This is called from IRQ handler context. |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 53 | * @handle_ready_for_kickoff: Notify virtual encoder that this phys encoder |
| 54 | * is now ready for the next kickoff. |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 55 | */ |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 56 | struct sde_encoder_virt_ops { |
Dhaval Patel | 81e8788 | 2016-10-19 21:41:56 -0700 | [diff] [blame] | 57 | void (*handle_vblank_virt)(struct drm_encoder *, |
| 58 | struct sde_encoder_phys *phys); |
| 59 | void (*handle_underrun_virt)(struct drm_encoder *, |
| 60 | struct sde_encoder_phys *phys); |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 61 | void (*handle_ready_for_kickoff)(struct drm_encoder *, |
| 62 | struct sde_encoder_phys *phys); |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 63 | }; |
| 64 | |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 65 | /** |
| 66 | * struct sde_encoder_phys_ops - Interface the physical encoders provide to |
| 67 | * the containing virtual encoder. |
| 68 | * @is_master: Whether this phys_enc is the current master |
| 69 | * encoder. Can be switched at enable time. Based |
| 70 | * on split_role and current mode (CMD/VID). |
| 71 | * @mode_fixup: DRM Call. Fixup a DRM mode. |
| 72 | * @mode_set: DRM Call. Set a DRM mode. |
| 73 | * This likely caches the mode, for use at enable. |
| 74 | * @enable: DRM Call. Enable a DRM mode. |
| 75 | * @disable: DRM Call. Disable mode. |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 76 | * @atomic_check: DRM Call. Atomic check new DRM state. |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 77 | * @destroy: DRM Call. Destroy and release resources. |
| 78 | * @get_hw_resources: Populate the structure with the hardware |
| 79 | * resources that this phys_enc is using. |
| 80 | * Expect no overlap between phys_encs. |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 81 | * @control_vblank_irq Register/Deregister for VBLANK IRQ |
| 82 | * @wait_for_commit_done: Wait for hardware to have flushed the |
| 83 | * current pending frames to hardware |
| 84 | * @prepare_for_kickoff: Do any work necessary prior to a kickoff |
| 85 | * and report whether need to wait before |
| 86 | * triggering the next kickoff |
| 87 | * (ie for previous tx to complete) |
| 88 | * @handle_post_kickoff: Do any work necessary post-kickoff work |
Clarence Ip | 110d15c | 2016-08-16 14:44:41 -0400 | [diff] [blame] | 89 | * @trigger_start: Process start event on physical encoder |
| 90 | * @needs_split_flush: Whether encoder type needs split flush |
Jayant Shekhar | 1d50ed2 | 2016-11-04 18:41:12 +0530 | [diff] [blame^] | 91 | * @setup_misr: Sets up MISR, enable and disables based on sysfs |
| 92 | * @collect_misr: Collects MISR data on frame update |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 93 | */ |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 94 | |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 95 | struct sde_encoder_phys_ops { |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 96 | bool (*is_master)(struct sde_encoder_phys *encoder); |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 97 | bool (*mode_fixup)(struct sde_encoder_phys *encoder, |
| 98 | const struct drm_display_mode *mode, |
| 99 | struct drm_display_mode *adjusted_mode); |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 100 | void (*mode_set)(struct sde_encoder_phys *encoder, |
| 101 | struct drm_display_mode *mode, |
| 102 | struct drm_display_mode *adjusted_mode); |
| 103 | void (*enable)(struct sde_encoder_phys *encoder); |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 104 | void (*disable)(struct sde_encoder_phys *encoder); |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 105 | int (*atomic_check)(struct sde_encoder_phys *encoder, |
| 106 | struct drm_crtc_state *crtc_state, |
| 107 | struct drm_connector_state *conn_state); |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 108 | void (*destroy)(struct sde_encoder_phys *encoder); |
| 109 | void (*get_hw_resources)(struct sde_encoder_phys *encoder, |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 110 | struct sde_encoder_hw_resources *hw_res, |
| 111 | struct drm_connector_state *conn_state); |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 112 | int (*control_vblank_irq)(struct sde_encoder_phys *enc, bool enable); |
| 113 | int (*wait_for_commit_done)(struct sde_encoder_phys *phys_enc); |
| 114 | void (*prepare_for_kickoff)(struct sde_encoder_phys *phys_enc, |
| 115 | bool *wait_until_ready); |
| 116 | void (*handle_post_kickoff)(struct sde_encoder_phys *phys_enc); |
Clarence Ip | 110d15c | 2016-08-16 14:44:41 -0400 | [diff] [blame] | 117 | void (*trigger_start)(struct sde_encoder_phys *phys_enc); |
| 118 | bool (*needs_split_flush)(struct sde_encoder_phys *phys_enc); |
Jayant Shekhar | 1d50ed2 | 2016-11-04 18:41:12 +0530 | [diff] [blame^] | 119 | |
| 120 | void (*setup_misr)(struct sde_encoder_phys *phys_encs, |
| 121 | struct sde_misr_params *misr_map); |
| 122 | void (*collect_misr)(struct sde_encoder_phys *phys_enc, |
| 123 | struct sde_misr_params *misr_map); |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | /** |
| 127 | * enum sde_enc_enable_state - current enabled state of the physical encoder |
| 128 | * @SDE_ENC_DISABLED: Encoder is disabled |
| 129 | * @SDE_ENC_ENABLING: Encoder transitioning to enabled |
| 130 | * Events bounding transition are encoder type specific |
| 131 | * @SDE_ENC_ENABLED: Encoder is enabled |
| 132 | */ |
| 133 | enum sde_enc_enable_state { |
| 134 | SDE_ENC_DISABLED, |
| 135 | SDE_ENC_ENABLING, |
| 136 | SDE_ENC_ENABLED |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 137 | }; |
| 138 | |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 139 | /** |
Dhaval Patel | 81e8788 | 2016-10-19 21:41:56 -0700 | [diff] [blame] | 140 | * enum sde_intr_idx - sde encoder interrupt index |
| 141 | * @INTR_IDX_VSYNC: Vsync interrupt for video mode panel |
| 142 | * @INTR_IDX_PINGPONG: Pingpong done unterrupt for cmd mode panel |
| 143 | * @INTR_IDX_UNDERRUN: Underrun unterrupt for video and cmd mode panel |
| 144 | * @INTR_IDX_RDPTR: Readpointer done unterrupt for cmd mode panel |
| 145 | */ |
| 146 | enum sde_intr_idx { |
| 147 | INTR_IDX_VSYNC, |
| 148 | INTR_IDX_PINGPONG, |
| 149 | INTR_IDX_UNDERRUN, |
| 150 | INTR_IDX_RDPTR, |
| 151 | INTR_IDX_MAX, |
| 152 | }; |
| 153 | |
| 154 | /** |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 155 | * struct sde_encoder_phys - physical encoder that drives a single INTF block |
| 156 | * tied to a specific panel / sub-panel. Abstract type, sub-classed by |
| 157 | * phys_vid or phys_cmd for video mode or command mode encs respectively. |
| 158 | * @parent: Pointer to the containing virtual encoder |
Lloyd Atkinson | 55987b0 | 2016-08-16 16:57:46 -0400 | [diff] [blame] | 159 | * @connector: If a mode is set, cached pointer to the active connector |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 160 | * @ops: Operations exposed to the virtual encoder |
| 161 | * @parent_ops: Callbacks exposed by the parent to the phys_enc |
| 162 | * @hw_mdptop: Hardware interface to the top registers |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 163 | * @hw_ctl: Hardware interface to the ctl registers |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 164 | * @hw_cdm: Hardware interface to the cdm registers |
| 165 | * @cdm_cfg: Chroma-down hardware configuration |
Jeykumar Sankaran | fdd77a9 | 2016-11-02 12:34:29 -0700 | [diff] [blame] | 166 | * @hw_pp: Hardware interface to the ping pong registers |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 167 | * @sde_kms: Pointer to the sde_kms top level |
| 168 | * @cached_mode: DRM mode cached at mode_set time, acted on in enable |
Jayant Shekhar | 1d50ed2 | 2016-11-04 18:41:12 +0530 | [diff] [blame^] | 169 | * @misr_map: Interface for setting and collecting MISR data |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 170 | * @enabled: Whether the encoder has enabled and running a mode |
| 171 | * @split_role: Role to play in a split-panel configuration |
Clarence Ip | 0352198 | 2016-08-26 10:49:47 -0400 | [diff] [blame] | 172 | * @intf_mode: Interface mode |
Dhaval Patel | 81e8788 | 2016-10-19 21:41:56 -0700 | [diff] [blame] | 173 | * @intf_idx: Interface index on sde hardware |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 174 | * @spin_lock: Lock for IRQ purposes |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 175 | * @enable_state: Enable state tracking |
Alan Kwong | baa5635 | 2016-10-04 09:38:11 -0400 | [diff] [blame] | 176 | * @vblank_refcount: Reference count of vblank request |
Dhaval Patel | 81e8788 | 2016-10-19 21:41:56 -0700 | [diff] [blame] | 177 | * @vsync_cnt: Vsync count for the physical encoder |
| 178 | * @underrun_cnt: Underrun count for the physical encoder |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 179 | */ |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 180 | struct sde_encoder_phys { |
| 181 | struct drm_encoder *parent; |
Lloyd Atkinson | 55987b0 | 2016-08-16 16:57:46 -0400 | [diff] [blame] | 182 | struct drm_connector *connector; |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 183 | struct sde_encoder_phys_ops ops; |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 184 | struct sde_encoder_virt_ops parent_ops; |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 185 | struct sde_hw_mdp *hw_mdptop; |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 186 | struct sde_hw_ctl *hw_ctl; |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 187 | struct sde_hw_cdm *hw_cdm; |
| 188 | struct sde_hw_cdm_cfg cdm_cfg; |
Jeykumar Sankaran | fdd77a9 | 2016-11-02 12:34:29 -0700 | [diff] [blame] | 189 | struct sde_hw_pingpong *hw_pp; |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 190 | struct sde_kms *sde_kms; |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 191 | struct drm_display_mode cached_mode; |
Jayant Shekhar | 1d50ed2 | 2016-11-04 18:41:12 +0530 | [diff] [blame^] | 192 | struct sde_misr_params *misr_map; |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 193 | enum sde_enc_split_role split_role; |
Clarence Ip | 0352198 | 2016-08-26 10:49:47 -0400 | [diff] [blame] | 194 | enum sde_intf_mode intf_mode; |
Dhaval Patel | 81e8788 | 2016-10-19 21:41:56 -0700 | [diff] [blame] | 195 | enum sde_intf intf_idx; |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 196 | spinlock_t spin_lock; |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 197 | enum sde_enc_enable_state enable_state; |
Alan Kwong | baa5635 | 2016-10-04 09:38:11 -0400 | [diff] [blame] | 198 | atomic_t vblank_refcount; |
Dhaval Patel | 81e8788 | 2016-10-19 21:41:56 -0700 | [diff] [blame] | 199 | atomic_t vsync_cnt; |
| 200 | atomic_t underrun_cnt; |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 201 | }; |
| 202 | |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 203 | /** |
| 204 | * struct sde_encoder_phys_vid - sub-class of sde_encoder_phys to handle video |
| 205 | * mode specific operations |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 206 | * @base: Baseclass physical encoder structure |
| 207 | * @irq_idx: IRQ interface lookup index |
Alan Kwong | a172ef5 | 2016-09-27 00:29:10 -0400 | [diff] [blame] | 208 | * @irq_cb: interrupt callback |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 209 | * @hw_intf: Hardware interface to the intf registers |
| 210 | * @vblank_completion: Completion event signaled on reception of the vsync irq |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 211 | */ |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 212 | struct sde_encoder_phys_vid { |
| 213 | struct sde_encoder_phys base; |
Dhaval Patel | 81e8788 | 2016-10-19 21:41:56 -0700 | [diff] [blame] | 214 | int irq_idx[INTR_IDX_MAX]; |
Alan Kwong | a172ef5 | 2016-09-27 00:29:10 -0400 | [diff] [blame] | 215 | struct sde_irq_callback irq_cb[INTR_IDX_MAX]; |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 216 | struct sde_hw_intf *hw_intf; |
| 217 | struct completion vblank_completion; |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 218 | }; |
| 219 | |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 220 | /** |
Lloyd Atkinson | a59eead | 2016-05-30 14:37:06 -0400 | [diff] [blame] | 221 | * struct sde_encoder_phys_cmd - sub-class of sde_encoder_phys to handle command |
| 222 | * mode specific operations |
| 223 | * @base: Baseclass physical encoder structure |
| 224 | * @intf_idx: Intf Block index used by this phys encoder |
| 225 | * @stream_sel: Stream selection for multi-stream interfaces |
Lloyd Atkinson | a59eead | 2016-05-30 14:37:06 -0400 | [diff] [blame] | 226 | * @pp_rd_ptr_irq_idx: IRQ signifying panel's frame read pointer |
| 227 | * For CMD encoders, VBLANK is driven by the PP RD Done IRQ |
| 228 | * @pp_tx_done_irq_idx: IRQ signifying frame transmission to panel complete |
Alan Kwong | a172ef5 | 2016-09-27 00:29:10 -0400 | [diff] [blame] | 229 | * @irq_cb: interrupt callback |
Lloyd Atkinson | a59eead | 2016-05-30 14:37:06 -0400 | [diff] [blame] | 230 | * @pp_tx_done_wq: Wait queue that tracks when a commit is flushed |
| 231 | * to hardware after the reception of pp_done |
| 232 | * Used to prevent back to back commits |
| 233 | * @pending_cnt: Atomic counter tracking the number of kickoffs vs. |
| 234 | * the number of pp_done irqs. Should hover between 0-2 |
| 235 | * Incremented when a new kickoff is scheduled |
| 236 | * Decremented in pp_done irq |
| 237 | */ |
| 238 | struct sde_encoder_phys_cmd { |
| 239 | struct sde_encoder_phys base; |
| 240 | int intf_idx; |
| 241 | int stream_sel; |
Dhaval Patel | 81e8788 | 2016-10-19 21:41:56 -0700 | [diff] [blame] | 242 | int irq_idx[INTR_IDX_MAX]; |
Alan Kwong | a172ef5 | 2016-09-27 00:29:10 -0400 | [diff] [blame] | 243 | struct sde_irq_callback irq_cb[INTR_IDX_MAX]; |
Lloyd Atkinson | a59eead | 2016-05-30 14:37:06 -0400 | [diff] [blame] | 244 | wait_queue_head_t pp_tx_done_wq; |
| 245 | atomic_t pending_cnt; |
| 246 | }; |
| 247 | |
| 248 | /** |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 249 | * struct sde_encoder_phys_wb - sub-class of sde_encoder_phys to handle |
| 250 | * writeback specific operations |
| 251 | * @base: Baseclass physical encoder structure |
| 252 | * @hw_wb: Hardware interface to the wb registers |
| 253 | * @irq_idx: IRQ interface lookup index |
| 254 | * @wbdone_timeout: Timeout value for writeback done in msec |
| 255 | * @bypass_irqreg: Bypass irq register/unregister if non-zero |
| 256 | * @wbdone_complete: for wbdone irq synchronization |
| 257 | * @wb_cfg: Writeback hardware configuration |
| 258 | * @intf_cfg: Interface hardware configuration |
| 259 | * @wb_roi: Writeback region-of-interest |
| 260 | * @wb_fmt: Writeback pixel format |
| 261 | * @frame_count: Counter of completed writeback operations |
| 262 | * @kickoff_count: Counter of issued writeback operations |
| 263 | * @mmu_id: mmu identifier for non-secure/secure domain |
| 264 | * @wb_dev: Pointer to writeback device |
| 265 | * @start_time: Start time of writeback latest request |
| 266 | * @end_time: End time of writeback latest request |
| 267 | * @wb_name: Name of this writeback device |
| 268 | * @debugfs_root: Root entry of writeback debugfs |
| 269 | */ |
| 270 | struct sde_encoder_phys_wb { |
| 271 | struct sde_encoder_phys base; |
| 272 | struct sde_hw_wb *hw_wb; |
| 273 | int irq_idx; |
Alan Kwong | a172ef5 | 2016-09-27 00:29:10 -0400 | [diff] [blame] | 274 | struct sde_irq_callback irq_cb; |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 275 | u32 wbdone_timeout; |
| 276 | u32 bypass_irqreg; |
| 277 | struct completion wbdone_complete; |
| 278 | struct sde_hw_wb_cfg wb_cfg; |
| 279 | struct sde_hw_intf_cfg intf_cfg; |
| 280 | struct sde_rect wb_roi; |
| 281 | const struct sde_format *wb_fmt; |
| 282 | u32 frame_count; |
| 283 | u32 kickoff_count; |
| 284 | int mmu_id[SDE_IOMMU_DOMAIN_MAX]; |
| 285 | struct sde_wb_device *wb_dev; |
| 286 | ktime_t start_time; |
| 287 | ktime_t end_time; |
| 288 | #ifdef CONFIG_DEBUG_FS |
| 289 | char wb_name[SDE_ENCODER_NAME_MAX]; |
| 290 | struct dentry *debugfs_root; |
| 291 | #endif |
| 292 | }; |
| 293 | |
| 294 | /** |
Lloyd Atkinson | 6ef6cb5 | 2016-07-06 11:49:18 -0400 | [diff] [blame] | 295 | * struct sde_enc_phys_init_params - initialization parameters for phys encs |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 296 | * @sde_kms: Pointer to the sde_kms top level |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 297 | * @parent: Pointer to the containing virtual encoder |
| 298 | * @parent_ops: Callbacks exposed by the parent to the phys_enc |
Lloyd Atkinson | 6ef6cb5 | 2016-07-06 11:49:18 -0400 | [diff] [blame] | 299 | * @split_role: Role to play in a split-panel configuration |
| 300 | * @intf_idx: Interface index this phys_enc will control |
| 301 | * @wb_idx: Writeback index this phys_enc will control |
Lloyd Atkinson | 6ef6cb5 | 2016-07-06 11:49:18 -0400 | [diff] [blame] | 302 | */ |
| 303 | struct sde_enc_phys_init_params { |
| 304 | struct sde_kms *sde_kms; |
| 305 | struct drm_encoder *parent; |
| 306 | struct sde_encoder_virt_ops parent_ops; |
| 307 | enum sde_enc_split_role split_role; |
| 308 | enum sde_intf intf_idx; |
| 309 | enum sde_wb wb_idx; |
Lloyd Atkinson | 6ef6cb5 | 2016-07-06 11:49:18 -0400 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | /** |
| 313 | * sde_encoder_phys_vid_init - Construct a new video mode physical encoder |
| 314 | * @p: Pointer to init params structure |
Lloyd Atkinson | e5c2c0b | 2016-07-05 12:23:29 -0400 | [diff] [blame] | 315 | * Return: Error code or newly allocated encoder |
| 316 | */ |
| 317 | struct sde_encoder_phys *sde_encoder_phys_vid_init( |
Lloyd Atkinson | 6ef6cb5 | 2016-07-06 11:49:18 -0400 | [diff] [blame] | 318 | struct sde_enc_phys_init_params *p); |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 319 | |
Lloyd Atkinson | a59eead | 2016-05-30 14:37:06 -0400 | [diff] [blame] | 320 | /** |
| 321 | * sde_encoder_phys_cmd_init - Construct a new command mode physical encoder |
Lloyd Atkinson | 6ef6cb5 | 2016-07-06 11:49:18 -0400 | [diff] [blame] | 322 | * @p: Pointer to init params structure |
Lloyd Atkinson | a59eead | 2016-05-30 14:37:06 -0400 | [diff] [blame] | 323 | * Return: Error code or newly allocated encoder |
| 324 | */ |
| 325 | struct sde_encoder_phys *sde_encoder_phys_cmd_init( |
Lloyd Atkinson | 6ef6cb5 | 2016-07-06 11:49:18 -0400 | [diff] [blame] | 326 | struct sde_enc_phys_init_params *p); |
Lloyd Atkinson | a59eead | 2016-05-30 14:37:06 -0400 | [diff] [blame] | 327 | |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 328 | /** |
| 329 | * sde_encoder_phys_wb_init - Construct a new writeback physical encoder |
Lloyd Atkinson | 6ef6cb5 | 2016-07-06 11:49:18 -0400 | [diff] [blame] | 330 | * @p: Pointer to init params structure |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 331 | * Return: Error code or newly allocated encoder |
| 332 | */ |
| 333 | #ifdef CONFIG_DRM_SDE_WB |
| 334 | struct sde_encoder_phys *sde_encoder_phys_wb_init( |
Lloyd Atkinson | 6ef6cb5 | 2016-07-06 11:49:18 -0400 | [diff] [blame] | 335 | struct sde_enc_phys_init_params *p); |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 336 | #else |
| 337 | static inline |
| 338 | struct sde_encoder_phys *sde_encoder_phys_wb_init( |
Lloyd Atkinson | 6ef6cb5 | 2016-07-06 11:49:18 -0400 | [diff] [blame] | 339 | struct sde_enc_phys_init_params *p) |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 340 | { |
| 341 | return NULL; |
| 342 | } |
| 343 | #endif |
Lloyd Atkinson | a59eead | 2016-05-30 14:37:06 -0400 | [diff] [blame] | 344 | |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 345 | void sde_encoder_phys_setup_cdm(struct sde_encoder_phys *phys_enc, |
| 346 | struct drm_framebuffer *fb, const struct sde_format *format, |
| 347 | struct sde_rect *wb_roi); |
Lloyd Atkinson | a59eead | 2016-05-30 14:37:06 -0400 | [diff] [blame] | 348 | |
Clarence Ip | 110d15c | 2016-08-16 14:44:41 -0400 | [diff] [blame] | 349 | /** |
| 350 | * sde_encoder_helper_trigger_start - control start helper function |
| 351 | * This helper function may be optionally specified by physical |
| 352 | * encoders if they require ctl_start triggering. |
| 353 | * @phys_enc: Pointer to physical encoder structure |
| 354 | */ |
| 355 | void sde_encoder_helper_trigger_start(struct sde_encoder_phys *phys_enc); |
| 356 | |
Lloyd Atkinson | 55987b0 | 2016-08-16 16:57:46 -0400 | [diff] [blame] | 357 | |
| 358 | static inline enum sde_3d_blend_mode sde_encoder_helper_get_3d_blend_mode( |
| 359 | struct sde_encoder_phys *phys_enc) |
| 360 | { |
| 361 | enum sde_rm_topology_name topology; |
| 362 | |
| 363 | topology = sde_connector_get_topology_name(phys_enc->connector); |
| 364 | if (phys_enc->split_role == ENC_ROLE_SOLO && |
| 365 | topology == SDE_RM_TOPOLOGY_DUALPIPEMERGE) |
| 366 | return BLEND_3D_H_ROW_INT; |
| 367 | |
| 368 | return BLEND_3D_NONE; |
| 369 | } |
| 370 | |
Lloyd Atkinson | 09fed91 | 2016-06-24 18:14:13 -0400 | [diff] [blame] | 371 | #endif /* __sde_encoder_phys_H__ */ |