1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved
4  */
5 
6 #ifndef _DPU_HW_WB_H
7 #define _DPU_HW_WB_H
8 
9 #include "dpu_hw_catalog.h"
10 #include "dpu_hw_mdss.h"
11 #include "dpu_hw_top.h"
12 #include "dpu_hw_util.h"
13 #include "dpu_hw_pingpong.h"
14 
15 struct dpu_hw_wb;
16 
17 struct dpu_hw_wb_cfg {
18 	struct dpu_hw_fmt_layout dest;
19 	enum dpu_intf_mode intf_mode;
20 	struct drm_rect roi;
21 	struct drm_rect crop;
22 };
23 
24 /**
25  *
26  * struct dpu_hw_wb_ops : Interface to the wb hw driver functions
27  *  Assumption is these functions will be called after clocks are enabled
28  *  @setup_outaddress: setup output address from the writeback job
29  *  @setup_outformat: setup output format of writeback block from writeback job
30  *  @setup_qos_lut:   setup qos LUT for writeback block based on input
31  *  @setup_cdp:       setup chroma down prefetch block for writeback block
32  *  @bind_pingpong_blk: enable/disable the connection with ping-pong block
33  */
34 struct dpu_hw_wb_ops {
35 	void (*setup_outaddress)(struct dpu_hw_wb *ctx,
36 			struct dpu_hw_wb_cfg *wb);
37 
38 	void (*setup_outformat)(struct dpu_hw_wb *ctx,
39 			struct dpu_hw_wb_cfg *wb);
40 
41 	void (*setup_roi)(struct dpu_hw_wb *ctx,
42 			struct dpu_hw_wb_cfg *wb);
43 
44 	void (*setup_qos_lut)(struct dpu_hw_wb *ctx,
45 			struct dpu_hw_qos_cfg *cfg);
46 
47 	void (*setup_cdp)(struct dpu_hw_wb *ctx,
48 			  const struct dpu_format *fmt,
49 			  bool enable);
50 
51 	void (*bind_pingpong_blk)(struct dpu_hw_wb *ctx,
52 				  const enum dpu_pingpong pp);
53 };
54 
55 /**
56  * struct dpu_hw_wb : WB driver object
57  * @hw: block hardware details
58  * @idx: hardware index number within type
59  * @wb_hw_caps: hardware capabilities
60  * @ops: function pointers
61  */
62 struct dpu_hw_wb {
63 	struct dpu_hw_blk_reg_map hw;
64 
65 	/* wb path */
66 	int idx;
67 	const struct dpu_wb_cfg *caps;
68 
69 	/* ops */
70 	struct dpu_hw_wb_ops ops;
71 };
72 
73 /**
74  * dpu_hw_wb_init() - Initializes the writeback hw driver object.
75  * @cfg:  wb_path catalog entry for which driver object is required
76  * @addr: mapped register io address of MDP
77  * Return: Error code or allocated dpu_hw_wb context
78  */
79 struct dpu_hw_wb *dpu_hw_wb_init(const struct dpu_wb_cfg *cfg,
80 		void __iomem *addr);
81 
82 /**
83  * dpu_hw_wb_destroy(): Destroy writeback hw driver object.
84  * @hw_wb:  Pointer to writeback hw driver object
85  */
86 void dpu_hw_wb_destroy(struct dpu_hw_wb *hw_wb);
87 
88 #endif /*_DPU_HW_WB_H */
89