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 #include "dpu_hw_blk.h"
9e47616dfSKalyan Thota 
10e47616dfSKalyan Thota struct dpu_hw_dspp;
11e47616dfSKalyan Thota 
12e47616dfSKalyan Thota /**
134259ff7aSKalyan Thota  * struct dpu_hw_pcc_coeff - PCC coefficient structure for each color
144259ff7aSKalyan Thota  *                            component.
154259ff7aSKalyan Thota  * @r: red coefficient.
164259ff7aSKalyan Thota  * @g: green coefficient.
174259ff7aSKalyan Thota  * @b: blue coefficient.
184259ff7aSKalyan Thota  */
194259ff7aSKalyan Thota 
204259ff7aSKalyan Thota struct dpu_hw_pcc_coeff {
214259ff7aSKalyan Thota 	__u32 r;
224259ff7aSKalyan Thota 	__u32 g;
234259ff7aSKalyan Thota 	__u32 b;
244259ff7aSKalyan Thota };
254259ff7aSKalyan Thota 
264259ff7aSKalyan Thota /**
274259ff7aSKalyan Thota  * struct dpu_hw_pcc - pcc feature structure
284259ff7aSKalyan Thota  * @r: red coefficients.
294259ff7aSKalyan Thota  * @g: green coefficients.
304259ff7aSKalyan Thota  * @b: blue coefficients.
314259ff7aSKalyan Thota  */
324259ff7aSKalyan Thota struct dpu_hw_pcc_cfg {
334259ff7aSKalyan Thota 	struct dpu_hw_pcc_coeff r;
344259ff7aSKalyan Thota 	struct dpu_hw_pcc_coeff g;
354259ff7aSKalyan Thota 	struct dpu_hw_pcc_coeff b;
364259ff7aSKalyan Thota };
374259ff7aSKalyan Thota 
384259ff7aSKalyan Thota /**
39e47616dfSKalyan Thota  * struct dpu_hw_dspp_ops - interface to the dspp hardware driver functions
40e47616dfSKalyan Thota  * Caller must call the init function to get the dspp context for each dspp
41e47616dfSKalyan Thota  * Assumption is these functions will be called after clocks are enabled
42e47616dfSKalyan Thota  */
43e47616dfSKalyan Thota struct dpu_hw_dspp_ops {
444259ff7aSKalyan Thota 	/**
454259ff7aSKalyan Thota 	 * setup_pcc - setup dspp pcc
464259ff7aSKalyan Thota 	 * @ctx: Pointer to dspp context
474259ff7aSKalyan Thota 	 * @cfg: Pointer to configuration
484259ff7aSKalyan Thota 	 */
494259ff7aSKalyan Thota 	void (*setup_pcc)(struct dpu_hw_dspp *ctx, struct dpu_hw_pcc_cfg *cfg);
50e47616dfSKalyan Thota 
51e47616dfSKalyan Thota };
52e47616dfSKalyan Thota 
53e47616dfSKalyan Thota /**
54e47616dfSKalyan Thota  * struct dpu_hw_dspp - dspp description
55e47616dfSKalyan Thota  * @base: Hardware block base structure
56e47616dfSKalyan Thota  * @hw: Block hardware details
57e47616dfSKalyan Thota  * @idx: DSPP index
58e47616dfSKalyan Thota  * @cap: Pointer to layer_cfg
59e47616dfSKalyan Thota  * @ops: Pointer to operations possible for this DSPP
60e47616dfSKalyan Thota  */
61e47616dfSKalyan Thota struct dpu_hw_dspp {
62e47616dfSKalyan Thota 	struct dpu_hw_blk base;
63e47616dfSKalyan Thota 	struct dpu_hw_blk_reg_map hw;
64e47616dfSKalyan Thota 
65e47616dfSKalyan Thota 	/* dspp */
66e47616dfSKalyan Thota 	int idx;
67e47616dfSKalyan Thota 	const struct dpu_dspp_cfg *cap;
68e47616dfSKalyan Thota 
69e47616dfSKalyan Thota 	/* Ops */
70e47616dfSKalyan Thota 	struct dpu_hw_dspp_ops ops;
71e47616dfSKalyan Thota };
72e47616dfSKalyan Thota 
73e47616dfSKalyan Thota /**
74e47616dfSKalyan Thota  * dpu_hw_dspp - convert base object dpu_hw_base to container
75e47616dfSKalyan Thota  * @hw: Pointer to base hardware block
76e47616dfSKalyan Thota  * return: Pointer to hardware block container
77e47616dfSKalyan Thota  */
78e47616dfSKalyan Thota static inline struct dpu_hw_dspp *to_dpu_hw_dspp(struct dpu_hw_blk *hw)
79e47616dfSKalyan Thota {
80e47616dfSKalyan Thota 	return container_of(hw, struct dpu_hw_dspp, base);
81e47616dfSKalyan Thota }
82e47616dfSKalyan Thota 
83e47616dfSKalyan Thota /**
84e47616dfSKalyan Thota  * dpu_hw_dspp_init - initializes the dspp hw driver object.
85e47616dfSKalyan Thota  * should be called once before accessing every dspp.
86e47616dfSKalyan Thota  * @idx:  DSPP index for which driver object is required
87e47616dfSKalyan Thota  * @addr: Mapped register io address of MDP
88e47616dfSKalyan Thota  * @Return: pointer to structure or ERR_PTR
89e47616dfSKalyan Thota  */
90e47616dfSKalyan Thota struct dpu_hw_dspp *dpu_hw_dspp_init(enum dpu_dspp idx,
91e47616dfSKalyan Thota 	void __iomem *addr, const struct dpu_mdss_cfg *m);
92e47616dfSKalyan Thota 
93e47616dfSKalyan Thota /**
94e47616dfSKalyan Thota  * dpu_hw_dspp_destroy(): Destroys DSPP driver context
95e47616dfSKalyan Thota  * @dspp: Pointer to DSPP driver context
96e47616dfSKalyan Thota  */
97e47616dfSKalyan Thota void dpu_hw_dspp_destroy(struct dpu_hw_dspp *dspp);
98e47616dfSKalyan Thota 
99e47616dfSKalyan Thota #endif /*_DPU_HW_DSPP_H */
100e47616dfSKalyan Thota 
101