Merge tag 'pull-work.unaligned' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / drivers / gpu / drm / msm / disp / dpu1 / dpu_hw_pingpong.h
CommitLineData
97fb5e8d 1/* SPDX-License-Identifier: GPL-2.0-only */
25fdd593 2/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
25fdd593
JS
3 */
4
5#ifndef _DPU_HW_PINGPONG_H
6#define _DPU_HW_PINGPONG_H
7
8#include "dpu_hw_catalog.h"
9#include "dpu_hw_mdss.h"
10#include "dpu_hw_util.h"
25fdd593 11
3c128638
KT
12#define DITHER_MATRIX_SZ 16
13
25fdd593
JS
14struct dpu_hw_pingpong;
15
3c128638
KT
16/**
17 * struct dpu_hw_dither_cfg - dither feature structure
18 * @flags: for customizing operations
19 * @temporal_en: temperal dither enable
20 * @c0_bitdepth: c0 component bit depth
21 * @c1_bitdepth: c1 component bit depth
22 * @c2_bitdepth: c2 component bit depth
23 * @c3_bitdepth: c2 component bit depth
24 * @matrix: dither strength matrix
25 */
26struct dpu_hw_dither_cfg {
27 u64 flags;
28 u32 temporal_en;
29 u32 c0_bitdepth;
30 u32 c1_bitdepth;
31 u32 c2_bitdepth;
32 u32 c3_bitdepth;
33 u32 matrix[DITHER_MATRIX_SZ];
34};
35
25fdd593
JS
36/**
37 *
38 * struct dpu_hw_pingpong_ops : Interface to the pingpong Hw driver functions
39 * Assumption is these functions will be called after clocks are enabled
bb9f1880
MS
40 * @enable_tearcheck: program and enable tear check block
41 * @disable_tearcheck: disable able tear check block
25fdd593
JS
42 * @setup_dither : function to program the dither hw block
43 * @get_line_count: obtain current vertical line counter
44 */
45struct dpu_hw_pingpong_ops {
46 /**
47 * enables vysnc generation and sets up init value of
48 * read pointer and programs the tear check cofiguration
49 */
bb9f1880 50 int (*enable_tearcheck)(struct dpu_hw_pingpong *pp,
25fdd593
JS
51 struct dpu_hw_tear_check *cfg);
52
53 /**
bb9f1880 54 * disables tear check block
25fdd593 55 */
bb9f1880 56 int (*disable_tearcheck)(struct dpu_hw_pingpong *pp);
25fdd593
JS
57
58 /**
59 * read, modify, write to either set or clear listening to external TE
60 * @Return: 1 if TE was originally connected, 0 if not, or -ERROR
61 */
62 int (*connect_external_te)(struct dpu_hw_pingpong *pp,
63 bool enable_external_te);
64
65 /**
4a7c38ec 66 * Obtain current vertical line counter
aa9223a6 67 */
4a7c38ec 68 u32 (*get_line_count)(struct dpu_hw_pingpong *pp);
aa9223a6 69
25fdd593 70 /**
4a7c38ec 71 * Disable autorefresh if enabled
25fdd593 72 */
4a7c38ec 73 void (*disable_autorefresh)(struct dpu_hw_pingpong *pp, uint32_t encoder_id, u16 vdisplay);
3c128638
KT
74
75 /**
76 * Setup dither matix for pingpong block
77 */
78 void (*setup_dither)(struct dpu_hw_pingpong *pp,
79 struct dpu_hw_dither_cfg *cfg);
893d6982
VK
80 /**
81 * Enable DSC
82 */
83 int (*enable_dsc)(struct dpu_hw_pingpong *pp);
84
85 /**
86 * Disable DSC
87 */
88 void (*disable_dsc)(struct dpu_hw_pingpong *pp);
89
90 /**
91 * Setup DSC
92 */
93 int (*setup_dsc)(struct dpu_hw_pingpong *pp);
25fdd593
JS
94};
95
dfa35bac
DB
96struct dpu_hw_merge_3d;
97
25fdd593
JS
98struct dpu_hw_pingpong {
99 struct dpu_hw_blk base;
100 struct dpu_hw_blk_reg_map hw;
101
102 /* pingpong */
103 enum dpu_pingpong idx;
104 const struct dpu_pingpong_cfg *caps;
dfa35bac 105 struct dpu_hw_merge_3d *merge_3d;
25fdd593
JS
106
107 /* ops */
108 struct dpu_hw_pingpong_ops ops;
109};
110
b954fa6b
DD
111/**
112 * to_dpu_hw_pingpong - convert base object dpu_hw_base to container
113 * @hw: Pointer to base hardware block
114 * return: Pointer to hardware block container
115 */
116static inline struct dpu_hw_pingpong *to_dpu_hw_pingpong(struct dpu_hw_blk *hw)
117{
118 return container_of(hw, struct dpu_hw_pingpong, base);
119}
120
25fdd593 121/**
babdb815
MS
122 * dpu_hw_pingpong_init() - initializes the pingpong driver for the passed
123 * pingpong catalog entry.
a106ed98 124 * @dev: Corresponding device for devres management
babdb815 125 * @cfg: Pingpong catalog entry for which driver object is required
25fdd593 126 * @addr: Mapped register io address of MDP
48d67e42 127 * @mdss_rev: dpu core's major and minor versions
babdb815 128 * Return: Error code or allocated dpu_hw_pingpong context
25fdd593 129 */
a106ed98
DB
130struct dpu_hw_pingpong *dpu_hw_pingpong_init(struct drm_device *dev,
131 const struct dpu_pingpong_cfg *cfg,
132 void __iomem *addr,
133 const struct dpu_mdss_version *mdss_rev);
25fdd593
JS
134
135#endif /*_DPU_HW_PINGPONG_H */