1e47616dfSKalyan Thota /* SPDX-License-Identifier: GPL-2.0-only */
2e47616dfSKalyan Thota /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
3e47616dfSKalyan Thota  */
4e47616dfSKalyan Thota 
5e47616dfSKalyan Thota #ifndef _DPU_HW_DSPP_H
6e47616dfSKalyan Thota #define _DPU_HW_DSPP_H
7e47616dfSKalyan Thota 
8e47616dfSKalyan Thota struct dpu_hw_dspp;
9e47616dfSKalyan Thota 
10e47616dfSKalyan Thota /**
114259ff7aSKalyan Thota  * struct dpu_hw_pcc_coeff - PCC coefficient structure for each color
124259ff7aSKalyan Thota  *                            component.
134259ff7aSKalyan Thota  * @r: red coefficient.
144259ff7aSKalyan Thota  * @g: green coefficient.
154259ff7aSKalyan Thota  * @b: blue coefficient.
164259ff7aSKalyan Thota  */
174259ff7aSKalyan Thota 
184259ff7aSKalyan Thota struct dpu_hw_pcc_coeff {
194259ff7aSKalyan Thota 	__u32 r;
204259ff7aSKalyan Thota 	__u32 g;
214259ff7aSKalyan Thota 	__u32 b;
224259ff7aSKalyan Thota };
234259ff7aSKalyan Thota 
244259ff7aSKalyan Thota /**
254259ff7aSKalyan Thota  * struct dpu_hw_pcc - pcc feature structure
264259ff7aSKalyan Thota  * @r: red coefficients.
274259ff7aSKalyan Thota  * @g: green coefficients.
284259ff7aSKalyan Thota  * @b: blue coefficients.
294259ff7aSKalyan Thota  */
304259ff7aSKalyan Thota struct dpu_hw_pcc_cfg {
314259ff7aSKalyan Thota 	struct dpu_hw_pcc_coeff r;
324259ff7aSKalyan Thota 	struct dpu_hw_pcc_coeff g;
334259ff7aSKalyan Thota 	struct dpu_hw_pcc_coeff b;
344259ff7aSKalyan Thota };
354259ff7aSKalyan Thota 
364259ff7aSKalyan Thota /**
37e47616dfSKalyan Thota  * struct dpu_hw_dspp_ops - interface to the dspp hardware driver functions
38e47616dfSKalyan Thota  * Caller must call the init function to get the dspp context for each dspp
39e47616dfSKalyan Thota  * Assumption is these functions will be called after clocks are enabled
40e47616dfSKalyan Thota  */
41e47616dfSKalyan Thota struct dpu_hw_dspp_ops {
424259ff7aSKalyan Thota 	/**
434259ff7aSKalyan Thota 	 * setup_pcc - setup dspp pcc
444259ff7aSKalyan Thota 	 * @ctx: Pointer to dspp context
454259ff7aSKalyan Thota 	 * @cfg: Pointer to configuration
464259ff7aSKalyan Thota 	 */
474259ff7aSKalyan Thota 	void (*setup_pcc)(struct dpu_hw_dspp *ctx, struct dpu_hw_pcc_cfg *cfg);
48e47616dfSKalyan Thota 
49e47616dfSKalyan Thota };
50e47616dfSKalyan Thota 
51e47616dfSKalyan Thota /**
52e47616dfSKalyan Thota  * struct dpu_hw_dspp - dspp description
53e47616dfSKalyan Thota  * @base: Hardware block base structure
54e47616dfSKalyan Thota  * @hw: Block hardware details
55e47616dfSKalyan Thota  * @idx: DSPP index
56e47616dfSKalyan Thota  * @cap: Pointer to layer_cfg
57e47616dfSKalyan Thota  * @ops: Pointer to operations possible for this DSPP
58e47616dfSKalyan Thota  */
59e47616dfSKalyan Thota struct dpu_hw_dspp {
60e47616dfSKalyan Thota 	struct dpu_hw_blk base;
61e47616dfSKalyan Thota 	struct dpu_hw_blk_reg_map hw;
62e47616dfSKalyan Thota 
63e47616dfSKalyan Thota 	/* dspp */
64e47616dfSKalyan Thota 	int idx;
65e47616dfSKalyan Thota 	const struct dpu_dspp_cfg *cap;
66e47616dfSKalyan Thota 
67e47616dfSKalyan Thota 	/* Ops */
68e47616dfSKalyan Thota 	struct dpu_hw_dspp_ops ops;
69e47616dfSKalyan Thota };
70e47616dfSKalyan Thota 
71e47616dfSKalyan Thota /**
72e47616dfSKalyan Thota  * dpu_hw_dspp - convert base object dpu_hw_base to container
73e47616dfSKalyan Thota  * @hw: Pointer to base hardware block
74e47616dfSKalyan Thota  * return: Pointer to hardware block container
75e47616dfSKalyan Thota  */
to_dpu_hw_dspp(struct dpu_hw_blk * hw)76e47616dfSKalyan Thota static inline struct dpu_hw_dspp *to_dpu_hw_dspp(struct dpu_hw_blk *hw)
77e47616dfSKalyan Thota {
78e47616dfSKalyan Thota 	return container_of(hw, struct dpu_hw_dspp, base);
79e47616dfSKalyan Thota }
80e47616dfSKalyan Thota 
81e47616dfSKalyan Thota /**
82*babdb815SMarijn Suijten  * dpu_hw_dspp_init() - Initializes the DSPP hw driver object.
83*babdb815SMarijn Suijten  * should be called once before accessing every DSPP.
84*babdb815SMarijn Suijten  * @cfg:  DSPP catalog entry for which driver object is required
85e47616dfSKalyan Thota  * @addr: Mapped register io address of MDP
86*babdb815SMarijn Suijten  * Return: pointer to structure or ERR_PTR
87e47616dfSKalyan Thota  */
88*babdb815SMarijn Suijten struct dpu_hw_dspp *dpu_hw_dspp_init(const struct dpu_dspp_cfg *cfg,
89*babdb815SMarijn Suijten 	void __iomem *addr);
90e47616dfSKalyan Thota 
91e47616dfSKalyan Thota /**
92e47616dfSKalyan Thota  * dpu_hw_dspp_destroy(): Destroys DSPP driver context
93e47616dfSKalyan Thota  * @dspp: Pointer to DSPP driver context
94e47616dfSKalyan Thota  */
95e47616dfSKalyan Thota void dpu_hw_dspp_destroy(struct dpu_hw_dspp *dspp);
96e47616dfSKalyan Thota 
97e47616dfSKalyan Thota #endif /*_DPU_HW_DSPP_H */
98e47616dfSKalyan Thota 
99