Jeykumar Sankaran | 5c2f070 | 2017-03-09 18:03:15 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 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_PINGPONG_H |
| 14 | #define _SDE_HW_PINGPONG_H |
| 15 | |
| 16 | struct sde_hw_pingpong; |
| 17 | |
| 18 | struct sde_hw_tear_check { |
| 19 | /* |
| 20 | * This is ratio of MDP VSYNC clk freq(Hz) to |
| 21 | * refresh rate divided by no of lines |
| 22 | */ |
| 23 | u32 vsync_count; |
| 24 | u32 sync_cfg_height; |
| 25 | u32 vsync_init_val; |
| 26 | u32 sync_threshold_start; |
| 27 | u32 sync_threshold_continue; |
| 28 | u32 start_pos; |
| 29 | u32 rd_ptr_irq; |
| 30 | u8 hw_vsync_mode; |
| 31 | }; |
| 32 | |
| 33 | struct sde_hw_autorefresh { |
| 34 | bool enable; |
| 35 | u32 frame_count; |
| 36 | }; |
| 37 | |
| 38 | struct sde_hw_pp_vsync_info { |
| 39 | u32 init_val; /* value of rd pointer at vsync edge */ |
| 40 | u32 vsync_count; /* mdp clocks to complete one line */ |
| 41 | u32 line_count; /* current line count */ |
| 42 | }; |
| 43 | |
| 44 | struct sde_hw_dsc_cfg { |
| 45 | u8 enable; |
| 46 | }; |
| 47 | |
| 48 | /** |
| 49 | * |
| 50 | * struct sde_hw_pingpong_ops : Interface to the pingpong Hw driver functions |
| 51 | * Assumption is these functions will be called after clocks are enabled |
Jeykumar Sankaran | 5c2f070 | 2017-03-09 18:03:15 -0800 | [diff] [blame] | 52 | * @setup_tearcheck : program tear check values |
| 53 | * @enable_tearcheck : enables tear check |
| 54 | * @get_vsync_info : retries timing info of the panel |
| 55 | * @setup_autorefresh : program auto refresh |
| 56 | * @setup_dsc : program DSC block with encoding details |
| 57 | * @enable_dsc : enables DSC encoder |
| 58 | * @disable_dsc : disables DSC encoder |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 59 | */ |
| 60 | struct sde_hw_pingpong_ops { |
| 61 | /** |
| 62 | * enables vysnc generation and sets up init value of |
| 63 | * read pointer and programs the tear check cofiguration |
| 64 | */ |
| 65 | int (*setup_tearcheck)(struct sde_hw_pingpong *pp, |
| 66 | struct sde_hw_tear_check *cfg); |
| 67 | |
| 68 | /** |
| 69 | * enables tear check block |
| 70 | */ |
| 71 | int (*enable_tearcheck)(struct sde_hw_pingpong *pp, |
| 72 | bool enable); |
| 73 | |
| 74 | /** |
| 75 | * provides the programmed and current |
| 76 | * line_count |
| 77 | */ |
| 78 | int (*get_vsync_info)(struct sde_hw_pingpong *pp, |
| 79 | struct sde_hw_pp_vsync_info *info); |
| 80 | |
| 81 | /** |
| 82 | * configure and enable the autorefresh config |
| 83 | */ |
| 84 | int (*setup_autorefresh)(struct sde_hw_pingpong *pp, |
| 85 | struct sde_hw_autorefresh *cfg); |
| 86 | |
| 87 | /** |
| 88 | * Program the dsc compression block |
| 89 | */ |
Jeykumar Sankaran | 5c2f070 | 2017-03-09 18:03:15 -0800 | [diff] [blame] | 90 | int (*setup_dsc)(struct sde_hw_pingpong *pp); |
| 91 | |
| 92 | /** |
| 93 | * Enables DSC encoder |
| 94 | */ |
| 95 | void (*enable_dsc)(struct sde_hw_pingpong *pp); |
| 96 | |
| 97 | /** |
| 98 | * Disables DSC encoder |
| 99 | */ |
| 100 | void (*disable_dsc)(struct sde_hw_pingpong *pp); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | struct sde_hw_pingpong { |
| 104 | /* base */ |
| 105 | struct sde_hw_blk_reg_map hw; |
| 106 | |
| 107 | /* pingpong */ |
| 108 | enum sde_pingpong idx; |
| 109 | const struct sde_pingpong_cfg *pingpong_hw_cap; |
| 110 | |
| 111 | /* ops */ |
| 112 | struct sde_hw_pingpong_ops ops; |
| 113 | }; |
| 114 | |
| 115 | /** |
Lloyd Atkinson | 3127a09 | 2016-05-30 13:46:55 -0400 | [diff] [blame] | 116 | * sde_hw_pingpong_init - initializes the pingpong driver for the passed |
| 117 | * pingpong idx. |
| 118 | * @idx: Pingpong index for which driver object is required |
| 119 | * @addr: Mapped register io address of MDP |
| 120 | * @m: Pointer to mdss catalog data |
| 121 | * Returns: Error code or allocated sde_hw_pingpong context |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 122 | */ |
| 123 | struct sde_hw_pingpong *sde_hw_pingpong_init(enum sde_pingpong idx, |
| 124 | void __iomem *addr, |
| 125 | struct sde_mdss_cfg *m); |
| 126 | |
Lloyd Atkinson | 3127a09 | 2016-05-30 13:46:55 -0400 | [diff] [blame] | 127 | /** |
| 128 | * sde_hw_pingpong_destroy - destroys pingpong driver context |
| 129 | * should be called to free the context |
| 130 | * @pp: Pointer to PP driver context returned by sde_hw_pingpong_init |
| 131 | */ |
| 132 | void sde_hw_pingpong_destroy(struct sde_hw_pingpong *pp); |
| 133 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 134 | #endif /*_SDE_HW_PINGPONG_H */ |