Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2017, 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_HW_ROT_H |
| 14 | #define _SDE_HW_ROT_H |
| 15 | |
| 16 | #include "sde_hw_catalog.h" |
| 17 | #include "sde_hw_mdss.h" |
| 18 | #include "sde_hw_util.h" |
| 19 | #include "sde_hw_blk.h" |
| 20 | |
Alan Kwong | aa53e68 | 2017-07-31 18:21:15 -0400 | [diff] [blame] | 21 | #define SDE_HW_ROT_NAME_SIZE 80 |
| 22 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 23 | struct sde_hw_rot; |
| 24 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 25 | /** |
| 26 | * enum sde_hw_rot_cmd_type - type of rotator hardware command |
| 27 | * @SDE_HW_ROT_CMD_VALDIATE: validate rotator command; do not commit |
| 28 | * @SDE_HW_ROT_CMD_COMMIT: commit/execute rotator command |
Clarence Ip | ddbf775 | 2017-05-21 18:07:30 -0400 | [diff] [blame] | 29 | * @SDE_HW_ROT_CMD_START: mdp is ready to start |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 30 | * @SDE_HW_ROT_CMD_CLEANUP: cleanup rotator command after it is done |
| 31 | */ |
| 32 | enum sde_hw_rot_cmd_type { |
| 33 | SDE_HW_ROT_CMD_VALIDATE, |
| 34 | SDE_HW_ROT_CMD_COMMIT, |
Clarence Ip | ddbf775 | 2017-05-21 18:07:30 -0400 | [diff] [blame] | 35 | SDE_HW_ROT_CMD_START, |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 36 | SDE_HW_ROT_CMD_CLEANUP, |
| 37 | }; |
| 38 | |
| 39 | /** |
| 40 | * struct sde_hw_rot_cmd - definition of hardware rotation command |
| 41 | * @master: true if client is the master in source split inline rotation |
| 42 | * @sequence_id: command sequence identifier |
| 43 | * @fps: frame rate of the stream in frame per second |
| 44 | * @rot90: true if rotation 90 in counter clockwise is required |
| 45 | * @hflip: true if horizontal flip is required prior to rotation |
| 46 | * @vflip: true if vertical flip is required prior to rotation |
| 47 | * @secure: true if image content is in secure domain |
| 48 | * @video_mode: true if rotator is feeding into video interface |
| 49 | * @clkrate : clock rate in Hz |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 50 | * @prefill_bw: prefill bandwidth in Bps (video mode only) |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 51 | * @src_iova: source i/o virtual address |
| 52 | * @src_len: source i/o buffer length |
| 53 | * @src_planes: source plane number |
| 54 | * @src_format: pointer to source sde pixel format |
| 55 | * @src_pixel_format: source pixel format in drm fourcc |
| 56 | * @src_modifier: source pixel format modifier |
| 57 | * @src_width: source width in pixel |
| 58 | * @src_height: source height in pixel |
| 59 | * @src_rect_x: source rectangle x coordinate |
| 60 | * @src_rect_y: source rectangle y coordinate |
| 61 | * @src_rect_w: source rectangle width |
| 62 | * @src_rect_h: source rectangle height |
| 63 | * @dst_writeback: true if writeback of rotated output is required |
| 64 | * @dst_iova: destination i/o virtual address |
| 65 | * @dst_len: destination i/o buffer length |
| 66 | * @dst_planes: destination plane number |
| 67 | * @dst_format: pointer to destination sde pixel format (input/output) |
| 68 | * @dst_pixel_format: destination pixel format in drm fourcc (input/output) |
| 69 | * @dst_modifier: destination pixel format modifier (input/output) |
| 70 | * @dst_rect_x: destination rectangle x coordinate |
| 71 | * @dst_rect_y: destination rectangle y coordinate |
| 72 | * @dst_rect_w: destination rectangle width |
| 73 | * @dst_rect_h: destination rectangle height |
| 74 | * @priv_handle: private handle of rotator driver (output) |
| 75 | */ |
| 76 | struct sde_hw_rot_cmd { |
| 77 | bool master; |
| 78 | u32 sequence_id; |
| 79 | u32 fps; |
| 80 | bool rot90; |
| 81 | bool hflip; |
| 82 | bool vflip; |
| 83 | bool secure; |
| 84 | bool video_mode; |
| 85 | u64 clkrate; |
Alan Kwong | 4aacd53 | 2017-02-04 18:51:33 -0800 | [diff] [blame] | 86 | u64 prefill_bw; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 87 | dma_addr_t src_iova[4]; |
| 88 | u32 src_len[4]; |
| 89 | u32 src_planes; |
| 90 | const struct sde_format *src_format; |
| 91 | u32 src_pixel_format; |
| 92 | u64 src_modifier; |
| 93 | u32 src_width; |
| 94 | u32 src_height; |
| 95 | u32 src_stride; |
| 96 | u32 src_rect_x; |
| 97 | u32 src_rect_y; |
| 98 | u32 src_rect_w; |
| 99 | u32 src_rect_h; |
| 100 | bool dst_writeback; |
| 101 | dma_addr_t dst_iova[4]; |
| 102 | u32 dst_len[4]; |
| 103 | u32 dst_planes; |
| 104 | const struct sde_format *dst_format; |
| 105 | u32 dst_pixel_format; |
| 106 | u64 dst_modifier; |
| 107 | u32 dst_rect_x; |
| 108 | u32 dst_rect_y; |
| 109 | u32 dst_rect_w; |
| 110 | u32 dst_rect_h; |
| 111 | void *priv_handle; |
| 112 | }; |
| 113 | |
| 114 | /** |
| 115 | * struct sde_hw_rot_ops - interface to the rotator hw driver functions |
| 116 | * Assumption is these functions will be called after clocks are enabled |
| 117 | */ |
| 118 | struct sde_hw_rot_ops { |
| 119 | int (*commit)(struct sde_hw_rot *hw, struct sde_hw_rot_cmd *data, |
| 120 | enum sde_hw_rot_cmd_type cmd); |
| 121 | const struct sde_format_extended *(*get_format_caps)( |
| 122 | struct sde_hw_rot *hw); |
| 123 | const char *(*get_downscale_caps)(struct sde_hw_rot *hw); |
| 124 | size_t (*get_cache_size)(struct sde_hw_rot *hw); |
Alan Kwong | 1a91580 | 2017-03-31 12:55:46 -0700 | [diff] [blame] | 125 | int (*get_maxlinewidth)(struct sde_hw_rot *hw); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | /** |
| 129 | * struct sde_hw_rot : ROT driver object |
| 130 | * @base: hw block base object |
| 131 | * @hw: hardware address map |
| 132 | * @idx: instance index |
| 133 | * @caps: capabilities bitmask |
| 134 | * @ops: operation table |
| 135 | * @rot_ctx: pointer to private rotator context |
| 136 | * @format_caps: pointer to pixel format capability array |
| 137 | * @downscale_caps: pointer to scaling capability string |
| 138 | */ |
| 139 | struct sde_hw_rot { |
| 140 | struct sde_hw_blk base; |
| 141 | struct sde_hw_blk_reg_map hw; |
Alan Kwong | aa53e68 | 2017-07-31 18:21:15 -0400 | [diff] [blame] | 142 | char name[SDE_HW_ROT_NAME_SIZE]; |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 143 | int idx; |
| 144 | const struct sde_rot_cfg *caps; |
| 145 | struct sde_hw_rot_ops ops; |
| 146 | void *rot_ctx; |
| 147 | struct sde_format_extended *format_caps; |
| 148 | char *downscale_caps; |
| 149 | }; |
| 150 | |
| 151 | /** |
| 152 | * sde_hw_rot_init - initialize and return rotator hw driver object. |
| 153 | * @idx: wb_path index for which driver object is required |
| 154 | * @addr: mapped register io address of MDP |
| 155 | * @m : pointer to mdss catalog data |
| 156 | */ |
| 157 | struct sde_hw_rot *sde_hw_rot_init(enum sde_rot idx, |
| 158 | void __iomem *addr, |
| 159 | struct sde_mdss_cfg *m); |
| 160 | |
| 161 | /** |
| 162 | * sde_hw_rot_destroy - destroy rotator hw driver object. |
| 163 | * @hw_rot: Pointer to rotator hw driver object |
| 164 | */ |
| 165 | void sde_hw_rot_destroy(struct sde_hw_rot *hw_rot); |
| 166 | |
| 167 | /** |
| 168 | * to_sde_hw_rot - convert base object sde_hw_base to rotator object |
| 169 | * @hw: Pointer to base hardware block |
| 170 | * return: Pointer to rotator hardware block |
| 171 | */ |
| 172 | static inline struct sde_hw_rot *to_sde_hw_rot(struct sde_hw_blk *hw) |
| 173 | { |
| 174 | return container_of(hw, struct sde_hw_rot, base); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * sde_hw_rot_get - get next available hardware rotator, or increment reference |
| 179 | * count if hardware rotator provided |
| 180 | * @hw_rot: Pointer to hardware rotator |
| 181 | * return: Pointer to rotator hardware block if success; NULL otherwise |
| 182 | */ |
| 183 | struct sde_hw_rot *sde_hw_rot_get(struct sde_hw_rot *hw_rot); |
| 184 | |
| 185 | /** |
| 186 | * sde_hw_rot_put - put the given hardware rotator |
| 187 | * @hw_rot: Pointer to hardware rotator |
| 188 | * return: none |
| 189 | */ |
| 190 | void sde_hw_rot_put(struct sde_hw_rot *hw_rot); |
| 191 | |
| 192 | #endif /*_SDE_HW_ROT_H */ |